diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-03-08 08:48:14 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-03-10 06:54:05 +0300 |
commit | b66efbecf4780c65833f72ac8de5d18b5bca7e15 (patch) | |
tree | 58f258df9e797f55ad1a77082115989df147e6db /intern/cycles/blender | |
parent | 623141f339d5066ed6b96ad70ab45fb294e3e612 (diff) |
Code refactor: make Transform always affine, dropping last row.
This save a little memory and copying in the kernel by storing only a 4x3
matrix instead of a 4x4 matrix. We already did this in a few places, and
those don't need to be special exceptions anymore now.
Diffstat (limited to 'intern/cycles/blender')
-rw-r--r-- | intern/cycles/blender/blender_camera.cpp | 6 | ||||
-rw-r--r-- | intern/cycles/blender/blender_util.h | 13 |
2 files changed, 9 insertions, 10 deletions
diff --git a/intern/cycles/blender/blender_camera.cpp b/intern/cycles/blender/blender_camera.cpp index 62e950e3bef..e5f885c0012 100644 --- a/intern/cycles/blender/blender_camera.cpp +++ b/intern/cycles/blender/blender_camera.cpp @@ -246,8 +246,7 @@ static Transform blender_camera_matrix(const Transform& tfm, result = tfm * make_transform(1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, - 0.0f, 1.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f); + 0.0f, 1.0f, 0.0f, 0.0f); } else { /* Make it so environment camera needs to be pointed in the direction @@ -257,8 +256,7 @@ static Transform blender_camera_matrix(const Transform& tfm, result = tfm * make_transform( 0.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, - -1.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f); + -1.0f, 0.0f, 0.0f, 0.0f); } } else { diff --git a/intern/cycles/blender/blender_util.h b/intern/cycles/blender/blender_util.h index 363e19f7a20..c4c45035b5a 100644 --- a/intern/cycles/blender/blender_util.h +++ b/intern/cycles/blender/blender_util.h @@ -247,14 +247,15 @@ static inline float *image_get_float_pixels_for_frame(BL::Image& image, static inline Transform get_transform(const BL::Array<float, 16>& array) { - Transform tfm; + ProjectionTransform projection; - /* we assume both types to be just 16 floats, and transpose because blender - * use column major matrix order while we use row major */ - memcpy(&tfm, &array, sizeof(float)*16); - tfm = transform_transpose(tfm); + /* We assume both types to be just 16 floats, and transpose because blender + * use column major matrix order while we use row major. */ + memcpy(&projection, &array, sizeof(float)*16); + projection = projection_transpose(projection); - return tfm; + /* Drop last row, matrix is assumed to be affine transform. */ + return projection_to_transform(projection); } static inline float2 get_float2(const BL::Array<float, 2>& array) |