37 switch (component_type) {
63 if (attributes.has_value()) {
90void GeometryComponent::delete_self()
95void GeometryComponent::delete_data_only()
116 if (!component_ptr) {
120 else if (component_ptr->is_mutable()) {
122 component_ptr->tag_ensured_mutable();
127 component_ptr = component_ptr->copy();
134 if (this->
has(type)) {
142 return components_[size_t(component_type)].get();
148 return component.
has_value() && !component->is_empty();
153 components_[size_t(component_type)].
reset();
160 if (!component_types.
contains(component_ptr->type())) {
161 component_ptr.reset();
180 components.
append(component_ptr.get());
187 const bool use_radius,
const bool use_subdiv)
const
189 std::optional<Bounds<float3>>
bounds;
195 if (use_subdiv &&
mesh->runtime->mesh_eval) {
217 if (!geometry_set.
name.empty()) {
218 parts.
append(fmt::format(
"\"{}\"", geometry_set.
name));
221 parts.
append(std::to_string(
mesh->verts_num) +
" verts");
222 parts.
append(std::to_string(
mesh->edges_num) +
" edges");
223 parts.
append(std::to_string(
mesh->faces_num) +
" faces");
224 parts.
append(std::to_string(
mesh->corners_num) +
" corners");
225 if (
mesh->runtime->subsurf_runtime_data) {
226 const int resolution =
mesh->runtime->subsurf_runtime_data->resolution;
229 const int level = log2_floor(resolution - 1);
230 parts.
append(std::to_string(level) +
" subdiv levels");
233 parts.
append(std::to_string(resolution) +
" subdiv resolution");
238 parts.
append(std::to_string(
curves->geometry.point_num) +
" control points");
239 parts.
append(std::to_string(
curves->geometry.curve_num) +
" curves");
242 parts.
append(std::to_string(grease_pencil->layers().size()) +
" Grease Pencil layers");
245 parts.
append(std::to_string(pointcloud->totpoint) +
" points");
254 parts.
append(
"curve edit hints");
257 stream <<
"<GeometrySet: ";
260 if (
i < parts.size() - 1) {
271 component_ptr.reset();
278 if (!component_ptr) {
281 if (component_ptr->owns_direct_data()) {
292 instances->ensure_geometry_instances();
301 if (!component_ptr->owns_direct_data()) {
311 for (
const int i :
IndexRange(this->components_.size())) {
312 if (components_[
i]) {
321 return (component ==
nullptr) ?
nullptr : component->
get();
327 return component !=
nullptr && component->
has_mesh();
333 return (component ==
nullptr) ?
nullptr : component->
get();
339 return (component ==
nullptr) ?
nullptr : component->
get();
345 return (component ==
nullptr) ?
nullptr : component->
get();
351 return (component ==
nullptr) ?
nullptr : component->
get();
375 return (component ==
nullptr) ?
nullptr : component->
get();
387 return component !=
nullptr && component->
get() !=
nullptr &&
394 return component !=
nullptr && component->
has_volume();
400 return component !=
nullptr && component->
has_curves();
407 if (!
ELEM(component_ptr->type(),
475 if (
mesh ==
nullptr) {
503 if (instances ==
nullptr) {
512 component.
replace(instances, ownership);
517 if (pointcloud ==
nullptr) {
526 component.
replace(pointcloud, ownership);
531 if (volume ==
nullptr) {
540 component.
replace(volume, ownership);
546 if (grease_pencil ==
nullptr) {
555 component.
replace(grease_pencil, ownership);
560 MeshComponent *component = this->get_component_ptr<MeshComponent>();
572 VolumeComponent *component = this->get_component_ptr<VolumeComponent>();
578 CurveComponent *component = this->get_component_ptr<CurveComponent>();
629 component->count_memory(shared_memory);
636 const bool include_instances,
640 if (!this->
has(component_type)) {
644 const std::optional<AttributeAccessor> attributes = component.
attributes();
645 if (attributes.has_value()) {
646 attributes->foreach_attribute([&](
const AttributeIter &iter) {
647 callback(iter.
name, {iter.domain, iter.data_type}, component);
657 callback(iter.
name, {iter.domain, iter.data_type}, component);
666 instance_geometry_set.
attribute_foreach(component_types, include_instances, callback);
677 return component->attributes()->is_builtin(
name);
681 return component->attributes()->is_builtin(
name);
685 return component->attributes()->is_builtin(
name);
689 return component->attributes()->is_builtin(
name);
695 return grease_pencil_component->attributes()->is_builtin(
name) ||
696 curves_component->attributes()->is_builtin(
name);
709 const int index = this->
names.index_of_or_add(
name);
710 if (index >= this->
kinds.size()) {
724 bool include_instances,
734 if (component.
attributes()->is_builtin(attribute_id)) {
745 if (attribute_filter.
allow_skip(attribute_id)) {
760 const bool include_instances,
761 const bool ignore_empty,
766 if (component->is_empty()) {
772 if (!include_instances) {
776 if (instances ==
nullptr) {
781 instance_geometry_set, include_instances, ignore_empty, r_types);
786 bool ignore_empty)
const
795 const GeometrySet *geometry_set =
object.runtime->geometry_set_eval;
796 if (geometry_set ==
nullptr) {
Low-level operations for curves.
Low-level operations for grease pencil.
int BKE_volume_num_grids(const Volume *volume)
std::optional< blender::Bounds< blender::float3 > > BKE_volume_min_max(const Volume *volume)
#define BLI_assert_unreachable()
MINLINE int is_power_of_2_i(int n)
Object is a sort of wrapper for general info.
constexpr bool contains(const T &value) const
void append(const T &value)
IndexRange index_range() const
void append_non_duplicates(const T &value)
void foreach_attribute(const FunctionRef< void(const AttributeIter &)> fn) const
void replace(Curves *curve, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
const Curves * get() const
std::unique_ptr< GreasePencilEditHints > grease_pencil_edit_hints_
std::unique_ptr< GizmoEditHints > gizmo_edit_hints_
std::unique_ptr< CurvesEditHints > curves_edit_hints_
int attribute_domain_size(AttrDomain domain) const
virtual std::optional< AttributeAccessor > attributes() const
GeometryComponent(Type type)
virtual std::optional< MutableAttributeAccessor > attributes_for_write()
virtual bool is_empty() const
virtual void count_memory(MemoryCounter &memory) const
virtual void ensure_owns_direct_data()=0
static GeometryComponentPtr create(Type component_type)
bool has_grease_pencil() const
const GreasePencil * get() const
GreasePencil * get_for_write()
void replace(GreasePencil *grease_pencil, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
Instances * get_for_write()
const Instances * get() const
void replace(Instances *instances, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
void foreach_referenced_geometry(FunctionRef< void(const GeometrySet &geometry_set)> callback) const
int instances_num() const
void replace(Mesh *mesh, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
void replace(PointCloud *pointcloud, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
const PointCloud * get() const
bool has_pointcloud() const
PointCloud * get_for_write()
void replace(Volume *volume, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
const Volume * get() const
void add_shared(const ImplicitSharingInfo *sharing_info, const FunctionRef< void(MemoryCounter &shared_memory)> count_fn)
ImplicitSharingPtr< GeometryComponent > GeometryComponentPtr
static void gather_component_types_recursive(const GeometrySet &geometry_set, const bool include_instances, const bool ignore_empty, Vector< GeometryComponent::Type > &r_types)
bool attribute_is_builtin_on_component_type(const GeometryComponent::Type type, StringRef name)
AttrType attribute_data_type_highest_complexity(Span< AttrType > data_types)
AttrDomain attribute_domain_highest_priority(Span< AttrDomain > domains)
std::ostream & operator<<(std::ostream &stream, const GeometrySet &geometry_set)
bool object_has_geometry_set_instances(const Object &object)
Bounds< T > merge(const Bounds< T > &a, const Bounds< T > &b)
bool allow_skip(const StringRef name) const
void add(const StringRef name, const AttributeDomainAndType &kind)
Vector< AttributeDomainAndType, 16 > kinds
VectorSet< StringRef, 16 > names
bool owns_direct_data() const
void ensure_owns_all_data()
void replace_volume(Volume *volume, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
void keep_only(Span< GeometryComponent::Type > component_types)
const CurvesEditHints * get_curve_edit_hints() const
GeometrySet & operator=(const GeometrySet &other)
void ensure_no_shared_components()
static GeometrySet from_instances(Instances *instances, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
static GeometrySet from_grease_pencil(GreasePencil *grease_pencil, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
bool has_component() const
PointCloud * get_pointcloud_for_write()
static GeometrySet from_curves(Curves *curves, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
GizmoEditHints * get_gizmo_edit_hints_for_write()
void replace_instances(Instances *instances, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
Instances * get_instances_for_write()
const GreasePencil * get_grease_pencil() const
bool has_pointcloud() const
const Component * get_component() const
Component & get_component_for_write()
const GizmoEditHints * get_gizmo_edit_hints() const
FunctionRef< void(StringRef attribute_id, const AttributeMetaData &meta_data, const GeometryComponent &component)> AttributeForeachCallback
Vector< const GeometryComponent * > get_components() const
const Volume * get_volume() const
std::optional< Bounds< float3 > > compute_boundbox_without_instances(bool use_radius=true, bool use_subdiv=false) const
static GeometrySet from_mesh(Mesh *mesh, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
bool has(const GeometryComponent::Type component_type) const
void replace_pointcloud(PointCloud *pointcloud, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
Curves * get_curves_for_write()
bool has_realized_data() const
const Curves * get_curves() const
static GeometrySet from_pointcloud(PointCloud *pointcloud, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
const Instances * get_instances() const
bool has_grease_pencil() const
static GeometrySet from_volume(Volume *volume, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
bool has_instances() const
void gather_attributes_for_propagation(Span< GeometryComponent::Type > component_types, GeometryComponent::Type dst_component_type, bool include_instances, const AttributeFilter &attribute_filter, GatheredAttributes &r_attributes) const
void ensure_owns_direct_data()
GreasePencilEditHints * get_grease_pencil_edit_hints_for_write()
void replace_curves(Curves *curves, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
CurvesEditHints * get_curve_edit_hints_for_write()
void count_memory(MemoryCounter &memory) const
const GreasePencilEditHints * get_grease_pencil_edit_hints() const
const PointCloud * get_pointcloud() const
const Mesh * get_mesh() const
void replace_mesh(Mesh *mesh, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
GreasePencil * get_grease_pencil_for_write()
Vector< GeometryComponent::Type > gather_component_types(bool include_instances, bool ignore_empty) const
Volume * get_volume_for_write()
void attribute_foreach(Span< GeometryComponent::Type > component_types, bool include_instances, AttributeForeachCallback callback) const
Mesh * get_mesh_for_write()
void add(const GeometryComponent &component)
void replace_grease_pencil(GreasePencil *grease_pencil, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)