Skip to content

Commit 998e0bd

Browse files
committed
Moved CreateModelOptions into tilesetOptions.rendererOptions
1 parent 667432b commit 998e0bd

3 files changed

Lines changed: 11 additions & 16 deletions

File tree

Editor/Cesium3DTilesetEditor.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ private void OnEnable()
8484
// this.serializedObject.FindProperty("_lodTransitionLength");
8585
this._generateSmoothNormals =
8686
this.serializedObject.FindProperty("_generateSmoothNormals");
87-
this._ignoreKhrMaterialsUnlit = this.serializedObject.FindProperty("_ignoreKHRMaterialsUnlit");
87+
this._ignoreKhrMaterialsUnlit = this.serializedObject.FindProperty("_ignoreKhrMaterialsUnlit");
8888

8989
this._pointCloudShading = this.serializedObject.FindProperty("_pointCloudShading");
9090

@@ -428,7 +428,7 @@ private void DrawRenderProperties()
428428
"rendered with smooth normals instead when the original glTF is missing normals.");
429429
EditorGUILayout.PropertyField(this._generateSmoothNormals, generateSmoothNormalsContent);
430430

431-
var ignoreKHRMaterialsUnlit = new GUIContent(
431+
var ignoreKhrMaterialsUnlit = new GUIContent(
432432
"Ignore KHR_materials_unlit",
433433
"Whether to ignore the KHR_materials_unlit extension on the glTF tiles in "+
434434
"this tileset, if it exists, and instead render with standard lighting and "+
@@ -439,7 +439,7 @@ private void DrawRenderProperties()
439439
"tilesets because lighting and shadows are already baked into their "+
440440
"textures. "
441441
);
442-
EditorGUILayout.PropertyField(this._ignoreKhrMaterialsUnlit, ignoreKHRMaterialsUnlit);
442+
EditorGUILayout.PropertyField(this._ignoreKhrMaterialsUnlit, ignoreKhrMaterialsUnlit);
443443
}
444444

445445
private void DrawPointCloudShadingProperties()

native~/Runtime/src/Cesium3DTilesetImpl.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,7 @@ void Cesium3DTilesetImpl::DestroyTileset(
566566
void Cesium3DTilesetImpl::LoadTileset(
567567
const DotNet::CesiumForUnity::Cesium3DTileset& tileset) {
568568
TilesetOptions options{};
569+
options.rendererOptions = CreateModelOptions(tileset);
569570
options.maximumScreenSpaceError = tileset.maximumScreenSpaceError();
570571
options.preloadAncestors = tileset.preloadAncestors();
571572
options.preloadSiblings = tileset.preloadSiblings();

native~/Runtime/src/UnityPrepareRendererResources.cpp

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -907,31 +907,25 @@ UnityPrepareRendererResources::prepareInLoadThread(
907907
TileLoadResult tileLoadResult;
908908
};
909909

910-
CreateModelOptions options{};
911-
912910
return asyncSystem
913-
.runInMainThread([numberOfPrimitives,
914-
tileset = this->_tilesetGameObject,
915-
&options]() {
916-
const auto tilesetComponent =
917-
tileset.GetComponent<DotNet::CesiumForUnity::Cesium3DTileset>();
918-
if (tilesetComponent != nullptr)
919-
options.ignoreKhrMaterialUnlit =
920-
tilesetComponent.ignoreKhrMaterialsUnlit();
911+
.runInMainThread([numberOfPrimitives]() {
921912
// Allocate a MeshDataArray for the primitives.
922913
// Unfortunately, this must be done on the main thread.
923914
return UnityEngine::Mesh::AllocateWritableMeshData(numberOfPrimitives);
924915
})
925916
.thenInWorkerThread(
926-
[tileLoadResult = std::move(tileLoadResult),
927-
&options](UnityEngine::MeshDataArray&& meshDataArray) mutable {
917+
[tileLoadResult = std::move(tileLoadResult), rendererOptions](UnityEngine::MeshDataArray&& meshDataArray) mutable {
928918
MeshDataResult meshDataResult{std::move(meshDataArray), {}};
929919
// Free the MeshDataArray if something goes wrong.
930920
ScopeGuard sg([&meshDataResult]() {
931921
meshDataResult.meshDataArray.Dispose();
932922
});
933923

934-
populateMeshDataArray(meshDataResult, tileLoadResult, options);
924+
const auto* pOptions = std::any_cast<CreateModelOptions>(&rendererOptions);
925+
if (pOptions)
926+
populateMeshDataArray(meshDataResult, tileLoadResult, *pOptions);
927+
else
928+
populateMeshDataArray(meshDataResult, tileLoadResult, {});
935929

936930
// We're returning the MeshDataArray, so don't free it.
937931
sg.release();

0 commit comments

Comments
 (0)