Skip to content

Commit

Permalink
Merge pull request #658 from CesiumGS/exclude-tiles-not-in-polygon
Browse files Browse the repository at this point in the history
Bypass loading of clipped tiles
  • Loading branch information
corybarr authored Feb 15, 2024
2 parents c94fb7f + 288bcc2 commit 6418a52
Show file tree
Hide file tree
Showing 14 changed files with 109 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* Fixed crash when updating tilesets shader inputs.
* Fixed crash when setting certain `/Cesium` debug options at runtime.
* Fixed crash when disabling and re-enabling the extension.
* Added ability to bypass downloading of tiles clipped by a cartographic polygon raster overlay.
* Fixed a bug where save stage dialog would appear when reloading Fabric stage at startup.
* Fixed crash when removing USD prims in certain order.
* Fixed issue where Cesium ion session would not resume on reload.
Expand Down
2 changes: 1 addition & 1 deletion extern/cesium-native
Submodule cesium-native updated 83 files
+3 −3 .gitmodules
+18 −1 CHANGES.md
+2 −1 Cesium3DTilesContent/src/upsampleGltfForRasterOverlays.cpp
+1 −1 Cesium3DTilesContent/test/TestPntsToGltfConverter.cpp
+8 −0 Cesium3DTilesSelection/src/BoundingVolume.cpp
+9 −0 CesiumGeometry/include/CesiumGeometry/BoundingSphere.h
+1 −1 CesiumGeometry/include/CesiumGeometry/OrientedBoundingBox.h
+4 −0 CesiumGeometry/src/BoundingSphere.cpp
+11 −0 CesiumGeometry/test/TestBoundingSphere.cpp
+11 −0 CesiumGeospatial/include/CesiumGeospatial/Ellipsoid.h
+12 −1 CesiumGeospatial/include/CesiumGeospatial/GlobeRectangle.h
+102 −0 CesiumGeospatial/include/CesiumGeospatial/SimplePlanarEllipsoidCurve.h
+25 −0 CesiumGeospatial/src/Ellipsoid.cpp
+6 −0 CesiumGeospatial/src/GlobeRectangle.cpp
+106 −0 CesiumGeospatial/src/SimplePlanarEllipsoidCurve.cpp
+213 −0 CesiumGeospatial/test/TestSimplePlanarEllipsoidCurve.cpp
+0 −42 CesiumGltf/generated/include/CesiumGltf/ExtensionExtFeatureMetadataClass.h
+0 −182 CesiumGltf/generated/include/CesiumGltf/ExtensionExtFeatureMetadataClassProperty.h
+0 −38 CesiumGltf/generated/include/CesiumGltf/ExtensionExtFeatureMetadataClassStatistics.h
+0 −68 CesiumGltf/generated/include/CesiumGltf/ExtensionExtFeatureMetadataEnum.h
+0 −37 CesiumGltf/generated/include/CesiumGltf/ExtensionExtFeatureMetadataEnumValue.h
+0 −35 CesiumGltf/generated/include/CesiumGltf/ExtensionExtFeatureMetadataFeatureIDAttribute.h
+0 −37 CesiumGltf/generated/include/CesiumGltf/ExtensionExtFeatureMetadataFeatureIDTexture.h
+0 −43 CesiumGltf/generated/include/CesiumGltf/ExtensionExtFeatureMetadataFeatureIDs.h
+0 −48 CesiumGltf/generated/include/CesiumGltf/ExtensionExtFeatureMetadataFeatureTable.h
+0 −91 CesiumGltf/generated/include/CesiumGltf/ExtensionExtFeatureMetadataFeatureTableProperty.h
+0 −40 CesiumGltf/generated/include/CesiumGltf/ExtensionExtFeatureMetadataFeatureTexture.h
+0 −93 CesiumGltf/generated/include/CesiumGltf/ExtensionExtFeatureMetadataPropertyStatistics.h
+0 −53 CesiumGltf/generated/include/CesiumGltf/ExtensionExtFeatureMetadataSchema.h
+0 −31 CesiumGltf/generated/include/CesiumGltf/ExtensionExtFeatureMetadataStatistics.h
+0 −33 CesiumGltf/generated/include/CesiumGltf/ExtensionExtFeatureMetadataTextureAccessor.h
+0 −45 CesiumGltf/generated/include/CesiumGltf/ExtensionMeshPrimitiveExtFeatureMetadata.h
+0 −60 CesiumGltf/generated/include/CesiumGltf/ExtensionModelExtFeatureMetadata.h
+0 −78 CesiumGltfReader/generated/include/CesiumGltfReader/ExtensionExtFeatureMetadataClassPropertyReader.h
+0 −76 CesiumGltfReader/generated/include/CesiumGltfReader/ExtensionExtFeatureMetadataClassReader.h
+0 −78 CesiumGltfReader/generated/include/CesiumGltfReader/ExtensionExtFeatureMetadataClassStatisticsReader.h
+0 −76 CesiumGltfReader/generated/include/CesiumGltfReader/ExtensionExtFeatureMetadataEnumReader.h
+0 −78 CesiumGltfReader/generated/include/CesiumGltfReader/ExtensionExtFeatureMetadataEnumValueReader.h
+0 −78 CesiumGltfReader/generated/include/CesiumGltfReader/ExtensionExtFeatureMetadataFeatureIDAttributeReader.h
+0 −78 CesiumGltfReader/generated/include/CesiumGltfReader/ExtensionExtFeatureMetadataFeatureIDTextureReader.h
+0 −78 CesiumGltfReader/generated/include/CesiumGltfReader/ExtensionExtFeatureMetadataFeatureIDsReader.h
+0 −79 CesiumGltfReader/generated/include/CesiumGltfReader/ExtensionExtFeatureMetadataFeatureTablePropertyReader.h
+0 −78 CesiumGltfReader/generated/include/CesiumGltfReader/ExtensionExtFeatureMetadataFeatureTableReader.h
+0 −78 CesiumGltfReader/generated/include/CesiumGltfReader/ExtensionExtFeatureMetadataFeatureTextureReader.h
+0 −78 CesiumGltfReader/generated/include/CesiumGltfReader/ExtensionExtFeatureMetadataPropertyStatisticsReader.h
+0 −78 CesiumGltfReader/generated/include/CesiumGltfReader/ExtensionExtFeatureMetadataSchemaReader.h
+0 −78 CesiumGltfReader/generated/include/CesiumGltfReader/ExtensionExtFeatureMetadataStatisticsReader.h
+0 −78 CesiumGltfReader/generated/include/CesiumGltfReader/ExtensionExtFeatureMetadataTextureAccessorReader.h
+0 −78 CesiumGltfReader/generated/include/CesiumGltfReader/ExtensionMeshPrimitiveExtFeatureMetadataReader.h
+0 −76 CesiumGltfReader/generated/include/CesiumGltfReader/ExtensionModelExtFeatureMetadataReader.h
+0 −45 CesiumGltfReader/generated/src/ExtensionExtFeatureMetadataClassJsonHandler.h
+0 −51 CesiumGltfReader/generated/src/ExtensionExtFeatureMetadataClassPropertyJsonHandler.h
+0 −44 CesiumGltfReader/generated/src/ExtensionExtFeatureMetadataClassStatisticsJsonHandler.h
+0 −46 CesiumGltfReader/generated/src/ExtensionExtFeatureMetadataEnumJsonHandler.h
+0 −40 CesiumGltfReader/generated/src/ExtensionExtFeatureMetadataEnumValueJsonHandler.h
+0 −40 CesiumGltfReader/generated/src/ExtensionExtFeatureMetadataFeatureIDAttributeJsonHandler.h
+0 −40 CesiumGltfReader/generated/src/ExtensionExtFeatureMetadataFeatureIDTextureJsonHandler.h
+0 −40 CesiumGltfReader/generated/src/ExtensionExtFeatureMetadataFeatureIDsJsonHandler.h
+0 −46 CesiumGltfReader/generated/src/ExtensionExtFeatureMetadataFeatureTableJsonHandler.h
+0 −42 CesiumGltfReader/generated/src/ExtensionExtFeatureMetadataFeatureTablePropertyJsonHandler.h
+0 −44 CesiumGltfReader/generated/src/ExtensionExtFeatureMetadataFeatureTextureJsonHandler.h
+0 −48 CesiumGltfReader/generated/src/ExtensionExtFeatureMetadataPropertyStatisticsJsonHandler.h
+0 −51 CesiumGltfReader/generated/src/ExtensionExtFeatureMetadataSchemaJsonHandler.h
+0 −42 CesiumGltfReader/generated/src/ExtensionExtFeatureMetadataStatisticsJsonHandler.h
+0 −40 CesiumGltfReader/generated/src/ExtensionExtFeatureMetadataTextureAccessorJsonHandler.h
+0 −61 CesiumGltfReader/generated/src/ExtensionMeshPrimitiveExtFeatureMetadataJsonHandler.h
+0 −63 CesiumGltfReader/generated/src/ExtensionModelExtFeatureMetadataJsonHandler.h
+0 −1,802 CesiumGltfReader/generated/src/GeneratedJsonHandlers.cpp
+8 −8 CesiumGltfReader/generated/src/registerExtensions.cpp
+17 −14 CesiumGltfReader/test/TestExtensionModelExtStructuralMetadata.cpp
+94 −803 CesiumGltfWriter/generated/src/ModelJsonWriter.cpp
+0 −174 CesiumGltfWriter/generated/src/ModelJsonWriter.h
+8 −8 CesiumGltfWriter/generated/src/registerExtensions.cpp
+1 −1 CesiumGltfWriter/include/CesiumGltfWriter/GltfWriter.h
+1 −5 CesiumRasterOverlays/src/RasterizedPolygonsOverlay.cpp
+6 −6 CesiumUtility/src/Gunzip.cpp
+48 −0 CesiumUtility/test/TestGunzip.cpp
+3 −2 extern/CMakeLists.txt
+0 −1 extern/zlib
+1 −0 extern/zlib-ng
+2 −2 package-lock.json
+3 −60 tools/generate-classes/glTF.json
+12 −2 tools/generate-classes/index.js
8 changes: 8 additions & 0 deletions exts/cesium.usd.plugins/schemas/cesium_schemas.usda
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,14 @@ class CesiumPolygonRasterOverlayPrim "CesiumPolygonRasterOverlayPrim" (
doc = "Whether to invert the selection specified by the polygons. If this is true, only the areas outside of the polygons will be rasterized."
)

