Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/geometry_set.cc
| Show First 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | |||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Geometry Component | /** \name Geometry Component | ||||
| * \{ */ | * \{ */ | ||||
| GeometryComponent::GeometryComponent(GeometryComponentType type) : type_(type) | GeometryComponent::GeometryComponent(GeometryComponentType type) : type_(type) | ||||
| { | { | ||||
| } | } | ||||
| GeometryComponent ::~GeometryComponent() | |||||
| { | |||||
| } | |||||
| GeometryComponent *GeometryComponent::create(GeometryComponentType component_type) | GeometryComponent *GeometryComponent::create(GeometryComponentType component_type) | ||||
| { | { | ||||
| switch (component_type) { | switch (component_type) { | ||||
| case GEO_COMPONENT_TYPE_MESH: | case GEO_COMPONENT_TYPE_MESH: | ||||
| return new MeshComponent(); | return new MeshComponent(); | ||||
| case GEO_COMPONENT_TYPE_POINT_CLOUD: | case GEO_COMPONENT_TYPE_POINT_CLOUD: | ||||
| return new PointCloudComponent(); | return new PointCloudComponent(); | ||||
| case GEO_COMPONENT_TYPE_INSTANCES: | case GEO_COMPONENT_TYPE_INSTANCES: | ||||
| ▲ Show 20 Lines • Show All 113 Lines • ▼ Show 20 Lines | void GeometrySet::compute_boundbox_without_instances(float3 *r_min, float3 *r_max) const | ||||
| const PointCloud *pointcloud = this->get_pointcloud_for_read(); | const PointCloud *pointcloud = this->get_pointcloud_for_read(); | ||||
| if (pointcloud != nullptr) { | if (pointcloud != nullptr) { | ||||
| BKE_pointcloud_minmax(pointcloud, *r_min, *r_max); | BKE_pointcloud_minmax(pointcloud, *r_min, *r_max); | ||||
| } | } | ||||
| const Mesh *mesh = this->get_mesh_for_read(); | const Mesh *mesh = this->get_mesh_for_read(); | ||||
| if (mesh != nullptr) { | if (mesh != nullptr) { | ||||
| BKE_mesh_wrapper_minmax(mesh, *r_min, *r_max); | BKE_mesh_wrapper_minmax(mesh, *r_min, *r_max); | ||||
| } | } | ||||
| const Volume *volume = this->get_volume_for_read(); | |||||
| if (volume != nullptr) { | |||||
| BKE_volume_min_max(volume, *r_min, *r_max); | |||||
| } | |||||
| } | } | ||||
| std::ostream &operator<<(std::ostream &stream, const GeometrySet &geometry_set) | std::ostream &operator<<(std::ostream &stream, const GeometrySet &geometry_set) | ||||
| { | { | ||||
| stream << "<GeometrySet at " << &geometry_set << ", " << geometry_set.components_.size() | stream << "<GeometrySet at " << &geometry_set << ", " << geometry_set.components_.size() | ||||
| << " components>"; | << " components>"; | ||||
| return stream; | return stream; | ||||
| } | } | ||||
| Show All 13 Lines | |||||
| } | } | ||||
| /* Remove all geometry components from the geometry set. */ | /* Remove all geometry components from the geometry set. */ | ||||
| void GeometrySet::clear() | void GeometrySet::clear() | ||||
| { | { | ||||
| components_.clear(); | components_.clear(); | ||||
| } | } | ||||
| /* Make sure that the geometry can be cached. This does not ensure ownership of object/collection | |||||
| * instances. */ | |||||
| void GeometrySet::ensure_owns_direct_data() | |||||
| { | |||||
| for (GeometryComponentType type : components_.keys()) { | |||||
| const GeometryComponent *component = this->get_component_for_read(type); | |||||
| if (!component->owns_direct_data()) { | |||||
| GeometryComponent &component_for_write = this->get_component_for_write(type); | |||||
| component_for_write.ensure_owns_direct_data(); | |||||
| } | |||||
| } | |||||
| } | |||||
| /* Returns a read-only mesh or null. */ | /* Returns a read-only mesh or null. */ | ||||
| const Mesh *GeometrySet::get_mesh_for_read() const | const Mesh *GeometrySet::get_mesh_for_read() const | ||||
| { | { | ||||
| const MeshComponent *component = this->get_component_for_read<MeshComponent>(); | const MeshComponent *component = this->get_component_for_read<MeshComponent>(); | ||||
| return (component == nullptr) ? nullptr : component->get_for_read(); | return (component == nullptr) ? nullptr : component->get_for_read(); | ||||
| } | } | ||||
| /* Returns true when the geometry set has a mesh component that has a mesh. */ | /* Returns true when the geometry set has a mesh component that has a mesh. */ | ||||
| ▲ Show 20 Lines • Show All 112 Lines • Show Last 20 Lines | |||||