Cycles: Fix wrong intersection with motion blur and degenerate object transform
authorSergey Sharybin <sergey.vfx@gmail.com>
Thu, 8 Oct 2015 16:24:54 +0000 (21:24 +0500)
committerSergey Sharybin <sergey.vfx@gmail.com>
Fri, 9 Oct 2015 10:58:03 +0000 (15:58 +0500)
intern/cycles/kernel/geom/geom_bvh_shadow.h
intern/cycles/kernel/geom/geom_bvh_subsurface.h
intern/cycles/kernel/geom/geom_bvh_traversal.h
intern/cycles/kernel/geom/geom_bvh_volume.h
intern/cycles/kernel/geom/geom_bvh_volume_all.h
intern/cycles/kernel/geom/geom_object.h
intern/cycles/kernel/geom/geom_qbvh_shadow.h
intern/cycles/kernel/geom/geom_qbvh_subsurface.h
intern/cycles/kernel/geom/geom_qbvh_traversal.h
intern/cycles/kernel/geom/geom_qbvh_volume.h
intern/cycles/kernel/geom/geom_qbvh_volume_all.h

index e4cba99dc9600dc1818d1a68ab1330102f430819..cb3f75f2a8f8fdb6149bd0f3418b42586ff63988 100644 (file)
@@ -59,7 +59,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
        float isect_t = tmax;
 
 #if BVH_FEATURE(BVH_MOTION)
-       Transform ob_tfm;
+       Transform ob_itfm;
 #endif
 
 #if BVH_FEATURE(BVH_INSTANCING)
@@ -302,7 +302,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
                                        object = kernel_tex_fetch(__prim_object, -primAddr-1);
 
 #if BVH_FEATURE(BVH_MOTION)
-                                       bvh_instance_motion_push(kg, object, ray, &P, &dir, &idir, &isect_t, &ob_tfm);
+                                       bvh_instance_motion_push(kg, object, ray, &P, &dir, &idir, &isect_t, &ob_itfm);
 #else
                                        bvh_instance_push(kg, object, ray, &P, &dir, &idir, &isect_t);
 #endif
@@ -338,7 +338,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
                                float t_fac;
 
 #if BVH_FEATURE(BVH_MOTION)
-                               bvh_instance_motion_pop_factor(kg, object, ray, &P, &dir, &idir, &t_fac, &ob_tfm);
+                               bvh_instance_motion_pop_factor(kg, object, ray, &P, &dir, &idir, &t_fac, &ob_itfm);
 #else
                                bvh_instance_pop_factor(kg, object, ray, &P, &dir, &idir, &t_fac);
 #endif
@@ -353,7 +353,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
                                float ignore_t = FLT_MAX;
 
 #if BVH_FEATURE(BVH_MOTION)
-                               bvh_instance_motion_pop(kg, object, ray, &P, &dir, &idir, &ignore_t, &ob_tfm);
+                               bvh_instance_motion_pop(kg, object, ray, &P, &dir, &idir, &ignore_t, &ob_itfm);
 #else
                                bvh_instance_pop(kg, object, ray, &P, &dir, &idir, &ignore_t);
 #endif
index a73139f9c88dec389046999eabe1a88af4e5d0bb..a093b9b55aace7c9acc70c116f9454c12c5f8986 100644 (file)
@@ -63,7 +63,7 @@ ccl_device uint BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
        uint num_hits = 0;
 
 #if BVH_FEATURE(BVH_MOTION)
-       Transform ob_tfm;
+       Transform ob_itfm;
 #endif
 
 #if defined(__KERNEL_SSE2__)
@@ -240,7 +240,7 @@ ccl_device uint BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
                                                object = subsurface_object;
 
 #if BVH_FEATURE(BVH_MOTION)
-                                               bvh_instance_motion_push(kg, object, ray, &P, &dir, &idir, &isect_t, &ob_tfm);
+                                               bvh_instance_motion_push(kg, object, ray, &P, &dir, &idir, &isect_t, &ob_itfm);
 #else
                                                bvh_instance_push(kg, object, ray, &P, &dir, &idir, &isect_t);
 #endif
