32 "Output each child of the collection as a separate instance, sorted alphabetically");
35 "Reset the transforms of every child instance in the output. Only used when Separate "
36 "Children is enabled");
62 if (collection ==
nullptr) {
63 params.set_default_remaining_outputs();
69 collection,
const_cast<Object *
>(self_object));
71 params.error_message_add(NodeWarningType::Error,
TIP_(
"Collection contains current object"));
72 params.set_default_remaining_outputs();
76 params.error_message_add(NodeWarningType::Error,
77 TIP_(
"Can't access collections geometry because it's not evaluated "
78 "yet. This can happen when there is a dependency cycle"));
79 params.set_default_remaining_outputs();
87 std::unique_ptr<bke::Instances> instances = std::make_unique<bke::Instances>();
89 const bool separate_children =
params.get_input<
bool>(
"Separate Children");
90 if (separate_children) {
91 const bool reset_children =
params.get_input<
bool>(
"Reset Children");
94 children_collections.
append(collection_child->collection);
98 children_objects.
append(collection_object->ob);
102 entries.
reserve(children_collections.size() + children_objects.
size());
104 for (
Collection *child_collection : children_collections) {
106 if (!reset_children) {
107 transform.location() +=
float3(child_collection->instance_offset);
108 if (use_relative_transform) {
109 transform = self_object->world_to_object() *
transform;
112 transform.location() -=
float3(collection->instance_offset);
115 const int handle = instances->add_reference(*child_collection);
116 entries.
append({handle, &(child_collection->id.name[2]), transform});
118 for (
Object *child_object : children_objects) {
119 const int handle = instances->add_reference(*child_object);
121 if (!reset_children) {
122 if (use_relative_transform) {
123 transform = self_object->world_to_object();
126 transform.location() -=
float3(collection->instance_offset);
128 transform *= child_object->object_to_world();
130 entries.
append({handle, &(child_object->id.name[2]), transform});
133 std::sort(entries.
begin(),
136 return BLI_strcasecmp_natural(a.name, b.name) < 0;
139 instances->add_instance(entry.handle, entry.transform);
144 if (use_relative_transform) {
145 transform.location() = collection->instance_offset;
146 transform = self_object->world_to_object() *
transform;
149 const int handle = instances->add_reference(*collection);
150 instances->add_instance(handle, transform);
153 geometry.name = collection->id.name + 2;
155 params.set_output(
"Instances", std::move(geometry));
160 static const EnumPropertyItem rna_node_geometry_collection_info_transform_space_items[] = {
165 "Output the geometry relative to the collection offset"},
170 "Bring the input collection geometry into the modified object, maintaining the relative "
171 "position between the objects in the scene"},
172 {0,
nullptr, 0,
nullptr,
nullptr},
179 "The transformation of the instances output. Does not affect the internal geometry",
180 rna_node_geometry_collection_info_transform_space_items,
194 "NodeGeometryCollectionInfo",
bool BKE_collection_has_object_recursive_instanced_orig_id(Collection *collection_eval, Object *object_eval)
#define NODE_STORAGE_FUNCS(StorageT)
#define LISTBASE_FOREACH(type, var, list)
bool DEG_collection_geometry_is_evaluated(const Collection &collection)
Object groups, one object can be in many groups at once.
@ GEO_NODE_TRANSFORM_SPACE_RELATIVE
@ GEO_NODE_TRANSFORM_SPACE_ORIGINAL
#define NOD_REGISTER_NODE(REGISTER_FUNC)
void rna_Node_update_relations(Main *bmain, Scene *scne, PointerRNA *ptr)
#define NOD_storage_enum_accessors(member)
void uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, eUI_Item_Flag flag, const char *name, int icon)
void append(const T &value)
void reserve(const int64_t min_capacity)
local_group_size(16, 16) .push_constant(Type b
void node_type_storage(bNodeType *ntype, const char *storagename, void(*freefunc)(bNode *node), void(*copyfunc)(bNodeTree *dest_ntree, bNode *dest_node, const bNode *src_node))
void node_register_type(bNodeType *ntype)
static void node_rna(StructRNA *srna)
static void node_declare(NodeDeclarationBuilder &b)
static void node_layout(uiLayout *layout, bContext *, PointerRNA *ptr)
static void node_register()
static void node_node_init(bNodeTree *, bNode *node)
static void node_geo_exec(GeoNodeExecParams params)
PropertyRNA * RNA_def_node_enum(StructRNA *srna, const char *identifier, const char *ui_name, const char *ui_description, const EnumPropertyItem *static_items, const EnumRNAAccessors accessors, std::optional< int > default_value, const EnumPropertyItemFunc item_func, const bool allow_animation)
void transform(Context &context, Result &input, Result &output, const float3x3 &transformation, RealizationOptions realization_options)
VecBase< float, 3 > float3
void geo_node_type_base(blender::bke::bNodeType *ntype, int type, const char *name, short nclass)
void node_free_standard_storage(bNode *node)
void node_copy_standard_storage(bNodeTree *, bNode *dest_node, const bNode *src_node)
void RNA_def_property_update_runtime(PropertyRNA *prop, RNAPropertyUpdateFunc func)
static MatBase identity()
static GeometrySet from_instances(Instances *instances, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
void(* initfunc)(bNodeTree *ntree, bNode *node)
NodeGeometryExecFunction geometry_node_execute
void(* draw_buttons)(uiLayout *, bContext *C, PointerRNA *ptr)
NodeDeclareFunction declare