Blender V4.3
MOD_meshcache_util.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#include "BLI_math_base.h"
10#include "BLI_utildefines.h"
11
12#include "DNA_modifier_types.h"
13
14#include "MOD_meshcache_util.hh"
15
16void MOD_meshcache_calc_range(const float frame,
17 const char interp,
18 const int frame_tot,
19 int r_index_range[2],
20 float *r_factor)
21{
23 r_index_range[0] = r_index_range[1] = max_ii(0, min_ii(frame_tot - 1, round_fl_to_int(frame)));
24 *r_factor = 1.0f; /* dummy */
25 }
26 else {
27 const float tframe = floorf(frame);
28 const float range = frame - tframe;
29 r_index_range[0] = int(tframe);
30 if (range <= FRAME_SNAP_EPS) {
31 /* we're close enough not to need blending */
32 r_index_range[1] = r_index_range[0];
33 *r_factor = 1.0f; /* dummy */
34 }
35 else {
36 /* blend between 2 frames */
37 r_index_range[1] = r_index_range[0] + 1;
38 *r_factor = range;
39 }
40
41 /* clamp */
42 if ((r_index_range[0] >= frame_tot) || (r_index_range[1] >= frame_tot)) {
43 r_index_range[0] = r_index_range[1] = frame_tot - 1;
44 *r_factor = 1.0f; /* dummy */
45 }
46 else if ((r_index_range[0] < 0) || (r_index_range[1] < 0)) {
47 r_index_range[0] = r_index_range[1] = 0;
48 *r_factor = 1.0f; /* dummy */
49 }
50 }
51}
MINLINE int round_fl_to_int(float a)
MINLINE int min_ii(int a, int b)
MINLINE int max_ii(int a, int b)
@ MOD_MESHCACHE_INTERP_NONE
void MOD_meshcache_calc_range(const float frame, const char interp, const int frame_tot, int r_index_range[2], float *r_factor)
#define FRAME_SNAP_EPS
#define floorf(x)
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
IndexRange range
ccl_device_inline float2 interp(const float2 a, const float2 b, float t)