Blender V5.3
object_edit.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
8
9#include <cctype>
10#include <cfloat>
11#include <cstdlib>
12#include <cstring>
13#include <ctime>
14
15#include "AS_asset_library.hh"
16#include "BLI_path_utils.hh"
17#include "MEM_guardedalloc.h"
18
19#include "BLI_listbase.hh"
21#include "BLI_string.hh"
22#include "BLI_string_utf8.hh"
23#include "BLI_utildefines.hh"
24
25#include "BLT_translation.hh"
26
27#include "DNA_armature_types.h"
28#include "DNA_asset_types.h"
30#include "DNA_curve_types.h"
31#include "DNA_lattice_types.h"
32#include "DNA_material_types.h"
33#include "DNA_mesh_types.h"
34#include "DNA_meta_types.h"
36#include "DNA_object_types.h"
37#include "DNA_scene_types.h"
38
40#include "BKE_armature.hh"
41#include "BKE_collection.hh"
42#include "BKE_constraint.h"
43#include "BKE_context.hh"
44#include "BKE_curve.hh"
45#include "BKE_editlattice.h"
46#include "BKE_editmesh.hh"
47#include "BKE_effect.h"
48#include "BKE_global.hh"
49#include "BKE_idprop.hh"
50#include "BKE_image.hh"
51#include "BKE_lattice.hh"
52#include "BKE_layer.hh"
53#include "BKE_lib_id.hh"
54#include "BKE_library.hh"
55#include "BKE_main.hh"
56#include "BKE_material.hh"
57#include "BKE_mball.hh"
58#include "BKE_mesh.hh"
59#include "BKE_modifier.hh"
60#include "BKE_node_runtime.hh"
61#include "BKE_object.hh"
62#include "BKE_paint.hh"
63#include "BKE_particle.h"
64#include "BKE_pointcache.h"
65#include "BKE_report.hh"
66#include "BKE_scene.hh"
67#include "BKE_screen.hh"
68#include "BKE_softbody.h"
69#include "BKE_workspace.hh"
70
71#include "DEG_depsgraph.hh"
73
74#include "ED_anim_api.hh"
75#include "ED_armature.hh"
76#include "ED_asset.hh"
78#include "ED_curve.hh"
79#include "ED_gpencil_legacy.hh"
80#include "ED_grease_pencil.hh"
81#include "ED_image.hh"
83#include "ED_lattice.hh"
84#include "ED_mball.hh"
85#include "ED_mesh.hh"
86#include "ED_object.hh"
87#include "ED_outliner.hh"
88#include "ED_screen.hh"
89#include "ED_undo.hh"
90
91#include "RNA_access.hh"
92#include "RNA_define.hh"
93#include "RNA_enum_types.hh"
94#include "RNA_types.hh"
95
96#include "UI_interface.hh"
97#include "UI_interface_icons.hh"
99
100#include "CLG_log.h"
101
102/* For menu/popup icons etc. */
103
104#include "UI_resources.hh"
105
106#include "WM_api.hh"
107#include "WM_message.hh"
108#include "WM_toolsystem.hh"
109#include "WM_types.hh"
110
111#include "MOD_nodes.hh"
112
113#include "object_intern.hh" /* own include */
114
115namespace blender::ed::object {
116
117static CLG_LogRef LOG = {"object.edit"};
118
119/* prototypes */
120static ListBaseT<LinkData> selected_objects_get(bContext *C);
121
122/* -------------------------------------------------------------------- */
125
127{
128 /* NOTE(@ideasman42): toggling modes while transforming should not be allowed by the key-map,
129 * so users should not be able do this. Python scripts can though,
130 * so check here to report an error instead of crashing.
131 *
132 * This is *not* a comprehensive check, since users might be trying to change modes
133 * while in the middle of *any* modal operator (painting or dragging a UI slider... etc).
134 *
135 * This check could be removed if it causes any problems since the error it prevents
136 * is quite obscure. See: #137380. */
137
138 if (G.moving & (G_TRANSFORM_OBJ | G_TRANSFORM_EDIT)) {
139 BKE_reportf(reports, RPT_ERROR, "Unable to change object mode while transforming");
140 return false;
141 }
142
143 return true;
144}
145
147{
148 return static_cast<Object *>(CTX_data_pointer_get_type(C, "object", RNA_Object).data);
149}
150
152{
153 Object *ob = nullptr;
154 if (C) {
155 ob = context_object(C);
156 if (!ob) {
158 }
159 }
160 return ob;
161}
162
164 bool (*filter_fn)(const Object *ob, void *user_data),
165 void *filter_user_data)
166{
167 ScrArea *area = CTX_wm_area(C);
168 const Main *bmain = CTX_data_main(C);
169 const Scene *scene = CTX_data_scene(C);
170 ViewLayer *view_layer = CTX_data_view_layer(C);
171 BKE_view_layer_synced_ensure(*bmain, scene, view_layer);
172 Object *ob_active = BKE_view_layer_active_object_get(view_layer);
173 ID *id_pin = nullptr;
174 const bool use_objects_in_mode = (ob_active != nullptr) &&
175 (ob_active->mode & (OB_MODE_EDIT | OB_MODE_POSE));
176 const eSpace_Type space_type = area ? eSpace_Type(area->spacetype) : SPACE_EMPTY;
177
178 Object *ob = nullptr;
179 bool use_ob = true;
180
181 if (space_type == SPACE_PROPERTIES) {
182 SpaceProperties *sbuts = area->spacedata.first_as<SpaceProperties>();
183 id_pin = sbuts->pinid;
184 }
185
186 if (id_pin && (id_pin->id_type() == ID_OB)) {
187 /* Pinned data takes priority, in this case ignore selection & other objects in the mode. */
188 ob = id_cast<Object *>(id_pin);
189 }
190 else if ((space_type == SPACE_PROPERTIES) && (use_objects_in_mode == false)) {
191 /* When using the space-properties, we don't want to use the entire selection
192 * as the current active object may not be selected.
193 *
194 * This is not the case when we're in a mode that supports multi-mode editing,
195 * since the active object and all other objects in the mode will be included
196 * irrespective of selection. */
197 ob = ob_active;
198 }
199 else if (ob_active && (ob_active->mode & (OB_MODE_ALL_PAINT_MESH | OB_MODE_ALL_PAINT_GPENCIL))) {
200 /* When painting, limit to active. */
201 ob = ob_active;
202 }
203 else {
204 /* Otherwise use full selection. */
205 use_ob = false;
206 }
207
208 if (use_ob) {
209 if ((ob != nullptr) && !filter_fn(ob, filter_user_data)) {
210 ob = nullptr;
211 }
212 return ob ? Vector<Object *>({ob}) : Vector<Object *>();
213 }
214 const View3D *v3d = (space_type == SPACE_VIEW3D) ? area->spacedata.first_as<View3D>() : nullptr;
215
216 /* When in a mode that supports multiple active objects, use "objects in mode"
217 * instead of the object's selection. */
218 if (use_objects_in_mode) {
219 ObjectsInModeParams params = {0};
220 params.object_mode = ob_active->mode;
221 params.no_dup_data = true;
222 params.filter_fn = filter_fn;
223 params.filter_userdata = filter_user_data;
225 *bmain, scene, view_layer, v3d, &params);
226 }
227
229 params.no_dup_data = true;
230 params.filter_fn = filter_fn;
231 params.filter_userdata = filter_user_data;
232 return BKE_view_layer_array_selected_objects_params(view_layer, v3d, &params);
233}
234
236
237/* -------------------------------------------------------------------- */
240
242 const Scene *scene,
243 ViewLayer *view_layer,
244 const eObjectMode mode,
245 const Object *ob)
246{
247 BLI_assert(ob != nullptr);
248 /* NOTE: the `v3d` is always nullptr because the purpose of this function is to return
249 * a reusable index, using the `v3d` only increases the chance the index may become
250 * invalid-parameters. */
251 int index = -1;
252 int i = 0;
253 FOREACH_BASE_IN_MODE_BEGIN (&bmain, scene, view_layer, nullptr, -1, mode, base_iter) {
254 if (base_iter->object == ob) {
255 index = i;
256 break;
257 }
258 i++;
259 }
261 return index;
262}
263
265 const Scene *scene,
266 ViewLayer *view_layer,
267 const eObjectMode mode,
268 int index)
269{
270 BLI_assert(index >= 0);
271 Object *ob = nullptr;
272 int i = 0;
273 FOREACH_BASE_IN_MODE_BEGIN (&bmain, scene, view_layer, nullptr, -1, mode, base_iter) {
274 if (index == i) {
275 ob = base_iter->object;
276 break;
277 }
278 i++;
279 }
281 return ob;
282}
283
285
286/* -------------------------------------------------------------------- */
289
291{
292 if (CTX_wm_space_outliner(C) != nullptr) {
294 }
296}
297
299{
300 const Main *bmain = CTX_data_main(C);
301 Scene *scene = CTX_data_scene(C);
302 ViewLayer *view_layer = CTX_data_view_layer(C);
303 const View3D *v3d = CTX_wm_view3d(C);
304 const bool select = RNA_boolean_get(op->ptr, "select");
305 bool changed = false;
306
307 BKE_view_layer_synced_ensure(*bmain, scene, view_layer);
308 for (Base &base : *BKE_view_layer_object_bases_get(view_layer)) {
309 if (v3d && v3d->localvd && (base.local_view_bits & v3d->local_view_uid) == 0) {
310 continue;
311 }
312
313 if (base.flag & BASE_HIDDEN) {
314 base.flag &= ~BASE_HIDDEN;
315 changed = true;
316
317 if (select) {
318 /* We cannot call `base_select` because
319 * base is not selectable while it is hidden. */
320 base.flag |= BASE_SELECTED;
322 }
323 }
324 }
325
326 if (!changed) {
327 return OPERATOR_CANCELLED;
328 }
329
334
335 return OPERATOR_FINISHED;
336}
337
339{
340 /* identifiers */
341 ot->name = "Show Hidden Objects";
342 ot->description = "Reveal temporarily hidden objects";
343 ot->idname = "OBJECT_OT_hide_view_clear";
344
345 /* API callbacks. */
348
349 /* flags */
351
352 RNA_def_boolean(ot->srna, "select", true, "Select", "Select revealed objects");
353}
354
356{
357 const Main *bmain = CTX_data_main(C);
358 Scene *scene = CTX_data_scene(C);
359 ViewLayer *view_layer = CTX_data_view_layer(C);
360 const View3D *v3d = CTX_wm_view3d(C);
361 const bool unselected = RNA_boolean_get(op->ptr, "unselected");
362 bool changed = false;
363 const bool confirm = op->flag & OP_IS_INVOKE;
364 uint hide_count = 0;
365
366 /* Hide selected or unselected objects. */
367 BKE_view_layer_synced_ensure(*bmain, scene, view_layer);
368 for (Base &base : *BKE_view_layer_object_bases_get(view_layer)) {
369 if (!BKE_base_is_visible(v3d, &base)) {
370 continue;
371 }
372
373 if (!unselected) {
374 if (base.flag & BASE_SELECTED) {
375 base_select(&base, BA_DESELECT);
376 base.flag |= BASE_HIDDEN;
377 hide_count++;
378 changed = true;
379 }
380 }
381 else {
382 if (!(base.flag & BASE_SELECTED)) {
383 base_select(&base, BA_DESELECT);
384 base.flag |= BASE_HIDDEN;
385 hide_count++;
386 changed = true;
387 }
388 }
389 }
390 if (!changed) {
391 return OPERATOR_CANCELLED;
392 }
393
394 if (hide_count > 0 && confirm) {
395 BKE_reportf(op->reports, RPT_INFO, "%u object(s) hidden", (hide_count));
396 }
397
402
403 return OPERATOR_FINISHED;
404}
405
407{
408 /* identifiers */
409 ot->name = "Hide Objects";
410 ot->description = "Temporarily hide objects from the viewport";
411 ot->idname = "OBJECT_OT_hide_view_set";
412
413 /* API callbacks. */
416
417 /* flags */
419
420 PropertyRNA *prop;
421 prop = RNA_def_boolean(
422 ot->srna, "unselected", false, "Unselected", "Hide unselected rather than selected objects");
424}
425
427{
428 View3D *v3d = CTX_wm_view3d(C);
429
430 int index = RNA_int_get(op->ptr, "collection_index");
431 const bool extend = RNA_boolean_get(op->ptr, "extend");
432 const bool toggle = RNA_boolean_get(op->ptr, "toggle");
433
434 Main *bmain = CTX_data_main(C);
435 Scene *scene = CTX_data_scene(C);
436 ViewLayer *view_layer = CTX_data_view_layer(C);
438
439 if (!lc) {
440 return OPERATOR_CANCELLED;
441 }
442
444
445 if (v3d && v3d->flag & V3D_LOCAL_COLLECTIONS) {
447 return OPERATOR_CANCELLED;
448 }
449 if (toggle) {
451 BKE_layer_collection_local_sync(*bmain, scene, view_layer, v3d);
452 }
453 else {
454 BKE_layer_collection_isolate_local(*bmain, scene, view_layer, v3d, lc, extend);
455 }
456 }
457 else {
458 BKE_layer_collection_isolate_global(scene, view_layer, lc, extend);
459 }
460
462
463 return OPERATOR_FINISHED;
464}
465
466#define COLLECTION_INVALID_INDEX -1
467
469{
470 const Main *bmain = CTX_data_main(C);
471 const Scene *scene = CTX_data_scene(C);
472 ViewLayer *view_layer = CTX_data_view_layer(C);
473 LayerCollection *lc_scene = view_layer->layer_collections.first();
474
475 /* Use the "invoke" operator context so the "Shift" modifier is used to extend. */
477
478 for (LayerCollection &lc : lc_scene->layer_collections) {
479 int index = BKE_layer_collection_findindex(view_layer, &lc);
480 ui::Layout &row = layout.row(false);
481
483 continue;
484 }
485
487 continue;
488 }
489
490 int icon = ICON_NONE;
491 if (BKE_layer_collection_has_selected_objects(*bmain, scene, view_layer, &lc)) {
492 icon = ICON_LAYER_ACTIVE;
493 }
495 icon = ICON_LAYER_USED;
496 }
497 PointerRNA op_ptr = row.op("OBJECT_OT_hide_collection", lc.collection->id.name + 2, icon);
498 RNA_int_set(&op_ptr, "collection_index", index);
499 }
500}
501
503 wmOperator *op,
504 const wmEvent *event)
505{
506 /* Immediately execute if collection index was specified. */
507 int index = RNA_int_get(op->ptr, "collection_index");
509 /* Only initialize extend from the shift key if the property isn't set
510 * (typically initialized from the key-map). */
511 PropertyRNA *prop = RNA_struct_find_property(op->ptr, "extend");
512 if (!RNA_property_is_set(op->ptr, prop)) {
513 RNA_property_boolean_set(op->ptr, prop, (event->modifier & KM_SHIFT) != 0);
514 }
515 return object_hide_collection_exec(C, op);
516 }
517
518 /* Open popup menu. */
519 const char *title = CTX_IFACE_(op->type->translation_context, op->type->name);
520 ui::PopupMenu *pup = ui::popup_menu_begin(C, title, ICON_OUTLINER_COLLECTION);
521 ui::Layout &layout = *popup_menu_layout(pup);
522
524
525 popup_menu_end(C, pup);
526
527 return OPERATOR_INTERFACE;
528}
529
531{
532 /* identifiers */
533 ot->name = "Hide Other Collections";
534 ot->description = "Show only objects in collection (Shift to extend)";
535 ot->idname = "OBJECT_OT_hide_collection";
536
537 /* API callbacks. */
540
541 /* flags */
543
544 /* Properties. */
545 PropertyRNA *prop;
546 prop = RNA_def_int(ot->srna,
547 "collection_index",
550 INT_MAX,
551 "Collection Index",
552 "Index of the collection to change visibility",
553 0,
554 INT_MAX);
556 prop = RNA_def_boolean(ot->srna, "toggle", false, "Toggle", "Toggle visibility");
558 prop = RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend visibility");
560}
561
563
564/* -------------------------------------------------------------------- */
567
568/* When switching mode, certain data needs to be copied from the `bPoseChannel` to the `Bone`. This
569 * is not done in `BKE_pose_rebuild` because that is called in other cases other than mode
570 * switching. */
572{
573 BLI_assert(ob.pose);
574 for (bPoseChannel &pose_bone : ob.pose->chanbase) {
576 const Bone *bone = pose_bone.bone_get(ob);
577 if (bone->flag & BONE_ROOTSEL) {
578 pose_bone.flag |= POSE_SELECTED_ROOT;
579 }
580 if (bone->flag & BONE_TIPSEL) {
581 pose_bone.flag |= POSE_SELECTED_TIP;
582 }
583 if (bone->flag & BONE_SELECTED) {
584 pose_bone.flag |= POSE_SELECTED;
585 }
586 }
587}
588
590{
591 BLI_assert(ob.pose);
592 for (bPoseChannel &pose_bone : ob.pose->chanbase) {
593 Bone *bone = pose_bone.bone_get(ob);
595 if (pose_bone.flag & POSE_SELECTED_ROOT) {
596 bone->flag |= BONE_ROOTSEL;
597 }
598 if (pose_bone.flag & POSE_SELECTED_TIP) {
599 bone->flag |= BONE_TIPSEL;
600 }
601 if (pose_bone.flag & POSE_SELECTED) {
602 bone->flag |= BONE_SELECTED;
603 }
604 }
605}
606
607static bool mesh_needs_keyindex(Main *bmain, const Mesh *mesh)
608{
609 if (mesh->key) {
610 return false; /* will be added */
611 }
612
613 for (const Object &ob : bmain->objects) {
614 if ((ob.parent) && (ob.parent->data == id_cast<const ID *>(mesh)) &&
616 {
617 return true;
618 }
619 if (ob.data == id_cast<const ID *>(mesh)) {
620 for (const ModifierData &md : ob.modifiers) {
621 if (md.type == eModifierType_Hook) {
622 return true;
623 }
624 }
625 }
626 }
627 return false;
628}
629
636static bool editmode_load_free_ex(Main *bmain,
637 Object *obedit,
638 const bool load_data,
639 const bool free_data)
640{
641 BLI_assert(load_data || free_data);
642
643 if (obedit == nullptr) {
644 return false;
645 }
646
647 if (obedit->type == OB_MESH) {
648 Mesh *mesh = id_cast<Mesh *>(obedit->data);
649 if (mesh->runtime->edit_mesh == nullptr) {
650 return false;
651 }
653 if (bm->totvert > MESH_MAX_VERTS) {
654 /* This used to be warned int the UI, we could warn again although it's quite rare. */
655 CLOG_WARN(&LOG, "Too many vertices for mesh '%s' (%d)", mesh->id.name + 2, bm->totvert);
656 return false;
657 }
658
659 if (load_data) {
660 EDBM_mesh_load_ex(bmain, obedit, free_data);
661 }
662
663 if (free_data) {
664 EDBM_mesh_free_data(mesh->runtime->edit_mesh.get());
665 mesh->runtime->edit_mesh.reset();
666 }
667 /* will be recalculated as needed. */
668 {
671 }
672 }
673 else if (obedit->type == OB_ARMATURE) {
674 const bArmature *arm = id_cast<const bArmature *>(obedit->data);
675 if (arm->edbo == nullptr) {
676 return false;
677 }
678
679 if (load_data) {
680 ED_armature_from_edit(bmain, id_cast<bArmature *>(obedit->data));
681 }
682
683 if (free_data) {
684 ED_armature_edit_free(id_cast<bArmature *>(obedit->data));
685
686 if (load_data == false) {
687 /* Don't keep unused pose channels created by duplicating bones
688 * which may have been deleted/undone, see: #87631. */
689 if (obedit->pose != nullptr) {
691 }
692 }
693 }
694
695 /* After regenerating the bones, sync the selection onto the pose bones. */
697 /* TODO(sergey): Pose channels might have been changed, so need
698 * to inform dependency graph about this. But is it really the
699 * best place to do this?
700 */
702 }
703 else if (ELEM(obedit->type, OB_CURVES_LEGACY, OB_SURF)) {
704 const Curve *cu = id_cast<const Curve *>(obedit->data);
705 if (cu->editnurb == nullptr) {
706 return false;
707 }
708
709 if (load_data) {
710 ED_curve_editnurb_load(bmain, obedit);
711 }
712
713 if (free_data) {
715 }
716 }
717 else if (obedit->type == OB_FONT) {
718 const Curve *cu = id_cast<const Curve *>(obedit->data);
719 if (cu->editfont == nullptr) {
720 return false;
721 }
722
723 if (load_data) {
725 }
726
727 if (free_data) {
729 }
730 }
731 else if (obedit->type == OB_LATTICE) {
732 const Lattice *lt = id_cast<const Lattice *>(obedit->data);
733 if (lt->editlatt == nullptr) {
734 return false;
735 }
736
737 if (load_data) {
738 BKE_editlattice_load(obedit);
739 }
740
741 if (free_data) {
742 BKE_editlattice_free(obedit);
743 }
744 }
745 else if (obedit->type == OB_MBALL) {
746 const MetaBall *mb = id_cast<const MetaBall *>(obedit->data);
747 if (mb->editelems == nullptr) {
748 return false;
749 }
750
751 if (load_data) {
753 }
754
755 if (free_data) {
757 }
758 }
759 else if (ELEM(obedit->type, OB_CURVES, OB_GREASE_PENCIL, OB_POINTCLOUD)) {
760 /* Object doesn't have specific edit mode data, so pass. */
761 }
762 else {
763 return false;
764 }
765
766 if (load_data) {
767 char *needs_flush_ptr = BKE_object_data_editmode_flush_ptr_get(obedit->data);
768 if (needs_flush_ptr) {
769 *needs_flush_ptr = false;
770 }
771 }
772
773 return true;
774}
775
776bool editmode_load(Main *bmain, Object *obedit)
777{
778 return editmode_load_free_ex(bmain, obedit, true, false);
779}
780
781bool editmode_exit_ex(Main *bmain, Scene *scene, Object *obedit, int flag)
782{
783 const bool free_data = (flag & EM_FREEDATA) != 0;
784
785 if (editmode_load_free_ex(bmain, obedit, true, free_data) == false) {
786 /* in rare cases (background mode) its possible active object
787 * is flagged for editmode, without 'obedit' being set #35489. */
788 if (obedit && obedit->mode & OB_MODE_EDIT) [[unlikely]] {
789 obedit->mode &= ~OB_MODE_EDIT;
790 /* Also happens when mesh is shared across multiple objects. #69834. */
792 /* Leaving edit mode may modify the original object data; tag that as well. */
794 }
795 return true;
796 }
797
798 /* `free_data` only false now on file saves and render. */
799 if (free_data) {
800 /* flag object caches as outdated */
801 ListBaseT<PTCacheID> pidlist;
802 BKE_ptcache_ids_from_object(&pidlist, obedit, scene, 0);
803 for (PTCacheID &pid : pidlist) {
804 /* particles don't need reset on geometry change */
805 if (pid.type != PTCACHE_TYPE_PARTICLES) {
806 pid.cache->flag |= PTCACHE_OUTDATED;
807 }
808 }
809 pidlist.free_no_destruct();
810
813
814 /* also flush ob recalc, doesn't take much overhead, but used for particles */
816 /* Leaving edit mode may modify the original object data; tag that as well. */
818
820
821 obedit->mode &= ~OB_MODE_EDIT;
822 }
823
824 return (obedit->mode & OB_MODE_EDIT) == 0;
825}
826
827bool editmode_exit(bContext *C, int flag)
828{
829 Main *bmain = CTX_data_main(C);
830 Scene *scene = CTX_data_scene(C);
831 Object *obedit = CTX_data_edit_object(C);
832 return editmode_exit_ex(bmain, scene, obedit, flag);
833}
834
835bool editmode_free_ex(Main *bmain, Object *obedit)
836{
837 return editmode_load_free_ex(bmain, obedit, false, true);
838}
839
840bool editmode_exit_multi_ex(Main *bmain, Scene *scene, ViewLayer *view_layer, int flag)
841{
842 BKE_view_layer_synced_ensure(*bmain, scene, view_layer);
843 Object *obedit = BKE_view_layer_edit_object_get(view_layer);
844 if (obedit == nullptr) {
845 return false;
846 }
847 bool changed = false;
848 const short obedit_type = obedit->type;
849
850 BKE_view_layer_synced_ensure(*bmain, scene, view_layer);
851 for (Base &base : *BKE_view_layer_object_bases_get(view_layer)) {
852 Object *ob = base.object;
853 if ((ob->type == obedit_type) && (ob->mode & OB_MODE_EDIT)) {
854 changed |= editmode_exit_ex(bmain, scene, base.object, flag);
855 }
856 }
857 return changed;
858}
859
861{
862 Main *bmain = CTX_data_main(C);
863 Scene *scene = CTX_data_scene(C);
864 ViewLayer *view_layer = CTX_data_view_layer(C);
865 return editmode_exit_multi_ex(bmain, scene, view_layer, flag);
866}
867
868bool editmode_enter_ex(Main *bmain, Scene *scene, Object *ob, int flag)
869{
870 bool ok = false;
871
872 if (ELEM(nullptr, ob, ob->data) || !ID_IS_EDITABLE(ob) || !ID_IS_EDITABLE(ob->data) ||
874 {
875 return false;
876 }
877
878 /* This checks actual `ob->data`, for cases when other scenes have it in edit-mode context.
879 * Currently multiple objects sharing a mesh being in edit-mode at once isn't supported,
880 * see: #86767. */
882 return true;
883 }
884
886 /* Ideally the caller should check this. */
887 CLOG_WARN(&LOG, "Unable to enter edit-mode on library data for object '%s'", ob->id.name + 2);
888 return false;
889 }
890
891 ob->restore_mode = ob->mode;
892
893 ob->mode = OB_MODE_EDIT;
894
895 if (ob->type == OB_MESH) {
896 ok = true;
897
898 const bool use_key_index = mesh_needs_keyindex(bmain, id_cast<const Mesh *>(ob->data));
899
900 EDBM_mesh_make(ob, scene->toolsettings->selectmode, use_key_index);
901
903 if (em) [[likely]] {
905 }
906
908 }
909 else if (ob->type == OB_ARMATURE) {
910 /* Syncing the selection to the `Bone` before converting to edit bones. This is not possible if
911 * the Armature was just created, because then there is no pose data yet. Which is fine, the
912 * just-created edit bones already have the expected selection state. */
913 if (ob->pose) {
915 }
916
917 bArmature *arm = id_cast<bArmature *>(ob->data);
918 ok = true;
920 /* To ensure all goes in rest-position and without striding. */
921
922 arm->needs_flush_to_id = 0;
923
924 /* WORKAROUND / FIXME: this is a temporary workaround to ensure that
925 * full bone collection data gets restored when exiting edit mode
926 * via an undo step. The correct fix is to have a full edit-mode
927 * copy of bone collections so that edit-mode changes don't modify
928 * object-mode armature data until exiting edit mode. But that
929 * change is a bit of a project, and will be done later. This line
930 * should be removed when that is done. */
931 bmain->is_memfile_undo_written = false;
932
933 /* XXX: should this be ID_RECALC_GEOMETRY? */
935
937 }
938 else if (ob->type == OB_FONT) {
939 ok = true;
941
943 }
944 else if (ob->type == OB_MBALL) {
945 MetaBall *mb = id_cast<MetaBall *>(ob->data);
946
947 ok = true;
949
950 mb->needs_flush_to_id = 0;
951
953 }
954 else if (ob->type == OB_LATTICE) {
955 ok = true;
957
959 }
960 else if (ELEM(ob->type, OB_SURF, OB_CURVES_LEGACY)) {
961 ok = true;
963
965 }
966 else if (ob->type == OB_CURVES) {
967 ok = true;
969 }
970 else if (ob->type == OB_GREASE_PENCIL) {
971 ok = true;
974 }
975 else if (ob->type == OB_POINTCLOUD) {
976 ok = true;
978 }
979
980 if (ok) {
982 }
983 else {
984 if ((flag & EM_NO_CONTEXT) == 0) {
985 ob->mode &= ~OB_MODE_EDIT;
986 }
988 }
989
990 return (ob->mode & OB_MODE_EDIT) != 0;
991}
992
993bool editmode_enter(bContext *C, int flag)
994{
995 Main *bmain = CTX_data_main(C);
996 Scene *scene = CTX_data_scene(C);
997
998 /* Active layer checked here for view3d,
999 * callers that don't want view context can call the extended version. */
1001 return editmode_enter_ex(bmain, scene, ob, flag);
1002}
1003
1005{
1006 Main *bmain = CTX_data_main(C);
1007 Scene *scene = CTX_data_scene(C);
1008 View3D *v3d = CTX_wm_view3d(C);
1009 ViewLayer *view_layer = CTX_data_view_layer(C);
1010 BKE_view_layer_synced_ensure(*bmain, scene, view_layer);
1011 Object *obact = BKE_view_layer_active_object_get(view_layer);
1012 const int mode_flag = OB_MODE_EDIT;
1013 const bool is_mode_set = (obact->mode & mode_flag) != 0;
1014 wmMsgBus *mbus = CTX_wm_message_bus(C);
1015
1017 return OPERATOR_CANCELLED;
1018 }
1019 if (!is_mode_set) {
1020 if (!mode_compat_set(C, obact, eObjectMode(mode_flag), op->reports)) {
1021 return OPERATOR_CANCELLED;
1022 }
1023 }
1024
1025 if (!is_mode_set) {
1026 editmode_enter_ex(bmain, scene, obact, 0);
1027 /* Grease Pencil does not support multi-object editing. */
1028 if ((obact->type != OB_GREASE_PENCIL) && ((obact->mode & mode_flag) != 0)) {
1029 FOREACH_SELECTED_OBJECT_BEGIN (view_layer, v3d, ob) {
1030 if ((ob != obact) && (ob->type == obact->type)) {
1031 editmode_enter_ex(bmain, scene, ob, EM_NO_CONTEXT);
1032 }
1033 }
1035 }
1036 }
1037 else {
1038 editmode_exit_ex(bmain, scene, obact, EM_FREEDATA);
1039
1040 if ((obact->mode & mode_flag) == 0) {
1041 FOREACH_OBJECT_BEGIN (bmain, scene, view_layer, ob) {
1042 if ((ob != obact) && (ob->type == obact->type)) {
1043 editmode_exit_ex(bmain, scene, ob, EM_FREEDATA);
1044 }
1045 }
1047 }
1048 }
1049
1050 WM_msg_publish_rna_prop(mbus, &obact->id, obact, Object, mode);
1051
1052 if (G.background == false) {
1054 }
1055
1056 return OPERATOR_FINISHED;
1057}
1058
1060{
1061 /* Get object the same way as in editmode_toggle_exec(). Otherwise overriding context can crash,
1062 * see #137998. */
1063 const Main *bmain = CTX_data_main(C);
1064 ViewLayer *view_layer = CTX_data_view_layer(C);
1065 BKE_view_layer_synced_ensure(*bmain, CTX_data_scene(C), view_layer);
1066 Object *ob = BKE_view_layer_active_object_get(view_layer);
1067
1068 /* Covers liboverrides too. */
1069 if (ELEM(nullptr, ob, ob->data) || !ID_IS_EDITABLE(ob) || !ID_IS_EDITABLE(ob->data) ||
1071 {
1072 return false;
1073 }
1074
1075 /* If hidden but in edit mode, we still display. */
1076 if ((ob->visibility_flag & OB_HIDE_VIEWPORT) && !(ob->mode & OB_MODE_EDIT)) {
1077 return false;
1078 }
1079
1080 return OB_TYPE_SUPPORT_EDITMODE(ob->type);
1081}
1082
1084{
1085
1086 /* identifiers */
1087 ot->name = "Edit Mode";
1088 ot->description = "Toggle object's edit mode";
1089 ot->idname = "OBJECT_OT_editmode_toggle";
1090
1091 /* API callbacks. */
1094
1095 /* flags */
1097}
1098
1100
1101/* -------------------------------------------------------------------- */
1104
1106{
1107 wmMsgBus *mbus = CTX_wm_message_bus(C);
1108 Main *bmain = CTX_data_main(C);
1109 Scene *scene = CTX_data_scene(C);
1110 ViewLayer *view_layer = CTX_data_view_layer(C);
1111 Base *base = CTX_data_active_base(C);
1112
1114 return OPERATOR_CANCELLED;
1115 }
1116
1117 /* If the base is nullptr it means we have an active object, but the object itself is hidden. */
1118 if (base == nullptr) {
1119 return OPERATOR_CANCELLED;
1120 }
1121
1122 Object *obact = base->object;
1123 const int mode_flag = OB_MODE_POSE;
1124 bool is_mode_set = (obact->mode & mode_flag) != 0;
1125
1126 if (!is_mode_set) {
1127 if (!mode_compat_set(C, obact, eObjectMode(mode_flag), op->reports)) {
1128 return OPERATOR_CANCELLED;
1129 }
1130 }
1131
1132 if (obact->type != OB_ARMATURE) {
1133 return OPERATOR_PASS_THROUGH;
1134 }
1135
1136 {
1137 BKE_view_layer_synced_ensure(*bmain, scene, view_layer);
1138 Object *obedit = BKE_view_layer_edit_object_get(view_layer);
1139 if (obact == obedit) {
1140 editmode_exit_ex(bmain, scene, obedit, EM_FREEDATA);
1141 is_mode_set = false;
1142 }
1143 }
1144
1145 if (is_mode_set) {
1146 bool ok = ED_object_posemode_exit(C, obact);
1147 if (ok) {
1148 FOREACH_OBJECT_BEGIN (bmain, scene, view_layer, ob) {
1149 if ((ob != obact) && (ob->type == OB_ARMATURE) && (ob->mode & mode_flag)) {
1150 ED_object_posemode_exit_ex(bmain, ob);
1151 }
1152 }
1154 }
1155 }
1156 else {
1157 bool ok = ED_object_posemode_enter(C, obact);
1158 if (ok) {
1159 const View3D *v3d = CTX_wm_view3d(C);
1160 FOREACH_SELECTED_OBJECT_BEGIN (view_layer, v3d, ob) {
1161 if ((ob != obact) && (ob->type == OB_ARMATURE) && (ob->mode == OB_MODE_OBJECT) &&
1162 BKE_id_is_editable(bmain, &ob->id))
1163 {
1164 ED_object_posemode_enter_ex(bmain, ob);
1165 }
1166 }
1168 }
1169 }
1170
1171 WM_msg_publish_rna_prop(mbus, &obact->id, obact, Object, mode);
1172
1173 if (G.background == false) {
1175 }
1176
1177 return OPERATOR_FINISHED;
1178}
1179
1181{
1182 /* identifiers */
1183 ot->name = "Toggle Pose Mode";
1184 ot->idname = "OBJECT_OT_posemode_toggle";
1185 ot->description = "Enable or disable posing/selecting bones";
1186
1187 /* API callbacks. */
1188 ot->exec = posemode_exec;
1190
1191 /* flag */
1193}
1194
1196
1197/* -------------------------------------------------------------------- */
1200
1201void check_force_modifiers(Main *bmain, Scene *scene, Object *object)
1202{
1203 PartDeflect *pd = object->pd;
1205
1206 /* add/remove modifier as needed */
1207 if (!md) {
1208 if (pd && (pd->shape == PFIELD_SHAPE_SURFACE) &&
1210 {
1212 modifier_add(nullptr, bmain, scene, object, nullptr, eModifierType_Surface);
1213 }
1214 }
1215 }
1216 else {
1217 if (!pd || (pd->shape != PFIELD_SHAPE_SURFACE) ||
1219 {
1220 modifier_remove(nullptr, bmain, scene, object, md);
1221 }
1222 }
1223}
1224
1226{
1228
1229 if (ob->pd == nullptr) {
1232 }
1233 else if (ob->pd->forcefield == 0) {
1234 ob->pd->forcefield = PFIELD_FORCE;
1236 }
1237 else {
1238 ob->pd->forcefield = ePFieldType{};
1239 }
1240
1244
1246
1247 return OPERATOR_FINISHED;
1248}
1249
1251{
1252
1253 /* identifiers */
1254 ot->name = "Toggle Force Field";
1255 ot->description = "Toggle object's force field";
1256 ot->idname = "OBJECT_OT_forcefield_toggle";
1257
1258 /* API callbacks. */
1261
1262 /* flags */
1264}
1265
1267
1268/* -------------------------------------------------------------------- */
1271
1273{
1274 return (ob->avs.path_bakeflag & MOTIONPATH_BAKE_HAS_PATHS) != 0;
1275}
1276
1278{
1279 return ob->pose && (ob->pose->avs.path_bakeflag & MOTIONPATH_BAKE_HAS_PATHS) != 0;
1280}
1281
1283{
1284 BLI_assert(C != nullptr);
1285 Main *bmain = CTX_data_main(C);
1286 ViewLayer *view_layer = CTX_data_view_layer(C);
1287
1288 Vector<MPathTarget> targets;
1289 for (Object *ob : objects) {
1290 /* set flag to force recalc, then grab path(s) from object */
1291 if (has_object_motion_paths(ob)) {
1292 ob->avs.recalc |= ANIMVIZ_RECALC_PATHS;
1293 }
1294
1295 if (has_pose_motion_paths(ob)) {
1296 ob->pose->avs.recalc |= ANIMVIZ_RECALC_PATHS;
1297 }
1298
1300 }
1301
1302 Depsgraph *depsgraph = animviz_depsgraph_build(bmain, scene, view_layer, targets);
1303
1304 animviz_calc_motionpaths(depsgraph, scene, targets, BKE_scene_frame_get(scene));
1305
1306 /* Tag objects for copy-on-eval - so paths will draw/redraw
1307 * For currently frame only we update evaluated object directly. */
1308 for (Object *ob : objects) {
1311 }
1312 }
1313
1314 /* Free temporary depsgraph. */
1315 DEG_graph_free(depsgraph);
1316}
1317
1318/* show popup to determine settings */
1320 wmOperator *op,
1321 const wmEvent * /*event*/)
1322{
1324
1325 /* set default settings from existing/stored settings */
1326 {
1327 bAnimVizSettings *avs = &ob->avs;
1328 RNA_enum_set(op->ptr, "display_type", avs->path_type);
1329 RNA_enum_set(op->ptr, "range", avs->path_range);
1330 }
1331
1332 /* show popup dialog to allow editing of range... */
1333 /* FIXME: hard-coded dimensions here are just arbitrary. */
1335 C, op, 270, IFACE_("Calculate Object Motion Paths"), IFACE_("Calculate"));
1336}
1337
1338/* Calculate/recalculate whole paths (avs.path_sf to avs.path_ef) */
1340{
1341 Scene *scene = CTX_data_scene(C);
1342 eMotionPaths_Types path_type = eMotionPaths_Types(RNA_enum_get(op->ptr, "display_type"));
1343 eMotionPath_Ranges path_range = eMotionPath_Ranges(RNA_enum_get(op->ptr, "range"));
1344
1345 Vector<Object *> selected_objects;
1346 /* set up path data for objects being calculated */
1347 CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) {
1348 bAnimVizSettings *avs = &ob->avs;
1349 /* grab baking settings from operator settings */
1350 avs->path_type = path_type;
1351 avs->path_range = path_range;
1353
1354 /* verify that the selected object has the appropriate settings */
1355 bke::motionpath::ensure(op->reports, scene, ob, nullptr);
1356 if (ob->mpath) {
1358 selected_objects.append(ob);
1359 }
1360 }
1362
1363 /* calculate the paths for objects that have them (and are tagged to get refreshed) */
1364 motion_paths_recalc(C, scene, selected_objects);
1365
1366 /* notifiers for updates */
1368 /* NOTE: the notifier below isn't actually correct, but kept around just to be on the safe side.
1369 * If further testing shows it's not necessary (for both bones and objects) removal is fine. */
1371
1372 return OPERATOR_FINISHED;
1373}
1374
1376{
1377 /* identifiers */
1378 ot->name = "Calculate Object Motion Paths";
1379 ot->idname = "OBJECT_OT_paths_calculate";
1380 ot->description = "Generate motion paths for the selected objects";
1381
1382 /* API callbacks. */
1386
1387 /* flags */
1389
1390 /* properties */
1391 RNA_def_enum(ot->srna,
1392 "display_type",
1395 "Display Type",
1396 "");
1397 RNA_def_enum(ot->srna,
1398 "range",
1401 "Computation Range",
1402 "");
1403}
1404
1406
1407/* -------------------------------------------------------------------- */
1410
1412{
1415 return (ob->avs.path_bakeflag & MOTIONPATH_BAKE_HAS_PATHS) != 0;
1416 }
1417
1418 return false;
1419}
1420
1422{
1423 Scene *scene = CTX_data_scene(C);
1424
1425 if (scene == nullptr) {
1426 return OPERATOR_CANCELLED;
1427 }
1428 Vector<Object *> selected_objects;
1429 CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) {
1431 /* verify that the selected object has the appropriate settings */
1432 bke::motionpath::ensure(op->reports, scene, ob, nullptr);
1433 if (ob->mpath) {
1435 selected_objects.append(ob);
1436 }
1437 }
1439
1440 /* calculate the paths for objects that have them (and are tagged to get refreshed) */
1441 motion_paths_recalc(C, scene, selected_objects);
1442
1443 /* notifiers for updates */
1445 /* NOTE: the notifier below isn't actually correct, but kept around just to be on the safe side.
1446 * If further testing shows it's not necessary (for both bones and objects) removal is fine. */
1448
1449 return OPERATOR_FINISHED;
1450}
1451
1453{
1454 /* identifiers */
1455 ot->name = "Update Object Paths";
1456 ot->idname = "OBJECT_OT_paths_update";
1457 ot->description = "Recalculate motion paths for selected objects";
1458
1459 /* API callbacks. */
1462
1463 /* flags */
1465}
1466
1468
1469/* -------------------------------------------------------------------- */
1472
1474{
1475 return true;
1476}
1477
1479{
1480 Scene *scene = CTX_data_scene(C);
1481
1482 if (scene == nullptr) {
1483 return OPERATOR_CANCELLED;
1484 }
1485 Vector<Object *> visible_objects_with_mpath;
1486 CTX_DATA_BEGIN (C, Object *, ob, visible_objects) {
1487 bool has_any_motion_path = false;
1488 if (ob->mpath) {
1490 has_any_motion_path = true;
1491 }
1492 if (ob->pose) {
1493 for (bPoseChannel &pchan : ob->pose->chanbase) {
1494 if (pchan.mpath) {
1496 has_any_motion_path = true;
1497 }
1498 }
1499 }
1500 if (has_any_motion_path) {
1501 visible_objects_with_mpath.append(ob);
1502 }
1503 }
1505 motion_paths_recalc(C, scene, visible_objects_with_mpath);
1506
1508
1509 return OPERATOR_FINISHED;
1510}
1511
1513{
1514 /* identifiers */
1515 ot->name = "Update All Object Paths";
1516 ot->idname = "OBJECT_OT_paths_update_visible";
1517 ot->description = "Recalculate all visible motion paths for objects and poses";
1518
1519 /* API callbacks. */
1522
1523 /* flags */
1525}
1526
1528
1529/* -------------------------------------------------------------------- */
1532
1533/* Helper for motion_paths_clear() */
1535{
1536 if (ob->mpath) {
1538 ob->mpath = nullptr;
1540
1541 /* tag object for copy-on-eval - so removed paths don't still show */
1543 }
1544}
1545
1546void motion_paths_clear(bContext *C, bool only_selected)
1547{
1548 if (only_selected) {
1549 /* Loop over all selected + editable objects in scene. */
1550 CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) {
1552 }
1554 }
1555 else {
1556 /* Loop over all editable objects in scene. */
1557 CTX_DATA_BEGIN (C, Object *, ob, editable_objects) {
1559 }
1561 }
1562}
1563
1564/* operator callback for this */
1566{
1567 bool only_selected = RNA_boolean_get(op->ptr, "only_selected");
1568
1569 /* use the backend function for this */
1570 motion_paths_clear(C, only_selected);
1571
1572 /* notifiers for updates */
1574
1575 return OPERATOR_FINISHED;
1576}
1577
1579 wmOperatorType * /*ot*/,
1580 PointerRNA *ptr)
1581{
1582 const bool only_selected = RNA_boolean_get(ptr, "only_selected");
1583 if (only_selected) {
1584 return TIP_("Clear motion paths of selected objects");
1585 }
1586 return TIP_("Clear motion paths of all objects");
1587}
1588
1590{
1591 /* identifiers */
1592 ot->name = "Clear Object Paths";
1593 ot->idname = "OBJECT_OT_paths_clear";
1594
1595 /* API callbacks. */
1599
1600 /* flags */
1602
1603 /* properties */
1604 ot->prop = RNA_def_boolean(ot->srna,
1605 "only_selected",
1606 false,
1607 "Only Selected",
1608 "Only clear motion paths of selected objects");
1610}
1611
1613
1614/* -------------------------------------------------------------------- */
1617
1619{
1620 if (md.type != eModifierType_Nodes) {
1621 return false;
1622 }
1623 const NodesModifierData &nmd = reinterpret_cast<const NodesModifierData &>(md);
1624 if (!nmd.node_group || ID_MISSING(nmd.node_group)) {
1625 return false;
1626 }
1627 if (const LibraryWeakReference *library_ref = nmd.node_group->id.library_weak_reference) {
1628 /* Support appended assets added before asset packing in Blender 5.0. */
1629 if (!library_ref) {
1630 return false;
1631 }
1632 if (!STREQ(library_ref->library_id_name + 2, "Smooth by Angle")) {
1633 return false;
1634 }
1635 return true;
1636 }
1637 const Library *library = nmd.node_group->id.lib;
1638 if (!library) {
1639 return false;
1640 }
1641 char auto_smooth_asset_path[FILE_MAX] = "datafiles/assets/nodes/geometry_nodes_essentials.blend";
1642 BLI_path_slash_native(auto_smooth_asset_path);
1643 if (!StringRef(library->filepath).endswith(auto_smooth_asset_path)) {
1644 return false;
1645 }
1646 if (!STREQ(BKE_id_name(nmd.node_group->id), "Smooth by Angle")) {
1647 return false;
1648 }
1649 return true;
1650}
1651
1653{
1654 const bool use_flat = STREQ(op->idname, "OBJECT_OT_shade_flat");
1655 const bool use_smooth = STREQ(op->idname, "OBJECT_OT_shade_smooth");
1656 const bool use_smooth_by_angle = STREQ(op->idname, "OBJECT_OT_shade_smooth_by_angle");
1657 Main *bmain = CTX_data_main(C);
1658 Scene *scene = CTX_data_scene(C);
1659
1660 Vector<PointerRNA> ctx_objects;
1661
1662 /* For modes that only use an active object, don't handle the whole selection. */
1663 {
1664 const Main *bmain = CTX_data_main(C);
1665 Scene *scene = CTX_data_scene(C);
1666 ViewLayer *view_layer = CTX_data_view_layer(C);
1667 BKE_view_layer_synced_ensure(*bmain, scene, view_layer);
1668 Object *obact = BKE_view_layer_active_object_get(view_layer);
1669 if (obact && (obact->mode & OB_MODE_ALL_PAINT_MESH)) {
1670 ctx_objects.append(RNA_id_pointer_create(&obact->id));
1671 }
1672 }
1673
1674 if (ctx_objects.is_empty()) {
1676 }
1677
1678 Set<ID *> object_data;
1679 for (const PointerRNA &ptr : ctx_objects) {
1680 Object *ob = static_cast<Object *>(ptr.data);
1681 if (ID *data = ob->data) {
1682 object_data.add(data);
1683
1684 if (ob->type == OB_MESH) {
1685 if (use_flat || use_smooth) {
1686 for (ModifierData &md : ob->modifiers) {
1688 modifier_remove(op->reports, bmain, scene, ob, &md);
1691 break;
1692 }
1693 }
1694 }
1695 }
1696 }
1697 }
1698
1699 bool changed_multi = false;
1700 bool has_linked_data = false;
1701 for (ID *data : object_data) {
1702 if (!BKE_id_is_editable(bmain, data)) {
1703 has_linked_data = true;
1704 continue;
1705 }
1706
1707 bool changed = false;
1708 if (data->id_type() == ID_ME) {
1709 Mesh &mesh = *reinterpret_cast<Mesh *>(data);
1710 const bool keep_sharp_edges = RNA_boolean_get(op->ptr, "keep_sharp_edges");
1711 bke::mesh_smooth_set(mesh, use_smooth || use_smooth_by_angle, keep_sharp_edges);
1712 if (use_smooth_by_angle) {
1713 const float angle = RNA_float_get(op->ptr, "angle");
1715 }
1717 changed = true;
1718 }
1719 else if (data->id_type() == ID_CU_LEGACY) {
1720 BKE_curve_smooth_flag_set(reinterpret_cast<Curve *>(data), use_smooth);
1721 changed = true;
1722 }
1723
1724 if (changed) {
1725 changed_multi = true;
1728 }
1729 }
1730
1731 if (has_linked_data) {
1732 BKE_report(op->reports, RPT_WARNING, "Cannot edit linked mesh or curve data");
1733 }
1734
1735 return (changed_multi) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
1736}
1737
1738static bool shade_poll(bContext *C)
1739{
1740 const Main *bmain = CTX_data_main(C);
1741 const Scene *scene = CTX_data_scene(C);
1742 ViewLayer *view_layer = CTX_data_view_layer(C);
1743 BKE_view_layer_synced_ensure(*bmain, scene, view_layer);
1744 Object *obact = BKE_view_layer_active_object_get(view_layer);
1745 if (obact != nullptr) {
1746 /* Doesn't handle edit-data, sculpt dynamic-topology, or their undo systems. */
1747 if (obact->mode & (OB_MODE_EDIT | OB_MODE_SCULPT) || obact->data == nullptr ||
1748 !ID_IS_EDITABLE(obact) || !ID_IS_EDITABLE(obact->data) || ID_IS_OVERRIDE_LIBRARY(obact) ||
1750 {
1751 return false;
1752 }
1753 }
1754 return true;
1755}
1756
1758{
1759 /* identifiers */
1760 ot->name = "Shade Flat";
1761 ot->description = "Render and display faces uniform, using face normals";
1762 ot->idname = "OBJECT_OT_shade_flat";
1763
1764 /* API callbacks. */
1765 ot->poll = shade_poll;
1766 ot->exec = shade_smooth_exec;
1767
1768 /* flags */
1770
1772 "keep_sharp_edges",
1773 true,
1774 "Keep Sharp Edges",
1775 "Don't remove sharp edges, which are redundant with faces shaded smooth");
1776}
1777
1779{
1780 /* identifiers */
1781 ot->name = "Shade Smooth";
1782 ot->description = "Render and display faces smooth, using interpolated vertex normals";
1783 ot->idname = "OBJECT_OT_shade_smooth";
1784
1785 /* API callbacks. */
1786 ot->poll = shade_poll;
1787 ot->exec = shade_smooth_exec;
1788
1789 /* flags */
1791
1793 "keep_sharp_edges",
1794 true,
1795 "Keep Sharp Edges",
1796 "Don't remove sharp edges. Tagged edges will remain sharp");
1797}
1798
1800{
1801 ot->name = "Shade Smooth by Angle";
1802 ot->description =
1803 "Set the sharpness of mesh edges based on the angle between the neighboring faces";
1804 ot->idname = "OBJECT_OT_shade_smooth_by_angle";
1805
1806 ot->poll = shade_poll;
1807 ot->exec = shade_smooth_exec;
1808
1810
1811 PropertyRNA *prop = RNA_def_property(ot->srna, "angle", PROP_FLOAT, PROP_ANGLE);
1812 RNA_def_property_range(prop, 0.0f, DEG2RADF(180.0f));
1815 prop, "Angle", "Maximum angle between face normals that will be considered as smooth");
1816
1818 "keep_sharp_edges",
1819 true,
1820 "Keep Sharp Edges",
1821 "Only add sharp edges instead of clearing existing tags first");
1822}
1823
1825
1826/* -------------------------------------------------------------------- */
1829
1835{
1836 if (ntree.type != NTREE_GEOMETRY) {
1837 return false;
1838 }
1839 if (ntree.interface_inputs().size() != 3) {
1840 return false;
1841 }
1842 if (ntree.interface_outputs().size() != 1) {
1843 return false;
1844 }
1845 return true;
1846}
1847
1849{
1850 Main &bmain = *CTX_data_main(C);
1851 Scene &scene = *CTX_data_scene(C);
1852
1853 const bool use_auto_smooth = RNA_boolean_get(op->ptr, "use_auto_smooth");
1854 const float angle = RNA_float_get(op->ptr, "angle");
1855
1856 Vector<PointerRNA> ctx_objects;
1858
1859 if (use_auto_smooth) {
1860 AssetWeakReference asset_weak_ref{};
1862 asset_weak_ref.relative_asset_identifier = BLI_strdup(
1863 "nodes/geometry_nodes_essentials.blend/NodeTree/Smooth by Angle");
1864
1865 if (G.background) {
1866 /* For testing purposes, make sure assets are loaded (this make take too long to do
1867 * automatically during user interaction). */
1869 }
1870
1871 const asset_system::AssetRepresentation *asset_representation =
1872 asset::find_asset_from_weak_ref(*C, asset_weak_ref, op->reports);
1873 if (!asset_representation) {
1874 return OPERATOR_CANCELLED;
1875 }
1876
1877 bNodeTree *node_group = nullptr;
1878 while (!node_group) {
1879 ID *node_group_id = asset::asset_local_id_ensure_imported(bmain, *asset_representation);
1880 if (!node_group_id) {
1881 return OPERATOR_CANCELLED;
1882 }
1883 if (node_group_id->id_type() != ID_NT) {
1884 return OPERATOR_CANCELLED;
1885 }
1886 node_group = reinterpret_cast<bNodeTree *>(node_group_id);
1887 node_group->ensure_topology_cache();
1888 node_group->ensure_interface_cache();
1889 if (is_valid_smooth_by_angle_group(*node_group)) {
1890 break;
1891 }
1892 /* Remove the weak library reference, since the already loaded group is not valid anymore. */
1893 MEM_SAFE_DELETE(node_group_id->library_weak_reference);
1894 /* Stay in the loop and load the asset again. */
1895 node_group = nullptr;
1896 }
1897
1898 const StringRefNull angle_identifier = node_group->interface_inputs()[1]->identifier;
1899
1900 for (const PointerRNA &ob_ptr : ctx_objects) {
1901 Object *object = static_cast<Object *>(ob_ptr.data);
1902 if (object->type == OB_MESH) {
1903 Mesh *mesh = id_cast<Mesh *>(object->data);
1904 bke::mesh_smooth_set(*mesh, true, true);
1906 }
1907 NodesModifierData *smooth_by_angle_nmd = nullptr;
1908 for (ModifierData &md : object->modifiers) {
1910 smooth_by_angle_nmd = reinterpret_cast<NodesModifierData *>(&md);
1911 break;
1912 }
1913 }
1914 if (!smooth_by_angle_nmd) {
1915 smooth_by_angle_nmd = reinterpret_cast<NodesModifierData *>(
1916 modifier_add(op->reports, &bmain, &scene, object, nullptr, eModifierType_Nodes));
1917 if (!smooth_by_angle_nmd) {
1918 continue;
1919 }
1920 smooth_by_angle_nmd->modifier.flag |= eModifierFlag_PinLast;
1921 smooth_by_angle_nmd->node_group = node_group;
1922 id_us_plus(&node_group->id);
1923 MOD_nodes_update_interface(bmain, object, smooth_by_angle_nmd);
1924 smooth_by_angle_nmd->flag |= NODES_MODIFIER_HIDE_DATABLOCK_SELECTOR |
1926 STRNCPY_UTF8(smooth_by_angle_nmd->modifier.name, DATA_(node_group->id.name + 2));
1927 BKE_modifier_unique_name(&object->modifiers, &smooth_by_angle_nmd->modifier);
1928 }
1929
1931 &object->id, RNA_NodesModifier, smooth_by_angle_nmd);
1932 PointerRNA properties_ptr = RNA_pointer_get(&nmd_ptr, "properties");
1933 PointerRNA inputs_ptr = RNA_pointer_get(&properties_ptr, "inputs");
1934 PointerRNA input_ptr = RNA_pointer_get(&inputs_ptr, angle_identifier.c_str());
1935
1936 RNA_float_set(&input_ptr, "value", angle);
1937
1940 }
1941 }
1942 else {
1943 for (const PointerRNA &ob_ptr : ctx_objects) {
1944 Object *object = static_cast<Object *>(ob_ptr.data);
1945 for (ModifierData &md : object->modifiers) {
1947 modifier_remove(op->reports, &bmain, &scene, object, &md);
1949 break;
1950 }
1951 }
1952 }
1953 }
1954
1955 return OPERATOR_FINISHED;
1956}
1957
1959{
1960 ui::Layout &layout = *op->layout;
1961
1962 layout.use_property_split_set(true);
1963 layout.use_property_decorate_set(false);
1964
1965 layout.prop(op->ptr, "use_auto_smooth", UI_ITEM_NONE, std::nullopt, ICON_NONE);
1966
1967 ui::Layout &col = layout.column(false);
1968 col.active_set(RNA_boolean_get(op->ptr, "use_auto_smooth"));
1969 layout.prop(op->ptr, "angle", UI_ITEM_NONE, std::nullopt, ICON_NONE);
1970}
1971
1973{
1974 ot->name = "Shade Auto Smooth";
1975 ot->description =
1976 "Add modifier to automatically set the sharpness of mesh edges based on the angle between "
1977 "the neighboring faces";
1978 ot->idname = "OBJECT_OT_shade_auto_smooth";
1979
1980 ot->poll = shade_poll;
1983
1985
1986 PropertyRNA *prop;
1987
1988 prop = RNA_def_boolean(ot->srna,
1989 "use_auto_smooth",
1990 true,
1991 "Auto Smooth",
1992 "Add modifier to set edge sharpness automatically");
1994
1995 prop = RNA_def_property(ot->srna, "angle", PROP_FLOAT, PROP_ANGLE);
1996 RNA_def_property_range(prop, 0.0f, DEG2RADF(180.0f));
1999 prop, "Angle", "Maximum angle between face normals that will be considered as smooth");
2000}
2001
2003
2004/* -------------------------------------------------------------------- */
2007
2009 PointerRNA * /*ptr*/,
2010 PropertyRNA * /*prop*/,
2011 bool *r_free)
2012{
2014 EnumPropertyItem *item = nullptr;
2015 int totitem = 0;
2016
2017 if (!C) { /* needed for docs */
2019 }
2020
2021 const Object *ob = CTX_data_active_object(C);
2022 if (ob) {
2023 while (input->identifier) {
2024 if (mode_compat_test(ob, eObjectMode(input->value))) {
2025 RNA_enum_item_add(&item, &totitem, input);
2026 }
2027 input++;
2028 }
2029 }
2030 else {
2031 /* We need at least this one! */
2032 RNA_enum_items_add_value(&item, &totitem, input, OB_MODE_OBJECT);
2033 }
2034
2035 RNA_enum_item_end(&item, &totitem);
2036
2037 *r_free = true;
2038
2039 return item;
2040}
2041
2043{
2044 /* Needed as #ED_operator_object_active_editable doesn't call use 'active_object'. */
2047}
2048
2050{
2051 const bool use_submode = STREQ(op->idname, "OBJECT_OT_mode_set_with_submode");
2053 eObjectMode mode = eObjectMode(RNA_enum_get(op->ptr, "mode"));
2054 const bool toggle = RNA_boolean_get(op->ptr, "toggle");
2055
2056 if (!mode_compat_test(ob, mode)) {
2057 return OPERATOR_PASS_THROUGH;
2058 }
2060 return OPERATOR_CANCELLED;
2061 }
2062
2081 if (toggle == false) {
2082 if (ob->mode != mode) {
2083 mode_set_ex(C, mode, true, op->reports);
2084 }
2085 }
2086 else {
2087 const eObjectMode mode_prev = ob->mode;
2088 /* When toggling object mode, we always use the restore mode,
2089 * otherwise there is nothing to do. */
2090 if (mode == OB_MODE_OBJECT) {
2091 if (ob->mode != OB_MODE_OBJECT) {
2092 if (mode_set_ex(C, OB_MODE_OBJECT, true, op->reports)) {
2093 /* Store old mode so we know what to go back to. */
2094 ob->restore_mode = mode_prev;
2095 }
2096 }
2097 else {
2098 if (ob->restore_mode != OB_MODE_OBJECT) {
2099 mode_set_ex(C, ob->restore_mode, true, op->reports);
2100 }
2101 }
2102 }
2103 else {
2104 /* Non-object modes, enter the 'mode' unless it's already set,
2105 * in that case use restore mode. */
2106 if (ob->mode != mode) {
2107 if (mode_set_ex(C, mode, true, op->reports)) {
2108 /* Store old mode so we know what to go back to. */
2109 ob->restore_mode = mode_prev;
2110 }
2111 }
2112 else {
2113 if (ob->restore_mode != OB_MODE_OBJECT) {
2114 mode_set_ex(C, ob->restore_mode, true, op->reports);
2115 }
2116 else {
2117 mode_set_ex(C, OB_MODE_OBJECT, true, op->reports);
2118 }
2119 }
2120 }
2121 }
2122
2123 if (use_submode) {
2124 if (ob->type == OB_MESH) {
2125 if (ob->mode & OB_MODE_EDIT) {
2126 PropertyRNA *prop = RNA_struct_find_property(op->ptr, "mesh_select_mode");
2127 if (RNA_property_is_set(op->ptr, prop)) {
2128 int mesh_select_mode = RNA_property_enum_get(op->ptr, prop);
2129 if (mesh_select_mode != 0) {
2130 EDBM_selectmode_set_multi(C, mesh_select_mode);
2131 }
2132 }
2133 }
2134 }
2135 }
2136
2138 if (wm) {
2140 /* Note, this uses the global `ReportList` rather than the operator, as we do not want to
2141 * interpret this failure as a failure of switching modes. */
2142 const bool success = WM_autosave_write(wm, CTX_data_main(C), &wm->runtime->reports);
2143 if (!success) {
2145 }
2146 }
2147 }
2148
2149 return OPERATOR_FINISHED;
2150}
2151
2153{
2154 PropertyRNA *prop;
2155
2156 /* identifiers */
2157 ot->name = "Set Object Mode";
2158 ot->description = "Sets the object interaction mode";
2159 ot->idname = "OBJECT_OT_mode_set";
2160
2161 /* API callbacks. */
2164
2165 /* flags */
2166 ot->flag = 0; /* no register/undo here, leave it to operators being called */
2167
2168 ot->prop = RNA_def_enum(
2169 ot->srna, "mode", rna_enum_object_mode_items, OB_MODE_OBJECT, "Mode", "");
2172
2173 prop = RNA_def_boolean(ot->srna, "toggle", false, "Toggle", "");
2175}
2176
2178{
2180
2181 /* identifiers */
2182 ot->name = "Set Object Mode with Sub-mode";
2183 ot->idname = "OBJECT_OT_mode_set_with_submode";
2184
2185 /* properties */
2186 /* we could add other types - particle for eg. */
2187 PropertyRNA *prop;
2188 prop = RNA_def_enum_flag(
2189 ot->srna, "mesh_select_mode", rna_enum_mesh_select_mode_items, 0, "Mesh Mode", "");
2191}
2192
2194
2195/* -------------------------------------------------------------------- */
2198
2199static ListBaseT<LinkData> selected_objects_get(bContext *C)
2200{
2201 ListBaseT<LinkData> objects = {nullptr};
2202
2203 if (CTX_wm_space_outliner(C) != nullptr) {
2205 }
2206 else {
2207 CTX_DATA_BEGIN (C, Object *, ob, selected_objects) {
2208 BLI_addtail(&objects, BLI_genericNodeN(ob));
2209 }
2211 }
2212
2213 return objects;
2214}
2215
2217{
2218 if (CTX_wm_space_outliner(C) != nullptr) {
2220 }
2221 return ED_operator_objectmode(C);
2222}
2223
2225{
2226 Main *bmain = CTX_data_main(C);
2227 PropertyRNA *prop = RNA_struct_find_property(op->ptr, "collection_uid");
2228 const bool is_link = STREQ(op->idname, "OBJECT_OT_link_to_collection");
2229 const bool is_new = RNA_boolean_get(op->ptr, "is_new");
2230
2231 if (!RNA_property_is_set(op->ptr, prop)) {
2232 BKE_report(op->reports, RPT_ERROR, "No collection selected");
2233 return OPERATOR_CANCELLED;
2234 }
2235 Scene *src_scene = CTX_data_scene(C);
2236
2237 int collection_uid = RNA_property_int_get(op->ptr, prop);
2238 Scene *dest_scene = nullptr;
2239 Collection *collection = BKE_collection_from_session_uid(bmain, collection_uid, &dest_scene);
2240 if (collection == nullptr) {
2241 BKE_report(op->reports, RPT_ERROR, "Unexpected error, collection not found");
2242 return OPERATOR_CANCELLED;
2243 }
2244
2245 std::string reason;
2246 if (!BKE_collection_is_content_editable(collection, &reason)) {
2248 op->reports, RPT_ERROR, "Cannot add objects to the collection. %s", reason.c_str());
2249 return OPERATOR_CANCELLED;
2250 }
2251
2252 ListBaseT<LinkData> objects = selected_objects_get(C);
2253
2254 if (is_new) {
2255 char new_collection_name[MAX_ID_NAME - 2];
2256 RNA_string_get(op->ptr, "new_collection_name", new_collection_name);
2257 collection = BKE_collection_add(bmain, collection, new_collection_name);
2258 }
2259
2260 Object *single_object = objects.is_single() ? static_cast<Object *>((objects.first())->data) :
2261 nullptr;
2262
2263 if ((single_object != nullptr) && is_link &&
2264 BKE_collection_has_object(collection, single_object))
2265 {
2266 BKE_reportf(op->reports,
2267 RPT_ERROR,
2268 "%s already in %s",
2269 single_object->id.name + 2,
2270 BKE_collection_ui_name_get(collection));
2271 objects.free_no_destruct();
2272 return OPERATOR_CANCELLED;
2273 }
2274
2275 for (LinkData &link : objects) {
2276 Object *ob = static_cast<Object *>(link.data);
2277
2278 if (!is_link) {
2279 BKE_collection_object_move(bmain, src_scene, collection, nullptr, ob);
2280 }
2281 else {
2282 BKE_collection_object_add(bmain, collection, ob);
2283 }
2284 }
2285 objects.free_no_destruct();
2286
2287 if (is_link) {
2288 if (single_object != nullptr) {
2289 BKE_reportf(op->reports,
2290 RPT_INFO,
2291 "%s linked to %s",
2292 single_object->id.name + 2,
2293 BKE_collection_ui_name_get(collection));
2294 }
2295 else {
2297 op->reports, RPT_INFO, "Objects linked to %s", BKE_collection_ui_name_get(collection));
2298 }
2299 }
2300 else {
2301 if (single_object != nullptr) {
2302 BKE_reportf(op->reports,
2303 RPT_INFO,
2304 "%s moved to %s",
2305 single_object->id.name + 2,
2306 BKE_collection_ui_name_get(collection));
2307 }
2308 else {
2310 op->reports, RPT_INFO, "Objects moved to %s", BKE_collection_ui_name_get(collection));
2311 }
2312 }
2313
2316
2320
2321 if (src_scene != dest_scene) {
2323
2324 WM_event_add_notifier(C, NC_SCENE | ND_LAYER, dest_scene);
2327 }
2328
2329 return OPERATOR_FINISHED;
2330}
2331
2333 wmOperator *op,
2334 const wmEvent * /*event*/)
2335{
2336 ListBaseT<LinkData> objects = selected_objects_get(C);
2337 if (objects.is_empty()) {
2338 BKE_report(op->reports, RPT_ERROR, "No objects selected");
2339 return OPERATOR_CANCELLED;
2340 }
2341 objects.free_no_destruct();
2342 PropertyRNA *prop = RNA_struct_find_property(op->ptr, "collection_uid");
2343 bool is_move = STREQ(op->type->idname, "OBJECT_OT_move_to_collection");
2344 if (!RNA_property_is_set(op->ptr, prop)) {
2346 is_move ? "OBJECT_MT_move_to_collection" : "OBJECT_MT_link_to_collection",
2348 return OPERATOR_FINISHED;
2349 }
2350
2351 if (!RNA_boolean_get(op->ptr, "is_new")) {
2352 return move_to_collection_exec(C, op);
2353 }
2354
2355 int collection_uid = RNA_property_int_get(op->ptr, prop);
2356 Collection *collection = BKE_collection_from_session_uid(CTX_data_main(C), collection_uid);
2357
2358 if (!collection) {
2359 BKE_report(op->reports, RPT_ERROR, "Unexpected error, collection not found");
2360 return OPERATOR_CANCELLED;
2361 }
2362
2363 prop = RNA_struct_find_property(op->ptr, "new_collection_name");
2364 if (!RNA_property_is_set(op->ptr, prop)) {
2365 char name[MAX_ID_NAME - 2];
2366
2367 BKE_collection_new_name_get(collection, name);
2368
2369 RNA_property_string_set(op->ptr, prop, name);
2371 op,
2372 200,
2373 is_move ? IFACE_("Move to New Collection") :
2374 IFACE_("Link to New Collection"),
2375 IFACE_("Create"));
2376 }
2377 return move_to_collection_exec(C, op);
2378}
2379
2381 Collection *collection,
2382 int icon,
2383 const bool is_scene_collection = false)
2384{
2385 ui::Layout &layout = *menu->layout;
2386 bool is_move = ELEM(StringRefNull(menu->type->idname),
2387 "OBJECT_MT_move_to_collection",
2388 "OBJECT_MT_move_to_collection_recursive");
2390 is_move ? "OBJECT_OT_move_to_collection" : "OBJECT_OT_link_to_collection", false);
2391
2393
2394 if (!is_scene_collection) {
2395 PointerRNA op_ptr = layout.op(
2396 ot, is_move ? IFACE_("Move Inside") : IFACE_("Link Inside"), ICON_NONE);
2397 RNA_int_set(&op_ptr, "collection_uid", collection->id.session_uid);
2398 layout.separator();
2399 }
2400
2401 PointerRNA op_ptr = layout.op(
2402 ot, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "New Collection"), ICON_ADD);
2403 RNA_int_set(&op_ptr, "collection_uid", collection->id.session_uid);
2404 RNA_boolean_set(&op_ptr, "is_new", true);
2405
2406 if (is_scene_collection) {
2407 layout.separator();
2408 op_ptr = layout.op(ot, BKE_collection_ui_name_get(collection), icon);
2409 RNA_int_set(&op_ptr, "collection_uid", collection->id.session_uid);
2410 }
2411
2412 for (CollectionChild &child : collection->children) {
2413 collection = child.collection;
2414 const PointerRNA ptr = RNA_id_pointer_create(&collection->id);
2415 layout.context_ptr_set("collection", &ptr);
2416 layout.menu(is_move ? "OBJECT_MT_move_to_collection_recursive" :
2417 "OBJECT_MT_link_to_collection_recursive",
2418 BKE_collection_ui_name_get(collection),
2419 ui::icon_color_from_collection(collection));
2420 }
2421}
2422
2424{
2425 ui::Layout &layout = *menu->layout;
2426 const PointerRNA *ptr = layout.context_ptr_get("collection", RNA_Collection);
2427 Collection *collection = ptr ? ptr->data_as<Collection>() : nullptr;
2428 if (!collection) {
2429 return;
2430 }
2431 move_to_collection_menu_draw(menu, collection, ui::icon_color_from_collection(collection));
2432}
2433
2435{
2436 ui::Layout &layout = *menu->layout;
2437 Scene *scene = CTX_data_scene(C);
2440 PointerRNA op_ptr = layout.op("WM_OT_search_single_menu",
2442 ICON_VIEWZOOM);
2443 RNA_string_set(&op_ptr, "menu_idname", menu->type->idname);
2444 layout.separator();
2445 }
2446 move_to_collection_menu_draw(menu, scene->master_collection, ICON_SCENE_DATA, true);
2447}
2448
2450{
2451 /* Add recursive sub-menu type, to avoid each sub-menu from showing the main menu shortcut. */
2452 MenuType *mt = MEM_new_zeroed<MenuType>("OBJECT_MT_move_to_collection_recursive");
2453 STRNCPY_UTF8(mt->idname, "OBJECT_MT_move_to_collection_recursive");
2454 STRNCPY_UTF8(mt->label, N_("Move to Collection Recursive"));
2458 WM_menutype_add(mt);
2459
2460 mt = MEM_new_zeroed<MenuType>("OBJECT_MT_move_to_collection");
2461 STRNCPY_UTF8(mt->idname, "OBJECT_MT_move_to_collection");
2462 STRNCPY_UTF8(mt->label, N_("Move to Collection"));
2466 WM_menutype_add(mt);
2467}
2468
2470{
2471 /* Add recursive sub-menu type, to avoid each sub-menu from showing the main menu shortcut. */
2472 MenuType *mt = MEM_new_zeroed<MenuType>("OBJECT_MT_link_to_collection_recursive");
2473 STRNCPY_UTF8(mt->idname, "OBJECT_MT_link_to_collection_recursive");
2474 STRNCPY_UTF8(mt->label, N_("Link to Collection Recursive"));
2478 WM_menutype_add(mt);
2479
2480 mt = MEM_new_zeroed<MenuType>("OBJECT_MT_link_to_collection");
2481 STRNCPY_UTF8(mt->idname, "OBJECT_MT_link_to_collection");
2482 STRNCPY_UTF8(mt->label, N_("Link to Collection"));
2486 WM_menutype_add(mt);
2487}
2488
2490{
2491 PropertyRNA *prop;
2492
2493 /* identifiers */
2494 ot->name = "Move to Collection";
2495 ot->description = "Move objects to a collection";
2496 ot->idname = "OBJECT_OT_move_to_collection";
2497
2498 /* API callbacks. */
2502
2503 /* flags */
2505
2506 prop = RNA_def_int(ot->srna,
2507 "collection_uid",
2510 INT_MAX,
2511 "Collection UID",
2512 "Session UID of the collection to move to",
2513 0,
2514 INT_MAX);
2516 prop = RNA_def_boolean(ot->srna, "is_new", false, "New", "Move objects to a new collection");
2518 prop = RNA_def_string(ot->srna,
2519 "new_collection_name",
2520 nullptr,
2521 MAX_ID_NAME - 2,
2522 "Name",
2523 "Name of the newly added collection");
2525 ot->prop = prop;
2526}
2527
2529{
2530 PropertyRNA *prop;
2531
2532 /* identifiers */
2533 ot->name = "Link to Collection";
2534 ot->description = "Link objects to a collection";
2535 ot->idname = "OBJECT_OT_link_to_collection";
2536
2537 /* API callbacks. */
2541
2542 /* flags */
2544
2545 prop = RNA_def_int(ot->srna,
2546 "collection_uid",
2549 INT_MAX,
2550 "Collection UID",
2551 "Session UID of the collection to link to",
2552 0,
2553 INT_MAX);
2555 prop = RNA_def_boolean(ot->srna, "is_new", false, "New", "Link objects to a new collection");
2557 prop = RNA_def_string(ot->srna,
2558 "new_collection_name",
2559 nullptr,
2560 MAX_ID_NAME - 2,
2561 "Name",
2562 "Name of the newly added collection");
2564 ot->prop = prop;
2565}
2566
2568
2569} // namespace blender::ed::object
#define CTX_DATA_BEGIN(C, Type, instance, member)
#define CTX_DATA_END
#define FOREACH_BASE_IN_MODE_BEGIN(_bmain, _scene, _view_layer, _v3d, _object_type, _object_mode, _instance)
Definition BKE_layer.hh:436
#define FOREACH_BASE_IN_MODE_END
Definition BKE_layer.hh:454
#define FOREACH_SELECTED_OBJECT_BEGIN(_view_layer, _v3d, _instance)
Definition BKE_layer.hh:374
#define FOREACH_OBJECT_END
Definition BKE_layer.hh:533
#define FOREACH_OBJECT_BEGIN(_bmain, _scene, _view_layer, _instance)
Definition BKE_layer.hh:523
#define FOREACH_SELECTED_OBJECT_END
Definition BKE_layer.hh:386
General operations, lookup, etc. for materials.
General operations, lookup, etc. for blender objects.
#define PTCACHE_TYPE_PARTICLES
#define PTCACHE_RESET_OUTDATED
#define DEG2RADF(_deg)
#define FILE_MAX
#define STRNCPY_UTF8(dst, src)
#define TIP_(msgid)
#define CTX_IFACE_(context, msgid)
#define BLT_I18NCONTEXT_OPERATOR_DEFAULT
#define IFACE_(msgid)
#define BLT_I18NCONTEXT_DEFAULT_BPYRNA
#define DATA_(msgid)
#define CLOG_WARN(clg_ref,...)
Definition CLG_log.h:189
#define MAX_ID_NAME
Definition DNA_ID.h:367
#define ID_IS_EDITABLE(_id)
Definition DNA_ID.h:708
#define ID_IS_OVERRIDE_LIBRARY(_id)
Definition DNA_ID.h:736
#define ID_MISSING(_id)
Definition DNA_ID.h:695
Object groups, one object can be in many groups at once.
#define MESH_MAX_VERTS
#define OB_MODE_ALL_PAINT_MESH
#define OB_MODE_ALL_PAINT_GPENCIL
Object is a sort of wrapper for general info.
#define OB_TYPE_SUPPORT_EDITMODE(_type)
Read Blender memory allocation and freeing.
#define C
Definition RandGen.cpp:29
#define UI_ITEM_NONE
#define NS_EDITMODE_MESH
Definition WM_types.hh:612
#define NS_EDITMODE_TEXT
Definition WM_types.hh:615
#define NC_GEOM
Definition WM_types.hh:406
#define ND_DRAW
Definition WM_types.hh:502
#define ND_OB_ACTIVE
Definition WM_types.hh:459
#define NS_EDITMODE_POINTCLOUD
Definition WM_types.hh:623
#define ND_DATA
Definition WM_types.hh:552
#define NS_EDITMODE_CURVES
Definition WM_types.hh:621
#define ND_MODE
Definition WM_types.hh:464
#define ND_OB_SELECT
Definition WM_types.hh:461
#define NC_SCENE
Definition WM_types.hh:391
#define NS_EDITMODE_ARMATURE
Definition WM_types.hh:618
#define ND_OB_VISIBLE
Definition WM_types.hh:462
#define ND_LAYER_CONTENT
Definition WM_types.hh:472
#define ND_MODIFIER
Definition WM_types.hh:503
#define ND_POSE
Definition WM_types.hh:482
#define NS_MODE_OBJECT
Definition WM_types.hh:610
#define NA_REMOVED
Definition WM_types.hh:637
#define NS_EDITMODE_MBALL
Definition WM_types.hh:616
#define NS_EDITMODE_GREASE_PENCIL
Definition WM_types.hh:622
#define ND_TRANSFORM
Definition WM_types.hh:475
#define NS_EDITMODE_LATTICE
Definition WM_types.hh:617
#define ND_LAYER
Definition WM_types.hh:469
#define ND_DRAW_ANIMVIZ
Definition WM_types.hh:514
#define NC_OBJECT
Definition WM_types.hh:392
#define NS_EDITMODE_CURVE
Definition WM_types.hh:613
#define ELEM(...)
#define STREQ(a, b)
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
Definition btVector3.h:356
bool add(const Key &key)
Definition BLI_set.hh:248
constexpr const char * c_str() const
constexpr StringRefNull()
constexpr StringRef()
void append(const T &value)
friend class Vector
bool is_empty() const
float4 load_data(StoredFloat4 data)
#define INT_MAX
AssetLibraryReference all_library_reference()
void free(struct bMotionPath *mpath)
struct bMotionPath * ensure(struct ReportList *reports, struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan)
void mesh_sharp_edges_set_from_angle(Mesh &mesh, float angle, bool keep_sharp_edges=false)
void mesh_smooth_set(Mesh &mesh, bool use_smooth, bool keep_sharp_edges=false)
void storage_fetch_blocking(const AssetLibraryReference &library_reference, const bContext &C)
const asset_system::AssetRepresentation * find_asset_from_weak_ref(const bContext &C, const AssetWeakReference &weak_ref, ReportList *reports)
ID * asset_local_id_ensure_imported(Main &bmain, const asset_system::AssetRepresentation &asset, int flags=0, const std::optional< eAssetImportMethod > import_method=std::nullopt, const std::optional< ImportInstantiateContext > instantiate_context=std::nullopt, ReportList *reports=nullptr)
bool ensure_selection_domain(ToolSettings *ts, Object *object)
void tag_for_recalc(bMotionPath &motion_path)
void OBJECT_OT_paths_update_visible(wmOperatorType *ot)
void OBJECT_OT_shade_smooth(wmOperatorType *ot)
ModifierData * modifier_add(ReportList *reports, Main *bmain, Scene *scene, Object *ob, const char *name, int type)
static bool is_valid_smooth_by_angle_group(const bNodeTree &ntree)
static wmOperatorStatus object_update_paths_exec(bContext *C, wmOperator *op)
void OBJECT_OT_editmode_toggle(wmOperatorType *ot)
void motion_paths_recalc(bContext *C, Scene *scene, const Span< Object * > objects)
bool editmode_exit_multi(bContext *C, int flag)
void OBJECT_OT_mode_set(wmOperatorType *ot)
static bool editmode_load_free_ex(Main *bmain, Object *obedit, const bool load_data, const bool free_data)
bool editmode_enter(bContext *C, int flag)
void OBJECT_OT_posemode_toggle(wmOperatorType *ot)
static bool object_mode_set_poll(bContext *C)
static void flush_pose_selection_to_bone(Object &ob)
static bool object_mode_set_ok_or_report(ReportList *reports)
static wmOperatorStatus object_calculate_paths_exec(bContext *C, wmOperator *op)
void OBJECT_OT_shade_flat(wmOperatorType *ot)
void OBJECT_OT_hide_view_clear(wmOperatorType *ot)
void OBJECT_OT_shade_auto_smooth(wmOperatorType *ot)
static wmOperatorStatus editmode_toggle_exec(bContext *C, wmOperator *op)
static void object_clear_mpath(Object *ob)
void motion_paths_clear(bContext *C, bool only_selected)
void OBJECT_OT_shade_smooth_by_angle(wmOperatorType *ot)
static wmOperatorStatus object_clear_paths_exec(bContext *C, wmOperator *op)
void OBJECT_OT_move_to_collection(wmOperatorType *ot)
static void move_to_collection_recursive_menu_draw(const bContext *, Menu *menu)
bool editmode_free_ex(Main *bmain, Object *obedit)
static wmOperatorStatus move_to_collection_invoke(bContext *C, wmOperator *op, const wmEvent *)
bool mode_set_ex(bContext *C, eObjectMode mode, bool use_undo, ReportList *reports)
static wmOperatorStatus object_calculate_paths_invoke(bContext *C, wmOperator *op, const wmEvent *)
void OBJECT_OT_hide_view_set(wmOperatorType *ot)
static wmOperatorStatus object_update_all_paths_exec(bContext *C, wmOperator *)
static wmOperatorStatus object_hide_collection_exec(bContext *C, wmOperator *op)
void base_select(Base *base, eObjectSelect_Mode mode)
static wmOperatorStatus object_hide_view_set_exec(bContext *C, wmOperator *op)
static wmOperatorStatus move_to_collection_exec(bContext *C, wmOperator *op)
Object * context_object(const bContext *C)
void OBJECT_OT_mode_set_with_submode(wmOperatorType *ot)
void OBJECT_OT_hide_collection(wmOperatorType *ot)
static bool shade_poll(bContext *C)
void OBJECT_OT_paths_update(wmOperatorType *ot)
void link_to_collection_menu_register()
void OBJECT_OT_paths_calculate(wmOperatorType *ot)
static wmOperatorStatus object_hide_view_clear_exec(bContext *C, wmOperator *op)
bool mode_compat_test(const Object *ob, eObjectMode mode)
bool editmode_enter_ex(Main *bmain, Scene *scene, Object *ob, int flag)
Object * context_active_object(const bContext *C)
static wmOperatorStatus shade_auto_smooth_exec(bContext *C, wmOperator *op)
void OBJECT_OT_forcefield_toggle(wmOperatorType *ot)
static const EnumPropertyItem * object_mode_set_itemf(bContext *C, PointerRNA *, PropertyRNA *, bool *r_free)
bool editmode_exit(bContext *C, int flag)
int object_in_mode_to_index(const Main &bmain, const Scene *scene, ViewLayer *view_layer, eObjectMode mode, const Object *ob)
static bool has_object_motion_paths(Object *ob)
void OBJECT_OT_link_to_collection(wmOperatorType *ot)
static bool move_to_collection_poll(bContext *C)
static wmOperatorStatus object_mode_set_exec(bContext *C, wmOperator *op)
bool mode_compat_set(bContext *C, Object *ob, eObjectMode mode, ReportList *reports)
void move_to_collection_menu_register()
bool editmode_exit_multi_ex(Main *bmain, Scene *scene, ViewLayer *view_layer, int flag)
static bool object_update_all_paths_poll(bContext *)
void collection_hide_menu_draw(const bContext *C, ui::Layout &layout)
void check_force_modifiers(Main *bmain, Scene *scene, Object *object)
static ListBaseT< LinkData > selected_objects_get(bContext *C)
Object * object_in_mode_from_index(const Main &bmain, const Scene *scene, ViewLayer *view_layer, eObjectMode mode, int index)
static bool object_update_paths_poll(bContext *C)
static bool editmode_toggle_poll(bContext *C)
static void shade_auto_smooth_ui(bContext *, wmOperator *op)
static bool mesh_needs_keyindex(Main *bmain, const Mesh *mesh)
static bool has_pose_motion_paths(Object *ob)
static bool is_smooth_by_angle_modifier(const ModifierData &md)
static wmOperatorStatus shade_smooth_exec(bContext *C, wmOperator *op)
static void flush_bone_selection_to_pose(Object &ob)
bool editmode_load(Main *bmain, Object *obedit)
static wmOperatorStatus object_hide_collection_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static std::string object_clear_paths_get_description(bContext *, wmOperatorType *, PointerRNA *ptr)
Vector< Object * > objects_in_mode_or_selected(bContext *C, bool(*filter_fn)(const Object *ob, void *user_data), void *filter_user_data)
bool editmode_exit_ex(Main *bmain, Scene *scene, Object *obedit, int flag)
static CLG_LogRef LOG
void OBJECT_OT_paths_clear(wmOperatorType *ot)
static bool object_hide_poll(bContext *C)
static void move_to_collection_menu_draw(Menu *menu, Collection *collection, int icon, const bool is_scene_collection=false)
static wmOperatorStatus posemode_exec(bContext *C, wmOperator *op)
static wmOperatorStatus forcefield_toggle_exec(bContext *C, wmOperator *)
bool modifier_remove(ReportList *reports, Main *bmain, Scene *scene, Object *ob, ModifierData *md)
PopupMenu * popup_menu_begin(bContext *C, const char *title, int icon) ATTR_NONNULL()
int icon_color_from_collection(const Collection *collection)
void WM_main_add_notifier(uint type, void *reference)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void RNA_def_enum_funcs(PropertyRNA *prop, EnumPropertyItemFunc itemfunc)
void ED_mesh_mirror_topo_table_end(Object *ob)
Definition meshtools.cc:253
struct PartDeflect * BKE_partdeflect_new(ePFieldType type)
Definition effect.cc:76
const EnumPropertyItem rna_enum_mesh_select_mode_items[]
Definition rna_scene.cc:135
void RNA_enum_item_add(EnumPropertyItem **items, int *totitem, const EnumPropertyItem *item)
ScrArea * CTX_wm_area(const bContext *C)
void WM_report_banner_show(wmWindowManager *wm, wmWindow *win)
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
int RNA_enum_get(PointerRNA *ptr, const char *name)
void BKE_editlattice_load(struct Object *obedit)
Object * BKE_view_layer_active_object_get(const ViewLayer *view_layer)
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
@ RPT_WARNING
Definition BKE_report.hh:40
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
void ED_curve_editnurb_load(Main *bmain, Object *obedit)
BMesh * BKE_editmesh_bmesh_get_for_write(Mesh *mesh)
Definition editmesh.cc:79
int BKE_ptcache_object_reset(struct Scene *scene, struct Object *ob, int mode)
unsigned int uint
Definition BKE_text.h:55
void ED_armature_to_edit(bArmature *arm)
void ED_armature_from_edit(Main *bmain, bArmature *arm)
const char * BKE_collection_ui_name_get(Collection *collection)
void ED_curve_editfont_load(Object *obedit)
Definition editfont.cc:2305
SpaceOutliner * CTX_wm_space_outliner(const bContext *C)
void DEG_graph_free(Depsgraph *graph)
Definition depsgraph.cc:307
void id_us_plus(ID *id)
Definition lib_id.cc:433
Collection * BKE_collection_from_session_uid(Scene *scene, uint64_t session_uid)
bool BKE_base_is_visible(const View3D *v3d, const Base *base)
PointerRNA RNA_id_pointer_create(ID *id)
void ED_mball_editmball_free(Object *obedit)
Definition mball_edit.cc:62
void RNA_string_set(PointerRNA *ptr, const char *name, const char *value)
int RNA_property_enum_get(PointerRNA *ptr, PropertyRNA *prop)
void BKE_editlattice_make(struct Object *obedit)
void RNA_int_set(PointerRNA *ptr, const char *name, int value)
void ED_mesh_mirror_spatial_table_end(Object *ob)
void MOD_nodes_update_interface(Main &bmain, Object *object, NodesModifierData *nmd)
Definition MOD_nodes.cc:405
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
int RNA_int_get(PointerRNA *ptr, const char *name)
wmWindow * CTX_wm_window(const bContext *C)
void EDBM_mesh_load_ex(Main *bmain, Object *ob, bool free_data)
@ V3D_LOCAL_COLLECTIONS
void RNA_enum_set(PointerRNA *ptr, const char *name, int value)
void ED_curve_editfont_free(Object *obedit)
Definition editfont.cc:2337
bool WM_autosave_write(wmWindowManager *wm, Main *bmain, ReportList *reports)
Definition wm_files.cc:2427
void BKE_editlattice_free(struct Object *ob)
int BKE_layer_collection_findindex(ViewLayer *view_layer, const LayerCollection *lc)
void ED_curve_editnurb_free(Object *obedit)
const char * BKE_id_name(const ID &id)
void BKE_layer_collection_isolate_local(const Main &bmain, const Scene *scene, ViewLayer *view_layer, const View3D *v3d, LayerCollection *lc, bool extend)
void BLI_path_slash_native(char *path) ATTR_NONNULL(1)
void BKE_view_layer_need_resync_tag(ViewLayer *view_layer)
Base * CTX_data_active_base(const bContext *C)
@ ASSET_LIBRARY_ESSENTIALS
ViewLayer * CTX_data_view_layer(const bContext *C)
bool EDBM_selectmode_set_multi(bContext *C, short selectmode)
bool BKE_collection_has_object(Collection *collection, const Object *ob)
void RNA_def_property_float_default(PropertyRNA *prop, float value)
Global G
Definition blender.cc:57
void EDBM_mesh_free_data(BMEditMesh *em)
void BKE_modifier_unique_name(ListBaseT< ModifierData > *modifiers, ModifierData *md)
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier_c_str, int type, int subtype)
void animviz_build_motionpath_targets(Object *ob, Vector< MPathTarget > &r_targets)
bool ED_outliner_collections_editor_poll(bContext *C)
LayerCollection * BKE_layer_collection_from_index(ViewLayer *view_layer, int index)
void RNA_property_string_set(PointerRNA *ptr, PropertyRNA *prop, const char *value)
Depsgraph * animviz_depsgraph_build(Main *bmain, Scene *scene, ViewLayer *view_layer, const Span< MPathTarget > targets)
void * MEM_new_zeroed(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
void ED_curve_editfont_make(Object *obedit)
Definition editfont.cc:2267
bool ED_object_posemode_exit_ex(Main *bmain, Object *ob)
Definition pose_edit.cc:117
Object * BKE_view_layer_edit_object_get(const ViewLayer *view_layer)
void DEG_id_tag_update(ID *id, unsigned int flags)
float BKE_scene_frame_get(const Scene *scene)
Definition scene.cc:2595
void BKE_layer_collection_isolate_global(Scene *scene, ViewLayer *view_layer, LayerCollection *lc, bool extend)
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:162
BMesh const char void * data
void BKE_mesh_batch_cache_dirty_tag(Mesh *mesh, eMeshBatchDirtyMode mode)
@ LAYER_COLLECTION_EXCLUDE
Vector< Object * > BKE_view_layer_array_from_objects_in_mode_params(const Main &bmain, const Scene *scene, ViewLayer *view_layer, const View3D *v3d, const ObjectsInModeParams *params)
wmWindowManager * CTX_wm_manager(const bContext *C)
void RNA_def_property_range(PropertyRNA *prop, double min, double max)
Object * CTX_data_edit_object(const bContext *C)
void BKE_pose_channels_clear_with_null_bone(Object *armature_ob, bool do_id_user)
void BKE_scene_object_base_flag_sync_from_base(Base *base)
Definition scene.cc:3111
void WM_menu_name_call(bContext *C, const char *menu_name, wm::OpCallContext context)
@ LAYER_COLLECTION_HIDE_VIEWPORT
@ LAYER_COLLECTION_HAS_OBJECTS
void WM_toolsystem_update_from_context_view3d(bContext *C)
bool BKE_layer_collection_local_sync(const Main &bmain, const Scene *scene, ViewLayer *view_layer, const View3D *v3d)
bool BKE_view_layer_synced_ensure(const Main &bmain, const Scene *scene, ViewLayer *view_layer)
void ED_outliner_selected_objects_get(const bContext *C, ListBaseT< LinkData > *objects)
void BKE_editmesh_looptris_and_normals_calc(BMEditMesh *em, BMesh *bm)
Definition editmesh.cc:122
LinkData * BLI_genericNodeN(void *data)
Definition listbase.cc:936
void animviz_calc_motionpaths(Depsgraph *depsgraph, Scene *scene, MutableSpan< MPathTarget > targets, const int modified_frame)
void BKE_collection_object_move(Main *bmain, Scene *scene, Collection *collection_dst, Collection *collection_src, Object *ob)
bool BKE_collection_object_add(Main *bmain, Collection *collection, Object *ob)
PointerRNA RNA_pointer_create_discrete(ID *id, StructRNA *type, void *data)
bool ED_operator_view3d_active(bContext *C)
void RNA_enum_items_add_value(EnumPropertyItem **items, int *totitem, const EnumPropertyItem *item, int value)
void BKE_curve_smooth_flag_set(Curve *cu, bool use_smooth)
Definition curve.cc:5441
const EnumPropertyItem rna_enum_motionpath_range_items[]
bool CTX_data_selected_editable_objects(const bContext *C, Vector< PointerRNA > *list)
void RNA_enum_item_end(EnumPropertyItem **items, int *totitem)
wmOperatorStatus WM_operator_props_dialog_popup(bContext *C, wmOperator *op, int width, std::optional< std::string > title, std::optional< std::string > confirm_text, const bool cancel_default, std::optional< std::string > message, const bool show_icon)
void BKE_ptcache_ids_from_object(ListBaseT< PTCacheID > *lb, struct Object *ob, struct Scene *scene, int duplis)
void ED_armature_edit_free(bArmature *arm)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
void BKE_particlesystem_reset_all(struct Object *object)
bool ED_operator_object_active_editable(bContext *C)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
wmMsgBus * CTX_wm_message_bus(const bContext *C)
void RNA_float_set(PointerRNA *ptr, const char *name, float value)
void RNA_boolean_set(PointerRNA *ptr, const char *name, bool value)
char * BKE_object_data_editmode_flush_ptr_get(ID *id)
Definition object.cc:1961
const EnumPropertyItem rna_enum_object_mode_items[]
Definition rna_object.cc:39
PointerRNA RNA_pointer_get(PointerRNA *ptr, const char *name)
Vector< Object * > BKE_view_layer_array_selected_objects_params(ViewLayer *view_layer, const View3D *v3d, const ObjectsInViewLayerParams *params)
void animviz_motionpath_compute_range(Object *ob, Scene *scene)
BMEditMesh * BKE_editmesh_from_object(Object *ob)
Return the BMEditMesh for a given object.
Definition editmesh.cc:59
bool BKE_object_is_in_editmode(const Object *ob)
Definition object.cc:1898
ModifierData * BKE_modifiers_findby_type(const Object *ob, ModifierType type)
wmOperatorType * WM_operatortype_find(const char *idname, bool quiet)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, const int default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
bool ED_object_posemode_exit(bContext *C, Object *ob)
Definition pose_edit.cc:130
bool ED_operator_objectmode(bContext *C)
bool BKE_collection_is_content_editable(const Collection *collection, std::string *reason=nullptr)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
Definition report.cc:191
void EDBM_mesh_make(Object *ob, int select_mode, bool add_key_index)
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:118
Main * CTX_data_main(const bContext *C)
@ NODES_MODIFIER_HIDE_DATABLOCK_SELECTOR
@ NODES_MODIFIER_HIDE_MANAGE_PANEL
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC
bool WM_menutype_add(MenuType *mt)
bool WM_autosave_is_scheduled(wmWindowManager *wm)
Definition wm_files.cc:2422
@ ID_RECALC_SELECT
Definition DNA_ID.h:1101
@ ID_RECALC_ANIMATION
Definition DNA_ID.h:1077
@ ID_RECALC_TRANSFORM
Definition DNA_ID.h:1054
@ ID_RECALC_SYNC_TO_EVAL
Definition DNA_ID.h:1118
@ ID_RECALC_GEOMETRY
Definition DNA_ID.h:1074
@ ID_RECALC_BASE_FLAGS
Definition DNA_ID.h:1104
@ PROP_SKIP_SAVE
Definition RNA_types.hh:414
@ PROP_HIDDEN
Definition RNA_types.hh:408
bool ED_object_posemode_enter_ex(Main *bmain, Object *ob)
Definition pose_edit.cc:81
const EnumPropertyItem rna_enum_motionpath_display_type_items[]
void ED_curve_editnurb_make(Object *obedit)
const BMesh * BKE_editmesh_bmesh_get(const Object *ob)
Definition editmesh.cc:65
@ G_TRANSFORM_OBJ
@ G_TRANSFORM_EDIT
PropertyRNA * RNA_def_enum_flag(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
void DEG_relations_tag_update(Main *bmain)
void RNA_property_boolean_set(PointerRNA *ptr, PropertyRNA *prop, bool value)
Scene * CTX_data_scene(const bContext *C)
@ OPTYPE_REGISTER
Definition WM_types.hh:188
@ OPTYPE_UNDO
Definition WM_types.hh:190
std::string RNA_string_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
void BKE_collection_new_name_get(Collection *collection_parent, char r_name[256])
@ BKE_MESH_BATCH_DIRTY_ALL
Definition BKE_mesh.h:48
int RNA_property_int_get(PointerRNA *ptr, PropertyRNA *prop)
bool BKE_id_is_editable(const Main *bmain, const ID *id)
Definition lib_id.cc:2782
@ MOTIONPATH_BAKE_HAS_PATHS
void ED_mball_editmball_load(Object *obedit)
Definition mball_edit.cc:87
Object * CTX_data_active_object(const bContext *C)
bool ED_operator_object_active_editable_ex(bContext *C, const Object *ob)
bool BKE_layer_collection_has_selected_objects(const Main &bmain, const Scene *scene, ViewLayer *view_layer, LayerCollection *lc)
ListBaseT< Base > * BKE_view_layer_object_bases_get(ViewLayer *view_layer)
float RNA_float_get(PointerRNA *ptr, const char *name)
PointerRNA CTX_data_pointer_get_type(const bContext *C, const char *member, StructRNA *type)
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
View3D * CTX_wm_view3d(const bContext *C)
bool BKE_object_obdata_is_libdata(const Object *ob)
Definition object.cc:2845
bool ED_object_posemode_enter(bContext *C, Object *ob)
Definition pose_edit.cc:102
void ED_mball_editmball_make(Object *obedit)
Definition mball_edit.cc:70
Collection * BKE_collection_add(Main *bmain, Collection *collection_parent, const char *name_custom)
#define COLLECTION_INVALID_INDEX
eAssetLibraryType asset_library_type
struct Object * object
ListBaseT< CollectionChild > children
EditNurb * editnurb
struct EditFont * editfont
char name[258]
Definition DNA_ID.h:433
unsigned int session_uid
Definition DNA_ID.h:463
struct LibraryWeakReference * library_weak_reference
Definition DNA_ID.h:529
struct Library * lib
Definition DNA_ID.h:421
struct EditLatt * editlatt
eLayerCollection_Flag flag
struct Collection * collection
ListBaseT< LayerCollection > layer_collections
eLayerCollection_RuntimeFlag runtime_flag
unsigned short local_collections_bits
ListBaseT< Object > objects
Definition BKE_main.hh:388
bool is_memfile_undo_written
Definition BKE_main.hh:297
char idname[BKE_ST_MAXNAME]
char translation_context[BKE_ST_MAXNAME]
char label[BKE_ST_MAXNAME]
MenuTypeFlag flag
void(*) draw(const bContext *C, Menu *menu)
ui::Layout * layout
MenuType * type
ListBaseT< MetaElem > * editelems
eObjectMode restore_mode
struct PartDeflect * pd
struct Object * parent
ListBaseT< ModifierData > modifiers
eObject_VisibilityFlag visibility_flag
bAnimVizSettings avs
eObject_Partype partype
bMotionPath * mpath
eObject_EmptyDrawType empty_drawtype
struct bPose * pose
bool(*) filter_fn(const Object *ob, void *user_data)
Definition BKE_layer.hh:616
bool(*) filter_fn(const Object *ob, void *user_data)
Definition BKE_layer.hh:593
T * data_as() const
Definition RNA_types.hh:139
struct Collection * master_collection
struct ToolSettings * toolsettings
ListBaseT< SpaceLink > spacedata
unsigned short local_collections_uid
struct View3D * localvd
unsigned short local_view_uid
ListBaseT< LayerCollection > layer_collections
eMotionPath_Ranges path_range
eMotionPath_BakeFlag path_bakeflag
eMotionPaths_Types path_type
ListBaseT< EditBone > * edbo
eNodeTree_Type type
bAnimVizSettings avs
ListBaseT< bPoseChannel > chanbase
void use_property_decorate_set(bool is_decorate)
void operator_context_set(wm::OpCallContext opcontext)
wm::OpCallContext operator_context() const
void use_property_split_set(bool is_sep)
PointerRNA op(wmOperatorType *ot, std::optional< StringRef > name, int icon, wm::OpCallContext context, eUI_Item_Flag flag)
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< StringRef > name_opt, int icon, std::optional< StringRef > placeholder=std::nullopt)
void menu(MenuType *mt, std::optional< StringRef > name, int icon)
const PointerRNA * context_ptr_get(const StringRef name, const StructRNA *type) const
void active_set(bool active)
Layout & column(bool align)
void separator(float factor=1.0f, LayoutSeparatorType type=LayoutSeparatorType::Auto)
Layout & row(bool align)
void context_ptr_set(StringRef name, const PointerRNA *ptr)
wmEventModifierFlag modifier
Definition WM_types.hh:834
wmOperatorStatus(*) exec(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1125
const char * description
Definition WM_types.hh:1115
const char * translation_context
Definition WM_types.hh:1113
void(*) ui(bContext *C, wmOperator *op)
Definition WM_types.hh:1176
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
std::string(*) get_description(bContext *C, wmOperatorType *ot, PointerRNA *ptr)
Definition WM_types.hh:1197
struct ReportList * reports
struct wmOperatorType * type
#define N_(msgid)
#define WM_msg_publish_rna_prop(mbus, id_, data_, type_, prop_)