Cycles: Fix issues with quick inverse of degenerate matrix
This fixes part of the issues reported in T46322. Still need to solve issue with wrong intersection distance scaling.
This commit is contained in:
parent
8fa4fccec4
commit
4974ed93ef
|
@ -347,7 +347,12 @@ ccl_device_inline Transform transform_quick_inverse(Transform M)
|
|||
* scale can be inverted but what about shearing? */
|
||||
Transform R;
|
||||
float det = M.x.x*(M.z.z*M.y.y - M.z.y*M.y.z) - M.y.x*(M.z.z*M.x.y - M.z.y*M.x.z) + M.z.x*(M.y.z*M.x.y - M.y.y*M.x.z);
|
||||
|
||||
if(det == 0.0f) {
|
||||
M[0][0] += 1e-8f;
|
||||
M[1][1] += 1e-8f;
|
||||
M[2][2] += 1e-8f;
|
||||
det = M.x.x*(M.z.z*M.y.y - M.z.y*M.y.z) - M.y.x*(M.z.z*M.x.y - M.z.y*M.x.z) + M.z.x*(M.y.z*M.x.y - M.y.y*M.x.z);
|
||||
}
|
||||
det = (det != 0.0f)? 1.0f/det: 0.0f;
|
||||
|
||||
float3 Rx = det*make_float3(M.z.z*M.y.y - M.z.y*M.y.z, M.z.y*M.x.z - M.z.z*M.x.y, M.y.z*M.x.y - M.y.y*M.x.z);
|
||||
|
|
Loading…
Reference in New Issue