Fix T43120: Cycles mapping node rotation order is different from viewport

Root of the issue goes to the fact that since the very beginning Cycles was
using ZYX euler rotation for mapping shader node but blender was always
using XYZ euler rotation.

This commit switches Cycles to use XYZ euler order and adds versioning code
to preserve backward compatibility.

There was no really nice solution here because either we're ending up with
versioning code or we'll need to deal with all sort of exceptions from blender
side in order to support ZYX order for the mapping node. The latest one is
also creepy from the other render engines points of view -- that might break
compatibility with existing bindings or introduce some extra headache for them
in the future.

This could also become a PITA for us with need of supporting all sort of weird
and wonderful exceptions in the refactored viewport project.

NOTE: This commit breaks forward compatibility, meaning opening new files in
older blender might not give proper result if Mapping node was used.

Also, libraries are to be re-saved separately from the scene file, otherwise
versioning code for them wouldn't run if scene file was re-saved with new
version of blender.

Reviewers: brecht, juicyfruit, campbellbarton

Reviewed By: campbellbarton

Differential Revision: https://developer.blender.org/D973
This commit is contained in:
2015-01-15 13:23:33 +05:00
parent 1aa8f0d3c0
commit a1ffb49e49
3 changed files with 61 additions and 3 deletions

View File

@@ -216,12 +216,13 @@ ccl_device_inline Transform transform_rotate(float angle, float3 axis)
0.0f, 0.0f, 0.0f, 1.0f);
}
/* Euler is assumed to be in XYZ order. */
ccl_device_inline Transform transform_euler(float3 euler)
{
return
transform_rotate(euler.x, make_float3(1.0f, 0.0f, 0.0f)) *
transform_rotate(euler.z, make_float3(0.0f, 0.0f, 1.0f)) *
transform_rotate(euler.y, make_float3(0.0f, 1.0f, 0.0f)) *
transform_rotate(euler.z, make_float3(0.0f, 0.0f, 1.0f));
transform_rotate(euler.x, make_float3(1.0f, 0.0f, 0.0f));
}
ccl_device_inline Transform transform_orthographic(float znear, float zfar)