bool cesium:excludeSelectedTiles = true (
customData = {
string apiName = "excludeSelectedTiles"
}
displayName = "Exclude Selected Tiles"
doc = "Whether tiles that fall entirely within the rasterized selection should be excluded from loading and rendering. For better performance, this should be enabled when this overlay will be used for clipping. But when this overlay is used for other effects, this option should be disabled to avoid missing tiles. Note that if InvertSelection is true, this will cull tiles that are outside of all the polygons. If it is false, this will cull tiles that are completely inside at least one polygon."
)

uniform token cesium:overlayRenderMethod = "clip"
}

Expand Down
4 changes: 4 additions & 0 deletions src/core/include/cesium/omniverse/OmniPolygonRasterOverlay.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "cesium/omniverse/OmniRasterOverlay.h"

#include <Cesium3DTilesSelection/RasterizedPolygonsTileExcluder.h>
#include <CesiumRasterOverlays/RasterizedPolygonsOverlay.h>
#include <CesiumUtility/IntrusivePointer.h>

Expand All @@ -19,9 +20,12 @@ class OmniPolygonRasterOverlay final : public OmniRasterOverlay {
[[nodiscard]] std::vector<pxr::SdfPath> getCartographicPolygonPaths() const;
[[nodiscard]] CesiumRasterOverlays::RasterOverlay* getRasterOverlay() const override;
[[nodiscard]] bool getInvertSelection() const;
[[nodiscard]] bool getExcludeSelectedTiles() const;
[[nodiscard]] std::shared_ptr<Cesium3DTilesSelection::RasterizedPolygonsTileExcluder> getExcluder();
void reload() override;

private:
CesiumUtility::IntrusivePointer<CesiumRasterOverlays::RasterizedPolygonsOverlay> _pPolygonRasterOverlay;
std::shared_ptr<Cesium3DTilesSelection::RasterizedPolygonsTileExcluder> _pExcluder;
};
} // namespace cesium::omniverse
16 changes: 16 additions & 0 deletions src/core/src/OmniPolygonRasterOverlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,17 @@ bool OmniPolygonRasterOverlay::getInvertSelection() const {
return invertSelection;
}

