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/util/util_projection.h | |
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/util/util_projection.h')
-rw-r--r-- | intern/cycles/util/util_projection.h | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/intern/cycles/util/util_projection.h b/intern/cycles/util/util_projection.h index 8073568046d..dbcb9877a48 100644 --- a/intern/cycles/util/util_projection.h +++ b/intern/cycles/util/util_projection.h @@ -35,7 +35,7 @@ typedef struct ProjectionTransform { : x(tfm.x), y(tfm.y), z(tfm.z), - w(tfm.w) + w(make_float4(0.0f, 0.0f, 0.0f, 1.0f)) { } #endif @@ -69,6 +69,12 @@ ccl_device_inline float3 transform_perspective_direction(const ProjectionTransfo #ifndef __KERNEL_GPU__ +ccl_device_inline Transform projection_to_transform(const ProjectionTransform& a) +{ + Transform tfm = {a.x, a.y, a.z}; + return tfm; +} + ccl_device_inline ProjectionTransform projection_transpose(const ProjectionTransform& a) { ProjectionTransform t; @@ -81,12 +87,7 @@ ccl_device_inline ProjectionTransform projection_transpose(const ProjectionTrans return t; } -ccl_device_inline ProjectionTransform projection_inverse(const ProjectionTransform& a) -{ - Transform t = {a.x, a.y, a.z, a.w}; - t = transform_inverse(t); - return ProjectionTransform(t); -} +ProjectionTransform projection_inverse(const ProjectionTransform& a); ccl_device_inline ProjectionTransform make_projection( float a, float b, float c, float d, |