Skip to content

Commit 0ad7a8e

Browse files
authored
Merge pull request #1680 from CesiumGS/null-georeference-checks
Fix crash that results from duplicating a georeference
2 parents 2877700 + f0cb7f3 commit 0ad7a8e

File tree

3 files changed

+22
-16
lines changed

3 files changed

+22
-16
lines changed

CHANGES.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010

1111
- Worked around an Unreal Engine limitation that prevented collisions and line traces from working correctly for tilesets with a very small scale factor.
1212
- Add a missing include for `GEngine` when packaging from source, introduced in *v2.16.0*.
13-
- Fixed a bug in UCesiumFeaturesMetadataComponent where multiple references to same feature ID set would cause improper encoding of its feature IDs.
13+
- Fixed a bug in `UCesiumFeaturesMetadataComponent` where multiple references to same feature ID set would cause improper encoding of its feature IDs.
14+
- Fixed a crash that would occur when duplicating an `ACesiumGeoreference`.
1415
- Removed an unnecessary copy operation that happened while constructing tile meshes.
1516

1617
### v2.16.0 - 2025-05-01

Source/CesiumRuntime/Private/Cesium3DTileset.cpp

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -232,17 +232,20 @@ ACesiumGeoreference* ACesium3DTileset::ResolveGeoreference() {
232232
ACesiumGeoreference::GetDefaultGeoreferenceForActor(this);
233233
}
234234

235-
UCesium3DTilesetRoot* pRoot = Cast<UCesium3DTilesetRoot>(this->RootComponent);
236-
if (pRoot) {
237-
this->ResolvedGeoreference->OnGeoreferenceUpdated.AddUniqueDynamic(
238-
pRoot,
239-
&UCesium3DTilesetRoot::HandleGeoreferenceUpdated);
240-
this->ResolvedGeoreference->OnEllipsoidChanged.AddUniqueDynamic(
241-
this,
242-
&ACesium3DTileset::HandleOnGeoreferenceEllipsoidChanged);
243-
244-
// Update existing tile positions, if any.
245-
pRoot->HandleGeoreferenceUpdated();
235+
if (this->ResolvedGeoreference) {
236+
UCesium3DTilesetRoot* pRoot =
237+
Cast<UCesium3DTilesetRoot>(this->RootComponent);
238+
if (pRoot) {
239+
this->ResolvedGeoreference->OnGeoreferenceUpdated.AddUniqueDynamic(
240+
pRoot,
241+
&UCesium3DTilesetRoot::HandleGeoreferenceUpdated);
242+
this->ResolvedGeoreference->OnEllipsoidChanged.AddUniqueDynamic(
243+
this,
244+
&ACesium3DTileset::HandleOnGeoreferenceEllipsoidChanged);
245+
246+
// Update existing tile positions, if any.
247+
pRoot->HandleGeoreferenceUpdated();
248+
}
246249
}
247250

248251
return this->ResolvedGeoreference;

Source/CesiumRuntime/Private/Cesium3DTilesetRoot.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,12 @@ void UCesium3DTilesetRoot::_updateAbsoluteLocation() {
6262

6363
void UCesium3DTilesetRoot::_updateTilesetToUnrealRelativeWorldTransform() {
6464
ACesium3DTileset* pTileset = this->GetOwner<ACesium3DTileset>();
65+
ACesiumGeoreference* pGeoreference = pTileset->ResolveGeoreference();
6566

66-
this->_tilesetToUnrealRelativeWorld = VecMath::createMatrix4D(
67-
pTileset->ResolveGeoreference()
68-
->ComputeEarthCenteredEarthFixedToUnrealTransformation());
67+
if (pGeoreference) {
68+
this->_tilesetToUnrealRelativeWorld = VecMath::createMatrix4D(
69+
pGeoreference->ComputeEarthCenteredEarthFixedToUnrealTransformation());
6970

70-
pTileset->UpdateTransformFromCesium();
71+
pTileset->UpdateTransformFromCesium();
72+
}
7173
}

0 commit comments

Comments
 (0)