Skip to content

Commit 18fa4cf

Browse files
authored
fix(testrender): Default to identity for unknown testrender xforms (#2043)
Default to identity for unknown testrender xforms. This is a quick workaround for a testrender crash due to missing object transforms, as observed in MaterialX's OSL codegen testsuite: https://github.com/AcademySoftwareFoundation/MaterialX/blob/main/source/MaterialXRenderOsl/OslRenderer.cpp#L490 Signed-off-by: Chris Hellmuth <[email protected]>
1 parent 8725c3c commit 18fa4cf

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/testrender/simpleraytracer.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,11 @@ SimpleRaytracer::get_matrix(ShaderGlobals* /*sg*/, Matrix44& result,
516516
{
517517
// SimpleRaytracer doesn't understand motion blur and transformations
518518
// are just simple 4x4 matrices.
519-
result = *reinterpret_cast<const Matrix44*>(xform);
519+
if (xform)
520+
result = *reinterpret_cast<const Matrix44*>(xform);
521+
else
522+
result = Matrix44(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
523+
520524
return true;
521525
}
522526

@@ -543,7 +547,10 @@ SimpleRaytracer::get_matrix(ShaderGlobals* /*sg*/, Matrix44& result,
543547
{
544548
// SimpleRaytracer doesn't understand motion blur and transformations
545549
// are just simple 4x4 matrices.
546-
result = *reinterpret_cast<const Matrix44*>(xform);
550+
if (xform)
551+
result = *reinterpret_cast<const Matrix44*>(xform);
552+
else
553+
result = Matrix44(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
547554
return true;
548555
}
549556

0 commit comments

Comments
 (0)