81 float bone_lengths[255];
110 pchan = pchan->
parent, segcount++) {
112 pchan_chain[segcount] = pchan;
123 pchan_root = pchan_chain[segcount - 1];
127 float segmentLen = (1.0f / (
float)segcount);
142 for (
int i = 0; i < segcount; i++) {
173 tree->chainlen = segcount;
184 tree->root = pchan_root;
240 state->curve_position = 0.0f;
241 state->curve_scale = 1.0f;
244 state->prev_tail_radius = 1.0f;
245 state->prev_tail_seg_idx = 0;
257 state->curve_scale =
tree->totlength / spline_len;
277 *r_radius = (radius + *r_radius) / 2;
281 const float sphere_radius,
282 const float point[3])
286 return sphere_radius -
len_v3(vec);
293 const float head_pos[3],
294 const float sphere_radius,
297 float *r_new_curve_pos,
314 const float guessed_len = *r_new_curve_pos * spline_len;
317 int cur_seg_idx = prev_seg_idx;
318 while (cur_seg_idx < max_seg_idx && guessed_len > seg_accum_len[cur_seg_idx]) {
325 int bp_idx = cur_seg_idx + 1;
328 bool is_cyclic = bl->
poly >= 0;
335 while (
len_v3v3(head_pos, bp->
vec) < sphere_radius) {
336 if (bp_idx > max_seg_idx) {
341 if (is_cyclic && bp_idx == max_seg_idx) {
354 float x0 = 0.0f, x1 = 1.0f,
x2 = 0.5f;
355 float x0_point[3], x1_point[3], start_p[3];
358 if (prev_seg_idx == bp_idx - 1) {
369 for (
int i = 0; i < 10; i++) {
380 x2 = x1 - f_x1 * (x1 - x0) / (f_x1 - f_x0);
391 prev_seg_idx = bp_idx - 2;
392 float prev_seg_len = 0;
394 if (prev_seg_idx < 0) {
399 prev_seg_len = seg_accum_len[prev_seg_idx];
403 const float isect_seg_len =
len_v3v3(prev_bp->
vec, r_tail_pos);
405 *r_new_curve_pos = (prev_seg_len + isect_seg_len) / spline_len;
407 if (*r_new_curve_pos > 1.0f) {
426 float bone_pos[4], dir[3], rad;
438 float orig_head[3], orig_tail[3], pose_head[3], pose_tail[3];
439 float base_pose_mat[3][3], pose_mat[3][3];
440 float spline_vec[3], scale_fac, radius = 1.0f;
441 float tail_blend_fac = 0.0f;
449 float curveLen =
tree->points[index] -
tree->points[index + 1];
450 float bone_len =
len_v3v3(pose_head, pose_tail);
451 float point_start =
state->curve_position;
452 float pose_scale = bone_len / pchan->
bone->
length;
453 float base_scale = 1.0f;
457 base_scale = pose_scale;
460 float point_end = point_start + curveLen * base_scale *
state->curve_scale;
462 state->curve_position = point_end;
465 if (point_start < 1.0f) {
466 float vec[4], dir[3], rad;
470 if (point_start == 0.0f) {
476 rad =
state->prev_tail_radius;
488 sphere_radius = bone_len;
497 ik_data, vec, sphere_radius,
state->prev_tail_seg_idx, pose_tail, &point_end, &rad);
499 state->prev_tail_radius = rad;
503 state->curve_position = point_end;
508 state->prev_tail_radius = rad;
520 if (point_end >= 1.0f) {
522 tail_blend_fac = (1.0f - point_start) / (point_end - point_start);
525 tail_blend_fac = 1.0f;
542 float dmat[3][3], rmat[3][3];
543 float raxis[3], rangle;
566 if (
norm < FLT_EPSILON) {
568 int order[3] = {0, 1, 2};
575 tmp_axis[
order[1]] = 1.0f;
579 rangle =
dot_v3v3(rmat[1], spline_vec);
580 CLAMP(rangle, -1.0f, 1.0f);
581 rangle =
acosf(rangle);
586 rangle *=
tree->con->enforce * tail_blend_fac;
627 scale_fac /= pose_scale;
639 if (
fabsf(scale_fac) != 0.0f) {
640 scale = 1.0f /
fabsf(scale_fac);
644 CLAMP(scale, 0.0001f, 100000.0f);
660 if (
fabsf(scale_fac) != 0.0f) {
667 float hard =
min_ff(bulge, bulge_max);
669 float range = bulge_max - 1.0f;
670 float scale = (range > 0.0f) ? 1.0f / range : 0.0f;
679 float hard =
max_ff(bulge, bulge_min);
681 float range = 1.0f - bulge_min;
682 float scale = (range > 0.0f) ? 1.0f / range : 0.0f;
690 final_scale =
sqrtf(bulge);
715 madd_m3_m3m3fl(pose_mat, base_pose_mat, pose_mat,
tree->con->enforce * tail_blend_fac);
724 else if (
tree->con->enforce < 1.0f) {
729 if (index < tree->chainlen - 1) {
764 for (
int i =
tree->chainlen - 1; i >= 0; i--) {
776 for (
int i =
tree->chainlen - 1; i >= 0; i--) {
828 bPose *pose =
object->pose;
847 if (pchan->bone ==
NULL || pchan->bone->segments <= 1) {
855 object->proxy->proxy_from = object;
1046 bPose *pose =
object->pose;
1054 bPose *pose =
object->pose;
1063 bPose *pose =
object->pose;
1114 if (pchan_from ==
NULL) {
1116 "WARNING: Could not find bone %s in linked ID anymore... "
1117 "You should delete and re-generate your proxy.\n",
typedef float(TangentPoint)[2]
void BIK_init_tree(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, float ctime)
void BIK_release_tree(struct Scene *scene, struct Object *ob, float ctime)
void BIK_execute_tree(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan, float ctime)
Blender kernel action and pose functionality.
struct bPoseChannel * BKE_pose_channel_find_name(const struct bPose *pose, const char *name)
void BKE_pose_copy_pchan_result(struct bPoseChannel *pchanto, const struct bPoseChannel *pchanfrom)
void BKE_pose_channel_free_bbone_cache(struct bPoseChannel_Runtime *runtime)
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)
int BKE_anim_path_get_array_size(const struct CurveCache *curve_cache)
float BKE_anim_path_get_length(const struct CurveCache *curve_cache)
void BKE_pchan_bbone_segments_cache_compute(struct bPoseChannel *pchan)
void BKE_pose_where_is_bone_tail(struct bPoseChannel *pchan)
void BKE_pose_where_is_bone(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan, float ctime, bool do_extra)
void BKE_pchan_bbone_segments_cache_copy(struct bPoseChannel *pchan, struct bPoseChannel *pchan_from)
display list (or rather multi purpose list) stuff.
General operations, lookup, etc. for blender objects.
float BKE_scene_frame_get(const struct Scene *scene)
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
void BLI_freelinkN(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
int BLI_listbase_count(const struct ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
MINLINE float max_fff(float a, float b, float c)
MINLINE float max_ff(float a, float b)
MINLINE float min_ff(float a, float b)
MINLINE float interpf(float a, float b, float t)
void sub_m3_m3m3(float R[3][3], const float A[3][3], const float B[3][3])
void mul_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
void normalize_m3_m3(float R[3][3], const float M[3][3]) ATTR_NONNULL()
void unit_m4(float m[4][4])
void copy_m4_m3(float m1[4][4], const float m2[3][3])
bool invert_m4_m4(float R[4][4], const float A[4][4])
void normalize_m3(float R[3][3]) ATTR_NONNULL()
void mul_m4_v3(const float M[4][4], float r[3])
void copy_m4_m4(float m1[4][4], const float m2[4][4])
void mul_v3_m4v3(float r[3], const float M[4][4], const float v[3])
void mul_m3_m3m3(float R[3][3], const float A[3][3], const float B[3][3])
void mul_m4_m3m4(float R[4][4], const float A[3][3], const float B[4][4])
void madd_m3_m3m3fl(float R[3][3], const float A[3][3], const float B[3][3], const float f)
void mul_m3_m4m4(float R[3][3], const float A[4][4], const float B[4][4])
void mul_v3_mat3_m4v3(float r[3], const float M[4][4], const float v[3])
void mat4_to_dquat(DualQuat *dq, const float basemat[4][4], const float mat[4][4])
void copy_dq_dq(DualQuat *r, const DualQuat *dq)
void axis_angle_to_mat3(float R[3][3], const float axis[3], const float angle)
void axis_sort_v3(const float axis_values[3], int r_axis_order[3])
void interp_v3_v3v3(float r[3], const float a[3], const float b[3], const float t)
MINLINE float len_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE float normalize_v3(float r[3])
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void mul_v3_fl(float r[3], float f)
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void zero_v3(float r[3])
MINLINE float len_v3(const float a[3]) ATTR_WARN_UNUSED_RESULT
#define UNUSED_VARS_NDEBUG(...)
struct Depsgraph Depsgraph
bool DEG_is_active(const struct Depsgraph *depsgraph)
void DEG_debug_print_eval(struct Depsgraph *depsgraph, const char *function_name, const char *object_name, const void *object_address)
void DEG_debug_print_eval_subdata(struct Depsgraph *depsgraph, const char *function_name, const char *object_name, const void *object_address, const char *subdata_comment, const char *subdata_name, const void *subdata_address)
#define ID_IS_LINKED(_id)
@ CONSTRAINT_TYPE_SPLINEIK
@ CONSTRAINT_SPLINEIK_YS_FIT_CURVE
@ CONSTRAINT_SPLINEIK_YS_ORIGINAL
@ CONSTRAINT_SPLINEIK_EVENSPLITS
@ CONSTRAINT_SPLINEIK_USE_BULGE_MAX
@ CONSTRAINT_SPLINEIK_USE_ORIGINAL_SCALE
@ CONSTRAINT_SPLINEIK_USE_BULGE_MIN
@ CONSTRAINT_SPLINEIK_BOUND
@ CONSTRAINT_SPLINEIK_NO_CURVERAD
@ CONSTRAINT_SPLINEIK_NO_ROOT
@ CONSTRAINT_SPLINEIK_XZS_VOLUMETRIC
@ CONSTRAINT_SPLINEIK_XZS_ORIGINAL
@ CONSTRAINT_SPLINEIK_XZS_NONE
@ CONSTRAINT_SPLINEIK_XZS_INVERSE
Object is a sort of wrapper for general info.
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble x2
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint order
Read Guarded memory(de)allocation.
Group RGB to Bright Vector Camera CLAMP
static bool splineik_evaluate_init(tSplineIK_Tree *tree, tSplineIk_EvalState *state)
void BKE_splineik_execute_tree(struct Depsgraph *depsgraph, Scene *scene, Object *ob, bPoseChannel *pchan_root, float ctime)
void BKE_pose_pchan_index_rebuild(bPose *pose)
static void pose_channel_flush_to_orig_if_needed(struct Depsgraph *depsgraph, struct Object *object, bPoseChannel *pchan)
void BKE_pose_eval_init(struct Depsgraph *depsgraph, Scene *UNUSED(scene), Object *object)
static void apply_curve_transform(bSplineIKConstraint *ik_data, Object *ob, float radius, float r_vec[3], float *r_radius)
void BKE_pose_eval_proxy_cleanup(struct Depsgraph *depsgraph, Object *object)
static void splineik_execute_tree(struct Depsgraph *depsgraph, Scene *scene, Object *ob, bPoseChannel *pchan_root, float ctime)
void BKE_pose_splineik_init_tree(Scene *scene, Object *ob, float ctime)
static void splineik_evaluate_bone(tSplineIK_Tree *tree, Object *ob, bPoseChannel *pchan, int index, tSplineIk_EvalState *state)
static int position_tail_on_spline(bSplineIKConstraint *ik_data, const float head_pos[3], const float sphere_radius, int prev_seg_idx, float r_tail_pos[3], float *r_new_curve_pos, float *r_radius)
void BKE_pose_eval_done(struct Depsgraph *depsgraph, Object *object)
void BKE_pose_eval_bbone_segments(struct Depsgraph *depsgraph, struct Object *object, int pchan_index)
static void splineik_init_tree_from_pchan(Scene *UNUSED(scene), Object *UNUSED(ob), bPoseChannel *pchan_tip)
void BKE_pose_bone_done(struct Depsgraph *depsgraph, struct Object *object, int pchan_index)
void BKE_pose_eval_proxy_done(struct Depsgraph *depsgraph, Object *object)
static float dist_to_sphere_shell(const float sphere_origin[3], const float sphere_radius, const float point[3])
void BKE_pose_eval_init_ik(struct Depsgraph *depsgraph, Scene *scene, Object *object)
void BKE_pose_eval_bone(struct Depsgraph *depsgraph, Scene *scene, Object *object, int pchan_index)
void BKE_pose_eval_cleanup(struct Depsgraph *depsgraph, Scene *scene, Object *object)
static void splineik_init_tree(Scene *scene, Object *ob, float UNUSED(ctime))
void BKE_pose_constraints_evaluate(struct Depsgraph *depsgraph, Scene *scene, Object *object, int pchan_index)
void BKE_pose_iktree_evaluate(struct Depsgraph *depsgraph, Scene *scene, Object *object, int rootchan_index)
void BKE_pose_eval_proxy_init(struct Depsgraph *depsgraph, Object *object)
void BKE_pose_splineik_evaluate(struct Depsgraph *depsgraph, Scene *scene, Object *object, int rootchan_index)
static void pose_eval_cleanup_common(Object *object)
void BKE_pose_eval_proxy_copy_bone(struct Depsgraph *depsgraph, Object *object, int pchan_index)
BLI_INLINE bPoseChannel * pose_pchan_get_indexed(Object *ob, int pchan_index)
struct tSplineIK_Tree tSplineIK_Tree
struct tSplineIk_EvalState tSplineIk_EvalState
SIMD_FORCE_INLINE btScalar norm() const
Return the norm (length) of the vector.
const Depsgraph * depsgraph
void *(* MEM_malloc_arrayN)(size_t len, size_t size, const char *str)
void(* MEM_freeN)(void *vmemh)
size_t(* MEM_allocN_len)(const void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
void *(* MEM_mallocN)(size_t len, const char *str)
ccl_device_inline float frac(float x, int *ix)
const float * anim_path_accum_length
struct CurveCache * curve_cache
struct Object * proxy_from
struct bConstraint * next
struct DualQuat deform_dual_quat
struct bPoseChannel * parent
struct bPoseChannel * next
struct bPoseChannel_Runtime runtime
struct bPoseChannel * orig_pchan
bPoseChannel ** chan_array
struct tSplineIK_Tree * next
bSplineIKConstraint * ik_data
struct tSplineIK_Tree * prev
float locrot_offset[4][4]