Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/geom/geom_motion_curve.h
| Show All 21 Lines | |||||
| * other than the frame center. Computing the curve keys at a given ray time is | * other than the frame center. Computing the curve keys at a given ray time is | ||||
| * a matter of interpolation of the two steps between which the ray time lies. | * a matter of interpolation of the two steps between which the ray time lies. | ||||
| * | * | ||||
| * The extra curve keys are stored as ATTR_STD_MOTION_VERTEX_POSITION. | * The extra curve keys are stored as ATTR_STD_MOTION_VERTEX_POSITION. | ||||
| */ | */ | ||||
| #ifdef __HAIR__ | #ifdef __HAIR__ | ||||
| ccl_device_inline void motion_curve_keys_for_step_linear(ccl_global const KernelGlobals *kg, | ccl_device_inline void motion_curve_keys_for_step_linear(KernelGlobals kg, | ||||
| int offset, | int offset, | ||||
| int numkeys, | int numkeys, | ||||
| int numsteps, | int numsteps, | ||||
| int step, | int step, | ||||
| int k0, | int k0, | ||||
| int k1, | int k1, | ||||
| float4 keys[2]) | float4 keys[2]) | ||||
| { | { | ||||
| Show All 10 Lines | else { | ||||
| offset += step * numkeys; | offset += step * numkeys; | ||||
| keys[0] = kernel_tex_fetch(__attributes_float3, offset + k0); | keys[0] = kernel_tex_fetch(__attributes_float3, offset + k0); | ||||
| keys[1] = kernel_tex_fetch(__attributes_float3, offset + k1); | keys[1] = kernel_tex_fetch(__attributes_float3, offset + k1); | ||||
| } | } | ||||
| } | } | ||||
| /* return 2 curve key locations */ | /* return 2 curve key locations */ | ||||
| ccl_device_inline void motion_curve_keys_linear(ccl_global const KernelGlobals *kg, | ccl_device_inline void motion_curve_keys_linear( | ||||
| int object, | KernelGlobals kg, int object, int prim, float time, int k0, int k1, float4 keys[2]) | ||||
| int prim, | |||||
| float time, | |||||
| int k0, | |||||
| int k1, | |||||
| float4 keys[2]) | |||||
| { | { | ||||
| /* get motion info */ | /* get motion info */ | ||||
| int numsteps, numkeys; | int numsteps, numkeys; | ||||
| object_motion_info(kg, object, &numsteps, NULL, &numkeys); | object_motion_info(kg, object, &numsteps, NULL, &numkeys); | ||||
| /* figure out which steps we need to fetch and their interpolation factor */ | /* figure out which steps we need to fetch and their interpolation factor */ | ||||
| const int maxstep = numsteps * 2; | const int maxstep = numsteps * 2; | ||||
| const int step = min((int)(time * maxstep), maxstep - 1); | const int step = min((int)(time * maxstep), maxstep - 1); | ||||
| Show All 9 Lines | ccl_device_inline void motion_curve_keys_linear( | ||||
| motion_curve_keys_for_step_linear(kg, offset, numkeys, numsteps, step, k0, k1, keys); | motion_curve_keys_for_step_linear(kg, offset, numkeys, numsteps, step, k0, k1, keys); | ||||
| motion_curve_keys_for_step_linear(kg, offset, numkeys, numsteps, step + 1, k0, k1, next_keys); | motion_curve_keys_for_step_linear(kg, offset, numkeys, numsteps, step + 1, k0, k1, next_keys); | ||||
| /* interpolate between steps */ | /* interpolate between steps */ | ||||
| keys[0] = (1.0f - t) * keys[0] + t * next_keys[0]; | keys[0] = (1.0f - t) * keys[0] + t * next_keys[0]; | ||||
| keys[1] = (1.0f - t) * keys[1] + t * next_keys[1]; | keys[1] = (1.0f - t) * keys[1] + t * next_keys[1]; | ||||
| } | } | ||||
| ccl_device_inline void motion_curve_keys_for_step(ccl_global const KernelGlobals *kg, | ccl_device_inline void motion_curve_keys_for_step(KernelGlobals kg, | ||||
| int offset, | int offset, | ||||
| int numkeys, | int numkeys, | ||||
| int numsteps, | int numsteps, | ||||
| int step, | int step, | ||||
| int k0, | int k0, | ||||
| int k1, | int k1, | ||||
| int k2, | int k2, | ||||
| int k3, | int k3, | ||||
| Show All 16 Lines | else { | ||||
| keys[0] = kernel_tex_fetch(__attributes_float3, offset + k0); | keys[0] = kernel_tex_fetch(__attributes_float3, offset + k0); | ||||
| keys[1] = kernel_tex_fetch(__attributes_float3, offset + k1); | keys[1] = kernel_tex_fetch(__attributes_float3, offset + k1); | ||||
| keys[2] = kernel_tex_fetch(__attributes_float3, offset + k2); | keys[2] = kernel_tex_fetch(__attributes_float3, offset + k2); | ||||
| keys[3] = kernel_tex_fetch(__attributes_float3, offset + k3); | keys[3] = kernel_tex_fetch(__attributes_float3, offset + k3); | ||||
| } | } | ||||
| } | } | ||||
| /* return 2 curve key locations */ | /* return 2 curve key locations */ | ||||
| ccl_device_inline void motion_curve_keys(ccl_global const KernelGlobals *kg, | ccl_device_inline void motion_curve_keys(KernelGlobals kg, | ||||
| int object, | int object, | ||||
| int prim, | int prim, | ||||
| float time, | float time, | ||||
| int k0, | int k0, | ||||
| int k1, | int k1, | ||||
| int k2, | int k2, | ||||
| int k3, | int k3, | ||||
| float4 keys[4]) | float4 keys[4]) | ||||
| Show All 30 Lines | |||||