diff --git a/source/blender/blenkernel/BKE_geometry_set.hh b/source/blender/blenkernel/BKE_geometry_set.hh index 5022728e834..0eb573777da 100644 --- a/source/blender/blenkernel/BKE_geometry_set.hh +++ b/source/blender/blenkernel/BKE_geometry_set.hh @@ -87,8 +87,10 @@ class GeometryComponent : public ImplicitSharingMixin { virtual std::optional attributes() const; virtual std::optional attributes_for_write(); - /* The returned component should be of the same type as the type this is called on. */ - virtual GeometryComponent *copy() const = 0; + /** + * Copies the component. The returned component only has a single user and is therefor mutable. + */ + virtual GeometryComponentPtr copy() const = 0; /** Remove referenced data from the geometry component. */ virtual void clear() = 0; @@ -437,7 +439,7 @@ class MeshComponent : public GeometryComponent { public: MeshComponent(); ~MeshComponent(); - GeometryComponent *copy() const override; + GeometryComponentPtr copy() const override; void clear() override; bool has_mesh() const; @@ -491,7 +493,7 @@ class PointCloudComponent : public GeometryComponent { public: PointCloudComponent(); ~PointCloudComponent(); - GeometryComponent *copy() const override; + GeometryComponentPtr copy() const override; void clear() override; bool has_pointcloud() const; @@ -551,7 +553,7 @@ class CurveComponent : public GeometryComponent { public: CurveComponent(); ~CurveComponent(); - GeometryComponent *copy() const override; + GeometryComponentPtr copy() const override; void clear() override; bool has_curves() const; @@ -592,7 +594,7 @@ class InstancesComponent : public GeometryComponent { public: InstancesComponent(); ~InstancesComponent(); - GeometryComponent *copy() const override; + GeometryComponentPtr copy() const override; void clear() override; @@ -626,7 +628,7 @@ class VolumeComponent : public GeometryComponent { public: VolumeComponent(); ~VolumeComponent(); - GeometryComponent *copy() const override; + GeometryComponentPtr copy() const override; void clear() override; bool has_volume() const; @@ -681,7 +683,7 @@ class GeometryComponentEditData final : public GeometryComponent { GeometryComponentEditData(); - GeometryComponent *copy() const final; + GeometryComponentPtr copy() const final; bool owns_direct_data() const final; void ensure_owns_direct_data() final; @@ -711,7 +713,7 @@ class GreasePencilComponent : public GeometryComponent { public: GreasePencilComponent(); ~GreasePencilComponent(); - GeometryComponent *copy() const override; + GeometryComponentPtr copy() const override; void clear() override; bool has_grease_pencil() const; diff --git a/source/blender/blenkernel/intern/geometry_component_curves.cc b/source/blender/blenkernel/intern/geometry_component_curves.cc index 32d5a9f0f61..36c6c0bf5e3 100644 --- a/source/blender/blenkernel/intern/geometry_component_curves.cc +++ b/source/blender/blenkernel/intern/geometry_component_curves.cc @@ -32,14 +32,14 @@ CurveComponent::~CurveComponent() this->clear(); } -GeometryComponent *CurveComponent::copy() const +GeometryComponentPtr CurveComponent::copy() const { CurveComponent *new_component = new CurveComponent(); if (curves_ != nullptr) { new_component->curves_ = BKE_curves_copy_for_eval(curves_); new_component->ownership_ = GeometryOwnershipType::Owned; } - return new_component; + return GeometryComponentPtr(new_component); } void CurveComponent::clear() diff --git a/source/blender/blenkernel/intern/geometry_component_edit_data.cc b/source/blender/blenkernel/intern/geometry_component_edit_data.cc index 7a022d78b5c..09dcfa0a89f 100644 --- a/source/blender/blenkernel/intern/geometry_component_edit_data.cc +++ b/source/blender/blenkernel/intern/geometry_component_edit_data.cc @@ -10,7 +10,7 @@ namespace blender::bke { GeometryComponentEditData::GeometryComponentEditData() : GeometryComponent(Type::Edit) {} -GeometryComponent *GeometryComponentEditData::copy() const +GeometryComponentPtr GeometryComponentEditData::copy() const { GeometryComponentEditData *new_component = new GeometryComponentEditData(); if (curves_edit_hints_) { @@ -20,7 +20,7 @@ GeometryComponent *GeometryComponentEditData::copy() const new_component->grease_pencil_edit_hints_ = std::make_unique( *grease_pencil_edit_hints_); } - return new_component; + return GeometryComponentPtr(new_component); } bool GeometryComponentEditData::owns_direct_data() const diff --git a/source/blender/blenkernel/intern/geometry_component_grease_pencil.cc b/source/blender/blenkernel/intern/geometry_component_grease_pencil.cc index ff8308ea39c..fe7668a5c5b 100644 --- a/source/blender/blenkernel/intern/geometry_component_grease_pencil.cc +++ b/source/blender/blenkernel/intern/geometry_component_grease_pencil.cc @@ -23,14 +23,14 @@ GreasePencilComponent::~GreasePencilComponent() this->clear(); } -GeometryComponent *GreasePencilComponent::copy() const +GeometryComponentPtr GreasePencilComponent::copy() const { GreasePencilComponent *new_component = new GreasePencilComponent(); if (grease_pencil_ != nullptr) { new_component->grease_pencil_ = BKE_grease_pencil_copy_for_eval(grease_pencil_); new_component->ownership_ = GeometryOwnershipType::Owned; } - return new_component; + return GeometryComponentPtr(new_component); } void GreasePencilComponent::clear() diff --git a/source/blender/blenkernel/intern/geometry_component_instances.cc b/source/blender/blenkernel/intern/geometry_component_instances.cc index d019b65f84f..6e9d8e5ab48 100644 --- a/source/blender/blenkernel/intern/geometry_component_instances.cc +++ b/source/blender/blenkernel/intern/geometry_component_instances.cc @@ -37,14 +37,14 @@ InstancesComponent::~InstancesComponent() this->clear(); } -GeometryComponent *InstancesComponent::copy() const +GeometryComponentPtr InstancesComponent::copy() const { InstancesComponent *new_component = new InstancesComponent(); if (instances_ != nullptr) { new_component->instances_ = new Instances(*instances_); new_component->ownership_ = GeometryOwnershipType::Owned; } - return new_component; + return GeometryComponentPtr(new_component); } void InstancesComponent::clear() diff --git a/source/blender/blenkernel/intern/geometry_component_mesh.cc b/source/blender/blenkernel/intern/geometry_component_mesh.cc index 5b2744abdab..2734e2b5b1d 100644 --- a/source/blender/blenkernel/intern/geometry_component_mesh.cc +++ b/source/blender/blenkernel/intern/geometry_component_mesh.cc @@ -34,14 +34,14 @@ MeshComponent::~MeshComponent() this->clear(); } -GeometryComponent *MeshComponent::copy() const +GeometryComponentPtr MeshComponent::copy() const { MeshComponent *new_component = new MeshComponent(); if (mesh_ != nullptr) { new_component->mesh_ = BKE_mesh_copy_for_eval(mesh_); new_component->ownership_ = GeometryOwnershipType::Owned; } - return new_component; + return GeometryComponentPtr(new_component); } void MeshComponent::clear() diff --git a/source/blender/blenkernel/intern/geometry_component_pointcloud.cc b/source/blender/blenkernel/intern/geometry_component_pointcloud.cc index 8f3b801a3cd..6e7b385fcdd 100644 --- a/source/blender/blenkernel/intern/geometry_component_pointcloud.cc +++ b/source/blender/blenkernel/intern/geometry_component_pointcloud.cc @@ -23,14 +23,14 @@ PointCloudComponent::~PointCloudComponent() this->clear(); } -GeometryComponent *PointCloudComponent::copy() const +GeometryComponentPtr PointCloudComponent::copy() const { PointCloudComponent *new_component = new PointCloudComponent(); if (pointcloud_ != nullptr) { new_component->pointcloud_ = BKE_pointcloud_copy_for_eval(pointcloud_); new_component->ownership_ = GeometryOwnershipType::Owned; } - return new_component; + return GeometryComponentPtr(new_component); } void PointCloudComponent::clear() diff --git a/source/blender/blenkernel/intern/geometry_component_volume.cc b/source/blender/blenkernel/intern/geometry_component_volume.cc index a616d3b30a4..70504e86650 100644 --- a/source/blender/blenkernel/intern/geometry_component_volume.cc +++ b/source/blender/blenkernel/intern/geometry_component_volume.cc @@ -21,14 +21,14 @@ VolumeComponent::~VolumeComponent() this->clear(); } -GeometryComponent *VolumeComponent::copy() const +GeometryComponentPtr VolumeComponent::copy() const { VolumeComponent *new_component = new VolumeComponent(); if (volume_ != nullptr) { new_component->volume_ = BKE_volume_copy_for_eval(volume_); new_component->ownership_ = GeometryOwnershipType::Owned; } - return new_component; + return GeometryComponentPtr(new_component); } void VolumeComponent::clear() diff --git a/source/blender/blenkernel/intern/geometry_set.cc b/source/blender/blenkernel/intern/geometry_set.cc index 8752f19aa45..aa5ed790a1d 100644 --- a/source/blender/blenkernel/intern/geometry_set.cc +++ b/source/blender/blenkernel/intern/geometry_set.cc @@ -128,7 +128,7 @@ GeometryComponent &GeometrySet::get_component_for_write(GeometryComponent::Type else { /* If the referenced component is shared, make a copy. The copy is not shared and is * therefore mutable. */ - component_ptr = GeometryComponentPtr(component_ptr->copy()); + component_ptr = component_ptr->copy(); } return const_cast(*component_ptr); }