Fix T43484: Motion blur fails in certain circumstances

The issue was caused by mismatch in how aligned triangles storage was
filled in during BVH construction and how it was used during rendering.

Basically, i  was leaving uninitialized storage for triangles when
there was deformation motion blur detected for the mesh. Was likely
some sort of optimization, but in fact it's still possible that regular
triangles would be needed for rendering.

So now we're storing aligned storage for all triangle primitives and
only skipping motion triangles (the deformation motion blur flag from
mesh is now ignored).
This commit is contained in:
Sergey Sharybin 2015-03-09 14:15:35 +05:00
parent b13b900d50
commit d4c1e98dd4

@ -268,9 +268,6 @@ void BVH::pack_triangle(int idx, float4 woop[3])
assert(tob >= 0 && tob < objects.size());
const Mesh *mesh = objects[tob]->mesh;
if(mesh->has_motion_blur())
return;
int tidx = pack.prim_index[idx];
const int *vidx = mesh->triangles[tidx].v;
const float3* vpos = &mesh->verts[0];
@ -299,9 +296,14 @@ void BVH::pack_primitives()
if(pack.prim_index[i] != -1) {
float4 woop[3];
if(pack.prim_type[i] & PRIMITIVE_ALL_TRIANGLE)
if(pack.prim_type[i] & PRIMITIVE_TRIANGLE) {
pack_triangle(i, woop);
}
else {
/* Avoid use of uninitialized memory. */
memset(&woop, 0, sizeof(woop));
}
memcpy(&pack.tri_woop[i * nsize], woop, sizeof(float4)*3);
int tob = pack.prim_object[i];