Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/geometry_set.cc
| Show First 20 Lines • Show All 333 Lines • ▼ Show 20 Lines | |||||
| void MeshComponent::replace(Mesh *mesh, GeometryOwnershipType ownership) | void MeshComponent::replace(Mesh *mesh, GeometryOwnershipType ownership) | ||||
| { | { | ||||
| BLI_assert(this->is_mutable()); | BLI_assert(this->is_mutable()); | ||||
| this->clear(); | this->clear(); | ||||
| mesh_ = mesh; | mesh_ = mesh; | ||||
| ownership_ = ownership; | ownership_ = ownership; | ||||
| } | } | ||||
| /* Replace only the mesh, not the other data. */ | |||||
| void MeshComponent::replace_mesh(Mesh *mesh, GeometryOwnershipType ownership) | |||||
| { | |||||
| BLI_assert(this->is_mutable()); | |||||
| if (mesh_ != nullptr) { | |||||
| if (ownership_ == GeometryOwnershipType::Owned) { | |||||
| BKE_id_free(nullptr, mesh_); | |||||
| } | |||||
| mesh_ = nullptr; | |||||
| } | |||||
| mesh_ = mesh; | |||||
| ownership_ = ownership; | |||||
| } | |||||
| /* Return the mesh and clear the component. The caller takes over responsibility for freeing the | /* Return the mesh and clear the component. The caller takes over responsibility for freeing the | ||||
| * mesh (if the component was responsible before). */ | * mesh (if the component was responsible before). */ | ||||
| Mesh *MeshComponent::release() | Mesh *MeshComponent::release() | ||||
| { | { | ||||
| BLI_assert(this->is_mutable()); | BLI_assert(this->is_mutable()); | ||||
| Mesh *mesh = mesh_; | Mesh *mesh = mesh_; | ||||
| mesh_ = nullptr; | mesh_ = nullptr; | ||||
| return mesh; | return mesh; | ||||
| ▲ Show 20 Lines • Show All 314 Lines • Show Last 20 Lines | |||||