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/render/object.cpp | |
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/render/object.cpp')
-rw-r--r-- | intern/cycles/render/object.cpp | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/intern/cycles/render/object.cpp b/intern/cycles/render/object.cpp index f632f7c4a53..92c7e9cf1b8 100644 --- a/intern/cycles/render/object.cpp +++ b/intern/cycles/render/object.cpp @@ -132,7 +132,7 @@ void Object::apply_transform(bool apply_to_motion) /* store matrix to transform later. when accessing these as attributes we * do not want the transform to be applied for consistency between static * and dynamic BVH, so we do it on packing. */ - mesh->transform_normal = transform_transpose(transform_inverse(tfm)); + mesh->transform_normal = transform_transposed_inverse(tfm); /* apply to mesh vertices */ for(size_t i = 0; i < mesh->verts.size(); i++) @@ -290,7 +290,7 @@ void ObjectManager::device_update_object_transform(UpdateObjectTransformState *s int object_index) { KernelObject& kobject = state->objects[object_index]; - float4 *objects_vector = state->objects_vector; + Transform *objects_vector = state->objects_vector; Mesh *mesh = ob->mesh; uint flag = 0; @@ -357,11 +357,8 @@ void ObjectManager::device_update_object_transform(UpdateObjectTransformState *s } } - /* OBJECT_TRANSFORM */ - memcpy(&kobject.tfm.pre, &tfm, sizeof(float4)*3); - /* OBJECT_INVERSE_TRANSFORM */ - memcpy(&kobject.tfm.mid, &itfm, sizeof(float4)*3); - /* OBJECT_PROPERTIES */ + memcpy(&kobject.tfm.pre, &tfm, sizeof(tfm)); + memcpy(&kobject.tfm.mid, &itfm, sizeof(itfm)); kobject.surface_area = surface_area; kobject.pass_id = pass_id; kobject.random_number = random_number; @@ -395,8 +392,8 @@ void ObjectManager::device_update_object_transform(UpdateObjectTransformState *s mtfm.post = mtfm.post * itfm; } - memcpy(&objects_vector[object_index*OBJECT_VECTOR_SIZE+0], &mtfm.pre, sizeof(float4)*3); - memcpy(&objects_vector[object_index*OBJECT_VECTOR_SIZE+3], &mtfm.post, sizeof(float4)*3); + objects_vector[object_index*OBJECT_VECTOR_SIZE+0] = mtfm.pre; + objects_vector[object_index*OBJECT_VECTOR_SIZE+1] = mtfm.post; } else if(state->need_motion == Scene::MOTION_BLUR) { if(ob->use_motion) { |