Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/BKE_geometry_set.hh
| Show All 31 Lines | |||||
| #include "BKE_attribute_access.hh" | #include "BKE_attribute_access.hh" | ||||
| #include "BKE_geometry_set.h" | #include "BKE_geometry_set.h" | ||||
| struct Collection; | struct Collection; | ||||
| struct Mesh; | struct Mesh; | ||||
| struct Object; | struct Object; | ||||
| struct PointCloud; | struct PointCloud; | ||||
| struct Volume; | |||||
| /* Each geometry component has a specific type. The type determines what kind of data the component | /* Each geometry component has a specific type. The type determines what kind of data the component | ||||
| * stores. Functions modifying a geometry will usually just modify a subset of the component types. | * stores. Functions modifying a geometry will usually just modify a subset of the component types. | ||||
| */ | */ | ||||
| enum class GeometryComponentType { | enum class GeometryComponentType { | ||||
| Mesh = 0, | Mesh = 0, | ||||
| PointCloud = 1, | PointCloud = 1, | ||||
| Instances = 2, | Instances = 2, | ||||
| Volume = 3, | |||||
| }; | }; | ||||
| enum class GeometryOwnershipType { | enum class GeometryOwnershipType { | ||||
| /* The geometry is owned. This implies that it can be changed. */ | /* The geometry is owned. This implies that it can be changed. */ | ||||
| Owned = 0, | Owned = 0, | ||||
| /* The geometry can be changed, but someone else is responsible for freeing it. */ | /* The geometry can be changed, but someone else is responsible for freeing it. */ | ||||
| Editable = 1, | Editable = 1, | ||||
| /* The geometry cannot be changed and someone else is responsible for freeing it. */ | /* The geometry cannot be changed and someone else is responsible for freeing it. */ | ||||
| ▲ Show 20 Lines • Show All 259 Lines • ▼ Show 20 Lines | static GeometrySet create_with_mesh( | ||||
| Mesh *mesh, GeometryOwnershipType ownership = GeometryOwnershipType::Owned); | Mesh *mesh, GeometryOwnershipType ownership = GeometryOwnershipType::Owned); | ||||
| static GeometrySet create_with_pointcloud( | static GeometrySet create_with_pointcloud( | ||||
| PointCloud *pointcloud, GeometryOwnershipType ownership = GeometryOwnershipType::Owned); | PointCloud *pointcloud, GeometryOwnershipType ownership = GeometryOwnershipType::Owned); | ||||
| /* Utility methods for access. */ | /* Utility methods for access. */ | ||||
| bool has_mesh() const; | bool has_mesh() const; | ||||
| bool has_pointcloud() const; | bool has_pointcloud() const; | ||||
| bool has_instances() const; | bool has_instances() const; | ||||
| bool has_volume() const; | |||||
| const Mesh *get_mesh_for_read() const; | const Mesh *get_mesh_for_read() const; | ||||
| const PointCloud *get_pointcloud_for_read() const; | const PointCloud *get_pointcloud_for_read() const; | ||||
| const Volume *get_volume_for_read() const; | |||||
| Mesh *get_mesh_for_write(); | Mesh *get_mesh_for_write(); | ||||
| PointCloud *get_pointcloud_for_write(); | PointCloud *get_pointcloud_for_write(); | ||||
| Volume *get_volume_for_write(); | |||||
| /* Utility methods for replacement. */ | /* Utility methods for replacement. */ | ||||
| void replace_mesh(Mesh *mesh, GeometryOwnershipType ownership = GeometryOwnershipType::Owned); | void replace_mesh(Mesh *mesh, GeometryOwnershipType ownership = GeometryOwnershipType::Owned); | ||||
| void replace_pointcloud(PointCloud *pointcloud, | void replace_pointcloud(PointCloud *pointcloud, | ||||
| GeometryOwnershipType ownership = GeometryOwnershipType::Owned); | GeometryOwnershipType ownership = GeometryOwnershipType::Owned); | ||||
| }; | }; | ||||
| /** A geometry component that can store a mesh. */ | /** A geometry component that can store a mesh. */ | ||||
| ▲ Show 20 Lines • Show All 109 Lines • ▼ Show 20 Lines | public: | ||||
| blender::Span<int> ids() const; | blender::Span<int> ids() const; | ||||
| blender::MutableSpan<blender::float4x4> transforms(); | blender::MutableSpan<blender::float4x4> transforms(); | ||||
| int instances_amount() const; | int instances_amount() const; | ||||
| bool is_empty() const final; | bool is_empty() const final; | ||||
| static constexpr inline GeometryComponentType static_type = GeometryComponentType::Instances; | static constexpr inline GeometryComponentType static_type = GeometryComponentType::Instances; | ||||
| }; | }; | ||||
| /** A geometry component that stores volume grids. */ | |||||
| class VolumeComponent : public GeometryComponent { | |||||
| private: | |||||
| Volume *volume_ = nullptr; | |||||
| GeometryOwnershipType ownership_ = GeometryOwnershipType::Owned; | |||||
| public: | |||||
| VolumeComponent(); | |||||
| ~VolumeComponent(); | |||||
| GeometryComponent *copy() const override; | |||||
| void clear(); | |||||
| bool has_volume() const; | |||||
| void replace(Volume *volume, GeometryOwnershipType ownership = GeometryOwnershipType::Owned); | |||||
| Volume *release(); | |||||
| const Volume *get_for_read() const; | |||||
| Volume *get_for_write(); | |||||
| static constexpr inline GeometryComponentType static_type = GeometryComponentType::Volume; | |||||
| }; | |||||