Blender V4.5
blender::geometry::GeometrySet Struct Reference

#include <BKE_geometry_set.hh>

Public Types

using AttributeForeachCallback
using ForeachSubGeometryCallback = FunctionRef<void(GeometrySet &geometry_set)>

Public Member Functions

template<typename Component>
Component & get_component_for_write ()
template<typename Component>
const Component * get_component () const
template<typename Component>
bool has () const
template<typename Component>
bool has_component () const
template<typename Component>
void remove ()
uint64_t hash () const

Public Attributes

std::string name

Friends

std::ostream & operator<< (std::ostream &stream, const GeometrySet &geometry_set)
bool operator== (const GeometrySet &a, const GeometrySet &b)

Geometry Set

 GeometrySet ()
 GeometrySet (const GeometrySet &other)
 GeometrySet (GeometrySet &&other)
 ~GeometrySet ()
GeometrySetoperator= (const GeometrySet &other)
GeometrySetoperator= (GeometrySet &&other)
GeometryComponentget_component_for_write (GeometryComponent::Type component_type)
const GeometryComponentget_component (GeometryComponent::Type component_type) const
bool has (const GeometryComponent::Type component_type) const
void remove (const GeometryComponent::Type component_type)
void keep_only (Span< GeometryComponent::Type > component_types)
void keep_only_during_modify (Span< GeometryComponent::Type > component_types)
void remove_geometry_during_modify ()
void add (const GeometryComponent &component)
Vector< const GeometryComponent * > get_components () const
std::optional< Bounds< float3float3 > > compute_boundbox_without_instances (bool use_radius=true, bool use_subdiv=false) const
void clear ()
bool owns_direct_data () const
void ensure_owns_direct_data ()
void ensure_owns_all_data ()
void ensure_no_shared_components ()
void attribute_foreach (Span< GeometryComponent::Type > component_types, bool include_instances, AttributeForeachCallback callback) const
void gather_attributes_for_propagation (Span< GeometryComponent::Type > component_types, GeometryComponent::Type dst_component_type, bool include_instances, const AttributeFilter &attribute_filter, Map< StringRef, AttributeDomainAndType > &r_attributes) const
Vector< GeometryComponent::Typegather_component_types (bool include_instances, bool ignore_empty) const
void modify_geometry_sets (ForeachSubGeometryCallback callback)
bool has_mesh () const
bool has_pointcloud () const
bool has_instances () const
bool has_volume () const
bool has_curves () const
bool has_realized_data () const
bool has_grease_pencil () const
bool is_empty () const
const Meshget_mesh () const
const PointCloudget_pointcloud () const
const Volumeget_volume () const
const Curvesget_curves () const
const Instancesget_instances () const
const CurvesEditHints * get_curve_edit_hints () const
const GreasePencilEditHints * get_grease_pencil_edit_hints () const
const GizmoEditHints * get_gizmo_edit_hints () const
const GreasePencilget_grease_pencil () const
Meshget_mesh_for_write ()
PointCloudget_pointcloud_for_write ()
Volumeget_volume_for_write ()
Curvesget_curves_for_write ()
Instancesget_instances_for_write ()
CurvesEditHints * get_curve_edit_hints_for_write ()
GreasePencilEditHints * get_grease_pencil_edit_hints_for_write ()
GizmoEditHints * get_gizmo_edit_hints_for_write ()
GreasePencilget_grease_pencil_for_write ()
void replace_mesh (Mesh *mesh, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
void replace_pointcloud (PointCloud *pointcloud, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
void replace_volume (Volume *volume, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
void replace_curves (Curves *curves, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
void replace_instances (Instances *instances, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
void replace_grease_pencil (GreasePencil *grease_pencil, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
void count_memory (MemoryCounter &memory) const
static GeometrySet from_mesh (Mesh *mesh, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
static GeometrySet from_volume (Volume *volume, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
static GeometrySet from_pointcloud (PointCloud *pointcloud, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
static GeometrySet from_curves (Curves *curves, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
static GeometrySet from_instances (Instances *instances, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
static GeometrySet from_grease_pencil (GreasePencil *grease_pencil, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)

Detailed Description

A geometry set is a container for multiple kinds of geometry. It does not own geometry directly itself, instead geometry is owned by multiple #GeometryComponents, and the geometry set increases the user count of each component, so they avoid losing the data. This means individual components might be shared between multiple geometries and other code. Shared components are copied automatically when write access is requested.

The components usually do not store data directly, but keep a reference to a data structure defined elsewhere. There is at most one component of each type:

Copying a geometry set is a relatively cheap operation, because it does not copy the referenced geometry components, so GeometrySet can often be passed or moved by value.

Definition at line 145 of file BKE_geometry_set.hh.

Member Typedef Documentation

◆ AttributeForeachCallback

Initial value:
FunctionRef<void(StringRef attribute_id,
const AttributeMetaData &meta_data,
const GeometryComponent &component)>

Definition at line 257 of file BKE_geometry_set.hh.

◆ ForeachSubGeometryCallback

Constructor & Destructor Documentation

◆ GeometrySet() [1/3]

The methods are defaulted here so that they are not instantiated in every translation unit.

◆ GeometrySet() [2/3]

◆ GeometrySet() [3/3]

◆ ~GeometrySet()

Member Function Documentation

◆ add()

Definition at line 180 of file geometry_set.cc.

◆ attribute_foreach()

void blender::bke::GeometrySet::attribute_foreach ( Span< GeometryComponent::Type > component_types,
bool include_instances,
AttributeForeachCallback callback ) const

Definition at line 645 of file geometry_set.cc.

◆ clear()

Remove all geometry components from the geometry set.

Definition at line 281 of file geometry_set.cc.

◆ compute_boundbox_without_instances()

std::optional< Bounds< float3float3 > > blender::bke::GeometrySet::compute_boundbox_without_instances ( bool use_radius = true,
bool use_subdiv = false ) const

Definition at line 199 of file geometry_set.cc.

◆ count_memory()

Definition at line 634 of file geometry_set.cc.

◆ ensure_no_shared_components()

Typically, multiple GeometrySet may share the same GeometryComponent. This is fine as long as we can guarantee that the data is read-only. However, if some geometry is available in Python, that guarantee is not possible currently. For that case it can make sense that the GeometrySet is the unique owner of the geometries it contains.

Definition at line 322 of file geometry_set.cc.

◆ ensure_owns_all_data()

Same as ensure_owns_direct_data but also turns object/collection instances into geometry instances so that they can be owned.

Definition at line 302 of file geometry_set.cc.

◆ ensure_owns_direct_data()

Make sure that the geometry can be cached. This does not ensure ownership of object/collection instances. This is necessary because sometimes components only have read-only or editing access to their data, which might be freed later if this geometry set outlasts the data.

Definition at line 288 of file geometry_set.cc.

◆ from_curves()

Create a new geometry set that only contains the given curves.

Definition at line 461 of file geometry_set.cc.

Referenced by blender::geometry::tests::TEST_F().

◆ from_grease_pencil()

Create a new geometry set that only contains the given Grease Pencil data.

Definition at line 475 of file geometry_set.cc.

◆ from_instances()

Create a new geometry set that only contains the given instances.

Definition at line 468 of file geometry_set.cc.

Referenced by blender::geometry::join_component_type(), and blender::geometry::tests::TEST_F().

◆ from_mesh()

Create a new geometry set that only contains the given mesh.

Definition at line 440 of file geometry_set.cc.

◆ from_pointcloud()

Create a new geometry set that only contains the given point cloud.

Definition at line 454 of file geometry_set.cc.

◆ from_volume()

Create a new geometry set that only contains the given volume.

Definition at line 447 of file geometry_set.cc.

◆ gather_attributes_for_propagation()

void blender::bke::GeometrySet::gather_attributes_for_propagation ( Span< GeometryComponent::Type > component_types,
GeometryComponent::Type dst_component_type,
bool include_instances,
const AttributeFilter & attribute_filter,
Map< StringRef, AttributeDomainAndType > & r_attributes ) const

Definition at line 717 of file geometry_set.cc.

◆ gather_component_types()

Vector< GeometryComponent::Type > blender::bke::GeometrySet::gather_component_types ( bool include_instances,
bool ignore_empty ) const

Definition at line 791 of file geometry_set.cc.

◆ get_component() [1/2]

template<typename Component>
const Component * blender::bke::GeometrySet::get_component ( ) const
inline

Definition at line 183 of file BKE_geometry_set.hh.

◆ get_component() [2/2]

Get the component of the given type. Might return null if the component does not exist yet.

Definition at line 140 of file geometry_set.cc.

◆ get_component_for_write() [1/2]

template<typename Component>
Component & blender::bke::GeometrySet::get_component_for_write ( )
inline

Definition at line 173 of file BKE_geometry_set.hh.

◆ get_component_for_write() [2/2]

This method can only be used when the geometry set is mutable. It returns a mutable geometry component of the given type.

Definition at line 113 of file geometry_set.cc.

◆ get_components()

Get all geometry components in this geometry set for read-only access.

Definition at line 188 of file geometry_set.cc.

◆ get_curve_edit_hints()

const CurvesEditHints * blender::bke::GeometrySet::get_curve_edit_hints ( ) const

Returns read-only curve edit hints or null.

Definition at line 367 of file geometry_set.cc.

◆ get_curve_edit_hints_for_write()

Returns mutable curve edit hints or null.

Definition at line 598 of file geometry_set.cc.

◆ get_curves()

Returns a read-only curves data-block or null.

Definition at line 355 of file geometry_set.cc.

◆ get_curves_for_write()

Returns a mutable curves data-block or null. No ownership is transferred.

Definition at line 586 of file geometry_set.cc.

◆ get_gizmo_edit_hints()

const GizmoEditHints * blender::bke::GeometrySet::get_gizmo_edit_hints ( ) const

Returns read-only gizmo edit hints or null.

Definition at line 379 of file geometry_set.cc.

◆ get_gizmo_edit_hints_for_write()

Returns mutable gizmo edit hints or null.

Definition at line 618 of file geometry_set.cc.

◆ get_grease_pencil()

Returns a read-only Grease Pencil data-block or null.

Definition at line 385 of file geometry_set.cc.

◆ get_grease_pencil_edit_hints()

const GreasePencilEditHints * blender::bke::GeometrySet::get_grease_pencil_edit_hints ( ) const

Returns read-only Grease Pencil edit hints or null.

Definition at line 373 of file geometry_set.cc.

◆ get_grease_pencil_edit_hints_for_write()

Returns mutable Grease Pencil edit hints or null.

Definition at line 608 of file geometry_set.cc.

◆ get_grease_pencil_for_write()

Returns a mutable Grease Pencil data-block or null. No ownership is transferred.

Definition at line 628 of file geometry_set.cc.

◆ get_instances()

Returns read-only instances or null.

Definition at line 361 of file geometry_set.cc.

◆ get_instances_for_write()

Returns mutable instances or null. No ownership is transferred.

Definition at line 592 of file geometry_set.cc.

◆ get_mesh()

Returns a read-only mesh or null.

Definition at line 331 of file geometry_set.cc.

◆ get_mesh_for_write()

Returns a mutable mesh or null. No ownership is transferred.

Definition at line 568 of file geometry_set.cc.

◆ get_pointcloud()

Returns a read-only point cloud of null.

Definition at line 343 of file geometry_set.cc.

◆ get_pointcloud_for_write()

Returns a mutable point cloud or null. No ownership is transferred.

Definition at line 574 of file geometry_set.cc.

◆ get_volume()

Returns a read-only volume or null.

Definition at line 349 of file geometry_set.cc.

◆ get_volume_for_write()

Returns a mutable volume or null. No ownership is transferred.

Definition at line 580 of file geometry_set.cc.

◆ has() [1/2]

template<typename Component>
bool blender::bke::GeometrySet::has ( ) const
inline

Definition at line 190 of file BKE_geometry_set.hh.

◆ has() [2/2]

bool blender::bke::GeometrySet::has ( const GeometryComponent::Type component_type) const

Definition at line 145 of file geometry_set.cc.

◆ has_component()

template<typename Component>
bool blender::bke::GeometrySet::has_component ( ) const
inline

Definition at line 196 of file BKE_geometry_set.hh.

◆ has_curves()

Returns true when the geometry set has a curves component that has a curves data-block.

Definition at line 410 of file geometry_set.cc.

◆ has_grease_pencil()

Returns true when the geometry set has a Grease Pencil component that has grease pencil data.

Definition at line 428 of file geometry_set.cc.

◆ has_instances()

Returns true when the geometry set has an instances component that has at least one instance.

Definition at line 397 of file geometry_set.cc.

◆ has_mesh()

Returns true when the geometry set has a mesh component that has a mesh.

Definition at line 337 of file geometry_set.cc.

◆ has_pointcloud()

Returns true when the geometry set has a point cloud component that has a point cloud.

Definition at line 391 of file geometry_set.cc.

◆ has_realized_data()

Returns true when the geometry set has any data that is not an instance.

Definition at line 416 of file geometry_set.cc.

◆ has_volume()

Returns true when the geometry set has a volume component that has a volume.

Definition at line 404 of file geometry_set.cc.

◆ hash()

Definition at line 460 of file BKE_geometry_set.hh.

◆ is_empty()

Return true if the geometry set has any component that isn't empty.

Definition at line 434 of file geometry_set.cc.

◆ keep_only()

Remove all geometry components with types that are not in the provided list.

Definition at line 156 of file geometry_set.cc.

◆ keep_only_during_modify()

Keeps the provided geometry types, but also instances and edit data. Instances must not be removed while using modify_geometry_sets.

Definition at line 167 of file geometry_set.cc.

◆ modify_geometry_sets()

Modify every (recursive) instance separately. This is often more efficient than realizing all instances just to change the same thing on all of them.

Definition at line 818 of file geometry_set.cc.

◆ operator=() [1/2]

GeometrySet & blender::bke::GeometrySet::operator= ( const GeometrySet & other)
default

◆ operator=() [2/2]

GeometrySet & blender::bke::GeometrySet::operator= ( GeometrySet && other)
default

◆ owns_direct_data()

Definition at line 310 of file geometry_set.cc.

◆ remove() [1/2]

template<typename Component>
void blender::bke::GeometrySet::remove ( )
inline

Definition at line 203 of file BKE_geometry_set.hh.

◆ remove() [2/2]

Definition at line 151 of file geometry_set.cc.

◆ remove_geometry_during_modify()

◆ replace_curves()

Clear the existing curves data-block and replace it with the given one.

Definition at line 497 of file geometry_set.cc.

◆ replace_grease_pencil()

Clear the existing Grease Pencil data-block and replace it with the given one.

Definition at line 553 of file geometry_set.cc.

◆ replace_instances()

Clear the existing instances and replace them with the given one.

Definition at line 511 of file geometry_set.cc.

◆ replace_mesh()

Clear the existing mesh and replace it with the given one.

Definition at line 483 of file geometry_set.cc.

◆ replace_pointcloud()

Clear the existing point cloud and replace with the given one.

Definition at line 525 of file geometry_set.cc.

◆ replace_volume()

Clear the existing volume and replace with the given one.

Definition at line 539 of file geometry_set.cc.

◆ operator<<

std::ostream & operator<< ( std::ostream & stream,
const GeometrySet & geometry_set )
friend

Definition at line 227 of file geometry_set.cc.

◆ operator==

bool operator== ( const GeometrySet & a,
const GeometrySet & b )
friend

Definition at line 454 of file BKE_geometry_set.hh.

Member Data Documentation

◆ name

A user defined name for this geometry. It is not expected to be unique. Its main purpose is help debugging instance trees. It may eventually also be used when exporting instance trees or when creating separate objects from them.

Definition at line 156 of file BKE_geometry_set.hh.


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