-
Notifications
You must be signed in to change notification settings - Fork 297
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1229 from CesiumGS/more-tweaks
Usability improvements for CesiumGeoreference parentage
- Loading branch information
Showing
17 changed files
with
340 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
Source/CesiumEditor/Private/CesiumEditorReparentHandler.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright 2020-2023 CesiumGS, Inc. and Contributors | ||
|
||
#include "CesiumEditorReparentHandler.h" | ||
#include "Cesium3DTileset.h" | ||
#include "CesiumGlobeAnchorComponent.h" | ||
#include "CesiumSubLevelComponent.h" | ||
#include "Engine/Engine.h" | ||
|
||
CesiumEditorReparentHandler::CesiumEditorReparentHandler() { | ||
if (GEngine) { | ||
this->_subscription = GEngine->OnLevelActorAttached().AddRaw( | ||
this, | ||
&CesiumEditorReparentHandler::OnLevelActorAttached); | ||
} | ||
} | ||
|
||
CesiumEditorReparentHandler::~CesiumEditorReparentHandler() { | ||
if (GEngine) { | ||
GEngine->OnLevelActorAttached().Remove(this->_subscription); | ||
this->_subscription.Reset(); | ||
} | ||
} | ||
|
||
void CesiumEditorReparentHandler::OnLevelActorAttached( | ||
AActor* Actor, | ||
const AActor* Parent) { | ||
ACesium3DTileset* Tileset = Cast<ACesium3DTileset>(Actor); | ||
if (IsValid(Tileset)) { | ||
Tileset->InvalidateResolvedGeoreference(); | ||
} | ||
|
||
UCesiumGlobeAnchorComponent* GlobeAnchor = | ||
Actor->FindComponentByClass<UCesiumGlobeAnchorComponent>(); | ||
if (IsValid(GlobeAnchor)) { | ||
GlobeAnchor->ResolveGeoreference(true); | ||
} | ||
|
||
UCesiumSubLevelComponent* SubLevel = | ||
Actor->FindComponentByClass<UCesiumSubLevelComponent>(); | ||
if (IsValid(SubLevel)) { | ||
SubLevel->ResolveGeoreference(true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright 2020-2023 CesiumGS, Inc. and Contributors | ||
|
||
#pragma once | ||
|
||
#include "Delegates/IDelegateInstance.h" | ||
|
||
class AActor; | ||
|
||
/** | ||
* Detects when Actors are reparented in the Editor by subscribing to | ||
* GEngine::OnLevelActorAttached and handling it appropriately. For example, | ||
* when a Cesium3DTileset's parent changes, we need to re-resolve its | ||
* CesiumGeoreference. | ||
*/ | ||
class CesiumEditorReparentHandler { | ||
public: | ||
CesiumEditorReparentHandler(); | ||
~CesiumEditorReparentHandler(); | ||
|
||
private: | ||
void OnLevelActorAttached(AActor* Actor, const AActor* Parent); | ||
|
||
FDelegateHandle _subscription; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.