Blender V4.5
armature_relations.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9
10#include "MEM_guardedalloc.h"
11
12#include "DNA_anim_types.h"
13#include "DNA_armature_types.h"
15#include "DNA_object_types.h"
16#include "DNA_scene_types.h"
17
18#include "BLI_ghash.h"
19#include "BLI_listbase.h"
20#include "BLI_map.hh"
21#include "BLI_math_matrix.h"
22#include "BLI_math_vector.h"
23#include "BLI_string.h"
24
25#include "BLT_translation.hh"
26
27#include "BKE_action.hh"
28#include "BKE_anim_data.hh"
29#include "BKE_animsys.h"
30#include "BKE_armature.hh"
31#include "BKE_constraint.h"
32#include "BKE_context.hh"
33#include "BKE_fcurve_driver.h"
34#include "BKE_idprop.hh"
35#include "BKE_layer.hh"
36#include "BKE_main.hh"
37#include "BKE_report.hh"
38
39#include "DEG_depsgraph.hh"
41
42#include "RNA_access.hh"
43#include "RNA_define.hh"
44
45#include "WM_api.hh"
46#include "WM_types.hh"
47
48#include "ED_armature.hh"
49#include "ED_object.hh"
50#include "ED_outliner.hh"
51#include "ED_screen.hh"
52
53#include "UI_interface.hh"
54#include "UI_resources.hh"
55
56#include "ANIM_armature.hh"
58
59#include "armature_intern.hh"
60
61using blender::Vector;
62
63/* -------------------------------------------------------------------- */
68
70 Object *ob,
71 Object *tarArm,
72 Object *srcArm,
73 bPoseChannel *pchan,
74 EditBone *curbone,
75 ListBase *lb)
76{
77 bool changed = false;
78
79 LISTBASE_FOREACH (bConstraint *, con, lb) {
80 ListBase targets = {nullptr, nullptr};
81
82 /* constraint targets */
83 if (BKE_constraint_targets_get(con, &targets)) {
84 LISTBASE_FOREACH (bConstraintTarget *, ct, &targets) {
85 if (ct->tar == srcArm) {
86 if (ct->subtarget[0] == '\0') {
87 ct->tar = tarArm;
88 changed = true;
89 }
90 else if (STREQ(ct->subtarget, pchan->name)) {
91 ct->tar = tarArm;
92 STRNCPY(ct->subtarget, curbone->name);
93 changed = true;
94 }
95 }
96 }
97
98 BKE_constraint_targets_flush(con, &targets, false);
99 }
100
101 /* action constraint? (pose constraints only) */
102 if (con->type == CONSTRAINT_TYPE_ACTION) {
103 bActionConstraint *data = static_cast<bActionConstraint *>(con->data);
104
105 if (data->act) {
107 data->act,
108 data->action_slot_handle,
109 "pose.bones[",
110 pchan->name,
111 curbone->name,
112 0,
113 0,
114 false);
115
117 }
118 }
119 }
120
121 if (changed) {
123 }
124}
125
126/* Callback to pass to BKE_animdata_main_cb() for fixing driver ID's to point to the new ID. */
127/* FIXME: For now, we only care about drivers here.
128 * When editing rigs, it's very rare to have animation on the rigs being edited already,
129 * so it should be safe to skip these.
130 */
132 Main *bmain, ID *id, FCurve *fcu, Object *srcArm, Object *tarArm, GHash *names_map)
133{
134 ID *src_id = &srcArm->id;
135 ID *dst_id = &tarArm->id;
136
137 GHashIterator gh_iter;
138 bool changed = false;
139
140 /* Fix paths - If this is the target object, it will have some "dirty" paths */
141 if ((id == src_id) && strstr(fcu->rna_path, "pose.bones[")) {
142 GHASH_ITER (gh_iter, names_map) {
143 const char *old_name = static_cast<const char *>(BLI_ghashIterator_getKey(&gh_iter));
144 const char *new_name = static_cast<const char *>(BLI_ghashIterator_getValue(&gh_iter));
145
146 /* only remap if changed; this still means there will be some
147 * waste if there aren't many drivers/keys */
148 if (!STREQ(old_name, new_name) && strstr(fcu->rna_path, old_name)) {
150 id, fcu->rna_path, "pose.bones", old_name, new_name, 0, 0, false);
151
152 changed = true;
153
154 /* we don't want to apply a second remapping on this driver now,
155 * so stop trying names, but keep fixing drivers
156 */
157 break;
158 }
159 }
160 }
161
162 /* Driver targets */
163 if (fcu->driver) {
164 ChannelDriver *driver = fcu->driver;
165
166 /* Ensure that invalid drivers gets re-evaluated in case they become valid once the join
167 * operation is finished. */
168 fcu->flag &= ~FCURVE_DISABLED;
169 driver->flag &= ~DRIVER_FLAG_INVALID;
170
171 /* Fix driver references to invalid ID's */
172 LISTBASE_FOREACH (DriverVar *, dvar, &driver->variables) {
173 /* only change the used targets, since the others will need fixing manually anyway */
175 /* change the ID's used... */
176 if (dtar->id == src_id) {
177 dtar->id = dst_id;
178
179 changed = true;
180
181 /* also check on the subtarget...
182 * XXX: We duplicate the logic from drivers_path_rename_fix() here, with our own
183 * little twists so that we know that it isn't going to clobber the wrong data
184 */
185 if ((dtar->rna_path && strstr(dtar->rna_path, "pose.bones[")) || (dtar->pchan_name[0])) {
186 GHASH_ITER (gh_iter, names_map) {
187 const char *old_name = static_cast<const char *>(BLI_ghashIterator_getKey(&gh_iter));
188 const char *new_name = static_cast<const char *>(
190
191 /* only remap if changed */
192 if (!STREQ(old_name, new_name)) {
193 if ((dtar->rna_path) && strstr(dtar->rna_path, old_name)) {
194 /* Fix up path */
195 dtar->rna_path = BKE_animsys_fix_rna_path_rename(
196 id, dtar->rna_path, "pose.bones", old_name, new_name, 0, 0, false);
197 break; /* no need to try any more names for bone path */
198 }
199 if (STREQ(dtar->pchan_name, old_name)) {
200 /* Change target bone name */
201 STRNCPY(dtar->pchan_name, new_name);
202 break; /* no need to try any more names for bone subtarget */
203 }
204 }
205 }
206 }
207 }
208 }
210 }
211 }
212
213 if (changed) {
215 }
216}
217
218/* Helper function for armature joining - link fixing */
220 Main *bmain, Object *tarArm, Object *srcArm, bPoseChannel *pchan, EditBone *curbone)
221{
222 Object *ob;
223 bPose *pose;
224
225 /* Important: Ensure that no hierarchy cycles are created with this operation. See #154651. */
226 blender::Set<Object *> skip_reparenting;
227 Object *ob_iter = tarArm;
228 while (ob_iter) {
229 skip_reparenting.add(ob_iter);
230 ob_iter = ob_iter->parent;
231 }
232
233 /* let's go through all objects in database */
234 for (ob = static_cast<Object *>(bmain->objects.first); ob;
235 ob = static_cast<Object *>(ob->id.next))
236 {
237 /* do some object-type specific things */
238 if (ob->type == OB_ARMATURE) {
239 pose = ob->pose;
240 LISTBASE_FOREACH (bPoseChannel *, pchant, &pose->chanbase) {
242 bmain, ob, tarArm, srcArm, pchan, curbone, &pchant->constraints);
243 }
244 }
245
246 /* fix object-level constraints */
247 if (ob != srcArm) {
249 bmain, ob, tarArm, srcArm, pchan, curbone, &ob->constraints);
250 }
251
252 /* See if an object is parented to this armature */
253 if (ob->parent && (ob->parent == srcArm)) {
254 /* Is object parented to a bone of this src armature? */
255 if (ob->partype == PARBONE) {
256 /* bone name in object */
257 if (STREQ(ob->parsubstr, pchan->name)) {
258 STRNCPY(ob->parsubstr, curbone->name);
259 }
260 }
261
262 /* make tar armature be new parent */
263 if (!skip_reparenting.contains(ob)) {
264 ob->parent = tarArm;
265 }
266
268 }
269 }
270}
271
273 const bArmature *src_arm,
274 const int src_index,
275 bArmature *dest_arm,
276 blender::Map<std::string, BoneCollection *> &bone_collection_by_name)
277{
278 using namespace blender::animrig;
279 const BoneCollection *bcoll = src_arm->collection_array[src_index];
280
281 /* Check if already remapped. */
282 BoneCollection *mapped = bone_collection_by_name.lookup_default(bcoll->name, nullptr);
283
284 if (mapped) {
285 return mapped;
286 }
287
288 /* Remap the parent collection if necessary. */
289 const int src_parent_index = armature_bonecoll_find_parent_index(src_arm, src_index);
290 int parent_index = -1;
291
292 if (src_parent_index >= 0) {
294 src_arm, src_parent_index, dest_arm, bone_collection_by_name);
295
296 if (mapped_parent) {
297 parent_index = armature_bonecoll_find_index(dest_arm, mapped_parent);
298 }
299 }
300
301 /* Create the new collection instance. */
302 BoneCollection *new_bcoll = ANIM_armature_bonecoll_new(dest_arm, bcoll->name, parent_index);
303
304 /* Copy collection visibility. */
305 new_bcoll->flags = bcoll->flags;
306
307 /* Copy custom properties. */
308 if (bcoll->prop) {
309 new_bcoll->prop = IDP_CopyProperty_ex(bcoll->prop, 0);
310 }
311 if (bcoll->system_properties) {
313 }
314
315 bone_collection_by_name.add(bcoll->name, new_bcoll);
316 return new_bcoll;
317}
318
320{
321 Main *bmain = CTX_data_main(C);
322 Scene *scene = CTX_data_scene(C);
323 Object *ob_active = CTX_data_active_object(C);
324 bArmature *arm = static_cast<bArmature *>((ob_active) ? ob_active->data : nullptr);
325 bPose *pose, *opose;
326 bPoseChannel *pchan, *pchann;
327 EditBone *curbone;
328 float mat[4][4], oimat[4][4];
329 bool ok = false;
330
331 /* Ensure we're not in edit-mode and that the active object is an armature. */
332 if (!ob_active || ob_active->type != OB_ARMATURE) {
333 return OPERATOR_CANCELLED;
334 }
335 if (!arm || arm->edbo) {
336 return OPERATOR_CANCELLED;
337 }
338
339 CTX_DATA_BEGIN (C, Object *, ob_iter, selected_editable_objects) {
340 if (ob_iter == ob_active) {
341 ok = true;
342 break;
343 }
344 }
346
347 /* that way the active object is always selected */
348 if (ok == false) {
349 BKE_report(op->reports, RPT_WARNING, "Active object is not a selected armature");
350 return OPERATOR_CANCELLED;
351 }
352
353 /* Check that there are no shared Armatures, as the code below assumes that
354 * each to-be-joined Armature is unique. */
355 {
356 blender::Set<const bArmature *> seen_armatures;
357 CTX_DATA_BEGIN (C, const Object *, ob_iter, selected_editable_objects) {
358 if (ob_iter->type != OB_ARMATURE) {
359 continue;
360 }
361
362 const bArmature *armature = static_cast<bArmature *>(ob_iter->data);
363 if (seen_armatures.add(armature)) {
364 /* Armature pointer was added to the set, which means it wasn't seen before. */
365 continue;
366 }
367
369 RPT_ERROR,
370 "Cannot join objects that share armature data: %s",
371 armature->id.name + 2);
372 return OPERATOR_CANCELLED;
373 }
375 }
376
377 /* Inverse transform for all selected armatures in this object,
378 * See #object_join_exec for detailed comment on why the safe version is used. */
379 invert_m4_m4_safe_ortho(oimat, ob_active->object_to_world().ptr());
380
381 /* Index bone collections by name. This is also used later to keep track
382 * of collections added from other armatures. */
383 blender::Map<std::string, BoneCollection *> bone_collection_by_name;
384 for (BoneCollection *bcoll : arm->collections_span()) {
385 bone_collection_by_name.add(bcoll->name, bcoll);
386 }
387
388 /* Used to track how bone collections should be remapped after merging
389 * other armatures. */
391
392 /* Get edit-bones of active armature to add edit-bones to */
394
395 /* Get pose of active object and move it out of pose-mode */
396 pose = ob_active->pose;
397 ob_active->mode &= ~OB_MODE_POSE;
398
399 CTX_DATA_BEGIN (C, Object *, ob_iter, selected_editable_objects) {
400 if ((ob_iter->type == OB_ARMATURE) && (ob_iter != ob_active)) {
401 bArmature *curarm = static_cast<bArmature *>(ob_iter->data);
402
403 /* we assume that each armature datablock is only used in a single place */
404 BLI_assert(ob_active->data != ob_iter->data);
405
406 /* init callback data for fixing up AnimData links later */
407 GHash *names_map = BLI_ghash_str_new("join_armature_adt_fix");
408
409 /* Make a list of edit-bones in current armature */
410 ED_armature_to_edit(curarm);
411
412 /* Copy new bone collections, and store their remapping info. */
413 for (int i = 0; i < curarm->collection_array_num; i++) {
415 curarm, i, arm, bone_collection_by_name);
416
417 bone_collection_remap.add(curarm->collection_array[i], mapped);
418 }
419
420 /* Get Pose of current armature */
421 opose = ob_iter->pose;
422 ob_iter->mode &= ~OB_MODE_POSE;
423 // BASACT->flag &= ~OB_MODE_POSE;
424
425 /* Find the difference matrix */
426 mul_m4_m4m4(mat, oimat, ob_iter->object_to_world().ptr());
427
428 /* Copy bones and pose-channels from the object to the edit armature. */
429 for (pchan = static_cast<bPoseChannel *>(opose->chanbase.first); pchan; pchan = pchann) {
430 pchann = pchan->next;
431 curbone = ED_armature_ebone_find_name(curarm->edbo, pchan->name);
432
433 /* Get new name */
434 ED_armature_ebone_unique_name(arm->edbo, curbone->name, nullptr);
435 BLI_ghash_insert(names_map, BLI_strdup(pchan->name), curbone->name);
436
437 /* Transform the bone */
438 {
439 float premat[4][4];
440 float postmat[4][4];
441 float difmat[4][4];
442 float imat[4][4];
443 float temp[3][3];
444
445 /* Get the premat */
446 ED_armature_ebone_to_mat3(curbone, temp);
447
448 unit_m4(premat); /* mul_m4_m3m4 only sets 3x3 part */
449 mul_m4_m3m4(premat, temp, mat);
450
451 mul_m4_v3(mat, curbone->head);
452 mul_m4_v3(mat, curbone->tail);
453
454 /* Get the postmat */
455 ED_armature_ebone_to_mat3(curbone, temp);
456 copy_m4_m3(postmat, temp);
457
458 /* Find the roll */
459 invert_m4_m4(imat, premat);
460 mul_m4_m4m4(difmat, imat, postmat);
461
462 curbone->roll -= atan2f(difmat[2][0], difmat[2][2]);
463 }
464
465 /* Fix Constraints and Other Links to this Bone and Armature */
466 joined_armature_fix_links(bmain, ob_active, ob_iter, pchan, curbone);
467
468 /* Rename pchan */
469 STRNCPY(pchan->name, curbone->name);
470
471 /* Jump Ship! */
472 BLI_remlink(curarm->edbo, curbone);
473 BLI_addtail(arm->edbo, curbone);
474
475 /* Pose channel is moved from one storage to another, its UUID is still unique. */
476 BLI_remlink(&opose->chanbase, pchan);
477 BLI_addtail(&pose->chanbase, pchan);
480
481 /* Remap collections. */
483 bcoll_ref->bcoll = bone_collection_remap.lookup(bcoll_ref->bcoll);
484 }
485 }
486
487 /* Armature ID itself is not freed below, however it has been modified (and is now completely
488 * empty). This needs to be told to the depsgraph, it will also ensure that the global
489 * memfile undo system properly detects the change.
490 *
491 * FIXME: Modifying an existing obdata because we are joining an object using it into another
492 * object is a very questionable behavior, which also does not match with other object types
493 * joining. */
495
496 /* Fix all the drivers (and animation data) */
497 BKE_fcurves_main_cb(bmain, [&](ID *id, FCurve *fcu) {
498 joined_armature_fix_animdata_cb(bmain, id, fcu, ob_iter, ob_active, names_map);
499 });
500 BLI_ghash_free(names_map, MEM_freeN, nullptr);
501
502 /* Only copy over animdata now, after all the remapping has been done,
503 * so that we don't have to worry about ambiguities re which armature
504 * a bone came from!
505 */
506 if (ob_iter->adt) {
507 if (ob_active->adt == nullptr) {
508 /* no animdata, so just use a copy of the whole thing */
509 ob_active->adt = BKE_animdata_copy(bmain, ob_iter->adt, 0);
510 }
511 else {
512 /* merge in data - we'll fix the drivers manually */
514 bmain, &ob_active->id, &ob_iter->id, ADT_MERGECOPY_KEEP_DST, false);
515 }
516 }
517
518 if (curarm->adt) {
519 if (arm->adt == nullptr) {
520 /* no animdata, so just use a copy of the whole thing */
521 arm->adt = BKE_animdata_copy(bmain, curarm->adt, 0);
522 }
523 else {
524 /* merge in data - we'll fix the drivers manually */
525 BKE_animdata_merge_copy(bmain, &arm->id, &curarm->id, ADT_MERGECOPY_KEEP_DST, false);
526 }
527 }
528
529 /* Free the old object data */
530 blender::ed::object::base_free_and_unlink(bmain, scene, ob_iter);
531 }
532 }
534
535 DEG_relations_tag_update(bmain); /* because we removed object(s) */
536
537 ED_armature_from_edit(bmain, arm);
539
540 /* Make sure to recompute bone collection visibility. */
542
546
547 return OPERATOR_FINISHED;
548}
549
551
552/* -------------------------------------------------------------------- */
555
556/* Helper function for armature separating - link fixing */
557static void separated_armature_fix_links(Main *bmain, Object *origArm, Object *newArm)
558{
559 Object *ob;
560 ListBase *opchans, *npchans;
561
562 /* Get reference to list of bones in original and new armatures. */
563 opchans = &origArm->pose->chanbase;
564 npchans = &newArm->pose->chanbase;
565
566 /* let's go through all objects in database */
567 for (ob = static_cast<Object *>(bmain->objects.first); ob;
568 ob = static_cast<Object *>(ob->id.next))
569 {
570 /* do some object-type specific things */
571 if (ob->type == OB_ARMATURE) {
572 LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
573 LISTBASE_FOREACH (bConstraint *, con, &pchan->constraints) {
574 ListBase targets = {nullptr, nullptr};
575
576 /* constraint targets */
577 if (BKE_constraint_targets_get(con, &targets)) {
578 LISTBASE_FOREACH (bConstraintTarget *, ct, &targets) {
579 /* Any targets which point to original armature
580 * are redirected to the new one only if:
581 * - The target isn't origArm/newArm itself.
582 * - The target is one that can be found in newArm/origArm.
583 */
584 if (ct->subtarget[0] != 0) {
585 if (ct->tar == origArm) {
586 if (BLI_findstring(npchans, ct->subtarget, offsetof(bPoseChannel, name))) {
587 ct->tar = newArm;
588 }
589 }
590 else if (ct->tar == newArm) {
591 if (BLI_findstring(opchans, ct->subtarget, offsetof(bPoseChannel, name))) {
592 ct->tar = origArm;
593 }
594 }
595 }
596 }
597
598 BKE_constraint_targets_flush(con, &targets, false);
599 }
600 }
601 }
602 }
603
604 /* fix object-level constraints */
605 if (ob != origArm) {
607 ListBase targets = {nullptr, nullptr};
608
609 /* constraint targets */
610 if (BKE_constraint_targets_get(con, &targets)) {
611 LISTBASE_FOREACH (bConstraintTarget *, ct, &targets) {
612 /* any targets which point to original armature are redirected to the new one only if:
613 * - the target isn't origArm/newArm itself
614 * - the target is one that can be found in newArm/origArm
615 */
616 if (ct->subtarget[0] != '\0') {
617 if (ct->tar == origArm) {
618 if (BLI_findstring(npchans, ct->subtarget, offsetof(bPoseChannel, name))) {
619 ct->tar = newArm;
620 }
621 }
622 else if (ct->tar == newArm) {
623 if (BLI_findstring(opchans, ct->subtarget, offsetof(bPoseChannel, name))) {
624 ct->tar = origArm;
625 }
626 }
627 }
628 }
629
630 BKE_constraint_targets_flush(con, &targets, false);
631 }
632 }
633 }
634
635 /* See if an object is parented to this armature */
636 if (ob->parent && (ob->parent == origArm)) {
637 /* Is object parented to a bone of this src armature? */
638 if ((ob->partype == PARBONE) && (ob->parsubstr[0] != '\0')) {
639 if (BLI_findstring(npchans, ob->parsubstr, offsetof(bPoseChannel, name))) {
640 ob->parent = newArm;
641 }
642 }
643 }
644 }
645}
646
654static void separate_armature_bones(Main *bmain, Object *ob, const bool is_select)
655{
656 bArmature *arm = static_cast<bArmature *>(ob->data);
657 bPoseChannel *pchan, *pchann;
658 EditBone *curbone;
659
660 /* make local set of edit-bones to manipulate here */
662
663 /* go through pose-channels, checking if a bone should be removed */
664 for (pchan = static_cast<bPoseChannel *>(ob->pose->chanbase.first); pchan; pchan = pchann) {
665 pchann = pchan->next;
666 curbone = ED_armature_ebone_find_name(arm->edbo, pchan->name);
667
668 /* check if bone needs to be removed */
669 if (is_select == (blender::animrig::bone_is_visible_editbone(arm, curbone) &&
670 (curbone->flag & BONE_SELECTED)))
671 {
672
673 /* Clear the bone->parent var of any bone that had this as its parent. */
674 LISTBASE_FOREACH (EditBone *, ebo, arm->edbo) {
675 if (ebo->parent == curbone) {
676 ebo->parent = nullptr;
677 /* this is needed to prevent random crashes with in ED_armature_from_edit */
678 ebo->temp.p = nullptr;
679 ebo->flag &= ~BONE_CONNECTED;
680 }
681 }
682
683 /* clear the pchan->parent var of any pchan that had this as its parent */
684 LISTBASE_FOREACH (bPoseChannel *, pchn, &ob->pose->chanbase) {
685 if (pchn->parent == pchan) {
686 pchn->parent = nullptr;
687 }
688 if (pchn->bbone_next == pchan) {
689 pchn->bbone_next = nullptr;
690 }
691 if (pchn->bbone_prev == pchan) {
692 pchn->bbone_prev = nullptr;
693 }
694 }
695
696 /* Free any of the extra-data this pchan might have. */
699
700 /* get rid of unneeded bone */
701 bone_free(arm, curbone);
702 BLI_freelinkN(&ob->pose->chanbase, pchan);
703 }
704 }
705
706 /* Exit edit-mode (recalculates pose-channels too). */
708 ED_armature_from_edit(bmain, static_cast<bArmature *>(ob->data));
709 ED_armature_edit_free(static_cast<bArmature *>(ob->data));
710}
711
712/* separate selected bones into their armature */
714{
715 Main *bmain = CTX_data_main(C);
716 Scene *scene = CTX_data_scene(C);
717 ViewLayer *view_layer = CTX_data_view_layer(C);
718 bool ok = false;
719
720 /* set wait cursor in case this takes a while */
721 WM_cursor_wait(true);
722
724 scene, view_layer, CTX_wm_view3d(C));
725
726 for (Base *base_old : bases) {
727 Object *ob_old = base_old->object;
728
729 {
730 bArmature *arm_old = static_cast<bArmature *>(ob_old->data);
731 bool has_selected_bone = false;
732 bool has_selected_any = false;
733 LISTBASE_FOREACH (EditBone *, ebone, arm_old->edbo) {
734 if (blender::animrig::bone_is_visible_editbone(arm_old, ebone)) {
735 if (ebone->flag & BONE_SELECTED) {
736 has_selected_bone = true;
737 break;
738 }
739 if (ebone->flag & (BONE_TIPSEL | BONE_ROOTSEL)) {
740 has_selected_any = true;
741 }
742 }
743 }
744 if (has_selected_bone == false) {
745 if (has_selected_any) {
746 /* Without this, we may leave head/tail selected
747 * which isn't expected after separating. */
749 }
750 continue;
751 }
752 }
753
754 /* We are going to do this as follows (unlike every other instance of separate):
755 * 1. Exit edit-mode & pose-mode for active armature/base. Take note of what this is.
756 * 2. Duplicate base - BASACT is the new one now
757 * 3. For each of the two armatures,
758 * enter edit-mode -> remove appropriate bones -> exit edit-mode + recalculate.
759 * 4. Fix constraint links
760 * 5. Make original armature active and enter edit-mode
761 */
762
763 /* 1) store starting settings and exit edit-mode */
764 ob_old->mode &= ~OB_MODE_POSE;
765
766 ED_armature_from_edit(bmain, static_cast<bArmature *>(ob_old->data));
767 ED_armature_edit_free(static_cast<bArmature *>(ob_old->data));
768
769 /* 2) duplicate base */
770
771 /* Only duplicate linked armature but take into account
772 * user preferences for duplicating actions. */
773 short dupflag = USER_DUP_ARM | (U.dupflag & USER_DUP_ACT);
775 bmain, scene, view_layer, base_old, eDupli_ID_Flags(dupflag));
776 Object *ob_new = base_new->object;
777
779
780 /* 3) remove bones that shouldn't still be around on both armatures */
781 separate_armature_bones(bmain, ob_old, true);
782 separate_armature_bones(bmain, ob_new, false);
783
784 /* 4) fix links before depsgraph flushes, err... or after? */
785 separated_armature_fix_links(bmain, ob_old, ob_new);
786
787 DEG_id_tag_update(&ob_old->id, ID_RECALC_GEOMETRY); /* this is the original one */
788 DEG_id_tag_update(&ob_new->id, ID_RECALC_GEOMETRY); /* this is the separated one */
789
790 /* 5) restore original conditions */
791 ED_armature_to_edit(static_cast<bArmature *>(ob_old->data));
792
793 /* parents tips remain selected when connected children are removed. */
795
796 ok = true;
797
798 /* NOTE: notifier might evolve. */
800 }
801
802 /* Recalculate/redraw + cleanup */
803 WM_cursor_wait(false);
804
805 if (ok) {
806 BKE_report(op->reports, RPT_INFO, "Separated bones");
808 }
809
810 return OPERATOR_FINISHED;
811}
812
814{
815 /* identifiers */
816 ot->name = "Separate Bones";
817 ot->idname = "ARMATURE_OT_separate";
818 ot->description = "Isolate selected bones into a separate armature";
819
820 /* callbacks */
823
824 /* flags */
826}
827
829
830/* -------------------------------------------------------------------- */
833
834/* armature parenting options */
835#define ARM_PAR_CONNECT 1
836#define ARM_PAR_OFFSET 2
837
838/* armature un-parenting options */
839#define ARM_PAR_CLEAR 1
840#define ARM_PAR_CLEAR_DISCONNECT 2
841
842/* check for null, before calling! */
844{
845 bone->flag |= BONE_CONNECTED;
846 copy_v3_v3(bone->head, bone->parent->tail);
847 bone->rad_head = bone->parent->rad_tail;
848}
849
851 EditBone *selbone,
852 EditBone *actbone,
853 short mode)
854{
855 EditBone *ebone;
856 float offset[3];
857
858 if ((selbone->parent) && (selbone->flag & BONE_CONNECTED)) {
859 selbone->parent->flag &= ~BONE_TIPSEL;
860 }
861
862 /* make actbone the parent of selbone */
863 selbone->parent = actbone;
864
865 /* in actbone tree we cannot have a loop */
866 for (ebone = actbone->parent; ebone; ebone = ebone->parent) {
867 if (ebone->parent == selbone) {
868 ebone->parent = nullptr;
869 ebone->flag &= ~BONE_CONNECTED;
870 }
871 }
872
873 if (mode == ARM_PAR_CONNECT) {
874 /* Connected: Child bones will be moved to the parent tip */
875 selbone->flag |= BONE_CONNECTED;
876 sub_v3_v3v3(offset, actbone->tail, selbone->head);
877
878 copy_v3_v3(selbone->head, actbone->tail);
879 selbone->rad_head = actbone->rad_tail;
880
881 add_v3_v3(selbone->tail, offset);
882
883 /* offset for all its children */
884 LISTBASE_FOREACH (EditBone *, ebone, edbo) {
885 EditBone *par;
886
887 for (par = ebone->parent; par; par = par->parent) {
888 if (par == selbone) {
889 add_v3_v3(ebone->head, offset);
890 add_v3_v3(ebone->tail, offset);
891 break;
892 }
893 }
894 }
895 }
896 else {
897 /* Offset: Child bones will retain their distance from the parent tip */
898 selbone->flag &= ~BONE_CONNECTED;
899 }
900}
901
903 {ARM_PAR_CONNECT, "CONNECTED", 0, "Connected", ""},
904 {ARM_PAR_OFFSET, "OFFSET", 0, "Keep Offset", ""},
905 {0, nullptr, 0, nullptr, nullptr},
906};
907
909{
911 bArmature *arm = static_cast<bArmature *>(ob->data);
912 EditBone *actbone = CTX_data_active_bone(C);
913 EditBone *actmirb = nullptr;
914 short val = RNA_enum_get(op->ptr, "type");
915
916 /* there must be an active bone */
917 if (actbone == nullptr) {
918 BKE_report(op->reports, RPT_ERROR, "Operation requires an active bone");
919 return OPERATOR_CANCELLED;
920 }
921 if (arm->flag & ARM_MIRROR_EDIT) {
922 /* For X-Axis Mirror Editing option, we may need a mirror copy of actbone:
923 * - If there's a mirrored copy of selbone, try to find a mirrored copy of actbone
924 * (i.e. selbone="child.L" and actbone="parent.L", find "child.R" and "parent.R").
925 * This is useful for arm-chains, for example parenting lower arm to upper arm.
926 * - If there's no mirrored copy of actbone (i.e. actbone = "parent.C" or "parent")
927 * then just use actbone. Useful when doing upper arm to spine.
928 */
929 actmirb = ED_armature_ebone_get_mirrored(arm->edbo, actbone);
930 if (actmirb == nullptr) {
931 actmirb = actbone;
932 }
933 }
934
935 /* If there is only 1 selected bone, we assume that it is the active bone,
936 * since a user will need to have clicked on a bone (thus selecting it) to make it active. */
937 bool is_active_only_selected = false;
938 if (actbone->flag & BONE_SELECTED) {
939 is_active_only_selected = true;
940 LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
941 if (EBONE_EDITABLE(ebone)) {
942 if (ebone != actbone) {
943 is_active_only_selected = false;
944 break;
945 }
946 }
947 }
948 }
949
950 if (is_active_only_selected) {
951 /* When only the active bone is selected, and it has a parent,
952 * connect it to the parent, as that is the only possible outcome.
953 */
954 if (actbone->parent) {
956
957 if ((arm->flag & ARM_MIRROR_EDIT) && (actmirb->parent)) {
959 }
960 }
961 }
962 else {
963 /* Parent 'selected' bones to the active one:
964 * - The context iterator contains both selected bones and their mirrored copies,
965 * so we assume that unselected bones are mirrored copies of some selected bone.
966 * - Since the active one (and/or its mirror) will also be selected, we also need
967 * to check that we are not trying to operate on them, since such an operation
968 * would cause errors.
969 */
970
971 /* Parent selected bones to the active one. */
972 LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
973 if (EBONE_EDITABLE(ebone)) {
974 if (ebone != actbone) {
975 bone_connect_to_new_parent(arm->edbo, ebone, actbone, val);
976 }
977
978 if (arm->flag & ARM_MIRROR_EDIT) {
979 EditBone *ebone_mirror = ED_armature_ebone_get_mirrored(arm->edbo, ebone);
980 if (ebone_mirror && (ebone_mirror->flag & BONE_SELECTED) == 0) {
981 if (ebone_mirror != actmirb) {
982 bone_connect_to_new_parent(arm->edbo, ebone_mirror, actmirb, val);
983 }
984 }
985 }
986 }
987 }
988 }
989
990 /* NOTE: notifier might evolve. */
993
994 return OPERATOR_FINISHED;
995}
996
998 wmOperator * /*op*/,
999 const wmEvent * /*event*/)
1000{
1001 /* False when all selected bones are parented to the active bone. */
1002 bool enable_offset = false;
1003 /* False when all selected bones are connected to the active bone. */
1004 bool enable_connect = false;
1005 {
1007 bArmature *arm = static_cast<bArmature *>(ob->data);
1008 EditBone *actbone = arm->act_edbone;
1009 LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
1010 if (!EBONE_EDITABLE(ebone) || !(ebone->flag & BONE_SELECTED)) {
1011 continue;
1012 }
1013 if (ebone == actbone) {
1014 continue;
1015 }
1016
1017 if (ebone->parent != actbone) {
1018 enable_offset = true;
1019 enable_connect = true;
1020 break;
1021 }
1022 if (!(ebone->flag & BONE_CONNECTED)) {
1023 enable_connect = true;
1024 }
1025 }
1026 }
1027
1029 C, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Make Parent"), ICON_NONE);
1030 uiLayout *layout = UI_popup_menu_layout(pup);
1031
1032 uiLayout *row_offset = &layout->row(false);
1033 uiLayoutSetEnabled(row_offset, enable_offset);
1035 row_offset, "ARMATURE_OT_parent_set", std::nullopt, ICON_NONE, "type", ARM_PAR_OFFSET);
1036
1037 uiLayout *row_connect = &layout->row(false);
1038 uiLayoutSetEnabled(row_connect, enable_connect);
1040 row_connect, "ARMATURE_OT_parent_set", std::nullopt, ICON_NONE, "type", ARM_PAR_CONNECT);
1041
1042 UI_popup_menu_end(C, pup);
1043
1044 return OPERATOR_INTERFACE;
1045}
1046
1048{
1049 /* identifiers */
1050 ot->name = "Make Parent";
1051 ot->idname = "ARMATURE_OT_parent_set";
1052 ot->description = "Set the active bone as the parent of the selected bones";
1053
1054 /* API callbacks. */
1058
1059 /* flags */
1060 ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
1061
1063 ot->srna, "type", prop_editarm_make_parent_types, 0, "Parent Type", "Type of parenting");
1064}
1065
1067 {ARM_PAR_CLEAR, "CLEAR", 0, "Clear Parent", ""},
1068 {ARM_PAR_CLEAR_DISCONNECT, "DISCONNECT", 0, "Disconnect Bone", ""},
1069 {0, nullptr, 0, nullptr, nullptr},
1070};
1071
1072static void editbone_clear_parent(EditBone *ebone, int mode)
1073{
1074 if (ebone->parent) {
1075 /* for nice selection */
1076 ebone->parent->flag &= ~BONE_TIPSEL;
1077 }
1078
1079 if (mode == 1) {
1080 ebone->parent = nullptr;
1081 }
1082 ebone->flag &= ~BONE_CONNECTED;
1083}
1084
1086{
1087 const Scene *scene = CTX_data_scene(C);
1088 ViewLayer *view_layer = CTX_data_view_layer(C);
1089 const int val = RNA_enum_get(op->ptr, "type");
1090
1091 CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones) {
1092 editbone_clear_parent(ebone, val);
1093 }
1095
1097 scene, view_layer, CTX_wm_view3d(C));
1098 for (Object *ob : objects) {
1099 bArmature *arm = static_cast<bArmature *>(ob->data);
1100 bool changed = false;
1101
1102 LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
1103 if (EBONE_EDITABLE(ebone)) {
1104 changed = true;
1105 break;
1106 }
1107 }
1108
1109 if (!changed) {
1110 continue;
1111 }
1112
1114
1115 /* NOTE: notifier might evolve. */
1117 }
1118 return OPERATOR_FINISHED;
1119}
1120
1122 wmOperator * /*op*/,
1123 const wmEvent * /*event*/)
1124{
1125 /* False when no selected bones are connected to the active bone. */
1126 bool enable_disconnect = false;
1127 /* False when no selected bones are parented to the active bone. */
1128 bool enable_clear = false;
1129 {
1131 bArmature *arm = static_cast<bArmature *>(ob->data);
1132 LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
1133 if (!EBONE_EDITABLE(ebone) || !(ebone->flag & BONE_SELECTED)) {
1134 continue;
1135 }
1136 if (ebone->parent == nullptr) {
1137 continue;
1138 }
1139 enable_clear = true;
1140
1141 if (ebone->flag & BONE_CONNECTED) {
1142 enable_disconnect = true;
1143 break;
1144 }
1145 }
1146 }
1147
1149 C, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Clear Parent"), ICON_NONE);
1150 uiLayout *layout = UI_popup_menu_layout(pup);
1151
1152 uiLayout *row_clear = &layout->row(false);
1153 uiLayoutSetEnabled(row_clear, enable_clear);
1155 row_clear, "ARMATURE_OT_parent_clear", std::nullopt, ICON_NONE, "type", ARM_PAR_CLEAR);
1156
1157 uiLayout *row_disconnect = &layout->row(false);
1158 uiLayoutSetEnabled(row_disconnect, enable_disconnect);
1159 uiItemEnumO(row_disconnect,
1160 "ARMATURE_OT_parent_clear",
1161 std::nullopt,
1162 ICON_NONE,
1163 "type",
1165
1166 UI_popup_menu_end(C, pup);
1167
1168 return OPERATOR_INTERFACE;
1169}
1170
1172{
1173 /* identifiers */
1174 ot->name = "Clear Parent";
1175 ot->idname = "ARMATURE_OT_parent_clear";
1176 ot->description =
1177 "Remove the parent-child relationship between selected bones and their parents";
1178
1179 /* API callbacks. */
1183
1184 /* flags */
1185 ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
1186
1187 ot->prop = RNA_def_enum(ot->srna,
1188 "type",
1190 0,
1191 "Clear Type",
1192 "What way to clear parenting");
1193}
1194
Functions to deal with Armatures.
C++ functions to deal with Armature collections (i.e. the successor of bone layers).
void ANIM_armature_runtime_refresh(bArmature *armature)
BoneCollection * ANIM_armature_bonecoll_new(bArmature *armature, const char *name, int parent_index=-1)
Blender kernel action and pose functionality.
void BKE_pose_channels_hash_free(bPose *pose) ATTR_NONNULL(1)
void BKE_pose_channel_free(bPoseChannel *pchan) ATTR_NONNULL(1)
void BKE_animdata_merge_copy(Main *bmain, ID *dst_id, ID *src_id, eAnimData_MergeCopy_Modes action_mode, bool fix_drivers)
Definition anim_data.cc:450
AnimData * BKE_animdata_copy(Main *bmain, AnimData *adt, int flag)
Definition anim_data.cc:363
@ ADT_MERGECOPY_KEEP_DST
void BKE_fcurves_main_cb(struct Main *bmain, blender::FunctionRef< void(ID *, FCurve *)> func)
void BKE_action_fix_paths_rename(struct ID *owner_id, struct bAction *act, int32_t slot_handle, const char *prefix, const char *oldName, const char *newName, int oldSubscript, int newSubscript, bool verify_paths)
char * BKE_animsys_fix_rna_path_rename(struct ID *owner_id, char *old_path, const char *prefix, const char *oldName, const char *newName, int oldSubscript, int newSubscript, bool verify_paths)
Definition anim_data.cc:898
void BKE_constraint_targets_flush(struct bConstraint *con, struct ListBase *targets, bool no_copy)
int BKE_constraint_targets_get(struct bConstraint *con, struct ListBase *r_targets)
#define CTX_DATA_BEGIN(C, Type, instance, member)
Object * CTX_data_active_object(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
Object * CTX_data_edit_object(const bContext *C)
Main * CTX_data_main(const bContext *C)
EditBone * CTX_data_active_bone(const bContext *C)
#define CTX_DATA_END
View3D * CTX_wm_view3d(const bContext *C)
ViewLayer * CTX_data_view_layer(const bContext *C)
#define DRIVER_TARGETS_USED_LOOPER_BEGIN(dvar)
#define DRIVER_TARGETS_LOOPER_END
IDProperty * IDP_CopyProperty_ex(const IDProperty *prop, int flag) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition idprop.cc:855
blender::Vector< Base * > BKE_view_layer_array_from_bases_in_edit_mode_unique_data(const Scene *scene, ViewLayer *view_layer, const View3D *v3d)
blender::Vector< Object * > BKE_view_layer_array_from_objects_in_edit_mode_unique_data(const Scene *scene, ViewLayer *view_layer, const View3D *v3d)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:126
#define BLI_assert(a)
Definition BLI_assert.h:46
BLI_INLINE void * BLI_ghashIterator_getKey(GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT
Definition BLI_ghash.h:295
BLI_INLINE void * BLI_ghashIterator_getValue(GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT
Definition BLI_ghash.h:299
#define GHASH_ITER(gh_iter_, ghash_)
Definition BLI_ghash.h:318
GHash * BLI_ghash_str_new(const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
void BLI_ghash_insert(GHash *gh, void *key, void *val)
Definition BLI_ghash.cc:707
void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
Definition BLI_ghash.cc:860
#define LISTBASE_FOREACH(type, var, list)
void * BLI_findstring(const ListBase *listbase, const char *id, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:608
void BLI_freelinkN(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:270
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:111
void BLI_remlink(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:131
void mul_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
void copy_m4_m3(float m1[4][4], const float m2[3][3])
void mul_m4_v3(const float M[4][4], float r[3])
bool invert_m4_m4(float inverse[4][4], const float mat[4][4])
void invert_m4_m4_safe_ortho(float inverse[4][4], const float mat[4][4])
void mul_m4_m3m4(float R[4][4], const float A[3][3], const float B[4][4])
void unit_m4(float m[4][4])
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void add_v3_v3(float r[3], const float a[3])
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC
Definition string.cc:41
char * STRNCPY(char(&dst)[N], const char *src)
Definition BLI_string.h:688
#define STREQ(a, b)
#define CTX_IFACE_(context, msgid)
#define BLT_I18NCONTEXT_OPERATOR_DEFAULT
void DEG_id_tag_update(ID *id, unsigned int flags)
void DEG_relations_tag_update(Main *bmain)
@ ID_RECALC_SELECT
Definition DNA_ID.h:1009
@ ID_RECALC_SYNC_TO_EVAL
Definition DNA_ID.h:1026
@ ID_RECALC_GEOMETRY
Definition DNA_ID.h:982
@ DRIVER_FLAG_INVALID
@ FCURVE_DISABLED
@ BONE_ROOTSEL
@ BONE_SELECTED
@ BONE_TIPSEL
@ BONE_CONNECTED
@ ARM_MIRROR_EDIT
@ CONSTRAINT_TYPE_ACTION
@ OB_MODE_POSE
Object is a sort of wrapper for general info.
@ OB_ARMATURE
@ PARBONE
eDupli_ID_Flags
@ USER_DUP_ARM
@ USER_DUP_ACT
@ OPERATOR_CANCELLED
@ OPERATOR_INTERFACE
@ OPERATOR_FINISHED
#define EBONE_EDITABLE(ebone)
void ED_outliner_select_sync_from_object_tag(bContext *C)
bool ED_operator_editarmature(bContext *C)
Read Guarded memory(de)allocation.
#define C
Definition RandGen.cpp:29
void UI_popup_menu_end(bContext *C, uiPopupMenu *pup)
uiPopupMenu * UI_popup_menu_begin(bContext *C, const char *title, int icon) ATTR_NONNULL()
uiLayout * UI_popup_menu_layout(uiPopupMenu *pup)
void uiLayoutSetEnabled(uiLayout *layout, bool enabled)
void uiItemEnumO(uiLayout *layout, blender::StringRefNull opname, std::optional< blender::StringRef > name, int icon, blender::StringRefNull propname, int value)
#define ND_OB_ACTIVE
Definition WM_types.hh:437
#define NC_SCENE
Definition WM_types.hh:375
#define ND_LAYER_CONTENT
Definition WM_types.hh:450
#define ND_POSE
Definition WM_types.hh:455
#define ND_BONE_SELECT
Definition WM_types.hh:457
#define NC_OBJECT
Definition WM_types.hh:376
@ OPTYPE_UNDO
Definition WM_types.hh:182
@ OPTYPE_REGISTER
Definition WM_types.hh:180
void bone_free(bArmature *arm, EditBone *bone)
void ED_armature_ebone_unique_name(ListBase *ebones, char *name, EditBone *bone)
static void separate_armature_bones(Main *bmain, Object *ob, const bool is_select)
static wmOperatorStatus armature_parent_clear_invoke(bContext *C, wmOperator *, const wmEvent *)
static void joined_armature_fix_links(Main *bmain, Object *tarArm, Object *srcArm, bPoseChannel *pchan, EditBone *curbone)
static const EnumPropertyItem prop_editarm_clear_parent_types[]
static wmOperatorStatus armature_parent_set_invoke(bContext *C, wmOperator *, const wmEvent *)
static wmOperatorStatus armature_parent_set_exec(bContext *C, wmOperator *op)
void ARMATURE_OT_parent_clear(wmOperatorType *ot)
static void joined_armature_fix_animdata_cb(Main *bmain, ID *id, FCurve *fcu, Object *srcArm, Object *tarArm, GHash *names_map)
static BoneCollection * join_armature_remap_collection(const bArmature *src_arm, const int src_index, bArmature *dest_arm, blender::Map< std::string, BoneCollection * > &bone_collection_by_name)
#define ARM_PAR_CLEAR_DISCONNECT
static void joined_armature_fix_links_constraints(Main *bmain, Object *ob, Object *tarArm, Object *srcArm, bPoseChannel *pchan, EditBone *curbone, ListBase *lb)
void ARMATURE_OT_parent_set(wmOperatorType *ot)
static void separated_armature_fix_links(Main *bmain, Object *origArm, Object *newArm)
static void bone_connect_to_new_parent(ListBase *edbo, EditBone *selbone, EditBone *actbone, short mode)
wmOperatorStatus ED_armature_join_objects_exec(bContext *C, wmOperator *op)
#define ARM_PAR_OFFSET
static wmOperatorStatus separate_armature_exec(bContext *C, wmOperator *op)
void ARMATURE_OT_separate(wmOperatorType *ot)
static void editbone_clear_parent(EditBone *ebone, int mode)
#define ARM_PAR_CONNECT
static wmOperatorStatus armature_parent_clear_exec(bContext *C, wmOperator *op)
#define ARM_PAR_CLEAR
static const EnumPropertyItem prop_editarm_make_parent_types[]
static void bone_connect_to_existing_parent(EditBone *bone)
bool ED_armature_edit_deselect_all(Object *obedit)
EditBone * ED_armature_ebone_find_name(const ListBase *edbo, const char *name)
void ED_armature_edit_sync_selection(ListBase *edbo)
void ED_armature_edit_free(bArmature *arm)
void ED_armature_ebone_to_mat3(EditBone *ebone, float r_mat[3][3])
void ED_armature_from_edit(Main *bmain, bArmature *arm)
void ED_armature_to_edit(bArmature *arm)
EditBone * ED_armature_ebone_get_mirrored(const ListBase *edbo, EditBone *ebo)
#define U
BMesh const char void * data
bool add(const Key &key, const Value &value)
Definition BLI_map.hh:295
const Value & lookup(const Key &key) const
Definition BLI_map.hh:545
Value lookup_default(const Key &key, const Value &default_value) const
Definition BLI_map.hh:570
bool contains(const Key &key) const
Definition BLI_set.hh:310
bool add(const Key &key)
Definition BLI_set.hh:248
#define atan2f(x, y)
#define offsetof(t, d)
DEG_id_tag_update_ex(cb_data->bmain, cb_data->owner_id, ID_RECALC_TAG_FOR_UNDO|ID_RECALC_SYNC_TO_EVAL)
void MEM_freeN(void *vmemh)
Definition mallocn.cc:113
bool bone_is_visible_editbone(const bArmature *armature, const EditBone *ebone)
int armature_bonecoll_find_index(const bArmature *armature, const ::BoneCollection *bcoll)
int armature_bonecoll_find_parent_index(const bArmature *armature, int bcoll_index)
Base * add_duplicate(Main *bmain, Scene *scene, ViewLayer *view_layer, Base *base, eDupli_ID_Flags dupflag)
void base_free_and_unlink(Main *bmain, Scene *scene, Object *ob)
int RNA_enum_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
struct Object * object
struct IDProperty * system_properties
struct IDProperty * prop
char name[64]
float tail[3]
EditBone * parent
ListBase bone_collections
float rad_tail
float rad_head
float head[3]
char * rna_path
ChannelDriver * driver
Definition DNA_ID.h:404
void * next
Definition DNA_ID.h:407
char name[66]
Definition DNA_ID.h:415
void * first
ListBase objects
Definition BKE_main.hh:247
ListBase constraints
struct bPose * pose
struct AnimData * adt
struct Object * parent
char parsubstr[64]
struct AnimData * adt
struct BoneCollection ** collection_array
struct EditBone * act_edbone
ListBase * edbo
struct bPoseChannel * next
ListBase chanbase
uiLayout & row(bool align)
struct ReportList * reports
struct PointerRNA * ptr
i
Definition text_draw.cc:230
void WM_cursor_wait(bool val)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
wmOperatorType * ot
Definition wm_files.cc:4226