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 &tarArm->id, data->act, "pose.bones[", pchan->name, curbone->name, 0, 0, false);
108
110 }
111 }
112 }
113
114 if (changed) {
116 }
117}
118
119/* Callback to pass to BKE_animdata_main_cb() for fixing driver ID's to point to the new ID. */
120/* FIXME: For now, we only care about drivers here.
121 * When editing rigs, it's very rare to have animation on the rigs being edited already,
122 * so it should be safe to skip these.
123 */
125 Main *bmain, ID *id, FCurve *fcu, Object *srcArm, Object *tarArm, GHash *names_map)
126{
127 ID *src_id = &srcArm->id;
128 ID *dst_id = &tarArm->id;
129
130 GHashIterator gh_iter;
131 bool changed = false;
132
133 /* Fix paths - If this is the target object, it will have some "dirty" paths */
134 if ((id == src_id) && strstr(fcu->rna_path, "pose.bones[")) {
135 GHASH_ITER (gh_iter, names_map) {
136 const char *old_name = static_cast<const char *>(BLI_ghashIterator_getKey(&gh_iter));
137 const char *new_name = static_cast<const char *>(BLI_ghashIterator_getValue(&gh_iter));
138
139 /* only remap if changed; this still means there will be some
140 * waste if there aren't many drivers/keys */
141 if (!STREQ(old_name, new_name) && strstr(fcu->rna_path, old_name)) {
143 id, fcu->rna_path, "pose.bones", old_name, new_name, 0, 0, false);
144
145 changed = true;
146
147 /* we don't want to apply a second remapping on this driver now,
148 * so stop trying names, but keep fixing drivers
149 */
150 break;
151 }
152 }
153 }
154
155 /* Driver targets */
156 if (fcu->driver) {
157 ChannelDriver *driver = fcu->driver;
158
159 /* Ensure that invalid drivers gets re-evaluated in case they become valid once the join
160 * operation is finished. */
161 fcu->flag &= ~FCURVE_DISABLED;
162 driver->flag &= ~DRIVER_FLAG_INVALID;
163
164 /* Fix driver references to invalid ID's */
165 LISTBASE_FOREACH (DriverVar *, dvar, &driver->variables) {
166 /* only change the used targets, since the others will need fixing manually anyway */
168 /* change the ID's used... */
169 if (dtar->id == src_id) {
170 dtar->id = dst_id;
171
172 changed = true;
173
174 /* also check on the subtarget...
175 * XXX: We duplicate the logic from drivers_path_rename_fix() here, with our own
176 * little twists so that we know that it isn't going to clobber the wrong data
177 */
178 if ((dtar->rna_path && strstr(dtar->rna_path, "pose.bones[")) || (dtar->pchan_name[0])) {
179 GHASH_ITER (gh_iter, names_map) {
180 const char *old_name = static_cast<const char *>(BLI_ghashIterator_getKey(&gh_iter));
181 const char *new_name = static_cast<const char *>(
183
184 /* only remap if changed */
185 if (!STREQ(old_name, new_name)) {
186 if ((dtar->rna_path) && strstr(dtar->rna_path, old_name)) {
187 /* Fix up path */
188 dtar->rna_path = BKE_animsys_fix_rna_path_rename(
189 id, dtar->rna_path, "pose.bones", old_name, new_name, 0, 0, false);
190 break; /* no need to try any more names for bone path */
191 }
192 if (STREQ(dtar->pchan_name, old_name)) {
193 /* Change target bone name */
194 STRNCPY(dtar->pchan_name, new_name);
195 break; /* no need to try any more names for bone subtarget */
196 }
197 }
198 }
199 }
200 }
201 }
203 }
204 }
205
206 if (changed) {
208 }
209}
210
211/* Helper function for armature joining - link fixing */
213 Main *bmain, Object *tarArm, Object *srcArm, bPoseChannel *pchan, EditBone *curbone)
214{
215 Object *ob;
216 bPose *pose;
217
218 /* let's go through all objects in database */
219 for (ob = static_cast<Object *>(bmain->objects.first); ob;
220 ob = static_cast<Object *>(ob->id.next))
221 {
222 /* do some object-type specific things */
223 if (ob->type == OB_ARMATURE) {
224 pose = ob->pose;
225 LISTBASE_FOREACH (bPoseChannel *, pchant, &pose->chanbase) {
227 bmain, ob, tarArm, srcArm, pchan, curbone, &pchant->constraints);
228 }
229 }
230
231 /* fix object-level constraints */
232 if (ob != srcArm) {
234 bmain, ob, tarArm, srcArm, pchan, curbone, &ob->constraints);
235 }
236
237 /* See if an object is parented to this armature */
238 if (ob->parent && (ob->parent == srcArm)) {
239 /* Is object parented to a bone of this src armature? */
240 if (ob->partype == PARBONE) {
241 /* bone name in object */
242 if (STREQ(ob->parsubstr, pchan->name)) {
243 STRNCPY(ob->parsubstr, curbone->name);
244 }
245 }
246
247 /* make tar armature be new parent */
248 ob->parent = tarArm;
249
251 }
252 }
253}
254
256 const bArmature *src_arm,
257 const int src_index,
258 bArmature *dest_arm,
259 blender::Map<std::string, BoneCollection *> &bone_collection_by_name)
260{
261 using namespace blender::animrig;
262 const BoneCollection *bcoll = src_arm->collection_array[src_index];
263
264 /* Check if already remapped. */
265 BoneCollection *mapped = bone_collection_by_name.lookup_default(bcoll->name, nullptr);
266
267 if (mapped) {
268 return mapped;
269 }
270
271 /* Remap the parent collection if necessary. */
272 const int src_parent_index = armature_bonecoll_find_parent_index(src_arm, src_index);
273 int parent_index = -1;
274
275 if (src_parent_index >= 0) {
277 src_arm, src_parent_index, dest_arm, bone_collection_by_name);
278
279 if (mapped_parent) {
280 parent_index = armature_bonecoll_find_index(dest_arm, mapped_parent);
281 }
282 }
283
284 /* Create the new collection instance. */
285 BoneCollection *new_bcoll = ANIM_armature_bonecoll_new(dest_arm, bcoll->name, parent_index);
286
287 /* Copy collection visibility. */
288 new_bcoll->flags = bcoll->flags;
289
290 /* Copy custom properties. */
291 if (bcoll->prop) {
292 new_bcoll->prop = IDP_CopyProperty_ex(bcoll->prop, 0);
293 }
294 if (bcoll->system_properties) {
296 }
297
298 bone_collection_by_name.add(bcoll->name, new_bcoll);
299 return new_bcoll;
300}
301
303{
304 Main *bmain = CTX_data_main(C);
305 Scene *scene = CTX_data_scene(C);
306 Object *ob_active = CTX_data_active_object(C);
307 bArmature *arm = static_cast<bArmature *>((ob_active) ? ob_active->data : nullptr);
308 bPose *pose, *opose;
309 bPoseChannel *pchan, *pchann;
310 EditBone *curbone;
311 float mat[4][4], oimat[4][4];
312 bool ok = false;
313
314 /* Ensure we're not in edit-mode and that the active object is an armature. */
315 if (!ob_active || ob_active->type != OB_ARMATURE) {
316 return OPERATOR_CANCELLED;
317 }
318 if (!arm || arm->edbo) {
319 return OPERATOR_CANCELLED;
320 }
321
322 CTX_DATA_BEGIN (C, Object *, ob_iter, selected_editable_objects) {
323 if (ob_iter == ob_active) {
324 ok = true;
325 break;
326 }
327 }
329
330 /* that way the active object is always selected */
331 if (ok == false) {
332 BKE_report(op->reports, RPT_WARNING, "Active object is not a selected armature");
333 return OPERATOR_CANCELLED;
334 }
335
336 /* Check that there are no shared Armatures, as the code below assumes that
337 * each to-be-joined Armature is unique. */
338 {
339 blender::Set<const bArmature *> seen_armatures;
340 CTX_DATA_BEGIN (C, const Object *, ob_iter, selected_editable_objects) {
341 if (ob_iter->type != OB_ARMATURE) {
342 continue;
343 }
344
345 const bArmature *armature = static_cast<bArmature *>(ob_iter->data);
346 if (seen_armatures.add(armature)) {
347 /* Armature pointer was added to the set, which means it wasn't seen before. */
348 continue;
349 }
350
352 RPT_ERROR,
353 "Cannot join objects that share armature data: %s",
354 armature->id.name + 2);
355 return OPERATOR_CANCELLED;
356 }
358 }
359
360 /* Inverse transform for all selected armatures in this object,
361 * See #object_join_exec for detailed comment on why the safe version is used. */
362 invert_m4_m4_safe_ortho(oimat, ob_active->object_to_world().ptr());
363
364 /* Index bone collections by name. This is also used later to keep track
365 * of collections added from other armatures. */
366 blender::Map<std::string, BoneCollection *> bone_collection_by_name;
367 for (BoneCollection *bcoll : arm->collections_span()) {
368 bone_collection_by_name.add(bcoll->name, bcoll);
369 }
370
371 /* Used to track how bone collections should be remapped after merging
372 * other armatures. */
374
375 /* Get edit-bones of active armature to add edit-bones to */
377
378 /* Get pose of active object and move it out of pose-mode */
379 pose = ob_active->pose;
380 ob_active->mode &= ~OB_MODE_POSE;
381
382 CTX_DATA_BEGIN (C, Object *, ob_iter, selected_editable_objects) {
383 if ((ob_iter->type == OB_ARMATURE) && (ob_iter != ob_active)) {
384 bArmature *curarm = static_cast<bArmature *>(ob_iter->data);
385
386 /* we assume that each armature datablock is only used in a single place */
387 BLI_assert(ob_active->data != ob_iter->data);
388
389 /* init callback data for fixing up AnimData links later */
390 GHash *names_map = BLI_ghash_str_new("join_armature_adt_fix");
391
392 /* Make a list of edit-bones in current armature */
393 ED_armature_to_edit(curarm);
394
395 /* Copy new bone collections, and store their remapping info. */
396 for (int i = 0; i < curarm->collection_array_num; i++) {
398 curarm, i, arm, bone_collection_by_name);
399
400 bone_collection_remap.add(curarm->collection_array[i], mapped);
401 }
402
403 /* Get Pose of current armature */
404 opose = ob_iter->pose;
405 ob_iter->mode &= ~OB_MODE_POSE;
406 // BASACT->flag &= ~OB_MODE_POSE;
407
408 /* Find the difference matrix */
409 mul_m4_m4m4(mat, oimat, ob_iter->object_to_world().ptr());
410
411 /* Copy bones and pose-channels from the object to the edit armature. */
412 for (pchan = static_cast<bPoseChannel *>(opose->chanbase.first); pchan; pchan = pchann) {
413 pchann = pchan->next;
414 curbone = ED_armature_ebone_find_name(curarm->edbo, pchan->name);
415
416 /* Get new name */
417 ED_armature_ebone_unique_name(arm->edbo, curbone->name, nullptr);
418 BLI_ghash_insert(names_map, BLI_strdup(pchan->name), curbone->name);
419
420 /* Transform the bone */
421 {
422 float premat[4][4];
423 float postmat[4][4];
424 float difmat[4][4];
425 float imat[4][4];
426 float temp[3][3];
427
428 /* Get the premat */
429 ED_armature_ebone_to_mat3(curbone, temp);
430
431 unit_m4(premat); /* mul_m4_m3m4 only sets 3x3 part */
432 mul_m4_m3m4(premat, temp, mat);
433
434 mul_m4_v3(mat, curbone->head);
435 mul_m4_v3(mat, curbone->tail);
436
437 /* Get the postmat */
438 ED_armature_ebone_to_mat3(curbone, temp);
439 copy_m4_m3(postmat, temp);
440
441 /* Find the roll */
442 invert_m4_m4(imat, premat);
443 mul_m4_m4m4(difmat, imat, postmat);
444
445 curbone->roll -= atan2f(difmat[2][0], difmat[2][2]);
446 }
447
448 /* Fix Constraints and Other Links to this Bone and Armature */
449 joined_armature_fix_links(bmain, ob_active, ob_iter, pchan, curbone);
450
451 /* Rename pchan */
452 STRNCPY(pchan->name, curbone->name);
453
454 /* Jump Ship! */
455 BLI_remlink(curarm->edbo, curbone);
456 BLI_addtail(arm->edbo, curbone);
457
458 /* Pose channel is moved from one storage to another, its UUID is still unique. */
459 BLI_remlink(&opose->chanbase, pchan);
460 BLI_addtail(&pose->chanbase, pchan);
463
464 /* Remap collections. */
466 bcoll_ref->bcoll = bone_collection_remap.lookup(bcoll_ref->bcoll);
467 }
468 }
469
470 /* Armature ID itself is not freed below, however it has been modified (and is now completely
471 * empty). This needs to be told to the depsgraph, it will also ensure that the global
472 * memfile undo system properly detects the change.
473 *
474 * FIXME: Modifying an existing obdata because we are joining an object using it into another
475 * object is a very questionable behavior, which also does not match with other object types
476 * joining. */
478
479 /* Fix all the drivers (and animation data) */
480 BKE_fcurves_main_cb(bmain, [&](ID *id, FCurve *fcu) {
481 joined_armature_fix_animdata_cb(bmain, id, fcu, ob_iter, ob_active, names_map);
482 });
483 BLI_ghash_free(names_map, MEM_freeN, nullptr);
484
485 /* Only copy over animdata now, after all the remapping has been done,
486 * so that we don't have to worry about ambiguities re which armature
487 * a bone came from!
488 */
489 if (ob_iter->adt) {
490 if (ob_active->adt == nullptr) {
491 /* no animdata, so just use a copy of the whole thing */
492 ob_active->adt = BKE_animdata_copy(bmain, ob_iter->adt, 0);
493 }
494 else {
495 /* merge in data - we'll fix the drivers manually */
497 bmain, &ob_active->id, &ob_iter->id, ADT_MERGECOPY_KEEP_DST, false);
498 }
499 }
500
501 if (curarm->adt) {
502 if (arm->adt == nullptr) {
503 /* no animdata, so just use a copy of the whole thing */
504 arm->adt = BKE_animdata_copy(bmain, curarm->adt, 0);
505 }
506 else {
507 /* merge in data - we'll fix the drivers manually */
508 BKE_animdata_merge_copy(bmain, &arm->id, &curarm->id, ADT_MERGECOPY_KEEP_DST, false);
509 }
510 }
511
512 /* Free the old object data */
513 blender::ed::object::base_free_and_unlink(bmain, scene, ob_iter);
514 }
515 }
517
518 DEG_relations_tag_update(bmain); /* because we removed object(s) */
519
520 ED_armature_from_edit(bmain, arm);
522
523 /* Make sure to recompute bone collection visibility. */
525
529
530 return OPERATOR_FINISHED;
531}
532
534
535/* -------------------------------------------------------------------- */
538
539/* Helper function for armature separating - link fixing */
540static void separated_armature_fix_links(Main *bmain, Object *origArm, Object *newArm)
541{
542 Object *ob;
543 ListBase *opchans, *npchans;
544
545 /* Get reference to list of bones in original and new armatures. */
546 opchans = &origArm->pose->chanbase;
547 npchans = &newArm->pose->chanbase;
548
549 /* let's go through all objects in database */
550 for (ob = static_cast<Object *>(bmain->objects.first); ob;
551 ob = static_cast<Object *>(ob->id.next))
552 {
553 /* do some object-type specific things */
554 if (ob->type == OB_ARMATURE) {
555 LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
556 LISTBASE_FOREACH (bConstraint *, con, &pchan->constraints) {
557 ListBase targets = {nullptr, nullptr};
558
559 /* constraint targets */
560 if (BKE_constraint_targets_get(con, &targets)) {
561 LISTBASE_FOREACH (bConstraintTarget *, ct, &targets) {
562 /* Any targets which point to original armature
563 * are redirected to the new one only if:
564 * - The target isn't origArm/newArm itself.
565 * - The target is one that can be found in newArm/origArm.
566 */
567 if (ct->subtarget[0] != 0) {
568 if (ct->tar == origArm) {
569 if (BLI_findstring(npchans, ct->subtarget, offsetof(bPoseChannel, name))) {
570 ct->tar = newArm;
571 }
572 }
573 else if (ct->tar == newArm) {
574 if (BLI_findstring(opchans, ct->subtarget, offsetof(bPoseChannel, name))) {
575 ct->tar = origArm;
576 }
577 }
578 }
579 }
580
581 BKE_constraint_targets_flush(con, &targets, false);
582 }
583 }
584 }
585 }
586
587 /* fix object-level constraints */
588 if (ob != origArm) {
590 ListBase targets = {nullptr, nullptr};
591
592 /* constraint targets */
593 if (BKE_constraint_targets_get(con, &targets)) {
594 LISTBASE_FOREACH (bConstraintTarget *, ct, &targets) {
595 /* any targets which point to original armature are redirected to the new one only if:
596 * - the target isn't origArm/newArm itself
597 * - the target is one that can be found in newArm/origArm
598 */
599 if (ct->subtarget[0] != '\0') {
600 if (ct->tar == origArm) {
601 if (BLI_findstring(npchans, ct->subtarget, offsetof(bPoseChannel, name))) {
602 ct->tar = newArm;
603 }
604 }
605 else if (ct->tar == newArm) {
606 if (BLI_findstring(opchans, ct->subtarget, offsetof(bPoseChannel, name))) {
607 ct->tar = origArm;
608 }
609 }
610 }
611 }
612
613 BKE_constraint_targets_flush(con, &targets, false);
614 }
615 }
616 }
617
618 /* See if an object is parented to this armature */
619 if (ob->parent && (ob->parent == origArm)) {
620 /* Is object parented to a bone of this src armature? */
621 if ((ob->partype == PARBONE) && (ob->parsubstr[0] != '\0')) {
622 if (BLI_findstring(npchans, ob->parsubstr, offsetof(bPoseChannel, name))) {
623 ob->parent = newArm;
624 }
625 }
626 }
627 }
628}
629
637static void separate_armature_bones(Main *bmain, Object *ob, const bool is_select)
638{
639 bArmature *arm = static_cast<bArmature *>(ob->data);
640 bPoseChannel *pchan, *pchann;
641 EditBone *curbone;
642
643 /* make local set of edit-bones to manipulate here */
645
646 /* go through pose-channels, checking if a bone should be removed */
647 for (pchan = static_cast<bPoseChannel *>(ob->pose->chanbase.first); pchan; pchan = pchann) {
648 pchann = pchan->next;
649 curbone = ED_armature_ebone_find_name(arm->edbo, pchan->name);
650
651 /* check if bone needs to be removed */
652 if (is_select == (blender::animrig::bone_is_visible_editbone(arm, curbone) &&
653 (curbone->flag & BONE_SELECTED)))
654 {
655
656 /* Clear the bone->parent var of any bone that had this as its parent. */
657 LISTBASE_FOREACH (EditBone *, ebo, arm->edbo) {
658 if (ebo->parent == curbone) {
659 ebo->parent = nullptr;
660 /* this is needed to prevent random crashes with in ED_armature_from_edit */
661 ebo->temp.p = nullptr;
662 ebo->flag &= ~BONE_CONNECTED;
663 }
664 }
665
666 /* clear the pchan->parent var of any pchan that had this as its parent */
667 LISTBASE_FOREACH (bPoseChannel *, pchn, &ob->pose->chanbase) {
668 if (pchn->parent == pchan) {
669 pchn->parent = nullptr;
670 }
671 if (pchn->bbone_next == pchan) {
672 pchn->bbone_next = nullptr;
673 }
674 if (pchn->bbone_prev == pchan) {
675 pchn->bbone_prev = nullptr;
676 }
677 }
678
679 /* Free any of the extra-data this pchan might have. */
682
683 /* get rid of unneeded bone */
684 bone_free(arm, curbone);
685 BLI_freelinkN(&ob->pose->chanbase, pchan);
686 }
687 }
688
689 /* Exit edit-mode (recalculates pose-channels too). */
691 ED_armature_from_edit(bmain, static_cast<bArmature *>(ob->data));
692 ED_armature_edit_free(static_cast<bArmature *>(ob->data));
693}
694
695/* separate selected bones into their armature */
697{
698 Main *bmain = CTX_data_main(C);
699 Scene *scene = CTX_data_scene(C);
700 ViewLayer *view_layer = CTX_data_view_layer(C);
701 bool ok = false;
702
703 /* set wait cursor in case this takes a while */
704 WM_cursor_wait(true);
705
707 scene, view_layer, CTX_wm_view3d(C));
708
709 for (Base *base_old : bases) {
710 Object *ob_old = base_old->object;
711
712 {
713 bArmature *arm_old = static_cast<bArmature *>(ob_old->data);
714 bool has_selected_bone = false;
715 bool has_selected_any = false;
716 LISTBASE_FOREACH (EditBone *, ebone, arm_old->edbo) {
717 if (blender::animrig::bone_is_visible_editbone(arm_old, ebone)) {
718 if (ebone->flag & BONE_SELECTED) {
719 has_selected_bone = true;
720 break;
721 }
722 if (ebone->flag & (BONE_TIPSEL | BONE_ROOTSEL)) {
723 has_selected_any = true;
724 }
725 }
726 }
727 if (has_selected_bone == false) {
728 if (has_selected_any) {
729 /* Without this, we may leave head/tail selected
730 * which isn't expected after separating. */
732 }
733 continue;
734 }
735 }
736
737 /* We are going to do this as follows (unlike every other instance of separate):
738 * 1. Exit edit-mode & pose-mode for active armature/base. Take note of what this is.
739 * 2. Duplicate base - BASACT is the new one now
740 * 3. For each of the two armatures,
741 * enter edit-mode -> remove appropriate bones -> exit edit-mode + recalculate.
742 * 4. Fix constraint links
743 * 5. Make original armature active and enter edit-mode
744 */
745
746 /* 1) store starting settings and exit edit-mode */
747 ob_old->mode &= ~OB_MODE_POSE;
748
749 ED_armature_from_edit(bmain, static_cast<bArmature *>(ob_old->data));
750 ED_armature_edit_free(static_cast<bArmature *>(ob_old->data));
751
752 /* 2) duplicate base */
753
754 /* Only duplicate linked armature but take into account
755 * user preferences for duplicating actions. */
756 short dupflag = USER_DUP_ARM | (U.dupflag & USER_DUP_ACT);
758 bmain, scene, view_layer, base_old, eDupli_ID_Flags(dupflag));
759 Object *ob_new = base_new->object;
760
762
763 /* 3) remove bones that shouldn't still be around on both armatures */
764 separate_armature_bones(bmain, ob_old, true);
765 separate_armature_bones(bmain, ob_new, false);
766
767 /* 4) fix links before depsgraph flushes, err... or after? */
768 separated_armature_fix_links(bmain, ob_old, ob_new);
769
770 DEG_id_tag_update(&ob_old->id, ID_RECALC_GEOMETRY); /* this is the original one */
771 DEG_id_tag_update(&ob_new->id, ID_RECALC_GEOMETRY); /* this is the separated one */
772
773 /* 5) restore original conditions */
774 ED_armature_to_edit(static_cast<bArmature *>(ob_old->data));
775
776 /* parents tips remain selected when connected children are removed. */
778
779 ok = true;
780
781 /* NOTE: notifier might evolve. */
783 }
784
785 /* Recalculate/redraw + cleanup */
786 WM_cursor_wait(false);
787
788 if (ok) {
789 BKE_report(op->reports, RPT_INFO, "Separated bones");
791 }
792
793 return OPERATOR_FINISHED;
794}
795
797{
798 /* identifiers */
799 ot->name = "Separate Bones";
800 ot->idname = "ARMATURE_OT_separate";
801 ot->description = "Isolate selected bones into a separate armature";
802
803 /* callbacks */
806
807 /* flags */
809}
810
812
813/* -------------------------------------------------------------------- */
816
817/* armature parenting options */
818#define ARM_PAR_CONNECT 1
819#define ARM_PAR_OFFSET 2
820
821/* armature un-parenting options */
822#define ARM_PAR_CLEAR 1
823#define ARM_PAR_CLEAR_DISCONNECT 2
824
825/* check for null, before calling! */
827{
828 bone->flag |= BONE_CONNECTED;
829 copy_v3_v3(bone->head, bone->parent->tail);
830 bone->rad_head = bone->parent->rad_tail;
831}
832
834 EditBone *selbone,
835 EditBone *actbone,
836 short mode)
837{
838 EditBone *ebone;
839 float offset[3];
840
841 if ((selbone->parent) && (selbone->flag & BONE_CONNECTED)) {
842 selbone->parent->flag &= ~BONE_TIPSEL;
843 }
844
845 /* make actbone the parent of selbone */
846 selbone->parent = actbone;
847
848 /* in actbone tree we cannot have a loop */
849 for (ebone = actbone->parent; ebone; ebone = ebone->parent) {
850 if (ebone->parent == selbone) {
851 ebone->parent = nullptr;
852 ebone->flag &= ~BONE_CONNECTED;
853 }
854 }
855
856 if (mode == ARM_PAR_CONNECT) {
857 /* Connected: Child bones will be moved to the parent tip */
858 selbone->flag |= BONE_CONNECTED;
859 sub_v3_v3v3(offset, actbone->tail, selbone->head);
860
861 copy_v3_v3(selbone->head, actbone->tail);
862 selbone->rad_head = actbone->rad_tail;
863
864 add_v3_v3(selbone->tail, offset);
865
866 /* offset for all its children */
867 LISTBASE_FOREACH (EditBone *, ebone, edbo) {
868 EditBone *par;
869
870 for (par = ebone->parent; par; par = par->parent) {
871 if (par == selbone) {
872 add_v3_v3(ebone->head, offset);
873 add_v3_v3(ebone->tail, offset);
874 break;
875 }
876 }
877 }
878 }
879 else {
880 /* Offset: Child bones will retain their distance from the parent tip */
881 selbone->flag &= ~BONE_CONNECTED;
882 }
883}
884
886 {ARM_PAR_CONNECT, "CONNECTED", 0, "Connected", ""},
887 {ARM_PAR_OFFSET, "OFFSET", 0, "Keep Offset", ""},
888 {0, nullptr, 0, nullptr, nullptr},
889};
890
892{
894 bArmature *arm = static_cast<bArmature *>(ob->data);
895 EditBone *actbone = CTX_data_active_bone(C);
896 EditBone *actmirb = nullptr;
897 short val = RNA_enum_get(op->ptr, "type");
898
899 /* there must be an active bone */
900 if (actbone == nullptr) {
901 BKE_report(op->reports, RPT_ERROR, "Operation requires an active bone");
902 return OPERATOR_CANCELLED;
903 }
904 if (arm->flag & ARM_MIRROR_EDIT) {
905 /* For X-Axis Mirror Editing option, we may need a mirror copy of actbone:
906 * - If there's a mirrored copy of selbone, try to find a mirrored copy of actbone
907 * (i.e. selbone="child.L" and actbone="parent.L", find "child.R" and "parent.R").
908 * This is useful for arm-chains, for example parenting lower arm to upper arm.
909 * - If there's no mirrored copy of actbone (i.e. actbone = "parent.C" or "parent")
910 * then just use actbone. Useful when doing upper arm to spine.
911 */
912 actmirb = ED_armature_ebone_get_mirrored(arm->edbo, actbone);
913 if (actmirb == nullptr) {
914 actmirb = actbone;
915 }
916 }
917
918 /* If there is only 1 selected bone, we assume that it is the active bone,
919 * since a user will need to have clicked on a bone (thus selecting it) to make it active. */
920 bool is_active_only_selected = false;
921 if (actbone->flag & BONE_SELECTED) {
922 is_active_only_selected = true;
923 LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
924 if (EBONE_EDITABLE(ebone)) {
925 if (ebone != actbone) {
926 is_active_only_selected = false;
927 break;
928 }
929 }
930 }
931 }
932
933 if (is_active_only_selected) {
934 /* When only the active bone is selected, and it has a parent,
935 * connect it to the parent, as that is the only possible outcome.
936 */
937 if (actbone->parent) {
939
940 if ((arm->flag & ARM_MIRROR_EDIT) && (actmirb->parent)) {
942 }
943 }
944 }
945 else {
946 /* Parent 'selected' bones to the active one:
947 * - The context iterator contains both selected bones and their mirrored copies,
948 * so we assume that unselected bones are mirrored copies of some selected bone.
949 * - Since the active one (and/or its mirror) will also be selected, we also need
950 * to check that we are not trying to operate on them, since such an operation
951 * would cause errors.
952 */
953
954 /* Parent selected bones to the active one. */
955 LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
956 if (EBONE_EDITABLE(ebone)) {
957 if (ebone != actbone) {
958 bone_connect_to_new_parent(arm->edbo, ebone, actbone, val);
959 }
960
961 if (arm->flag & ARM_MIRROR_EDIT) {
962 EditBone *ebone_mirror = ED_armature_ebone_get_mirrored(arm->edbo, ebone);
963 if (ebone_mirror && (ebone_mirror->flag & BONE_SELECTED) == 0) {
964 if (ebone_mirror != actmirb) {
965 bone_connect_to_new_parent(arm->edbo, ebone_mirror, actmirb, val);
966 }
967 }
968 }
969 }
970 }
971 }
972
973 /* NOTE: notifier might evolve. */
976
977 return OPERATOR_FINISHED;
978}
979
981 wmOperator * /*op*/,
982 const wmEvent * /*event*/)
983{
984 /* False when all selected bones are parented to the active bone. */
985 bool enable_offset = false;
986 /* False when all selected bones are connected to the active bone. */
987 bool enable_connect = false;
988 {
990 bArmature *arm = static_cast<bArmature *>(ob->data);
991 EditBone *actbone = arm->act_edbone;
992 LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
993 if (!EBONE_EDITABLE(ebone) || !(ebone->flag & BONE_SELECTED)) {
994 continue;
995 }
996 if (ebone == actbone) {
997 continue;
998 }
999
1000 if (ebone->parent != actbone) {
1001 enable_offset = true;
1002 enable_connect = true;
1003 break;
1004 }
1005 if (!(ebone->flag & BONE_CONNECTED)) {
1006 enable_connect = true;
1007 }
1008 }
1009 }
1010
1012 C, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Make Parent"), ICON_NONE);
1013 uiLayout *layout = UI_popup_menu_layout(pup);
1014
1015 uiLayout *row_offset = &layout->row(false);
1016 uiLayoutSetEnabled(row_offset, enable_offset);
1018 row_offset, "ARMATURE_OT_parent_set", std::nullopt, ICON_NONE, "type", ARM_PAR_OFFSET);
1019
1020 uiLayout *row_connect = &layout->row(false);
1021 uiLayoutSetEnabled(row_connect, enable_connect);
1023 row_connect, "ARMATURE_OT_parent_set", std::nullopt, ICON_NONE, "type", ARM_PAR_CONNECT);
1024
1025 UI_popup_menu_end(C, pup);
1026
1027 return OPERATOR_INTERFACE;
1028}
1029
1031{
1032 /* identifiers */
1033 ot->name = "Make Parent";
1034 ot->idname = "ARMATURE_OT_parent_set";
1035 ot->description = "Set the active bone as the parent of the selected bones";
1036
1037 /* API callbacks. */
1041
1042 /* flags */
1043 ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
1044
1046 ot->srna, "type", prop_editarm_make_parent_types, 0, "Parent Type", "Type of parenting");
1047}
1048
1050 {ARM_PAR_CLEAR, "CLEAR", 0, "Clear Parent", ""},
1051 {ARM_PAR_CLEAR_DISCONNECT, "DISCONNECT", 0, "Disconnect Bone", ""},
1052 {0, nullptr, 0, nullptr, nullptr},
1053};
1054
1055static void editbone_clear_parent(EditBone *ebone, int mode)
1056{
1057 if (ebone->parent) {
1058 /* for nice selection */
1059 ebone->parent->flag &= ~BONE_TIPSEL;
1060 }
1061
1062 if (mode == 1) {
1063 ebone->parent = nullptr;
1064 }
1065 ebone->flag &= ~BONE_CONNECTED;
1066}
1067
1069{
1070 const Scene *scene = CTX_data_scene(C);
1071 ViewLayer *view_layer = CTX_data_view_layer(C);
1072 const int val = RNA_enum_get(op->ptr, "type");
1073
1074 CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones) {
1075 editbone_clear_parent(ebone, val);
1076 }
1078
1080 scene, view_layer, CTX_wm_view3d(C));
1081 for (Object *ob : objects) {
1082 bArmature *arm = static_cast<bArmature *>(ob->data);
1083 bool changed = false;
1084
1085 LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
1086 if (EBONE_EDITABLE(ebone)) {
1087 changed = true;
1088 break;
1089 }
1090 }
1091
1092 if (!changed) {
1093 continue;
1094 }
1095
1097
1098 /* NOTE: notifier might evolve. */
1100 }
1101 return OPERATOR_FINISHED;
1102}
1103
1105 wmOperator * /*op*/,
1106 const wmEvent * /*event*/)
1107{
1108 /* False when no selected bones are connected to the active bone. */
1109 bool enable_disconnect = false;
1110 /* False when no selected bones are parented to the active bone. */
1111 bool enable_clear = false;
1112 {
1114 bArmature *arm = static_cast<bArmature *>(ob->data);
1115 LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
1116 if (!EBONE_EDITABLE(ebone) || !(ebone->flag & BONE_SELECTED)) {
1117 continue;
1118 }
1119 if (ebone->parent == nullptr) {
1120 continue;
1121 }
1122 enable_clear = true;
1123
1124 if (ebone->flag & BONE_CONNECTED) {
1125 enable_disconnect = true;
1126 break;
1127 }
1128 }
1129 }
1130
1132 C, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Clear Parent"), ICON_NONE);
1133 uiLayout *layout = UI_popup_menu_layout(pup);
1134
1135 uiLayout *row_clear = &layout->row(false);
1136 uiLayoutSetEnabled(row_clear, enable_clear);
1138 row_clear, "ARMATURE_OT_parent_clear", std::nullopt, ICON_NONE, "type", ARM_PAR_CLEAR);
1139
1140 uiLayout *row_disconnect = &layout->row(false);
1141 uiLayoutSetEnabled(row_disconnect, enable_disconnect);
1142 uiItemEnumO(row_disconnect,
1143 "ARMATURE_OT_parent_clear",
1144 std::nullopt,
1145 ICON_NONE,
1146 "type",
1148
1149 UI_popup_menu_end(C, pup);
1150
1151 return OPERATOR_INTERFACE;
1152}
1153
1155{
1156 /* identifiers */
1157 ot->name = "Clear Parent";
1158 ot->idname = "ARMATURE_OT_parent_clear";
1159 ot->description =
1160 "Remove the parent-child relationship between selected bones and their parents";
1161
1162 /* API callbacks. */
1166
1167 /* flags */
1168 ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
1169
1170 ot->prop = RNA_def_enum(ot->srna,
1171 "type",
1173 0,
1174 "Clear Type",
1175 "What way to clear parenting");
1176}
1177
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:446
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, const char *prefix, const char *oldName, const char *newName, int oldSubscript, int newSubscript, bool verify_paths)
Definition anim_data.cc:951
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:894
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.
@ PARBONE
@ OB_ARMATURE
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
@ OPTYPE_UNDO
Definition WM_types.hh:182
@ OPTYPE_REGISTER
Definition WM_types.hh:180
#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
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 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:4225