Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2014-03-29 16:03:47 +0400
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2014-03-29 16:03:47 +0400
commite2184c653e1f2cc7e05cf9a42a87d23ea3050eac (patch)
treedc39ada14e14259a4cd18c2d5974390a585eb7b8 /intern/cycles/render
parent6020d0099039ed18c6a6cd330b68361123c85c1a (diff)
Cycles: add support for curve deformation motion blur.
Diffstat (limited to 'intern/cycles/render')
-rw-r--r--intern/cycles/render/mesh.cpp8
-rw-r--r--intern/cycles/render/object.cpp50
2 files changed, 36 insertions, 22 deletions
diff --git a/intern/cycles/render/mesh.cpp b/intern/cycles/render/mesh.cpp
index e216630b48c..52cd946456f 100644
--- a/intern/cycles/render/mesh.cpp
+++ b/intern/cycles/render/mesh.cpp
@@ -199,7 +199,7 @@ void Mesh::compute_bounds()
}
Attribute *curve_attr = curve_attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);
- if (curve_attr) {
+ if(use_motion_blur && curve_attr) {
size_t steps_size = curve_keys.size() * (motion_steps - 1);
float3 *key_steps = curve_attr->data_float3();
@@ -225,7 +225,7 @@ void Mesh::compute_bounds()
bnds.grow_safe(vert_steps[i]);
}
- if (curve_attr) {
+ if (use_motion_blur && curve_attr) {
size_t steps_size = curve_keys.size() * (motion_steps - 1);
float3 *key_steps = curve_attr->data_float3();
@@ -536,7 +536,9 @@ void Mesh::tag_update(Scene *scene, bool rebuild)
bool Mesh::has_motion_blur() const
{
- return (use_motion_blur && attributes.find(ATTR_STD_MOTION_VERTEX_POSITION));
+ return (use_motion_blur &&
+ (attributes.find(ATTR_STD_MOTION_VERTEX_POSITION) ||
+ curve_attributes.find(ATTR_STD_MOTION_VERTEX_POSITION)));
}
/* Mesh Manager */
diff --git a/intern/cycles/render/object.cpp b/intern/cycles/render/object.cpp
index df03fa4a04c..dab00eae2df 100644
--- a/intern/cycles/render/object.cpp
+++ b/intern/cycles/render/object.cpp
@@ -84,11 +84,6 @@ 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);
-
/* triangles */
if(mesh->verts.size()) {
/* store matrix to transform later. when accessing these as attributes we
@@ -121,23 +116,40 @@ void Object::apply_transform()
}
}
- /* apply to curve keys */
- for(size_t i = 0; i < mesh->curve_keys.size(); i++) {
- float3 co = transform_point(&tfm, float4_to_float3(mesh->curve_keys[i]));
- float radius = mesh->curve_keys[i].w * scalar;
+ /* curves */
+ if(mesh->curve_keys.size()) {
+ /* compute uniform scale */
+ 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 transform to curve keys */
+ for(size_t i = 0; i < mesh->curve_keys.size(); i++) {
+ float3 co = transform_point(&tfm, float4_to_float3(mesh->curve_keys[i]));
+ float radius = mesh->curve_keys[i].w * scalar;
+
+ /* scale for curve radius is only correct for uniform scale */
+ mesh->curve_keys[i] = float3_to_float4(co);
+ mesh->curve_keys[i].w = radius;
+ }
- mesh->curve_keys[i] = float3_to_float4(co);
- /* scale for strand radius - only correct for uniform transforms*/
- mesh->curve_keys[i].w *= radius;
- }
+ Attribute *curve_attr = mesh->curve_attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);
- Attribute *curve_attr = mesh->curve_attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);
- if (curve_attr) {
- size_t steps_size = mesh->curve_keys.size() * (mesh->motion_steps - 1);
- float3 *vert_steps = curve_attr->data_float3();
+ if (curve_attr) {
+ /* apply transform to motion curve keys */
+ size_t steps_size = mesh->curve_keys.size() * (mesh->motion_steps - 1);
+ float4 *key_steps = curve_attr->data_float4();
- for (size_t i = 0; i < steps_size; i++)
- vert_steps[i] = transform_point(&tfm, vert_steps[i]);
+ for (size_t i = 0; i < steps_size; i++) {
+ float3 co = transform_point(&tfm, float4_to_float3(key_steps[i]));
+ float radius = key_steps[i].w * scalar;
+
+ /* scale for curve radius is only correct for uniform scale */
+ key_steps[i] = float3_to_float4(co);
+ key_steps[i].w = radius;
+ }
+ }
}
/* we keep normals pointing in same direction on negative scale, notify