94 float prev_len = 0.0f;
95 for (
int i = 0; i < bl->
nr - 1; i++) {
96 prev_len +=
len_v3v3(bp_arr[i].vec, bp_arr[i + 1].vec);
97 len_data[i] = prev_len;
102 len_data[seg_size - 1] = prev_len +
len_v3v3(bp_arr[0].vec, bp_arr[bl->
nr - 1].
vec);
108 const bool is_cyclic,
115 BLI_assert(idx < bl->nr - 1 || (is_cyclic && idx < bl->nr));
124 *r_p0 = &bp_arr[bl->
nr - 1];
142 if (idx == bl->
nr - 2) {
146 *r_p0 = &bp_arr[idx - 1];
147 *r_p1 = &bp_arr[idx];
148 *r_p2 = &bp_arr[idx + 1];
159 if (idx == bl->
nr - 1) {
162 *r_p0 = &bp_arr[idx - 1];
163 *r_p1 = &bp_arr[idx];
173 *r_p0 = &bp_arr[idx - 1];
174 *r_p1 = &bp_arr[idx];
175 *r_p2 = &bp_arr[idx + 1];
176 *r_p3 = &bp_arr[idx + 2];
181 const float goal_len,
185 float left_len, right_len;
186 int cur_idx = 0, cur_base = 0;
187 int cur_step = seg_size - 1;
191 if (seg_size == 1) [[unlikely]] {
193 *r_frac = goal_len / accum_len_arr[0];
199 cur_idx = cur_base + cur_step / 2;
200 left_len = accum_len_arr[cur_idx];
201 right_len = accum_len_arr[cur_idx + 1];
203 if (left_len <= goal_len && right_len > goal_len) {
204 *r_idx = cur_idx + 1;
205 *r_frac = (goal_len - left_len) / (right_len - left_len);
211 *r_frac = goal_len / accum_len_arr[0];
215 if (cur_step == 0) [[unlikely]] {
217 CLOG_ERROR(&
LOG,
"Couldn't find any valid point on the animation path!");
218 BLI_assert_msg(0,
"Couldn't find any valid point on the animation path!");
222 if (left_len < goal_len) {
224 cur_base = cur_idx + 1;
254 if (bl ==
nullptr || !bl->
nr) {
267 const bool is_cyclic = bl->
poly >= 0;
271 if (ctime < 0.0f || ctime > 1.0f) {
282 const float goal_len = ctime * accum_len_arr[seg_size - 1];
285 if (ctime <= 0.0f || ctime >= 1.0f) {
286 const float clamp_time =
clamp_f(ctime, 0.0f, 1.0f);
287 const int idx = clamp_time * (seg_size - 1);
291 frac = goal_len / accum_len_arr[0];
294 frac = (goal_len - accum_len_arr[idx - 1]) / (accum_len_arr[idx] - accum_len_arr[idx - 1]);
302 if (!found_idx) [[unlikely]] {
332 const Nurb *nu = nurbs->first();
347 r_vec[0] =
w[0] * p0->
vec[0] +
w[1] * p1->
vec[0] +
w[2] * p2->
vec[0] +
w[3] * p3->
vec[0];
348 r_vec[1] =
w[0] * p0->
vec[1] +
w[1] * p1->
vec[1] +
w[2] * p2->
vec[1] +
w[3] * p3->
vec[1];
349 r_vec[2] =
w[0] * p0->
vec[2] +
w[1] * p1->
vec[2] +
w[2] * p2->
vec[2] +
w[3] * p3->
vec[2];
361 float totfac, q1[4], q2[4];
363 totfac =
w[0] +
w[3];
371 totfac =
w[1] +
w[2];
379 totfac =
w[0] +
w[1] +
w[2] +
w[3];
#define CLOG_ERROR(clg_ref,...)
#define CLOG_WARN(clg_ref,...)
Object is a sort of wrapper for general info.
Read Blender memory allocation and freeing.
#define BLI_assert_msg(a, msg)
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
CCL_NAMESPACE_BEGIN ccl_device_inline float frac(const float x, ccl_private int *ix)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void * MEM_new_array_uninitialized(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
bool BKE_where_on_path(const struct Object *ob, float ctime, float r_vec[4], float r_dir[3], float r_quat[4], float *r_radius, float *r_weight)
static void get_curve_points_from_idx(const int idx, const BevList *bl, const bool is_cyclic, BevPoint const **r_p0, BevPoint const **r_p1, BevPoint const **r_p2, BevPoint const **r_p3)
void copy_qt_qt(float q[4], const float a[4])
void interp_qt_qtqt(float q[4], const float a[4], const float b[4], float t)
void interp_v3_v3v3v3v3(float p[3], const float v1[3], const float v2[3], const float v3[3], const float v4[3], const float w[4])
MINLINE void negate_v3(float r[3])
MINLINE void clamp_v4(float vec[4], float min, float max)
int BKE_anim_path_get_array_size(const struct CurveCache *curve_cache)
static int get_bevlist_seg_array_size(const BevList *bl)
static bool binary_search_anim_path(const float *accum_len_arr, const int seg_size, const float goal_len, int *r_idx, float *r_frac)
ListBaseT< Nurb > * BKE_curve_editNurbs_get(Curve *cu)
float BKE_anim_path_get_length(const struct CurveCache *curve_cache)
void key_curve_position_weights(float t, float data[4], KeyInterpolationType type)
MINLINE float len_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
void BKE_anim_path_calc_data(struct Object *ob)
MINLINE float clamp_f(float value, float min, float max)
void key_curve_tangent_weights(float t, float data[4], KeyInterpolationType type)
const float * anim_path_accum_length
bke::ObjectRuntime * runtime