Skip to content

Commit

Permalink
Add flag validate functions and hook into post load
Browse files Browse the repository at this point in the history
  • Loading branch information
csciguy8 committed Sep 14, 2023
1 parent fddb214 commit 6020a67
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Source/CesiumRuntime/Private/Cesium3DTileset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "Cesium3DTilesSelection/TilesetOptions.h"
#include "Cesium3DTilesetLoadFailureDetails.h"
#include "Cesium3DTilesetRoot.h"
#include "CesiumActors.h"
#include "CesiumAsync/IAssetResponse.h"
#include "CesiumBoundingVolumeComponent.h"
#include "CesiumCamera.h"
Expand Down Expand Up @@ -2087,6 +2088,8 @@ void ACesium3DTileset::PostLoad() {
// actor to have correct BodyInstance values.

Super::PostLoad();

CesiumActors::validateActorFlags(this);
}

void ACesium3DTileset::Serialize(FArchive& Ar) {
Expand Down
32 changes: 32 additions & 0 deletions Source/CesiumRuntime/Private/CesiumActors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,35 @@ glm::dvec4 CesiumActors::getWorldOrigin4D(const AActor* actor) {
const FIntVector& originLocation = world->OriginLocation;
return glm::dvec4(originLocation.X, originLocation.Y, originLocation.Z, 1.0);
}

void CesiumActors::validatePublicFlag(UObject* object, const FString& label) {
//
// From an Epic Engine Developer...
// RF_Public means that the object is an asset, so it should be only set for
// worlds, textures, meshes, etc. This flags essentially says it's ok to
// have a reference to public objects from other packages (with the
// exception of worlds). Actors are not assets since they are part of a
// level which is part of a world, etc. that's why they should not key the
// public flag.
//
// In earlier versions of cesium-unreal, this flag may have been set
//
if (object->HasAnyFlags(RF_Public)) {
UE_LOG(
LogCesium,
Display,
TEXT("Clearing invalid RF_Public flag on %s"),
*label);
object->ClearFlags(RF_Public);
}
}

void CesiumActors::validateActorFlags(AActor* actor) {
FString label = FString("actor: ") + *actor->GetName();
validatePublicFlag(actor, label);
}

void CesiumActors::validateActorComponentFlags(UActorComponent* component) {
FString label = FString("actor component: ") + *component->GetName();
validatePublicFlag(component, label);
}
6 changes: 6 additions & 0 deletions Source/CesiumRuntime/Private/CesiumActors.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,10 @@ class CesiumActors {
* @return The world origin
*/
static glm::dvec4 getWorldOrigin4D(const AActor* actor);

static void validateActorFlags(AActor* actor);
static void validateActorComponentFlags(UActorComponent* component);

private:
static void validatePublicFlag(UObject* object, const FString& label);
};
7 changes: 7 additions & 0 deletions Source/CesiumRuntime/Private/CesiumCartographicPolygon.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright 2020-2021 CesiumGS, Inc. and Contributors

#include "CesiumCartographicPolygon.h"
#include "CesiumActors.h"
#include "CesiumUtility/Math.h"
#include "Components/SceneComponent.h"
#include "StaticMeshResources.h"
Expand Down Expand Up @@ -79,3 +80,9 @@ void ACesiumCartographicPolygon::MakeLinear() {
this->Polygon->SetSplinePointType(i, ESplinePointType::Linear);
}
}

void ACesiumCartographicPolygon::PostLoad() {
Super::PostLoad();

CesiumActors::validateActorFlags(this);
}
7 changes: 7 additions & 0 deletions Source/CesiumRuntime/Private/CesiumIonRasterOverlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "CesiumIonRasterOverlay.h"
#include "Cesium3DTilesSelection/IonRasterOverlay.h"
#include "Cesium3DTilesSelection/Tileset.h"
#include "CesiumActors.h"
#include "CesiumRuntime.h"
#include "CesiumRuntimeSettings.h"

Expand Down Expand Up @@ -36,3 +37,9 @@ UCesiumIonRasterOverlay::CreateOverlay(
TCHAR_TO_UTF8(*token),
options);
}

void UCesiumIonRasterOverlay::PostLoad() {
Super::PostLoad();

CesiumActors::validateActorComponentFlags(this);
}
3 changes: 3 additions & 0 deletions Source/CesiumRuntime/Public/CesiumCartographicPolygon.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ class CESIUMRUNTIME_API ACesiumCartographicPolygon : public AActor {
CesiumGeospatial::CartographicPolygon
CreateCartographicPolygon(const FTransform& worldToTileset) const;

// AActor overrides
virtual void PostLoad() override;

protected:
virtual void BeginPlay() override;

Expand Down
3 changes: 3 additions & 0 deletions Source/CesiumRuntime/Public/CesiumIonRasterOverlay.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ class CESIUMRUNTIME_API UCesiumIonRasterOverlay : public UCesiumRasterOverlay {
UFUNCTION(CallInEditor, Category = "Cesium")
void TroubleshootToken();

// UActorComponent overrides
virtual void PostLoad() override;

protected:
virtual std::unique_ptr<Cesium3DTilesSelection::RasterOverlay> CreateOverlay(
const Cesium3DTilesSelection::RasterOverlayOptions& options = {})
Expand Down

0 comments on commit 6020a67

Please sign in to comment.