Blender V4.3
geometry_component_volume.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#include "BKE_geometry_set.hh"
6#include "BKE_lib_id.hh"
7#include "BKE_volume.hh"
8
9namespace blender::bke {
10
11/* -------------------------------------------------------------------- */
16
21
23{
24 VolumeComponent *new_component = new VolumeComponent();
25 if (volume_ != nullptr) {
26 new_component->volume_ = BKE_volume_copy_for_eval(volume_);
27 new_component->ownership_ = GeometryOwnershipType::Owned;
28 }
29 return GeometryComponentPtr(new_component);
30}
31
33{
34 BLI_assert(this->is_mutable() || this->is_expired());
35 if (volume_ != nullptr) {
36 if (ownership_ == GeometryOwnershipType::Owned) {
37 BKE_id_free(nullptr, volume_);
38 }
39 volume_ = nullptr;
40 }
41}
42
44{
45 return volume_ != nullptr;
46}
47
49{
50 BLI_assert(this->is_mutable());
51 this->clear();
52 volume_ = volume;
53 ownership_ = ownership;
54}
55
57{
58 BLI_assert(this->is_mutable());
59 Volume *volume = volume_;
60 volume_ = nullptr;
61 return volume;
62}
63
65{
66 return volume_;
67}
68
70{
71 BLI_assert(this->is_mutable());
72 if (ownership_ == GeometryOwnershipType::ReadOnly) {
73 volume_ = BKE_volume_copy_for_eval(volume_);
75 }
76 return volume_;
77}
78
80{
81 return ownership_ == GeometryOwnershipType::Owned;
82}
83
85{
86 BLI_assert(this->is_mutable());
87 if (ownership_ != GeometryOwnershipType::Owned) {
88 if (volume_) {
89 volume_ = BKE_volume_copy_for_eval(volume_);
90 }
92 }
93}
94
96{
97 if (volume_) {
98 BKE_volume_count_memory(*volume_, memory);
99 }
100}
101
104} // namespace blender::bke
void BKE_id_free(Main *bmain, void *idv)
Volume data-block.
Volume * BKE_volume_copy_for_eval(const Volume *volume_src)
void BKE_volume_count_memory(const Volume &volume, blender::MemoryCounter &memory)
#define BLI_assert(a)
Definition BLI_assert.h:50
void count_memory(MemoryCounter &memory) const override
GeometryComponentPtr copy() const override
void replace(Volume *volume, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
ImplicitSharingPtr< GeometryComponent > GeometryComponentPtr