From 04fe5459a24b746707c1347fc91d59f99bf1c04b Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Tue, 7 May 2024 11:20:21 -0400 Subject: [PATCH] Fix crash when setting globe anchor attributes when georefencing is disabled --- src/core/include/cesium/omniverse/UsdUtil.h | 2 ++ src/core/src/OmniGlobeAnchor.cpp | 4 ++++ src/core/src/UsdUtil.cpp | 22 +++++++++------------ 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/core/include/cesium/omniverse/UsdUtil.h b/src/core/include/cesium/omniverse/UsdUtil.h index 1ee37d78..4b742563 100644 --- a/src/core/include/cesium/omniverse/UsdUtil.h +++ b/src/core/include/cesium/omniverse/UsdUtil.h @@ -168,4 +168,6 @@ struct TranslateRotateScaleOps { std::optional getOrCreateTranslateRotateScaleOps(const pxr::UsdGeomXformable& xformable); +bool getDebugDisableGeoreferencing(const Context& context); + }; // namespace cesium::omniverse::UsdUtil diff --git a/src/core/src/OmniGlobeAnchor.cpp b/src/core/src/OmniGlobeAnchor.cpp index ac1e4170..07eb7df2 100644 --- a/src/core/src/OmniGlobeAnchor.cpp +++ b/src/core/src/OmniGlobeAnchor.cpp @@ -235,6 +235,10 @@ bool OmniGlobeAnchor::isAnchorValid() const { return false; } + if (UsdUtil::getDebugDisableGeoreferencing(*_pContext)) { + return false; + } + return true; } diff --git a/src/core/src/UsdUtil.cpp b/src/core/src/UsdUtil.cpp index 2017d46e..23f71a85 100644 --- a/src/core/src/UsdUtil.cpp +++ b/src/core/src/UsdUtil.cpp @@ -50,19 +50,6 @@ namespace cesium::omniverse::UsdUtil { -namespace { - -bool getDebugDisableGeoreferencing(const Context& context) { - const auto pData = context.getAssetRegistry().getFirstData(); - if (!pData) { - return false; - } - - return pData->getDebugDisableGeoreferencing(); -} - -} // namespace - glm::dvec3 usdToGlmVector(const pxr::GfVec3d& vector) { return {vector[0], vector[1], vector[2]}; } @@ -803,4 +790,13 @@ std::optional getOrCreateTranslateRotateScaleOps(const return TranslateRotateScaleOps{translateOp, rotateOp, scaleOp, eulerAngleOrder}; } +bool getDebugDisableGeoreferencing(const Context& context) { + const auto pData = context.getAssetRegistry().getFirstData(); + if (!pData) { + return false; + } + + return pData->getDebugDisableGeoreferencing(); +} + } // namespace cesium::omniverse::UsdUtil