Skip to content

Commit

Permalink
Don't set localTransform
Browse files Browse the repository at this point in the history
  • Loading branch information
lilleyse committed Sep 17, 2024
1 parent 7608a24 commit c54ab60
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
7 changes: 4 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_localMatrix, "omni:fabric:localMatrix")) \
((omni_fabric_worldMatrix, "omni:fabric:worldMatrix")) \
((outputs_mdl_displacement, "outputs:mdl:displacement")) \
((outputs_mdl_surface, "outputs:mdl:surface")) \
Expand All @@ -149,7 +151,6 @@ __pragma(warning(push)) __pragma(warning(disable : 4003))
((xformOp_rotateZYX, "xformOp:rotateZYX")) \
((xformOp_scale, "xformOp:scale")) \
((xformOp_translate, "xformOp:translate")) \
((_localMatrix, "omni:fabric:localMatrix")) \
((_auto, "auto"))

#ifdef CESIUM_OMNI_CLANG
Expand Down Expand Up @@ -262,6 +263,7 @@ const omni::fabric::Type inputs_wrap_t(omni::fabric::BaseDataType::eInt, 1, 0, o
const omni::fabric::Type Material(omni::fabric::BaseDataType::eTag, 1, 0, omni::fabric::AttributeRole::ePrimTypeName);
const omni::fabric::Type material_binding(omni::fabric::BaseDataType::eRelationship, 1, 0, omni::fabric::AttributeRole::eNone);
const omni::fabric::Type Mesh(omni::fabric::BaseDataType::eTag, 1, 0, omni::fabric::AttributeRole::ePrimTypeName);
const omni::fabric::Type omni_fabric_localMatrix(omni::fabric::BaseDataType::eDouble, 16, 0, omni::fabric::AttributeRole::eMatrix);
const omni::fabric::Type omni_fabric_worldMatrix(omni::fabric::BaseDataType::eDouble, 16, 0, omni::fabric::AttributeRole::eMatrix);
const omni::fabric::Type outputs_out(omni::fabric::BaseDataType::eToken, 1, 0, omni::fabric::AttributeRole::eNone);
const omni::fabric::Type points(omni::fabric::BaseDataType::eFloat, 3, 1, omni::fabric::AttributeRole::ePosition);
Expand All @@ -273,13 +275,12 @@ 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);

}
// clang-format on
21 changes: 13 additions & 8 deletions src/core/src/FabricGeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ void FabricGeometry::setMaterial(const omni::fabric::Path& materialPath) {

auto& fabricStage = _pContext->getFabricStage();
fabricStage.setArrayAttributeSize(_path, FabricTokens::material_binding, 1);
auto materialBindingFabric =
const auto materialBindingFabric =
fabricStage.getArrayAttributeWr<omni::fabric::Path>(_path, FabricTokens::material_binding);
materialBindingFabric[0] = materialPath;
}
Expand Down Expand Up @@ -150,7 +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::_cesium_gltfLocalToEcefTransform, FabricTokens::_cesium_gltfLocalToEcefTransform);
attributes.addAttribute(FabricTypes::omni_fabric_localMatrix, FabricTokens::omni_fabric_localMatrix);
attributes.addAttribute(FabricTypes::omni_fabric_worldMatrix, FabricTokens::omni_fabric_worldMatrix);
attributes.addAttribute(FabricTypes::doubleSided, FabricTokens::doubleSided);
attributes.addAttribute(FabricTypes::subdivisionScheme, FabricTokens::subdivisionScheme);
Expand Down Expand Up @@ -184,6 +185,10 @@ void FabricGeometry::initialize() {
fabricStage.getAttributeWr<omni::fabric::TokenC>(_path, FabricTokens::subdivisionScheme);
*subdivisionSchemeFabric = FabricTokens::none;

const auto localMatrixFabric =
fabricStage.getAttributeWr<pxr::GfMatrix4d>(_path, FabricTokens::omni_fabric_localMatrix);
*localMatrixFabric = UsdUtil::glmToUsdMatrix(DEFAULT_MATRIX);

// Initialize primvars
uint64_t primvarsCount = 0;
uint64_t primvarIndexNormal = 0;
Expand Down Expand Up @@ -265,8 +270,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::omni_fabric_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 @@ -275,7 +280,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 @@ -519,15 +524,15 @@ 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::omni_fabric_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);
*gltfLocalToEcefTransformFabric = UsdUtil::glmToUsdMatrix(gltfLocalToEcefTransform);
*worldMatrixFabric = UsdUtil::glmToUsdMatrix(gltfLocalToPrimWorldTransform);

*tilesetIdFabric = tilesetId;
Expand Down
4 changes: 2 additions & 2 deletions src/core/src/FabricUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -542,12 +542,12 @@ 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::omni_fabric_worldMatrix);
Expand Down

0 comments on commit c54ab60

Please sign in to comment.