@@ -278,7 +278,7 @@ ccl_device uint BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
 
                        /* instance pop */
 #if BVH_FEATURE(BVH_MOTION)
-                       bvh_instance_motion_pop(kg, object, ray, &P, &dir, &idir, &isect_t, &ob_tfm);
+                       bvh_instance_motion_pop(kg, object, ray, &P, &dir, &idir, &isect_t, &ob_itfm);
 #else
                        bvh_instance_pop(kg, object, ray, &P, &dir, &idir, &isect_t);
 #endif
index 73d79fd78ee24cc987f66b43aed1471efac62ac8..13d118b6d1935e62d7af1726a9c585516d6543ef 100644 (file)
@@ -65,7 +65,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
        int object = OBJECT_NONE;
 
 #if BVH_FEATURE(BVH_MOTION)
-       Transform ob_tfm;
+       Transform ob_itfm;
 #endif
 
        isect->t = ray->t;
@@ -342,7 +342,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
                                        object = kernel_tex_fetch(__prim_object, -primAddr-1);
 
 #if BVH_FEATURE(BVH_MOTION)
-                                       bvh_instance_motion_push(kg, object, ray, &P, &dir, &idir, &isect->t, &ob_tfm);
+                                       bvh_instance_motion_push(kg, object, ray, &P, &dir, &idir, &isect->t, &ob_itfm);
 #else
                                        bvh_instance_push(kg, object, ray, &P, &dir, &idir, &isect->t);
 #endif
@@ -378,7 +378,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
 
                        /* instance pop */
 #if BVH_FEATURE(BVH_MOTION)
-                       bvh_instance_motion_pop(kg, object, ray, &P, &dir, &idir, &isect->t, &ob_tfm);
+                       bvh_instance_motion_pop(kg, object, ray, &P, &dir, &idir, &isect->t, &ob_itfm);
 #else
                        bvh_instance_pop(kg, object, ray, &P, &dir, &idir, &isect->t);
 #endif
index 41c784869f2748d014ab310a0ee1364a8858a5e7..656cd6e7a0ebe9cafc91ef6b493d8cbf2d9f7675 100644 (file)
@@ -59,7 +59,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
        const uint visibility = PATH_RAY_ALL_VISIBILITY;
 
 #if BVH_FEATURE(BVH_MOTION)
-       Transform ob_tfm;
+       Transform ob_itfm;
 #endif
 
        isect->t = ray->t;
