-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #248 from CesiumGS/tile-excluder
Add ability to exclude tiles by implementing a C# class.
- Loading branch information
Showing
17 changed files
with
522 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
| ||
using Reinterop; | ||
using System; | ||
using Unity.Mathematics; | ||
using UnityEngine; | ||
|
||
namespace CesiumForUnity | ||
{ | ||
/// <summary> | ||
/// Represents a tile in a <see cref="Cesium3DTileset"/> and allows information | ||
/// about the tile to be queried from the underlying C++ tile representation. | ||
/// </summary> | ||
[ReinteropNativeImplementation("CesiumForUnityNative::Cesium3DTileImpl", "Cesium3DTileImpl.h", staticOnly: true)] | ||
public partial class Cesium3DTile | ||
{ | ||
internal double4x4 _transform; | ||
internal IntPtr _pTile; | ||
|
||
internal Cesium3DTile() | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Gets the axis-aligned bounding box of this tile. If this tile came from a <see cref="CesiumTileExcluder"/>, | ||
/// the bounding box is expressed in the local coordinates of the excluder's game object. | ||
/// </summary> | ||
public Bounds bounds | ||
{ | ||
get | ||
{ | ||
return Cesium3DTile.getBounds(this._pTile, this._transform); | ||
} | ||
} | ||
|
||
private static partial Bounds getBounds(IntPtr pTile, double4x4 ecefToLocalMatrix); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using Reinterop; | ||
using UnityEngine; | ||
|
||
namespace CesiumForUnity | ||
{ | ||
/// <summary> | ||
/// The abstract base class for <see cref="Cesium3DTileset"/> tile excluders. By creating a class derived | ||
/// from `CesiumTileExcluder`, then adding it to a game object containing a `Cesium3DTileset` (or one of | ||
/// its parents), you can implement custom rules for excluding tiles in the `Cesium3DTileset` from loading | ||
/// and rendering. | ||
/// </summary> | ||
[ExecuteInEditMode] | ||
[ReinteropNativeImplementation("CesiumForUnityNative::CesiumTileExcluderImpl", "CesiumTileExcluderImpl.h", staticOnly: true)] | ||
public abstract partial class CesiumTileExcluder : MonoBehaviour | ||
{ | ||
/// <summary> | ||
/// Determines whether the given tile should be excluded from loading and rendering. If a tile is | ||
/// excluded, all of its children and other descendants in the bounding volume hierarchy will be | ||
/// excluded as well. | ||
/// </summary> | ||
/// <param name="tile">The tile to check. This instance is only valid for the duration of this call. Saving | ||
/// it and using it later will result in undefined behavior, including crashes.</param> | ||
/// <returns>True if the tile should be excluded, false if the tile should be loaded and rendered.</returns> | ||
public abstract bool ShouldExclude(Cesium3DTile tile); | ||
|
||
protected virtual void OnEnable() | ||
{ | ||
Cesium3DTileset[] tilesets = this.GetComponentsInChildren<Cesium3DTileset>(); | ||
foreach (Cesium3DTileset tileset in tilesets) | ||
{ | ||
this.AddToTileset(tileset); | ||
} | ||
} | ||
|
||
protected virtual void OnDisable() | ||
{ | ||
Cesium3DTileset[] tilesets = this.GetComponentsInChildren<Cesium3DTileset>(); | ||
foreach (Cesium3DTileset tileset in tilesets) | ||
{ | ||
this.RemoveFromTileset(tileset); | ||
} | ||
} | ||
|
||
internal partial void AddToTileset(Cesium3DTileset tileset); | ||
internal partial void RemoveFromTileset(Cesium3DTileset tileset); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.