Merge pull request #2724 from erikaharrison-adsk/adsk/bugfix/FloatMatrix
authorpixar-oss <pixar-oss@users.noreply.github.com>
Fri, 15 Dec 2023 00:30:44 +0000 (16:30 -0800)
committerpixar-oss <pixar-oss@users.noreply.github.com>
Fri, 15 Dec 2023 00:30:44 +0000 (16:30 -0800)
Autodesk: Support float type matrix (GfMatrix4f) for instanceTransform

(Internal change: 2308434)

1  2 
pxr/imaging/hdSt/instancer.cpp

index 0abd0e48ddba7117e3ac52c2cb591e1091fef05a,de8d44dfe024b29957db4ffeeaa2255acbff0f58..6c36a8f944be74c0c2963a40432a78b34fb5fd11
@@@ -83,21 -83,30 +83,29 @@@ HdStInstancer::_SyncPrimvars(HdSceneDel
          VtValue value = sceneDelegate->Get(instancerId, primvar.name);
          if (!value.IsEmpty()) {
              HdBufferSourceSharedPtr source;
 -            if (primvar.name == HdInstancerTokens->instanceTransform) {
 -                if (value.IsHolding<VtArray<GfMatrix4d> >()) {
 +            if ((primvar.name == HdInstancerTokens->instanceTransform ||
-                  primvar.name == HdInstancerTokens->instanceTransforms) &&
-                 TF_VERIFY(value.IsHolding<VtArray<GfMatrix4d> >())) {
-                 // Explicitly invoke the c'tor taking a
-                 // VtArray<GfMatrix4d> to ensure we properly convert to
-                 // the appropriate floating-point matrix type.
-                 HgiCapabilities const * capabilities =
-                     resourceRegistry->GetHgi()->GetCapabilities();
-                 bool const doublesSupported = capabilities->IsSet(
-                     HgiDeviceCapabilitiesBitsShaderDoublePrecision);
-                 source.reset(new HdVtBufferSource(
-                     primvar.name,
-                     value.UncheckedGet<VtArray<GfMatrix4d>>(),
-                     1,
-                     doublesSupported));
++                 primvar.name == HdInstancerTokens->instanceTransforms)) {
++                if (value.IsHolding<VtArray<GfMatrix4d>>()) {
+                     // Explicitly invoke the c'tor taking a
+                     // VtArray<GfMatrix4d> to ensure we properly convert to
+                     // the appropriate floating-point matrix type.
+                     HgiCapabilities const * capabilities =
+                         resourceRegistry->GetHgi()->GetCapabilities();
+                     bool const doublesSupported = capabilities->IsSet(
 -                            HgiDeviceCapabilitiesBitsShaderDoublePrecision);
 -                    source.reset(new HdVtBufferSource(primvar.name,
 -                                value.UncheckedGet<VtArray<GfMatrix4d>>(),
 -                                1,
 -                                doublesSupported));
++                        HgiDeviceCapabilitiesBitsShaderDoublePrecision);
++                    source.reset(new HdVtBufferSource(
++                        primvar.name,
++                        value.UncheckedGet<VtArray<GfMatrix4d>>(),
++                        1,
++                        doublesSupported));
+                 }
 -                else if (value.IsHolding<VtArray<GfMatrix4f> >()) {
 -                    source.reset(new HdVtBufferSource(primvar.name,
 -                                value,
 -                                1,
 -                                false));
 -                }
 -                else {
 -                    TF_VERIFY(false);
 -                    source.reset(new HdVtBufferSource(primvar.name, value));
++                else if (value.IsHolding<VtArray<GfMatrix4f>>()) {
++                    source.reset(new HdVtBufferSource(
++                        primvar.name,
++                        value,
++                        1,
++                        false));
+                 }
              }
              else {
                  source.reset(new HdVtBufferSource(primvar.name, value));