Cycles code refactor: change curve key to float4 for easier storage as attribute.

This commit is contained in:
Brecht Van Lommel
2014-03-29 13:03:46 +01:00
parent 0509553b5e
commit 934767cf7f
9 changed files with 101 additions and 82 deletions

View File

@@ -86,19 +86,24 @@ void Object::apply_transform()
{
if(!mesh || tfm == transform_identity())
return;
float3 c0 = transform_get_column(&tfm, 0);
float3 c1 = transform_get_column(&tfm, 1);
float3 c2 = transform_get_column(&tfm, 2);
float scalar = pow(fabsf(dot(cross(c0, c1), c2)), 1.0f/3.0f);
/* apply to mesh vertices */
for(size_t i = 0; i < mesh->verts.size(); i++)
mesh->verts[i] = transform_point(&tfm, mesh->verts[i]);
/* apply to curve keys */
for(size_t i = 0; i < mesh->curve_keys.size(); i++) {
mesh->curve_keys[i].co = transform_point(&tfm, mesh->curve_keys[i].co);
float3 co = transform_point(&tfm, float4_to_float3(mesh->curve_keys[i]));
float radius = mesh->curve_keys[i].w * scalar;
mesh->curve_keys[i] = float3_to_float4(co);
/* scale for strand radius - only correct for uniform transforms*/
mesh->curve_keys[i].radius *= scalar;
mesh->curve_keys[i].w *= radius;
}
/* store matrix to transform later. when accessing these as attributes we