Skip to content

Commit

Permalink
Merge branch 'main' into movie-capture-load-tiles
Browse files Browse the repository at this point in the history
  • Loading branch information
lilleyse authored Feb 14, 2024
2 parents 98b74fb + 164c163 commit 1a3b800
Show file tree
Hide file tree
Showing 13 changed files with 276 additions and 39 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* 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.
* Fixed issue where Cesium ion session would not resume on reload.
* The movie capture tool now waits for tilesets to complete loading before it captures a frame.

### v0.17.0 - 2024-02-01
Expand Down
2 changes: 2 additions & 0 deletions src/core/include/cesium/omniverse/UsdUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
3 changes: 3 additions & 0 deletions src/core/src/OmniCartographicPolygon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ std::vector<CesiumGeospatial::Cartographic> OmniCartographicPolygon::getCartogra
}

const auto cesiumCartographicPolygon = UsdUtil::getCesiumCartographicPolygon(_pContext->getUsdStage(), _path);
if (!UsdUtil::isSchemaValid(cesiumCartographicPolygon)) {
return {};
}

pxr::VtArray<pxr::GfVec3f> points;
cesiumCartographicPolygon.GetPointsAttr().Get(&points);
Expand Down
33 changes: 33 additions & 0 deletions src/core/src/OmniData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions src/core/src/OmniGeoreference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
64 changes: 55 additions & 9 deletions src/core/src/OmniGlobeAnchor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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) {
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand All @@ -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]);
Expand All @@ -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);
Expand All @@ -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();
Expand Down
9 changes: 9 additions & 0 deletions src/core/src/OmniIonRasterOverlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
Loading

0 comments on commit 1a3b800

Please sign in to comment.