Blender V5.3
BKE_volume.hh
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#pragma once
6
11
12#include <memory>
13#include <optional>
14
15#include "BLI_bounds_types.hh"
19#include "BLI_string_ref.hh"
20
22
23#include "DNA_volume_types.h"
24
25namespace blender {
26
27struct Depsgraph;
28struct Main;
29struct Object;
30struct ReportList;
31struct Scene;
32struct Volume;
33struct VolumeGridVector;
34
35namespace bke::bake {
37}
38
39/* Module */
40
41void BKE_volumes_init();
42
43/* Data-block Management */
44
45void BKE_volume_init_grids(Volume *volume);
46Volume *BKE_volume_add(Main *bmain, const char *name);
47
48bool BKE_volume_is_y_up(const Volume *volume);
49bool BKE_volume_is_points_only(const Volume *volume);
50
51/* Depsgraph */
52
53void BKE_volume_eval_geometry(Depsgraph *depsgraph, Volume *volume);
54void BKE_volume_data_update(Depsgraph *depsgraph, Scene *scene, Object *object);
55
57 VolumeGridVector *grids,
58 const char *filepath);
59
60/* Draw Cache */
61
62enum {
64};
65
66void BKE_volume_batch_cache_dirty_tag(Volume *volume, int mode);
68
69extern void (*BKE_volume_batch_cache_dirty_tag_cb)(Volume *volume, int mode);
70extern void (*BKE_volume_batch_cache_free_cb)(Volume *volume);
71
72/* Grids
73 *
74 * For volumes referencing a file, the list of grids and metadata must be
75 * loaded before it can be accessed. This happens on-demand, only when needed
76 * by the user interface, dependency graph or render engine. */
77
78bool BKE_volume_load(const Volume *volume, const Main *bmain);
79void BKE_volume_unload(Volume *volume);
80bool BKE_volume_is_loaded(const Volume *volume);
81
82int BKE_volume_num_grids(const Volume *volume);
83const char *BKE_volume_grids_error_msg(const Volume *volume);
84const char *BKE_volume_grids_frame_filepath(const Volume *volume);
85const bke::VolumeGridData *BKE_volume_grid_get(const Volume *volume, int grid_index);
86bke::VolumeGridData *BKE_volume_grid_get_for_write(Volume *volume, int grid_index);
87const bke::VolumeGridData *BKE_volume_grid_active_get_for_read(const Volume *volume);
88/* Tries to find a grid with the given name. Make sure that the volume has been loaded. */
89const bke::VolumeGridData *BKE_volume_grid_find(const Volume *volume, StringRef name);
90bke::VolumeGridData *BKE_volume_grid_find_for_write(Volume *volume, StringRef name);
91
92/* Tries to set the name of the velocity field. If no such grid exists with the given base name,
93 * this will try common post-fixes in order to detect velocity fields split into multiple grids.
94 * Return false if neither finding with the base name nor with the post-fixes succeeded. */
95bool BKE_volume_set_velocity_grid_by_name(Volume *volume, StringRef base_name);
96
97/* Volume Editing
98 *
99 * These are intended for modifiers to use on evaluated data-blocks.
100 *
101 * new_for_eval creates a volume data-block with no grids or file path, but
102 * preserves other settings such as viewport display options.
103 *
104 * copy_for_eval creates a volume data-block preserving everything except the
105 * file path. Grids are shared with the source data-block, not copied. */
106
107Volume *BKE_volume_new_for_eval(const Volume *volume_src);
108Volume *BKE_volume_copy_for_eval(const Volume *volume_src);
109
110void BKE_volume_grid_remove(Volume *volume, const bke::VolumeGridData *grid);
111
116void BKE_volume_grid_add(Volume *volume, const bke::VolumeGridData &grid);
117
122bool BKE_volume_voxel_size_valid(const float3 &voxel_size);
124
125/* Simplify */
126int BKE_volume_simplify_level(const Depsgraph *depsgraph);
127float BKE_volume_simplify_factor(const Depsgraph *depsgraph);
128
129/* File Save */
130bool BKE_volume_save(const Volume *volume,
131 const Main *bmain,
132 ReportList *reports,
133 const char *filepath);
134
135void BKE_volume_count_memory(const Volume &volume, MemoryCounter &memory);
136
137std::optional<Bounds<float3>> BKE_volume_min_max(const Volume *volume);
138
139namespace bke {
140
143 VolumeGridVector *grids = nullptr;
144
146 int frame = 0;
147
148 /* Names for scalar grids which would need to be merged to recompose the velocity grid. */
149 char velocity_x_grid[64] = "";
150 char velocity_y_grid[64] = "";
151 char velocity_z_grid[64] = "";
152
153 std::unique_ptr<bake::BakeMaterialsList> bake_materials;
154};
155
156} // namespace bke
157} // namespace blender
SIMD_FORCE_INLINE btVector3 transform(const btVector3 &point) const
b[1] b &&[1] b &&[1] b &&[1] b &&[1] b[3] b &&[1] b[3] float determinant(MatBase< C, R >) RET
MatBase< 4, 4 > float4x4
BMesh Iterators.
bke::VolumeGridData * BKE_volume_grid_find_for_write(Volume *volume, StringRef name)
bke::VolumeGridData * BKE_volume_grid_get_for_write(Volume *volume, int grid_index)
void BKE_volume_batch_cache_dirty_tag(Volume *volume, int mode)
std::optional< Bounds< float3 > > BKE_volume_min_max(const Volume *volume)
int BKE_volume_num_grids(const Volume *volume)
void BKE_volume_batch_cache_free(Volume *volume)
bool BKE_volume_set_velocity_grid_by_name(Volume *volume, StringRef base_name)
void BKE_volume_count_memory(const Volume &volume, MemoryCounter &memory)
Volume * BKE_volume_add(Main *bmain, const char *name)
const bke::VolumeGridData * BKE_volume_grid_find(const Volume *volume, StringRef name)
void BKE_volume_data_update(Depsgraph *depsgraph, Scene *scene, Object *object)
bool BKE_volume_grid_transform_valid(const float4x4 &transform)
const bke::VolumeGridData * BKE_volume_grid_get(const Volume *volume, int grid_index)
int BKE_volume_simplify_level(const Depsgraph *depsgraph)
Volume * BKE_volume_new_for_eval(const Volume *volume_src)
bool BKE_volume_is_y_up(const Volume *volume)
const char * BKE_volume_grids_error_msg(const Volume *volume)
bool BKE_volume_is_loaded(const Volume *volume)
Volume * BKE_volume_copy_for_eval(const Volume *volume_src)
void(*) BKE_volume_batch_cache_free_cb(Volume *volume)
const char * BKE_volume_grids_frame_filepath(const Volume *volume)
void(*) BKE_volume_batch_cache_dirty_tag_cb(Volume *volume, int mode)
void BKE_volume_unload(Volume *volume)
bool BKE_volume_is_points_only(const Volume *volume)
bool BKE_volume_save(const Volume *volume, const Main *bmain, ReportList *reports, const char *filepath)
void BKE_volume_grids_backup_restore(Volume *volume, VolumeGridVector *grids, const char *filepath)
bool BKE_volume_load(const Volume *volume, const Main *bmain)
float BKE_volume_simplify_factor(const Depsgraph *depsgraph)
void BKE_volume_grid_add(Volume *volume, const bke::VolumeGridData &grid)
const bke::VolumeGridData * BKE_volume_grid_active_get_for_read(const Volume *volume)
void BKE_volume_init_grids(Volume *volume)
void BKE_volume_grid_remove(Volume *volume, const bke::VolumeGridData *grid)
void BKE_volume_eval_geometry(Depsgraph *depsgraph, Volume *volume)
bool BKE_volume_grid_determinant_valid(double determinant)
@ BKE_VOLUME_BATCH_DIRTY_ALL
Definition BKE_volume.hh:63
bool BKE_volume_voxel_size_valid(const float3 &voxel_size)
std::unique_ptr< bake::BakeMaterialsList > bake_materials
VolumeGridVector * grids