Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to update Tileset options without reloading tileset #412

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 19 additions & 13 deletions Runtime/Cesium3DTileset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public float maximumScreenSpaceError
set
{
this._maximumScreenSpaceError = value;
this.RecreateTileset();
this.UpdateTilesetOptions();
}
}

Expand All @@ -264,7 +264,7 @@ public bool preloadAncestors
set
{
this._preloadAncestors = value;
this.RecreateTileset();
this.UpdateTilesetOptions();
}
}

Expand All @@ -285,7 +285,7 @@ public bool preloadSiblings
set
{
this._preloadSiblings = value;
this.RecreateTileset();
this.UpdateTilesetOptions();
}
}

Expand All @@ -308,7 +308,7 @@ public bool forbidHoles
set
{
this._forbidHoles = value;
this.RecreateTileset();
this.UpdateTilesetOptions();
}
}

Expand All @@ -331,7 +331,7 @@ public uint maximumSimultaneousTileLoads
set
{
this._maximumSimultaneousTileLoads = value;
this.RecreateTileset();
this.UpdateTilesetOptions();
}
}

Expand All @@ -354,7 +354,7 @@ public long maximumCachedBytes
set
{
this._maximumCachedBytes = value;
this.RecreateTileset();
this.UpdateTilesetOptions();
}
}

Expand All @@ -378,7 +378,7 @@ public uint loadingDescendantLimit
set
{
this._loadingDescendantLimit = value;
this.RecreateTileset();
this.UpdateTilesetOptions();
}
}

Expand Down Expand Up @@ -408,7 +408,7 @@ public bool enableFrustumCulling
set
{
this._enableFrustumCulling = value;
this.RecreateTileset();
this.UpdateTilesetOptions();
}
}

Expand All @@ -435,7 +435,7 @@ public bool enableFogCulling
set
{
this._enableFogCulling = value;
this.RecreateTileset();
this.UpdateTilesetOptions();
}
}

Expand Down Expand Up @@ -474,7 +474,7 @@ public bool enforceCulledScreenSpaceError
set
{
this._enforceCulledScreenSpaceError = value;
this.RecreateTileset();
this.UpdateTilesetOptions();
}
}

Expand Down Expand Up @@ -511,7 +511,7 @@ public float culledScreenSpaceError
set
{
this._culledScreenSpaceError = value;
this.RecreateTileset();
this.UpdateTilesetOptions();
}
}

Expand Down Expand Up @@ -540,7 +540,7 @@ public Material opaqueMaterial
// set
// {
// this._useLodTransitions = value;
// this.RecreateTileset();
// this.UpdateTilesetOptions();
// }
//}

Expand All @@ -554,7 +554,7 @@ public Material opaqueMaterial
// set
// {
// this._lodTransitionLength = value;
// this.RecreateTileset();
// this.UpdateTilesetOptions();
// }
//}

Expand Down Expand Up @@ -708,6 +708,12 @@ public bool createPhysicsMeshes
/// based on the current view.
/// </summary>
public partial void RecreateTileset();

/// <summary>
/// Update the tileset options. Tiles are not unloaded, but the Options of the tileset are updated
/// based on the current values of the properties.
/// </summary>
public partial void UpdateTilesetOptions();

/// <summary>
/// Zoom the Editor camera to this tileset. This method does nothing outside of the Editor.
Expand Down
1 change: 1 addition & 0 deletions Runtime/ConfigureReinterop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ public void ExposeToCPP()
tileset.showCreditsOnScreen = tileset.showCreditsOnScreen;
tileset.ionServer = tileset.ionServer;
tileset.RecreateTileset();
tileset.UpdateTilesetOptions();

GraphicsFormat gfxFmt = GraphicsFormat.RGB_ETC_UNorm;
FormatUsage fmtUsage = FormatUsage.Sample;
Expand Down
22 changes: 22 additions & 0 deletions native~/Runtime/src/Cesium3DTilesetImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,28 @@ void Cesium3DTilesetImpl::RecreateTileset(
this->DestroyTileset(tileset);
}

void Cesium3DTilesetImpl::UpdateTilesetOptions(
const DotNet::CesiumForUnity::Cesium3DTileset& tileset) {
if (this->_pTileset) {
TilesetOptions options = this->_pTileset->getOptions();
options.maximumScreenSpaceError = tileset.maximumScreenSpaceError();
options.preloadAncestors = tileset.preloadAncestors();
options.preloadSiblings = tileset.preloadSiblings();
options.forbidHoles = tileset.forbidHoles();
options.maximumSimultaneousTileLoads = tileset.maximumSimultaneousTileLoads();
options.maximumCachedBytes = tileset.maximumCachedBytes();
options.loadingDescendantLimit = tileset.loadingDescendantLimit();
options.enableFrustumCulling = tileset.enableFrustumCulling();
options.enableFogCulling = tileset.enableFogCulling();
options.enforceCulledScreenSpaceError = tileset.enforceCulledScreenSpaceError();
options.culledScreenSpaceError = tileset.culledScreenSpaceError();
// options.enableLodTransitionPeriod = tileset.useLodTransitions();
// options.lodTransitionLength = tileset.lodTransitionLength();
options.showCreditsOnScreen = tileset.showCreditsOnScreen();
this->_pTileset->getOptions() = options;
}
}

namespace {

struct CalculateECEFCameraPosition {
Expand Down
1 change: 1 addition & 0 deletions native~/Runtime/src/Cesium3DTilesetImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class Cesium3DTilesetImpl {
void OnDisable(const DotNet::CesiumForUnity::Cesium3DTileset& tileset);

void RecreateTileset(const DotNet::CesiumForUnity::Cesium3DTileset& tileset);
void UpdateTilesetOptions(const DotNet::CesiumForUnity::Cesium3DTileset& tileset);
void FocusTileset(const DotNet::CesiumForUnity::Cesium3DTileset& tileset);
void UpdateOverlayMaterialKeys(
const DotNet::CesiumForUnity::Cesium3DTileset& tileset);
Expand Down