From 0873090e524dee13ecdbec4f4145dd364f8d5040 Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Mon, 12 Feb 2024 18:08:16 -0500 Subject: [PATCH 1/9] Add more safeguards when removing prims in UsdNotificationHandler --- src/core/src/UsdNotificationHandler.cpp | 74 +++++++++++++++++++------ 1 file changed, 57 insertions(+), 17 deletions(-) diff --git a/src/core/src/UsdNotificationHandler.cpp b/src/core/src/UsdNotificationHandler.cpp index 0816073e..b86be9d3 100644 --- a/src/core/src/UsdNotificationHandler.cpp +++ b/src/core/src/UsdNotificationHandler.cpp @@ -44,8 +44,10 @@ void updateRasterOverlayBindings(const Context& context, const pxr::SdfPath& ras // Update tilesets that reference this raster overlay for (const auto& pTileset : tilesets) { - if (CppUtil::contains(pTileset->getRasterOverlayPaths(), rasterOverlayPath)) { - pTileset->reload(); + if (UsdUtil::primExists(context.getUsdStage(), pTileset->getPath())) { + if (CppUtil::contains(pTileset->getRasterOverlayPaths(), rasterOverlayPath)) { + pTileset->reload(); + } } } } @@ -55,8 +57,10 @@ void updateRasterOverlayBindingsAlpha(const Context& context, const pxr::SdfPath // Update tilesets that reference this raster overlay for (const auto& pTileset : tilesets) { - if (CppUtil::contains(pTileset->getRasterOverlayPaths(), rasterOverlayPath)) { - pTileset->updateRasterOverlayAlpha(rasterOverlayPath); + if (UsdUtil::primExists(context.getUsdStage(), pTileset->getPath())) { + if (CppUtil::contains(pTileset->getRasterOverlayPaths(), rasterOverlayPath)) { + pTileset->updateRasterOverlayAlpha(rasterOverlayPath); + } } } } @@ -65,14 +69,18 @@ void updateIonServerBindings(const Context& context) { // Update all tilesets. Some tilesets may have referenced this ion server implicitly. const auto& tilesets = context.getAssetRegistry().getTilesets(); for (const auto& pTileset : tilesets) { - pTileset->reload(); + if (UsdUtil::primExists(context.getUsdStage(), pTileset->getPath())) { + pTileset->reload(); + } } // Update all raster overlays. Some raster overlays may have referenced this ion server implicitly. const auto& ionRasterOverlays = context.getAssetRegistry().getIonRasterOverlays(); for (const auto& pIonRasterOverlay : ionRasterOverlays) { - pIonRasterOverlay->reload(); - updateRasterOverlayBindings(context, pIonRasterOverlay->getPath()); + if (UsdUtil::primExists(context.getUsdStage(), pIonRasterOverlay->getPath())) { + pIonRasterOverlay->reload(); + updateRasterOverlayBindings(context, pIonRasterOverlay->getPath()); + } } } @@ -80,10 +88,12 @@ void updateCartographicPolygonBindings(const Context& context, const pxr::SdfPat // Update polygon raster overlays that reference this cartographic polygon const auto& polygonRasterOverlays = context.getAssetRegistry().getPolygonRasterOverlays(); for (const auto& pPolygonRasterOverlay : polygonRasterOverlays) { - const auto paths = pPolygonRasterOverlay->getCartographicPolygonPaths(); - if (CppUtil::contains(paths, cartographicPolygonPath)) { - pPolygonRasterOverlay->reload(); - updateRasterOverlayBindings(context, pPolygonRasterOverlay->getPath()); + if (UsdUtil::primExists(context.getUsdStage(), pPolygonRasterOverlay->getPath())) { + const auto paths = pPolygonRasterOverlay->getCartographicPolygonPaths(); + if (CppUtil::contains(paths, cartographicPolygonPath)) { + pPolygonRasterOverlay->reload(); + updateRasterOverlayBindings(context, pPolygonRasterOverlay->getPath()); + } } } } @@ -92,8 +102,10 @@ void updateGlobeAnchorBindings(const Context& context, const pxr::SdfPath& globe // Don't need to update tilesets. Globe anchor changes are handled automatically in the update loop. if (context.getAssetRegistry().getCartographicPolygon(globeAnchorPath)) { - // Update cartographic polygon that this globe anchor is attached to - updateCartographicPolygonBindings(context, globeAnchorPath); + if (UsdUtil::primExists(context.getUsdStage(), globeAnchorPath)) { + // Update cartographic polygon that this globe anchor is attached to + updateCartographicPolygonBindings(context, globeAnchorPath); + } } } @@ -103,8 +115,10 @@ void updateGeoreferenceBindings(const Context& context) { // Update all globe anchors. Some globe anchors may have referenced this georeference implicitly. const auto& globeAnchors = context.getAssetRegistry().getGlobeAnchors(); for (const auto& pGlobeAnchor : globeAnchors) { - pGlobeAnchor->updateByGeoreference(); - updateGlobeAnchorBindings(context, pGlobeAnchor->getPath()); + if (UsdUtil::primExists(context.getUsdStage(), pGlobeAnchor->getPath())) { + pGlobeAnchor->updateByGeoreference(); + updateGlobeAnchorBindings(context, pGlobeAnchor->getPath()); + } } } @@ -164,6 +178,10 @@ void processCesiumGlobeAnchorChanged( return; } + if (!UsdUtil::primExists(context.getUsdStage(), pGlobeAnchor->getPath())) { + return; + } + // No change tracking needed for // * adjustOrientation @@ -238,6 +256,10 @@ void processCesiumTilesetChanged( return; } + if (!UsdUtil::primExists(context.getUsdStage(), pTileset->getPath())) { + return; + } + // Process globe anchor API schema first processCesiumGlobeAnchorChanged(context, tilesetPath, properties); @@ -306,6 +328,10 @@ void processCesiumRasterOverlayChanged( return; } + if (!UsdUtil::primExists(context.getUsdStage(), pRasterOverlay->getPath())) { + return; + } + auto reload = false; auto updateBindings = false; auto updateRasterOverlayAlpha = false; @@ -343,6 +369,10 @@ void processCesiumIonRasterOverlayChanged( return; } + if (!UsdUtil::primExists(context.getUsdStage(), pIonRasterOverlay->getPath())) { + return; + } + // Process base class first processCesiumRasterOverlayChanged(context, ionRasterOverlayPath, properties); @@ -375,6 +405,10 @@ void processCesiumPolygonRasterOverlayChanged( return; } + if (!UsdUtil::primExists(context.getUsdStage(), pPolygonRasterOverlay->getPath())) { + return; + } + // Process base class first processCesiumRasterOverlayChanged(context, polygonRasterOverlayPath, properties); @@ -409,6 +443,10 @@ void processCesiumWebMapServiceRasterOverlayChanged( return; } + if (!UsdUtil::primExists(context.getUsdStage(), pWebMapServiceRasterOverlay->getPath())) { + return; + } + // Process base class first processCesiumRasterOverlayChanged(context, webMapServiceRasterOverlayPath, properties); @@ -558,8 +596,10 @@ void processUsdShaderChanged( const auto& tilesets = context.getAssetRegistry().getTilesets(); for (const auto& pTileset : tilesets) { - if (pTileset->getMaterialPath() == materialPath) { - pTileset->updateShaderInput(shaderPath, property); + if (UsdUtil::primExists(context.getUsdStage(), pTileset->getPath())) { + if (pTileset->getMaterialPath() == materialPath) { + pTileset->updateShaderInput(shaderPath, property); + } } } From 2bfcc6cbb20ba203f45a9145b0b3b5869ec5409c Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Mon, 12 Feb 2024 18:38:31 -0500 Subject: [PATCH 2/9] Try to centralize primExists check some more --- src/core/src/UsdNotificationHandler.cpp | 31 +++++-------------------- 1 file changed, 6 insertions(+), 25 deletions(-) diff --git a/src/core/src/UsdNotificationHandler.cpp b/src/core/src/UsdNotificationHandler.cpp index b86be9d3..f40edea7 100644 --- a/src/core/src/UsdNotificationHandler.cpp +++ b/src/core/src/UsdNotificationHandler.cpp @@ -178,10 +178,6 @@ void processCesiumGlobeAnchorChanged( return; } - if (!UsdUtil::primExists(context.getUsdStage(), pGlobeAnchor->getPath())) { - return; - } - // No change tracking needed for // * adjustOrientation @@ -256,10 +252,6 @@ void processCesiumTilesetChanged( return; } - if (!UsdUtil::primExists(context.getUsdStage(), pTileset->getPath())) { - return; - } - // Process globe anchor API schema first processCesiumGlobeAnchorChanged(context, tilesetPath, properties); @@ -328,10 +320,6 @@ void processCesiumRasterOverlayChanged( return; } - if (!UsdUtil::primExists(context.getUsdStage(), pRasterOverlay->getPath())) { - return; - } - auto reload = false; auto updateBindings = false; auto updateRasterOverlayAlpha = false; @@ -369,10 +357,6 @@ void processCesiumIonRasterOverlayChanged( return; } - if (!UsdUtil::primExists(context.getUsdStage(), pIonRasterOverlay->getPath())) { - return; - } - // Process base class first processCesiumRasterOverlayChanged(context, ionRasterOverlayPath, properties); @@ -405,10 +389,6 @@ void processCesiumPolygonRasterOverlayChanged( return; } - if (!UsdUtil::primExists(context.getUsdStage(), pPolygonRasterOverlay->getPath())) { - return; - } - // Process base class first processCesiumRasterOverlayChanged(context, polygonRasterOverlayPath, properties); @@ -443,10 +423,6 @@ void processCesiumWebMapServiceRasterOverlayChanged( return; } - if (!UsdUtil::primExists(context.getUsdStage(), pWebMapServiceRasterOverlay->getPath())) { - return; - } - // Process base class first processCesiumRasterOverlayChanged(context, webMapServiceRasterOverlayPath, properties); @@ -472,7 +448,6 @@ void processCesiumWebMapServiceRasterOverlayChanged( } void processCesiumGeoreferenceChanged(const Context& context, const std::vector& properties) { - auto updateBindings = false; // clang-format off @@ -787,6 +762,12 @@ bool UsdNotificationHandler::processChangedPrims() { ChangedPrim* pPrevious = nullptr; for (const auto& changedPrim : _changedPrims) { + if (changedPrim.changedType == ChangedType::PROPERTY_CHANGED && + !UsdUtil::primExists(_pContext->getUsdStage(), changedPrim.primPath)) { + // Don't process property changes if the prim is no longer on the stage + continue; + } + if (pPrevious && changedPrim.primPath == pPrevious->primPath) { if (pPrevious->changedType == ChangedType::PRIM_ADDED && changedPrim.changedType == ChangedType::PROPERTY_CHANGED) { From 221aab595f8d8d571b4722f7e6abdec0b7846c00 Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Tue, 13 Feb 2024 09:58:56 -0500 Subject: [PATCH 3/9] Add isSchemaValid checks wherever attributes are accessed --- src/core/include/cesium/omniverse/UsdUtil.h | 2 + src/core/src/OmniCartographicPolygon.cpp | 3 + src/core/src/OmniData.cpp | 33 ++++++++ src/core/src/OmniGeoreference.cpp | 3 + src/core/src/OmniGlobeAnchor.cpp | 64 ++++++++++++-- src/core/src/OmniIonRasterOverlay.cpp | 9 ++ src/core/src/OmniIonServer.cpp | 15 ++++ src/core/src/OmniPolygonRasterOverlay.cpp | 9 +- src/core/src/OmniRasterOverlay.cpp | 9 ++ src/core/src/OmniTileset.cpp | 84 ++++++++++++++++++- .../src/OmniWebMapServiceRasterOverlay.cpp | 66 ++++++++++----- src/core/src/UsdNotificationHandler.cpp | 4 + src/core/src/UsdUtil.cpp | 12 ++- 13 files changed, 275 insertions(+), 38 deletions(-) diff --git a/src/core/include/cesium/omniverse/UsdUtil.h b/src/core/include/cesium/omniverse/UsdUtil.h index f3fb55ed..3e9c5c71 100644 --- a/src/core/include/cesium/omniverse/UsdUtil.h +++ b/src/core/include/cesium/omniverse/UsdUtil.h @@ -91,6 +91,8 @@ Cesium3DTilesSelection::ViewState computeViewState( const Viewport& viewport); bool primExists(const pxr::UsdStageWeakPtr& pStage, const pxr::SdfPath& path); +bool isSchemaValid(const pxr::UsdSchemaBase& schema); + bool isPrimVisible(const pxr::UsdStageWeakPtr& pStage, const pxr::SdfPath& path); const std::string& getName(const pxr::UsdStageWeakPtr& pStage, const pxr::SdfPath& path); diff --git a/src/core/src/OmniCartographicPolygon.cpp b/src/core/src/OmniCartographicPolygon.cpp index 7bc692de..16978dfd 100644 --- a/src/core/src/OmniCartographicPolygon.cpp +++ b/src/core/src/OmniCartographicPolygon.cpp @@ -38,6 +38,9 @@ std::vector OmniCartographicPolygon::getCartogra } const auto cesiumCartographicPolygon = UsdUtil::getCesiumCartographicPolygon(_pContext->getUsdStage(), _path); + if (!UsdUtil::isSchemaValid(cesiumCartographicPolygon)) { + return {}; + } pxr::VtArray points; cesiumCartographicPolygon.GetPointsAttr().Get(&points); diff --git a/src/core/src/OmniData.cpp b/src/core/src/OmniData.cpp index 02bc5941..6954a554 100644 --- a/src/core/src/OmniData.cpp +++ b/src/core/src/OmniData.cpp @@ -17,6 +17,9 @@ const pxr::SdfPath& OmniData::getPath() const { pxr::SdfPath OmniData::getSelectedIonServerPath() const { const auto cesiumData = UsdUtil::getCesiumData(_pContext->getUsdStage(), _path); + if (!UsdUtil::isSchemaValid(cesiumData)) { + return {}; + } pxr::SdfPathVector targets; cesiumData.GetSelectedIonServerRel().GetForwardedTargets(&targets); @@ -30,6 +33,9 @@ pxr::SdfPath OmniData::getSelectedIonServerPath() const { bool OmniData::getDebugDisableMaterials() const { const auto cesiumData = UsdUtil::getCesiumData(_pContext->getUsdStage(), _path); + if (!UsdUtil::isSchemaValid(cesiumData)) { + return false; + } bool disableMaterials; cesiumData.GetDebugDisableMaterialsAttr().Get(&disableMaterials); @@ -39,6 +45,9 @@ bool OmniData::getDebugDisableMaterials() const { bool OmniData::getDebugDisableTextures() const { const auto cesiumData = UsdUtil::getCesiumData(_pContext->getUsdStage(), _path); + if (!UsdUtil::isSchemaValid(cesiumData)) { + return false; + } bool disableTextures; cesiumData.GetDebugDisableTexturesAttr().Get(&disableTextures); @@ -48,6 +57,9 @@ bool OmniData::getDebugDisableTextures() const { bool OmniData::getDebugDisableGeometryPool() const { const auto cesiumData = UsdUtil::getCesiumData(_pContext->getUsdStage(), _path); + if (!UsdUtil::isSchemaValid(cesiumData)) { + return false; + } bool disableGeometryPool; cesiumData.GetDebugDisableGeometryPoolAttr().Get(&disableGeometryPool); @@ -57,6 +69,9 @@ bool OmniData::getDebugDisableGeometryPool() const { bool OmniData::getDebugDisableMaterialPool() const { const auto cesiumData = UsdUtil::getCesiumData(_pContext->getUsdStage(), _path); + if (!UsdUtil::isSchemaValid(cesiumData)) { + return false; + } bool disableMaterialPool; cesiumData.GetDebugDisableMaterialPoolAttr().Get(&disableMaterialPool); @@ -66,6 +81,9 @@ bool OmniData::getDebugDisableMaterialPool() const { bool OmniData::getDebugDisableTexturePool() const { const auto cesiumData = UsdUtil::getCesiumData(_pContext->getUsdStage(), _path); + if (!UsdUtil::isSchemaValid(cesiumData)) { + return false; + } bool disableTexturePool; cesiumData.GetDebugDisableTexturePoolAttr().Get(&disableTexturePool); @@ -75,6 +93,9 @@ bool OmniData::getDebugDisableTexturePool() const { uint64_t OmniData::getDebugGeometryPoolInitialCapacity() const { const auto cesiumData = UsdUtil::getCesiumData(_pContext->getUsdStage(), _path); + if (!UsdUtil::isSchemaValid(cesiumData)) { + return 2048; + } uint64_t geometryPoolInitialCapacity; cesiumData.GetDebugGeometryPoolInitialCapacityAttr().Get(&geometryPoolInitialCapacity); @@ -84,6 +105,9 @@ uint64_t OmniData::getDebugGeometryPoolInitialCapacity() const { uint64_t OmniData::getDebugMaterialPoolInitialCapacity() const { const auto cesiumData = UsdUtil::getCesiumData(_pContext->getUsdStage(), _path); + if (!UsdUtil::isSchemaValid(cesiumData)) { + return 2048; + } uint64_t materialPoolInitialCapacity; cesiumData.GetDebugMaterialPoolInitialCapacityAttr().Get(&materialPoolInitialCapacity); @@ -93,6 +117,9 @@ uint64_t OmniData::getDebugMaterialPoolInitialCapacity() const { uint64_t OmniData::getDebugTexturePoolInitialCapacity() const { const auto cesiumData = UsdUtil::getCesiumData(_pContext->getUsdStage(), _path); + if (!UsdUtil::isSchemaValid(cesiumData)) { + return 2048; + } uint64_t texturePoolInitialCapacity; cesiumData.GetDebugTexturePoolInitialCapacityAttr().Get(&texturePoolInitialCapacity); @@ -102,6 +129,9 @@ uint64_t OmniData::getDebugTexturePoolInitialCapacity() const { bool OmniData::getDebugRandomColors() const { const auto cesiumData = UsdUtil::getCesiumData(_pContext->getUsdStage(), _path); + if (!UsdUtil::isSchemaValid(cesiumData)) { + return false; + } bool debugRandomColors; cesiumData.GetDebugRandomColorsAttr().Get(&debugRandomColors); @@ -111,6 +141,9 @@ bool OmniData::getDebugRandomColors() const { bool OmniData::getDebugDisableGeoreferencing() const { const auto cesiumData = UsdUtil::getCesiumData(_pContext->getUsdStage(), _path); + if (!UsdUtil::isSchemaValid(cesiumData)) { + return false; + } bool debugDisableGeoreferencing; cesiumData.GetDebugDisableGeoreferencingAttr().Get(&debugDisableGeoreferencing); diff --git a/src/core/src/OmniGeoreference.cpp b/src/core/src/OmniGeoreference.cpp index 32ef5c6e..a539c62e 100644 --- a/src/core/src/OmniGeoreference.cpp +++ b/src/core/src/OmniGeoreference.cpp @@ -22,6 +22,9 @@ const pxr::SdfPath& OmniGeoreference::getPath() const { CesiumGeospatial::Cartographic OmniGeoreference::getOrigin() const { const auto cesiumGeoreference = UsdUtil::getCesiumGeoreference(_pContext->getUsdStage(), _path); + if (!UsdUtil::isSchemaValid(cesiumGeoreference)) { + return {0.0, 0.0, 0.0}; + } double longitude; double latitude; diff --git a/src/core/src/OmniGlobeAnchor.cpp b/src/core/src/OmniGlobeAnchor.cpp index c9337196..4b11f3c5 100644 --- a/src/core/src/OmniGlobeAnchor.cpp +++ b/src/core/src/OmniGlobeAnchor.cpp @@ -49,6 +49,9 @@ const pxr::SdfPath& OmniGlobeAnchor::getPath() const { bool OmniGlobeAnchor::getDetectTransformChanges() const { const auto cesiumGlobeAnchor = UsdUtil::getCesiumGlobeAnchor(_pContext->getUsdStage(), _path); + if (!UsdUtil::isSchemaValid(cesiumGlobeAnchor)) { + return true; + } bool detectTransformChanges; cesiumGlobeAnchor.GetDetectTransformChangesAttr().Get(&detectTransformChanges); @@ -58,6 +61,9 @@ bool OmniGlobeAnchor::getDetectTransformChanges() const { bool OmniGlobeAnchor::getAdjustOrientation() const { const auto cesiumGlobeAnchor = UsdUtil::getCesiumGlobeAnchor(_pContext->getUsdStage(), _path); + if (!UsdUtil::isSchemaValid(cesiumGlobeAnchor)) { + return true; + } bool adjustOrientation; cesiumGlobeAnchor.GetAdjustOrientationForGlobeWhenMovingAttr().Get(&adjustOrientation); @@ -67,6 +73,9 @@ bool OmniGlobeAnchor::getAdjustOrientation() const { pxr::SdfPath OmniGlobeAnchor::getResolvedGeoreferencePath() const { const auto cesiumGlobeAnchor = UsdUtil::getCesiumGlobeAnchor(_pContext->getUsdStage(), _path); + if (!UsdUtil::isSchemaValid(cesiumGlobeAnchor)) { + return {}; + } pxr::SdfPathVector targets; cesiumGlobeAnchor.GetGeoreferenceBindingRel().GetForwardedTargets(&targets); @@ -158,7 +167,7 @@ void OmniGlobeAnchor::updateByPrimLocalTransform(bool resetOrientation) { } const auto cesiumGlobeAnchor = UsdUtil::getCesiumGlobeAnchor(_pContext->getUsdStage(), _path); - const auto xformable = pxr::UsdGeomXformable(cesiumGlobeAnchor.GetPrim()); + const auto xformable = pxr::UsdGeomXformable(cesiumGlobeAnchor); const auto xformOps = UsdUtil::getOrCreateTranslateRotateScaleOps(xformable); const auto eulerAngleOrder = xformOps->eulerAngleOrder; @@ -202,7 +211,11 @@ bool OmniGlobeAnchor::isAnchorValid() const { } const auto cesiumGlobeAnchor = UsdUtil::getCesiumGlobeAnchor(_pContext->getUsdStage(), _path); - const auto xformable = pxr::UsdGeomXformable(cesiumGlobeAnchor.GetPrim()); + const auto xformable = pxr::UsdGeomXformable(cesiumGlobeAnchor); + if (!UsdUtil::isSchemaValid(xformable)) { + return false; + } + const auto xformOps = UsdUtil::getOrCreateTranslateRotateScaleOps(xformable); if (!xformOps) { @@ -229,7 +242,10 @@ void OmniGlobeAnchor::initialize() { // when using globe anchors. const auto cesiumGlobeAnchor = UsdUtil::getCesiumGlobeAnchor(_pContext->getUsdStage(), _path); - const auto xformable = pxr::UsdGeomXformable(cesiumGlobeAnchor.GetPrim()); + const auto xformable = pxr::UsdGeomXformable(cesiumGlobeAnchor); + if (!UsdUtil::isSchemaValid(xformable)) { + return; + } bool resetsXformStack; const auto originalXformOps = xformable.GetOrderedXformOps(&resetsXformStack); @@ -268,6 +284,9 @@ void OmniGlobeAnchor::finalize() { glm::dvec3 OmniGlobeAnchor::getPrimLocalToEcefTranslation() const { const auto cesiumGlobeAnchor = UsdUtil::getCesiumGlobeAnchor(_pContext->getUsdStage(), _path); + if (!UsdUtil::isSchemaValid(cesiumGlobeAnchor)) { + return {0.0, 0.0, 0.0}; + } pxr::GfVec3d primLocalToEcefTranslation; cesiumGlobeAnchor.GetPositionAttr().Get(&primLocalToEcefTranslation); @@ -277,6 +296,9 @@ glm::dvec3 OmniGlobeAnchor::getPrimLocalToEcefTranslation() const { CesiumGeospatial::Cartographic OmniGlobeAnchor::getGeographicCoordinates() const { const auto cesiumGlobeAnchor = UsdUtil::getCesiumGlobeAnchor(_pContext->getUsdStage(), _path); + if (!UsdUtil::isSchemaValid(cesiumGlobeAnchor)) { + return {0.0, 0.0, 0.0}; + } double longitude; double latitude; @@ -291,36 +313,57 @@ CesiumGeospatial::Cartographic OmniGlobeAnchor::getGeographicCoordinates() const glm::dvec3 OmniGlobeAnchor::getPrimLocalTranslation() const { const auto cesiumGlobeAnchor = UsdUtil::getCesiumGlobeAnchor(_pContext->getUsdStage(), _path); - const auto xformable = pxr::UsdGeomXformable(cesiumGlobeAnchor.GetPrim()); + const auto xformable = pxr::UsdGeomXformable(cesiumGlobeAnchor); + if (!UsdUtil::isSchemaValid(xformable)) { + return {0.0, 0.0, 0.0}; + } + const auto xformOps = UsdUtil::getOrCreateTranslateRotateScaleOps(xformable); return UsdUtil::getTranslate(xformOps.value().translateOp); } glm::dvec3 OmniGlobeAnchor::getPrimLocalRotation() const { const auto cesiumGlobeAnchor = UsdUtil::getCesiumGlobeAnchor(_pContext->getUsdStage(), _path); - const auto xformable = pxr::UsdGeomXformable(cesiumGlobeAnchor.GetPrim()); + const auto xformable = pxr::UsdGeomXformable(cesiumGlobeAnchor); + if (!UsdUtil::isSchemaValid(xformable)) { + return {0.0, 0.0, 0.0}; + } + const auto xformOps = UsdUtil::getOrCreateTranslateRotateScaleOps(xformable); return glm::radians(UsdUtil::getRotate(xformOps.value().rotateOp)); } glm::dvec3 OmniGlobeAnchor::getPrimLocalScale() const { const auto cesiumGlobeAnchor = UsdUtil::getCesiumGlobeAnchor(_pContext->getUsdStage(), _path); - const auto xformable = pxr::UsdGeomXformable(cesiumGlobeAnchor.GetPrim()); + const auto xformable = pxr::UsdGeomXformable(cesiumGlobeAnchor); + if (!UsdUtil::isSchemaValid(xformable)) { + return {1.0, 1.0, 1.0}; + } + const auto xformOps = UsdUtil::getOrCreateTranslateRotateScaleOps(xformable); return UsdUtil::getScale(xformOps.value().scaleOp); } void OmniGlobeAnchor::savePrimLocalToEcefTranslation() { + const auto cesiumGlobeAnchor = UsdUtil::getCesiumGlobeAnchor(_pContext->getUsdStage(), _path); + if (!UsdUtil::isSchemaValid(cesiumGlobeAnchor)) { + return; + } + const auto& primLocalToEcefTransform = _pAnchor->getAnchorToFixedTransform(); const auto primLocalToEcefTranslation = glm::dvec3(primLocalToEcefTransform[3]); _cachedPrimLocalToEcefTranslation = primLocalToEcefTranslation; - const auto cesiumGlobeAnchor = UsdUtil::getCesiumGlobeAnchor(_pContext->getUsdStage(), _path); cesiumGlobeAnchor.GetPositionAttr().Set(UsdUtil::glmToUsdVector(primLocalToEcefTranslation)); } void OmniGlobeAnchor::saveGeographicCoordinates() { + const auto cesiumGlobeAnchor = UsdUtil::getCesiumGlobeAnchor(_pContext->getUsdStage(), _path); + if (!UsdUtil::isSchemaValid(cesiumGlobeAnchor)) { + return; + } + const auto pGeoreference = _pContext->getAssetRegistry().getGeoreference(getResolvedGeoreferencePath()); const auto& primLocalToEcefTransform = _pAnchor->getAnchorToFixedTransform(); const auto primLocalToEcefTranslation = glm::dvec3(primLocalToEcefTransform[3]); @@ -332,7 +375,6 @@ void OmniGlobeAnchor::saveGeographicCoordinates() { _cachedGeographicCoordinates = *cartographic; - const auto cesiumGlobeAnchor = UsdUtil::getCesiumGlobeAnchor(_pContext->getUsdStage(), _path); cesiumGlobeAnchor.GetAnchorLongitudeAttr().Set(glm::degrees(cartographic->longitude)); cesiumGlobeAnchor.GetAnchorLatitudeAttr().Set(glm::degrees(cartographic->latitude)); cesiumGlobeAnchor.GetAnchorHeightAttr().Set(cartographic->height); @@ -343,7 +385,11 @@ void OmniGlobeAnchor::savePrimLocalTransform() { // work when rotation and scale properties are double precision, which is common in Omniverse. const auto cesiumGlobeAnchor = UsdUtil::getCesiumGlobeAnchor(_pContext->getUsdStage(), _path); - const auto xformable = pxr::UsdGeomXformable(cesiumGlobeAnchor.GetPrim()); + const auto xformable = pxr::UsdGeomXformable(cesiumGlobeAnchor); + if (!UsdUtil::isSchemaValid(xformable)) { + return; + } + auto xformOps = UsdUtil::getOrCreateTranslateRotateScaleOps(xformable); auto& [translateOp, rotateOp, scaleOp, eulerAngleOrder] = xformOps.value(); diff --git a/src/core/src/OmniIonRasterOverlay.cpp b/src/core/src/OmniIonRasterOverlay.cpp index ef8564f8..14e18e5f 100644 --- a/src/core/src/OmniIonRasterOverlay.cpp +++ b/src/core/src/OmniIonRasterOverlay.cpp @@ -25,6 +25,9 @@ OmniIonRasterOverlay::OmniIonRasterOverlay(Context* pContext, const pxr::SdfPath int64_t OmniIonRasterOverlay::getIonAssetId() const { const auto cesiumIonRasterOverlay = UsdUtil::getCesiumIonRasterOverlay(_pContext->getUsdStage(), _path); + if (!UsdUtil::isSchemaValid(cesiumIonRasterOverlay)) { + return 0; + } int64_t ionAssetId; cesiumIonRasterOverlay.GetIonAssetIdAttr().Get(&ionAssetId); @@ -34,6 +37,9 @@ int64_t OmniIonRasterOverlay::getIonAssetId() const { CesiumIonClient::Token OmniIonRasterOverlay::getIonAccessToken() const { const auto cesiumIonRasterOverlay = UsdUtil::getCesiumIonRasterOverlay(_pContext->getUsdStage(), _path); + if (!UsdUtil::isSchemaValid(cesiumIonRasterOverlay)) { + return {}; + } std::string ionAccessToken; cesiumIonRasterOverlay.GetIonAccessTokenAttr().Get(&ionAccessToken); @@ -77,6 +83,9 @@ std::string OmniIonRasterOverlay::getIonApiUrl() const { pxr::SdfPath OmniIonRasterOverlay::getResolvedIonServerPath() const { const auto cesiumIonRasterOverlay = UsdUtil::getCesiumIonRasterOverlay(_pContext->getUsdStage(), _path); + if (!UsdUtil::isSchemaValid(cesiumIonRasterOverlay)) { + return {}; + } pxr::SdfPathVector targets; cesiumIonRasterOverlay.GetIonServerBindingRel().GetForwardedTargets(&targets); diff --git a/src/core/src/OmniIonServer.cpp b/src/core/src/OmniIonServer.cpp index 47a4b06a..c4d28ae3 100644 --- a/src/core/src/OmniIonServer.cpp +++ b/src/core/src/OmniIonServer.cpp @@ -29,6 +29,9 @@ std::shared_ptr OmniIonServer::getSession() const { std::string OmniIonServer::getIonServerUrl() const { const auto cesiumIonServer = UsdUtil::getCesiumIonServer(_pContext->getUsdStage(), _path); + if (!UsdUtil::isSchemaValid(cesiumIonServer)) { + return ""; + } std::string ionServerUrl; cesiumIonServer.GetIonServerUrlAttr().Get(&ionServerUrl); @@ -38,6 +41,9 @@ std::string OmniIonServer::getIonServerUrl() const { std::string OmniIonServer::getIonServerApiUrl() const { const auto cesiumIonServer = UsdUtil::getCesiumIonServer(_pContext->getUsdStage(), _path); + if (!UsdUtil::isSchemaValid(cesiumIonServer)) { + return ""; + } std::string ionServerApiUrl; cesiumIonServer.GetIonServerApiUrlAttr().Get(&ionServerApiUrl); @@ -47,6 +53,9 @@ std::string OmniIonServer::getIonServerApiUrl() const { int64_t OmniIonServer::getIonServerApplicationId() const { const auto cesiumIonServer = UsdUtil::getCesiumIonServer(_pContext->getUsdStage(), _path); + if (!UsdUtil::isSchemaValid(cesiumIonServer)) { + return 0; + } int64_t ionServerApplicationId; cesiumIonServer.GetIonServerApplicationIdAttr().Get(&ionServerApplicationId); @@ -56,6 +65,9 @@ int64_t OmniIonServer::getIonServerApplicationId() const { CesiumIonClient::Token OmniIonServer::getToken() const { const auto cesiumIonServer = UsdUtil::getCesiumIonServer(_pContext->getUsdStage(), _path); + if (!UsdUtil::isSchemaValid(cesiumIonServer)) { + return {}; + } std::string projectDefaultIonAccessToken; std::string projectDefaultIonAccessTokenId; @@ -72,6 +84,9 @@ CesiumIonClient::Token OmniIonServer::getToken() const { void OmniIonServer::setToken(const CesiumIonClient::Token& token) { const auto cesiumIonServer = UsdUtil::getCesiumIonServer(_pContext->getUsdStage(), _path); + if (!UsdUtil::isSchemaValid(cesiumIonServer)) { + return; + } cesiumIonServer.GetProjectDefaultIonAccessTokenAttr().Set(token.token); cesiumIonServer.GetProjectDefaultIonAccessTokenIdAttr().Set(token.id); diff --git a/src/core/src/OmniPolygonRasterOverlay.cpp b/src/core/src/OmniPolygonRasterOverlay.cpp index 1b6a6de9..5454196a 100644 --- a/src/core/src/OmniPolygonRasterOverlay.cpp +++ b/src/core/src/OmniPolygonRasterOverlay.cpp @@ -20,6 +20,9 @@ OmniPolygonRasterOverlay::OmniPolygonRasterOverlay(Context* pContext, const pxr: std::vector OmniPolygonRasterOverlay::getCartographicPolygonPaths() const { const auto cesiumPolygonRasterOverlay = UsdUtil::getCesiumPolygonRasterOverlay(_pContext->getUsdStage(), _path); + if (!UsdUtil::isSchemaValid(cesiumPolygonRasterOverlay)) { + return {}; + } pxr::SdfPathVector targets; cesiumPolygonRasterOverlay.GetCartographicPolygonBindingRel().GetForwardedTargets(&targets); @@ -32,7 +35,11 @@ CesiumRasterOverlays::RasterOverlay* OmniPolygonRasterOverlay::getRasterOverlay( } bool OmniPolygonRasterOverlay::getInvertSelection() const { - auto cesiumPolygonRasterOverlay = UsdUtil::getCesiumPolygonRasterOverlay(_pContext->getUsdStage(), _path); + const auto cesiumPolygonRasterOverlay = UsdUtil::getCesiumPolygonRasterOverlay(_pContext->getUsdStage(), _path); + if (!UsdUtil::isSchemaValid(cesiumPolygonRasterOverlay)) { + return false; + } + bool invertSelection; cesiumPolygonRasterOverlay.GetInvertSelectionAttr().Get(&invertSelection); return invertSelection; diff --git a/src/core/src/OmniRasterOverlay.cpp b/src/core/src/OmniRasterOverlay.cpp index 1f88958f..84a06c05 100644 --- a/src/core/src/OmniRasterOverlay.cpp +++ b/src/core/src/OmniRasterOverlay.cpp @@ -22,6 +22,9 @@ const pxr::SdfPath& OmniRasterOverlay::getPath() const { bool OmniRasterOverlay::getShowCreditsOnScreen() const { const auto cesiumRasterOverlay = UsdUtil::getCesiumRasterOverlay(_pContext->getUsdStage(), _path); + if (!UsdUtil::isSchemaValid(cesiumRasterOverlay)) { + return false; + } bool showCreditsOnScreen; cesiumRasterOverlay.GetShowCreditsOnScreenAttr().Get(&showCreditsOnScreen); @@ -31,6 +34,9 @@ bool OmniRasterOverlay::getShowCreditsOnScreen() const { double OmniRasterOverlay::getAlpha() const { const auto cesiumRasterOverlay = UsdUtil::getCesiumRasterOverlay(_pContext->getUsdStage(), _path); + if (!UsdUtil::isSchemaValid(cesiumRasterOverlay)) { + return 1.0; + } float alpha; cesiumRasterOverlay.GetAlphaAttr().Get(&alpha); @@ -40,6 +46,9 @@ double OmniRasterOverlay::getAlpha() const { FabricOverlayRenderMethod OmniRasterOverlay::getOverlayRenderMethod() const { const auto cesiumRasterOverlay = UsdUtil::getCesiumRasterOverlay(_pContext->getUsdStage(), _path); + if (!UsdUtil::isSchemaValid(cesiumRasterOverlay)) { + return FabricOverlayRenderMethod::OVERLAY; + } pxr::TfToken overlayRenderMethod; cesiumRasterOverlay.GetOverlayRenderMethodAttr().Get(&overlayRenderMethod); diff --git a/src/core/src/OmniTileset.cpp b/src/core/src/OmniTileset.cpp index ee1fdc4e..4fefe9a3 100644 --- a/src/core/src/OmniTileset.cpp +++ b/src/core/src/OmniTileset.cpp @@ -108,6 +108,9 @@ TilesetStatistics OmniTileset::getStatistics() const { TilesetSourceType OmniTileset::getSourceType() const { const auto cesiumTileset = UsdUtil::getCesiumTileset(_pContext->getUsdStage(), _path); + if (!UsdUtil::isSchemaValid(cesiumTileset)) { + return TilesetSourceType::ION; + } pxr::TfToken sourceType; cesiumTileset.GetSourceTypeAttr().Get(&sourceType); @@ -121,6 +124,9 @@ TilesetSourceType OmniTileset::getSourceType() const { std::string OmniTileset::getUrl() const { const auto cesiumTileset = UsdUtil::getCesiumTileset(_pContext->getUsdStage(), _path); + if (!UsdUtil::isSchemaValid(cesiumTileset)) { + return ""; + } std::string url; cesiumTileset.GetUrlAttr().Get(&url); @@ -130,6 +136,9 @@ std::string OmniTileset::getUrl() const { int64_t OmniTileset::getIonAssetId() const { const auto cesiumTileset = UsdUtil::getCesiumTileset(_pContext->getUsdStage(), _path); + if (!UsdUtil::isSchemaValid(cesiumTileset)) { + return 0; + } int64_t ionAssetId; cesiumTileset.GetIonAssetIdAttr().Get(&ionAssetId); @@ -139,6 +148,9 @@ int64_t OmniTileset::getIonAssetId() const { CesiumIonClient::Token OmniTileset::getIonAccessToken() const { const auto cesiumTileset = UsdUtil::getCesiumTileset(_pContext->getUsdStage(), _path); + if (!UsdUtil::isSchemaValid(cesiumTileset)) { + return {}; + } std::string ionAccessToken; cesiumTileset.GetIonAccessTokenAttr().Get(&ionAccessToken); @@ -182,6 +194,9 @@ std::string OmniTileset::getIonApiUrl() const { pxr::SdfPath OmniTileset::getResolvedIonServerPath() const { const auto cesiumTileset = UsdUtil::getCesiumTileset(_pContext->getUsdStage(), _path); + if (!UsdUtil::isSchemaValid(cesiumTileset)) { + return {}; + } pxr::SdfPathVector targets; cesiumTileset.GetIonServerBindingRel().GetForwardedTargets(&targets); @@ -201,6 +216,9 @@ pxr::SdfPath OmniTileset::getResolvedIonServerPath() const { double OmniTileset::getMaximumScreenSpaceError() const { const auto cesiumTileset = UsdUtil::getCesiumTileset(_pContext->getUsdStage(), _path); + if (!UsdUtil::isSchemaValid(cesiumTileset)) { + return 16.0; + } float maximumScreenSpaceError; cesiumTileset.GetMaximumScreenSpaceErrorAttr().Get(&maximumScreenSpaceError); @@ -210,6 +228,9 @@ double OmniTileset::getMaximumScreenSpaceError() const { bool OmniTileset::getPreloadAncestors() const { const auto cesiumTileset = UsdUtil::getCesiumTileset(_pContext->getUsdStage(), _path); + if (!UsdUtil::isSchemaValid(cesiumTileset)) { + return true; + } bool preloadAncestors; cesiumTileset.GetPreloadAncestorsAttr().Get(&preloadAncestors); @@ -219,6 +240,9 @@ bool OmniTileset::getPreloadAncestors() const { bool OmniTileset::getPreloadSiblings() const { const auto cesiumTileset = UsdUtil::getCesiumTileset(_pContext->getUsdStage(), _path); + if (!UsdUtil::isSchemaValid(cesiumTileset)) { + return true; + } bool preloadSiblings; cesiumTileset.GetPreloadSiblingsAttr().Get(&preloadSiblings); @@ -228,6 +252,9 @@ bool OmniTileset::getPreloadSiblings() const { bool OmniTileset::getForbidHoles() const { const auto cesiumTileset = UsdUtil::getCesiumTileset(_pContext->getUsdStage(), _path); + if (!UsdUtil::isSchemaValid(cesiumTileset)) { + return false; + } bool forbidHoles; cesiumTileset.GetForbidHolesAttr().Get(&forbidHoles); @@ -237,6 +264,9 @@ bool OmniTileset::getForbidHoles() const { uint32_t OmniTileset::getMaximumSimultaneousTileLoads() const { const auto cesiumTileset = UsdUtil::getCesiumTileset(_pContext->getUsdStage(), _path); + if (!UsdUtil::isSchemaValid(cesiumTileset)) { + return 20; + } uint32_t maximumSimultaneousTileLoads; cesiumTileset.GetMaximumSimultaneousTileLoadsAttr().Get(&maximumSimultaneousTileLoads); @@ -246,6 +276,9 @@ uint32_t OmniTileset::getMaximumSimultaneousTileLoads() const { uint64_t OmniTileset::getMaximumCachedBytes() const { const auto cesiumTileset = UsdUtil::getCesiumTileset(_pContext->getUsdStage(), _path); + if (!UsdUtil::isSchemaValid(cesiumTileset)) { + return 536870912; + } uint64_t maximumCachedBytes; cesiumTileset.GetMaximumCachedBytesAttr().Get(&maximumCachedBytes); @@ -255,6 +288,9 @@ uint64_t OmniTileset::getMaximumCachedBytes() const { uint32_t OmniTileset::getLoadingDescendantLimit() const { const auto cesiumTileset = UsdUtil::getCesiumTileset(_pContext->getUsdStage(), _path); + if (!UsdUtil::isSchemaValid(cesiumTileset)) { + return 20; + } uint32_t loadingDescendantLimit; cesiumTileset.GetLoadingDescendantLimitAttr().Get(&loadingDescendantLimit); @@ -264,6 +300,9 @@ uint32_t OmniTileset::getLoadingDescendantLimit() const { bool OmniTileset::getEnableFrustumCulling() const { const auto cesiumTileset = UsdUtil::getCesiumTileset(_pContext->getUsdStage(), _path); + if (!UsdUtil::isSchemaValid(cesiumTileset)) { + return true; + } bool enableFrustumCulling; cesiumTileset.GetEnableFrustumCullingAttr().Get(&enableFrustumCulling); @@ -273,6 +312,9 @@ bool OmniTileset::getEnableFrustumCulling() const { bool OmniTileset::getEnableFogCulling() const { const auto cesiumTileset = UsdUtil::getCesiumTileset(_pContext->getUsdStage(), _path); + if (!UsdUtil::isSchemaValid(cesiumTileset)) { + return true; + } bool enableFogCulling; cesiumTileset.GetEnableFogCullingAttr().Get(&enableFogCulling); @@ -282,6 +324,9 @@ bool OmniTileset::getEnableFogCulling() const { bool OmniTileset::getEnforceCulledScreenSpaceError() const { const auto cesiumTileset = UsdUtil::getCesiumTileset(_pContext->getUsdStage(), _path); + if (!UsdUtil::isSchemaValid(cesiumTileset)) { + return true; + } bool enforceCulledScreenSpaceError; cesiumTileset.GetEnforceCulledScreenSpaceErrorAttr().Get(&enforceCulledScreenSpaceError); @@ -291,6 +336,9 @@ bool OmniTileset::getEnforceCulledScreenSpaceError() const { double OmniTileset::getMainThreadLoadingTimeLimit() const { const auto cesiumTileset = UsdUtil::getCesiumTileset(_pContext->getUsdStage(), _path); + if (!UsdUtil::isSchemaValid(cesiumTileset)) { + return 0.0; + } float mainThreadLoadingTimeLimit; cesiumTileset.GetMainThreadLoadingTimeLimitAttr().Get(&mainThreadLoadingTimeLimit); @@ -300,6 +348,9 @@ double OmniTileset::getMainThreadLoadingTimeLimit() const { double OmniTileset::getCulledScreenSpaceError() const { const auto cesiumTileset = UsdUtil::getCesiumTileset(_pContext->getUsdStage(), _path); + if (!UsdUtil::isSchemaValid(cesiumTileset)) { + return 64.0; + } float culledScreenSpaceError; cesiumTileset.GetCulledScreenSpaceErrorAttr().Get(&culledScreenSpaceError); @@ -309,6 +360,9 @@ double OmniTileset::getCulledScreenSpaceError() const { bool OmniTileset::getSuspendUpdate() const { const auto cesiumTileset = UsdUtil::getCesiumTileset(_pContext->getUsdStage(), _path); + if (!UsdUtil::isSchemaValid(cesiumTileset)) { + return false; + } bool suspendUpdate; cesiumTileset.GetSuspendUpdateAttr().Get(&suspendUpdate); @@ -318,6 +372,9 @@ bool OmniTileset::getSuspendUpdate() const { bool OmniTileset::getSmoothNormals() const { const auto cesiumTileset = UsdUtil::getCesiumTileset(_pContext->getUsdStage(), _path); + if (!UsdUtil::isSchemaValid(cesiumTileset)) { + return false; + } bool smoothNormals; cesiumTileset.GetSmoothNormalsAttr().Get(&smoothNormals); @@ -327,6 +384,9 @@ bool OmniTileset::getSmoothNormals() const { bool OmniTileset::getShowCreditsOnScreen() const { const auto cesiumTileset = UsdUtil::getCesiumTileset(_pContext->getUsdStage(), _path); + if (!UsdUtil::isSchemaValid(cesiumTileset)) { + return false; + } bool showCreditsOnScreen; cesiumTileset.GetShowCreditsOnScreenAttr().Get(&showCreditsOnScreen); @@ -344,6 +404,9 @@ pxr::SdfPath OmniTileset::getResolvedGeoreferencePath() const { } const auto cesiumTileset = UsdUtil::getCesiumTileset(_pContext->getUsdStage(), _path); + if (!UsdUtil::isSchemaValid(cesiumTileset)) { + return {}; + } pxr::SdfPathVector targets; cesiumTileset.GetGeoreferenceBindingRel().GetForwardedTargets(&targets); @@ -363,8 +426,11 @@ pxr::SdfPath OmniTileset::getResolvedGeoreferencePath() const { pxr::SdfPath OmniTileset::getMaterialPath() const { const auto cesiumTileset = UsdUtil::getCesiumTileset(_pContext->getUsdStage(), _path); - const auto materialBindingApi = pxr::UsdShadeMaterialBindingAPI(cesiumTileset); + if (!UsdUtil::isSchemaValid(materialBindingApi)) { + return {}; + } + const auto materialBinding = materialBindingApi.GetDirectBinding(); const auto& materialPath = materialBinding.GetMaterialPath(); @@ -373,6 +439,9 @@ pxr::SdfPath OmniTileset::getMaterialPath() const { glm::dvec3 OmniTileset::getDisplayColor() const { const auto cesiumTileset = UsdUtil::getCesiumTileset(_pContext->getUsdStage(), _path); + if (!UsdUtil::isSchemaValid(cesiumTileset)) { + return {1.0, 1.0, 1.0}; + } pxr::VtVec3fArray displayColorArray; cesiumTileset.GetDisplayColorAttr().Get(&displayColorArray); @@ -391,6 +460,9 @@ glm::dvec3 OmniTileset::getDisplayColor() const { double OmniTileset::getDisplayOpacity() const { const auto cesiumTileset = UsdUtil::getCesiumTileset(_pContext->getUsdStage(), _path); + if (!UsdUtil::isSchemaValid(cesiumTileset)) { + return 1.0; + } pxr::VtFloatArray displayOpacityArray; cesiumTileset.GetDisplayOpacityAttr().Get(&displayOpacityArray); @@ -404,6 +476,9 @@ double OmniTileset::getDisplayOpacity() const { std::vector OmniTileset::getRasterOverlayPaths() const { const auto cesiumTileset = UsdUtil::getCesiumTileset(_pContext->getUsdStage(), _path); + if (!UsdUtil::isSchemaValid(cesiumTileset)) { + return {}; + } pxr::SdfPathVector targets; cesiumTileset.GetRasterOverlayBindingRel().GetForwardedTargets(&targets); @@ -496,7 +571,6 @@ void OmniTileset::reload() { break; } - const auto cesiumTileset = UsdUtil::getCesiumTileset(_pContext->getUsdStage(), _path); const auto boundRasterOverlayPaths = getRasterOverlayPaths(); for (const auto& boundRasterOverlayPath : boundRasterOverlayPaths) { @@ -661,6 +735,11 @@ bool OmniTileset::updateExtent() { } const auto cesiumTileset = UsdUtil::getCesiumTileset(_pContext->getUsdStage(), _path); + const auto boundable = pxr::UsdGeomBoundable(cesiumTileset); + if (!UsdUtil::isSchemaValid(boundable)) { + return false; + } + const auto& boundingVolume = pRootTile->getBoundingVolume(); const auto ecefObb = Cesium3DTilesSelection::getOrientedBoundingBoxFromBoundingVolume(boundingVolume); const auto georeferencePath = getResolvedGeoreferencePath(); @@ -676,7 +755,6 @@ bool OmniTileset::updateExtent() { UsdUtil::glmToUsdVector(glm::fvec3(topRight)), }; - const auto boundable = pxr::UsdGeomBoundable(cesiumTileset); boundable.GetExtentAttr().Set(extent); return true; } diff --git a/src/core/src/OmniWebMapServiceRasterOverlay.cpp b/src/core/src/OmniWebMapServiceRasterOverlay.cpp index 71996b48..b9b124c4 100644 --- a/src/core/src/OmniWebMapServiceRasterOverlay.cpp +++ b/src/core/src/OmniWebMapServiceRasterOverlay.cpp @@ -22,51 +22,75 @@ CesiumRasterOverlays::RasterOverlay* OmniWebMapServiceRasterOverlay::getRasterOv } std::string OmniWebMapServiceRasterOverlay::getBaseUrl() const { - auto cesiumWebMapServiceRasterOverlay = + const auto cesiumWebMapServiceRasterOverlay = UsdUtil::getCesiumWebMapServiceRasterOverlay(_pContext->getUsdStage(), _path); + if (!UsdUtil::isSchemaValid(cesiumWebMapServiceRasterOverlay)) { + return ""; + } + std::string baseUrl; cesiumWebMapServiceRasterOverlay.GetBaseUrlAttr().Get(&baseUrl); return baseUrl; } int OmniWebMapServiceRasterOverlay::getMinimumLevel() const { - auto cesiumWebMapServiceRasterOverlay = + const auto cesiumWebMapServiceRasterOverlay = UsdUtil::getCesiumWebMapServiceRasterOverlay(_pContext->getUsdStage(), _path); - int val; - cesiumWebMapServiceRasterOverlay.GetMinimumLevelAttr().Get(&val); - return val; + if (!UsdUtil::isSchemaValid(cesiumWebMapServiceRasterOverlay)) { + return 0; + } + + int minimumLevel; + cesiumWebMapServiceRasterOverlay.GetMinimumLevelAttr().Get(&minimumLevel); + return minimumLevel; } int OmniWebMapServiceRasterOverlay::getMaximumLevel() const { - auto cesiumWebMapServiceRasterOverlay = + const auto cesiumWebMapServiceRasterOverlay = UsdUtil::getCesiumWebMapServiceRasterOverlay(_pContext->getUsdStage(), _path); - int val; - cesiumWebMapServiceRasterOverlay.GetMaximumLevelAttr().Get(&val); - return val; + if (!UsdUtil::isSchemaValid(cesiumWebMapServiceRasterOverlay)) { + return 14; + } + + int maximumLevel; + cesiumWebMapServiceRasterOverlay.GetMaximumLevelAttr().Get(&maximumLevel); + return maximumLevel; } int OmniWebMapServiceRasterOverlay::getTileWidth() const { - auto cesiumWebMapServiceRasterOverlay = + const auto cesiumWebMapServiceRasterOverlay = UsdUtil::getCesiumWebMapServiceRasterOverlay(_pContext->getUsdStage(), _path); - int val; - cesiumWebMapServiceRasterOverlay.GetTileWidthAttr().Get(&val); - return val; + if (!UsdUtil::isSchemaValid(cesiumWebMapServiceRasterOverlay)) { + return 256; + } + + int tileWidth; + cesiumWebMapServiceRasterOverlay.GetTileWidthAttr().Get(&tileWidth); + return tileWidth; } int OmniWebMapServiceRasterOverlay::getTileHeight() const { - auto cesiumWebMapServiceRasterOverlay = + const auto cesiumWebMapServiceRasterOverlay = UsdUtil::getCesiumWebMapServiceRasterOverlay(_pContext->getUsdStage(), _path); - int val; - cesiumWebMapServiceRasterOverlay.GetTileHeightAttr().Get(&val); - return val; + if (!UsdUtil::isSchemaValid(cesiumWebMapServiceRasterOverlay)) { + return 256; + } + + int tileHeight; + cesiumWebMapServiceRasterOverlay.GetTileHeightAttr().Get(&tileHeight); + return tileHeight; } std::string OmniWebMapServiceRasterOverlay::getLayers() const { - auto cesiumWebMapServiceRasterOverlay = + const auto cesiumWebMapServiceRasterOverlay = UsdUtil::getCesiumWebMapServiceRasterOverlay(_pContext->getUsdStage(), _path); - std::string val; - cesiumWebMapServiceRasterOverlay.GetLayersAttr().Get(&val); - return val; + if (!UsdUtil::isSchemaValid(cesiumWebMapServiceRasterOverlay)) { + return "1"; + } + + std::string layers; + cesiumWebMapServiceRasterOverlay.GetLayersAttr().Get(&layers); + return layers; } void OmniWebMapServiceRasterOverlay::reload() { diff --git a/src/core/src/UsdNotificationHandler.cpp b/src/core/src/UsdNotificationHandler.cpp index f40edea7..ae8942bc 100644 --- a/src/core/src/UsdNotificationHandler.cpp +++ b/src/core/src/UsdNotificationHandler.cpp @@ -527,6 +527,10 @@ void processUsdShaderChanged( const pxr::SdfPath& shaderPath, const std::vector& properties) { const auto usdShader = UsdUtil::getUsdShader(context.getUsdStage(), shaderPath); + if (!UsdUtil::isSchemaValid(usdShader)) { + return; + } + const auto shaderPathFabric = FabricUtil::toFabricPath(shaderPath); const auto materialPath = shaderPath.GetParentPath(); const auto materialPathFabric = FabricUtil::toFabricPath(materialPath); diff --git a/src/core/src/UsdUtil.cpp b/src/core/src/UsdUtil.cpp index a454a6ab..98ef3374 100644 --- a/src/core/src/UsdUtil.cpp +++ b/src/core/src/UsdUtil.cpp @@ -152,12 +152,12 @@ pxr::GfMatrix4d glmToUsdMatrix(const glm::dmat4& matrix) { glm::dmat4 computePrimLocalToWorldTransform(const pxr::UsdStageWeakPtr& pStage, const pxr::SdfPath& path) { const auto prim = pStage->GetPrimAtPath(path); + const auto xform = pxr::UsdGeomXformable(prim); - if (!prim.IsA()) { + if (!isSchemaValid(xform)) { return glm::dmat4(1.0); } - const auto xform = pxr::UsdGeomXformable(prim); const auto time = pxr::UsdTimeCode::Default(); const auto transform = xform.ComputeLocalToWorldTransform(time); return usdToGlmMatrix(transform); @@ -245,15 +245,19 @@ bool primExists(const pxr::UsdStageWeakPtr& pStage, const pxr::SdfPath& path) { return pStage->GetPrimAtPath(path).IsValid(); } +bool isSchemaValid(const pxr::UsdSchemaBase& schema) { + return schema.GetSchemaKind() != pxr::UsdSchemaKind::Invalid; +} + bool isPrimVisible(const pxr::UsdStageWeakPtr& pStage, const pxr::SdfPath& path) { // This is similar to isPrimVisible in kit-sdk/dev/include/omni/usd/UsdUtils.h const auto prim = pStage->GetPrimAtPath(path); + const auto imageable = pxr::UsdGeomImageable(prim); - if (!prim.IsA()) { + if (!isSchemaValid(imageable)) { return false; } - const auto imageable = pxr::UsdGeomImageable(prim); const auto time = pxr::UsdTimeCode::Default(); const auto visibility = imageable.ComputeVisibility(time); return visibility != pxr::UsdGeomTokens->invisible; From f9bbde3f866eabbaced917e79fdc516c79182968 Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Tue, 13 Feb 2024 10:00:31 -0500 Subject: [PATCH 4/9] Revert UsdNotificationHandler changes --- src/core/src/UsdNotificationHandler.cpp | 61 ++++++++----------------- 1 file changed, 18 insertions(+), 43 deletions(-) diff --git a/src/core/src/UsdNotificationHandler.cpp b/src/core/src/UsdNotificationHandler.cpp index ae8942bc..0816073e 100644 --- a/src/core/src/UsdNotificationHandler.cpp +++ b/src/core/src/UsdNotificationHandler.cpp @@ -44,10 +44,8 @@ void updateRasterOverlayBindings(const Context& context, const pxr::SdfPath& ras // Update tilesets that reference this raster overlay for (const auto& pTileset : tilesets) { - if (UsdUtil::primExists(context.getUsdStage(), pTileset->getPath())) { - if (CppUtil::contains(pTileset->getRasterOverlayPaths(), rasterOverlayPath)) { - pTileset->reload(); - } + if (CppUtil::contains(pTileset->getRasterOverlayPaths(), rasterOverlayPath)) { + pTileset->reload(); } } } @@ -57,10 +55,8 @@ void updateRasterOverlayBindingsAlpha(const Context& context, const pxr::SdfPath // Update tilesets that reference this raster overlay for (const auto& pTileset : tilesets) { - if (UsdUtil::primExists(context.getUsdStage(), pTileset->getPath())) { - if (CppUtil::contains(pTileset->getRasterOverlayPaths(), rasterOverlayPath)) { - pTileset->updateRasterOverlayAlpha(rasterOverlayPath); - } + if (CppUtil::contains(pTileset->getRasterOverlayPaths(), rasterOverlayPath)) { + pTileset->updateRasterOverlayAlpha(rasterOverlayPath); } } } @@ -69,18 +65,14 @@ void updateIonServerBindings(const Context& context) { // Update all tilesets. Some tilesets may have referenced this ion server implicitly. const auto& tilesets = context.getAssetRegistry().getTilesets(); for (const auto& pTileset : tilesets) { - if (UsdUtil::primExists(context.getUsdStage(), pTileset->getPath())) { - pTileset->reload(); - } + pTileset->reload(); } // Update all raster overlays. Some raster overlays may have referenced this ion server implicitly. const auto& ionRasterOverlays = context.getAssetRegistry().getIonRasterOverlays(); for (const auto& pIonRasterOverlay : ionRasterOverlays) { - if (UsdUtil::primExists(context.getUsdStage(), pIonRasterOverlay->getPath())) { - pIonRasterOverlay->reload(); - updateRasterOverlayBindings(context, pIonRasterOverlay->getPath()); - } + pIonRasterOverlay->reload(); + updateRasterOverlayBindings(context, pIonRasterOverlay->getPath()); } } @@ -88,12 +80,10 @@ void updateCartographicPolygonBindings(const Context& context, const pxr::SdfPat // Update polygon raster overlays that reference this cartographic polygon const auto& polygonRasterOverlays = context.getAssetRegistry().getPolygonRasterOverlays(); for (const auto& pPolygonRasterOverlay : polygonRasterOverlays) { - if (UsdUtil::primExists(context.getUsdStage(), pPolygonRasterOverlay->getPath())) { - const auto paths = pPolygonRasterOverlay->getCartographicPolygonPaths(); - if (CppUtil::contains(paths, cartographicPolygonPath)) { - pPolygonRasterOverlay->reload(); - updateRasterOverlayBindings(context, pPolygonRasterOverlay->getPath()); - } + const auto paths = pPolygonRasterOverlay->getCartographicPolygonPaths(); + if (CppUtil::contains(paths, cartographicPolygonPath)) { + pPolygonRasterOverlay->reload(); + updateRasterOverlayBindings(context, pPolygonRasterOverlay->getPath()); } } } @@ -102,10 +92,8 @@ void updateGlobeAnchorBindings(const Context& context, const pxr::SdfPath& globe // Don't need to update tilesets. Globe anchor changes are handled automatically in the update loop. if (context.getAssetRegistry().getCartographicPolygon(globeAnchorPath)) { - if (UsdUtil::primExists(context.getUsdStage(), globeAnchorPath)) { - // Update cartographic polygon that this globe anchor is attached to - updateCartographicPolygonBindings(context, globeAnchorPath); - } + // Update cartographic polygon that this globe anchor is attached to + updateCartographicPolygonBindings(context, globeAnchorPath); } } @@ -115,10 +103,8 @@ void updateGeoreferenceBindings(const Context& context) { // Update all globe anchors. Some globe anchors may have referenced this georeference implicitly. const auto& globeAnchors = context.getAssetRegistry().getGlobeAnchors(); for (const auto& pGlobeAnchor : globeAnchors) { - if (UsdUtil::primExists(context.getUsdStage(), pGlobeAnchor->getPath())) { - pGlobeAnchor->updateByGeoreference(); - updateGlobeAnchorBindings(context, pGlobeAnchor->getPath()); - } + pGlobeAnchor->updateByGeoreference(); + updateGlobeAnchorBindings(context, pGlobeAnchor->getPath()); } } @@ -448,6 +434,7 @@ void processCesiumWebMapServiceRasterOverlayChanged( } void processCesiumGeoreferenceChanged(const Context& context, const std::vector& properties) { + auto updateBindings = false; // clang-format off @@ -527,10 +514,6 @@ void processUsdShaderChanged( const pxr::SdfPath& shaderPath, const std::vector& properties) { const auto usdShader = UsdUtil::getUsdShader(context.getUsdStage(), shaderPath); - if (!UsdUtil::isSchemaValid(usdShader)) { - return; - } - const auto shaderPathFabric = FabricUtil::toFabricPath(shaderPath); const auto materialPath = shaderPath.GetParentPath(); const auto materialPathFabric = FabricUtil::toFabricPath(materialPath); @@ -575,10 +558,8 @@ void processUsdShaderChanged( const auto& tilesets = context.getAssetRegistry().getTilesets(); for (const auto& pTileset : tilesets) { - if (UsdUtil::primExists(context.getUsdStage(), pTileset->getPath())) { - if (pTileset->getMaterialPath() == materialPath) { - pTileset->updateShaderInput(shaderPath, property); - } + if (pTileset->getMaterialPath() == materialPath) { + pTileset->updateShaderInput(shaderPath, property); } } @@ -766,12 +747,6 @@ bool UsdNotificationHandler::processChangedPrims() { ChangedPrim* pPrevious = nullptr; for (const auto& changedPrim : _changedPrims) { - if (changedPrim.changedType == ChangedType::PROPERTY_CHANGED && - !UsdUtil::primExists(_pContext->getUsdStage(), changedPrim.primPath)) { - // Don't process property changes if the prim is no longer on the stage - continue; - } - if (pPrevious && changedPrim.primPath == pPrevious->primPath) { if (pPrevious->changedType == ChangedType::PRIM_ADDED && changedPrim.changedType == ChangedType::PROPERTY_CHANGED) { From 5b05abc3e438afb48f173e4ce7c7338ed5388b0c Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Tue, 13 Feb 2024 10:07:47 -0500 Subject: [PATCH 5/9] Check prim validity --- src/core/src/UsdUtil.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/src/UsdUtil.cpp b/src/core/src/UsdUtil.cpp index 98ef3374..9765e7e3 100644 --- a/src/core/src/UsdUtil.cpp +++ b/src/core/src/UsdUtil.cpp @@ -246,7 +246,7 @@ bool primExists(const pxr::UsdStageWeakPtr& pStage, const pxr::SdfPath& path) { } bool isSchemaValid(const pxr::UsdSchemaBase& schema) { - return schema.GetSchemaKind() != pxr::UsdSchemaKind::Invalid; + return schema.GetPrim().IsValid() && schema.GetSchemaKind() != pxr::UsdSchemaKind::Invalid; } bool isPrimVisible(const pxr::UsdStageWeakPtr& pStage, const pxr::SdfPath& path) { From 5915b31d1728bf55fc692aa3b017a029c1c0c464 Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Tue, 13 Feb 2024 11:47:19 -0500 Subject: [PATCH 6/9] Update CHANGES.md --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index e9019add..b1e749f5 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,6 +7,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. +* Fixed crash when removing USD prims in certain order. ### v0.17.0 - 2024-02-01 From 4f9177017f68a4ab3c35598706f293c55eb11937 Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Tue, 13 Feb 2024 13:45:10 -0500 Subject: [PATCH 7/9] Resume ion session on reload --- CHANGES.md | 1 + src/core/src/OmniIonServer.cpp | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index e9019add..3dcfbd1a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,6 +7,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. +* Fixed issue where Cesium ion session would not resume on reload. ### v0.17.0 - 2024-02-01 diff --git a/src/core/src/OmniIonServer.cpp b/src/core/src/OmniIonServer.cpp index 47a4b06a..70c07be8 100644 --- a/src/core/src/OmniIonServer.cpp +++ b/src/core/src/OmniIonServer.cpp @@ -17,7 +17,9 @@ OmniIonServer::OmniIonServer(Context* pContext, const pxr::SdfPath& path) pContext->getHttpAssetAccessor(), getIonServerUrl(), getIonServerApiUrl(), - getIonServerApplicationId())) {} + getIonServerApplicationId())) { + _session->resume(); +} const pxr::SdfPath& OmniIonServer::getPath() const { return _path; From de2e3bec924b42d4177144d45f2eea01815e213d Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Tue, 13 Feb 2024 14:16:32 -0500 Subject: [PATCH 8/9] Remove projectDefaultIonAccessToken and projectDefaultIonAccessToken from CesiumDataPrim --- CHANGES.md | 1 + .../CesiumOmniverseCppTestsPythonBindings.pyi | 4 +- .../CesiumOmniversePythonBindings.pyi | 6 +-- .../cesium/omniverse/extension.py | 7 --- .../usd/plugins/CesiumUsdSchemas/__init__.pyi | 29 +++++------- .../schemas/cesium_schemas.usda | 16 ------- .../CesiumUsdSchemas/generatedSchema.usda.in | 10 +---- .../src/CesiumUsdSchemas/data.cpp | 36 --------------- .../src/CesiumUsdSchemas/data.h | 44 ------------------- .../src/CesiumUsdSchemas/ionRasterOverlay.h | 2 +- .../src/CesiumUsdSchemas/tokens.h | 4 +- .../src/CesiumUsdSchemas/wrapData.cpp | 28 ------------ 12 files changed, 18 insertions(+), 169 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index e9019add..f9d39cac 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,6 +2,7 @@ ### v0.18.0 - 2024-03-01 +* **Breaking change:** removed deprecated properties `projectDefaultIonAccessToken` and `projectDefaultIonAccessToken` from `CesiumDataPrim`. `CesiumIonServerPrim` should be used instead. * Added support for globe anchors on non-georeferenced tilesets. * Fixed zooming to tileset extents when tileset prims have non identity transformation. * Fixed crash when updating tilesets shader inputs. diff --git a/exts/cesium.omniverse.cpp.tests/cesium/omniverse/cpp/tests/bindings/CesiumOmniverseCppTestsPythonBindings.pyi b/exts/cesium.omniverse.cpp.tests/cesium/omniverse/cpp/tests/bindings/CesiumOmniverseCppTestsPythonBindings.pyi index 8f84e483..dce8a63b 100644 --- a/exts/cesium.omniverse.cpp.tests/cesium/omniverse/cpp/tests/bindings/CesiumOmniverseCppTestsPythonBindings.pyi +++ b/exts/cesium.omniverse.cpp.tests/cesium/omniverse/cpp/tests/bindings/CesiumOmniverseCppTestsPythonBindings.pyi @@ -5,7 +5,5 @@ class ICesiumOmniverseCppTestsInterface: def run_all_tests(self) -> None: ... def set_up_tests(self, arg0: int) -> None: ... -def acquire_cesium_omniverse_tests_interface( - plugin_name: str = ..., library_path: str = ... -) -> ICesiumOmniverseCppTestsInterface: ... +def acquire_cesium_omniverse_tests_interface(plugin_name: str = ..., library_path: str = ...) -> ICesiumOmniverseCppTestsInterface: ... def release_cesium_omniverse_tests_interface(arg0: ICesiumOmniverseCppTestsInterface) -> None: ... diff --git a/exts/cesium.omniverse/cesium/omniverse/bindings/CesiumOmniversePythonBindings.pyi b/exts/cesium.omniverse/cesium/omniverse/bindings/CesiumOmniversePythonBindings.pyi index 4385f1fb..9245409d 100644 --- a/exts/cesium.omniverse/cesium/omniverse/bindings/CesiumOmniversePythonBindings.pyi +++ b/exts/cesium.omniverse/cesium/omniverse/bindings/CesiumOmniversePythonBindings.pyi @@ -71,7 +71,7 @@ class ICesiumOmniverseInterface: def credits_start_next_frame(self) -> None: ... def get_asset_token_troubleshooting_details(self, *args, **kwargs) -> Any: ... def get_asset_troubleshooting_details(self, *args, **kwargs) -> Any: ... - def get_credits(self) -> List[Tuple[str, bool]]: ... + def get_credits(self) -> List[Tuple[str,bool]]: ... def get_default_token_troubleshooting_details(self, *args, **kwargs) -> Any: ... def get_render_statistics(self, *args, **kwargs) -> Any: ... def get_server_path(self) -> str: ... @@ -174,7 +174,5 @@ class Viewport: width: float def __init__(self) -> None: ... -def acquire_cesium_omniverse_interface( - plugin_name: str = ..., library_path: str = ... -) -> ICesiumOmniverseInterface: ... +def acquire_cesium_omniverse_interface(plugin_name: str = ..., library_path: str = ...) -> ICesiumOmniverseInterface: ... def release_cesium_omniverse_interface(arg0: ICesiumOmniverseInterface) -> None: ... diff --git a/exts/cesium.omniverse/cesium/omniverse/extension.py b/exts/cesium.omniverse/cesium/omniverse/extension.py index 79dc7f40..3db98c59 100644 --- a/exts/cesium.omniverse/cesium/omniverse/extension.py +++ b/exts/cesium.omniverse/cesium/omniverse/extension.py @@ -498,10 +498,3 @@ def _setup_ion_server_prims(self): data_prim: CesiumData = CesiumData.Get(stage, CESIUM_DATA_PRIM_PATH) data_prim.GetSelectedIonServerRel().AddTarget(path) - - # For backwards compatibility. Add access token from CesiumData prim. - defaultAccessToken = data_prim.GetProjectDefaultIonAccessTokenAttr().Get() - defaultAccessTokenId = data_prim.GetProjectDefaultIonAccessTokenIdAttr().Get() - - prim.GetProjectDefaultIonAccessTokenAttr().Set(defaultAccessToken) - prim.GetProjectDefaultIonAccessTokenIdAttr().Set(defaultAccessTokenId) diff --git a/exts/cesium.usd.plugins/cesium/usd/plugins/CesiumUsdSchemas/__init__.pyi b/exts/cesium.usd.plugins/cesium/usd/plugins/CesiumUsdSchemas/__init__.pyi index c519ba08..068c55af 100644 --- a/exts/cesium.usd.plugins/cesium/usd/plugins/CesiumUsdSchemas/__init__.pyi +++ b/exts/cesium.usd.plugins/cesium/usd/plugins/CesiumUsdSchemas/__init__.pyi @@ -3,7 +3,6 @@ from typing import Any, ClassVar import Boost.Python import pxr.Usd import pxr.UsdGeom - __MFB_FULL_PACKAGE_NAME: str class Data(pxr.Usd.Typed): @@ -31,10 +30,6 @@ class Data(pxr.Usd.Typed): @classmethod def CreateDebugTexturePoolInitialCapacityAttr(cls, *args, **kwargs) -> Any: ... @classmethod - def CreateProjectDefaultIonAccessTokenAttr(cls, *args, **kwargs) -> Any: ... - @classmethod - def CreateProjectDefaultIonAccessTokenIdAttr(cls, *args, **kwargs) -> Any: ... - @classmethod def CreateSelectedIonServerRel(cls, *args, **kwargs) -> Any: ... @classmethod def Define(cls, *args, **kwargs) -> Any: ... @@ -61,10 +56,6 @@ class Data(pxr.Usd.Typed): @classmethod def GetDebugTexturePoolInitialCapacityAttr(cls, *args, **kwargs) -> Any: ... @classmethod - def GetProjectDefaultIonAccessTokenAttr(cls, *args, **kwargs) -> Any: ... - @classmethod - def GetProjectDefaultIonAccessTokenIdAttr(cls, *args, **kwargs) -> Any: ... - @classmethod def GetSchemaAttributeNames(cls, *args, **kwargs) -> Any: ... @classmethod def GetSelectedIonServerRel(cls, *args, **kwargs) -> Any: ... @@ -471,8 +462,6 @@ class Tokens(Boost.Python.instance): @property def cesiumGeoreferenceOriginLongitude(self) -> Any: ... @property - def cesiumHeight(self) -> Any: ... - @property def cesiumInvertSelection(self) -> Any: ... @property def cesiumIonAccessToken(self) -> Any: ... @@ -525,9 +514,11 @@ class Tokens(Boost.Python.instance): @property def cesiumSuspendUpdate(self) -> Any: ... @property - def cesiumUrl(self) -> Any: ... + def cesiumTileHeight(self) -> Any: ... @property - def cesiumWidth(self) -> Any: ... + def cesiumTileWidth(self) -> Any: ... + @property + def cesiumUrl(self) -> Any: ... @property def clip(self) -> Any: ... @property @@ -544,15 +535,15 @@ class WebMapServiceRasterOverlay(RasterOverlay): @classmethod def CreateBaseUrlAttr(cls, *args, **kwargs) -> Any: ... @classmethod - def CreateHeightAttr(cls, *args, **kwargs) -> Any: ... - @classmethod def CreateLayersAttr(cls, *args, **kwargs) -> Any: ... @classmethod def CreateMaximumLevelAttr(cls, *args, **kwargs) -> Any: ... @classmethod def CreateMinimumLevelAttr(cls, *args, **kwargs) -> Any: ... @classmethod - def CreateWidthAttr(cls, *args, **kwargs) -> Any: ... + def CreateTileHeightAttr(cls, *args, **kwargs) -> Any: ... + @classmethod + def CreateTileWidthAttr(cls, *args, **kwargs) -> Any: ... @classmethod def Define(cls, *args, **kwargs) -> Any: ... @classmethod @@ -560,8 +551,6 @@ class WebMapServiceRasterOverlay(RasterOverlay): @classmethod def GetBaseUrlAttr(cls, *args, **kwargs) -> Any: ... @classmethod - def GetHeightAttr(cls, *args, **kwargs) -> Any: ... - @classmethod def GetLayersAttr(cls, *args, **kwargs) -> Any: ... @classmethod def GetMaximumLevelAttr(cls, *args, **kwargs) -> Any: ... @@ -570,7 +559,9 @@ class WebMapServiceRasterOverlay(RasterOverlay): @classmethod def GetSchemaAttributeNames(cls, *args, **kwargs) -> Any: ... @classmethod - def GetWidthAttr(cls, *args, **kwargs) -> Any: ... + def GetTileHeightAttr(cls, *args, **kwargs) -> Any: ... + @classmethod + def GetTileWidthAttr(cls, *args, **kwargs) -> Any: ... @classmethod def _GetStaticTfType(cls, *args, **kwargs) -> Any: ... @classmethod diff --git a/exts/cesium.usd.plugins/schemas/cesium_schemas.usda b/exts/cesium.usd.plugins/schemas/cesium_schemas.usda index 98c947cf..1612f17f 100644 --- a/exts/cesium.usd.plugins/schemas/cesium_schemas.usda +++ b/exts/cesium.usd.plugins/schemas/cesium_schemas.usda @@ -34,22 +34,6 @@ class CesiumDataPrim "CesiumDataPrim" ( doc = "The current ion Server prim used in the Cesium for Omniverse UI." ) - string cesium:projectDefaultIonAccessToken = "" ( - customData = { - string apiName = "projectDefaultIonAccessToken" - } - displayName = "Project default ion Access Token" - doc = "DEPRECATED: A string representing the token for accessing Cesium ion assets. Moved to CesiumIonServerPrim. Will be removed in a future version." - ) - - string cesium:projectDefaultIonAccessTokenId = "" ( - customData = { - string apiName = "projectDefaultIonAccessTokenId" - } - displayName = "Project default ion Access Token ID" - doc = "DEPRECATED: A string representing the token ID for accessing Cesium ion assets. Moved to CesiumIonServerPrim. Will be removed in a future version." - ) - bool cesium:debug:disableMaterials = false ( customData = { string apiName = "debugDisableMaterials" diff --git a/src/plugins/CesiumUsdSchemas/generatedSchema.usda.in b/src/plugins/CesiumUsdSchemas/generatedSchema.usda.in index b102945a..9cc6a15b 100644 --- a/src/plugins/CesiumUsdSchemas/generatedSchema.usda.in +++ b/src/plugins/CesiumUsdSchemas/generatedSchema.usda.in @@ -47,14 +47,6 @@ class CesiumDataPrim "CesiumDataPrim" ( displayName = "Texture Pool Initial Capacity" doc = "Debug option that controls the initial capacity of the texture pool." ) - string cesium:projectDefaultIonAccessToken = "" ( - displayName = "Project default ion Access Token" - doc = "DEPRECATED: A string representing the token for accessing Cesium ion assets. Moved to CesiumIonServerPrim. Will be removed in a future version." - ) - string cesium:projectDefaultIonAccessTokenId = "" ( - displayName = "Project default ion Access Token ID" - doc = "DEPRECATED: A string representing the token ID for accessing Cesium ion assets. Moved to CesiumIonServerPrim. Will be removed in a future version." - ) rel cesium:selectedIonServer ( displayName = "Selected ion Server context" doc = "The current ion Server prim used in the Cesium for Omniverse UI." @@ -343,7 +335,7 @@ class "CesiumRasterOverlayPrim" ( } class CesiumIonRasterOverlayPrim "CesiumIonRasterOverlayPrim" ( - doc = "Adds a prim for representing an Ion raster overlay." + doc = "Adds a prim for representing an ion raster overlay." ) { float cesium:alpha = 1 ( diff --git a/src/plugins/CesiumUsdSchemas/src/CesiumUsdSchemas/data.cpp b/src/plugins/CesiumUsdSchemas/src/CesiumUsdSchemas/data.cpp index 73e7e8fd..329a9fe6 100644 --- a/src/plugins/CesiumUsdSchemas/src/CesiumUsdSchemas/data.cpp +++ b/src/plugins/CesiumUsdSchemas/src/CesiumUsdSchemas/data.cpp @@ -80,40 +80,6 @@ CesiumData::_GetTfType() const return _GetStaticTfType(); } -UsdAttribute -CesiumData::GetProjectDefaultIonAccessTokenAttr() const -{ - return GetPrim().GetAttribute(CesiumTokens->cesiumProjectDefaultIonAccessToken); -} - -UsdAttribute -CesiumData::CreateProjectDefaultIonAccessTokenAttr(VtValue const &defaultValue, bool writeSparsely) const -{ - return UsdSchemaBase::_CreateAttr(CesiumTokens->cesiumProjectDefaultIonAccessToken, - SdfValueTypeNames->String, - /* custom = */ false, - SdfVariabilityVarying, - defaultValue, - writeSparsely); -} - -UsdAttribute -CesiumData::GetProjectDefaultIonAccessTokenIdAttr() const -{ - return GetPrim().GetAttribute(CesiumTokens->cesiumProjectDefaultIonAccessTokenId); -} - -UsdAttribute -CesiumData::CreateProjectDefaultIonAccessTokenIdAttr(VtValue const &defaultValue, bool writeSparsely) const -{ - return UsdSchemaBase::_CreateAttr(CesiumTokens->cesiumProjectDefaultIonAccessTokenId, - SdfValueTypeNames->String, - /* custom = */ false, - SdfVariabilityVarying, - defaultValue, - writeSparsely); -} - UsdAttribute CesiumData::GetDebugDisableMaterialsAttr() const { @@ -314,8 +280,6 @@ const TfTokenVector& CesiumData::GetSchemaAttributeNames(bool includeInherited) { static TfTokenVector localNames = { - CesiumTokens->cesiumProjectDefaultIonAccessToken, - CesiumTokens->cesiumProjectDefaultIonAccessTokenId, CesiumTokens->cesiumDebugDisableMaterials, CesiumTokens->cesiumDebugDisableTextures, CesiumTokens->cesiumDebugDisableGeometryPool, diff --git a/src/plugins/CesiumUsdSchemas/src/CesiumUsdSchemas/data.h b/src/plugins/CesiumUsdSchemas/src/CesiumUsdSchemas/data.h index 9468d237..9dbaf143 100644 --- a/src/plugins/CesiumUsdSchemas/src/CesiumUsdSchemas/data.h +++ b/src/plugins/CesiumUsdSchemas/src/CesiumUsdSchemas/data.h @@ -125,50 +125,6 @@ class CesiumData : public UsdTyped CESIUMUSDSCHEMAS_API const TfType &_GetTfType() const override; -public: - // --------------------------------------------------------------------- // - // PROJECTDEFAULTIONACCESSTOKEN - // --------------------------------------------------------------------- // - /// DEPRECATED: A string representing the token for accessing Cesium ion assets. Moved to CesiumIonServerPrim. Will be removed in a future version. - /// - /// | || - /// | -- | -- | - /// | Declaration | `string cesium:projectDefaultIonAccessToken = ""` | - /// | C++ Type | std::string | - /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->String | - CESIUMUSDSCHEMAS_API - UsdAttribute GetProjectDefaultIonAccessTokenAttr() const; - - /// See GetProjectDefaultIonAccessTokenAttr(), 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 CreateProjectDefaultIonAccessTokenAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const; - -public: - // --------------------------------------------------------------------- // - // PROJECTDEFAULTIONACCESSTOKENID - // --------------------------------------------------------------------- // - /// DEPRECATED: A string representing the token ID for accessing Cesium ion assets. Moved to CesiumIonServerPrim. Will be removed in a future version. - /// - /// | || - /// | -- | -- | - /// | Declaration | `string cesium:projectDefaultIonAccessTokenId = ""` | - /// | C++ Type | std::string | - /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->String | - CESIUMUSDSCHEMAS_API - UsdAttribute GetProjectDefaultIonAccessTokenIdAttr() const; - - /// See GetProjectDefaultIonAccessTokenIdAttr(), 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 CreateProjectDefaultIonAccessTokenIdAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const; - public: // --------------------------------------------------------------------- // // DEBUGDISABLEMATERIALS diff --git a/src/plugins/CesiumUsdSchemas/src/CesiumUsdSchemas/ionRasterOverlay.h b/src/plugins/CesiumUsdSchemas/src/CesiumUsdSchemas/ionRasterOverlay.h index b6a4f946..80a590fb 100644 --- a/src/plugins/CesiumUsdSchemas/src/CesiumUsdSchemas/ionRasterOverlay.h +++ b/src/plugins/CesiumUsdSchemas/src/CesiumUsdSchemas/ionRasterOverlay.h @@ -29,7 +29,7 @@ class SdfAssetPath; /// \class CesiumIonRasterOverlay /// -/// Adds a prim for representing an Ion raster overlay. +/// Adds a prim for representing an ion raster overlay. /// class CesiumIonRasterOverlay : public CesiumRasterOverlay { diff --git a/src/plugins/CesiumUsdSchemas/src/CesiumUsdSchemas/tokens.h b/src/plugins/CesiumUsdSchemas/src/CesiumUsdSchemas/tokens.h index ce48fa09..fd5f669d 100644 --- a/src/plugins/CesiumUsdSchemas/src/CesiumUsdSchemas/tokens.h +++ b/src/plugins/CesiumUsdSchemas/src/CesiumUsdSchemas/tokens.h @@ -237,11 +237,11 @@ struct CesiumTokensType { const TfToken cesiumPreloadSiblings; /// \brief "cesium:projectDefaultIonAccessToken" /// - /// CesiumIonServer, CesiumData + /// CesiumIonServer const TfToken cesiumProjectDefaultIonAccessToken; /// \brief "cesium:projectDefaultIonAccessTokenId" /// - /// CesiumIonServer, CesiumData + /// CesiumIonServer const TfToken cesiumProjectDefaultIonAccessTokenId; /// \brief "cesium:rasterOverlayBinding" /// diff --git a/src/plugins/CesiumUsdSchemas/src/CesiumUsdSchemas/wrapData.cpp b/src/plugins/CesiumUsdSchemas/src/CesiumUsdSchemas/wrapData.cpp index 711e8276..6bdae671 100644 --- a/src/plugins/CesiumUsdSchemas/src/CesiumUsdSchemas/wrapData.cpp +++ b/src/plugins/CesiumUsdSchemas/src/CesiumUsdSchemas/wrapData.cpp @@ -26,20 +26,6 @@ namespace { WRAP_CUSTOM; -static UsdAttribute -_CreateProjectDefaultIonAccessTokenAttr(CesiumData &self, - object defaultVal, bool writeSparsely) { - return self.CreateProjectDefaultIonAccessTokenAttr( - UsdPythonToSdfType(defaultVal, SdfValueTypeNames->String), writeSparsely); -} - -static UsdAttribute -_CreateProjectDefaultIonAccessTokenIdAttr(CesiumData &self, - object defaultVal, bool writeSparsely) { - return self.CreateProjectDefaultIonAccessTokenIdAttr( - UsdPythonToSdfType(defaultVal, SdfValueTypeNames->String), writeSparsely); -} - static UsdAttribute _CreateDebugDisableMaterialsAttr(CesiumData &self, object defaultVal, bool writeSparsely) { @@ -152,20 +138,6 @@ void wrapCesiumData() .def(!self) - .def("GetProjectDefaultIonAccessTokenAttr", - &This::GetProjectDefaultIonAccessTokenAttr) - .def("CreateProjectDefaultIonAccessTokenAttr", - &_CreateProjectDefaultIonAccessTokenAttr, - (arg("defaultValue")=object(), - arg("writeSparsely")=false)) - - .def("GetProjectDefaultIonAccessTokenIdAttr", - &This::GetProjectDefaultIonAccessTokenIdAttr) - .def("CreateProjectDefaultIonAccessTokenIdAttr", - &_CreateProjectDefaultIonAccessTokenIdAttr, - (arg("defaultValue")=object(), - arg("writeSparsely")=false)) - .def("GetDebugDisableMaterialsAttr", &This::GetDebugDisableMaterialsAttr) .def("CreateDebugDisableMaterialsAttr", From 9cd8a8305be4f9b068b53913d247e6f481bd94eb Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Tue, 13 Feb 2024 18:22:52 -0500 Subject: [PATCH 9/9] Make sure to use correct black version in genStubs --- .../bindings/CesiumOmniverseCppTestsPythonBindings.pyi | 4 +++- .../bindings/CesiumOmniversePythonBindings.pyi | 6 ++++-- .../cesium/usd/plugins/CesiumUsdSchemas/__init__.pyi | 1 + genStubs.bat | 10 +++++----- genStubs.sh | 10 +++++----- 5 files changed, 18 insertions(+), 13 deletions(-) diff --git a/exts/cesium.omniverse.cpp.tests/cesium/omniverse/cpp/tests/bindings/CesiumOmniverseCppTestsPythonBindings.pyi b/exts/cesium.omniverse.cpp.tests/cesium/omniverse/cpp/tests/bindings/CesiumOmniverseCppTestsPythonBindings.pyi index dce8a63b..8f84e483 100644 --- a/exts/cesium.omniverse.cpp.tests/cesium/omniverse/cpp/tests/bindings/CesiumOmniverseCppTestsPythonBindings.pyi +++ b/exts/cesium.omniverse.cpp.tests/cesium/omniverse/cpp/tests/bindings/CesiumOmniverseCppTestsPythonBindings.pyi @@ -5,5 +5,7 @@ class ICesiumOmniverseCppTestsInterface: def run_all_tests(self) -> None: ... def set_up_tests(self, arg0: int) -> None: ... -def acquire_cesium_omniverse_tests_interface(plugin_name: str = ..., library_path: str = ...) -> ICesiumOmniverseCppTestsInterface: ... +def acquire_cesium_omniverse_tests_interface( + plugin_name: str = ..., library_path: str = ... +) -> ICesiumOmniverseCppTestsInterface: ... def release_cesium_omniverse_tests_interface(arg0: ICesiumOmniverseCppTestsInterface) -> None: ... diff --git a/exts/cesium.omniverse/cesium/omniverse/bindings/CesiumOmniversePythonBindings.pyi b/exts/cesium.omniverse/cesium/omniverse/bindings/CesiumOmniversePythonBindings.pyi index 9245409d..4385f1fb 100644 --- a/exts/cesium.omniverse/cesium/omniverse/bindings/CesiumOmniversePythonBindings.pyi +++ b/exts/cesium.omniverse/cesium/omniverse/bindings/CesiumOmniversePythonBindings.pyi @@ -71,7 +71,7 @@ class ICesiumOmniverseInterface: def credits_start_next_frame(self) -> None: ... def get_asset_token_troubleshooting_details(self, *args, **kwargs) -> Any: ... def get_asset_troubleshooting_details(self, *args, **kwargs) -> Any: ... - def get_credits(self) -> List[Tuple[str,bool]]: ... + def get_credits(self) -> List[Tuple[str, bool]]: ... def get_default_token_troubleshooting_details(self, *args, **kwargs) -> Any: ... def get_render_statistics(self, *args, **kwargs) -> Any: ... def get_server_path(self) -> str: ... @@ -174,5 +174,7 @@ class Viewport: width: float def __init__(self) -> None: ... -def acquire_cesium_omniverse_interface(plugin_name: str = ..., library_path: str = ...) -> ICesiumOmniverseInterface: ... +def acquire_cesium_omniverse_interface( + plugin_name: str = ..., library_path: str = ... +) -> ICesiumOmniverseInterface: ... def release_cesium_omniverse_interface(arg0: ICesiumOmniverseInterface) -> None: ... diff --git a/exts/cesium.usd.plugins/cesium/usd/plugins/CesiumUsdSchemas/__init__.pyi b/exts/cesium.usd.plugins/cesium/usd/plugins/CesiumUsdSchemas/__init__.pyi index 068c55af..3fb07134 100644 --- a/exts/cesium.usd.plugins/cesium/usd/plugins/CesiumUsdSchemas/__init__.pyi +++ b/exts/cesium.usd.plugins/cesium/usd/plugins/CesiumUsdSchemas/__init__.pyi @@ -3,6 +3,7 @@ from typing import Any, ClassVar import Boost.Python import pxr.Usd import pxr.UsdGeom + __MFB_FULL_PACKAGE_NAME: str class Data(pxr.Usd.Typed): diff --git a/genStubs.bat b/genStubs.bat index 9358897d..d6f0b07b 100644 --- a/genStubs.bat +++ b/genStubs.bat @@ -22,8 +22,8 @@ set CESIUM_TESTS_STUB_PATH=%PROJECT_ROOT%\exts\cesium.omniverse.cpp.tests\cesium set PYTHONPATH=%NVIDIA_USD_PYTHON_LIBS%;%PYTHONPATH% -echo "Ensuring mypy is installed" -%NVIDIA_PYTHON_EXECUTABLE% -m pip install mypy==1.6.1 +echo "Ensuring mypy and black are installed" +%NVIDIA_PYTHON_EXECUTABLE% -m pip install mypy==1.6.1 black==23.1.0 echo "Building lib files flat in temp dir" cmake -B build-stubs @@ -45,9 +45,9 @@ copy out\_CesiumUsdSchemas.pyi %CESIUM_USD_STUB_PATH% copy out\CesiumOmniverseCppTestsPythonBindings.pyi %CESIUM_TESTS_STUB_PATH% echo "Formatting stubs" -black %CESIUM_OMNI_STUB_PATH% -black %CESIUM_USD_STUB_PATH% -black %CESIUM_TESTS_STUB_PATH% +%NVIDIA_PYTHON_EXECUTABLE% -m black %CESIUM_OMNI_STUB_PATH% +%NVIDIA_PYTHON_EXECUTABLE% -m black %CESIUM_USD_STUB_PATH% +%NVIDIA_PYTHON_EXECUTABLE% -m black %CESIUM_TESTS_STUB_PATH% echo "Cleaning up temp dir" cd %PROJECT_ROOT% diff --git a/genStubs.sh b/genStubs.sh index ed1d7a34..7bbfb5d4 100755 --- a/genStubs.sh +++ b/genStubs.sh @@ -22,8 +22,8 @@ CESIUM_TESTS_STUB_PATH="$PROJECT_ROOT/exts/cesium.omniverse.cpp.tests/cesium/omn export PYTHONPATH="$NVIDIA_USD_PYTHON_LIBS:$PYTHONPATH" -echo "Ensuring mypy is installed" -$NVIDIA_PYTHON_EXECUTABLE -m pip install mypy==1.6.1 +echo "Ensuring mypy and black are installed" +$NVIDIA_PYTHON_EXECUTABLE -m pip install mypy==1.6.1 black==23.1.0 echo "Building lib files flat in temp dir" cmake -B build @@ -45,9 +45,9 @@ cp "out/_CesiumUsdSchemas.pyi" $CESIUM_USD_STUB_PATH cp "out/CesiumOmniverseCppTestsPythonBindings.pyi" $CESIUM_TESTS_STUB_PATH echo "Formatting stubs" -black $CESIUM_OMNI_STUB_PATH -black $CESIUM_USD_STUB_PATH -black $CESIUM_TESTS_STUB_PATH +$NVIDIA_PYTHON_EXECUTABLE -m black $CESIUM_OMNI_STUB_PATH +$NVIDIA_PYTHON_EXECUTABLE -m black $CESIUM_USD_STUB_PATH +$NVIDIA_PYTHON_EXECUTABLE -m black $CESIUM_TESTS_STUB_PATH echo "Cleaning up temp dir" rm -rf $FLAT_LIBRARIES_DIR