Blender  V3.3
armature_update.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2015 Blender Foundation. All rights reserved. */
3 
8 #include "MEM_guardedalloc.h"
9 
10 #include "BLI_listbase.h"
11 #include "BLI_math.h"
12 #include "BLI_utildefines.h"
13 
14 #include "DNA_armature_types.h"
15 #include "DNA_constraint_types.h"
16 #include "DNA_object_types.h"
17 #include "DNA_scene_types.h"
18 
19 #include "BKE_action.h"
20 #include "BKE_anim_path.h"
21 #include "BKE_armature.h"
22 #include "BKE_curve.h"
23 #include "BKE_displist.h"
24 #include "BKE_fcurve.h"
25 #include "BKE_object.h"
26 #include "BKE_scene.h"
27 
28 #include "BIK_api.h"
29 
30 #include "DEG_depsgraph.h"
31 
32 /* ********************** SPLINE IK SOLVER ******************* */
33 
34 /* Temporary evaluation tree data used for Spline IK */
35 typedef struct tSplineIK_Tree {
37 
38  int type; /* type of IK that this serves (CONSTRAINT_TYPE_KINEMATIC or ..._SPLINEIK) */
39 
40  short chainlen; /* number of bones in the chain */
41  float totlength; /* total length of bones in the chain */
42 
43  const float *points; /* parametric positions for the joints along the curve */
44  bPoseChannel **chain; /* chain of bones to affect using Spline IK (ordered from the tip) */
45 
46  bPoseChannel *root; /* bone that is the root node of the chain */
47 
48  bConstraint *con; /* constraint for this chain */
49  bSplineIKConstraint *ik_data; /* constraint settings for this chain */
51 
52 /* ----------- */
53 
54 /* Tag the bones in the chain formed by the given bone for IK. */
56  Object *UNUSED(ob),
57  bPoseChannel *pchan_tip)
58 {
59  bPoseChannel *pchan, *pchan_root = NULL;
60  bPoseChannel *pchan_chain[255];
61  bConstraint *con = NULL;
63  float bone_lengths[255];
64  float totlength = 0.0f;
65  int segcount = 0;
66 
67  /* Find the SplineIK constraint. */
68  for (con = pchan_tip->constraints.first; con; con = con->next) {
70  ik_data = con->data;
71 
72  /* Target can only be a curve. */
73  if ((ik_data->tar == NULL) || (ik_data->tar->type != OB_CURVES_LEGACY)) {
74  continue;
75  }
76  /* Skip if disabled. */
77  if ((con->enforce == 0.0f) || (con->flag & (CONSTRAINT_DISABLE | CONSTRAINT_OFF))) {
78  continue;
79  }
80 
81  /* Otherwise, constraint is ok... */
82  break;
83  }
84  }
85  if (con == NULL) {
86  return;
87  }
88 
89  /* Find the root bone and the chain of bones from the root to the tip.
90  * NOTE: this assumes that the bones are connected, but that may not be true... */
91  for (pchan = pchan_tip; pchan && (segcount < ik_data->chainlen);
92  pchan = pchan->parent, segcount++) {
93  /* Store this segment in the chain. */
94  pchan_chain[segcount] = pchan;
95 
96  /* If performing rebinding, calculate the length of the bone. */
97  bone_lengths[segcount] = pchan->bone->length;
98  totlength += bone_lengths[segcount];
99  }
100 
101  if (segcount == 0) {
102  return;
103  }
104 
105  pchan_root = pchan_chain[segcount - 1];
106 
107  /* Perform binding step if required. */
108  if ((ik_data->flag & CONSTRAINT_SPLINEIK_BOUND) == 0) {
109  float segmentLen = (1.0f / (float)segcount);
110 
111  /* Setup new empty array for the points list. */
112  if (ik_data->points) {
114  }
116  ik_data->points = MEM_mallocN(sizeof(float) * ik_data->numpoints, "Spline IK Binding");
117 
118  /* Bind 'tip' of chain (i.e. first joint = tip of bone with the Spline IK Constraint). */
119  ik_data->points[0] = 1.0f;
120 
121  /* Perform binding of the joints to parametric positions along the curve based
122  * proportion of the total length that each bone occupies.
123  */
124  for (int i = 0; i < segcount; i++) {
125  /* 'head' joints, traveling towards the root of the chain.
126  * - 2 methods; the one chosen depends on whether we've got usable lengths.
127  */
128  if ((ik_data->flag & CONSTRAINT_SPLINEIK_EVENSPLITS) || (totlength == 0.0f)) {
129  /* 1) Equi-spaced joints. */
130  ik_data->points[i + 1] = ik_data->points[i] - segmentLen;
131  }
132  else {
133  /* 2) To find this point on the curve, we take a step from the previous joint
134  * a distance given by the proportion that this bone takes.
135  */
136  ik_data->points[i + 1] = ik_data->points[i] - (bone_lengths[i] / totlength);
137  }
138  }
139 
140  /* Spline has now been bound. */
142  }
143 
144  /* Disallow negative values (happens with float precision). */
145  CLAMP_MIN(ik_data->points[segcount], 0.0f);
146 
147  /* Make a new Spline-IK chain, and store it in the IK chains. */
148  /* TODO: we should check if there is already an IK chain on this,
149  * since that would take precedence... */
150  {
151  /* Make a new tree. */
152  tSplineIK_Tree *tree = MEM_callocN(sizeof(tSplineIK_Tree), "SplineIK Tree");
154 
155  tree->chainlen = segcount;
156  tree->totlength = totlength;
157 
158  /* Copy over the array of links to bones in the chain (from tip to root). */
159  tree->chain = MEM_mallocN(sizeof(bPoseChannel *) * segcount, "SplineIK Chain");
160  memcpy(tree->chain, pchan_chain, sizeof(bPoseChannel *) * segcount);
161 
162  /* Store reference to joint position array. */
163  tree->points = ik_data->points;
164 
165  /* Store references to different parts of the chain. */
166  tree->root = pchan_root;
167  tree->con = con;
168  tree->ik_data = ik_data;
169 
170  /* AND! Link the tree to the root. */
171  BLI_addtail(&pchan_root->siktree, tree);
172  }
173 
174  /* Mark root channel having an IK tree. */
175  pchan_root->flag |= POSE_IKSPLINE;
176 }
177 
178 /* Tag which bones are members of Spline IK chains. */
179 static void splineik_init_tree(Scene *scene, Object *ob, float UNUSED(ctime))
180 {
181  bPoseChannel *pchan;
182 
183  /* Find the tips of Spline IK chains,
184  * which are simply the bones which have been tagged as such. */
185  for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
186  if (pchan->constflag & PCHAN_HAS_SPLINEIK) {
188  }
189  }
190 }
191 
192 /* ----------- */
193 
194 typedef struct tSplineIk_EvalState {
195  float curve_position; /* Current position along the curve. */
196  float curve_scale; /* Global scale to apply to curve positions. */
197  float locrot_offset[4][4]; /* Bone rotation and location offset inherited from parent. */
198  float prev_tail_loc[3]; /* Tail location of the previous bone. */
199  float prev_tail_radius; /* Tail curve radius of the previous bone. */
200  int prev_tail_seg_idx; /* Curve segment the previous tail bone belongs to. */
202 
203 /* Prepare data to evaluate spline IK. */
205 {
206  bSplineIKConstraint *ik_data = tree->ik_data;
207 
208  /* Make sure that the constraint targets are ok, to avoid crashes
209  * in case of a depsgraph bug or dependency cycle.
210  */
211  if (ik_data->tar == NULL) {
212  return false;
213  }
214 
215  CurveCache *cache = ik_data->tar->runtime.curve_cache;
216 
217  if (ELEM(NULL, cache, cache->anim_path_accum_length)) {
218  return false;
219  }
220 
221  /* Initialize the evaluation state. */
222  state->curve_position = 0.0f;
223  state->curve_scale = 1.0f;
224  unit_m4(state->locrot_offset);
225  zero_v3(state->prev_tail_loc);
226  state->prev_tail_radius = 1.0f;
227  state->prev_tail_seg_idx = 0;
228 
229  /* Apply corrections for sensitivity to scaling. */
230  if ((ik_data->yScaleMode != CONSTRAINT_SPLINEIK_YS_FIT_CURVE) && (tree->totlength != 0.0f)) {
231  /* Get the current length of the curve. */
232  /* NOTE: This is assumed to be correct even after the curve was resized. */
233  const float spline_len = BKE_anim_path_get_length(cache);
234 
235  /* Calculate the scale factor to multiply all the path values by so that the
236  * bone chain retains its current length, such that:
237  * maxScale * splineLen = totLength
238  */
239  state->curve_scale = tree->totlength / spline_len;
240  }
241 
242  return true;
243 }
244 
246  bSplineIKConstraint *ik_data, Object *ob, float radius, float r_vec[3], float *r_radius)
247 {
248  /* Apply the curve's object-mode transforms to the position
249  * unless the option to allow curve to be positioned elsewhere is activated (i.e. no root).
250  */
251  if ((ik_data->flag & CONSTRAINT_SPLINEIK_NO_ROOT) == 0) {
252  mul_m4_v3(ik_data->tar->obmat, r_vec);
253  }
254 
255  /* Convert the position to pose-space. */
256  mul_m4_v3(ob->imat, r_vec);
257 
258  /* Set the new radius (it should be the average value). */
259  *r_radius = (radius + *r_radius) / 2;
260 }
261 
262 static float dist_to_sphere_shell(const float sphere_origin[3],
263  const float sphere_radius,
264  const float point[3])
265 {
266  float vec[3];
267  sub_v3_v3v3(vec, sphere_origin, point);
268  return sphere_radius - len_v3(vec);
269 }
270 
271 /* This function positions the tail of the bone so that it preserves the length of it.
272  * The length of the bone can be seen as a sphere radius.
273  */
275  const float head_pos[3],
276  const float sphere_radius,
277  int prev_seg_idx,
278  float r_tail_pos[3],
279  float *r_new_curve_pos,
280  float *r_radius)
281 {
282  /* This is using the tessellated curve data.
283  * So we are working with piece-wise linear curve segments.
284  * The same method is used in #BKE_where_on_path to get curve location data. */
285  const CurveCache *cache = ik_data->tar->runtime.curve_cache;
286  const float *seg_accum_len = cache->anim_path_accum_length;
287 
288  int max_seg_idx = BKE_anim_path_get_array_size(cache) - 1;
289 
290  /* Make an initial guess of where our intersection point will be.
291  * If the curve was a straight line, then the faction passed in r_new_curve_pos
292  * would be the correct location.
293  * So make it our first initial guess.
294  */
295  const float spline_len = BKE_anim_path_get_length(cache);
296  const float guessed_len = *r_new_curve_pos * spline_len;
297 
298  BLI_assert(prev_seg_idx >= 0);
299  int cur_seg_idx = prev_seg_idx;
300  while (cur_seg_idx < max_seg_idx && guessed_len > seg_accum_len[cur_seg_idx]) {
301  cur_seg_idx++;
302  }
303 
304  /* Convert the segment to bev points.
305  * For example, the segment with index 0 will have bev points 0 and 1.
306  */
307  int bp_idx = cur_seg_idx + 1;
308 
309  const BevList *bl = cache->bev.first;
310  bool is_cyclic = bl->poly >= 0;
311  BevPoint *bp = bl->bevpoints;
312  BevPoint *prev_bp;
313  bp = bp + bp_idx;
314  prev_bp = bp - 1;
315 
316  /* Go to the next tessellated curve point until we cross to outside of the sphere. */
317  while (len_v3v3(head_pos, bp->vec) < sphere_radius) {
318  if (bp_idx > max_seg_idx) {
319  /* We are outside the defined curve. We will now extrapolate the intersection point. */
320  break;
321  }
322  prev_bp = bp;
323  if (is_cyclic && bp_idx == max_seg_idx) {
324  /* Wrap around to the start point.
325  * Don't set the bp_idx to zero here as we use it to get the segment index later.
326  */
327  bp = bl->bevpoints;
328  }
329  else {
330  bp++;
331  }
332  bp_idx++;
333  }
334 
335  /* Calculate the intersection point using the secant root finding method */
336  float x0 = 0.0f, x1 = 1.0f, x2 = 0.5f;
337  float x0_point[3], x1_point[3], start_p[3];
338  float epsilon = max_fff(1.0f, len_v3(head_pos), len_v3(bp->vec)) * FLT_EPSILON;
339 
340  if (prev_seg_idx == bp_idx - 1) {
341  /* The intersection lies inside the same segment as the last point.
342  * Set the last point to be the start search point so we minimize the risks of going backwards
343  * on the curve.
344  */
345  copy_v3_v3(start_p, head_pos);
346  }
347  else {
348  copy_v3_v3(start_p, prev_bp->vec);
349  }
350 
351  for (int i = 0; i < 10; i++) {
352  interp_v3_v3v3(x0_point, start_p, bp->vec, x0);
353  interp_v3_v3v3(x1_point, start_p, bp->vec, x1);
354 
355  float f_x0 = dist_to_sphere_shell(head_pos, sphere_radius, x0_point);
356  float f_x1 = dist_to_sphere_shell(head_pos, sphere_radius, x1_point);
357 
358  if (fabsf(f_x1) <= epsilon || f_x0 == f_x1) {
359  break;
360  }
361 
362  x2 = x1 - f_x1 * (x1 - x0) / (f_x1 - f_x0);
363  x0 = x1;
364  x1 = x2;
365  }
366  /* Found the bone tail position! */
367  copy_v3_v3(r_tail_pos, x1_point);
368 
369  /* Because our intersection point lies inside the current segment,
370  * Convert our bevpoint index back to the previous segment index (-2 instead of -1).
371  * This is because our actual location is prev_seg_len + isect_seg_len.
372  */
373  prev_seg_idx = bp_idx - 2;
374  float prev_seg_len = 0;
375 
376  if (prev_seg_idx < 0) {
377  prev_seg_idx = 0;
378  prev_seg_len = 0;
379  }
380  else {
381  prev_seg_len = seg_accum_len[prev_seg_idx];
382  }
383 
384  /* Convert the point back into the 0-1 interpolation range. */
385  const float isect_seg_len = len_v3v3(prev_bp->vec, r_tail_pos);
386  const float frac = isect_seg_len / len_v3v3(prev_bp->vec, bp->vec);
387  *r_new_curve_pos = (prev_seg_len + isect_seg_len) / spline_len;
388 
389  if (*r_new_curve_pos > 1.0f) {
390  *r_radius = bp->radius;
391  }
392  else {
393  *r_radius = (1.0f - frac) * prev_bp->radius + frac * bp->radius;
394  }
395 
396  /* Return the current segment. */
397  return bp_idx - 1;
398 }
399 
400 /* Evaluate spline IK for a given bone. */
402  tSplineIK_Tree *tree, Object *ob, bPoseChannel *pchan, int index, tSplineIk_EvalState *state)
403 {
404  bSplineIKConstraint *ik_data = tree->ik_data;
405 
406  if (pchan->bone->length < FLT_EPSILON) {
407  /* Only move the bone position with zero length bones. */
408  float bone_pos[4], rad;
409  BKE_where_on_path(ik_data->tar, state->curve_position, bone_pos, NULL, NULL, &rad, NULL);
410 
411  apply_curve_transform(ik_data, ob, rad, bone_pos, &rad);
412 
413  copy_v3_v3(pchan->pose_mat[3], bone_pos);
414  copy_v3_v3(pchan->pose_head, bone_pos);
415  copy_v3_v3(pchan->pose_tail, bone_pos);
416  pchan->flag |= POSE_DONE;
417  return;
418  }
419 
420  float orig_head[3], orig_tail[3], pose_head[3], pose_tail[3];
421  float base_pose_mat[3][3], pose_mat[3][3];
422  float spline_vec[3], scale_fac, radius = 1.0f;
423  float tail_blend_fac = 0.0f;
424 
425  mul_v3_m4v3(pose_head, state->locrot_offset, pchan->pose_head);
426  mul_v3_m4v3(pose_tail, state->locrot_offset, pchan->pose_tail);
427 
428  copy_v3_v3(orig_head, pose_head);
429 
430  /* First, adjust the point positions on the curve. */
431  float curveLen = tree->points[index] - tree->points[index + 1];
432  float bone_len = len_v3v3(pose_head, pose_tail);
433  float point_start = state->curve_position;
434  float pose_scale = bone_len / pchan->bone->length;
435  float base_scale = 1.0f;
436 
438  /* Carry over the bone Y scale to the curve range. */
439  base_scale = pose_scale;
440  }
441 
442  float point_end = point_start + curveLen * base_scale * state->curve_scale;
443 
444  state->curve_position = point_end;
445 
446  /* Step 1: determine the positions for the endpoints of the bone. */
447  if (point_start < 1.0f) {
448  float vec[4], rad;
449  radius = 0.0f;
450 
451  /* Calculate head position. */
452  if (point_start == 0.0f) {
453  /* Start of the path. We have no previous tail position to copy. */
454  BKE_where_on_path(ik_data->tar, point_start, vec, NULL, NULL, &rad, NULL);
455  }
456  else {
457  copy_v3_v3(vec, state->prev_tail_loc);
458  rad = state->prev_tail_radius;
459  }
460 
461  radius = rad;
462  copy_v3_v3(pose_head, vec);
463  apply_curve_transform(ik_data, ob, rad, pose_head, &radius);
464 
465  /* Calculate tail position. */
467  float sphere_radius;
468 
470  sphere_radius = bone_len;
471  }
472  else {
473  /* Don't take bone scale into account. */
474  sphere_radius = pchan->bone->length;
475  }
476 
477  /* Calculate the tail position with sphere curve intersection. */
478  state->prev_tail_seg_idx = position_tail_on_spline(
479  ik_data, vec, sphere_radius, state->prev_tail_seg_idx, pose_tail, &point_end, &rad);
480 
481  state->prev_tail_radius = rad;
482  copy_v3_v3(state->prev_tail_loc, pose_tail);
483 
484  apply_curve_transform(ik_data, ob, rad, pose_tail, &radius);
485  state->curve_position = point_end;
486  }
487  else {
488  /* Scale to fit curve end position. */
489  if (BKE_where_on_path(ik_data->tar, point_end, vec, NULL, NULL, &rad, NULL)) {
490  state->prev_tail_radius = rad;
491  copy_v3_v3(state->prev_tail_loc, vec);
492  copy_v3_v3(pose_tail, vec);
493  apply_curve_transform(ik_data, ob, rad, pose_tail, &radius);
494  }
495  }
496 
497  /* Determine if the bone should still be affected by SplineIK.
498  * This makes it so that the bone slowly becomes poseable again the further it rolls off the
499  * curve. When the whole bone has rolled off the curve, the IK constraint will not influence it
500  * anymore.
501  */
502  if (point_end >= 1.0f) {
503  /* Blending factor depends on the amount of the bone still left on the chain. */
504  tail_blend_fac = (1.0f - point_start) / (point_end - point_start);
505  }
506  else {
507  tail_blend_fac = 1.0f;
508  }
509  }
510 
511  /* Step 2: determine the implied transform from these endpoints.
512  * - splineVec: the vector direction that the spline applies on the bone.
513  * - scaleFac: the factor that the bone length is scaled by to get the desired amount.
514  */
515  sub_v3_v3v3(spline_vec, pose_tail, pose_head);
516  scale_fac = len_v3(spline_vec) / pchan->bone->length;
517 
518  /* Step 3: compute the shortest rotation needed
519  * to map from the bone rotation to the current axis.
520  * - this uses the same method as is used for the Damped Track Constraint
521  * (see the code there for details).
522  */
523  {
524  float dmat[3][3], rmat[3][3];
525  float raxis[3], rangle;
526 
527  /* Compute the raw rotation matrix from the bone's current matrix by extracting only the
528  * orientation-relevant axes, and normalizing them.
529  */
530  mul_m3_m4m4(base_pose_mat, state->locrot_offset, pchan->pose_mat);
531  normalize_m3_m3(rmat, base_pose_mat);
532 
533  /* Also, normalize the orientation imposed by the bone,
534  * now that we've extracted the scale factor. */
535  normalize_v3(spline_vec);
536 
537  /* Calculate smallest axis-angle rotation necessary for getting from the
538  * current orientation of the bone, to the spline-imposed direction.
539  */
540  cross_v3_v3v3(raxis, rmat[1], spline_vec);
541 
542  /* Check if the old and new bone direction is parallel to each other.
543  * If they are, then 'raxis' should be near zero and we will have to get the rotation axis in
544  * some other way.
545  */
546  float norm = normalize_v3(raxis);
547 
548  if (norm < FLT_EPSILON) {
549  /* Can't use cross product! */
550  int order[3] = {0, 1, 2};
551  float tmp_axis[3];
552  zero_v3(tmp_axis);
553 
554  axis_sort_v3(spline_vec, order);
555 
556  /* Use the second largest axis as the basis for the rotation axis. */
557  tmp_axis[order[1]] = 1.0f;
558  cross_v3_v3v3(raxis, tmp_axis, spline_vec);
559  }
560 
561  rangle = dot_v3v3(rmat[1], spline_vec);
562  CLAMP(rangle, -1.0f, 1.0f);
563  rangle = acosf(rangle);
564 
565  /* Multiply the magnitude of the angle by the influence of the constraint to
566  * control the influence of the SplineIK effect.
567  */
568  rangle *= tree->con->enforce * tail_blend_fac;
569 
570  /* Construct rotation matrix from the axis-angle rotation found above.
571  * - This call takes care to make sure that the axis provided is a unit vector first.
572  */
573  axis_angle_to_mat3(dmat, raxis, rangle);
574 
575  /* Combine these rotations so that the y-axis of the bone is now aligned as the
576  * spline dictates, while still maintaining roll control from the existing bone animation. */
577  mul_m3_m3m3(pose_mat, dmat, rmat);
578 
579  /* Attempt to reduce shearing, though I doubt this will really help too much now. */
580  normalize_m3(pose_mat);
581 
582  mul_m3_m3m3(base_pose_mat, dmat, base_pose_mat);
583 
584  /* Apply rotation to the accumulated parent transform. */
585  mul_m4_m3m4(state->locrot_offset, dmat, state->locrot_offset);
586  }
587 
588  /* Step 4: Set the scaling factors for the axes. */
589 
590  /* Always multiply the y-axis by the scaling factor to get the correct length. */
591  mul_v3_fl(pose_mat[1], scale_fac);
592 
593  /* After that, apply x/z scaling modes. */
594  if (ik_data->xzScaleMode != CONSTRAINT_SPLINEIK_XZS_NONE) {
595  /* First, apply the original scale if enabled. */
597  (ik_data->flag & CONSTRAINT_SPLINEIK_USE_ORIGINAL_SCALE) != 0) {
598  float scale;
599 
600  /* X-axis scale. */
601  scale = len_v3(pchan->pose_mat[0]);
602  mul_v3_fl(pose_mat[0], scale);
603  /* Z-axis scale. */
604  scale = len_v3(pchan->pose_mat[2]);
605  mul_v3_fl(pose_mat[2], scale);
606 
607  /* Adjust the scale factor used for volume preservation
608  * to consider the pre-IK scaling as the initial volume. */
609  scale_fac /= pose_scale;
610  }
611 
612  /* Apply volume preservation. */
613  switch (ik_data->xzScaleMode) {
615  /* Old 'volume preservation' method using the inverse scale. */
616  float scale;
617 
618  /* Calculate volume preservation factor which is
619  * basically the inverse of the y-scaling factor.
620  */
621  if (fabsf(scale_fac) != 0.0f) {
622  scale = 1.0f / fabsf(scale_fac);
623 
624  /* We need to clamp this within sensible values. */
625  /* NOTE: these should be fine for now, but should get sanitized in future. */
626  CLAMP(scale, 0.0001f, 100000.0f);
627  }
628  else {
629  scale = 1.0f;
630  }
631 
632  /* Apply the scaling. */
633  mul_v3_fl(pose_mat[0], scale);
634  mul_v3_fl(pose_mat[2], scale);
635  break;
636  }
638  /* Improved volume preservation based on the Stretch To constraint. */
639  float final_scale;
640 
641  /* As the basis for volume preservation, we use the inverse scale factor... */
642  if (fabsf(scale_fac) != 0.0f) {
643  /* NOTE: The method here is taken wholesale from the Stretch To constraint. */
644  float bulge = powf(1.0f / fabsf(scale_fac), ik_data->bulge);
645 
646  if (bulge > 1.0f) {
647  if (ik_data->flag & CONSTRAINT_SPLINEIK_USE_BULGE_MAX) {
648  float bulge_max = max_ff(ik_data->bulge_max, 1.0f);
649  float hard = min_ff(bulge, bulge_max);
650 
651  float range = bulge_max - 1.0f;
652  float scale = (range > 0.0f) ? 1.0f / range : 0.0f;
653  float soft = 1.0f + range * atanf((bulge - 1.0f) * scale) / (float)M_PI_2;
654 
655  bulge = interpf(soft, hard, ik_data->bulge_smooth);
656  }
657  }
658  if (bulge < 1.0f) {
659  if (ik_data->flag & CONSTRAINT_SPLINEIK_USE_BULGE_MIN) {
660  float bulge_min = CLAMPIS(ik_data->bulge_min, 0.0f, 1.0f);
661  float hard = max_ff(bulge, bulge_min);
662 
663  float range = 1.0f - bulge_min;
664  float scale = (range > 0.0f) ? 1.0f / range : 0.0f;
665  float soft = 1.0f - range * atanf((1.0f - bulge) * scale) / (float)M_PI_2;
666 
667  bulge = interpf(soft, hard, ik_data->bulge_smooth);
668  }
669  }
670 
671  /* Compute scale factor for xz axes from this value. */
672  final_scale = sqrtf(bulge);
673  }
674  else {
675  /* No scaling, so scale factor is simple. */
676  final_scale = 1.0f;
677  }
678 
679  /* Apply the scaling (assuming normalized scale). */
680  mul_v3_fl(pose_mat[0], final_scale);
681  mul_v3_fl(pose_mat[2], final_scale);
682  break;
683  }
684  }
685  }
686 
687  /* Finally, multiply the x and z scaling by the radius of the curve too,
688  * to allow automatic scales to get tweaked still.
689  */
690  if ((ik_data->flag & CONSTRAINT_SPLINEIK_NO_CURVERAD) == 0) {
691  mul_v3_fl(pose_mat[0], radius);
692  mul_v3_fl(pose_mat[2], radius);
693  }
694 
695  /* Blend the scaling of the matrix according to the influence. */
696  sub_m3_m3m3(pose_mat, pose_mat, base_pose_mat);
697  madd_m3_m3m3fl(pose_mat, base_pose_mat, pose_mat, tree->con->enforce * tail_blend_fac);
698 
699  /* Step 5: Set the location of the bone in the matrix. */
700  if (ik_data->flag & CONSTRAINT_SPLINEIK_NO_ROOT) {
701  /* When the 'no-root' option is affected, the chain can retain
702  * the shape but be moved elsewhere.
703  */
704  copy_v3_v3(pose_head, orig_head);
705  }
706  else if (tree->con->enforce < 1.0f) {
707  /* When the influence is too low:
708  * - Blend the positions for the 'root' bone.
709  * - Stick to the parent for any other.
710  */
711  if (index < tree->chainlen - 1) {
712  copy_v3_v3(pose_head, orig_head);
713  }
714  else {
715  interp_v3_v3v3(pose_head, orig_head, pose_head, tree->con->enforce);
716  }
717  }
718 
719  /* Finally, store the new transform. */
720  copy_m4_m3(pchan->pose_mat, pose_mat);
721  copy_v3_v3(pchan->pose_mat[3], pose_head);
722  copy_v3_v3(pchan->pose_head, pose_head);
723 
724  mul_v3_mat3_m4v3(orig_tail, state->locrot_offset, pchan->pose_tail);
725 
726  /* Recalculate tail, as it's now outdated after the head gets adjusted above! */
728 
729  /* Update the offset in the accumulated parent transform. */
730  sub_v3_v3v3(state->locrot_offset[3], pchan->pose_tail, orig_tail);
731 
732  /* Done! */
733  pchan->flag |= POSE_DONE;
734 }
735 
736 /* Evaluate the chain starting from the nominated bone */
738  struct Depsgraph *depsgraph, Scene *scene, Object *ob, bPoseChannel *pchan_root, float ctime)
739 {
741 
742  /* for each pose-tree, execute it if it is spline, otherwise just free it */
743  while ((tree = pchan_root->siktree.first) != NULL) {
744  /* Firstly, calculate the bone matrix the standard way,
745  * since this is needed for roll control. */
746  for (int i = tree->chainlen - 1; i >= 0; i--) {
747  BKE_pose_where_is_bone(depsgraph, scene, ob, tree->chain[i], ctime, 1);
748  }
749 
750  /* After that, evaluate the actual Spline IK, unless there are missing dependencies. */
752 
754  /* Walk over each bone in the chain, calculating the effects of spline IK
755  * - the chain is traversed in the opposite order to storage order
756  * (i.e. parent to children) so that dependencies are correct
757  */
758  for (int i = tree->chainlen - 1; i >= 0; i--) {
759  bPoseChannel *pchan = tree->chain[i];
760  splineik_evaluate_bone(tree, ob, pchan, i, &state);
761  }
762  }
763 
764  /* free the tree info specific to SplineIK trees now */
765  if (tree->chain) {
766  MEM_freeN(tree->chain);
767  }
768 
769  /* free this tree */
770  BLI_freelinkN(&pchan_root->siktree, tree);
771  }
772 }
773 
775 {
776  splineik_init_tree(scene, ob, ctime);
777 }
778 
780  struct Depsgraph *depsgraph, Scene *scene, Object *ob, bPoseChannel *pchan_root, float ctime)
781 {
782  splineik_execute_tree(depsgraph, scene, ob, pchan_root, ctime);
783 }
784 
785 /* *************** Depsgraph evaluation callbacks ************ */
786 
788 {
789  MEM_SAFE_FREE(pose->chan_array);
790  const int num_channels = BLI_listbase_count(&pose->chanbase);
791  pose->chan_array = MEM_malloc_arrayN(num_channels, sizeof(bPoseChannel *), "pose->chan_array");
792  int pchan_index = 0;
793  for (bPoseChannel *pchan = pose->chanbase.first; pchan != NULL; pchan = pchan->next) {
794  pose->chan_array[pchan_index++] = pchan;
795  }
796 }
797 
799 {
800  bPose *pose = ob->pose;
801  BLI_assert(pose != NULL);
802  BLI_assert(pose->chan_array != NULL);
803  BLI_assert(pchan_index >= 0);
804  BLI_assert(pchan_index < MEM_allocN_len(pose->chan_array) / sizeof(bPoseChannel *));
805  return pose->chan_array[pchan_index];
806 }
807 
809 {
810  bPose *pose = object->pose;
811  BLI_assert(pose != NULL);
812 
813  DEG_debug_print_eval(depsgraph, __func__, object->id.name, object);
814 
815  BLI_assert(object->type == OB_ARMATURE);
816 
817  /* We demand having proper pose. */
818  BLI_assert(object->pose != NULL);
819  BLI_assert((object->pose->flag & POSE_RECALC) == 0);
820 
821  /* imat is needed for solvers. */
822  invert_m4_m4(object->imat, object->obmat);
823 
824  /* clear flags */
825  for (bPoseChannel *pchan = pose->chanbase.first; pchan != NULL; pchan = pchan->next) {
826  pchan->flag &= ~(POSE_DONE | POSE_CHAIN | POSE_IKTREE | POSE_IKSPLINE);
827 
828  /* Free B-Bone shape data cache if it's not a B-Bone. */
829  if (pchan->bone == NULL || pchan->bone->segments <= 1) {
830  BKE_pose_channel_free_bbone_cache(&pchan->runtime);
831  }
832  }
833 
835 }
836 
838 {
839  DEG_debug_print_eval(depsgraph, __func__, object->id.name, object);
840  BLI_assert(object->type == OB_ARMATURE);
841  const float ctime = BKE_scene_ctime_get(scene); /* not accurate... */
842  bArmature *armature = (bArmature *)object->data;
843  if (armature->flag & ARM_RESTPOS) {
844  return;
845  }
846  /* construct the IK tree (standard IK) */
847  BIK_init_tree(depsgraph, scene, object, ctime);
848  /* construct the Spline IK trees
849  * - this is not integrated as an IK plugin, since it should be able
850  * to function in conjunction with standard IK. */
851  BKE_pose_splineik_init_tree(scene, object, ctime);
852 }
853 
854 void BKE_pose_eval_bone(struct Depsgraph *depsgraph, Scene *scene, Object *object, int pchan_index)
855 {
856  const bArmature *armature = (bArmature *)object->data;
857  if (armature->edbo != NULL) {
858  return;
859  }
860  bPoseChannel *pchan = pose_pchan_get_indexed(object, pchan_index);
862  depsgraph, __func__, object->id.name, object, "pchan", pchan->name, pchan);
863  BLI_assert(object->type == OB_ARMATURE);
864  if (armature->flag & ARM_RESTPOS) {
865  Bone *bone = pchan->bone;
866  if (bone) {
867  copy_m4_m4(pchan->pose_mat, bone->arm_mat);
868  copy_v3_v3(pchan->pose_head, bone->arm_head);
869  copy_v3_v3(pchan->pose_tail, bone->arm_tail);
870  }
871  }
872  else {
873  /* TODO(sergey): Currently if there are constraints full transform is
874  * being evaluated in BKE_pose_constraints_evaluate. */
875  if (pchan->constraints.first == NULL) {
876  if (pchan->flag & POSE_IKTREE || pchan->flag & POSE_IKSPLINE) {
877  /* pass */
878  }
879  else {
880  if ((pchan->flag & POSE_DONE) == 0) {
881  /* TODO(sergey): Use time source node for time. */
882  float ctime = BKE_scene_ctime_get(scene); /* not accurate... */
883  BKE_pose_where_is_bone(depsgraph, scene, object, pchan, ctime, 1);
884  }
885  }
886  }
887  }
888 }
889 
891  Scene *scene,
892  Object *object,
893  int pchan_index)
894 {
895  const bArmature *armature = (bArmature *)object->data;
896  if (armature->edbo != NULL) {
897  return;
898  }
899  bPoseChannel *pchan = pose_pchan_get_indexed(object, pchan_index);
901  depsgraph, __func__, object->id.name, object, "pchan", pchan->name, pchan);
902  if (armature->flag & ARM_RESTPOS) {
903  return;
904  }
905  if (pchan->flag & POSE_IKTREE || pchan->flag & POSE_IKSPLINE) {
906  /* IK are being solved separately/ */
907  }
908  else {
909  if ((pchan->flag & POSE_DONE) == 0) {
910  float ctime = BKE_scene_ctime_get(scene); /* not accurate... */
911  BKE_pose_where_is_bone(depsgraph, scene, object, pchan, ctime, 1);
912  }
913  }
914 }
915 
917  struct Object *object,
918  bPoseChannel *pchan)
919 {
920  if (!DEG_is_active(depsgraph)) {
921  return;
922  }
923  const bArmature *armature = (bArmature *)object->data;
924  if (armature->edbo != NULL) {
925  return;
926  }
927  bPoseChannel *pchan_orig = pchan->orig_pchan;
928  /* TODO(sergey): Using BKE_pose_copy_pchan_result() introduces T70901, but why? */
929  copy_m4_m4(pchan_orig->pose_mat, pchan->pose_mat);
930  copy_m4_m4(pchan_orig->chan_mat, pchan->chan_mat);
931  copy_v3_v3(pchan_orig->pose_head, pchan->pose_mat[3]);
932  copy_m4_m4(pchan_orig->constinv, pchan->constinv);
933  copy_v3_v3(pchan_orig->pose_tail, pchan->pose_tail);
934 }
935 
936 void BKE_pose_bone_done(struct Depsgraph *depsgraph, struct Object *object, int pchan_index)
937 {
938  const bArmature *armature = (bArmature *)object->data;
939  if (armature->edbo != NULL) {
940  return;
941  }
942  bPoseChannel *pchan = pose_pchan_get_indexed(object, pchan_index);
943  float imat[4][4];
945  depsgraph, __func__, object->id.name, object, "pchan", pchan->name, pchan);
946  if (pchan->bone) {
947  invert_m4_m4(imat, pchan->bone->arm_mat);
948  mul_m4_m4m4(pchan->chan_mat, pchan->pose_mat, imat);
949  if (!(pchan->bone->flag & BONE_NO_DEFORM)) {
950  mat4_to_dquat(&pchan->runtime.deform_dual_quat, pchan->bone->arm_mat, pchan->chan_mat);
951  }
952  }
954  if (DEG_is_active(depsgraph)) {
955  bPoseChannel *pchan_orig = pchan->orig_pchan;
956  if (pchan->bone == NULL || pchan->bone->segments <= 1) {
958  }
959  }
960 }
961 
963  struct Object *object,
964  int pchan_index)
965 {
966  const bArmature *armature = (bArmature *)object->data;
967  if (armature->edbo != NULL) {
968  return;
969  }
970  bPoseChannel *pchan = pose_pchan_get_indexed(object, pchan_index);
972  depsgraph, __func__, object->id.name, object, "pchan", pchan->name, pchan);
973  if (pchan->bone != NULL && pchan->bone->segments > 1) {
975  if (DEG_is_active(depsgraph)) {
977  }
978  }
979 }
980 
982  Scene *scene,
983  Object *object,
984  int rootchan_index)
985 {
986  const bArmature *armature = (bArmature *)object->data;
987  if (armature->edbo != NULL) {
988  return;
989  }
990  bPoseChannel *rootchan = pose_pchan_get_indexed(object, rootchan_index);
992  depsgraph, __func__, object->id.name, object, "rootchan", rootchan->name, rootchan);
993  BLI_assert(object->type == OB_ARMATURE);
994  const float ctime = BKE_scene_ctime_get(scene); /* not accurate... */
995  if (armature->flag & ARM_RESTPOS) {
996  return;
997  }
998  BIK_execute_tree(depsgraph, scene, object, rootchan, ctime);
999 }
1000 
1002  Scene *scene,
1003  Object *object,
1004  int rootchan_index)
1005 
1006 {
1007  const bArmature *armature = (bArmature *)object->data;
1008  if (armature->edbo != NULL) {
1009  return;
1010  }
1011  bPoseChannel *rootchan = pose_pchan_get_indexed(object, rootchan_index);
1013  depsgraph, __func__, object->id.name, object, "rootchan", rootchan->name, rootchan);
1014  BLI_assert(object->type == OB_ARMATURE);
1015  const float ctime = BKE_scene_ctime_get(scene); /* not accurate... */
1016  if (armature->flag & ARM_RESTPOS) {
1017  return;
1018  }
1019  BKE_splineik_execute_tree(depsgraph, scene, object, rootchan, ctime);
1020 }
1021 
1022 static void pose_eval_cleanup_common(Object *object)
1023 {
1024  bPose *pose = object->pose;
1025  BLI_assert(pose != NULL);
1027  UNUSED_VARS_NDEBUG(pose);
1028 }
1029 
1031 {
1032  bPose *pose = object->pose;
1033  BLI_assert(pose != NULL);
1034  UNUSED_VARS_NDEBUG(pose);
1035  DEG_debug_print_eval(depsgraph, __func__, object->id.name, object);
1036  BLI_assert(object->type == OB_ARMATURE);
1037 }
1038 
1040 {
1041  bPose *pose = object->pose;
1042  BLI_assert(pose != NULL);
1043  UNUSED_VARS_NDEBUG(pose);
1044  const float ctime = BKE_scene_ctime_get(scene); /* not accurate... */
1045  DEG_debug_print_eval(depsgraph, __func__, object->id.name, object);
1046  BLI_assert(object->type == OB_ARMATURE);
1047  /* Release the IK tree. */
1048  BIK_release_tree(scene, object, ctime);
1049  pose_eval_cleanup_common(object);
1050 }
typedef float(TangentPoint)[2]
void BIK_init_tree(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, float ctime)
Definition: ikplugin_api.c:66
void BIK_release_tree(struct Scene *scene, struct Object *ob, float ctime)
Definition: ikplugin_api.c:85
void BIK_execute_tree(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan, float ctime)
Definition: ikplugin_api.c:75
Blender kernel action and pose functionality.
void BKE_pose_channel_free_bbone_cache(struct bPoseChannel_Runtime *runtime)
Definition: action.c:1069
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)
Definition: armature.c:1484
void BKE_pose_where_is_bone_tail(struct bPoseChannel *pchan)
Definition: armature.c:2465
void BKE_pose_where_is_bone(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan, float ctime, bool do_extra)
Definition: armature.c:2474
void BKE_pchan_bbone_segments_cache_copy(struct bPoseChannel *pchan, struct bPoseChannel *pchan_from)
Definition: armature.c:1535
display list (or rather multi purpose list) stuff.
General operations, lookup, etc. for blender objects.
float BKE_scene_ctime_get(const struct Scene *scene)
#define BLI_assert(a)
Definition: BLI_assert.h:46
#define BLI_INLINE
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
Definition: BLI_listbase.h:269
void BLI_freelinkN(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:239
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:80
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)
#define M_PI_2
Definition: BLI_math_base.h:23
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])
Definition: math_matrix.c:1076
void mul_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
Definition: math_matrix.c:259
void normalize_m3_m3(float R[3][3], const float M[3][3]) ATTR_NONNULL()
Definition: math_matrix.c:1927
void unit_m4(float m[4][4])
Definition: rct.c:1090
void copy_m4_m3(float m1[4][4], const float m2[3][3])
Definition: math_matrix.c:102
bool invert_m4_m4(float R[4][4], const float A[4][4])
Definition: math_matrix.c:1287
void normalize_m3(float R[3][3]) ATTR_NONNULL()
Definition: math_matrix.c:1912
void mul_m4_v3(const float M[4][4], float r[3])
Definition: math_matrix.c:729
void copy_m4_m4(float m1[4][4], const float m2[4][4])
Definition: math_matrix.c:77
void madd_m3_m3m3fl(float R[3][3], const float A[3][3], const float B[3][3], float f)
Definition: math_matrix.c:1054
void mul_v3_m4v3(float r[3], const float M[4][4], const float v[3])
Definition: math_matrix.c:739
void mul_m3_m3m3(float R[3][3], const float A[3][3], const float B[3][3])
Definition: math_matrix.c:388
void mul_m4_m3m4(float R[4][4], const float A[3][3], const float B[4][4])
Definition: math_matrix.c:500
void mul_m3_m4m4(float R[3][3], const float A[4][4], const float B[4][4])
Definition: math_matrix.c:520
void mul_v3_mat3_m4v3(float r[3], const float M[4][4], const float v[3])
Definition: math_matrix.c:800
void mat4_to_dquat(DualQuat *dq, const float basemat[4][4], const float mat[4][4])
void axis_angle_to_mat3(float R[3][3], const float axis[3], float angle)
void axis_sort_v3(const float axis_values[3], int r_axis_order[3])
Definition: math_vector.c:939
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
void interp_v3_v3v3(float r[3], const float a[3], const float b[3], float t)
Definition: math_vector.c:29
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 CLAMPIS(a, b, c)
#define UNUSED_VARS_NDEBUG(...)
#define UNUSED(x)
#define ELEM(...)
#define CLAMP_MIN(a, b)
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:35
bool DEG_is_active(const struct Depsgraph *depsgraph)
Definition: depsgraph.cc:312
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)
@ PCHAN_HAS_SPLINEIK
@ POSE_DONE
@ POSE_IKTREE
@ POSE_IKSPLINE
@ POSE_CHAIN
@ POSE_RECALC
@ BONE_NO_DEFORM
@ ARM_RESTPOS
@ CONSTRAINT_OFF
@ CONSTRAINT_DISABLE
@ 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.
@ OB_ARMATURE
@ OB_CURVES_LEGACY
_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.
#define MEM_SAFE_FREE(v)
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input Camera Retrieve information about the camera and how it relates to the current shading point s position CLAMP
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Sky Generate a procedural sky texture Noise Generate fractal Perlin noise Wave Generate procedural bands or rings with noise Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a point
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)
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)
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_splineik_evaluate(struct Depsgraph *depsgraph, Scene *scene, Object *object, int rootchan_index)
static void pose_eval_cleanup_common(Object *object)
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.
Definition: btVector3.h:263
#define powf(x, y)
Definition: cuda/compat.h:103
Scene scene
const Depsgraph * depsgraph
static bool is_cyclic(const Nurb *nu)
void * tree
const int state
void *(* MEM_malloc_arrayN)(size_t len, size_t size, const char *str)
Definition: mallocn.c:34
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:27
size_t(* MEM_allocN_len)(const void *vmemh)
Definition: mallocn.c:26
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:31
void *(* MEM_mallocN)(size_t len, const char *str)
Definition: mallocn.c:33
#define atanf(x)
Definition: metal/compat.h:223
#define acosf(x)
Definition: metal/compat.h:222
#define fabsf(x)
Definition: metal/compat.h:219
#define sqrtf(x)
Definition: metal/compat.h:243
ccl_device_inline float frac(float x, int *ix)
static double epsilon
BevPoint * bevpoints
float radius
float vec[3]
float arm_head[3]
float arm_tail[3]
short segments
float length
float arm_mat[4][4]
ListBase bev
Definition: BKE_curve.h:34
const float * anim_path_accum_length
Definition: BKE_curve.h:42
char name[66]
Definition: DNA_ID.h:378
void * first
Definition: DNA_listBase.h:31
struct CurveCache * curve_cache
struct bPose * pose
float imat[4][4]
Object_Runtime runtime
float obmat[4][4]
void * data
ListBase * edbo
struct bConstraint * next
struct DualQuat deform_dual_quat
ListBase constraints
struct Bone * bone
struct bPoseChannel * parent
float pose_head[3]
float chan_mat[4][4]
float pose_tail[3]
struct bPoseChannel * next
float constinv[4][4]
struct bPoseChannel_Runtime runtime
struct bPoseChannel * orig_pchan
float pose_mat[4][4]
struct ListBase siktree
ListBase chanbase
short flag
bPoseChannel ** chan_array
struct tSplineIK_Tree * next
bPoseChannel ** chain
bPoseChannel * root
bSplineIKConstraint * ik_data
const float * points
bConstraint * con
struct tSplineIK_Tree * prev
float locrot_offset[4][4]