Blender V4.3
motion_point.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2021-2022 Blender Foundation
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
6
7/* Motion Point Primitive
8 *
9 * These are stored as regular points, plus extra positions and radii at times
10 * other than the frame center. Computing the point at a given ray time is
11 * a matter of interpolation of the two steps between which the ray time lies.
12 *
13 * The extra points are stored as ATTR_STD_MOTION_VERTEX_POSITION.
14 */
15
16#ifdef __POINTCLOUD__
17
19motion_point_for_step(KernelGlobals kg, int offset, int numverts, int numsteps, int step, int prim)
20{
21 if (step == numsteps) {
22 /* center step: regular key location */
23 return kernel_data_fetch(points, prim);
24 }
25 else {
26 /* center step is not stored in this array */
27 if (step > numsteps)
28 step--;
29
30 offset += step * numverts;
31
32 return kernel_data_fetch(attributes_float4, offset + prim);
33 }
34}
35
36/* return 2 point key locations */
37ccl_device_inline float4 motion_point(KernelGlobals kg, int object, int prim, float time)
38{
39 /* get motion info */
40 const int numsteps = kernel_data_fetch(objects, object).numsteps;
41 const int numverts = kernel_data_fetch(objects, object).numverts;
42
43 /* figure out which steps we need to fetch and their interpolation factor */
44 int maxstep = numsteps * 2;
45 int step = min((int)(time * maxstep), maxstep - 1);
46 float t = time * maxstep - step;
47
48 /* find attribute */
51
52 /* fetch key coordinates */
53 float4 point = motion_point_for_step(kg, offset, numverts, numsteps, step, prim);
54 float4 next_point = motion_point_for_step(kg, offset, numverts, numsteps, step + 1, prim);
55
56 /* interpolate between steps */
57 return (1.0f - t) * point + t * next_point;
58}
59
60#endif
61
ccl_device_inline int intersection_find_attribute(KernelGlobals kg, const int object, const uint id)
#define kernel_assert(cond)
const KernelGlobalsCPU *ccl_restrict KernelGlobals
#define kernel_data_fetch(name, index)
#define ccl_device_inline
#define CCL_NAMESPACE_END
@ ATTR_STD_NOT_FOUND
@ ATTR_STD_MOTION_VERTEX_POSITION
T step(const T &edge, const T &value)
VecBase< float, 4 > float4
#define min(a, b)
Definition sort.c:32