Blender V5.3
rna_pose.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
8
9#include <cstdlib>
10#include <cstring>
11
12#include "RNA_define.hh"
13#include "RNA_enum_types.hh"
14
15#include "rna_internal.hh"
16
17#include "DNA_action_types.h"
18#include "DNA_anim_types.h"
19#include "DNA_object_types.h"
20
21#include "BLI_math_base_c.hh"
22
24
25#include "UI_resources.hh"
26
27#include "WM_types.hh"
28
29#include "ANIM_rna.hh"
30
31namespace blender {
32
33/* Bone and Group Color Sets */
35 {0, "DEFAULT", 0, "Default Colors", ""},
36 {1, "THEME01", ICON_COLORSET_01_VEC, "01 - Theme Color Set", ""},
37 {2, "THEME02", ICON_COLORSET_02_VEC, "02 - Theme Color Set", ""},
38 {3, "THEME03", ICON_COLORSET_03_VEC, "03 - Theme Color Set", ""},
39 {4, "THEME04", ICON_COLORSET_04_VEC, "04 - Theme Color Set", ""},
40 {5, "THEME05", ICON_COLORSET_05_VEC, "05 - Theme Color Set", ""},
41 {6, "THEME06", ICON_COLORSET_06_VEC, "06 - Theme Color Set", ""},
42 {7, "THEME07", ICON_COLORSET_07_VEC, "07 - Theme Color Set", ""},
43 {8, "THEME08", ICON_COLORSET_08_VEC, "08 - Theme Color Set", ""},
44 {9, "THEME09", ICON_COLORSET_09_VEC, "09 - Theme Color Set", ""},
45 {10, "THEME10", ICON_COLORSET_10_VEC, "10 - Theme Color Set", ""},
46 {11, "THEME11", ICON_COLORSET_11_VEC, "11 - Theme Color Set", ""},
47 {12, "THEME12", ICON_COLORSET_12_VEC, "12 - Theme Color Set", ""},
48 {13, "THEME13", ICON_COLORSET_13_VEC, "13 - Theme Color Set", ""},
49 {14, "THEME14", ICON_COLORSET_14_VEC, "14 - Theme Color Set", ""},
50 {15, "THEME15", ICON_COLORSET_15_VEC, "15 - Theme Color Set", ""},
51 {16, "THEME16", ICON_COLORSET_16_VEC, "16 - Theme Color Set", ""},
52 {17, "THEME17", ICON_COLORSET_17_VEC, "17 - Theme Color Set", ""},
53 {18, "THEME18", ICON_COLORSET_18_VEC, "18 - Theme Color Set", ""},
54 {19, "THEME19", ICON_COLORSET_19_VEC, "19 - Theme Color Set", ""},
55 {20, "THEME20", ICON_COLORSET_20_VEC, "20 - Theme Color Set", ""},
56 {-1, "CUSTOM", 0, "Custom Color Set", ""},
57 {0, nullptr, 0, nullptr, nullptr},
58};
59
60} // namespace blender
61
62#ifdef RNA_RUNTIME
63
64# include <algorithm>
65
66# include <fmt/format.h>
67
68# include "BLI_listbase.hh"
69# include "BLI_math_vector_c.hh"
70# include "BLI_string.hh"
71# include "BLI_string_utf8.hh"
72
73# include "MEM_guardedalloc.h"
74
75# include "DNA_constraint_types.h"
76
77# include "BIK_api.h"
78
79# include "BKE_action.hh"
80# include "BKE_armature.hh"
81# include "BKE_constraint.h"
82# include "BKE_context.hh"
83# include "BKE_global.hh"
84# include "BKE_lib_id.hh"
85# include "BKE_main.hh"
86# include "BKE_report.hh"
87
88# include "DEG_depsgraph.hh"
89# include "DEG_depsgraph_build.hh"
90
91# include "ED_anim_api.hh"
93# include "ED_armature.hh"
94# include "ED_object.hh"
95
96# include "WM_api.hh"
97
98# include "RNA_access.hh"
99
100namespace blender {
101
102static void rna_Pose_update(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
103{
105 WM_main_add_notifier(NC_OBJECT | ND_POSE, ptr->owner_id);
106}
107
108static void rna_PoseBone_visibility_update(Main * /* bmain */,
109 Scene * /* scene */,
110 PointerRNA *ptr)
111{
114}
115
116static void rna_Pose_dependency_update(Main *bmain, Scene * /*scene*/, PointerRNA *ptr)
117{
119
121 WM_main_add_notifier(NC_OBJECT | ND_POSE, ptr->owner_id);
122}
123
124static void rna_Pose_IK_update(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
125{
126 Object *ob = id_cast<Object *>(ptr->owner_id);
127
129 WM_main_add_notifier(NC_OBJECT | ND_POSE, ptr->owner_id);
130
131 BIK_clear_data(ob->pose);
132}
133
134static std::optional<std::string> rna_Pose_path(const PointerRNA * /*ptr*/)
135{
136 return "pose";
137}
138
139static std::optional<std::string> rna_PoseBone_path(const PointerRNA *ptr)
140{
141 const bPoseChannel *pchan = static_cast<const bPoseChannel *>(ptr->data);
142 return animrig::get_pose_bone_rna_path(*pchan);
143}
144
145/* shared for actions groups and bone groups */
146
147static bool rna_bone_group_poll(Object *ob, ReportList *reports)
148{
149 if (ID_IS_OVERRIDE_LIBRARY(ob)) {
150 BKE_report(reports, RPT_ERROR, "Cannot edit bone groups for library overrides");
151 return false;
152 }
153
154 return true;
155}
156
157void rna_ActionGroup_colorset_set(PointerRNA *ptr, int value)
158{
159 Object *ob = id_cast<Object *>(ptr->owner_id);
160 if (!rna_bone_group_poll(ob, nullptr)) {
161 return;
162 }
163
164 bActionGroup *grp = static_cast<bActionGroup *>(ptr->data);
165
166 /* ensure only valid values get set */
167 if ((value >= -1) && (value < 21)) {
168 grp->customCol = value;
169
170 /* sync colors stored with theme colors based on the index specified */
172 }
173}
174
176{
177 bActionGroup *grp = static_cast<bActionGroup *>(ptr->data);
178
179 return (grp->customCol < 0);
180}
181
182static IDProperty **rna_PoseBone_idprops(PointerRNA *ptr)
183{
184 bPoseChannel *pchan = static_cast<bPoseChannel *>(ptr->data);
185 return &pchan->prop;
186}
187
188static IDProperty **rna_PoseBone_system_idprops(PointerRNA *ptr)
189{
190 bPoseChannel *pchan = static_cast<bPoseChannel *>(ptr->data);
191 return &pchan->system_properties;
192}
193
194static void rna_Pose_ik_solver_set(PointerRNA *ptr, int value)
195{
196 bPose *pose = static_cast<bPose *>(ptr->data);
197
198 if (pose->iksolver != value) {
199 /* the solver has changed, must clean any temporary structures */
201 MEM_SAFE_DELETE(pose->ikparam);
202 pose->iksolver = ePose_IKSolverType(value);
204 }
205}
206
207static void rna_Pose_ik_solver_update(Main *bmain, Scene * /*scene*/, PointerRNA *ptr)
208{
209 Object *ob = id_cast<Object *>(ptr->owner_id);
210 bPose *pose = static_cast<bPose *>(ptr->data);
211 BLI_assert(ob->pose == pose);
212
213 BKE_pose_tag_recalc(bmain, pose); /* checks & sorts pose channels */
215
217
219
221}
222
223/* rotation - axis-angle */
224static void rna_PoseChannel_rotation_axis_angle_get(PointerRNA *ptr, float *value)
225{
226 bPoseChannel *pchan = static_cast<bPoseChannel *>(ptr->data);
227
228 /* for now, assume that rotation mode is axis-angle */
229 value[0] = pchan->rotAngle;
230 copy_v3_v3(&value[1], pchan->rotAxis);
231}
232
233/* rotation - axis-angle */
234static void rna_PoseChannel_rotation_axis_angle_set(PointerRNA *ptr, const float *value)
235{
236 bPoseChannel *pchan = static_cast<bPoseChannel *>(ptr->data);
237
238 /* for now, assume that rotation mode is axis-angle */
239 pchan->rotAngle = value[0];
240 copy_v3_v3(pchan->rotAxis, &value[1]);
241
242 /* TODO: validate axis? */
243}
244
245static void rna_PoseChannel_rotation_mode_set(PointerRNA *ptr, int value)
246{
247 bPoseChannel *pchan = static_cast<bPoseChannel *>(ptr->data);
248
249 /* use API Method for conversions... */
250 BKE_rotMode_change_values(pchan->quat,
251 pchan->eul,
252 pchan->rotAxis,
253 &pchan->rotAngle,
254 pchan->rotmode,
255 eRotationModes(value));
256
257 /* finally, set the new rotation type */
258 pchan->rotmode = eRotationModes(clamp_i(value, ROT_MODE_MIN, ROT_MODE_MAX));
259}
260
261static void rna_PoseChannel_convert_rotation_mode(
262 ID *id, bPoseChannel *pchan, bContext *C, const short rotation_mode, const bool bake)
263{
264 if (rotation_mode < ROT_MODE_MIN || rotation_mode > ROT_MODE_MAX) {
265 return;
266 }
267
268 Object *ob = id_cast<Object *>(id);
269 ed::AnimTransformable transformable(*ob, *pchan);
270
271 convert_to_rotation_mode(*C, transformable, eRotationModes(rotation_mode), bake);
272}
273
274static float rna_PoseChannel_length_get(PointerRNA *ptr)
275{
276 bPoseChannel *pchan = static_cast<bPoseChannel *>(ptr->data);
277 return len_v3v3(pchan->pose_head, pchan->pose_tail);
278}
279
280static void rna_PoseChannel_name_set(PointerRNA *ptr, const char *value)
281{
282 Object *ob = id_cast<Object *>(ptr->owner_id);
283 bPoseChannel *pchan = static_cast<bPoseChannel *>(ptr->data);
284 char oldname[sizeof(pchan->name)], newname[sizeof(pchan->name)];
285
286 /* need to be on the stack */
287 STRNCPY_UTF8(newname, value);
288 STRNCPY(oldname, pchan->name); /* Allow non UTF8 encoding for the old name. */
289
292 ED_armature_bone_rename(G_MAIN, id_cast<bArmature *>(ob->data), oldname, newname);
293}
294
295/* See rna_Bone_update_renamed() */
296static void rna_PoseChannel_name_update(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
297{
298 ID *id = ptr->owner_id;
299
300 /* Redraw Outliner / Dope-sheet. */
302
303 /* update animation channels */
305}
306
307static PointerRNA rna_PoseChannel_bone_get(PointerRNA *ptr)
308{
309 Object *ob = id_cast<Object *>(ptr->owner_id);
310 bPoseChannel *pchan = static_cast<bPoseChannel *>(ptr->data);
311 PointerRNA tmp_ptr = *ptr;
312
313 /* Replace the id_data pointer with the Armature ID. */
314 tmp_ptr.owner_id = ob->data;
315
316 return RNA_pointer_create_with_parent(tmp_ptr, RNA_Bone, pchan->bone_get(*ob));
317}
318
319static bool rna_PoseChannel_has_ik_get(PointerRNA *ptr)
320{
321 Object *ob = id_cast<Object *>(ptr->owner_id);
322 bPoseChannel *pchan = static_cast<bPoseChannel *>(ptr->data);
323
324 return BKE_pose_channel_in_IK_chain(ob, pchan);
325}
326
327static StructRNA *rna_IKParam_refine(PointerRNA *ptr)
328{
329 bIKParam *param = static_cast<bIKParam *>(ptr->data);
330
331 switch (param->iksolver) {
332 case IKSOLVER_ITASC:
333 return RNA_Itasc;
334 default:
335 return RNA_IKParam;
336 }
337}
338
339static PointerRNA rna_Pose_ikparam_get(PointerRNA *ptr)
340{
341 bPose *pose = static_cast<bPose *>(ptr->data);
342 return RNA_pointer_create_with_parent(*ptr, RNA_IKParam, pose->ikparam);
343}
344
345static StructRNA *rna_Pose_ikparam_typef(PointerRNA *ptr)
346{
347 bPose *pose = static_cast<bPose *>(ptr->data);
348
349 switch (pose->iksolver) {
350 case IKSOLVER_ITASC:
351 return RNA_Itasc;
352 default:
353 return RNA_IKParam;
354 }
355}
356
357static void rna_Itasc_update(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
358{
359 Object *ob = id_cast<Object *>(ptr->owner_id);
360 bItasc *itasc = static_cast<bItasc *>(ptr->data);
361
362 /* verify values */
363 itasc->precision = std::max(itasc->precision, 0.0001f);
364 itasc->minstep = std::max(itasc->minstep, 0.001f);
365 itasc->maxstep = std::max(itasc->maxstep, itasc->minstep);
366 itasc->feedback = std::max(itasc->feedback, 0.01f);
367 itasc->feedback = std::min(itasc->feedback, 100.0f);
368 itasc->maxvel = std::max(itasc->maxvel, 0.01f);
369 itasc->maxvel = std::min(itasc->maxvel, 100.0f);
370 BIK_update_param(ob->pose);
371
373}
374
375static void rna_Itasc_update_rebuild(Main *bmain, Scene *scene, PointerRNA *ptr)
376{
377 Object *ob = id_cast<Object *>(ptr->owner_id);
378 bPose *pose = ob->pose;
379
380 BKE_pose_tag_recalc(bmain, pose); /* checks & sorts pose channels */
381 rna_Itasc_update(bmain, scene, ptr);
382}
383
384static PointerRNA rna_PoseChannel_active_constraint_get(PointerRNA *ptr)
385{
386 bPoseChannel *pchan = static_cast<bPoseChannel *>(ptr->data);
387 bConstraint *con = BKE_constraints_active_get(&pchan->constraints);
388 return RNA_pointer_create_with_parent(*ptr, RNA_Constraint, con);
389}
390
391static void rna_PoseChannel_active_constraint_set(PointerRNA *ptr,
392 PointerRNA value,
393 ReportList * /*reports*/)
394{
395 bPoseChannel *pchan = static_cast<bPoseChannel *>(ptr->data);
396 BKE_constraints_active_set(&pchan->constraints, static_cast<bConstraint *>(value.data));
397}
398
399static bConstraint *rna_PoseChannel_constraints_new(
400 ID *id, bPoseChannel *pchan, Main *main, int type, const char *name)
401{
402 Object *ob = id_cast<Object *>(id);
403 bConstraint *new_con = BKE_constraint_add_for_pose(ob, pchan, name, eBConstraint_Types(type));
404
407
408 return new_con;
409}
410
411static void rna_PoseChannel_constraints_remove(
412 ID *id, bPoseChannel *pchan, Main *bmain, ReportList *reports, PointerRNA *con_ptr)
413{
414 bConstraint *con = static_cast<bConstraint *>(con_ptr->data);
415 const bool is_ik = ELEM(con->type, CONSTRAINT_TYPE_KINEMATIC, CONSTRAINT_TYPE_SPLINEIK);
416 Object *ob = id_cast<Object *>(id);
417
418 if (BLI_findindex(&pchan->constraints, con) == -1) {
420 reports, RPT_ERROR, "Constraint '%s' not found in pose bone '%s'", con->name, pchan->name);
421 return;
422 }
423
424 BKE_constraint_remove_ex(&pchan->constraints, ob, con);
425 con_ptr->invalidate();
426
429
430 /* XXX(@ideasman42): is this really needed? */
431 BKE_constraints_active_set(&pchan->constraints, nullptr);
432
434
435 if (is_ik) {
436 BIK_clear_data(ob->pose);
437 }
438}
439
440static void rna_PoseChannel_constraints_move(
441 ID *id, bPoseChannel *pchan, Main *bmain, ReportList *reports, int from, int to)
442{
443 Object *ob = id_cast<Object *>(id);
444
445 if (from == to) {
446 return;
447 }
448
449 if (!BLI_listbase_move_index(&pchan->constraints, from, to)) {
450 BKE_reportf(reports, RPT_ERROR, "Could not move constraint from index '%d' to '%d'", from, to);
451 return;
452 }
453
454 ed::object::constraint_tag_update(bmain, ob, nullptr);
456}
457
458static bConstraint *rna_PoseChannel_constraints_copy(ID *id,
459 bPoseChannel *pchan,
460 Main *bmain,
461 PointerRNA *con_ptr)
462{
463 Object *ob = id_cast<Object *>(id);
464 bConstraint *con = static_cast<bConstraint *>(con_ptr->data);
465 bConstraint *new_con = BKE_constraint_copy_for_pose(ob, pchan, con);
466 new_con->flag |= CONSTRAINT_OVERRIDE_LIBRARY_LOCAL;
467
470
471 return new_con;
472}
473
474bool rna_PoseChannel_constraints_override_apply(Main *bmain,
476{
477 PointerRNA *ptr_dst = &rnaapply_ctx.ptr_dst;
478 PointerRNA *ptr_src = &rnaapply_ctx.ptr_src;
479 PropertyRNA *prop_dst = rnaapply_ctx.prop_dst;
480 IDOverrideLibraryPropertyOperation *opop = rnaapply_ctx.liboverride_operation;
481
483 "Unsupported RNA override operation on constraints collection");
484
485 bPoseChannel *pchan_dst = static_cast<bPoseChannel *>(ptr_dst->data);
486 bPoseChannel *pchan_src = static_cast<bPoseChannel *>(ptr_src->data);
487
488 /* Remember that insertion operations are defined and stored in correct order, which means that
489 * even if we insert several items in a row, we always insert first one, then second one, etc.
490 * So we should always find 'anchor' constraint in both _src *and* _dst */
491 const size_t name_offset = offsetof(bConstraint, name);
492 bConstraint *con_anchor = static_cast<bConstraint *>(
493 BLI_listbase_string_or_index_find(&pchan_dst->constraints,
494 opop->subitem_reference_name,
495 name_offset,
496 opop->subitem_reference_index));
497 /* If `con_anchor` is nullptr, `con_src` will be inserted in first position. */
498
500 &pchan_src->constraints, opop->subitem_local_name, name_offset, opop->subitem_local_index));
501
502 if (con_src == nullptr) {
503 BLI_assert(con_src != nullptr);
504 return false;
505 }
506
507 bConstraint *con_dst = BKE_constraint_duplicate_ex(con_src, 0, true);
508
509 /* This handles nullptr anchor as expected by adding at head of list. */
510 BLI_insertlinkafter(&pchan_dst->constraints, con_anchor, con_dst);
511
512 /* This should actually *not* be needed in typical cases.
513 * However, if overridden source was edited,
514 * we *may* have some new conflicting names. */
515 BKE_constraint_unique_name(con_dst, &pchan_dst->constraints);
516
517 // printf("%s: We inserted a constraint...\n", __func__);
518 RNA_property_update_main(bmain, nullptr, ptr_dst, prop_dst);
519 return true;
520}
521
522static int rna_PoseChannel_proxy_editable(const PointerRNA * /*ptr*/, const char ** /*r_info*/)
523{
524# if 0
525 Object *ob = (Object *)ptr->owner_id;
526 bArmature *arm = ob->data;
527 bPoseChannel *pchan = (bPoseChannel *)ptr->data;
528 Bone *bone = pchan->bone_get(*ob);
529 if (bone && (bone->layer & arm->layer_protected)) {
530 *r_info = "Can't edit property of a proxy on a protected layer";
531 return 0;
532 }
533# endif
534
535 return PROP_EDITABLE;
536}
537
538static int rna_PoseChannel_location_editable(const PointerRNA *ptr, int index)
539{
540 bPoseChannel *pchan = static_cast<bPoseChannel *>(ptr->data);
541
542 /* only if the axis in question is locked, not editable... */
543 if ((index == 0) && (pchan->protectflag & OB_LOCK_LOCX)) {
544 return 0;
545 }
546 if ((index == 1) && (pchan->protectflag & OB_LOCK_LOCY)) {
547 return 0;
548 }
549 if ((index == 2) && (pchan->protectflag & OB_LOCK_LOCZ)) {
550 return 0;
551 }
552 return PROP_EDITABLE;
553}
554
555static int rna_PoseChannel_scale_editable(const PointerRNA *ptr, int index)
556{
557 bPoseChannel *pchan = static_cast<bPoseChannel *>(ptr->data);
558
559 /* only if the axis in question is locked, not editable... */
560 if ((index == 0) && (pchan->protectflag & OB_LOCK_SCALEX)) {
561 return 0;
562 }
563 if ((index == 1) && (pchan->protectflag & OB_LOCK_SCALEY)) {
564 return 0;
565 }
566 if ((index == 2) && (pchan->protectflag & OB_LOCK_SCALEZ)) {
567 return 0;
568 }
569 return PROP_EDITABLE;
570}
571
572static int rna_PoseChannel_rotation_euler_editable(const PointerRNA *ptr, int index)
573{
574 bPoseChannel *pchan = static_cast<bPoseChannel *>(ptr->data);
575
576 /* only if the axis in question is locked, not editable... */
577 if ((index == 0) && (pchan->protectflag & OB_LOCK_ROTX)) {
578 return 0;
579 }
580 if ((index == 1) && (pchan->protectflag & OB_LOCK_ROTY)) {
581 return 0;
582 }
583 if ((index == 2) && (pchan->protectflag & OB_LOCK_ROTZ)) {
584 return 0;
585 }
586 return PROP_EDITABLE;
587}
588
589static int rna_PoseChannel_rotation_4d_editable(const PointerRNA *ptr, int index)
590{
591 bPoseChannel *pchan = static_cast<bPoseChannel *>(ptr->data);
592
593 /* only consider locks if locking components individually... */
594 if (pchan->protectflag & OB_LOCK_ROT4D) {
595 /* only if the axis in question is locked, not editable... */
596 if ((index == 0) && (pchan->protectflag & OB_LOCK_ROTW)) {
597 return 0;
598 }
599 if ((index == 1) && (pchan->protectflag & OB_LOCK_ROTX)) {
600 return 0;
601 }
602 if ((index == 2) && (pchan->protectflag & OB_LOCK_ROTY)) {
603 return 0;
604 }
605 if ((index == 3) && (pchan->protectflag & OB_LOCK_ROTZ)) {
606 return 0;
607 }
608 }
609
610 return PROP_EDITABLE;
611}
612
613/* not essential, but much faster than the default lookup function */
614static bool rna_PoseBones_lookup_string(PointerRNA *ptr, const char *key, PointerRNA *r_ptr)
615{
616 bPose *pose = static_cast<bPose *>(ptr->data);
618 if (pchan) {
619 rna_pointer_create_with_ancestors(*ptr, RNA_PoseBone, pchan, *r_ptr);
620 return true;
621 }
622 return false;
623}
624
625static void rna_PoseChannel_matrix_basis_get(PointerRNA *ptr, float *values)
626{
627 bPoseChannel *pchan = static_cast<bPoseChannel *>(ptr->data);
628 Object *ob = id_cast<Object *>(ptr->owner_id);
629 BKE_pchan_to_mat4({pchan, pchan->bone_get(*ob)}, reinterpret_cast<float (*)[4]>(values));
630}
631
632static void rna_PoseChannel_matrix_basis_set(PointerRNA *ptr, const float *values)
633{
634 bPoseChannel *pchan = static_cast<bPoseChannel *>(ptr->data);
635 /* No compatibility for predictable result. */
636 BKE_pchan_apply_mat4(pchan, reinterpret_cast<const float (*)[4]>(values), false);
637}
638
639static void rna_PoseChannel_matrix_set(PointerRNA *ptr, const float *values)
640{
641 bPoseChannel *pchan = static_cast<bPoseChannel *>(ptr->data);
642 Object *ob = id_cast<Object *>(ptr->owner_id);
643 float tmat[4][4];
644
646 nullptr, ob, pchan, reinterpret_cast<const float (*)[4]>(values), tmat);
647
648 /* No compatibility for predictable result. */
649 BKE_pchan_apply_mat4(pchan, tmat, false);
650}
651
652static bPoseChannel *rna_PoseChannel_ensure_own_pchan(Object *ob,
653 Object *ref_ob,
654 bPoseChannel *ref_pchan)
655{
656 if (ref_ob != ob) {
657 /* We are trying to set a pchan from another object! Forbidden,
658 * try to find by name, or abort. */
659 if (ref_pchan != nullptr) {
660 ref_pchan = BKE_pose_channel_find_name(ob->pose, ref_pchan->name);
661 }
662 }
663 return ref_pchan;
664}
665
666static void rna_PoseChannel_custom_shape_transform_set(PointerRNA *ptr,
667 PointerRNA value,
668 ReportList * /*reports*/)
669{
670 bPoseChannel *pchan = static_cast<bPoseChannel *>(ptr->data);
671 Object *ob = id_cast<Object *>(ptr->owner_id);
672
673 pchan->custom_tx = rna_PoseChannel_ensure_own_pchan(
674 ob, id_cast<Object *>(value.owner_id), static_cast<bPoseChannel *>(value.data));
675}
676
677void rna_Pose_custom_shape_set(PointerRNA *ptr, PointerRNA value, struct ReportList *reports)
678{
679 bPoseChannel *pchan = static_cast<bPoseChannel *>(ptr->data);
680 Object *custom_shape = static_cast<Object *>(value.data);
681
682 if (!custom_shape) {
683 id_us_min(reinterpret_cast<ID *>(pchan->custom));
684 pchan->custom = nullptr;
685 return;
686 }
687
688 /* This should be ensured by the RNA property type. */
689 BLI_assert(GS(custom_shape->id.name) == ID_OB);
690
691 if (custom_shape->type == OB_ARMATURE) {
692 BKE_report(reports, RPT_ERROR, "Cannot use armature object as custom bone shape");
693 return;
694 }
695
696 id_us_min(reinterpret_cast<ID *>(pchan->custom));
697 pchan->custom = custom_shape;
698 id_us_plus(reinterpret_cast<ID *>(pchan->custom));
699}
700
701bool rna_Pose_custom_shape_object_poll(PointerRNA * /*ptr*/, PointerRNA value)
702{
703 return (reinterpret_cast<Object *>(value.owner_id))->type != OB_ARMATURE;
704}
705
706static void rna_Pose_select_update(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
707{
708 ID *id = ptr->owner_id;
709
710 if (!id) {
711 /* There shouldn't be a pose bone without an object. */
713 return;
714 }
715 BLI_assert(GS(id->name) == ID_OB);
716 Object *ob = id_cast<Object *>(id);
717 bArmature *arm = id_cast<bArmature *>(ob->data);
718
719 if (arm->flag & ARM_HAS_VIZ_DEPS) {
721 }
722
724
727}
728
729} // namespace blender
730
731#else
732
733namespace blender {
734
735void rna_def_actionbone_group_common(StructRNA *srna, int update_flag, const char *update_cb)
736{
737 PropertyRNA *prop;
738
739 /* color set + colors */
740 prop = RNA_def_property(srna, "color_set", PROP_ENUM, PROP_NONE);
741 RNA_def_property_enum_sdna(prop, nullptr, "customCol");
743 RNA_def_property_enum_funcs(prop, nullptr, "rna_ActionGroup_colorset_set", nullptr);
744 RNA_def_property_ui_text(prop, "Color Set", "Custom color set to use");
745 RNA_def_property_update(prop, update_flag, update_cb);
746
747 prop = RNA_def_property(srna, "is_custom_color_set", PROP_BOOLEAN, PROP_NONE);
748 RNA_def_property_boolean_funcs(prop, "rna_ActionGroup_is_custom_colorset_get", nullptr);
751 prop, "Custom Color Set", "Color set is user-defined instead of a fixed theme color set");
752
753 /* TODO: editing the colors for this should result in changes to the color type... */
754 prop = RNA_def_property(srna, "colors", PROP_POINTER, PROP_NONE);
756 RNA_def_property_struct_type(prop, "ThemeBoneColorSet");
757 /* NOTE: the DNA data is not really a pointer, but this code works :) */
758 RNA_def_property_pointer_sdna(prop, nullptr, "cs");
760 prop, "Colors", "Copy of the colors associated with the group's color set");
761 RNA_def_property_update(prop, update_flag, update_cb);
762}
763
765 {IKSOLVER_STANDARD, "LEGACY", 0, "Standard", "Original IK solver"},
766 {IKSOLVER_ITASC, "ITASC", 0, "iTaSC", "Multi constraint, stateful IK solver"},
767 {0, nullptr, 0, nullptr, nullptr},
768};
769
771 {ITASC_SOLVER_SDLS, "SDLS", 0, "SDLS", "Selective Damped Least Square"},
772 {ITASC_SOLVER_DLS, "DLS", 0, "DLS", "Damped Least Square with Numerical Filtering"},
773 {0, nullptr, 0, nullptr, nullptr},
774};
775
777{
778 StructRNA *srna;
779 PropertyRNA *prop;
780
781 FunctionRNA *func;
782 PropertyRNA *parm;
783
784 RNA_def_property_srna(cprop, "PoseBoneConstraints");
785 srna = RNA_def_struct(brna, "PoseBoneConstraints", nullptr);
786 RNA_def_struct_sdna(srna, "bPoseChannel");
787 RNA_def_struct_ui_text(srna, "PoseBone Constraints", "Collection of pose bone constraints");
788
789 /* Collection active property */
790 prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
791 RNA_def_property_struct_type(prop, "Constraint");
793 "rna_PoseChannel_active_constraint_get",
794 "rna_PoseChannel_active_constraint_set",
795 nullptr,
796 nullptr);
798 RNA_def_property_ui_text(prop, "Active Constraint", "Active PoseChannel constraint");
799
800 /* Constraint collection */
801 func = RNA_def_function(srna, "new", "rna_PoseChannel_constraints_new");
802 RNA_def_function_ui_description(func, "Add a constraint to this object");
804 FUNC_USE_MAIN | FUNC_USE_SELF_ID); /* ID and Main needed for refresh */
805 /* return type */
806 parm = RNA_def_pointer(func, "constraint", "Constraint", "", "New constraint");
808 RNA_def_function_return(func, parm);
809 /* constraint to add */
810 parm = RNA_def_enum(
811 func, "type", rna_enum_constraint_type_items, 1, "", "Constraint type to add");
813 RNA_def_string(func,
814 "name",
815 nullptr,
816 0,
817 "",
818 "Name of the new constraint. If empty, the name of the constraint type is used");
819
820 func = RNA_def_function(srna, "remove", "rna_PoseChannel_constraints_remove");
821 RNA_def_function_ui_description(func, "Remove a constraint from this object");
823 func, FUNC_USE_SELF_ID | FUNC_USE_MAIN | FUNC_USE_REPORTS); /* ID needed for refresh */
824 /* constraint to remove */
825 parm = RNA_def_pointer(func, "constraint", "Constraint", "", "Removed constraint");
828
829 func = RNA_def_function(srna, "move", "rna_PoseChannel_constraints_move");
830 RNA_def_function_ui_description(func, "Move a constraint to a different position");
832 parm = RNA_def_int(
833 func, "from_index", -1, INT_MIN, INT_MAX, "From Index", "Index to move", 0, 10000);
835 parm = RNA_def_int(func, "to_index", -1, INT_MIN, INT_MAX, "To Index", "Target index", 0, 10000);
837
838 func = RNA_def_function(srna, "copy", "rna_PoseChannel_constraints_copy");
839 RNA_def_function_ui_description(func, "Add a new constraint that is a copy of the given one");
841 /* constraint to copy */
842 parm = RNA_def_pointer(func,
843 "constraint",
844 "Constraint",
845 "",
846 "Constraint to copy - may belong to a different object");
849 /* return type */
850 parm = RNA_def_pointer(func, "new_constraint", "Constraint", "", "New constraint");
852 RNA_def_function_return(func, parm);
853}
854
856{
857 StructRNA *srna;
858 PropertyRNA *prop;
859
860 srna = RNA_def_struct(brna, "PoseBone", nullptr);
861 RNA_def_struct_sdna(srna, "bPoseChannel");
862 RNA_def_struct_ui_text(srna, "Pose Bone", "Channel defining pose data for a bone in a Pose");
863 RNA_def_struct_path_func(srna, "rna_PoseBone_path");
864 RNA_def_struct_idprops_func(srna, "rna_PoseBone_idprops");
865 RNA_def_struct_system_idprops_func(srna, "rna_PoseBone_system_idprops");
866 RNA_def_struct_ui_icon(srna, ICON_BONE_DATA);
867
868 /* Bone Constraints */
869 prop = RNA_def_property(srna, "constraints", PROP_COLLECTION, PROP_NONE);
870 RNA_def_property_struct_type(prop, "Constraint");
873 RNA_def_property_ui_text(prop, "Constraints", "Constraints that act on this pose channel");
875 prop, nullptr, nullptr, "rna_PoseChannel_constraints_override_apply");
876
878
879 /* Name + Selection Status */
880 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
881 RNA_def_property_string_funcs(prop, nullptr, nullptr, "rna_PoseChannel_name_set");
882 RNA_def_property_ui_text(prop, "Name", "");
883 RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
885 RNA_def_property_update(prop, 0, "rna_PoseChannel_name_update");
886
887 /* Baked Bone Path cache data */
889
890 /* Relationships to other bones */
891 prop = RNA_def_property(srna, "bone", PROP_POINTER, PROP_NONE);
893 RNA_def_property_struct_type(prop, "Bone");
894 RNA_def_property_pointer_funcs(prop, "rna_PoseChannel_bone_get", nullptr, nullptr, nullptr);
897 RNA_def_property_ui_text(prop, "Bone", "Bone associated with this PoseBone");
898
899 prop = RNA_def_property(srna, "parent", PROP_POINTER, PROP_NONE);
900 RNA_def_property_struct_type(prop, "PoseBone");
903 RNA_def_property_ui_text(prop, "Parent", "Parent of this pose bone");
904
905 prop = RNA_def_property(srna, "child", PROP_POINTER, PROP_NONE);
906 RNA_def_property_struct_type(prop, "PoseBone");
909 RNA_def_property_ui_text(prop, "Child", "Child of this pose bone");
910
911 /* Transformation settings */
912 prop = RNA_def_property(srna, "location", PROP_FLOAT, PROP_TRANSLATION);
913 RNA_def_property_float_sdna(prop, nullptr, "loc");
915 RNA_def_property_editable_array_func(prop, "rna_PoseChannel_location_editable");
916 RNA_def_property_ui_text(prop, "Location", "");
918 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_IK_update");
919
920 prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_XYZ);
923 RNA_def_property_editable_array_func(prop, "rna_PoseChannel_scale_editable");
924 RNA_def_property_ui_text(prop, "Scale", "");
925 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_IK_update");
926
927 prop = RNA_def_property(srna, "rotation_quaternion", PROP_FLOAT, PROP_QUATERNION);
928 RNA_def_property_float_sdna(prop, nullptr, "quat");
930 RNA_def_property_editable_array_func(prop, "rna_PoseChannel_rotation_4d_editable");
931 RNA_def_property_ui_text(prop, "Quaternion Rotation", "Rotation in Quaternions");
932 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
933
934 /* XXX: for axis-angle, it would have been nice to have 2 separate fields for UI purposes, but
935 * having a single one is better for Keyframing and other property-management situations...
936 */
937 prop = RNA_def_property(srna, "rotation_axis_angle", PROP_FLOAT, PROP_AXISANGLE);
939 RNA_def_property_array(prop, 4);
941 "rna_PoseChannel_rotation_axis_angle_get",
942 "rna_PoseChannel_rotation_axis_angle_set",
943 nullptr);
944 RNA_def_property_editable_array_func(prop, "rna_PoseChannel_rotation_4d_editable");
947 prop, "Axis-Angle Rotation", "Angle of Rotation for Axis-Angle rotation representation");
948 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
949
950 prop = RNA_def_property(srna, "rotation_euler", PROP_FLOAT, PROP_EULER);
951 RNA_def_property_float_sdna(prop, nullptr, "eul");
953 RNA_def_property_editable_array_func(prop, "rna_PoseChannel_rotation_euler_editable");
954 RNA_def_property_ui_text(prop, "Euler Rotation", "Rotation in Eulers");
956 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
957
958 prop = RNA_def_property(srna, "rotation_mode", PROP_ENUM, PROP_NONE);
959 RNA_def_property_enum_sdna(prop, nullptr, "rotmode");
962 RNA_def_property_enum_funcs(prop, nullptr, "rna_PoseChannel_rotation_mode_set", nullptr);
963 /* XXX... disabled, since proxy-locked layers are currently
964 * used for ensuring proxy-syncing too */
965 RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
967 prop,
968 "Rotation Mode",
969 /* This description is shared by other "rotation_mode" properties. */
970 "The kind of rotation to apply, values from other rotation modes are not used");
971 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
972
974 srna, "convert_rotation_mode", "rna_PoseChannel_convert_rotation_mode");
976 "Changes the rotation mode and converts all actions used by "
977 "that bone to match that new mode");
979 PropertyRNA *parm = RNA_def_enum(func,
980 "rotation_mode",
983 "Rotation Mode",
984 "The rotation mode to change to");
986
987 parm = RNA_def_boolean(func,
988 "bake",
989 false,
990 "Bake",
991 "Insert a key on every frame to ensure interpolation is preserved");
992
993 /* Curved bones settings - Applied on top of rest-pose values. */
994 rna_def_bone_curved_common(srna, true, false);
995
996 /* Custom BBone next/prev sources */
997 prop = RNA_def_property(srna, "bbone_custom_handle_start", PROP_POINTER, PROP_NONE);
998 RNA_def_property_pointer_sdna(prop, nullptr, "bbone_prev");
999 RNA_def_property_struct_type(prop, "PoseBone");
1003 prop, "B-Bone Start Handle", "Bone that serves as the start handle for the B-Bone curve");
1004 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_dependency_update");
1005
1006 prop = RNA_def_property(srna, "bbone_custom_handle_end", PROP_POINTER, PROP_NONE);
1007 RNA_def_property_pointer_sdna(prop, nullptr, "bbone_next");
1008 RNA_def_property_struct_type(prop, "PoseBone");
1012 prop, "B-Bone End Handle", "Bone that serves as the end handle for the B-Bone curve");
1013 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_dependency_update");
1014
1015 /* transform matrices - should be read-only since these are set directly by AnimSys evaluation */
1016 prop = RNA_def_property(srna, "matrix_channel", PROP_FLOAT, PROP_MATRIX);
1017 RNA_def_property_float_sdna(prop, nullptr, "chan_mat");
1021 "Channel Matrix",
1023 "4 matrix of the bone's location/rotation/scale channels (including "
1024 "animation and drivers) and the effect of bone constraints");
1025
1026 /* writable because it touches loc/scale/rot directly */
1027 prop = RNA_def_property(srna, "matrix_basis", PROP_FLOAT, PROP_MATRIX);
1030 prop,
1031 "Basis Matrix",
1032 "Alternative access to location/scale/rotation relative to the parent and own rest bone");
1034 prop, "rna_PoseChannel_matrix_basis_get", "rna_PoseChannel_matrix_basis_set", nullptr);
1036 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
1037
1038 /* final matrix */
1039 prop = RNA_def_property(srna, "matrix", PROP_FLOAT, PROP_MATRIX);
1040 RNA_def_property_float_sdna(prop, nullptr, "pose_mat");
1042 RNA_def_property_float_funcs(prop, nullptr, "rna_PoseChannel_matrix_set", nullptr);
1044 "Pose Matrix",
1046 "4 matrix after constraints and drivers are applied, in "
1047 "the armature object space");
1048 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
1049
1050 /* Head/Tail Coordinates (in Pose Space) - Automatically calculated... */
1051 prop = RNA_def_property(srna, "head", PROP_FLOAT, PROP_TRANSLATION);
1052 RNA_def_property_float_sdna(prop, nullptr, "pose_head");
1054 RNA_def_property_ui_text(prop, "Pose Head Position", "Location of head of the channel's bone");
1056
1057 prop = RNA_def_property(srna, "tail", PROP_FLOAT, PROP_TRANSLATION);
1058 RNA_def_property_float_sdna(prop, nullptr, "pose_tail");
1060 RNA_def_property_ui_text(prop, "Pose Tail Position", "Location of tail of the channel's bone");
1062
1063 prop = RNA_def_property(srna, "length", PROP_FLOAT, PROP_DISTANCE);
1064 RNA_def_property_float_funcs(prop, "rna_PoseChannel_length_get", nullptr, nullptr);
1066 RNA_def_property_ui_text(prop, "Length", "Length of the bone");
1067
1068 /* IK Settings */
1069 prop = RNA_def_property(srna, "is_in_ik_chain", PROP_BOOLEAN, PROP_NONE);
1070 RNA_def_property_boolean_funcs(prop, "rna_PoseChannel_has_ik_get", nullptr);
1073 RNA_def_property_ui_text(prop, "Has IK", "Is part of an IK chain");
1074 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_IK_update");
1075
1076 prop = RNA_def_property(srna, "lock_ik_x", PROP_BOOLEAN, PROP_NONE);
1077 RNA_def_property_boolean_sdna(prop, nullptr, "ikflag", BONE_IK_NO_XDOF);
1078 RNA_def_property_ui_icon(prop, ICON_UNLOCKED, true);
1079 RNA_def_property_ui_text(prop, "IK X Lock", "Disallow movement around the X axis");
1080 RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
1081 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_IK_update");
1082
1083 prop = RNA_def_property(srna, "lock_ik_y", PROP_BOOLEAN, PROP_NONE);
1084 RNA_def_property_boolean_sdna(prop, nullptr, "ikflag", BONE_IK_NO_YDOF);
1085 RNA_def_property_ui_icon(prop, ICON_UNLOCKED, true);
1086 RNA_def_property_ui_text(prop, "IK Y Lock", "Disallow movement around the Y axis");
1087 RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
1088 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_IK_update");
1089
1090 prop = RNA_def_property(srna, "lock_ik_z", PROP_BOOLEAN, PROP_NONE);
1091 RNA_def_property_boolean_sdna(prop, nullptr, "ikflag", BONE_IK_NO_ZDOF);
1092 RNA_def_property_ui_icon(prop, ICON_UNLOCKED, true);
1093 RNA_def_property_ui_text(prop, "IK Z Lock", "Disallow movement around the Z axis");
1094 RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
1095 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_IK_update");
1096
1097 prop = RNA_def_property(srna, "use_ik_limit_x", PROP_BOOLEAN, PROP_NONE);
1098 RNA_def_property_boolean_sdna(prop, nullptr, "ikflag", BONE_IK_XLIMIT);
1099 RNA_def_property_ui_text(prop, "IK X Limit", "Limit movement around the X axis");
1100 RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
1101 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_IK_update");
1102
1103 prop = RNA_def_property(srna, "use_ik_limit_y", PROP_BOOLEAN, PROP_NONE);
1104 RNA_def_property_boolean_sdna(prop, nullptr, "ikflag", BONE_IK_YLIMIT);
1105 RNA_def_property_ui_text(prop, "IK Y Limit", "Limit movement around the Y axis");
1106 RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
1107 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_IK_update");
1108
1109 prop = RNA_def_property(srna, "use_ik_limit_z", PROP_BOOLEAN, PROP_NONE);
1110 RNA_def_property_boolean_sdna(prop, nullptr, "ikflag", BONE_IK_ZLIMIT);
1111 RNA_def_property_ui_text(prop, "IK Z Limit", "Limit movement around the Z axis");
1112 RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
1113 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_IK_update");
1114
1115 prop = RNA_def_property(srna, "use_ik_rotation_control", PROP_BOOLEAN, PROP_NONE);
1116 RNA_def_property_boolean_sdna(prop, nullptr, "ikflag", BONE_IK_ROTCTL);
1117 RNA_def_property_ui_text(prop, "IK Rotation Control", "Apply channel rotation as IK constraint");
1118 RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
1119 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_IK_update");
1120
1121 prop = RNA_def_property(srna, "use_ik_linear_control", PROP_BOOLEAN, PROP_NONE);
1122 RNA_def_property_boolean_sdna(prop, nullptr, "ikflag", BONE_IK_LINCTL);
1124 prop, "IK Linear Control", "Apply channel size as IK constraint if stretching is enabled");
1125 RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
1126 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_IK_update");
1127
1128 prop = RNA_def_property(srna, "ik_min_x", PROP_FLOAT, PROP_ANGLE);
1129 RNA_def_property_float_sdna(prop, nullptr, "limitmin[0]");
1130 RNA_def_property_range(prop, -M_PI, 0.0f);
1132 RNA_def_property_ui_text(prop, "IK X Minimum", "Minimum angles for IK Limit");
1133 RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
1134 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_IK_update");
1135
1136 prop = RNA_def_property(srna, "ik_max_x", PROP_FLOAT, PROP_ANGLE);
1137 RNA_def_property_float_sdna(prop, nullptr, "limitmax[0]");
1138 RNA_def_property_range(prop, 0.0f, M_PI);
1140 RNA_def_property_ui_text(prop, "IK X Maximum", "Maximum angles for IK Limit");
1141 RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
1142 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_IK_update");
1143
1144 prop = RNA_def_property(srna, "ik_min_y", PROP_FLOAT, PROP_ANGLE);
1145 RNA_def_property_float_sdna(prop, nullptr, "limitmin[1]");
1146 RNA_def_property_range(prop, -M_PI, 0.0f);
1148 RNA_def_property_ui_text(prop, "IK Y Minimum", "Minimum angles for IK Limit");
1149 RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
1150 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_IK_update");
1151
1152 prop = RNA_def_property(srna, "ik_max_y", PROP_FLOAT, PROP_ANGLE);
1153 RNA_def_property_float_sdna(prop, nullptr, "limitmax[1]");
1154 RNA_def_property_range(prop, 0.0f, M_PI);
1156 RNA_def_property_ui_text(prop, "IK Y Maximum", "Maximum angles for IK Limit");
1157 RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
1158 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_IK_update");
1159
1160 prop = RNA_def_property(srna, "ik_min_z", PROP_FLOAT, PROP_ANGLE);
1161 RNA_def_property_float_sdna(prop, nullptr, "limitmin[2]");
1162 RNA_def_property_range(prop, -M_PI, 0.0f);
1164 RNA_def_property_ui_text(prop, "IK Z Minimum", "Minimum angles for IK Limit");
1165 RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
1166 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_IK_update");
1167
1168 prop = RNA_def_property(srna, "ik_max_z", PROP_FLOAT, PROP_ANGLE);
1169 RNA_def_property_float_sdna(prop, nullptr, "limitmax[2]");
1170 RNA_def_property_range(prop, 0.0f, M_PI);
1172 RNA_def_property_ui_text(prop, "IK Z Maximum", "Maximum angles for IK Limit");
1173 RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
1174 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_IK_update");
1175
1176 prop = RNA_def_property(srna, "ik_stiffness_x", PROP_FLOAT, PROP_NONE);
1177 RNA_def_property_float_sdna(prop, nullptr, "stiffness[0]");
1178 RNA_def_property_range(prop, 0.0f, 0.99f);
1179 RNA_def_property_ui_text(prop, "IK X Stiffness", "IK stiffness around the X axis");
1180 RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
1181 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_IK_update");
1182
1183 prop = RNA_def_property(srna, "ik_stiffness_y", PROP_FLOAT, PROP_NONE);
1184 RNA_def_property_float_sdna(prop, nullptr, "stiffness[1]");
1185 RNA_def_property_range(prop, 0.0f, 0.99f);
1186 RNA_def_property_ui_text(prop, "IK Y Stiffness", "IK stiffness around the Y axis");
1187 RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
1188 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_IK_update");
1189
1190 prop = RNA_def_property(srna, "ik_stiffness_z", PROP_FLOAT, PROP_NONE);
1191 RNA_def_property_float_sdna(prop, nullptr, "stiffness[2]");
1192 RNA_def_property_range(prop, 0.0f, 0.99f);
1193 RNA_def_property_ui_text(prop, "IK Z Stiffness", "IK stiffness around the Z axis");
1194 RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
1195 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_IK_update");
1196
1197 prop = RNA_def_property(srna, "ik_stretch", PROP_FLOAT, PROP_FACTOR);
1198 RNA_def_property_float_sdna(prop, nullptr, "ikstretch");
1199 RNA_def_property_range(prop, 0.0f, 1.0f);
1200 RNA_def_property_ui_text(prop, "IK Stretch", "Allow scaling of the bone for IK");
1201 RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
1202 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_IK_update");
1203
1204 prop = RNA_def_property(srna, "ik_rotation_weight", PROP_FLOAT, PROP_FACTOR);
1205 RNA_def_property_float_sdna(prop, nullptr, "ikrotweight");
1206 RNA_def_property_range(prop, 0.0f, 1.0f);
1207 RNA_def_property_ui_text(prop, "IK Rotation Weight", "Weight of rotation constraint for IK");
1208 RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
1209 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
1210
1211 prop = RNA_def_property(srna, "ik_linear_weight", PROP_FLOAT, PROP_FACTOR);
1212 RNA_def_property_float_sdna(prop, nullptr, "iklinweight");
1213 RNA_def_property_range(prop, 0.0f, 1.0f);
1214 RNA_def_property_ui_text(prop, "IK Lin Weight", "Weight of scale constraint for IK");
1215 RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
1216 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
1217
1218 /* custom bone shapes */
1219 prop = RNA_def_property(srna, "custom_shape", PROP_POINTER, PROP_NONE);
1220 RNA_def_property_pointer_sdna(prop, nullptr, "custom");
1221 RNA_def_property_struct_type(prop, "Object");
1225 prop, "Custom Object", "Object that defines custom display shape for this bone");
1226 RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
1228 prop, nullptr, "rna_Pose_custom_shape_set", nullptr, "rna_Pose_custom_shape_object_poll");
1229 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_dependency_update");
1230
1231 prop = RNA_def_property(srna, "custom_shape_scale_xyz", PROP_FLOAT, PROP_XYZ);
1232 RNA_def_property_float_sdna(prop, nullptr, "custom_scale_xyz");
1234 RNA_def_property_ui_text(prop, "Custom Shape Scale", "Adjust the size of the custom shape");
1235 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
1236
1237 prop = RNA_def_property(srna, "custom_shape_translation", PROP_FLOAT, PROP_XYZ);
1238 RNA_def_property_float_sdna(prop, nullptr, "custom_translation");
1241 prop, "Custom Shape Translation", "Adjust the location of the custom shape");
1243 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
1244
1245 prop = RNA_def_property(srna, "custom_shape_rotation_euler", PROP_FLOAT, PROP_EULER);
1246 RNA_def_property_float_sdna(prop, nullptr, "custom_rotation_euler");
1248 prop, "Custom Shape Rotation", "Adjust the rotation of the custom shape");
1250 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
1251
1252 prop = RNA_def_property(srna, "use_transform_at_custom_shape", PROP_BOOLEAN, PROP_NONE);
1255 prop,
1256 "Affect Gizmo",
1257 "The location and orientation of the Custom Shape Transform bone will be used for transform "
1258 "gizmos and for other transform operators in the 3D Viewport. When disabled, the 3D "
1259 "Viewport will still use the actual bone transform for these, even when the custom bone "
1260 "shape transform is overridden.");
1261 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
1262
1263 prop = RNA_def_property(srna, "use_transform_around_custom_shape", PROP_BOOLEAN, PROP_NONE);
1266 prop,
1267 "Use As Pivot",
1268 "Transform the bone as if it was a child of the Custom Shape Transform bone. This can be "
1269 "useful when combining shape-key and armature deformations.");
1270 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
1271
1272 prop = RNA_def_property(srna, "use_custom_shape_bone_size", PROP_BOOLEAN, PROP_NONE);
1274 prop, nullptr, "drawflag", PCHAN_DRAW_NO_CUSTOM_BONE_SIZE);
1276 prop, "Scale to Bone Length", "Scale the custom object by the bone length");
1277 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
1278
1279 prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
1281 RNA_def_property_boolean_sdna(prop, nullptr, "drawflag", PCHAN_DRAW_HIDDEN);
1282 RNA_def_property_ui_text(prop, "Hide", "Bone is not visible except for Edit Mode");
1283 RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_OFF, -1);
1284 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_PoseBone_visibility_update");
1285
1286 prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
1288 RNA_def_property_boolean_sdna(prop, nullptr, "flag", POSE_SELECTED);
1289 RNA_def_property_ui_text(prop, "Select", "Bone is selected in Pose Mode");
1290 RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_OFF, -1);
1292 RNA_def_property_update(prop, 0, "rna_Pose_select_update");
1293
1294 prop = RNA_def_property(srna, "custom_shape_transform", PROP_POINTER, PROP_NONE);
1295 RNA_def_property_pointer_sdna(prop, nullptr, "custom_tx");
1296 RNA_def_property_struct_type(prop, "PoseBone");
1300 "Custom Shape Transform",
1301 "Bone that defines the display transform of this custom shape");
1302 RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
1304 prop, nullptr, "rna_PoseChannel_custom_shape_transform_set", nullptr, nullptr);
1305 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
1306
1307 prop = RNA_def_property(srna, "custom_shape_wire_width", PROP_FLOAT, PROP_NONE);
1308 RNA_def_property_float_sdna(prop, nullptr, "custom_shape_wire_width");
1309 RNA_def_property_ui_text(prop, "Wire Width", "Adjust the line thickness of custom shapes");
1310 /* When changing the upper limit of the range, also adjust the WIRE_WIDTH_COMPRESSION in
1311 * overlay_shader_shared.hh */
1312 RNA_def_property_range(prop, 1.0f, 16.0f);
1313 RNA_def_property_ui_range(prop, 1.0f, 10.0f, 1, 2);
1314 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
1315
1316 prop = RNA_def_property(srna, "color", PROP_POINTER, PROP_NONE);
1317 RNA_def_property_struct_type(prop, "BoneColor");
1320
1321 /* transform locks */
1322 prop = RNA_def_property(srna, "lock_location", PROP_BOOLEAN, PROP_NONE);
1323 RNA_def_property_boolean_bitset_array_sdna(prop, nullptr, "protectflag", OB_LOCK_LOCX, 3);
1324 RNA_def_property_ui_text(prop, "Lock Location", "Lock editing of location when transforming");
1325 RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1);
1327 RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
1328 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
1329
1330 prop = RNA_def_property(srna, "lock_rotation", PROP_BOOLEAN, PROP_NONE);
1331 RNA_def_property_boolean_bitset_array_sdna(prop, nullptr, "protectflag", OB_LOCK_ROTX, 3);
1332 RNA_def_property_ui_text(prop, "Lock Rotation", "Lock editing of rotation when transforming");
1333 RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1);
1335 RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
1336 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
1337
1338 /* XXX this is sub-optimal - it really should be included above, but due to technical reasons
1339 * we can't do this! */
1340 prop = RNA_def_property(srna, "lock_rotation_w", PROP_BOOLEAN, PROP_NONE);
1341 RNA_def_property_boolean_sdna(prop, nullptr, "protectflag", OB_LOCK_ROTW);
1343 prop,
1344 "Lock Rotation (4D Angle)",
1345 "Lock editing of 'angle' component of four-component rotations when transforming");
1346 RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1);
1348 RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
1349 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
1350
1351 /* XXX this needs a better name */
1352 prop = RNA_def_property(srna, "lock_rotations_4d", PROP_BOOLEAN, PROP_NONE);
1353 RNA_def_property_boolean_sdna(prop, nullptr, "protectflag", OB_LOCK_ROT4D);
1355 prop,
1356 "Lock Rotations (4D)",
1357 "Lock editing of four component rotations by components (instead of as Eulers)");
1359 RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
1360 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
1361
1362 prop = RNA_def_property(srna, "lock_scale", PROP_BOOLEAN, PROP_NONE);
1363 RNA_def_property_boolean_bitset_array_sdna(prop, nullptr, "protectflag", OB_LOCK_SCALEX, 3);
1364 RNA_def_property_ui_text(prop, "Lock Scale", "Lock editing of scale when transforming");
1365 RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1);
1367 RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
1368 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
1369
1371}
1372
1374{
1375 static const EnumPropertyItem prop_itasc_mode_items[] = {
1376 {0,
1377 "ANIMATION",
1378 0,
1379 "Animation",
1380 "Stateless solver computing pose starting from current action and non-IK constraints"},
1382 "SIMULATION",
1383 0,
1384 "Simulation",
1385 "State-full solver running in real-time context and ignoring actions "
1386 "and non-IK constraints"},
1387 {0, nullptr, 0, nullptr, nullptr},
1388 };
1389 static const EnumPropertyItem prop_itasc_reiteration_items[] = {
1390 {0,
1391 "NEVER",
1392 0,
1393 "Never",
1394 "The solver does not reiterate, not even on first frame (starts from rest pose)"},
1396 "INITIAL",
1397 0,
1398 "Initial",
1399 "The solver reiterates (converges) on the first frame but not on "
1400 "subsequent frame"},
1402 "ALWAYS",
1403 0,
1404 "Always",
1405 "The solver reiterates (converges) on all frames"},
1406 {0, nullptr, 0, nullptr, nullptr},
1407 };
1408
1409 StructRNA *srna;
1410 PropertyRNA *prop;
1411
1412 srna = RNA_def_struct(brna, "Itasc", "IKParam");
1413 RNA_def_struct_sdna(srna, "bItasc");
1414 RNA_def_struct_ui_text(srna, "bItasc", "Parameters for the iTaSC IK solver");
1415
1416 prop = RNA_def_property(srna, "precision", PROP_FLOAT, PROP_NONE);
1417 RNA_def_property_float_sdna(prop, nullptr, "precision");
1418 RNA_def_property_range(prop, 0.0f, 0.1f);
1419 RNA_def_property_ui_text(prop, "Precision", "Precision of convergence in case of reiteration");
1420 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Itasc_update");
1421
1422 prop = RNA_def_property(srna, "iterations", PROP_INT, PROP_NONE);
1423 RNA_def_property_int_sdna(prop, nullptr, "numiter");
1424 RNA_def_property_range(prop, 0, 1000);
1426 prop, "Iterations", "Maximum number of iterations for convergence in case of reiteration");
1427 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Itasc_update");
1428
1429 prop = RNA_def_property(srna, "step_count", PROP_INT, PROP_NONE);
1430 RNA_def_property_int_sdna(prop, nullptr, "numstep");
1431 RNA_def_property_range(prop, 1.0f, 50.0f);
1432 RNA_def_property_ui_text(prop, "Num Steps", "Divide the frame interval into this many steps");
1433 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Itasc_update");
1434
1435 prop = RNA_def_property(srna, "translate_root_bones", PROP_BOOLEAN, PROP_NONE);
1438 prop, "Translate Roots", "Translate root (i.e. parentless) bones to the armature origin");
1439 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Itasc_update");
1440
1441 prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
1442 RNA_def_property_enum_bitflag_sdna(prop, nullptr, "flag");
1443 RNA_def_property_enum_items(prop, prop_itasc_mode_items);
1444 RNA_def_property_ui_text(prop, "Mode", nullptr);
1445 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Itasc_update_rebuild");
1446
1447 prop = RNA_def_property(srna, "reiteration_method", PROP_ENUM, PROP_NONE);
1448 RNA_def_property_enum_bitflag_sdna(prop, nullptr, "flag");
1449 RNA_def_property_enum_items(prop, prop_itasc_reiteration_items);
1451 "Reiteration",
1452 "Defines if the solver is allowed to reiterate (converge until "
1453 "precision is met) on none, first or all frames");
1454 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Itasc_update");
1455
1456 prop = RNA_def_property(srna, "use_auto_step", PROP_BOOLEAN, PROP_NONE);
1457 RNA_def_property_boolean_sdna(prop, nullptr, "flag", ITASC_AUTO_STEP);
1459 "Auto Step",
1460 "Automatically determine the optimal number of steps for best "
1461 "performance/accuracy trade off");
1462 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Itasc_update");
1463
1464 prop = RNA_def_property(srna, "step_min", PROP_FLOAT, PROP_FACTOR);
1465 RNA_def_property_float_sdna(prop, nullptr, "minstep");
1466 RNA_def_property_range(prop, 0.0f, 0.1f);
1468 prop, "Min Step", "Lower bound for timestep in second in case of automatic substeps");
1469 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Itasc_update");
1470
1471 prop = RNA_def_property(srna, "step_max", PROP_FLOAT, PROP_FACTOR);
1472 RNA_def_property_float_sdna(prop, nullptr, "maxstep");
1473 RNA_def_property_range(prop, 0.0f, 1.0f);
1475 prop, "Max Step", "Higher bound for timestep in second in case of automatic substeps");
1476 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Itasc_update");
1477
1478 prop = RNA_def_property(srna, "feedback", PROP_FLOAT, PROP_NONE);
1479 RNA_def_property_float_sdna(prop, nullptr, "feedback");
1480 RNA_def_property_range(prop, 0.0f, 100.0f);
1482 prop,
1483 "Feedback",
1484 "Feedback coefficient for error correction, average response time is 1/feedback");
1485 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Itasc_update");
1486
1487 prop = RNA_def_property(srna, "velocity_max", PROP_FLOAT, PROP_NONE);
1488 RNA_def_property_float_sdna(prop, nullptr, "maxvel");
1489 RNA_def_property_range(prop, 0.0f, 100.0f);
1490 RNA_def_property_ui_text(prop, "Max Velocity", "Maximum joint velocity in radians/second");
1491 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Itasc_update");
1492
1493 prop = RNA_def_property(srna, "solver", PROP_ENUM, PROP_NONE);
1494 RNA_def_property_enum_sdna(prop, nullptr, "solver");
1497 prop, "Solver", "Solving method selection: automatic damping or manual damping");
1498 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Itasc_update_rebuild");
1499
1500 prop = RNA_def_property(srna, "damping_max", PROP_FLOAT, PROP_FACTOR);
1501 RNA_def_property_float_sdna(prop, nullptr, "dampmax");
1502 RNA_def_property_range(prop, 0.0f, 1.0f);
1504 "Damp",
1505 "Maximum damping coefficient when singular value is nearly 0 "
1506 "(higher values produce results with more stability, less reactivity)");
1507 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Itasc_update");
1508
1509 prop = RNA_def_property(srna, "damping_epsilon", PROP_FLOAT, PROP_FACTOR);
1510 RNA_def_property_float_sdna(prop, nullptr, "dampeps");
1511 RNA_def_property_range(prop, 0.0f, 1.0f);
1513 "Epsilon",
1514 "Singular value under which damping is progressively applied "
1515 "(higher values produce results with more stability, less reactivity)");
1516 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Itasc_update");
1517}
1518
1520{
1521 StructRNA *srna;
1522 PropertyRNA *prop;
1523
1524 srna = RNA_def_struct(brna, "IKParam", nullptr);
1525 RNA_def_struct_sdna(srna, "bIKParam");
1526 RNA_def_struct_ui_text(srna, "IKParam", "Base type for IK solver parameters");
1527 RNA_def_struct_refine_func(srna, "rna_IKParam_refine");
1528
1529 prop = RNA_def_property(srna, "ik_solver", PROP_ENUM, PROP_NONE);
1530 RNA_def_property_enum_sdna(prop, nullptr, "iksolver");
1533 RNA_def_property_ui_text(prop, "IK Solver", "IK solver for which these parameters are defined");
1534}
1535
1536static void rna_def_pose(BlenderRNA *brna)
1537{
1538 StructRNA *srna;
1539 PropertyRNA *prop;
1540
1541 /* struct definition */
1542 srna = RNA_def_struct(brna, "Pose", nullptr);
1543 RNA_def_struct_sdna(srna, "bPose");
1545 srna, "Pose", "A collection of pose channels, including settings for animating bones");
1546
1547 /* pose channels */
1548 prop = RNA_def_property(srna, "bones", PROP_COLLECTION, PROP_NONE);
1549 RNA_def_property_collection_sdna(prop, nullptr, "chanbase", nullptr);
1550 RNA_def_property_struct_type(prop, "PoseBone");
1552 RNA_def_property_ui_text(prop, "Pose Bones", "Individual pose bones for the armature");
1553 /* can be removed, only for fast lookup */
1555 nullptr,
1556 nullptr,
1557 nullptr,
1558 nullptr,
1559 nullptr,
1560 nullptr,
1561 "rna_PoseBones_lookup_string",
1562 nullptr);
1563
1564 /* ik solvers */
1565 prop = RNA_def_property(srna, "ik_solver", PROP_ENUM, PROP_NONE);
1566 RNA_def_property_enum_sdna(prop, nullptr, "iksolver");
1567 RNA_def_property_enum_funcs(prop, nullptr, "rna_Pose_ik_solver_set", nullptr);
1569 RNA_def_property_ui_text(prop, "IK Solver", "Selection of IK solver for IK chain");
1570 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_ik_solver_update");
1571
1572 prop = RNA_def_property(srna, "ik_param", PROP_POINTER, PROP_NONE);
1573 RNA_def_property_struct_type(prop, "IKParam");
1575 prop, "rna_Pose_ikparam_get", nullptr, "rna_Pose_ikparam_typef", nullptr);
1577 RNA_def_property_ui_text(prop, "IK Param", "Parameters for IK solver");
1578
1580
1581 /* pose edit options */
1582 prop = RNA_def_property(srna, "use_mirror_x", PROP_BOOLEAN, PROP_NONE);
1583 RNA_def_property_boolean_sdna(prop, nullptr, "flag", POSE_MIRROR_EDIT);
1585 prop, "X-Axis Mirror", "Apply changes to matching bone on opposite side of X-Axis");
1586 RNA_def_struct_path_func(srna, "rna_Pose_path");
1587 RNA_def_property_update(prop, 0, "rna_Pose_update");
1589
1590 prop = RNA_def_property(srna, "use_mirror_relative", PROP_BOOLEAN, PROP_NONE);
1593 prop,
1594 "Relative Mirror",
1595 "Apply relative transformations in X-mirror mode (not supported with Auto IK)");
1596 RNA_def_struct_path_func(srna, "rna_Pose_path");
1597 RNA_def_property_update(prop, 0, "rna_Pose_update");
1599
1600 prop = RNA_def_property(srna, "use_auto_ik", PROP_BOOLEAN, PROP_NONE);
1601 RNA_def_property_boolean_sdna(prop, nullptr, "flag", POSE_AUTO_IK);
1603 prop, "Auto IK", "Add temporary IK constraints while grabbing bones in Pose Mode");
1604 RNA_def_struct_path_func(srna, "rna_Pose_path");
1605 RNA_def_property_update(prop, 0, "rna_Pose_update");
1607
1609
1610 /* animviz */
1612
1613 RNA_api_pose(srna);
1614}
1615
1617{
1618 rna_def_pose(brna);
1621 rna_def_pose_itasc(brna);
1622}
1623
1624} // namespace blender
1625
1626#endif
Helper functions for animation to interact with the RNA system.
Blender kernel action and pose functionality.
#define G_MAIN
#define M_PI
#define STRNCPY_UTF8(dst, src)
#define BLI_STR_UTF8_MULTIPLICATION_SIGN
#define ID_IS_OVERRIDE_LIBRARY(_id)
Definition DNA_ID.h:736
Object is a sort of wrapper for general info.
Defines an abstraction around various structs to modify their transform properties via a unified API ...
Read Blender memory allocation and freeing.
#define RNA_TRANSLATION_PREC_DEFAULT
Definition RNA_types.hh:272
#define C
Definition RandGen.cpp:29
#define NC_GEOM
Definition WM_types.hh:406
#define ND_DATA
Definition WM_types.hh:552
#define NC_ANIMATION
Definition WM_types.hh:401
#define NA_ADDED
Definition WM_types.hh:636
#define ND_POSE
Definition WM_types.hh:482
#define ND_CONSTRAINT
Definition WM_types.hh:505
#define NA_REMOVED
Definition WM_types.hh:637
#define NA_RENAME
Definition WM_types.hh:638
#define ND_BONE_SELECT
Definition WM_types.hh:491
#define NC_OBJECT
Definition WM_types.hh:392
#define ND_ANIMCHAN
Definition WM_types.hh:539
#define BLI_assert_unreachable()
#define ELEM(...)
#define BLI_assert_msg(a, msg)
#define offsetof(t, d)
#define FLT_MAX
#define INT_MAX
#define main()
std::string get_pose_bone_rna_path(const bPoseChannel &pose_bone)
Definition anim_rna.cc:85
void object_test_constraints(Main *bmain, Object *ob)
void constraint_dependency_tag_update(Main *bmain, Object *ob, bConstraint *con)
void constraint_update(Main *bmain, Object *ob)
void constraint_tag_update(Main *bmain, Object *ob, bConstraint *con)
BMesh Iterators.
void WM_main_add_notifier(uint type, void *reference)
void RNA_def_property_srna(PropertyRNA *prop, const char *type)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
void RNA_def_property_editable_func(PropertyRNA *prop, const char *editable)
static void rna_def_pose_itasc(BlenderRNA *brna)
Definition rna_pose.cc:1373
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
char * STRNCPY(char(&dst)[N], const char *src)
void RNA_def_struct_ui_icon(StructRNA *srna, int icon)
void BKE_pose_tag_recalc(Main *bmain, bPose *pose) ATTR_NONNULL(1
struct bConstraint * BKE_constraint_add_for_pose(struct Object *ob, struct bPoseChannel *pchan, const char *name, eBConstraint_Types type)
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
void RNA_def_property_boolean_bitset_array_sdna(PropertyRNA *prop, const char *structname, const char *propname, const int64_t booleanbit, const int length)
void RNA_def_property_boolean_negative_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t booleanbit)
void RNA_def_property_override_funcs(PropertyRNA *prop, const char *diff, const char *store, const char *apply)
MINLINE void copy_v3_v3(float r[3], const float a[3])
const EnumPropertyItem rna_enum_constraint_type_items[]
void RNA_property_update_main(Main *bmain, Scene *scene, PointerRNA *ptr, PropertyRNA *prop)
void RNA_def_property_float_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
void RNA_def_property_pointer_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const char *set, const char *type_fn, const char *poll)
void id_us_plus(ID *id)
Definition lib_id.cc:433
void RNA_def_property_collection_sdna(PropertyRNA *prop, const char *structname, const char *propname, const char *lengthpropname)
void RNA_def_struct_refine_func(StructRNA *srna, const char *refine)
void convert_to_rotation_mode(bContext &C, ed::AnimTransformable &transformable, const eRotationModes to_mode, const bool bake)
void RNA_def_property_boolean_funcs(PropertyRNA *prop, const char *get, const char *set)
void RNA_def_property_multi_array(PropertyRNA *prop, int dimension, const int length[])
void RNA_def_struct_system_idprops_func(StructRNA *srna, const char *system_idproperties)
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
const EnumPropertyItem rna_enum_object_rotation_mode_items[]
@ FUNC_USE_REPORTS
@ FUNC_USE_SELF_ID
Definition RNA_types.hh:980
@ FUNC_USE_MAIN
@ FUNC_USE_CONTEXT
void RNA_define_lib_overridable(const bool make_overridable)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
static void rna_def_pose_channel(BlenderRNA *brna)
Definition rna_pose.cc:855
PropertyRNA * RNA_def_pointer(StructOrFunctionRNA *cont_, const char *identifier, const char *type, const char *ui_name, const char *ui_description)
void rna_pointer_create_with_ancestors(const PointerRNA &parent, StructRNA *type, void *data, PointerRNA &r_ptr)
void RNA_def_property_struct_type(PropertyRNA *prop, const char *type)
void BKE_pchan_to_mat4(bke::PChanBoneConst pchanbone, float r_chanmat[4][4])
static const EnumPropertyItem prop_iksolver_items[]
Definition rna_pose.cc:764
const EnumPropertyItem rna_enum_color_sets_items[]
Definition rna_pose.cc:34
void BIK_clear_data(struct bPose *pose)
void RNA_api_pose_channel(StructRNA *srna)
@ LIBOVERRIDE_OP_INSERT_AFTER
Definition DNA_ID.h:200
struct bConstraint * BKE_constraint_copy_for_pose(struct Object *ob, struct bPoseChannel *pchan, struct bConstraint *src)
void RNA_def_property_enum_bitflag_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void rna_def_animviz_common(StructRNA *srna)
const float rna_default_axis_angle[4]
void RNA_def_property_float_array_default(PropertyRNA *prop, const float *array)
void RNA_def_property_ui_range(PropertyRNA *prop, double min, double max, double step, int precision)
void RNA_def_property_float_sdna(PropertyRNA *prop, const char *structname, const char *propname)
@ PROPOVERRIDE_LIBRARY_INSERTION
Definition RNA_types.hh:614
@ PROPOVERRIDE_OVERRIDABLE_LIBRARY
Definition RNA_types.hh:588
@ PROPOVERRIDE_NO_COMPARISON
Definition RNA_types.hh:596
void RNA_def_property_float_default(PropertyRNA *prop, float value)
void ED_armature_bone_rename(Main *bmain, bArmature *arm, const char *oldnamep, const char *newnamep)
static void rna_def_pose_ikparam(BlenderRNA *brna)
Definition rna_pose.cc:1519
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier_c_str, int type, int subtype)
void BKE_constraint_unique_name(struct bConstraint *con, ListBaseT< bConstraint > *list)
int BLI_findindex(const ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:593
void RNA_def_struct_sdna(StructRNA *srna, const char *structname)
bool rna_ActionGroup_is_custom_colorset_get(PointerRNA *ptr)
void RNA_def_parameter_clear_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item)
@ PROP_BOOLEAN
Definition RNA_types.hh:210
@ PROP_POINTER
Definition RNA_types.hh:215
@ PROP_STRING
Definition RNA_types.hh:213
@ PROP_COLLECTION
Definition RNA_types.hh:216
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
void RNA_def_property_collection_funcs(PropertyRNA *prop, const char *begin, const char *next, const char *end, const char *get, const char *length, const char *lookupint, const char *lookupstring, const char *assignint)
void DEG_id_tag_update(ID *id, unsigned int flags)
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:162
static const EnumPropertyItem prop_solver_items[]
Definition rna_pose.cc:770
void BLI_insertlinkafter(ListBase *listbase, void *vprevlink, void *vnewlink) ATTR_NONNULL(1)
Definition listbase.cc:339
void RNA_def_property_override_flag(PropertyRNA *prop, PropertyOverrideFlag flag)
void RNA_api_pose(StructRNA *srna)
void RNA_def_property_boolean_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t booleanbit)
void RNA_def_property_range(PropertyRNA *prop, double min, double max)
bool BLI_listbase_move_index(ListBase *listbase, int from, int to) ATTR_NONNULL()
Definition listbase.cc:474
void BKE_pchan_apply_mat4(bPoseChannel *pchan, const float mat[4][4], bool use_compat)
struct bConstraint * BKE_constraint_duplicate_ex(struct bConstraint *src, int flag, bool do_extern)
void RNA_def_struct_path_func(StructRNA *srna, const char *path)
void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret)
bool BKE_constraint_remove_ex(ListBaseT< bConstraint > *list, struct Object *ob, struct bConstraint *con)
struct bConstraint * BKE_constraints_active_get(ListBaseT< bConstraint > *list)
void RNA_def_property_enum_funcs(PropertyRNA *prop, const char *get, const char *set, const char *item)
void BKE_pose_update_constraint_flags(Object &pose_ob)
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier_c_str, const char *call)
@ ITASC_INITIAL_REITERATION
@ ITASC_TRANSLATE_ROOT_BONES
void BKE_armature_mat_pose_to_bone_ex(Depsgraph *depsgraph, Object *ob, const bPoseChannel *pchan, const float inmat[4][4], float outmat[4][4])
void RNA_def_property_enum_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void rna_ActionGroup_colorset_set(PointerRNA *ptr, int value)
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
void BKE_rotMode_change_values(float quat[4], float eul[3], float axis[3], float *angle, eRotationModes oldMode, eRotationModes newMode)
void RNA_def_struct_idprops_func(StructRNA *srna, const char *idproperties)
void RNA_def_function_flag(FunctionRNA *func, FunctionFlag flag)
static void rna_def_pose_channel_constraints(BlenderRNA *brna, PropertyRNA *cprop)
Definition rna_pose.cc:776
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, const int default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
void void * BLI_listbase_string_or_index_find(const ListBase *listbase, const char *string, size_t string_offset, int index) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:768
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
Definition report.cc:191
bool BKE_pose_channel_in_IK_chain(Object *ob, bPoseChannel *pchan)
void rna_def_bone_curved_common(StructRNA *srna, bool is_posebone, bool is_editbone)
void RNA_def_property_editable_array_func(PropertyRNA *prop, const char *editable)
void rna_def_actionbone_group_common(StructRNA *srna, int update_flag, const char *update_cb)
Definition rna_pose.cc:735
void BIK_update_param(struct bPose *pose)
@ POSE_TRANSFORM_AROUND_CUSTOM_TX
@ POSE_TRANSFORM_AT_CUSTOM_TX
StructRNA * RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
@ ID_RECALC_TRANSFORM
Definition DNA_ID.h:1054
@ ID_RECALC_SYNC_TO_EVAL
Definition DNA_ID.h:1118
@ ID_RECALC_GEOMETRY
Definition DNA_ID.h:1074
ID_Type GS(const char *name)
Definition DNA_ID.h:410
@ PROP_EDITABLE
Definition RNA_types.hh:376
@ PROP_PROPORTIONAL
Definition RNA_types.hh:419
@ PROP_THICK_WRAP
Definition RNA_types.hh:493
@ PROP_PTR_NO_OWNERSHIP
Definition RNA_types.hh:465
@ PROP_ID_REFCOUNT
Definition RNA_types.hh:434
@ PROP_NEVER_NULL
Definition RNA_types.hh:447
@ PROP_ANIMATABLE
Definition RNA_types.hh:389
@ PROP_LIB_EXCEPTION
Definition RNA_types.hh:382
void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const char *propname)
static void rna_def_pose(BlenderRNA *brna)
Definition rna_pose.cc:1536
@ PCHAN_DRAW_NO_CUSTOM_BONE_SIZE
void BKE_constraints_active_set(ListBaseT< bConstraint > *list, struct bConstraint *con)
void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *func)
PointerRNA RNA_pointer_create_with_parent(const PointerRNA &parent, StructRNA *type, void *data)
void DEG_relations_tag_update(Main *bmain)
void RNA_def_pose(BlenderRNA *brna)
Definition rna_pose.cc:1616
void RNA_def_property_string_funcs(PropertyRNA *prop, const char *get, const char *length, const char *set)
void rna_def_motionpath_common(StructRNA *srna)
void action_group_colors_sync(bActionGroup *grp)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
@ PROP_FACTOR
Definition RNA_types.hh:308
@ PROP_TRANSLATION
Definition RNA_types.hh:318
@ PROP_MATRIX
Definition RNA_types.hh:322
@ PROP_DISTANCE
Definition RNA_types.hh:313
@ PROP_QUATERNION
Definition RNA_types.hh:324
@ PROP_AXISANGLE
Definition RNA_types.hh:325
MINLINE float len_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
@ PARM_REQUIRED
Definition RNA_types.hh:631
@ PARM_RNAPTR
Definition RNA_types.hh:633
void RNA_def_struct_name_property(StructRNA *srna, PropertyRNA *prop, const bool allow_replace)
MINLINE int clamp_i(int value, int min, int max)
bool BKE_id_is_in_global_main(ID *id)
Definition lib_id.cc:2759
void id_us_min(ID *id)
Definition lib_id.cc:441
void RNA_def_property_array(PropertyRNA *prop, int length)
const int rna_matrix_dimsize_4x4[]
void RNA_def_property_ui_icon(PropertyRNA *prop, int icon, int consecutive)
bPoseChannel * BKE_pose_channel_find_name(const bPose *pose, const char *name)
void BKE_pose_ikparam_init(bPose *pose) ATTR_NONNULL(1)
@ CONSTRAINT_OVERRIDE_LIBRARY_LOCAL
const NodeType * type
Definition graph/node.h:179
ustring name
Definition graph/node.h:178