Blender  V3.3
pose_edit.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2001-2002 NaN Holding BV. All rights reserved. */
3 
9 #include "MEM_guardedalloc.h"
10 
11 #include "BLI_blenlib.h"
12 #include "BLI_math.h"
13 
14 #include "DNA_anim_types.h"
15 #include "DNA_armature_types.h"
16 #include "DNA_object_types.h"
17 #include "DNA_scene_types.h"
18 
19 #include "BKE_action.h"
20 #include "BKE_anim_visualization.h"
21 #include "BKE_armature.h"
22 #include "BKE_context.h"
23 #include "BKE_deform.h"
24 #include "BKE_global.h"
25 #include "BKE_layer.h"
26 #include "BKE_lib_id.h"
27 #include "BKE_main.h"
28 #include "BKE_object.h"
29 #include "BKE_report.h"
30 #include "BKE_scene.h"
31 
32 #include "DEG_depsgraph.h"
33 #include "DEG_depsgraph_query.h"
34 
35 #include "RNA_access.h"
36 #include "RNA_define.h"
37 #include "RNA_enum_types.h"
38 #include "RNA_prototypes.h"
39 
40 #include "WM_api.h"
41 #include "WM_types.h"
42 
43 #include "ED_anim_api.h"
44 #include "ED_armature.h"
45 #include "ED_keyframing.h"
46 #include "ED_object.h"
47 #include "ED_screen.h"
48 #include "ED_view3d.h"
49 
50 #include "UI_interface.h"
51 
52 #include "armature_intern.h"
53 
54 #undef DEBUG_TIME
55 
56 #include "PIL_time.h"
57 #ifdef DEBUG_TIME
58 # include "PIL_time_utildefines.h"
59 #endif
60 
62 {
63  /* NOTE: matches logic with #ED_operator_posemode_context(). */
64 
66  Object *ob;
67 
68  /* Since this call may also be used from the buttons window,
69  * we need to check for where to get the object. */
70  if (area && area->spacetype == SPACE_PROPERTIES) {
71  ob = ED_object_context(C);
72  }
73  else {
75  }
76 
77  return ob;
78 }
79 
80 bool ED_object_posemode_enter_ex(struct Main *bmain, Object *ob)
81 {
82  BLI_assert(BKE_id_is_editable(bmain, &ob->id));
83  bool ok = false;
84 
85  switch (ob->type) {
86  case OB_ARMATURE:
87  ob->restore_mode = ob->mode;
88  ob->mode |= OB_MODE_POSE;
89  /* Inform all CoW versions that we changed the mode. */
91  ok = true;
92 
93  break;
94  default:
95  break;
96  }
97 
98  return ok;
99 }
101 {
102  ReportList *reports = CTX_wm_reports(C);
103  struct Main *bmain = CTX_data_main(C);
104  if (!BKE_id_is_editable(bmain, &ob->id)) {
105  BKE_report(reports, RPT_WARNING, "Cannot pose libdata");
106  return false;
107  }
108  bool ok = ED_object_posemode_enter_ex(bmain, ob);
109  if (ok) {
111  }
112  return ok;
113 }
114 
115 bool ED_object_posemode_exit_ex(struct Main *bmain, Object *ob)
116 {
117  bool ok = false;
118  if (ob) {
119  ob->restore_mode = ob->mode;
120  ob->mode &= ~OB_MODE_POSE;
121 
122  /* Inform all CoW versions that we changed the mode. */
124  ok = true;
125  }
126  return ok;
127 }
129 {
130  struct Main *bmain = CTX_data_main(C);
131  bool ok = ED_object_posemode_exit_ex(bmain, ob);
132  if (ok) {
134  }
135  return ok;
136 }
137 
138 /* ********************************************** */
139 /* Motion Paths */
140 
142 {
143  switch (range) {
150  }
152 }
153 
155 {
156  /* Transform doesn't always have context available to do update. */
157  if (C == NULL) {
158  return;
159  }
160 
161  Main *bmain = CTX_data_main(C);
162  ViewLayer *view_layer = CTX_data_view_layer(C);
163 
165  bool free_depsgraph = false;
166 
167  ListBase targets = {NULL, NULL};
168  /* set flag to force recalc, then grab the relevant bones to target */
170  animviz_get_object_motionpaths(ob, &targets);
171 
172  /* recalculate paths, then free */
173 #ifdef DEBUG_TIME
174  TIMEIT_START(pose_path_calc);
175 #endif
176 
177  /* For a single frame update it's faster to re-use existing dependency graph and avoid overhead
178  * of building all the relations and so on for a temporary one. */
179  if (range == POSE_PATH_CALC_RANGE_CURRENT_FRAME) {
180  /* NOTE: Dependency graph will be evaluated at all the frames, but we first need to access some
181  * nested pointers, like animation data. */
183  free_depsgraph = false;
184  }
185  else {
186  depsgraph = animviz_depsgraph_build(bmain, scene, view_layer, &targets);
187  free_depsgraph = true;
188  }
189 
191  depsgraph, bmain, scene, &targets, pose_path_convert_range(range), !free_depsgraph);
192 
193 #ifdef DEBUG_TIME
194  TIMEIT_END(pose_path_calc);
195 #endif
196 
197  BLI_freelistN(&targets);
198 
199  if (range != POSE_PATH_CALC_RANGE_CURRENT_FRAME) {
200  /* Tag armature object for copy on write - so paths will draw/redraw.
201  * For currently frame only we update evaluated object directly. */
203  }
204 
205  /* Free temporary depsgraph. */
206  if (free_depsgraph) {
208  }
209 }
210 
211 /* show popup to determine settings */
213 {
215 
216  if (ELEM(NULL, ob, ob->pose)) {
217  return OPERATOR_CANCELLED;
218  }
219 
220  /* set default settings from existing/stored settings */
221  {
222  bAnimVizSettings *avs = &ob->pose->avs;
223  PointerRNA avs_ptr;
224 
225  RNA_pointer_create(NULL, &RNA_AnimVizMotionPaths, avs, &avs_ptr);
226  RNA_enum_set(op->ptr, "display_type", RNA_enum_get(&avs_ptr, "type"));
227  RNA_enum_set(op->ptr, "range", RNA_enum_get(&avs_ptr, "range"));
228  RNA_enum_set(op->ptr, "bake_location", RNA_enum_get(&avs_ptr, "bake_location"));
229  }
230 
231  /* show popup dialog to allow editing of range... */
232  /* FIXME: hard-coded dimensions here are just arbitrary. */
233  return WM_operator_props_dialog_popup(C, op, 270);
234 }
235 
236 /* For the object with pose/action: create path curves for selected bones
237  * This recalculates the WHOLE path within the pchan->pathsf and pchan->pathef range
238  */
240 {
243 
244  if (ELEM(NULL, ob, ob->pose)) {
245  return OPERATOR_CANCELLED;
246  }
247 
248  /* grab baking settings from operator settings */
249  {
250  bAnimVizSettings *avs = &ob->pose->avs;
251  PointerRNA avs_ptr;
252 
253  avs->path_type = RNA_enum_get(op->ptr, "display_type");
254  avs->path_range = RNA_enum_get(op->ptr, "range");
256 
257  RNA_pointer_create(NULL, &RNA_AnimVizMotionPaths, avs, &avs_ptr);
258  RNA_enum_set(&avs_ptr, "bake_location", RNA_enum_get(op->ptr, "bake_location"));
259  }
260 
261  /* set up path data for bones being calculated */
262  CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones_from_active_object) {
263  /* verify makes sure that the selected bone has a bone with the appropriate settings */
264  animviz_verify_motionpaths(op->reports, scene, ob, pchan);
265  }
266  CTX_DATA_END;
267 
268 #ifdef DEBUG_TIME
269  TIMEIT_START(recalc_pose_paths);
270 #endif
271 
272  /* Calculate the bones that now have motionpaths. */
273  /* TODO: only make for the selected bones? */
275 
276 #ifdef DEBUG_TIME
277  TIMEIT_END(recalc_pose_paths);
278 #endif
279 
280  /* notifiers for updates */
282 
283  return OPERATOR_FINISHED;
284 }
285 
287 {
288  /* identifiers */
289  ot->name = "Calculate Bone Paths";
290  ot->idname = "POSE_OT_paths_calculate";
291  ot->description = "Calculate paths for the selected bones";
292 
293  /* api callbacks */
297 
298  /* flags */
300 
301  /* properties */
303  "display_type",
306  "Display type",
307  "");
309  "range",
312  "Computation Range",
313  "");
314 
316  "bake_location",
319  "Bake Location",
320  "Which point on the bones is used when calculating paths");
321 }
322 
323 /* --------- */
324 
326 {
329  return (ob->pose->avs.path_bakeflag & MOTIONPATH_BAKE_HAS_PATHS) != 0;
330  }
331 
332  return false;
333 }
334 
336 {
339 
340  if (ELEM(NULL, ob, scene)) {
341  return OPERATOR_CANCELLED;
342  }
344 
345  /* set up path data for bones being calculated */
346  CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones_from_active_object) {
347  animviz_verify_motionpaths(op->reports, scene, ob, pchan);
348  }
349  CTX_DATA_END;
350 
351  /* Calculate the bones that now have motion-paths. */
352  /* TODO: only make for the selected bones? */
354 
355  /* notifiers for updates */
357 
358  return OPERATOR_FINISHED;
359 }
360 
362 {
363  /* identifiers */
364  ot->name = "Update Bone Paths";
365  ot->idname = "POSE_OT_paths_update";
366  ot->description = "Recalculate paths for bones that already have them";
367 
368  /* api callbacks */
371 
372  /* flags */
374 }
375 
376 /* --------- */
377 
378 /* for the object with pose/action: clear path curves for selected bones only */
379 static void ED_pose_clear_paths(Object *ob, bool only_selected)
380 {
381  bPoseChannel *pchan;
382  bool skipped = false;
383 
384  if (ELEM(NULL, ob, ob->pose)) {
385  return;
386  }
387 
388  /* free the motionpath blocks for all bones - This is easier for users to quickly clear all */
389  for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
390  if (pchan->mpath) {
391  if ((only_selected == false) || ((pchan->bone) && (pchan->bone->flag & BONE_SELECTED))) {
393  pchan->mpath = NULL;
394  }
395  else {
396  skipped = true;
397  }
398  }
399  }
400 
401  /* if nothing was skipped, there should be no paths left! */
402  if (skipped == false) {
404  }
405 
406  /* tag armature object for copy on write - so removed paths don't still show */
408 }
409 
410 /* Operator callback - wrapper for the back-end function. */
412 {
414  bool only_selected = RNA_boolean_get(op->ptr, "only_selected");
415 
416  /* only continue if there's an object */
417  if (ELEM(NULL, ob, ob->pose)) {
418  return OPERATOR_CANCELLED;
419  }
420 
421  /* use the backend function for this */
422  ED_pose_clear_paths(ob, only_selected);
423 
424  /* notifiers for updates */
426 
427  return OPERATOR_FINISHED;
428 }
429 
430 /* operator callback/wrapper */
431 static int pose_clear_paths_invoke(bContext *C, wmOperator *op, const wmEvent *event)
432 {
433  if ((event->modifier & KM_SHIFT) && !RNA_struct_property_is_set(op->ptr, "only_selected")) {
434  RNA_boolean_set(op->ptr, "only_selected", true);
435  }
436  return pose_clear_paths_exec(C, op);
437 }
438 
440 {
441  /* identifiers */
442  ot->name = "Clear Bone Paths";
443  ot->idname = "POSE_OT_paths_clear";
444  ot->description = "Clear path caches for all bones, hold Shift key for selected bones only";
445 
446  /* api callbacks */
450 
451  /* flags */
453 
454  /* properties */
456  ot->srna, "only_selected", false, "Only Selected", "Only clear paths from selected bones");
458 }
459 
460 /* --------- */
461 
463 {
466 
467  if (ELEM(NULL, scene, ob, ob->pose)) {
468  return OPERATOR_CANCELLED;
469  }
470 
471  /* use Preview Range or Full Frame Range - whichever is in use */
472  ob->pose->avs.path_sf = PSFRA;
473  ob->pose->avs.path_ef = PEFRA;
474 
475  /* tag for updates */
478 
479  return OPERATOR_FINISHED;
480 }
481 
483 {
484  /* identifiers */
485  ot->name = "Update Range from Scene";
486  ot->idname = "POSE_OT_paths_range_update";
487  ot->description = "Update frame range for motion paths from the Scene's current frame range";
488 
489  /* callbacks */
492 
493  /* flags */
495 }
496 
497 /* ********************************************** */
498 
500 {
501  Main *bmain = CTX_data_main(C);
502  ViewLayer *view_layer = CTX_data_view_layer(C);
503  View3D *v3d = CTX_wm_view3d(C);
504  const bool do_strip_numbers = RNA_boolean_get(op->ptr, "do_strip_numbers");
505 
506  FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, v3d, OB_ARMATURE, OB_MODE_POSE, ob) {
507  bArmature *arm = ob->data;
508  ListBase bones_names = {NULL};
509 
511  BLI_addtail(&bones_names, BLI_genericNodeN(pchan->name));
512  }
514 
515  ED_armature_bones_flip_names(bmain, arm, &bones_names, do_strip_numbers);
516 
517  BLI_freelistN(&bones_names);
518 
519  /* since we renamed stuff... */
521 
522  /* NOTE: notifier might evolve. */
524  }
526 
527  return OPERATOR_FINISHED;
528 }
529 
531 {
532  /* identifiers */
533  ot->name = "Flip Names";
534  ot->idname = "POSE_OT_flip_names";
535  ot->description = "Flips (and corrects) the axis suffixes of the names of selected bones";
536 
537  /* api callbacks */
540 
541  /* flags */
543 
545  "do_strip_numbers",
546  false,
547  "Strip Numbers",
548  "Try to remove right-most dot-number from flipped names.\n"
549  "Warning: May result in incoherent naming in some cases");
550 }
551 
552 /* ------------------ */
553 
555 {
556  Main *bmain = CTX_data_main(C);
557  char newname[MAXBONENAME];
558  short axis = RNA_enum_get(op->ptr, "axis");
559  Object *ob_prev = NULL;
560 
561  /* loop through selected bones, auto-naming them */
562  CTX_DATA_BEGIN_WITH_ID (C, bPoseChannel *, pchan, selected_pose_bones, Object *, ob) {
563  bArmature *arm = ob->data;
564  BLI_strncpy(newname, pchan->name, sizeof(newname));
565  if (bone_autoside_name(newname, 1, axis, pchan->bone->head[axis], pchan->bone->tail[axis])) {
566  ED_armature_bone_rename(bmain, arm, pchan->name, newname);
567  }
568 
569  if (ob_prev != ob) {
570  /* since we renamed stuff... */
572 
573  /* NOTE: notifier might evolve. */
575  ob_prev = ob;
576  }
577  }
578  CTX_DATA_END;
579 
580  return OPERATOR_FINISHED;
581 }
582 
584 {
585  static const EnumPropertyItem axis_items[] = {
586  {0, "XAXIS", 0, "X-Axis", "Left/Right"},
587  {1, "YAXIS", 0, "Y-Axis", "Front/Back"},
588  {2, "ZAXIS", 0, "Z-Axis", "Top/Bottom"},
589  {0, NULL, 0, NULL, NULL},
590  };
591 
592  /* identifiers */
593  ot->name = "Auto-Name by Axis";
594  ot->idname = "POSE_OT_autoside_names";
595  ot->description =
596  "Automatically renames the selected bones according to which side of the target axis they "
597  "fall on";
598 
599  /* api callbacks */
603 
604  /* flags */
606 
607  /* settings */
608  ot->prop = RNA_def_enum(ot->srna, "axis", axis_items, 0, "Axis", "Axis tag names with");
609 }
610 
611 /* ********************************************** */
612 
614 {
615  const int mode = RNA_enum_get(op->ptr, "type");
616  Object *prev_ob = NULL;
617 
618  /* Set rotation mode of selected bones. */
619  CTX_DATA_BEGIN_WITH_ID (C, bPoseChannel *, pchan, selected_pose_bones, Object *, ob) {
620  /* use API Method for conversions... */
622  pchan->quat, pchan->eul, pchan->rotAxis, &pchan->rotAngle, pchan->rotmode, (short)mode);
623 
624  /* finally, set the new rotation type */
625  pchan->rotmode = mode;
626 
627  if (prev_ob != ob) {
628  /* Notifiers and updates. */
632  prev_ob = ob;
633  }
634  }
635  CTX_DATA_END;
636 
637  return OPERATOR_FINISHED;
638 }
639 
641 {
642  /* identifiers */
643  ot->name = "Set Rotation Mode";
644  ot->idname = "POSE_OT_rotation_mode_set";
645  ot->description = "Set the rotation representation used by selected bones";
646 
647  /* callbacks */
651 
652  /* flags */
654 
655  /* properties */
656  ot->prop = RNA_def_enum(
657  ot->srna, "type", rna_enum_object_rotation_mode_items, 0, "Rotation Mode", "");
658 }
659 
660 /* ********************************************** */
661 
663 {
664  /* Armature layers operators can be used in posemode OR editmode for armatures */
666 }
667 
669 {
670  bArmature *arm = NULL;
671 
672  /* Sanity checking and handling of posemode. */
673  if (*ob) {
675  if (tob) {
676  *ob = tob;
677  arm = (*ob)->data;
678  }
679  else if ((*ob)->type == OB_ARMATURE) {
680  arm = (*ob)->data;
681  }
682  }
683 
684  return arm;
685 }
686 
687 /* Show all armature layers */
688 
690 {
693  PointerRNA ptr;
694  int maxLayers = (RNA_boolean_get(op->ptr, "all")) ? 32 : 16;
695  /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */
696  bool layers[32] = {false};
697 
698  /* sanity checking */
699  if (arm == NULL) {
700  return OPERATOR_CANCELLED;
701  }
702 
703  /* use RNA to set the layers
704  * although it would be faster to just set directly using bitflags, we still
705  * need to setup a RNA pointer so that we get the "update" callbacks for free...
706  */
707  RNA_id_pointer_create(&arm->id, &ptr);
708 
709  for (int i = 0; i < maxLayers; i++) {
710  layers[i] = 1;
711  }
712 
713  RNA_boolean_set_array(&ptr, "layers", layers);
714 
715  /* NOTE: notifier might evolve. */
718 
719  /* done */
720  return OPERATOR_FINISHED;
721 }
722 
724 {
725  /* identifiers */
726  ot->name = "Show All Layers";
727  ot->idname = "ARMATURE_OT_layers_show_all";
728  ot->description = "Make all armature layers visible";
729 
730  /* callbacks */
733 
734  /* flags */
736 
737  /* properties */
739  ot->srna, "all", 1, "All Layers", "Enable all layers or just the first 16 (top row)");
740 }
741 
742 /* ------------------- */
743 
744 /* Present a popup to get the layers that should be used */
745 static int armature_layers_invoke(bContext *C, wmOperator *op, const wmEvent *event)
746 {
749  PointerRNA ptr;
750  /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */
751  bool layers[32];
752 
753  /* sanity checking */
754  if (arm == NULL) {
755  return OPERATOR_CANCELLED;
756  }
757 
758  /* Get RNA pointer to armature data to use that to retrieve the layers as ints
759  * to init the operator. */
760  RNA_id_pointer_create((ID *)arm, &ptr);
761  RNA_boolean_get_array(&ptr, "layers", layers);
762  RNA_boolean_set_array(op->ptr, "layers", layers);
763 
764  /* part to sync with other similar operators... */
765  return WM_operator_props_popup(C, op, event);
766 }
767 
768 /* Set the visible layers for the active armature (edit and pose modes) */
770 {
773  PointerRNA ptr;
774  /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */
775  bool layers[32];
776 
777  if (arm == NULL) {
778  return OPERATOR_CANCELLED;
779  }
780 
781  /* get the values set in the operator properties */
782  RNA_boolean_get_array(op->ptr, "layers", layers);
783 
784  /* get pointer for armature, and write data there... */
785  RNA_id_pointer_create((ID *)arm, &ptr);
786  RNA_boolean_set_array(&ptr, "layers", layers);
787 
788  /* NOTE: notifier might evolve. */
791 
792  return OPERATOR_FINISHED;
793 }
794 
796 {
797  /* identifiers */
798  ot->name = "Change Armature Layers";
799  ot->idname = "ARMATURE_OT_armature_layers";
800  ot->description = "Change the visible armature layers";
801 
802  /* callbacks */
806 
807  /* flags */
809 
810  /* properties */
812  ot->srna, "layers", 32, NULL, "Layer", "Armature layers to make visible");
813 }
814 
815 /* ------------------- */
816 
817 /* Present a popup to get the layers that should be used */
818 static int pose_bone_layers_invoke(bContext *C, wmOperator *op, const wmEvent *event)
819 {
820  /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */
821  bool layers[32] = {0};
822 
823  /* get layers that are active already */
824  CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones) {
825  short bit;
826 
827  /* loop over the bits for this pchan's layers, adding layers where they're needed */
828  for (bit = 0; bit < 32; bit++) {
829  layers[bit] = (pchan->bone->layer & (1u << bit)) != 0;
830  }
831  }
832  CTX_DATA_END;
833 
834  /* copy layers to operator */
835  RNA_boolean_set_array(op->ptr, "layers", layers);
836 
837  /* part to sync with other similar operators... */
838  return WM_operator_props_popup(C, op, event);
839 }
840 
841 /* Set the visible layers for the active armature (edit and pose modes) */
843 {
844  PointerRNA ptr;
845  /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */
846  bool layers[32];
847 
848  /* get the values set in the operator properties */
849  RNA_boolean_get_array(op->ptr, "layers", layers);
850 
851  Object *prev_ob = NULL;
852 
853  /* Make sure that the pose bone data is up to date.
854  * (May not always be the case after undo/redo e.g.).
855  */
856  struct Main *bmain = CTX_data_main(C);
857  wmWindow *win = CTX_wm_window(C);
858  View3D *v3d = CTX_wm_view3d(C); /* This may be NULL in a lot of cases. */
859  ViewLayer *view_layer = WM_window_get_active_view_layer(win);
860 
861  FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, v3d, OB_ARMATURE, OB_MODE_POSE, ob_iter) {
862  bArmature *arm = ob_iter->data;
863  BKE_pose_ensure(bmain, ob_iter, arm, true);
864  }
866 
867  /* set layers of pchans based on the values set in the operator props */
868  CTX_DATA_BEGIN_WITH_ID (C, bPoseChannel *, pchan, selected_pose_bones, Object *, ob) {
869  /* get pointer for pchan, and write flags this way */
870  RNA_pointer_create((ID *)ob->data, &RNA_Bone, pchan->bone, &ptr);
871  RNA_boolean_set_array(&ptr, "layers", layers);
872 
873  if (prev_ob != ob) {
874  /* NOTE: notifier might evolve. */
877  prev_ob = ob;
878  }
879  }
880  CTX_DATA_END;
881  return OPERATOR_FINISHED;
882 }
883 
885 {
886  /* identifiers */
887  ot->name = "Change Bone Layers";
888  ot->idname = "POSE_OT_bone_layers";
889  ot->description = "Change the layers that the selected bones belong to";
890 
891  /* callbacks */
895 
896  /* flags */
898 
899  /* properties */
901  ot->srna, "layers", 32, NULL, "Layer", "Armature layers that bone belongs to");
902 }
903 
904 /* ------------------- */
905 
906 /* Present a popup to get the layers that should be used */
907 static int armature_bone_layers_invoke(bContext *C, wmOperator *op, const wmEvent *event)
908 {
909  /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */
910  bool layers[32] = {0};
911 
912  /* get layers that are active already */
913  CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones) {
914  short bit;
915 
916  /* loop over the bits for this pchan's layers, adding layers where they're needed */
917  for (bit = 0; bit < 32; bit++) {
918  if (ebone->layer & (1u << bit)) {
919  layers[bit] = 1;
920  }
921  }
922  }
923  CTX_DATA_END;
924 
925  /* copy layers to operator */
926  RNA_boolean_set_array(op->ptr, "layers", layers);
927 
928  /* part to sync with other similar operators... */
929  return WM_operator_props_popup(C, op, event);
930 }
931 
932 /* Set the visible layers for the active armature (edit and pose modes) */
934 {
936  PointerRNA ptr;
937  /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */
938  bool layers[32];
939 
940  /* get the values set in the operator properties */
941  RNA_boolean_get_array(op->ptr, "layers", layers);
942 
943  /* set layers of pchans based on the values set in the operator props */
944  CTX_DATA_BEGIN_WITH_ID (C, EditBone *, ebone, selected_editable_bones, bArmature *, arm) {
945  /* get pointer for pchan, and write flags this way */
946  RNA_pointer_create((ID *)arm, &RNA_EditBone, ebone, &ptr);
947  RNA_boolean_set_array(&ptr, "layers", layers);
948  }
949  CTX_DATA_END;
950 
952 
953  /* NOTE: notifier might evolve. */
956 
957  return OPERATOR_FINISHED;
958 }
959 
961 {
962  /* identifiers */
963  ot->name = "Change Bone Layers";
964  ot->idname = "ARMATURE_OT_bone_layers";
965  ot->description = "Change the layers that the selected bones belong to";
966 
967  /* callbacks */
971 
972  /* flags */
974 
975  /* properties */
977  ot->srna, "layers", 32, NULL, "Layer", "Armature layers that bone belongs to");
978 }
979 
980 /* ********************************************** */
981 /* Show/Hide Bones */
982 
983 static int hide_pose_bone_fn(Object *ob, Bone *bone, void *ptr)
984 {
985  bArmature *arm = ob->data;
986  const bool hide_select = (bool)POINTER_AS_INT(ptr);
987  int count = 0;
988  if (arm->layer & bone->layer) {
989  if (((bone->flag & BONE_SELECTED) != 0) == hide_select) {
990  bone->flag |= BONE_HIDDEN_P;
991  /* only needed when 'hide_select' is true, but harmless. */
992  bone->flag &= ~BONE_SELECTED;
993  if (arm->act_bone == bone) {
994  arm->act_bone = NULL;
995  }
996  count += 1;
997  }
998  }
999  return count;
1000 }
1001 
1002 /* active object is armature in posemode, poll checked */
1004 {
1005  ViewLayer *view_layer = CTX_data_view_layer(C);
1006  uint objects_len;
1007  Object **objects = BKE_object_pose_array_get_unique(view_layer, CTX_wm_view3d(C), &objects_len);
1008  bool changed_multi = false;
1009 
1010  const int hide_select = !RNA_boolean_get(op->ptr, "unselected");
1011  void *hide_select_p = POINTER_FROM_INT(hide_select);
1012 
1013  for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
1014  Object *ob_iter = objects[ob_index];
1015  bArmature *arm = ob_iter->data;
1016 
1017  bool changed = bone_looper(ob_iter, arm->bonebase.first, hide_select_p, hide_pose_bone_fn) !=
1018  0;
1019  if (changed) {
1020  changed_multi = true;
1023  }
1024  }
1025  MEM_freeN(objects);
1026 
1027  return changed_multi ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
1028 }
1029 
1031 {
1032  /* identifiers */
1033  ot->name = "Hide Selected";
1034  ot->idname = "POSE_OT_hide";
1035  ot->description = "Tag selected bones to not be visible in Pose Mode";
1036 
1037  /* api callbacks */
1038  ot->exec = pose_hide_exec;
1040 
1041  /* flags */
1043 
1044  /* props */
1045  RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "");
1046 }
1047 
1048 static int show_pose_bone_cb(Object *ob, Bone *bone, void *data)
1049 {
1050  const bool select = POINTER_AS_INT(data);
1051 
1052  bArmature *arm = ob->data;
1053  int count = 0;
1054  if (arm->layer & bone->layer) {
1055  if (bone->flag & BONE_HIDDEN_P) {
1056  if (!(bone->flag & BONE_UNSELECTABLE)) {
1058  }
1059  bone->flag &= ~BONE_HIDDEN_P;
1060  count += 1;
1061  }
1062  }
1063 
1064  return count;
1065 }
1066 
1067 /* active object is armature in posemode, poll checked */
1069 {
1070  ViewLayer *view_layer = CTX_data_view_layer(C);
1071  uint objects_len;
1072  Object **objects = BKE_object_pose_array_get_unique(view_layer, CTX_wm_view3d(C), &objects_len);
1073  bool changed_multi = false;
1074  const bool select = RNA_boolean_get(op->ptr, "select");
1075  void *select_p = POINTER_FROM_INT(select);
1076 
1077  for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
1078  Object *ob_iter = objects[ob_index];
1079  bArmature *arm = ob_iter->data;
1080 
1081  bool changed = bone_looper(ob_iter, arm->bonebase.first, select_p, show_pose_bone_cb);
1082  if (changed) {
1083  changed_multi = true;
1086  }
1087  }
1088  MEM_freeN(objects);
1089 
1090  return changed_multi ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
1091 }
1092 
1094 {
1095  /* identifiers */
1096  ot->name = "Reveal Selected";
1097  ot->idname = "POSE_OT_reveal";
1098  ot->description = "Reveal all bones hidden in Pose Mode";
1099 
1100  /* api callbacks */
1103 
1104  /* flags */
1106 
1107  RNA_def_boolean(ot->srna, "select", true, "Select", "");
1108 }
1109 
1110 /* ********************************************** */
1111 /* Flip Quats */
1112 
1114 {
1117 
1118  bool changed_multi = false;
1119 
1120  ViewLayer *view_layer = CTX_data_view_layer(C);
1121  View3D *v3d = CTX_wm_view3d(C);
1122  FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, v3d, OB_ARMATURE, OB_MODE_POSE, ob_iter) {
1123  bool changed = false;
1124  /* loop through all selected pchans, flipping and keying (as needed) */
1125  FOREACH_PCHAN_SELECTED_IN_OBJECT_BEGIN (ob_iter, pchan) {
1126  /* only if bone is using quaternion rotation */
1127  if (pchan->rotmode == ROT_MODE_QUAT) {
1128  changed = true;
1129  /* quaternions have 720 degree range */
1130  negate_v4(pchan->quat);
1131 
1132  ED_autokeyframe_pchan(C, scene, ob_iter, pchan, ks);
1133  }
1134  }
1136 
1137  if (changed) {
1138  changed_multi = true;
1139  /* notifiers and updates */
1140  DEG_id_tag_update(&ob_iter->id, ID_RECALC_GEOMETRY);
1142  }
1143  }
1145 
1146  return changed_multi ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
1147 }
1148 
1150 {
1151  /* identifiers */
1152  ot->name = "Flip Quats";
1153  ot->idname = "POSE_OT_quaternions_flip";
1154  ot->description =
1155  "Flip quaternion values to achieve desired rotations, while maintaining the same "
1156  "orientations";
1157 
1158  /* callbacks */
1161 
1162  /* flags */
1164 }
Blender kernel action and pose functionality.
void animviz_free_motionpath(struct bMotionPath *mpath)
struct bMotionPath * animviz_verify_motionpaths(struct ReportList *reports, struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan)
void BKE_pose_ensure(struct Main *bmain, struct Object *ob, struct bArmature *arm, bool do_id_user)
Definition: armature.c:2419
#define FOREACH_PCHAN_SELECTED_IN_OBJECT_END
Definition: BKE_armature.h:564
void BKE_rotMode_change_values(float quat[4], float eul[3], float axis[3], float *angle, short oldMode, short newMode)
Definition: armature.c:1983
#define FOREACH_PCHAN_SELECTED_IN_OBJECT_BEGIN(_ob, _pchan)
Definition: BKE_armature.h:560
bool bone_autoside_name(char name[64], int strip_number, short axis, float head, float tail)
#define CTX_DATA_BEGIN_WITH_ID(C, Type, instance, member, Type_id, instance_id)
Definition: BKE_context.h:284
struct ScrArea * CTX_wm_area(const bContext *C)
Definition: context.c:738
struct Scene * CTX_data_scene(const bContext *C)
Definition: context.c:1090
struct Object * CTX_data_edit_object(const bContext *C)
Definition: context.c:1370
#define CTX_DATA_BEGIN(C, Type, instance, member)
Definition: BKE_context.h:269
struct ViewLayer * CTX_data_view_layer(const bContext *C)
Definition: context.c:1100
struct Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
Definition: context.c:1528
struct Object * CTX_data_active_object(const bContext *C)
Definition: context.c:1353
struct View3D * CTX_wm_view3d(const bContext *C)
Definition: context.c:784
struct ReportList * CTX_wm_reports(const bContext *C)
Definition: context.c:775
struct Main * CTX_data_main(const bContext *C)
Definition: context.c:1074
#define CTX_DATA_END
Definition: BKE_context.h:278
struct wmWindow * CTX_wm_window(const bContext *C)
Definition: context.c:723
support for deformation groups and hooks.
#define FOREACH_OBJECT_IN_MODE_END
Definition: BKE_layer.h:384
#define FOREACH_OBJECT_IN_MODE_BEGIN(_view_layer, _v3d, _object_type, _object_mode, _instance)
Definition: BKE_layer.h:380
bool BKE_id_is_editable(const struct Main *bmain, const struct ID *id)
General operations, lookup, etc. for blender objects.
struct Object * BKE_object_pose_armature_get(struct Object *ob)
Definition: object.cc:2511
struct Object ** BKE_object_pose_array_get_unique(struct ViewLayer *view_layer, struct View3D *v3d, unsigned int *r_objects_len)
Definition: object.cc:2594
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition: report.c:83
#define BLI_assert(a)
Definition: BLI_assert.h:46
struct LinkData * BLI_genericNodeN(void *data)
Definition: listbase.c:842
void void BLI_freelistN(struct ListBase *listbase) ATTR_NONNULL(1)
Definition: listbase.c:466
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:80
MINLINE void negate_v4(float r[4])
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_NONNULL()
Definition: string.c:64
unsigned int uint
Definition: BLI_sys_types.h:67
#define POINTER_FROM_INT(i)
#define UNUSED(x)
#define SET_FLAG_FROM_TEST(value, test, flag)
#define POINTER_AS_INT(i)
#define ELEM(...)
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:35
void DEG_id_tag_update_ex(struct Main *bmain, struct ID *id, int flag)
void DEG_graph_free(Depsgraph *graph)
Definition: depsgraph.cc:295
void DEG_id_tag_update(struct ID *id, int flag)
@ ID_RECALC_PARAMETERS
Definition: DNA_ID.h:854
@ ID_RECALC_COPY_ON_WRITE
Definition: DNA_ID.h:834
@ ID_RECALC_GEOMETRY
Definition: DNA_ID.h:791
@ MOTIONPATH_BAKE_HEADS
@ MOTIONPATH_BAKE_HAS_PATHS
@ MOTIONPATH_TYPE_RANGE
@ ROT_MODE_QUAT
@ MOTIONPATH_RANGE_SCENE
@ ANIMVIZ_RECALC_PATHS
#define MAXBONENAME
@ BONE_SELECTED
@ BONE_UNSELECTABLE
@ BONE_HIDDEN_P
@ OB_MODE_POSE
Object is a sort of wrapper for general info.
@ OB_ARMATURE
#define PSFRA
#define PEFRA
@ SPACE_PROPERTIES
@ OPERATOR_CANCELLED
@ OPERATOR_FINISHED
eAnimvizCalcRange
Definition: ED_anim_api.h:1088
@ ANIMVIZ_CALC_RANGE_FULL
Definition: ED_anim_api.h:1096
@ ANIMVIZ_CALC_RANGE_CURRENT_FRAME
Definition: ED_anim_api.h:1090
@ ANIMVIZ_CALC_RANGE_CHANGED
Definition: ED_anim_api.h:1093
ePosePathCalcRange
Definition: ED_armature.h:294
@ POSE_PATH_CALC_RANGE_CURRENT_FRAME
Definition: ED_armature.h:295
@ POSE_PATH_CALC_RANGE_CHANGED
Definition: ED_armature.h:296
@ POSE_PATH_CALC_RANGE_FULL
Definition: ED_armature.h:297
#define ANIM_KS_LOC_ROT_SCALE_ID
struct Object * ED_object_context(const struct bContext *C)
bool ED_operator_posemode(struct bContext *C)
Definition: screen_ops.c:530
bool ED_operator_posemode_local(struct bContext *C)
Definition: screen_ops.c:546
bool ED_operator_editarmature(struct bContext *C)
Definition: screen_ops.c:466
bool ED_operator_posemode_exclusive(struct bContext *C)
Definition: screen_ops.c:494
Read Guarded memory(de)allocation.
Platform independent time functions.
Utility defines for timing/benchmarks.
#define TIMEIT_START(var)
#define TIMEIT_END(var)
@ PROP_SKIP_SAVE
Definition: RNA_types.h:218
#define C
Definition: RandGen.cpp:25
@ OPTYPE_UNDO
Definition: WM_types.h:148
@ OPTYPE_REGISTER
Definition: WM_types.h:146
#define ND_MODE
Definition: WM_types.h:393
#define NC_SCENE
Definition: WM_types.h:328
#define ND_POSE
Definition: WM_types.h:407
#define NS_MODE_OBJECT
Definition: WM_types.h:501
#define ND_TRANSFORM
Definition: WM_types.h:405
@ KM_SHIFT
Definition: WM_types.h:238
#define NS_MODE_POSE
Definition: WM_types.h:510
#define ND_BONE_SELECT
Definition: WM_types.h:409
#define NC_OBJECT
Definition: WM_types.h:329
void animviz_calc_motionpaths(Depsgraph *depsgraph, Main *bmain, Scene *scene, ListBase *targets, eAnimvizCalcRange range, bool restore)
void animviz_get_object_motionpaths(Object *ob, ListBase *targets)
Depsgraph * animviz_depsgraph_build(Main *bmain, Scene *scene, ViewLayer *view_layer, ListBase *targets)
void animviz_motionpath_compute_range(Object *ob, Scene *scene)
int bone_looper(struct Object *ob, struct Bone *bone, void *data, int(*bone_func)(struct Object *, struct Bone *, void *))
void ED_armature_bone_rename(Main *bmain, bArmature *arm, const char *oldnamep, const char *newnamep)
void ED_armature_bones_flip_names(Main *bmain, bArmature *arm, ListBase *bones_names, const bool do_strip_numbers)
void ED_armature_edit_refresh_layer_used(bArmature *arm)
__forceinline const avxb select(const avxb &m, const avxb &t, const avxb &f)
Definition: avxb.h:154
Scene scene
const Depsgraph * depsgraph
int count
bool ED_autokeyframe_pchan(bContext *C, Scene *scene, Object *ob, bPoseChannel *pchan, KeyingSet *ks)
Definition: keyframing.c:3090
KeyingSet * ANIM_builtin_keyingset_get_named(KeyingSet *prevKS, const char name[])
Definition: keyingsets.c:531
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:27
static void area(int d1, int d2, int e1, int e2, float weights[2])
static int pose_clear_paths_exec(bContext *C, wmOperator *op)
Definition: pose_edit.c:411
static int pose_update_paths_range_exec(bContext *C, wmOperator *UNUSED(op))
Definition: pose_edit.c:462
void POSE_OT_hide(wmOperatorType *ot)
Definition: pose_edit.c:1030
void ED_pose_recalculate_paths(bContext *C, Scene *scene, Object *ob, ePosePathCalcRange range)
Definition: pose_edit.c:154
void POSE_OT_paths_range_update(wmOperatorType *ot)
Definition: pose_edit.c:482
static int pose_calculate_paths_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
Definition: pose_edit.c:212
static int pose_update_paths_exec(bContext *C, wmOperator *op)
Definition: pose_edit.c:335
static int armature_bone_layers_exec(bContext *C, wmOperator *op)
Definition: pose_edit.c:933
static int pose_autoside_names_exec(bContext *C, wmOperator *op)
Definition: pose_edit.c:554
void POSE_OT_quaternions_flip(wmOperatorType *ot)
Definition: pose_edit.c:1149
void ARMATURE_OT_bone_layers(wmOperatorType *ot)
Definition: pose_edit.c:960
void POSE_OT_paths_update(wmOperatorType *ot)
Definition: pose_edit.c:361
static int armature_bone_layers_invoke(bContext *C, wmOperator *op, const wmEvent *event)
Definition: pose_edit.c:907
bool ED_object_posemode_enter(bContext *C, Object *ob)
Definition: pose_edit.c:100
static int pose_bone_layers_invoke(bContext *C, wmOperator *op, const wmEvent *event)
Definition: pose_edit.c:818
static bArmature * armature_layers_get_data(Object **ob)
Definition: pose_edit.c:668
static void ED_pose_clear_paths(Object *ob, bool only_selected)
Definition: pose_edit.c:379
static int pose_bone_layers_exec(bContext *C, wmOperator *op)
Definition: pose_edit.c:842
static int show_pose_bone_cb(Object *ob, Bone *bone, void *data)
Definition: pose_edit.c:1048
void ARMATURE_OT_layers_show_all(wmOperatorType *ot)
Definition: pose_edit.c:723
void POSE_OT_reveal(wmOperatorType *ot)
Definition: pose_edit.c:1093
static eAnimvizCalcRange pose_path_convert_range(ePosePathCalcRange range)
Definition: pose_edit.c:141
Object * ED_pose_object_from_context(bContext *C)
Definition: pose_edit.c:61
static int hide_pose_bone_fn(Object *ob, Bone *bone, void *ptr)
Definition: pose_edit.c:983
bool ED_object_posemode_enter_ex(struct Main *bmain, Object *ob)
Definition: pose_edit.c:80
void POSE_OT_flip_names(wmOperatorType *ot)
Definition: pose_edit.c:530
void POSE_OT_paths_clear(wmOperatorType *ot)
Definition: pose_edit.c:439
static int pose_reveal_exec(bContext *C, wmOperator *op)
Definition: pose_edit.c:1068
bool ED_object_posemode_exit_ex(struct Main *bmain, Object *ob)
Definition: pose_edit.c:115
static bool armature_layers_poll(bContext *C)
Definition: pose_edit.c:662
static int pose_flip_quats_exec(bContext *C, wmOperator *UNUSED(op))
Definition: pose_edit.c:1113
static int armature_layers_invoke(bContext *C, wmOperator *op, const wmEvent *event)
Definition: pose_edit.c:745
void POSE_OT_autoside_names(wmOperatorType *ot)
Definition: pose_edit.c:583
static int pose_calculate_paths_exec(bContext *C, wmOperator *op)
Definition: pose_edit.c:239
void POSE_OT_paths_calculate(wmOperatorType *ot)
Definition: pose_edit.c:286
static int pose_flip_names_exec(bContext *C, wmOperator *op)
Definition: pose_edit.c:499
static int pose_clear_paths_invoke(bContext *C, wmOperator *op, const wmEvent *event)
Definition: pose_edit.c:431
void POSE_OT_rotation_mode_set(wmOperatorType *ot)
Definition: pose_edit.c:640
static int pose_bone_rotmode_exec(bContext *C, wmOperator *op)
Definition: pose_edit.c:613
static int pose_hide_exec(bContext *C, wmOperator *op)
Definition: pose_edit.c:1003
static int pose_armature_layers_showall_exec(bContext *C, wmOperator *op)
Definition: pose_edit.c:689
static int armature_layers_exec(bContext *C, wmOperator *op)
Definition: pose_edit.c:769
void ARMATURE_OT_armature_layers(wmOperatorType *ot)
Definition: pose_edit.c:795
static bool pose_update_paths_poll(bContext *C)
Definition: pose_edit.c:325
bool ED_object_posemode_exit(bContext *C, Object *ob)
Definition: pose_edit.c:128
void POSE_OT_bone_layers(wmOperatorType *ot)
Definition: pose_edit.c:884
void RNA_boolean_set_array(PointerRNA *ptr, const char *name, const bool *values)
Definition: rna_access.c:4898
void RNA_pointer_create(ID *id, StructRNA *type, void *data, PointerRNA *r_ptr)
Definition: rna_access.c:136
void RNA_id_pointer_create(ID *id, PointerRNA *r_ptr)
Definition: rna_access.c:112
void RNA_boolean_get_array(PointerRNA *ptr, const char *name, bool *values)
Definition: rna_access.c:4886
void RNA_boolean_set(PointerRNA *ptr, const char *name, bool value)
Definition: rna_access.c:4874
bool RNA_struct_property_is_set(PointerRNA *ptr, const char *identifier)
Definition: rna_access.c:5301
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:4863
void RNA_enum_set(PointerRNA *ptr, const char *name, int value)
Definition: rna_access.c:5015
int RNA_enum_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:5004
const EnumPropertyItem rna_enum_motionpath_display_type_items[]
Definition: rna_animviz.c:39
const EnumPropertyItem rna_enum_motionpath_range_items[]
Definition: rna_animviz.c:53
const EnumPropertyItem rna_enum_motionpath_bake_location_items[]
Definition: rna_animviz.c:26
PropertyRNA * RNA_def_boolean_layer_member(StructOrFunctionRNA *cont_, const char *identifier, int len, bool *default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3553
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, bool default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3493
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
Definition: rna_define.c:1490
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, int default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3783
const EnumPropertyItem rna_enum_object_rotation_mode_items[]
Definition: rna_object.c:281
Definition: DNA_ID.h:368
void * first
Definition: DNA_listBase.h:31
Definition: BKE_main.h:121
ListBase objects
Definition: BKE_main.h:170
int restore_mode
struct bPose * pose
void * data
ListBase bonebase
unsigned int layer
struct Bone * bone
bMotionPath * mpath
struct bPoseChannel * next
ListBase chanbase
bAnimVizSettings avs
uint8_t modifier
Definition: WM_types.h:693
int(* invoke)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:919
const char * name
Definition: WM_types.h:888
const char * idname
Definition: WM_types.h:890
bool(* poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:943
struct StructRNA * srna
Definition: WM_types.h:969
const char * description
Definition: WM_types.h:893
int(* exec)(struct bContext *, struct wmOperator *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:903
PropertyRNA * prop
Definition: WM_types.h:981
struct ReportList * reports
struct PointerRNA * ptr
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
PointerRNA * ptr
Definition: wm_files.c:3480
wmOperatorType * ot
Definition: wm_files.c:3479
int WM_operator_props_popup(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
int WM_operator_props_dialog_popup(bContext *C, wmOperator *op, int width)
int WM_menu_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
ViewLayer * WM_window_get_active_view_layer(const wmWindow *win)
Definition: wm_window.c:2217