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