Blender V5.0
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
5#pragma once
6
7#include "kernel/globals.h"
8
9#include "kernel/bvh/util.h"
10
12
13/* Motion Point Primitive
14 *
15 * These are stored as regular points, plus extra positions and radii at times
16 * other than the frame center. Computing the point at a given ray time is
17 * a matter of interpolation of the two steps between which the ray time lies.
18 *
19 * The extra points are stored as ATTR_STD_MOTION_VERTEX_POSITION.
20 */
21
22#ifdef __POINTCLOUD__
23
24ccl_device_inline float4 motion_point_for_step(
25 KernelGlobals kg, int offset, const int numverts, const int numsteps, int step, const int prim)
26{
27 if (step == numsteps) {
28 /* center step: regular key location */
29 return kernel_data_fetch(points, prim);
30 }
31 /* center step is not stored in this array */
32 if (step > numsteps) {
33 step--;
34 }
35
36 offset += step * numverts;
37
38 return kernel_data_fetch(attributes_float4, offset + prim);
39}
40
41/* return 2 point key locations */
43 const int object,
44 const int prim,
45 const float time)
46{
47 /* get motion info */
48 const int numsteps = kernel_data_fetch(objects, object).num_geom_steps;
49 const int numverts = kernel_data_fetch(objects, object).numverts;
50
51 /* figure out which steps we need to fetch and their interpolation factor */
52 const int maxstep = numsteps * 2;
53 const int step = min((int)(time * maxstep), maxstep - 1);
54 const float t = time * maxstep - step;
55
56 /* find attribute */
59
60 /* fetch key coordinates */
61 const float4 point = motion_point_for_step(kg, offset, numverts, numsteps, step, prim);
62 const float4 next_point = motion_point_for_step(kg, offset, numverts, numsteps, step + 1, prim);
63
64 /* interpolate between steps */
65 return (1.0f - t) * point + t * next_point;
66}
67
68#endif
69
ccl_device_inline int intersection_find_attribute(KernelGlobals kg, const int object, const uint id)
#define kernel_assert(cond)
#define kernel_data_fetch(name, index)
const ThreadKernelGlobalsCPU * KernelGlobals
#define ccl_device_inline
#define CCL_NAMESPACE_END
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
@ ATTR_STD_NOT_FOUND
@ ATTR_STD_MOTION_VERTEX_POSITION
#define min(a, b)
Definition sort.cc:36