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