Blender V5.0
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
25struct Depsgraph;
26struct Main;
27struct Object;
28struct ReportList;
29struct Scene;
30struct Volume;
31struct VolumeGridVector;
32
33namespace blender::bke::bake {
35}
36
37/* Module */
38
39void BKE_volumes_init();
40
41/* Data-block Management */
42
43void BKE_volume_init_grids(Volume *volume);
44Volume *BKE_volume_add(Main *bmain, const char *name);
45
46bool BKE_volume_is_y_up(const Volume *volume);
47bool BKE_volume_is_points_only(const Volume *volume);
48
49/* Depsgraph */
50
51void BKE_volume_eval_geometry(Depsgraph *depsgraph, Volume *volume);
52void BKE_volume_data_update(Depsgraph *depsgraph, Scene *scene, Object *object);
53
55 VolumeGridVector *grids,
56 const char *filepath);
57
58/* Draw Cache */
59
60enum {
62};
63
64void BKE_volume_batch_cache_dirty_tag(Volume *volume, int mode);
66
67extern void (*BKE_volume_batch_cache_dirty_tag_cb)(Volume *volume, int mode);
68extern void (*BKE_volume_batch_cache_free_cb)(Volume *volume);
69
70/* Grids
71 *
72 * For volumes referencing a file, the list of grids and metadata must be
73 * loaded before it can be accessed. This happens on-demand, only when needed
74 * by the user interface, dependency graph or render engine. */
75
76bool BKE_volume_load(const Volume *volume, const Main *bmain);
77void BKE_volume_unload(Volume *volume);
78bool BKE_volume_is_loaded(const Volume *volume);
79
80int BKE_volume_num_grids(const Volume *volume);
81const char *BKE_volume_grids_error_msg(const Volume *volume);
82const char *BKE_volume_grids_frame_filepath(const Volume *volume);
83const blender::bke::VolumeGridData *BKE_volume_grid_get(const Volume *volume, int grid_index);
84blender::bke::VolumeGridData *BKE_volume_grid_get_for_write(Volume *volume, int grid_index);
85const blender::bke::VolumeGridData *BKE_volume_grid_active_get_for_read(const Volume *volume);
86/* Tries to find a grid with the given name. Make sure that the volume has been loaded. */
87const blender::bke::VolumeGridData *BKE_volume_grid_find(const Volume *volume,
89blender::bke::VolumeGridData *BKE_volume_grid_find_for_write(Volume *volume,
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. */
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 blender::bke::VolumeGridData *grid);
111
116void BKE_volume_grid_add(Volume *volume, const blender::bke::VolumeGridData &grid);
117
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, blender::MemoryCounter &memory);
136
137std::optional<blender::Bounds<blender::float3>> BKE_volume_min_max(const Volume *volume);
138
139namespace blender::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 blender::bke
const blender::bke::VolumeGridData * BKE_volume_grid_active_get_for_read(const Volume *volume)
void BKE_volume_grid_add(Volume *volume, const blender::bke::VolumeGridData &grid)
bool BKE_volume_is_loaded(const Volume *volume)
void BKE_volume_batch_cache_free(Volume *volume)
bool BKE_volume_is_y_up(const Volume *volume)
int BKE_volume_num_grids(const Volume *volume)
Volume * BKE_volume_copy_for_eval(const Volume *volume_src)
bool BKE_volume_save(const Volume *volume, const Main *bmain, ReportList *reports, const char *filepath)
@ BKE_VOLUME_BATCH_DIRTY_ALL
Definition BKE_volume.hh:61
void BKE_volume_batch_cache_dirty_tag(Volume *volume, int mode)
bool BKE_volume_load(const Volume *volume, const Main *bmain)
blender::bke::VolumeGridData * BKE_volume_grid_get_for_write(Volume *volume, int grid_index)
bool BKE_volume_is_points_only(const Volume *volume)
Volume * BKE_volume_add(Main *bmain, const char *name)
std::optional< blender::Bounds< blender::float3 > > BKE_volume_min_max(const Volume *volume)
void(* BKE_volume_batch_cache_dirty_tag_cb)(Volume *volume, int mode)
const blender::bke::VolumeGridData * BKE_volume_grid_find(const Volume *volume, blender::StringRef name)
Volume * BKE_volume_new_for_eval(const Volume *volume_src)
void BKE_volumes_init()
blender::bke::VolumeGridData * BKE_volume_grid_find_for_write(Volume *volume, blender::StringRef name)
void BKE_volume_grid_remove(Volume *volume, const blender::bke::VolumeGridData *grid)
int BKE_volume_simplify_level(const Depsgraph *depsgraph)
void BKE_volume_eval_geometry(Depsgraph *depsgraph, Volume *volume)
const char * BKE_volume_grids_frame_filepath(const Volume *volume)
float BKE_volume_simplify_factor(const Depsgraph *depsgraph)
const blender::bke::VolumeGridData * BKE_volume_grid_get(const Volume *volume, int grid_index)
void BKE_volume_unload(Volume *volume)
bool BKE_volume_grid_transform_valid(const blender::float4x4 &transform)
void(* BKE_volume_batch_cache_free_cb)(Volume *volume)
bool BKE_volume_voxel_size_valid(const blender::float3 &voxel_size)
void BKE_volume_count_memory(const Volume &volume, blender::MemoryCounter &memory)
bool BKE_volume_grid_determinant_valid(double determinant)
const char * BKE_volume_grids_error_msg(const Volume *volume)
void BKE_volume_data_update(Depsgraph *depsgraph, Scene *scene, Object *object)
void BKE_volume_grids_backup_restore(Volume *volume, VolumeGridVector *grids, const char *filepath)
void BKE_volume_init_grids(Volume *volume)
bool BKE_volume_set_velocity_grid_by_name(Volume *volume, blender::StringRef base_name)
BPy_StructRNA * depsgraph
SIMD_FORCE_INLINE btVector3 transform(const btVector3 &point) const
float determinant(MatBase< C, R >) RET
MatBase< float, 4, 4 > float4x4
VecBase< float, 3 > float3
const char * name
std::unique_ptr< bake::BakeMaterialsList > bake_materials
VolumeGridVector * grids