Skip to content

Commit 5d357f5

Browse files
committed
AdvViz: add GetVertexPositionScaleFactor to UCesiumLoadedTile to make sense of glTF vertices
1 parent 40676e5 commit 5d357f5

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

Source/CesiumRuntime/Private/CesiumGltfComponent.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1558,6 +1558,8 @@ static void loadPrimitive(
15581558
positionBuffer.Init(numVertices, false);
15591559

15601560
{
1561+
// Note: scaling from glTF vertices to Unreal's must match
1562+
// UCesiumGltfComponent::GetGltfToUnrealLocalVertexPositionScaleFactor
15611563
if (duplicateVertices) {
15621564
TRACE_CPUPROFILER_EVENT_SCOPE(Cesium::CopyDuplicatedPositions)
15631565
for (uint32 i = 0; i < numVertices; ++i) {
@@ -3601,6 +3603,15 @@ const Cesium3DTilesSelection::TileID& UCesiumGltfComponent::GetTileID() const {
36013603
return pTile->getTileID();
36023604
}
36033605

3606+
FVector
3607+
UCesiumGltfComponent::GetGltfToUnrealLocalVertexPositionScaleFactor() const {
3608+
// Note: replicates logic from (static) loadPrimitive
3609+
return FVector(
3610+
CesiumPrimitiveData::positionScaleFactor,
3611+
-CesiumPrimitiveData::positionScaleFactor,
3612+
CesiumPrimitiveData::positionScaleFactor);
3613+
}
3614+
36043615
void UCesiumGltfComponent::SetRenderReady(bool bToggle) {
36053616
if (pTile) {
36063617
pTile->setRenderEngineReadiness(bToggle);

Source/CesiumRuntime/Private/CesiumGltfComponent.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ class UCesiumGltfComponent : public USceneComponent, public ICesiumLoadedTile {
140140
// from ICesiumLoadedTile
141141
const FCesiumModelMetadata& GetModelMetadata() const override;
142142
const Cesium3DTilesSelection::TileID& GetTileID() const override;
143+
FVector GetGltfToUnrealLocalVertexPositionScaleFactor() const override;
143144
void SetRenderReady(bool bToggle) override;
144145

145146
void UpdateFade(float fadePercentage, bool fadingIn);

Source/CesiumRuntime/Public/CesiumLoadedTile.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "CesiumPrimitiveFeatures.h"
88
#include "CesiumPrimitiveMetadata.h"
99

10+
#include "Math/Vector.h"
1011
#include "UObject/ObjectMacros.h"
1112

1213
#include "CesiumLoadedTile.generated.h"
@@ -23,6 +24,11 @@ class ICesiumLoadedTile {
2324
/** Get the tile identifier: this is informational only, as there is no
2425
* guarantee of unicity */
2526
virtual const Cesium3DTilesSelection::TileID& GetTileID() const = 0;
27+
/** Scaling factor to be applied (component-wise multiplication) to glTF
28+
* vertices of this tile's models to obtain the values represented in their
29+
* matching mesh component (see @{link
30+
* UCesiumLoadedTilePrimitive::GetMeshComponent). */
31+
virtual FVector GetGltfToUnrealLocalVertexPositionScaleFactor() const = 0;
2632
virtual const FCesiumModelMetadata& GetModelMetadata() const = 0;
2733
virtual void SetRenderReady(bool bToggle) = 0;
2834
};

0 commit comments

Comments
 (0)