20 b.add_input<
decl::Bool>(
N_(
"Selection")).default_value(
true).supports_field().hide_value();
22 .description(
N_(
"Geometry that is instanced on the points"));
25 .
description(
N_(
"Choose instances from the \"Instance\" input at each point instead of "
26 "instancing the entire geometry"));
30 "Index of the instance that used for each point. This is only used when Pick Instances "
31 "is on. By default the point index is used"));
37 .default_value({1.0f, 1.0f, 1.0f})
63 evaluator.set_selection(selection_field);
72 const IndexMask selection = evaluator.get_evaluated_selection_as_mask();
81 dst_component.
resize(start_len + select_len);
89 "position", domain, {0, 0, 0});
96 if (src_instances !=
nullptr &&
99 handle_mapping.reinitialize(src_references.
size());
100 for (
const int src_instance_handle : src_references.
index_range()) {
102 const int dst_instance_handle = dst_component.
add_reference(reference);
103 handle_mapping[src_instance_handle] = dst_instance_handle;
112 for (const int range_i : selection_range) {
113 const int64_t i = selection[range_i];
116 float4x4 &dst_transform = dst_transforms[range_i];
117 dst_transform = float4x4::from_loc_eul_scale(positions[i], rotations[i], scales[i]);
120 int dst_handle = empty_reference_handle;
122 const bool use_individual_instance = pick_instance[i];
123 if (use_individual_instance) {
124 if (src_instances != nullptr) {
125 const int src_instances_num = src_instances->instances_num();
126 const int original_index = indices[i];
129 const int index = mod_i(original_index, std::max(src_instances_num, 1));
130 if (index < src_instances_num) {
132 const int src_handle = src_instances->instance_reference_handles()[index];
133 dst_handle = handle_mapping[src_handle];
136 mul_m4_m4_post(dst_transform.values,
137 src_instances->instance_transforms()[index].values);
143 dst_handle = full_instance_handle;
146 dst_handles[range_i] = dst_handle;
150 if (pick_instance.is_single()) {
151 if (pick_instance.get_internal_single()) {
155 TIP_(
"Realized geometry is not used when pick instances is true"));
160 bke::CustomDataAttributes &instance_attributes = dst_component.instance_attributes();
161 for (
const auto item : attributes_to_propagate.items()) {
162 const AttributeIDRef &attribute_id = item.key;
163 const AttributeKind attribute_kind = item.value;
165 const GVArray src_attribute = src_component.attributes()->lookup_or_default(
168 std::optional<GMutableSpan> dst_attribute_opt = instance_attributes.get_for_write(
170 if (!dst_attribute_opt) {
171 if (!instance_attributes.create(attribute_id, attribute_kind.data_type)) {
174 dst_attribute_opt = instance_attributes.get_for_write(attribute_id);
177 const GMutableSpan dst_attribute = dst_attribute_opt->slice(start_len, select_len);
179 attribute_math::convert_to_static_type(attribute_kind.data_type, [&](auto dummy) {
180 using T = decltype(dummy);
181 VArray<T> src = src_attribute.typed<T>();
182 MutableSpan<T> dst = dst_attribute.typed<T>();
183 for (const int range_i : selection_range) {
184 const int i = selection[range_i];
185 dst[range_i] = src[i];
207 attributes_to_propagate.
remove(
"position");
215 attributes_to_propagate);
229 params.set_output(
"Instances", std::move(geometry_set));
@ GEO_COMPONENT_TYPE_MESH
@ GEO_COMPONENT_TYPE_POINT_CLOUD
@ GEO_COMPONENT_TYPE_INSTANCES
@ GEO_COMPONENT_TYPE_CURVE
#define NODE_CLASS_GEOMETRY
#define GEO_NODE_INSTANCE_ON_POINTS
void nodeRegisterType(struct bNodeType *ntype)
Object groups, one object can be in many groups at once.
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
in reality light always falls off quadratically Particle Info
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object instance
int attribute_domain_size(eAttrDomain domain) const
virtual std::optional< blender::bke::AttributeAccessor > attributes() const
blender::Span< int > instance_reference_handles() const
void remove_unused_references()
int add_reference(const InstanceReference &reference)
void resize(int capacity)
blender::MutableSpan< blender::float4x4 > instance_transforms()
int instances_num() const
IndexRange index_range() const
constexpr int64_t size() const
bool remove(const Key &key)
constexpr Span slice(int64_t start, int64_t size) const
constexpr int64_t size() const
constexpr IndexRange index_range() const
T get_internal_single() const
StringRefNull description() const
ccl_gpu_kernel_postfix int ccl_global int * indices
static int domain_num(const CurvesGeometry &curves, const eAttrDomain domain)
static void add_instances_from_component(InstancesComponent &dst_component, const GeometryComponent &src_component, const GeometrySet &instance, const GeoNodeExecParams ¶ms, const Map< AttributeIDRef, AttributeKind > &attributes_to_propagate)
static void node_geo_exec(GeoNodeExecParams params)
static void node_declare(NodeDeclarationBuilder &b)
void parallel_for(IndexRange range, int64_t grain_size, const Function &function)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
MutableSpan< float3 > positions
MutableSpan< float3 > rotations
void register_node_type_geo_instance_on_points()
void geo_node_type_base(bNodeType *ntype, int type, const char *name, short nclass)
GeometryComponent & get_component_for_write(GeometryComponentType component_type)
bool has(const GeometryComponentType component_type) const
const GeometryComponent * get_component_for_read(GeometryComponentType component_type) const
void gather_attributes_for_propagation(blender::Span< GeometryComponentType > component_types, GeometryComponentType dst_component_type, bool include_instances, blender::Map< blender::bke::AttributeIDRef, blender::bke::AttributeKind > &r_attributes) const
void modify_geometry_sets(ForeachSubGeometryCallback callback)
void remove_geometry_during_modify()
NodeGeometryExecFunction geometry_node_execute
NodeDeclareFunction declare