Skip to content

Commit

Permalink
fixes to build with USD 24.11 (#2149)
Browse files Browse the repository at this point in the history
  • Loading branch information
cpichard authored Nov 21, 2024
1 parent f2829aa commit 19c4419
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 10 deletions.
8 changes: 4 additions & 4 deletions libs/translator/reader/read_geometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ AtNode* UsdArnoldReadCube::Read(const UsdPrim &prim, UsdArnoldReaderContext &con
0.0, 0.0, size, 0.0,
0.0, 0.0, 0.0, 1.0);
for (GfVec3f& pt : points)
pt = scale.Transform(pt);
pt = MatTransform(scale, pt);

_ReadPointsAndVertices(node, numVerts, verts, points);

Expand Down Expand Up @@ -911,7 +911,7 @@ AtNode* UsdArnoldReadSphere::Read(const UsdPrim &prim, UsdArnoldReaderContext &c
0.0, 0.0, radius, 0.0,
0.0, 0.0, 0.0, 1.0);
for (GfVec3f& pt : points)
pt = scale.Transform(pt);
pt = MatTransform(scale, pt);
}
}

Expand Down Expand Up @@ -1015,7 +1015,7 @@ AtNode* UsdArnoldReadCylinder::Read(const UsdPrim &prim, UsdArnoldReaderContext
// Get implicit geom scale transform
GfMatrix4d scale = exportCylindricalTransform<UsdGeomCylinder>(prim, node, frame);
for (GfVec3f& pt : points)
pt = scale.Transform(pt);
pt = MatTransform(scale, pt);

UsdGeomCylinder cylinder(prim);

Expand Down Expand Up @@ -1064,7 +1064,7 @@ AtNode* UsdArnoldReadCone::Read(const UsdPrim &prim, UsdArnoldReaderContext &con
// Get implicit geom scale transform
GfMatrix4d scale = exportCylindricalTransform<UsdGeomCone>(prim, node, frame);
for (GfVec3f& pt : points)
pt = scale.Transform(pt);
pt = MatTransform(scale, pt);

UsdGeomCone cone(prim);

Expand Down
12 changes: 8 additions & 4 deletions libs/translator/reader/read_skinning.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1266,7 +1266,7 @@ _SkinningAdapter::_DeformPointsWithLBS(const GfMatrix4d& skelToGprimXf)
// Transform the result into gprim space.

for (auto& pointValue : _points.value) {
pointValue = skelToGprimXf.Transform(pointValue);
pointValue = MatTransform(skelToGprimXf, pointValue);
}
}

Expand Down Expand Up @@ -1319,8 +1319,12 @@ _SkinningAdapter::_DeformNormalsWithLBS(const GfMatrix4d& skelToGprimXf)
const GfMatrix3d& skelToGprimInvTransposeXform =
skelToGprimXf.ExtractRotationMatrix().GetInverse().GetTranspose();

for (auto& n : _normals.value) {
n = n * skelToGprimInvTransposeXform;
for (GfVec3f & n : _normals.value) {
GfVec3d n_double(n);
n_double = n_double * skelToGprimInvTransposeXform;
n[0] = static_cast<float>(n_double[0]);
n[1] = static_cast<float>(n_double[1]);
n[2] = static_cast<float>(n_double[2]);
}
}

Expand Down Expand Up @@ -1753,7 +1757,7 @@ bool UsdArnoldSkelData::ApplyPointsSkinning(const UsdPrim &prim, const VtArray<G
if (_impl->skinningAdapter->GetXform(xform, timeIndex)) {
output = input;
for (auto &pt: output) {
pt = xform.Transform(pt);
pt = MatTransform(xform, pt);
}
return true;
}
Expand Down
14 changes: 14 additions & 0 deletions libs/translator/utils/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,20 @@

PXR_NAMESPACE_USING_DIRECTIVE

// Version 24.11 change
#if PXR_VERSION >= 2411
inline GfVec3f MatTransform(const GfMatrix4d &mat, const GfVec3f &ptin) {
GfVec3d ptind(ptin[0], ptin[1], ptin[2]);
GfVec3d ptoutd = mat.Transform(ptind);
GfVec3f ptout(static_cast<float>(ptoutd[0]), static_cast<float>(ptoutd[1]), static_cast<float>(ptoutd[2]));
return ptout;
}
#else
inline GfVec3f MatTransform(const GfMatrix4d &mat, const GfVec3f &ptin) {
return mat.Transform(ptin);
}
#endif

/*
* Expands all environment variables with the form "[envar]" in the input string
*
Expand Down
5 changes: 3 additions & 2 deletions plugins/ndr/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,9 @@ class ArnoldShaderProperty : public SdrShaderProperty {
_typeName(typeName)
{
}

#if PXR_VERSION >= 2108
#if PXR_VERSION >= 2411
NdrSdfTypeIndicator
#elif PXR_VERSION >= 2108
const NdrSdfTypeIndicator
#else
const SdfTypeIndicator
Expand Down

0 comments on commit 19c4419

Please sign in to comment.