This repository has been archived on 2023-10-09. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
blender-archive/source/blender/modifiers/intern/MOD_meshcache_util.c
Campbell Barton c434782e3a File headers: SPDX License migration
Use a shorter/simpler license convention, stops the header taking so
much space.

Follow the SPDX license specification: https://spdx.org/licenses

- C/C++/objc/objc++
- Python
- Shell Scripts
- CMake, GNUmakefile

While most of the source tree has been included

- `./extern/` was left out.
- `./intern/cycles` & `./intern/atomic` are also excluded because they
  use different header conventions.

doc/license/SPDX-license-identifiers.txt has been added to list SPDX all
used identifiers.

See P2788 for the script that automated these edits.

Reviewed By: brecht, mont29, sergey

Ref D14069
2022-02-11 09:14:36 +11:00

51 lines
1.4 KiB
C

/* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup modifiers
*/
#include "BLI_utildefines.h"
#include "BLI_math.h"
#include "DNA_modifier_types.h"
#include "MOD_meshcache_util.h"
void MOD_meshcache_calc_range(const float frame,
const char interp,
const int frame_tot,
int r_index_range[2],
float *r_factor)
{
if (interp == MOD_MESHCACHE_INTERP_NONE) {
r_index_range[0] = r_index_range[1] = max_ii(0, min_ii(frame_tot - 1, round_fl_to_int(frame)));
*r_factor = 1.0f; /* dummy */
}
else {
const float tframe = floorf(frame);
const float range = frame - tframe;
r_index_range[0] = (int)tframe;
if (range <= FRAME_SNAP_EPS) {
/* we're close enough not to need blending */
r_index_range[1] = r_index_range[0];
*r_factor = 1.0f; /* dummy */
}
else {
/* blend between 2 frames */
r_index_range[1] = r_index_range[0] + 1;
*r_factor = range;
}
/* clamp */
if ((r_index_range[0] >= frame_tot) || (r_index_range[1] >= frame_tot)) {
r_index_range[0] = r_index_range[1] = frame_tot - 1;
*r_factor = 1.0f; /* dummy */
}
else if ((r_index_range[0] < 0) || (r_index_range[1] < 0)) {
r_index_range[0] = r_index_range[1] = 0;
*r_factor = 1.0f; /* dummy */
}
}
}