43 switch (component_type) {
68 const std::optional<AttributeAccessor>
attributes = this->attributes();
96void GeometryComponent::delete_self()
101void GeometryComponent::delete_data_only()
122 if (!component_ptr) {
131 if (this->
has(type)) {
139 return components_[size_t(component_type)].get();
150 components_[size_t(component_type)].reset();
157 if (!component_types.
contains(component_ptr->type())) {
158 component_ptr.reset();
177 components.
append(component_ptr.get());
184 const bool use_radius,
const bool use_subdiv)
const
186 std::optional<Bounds<float3>>
bounds;
192 if (use_subdiv &&
mesh->runtime->mesh_eval) {
215 parts.
append(fmt::format(
"\"{}\"", geometry_set.
name()));
218 parts.
append(std::to_string(
mesh->verts_num) +
" verts");
219 parts.
append(std::to_string(
mesh->edges_num) +
" edges");
220 parts.
append(std::to_string(
mesh->faces_num) +
" faces");
221 parts.
append(std::to_string(
mesh->corners_num) +
" corners");
222 if (
mesh->runtime->subsurf_runtime_data) {
223 const int resolution =
mesh->runtime->subsurf_runtime_data->resolution;
227 parts.
append(std::to_string(level) +
" subdiv levels");
230 parts.
append(std::to_string(resolution) +
" subdiv resolution");
235 parts.
append(std::to_string(
curves->geometry.point_num) +
" control points");
236 parts.
append(std::to_string(
curves->geometry.curve_num) +
" curves");
242 parts.
append(std::to_string(pointcloud->totpoint) +
" points");
251 parts.
append(
"curve edit hints");
254 stream <<
"<GeometrySet: ";
257 if (i < parts.size() - 1) {
268 component_ptr.reset();
275 if (!component_ptr) {
278 if (component_ptr->owns_direct_data()) {
289 instances->ensure_geometry_instances();
298 if (!component_ptr->owns_direct_data()) {
308 for (
const int i :
IndexRange(this->components_.size())) {
309 if (components_[i]) {
318 return (component ==
nullptr) ?
nullptr : component->
get();
324 return component !=
nullptr && component->
has_mesh();
330 return (component ==
nullptr) ?
nullptr : component->
get();
336 return (component ==
nullptr) ?
nullptr : component->
get();
342 return (component ==
nullptr) ?
nullptr : component->
get();
348 return (component ==
nullptr) ?
nullptr : component->
get();
372 return (component ==
nullptr) ?
nullptr : component->
get();
384 return component !=
nullptr && component->
get() !=
nullptr &&
391 return component !=
nullptr && component->
has_volume();
397 return component !=
nullptr && component->
has_curves();
404 if (!
ELEM(component_ptr->type(),
479 if (
mesh ==
nullptr) {
507 if (instances ==
nullptr) {
516 component.
replace(instances, ownership);
521 if (pointcloud ==
nullptr) {
530 component.
replace(pointcloud, ownership);
535 if (volume ==
nullptr) {
544 component.
replace(volume, ownership);
564 MeshComponent *component = this->get_component_for_write_ptr<MeshComponent>();
576 VolumeComponent *component = this->get_component_for_write_ptr<VolumeComponent>();
582 CurveComponent *component = this->get_component_for_write_ptr<CurveComponent>();
588 InstancesComponent *component = this->get_component_for_write_ptr<InstancesComponent>();
633 component->count_memory(shared_memory);
640 const bool include_instances,
644 if (!this->
has(component_type)) {
648 const std::optional<AttributeAccessor> attributes = component.
attributes();
649 if (attributes.has_value()) {
650 attributes->foreach_attribute([&](
const AttributeIter &iter) {
651 callback(iter.
name, {iter.domain, iter.data_type}, component);
661 callback(iter.
name, {iter.domain, iter.data_type}, component);
670 instance_geometry_set.
attribute_foreach(component_types, include_instances, callback);
681 return component->attributes()->is_builtin(name);
685 return component->attributes()->is_builtin(name);
689 return component->attributes()->is_builtin(name);
693 return component->attributes()->is_builtin(name);
699 return grease_pencil_component->attributes()->is_builtin(name) ||
700 curves_component->attributes()->is_builtin(name);
726 const bool include_instances,
727 const bool ignore_empty,
732 if (component->is_empty()) {
738 if (!include_instances) {
742 if (instances ==
nullptr) {
747 instance_geometry_set, include_instances, ignore_empty, r_types);
752 bool ignore_empty)
const
766 return bundle_.get();
784 return bundle_.ensure_mutable_inplace();
789 bundle_ = other.bundle_;
807 name_ = std::move(
name);
817 const GeometrySet *geometry_set =
object.runtime->geometry_set_eval;
818 if (geometry_set ==
nullptr) {
Low-level operations for curves.
Low-level operations for grease pencil.
Object is a sort of wrapper for general info.
#define BLI_assert_unreachable()
T & ensure_mutable_inplace()
constexpr IndexRange()=default
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_
GeometryComponentEditData()
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
constexpr bool is_empty() const
void add_shared(const ImplicitSharingInfo *sharing_info, const FunctionRef< void(MemoryCounter &shared_memory)> count_fn)
static BundlePtr create()
void merge(const Bundle &other)
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)
bool object_has_geometry_set_instances(const Object &object)
Bounds< T > merge(const Bounds< T > &a, const Bounds< T > &b)
ImplicitSharingPtr< Bundle > BundlePtr
constexpr int64_t log2_floor(const int64_t x)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
std::optional< Bounds< float3 > > BKE_volume_min_max(const Volume *volume)
int BKE_volume_num_grids(const Volume *volume)
MINLINE int is_power_of_2_i(int n)
void add(const StringRef name, const AttributeDomainAndType &kind)
Vector< AttributeDomainAndType, 16 > kinds
VectorSet< StringRef, 16 > names
bool owns_direct_data() const
void merge_bundle_from(const GeometrySet &other)
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
GeometryComponent & get_component_for_write(GeometryComponent::Type component_type)
GeometrySet & operator=(const GeometrySet &other)
void ensure_no_shared_components()
StringRefNull name() const
void set_name(std::string name)
FunctionRef< void( StringRef name, const AttributeMetaData &meta_data, const GeometryComponent &component)> AttributeForeachCallback
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
nodes::Bundle & bundle_for_write()
const Component * get_component() const
Component & get_component_for_write()
const GizmoEditHints * get_gizmo_edit_hints() const
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)
friend std::ostream & operator<<(std::ostream &stream, const GeometrySet &geometry_set)
bool has(const GeometryComponent::Type component_type) const
void replace_pointcloud(PointCloud *pointcloud, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
Curves * get_curves_for_write()
const nodes::Bundle * bundle() const
static GeometrySet from_instances(std::unique_ptr< Instances > instances)
const GeometryComponent * get_component(GeometryComponent::Type component_type) const
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 copy_bundle_from(const GeometrySet &other)
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 remove(const GeometryComponent::Type component_type)
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
const nodes::BundlePtr & bundle_ptr() 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)