Blender V5.3
node_group_operator.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include "BLI_array_utils.hh"
10#include "BLI_index_mask.hh"
11#include "BLI_listbase.hh"
12#include "BLI_rect.hh"
13#include "BLI_string_utf8.hh"
14
15#include "DNA_key_types.h"
16#include "ED_curves.hh"
17#include "ED_grease_pencil.hh"
18#include "ED_object.hh"
19#include "ED_screen.hh"
20#include "ED_select_utils.hh"
21#include "ED_view3d.hh"
22
23#include "WM_api.hh"
24
25#include "BKE_asset.hh"
28#include "BKE_context.hh"
29#include "BKE_curves.hh"
30#include "BKE_customdata.hh"
31#include "BKE_editmesh.hh"
32#include "BKE_geometry_set.hh"
33#include "BKE_global.hh"
34#include "BKE_grease_pencil.hh"
35#include "BKE_idprop_hash.hh"
36#include "BKE_layer.hh"
37#include "BKE_lib_id.hh"
38#include "BKE_lib_query.hh"
39#include "BKE_main.hh"
40#include "BKE_material.hh"
41#include "BKE_mesh.hh"
42#include "BKE_mesh_wrapper.hh"
43#include "BKE_node_runtime.hh"
44#include "BKE_object.hh"
45#include "BKE_paint.hh"
46#include "BKE_paint_bvh.hh"
47#include "BKE_pointcloud.hh"
48#include "BKE_report.hh"
49#include "BKE_scene.hh"
50#include "BKE_screen.hh"
51#include "BKE_workspace.hh"
52
53#include "DNA_object_types.h"
54#include "DNA_scene_types.h"
55
56#include "DEG_depsgraph.hh"
59
60#include "RNA_access.hh"
61#include "RNA_define.hh"
62#include "RNA_enum_types.hh"
63#include "RNA_prototypes.hh"
64
66#include "UI_resources.hh"
67
68#include "ED_asset.hh"
70#include "ED_geometry.hh"
71#include "ED_mesh.hh"
72#include "ED_sculpt.hh"
73
74#include "BLT_translation.hh"
75
76#include "NOD_dependencies.hh"
81
82#include "AS_asset_catalog.hh"
84#include "AS_asset_library.hh"
86
87#include "PRF_profile.hh"
88
89#include <xxhash.h>
90
91#include "geometry_intern.hh"
92
93#include <fmt/format.h>
94
95namespace blender::ed::geometry {
96
97using asset_system::AssetRepresentation;
98
108
121
123{
124 static RegistrationData data;
125 return data;
126}
127
133 std::string name;
134 std::string idname;
136 std::string description;
138
139 std::unique_ptr<IDProperty, bke::idprop::IDPropertyDeleter> asset_meta_data_properties;
142
146 std::variant<AssetWeakReference, LocalRef> group_ref;
147
148 /* Only for assets: Set to true if the asset isn't available offline or it was downloaded before
149 * but is inconsistent now (e.g. outdated or missing new dependencies). For non-asset IDs this is
150 * always false. */
152
154
155 static std::optional<OperatorTypeData> from_asset(const AssetRepresentation &asset,
157 static std::optional<OperatorTypeData> from_group(const bNodeTree &group,
159
160 private:
162 void ensure_hash();
163};
164
165void OperatorTypeData::ensure_hash()
166{
167 XXH3_state_t *hash_state = XXH3_createState();
168 BLI_SCOPED_DEFER([&hash_state]() -> void { XXH3_freeState(hash_state); })
169 XXH3_128bits_reset(hash_state);
170 XXH3_128bits_update(hash_state, this->name.data(), this->name.size());
171 XXH3_128bits_update(hash_state, this->description.data(), this->description.size());
172 XXH3_128bits_update(hash_state, &this->flag, sizeof(this->flag));
173 std::visit(
174 [&](const auto &value) {
175 using T = std::decay_t<decltype(value)>;
176 if constexpr (std::is_same_v<T, AssetWeakReference>) {
177 XXH3_128bits_update(
178 hash_state, &value.asset_library_type, sizeof(value.asset_library_type));
179 if (value.asset_library_identifier) {
180 XXH3_128bits_update(hash_state,
181 value.asset_library_identifier,
182 strlen(value.asset_library_identifier));
183 }
184 if (value.relative_asset_identifier) {
185 XXH3_128bits_update(hash_state,
186 value.relative_asset_identifier,
187 strlen(value.relative_asset_identifier));
188 }
189 }
190 else if constexpr (std::is_same_v<T, LocalRef>) {
191 XXH3_128bits_update(hash_state, &value.session_uid, sizeof(value.session_uid));
192 }
193 else {
195 }
196 },
197 this->group_ref);
199 static_assert(sizeof(this->hash) == sizeof(XXH128_hash_t));
200 const XXH128_hash_t xxh3_hash = XXH3_128bits_digest(hash_state);
201 this->hash = {xxh3_hash.low64, xxh3_hash.high64};
202}
203
204static std::optional<std::string> operator_idname_get(const StringRefNull custom_idname,
206{
207 ReportList reports;
209 BLI_SCOPED_DEFER([&]() { BKE_reports_free(&reports); });
210 if (!WM_operator_idname_ok_or_report(&reports, custom_idname.c_str())) {
211 if (errors) {
212 ErrorsForType &errors_for_type = errors->lookup_or_add_default_as(custom_idname);
213 for (Report &report : reports.list) {
214 errors_for_type.idname_validation_errors.append_as(report.message);
215 }
216 }
217 return std::nullopt;
218 }
219 char idname_buf[OP_MAX_TYPENAME];
220 WM_operator_bl_idname(idname_buf, custom_idname.c_str());
221 return idname_buf;
222}
223
224static std::optional<StringRefNull> custom_idname_for_asset(const AssetRepresentation &asset)
225{
226 const AssetMetaData &metadata = asset.get_metadata();
227 const IDProperty *id_property = BKE_asset_metadata_idprop_find(&metadata, "node_tool_idname");
228 if (!id_property || id_property->type != IDP_STRING) {
229 return std::nullopt;
230 }
231 return IDP_string_get(id_property);
232}
233
234std::optional<OperatorTypeData> OperatorTypeData::from_asset(
236{
237 const std::optional<StringRefNull> custom_idname = custom_idname_for_asset(asset);
238 if (!custom_idname) {
239 return std::nullopt;
240 }
241 std::optional<std::string> idname = operator_idname_get(*custom_idname, &errors);
242 if (!idname) {
243 return std::nullopt;
244 }
245
246 const AssetMetaData &metadata = asset.get_metadata();
247 OperatorTypeData type_data;
248 type_data.name = asset.get_name();
249 type_data.idname = std::move(*idname);
250 type_data.custom_idname = *custom_idname;
251 type_data.description = metadata.description ? metadata.description : "";
252 const IDProperty *traits_flag = BKE_asset_metadata_idprop_find(
253 &metadata, "geometry_node_asset_traits_flag");
254 if (!traits_flag || traits_flag->type != IDP_INT) {
255 ErrorsForType &errors_for_type = errors.lookup_or_add_default_as(*custom_idname);
256 errors_for_type.invalid_metadata = true;
257 return std::nullopt;
258 }
259 type_data.flag = GeometryNodeAssetTraitFlag(IDP_int_get(traits_flag));
260 type_data.group_ref = asset.make_weak_reference();
261 type_data.asset_needs_downloading = asset.needs_download();
262
263 const IDProperty *properties = BKE_asset_metadata_idprop_find(&metadata, "properties");
264 if (!properties || properties->type != IDP_GROUP) {
265 ErrorsForType &errors_for_type = errors.lookup_or_add_default_as(*custom_idname);
266 errors_for_type.invalid_metadata = true;
267 return std::nullopt;
268 }
269 const IDProperty *inputs = IDP_GetPropertyFromGroup(properties, "inputs");
270 if (!inputs || inputs->type != IDP_GROUP) {
271 ErrorsForType &errors_for_type = errors.lookup_or_add_default_as(*custom_idname);
272 errors_for_type.invalid_metadata = true;
273 return std::nullopt;
274 }
275 for (const IDProperty &input_prop : inputs->data.group) {
276 if (input_prop.type != IDP_GROUP ||
277 !IDP_GetPropertyTypeFromGroup(&input_prop, "type", IDP_INT))
278 {
279 ErrorsForType &errors_for_type = errors.lookup_or_add_default_as(*custom_idname);
280 errors_for_type.invalid_input_metadata_errors.append(input_prop.name);
281 return std::nullopt;
282 }
283 }
285 std::unique_ptr<IDProperty, bke::idprop::IDPropertyDeleter>(IDP_CopyProperty(properties));
286
287 type_data.ensure_hash();
288 return type_data;
289}
290
291static std::optional<StringRefNull> custom_idname_for_group(const bNodeTree &group)
292{
293 const char *idname = group.geometry_node_asset_traits->node_tool_idname;
294 if (!idname) {
295 return std::nullopt;
296 }
297 return StringRefNull(idname);
298}
299
300std::optional<OperatorTypeData> OperatorTypeData::from_group(const bNodeTree &group,
302{
303 const std::optional<StringRefNull> custom_idname = custom_idname_for_group(group);
304 if (!custom_idname) {
305 return std::nullopt;
306 }
307 std::optional<std::string> idname = operator_idname_get(*custom_idname, &errors);
308 if (!idname) {
309 return std::nullopt;
310 }
311 OperatorTypeData type_data;
312 type_data.name = BKE_id_name(group.id);
313 type_data.idname = std::move(*idname);
314 type_data.custom_idname = *custom_idname;
315 type_data.description = group.description ? group.description : "";
318 type_data.asset_needs_downloading = false;
319
321 std::unique_ptr<IDProperty, bke::idprop::IDPropertyDeleter>(
323
324 type_data.ensure_hash();
325 return type_data;
326}
327
329
330/* -------------------------------------------------------------------- */
333
335 const wmOperatorType &ot,
336 ReportList *reports)
337{
338 Main &bmain = *CTX_data_main(&C);
339 const auto &type_data = static_cast<const OperatorTypeData &>(*ot.custom_data);
340 return std::visit(
341 [&](const auto &value) -> const bNodeTree * {
342 using T = std::decay_t<decltype(value)>;
343 if constexpr (std::is_same_v<T, OperatorTypeData::LocalRef>) {
344 return id_cast<const bNodeTree *>(
345 BKE_libblock_find_session_uid(&bmain, ID_NT, value.session_uid));
346 }
347 else if constexpr (std::is_same_v<T, AssetWeakReference>) {
349 C, value, reports);
350 if (!asset) {
351 return nullptr;
352 }
353 if (asset->is_online_only()) {
354 if (reports) {
355 BKE_reportf(reports,
356 RPT_ERROR,
357 "Node tool '%s' needs downloading before it can be used (check context "
358 "menu)",
359 asset->get_name().c_str());
360 }
361 return nullptr;
362 }
363 return id_cast<const bNodeTree *>(asset::asset_local_id_ensure_imported(bmain, *asset));
364 }
365 else {
367 }
368 },
369 type_data.group_ref);
370}
371
372static const bNodeTree *get_node_group(const bContext &C,
373 const wmOperatorType &ot,
374 ReportList *reports)
375{
376 const bNodeTree *group = get_asset_or_local_node_group(C, ot, reports);
377 if (!group) {
378 return nullptr;
379 }
380 if (group->type != NTREE_GEOMETRY) {
381 if (reports) {
382 BKE_report(reports, RPT_ERROR, "Asset is not a geometry node group");
383 }
384 return nullptr;
385 }
386 return group;
387}
388
390
397{
398 static GeoOperatorLog log;
399 return log;
400}
401
406
408static void find_verbose_log_contexts(const Main &bmain,
409 Set<ComputeContextHash> &r_verbose_log_contexts)
410{
411 wmWindowManager *wm = bmain.wm.first();
412 if (wm == nullptr) {
413 return;
414 }
415 for (const wmWindow &window : wm->windows) {
417 for (const ScrArea &area : screen->areabase) {
418 const SpaceLink *sl = area.spacedata.first_as<SpaceLink>();
419 if (sl->spacetype == SPACE_NODE) {
420 const SpaceNode &snode = *reinterpret_cast<const SpaceNode *>(sl);
421 if (snode.edittree == nullptr) {
422 continue;
423 }
425 continue;
426 }
427 bke::ComputeContextCache compute_context_cache;
430 snode, compute_context_cache);
431 for (const ComputeContextHash &hash : hash_by_zone.values()) {
432 r_verbose_log_contexts.add(hash);
433 }
434 }
435 }
436 }
437}
438
440{
441 const int layer_index = CustomData_get_layer_index(&mesh.vert_data, CD_MDEFORMVERT);
442 if (layer_index == -1) {
443 return nullptr;
444 }
445 return mesh.vert_data.layers[layer_index].sharing_info;
446}
447
454 VectorSet<ImplicitSharingPtr<>> sharing_infos_;
455
456 public:
458 {
459 if (mesh.runtime->face_offsets_sharing_info) {
460 this->freeze_shared_state(*mesh.runtime->face_offsets_sharing_info);
461 }
462 mesh.attributes().foreach_attribute([&](const bke::AttributeIter &iter) {
463 const bke::GAttributeReader attribute = iter.get();
464 if (attribute.varray.size() == 0) {
465 return;
466 }
467 if (attribute.sharing_info) {
468 this->freeze_shared_state(*attribute.sharing_info);
469 }
470 });
471 if (const ImplicitSharingInfo *sharing_info = get_vertex_group_sharing_info(mesh)) {
472 this->freeze_shared_state(*sharing_info);
473 }
474 }
475
476 void freeze_shared_state(const ImplicitSharingInfo &sharing_info)
477 {
478 if (sharing_infos_.add(ImplicitSharingPtr<>{&sharing_info})) {
479 sharing_info.add_user();
480 }
481 }
482};
483
484static std::string shape_key_attribute_name(const KeyBlock &kb)
485{
486 return fmt::format(".kb:{}", kb.name);
487}
488
490static void add_shape_keys_as_attributes(Mesh &mesh, const Key &key)
491{
492 bke::MutableAttributeAccessor attributes = mesh.attributes_for_write();
493 for (const KeyBlock &kb : key.block) {
494 if (&kb == key.refkey) {
495 /* The basis key will just receive values from the mesh positions. */
496 continue;
497 }
498 const Span<float3> key_data(static_cast<float3 *>(kb.data), kb.totelem);
499 attributes.add<float3>(shape_key_attribute_name(kb),
502 }
503}
504
505/* Copy shape key attributes back to the key data-block. */
507{
508 const bke::AttributeAccessor attributes = mesh.attributes();
509 for (KeyBlock &kb : key.block) {
510 const VArray attr = *attributes.lookup<float3>(shape_key_attribute_name(kb),
512 if (!attr) {
513 continue;
514 }
515 MEM_delete(static_cast<float3 *>(kb.data));
516 kb.data = MEM_new_array_uninitialized<float3>(attr.size(), __func__);
517 kb.totelem = attr.size();
518 attr.materialize({static_cast<float3 *>(kb.data), attr.size()});
519 }
520 if (KeyBlock *kb = key.refkey) {
521 const Span<float3> positions = mesh.vert_positions();
522 MEM_delete(static_cast<float3 *>(kb->data));
523 kb->data = MEM_new_array_uninitialized<float3>(positions.size(), __func__);
524 kb->totelem = positions.size();
525 array_utils::copy(positions, MutableSpan(static_cast<float3 *>(kb->data), positions.size()));
526 }
527}
528
529static void remove_shape_key_attributes(Mesh &mesh, const Key &key)
530{
531 bke::MutableAttributeAccessor attributes = mesh.attributes_for_write();
532 for (KeyBlock &kb : key.block) {
533 attributes.remove(shape_key_attribute_name(kb));
534 }
535}
536
544 Object &object,
545 nodes::GeoNodesOperatorData &operator_data,
546 Vector<MeshState> &orig_mesh_states)
547{
548 switch (object.type) {
549 case OB_CURVES: {
550 Curves *curves = BKE_curves_copy_for_eval(id_cast<const Curves *>(object.data));
552 }
553 case OB_POINTCLOUD: {
554 PointCloud *points = BKE_pointcloud_copy_for_eval(id_cast<const PointCloud *>(object.data));
556 }
557 case OB_MESH: {
558 Mesh *mesh = id_cast<Mesh *>(object.data);
559
560 if (mesh->runtime->edit_mesh) {
564 operator_data.active_face_index = BM_mesh_active_face_index_get(bm, false, true);
565 EDBM_mesh_load_ex(DEG_get_bmain(&depsgraph), &object, true);
566 EDBM_mesh_free_data(mesh->runtime->edit_mesh.get());
567 /* Clear the edit-mesh entirely rather than just freeing its #BMesh. Leaving a #BMEditMesh
568 * with a null `bm` behind is a non-standard state that other code (e.g. the active
569 * attribute lookup when the tool result is stored back) doesn't expect. The edit-mesh is
570 * rebuilt from the tool result in #EDBM_mesh_make_from_mesh. */
571 mesh->runtime->edit_mesh.reset();
572 }
573
575 /* Currently many sculpt mode operations do not tag normals dirty (see use of
576 * #Mesh::tag_positions_changed_no_normals()), so access within geometry nodes cannot
577 * know that normals are out of date and recalculate them. Update them here instead. */
578 bke::pbvh::update_normals(depsgraph, object, *pbvh);
579 }
580
581 if (Key *key = mesh->key) {
582 /* Add the shape key attributes to the original mesh before the evaluated copy. Applying
583 * the result of the operator in sculpt mode uses the attributes on the original mesh to
584 * detect which changes. */
586 }
587
588 Mesh *mesh_copy = BKE_mesh_copy_for_eval(*mesh);
589 orig_mesh_states.append_as(*mesh_copy);
590 return bke::GeometrySet::from_mesh(mesh_copy);
591 }
592 case OB_GREASE_PENCIL: {
593 const GreasePencil *grease_pencil = id_cast<const GreasePencil *>(object.data);
594 if (const bke::greasepencil::Layer *active_layer = grease_pencil->get_active_layer()) {
595 operator_data.active_layer_index = *grease_pencil->get_layer_index(*active_layer);
596 }
598 grease_pencil_copy->runtime->eval_frame = int(DEG_get_ctime(&depsgraph));
599 return bke::GeometrySet::from_grease_pencil(grease_pencil_copy);
600 }
601 default:
602 return {};
603 }
604}
605
607 const wmOperator &op,
608 const Depsgraph &depsgraph,
609 Main &bmain,
610 Scene &scene,
611 Object &object,
612 const RegionView3D *rv3d,
614{
615 geometry.ensure_owns_direct_data();
616 switch (object.type) {
617 case OB_CURVES: {
618 Curves &curves = *id_cast<Curves *>(object.data);
619 Curves *new_curves = geometry.get_curves_for_write();
620 if (!new_curves) {
621 curves.geometry.wrap() = {};
623 break;
624 }
625
626 /* Anonymous attributes shouldn't be available on the applied geometry. */
627 new_curves->geometry.wrap().attributes_for_write().remove_anonymous();
628
629 curves.geometry.wrap() = std::move(new_curves->geometry.wrap());
630 BKE_object_material_from_eval_data(&bmain, &object, &new_curves->id);
632 break;
633 }
634 case OB_POINTCLOUD: {
635 PointCloud &points = *id_cast<PointCloud *>(object.data);
636 PointCloud *new_points =
637 geometry.get_component_for_write<bke::PointCloudComponent>().release();
638 if (!new_points) {
639 points.attribute_storage.wrap() = {};
640 points.totpoint = 0;
642 break;
643 }
644
645 /* Anonymous attributes shouldn't be available on the applied geometry. */
646 new_points->attributes_for_write().remove_anonymous();
647
648 BKE_object_material_from_eval_data(&bmain, &object, &new_points->id);
649 BKE_pointcloud_nomain_to_pointcloud(new_points, &points);
651 break;
652 }
653 case OB_MESH: {
654 Mesh &mesh = *id_cast<Mesh *>(object.data);
655
656 Mesh *new_mesh = geometry.get_component_for_write<bke::MeshComponent>().release();
657 if (new_mesh) {
658 /* Anonymous attributes shouldn't be available on the applied geometry. */
659 new_mesh->attributes_for_write().remove_anonymous();
660 BKE_object_material_from_eval_data(&bmain, &object, &new_mesh->id);
661 }
662 else {
663 new_mesh = BKE_mesh_new_nomain(0, 0, 0, 0);
664 }
665
666 if (Key *key = mesh.key) {
667 /* Copy the evaluated shape key attributes back to the key data-block. */
668 store_attributes_to_shape_keys(*new_mesh, *key);
669 }
670
671 if (object.mode == OB_MODE_SCULPT) {
672 sculpt_paint::store_mesh_from_eval(op, scene, depsgraph, rv3d, object, new_mesh);
673 if (Key *key = mesh.key) {
674 /* Make sure to free the shape key attributes after `sculpt_paint::store_mesh_from_eval`
675 * because that uses the attributes to detect changes, for a critical performance
676 * optimization when only changing specific attributes. */
678 }
679 }
680 else {
681 if (Key *key = mesh.key) {
682 /* Make sure to free the attributes before converting to #BMesh for edit mode; removing
683 * attributes on #BMesh requires reallocating the dynamic AoS storage. */
684 remove_shape_key_attributes(*new_mesh, *key);
685 }
686 if (object.mode == OB_MODE_EDIT) {
687 EDBM_mesh_make_from_mesh(&object, new_mesh, scene.toolsettings->selectmode, true);
688 BKE_editmesh_looptris_and_normals_calc(mesh.runtime->edit_mesh.get(),
690 BKE_id_free(nullptr, new_mesh);
692 }
693 else {
694 BKE_mesh_nomain_to_mesh(new_mesh, &mesh, &object, false);
696 }
697 }
698
699 break;
700 }
701 case OB_GREASE_PENCIL: {
702 const int eval_frame = int(DEG_get_ctime(&depsgraph));
703
704 GreasePencil &grease_pencil = *id_cast<GreasePencil *>(object.data);
705 Vector<int> editable_layer_indices;
706 for (const int layer_i : grease_pencil.layers().index_range()) {
707 const bke::greasepencil::Layer &layer = grease_pencil.layer(layer_i);
708 if (!layer.is_editable()) {
709 continue;
710 }
711 editable_layer_indices.append(layer_i);
712 }
713
714 bool inserted_new_keyframe = false;
715 for (const int layer_i : editable_layer_indices) {
717 /* TODO: For now, we always create a blank keyframe, but it might be good to expose this as
718 * an option and allow to duplicate the previous key. */
719 const bool duplicate_previous_key = false;
721 scene, grease_pencil, layer, duplicate_previous_key, inserted_new_keyframe);
722 }
723 GreasePencil *new_grease_pencil =
724 geometry.get_component_for_write<bke::GreasePencilComponent>().get_for_write();
725 if (!new_grease_pencil) {
726 /* Clear the Grease Pencil geometry. */
727 for (const int layer_i : editable_layer_indices) {
729 if (bke::greasepencil::Drawing *drawing_orig = grease_pencil.get_drawing_at(layer,
730 eval_frame))
731 {
732 drawing_orig->strokes_for_write() = {};
733 drawing_orig->tag_topology_changed();
734 }
735 }
736 }
737 else {
738 IndexMaskMemory memory;
739 const IndexMask editable_layers = IndexMask::from_indices(editable_layer_indices.as_span(),
740 memory);
742 *new_grease_pencil, eval_frame, editable_layers, grease_pencil);
743
744 /* There might be layers with empty names after evaluation. Make sure to rename them. */
746 BKE_object_material_from_eval_data(&bmain, &object, &new_grease_pencil->id);
747 }
748
750 if (inserted_new_keyframe) {
752 }
753 break;
754 }
755 default:
756 break;
757 }
758}
759
765static void gather_node_group_ids(const bNodeTree &node_tree, Set<ID *> &ids)
766{
767 const int orig_size = ids.size();
769 for (ID *id : node_tree.runtime->eval_dependencies->ids.values()) {
770 ids.add(id);
771 }
772 if (ids.size() != orig_size) {
773 /* Only evaluate the node group if it references data-blocks. In that case it needs to be
774 * evaluated so that ID pointers are switched to point to evaluated data-blocks. */
775 ids.add(const_cast<ID *>(&node_tree.id));
776 }
777}
778
779static std::optional<ID_Type> socket_type_to_id_type(const eNodeSocketDatatype socket_type)
780{
781 switch (socket_type) {
782 case SOCK_CUSTOM:
783 case SOCK_FLOAT:
784 case SOCK_VECTOR:
785 case SOCK_INT_VECTOR:
786 case SOCK_RGBA:
787 case SOCK_SHADER:
788 case SOCK_BOOLEAN:
789 case SOCK_INT:
790 case SOCK_STRING:
791 case SOCK_GEOMETRY:
792 case SOCK_ROTATION:
793 case SOCK_MENU:
794 case SOCK_MATRIX:
795 case SOCK_BUNDLE:
796 case SOCK_CLOSURE:
797 return std::nullopt;
798 case SOCK_OBJECT:
799 return ID_OB;
800 case SOCK_IMAGE:
801 return ID_IM;
802 case SOCK_COLLECTION:
803 return ID_GR;
804 case SOCK_TEXTURE:
805 return ID_TE;
806 case SOCK_MATERIAL:
807 return ID_MA;
808 case SOCK_FONT:
809 return ID_VF;
810 case SOCK_SCENE:
811 return ID_SCE;
812 case SOCK_TEXT_ID:
813 return ID_TXT;
814 case SOCK_MASK:
815 return ID_MSK;
816 case SOCK_SOUND:
817 return ID_SO;
818 }
819 return std::nullopt;
820}
821
828 const bNodeTree &node_group,
829 const PointerRNA &properties_ptr)
830{
831 PointerRNA inputs_ptr = RNA_pointer_get(const_cast<PointerRNA *>(&properties_ptr), "inputs");
832
834 for (const bNodeTreeInterfaceSocket *input : node_group.interface_inputs()) {
835 const std::optional<ID_Type> id_type = socket_type_to_id_type(input->socket_typeinfo()->type);
836 if (!id_type) {
837 continue;
838 }
839 PointerRNA input_props_ptr = RNA_pointer_get(&inputs_ptr, input->identifier);
840 std::string name = RNA_string_get(&input_props_ptr, "value");
841 ID *id = BKE_libblock_find_name(&const_cast<Main &>(bmain), *id_type, name.c_str());
842 if (!id) {
843 continue;
844 }
845 ids.add(std::move(name), id);
846 }
847 return ids;
848}
849
850static Depsgraph *build_extra_depsgraph(const Depsgraph &depsgraph_active, const Set<ID *> &ids)
851{
852 Depsgraph *depsgraph = DEG_graph_new(DEG_get_bmain(&depsgraph_active),
853 DEG_get_input_scene(&depsgraph_active),
854 DEG_get_input_view_layer(&depsgraph_active),
855 DEG_get_mode(&depsgraph_active));
856 DEG_graph_build_from_ids(depsgraph, Vector<ID *>(ids.begin(), ids.end()));
857 DEG_evaluate_on_refresh(depsgraph);
858 return depsgraph;
859}
860
861static bool object_has_editable_data(const Main &bmain, const Object &object)
862{
863 if (!ELEM(object.type, OB_CURVES, OB_POINTCLOUD, OB_MESH, OB_GREASE_PENCIL)) {
864 return false;
865 }
866 if (!BKE_id_is_editable(&bmain, static_cast<const ID *>(object.data))) {
867 return false;
868 }
869 return true;
870}
871
873 const Main &bmain,
874 const eObjectMode mode)
875{
876 Vector<Object *> objects;
877 Set<const ID *> unique_object_data;
878
879 auto handle_object = [&](Object *object) {
880 if (object->mode != mode) {
881 return;
882 }
883 if (!unique_object_data.add(static_cast<const ID *>(object->data))) {
884 return;
885 }
886 if (!object_has_editable_data(bmain, *object)) {
887 return;
888 }
889 objects.append(object);
890 };
891
892 if (mode == OB_MODE_OBJECT) {
893 CTX_DATA_BEGIN (&C, Object *, object, selected_objects) {
894 handle_object(object);
895 }
897 }
898 else {
899 const Main *bmain = CTX_data_main(&C);
900 Scene *scene = CTX_data_scene(&C);
901 ViewLayer *view_layer = CTX_data_view_layer(&C);
902 View3D *v3d = CTX_wm_view3d(&C);
903 Object *active_object = CTX_data_active_object(&C);
904 if (v3d && active_object) {
905 FOREACH_OBJECT_IN_MODE_BEGIN (bmain, scene, view_layer, v3d, active_object->type, mode, ob) {
906 handle_object(ob);
907 }
909 }
910 }
911 return objects;
912}
913
926 wmOperator &op,
927 const wmEvent &event)
928{
929 Scene *scene = CTX_data_scene(&C);
930 /* NOTE: `region` and `rv3d` may be null when called from a script. */
931 const ARegion *region = CTX_wm_region(&C);
932 const RegionView3D *rv3d = CTX_wm_region_view3d(&C);
933
934 /* Mouse position node inputs. */
935 RNA_int_set_array(op.ptr, "mouse_position", event.mval);
937 op.ptr,
938 "region_size",
939 region ? int2(BLI_rcti_size_x(&region->winrct), BLI_rcti_size_y(&region->winrct)) : int2(0));
940
941 /* 3D cursor node inputs. */
942 const View3DCursor &cursor = scene->cursor;
943 RNA_float_set_array(op.ptr, "cursor_position", cursor.location);
944 math::Quaternion cursor_rotation = cursor.rotation();
945 RNA_float_set_array(op.ptr, "cursor_rotation", &cursor_rotation.w);
946
947 /* Viewport transform node inputs. */
949 "viewport_projection_matrix",
950 rv3d ? float4x4(rv3d->winmat).base_ptr() : float4x4::identity().base_ptr());
952 "viewport_view_matrix",
953 rv3d ? float4x4(rv3d->viewmat).base_ptr() : float4x4::identity().base_ptr());
954 RNA_boolean_set(op.ptr, "viewport_is_perspective", rv3d ? bool(rv3d->is_persp) : true);
955}
956
958{
959 Main *bmain = CTX_data_main(C);
960 Scene *scene = CTX_data_scene(C);
961 Object *active_object = CTX_data_active_object(C);
962 if (!active_object) {
963 return OPERATOR_CANCELLED;
964 }
965 const eObjectMode mode = active_object->mode;
966
967 const bNodeTree *node_tree_orig = get_node_group(*C, *op->type, op->reports);
968 if (!node_tree_orig) {
969 return OPERATOR_CANCELLED;
970 }
971
972 const Vector<Object *> objects = gather_supported_objects(*C, *bmain, mode);
973
974 Depsgraph *depsgraph_active = CTX_data_ensure_evaluated_depsgraph(C);
975 Set<ID *> extra_ids;
976 gather_node_group_ids(*node_tree_orig, extra_ids);
977 const Map<std::string, ID *> input_ids = gather_input_ids(*bmain, *node_tree_orig, *op->ptr);
978 for (ID *id : input_ids.values()) {
979 /* Skip IDs that are already fully evaluated in the active depsgraph. */
980 if (!DEG_id_is_fully_evaluated(depsgraph_active, id)) {
981 extra_ids.add(id);
982 }
983 }
984
985 const nodes::GeoNodesOperatorDepsgraphs depsgraphs{
986 depsgraph_active,
987 extra_ids.is_empty() ? nullptr : build_extra_depsgraph(*depsgraph_active, extra_ids),
988 };
989
990 const bNodeTree *node_tree = nullptr;
991 if (depsgraphs.extra) {
992 node_tree = DEG_get_evaluated(depsgraphs.extra, node_tree_orig);
993 }
994 else {
995 node_tree = node_tree_orig;
996 }
997
998 const nodes::GeometryNodesLazyFunctionGraphInfo *lf_graph_info =
1000 if (lf_graph_info == nullptr) {
1001 BKE_report(op->reports, RPT_ERROR, "Cannot evaluate node group");
1002 return OPERATOR_CANCELLED;
1003 }
1004
1005 if (!node_tree->group_output_node()) {
1006 BKE_report(op->reports, RPT_ERROR, "Node group must have a group output node");
1007 return OPERATOR_CANCELLED;
1008 }
1009 if (node_tree->interface_outputs().is_empty() ||
1010 !STREQ(node_tree->interface_outputs()[0]->socket_type, "NodeSocketGeometry"))
1011 {
1012 BKE_report(op->reports, RPT_ERROR, "Node group's first output must be a geometry");
1013 return OPERATOR_CANCELLED;
1014 }
1015
1016 bke::OperatorComputeContext compute_context;
1017 Set<ComputeContextHash> verbose_log_contexts;
1019 eval_log.log = std::make_unique<nodes::eval_log::NodesEvalLog>();
1020 eval_log.node_group_name = node_tree->id.name + 2;
1021 find_verbose_log_contexts(*bmain, verbose_log_contexts);
1022
1023 /* May be null if operator called from outside 3D view context. */
1024 const RegionView3D *rv3d = CTX_wm_region_view3d(C);
1025 Vector<MeshState> orig_mesh_states;
1026
1027 for (Object *object : objects) {
1028 nodes::GeoNodesOperatorData operator_eval_data{};
1029 operator_eval_data.mode = mode;
1030 operator_eval_data.depsgraphs = &depsgraphs;
1031 operator_eval_data.self_object_orig = object;
1032 operator_eval_data.scene_orig = scene;
1033 operator_eval_data.input_ids = &input_ids;
1034 RNA_int_get_array(op->ptr, "mouse_position", operator_eval_data.mouse_position);
1035 RNA_int_get_array(op->ptr, "region_size", operator_eval_data.region_size);
1036 RNA_float_get_array(op->ptr, "cursor_position", operator_eval_data.cursor_position);
1037 RNA_float_get_array(op->ptr, "cursor_rotation", &operator_eval_data.cursor_rotation.w);
1039 op->ptr, "viewport_projection_matrix", operator_eval_data.viewport_winmat.base_ptr());
1041 op->ptr, "viewport_view_matrix", operator_eval_data.viewport_viewmat.base_ptr());
1042 operator_eval_data.viewport_is_perspective = RNA_boolean_get(op->ptr,
1043 "viewport_is_perspective");
1044
1045 nodes::GeoNodesCallData call_data{};
1046 call_data.operator_data = &operator_eval_data;
1047 call_data.eval_log = eval_log.log.get();
1048 if (object == active_object) {
1049 /* Only log values from the active object. */
1050 call_data.verbose_log_contexts = &verbose_log_contexts;
1051 }
1052
1054 *depsgraph_active, *object, operator_eval_data, orig_mesh_states);
1055
1057 *node_tree, *op->ptr, compute_context, call_data, std::move(geometry_orig));
1058
1060 *C, *op, *depsgraph_active, *bmain, *scene, *object, rv3d, std::move(new_geometry));
1062 }
1063
1064 nodes::eval_log::NodeTreeLog &tree_log = eval_log.log->get_tree_log(compute_context.hash());
1065 tree_log.ensure_node_warnings(*bmain);
1066 for (const nodes::NodeWarning &warning : tree_log.all_warnings) {
1067 if (warning.type == nodes::NodeWarningType::Info) {
1068 BKE_report(op->reports, RPT_INFO, warning.message.c_str());
1069 }
1070 else {
1071 BKE_report(op->reports, RPT_WARNING, warning.message.c_str());
1072 }
1073 }
1074
1075 return OPERATOR_FINISHED;
1076}
1077
1079{
1080 const bNodeTree *node_tree = get_node_group(*C, *op->type, op->reports);
1081 if (!node_tree) {
1082 return OPERATOR_CANCELLED;
1083 }
1084
1085 store_input_node_values_rna_props(*C, *op, *event);
1086
1087 return run_node_group_exec(C, op);
1088}
1089
1091{
1092 ui::Layout &layout = *op->layout;
1093 layout.use_property_split_set(true);
1094 layout.use_property_decorate_set(false);
1095 Main *bmain = CTX_data_main(C);
1096 PointerRNA bmain_ptr = RNA_main_pointer_create(bmain);
1097
1098 const bNodeTree *node_tree = get_node_group(*C, *op->type, nullptr);
1099 if (!node_tree) {
1100 return;
1101 }
1102
1103 bke::OperatorComputeContext compute_context;
1105
1106 nodes::eval_log::NodeTreeLog *tree_log = eval_log.log ? &eval_log.log->get_tree_log(
1107 compute_context.hash()) :
1108 nullptr;
1110 *C, *op, const_cast<bNodeTree &>(*node_tree), tree_log);
1111}
1112
1113static bool run_node_ui_poll(wmOperatorType * /*ot*/, PointerRNA *ptr)
1114{
1115 bool result = false;
1116 RNA_STRUCT_BEGIN (ptr, prop) {
1117 int flag = RNA_property_flag(prop);
1118 if ((flag & PROP_HIDDEN) == 0) {
1119 result = true;
1120 break;
1121 }
1122 }
1124 return result;
1125}
1126
1128{
1129 const auto &type_data = *static_cast<const OperatorTypeData *>(ot->custom_data.get());
1130 const Object *active_object = CTX_data_active_object(C);
1131 if (!active_object) {
1132 return false;
1133 }
1134 const GeometryNodeAssetTraitFlag flag = asset_flag_for_context(*active_object);
1135 if (flag == GeometryNodeAssetTraitFlag(0)) {
1136 return false;
1137 }
1138 if ((type_data.flag & flag) != flag) {
1139 return false;
1140 }
1141 return true;
1142}
1143
1145{
1146 const IDProperty *items_idprop = IDP_GetPropertyFromGroup(&input_idprop, "items");
1147 if (!items_idprop || items_idprop->type != IDP_GROUP) {
1148 return {rna_enum_dummy_NULL_items[0]};
1149 }
1150
1152 for (const IDProperty &item_idprop : items_idprop->data.group) {
1153 if (item_idprop.type != IDP_GROUP) {
1154 continue;
1155 }
1157 .value = IDP_group_lookup_int(item_idprop, "value").value_or(0),
1158 .identifier = item_idprop.name,
1159 .icon = ICON_NONE,
1160 .name = item_idprop.name,
1161 .description = IDP_group_lookup_string(item_idprop, "description").value_or("").c_str(),
1162 });
1163 }
1164
1165 if (items.is_empty()) {
1166 return {rna_enum_dummy_NULL_items[0]};
1167 }
1168
1169 items.append({0, nullptr, 0, nullptr, nullptr});
1170
1171 return Array<EnumPropertyItem, 0>(items.as_span());
1172}
1173
1175 const EnumPropertyItem *items,
1176 const nodes::GeometryNodesInputType default_type)
1177{
1178 PropertyRNA *prop = RNA_def_enum(&srna, "type", items, int(default_type), "Input Type", "");
1180}
1181
1183 const StringRefNull name,
1184 const StringRefNull description,
1185 const IDProperty &input_idprop)
1186{
1187 const std::optional<StringRefNull> default_name = IDP_group_lookup_string(
1188 input_idprop, "default_attribute_name");
1189 RNA_def_string(&srna,
1190 "attribute_name",
1191 default_name.has_value() ? default_name->c_str() : nullptr,
1192 0,
1193 name.c_str(),
1194 description.c_str());
1195}
1196
1198 const StringRefNull name,
1199 const StringRefNull description,
1200 const IDProperty &input_idprop)
1201{
1205 make_common_attribute_name_prop(srna, name, description, input_idprop);
1206}
1207
1213
1215 OperatorTypeData &type_data)
1216{
1217 const StringRefNull identifier = input_idprop.name;
1218 const std::optional<int> type = IDP_group_lookup_int(input_idprop, "type");
1219 if (!type) {
1220 return nullptr;
1221 }
1223 &RNA_blender_rna_get(), identifier.c_str(), RNA_PropertyGroup);
1225 type_data.generated_structs.append(srna);
1226 // RNA_def_struct_path_func_runtime(srna, rna_NodesModifierPropertyInput_path);
1227 const StringRefNull name = IDP_group_lookup_string(input_idprop, "name").value_or(identifier);
1228 const StringRefNull description =
1229 IDP_group_lookup_string(input_idprop, "description").value_or("");
1230 RNA_def_struct_ui_text(srna, name.c_str(), description.c_str());
1231
1232 switch (eNodeSocketDatatype(*type)) {
1233 case SOCK_FLOAT: {
1234 PropertyRNA *prop = RNA_def_float(
1235 srna,
1236 "value",
1237 IDP_group_lookup_float(input_idprop, "default_value").value_or(0.0f),
1238 -FLT_MAX,
1239 FLT_MAX,
1240 name.c_str(),
1241 description.c_str(),
1242 IDP_group_lookup_float(input_idprop, "min").value_or(-FLT_MAX),
1243 IDP_group_lookup_float(input_idprop, "max").value_or(FLT_MAX));
1245 prop,
1246 PropertySubType(IDP_group_lookup_int(input_idprop, "subtype").value_or(PROP_NONE)));
1247 make_common_value_and_attribute_props(*srna, name, description, input_idprop);
1248 break;
1249 }
1250 case SOCK_VECTOR: {
1251 const int dimensions = IDP_group_lookup_int(input_idprop, "dimensions").value_or(3);
1252 std::optional<Span<float>> defaults = IDP_group_lookup_float_array(
1253 input_idprop, "default_value", dimensions);
1255 srna,
1256 "value",
1257 dimensions,
1258 defaults ? defaults->data() : nullptr,
1259 -FLT_MAX,
1260 FLT_MAX,
1261 name.c_str(),
1262 description.c_str(),
1263 IDP_group_lookup_float(input_idprop, "min").value_or(-FLT_MAX),
1264 IDP_group_lookup_float(input_idprop, "max").value_or(FLT_MAX));
1266 prop,
1267 PropertySubType(IDP_group_lookup_int(input_idprop, "subtype").value_or(PROP_NONE)));
1268 make_common_value_and_attribute_props(*srna, name, description, input_idprop);
1269 break;
1270 }
1271 case SOCK_RGBA: {
1272 std::optional<Span<float>> defaults = IDP_group_lookup_float_array(
1273 input_idprop, "default_value", 4);
1274 PropertyRNA *prop = RNA_def_float_color(srna,
1275 "value",
1276 4,
1277 defaults ? defaults->data() : nullptr,
1278 -FLT_MAX,
1279 FLT_MAX,
1280 name.c_str(),
1281 description.c_str(),
1282 0.0f,
1283 1.0f);
1285 make_common_value_and_attribute_props(*srna, name, description, input_idprop);
1286 break;
1287 }
1288 case SOCK_BOOLEAN: {
1289 RNA_def_boolean(srna,
1290 "value",
1291 IDP_group_lookup_bool(input_idprop, "default_value").value_or(false),
1292 name.c_str(),
1293 description.c_str());
1297 make_common_attribute_name_prop(*srna, name, description, input_idprop);
1298 break;
1299 }
1300 case SOCK_INT: {
1301 PropertyRNA *prop = RNA_def_int(
1302 srna,
1303 "value",
1304 IDP_group_lookup_int(input_idprop, "default_value").value_or(0),
1305 INT_MIN,
1306 INT_MAX,
1307 name.c_str(),
1308 description.c_str(),
1309 IDP_group_lookup_int(input_idprop, "min").value_or(INT_MIN),
1310 IDP_group_lookup_int(input_idprop, "max").value_or(INT_MIN));
1312 prop,
1313 PropertySubType(IDP_group_lookup_int(input_idprop, "subtype").value_or(PROP_NONE)));
1314 make_common_value_and_attribute_props(*srna, name, description, input_idprop);
1315 break;
1316 }
1317 case SOCK_STRING: {
1318 const StringRefNull default_value =
1319 IDP_group_lookup_string(input_idprop, "default_value").value_or("");
1320 PropertyRNA *prop = RNA_def_string(srna,
1321 "value",
1322 default_value.is_empty() ? nullptr :
1323 default_value.c_str(),
1324 0,
1325 name.c_str(),
1326 description.c_str());
1328 prop,
1329 PropertySubType(IDP_group_lookup_int(input_idprop, "subtype").value_or(PROP_NONE)));
1331 break;
1332 }
1333 case SOCK_IMAGE:
1334 case SOCK_COLLECTION:
1335 case SOCK_MATERIAL:
1336 case SOCK_FONT:
1337 case SOCK_SOUND:
1338 case SOCK_OBJECT: {
1339 RNA_def_string(srna, "value", nullptr, 0, name.c_str(), description.c_str());
1341 break;
1342 }
1343 case SOCK_ROTATION: {
1344 std::optional<Span<float>> defaults = IDP_group_lookup_float_array(
1345 input_idprop, "default_value", 3);
1347 "value",
1348 3,
1349 defaults ? defaults->data() : nullptr,
1350 -FLT_MAX,
1351 FLT_MAX,
1352 name.c_str(),
1353 description.c_str(),
1354 -FLT_MAX,
1355 FLT_MAX);
1356 make_common_value_and_attribute_props(*srna, name, description, input_idprop);
1357 break;
1358 }
1359 case SOCK_MENU: {
1360 type_data.enum_item_storage.append_as(get_input_enum_items(input_idprop));
1361 int default_value = IDP_group_lookup_int(input_idprop, "default_value").value_or(0);
1362 if (std::ranges::none_of(
1363 type_data.enum_item_storage.last(),
1364 [&](const EnumPropertyItem &item) { return item.value == default_value; }))
1365 {
1366 /* Default value must be used by one of the enum items. */
1367 default_value = 0;
1368 }
1369 RNA_def_enum(srna,
1370 "value",
1371 type_data.enum_item_storage.last().data(),
1372 IDP_group_lookup_int(input_idprop, "default_value").value_or(0),
1373 name.c_str(),
1374 description.c_str());
1376 break;
1377 }
1378 default:
1379 break;
1380 }
1381
1382 return srna;
1383}
1384
1385static StructRNA *create_inputs_srna(const IDProperty &properties, OperatorTypeData &type_data)
1386{
1388 &RNA_blender_rna_get(), "GeometryNodesInterfaceInputs", RNA_PropertyGroup);
1390 type_data.generated_structs.append(srna);
1391
1392 const IDProperty &inputs_props = *IDP_GetPropertyFromGroup(&properties, "inputs");
1393
1394 for (IDProperty &input_idprop : inputs_props.data.group) {
1395 if (input_idprop.type != IDP_GROUP) {
1396 continue;
1397 }
1398 StructRNA *input_srna = get_input_socket_struct_rna(input_idprop, type_data);
1399 if (!input_srna) {
1400 continue;
1401 }
1404 input_idprop.name,
1405 input_srna,
1406 RNA_struct_ui_name(input_srna),
1407 RNA_struct_ui_description(input_srna));
1408 }
1409 return srna;
1410}
1411
1412static StructRNA *create_panels_srna(const IDProperty &properties,
1413 Vector<StructRNA *> &r_generated)
1414{
1415 const IDProperty *panels_props = IDP_GetPropertyFromGroup(&properties, "panels");
1416 if (!panels_props || panels_props->type != IDP_GROUP) {
1417 return nullptr;
1418 }
1420 &RNA_blender_rna_get(), "GeometryNodesInterfacePanels", RNA_PropertyGroup);
1422 r_generated.append(srna);
1423 for (IDProperty &panel_prop : panels_props->data.group) {
1424 if (panel_prop.type != IDP_BOOLEAN) {
1425 continue;
1426 }
1427 RNA_def_boolean(srna, panel_prop.name, IDP_bool_get(&panel_prop), "Is Open", "");
1428 }
1429 return srna;
1430}
1431
1433 std::unique_ptr<OperatorTypeData> &type_data_ptr)
1434{
1435 OperatorTypeData &type_data = *type_data_ptr;
1436 ot->custom_data = std::move(type_data_ptr);
1437
1438 PropertyRNA *prop;
1439 ot->name = type_data.name.c_str();
1440 ot->idname = type_data.idname.c_str();
1441 ot->description = type_data.description.empty() ? nullptr : type_data.description.c_str();
1442
1446 ot->ui = run_node_group_ui;
1448
1450 if (type_data.flag & GEO_NODE_ASSET_WAIT_FOR_CURSOR) {
1452 }
1453
1454 StructRNA *inputs_srna = create_inputs_srna(*type_data.asset_meta_data_properties, type_data);
1455 RNA_def_pointer_runtime(ot->srna, "inputs", inputs_srna, "Inputs", "Settings for input sockets");
1456 if (StructRNA *panels_srna = create_panels_srna(*type_data.asset_meta_data_properties,
1457 type_data.generated_structs))
1458 {
1459 RNA_def_pointer_runtime(ot->srna, "panels", panels_srna, "Panels", "Settings for panels");
1460 }
1461
1462 /* See comment for #store_input_node_values_rna_props. */
1463 prop = RNA_def_int_array(ot->srna,
1464 "mouse_position",
1465 2,
1466 nullptr,
1467 INT_MIN,
1468 INT_MAX,
1469 "Mouse Position",
1470 "Mouse coordinates in region space",
1471 INT_MIN,
1472 INT_MAX);
1474 prop = RNA_def_int_array(
1475 ot->srna, "region_size", 2, nullptr, 0, INT_MAX, "Region Size", "", 0, INT_MAX);
1477 prop = RNA_def_float_array(ot->srna,
1478 "cursor_position",
1479 3,
1480 nullptr,
1481 -FLT_MAX,
1482 FLT_MAX,
1483 "3D Cursor Position",
1484 "",
1485 -FLT_MAX,
1486 FLT_MAX);
1488 prop = RNA_def_float_array(ot->srna,
1489 "cursor_rotation",
1490 4,
1491 nullptr,
1492 -FLT_MAX,
1493 FLT_MAX,
1494 "3D Cursor Rotation",
1495 "",
1496 -FLT_MAX,
1497 FLT_MAX);
1499 prop = RNA_def_float_array(ot->srna,
1500 "viewport_projection_matrix",
1501 16,
1502 nullptr,
1503 -FLT_MAX,
1504 FLT_MAX,
1505 "Viewport Projection Transform",
1506 "",
1507 -FLT_MAX,
1508 FLT_MAX);
1510 prop = RNA_def_float_array(ot->srna,
1511 "viewport_view_matrix",
1512 16,
1513 nullptr,
1514 -FLT_MAX,
1515 FLT_MAX,
1516 "Viewport View Transform",
1517 "",
1518 -FLT_MAX,
1519 FLT_MAX);
1521 prop = RNA_def_boolean(
1522 ot->srna, "viewport_is_perspective", false, "Viewport Is Perspective", "");
1524}
1525
1527 const StringRefNull idname_py)
1528{
1530 const ErrorsForType *errors_for_type = errors.lookup_ptr(idname_py);
1531 if (!errors_for_type) {
1532 return;
1533 }
1534 ui::Layout &col = layout.column(false);
1535 if (errors_for_type->is_builtin_operator) {
1536 col.label(TIP_("Operator is already registered"), ICON_STATUS_ERROR);
1537 }
1538 if (errors_for_type->duplicate_count != 0) {
1539 col.label(fmt::format(fmt::runtime(TIP_("Duplicates: {}")), errors_for_type->duplicate_count),
1540 ICON_STATUS_ERROR);
1541 }
1542 for (const std::string &error : errors_for_type->idname_validation_errors) {
1543 col.label(error, ICON_STATUS_ERROR);
1544 }
1545}
1546
1548 const Span<std::unique_ptr<RegistrationData::TypeTreeItem>> children, const StringRef name)
1549{
1550 for (const std::unique_ptr<RegistrationData::TypeTreeItem> &child : children) {
1551 if (child->name == name) {
1552 return child.get();
1553 }
1554 }
1555 return nullptr;
1556}
1557
1559 const Span<std::unique_ptr<RegistrationData::TypeTreeItem>> nodes, StringRef path)
1560{
1561 BLI_assert(!path.is_empty());
1562 const int64_t sep = path.find_first_of('/');
1563 if (sep == StringRef::not_found) {
1564 return find_tree_child(nodes, path);
1565 }
1566 const RegistrationData::TypeTreeItem *child = find_tree_child(nodes, path.substr(0, sep));
1567 if (!child) {
1568 return nullptr;
1569 }
1570 return find_tree_node(child->children, path.substr(sep + 1));
1571}
1572
1574 Vector<std::unique_ptr<RegistrationData::TypeTreeItem>> &children, const StringRef name)
1575{
1576 if (RegistrationData::TypeTreeItem *existing = find_tree_child(children, name)) {
1577 return *existing;
1578 }
1579 auto new_item = std::make_unique<RegistrationData::TypeTreeItem>();
1580 new_item->name = name;
1581 RegistrationData::TypeTreeItem &ref = *new_item;
1582 children.append(std::move(new_item));
1583 return ref;
1584}
1585
1586static void tree_add_type(Vector<std::unique_ptr<RegistrationData::TypeTreeItem>> &nodes,
1587 StringRef path,
1588 wmOperatorType *ot)
1589{
1590 BLI_assert(!path.is_empty());
1591 const int64_t sep = path.find_first_of('/');
1592 if (sep == StringRef::not_found) {
1594 child.types.append(ot);
1595 return;
1596 }
1598 tree_add_type(child.children, path.substr(sep + 1), ot);
1599}
1600
1602 StringRefNull operator()(const std::unique_ptr<OperatorTypeData> &value) const
1603 {
1604 return value->idname;
1605 }
1606};
1607
1609
1611 Main &bmain,
1613{
1614 OperatorsToRegister all_types;
1615 for (bNodeTree &ntree : bmain.nodetrees) {
1616 if (ID_IS_ASSET(&ntree.id)) {
1617 continue;
1618 }
1619 if (!ntree.geometry_node_asset_traits) {
1620 continue;
1621 }
1623 continue;
1624 }
1625 std::optional<OperatorTypeData> type_data = OperatorTypeData::from_group(ntree, errors);
1626 if (!type_data) {
1627 continue;
1628 }
1629 if (!all_types.add(std::make_unique<OperatorTypeData>(std::move(*type_data)))) {
1630 errors.lookup_or_add_default_as(type_data->custom_idname).duplicate_count++;
1631 }
1632 }
1633
1635 ed::asset::list::storage_fetch(&library_ref, &C);
1638 if (asset.get_id_type() != ID_NT) {
1639 return true;
1640 }
1641 const AssetMetaData &meta_data = asset.get_metadata();
1642 const IDProperty *tree_type = BKE_asset_metadata_idprop_find(&meta_data, "type");
1643 if (tree_type == nullptr) {
1644 return true;
1645 }
1646 if (IDP_int_get(tree_type) != NTREE_GEOMETRY) {
1647 return true;
1648 }
1649 const IDProperty *traits_flag = BKE_asset_metadata_idprop_find(
1650 &meta_data, "geometry_node_asset_traits_flag");
1651 if (!traits_flag) {
1652 return true;
1653 }
1654 if (traits_flag->type != IDP_INT) {
1655 return true;
1656 }
1657 if ((IDP_int_get(traits_flag) & GEO_NODE_ASSET_TOOL) == 0) {
1658 return true;
1659 }
1660 std::optional<OperatorTypeData> type_data = OperatorTypeData::from_asset(asset, errors);
1661 if (!type_data) {
1662 return true;
1663 }
1664 if (!all_types.add(std::make_unique<OperatorTypeData>(std::move(*type_data)))) {
1665 errors.lookup_or_add_default_as(type_data->custom_idname).duplicate_count++;
1666 }
1667 return true;
1668 });
1669 }
1670
1671 return all_types;
1672}
1673
1675{
1677 RegistrationData &registration_data = get_registration_data();
1678 if (errors == registration_data.errors_by_idname) {
1679 /* Don't display the same errors twice. That can be very noisy since this operator registration
1680 * process runs so often. */
1681 return;
1682 }
1683 ReportList *reports = CTX_wm_reports(&C);
1684 for (const RegistrationData::Errors::Item &item : errors.items()) {
1685 if (item.value.is_builtin_operator) {
1686 BKE_reportf(reports,
1687 RPT_ERROR,
1688 "Error registering node tool \"%s\", operator is already registered",
1689 item.key.c_str());
1690 }
1691 if (item.value.duplicate_count != 0) {
1692 BKE_reportf(reports,
1693 RPT_ERROR,
1694 "Error registering node tool \"%s\", %d duplicate(s)",
1695 item.key.c_str(),
1696 item.value.duplicate_count);
1697 }
1698 if (item.value.invalid_metadata) {
1700 reports,
1701 RPT_ERROR,
1702 "Node tool \"%s\" asset has invalid metadata. Asset meta-data may be out of date",
1703 item.key.c_str());
1704 }
1705 for (const std::string &error : item.value.idname_validation_errors) {
1706 BKE_reportf(reports,
1707 RPT_ERROR,
1708 "Error registering node tool \"%s\", %s",
1709 item.key.c_str(),
1710 error.c_str());
1711 }
1712 for (const std::string &error : item.value.invalid_input_metadata_errors) {
1713 BKE_reportf(reports,
1714 RPT_ERROR,
1715 "Error registering node tool \"%s\". Invalid metadata for input \"%s\". "
1716 "Asset meta-data may be out of date",
1717 item.key.c_str(),
1718 error.c_str());
1719 }
1720 }
1721 registration_data.errors_by_idname = std::move(errors);
1722 WM_report_banner_show(&wm, nullptr);
1723}
1724
1726{
1729 Main &bmain = *CTX_data_main(&C);
1730 RegistrationData &registration_data = get_registration_data();
1731
1733
1734 OperatorsToRegister types_to_register = get_node_tools_type_data(C, bmain, errors);
1735
1736 /* Remove node tools that conflict with builtin operators. */
1737 types_to_register.remove_if([&](const std::unique_ptr<OperatorTypeData> &item) {
1738 if (wmOperatorType *ot = WM_operatortype_find(item->idname.c_str(), true)) {
1739 if ((ot->flag & OPTYPE_NODE_TOOL) == 0) {
1740 errors.lookup_or_add_default(item->custom_idname).is_builtin_operator = true;
1741 return true;
1742 }
1743 }
1744 return false;
1745 });
1746
1747 Set<wmOperatorType *> types_to_remove;
1748
1749 /* Remove old operators for now-unused identifier names. */
1751 if ((ot->flag & OPTYPE_NODE_TOOL) == 0) {
1752 continue;
1753 }
1754 if (types_to_register.contains_as(ot->idname)) {
1755 continue;
1756 }
1757 types_to_remove.add(ot);
1758 }
1759
1760 /* Remove operators that are already registered and haven't changed. */
1761 types_to_register.remove_if([&](const std::unique_ptr<OperatorTypeData> &item) {
1762 if (wmOperatorType *ot = WM_operatortype_find(item->idname.c_str(), true)) {
1763 const auto &type_data = static_cast<const OperatorTypeData &>(*ot->custom_data);
1764 if (type_data.hash == item->hash) {
1765 return true;
1766 }
1767 }
1768 return false;
1769 });
1770
1771 /* Remove changed operators so they can be re-registered. */
1772 for (const std::unique_ptr<OperatorTypeData> &type : types_to_register) {
1773 if (wmOperatorType *ot = WM_operatortype_find(type->idname.c_str(), true)) {
1774 types_to_remove.add_new(ot);
1775 }
1776 }
1777
1778 show_error_reports(C, std::move(errors));
1779
1780 if (types_to_remove.is_empty() && types_to_register.is_empty()) {
1781 return;
1782 }
1783
1784 if (!types_to_remove.is_empty()) {
1785 WM_operator_stack_clear(&wm, types_to_remove);
1786 WM_operator_handlers_clear(&wm, types_to_remove);
1787 for (wmOperatorType *ot : types_to_remove) {
1788 auto &type_data = static_cast<OperatorTypeData &>(*ot->custom_data);
1789
1790 for (StructRNA *srna : type_data.generated_structs) {
1791 /* Avoids warning when freeing the #StructRNA. */
1792 RNA_struct_py_type_set(srna, nullptr);
1794 }
1795
1797 }
1798 }
1799
1800 Vector<std::unique_ptr<OperatorTypeData>> vector = types_to_register.extract_vector();
1801 for (std::unique_ptr<OperatorTypeData> &type : vector) {
1803 [](wmOperatorType *ot, void *user_data) {
1804 register_node_tool(ot, *static_cast<std::unique_ptr<OperatorTypeData> *>(user_data));
1805 },
1806 &type);
1807 }
1808
1809 registration_data.local_types.clear();
1810 registration_data.unassigned_types.clear();
1811 registration_data.menu_path_tree_roots.clear();
1815 if ((ot->flag & OPTYPE_NODE_TOOL) == 0) {
1816 continue;
1817 }
1818 const auto &type_data = static_cast<OperatorTypeData &>(*ot->custom_data);
1819 const auto *asset_ref = std::get_if<AssetWeakReference>(&type_data.group_ref);
1820 if (!asset_ref) {
1821 registration_data.local_types.append(ot);
1822 continue;
1823 }
1825 C, *asset_ref, nullptr);
1826 BLI_assert(asset != nullptr);
1827 const bUUID catalog_id = asset->get_metadata().catalog_id;
1828 const asset_system::AssetCatalog *catalog = all_library->catalog_service().find_catalog(
1829 catalog_id);
1830 if (!catalog) {
1831 registration_data.unassigned_types.append(ot);
1832 continue;
1833 }
1834 tree_add_type(registration_data.menu_path_tree_roots, catalog->path.str(), ot);
1835 }
1836}
1837
1839
1840/* -------------------------------------------------------------------- */
1843
1844static bool asset_menu_poll(const bContext *C, MenuType * /*mt*/)
1845{
1846 return CTX_wm_view3d(C);
1847}
1848
1850 const eObjectMode mode)
1851{
1852 switch (type) {
1853 case OB_MESH: {
1854 switch (mode) {
1855 case OB_MODE_OBJECT:
1857 case OB_MODE_EDIT:
1859 case OB_MODE_SCULPT:
1861 default:
1862 break;
1863 }
1864 break;
1865 }
1866 case OB_CURVES: {
1867 switch (mode) {
1868 case OB_MODE_OBJECT:
1870 case OB_MODE_EDIT:
1874 default:
1875 break;
1876 }
1877 break;
1878 }
1879 case OB_POINTCLOUD: {
1880 switch (mode) {
1881 case OB_MODE_OBJECT:
1883 case OB_MODE_EDIT:
1885 default:
1886 break;
1887 }
1888 break;
1889 }
1890 case OB_GREASE_PENCIL: {
1891 switch (mode) {
1892 case OB_MODE_OBJECT:
1894 case OB_MODE_EDIT:
1900 default:
1901 break;
1902 }
1903 }
1904 default:
1905 break;
1906 }
1908}
1909
1911{
1912 return asset_flag_for_context(active_object.type, active_object.mode);
1913}
1914
1920static Set<StringRef> get_builtin_menus(const ObjectType object_type, const eObjectMode mode)
1921{
1922 Set<StringRef> menus;
1923 switch (object_type) {
1924 case OB_CURVES:
1925 menus.add_new("View");
1926 menus.add_new("Select");
1927 menus.add_new("Curves");
1928 break;
1929 case OB_POINTCLOUD:
1930 menus.add_new("View");
1931 menus.add_new("Select");
1932 menus.add_new("Point Cloud");
1933 break;
1934 case OB_MESH:
1935 switch (mode) {
1936 case OB_MODE_OBJECT:
1937 menus.add_new("View");
1938 menus.add_new("Select");
1939 menus.add_new("Add");
1940 menus.add_new("Object");
1941 menus.add_new("Object/Apply");
1942 menus.add_new("Object/Convert");
1943 menus.add_new("Object/Quick Effects");
1944 break;
1945 case OB_MODE_EDIT:
1946 menus.add_new("View");
1947 menus.add_new("Select");
1948 menus.add_new("Add");
1949 menus.add_new("Mesh");
1950 menus.add_new("Mesh/Extrude");
1951 menus.add_new("Mesh/Clean Up");
1952 menus.add_new("Mesh/Delete");
1953 menus.add_new("Mesh/Merge");
1954 menus.add_new("Mesh/Normals");
1955 menus.add_new("Mesh/Shading");
1956 menus.add_new("Mesh/Split");
1957 menus.add_new("Mesh/Weights");
1958 menus.add_new("Vertex");
1959 menus.add_new("Edge");
1960 menus.add_new("Face");
1961 menus.add_new("Face/Face Data");
1962 menus.add_new("UV");
1963 menus.add_new("UV/Unwrap");
1964 break;
1965 case OB_MODE_SCULPT:
1966 menus.add_new("View");
1967 menus.add_new("Sculpt");
1968 menus.add_new("Mask");
1969 menus.add_new("Face Sets");
1970 break;
1972 menus.add_new("View");
1973 menus.add_new("Paint");
1974 break;
1976 menus.add_new("View");
1977 menus.add_new("Weights");
1978 break;
1979 default:
1980 break;
1981 }
1982 break;
1983 case OB_GREASE_PENCIL: {
1984 switch (mode) {
1985 case OB_MODE_OBJECT:
1986 menus.add_new("View");
1987 menus.add_new("Select");
1988 menus.add_new("Add");
1989 menus.add_new("Object");
1990 menus.add_new("Object/Apply");
1991 menus.add_new("Object/Convert");
1992 menus.add_new("Object/Quick Effects");
1993 break;
1994 case OB_MODE_EDIT:
1995 menus.add_new("View");
1996 menus.add_new("Select");
1997 menus.add_new("Grease Pencil");
1998 menus.add_new("Stroke");
1999 menus.add_new("Point");
2000 break;
2002 menus.add_new("View");
2003 break;
2005 menus.add_new("View");
2006 menus.add_new("Draw");
2007 break;
2008 default:
2009 break;
2010 }
2011 }
2012 default:
2013 break;
2014 }
2015 return menus;
2016}
2017
2019{
2020 if (std::ranges::any_of(
2021 node.types,
2022 [&](wmOperatorType *ot) { return WM_operator_poll(&const_cast<bContext &>(C), ot); }))
2023 {
2024 return true;
2025 }
2026 if (std::ranges::any_of(node.children,
2027 [&](const std::unique_ptr<RegistrationData::TypeTreeItem> &child) {
2028 return menu_operators_poll(C, *child);
2029 }))
2030 {
2031 return true;
2032 }
2033 return false;
2034}
2035
2041 ui::Layout &layout,
2042 wmOperatorType *ot)
2043{
2044 const auto &type_data = *static_cast<const OperatorTypeData *>(ot->custom_data.get());
2045
2046 const auto *asset_ref = std::get_if<AssetWeakReference>(&type_data.group_ref);
2047 if (asset_ref && type_data.asset_needs_downloading) {
2048 /* Don't pass reports to this function, as this is called on every draw.
2049 * If it has something to report, it'll get very noisy. */
2051 *C, *asset_ref, nullptr);
2052
2053 if (asset) {
2054 /* This sets up the layout for online assets if necessary, so users are forced to download
2055 * the asset via the context menu first. */
2056 asset::draw_asset_menu_item(asset, layout, [&](ui::Layout &sub, BIFIconID asset_icon) {
2057 sub.op(ot, std::nullopt, asset_icon, wm::OpCallContext::InvokeRegionWin, UI_ITEM_NONE);
2058 });
2059 return;
2060 }
2061 }
2062 layout.op(ot, std::nullopt, ICON_NONE, wm::OpCallContext::InvokeRegionWin, UI_ITEM_NONE);
2063}
2064
2065static void catalog_assets_draw(const bContext *C, Menu *menu)
2066{
2067 const Object *active_object = CTX_data_active_object(C);
2068 if (!active_object) {
2069 return;
2070 }
2071 const std::optional<StringRefNull> path = CTX_data_string_get(C, "asset_catalog_path");
2072 if (!path) {
2073 return;
2074 }
2076 const RegistrationData::TypeTreeItem *node = find_tree_node(data.menu_path_tree_roots, *path);
2077 if (!node) {
2078 return;
2079 }
2080
2081 ui::Layout &layout = *menu->layout;
2082 bool add_separator = true;
2083
2084 for (wmOperatorType *ot : node->types) {
2085 if (!WM_operator_poll(const_cast<bContext *>(C), ot)) {
2086 continue;
2087 }
2088 if (add_separator) {
2089 layout.separator();
2090 add_separator = false;
2091 }
2092 add_node_group_operator_button(C, layout, ot);
2093 }
2094
2095 const Set<StringRef> builtin_menus = get_builtin_menus(active_object->type, active_object->mode);
2096
2097 for (const std::unique_ptr<RegistrationData::TypeTreeItem> &child : node->children) {
2098 if (!menu_operators_poll(*C, *child)) {
2099 continue;
2100 }
2101 const std::string child_path = fmt::format("{}/{}", *path, child->name);
2102 if (builtin_menus.contains_as(child_path)) {
2103 continue;
2104 }
2105 if (add_separator) {
2106 layout.separator();
2107 add_separator = false;
2108 }
2109 layout.context_string_set("asset_catalog_path", child_path);
2110 layout.menu("GEO_MT_node_operator_catalog_assets", IFACE_(child->name), ICON_NONE);
2111 }
2112}
2113
2115{
2116 MenuType type{};
2117 STRNCPY_UTF8(type.idname, "GEO_MT_node_operator_catalog_assets");
2118 type.poll = asset_menu_poll;
2122 return type;
2123}
2124
2126{
2128 ui::Layout &layout = *menu->layout;
2129 bool add_separator = false;
2130 for (wmOperatorType *ot : data.unassigned_types) {
2131 if (!WM_operator_poll(const_cast<bContext *>(C), ot)) {
2132 continue;
2133 }
2134 add_node_group_operator_button(C, layout, ot);
2135 add_separator = true;
2136 }
2137
2138 bool first = true;
2139 for (wmOperatorType *ot : data.local_types) {
2140 if (!WM_operator_poll(const_cast<bContext *>(C), ot)) {
2141 continue;
2142 }
2143 if (add_separator) {
2144 layout.separator();
2145 add_separator = false;
2146 }
2147 if (first) {
2148 layout.label(IFACE_("Non-Assets"), ICON_NONE);
2149 first = false;
2150 }
2151 add_node_group_operator_button(C, layout, ot);
2152 }
2153}
2154
2156{
2157 MenuType type{};
2158 STRNCPY_UTF8(type.label, N_("Unassigned Node Tools"));
2159 STRNCPY_UTF8(type.idname, "GEO_MT_node_operator_unassigned");
2160 type.poll = asset_menu_poll;
2164 type.description = N_(
2165 "Tool node group assets not assigned to a catalog.\n"
2166 "Catalogs can be assigned in the Asset Browser");
2167 return type;
2168}
2169
2171 const bContext &C,
2172 const StringRef path)
2173{
2175 const RegistrationData::TypeTreeItem *node = find_tree_node(data.menu_path_tree_roots, path);
2176 if (!node) {
2177 return;
2178 }
2179 if (!menu_operators_poll(C, *node)) {
2180 return;
2181 }
2182 ui::Layout &col = layout.column(false);
2183 col.context_string_set("asset_catalog_path", path);
2184 col.menu_contents("GEO_MT_node_operator_catalog_assets");
2185}
2186
2188{
2189 const Object *active_object = CTX_data_active_object(&C);
2190 if (!active_object) {
2191 return;
2192 }
2194 const Set<StringRef> builtin_menus = get_builtin_menus(active_object->type, active_object->mode);
2195 for (const std::unique_ptr<RegistrationData::TypeTreeItem> &root : data.menu_path_tree_roots) {
2196 if (builtin_menus.contains_as(root->name)) {
2197 continue;
2198 }
2199 if (!menu_operators_poll(C, *root)) {
2200 continue;
2201 }
2202 layout.context_string_set("asset_catalog_path", root->name);
2203 layout.menu("GEO_MT_node_operator_catalog_assets", IFACE_(root->name), ICON_NONE);
2204 }
2205
2206 if (!data.unassigned_types.is_empty() || !data.local_types.is_empty()) {
2207 layout.menu("GEO_MT_node_operator_unassigned", "", ICON_FILE_HIDDEN);
2208 }
2209}
2210
2212
2213} // namespace blender::ed::geometry
Main runtime representation of an asset.
#define CTX_DATA_BEGIN(C, Type, instance, member)
#define CTX_DATA_END
Low-level operations for curves.
CustomData interface, see also DNA_customdata_types.h.
Low-level operations for grease pencil.
#define IDP_int_get(prop)
#define IDP_string_get(prop)
#define IDP_bool_get(prop)
#define FOREACH_OBJECT_IN_MODE_BEGIN(_bmain, _scene, _view_layer, _v3d, _object_type, _object_mode, _instance)
Definition BKE_layer.hh:470
#define FOREACH_OBJECT_IN_MODE_END
Definition BKE_layer.hh:477
General operations, lookup, etc. for materials.
General operations, lookup, etc. for blender objects.
A BVH for high poly meshes.
General operations for point clouds.
#define BLI_SCOPED_DEFER(function_to_defer)
#define STRNCPY_UTF8(dst, src)
#define TIP_(msgid)
#define IFACE_(msgid)
#define ID_IS_ASSET(_id)
Definition DNA_ID.h:743
Object is a sort of wrapper for general info.
#define OP_MAX_TYPENAME
#define PRF_scope(category)
#define RNA_STRUCT_BEGIN(sptr, prop)
#define RNA_STRUCT_END
#define C
Definition RandGen.cpp:29
#define UI_ITEM_NONE
#define NC_GEOM
Definition WM_types.hh:406
#define ND_DATA
Definition WM_types.hh:552
#define NA_EDITED
Definition WM_types.hh:634
#define NC_GPENCIL
Definition WM_types.hh:412
#define BLI_assert_unreachable_static_t(T)
#define ELEM(...)
#define STREQ(a, b)
Array(Allocator allocator={}) noexcept
Definition BLI_array.hh:78
const ComputeContextHash & hash() const
static IndexMask from_indices(Span< T > indices, LinearAllocator<> &memory)
const Value * lookup_ptr(const Key &key) const
Definition BLI_map.hh:508
Value & lookup_or_add_default(const Key &key)
Definition BLI_map.hh:639
ValueIterator values() const &
Definition BLI_map.hh:884
bool add(const Key &key, const Value &value)
Definition BLI_map.hh:295
Value & lookup_or_add_default_as(ForwardKey &&key)
Definition BLI_map.hh:647
MapItem< std::string, ErrorsForType > Item
Definition BLI_map.hh:132
ItemIterator items() const &
Definition BLI_map.hh:902
constexpr MutableSpan()=default
Iterator begin() const
Definition BLI_set.hh:499
int64_t size() const
Definition BLI_set.hh:606
bool contains_as(const ForwardKey &key) const
Definition BLI_set.hh:314
Iterator end() const
Definition BLI_set.hh:509
bool add(const Key &key)
Definition BLI_set.hh:248
bool is_empty() const
Definition BLI_set.hh:614
void add_new(const Key &key)
Definition BLI_set.hh:233
constexpr int64_t size() const
Definition BLI_span.hh:256
constexpr const char * c_str() const
constexpr StringRefNull()
void materialize(MutableSpan< T > r_span) const
static VArray from_span(Span< T > values)
bool contains_as(const ForwardKey &key) const
bool add(const Key &key)
int64_t remove_if(Predicate &&predicate)
void append(const T &value)
bool is_empty() const
Span< T > as_span() const
void append_as(ForwardValue &&...value)
AssetCatalog * find_catalog(CatalogID catalog_id) const
AssetCatalogService & catalog_service() const
GAttributeReader lookup(const StringRef name) const
GAttributeReader get() const
bool add(const StringRef name, const AttrDomain domain, const AttrType data_type, const AttributeInit &initializer)
std::unique_ptr< nodes::EvalDependencies > eval_dependencies
constexpr int64_t find_first_of(StringRef chars, int64_t pos=0) const
static constexpr int64_t not_found
constexpr bool is_empty() const
constexpr StringRef substr(int64_t start, int64_t size) const
void freeze_shared_state(const ImplicitSharingInfo &sharing_info)
void ensure_node_warnings(const NodesModifierData &nmd)
Definition eval_log.cc:438
VectorSet< NodeWarning > all_warnings
static Map< const bke::bNodeTreeZone *, ComputeContextHash > get_context_hash_by_zone_for_node_editor(const SpaceNode &snode, bke::ComputeContextCache &compute_context_cache)
Definition eval_log.cc:972
#define FLT_MAX
#define INT_MAX
#define attribute(slot)
#define layer
#define log
#define T
void copy(const GVArray &src, GMutableSpan dst, exec_mode::Mode mode=exec_mode::parallel)
AssetLibraryReference all_library_reference()
void ensure_non_empty_layer_names(Main &bmain, GreasePencil &grease_pencil)
void hash(const IDProperty &base_prop, XXH3_state_t *hash_state)
Definition idprop.cc:2251
pbvh::Tree * pbvh_get(Object &object)
void update_normals(const Depsgraph &depsgraph, Object &object_orig, Tree &pbvh)
Definition pbvh.cc:1179
IDProperty * node_create_asset_meta_data_properties(const bNodeTree &node_tree)
Definition node.cc:2415
void storage_fetch(const AssetLibraryReference *library_reference, const bContext *C)
void iterate(const AssetLibraryReference &library_reference, AssetListIterFn fn)
asset_system::AssetLibrary * library_get_once_available(const AssetLibraryReference &library_reference)
void asset_reading_region_listen_fn(const wmRegionListenerParams *params)
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)
void draw_asset_menu_item(const asset_system::AssetRepresentation *asset, ui::Layout &layout, FunctionRef< void(ui::Layout &, BIFIconID)> draw_item_fn)
static void remove_shape_key_attributes(Mesh &mesh, const Key &key)
static void add_node_group_operator_button(const bContext *C, ui::Layout &layout, wmOperatorType *ot)
static void make_common_value_props(StructRNA &srna)
static const bNodeTree * get_asset_or_local_node_group(const bContext &C, const wmOperatorType &ot, ReportList *reports)
static bool asset_menu_poll(const bContext *C, MenuType *)
static wmOperatorStatus run_node_group_exec(bContext *C, wmOperator *op)
static RegistrationData & get_registration_data()
void ui_template_node_operator_asset_root_items(ui::Layout &layout, const bContext &C)
static std::optional< StringRefNull > custom_idname_for_asset(const AssetRepresentation &asset)
static std::string shape_key_attribute_name(const KeyBlock &kb)
static Vector< Object * > gather_supported_objects(const bContext &C, const Main &bmain, const eObjectMode mode)
static void make_common_value_and_attribute_props(StructRNA &srna, const StringRefNull name, const StringRefNull description, const IDProperty &input_idprop)
static void add_shape_keys_as_attributes(Mesh &mesh, const Key &key)
static const ImplicitSharingInfo * get_vertex_group_sharing_info(const Mesh &mesh)
static StructRNA * create_inputs_srna(const IDProperty &properties, OperatorTypeData &type_data)
MenuType node_group_operator_assets_menu_unassigned()
GeometryNodeAssetTraitFlag asset_flag_for_context(const Object &active_object)
static bool run_node_group_poll(bContext *C, wmOperatorType *ot)
CustomIDVectorSet< std::unique_ptr< OperatorTypeData >, GetIDName > OperatorsToRegister
static bke::GeometrySet get_original_geometry_eval_copy(Depsgraph &depsgraph, Object &object, nodes::GeoNodesOperatorData &operator_data, Vector< MeshState > &orig_mesh_states)
const GeoOperatorLog & node_group_operator_static_eval_log()
static RegistrationData::TypeTreeItem & ensure_child(Vector< std::unique_ptr< RegistrationData::TypeTreeItem > > &children, const StringRef name)
static StructRNA * create_panels_srna(const IDProperty &properties, Vector< StructRNA * > &r_generated)
static Array< EnumPropertyItem, 0 > get_input_enum_items(const IDProperty &input_idprop)
static void catalog_assets_draw(const bContext *C, Menu *menu)
static void show_error_reports(const bContext &C, RegistrationData::Errors errors)
static void catalog_assets_draw_unassigned(const bContext *C, Menu *menu)
static std::optional< std::string > operator_idname_get(const StringRefNull custom_idname, RegistrationData::Errors *errors)
static bool object_has_editable_data(const Main &bmain, const Object &object)
static void make_common_attribute_name_prop(StructRNA &srna, const StringRefNull name, const StringRefNull description, const IDProperty &input_idprop)
static Map< std::string, ID * > gather_input_ids(const Main &bmain, const bNodeTree &node_group, const PointerRNA &properties_ptr)
static void store_result_geometry(const bContext &C, const wmOperator &op, const Depsgraph &depsgraph, Main &bmain, Scene &scene, Object &object, const RegionView3D *rv3d, bke::GeometrySet geometry)
static wmOperatorStatus run_node_group_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static void store_input_node_values_rna_props(const bContext &C, wmOperator &op, const wmEvent &event)
void ui_template_node_operator_asset_menu_items(ui::Layout &layout, const bContext &C, const StringRef path)
static void register_node_tool(wmOperatorType *ot, std::unique_ptr< OperatorTypeData > &type_data_ptr)
static void tree_add_type(Vector< std::unique_ptr< RegistrationData::TypeTreeItem > > &nodes, StringRef path, wmOperatorType *ot)
void ui_template_node_operator_registration_errors(ui::Layout &layout, const StringRefNull idname_py)
static Depsgraph * build_extra_depsgraph(const Depsgraph &depsgraph_active, const Set< ID * > &ids)
static void make_common_type_prop(StructRNA &srna, const EnumPropertyItem *items, const nodes::GeometryNodesInputType default_type)
static void find_verbose_log_contexts(const Main &bmain, Set< ComputeContextHash > &r_verbose_log_contexts)
static void run_node_group_ui(bContext *C, wmOperator *op)
static GeoOperatorLog & get_static_eval_log()
static std::optional< ID_Type > socket_type_to_id_type(const eNodeSocketDatatype socket_type)
static void store_attributes_to_shape_keys(const Mesh &mesh, Key &key)
static Set< StringRef > get_builtin_menus(const ObjectType object_type, const eObjectMode mode)
static const RegistrationData::TypeTreeItem * find_tree_node(const Span< std::unique_ptr< RegistrationData::TypeTreeItem > > nodes, StringRef path)
static RegistrationData::TypeTreeItem * find_tree_child(const Span< std::unique_ptr< RegistrationData::TypeTreeItem > > children, const StringRef name)
static bool menu_operators_poll(const bContext &C, const RegistrationData::TypeTreeItem &node)
static std::optional< StringRefNull > custom_idname_for_group(const bNodeTree &group)
static bool run_node_ui_poll(wmOperatorType *, PointerRNA *ptr)
static void gather_node_group_ids(const bNodeTree &node_tree, Set< ID * > &ids)
static const bNodeTree * get_node_group(const bContext &C, const wmOperatorType &ot, ReportList *reports)
static StructRNA * get_input_socket_struct_rna(IDProperty &input_idprop, OperatorTypeData &type_data)
void register_node_group_operators(const bContext &C)
static OperatorsToRegister get_node_tools_type_data(const bContext &C, Main &bmain, RegistrationData::Errors &errors)
bool ensure_active_keyframe(const Scene &scene, GreasePencil &grease_pencil, bke::greasepencil::Layer &layer, const bool duplicate_previous_key, bool &r_inserted_keyframe)
void apply_eval_grease_pencil_data(const GreasePencil &eval_grease_pencil, const int eval_frame, const IndexMask &orig_layers, GreasePencil &orig_grease_pencil)
void store_mesh_from_eval(const wmOperator &op, const Scene &scene, const Depsgraph &depsgraph, const RegionView3D *rv3d, Object &object, Mesh *new_mesh)
Definition sculpt.cc:5276
QuaternionBase< float > Quaternion
const EnumPropertyItem geometry_nodes_input_type_items_value_or_attribute_or_layer[]
void draw_geometry_nodes_operator_redo_ui(const bContext &C, wmOperator &op, bNodeTree &tree, eval_log::NodeTreeLog *tree_log)
const std::shared_ptr< const GeometryNodesLazyFunctionGraphInfo > & ensure_geometry_nodes_lazy_function_graph(const bNodeTree &btree)
const EnumPropertyItem geometry_nodes_input_type_items_value[]
const EnumPropertyItem geometry_nodes_input_type_items_value_or_attribute[]
bke::GeometrySet execute_geometry_nodes_on_geometry(const bNodeTree &btree, const PointerRNA &properties_ptr, const ComputeContext &base_compute_context, GeoNodesCallData &call_data, bke::GeometrySet input_geometry)
PointCloud * BKE_pointcloud_copy_for_eval(const PointCloud *pointcloud_src)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
void RNA_float_set_array(PointerRNA *ptr, const char *name, const float *values)
__int64 int64_t
Definition BKE_text.h:90
void WM_report_banner_show(wmWindowManager *wm, wmWindow *win)
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
ID * BKE_libblock_find_name(Main *bmain, short type, const char *name, const std::optional< Library * > lib=std::nullopt) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition lib_id.cc:1808
@ RPT_WARNING
Definition BKE_report.hh:40
PointerRNA RNA_main_pointer_create(Main *main)
IDProperty * IDP_GetPropertyTypeFromGroup(const IDProperty *prop, StringRef name, char type) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition idprop.cc:839
BMesh * BKE_editmesh_bmesh_get_for_write(Mesh *mesh)
Definition editmesh.cc:79
void * MEM_new_array_uninitialized(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
void BKE_pointcloud_nomain_to_pointcloud(PointCloud *pointcloud_src, PointCloud *pointcloud_dst)
void BKE_reports_free(ReportList *reports)
Definition report.cc:106
GreasePencil * BKE_grease_pencil_copy_for_eval(const GreasePencil *grease_pencil_src)
PropertyRNA * RNA_def_float_array(StructOrFunctionRNA *cont_, const char *identifier, const int len, const float *default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
ID * BKE_libblock_find_session_uid(Main *bmain, short type, uint32_t session_uid)
Definition lib_id.cc:1826
PropertyRNA * RNA_def_float_color(StructOrFunctionRNA *cont_, const char *identifier, const int len, const float *default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
Mesh * BKE_mesh_copy_for_eval(const Mesh &source)
struct Curves * BKE_curves_copy_for_eval(const struct Curves *curves_src)
bool DEG_id_is_fully_evaluated(const Depsgraph *depsgraph, const ID *id_eval)
IDProperty * IDP_CopyProperty(const IDProperty *prop) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition idprop.cc:986
void BKE_reports_init(ReportList *reports, int flag)
Definition report.cc:91
IDProperty * IDP_GetPropertyFromGroup(const IDProperty *prop, StringRef name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition idprop.cc:818
void BKE_mesh_nomain_to_mesh(Mesh *mesh_src, Mesh *mesh_dst, Object *ob, bool process_shape_keys=true)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
Depsgraph * DEG_graph_new(Main *bmain, Scene *scene, ViewLayer *view_layer, eEvaluationMode mode)
Definition depsgraph.cc:279
size_t WM_operator_bl_idname(char *dst, const char *src)
void EDBM_mesh_load_ex(Main *bmain, Object *ob, bool free_data)
GeometryNodeAssetTraitFlag
@ GEO_NODE_ASSET_PAINT
@ GEO_NODE_ASSET_GREASE_PENCIL
@ GEO_NODE_ASSET_CURVE
@ GEO_NODE_ASSET_EDIT
@ GEO_NODE_ASSET_MESH
@ GEO_NODE_ASSET_WAIT_FOR_CURSOR
@ GEO_NODE_ASSET_POINTCLOUD
@ GEO_NODE_ASSET_SCULPT
@ GEO_NODE_ASSET_OBJECT
@ GEO_NODE_ASSET_TOOL
void WM_operatortype_append_ptr(void(*opfunc)(wmOperatorType *, void *), void *userdata)
int CustomData_get_layer_index(const CustomData *data, eCustomDataType type)
const char * RNA_struct_ui_name(const StructRNA *type)
std::optional< int > IDP_group_lookup_int(const IDProperty &group, StringRef name)
Definition idprop.cc:880
bScreen * BKE_workspace_active_screen_get(const WorkSpaceInstanceHook *hook) GETTER_ATTRS
Definition workspace.cc:684
MatBase< float, 4, 4 > float4x4
const char * BKE_id_name(const ID &id)
std::optional< float > IDP_group_lookup_float(const IDProperty &group, StringRef name)
Definition idprop.cc:871
std::optional< StringRefNull > IDP_group_lookup_string(const IDProperty &group, StringRef name)
Definition idprop.cc:862
int BM_mesh_active_edge_index_get(BMesh *bm)
void DEG_evaluate_on_refresh(Depsgraph *graph, DepsgraphEvaluateSyncWriteback sync_writeback=DEG_EVALUATE_SYNC_WRITEBACK_NO)
PropertyRNA * RNA_def_pointer_runtime(StructOrFunctionRNA *cont, const char *identifier, StructRNA *type, const char *ui_name, const char *ui_description)
std::optional< StringRefNull > CTX_data_string_get(const bContext *C, const char *member)
StructRNA RNA_PropertyGroup
ViewLayer * CTX_data_view_layer(const bContext *C)
Span< wmOperatorType * > WM_operatortypes_registered_get()
std::optional< bool > IDP_group_lookup_bool(const IDProperty &group, StringRef name)
Definition idprop.cc:889
void EDBM_mesh_free_data(BMEditMesh *em)
unsigned int uint32_t
Definition BKE_text.h:81
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
Definition BLI_rect.hh:207
void RNA_int_set_array(PointerRNA *ptr, const char *name, const int *values)
ViewLayer * DEG_get_input_view_layer(const Depsgraph *graph)
void RNA_struct_free(BlenderRNA *brna, StructRNA *srna)
VecBase< int32_t, 2 > int2
Main * DEG_get_bmain(const Depsgraph *graph)
void DEG_id_tag_update(ID *id, unsigned int flags)
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:162
@ OB_MODE_SCULPT_GREASE_PENCIL
@ OB_MODE_SCULPT_CURVES
@ OB_MODE_PAINT_GREASE_PENCIL
BMesh const char void * data
void WM_operatortype_remove_ptr(wmOperatorType *ot)
void RNA_int_get_array(PointerRNA *ptr, const char *name, int *values)
T * DEG_get_evaluated(const Depsgraph *depsgraph, T *id)
wmWindowManager * CTX_wm_manager(const bContext *C)
Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C, bool rna_write_check=false)
VectorSet< T, InlineBufferCapacity, DefaultProbingStrategy, CustomIDHash< T, GetIDFn >, CustomIDEqual< T, GetIDFn > > CustomIDVectorSet
void DEG_graph_build_from_ids(Depsgraph *graph, Span< ID * > ids)
Mesh * BKE_mesh_new_nomain(int verts_num, int edges_num, int faces_num, int corners_num)
int RNA_property_flag(PropertyRNA *prop)
void RNA_def_property_subtype(PropertyRNA *prop, PropertySubType subtype)
void BKE_editmesh_looptris_and_normals_calc(BMEditMesh *em, BMesh *bm)
Definition editmesh.cc:122
IDProperty * BKE_asset_metadata_idprop_find(const AssetMetaData *asset_data, const char *name) ATTR_WARN_UNUSED_RESULT
Definition asset.cc:183
void RNA_struct_py_type_set(StructRNA *srna, void *py_type)
RegionView3D * CTX_wm_region_view3d(const bContext *C)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
const EnumPropertyItem rna_enum_dummy_NULL_items[]
Definition rna_rna.cc:28
void BKE_id_free(Main *bmain, void *idv)
eEvaluationMode DEG_get_mode(const Depsgraph *graph)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
Definition BLI_rect.hh:203
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
int BM_mesh_active_face_index_get(BMesh *bm, bool is_sloppy, bool is_selected)
void RNA_boolean_set(PointerRNA *ptr, const char *name, bool value)
PointerRNA RNA_pointer_get(PointerRNA *ptr, const char *name)
int BIFIconID
Definition ED_asset.hh:30
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
const char * RNA_struct_ui_description(const StructRNA *type)
wmOperatorType * WM_operatortype_find(const char *idname, bool quiet)
void WM_operator_handlers_clear(wmWindowManager *wm, const Set< wmOperatorType * > &types)
Definition wm.cc:400
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 WM_operator_idname_ok_or_report(ReportList *reports, const char *idname)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
Definition report.cc:191
void WM_operator_stack_clear(wmWindowManager *wm)
Definition wm.cc:375
Main * CTX_data_main(const bContext *C)
void EDBM_mesh_make_from_mesh(Object *ob, Mesh *src_mesh, int select_mode, bool add_key_index)
PropertyRNA * RNA_def_float_rotation(StructOrFunctionRNA *cont_, const char *identifier, const int len, const float *default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
@ ID_RECALC_GEOMETRY
Definition DNA_ID.h:1074
@ PROP_HIDDEN
Definition RNA_types.hh:408
@ PROP_ANIMATABLE
Definition RNA_types.hh:389
Scene * DEG_get_input_scene(const Depsgraph *graph)
std::optional< Span< float > > IDP_group_lookup_float_array(const IDProperty &group, StringRef name, int required_size)
Definition idprop.cc:898
PropertyRNA * RNA_def_int_array(StructOrFunctionRNA *cont_, const char *identifier, const int len, const int *default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
Scene * CTX_data_scene(const bContext *C)
@ OPTYPE_REGISTER
Definition WM_types.hh:188
@ OPTYPE_UNDO
Definition WM_types.hh:190
@ OPTYPE_NODE_TOOL
Definition WM_types.hh:234
@ OPTYPE_DEPENDS_ON_CURSOR
Definition WM_types.hh:228
std::string RNA_string_get(PointerRNA *ptr, const char *name)
VecBase< float, 3 > float3
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
@ RPT_PRINT_HANDLED_BY_OWNER
Definition BKE_report.hh:62
ReportList * CTX_wm_reports(const bContext *C)
bool BKE_id_is_editable(const Main *bmain, const ID *id)
Definition lib_id.cc:2782
bool WM_operator_poll(bContext *C, wmOperatorType *ot)
int BM_mesh_active_vert_index_get(BMesh *bm)
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, const float default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
Object * CTX_data_active_object(const bContext *C)
float DEG_get_ctime(const Depsgraph *graph)
bool RNA_struct_in_public_namespace(const StructRNA *type)
ARegion * CTX_wm_region(const bContext *C)
void BKE_object_material_from_eval_data(Main *bmain, Object *ob_orig, const ID *data_eval)
View3D * CTX_wm_view3d(const bContext *C)
void RNA_float_get_array(PointerRNA *ptr, const char *name, float *values)
BlenderRNA RNA_blender_rna_get()
StructRNA * RNA_def_struct_ptr(BlenderRNA *brna, const char *identifier, StructRNA *srnafrom)
#define hash
Definition noise_c.cc:156
The meta-data of an asset. By creating and giving this for a data-block (ID.asset_data),...
ListBaseT< struct IDProperty > group
Definition DNA_ID.h:133
eIDPropertyType type
Definition DNA_ID.h:145
IDPropertyData data
Definition DNA_ID.h:157
char name[258]
Definition DNA_ID.h:433
unsigned int session_uid
Definition DNA_ID.h:463
KeyBlock * refkey
ListBaseT< KeyBlock > block
ListBaseT< wmWindowManager > wm
Definition BKE_main.hh:415
ListBaseT< bNodeTree > nodetrees
Definition BKE_main.hh:409
const T * base_ptr() const
char idname[BKE_ST_MAXNAME]
bool(*) poll(const bContext *C, MenuType *mt)
char label[BKE_ST_MAXNAME]
MenuTypeFlag flag
void(*) draw(const bContext *C, Menu *menu)
const char * description
void(*) listener(const wmRegionListenerParams *params)
ui::Layout * layout
struct AttributeStorage attribute_storage
ListBaseT< Report > list
Definition BKE_report.hh:79
const char * message
Definition BKE_report.hh:73
View3DCursor cursor
struct ToolSettings * toolsettings
ListBaseT< SpaceLink > spacedata
struct bNodeTree * edittree
struct GeometryNodeAssetTraits * geometry_node_asset_traits
eNodeTree_Type type
bke::bNodeTreeRuntime * runtime
ListBaseT< struct ScrArea > areabase
Universally Unique Identifier according to RFC4122.
static GeometrySet from_grease_pencil(GreasePencil *grease_pencil, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
static GeometrySet from_curves(Curves *curves, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
static GeometrySet from_mesh(Mesh *mesh, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
static GeometrySet from_pointcloud(PointCloud *pointcloud, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
Vector< std::string > invalid_input_metadata_errors
friend bool operator==(const ErrorsForType &a, const ErrorsForType &b)=default
StringRefNull operator()(const std::unique_ptr< OperatorTypeData > &value) const
std::variant< AssetWeakReference, LocalRef > group_ref
static std::optional< OperatorTypeData > from_group(const bNodeTree &group, RegistrationData::Errors &errors)
std::unique_ptr< IDProperty, bke::idprop::IDPropertyDeleter > asset_meta_data_properties
Vector< Array< EnumPropertyItem, 0 > > enum_item_storage
static std::optional< OperatorTypeData > from_asset(const AssetRepresentation &asset, RegistrationData::Errors &errors)
Vector< std::unique_ptr< TypeTreeItem > > children
Map< std::string, ErrorsForType > Errors
Vector< std::unique_ptr< TypeTreeItem > > menu_path_tree_roots
const Set< ComputeContextHash > * verbose_log_contexts
void use_property_decorate_set(bool is_decorate)
void use_property_split_set(bool is_sep)
void label(StringRef name, int icon)
void menu_contents(StringRef menuname)
PointerRNA op(wmOperatorType *ot, std::optional< StringRef > name, int icon, wm::OpCallContext context, eUI_Item_Flag flag)
void menu(MenuType *mt, std::optional< StringRef > name, int icon)
Layout & column(bool align)
void context_string_set(StringRef name, StringRef value)
void separator(float factor=1.0f, LayoutSeparatorType type=LayoutSeparatorType::Auto)
std::unique_ptr< TypeData > custom_data
Definition WM_types.hh:1227
wmOperatorStatus(*) exec(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1125
const char * description
Definition WM_types.hh:1115
bool(*) pyop_poll(bContext *C, wmOperatorType *ot) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1224
bool(*) ui_poll(wmOperatorType *ot, PointerRNA *ptr)
Definition WM_types.hh:1181
void(*) ui(bContext *C, wmOperator *op)
Definition WM_types.hh:1176
wmOperatorStatus(*) invoke(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1141
struct ReportList * reports
struct wmOperatorType * type
struct WorkSpaceInstanceHook * workspace_hook
#define N_(msgid)