Blender
V3.3
|
#include <BKE_geometry_set.hh>
Static Public Attributes | |
static constexpr GeometryComponentType | static_type = GEO_COMPONENT_TYPE_INSTANCES |
Additional Inherited Members | |
![]() | |
static GeometryComponent * | create (GeometryComponentType component_type) |
A geometry component that stores instances. The instance data can be any type described by InstanceReference. Geometry instances can even contain instances themselves, for nested instancing. Each instance has an index into an array of unique instance data, and a transform. The component can also store generic attributes for each instance.
The component works differently from other geometry components in that it stores data about instancing directly, rather than owning a pointer to a separate data structure.
This component is not responsible for handling the interface to a render engine, or other areas that work with all visible geometry, that is handled by the dependency graph iterator (see DEG_depsgraph_query.h
).
Definition at line 697 of file BKE_geometry_set.hh.
InstancesComponent::InstancesComponent | ( | ) |
Definition at line 39 of file geometry_component_instances.cc.
Referenced by copy().
|
default |
void InstancesComponent::add_instance | ( | int | instance_handle, |
const blender::float4x4 & | transform | ||
) |
Add a reference to the instance reference with an index specified by the #instance_handle argument. For adding many instances, using resize and accessing the transform array directly is preferred.
Definition at line 75 of file geometry_component_instances.cc.
References blender::Vector< T, InlineBufferCapacity, Allocator >::append(), BLI_assert, instances_num(), blender::bke::CustomDataAttributes::reallocate(), blender::VectorSet< Key, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::size(), and transform().
Referenced by blender::nodes::node_geo_join_geometry_cc::join_component_type(), blender::nodes::node_geo_join_geometry_cc::join_components(), blender::nodes::node_geo_collection_info_cc::node_geo_exec(), blender::nodes::node_geo_geometry_to_instance_cc::node_geo_exec(), blender::nodes::node_geo_object_info_cc::node_geo_exec(), and blender::bke::object_get_evaluated_geometry_set().
int InstancesComponent::add_reference | ( | const InstanceReference & | reference | ) |
Returns a handle for the given reference. If the reference exists already, the handle of the existing reference is returned. Otherwise a new handle is added.
Definition at line 114 of file geometry_component_instances.cc.
References blender::VectorSet< Key, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::index_of_or_add_as().
Referenced by blender::nodes::node_geo_instance_on_points_cc::add_instances_from_component(), blender::nodes::node_geo_string_to_curves_cc::create_curve_instances(), blender::nodes::node_geo_duplicate_elements_cc::duplicate_instances(), blender::nodes::node_geo_join_geometry_cc::join_component_type(), blender::nodes::node_geo_join_geometry_cc::join_components(), blender::nodes::node_geo_collection_info_cc::node_geo_exec(), blender::nodes::node_geo_geometry_to_instance_cc::node_geo_exec(), blender::nodes::node_geo_object_info_cc::node_geo_exec(), and blender::bke::object_get_evaluated_geometry_set().
blender::Span< int > InstancesComponent::almost_unique_ids | ( | ) | const |
Definition at line 349 of file geometry_component_instances.cc.
References generate_unique_instance_ids(), instances_num(), lock, and blender::Span< T >::size().
|
finalvirtual |
Get access to the attributes in this geometry component. May return none if the geometry does not support the attribute system.
Reimplemented from GeometryComponent.
Definition at line 514 of file geometry_component_instances.cc.
References blender::bke::get_instances_accessor_functions_ref().
Referenced by blender::nodes::node_geo_instances_to_points_cc::convert_instances_to_points(), and blender::nodes::node_geo_duplicate_elements_cc::duplicate_instances().
|
finalvirtual |
Reimplemented from GeometryComponent.
Definition at line 520 of file geometry_component_instances.cc.
References blender::bke::get_instances_accessor_functions_ref().
Referenced by blender::nodes::node_geo_string_to_curves_cc::create_attributes(), and blender::nodes::node_geo_duplicate_elements_cc::duplicate_instances().
void InstancesComponent::clear | ( | ) |
|
overridevirtual |
Implements GeometryComponent.
Definition at line 43 of file geometry_component_instances.cc.
References InstancesComponent().
void InstancesComponent::ensure_geometry_instances | ( | ) |
If references have a collection or object type, convert them into geometry instances recursively. After that, the geometry sets can be edited. There may still be instances of other types of they can't be converted to geometry sets.
Definition at line 195 of file geometry_set_instances.cc.
References blender::VectorSet< Key, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::add_new(), InstanceReference::Collection, component(), FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN, FOREACH_COLLECTION_OBJECT_RECURSIVE_END, InstanceReference::GeometrySet, GeometrySet::get_component_for_write(), GeometrySet::has_instances(), InstanceReference::None, InstanceReference::Object, blender::bke::object_get_evaluated_geometry_set(), blender::VectorSet< Key, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::reserve(), sub_v3_v3(), and transform().
Referenced by gather_mutable_geometry_sets().
|
overridevirtual |
Implements GeometryComponent.
Definition at line 285 of file geometry_component_instances.cc.
References BLI_assert, InstanceReference::ensure_owns_direct_data(), and GeometryComponent::is_mutable().
Referenced by blender::nodes::node_geo_geometry_to_instance_cc::node_geo_exec().
void InstancesComponent::foreach_referenced_geometry | ( | blender::FunctionRef< void(const GeometrySet &geometry_set)> | callback | ) | const |
Definition at line 162 of file geometry_set_instances.cc.
References callback, InstanceReference::Collection, FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN, FOREACH_COLLECTION_OBJECT_RECURSIVE_END, InstanceReference::GeometrySet, InstanceReference::None, InstanceReference::Object, and blender::bke::object_get_evaluated_geometry_set().
Referenced by GeometrySet::attribute_foreach(), and gather_component_types_recursive().
GeometrySet & InstancesComponent::geometry_set_from_reference | ( | int | reference_index | ) |
With write access to the instances component, the data in the instanced geometry sets can be changed. This is a function on the component rather than each reference to ensure const
correctness for that reason.
Definition at line 103 of file geometry_component_instances.cc.
References BLI_assert, InstanceReference::GeometrySet, and GeometryComponent::type().
Referenced by gather_mutable_geometry_sets().
blender::bke::CustomDataAttributes & InstancesComponent::instance_attributes | ( | ) |
Definition at line 368 of file geometry_component_instances.cc.
Referenced by blender::bke::create_attribute_providers_for_instances(), blender::geometry::gather_realize_tasks_for_instances(), and blender::geometry::prepare_attribute_fallbacks().
const blender::bke::CustomDataAttributes & InstancesComponent::instance_attributes | ( | ) | const |
Definition at line 373 of file geometry_component_instances.cc.
blender::MutableSpan< int > InstancesComponent::instance_reference_handles | ( | ) |
Definition at line 89 of file geometry_component_instances.cc.
blender::Span< int > InstancesComponent::instance_reference_handles | ( | ) | const |
Definition at line 84 of file geometry_component_instances.cc.
Referenced by blender::nodes::node_geo_instance_on_points_cc::add_instances_from_component(), blender::nodes::node_geo_string_to_curves_cc::add_instances_from_handles(), blender::nodes::node_geo_duplicate_elements_cc::duplicate_instances(), blender::geometry::gather_realize_tasks_for_instances(), blender::bke::geometry_set_collect_recursive(), blender::ed::spreadsheet::GeometryDataSource::get_column_values(), and remove_instances().
blender::MutableSpan< blender::float4x4 > InstancesComponent::instance_transforms | ( | ) |
Definition at line 94 of file geometry_component_instances.cc.
Referenced by blender::nodes::node_geo_instance_on_points_cc::add_instances_from_component(), blender::nodes::node_geo_string_to_curves_cc::add_instances_from_handles(), blender::nodes::node_geo_duplicate_elements_cc::duplicate_instances(), blender::geometry::gather_realize_tasks_for_instances(), blender::bke::geometry_set_collect_recursive(), blender::ed::spreadsheet::GeometryDataSource::get_column_values(), blender::nodes::node_geo_input_instance_rotation_cc::VectorFieldInput::get_varray_for_context(), blender::nodes::node_geo_input_instance_scale_cc::VectorFieldInput::get_varray_for_context(), remove_instances(), blender::nodes::node_geo_rotate_instances_cc::rotate_instances(), blender::nodes::node_geo_scale_instances_cc::scale_instances(), blender::nodes::transform_instances(), blender::nodes::node_geo_translate_instances_cc::translate_instances(), blender::nodes::translate_instances(), blender::bke::InstancePositionAttributeProvider::try_get_for_read(), and blender::bke::InstancePositionAttributeProvider::try_get_for_write().
blender::Span< blender::float4x4 > InstancesComponent::instance_transforms | ( | ) | const |
Definition at line 98 of file geometry_component_instances.cc.
int InstancesComponent::instances_num | ( | ) | const |
Definition at line 260 of file geometry_component_instances.cc.
Referenced by add_instance(), blender::nodes::node_geo_instance_on_points_cc::add_instances_from_component(), almost_unique_ids(), blender::nodes::node_geo_instances_to_points_cc::convert_instances_to_points(), blender::bke::create_attribute_providers_for_instances(), blender::nodes::node_geo_delete_geometry_cc::delete_selected_instances(), blender::nodes::node_geo_duplicate_elements_cc::duplicate_instances(), blender::bke::get_instances_accessor_functions(), blender::nodes::node_geo_input_instance_rotation_cc::VectorFieldInput::get_varray_for_context(), blender::nodes::node_geo_input_instance_scale_cc::VectorFieldInput::get_varray_for_context(), blender::nodes::node_geo_join_geometry_cc::join_components(), blender::geometry::prepare_attribute_fallbacks(), remove_unused_references(), blender::nodes::node_geo_rotate_instances_cc::rotate_instances(), blender::nodes::node_geo_scale_instances_cc::scale_instances(), and blender::nodes::node_geo_translate_instances_cc::translate_instances().
|
finalvirtual |
Reimplemented from GeometryComponent.
Definition at line 270 of file geometry_component_instances.cc.
|
overridevirtual |
Implements GeometryComponent.
Definition at line 275 of file geometry_component_instances.cc.
blender::Span< InstanceReference > InstancesComponent::references | ( | ) | const |
Definition at line 119 of file geometry_component_instances.cc.
Referenced by blender::nodes::node_geo_duplicate_elements_cc::duplicate_instances(), gather_mutable_geometry_sets(), blender::geometry::gather_realize_tasks_for_instances(), blender::bke::geometry_set_collect_recursive(), and blender::ed::spreadsheet::GeometryDataSource::get_column_values().
int InstancesComponent::references_num | ( | ) | const |
Definition at line 265 of file geometry_component_instances.cc.
void InstancesComponent::remove_instances | ( | const blender::IndexMask | mask | ) |
Remove the indices that are not contained in the mask input, and remove unused instance references afterwards.
Definition at line 136 of file geometry_component_instances.cc.
References ATTR_DOMAIN_INSTANCE, blender::attribute_math::convert_to_static_type(), blender::bke::CustomDataAttributes::create(), blender::bke::AttributeMetaData::data_type, blender::bke::CustomDataAttributes::foreach_attribute(), blender::bke::CustomDataAttributes::get_for_read(), blender::bke::CustomDataAttributes::get_for_write(), instance_reference_handles(), instance_transforms(), mask(), blender::bke::CustomDataAttributes::reallocate(), remove_unused_references(), resize(), blender::IndexMask::size(), and src.
Referenced by blender::nodes::node_geo_delete_geometry_cc::delete_selected_instances().
void InstancesComponent::remove_unused_references | ( | ) |
Definition at line 180 of file geometry_component_instances.cc.
References blender::VectorSet< Key, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::add_new(), blender::Vector< T, InlineBufferCapacity, Allocator >::append(), blender::Array< T, InlineBufferCapacity, Allocator >::as_span(), BLI_assert, instances_num(), lock, mutex, and blender::threading::parallel_for().
Referenced by blender::nodes::node_geo_instance_on_points_cc::node_geo_exec(), and remove_instances().
void InstancesComponent::reserve | ( | int | min_capacity | ) |
Definition at line 53 of file geometry_component_instances.cc.
References blender::bke::CustomDataAttributes::reallocate(), and blender::Vector< T, InlineBufferCapacity, Allocator >::reserve().
Referenced by blender::nodes::node_geo_join_geometry_cc::join_components(), and blender::nodes::node_geo_collection_info_cc::node_geo_exec().
void InstancesComponent::resize | ( | int | capacity | ) |
Resize the transform, handles, and attributes to the specified capacity.
Definition at line 60 of file geometry_component_instances.cc.
References blender::bke::CustomDataAttributes::reallocate(), and blender::Vector< T, InlineBufferCapacity, Allocator >::resize().
Referenced by blender::nodes::node_geo_instance_on_points_cc::add_instances_from_component(), blender::nodes::node_geo_string_to_curves_cc::add_instances_from_handles(), blender::nodes::node_geo_duplicate_elements_cc::duplicate_instances(), and remove_instances().
|
inlinestaticconstexpr |
Definition at line 794 of file BKE_geometry_set.hh.