bool OmniPolygonRasterOverlay::getExcludeSelectedTiles() const {
auto cesiumPolygonRasterOverlay = UsdUtil::getCesiumPolygonRasterOverlay(_pContext->getUsdStage(), _path);
bool val;
cesiumPolygonRasterOverlay.GetExcludeSelectedTilesAttr().Get(&val);
return val;
}

std::shared_ptr<Cesium3DTilesSelection::RasterizedPolygonsTileExcluder> OmniPolygonRasterOverlay::getExcluder() {
return _pExcluder;
}

void OmniPolygonRasterOverlay::reload() {
const auto rasterOverlayName = UsdUtil::getName(_pContext->getUsdStage(), _path);

Expand Down Expand Up @@ -109,6 +120,11 @@ void OmniPolygonRasterOverlay::reload() {

_pPolygonRasterOverlay = new CesiumRasterOverlays::RasterizedPolygonsOverlay(
rasterOverlayName, polygons, getInvertSelection(), *pEllipsoid, projection, options);

if (getExcludeSelectedTiles()) {
auto pPolygons = _pPolygonRasterOverlay.get();
_pExcluder = std::make_shared<Cesium3DTilesSelection::RasterizedPolygonsTileExcluder>(pPolygons);
}
}

} // namespace cesium::omniverse
12 changes: 12 additions & 0 deletions src/core/src/OmniTileset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "cesium/omniverse/OmniGeoreference.h"
#include "cesium/omniverse/OmniGlobeAnchor.h"
#include "cesium/omniverse/OmniIonServer.h"
#include "cesium/omniverse/OmniPolygonRasterOverlay.h"
#include "cesium/omniverse/OmniRasterOverlay.h"
#include "cesium/omniverse/TaskProcessor.h"
#include "cesium/omniverse/TilesetStatistics.h"
Expand Down Expand Up @@ -553,6 +554,17 @@ void OmniTileset::reload() {

options.contentOptions.ktx2TranscodeTargets = GltfUtil::getKtx2TranscodeTargets();

const auto rasterOverlayPaths = getRasterOverlayPaths();
for (const auto& rasterOverlayPath : rasterOverlayPaths) {
const auto pPolygonRasterOverlay = _pContext->getAssetRegistry().getPolygonRasterOverlay(rasterOverlayPath);
if (pPolygonRasterOverlay) {
const auto pExcluder = pPolygonRasterOverlay->getExcluder();
if (pExcluder) {
options.excluders.push_back(pExcluder);
}
}
}

_pViewUpdateResult = nullptr;
_extentSet = false;
_activeLoading = false;
Expand Down
3 changes: 2 additions & 1 deletion src/core/src/UsdNotificationHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,8 @@ void processCesiumPolygonRasterOverlayChanged(

for (const auto& property : properties) {
if (property == pxr::CesiumTokens->cesiumCartographicPolygonBinding ||
property == pxr::CesiumTokens->cesiumInvertSelection) {
property == pxr::CesiumTokens->cesiumInvertSelection ||
property == pxr::CesiumTokens->cesiumExcludeSelectedTiles) {
reload = true;
updateBindings = true;
}
Expand Down
4 changes: 4 additions & 0 deletions src/plugins/CesiumUsdSchemas/generatedSchema.usda.in
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,10 @@ class CesiumPolygonRasterOverlayPrim "CesiumPolygonRasterOverlayPrim" (
displayName = "Cartographic Polygon Binding"
doc = "Specifies which Cartographic Polygons to use in the raster overlay"
)
bool cesium:excludeSelectedTiles = 1 (
displayName = "Exclude Selected Tiles"
doc = "Whether tiles that fall entirely within the rasterized selection should be excluded from loading and rendering. For better performance, this should be enabled when this overlay will be used for clipping. But when this overlay is used for other effects, this option should be disabled to avoid missing tiles. Note that if InvertSelection is true, this will cull tiles that are outside of all the polygons. If it is false, this will cull tiles that are completely inside at least one polygon."
)
bool cesium:invertSelection = 0 (
displayName = "Invert Selection"
doc = "Whether to invert the selection specified by the polygons. If this is true, only the areas outside of the polygons will be rasterized."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,23 @@ CesiumPolygonRasterOverlay::CreateInvertSelectionAttr(VtValue const &defaultValu
writeSparsely);
}

UsdAttribute
CesiumPolygonRasterOverlay::GetExcludeSelectedTilesAttr() const
{
return GetPrim().GetAttribute(CesiumTokens->cesiumExcludeSelectedTiles);
}

UsdAttribute
CesiumPolygonRasterOverlay::CreateExcludeSelectedTilesAttr(VtValue const &defaultValue, bool writeSparsely) const
{
return UsdSchemaBase::_CreateAttr(CesiumTokens->cesiumExcludeSelectedTiles,
SdfValueTypeNames->Bool,
/* custom = */ false,
SdfVariabilityVarying,
defaultValue,
writeSparsely);
}

UsdAttribute
CesiumPolygonRasterOverlay::GetCesiumOverlayRenderMethodAttr() const
{
Expand Down Expand Up @@ -145,6 +162,7 @@ CesiumPolygonRasterOverlay::GetSchemaAttributeNames(bool includeInherited)
{
static TfTokenVector localNames = {
CesiumTokens->cesiumInvertSelection,
CesiumTokens->cesiumExcludeSelectedTiles,
CesiumTokens->cesiumOverlayRenderMethod,
};
static TfTokenVector allNames =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,28 @@ class CesiumPolygonRasterOverlay : public CesiumRasterOverlay
CESIUMUSDSCHEMAS_API
UsdAttribute CreateInvertSelectionAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;

public:
// --------------------------------------------------------------------- //
// EXCLUDESELECTEDTILES
// --------------------------------------------------------------------- //
/// Whether tiles that fall entirely within the rasterized selection should be excluded from loading and rendering. For better performance, this should be enabled when this overlay will be used for clipping. But when this overlay is used for other effects, this option should be disabled to avoid missing tiles. Note that if InvertSelection is true, this will cull tiles that are outside of all the polygons. If it is false, this will cull tiles that are completely inside at least one polygon.
///
/// | ||
/// | -- | -- |
/// | Declaration | `bool cesium:excludeSelectedTiles = 1` |
/// | C++ Type | bool |
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Bool |
CESIUMUSDSCHEMAS_API
UsdAttribute GetExcludeSelectedTilesAttr() const;

/// See GetExcludeSelectedTilesAttr(), and also
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
/// If specified, author \p defaultValue as the attribute's default,
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
/// the default for \p writeSparsely is \c false.
CESIUMUSDSCHEMAS_API
UsdAttribute CreateExcludeSelectedTilesAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;

public:
// --------------------------------------------------------------------- //
// CESIUMOVERLAYRENDERMETHOD
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/CesiumUsdSchemas/src/CesiumUsdSchemas/tokens.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ CesiumTokensType::CesiumTokensType() :
cesiumEnableFogCulling("cesium:enableFogCulling", TfToken::Immortal),
cesiumEnableFrustumCulling("cesium:enableFrustumCulling", TfToken::Immortal),
cesiumEnforceCulledScreenSpaceError("cesium:enforceCulledScreenSpaceError", TfToken::Immortal),
cesiumExcludeSelectedTiles("cesium:excludeSelectedTiles", TfToken::Immortal),
cesiumForbidHoles("cesium:forbidHoles", TfToken::Immortal),
cesiumGeoreferenceBinding("cesium:georeferenceBinding", TfToken::Immortal),
cesiumGeoreferenceOriginHeight("cesium:georeferenceOrigin:height", TfToken::Immortal),
Expand Down Expand Up @@ -96,6 +97,7 @@ CesiumTokensType::CesiumTokensType() :
cesiumEnableFogCulling,
cesiumEnableFrustumCulling,
cesiumEnforceCulledScreenSpaceError,
cesiumExcludeSelectedTiles,
cesiumForbidHoles,
cesiumGeoreferenceBinding,
cesiumGeoreferenceOriginHeight,
Expand Down
4 changes: 4 additions & 0 deletions src/plugins/CesiumUsdSchemas/src/CesiumUsdSchemas/tokens.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ struct CesiumTokensType {
///
/// CesiumTileset
const TfToken cesiumEnforceCulledScreenSpaceError;
/// \brief "cesium:excludeSelectedTiles"
///
/// CesiumPolygonRasterOverlay
const TfToken cesiumExcludeSelectedTiles;
/// \brief "cesium:forbidHoles"
///
/// CesiumTileset
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ _CreateInvertSelectionAttr(CesiumPolygonRasterOverlay &self,
UsdPythonToSdfType(defaultVal, SdfValueTypeNames->Bool), writeSparsely);
}

static UsdAttribute
_CreateExcludeSelectedTilesAttr(CesiumPolygonRasterOverlay &self,
object defaultVal, bool writeSparsely) {
return self.CreateExcludeSelectedTilesAttr(
UsdPythonToSdfType(defaultVal, SdfValueTypeNames->Bool), writeSparsely);
}

static UsdAttribute
_CreateCesiumOverlayRenderMethodAttr(CesiumPolygonRasterOverlay &self,
object defaultVal, bool writeSparsely) {
Expand Down Expand Up @@ -89,6 +96,13 @@ void wrapCesiumPolygonRasterOverlay()
(arg("defaultValue")=object(),
arg("writeSparsely")=false))

.def("GetExcludeSelectedTilesAttr",
&This::GetExcludeSelectedTilesAttr)
.def("CreateExcludeSelectedTilesAttr",
&_CreateExcludeSelectedTilesAttr,
(arg("defaultValue")=object(),
arg("writeSparsely")=false))

.def("GetCesiumOverlayRenderMethodAttr",
&This::GetCesiumOverlayRenderMethodAttr)
.def("CreateCesiumOverlayRenderMethodAttr",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ void wrapCesiumTokens()
_AddToken(cls, "cesiumEnableFogCulling", CesiumTokens->cesiumEnableFogCulling);
_AddToken(cls, "cesiumEnableFrustumCulling", CesiumTokens->cesiumEnableFrustumCulling);
_AddToken(cls, "cesiumEnforceCulledScreenSpaceError", CesiumTokens->cesiumEnforceCulledScreenSpaceError);
_AddToken(cls, "cesiumExcludeSelectedTiles", CesiumTokens->cesiumExcludeSelectedTiles);
_AddToken(cls, "cesiumForbidHoles", CesiumTokens->cesiumForbidHoles);
_AddToken(cls, "cesiumGeoreferenceBinding", CesiumTokens->cesiumGeoreferenceBinding);
_AddToken(cls, "cesiumGeoreferenceOriginHeight", CesiumTokens->cesiumGeoreferenceOriginHeight);
Expand Down

0 comments on commit 6418a52

Please sign in to comment.