Skip to content

Commit

Permalink
Revert _localTransform change
Browse files Browse the repository at this point in the history
  • Loading branch information
lilleyse committed Sep 17, 2024
1 parent a5e72e9 commit 6e93948
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 20 deletions.
6 changes: 3 additions & 3 deletions src/core/include/cesium/omniverse/UsdTokens.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ __pragma(warning(push)) __pragma(warning(disable : 4003))
(subdivisionScheme) \
(vertex) \
(vertexId) \
(_cesium_gltfLocalToEcefTransform) \
(_cesium_tilesetId) \
(_deletedPrims) \
(_materialSource) \
Expand Down Expand Up @@ -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")) \
Expand All @@ -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
Expand Down Expand Up @@ -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);

}
Expand Down
23 changes: 11 additions & 12 deletions src/core/src/FabricGeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<omni::fabric::Path>(_path, FabricTokens::material_binding);
auto materialBindingFabric =
fabricStage.getArrayAttributeWr<omni::fabric::Path>(_path, FabricTokens::material_binding);
materialBindingFabric[0] = materialPath;
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -264,8 +265,8 @@ void FabricGeometry::reset() {
const auto extentFabric = fabricStage.getAttributeWr<pxr::GfRange3d>(_path, FabricTokens::extent);
const auto worldExtentFabric = fabricStage.getAttributeWr<pxr::GfRange3d>(_path, FabricTokens::_worldExtent);
const auto worldVisibilityFabric = fabricStage.getAttributeWr<bool>(_path, FabricTokens::_worldVisibility);
auto worldMatrixFabric = fabricStage.getAttributeWr<pxr::GfMatrix4d>(_path, FabricTokens::_worldMatrix);
auto localMatrixFabric = fabricStage.getAttributeWr<pxr::GfMatrix4d>(_path, FabricTokens::_localMatrix);
const auto gltfLocalToEcefTransformFabric = fabricStage.getAttributeWr<pxr::GfMatrix4d>(_path, FabricTokens::_cesium_gltfLocalToEcefTransform);
const auto worldMatrixFabric = fabricStage.getAttributeWr<pxr::GfMatrix4d>(_path, FabricTokens::omni_fabric_worldMatrix);

const auto tilesetIdFabric = fabricStage.getAttributeWr<int64_t>(_path, FabricTokens::_cesium_tilesetId);
// clang-format on
Expand All @@ -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;

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -519,17 +519,16 @@ void FabricGeometry::setGeometry(
const auto doubleSidedFabric = fabricStage.getAttributeWr<bool>(_path, FabricTokens::doubleSided);
const auto extentFabric = fabricStage.getAttributeWr<pxr::GfRange3d>(_path, FabricTokens::extent);
const auto worldExtentFabric = fabricStage.getAttributeWr<pxr::GfRange3d>(_path, FabricTokens::_worldExtent);
auto worldMatrixFabric = fabricStage.getAttributeWr<pxr::GfMatrix4d>(_path, FabricTokens::_worldMatrix);
auto localMatrixFabric = fabricStage.getAttributeWr<pxr::GfMatrix4d>(_path, FabricTokens::_localMatrix);
const auto gltfLocalToEcefTransformFabric = fabricStage.getAttributeWr<pxr::GfMatrix4d>(_path, FabricTokens::_cesium_gltfLocalToEcefTransform);
const auto worldMatrixFabric = fabricStage.getAttributeWr<pxr::GfMatrix4d>(_path, FabricTokens::omni_fabric_worldMatrix);
const auto tilesetIdFabric = fabricStage.getAttributeWr<int64_t>(_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;
}
Expand Down
9 changes: 4 additions & 5 deletions src/core/src/FabricUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int64_t>(buckets, bucketId, FabricTokens::_cesium_tilesetId);
const auto gltfLocalToEcefTransformFabric = fabricStage.getAttributeArrayRd<pxr::GfMatrix4d>(buckets, bucketId, FabricTokens::_localMatrix);
const auto gltfLocalToEcefTransformFabric = fabricStage.getAttributeArrayRd<pxr::GfMatrix4d>(buckets, bucketId, FabricTokens::_cesium_gltfLocalToEcefTransform);
const auto extentFabric = fabricStage.getAttributeArrayRd<pxr::GfRange3d>(buckets, bucketId, FabricTokens::extent);
const auto worldExtentFabric = fabricStage.getAttributeArrayWr<pxr::GfRange3d>(buckets, bucketId, FabricTokens::_worldExtent);
const auto worldMatrixFabric = fabricStage.getAttributeArrayWr<pxr::GfMatrix4d>(buckets, bucketId, FabricTokens::_worldMatrix);
const auto worldMatrixFabric = fabricStage.getAttributeArrayWr<pxr::GfMatrix4d>(buckets, bucketId, FabricTokens::omni_fabric_worldMatrix);
// clang-format on

for (uint64_t i = 0; i < tilesetIdFabric.size(); ++i) {
Expand All @@ -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);
}
}
Expand Down

0 comments on commit 6e93948

Please sign in to comment.