@@ -267,7 +267,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
                                        if(object_flag & SD_OBJECT_HAS_VOLUME) {
 
 #if BVH_FEATURE(BVH_MOTION)
-                                               bvh_instance_motion_push(kg, object, ray, &P, &dir, &idir, &isect->t, &ob_tfm);
+                                               bvh_instance_motion_push(kg, object, ray, &P, &dir, &idir, &isect->t, &ob_itfm);
 #else
                                                bvh_instance_push(kg, object, ray, &P, &dir, &idir, &isect->t);
 #endif
@@ -307,7 +307,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
 
                        /* instance pop */
 #if BVH_FEATURE(BVH_MOTION)
-                       bvh_instance_motion_pop(kg, object, ray, &P, &dir, &idir, &isect->t, &ob_tfm);
+                       bvh_instance_motion_pop(kg, object, ray, &P, &dir, &idir, &isect->t, &ob_itfm);
 #else
                        bvh_instance_pop(kg, object, ray, &P, &dir, &idir, &isect->t);
 #endif
index 5bb7a67f10bb6cfc17ce76d56f5c303c3d29dde3..8f7e3adae51d346b1043dca51c592a2663fa8a05 100644 (file)
@@ -62,7 +62,7 @@ ccl_device uint BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
        const uint visibility = PATH_RAY_ALL_VISIBILITY;
 
 #if BVH_FEATURE(BVH_MOTION)
-       Transform ob_tfm;
+       Transform ob_itfm;
 #endif
 
 #if BVH_FEATURE(BVH_INSTANCING)
@@ -230,7 +230,7 @@ ccl_device uint BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
                                                                        if(num_hits == max_hits) {
 #if BVH_FEATURE(BVH_INSTANCING)
 #if BVH_FEATURE(BVH_MOTION)
-                                                                               float t_fac = len(transform_direction(&ob_tfm, 1.0f/idir));
+                                                                               float t_fac = 1.0f / len(transform_direction(&ob_itfm, dir));
 #else
                                                                                Transform itfm = object_fetch_transform(kg, object, OBJECT_INVERSE_TRANSFORM);
                                                                                float t_fac = 1.0f / len(transform_direction(&itfm, dir));
@@ -268,7 +268,7 @@ ccl_device uint BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
                                                                        if(num_hits == max_hits) {
 #if BVH_FEATURE(BVH_INSTANCING)
 #  if BVH_FEATURE(BVH_MOTION)
-                                                                               float t_fac = len(transform_direction(&ob_tfm, 1.0f/idir));
+                                                                               float t_fac = 1.0f / len(transform_direction(&ob_itfm, dir));
 #  else
                                                                                Transform itfm = object_fetch_transform(kg, object, OBJECT_INVERSE_TRANSFORM);
                                                                                float t_fac = 1.0f / len(transform_direction(&itfm, dir));
@@ -311,7 +311,7 @@ ccl_device uint BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
                                                                        if(num_hits == max_hits) {
 #if BVH_FEATURE(BVH_INSTANCING)
 #  if BVH_FEATURE(BVH_MOTION)
-                                                                               float t_fac = len(transform_direction(&ob_tfm, 1.0f/idir));
+                                                                               float t_fac = 1.0f / len(transform_direction(&ob_itfm, dir));
 #  else
                                                                                Transform itfm = object_fetch_transform(kg, object, OBJECT_INVERSE_TRANSFORM);
                                                                                float t_fac = 1.0f / len(transform_direction(&itfm, dir));
@@ -341,7 +341,7 @@ ccl_device uint BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
                                        if(object_flag & SD_OBJECT_HAS_VOLUME) {
 
 #if BVH_FEATURE(BVH_MOTION)
-                                               bvh_instance_motion_push(kg, object, ray, &P, &dir, &idir, &isect_t, &ob_tfm);
+                                               bvh_instance_motion_push(kg, object, ray, &P, &dir, &idir, &isect_t, &ob_itfm);
 #else
                                                bvh_instance_push(kg, object, ray, &P, &dir, &idir, &isect_t);
 #endif
@@ -384,7 +384,7 @@ ccl_device uint BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
                        if(num_hits_in_instance) {
                                float t_fac;
 #if BVH_FEATURE(BVH_MOTION)
-                               bvh_instance_motion_pop_factor(kg, object, ray, &P, &dir, &idir, &t_fac, &ob_tfm);
+                               bvh_instance_motion_pop_factor(kg, object, ray, &P, &dir, &idir, &t_fac, &ob_itfm);
 #else
                                bvh_instance_pop_factor(kg, object, ray, &P, &dir, &idir, &t_fac);
 #endif
@@ -397,7 +397,7 @@ ccl_device uint BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
                        else {
                                float ignore_t = FLT_MAX;
 #if BVH_FEATURE(BVH_MOTION)
-                               bvh_instance_motion_pop(kg, object, ray, &P, &dir, &idir, &ignore_t, &ob_tfm);
+                               bvh_instance_motion_pop(kg, object, ray, &P, &dir, &idir, &ignore_t, &ob_itfm);
 #else
                                bvh_instance_pop(kg, object, ray, &P, &dir, &idir, &ignore_t);
 #endif
index bf1a3eb2413cf0d4d67dd3280cc34ee526361a36..ffd2f3b778f6e75a1382de2e184f4170429a7c9b 100644 (file)
@@ -453,15 +453,21 @@ ccl_device_inline void bvh_instance_pop_factor(KernelGlobals *kg, int object, co
 #ifdef __OBJECT_MOTION__
 /* Transform ray into object space to enter motion blurred object in BVH */
 
-ccl_device_inline void bvh_instance_motion_push(KernelGlobals *kg, int object, const Ray *ray, float3 *P, float3 *dir, float3 *idir, ccl_addr_space float *t, Transform *tfm)
+ccl_device_inline void bvh_instance_motion_push(KernelGlobals *kg,
+                                                int object,
+                                                const Ray *ray,
+                                                float3 *P,
+                                                float3 *dir,
+                                                float3 *idir,
+                                                ccl_addr_space float *t,
+                                                Transform *itfm)
 {
-       Transform itfm;
-       *tfm = object_fetch_transform_motion_test(kg, object, ray->time, &itfm);
+       object_fetch_transform_motion_test(kg, object, ray->time, itfm);
 
-       *P = transform_point(&itfm, ray->P);
+       *P = transform_point(itfm, ray->P);
 
        float len;
-       *dir = bvh_clamp_direction(normalize_len(transform_direction(&itfm, ray->D), &len));
+       *dir = bvh_clamp_direction(normalize_len(transform_direction(itfm, ray->D), &len));
        *idir = bvh_inverse_direction(*dir);
 
        if(*t != FLT_MAX)
@@ -475,18 +481,24 @@ ccl_device_inline void bvh_instance_motion_push(KernelGlobals *kg, int object, c
  * TODO(sergey): Investigate if passing NULL instead of t1 gets optimized
  * so we can avoid having this duplication.
  */
-ccl_device_inline void qbvh_instance_motion_push(KernelGlobals *kg, int object, const Ray *ray, float3 *P, float3 *dir, float3 *idir, float *t, float *t1, Transform *tfm)
+ccl_device_inline void qbvh_instance_motion_push(KernelGlobals *kg,
+                                                 int object,
+                                                 const Ray *ray,
+                                                 float3 *P,
+                                                 float3 *dir,
+                                                 float3 *idir,
+                                                 float *t,
+                                                 float *t1,
+                                                 Transform *itfm)
 {
-       Transform itfm;
-       *tfm = object_fetch_transform_motion_test(kg, object, ray->time, &itfm);
+       object_fetch_transform_motion_test(kg, object, ray->time, itfm);
 
-       *P = transform_point(&itfm, ray->P);
+       *P = transform_point(itfm, ray->P);
 
        float len;
-       *dir = bvh_clamp_direction(normalize_len(transform_direction(&itfm, ray->D), &len));
+       *dir = bvh_clamp_direction(normalize_len(transform_direction(itfm, ray->D), &len));
        *idir = bvh_inverse_direction(*dir);
 
-
        if(*t != FLT_MAX)
                *t *= len;
 
@@ -497,10 +509,18 @@ ccl_device_inline void qbvh_instance_motion_push(KernelGlobals *kg, int object,
 
 /* Transorm ray to exit motion blurred object in BVH */
 
-ccl_device_inline void bvh_instance_motion_pop(KernelGlobals *kg, int object, const Ray *ray, float3 *P, float3 *dir, float3 *idir, ccl_addr_space float *t, Transform *tfm)
+ccl_device_inline void bvh_instance_motion_pop(KernelGlobals *kg,
+                                               int object,
+                                               const Ray *ray,
+                                               float3 *P,
+                                               float3 *dir,
+                                               float3 *idir,
+                                               ccl_addr_space float *t,
+                                               Transform *itfm)
 {
-       if(*t != FLT_MAX)
-               *t *= len(transform_direction(tfm, 1.0f/(*idir)));
+       if(*t != FLT_MAX) {
+               *t /= len(transform_direction(itfm, ray->D));
+       }
 
        *P = ray->P;
        *dir = bvh_clamp_direction(ray->D);
@@ -509,10 +529,16 @@ ccl_device_inline void bvh_instance_motion_pop(KernelGlobals *kg, int object, co
 
 /* Same as above, but returns scale factor to apply to multiple intersection distances */
 
-ccl_device_inline void bvh_instance_motion_pop_factor(KernelGlobals *kg, int object, const Ray *ray, float3 *P, float3 *dir, float3 *idir, float *t_fac, Transform *tfm)
+ccl_device_inline void bvh_instance_motion_pop_factor(KernelGlobals *kg,
+                                                      int object,
+                                                      const Ray *ray,
+                                                      float3 *P,
+                                                      float3 *dir,
+                                                      float3 *idir,
+                                                      float *t_fac,
+                                                      Transform *itfm)
 {
-       *t_fac = len(transform_direction(tfm, 1.0f/(*idir)));
-
+       *t_fac /= len(transform_direction(itfm, ray->D));
        *P = ray->P;
        *dir = bvh_clamp_direction(ray->D);
        *idir = bvh_inverse_direction(*dir);
index dc37e6ecfa41eda36df5d60ed1ff6a41b86cf168..4564d5baf5ecbd554d97a2aba3025f5bd50d7d85 100644 (file)
@@ -55,7 +55,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
        float isect_t = tmax;
 
 #if BVH_FEATURE(BVH_MOTION)
-       Transform ob_tfm;
+       Transform ob_itfm;
 #endif
 
        *num_hits = 0;
@@ -317,7 +317,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
                                        object = kernel_tex_fetch(__prim_object, -primAddr-1);
 
 #if BVH_FEATURE(BVH_MOTION)
-                                       bvh_instance_motion_push(kg, object, ray, &P, &dir, &idir, &isect_t, &ob_tfm);
+                                       bvh_instance_motion_push(kg, object, ray, &P, &dir, &idir, &isect_t, &ob_itfm);
 #else
                                        bvh_instance_push(kg, object, ray, &P, &dir, &idir, &isect_t);
 #endif
@@ -357,7 +357,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
                                float t_fac;
 
 #if BVH_FEATURE(BVH_MOTION)
-                               bvh_instance_motion_pop_factor(kg, object, ray, &P, &dir, &idir, &t_fac, &ob_tfm);
+                               bvh_instance_motion_pop_factor(kg, object, ray, &P, &dir, &idir, &t_fac, &ob_itfm);
 #else
                                bvh_instance_pop_factor(kg, object, ray, &P, &dir, &idir, &t_fac);
 #endif
@@ -370,7 +370,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
                                float ignore_t = FLT_MAX;
 
 #if BVH_FEATURE(BVH_MOTION)
-                               bvh_instance_motion_pop(kg, object, ray, &P, &dir, &idir, &ignore_t, &ob_tfm);
+                               bvh_instance_motion_pop(kg, object, ray, &P, &dir, &idir, &ignore_t, &ob_itfm);
 #else
                                bvh_instance_pop(kg, object, ray, &P, &dir, &idir, &ignore_t);
 #endif
index d85e1a4691ec09bd0fc832a26d49206bac9f35ac..fe231720cf73f395d441dd1c3aa3317cc2e106dc 100644 (file)
@@ -58,7 +58,7 @@ ccl_device uint BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
        uint num_hits = 0;
 
 #if BVH_FEATURE(BVH_MOTION)
-       Transform ob_tfm;
+       Transform ob_itfm;
 #endif
 
 #ifndef __KERNEL_SSE41__
@@ -256,7 +256,7 @@ ccl_device uint BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
                                                object = subsurface_object;
 
 #if BVH_FEATURE(BVH_MOTION)
-                                               bvh_instance_motion_push(kg, object, ray, &P, &dir, &idir, &isect_t, &ob_tfm);
+                                               bvh_instance_motion_push(kg, object, ray, &P, &dir, &idir, &isect_t, &ob_itfm);
 #else
                                                bvh_instance_push(kg, object, ray, &P, &dir, &idir, &isect_t);
 #endif
@@ -297,7 +297,7 @@ ccl_device uint BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
 
                        /* Instance pop. */
 #if BVH_FEATURE(BVH_MOTION)
-                       bvh_instance_motion_pop(kg, object, ray, &P, &dir, &idir, &isect_t, &ob_tfm);
+                       bvh_instance_motion_pop(kg, object, ray, &P, &dir, &idir, &isect_t, &ob_itfm);
 #else
                        bvh_instance_pop(kg, object, ray, &P, &dir, &idir, &isect_t);
 #endif
index 7e356ea062b8a669ca5c9cd170ee9e4d4fe566b5..4e1678665c09ca70bca53cd4e41b9936b2a695d4 100644 (file)
@@ -63,7 +63,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
        int object = OBJECT_NONE;
 
 #if BVH_FEATURE(BVH_MOTION)
-       Transform ob_tfm;
+       Transform ob_itfm;
 #endif
 
 #ifndef __KERNEL_SSE41__
@@ -356,7 +356,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
                                        object = kernel_tex_fetch(__prim_object, -primAddr-1);
 
 #if BVH_FEATURE(BVH_MOTION)
-                                       qbvh_instance_motion_push(kg, object, ray, &P, &dir, &idir, &isect->t, &nodeDist, &ob_tfm);
+                                       qbvh_instance_motion_push(kg, object, ray, &P, &dir, &idir, &isect->t, &nodeDist, &ob_itfm);
 #else
                                        qbvh_instance_push(kg, object, ray, &P, &dir, &idir, &isect->t, &nodeDist);
 #endif
@@ -395,7 +395,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
 
                        /* Instance pop. */
 #if BVH_FEATURE(BVH_MOTION)
-                       bvh_instance_motion_pop(kg, object, ray, &P, &dir, &idir, &isect->t, &ob_tfm);
+                       bvh_instance_motion_pop(kg, object, ray, &P, &dir, &idir, &isect->t, &ob_itfm);
 #else
                        bvh_instance_pop(kg, object, ray, &P, &dir, &idir, &isect->t);
 #endif
index d8cfa3a4061e3ebd703276b298d94898a728a0a9..40864471d13441c401cfc8bfa963ee9b837a9e58 100644 (file)
@@ -54,7 +54,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
        const uint visibility = PATH_RAY_ALL_VISIBILITY;
 
 #if BVH_FEATURE(BVH_MOTION)
-       Transform ob_tfm;
+       Transform ob_itfm;
 #endif
 
 #ifndef __KERNEL_SSE41__
@@ -281,7 +281,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
                                        if(object_flag & SD_OBJECT_HAS_VOLUME) {
 
 #if BVH_FEATURE(BVH_MOTION)
-                                               bvh_instance_motion_push(kg, object, ray, &P, &dir, &idir, &isect->t, &ob_tfm);
+                                               bvh_instance_motion_push(kg, object, ray, &P, &dir, &idir, &isect->t, &ob_itfm);
 #else
                                                bvh_instance_push(kg, object, ray, &P, &dir, &idir, &isect->t);
 #endif
@@ -322,7 +322,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
 
                        /* Instance pop. */
 #if BVH_FEATURE(BVH_MOTION)
-                       bvh_instance_motion_pop(kg, object, ray, &P, &dir, &idir, &isect->t, &ob_tfm);
+                       bvh_instance_motion_pop(kg, object, ray, &P, &dir, &idir, &isect->t, &ob_itfm);
 #else
                        bvh_instance_pop(kg, object, ray, &P, &dir, &idir, &isect->t);
 #endif
index 2baf23d6bd63891b84fbb524c8e2cd1153186f84..75e4c4e8d9611df36ab37d76967de4783b13262a 100644 (file)
@@ -57,7 +57,7 @@ ccl_device uint BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
        const uint visibility = PATH_RAY_ALL_VISIBILITY;
 
 #if BVH_FEATURE(BVH_MOTION)
-       Transform ob_tfm;
+       Transform ob_itfm;
 #endif
 
        uint num_hits = 0;
@@ -247,7 +247,7 @@ ccl_device uint BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
                                                                        if(num_hits == max_hits) {
 #if BVH_FEATURE(BVH_INSTANCING)
 #if BVH_FEATURE(BVH_MOTION)
-                                                                               float t_fac = len(transform_direction(&ob_tfm, 1.0f/idir));
+                                                                               float t_fac = 1.0f / len(transform_direction(&ob_itfm, dir));
 #else
                                                                                Transform itfm = object_fetch_transform(kg, object, OBJECT_INVERSE_TRANSFORM);
                                                                                float t_fac = 1.0f / len(transform_direction(&itfm, dir));
@@ -285,7 +285,7 @@ ccl_device uint BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
                                                                        if(num_hits == max_hits) {
 #if BVH_FEATURE(BVH_INSTANCING)
 #  if BVH_FEATURE(BVH_MOTION)
-                                                                               float t_fac = len(transform_direction(&ob_tfm, 1.0f/idir));
+                                                                               float t_fac = 1.0f / len(transform_direction(&ob_itfm, dir));
 #  else
                                                                                Transform itfm = object_fetch_transform(kg, object, OBJECT_INVERSE_TRANSFORM);
                                                                                float t_fac = 1.0f / len(transform_direction(&itfm, dir));
@@ -328,7 +328,7 @@ ccl_device uint BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
                                                                        if(num_hits == max_hits) {
 #if BVH_FEATURE(BVH_INSTANCING)
 #  if BVH_FEATURE(BVH_MOTION)
-                                                                               float t_fac = len(transform_direction(&ob_tfm, 1.0f/idir));
+                                                                               float t_fac = 1.0f / len(transform_direction(&ob_itfm, dir));
 #  else
                                                                                Transform itfm = object_fetch_transform(kg, object, OBJECT_INVERSE_TRANSFORM);
                                                                                float t_fac = 1.0f / len(transform_direction(&itfm, dir));
@@ -355,7 +355,7 @@ ccl_device uint BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
                                        if(object_flag & SD_OBJECT_HAS_VOLUME) {
 
 #if BVH_FEATURE(BVH_MOTION)
-                                               bvh_instance_motion_push(kg, object, ray, &P, &dir, &idir, &isect_t, &ob_tfm);
+                                               bvh_instance_motion_push(kg, object, ray, &P, &dir, &idir, &isect_t, &ob_itfm);
 #else
                                                bvh_instance_push(kg, object, ray, &P, &dir, &idir, &isect_t);
 #endif
@@ -400,7 +400,7 @@ ccl_device uint BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
                        if(num_hits_in_instance) {
                                float t_fac;
 #if BVH_FEATURE(BVH_MOTION)
-                               bvh_instance_motion_pop_factor(kg, object, ray, &P, &dir, &idir, &t_fac, &ob_tfm);
+                               bvh_instance_motion_pop_factor(kg, object, ray, &P, &dir, &idir, &t_fac, &ob_itfm);
 #else
                                bvh_instance_pop_factor(kg, object, ray, &P, &dir, &idir, &t_fac);
 #endif
@@ -413,7 +413,7 @@ ccl_device uint BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
                        else {
                                float ignore_t = FLT_MAX;
 #if BVH_FEATURE(BVH_MOTION)
-                               bvh_instance_motion_pop(kg, object, ray, &P, &dir, &idir, &ignore_t, &ob_tfm);
+                               bvh_instance_motion_pop(kg, object, ray, &P, &dir, &idir, &ignore_t, &ob_itfm);
 #else
                                bvh_instance_pop(kg, object, ray, &P, &dir, &idir, &ignore_t);
 #endif