Blender V4.3
blender::bke::Instances Class Reference

#include <BKE_instances.hh>

Public Member Functions

 Instances ()
 
 Instances (Instances &&other)
 
 Instances (const Instances &other)
 
 ~Instances ()
 
Instancesoperator= (const Instances &other)
 
Instancesoperator= (Instances &&other)
 
void resize (int capacity)
 
int add_reference (const InstanceReference &reference)
 
int add_new_reference (const InstanceReference &reference)
 
std::optional< intfind_reference_handle (const InstanceReference &query)
 
void add_instance (int instance_handle, const float4x4 &transform)
 
Span< InstanceReferencereferences () const
 
void remove_unused_references ()
 
void ensure_geometry_instances ()
 
GeometrySetgeometry_set_from_reference (int reference_index)
 
Span< intreference_handles () const
 
MutableSpan< intreference_handles_for_write ()
 
Span< float4x4transforms () const
 
MutableSpan< float4x4transforms_for_write ()
 
int instances_num () const
 
int references_num () const
 
void remove (const IndexMask &mask, const AttributeFilter &attribute_filter)
 
Span< intalmost_unique_ids () const
 
Span< intreference_user_counts () const
 
void foreach_referenced_geometry (FunctionRef< void(const GeometrySet &geometry_set)> callback) const
 
bool owns_direct_data () const
 
void ensure_owns_direct_data ()
 
void count_memory (MemoryCounter &memory) const
 
void tag_reference_handles_changed ()
 
Geometry Component Implementation
bke::AttributeAccessor attributes () const
 
bke::MutableAttributeAccessor attributes_for_write ()
 
#InstanceReference Inline Methods
CustomDatacustom_data_attributes ()
 
const CustomDatacustom_data_attributes () const
 

Detailed Description

Definition at line 112 of file BKE_instances.hh.

Constructor & Destructor Documentation

◆ Instances() [1/3]

blender::bke::Instances::Instances ( )

Definition at line 140 of file instances.cc.

References CustomData_reset().

Referenced by operator=(), and operator=().

◆ Instances() [2/3]

blender::bke::Instances::Instances ( Instances && other)

Definition at line 145 of file instances.cc.

References CustomData_reset().

◆ Instances() [3/3]

blender::bke::Instances::Instances ( const Instances & other)

Definition at line 155 of file instances.cc.

References CD_MASK_ALL, and CustomData_init_from().

◆ ~Instances()

blender::bke::Instances::~Instances ( )

Definition at line 164 of file instances.cc.

References CustomData_free().

Member Function Documentation

◆ add_instance()

void blender::bke::Instances::add_instance ( int instance_handle,
const 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 195 of file instances.cc.

References BLI_assert, CustomData_realloc(), blender::MutableSpan< T >::last(), reference_handles_for_write(), tag_reference_handles_changed(), transform(), and transforms_for_write().

◆ add_new_reference()

int blender::bke::Instances::add_new_reference ( const InstanceReference & reference)

Same as above, but does not deduplicate with existing references.

Definition at line 271 of file instances.cc.

References tag_reference_handles_changed().

Referenced by add_reference().

◆ add_reference()

int blender::bke::Instances::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 263 of file instances.cc.

References add_new_reference(), and find_reference_handle().

Referenced by blender::nodes::node_geo_instance_on_points_cc::add_instances_from_component(), and blender::nodes::node_geo_split_to_instances_cc::node_geo_exec().

◆ almost_unique_ids()

◆ attributes()

◆ attributes_for_write()

◆ count_memory()

void blender::bke::Instances::count_memory ( MemoryCounter & memory) const

Definition at line 420 of file instances.cc.

References CustomData_count_memory().

Referenced by blender::bke::InstancesComponent::count_memory().

◆ custom_data_attributes() [1/2]

CustomData & blender::bke::Instances::custom_data_attributes ( )
inline

◆ custom_data_attributes() [2/2]

const CustomData & blender::bke::Instances::custom_data_attributes ( ) const
inline

Definition at line 312 of file BKE_instances.hh.

◆ ensure_geometry_instances()

◆ ensure_owns_direct_data()

void blender::bke::Instances::ensure_owns_direct_data ( )

◆ find_reference_handle()

std::optional< int > blender::bke::Instances::find_reference_handle ( const InstanceReference & query)

Definition at line 252 of file instances.cc.

Referenced by add_reference().

◆ foreach_referenced_geometry()

◆ geometry_set_from_reference()

GeometrySet & blender::bke::Instances::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 243 of file instances.cc.

References BLI_assert, and blender::bke::InstanceReference::GeometrySet.

◆ instances_num()

◆ operator=() [1/2]

Instances & blender::bke::Instances::operator= ( const Instances & other)

Definition at line 169 of file instances.cc.

References Instances().

◆ operator=() [2/2]

Instances & blender::bke::Instances::operator= ( Instances && other)

Definition at line 179 of file instances.cc.

References Instances().

◆ owns_direct_data()

bool blender::bke::Instances::owns_direct_data ( ) const

Definition at line 400 of file instances.cc.

Referenced by blender::bke::InstancesComponent::owns_direct_data().

◆ reference_handles()

◆ reference_handles_for_write()

◆ reference_user_counts()

Span< int > blender::bke::Instances::reference_user_counts ( ) const

◆ references()

◆ references_num()

int blender::bke::Instances::references_num ( ) const

Definition at line 395 of file instances.cc.

Referenced by reference_user_counts().

◆ remove()

void blender::bke::Instances::remove ( const IndexMask & mask,
const AttributeFilter & attribute_filter )

Remove the indices that are not contained in the mask input, and remove unused instance references afterwards.

Definition at line 282 of file instances.cc.

References attributes(), attributes_for_write(), blender::bke::gather_attributes(), blender::bke::Instance, remove_unused_references(), resize(), and blender::index_mask::IndexMask::size().

◆ remove_unused_references()

◆ resize()

void blender::bke::Instances::resize ( int capacity)

Resize the transform, handles, and attributes to the specified capacity.

Note
This function should be used carefully, only when it's guaranteed that the data will be filled.

Definition at line 189 of file instances.cc.

References CD_SET_DEFAULT, and CustomData_realloc().

Referenced by blender::nodes::node_geo_instance_on_points_cc::add_instances_from_component(), blender::nodes::node_geo_split_to_instances_cc::node_geo_exec(), and remove().

◆ tag_reference_handles_changed()

void blender::bke::Instances::tag_reference_handles_changed ( )
inline

◆ transforms()

Span< float4x4 > blender::bke::Instances::transforms ( ) const

◆ transforms_for_write()


The documentation for this class was generated from the following files: