From 6e93948d33b4aa050168852aee2725846cfe6f51 Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Mon, 16 Sep 2024 20:58:12 -0400 Subject: [PATCH] Revert _localTransform change --- src/core/include/cesium/omniverse/UsdTokens.h | 6 ++--- src/core/src/FabricGeometry.cpp | 23 +++++++++---------- src/core/src/FabricUtil.cpp | 9 ++++---- 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/src/core/include/cesium/omniverse/UsdTokens.h b/src/core/include/cesium/omniverse/UsdTokens.h index b7c90093..6d7c1b94 100644 --- a/src/core/include/cesium/omniverse/UsdTokens.h +++ b/src/core/include/cesium/omniverse/UsdTokens.h @@ -82,6 +82,7 @@ __pragma(warning(push)) __pragma(warning(disable : 4003)) (subdivisionScheme) \ (vertex) \ (vertexId) \ + (_cesium_gltfLocalToEcefTransform) \ (_cesium_tilesetId) \ (_deletedPrims) \ (_materialSource) \ @@ -130,6 +131,7 @@ __pragma(warning(push)) __pragma(warning(disable : 4003)) ((inputs_wrap_s, "inputs:wrap_s")) \ ((inputs_wrap_t, "inputs:wrap_t")) \ ((material_binding, "material:binding")) \ + ((omni_fabric_worldMatrix, "omni:fabric:worldMatrix")) \ ((outputs_mdl_displacement, "outputs:mdl:displacement")) \ ((outputs_mdl_surface, "outputs:mdl:surface")) \ ((outputs_mdl_volume, "outputs:mdl:volume")) \ @@ -148,8 +150,6 @@ __pragma(warning(push)) __pragma(warning(disable : 4003)) ((xformOp_rotateZYX, "xformOp:rotateZYX")) \ ((xformOp_scale, "xformOp:scale")) \ ((xformOp_translate, "xformOp:translate")) \ - ((_localMatrix, "omni:fabric:localMatrix")) \ - ((_worldMatrix, "omni:fabric:worldMatrix")) \ ((_auto, "auto")) #ifdef CESIUM_OMNI_CLANG @@ -272,13 +272,13 @@ const omni::fabric::Type primvars_st(omni::fabric::BaseDataType::eFloat, 2, 1, o const omni::fabric::Type primvars_vertexId(omni::fabric::BaseDataType::eFloat, 1, 1, omni::fabric::AttributeRole::eNone); const omni::fabric::Type Shader(omni::fabric::BaseDataType::eTag, 1, 0, omni::fabric::AttributeRole::ePrimTypeName); const omni::fabric::Type subdivisionScheme(omni::fabric::BaseDataType::eToken, 1, 0, omni::fabric::AttributeRole::eNone); +const omni::fabric::Type _cesium_gltfLocalToEcefTransform(omni::fabric::BaseDataType::eDouble, 16, 0, omni::fabric::AttributeRole::eMatrix); const omni::fabric::Type _cesium_tilesetId(omni::fabric::BaseDataType::eInt64, 1, 0, omni::fabric::AttributeRole::eNone); const omni::fabric::Type _materialSource(omni::fabric::BaseDataType::eRelationship, 1, 0, omni::fabric::AttributeRole::eNone); const omni::fabric::Type _paramColorSpace(omni::fabric::BaseDataType::eToken, 1, 1, omni::fabric::AttributeRole::eNone); const omni::fabric::Type _sdrMetadata(omni::fabric::BaseDataType::eToken, 1, 1, omni::fabric::AttributeRole::eNone); const omni::fabric::Type _worldExtent(omni::fabric::BaseDataType::eDouble, 6, 0, omni::fabric::AttributeRole::eNone); const omni::fabric::Type _worldVisibility(omni::fabric::BaseDataType::eBool, 1, 0, omni::fabric::AttributeRole::eNone); -const omni::fabric::Type _localMatrix(omni::fabric::BaseDataType::eDouble, 16, 0, omni::fabric::AttributeRole::eMatrix); const omni::fabric::Type _worldMatrix(omni::fabric::BaseDataType::eDouble, 16, 0, omni::fabric::AttributeRole::eMatrix); } diff --git a/src/core/src/FabricGeometry.cpp b/src/core/src/FabricGeometry.cpp index 6b4adfab..20c25c5f 100644 --- a/src/core/src/FabricGeometry.cpp +++ b/src/core/src/FabricGeometry.cpp @@ -121,7 +121,8 @@ void FabricGeometry::setMaterial(const omni::fabric::Path& materialPath) { auto& fabricStage = _pContext->getFabricStage(); fabricStage.setArrayAttributeSize(_path, FabricTokens::material_binding, 1); - auto materialBindingFabric = fabricStage.getArrayAttributeWr(_path, FabricTokens::material_binding); + auto materialBindingFabric = + fabricStage.getArrayAttributeWr(_path, FabricTokens::material_binding); materialBindingFabric[0] = materialPath; } @@ -149,8 +150,8 @@ void FabricGeometry::initialize() { attributes.addAttribute(FabricTypes::primvarInterpolations, FabricTokens::primvarInterpolations); attributes.addAttribute(FabricTypes::Mesh, FabricTokens::Mesh); attributes.addAttribute(FabricTypes::_cesium_tilesetId, FabricTokens::_cesium_tilesetId); - attributes.addAttribute(FabricTypes::_localMatrix, FabricTokens::_localMatrix); - attributes.addAttribute(FabricTypes::_worldMatrix, FabricTokens::_worldMatrix); + attributes.addAttribute(FabricTypes::_cesium_gltfLocalToEcefTransform, FabricTokens::_cesium_gltfLocalToEcefTransform); + attributes.addAttribute(FabricTypes::_worldMatrix, FabricTokens::omni_fabric_worldMatrix); attributes.addAttribute(FabricTypes::doubleSided, FabricTokens::doubleSided); attributes.addAttribute(FabricTypes::subdivisionScheme, FabricTokens::subdivisionScheme); attributes.addAttribute(FabricTypes::material_binding, FabricTokens::material_binding); @@ -264,8 +265,8 @@ void FabricGeometry::reset() { const auto extentFabric = fabricStage.getAttributeWr(_path, FabricTokens::extent); const auto worldExtentFabric = fabricStage.getAttributeWr(_path, FabricTokens::_worldExtent); const auto worldVisibilityFabric = fabricStage.getAttributeWr(_path, FabricTokens::_worldVisibility); - auto worldMatrixFabric = fabricStage.getAttributeWr(_path, FabricTokens::_worldMatrix); - auto localMatrixFabric = fabricStage.getAttributeWr(_path, FabricTokens::_localMatrix); + const auto gltfLocalToEcefTransformFabric = fabricStage.getAttributeWr(_path, FabricTokens::_cesium_gltfLocalToEcefTransform); + const auto worldMatrixFabric = fabricStage.getAttributeWr(_path, FabricTokens::omni_fabric_worldMatrix); const auto tilesetIdFabric = fabricStage.getAttributeWr(_path, FabricTokens::_cesium_tilesetId); // clang-format on @@ -274,7 +275,7 @@ void FabricGeometry::reset() { *extentFabric = UsdUtil::glmToUsdExtent(DEFAULT_EXTENT); *worldExtentFabric = UsdUtil::glmToUsdExtent(DEFAULT_EXTENT); *worldVisibilityFabric = DEFAULT_VISIBILITY; - *localMatrixFabric = UsdUtil::glmToUsdMatrix(DEFAULT_MATRIX); + *gltfLocalToEcefTransformFabric = UsdUtil::glmToUsdMatrix(DEFAULT_MATRIX); *worldMatrixFabric = UsdUtil::glmToUsdMatrix(DEFAULT_MATRIX); *tilesetIdFabric = FabricUtil::NO_TILESET_ID; @@ -341,7 +342,6 @@ void FabricGeometry::setGeometry( const auto doubleSided = materialInfo.doubleSided; const auto gltfLocalToPrimWorldTransform = ecefToPrimWorldTransform * gltfLocalToEcefTransform; - const auto worldMatrix = UsdUtil::glmToUsdMatrix(gltfLocalToPrimWorldTransform); const auto primWorldExtent = MathUtil::transformExtent(gltfLocalExtent.value(), gltfLocalToPrimWorldTransform); if (primitive.mode == CesiumGltf::MeshPrimitive::Mode::POINTS) { @@ -519,17 +519,16 @@ void FabricGeometry::setGeometry( const auto doubleSidedFabric = fabricStage.getAttributeWr(_path, FabricTokens::doubleSided); const auto extentFabric = fabricStage.getAttributeWr(_path, FabricTokens::extent); const auto worldExtentFabric = fabricStage.getAttributeWr(_path, FabricTokens::_worldExtent); - auto worldMatrixFabric = fabricStage.getAttributeWr(_path, FabricTokens::_worldMatrix); - auto localMatrixFabric = fabricStage.getAttributeWr(_path, FabricTokens::_localMatrix); + const auto gltfLocalToEcefTransformFabric = fabricStage.getAttributeWr(_path, FabricTokens::_cesium_gltfLocalToEcefTransform); + const auto worldMatrixFabric = fabricStage.getAttributeWr(_path, FabricTokens::omni_fabric_worldMatrix); const auto tilesetIdFabric = fabricStage.getAttributeWr(_path, FabricTokens::_cesium_tilesetId); // clang-format on *doubleSidedFabric = doubleSided; *extentFabric = UsdUtil::glmToUsdExtent(gltfLocalExtent.value()); *worldExtentFabric = UsdUtil::glmToUsdExtent(primWorldExtent); - *localMatrixFabric = UsdUtil::glmToUsdMatrix(gltfLocalToEcefTransform); - *worldMatrixFabric = worldMatrix; - + *gltfLocalToEcefTransformFabric = UsdUtil::glmToUsdMatrix(gltfLocalToEcefTransform); + *worldMatrixFabric = UsdUtil::glmToUsdMatrix(gltfLocalToPrimWorldTransform); *tilesetIdFabric = tilesetId; } diff --git a/src/core/src/FabricUtil.cpp b/src/core/src/FabricUtil.cpp index 20c2fdfb..f758cd48 100644 --- a/src/core/src/FabricUtil.cpp +++ b/src/core/src/FabricUtil.cpp @@ -542,15 +542,15 @@ void setTilesetTransform( const auto buckets = fabricStage.findPrims( {omni::fabric::AttrNameAndType(FabricTypes::_cesium_tilesetId, FabricTokens::_cesium_tilesetId)}, {omni::fabric::AttrNameAndType( - FabricTypes::_localMatrix, FabricTokens::_localMatrix)}); + FabricTypes::_cesium_gltfLocalToEcefTransform, FabricTokens::_cesium_gltfLocalToEcefTransform)}); for (uint64_t bucketId = 0; bucketId < buckets.bucketCount(); ++bucketId) { // clang-format off const auto tilesetIdFabric = fabricStage.getAttributeArrayRd(buckets, bucketId, FabricTokens::_cesium_tilesetId); - const auto gltfLocalToEcefTransformFabric = fabricStage.getAttributeArrayRd(buckets, bucketId, FabricTokens::_localMatrix); + const auto gltfLocalToEcefTransformFabric = fabricStage.getAttributeArrayRd(buckets, bucketId, FabricTokens::_cesium_gltfLocalToEcefTransform); const auto extentFabric = fabricStage.getAttributeArrayRd(buckets, bucketId, FabricTokens::extent); const auto worldExtentFabric = fabricStage.getAttributeArrayWr(buckets, bucketId, FabricTokens::_worldExtent); - const auto worldMatrixFabric = fabricStage.getAttributeArrayWr(buckets, bucketId, FabricTokens::_worldMatrix); + const auto worldMatrixFabric = fabricStage.getAttributeArrayWr(buckets, bucketId, FabricTokens::omni_fabric_worldMatrix); // clang-format on for (uint64_t i = 0; i < tilesetIdFabric.size(); ++i) { @@ -559,8 +559,7 @@ void setTilesetTransform( const auto gltfLocalToPrimWorldTransform = ecefToPrimWorldTransform * gltfLocalToEcefTransform; const auto gltfLocalExtent = UsdUtil::usdToGlmExtent(extentFabric[i]); const auto primWorldExtent = MathUtil::transformExtent(gltfLocalExtent, gltfLocalToPrimWorldTransform); - const auto worldMatrix = UsdUtil::glmToUsdMatrix(gltfLocalToPrimWorldTransform); - worldMatrixFabric[i] = worldMatrix; + worldMatrixFabric[i] = UsdUtil::glmToUsdMatrix(gltfLocalToPrimWorldTransform); worldExtentFabric[i] = UsdUtil::glmToUsdExtent(primWorldExtent); } }