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:
authorStefan Werner <stefan.werner@tangent-animation.com>2017-12-02 05:28:13 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2018-01-11 04:58:29 +0300
commit25b794a39d8cff87b6df2338d020e8d4ba90eeef (patch)
tree8a981b760e13061e8a8b9f142f2331822c73de2d /intern/cycles/util
parentac2ebf9c54a9081662ab17f04240c00d9e5ac799 (diff)
Cycles: support animated object scale in motion blur.
This was disabled previously due to CUDA compiler bugs, see T32900. Differential Revision: https://developer.blender.org/D2937
Diffstat (limited to 'intern/cycles/util')
-rw-r--r--intern/cycles/util/util_transform.cpp24
-rw-r--r--intern/cycles/util/util_transform.h37
2 files changed, 21 insertions, 40 deletions
diff --git a/intern/cycles/util/util_transform.cpp b/intern/cycles/util/util_transform.cpp
index b8f182ae962..c1270545339 100644
--- a/intern/cycles/util/util_transform.cpp
+++ b/intern/cycles/util/util_transform.cpp
@@ -247,30 +247,18 @@ static void transform_decompose(Transform *decomp, const Transform *tfm)
decomp->w = make_float4(scale.y.z, scale.z.x, scale.z.y, scale.z.z);
}
-void transform_motion_decompose(DecompMotionTransform *decomp, const MotionTransform *motion, const Transform *mid)
+void transform_motion_decompose(MotionTransform *decomp, const MotionTransform *motion, const Transform *mid)
{
- Transform pre, post;
-
- transform_decompose(&pre, &motion->pre);
+ transform_decompose(&decomp->pre, &motion->pre);
transform_decompose(&decomp->mid, mid);
- transform_decompose(&post, &motion->post);
+ transform_decompose(&decomp->post, &motion->post);
/* ensure rotation around shortest angle, negated quaternions are the same
* but this means we don't have to do the check in quat_interpolate */
- if(dot(decomp->mid.x, post.x) < 0.0f)
+ if(dot(decomp->pre.x, decomp->mid.x) < 0.0f)
+ decomp->pre.x = -decomp->pre.x;
+ if(dot(decomp->mid.x, decomp->post.x) < 0.0f)
decomp->mid.x = -decomp->mid.x;
- if(dot(pre.x, decomp->mid.x) < 0.0f)
- pre.x = -pre.x;
-
- /* drop scale of pre/post */
- pre.y.w = decomp->mid.y.w;
- post.y.w = decomp->mid.y.w;
-
- /* store translation/rotation part of pre/post */
- decomp->pre_x = pre.x;
- decomp->pre_y = pre.y;
- decomp->post_x = post.x;
- decomp->post_y = post.y;
}
Transform transform_from_viewplane(BoundBox2D& viewplane)
diff --git a/intern/cycles/util/util_transform.h b/intern/cycles/util/util_transform.h
index aef168ca64d..ac0804a7227 100644
--- a/intern/cycles/util/util_transform.h
+++ b/intern/cycles/util/util_transform.h
@@ -39,9 +39,7 @@ typedef struct Transform {
/* transform decomposed in rotation/translation/scale. we use the same data
* structure as Transform, and tightly pack decomposition into it. first the
- * rotation (4), then translation (3), then 3x3 scale matrix (9).
- *
- * For the DecompMotionTransform we drop scale from pre/post. */
+ * rotation (4), then translation (3), then 3x3 scale matrix (9). */
typedef struct ccl_may_alias MotionTransform {
Transform pre;
@@ -49,12 +47,6 @@ typedef struct ccl_may_alias MotionTransform {
Transform post;
} MotionTransform;
-typedef struct DecompMotionTransform {
- Transform mid;
- float4 pre_x, pre_y;
- float4 post_x, post_y;
-} DecompMotionTransform;
-
typedef struct PerspectiveMotionTransform {
Transform pre;
Transform post;
@@ -466,7 +458,7 @@ ccl_device_inline void transform_compose(Transform *tfm, const Transform *decomp
/* Disabled for now, need arc-length parametrization for constant speed motion.
* #define CURVED_MOTION_INTERPOLATE */
-ccl_device void transform_motion_interpolate(Transform *tfm, const DecompMotionTransform *motion, float t)
+ccl_device void transform_motion_interpolate(Transform *tfm, const MotionTransform *motion, float t)
{
/* possible optimization: is it worth it adding a check to skip scaling?
* it's probably quite uncommon to have scaling objects. or can we skip
@@ -475,9 +467,9 @@ ccl_device void transform_motion_interpolate(Transform *tfm, const DecompMotionT
#ifdef CURVED_MOTION_INTERPOLATE
/* 3 point bezier curve interpolation for position */
- float3 Ppre = float4_to_float3(motion->pre_y);
+ float3 Ppre = float4_to_float3(motion->pre.y);
float3 Pmid = float4_to_float3(motion->mid.y);
- float3 Ppost = float4_to_float3(motion->post_y);
+ float3 Ppost = float4_to_float3(motion->post.y);
float3 Pcontrol = 2.0f*Pmid - 0.5f*(Ppre + Ppost);
float3 P = Ppre*t*t + Pcontrol*2.0f*t*(1.0f - t) + Ppost*(1.0f - t)*(1.0f - t);
@@ -491,27 +483,28 @@ ccl_device void transform_motion_interpolate(Transform *tfm, const DecompMotionT
if(t < 0.5f) {
t *= 2.0f;
- decomp.x = quat_interpolate(motion->pre_x, motion->mid.x, t);
+ decomp.x = quat_interpolate(motion->pre.x, motion->mid.x, t);
#ifdef CURVED_MOTION_INTERPOLATE
- decomp.y.w = (1.0f - t)*motion->pre_y.w + t*motion->mid.y.w;
+ decomp.y.w = (1.0f - t)*motion->pre.y.w + t*motion->mid.y.w;
#else
- decomp.y = (1.0f - t)*motion->pre_y + t*motion->mid.y;
+ decomp.y = (1.0f - t)*motion->pre.y + t*motion->mid.y;
#endif
+ decomp.z = (1.0f - t)*motion->pre.z + t*motion->mid.z;
+ decomp.w = (1.0f - t)*motion->pre.w + t*motion->mid.w;
}
else {
t = (t - 0.5f)*2.0f;
- decomp.x = quat_interpolate(motion->mid.x, motion->post_x, t);
+ decomp.x = quat_interpolate(motion->mid.x, motion->post.x, t);
#ifdef CURVED_MOTION_INTERPOLATE
- decomp.y.w = (1.0f - t)*motion->mid.y.w + t*motion->post_y.w;
+ decomp.y.w = (1.0f - t)*motion->mid.y.w + t*motion->post.y.w;
#else
- decomp.y = (1.0f - t)*motion->mid.y + t*motion->post_y;
+ decomp.y = (1.0f - t)*motion->mid.y + t*motion->post.y;
#endif
+ decomp.z = (1.0f - t)*motion->mid.z + t*motion->post.z;
+ decomp.w = (1.0f - t)*motion->mid.w + t*motion->post.w;
}
- decomp.z = motion->mid.z;
- decomp.w = motion->mid.w;
-
/* compose rotation, translation, scale into matrix */
transform_compose(tfm, &decomp);
}
@@ -526,7 +519,7 @@ ccl_device_inline bool operator==(const MotionTransform& A, const MotionTransfor
}
float4 transform_to_quat(const Transform& tfm);
-void transform_motion_decompose(DecompMotionTransform *decomp, const MotionTransform *motion, const Transform *mid);
+void transform_motion_decompose(MotionTransform *decomp, const MotionTransform *motion, const Transform *mid);
Transform transform_from_viewplane(BoundBox2D& viewplane);
#endif