Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/geometry_set.cc
| Show All 25 Lines | |||||
| #include "BKE_modifier.h" | #include "BKE_modifier.h" | ||||
| #include "BKE_pointcloud.h" | #include "BKE_pointcloud.h" | ||||
| #include "BKE_spline.hh" | #include "BKE_spline.hh" | ||||
| #include "BKE_volume.h" | #include "BKE_volume.h" | ||||
| #include "DNA_collection_types.h" | #include "DNA_collection_types.h" | ||||
| #include "DNA_object_types.h" | #include "DNA_object_types.h" | ||||
| #include "BLT_translation.h" | |||||
| #include "BLI_rand.hh" | #include "BLI_rand.hh" | ||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| using blender::float3; | using blender::float3; | ||||
| using blender::float4x4; | using blender::float4x4; | ||||
| using blender::Map; | using blender::Map; | ||||
| using blender::MutableSpan; | using blender::MutableSpan; | ||||
| ▲ Show 20 Lines • Show All 467 Lines • ▼ Show 20 Lines | |||||
| void GeometrySet::modify_geometry_sets(ForeachSubGeometryCallback callback) | void GeometrySet::modify_geometry_sets(ForeachSubGeometryCallback callback) | ||||
| { | { | ||||
| Vector<GeometrySet *> geometry_sets; | Vector<GeometrySet *> geometry_sets; | ||||
| gather_mutable_geometry_sets(*this, geometry_sets); | gather_mutable_geometry_sets(*this, geometry_sets); | ||||
| blender::threading::parallel_for_each( | blender::threading::parallel_for_each( | ||||
| geometry_sets, [&](GeometrySet *geometry_set) { callback(*geometry_set); }); | geometry_sets, [&](GeometrySet *geometry_set) { callback(*geometry_set); }); | ||||
| } | } | ||||
| static const char *default_geometry_name = "Unnamed Geometry"; | |||||
| std::string GeometrySet::to_tooltip(int indentation) const | |||||
| { | |||||
| const std::string root_indent(indentation, ' '); | |||||
| std::stringstream ss; | |||||
| ss << (name_.empty() ? default_geometry_name : name_) << ":\n"; | |||||
| this->content_to_tooltip(ss, 0); | |||||
| return ss.str(); | |||||
| } | |||||
| void GeometrySet::content_to_tooltip(std::stringstream &ss, int indentation) const | |||||
| { | |||||
| auto to_string = [](int value) { | |||||
| char str[16]; | |||||
| BLI_str_format_int_grouped(str, value); | |||||
| return std::string(str); | |||||
| }; | |||||
| const std::string indent(indentation, ' '); | |||||
| const std::string sub_indent(indentation + 2, ' '); | |||||
| for (const GeometryComponentPtr &component_ptr : components_.values()) { | |||||
| switch (component_ptr->type()) { | |||||
| case GEO_COMPONENT_TYPE_MESH: { | |||||
| const MeshComponent &component = (const MeshComponent &)*component_ptr; | |||||
| char line[256]; | |||||
| BLI_snprintf(line, | |||||
| sizeof(line), | |||||
| TIP_("\u2022 Mesh: %s vertices, %s edges, %s faces"), | |||||
| to_string(component.attribute_domain_size(ATTR_DOMAIN_POINT)).c_str(), | |||||
| to_string(component.attribute_domain_size(ATTR_DOMAIN_EDGE)).c_str(), | |||||
| to_string(component.attribute_domain_size(ATTR_DOMAIN_FACE)).c_str()); | |||||
| ss << indent << line << ".\n"; | |||||
| break; | |||||
| } | |||||
| case GEO_COMPONENT_TYPE_POINT_CLOUD: { | |||||
| const PointCloudComponent &component = (const PointCloudComponent &)*component_ptr; | |||||
| char line[256]; | |||||
| BLI_snprintf(line, | |||||
| sizeof(line), | |||||
| TIP_("\u2022 Point Cloud: %s points"), | |||||
| to_string(component.attribute_domain_size(ATTR_DOMAIN_POINT)).c_str()); | |||||
| ss << indent << line << ".\n"; | |||||
| break; | |||||
| } | |||||
| case GEO_COMPONENT_TYPE_CURVE: { | |||||
| const CurveComponent &component = (const CurveComponent &)*component_ptr; | |||||
| char line[256]; | |||||
| BLI_snprintf(line, | |||||
| sizeof(line), | |||||
| TIP_("\u2022 Curve: %s splines"), | |||||
| to_string(component.attribute_domain_size(ATTR_DOMAIN_CURVE)).c_str()); | |||||
| ss << indent << line << ".\n"; | |||||
| break; | |||||
| } | |||||
| case GEO_COMPONENT_TYPE_INSTANCES: { | |||||
| const InstancesComponent &component = (const InstancesComponent &)*component_ptr; | |||||
| char line[256]; | |||||
| BLI_snprintf(line, | |||||
| sizeof(line), | |||||
| TIP_("\u2022 Instances: %s"), | |||||
| to_string(component.instances_amount()).c_str()); | |||||
| ss << indent << line << ".\n"; | |||||
| for (const InstanceReference &reference : component.references()) { | |||||
| switch (reference.type()) { | |||||
| case InstanceReference::Type::None: { | |||||
| ss << sub_indent << "\u2022 None.\n"; | |||||
| break; | |||||
| } | |||||
| case InstanceReference::Type::Object: { | |||||
| const Object &object = reference.object(); | |||||
| ss << sub_indent << "\u2022 Object: " << (object.id.name + 2) << ".\n"; | |||||
| break; | |||||
| } | |||||
| case InstanceReference::Type::Collection: { | |||||
| const Collection &collection = reference.collection(); | |||||
| ss << sub_indent << "\u2022 Collection: " << (collection.id.name + 2) << ".\n"; | |||||
| break; | |||||
| } | |||||
| case InstanceReference::Type::GeometrySet: { | |||||
| const GeometrySet &instance = reference.geometry_set(); | |||||
| ss << sub_indent << "▶ " | |||||
| << (instance.name_.empty() ? default_geometry_name : instance.name_) << ":\n"; | |||||
| instance.content_to_tooltip(ss, indentation + 4); | |||||
| break; | |||||
| } | |||||
| } | |||||
| } | |||||
| break; | |||||
| } | |||||
| case GEO_COMPONENT_TYPE_VOLUME: { | |||||
| ss << indent << TIP_("\u2022 Volume") << ".\n"; | |||||
| break; | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| blender::StringRefNull GeometrySet::name() const | |||||
| { | |||||
| return name_; | |||||
| } | |||||
| void GeometrySet::set_name(std::string name) | |||||
| { | |||||
| name_ = std::move(name); | |||||
| } | |||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name C API | /** \name C API | ||||
| * \{ */ | * \{ */ | ||||
| void BKE_geometry_set_free(GeometrySet *geometry_set) | void BKE_geometry_set_free(GeometrySet *geometry_set) | ||||
| { | { | ||||
| Show All 32 Lines | |||||