Skip to content

Commit

Permalink
Fix globe anchor stack overflow.
Browse files Browse the repository at this point in the history
  • Loading branch information
kring committed Aug 8, 2023
1 parent 5922166 commit 314f9d5
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions Source/CesiumRuntime/Private/CesiumGlobeAnchorComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,11 @@ void UCesiumGlobeAnchorComponent::SetAdjustOrientationForGlobeWhenMoving(

void UCesiumGlobeAnchorComponent::MoveToEarthCenteredEarthFixedPosition(
const FVector& TargetEcef) {
this->ECEF_X = TargetEcef.X;
this->ECEF_Y = TargetEcef.Y;
this->ECEF_Z = TargetEcef.Z;
this->_applyCartesianProperties();
if (!this->_actorToECEFIsValid)
this->_setNewActorToECEFFromRelativeTransform();
FMatrix newMatrix = this->_actorToECEF;
newMatrix.SetOrigin(TargetEcef);
this->_setNewActorToECEFMatrix(newMatrix);
}

void UCesiumGlobeAnchorComponent::SnapLocalUpToEllipsoidNormal() {
Expand Down Expand Up @@ -546,6 +547,21 @@ void UCesiumGlobeAnchorComponent::_updateFromNativeGlobeAnchor(
VecMath::createMatrix(nativeAnchor.getAnchorToFixedTransform());
this->_actorToECEFIsValid = true;

// Update the editable position properties
// TODO: it'd be nice if we didn't have to store these at all. But then we'd
// need a custom UI to make them directly editable, I think.
FVector origin = this->_actorToECEF.GetOrigin();
this->ECEF_X = origin.X;
this->ECEF_Y = origin.Y;
this->ECEF_Z = origin.Z;

FVector llh =
UCesiumWgs84Ellipsoid::EarthCenteredEarthFixedToLongitudeLatitudeHeight(
origin);
this->Longitude = llh.X;
this->Latitude = llh.Y;
this->Height = llh.Z;

// Update the Unreal relative transform
ACesiumGeoreference* pGeoreference = this->ResolvedGeoreference;
assert(pGeoreference != nullptr);
Expand Down

0 comments on commit 314f9d5

Please sign in to comment.