Blender V5.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
8
9#include "BKE_geometry_set.hh"
10#include "BKE_lib_id.hh"
11#include "BKE_volume.hh"
12
13namespace blender::bke {
14
15/* -------------------------------------------------------------------- */
18
20
25
27{
28 VolumeComponent *new_component = new VolumeComponent();
29 if (volume_ != nullptr) {
30 new_component->volume_ = BKE_volume_copy_for_eval(volume_);
31 new_component->ownership_ = GeometryOwnershipType::Owned;
32 }
33 return GeometryComponentPtr(new_component);
34}
35
37{
38 BLI_assert(this->is_mutable() || this->is_expired());
39 if (volume_ != nullptr) {
40 if (ownership_ == GeometryOwnershipType::Owned) {
41 BKE_id_free(nullptr, volume_);
42 }
43 volume_ = nullptr;
44 }
45}
46
48{
49 return volume_ != nullptr;
50}
51
53{
54 BLI_assert(this->is_mutable());
55 this->clear();
56 volume_ = volume;
57 ownership_ = ownership;
58}
59
61{
62 BLI_assert(this->is_mutable());
63 Volume *volume = volume_;
64 volume_ = nullptr;
65 return volume;
66}
67
69{
70 return volume_;
71}
72
74{
75 BLI_assert(this->is_mutable());
76 if (ownership_ == GeometryOwnershipType::ReadOnly) {
77 volume_ = BKE_volume_copy_for_eval(volume_);
79 }
80 return volume_;
81}
82
84{
85 return ownership_ == GeometryOwnershipType::Owned;
86}
87
89{
90 BLI_assert(this->is_mutable());
91 if (ownership_ != GeometryOwnershipType::Owned) {
92 if (volume_) {
93 volume_ = BKE_volume_copy_for_eval(volume_);
94 }
96 }
97}
98
100{
101 if (volume_) {
102 BKE_volume_count_memory(*volume_, memory);
103 }
104}
105
107
108} // namespace blender::bke
Volume data-block.
void count_memory(MemoryCounter &memory) const override
GeometryComponentPtr copy() const override
void replace(Volume *volume, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
ImplicitSharingPtr< GeometryComponent > GeometryComponentPtr
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void BKE_volume_count_memory(const Volume &volume, MemoryCounter &memory)
Volume * BKE_volume_copy_for_eval(const Volume *volume_src)
void BKE_id_free(Main *bmain, void *idv)