Blender V4.5
rna_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 <cstdlib>
10
11#include "RNA_define.hh"
12#include "RNA_enum_types.hh"
13
14#include "rna_internal.hh"
15
16#include "DNA_scene_types.h"
17#include "DNA_volume_types.h"
18
19#include "BKE_volume_enums.hh"
20
22
23#include "BLT_translation.hh"
24
26 {VOLUME_GRID_BOOLEAN, "BOOLEAN", 0, "Boolean", "Boolean"},
27 {VOLUME_GRID_FLOAT, "FLOAT", 0, "Float", "Single precision float"},
28 {VOLUME_GRID_DOUBLE, "DOUBLE", 0, "Double", "Double precision"},
29 {VOLUME_GRID_INT, "INT", 0, "Integer", "32-bit integer"},
30 {VOLUME_GRID_INT64, "INT64", 0, "Integer 64-bit", "64-bit integer"},
31 {VOLUME_GRID_MASK, "MASK", 0, "Mask", "No data, boolean mask of active voxels"},
32 {VOLUME_GRID_VECTOR_FLOAT, "VECTOR_FLOAT", 0, "Float Vector", "3D float vector"},
33 {VOLUME_GRID_VECTOR_DOUBLE, "VECTOR_DOUBLE", 0, "Double Vector", "3D double vector"},
34 {VOLUME_GRID_VECTOR_INT, "VECTOR_INT", 0, "Integer Vector", "3D integer vector"},
36 "POINTS",
37 0,
38 "Points (Unsupported)",
39 "Points grid, currently unsupported by volume objects"},
40 {VOLUME_GRID_UNKNOWN, "UNKNOWN", 0, "Unknown", "Unsupported data type"},
41 {0, nullptr, 0, nullptr, nullptr},
42};
43
50struct DummyVolumeGridData;
51
52#ifdef RNA_RUNTIME
53
54# include "BKE_volume.hh"
55
56# include "DEG_depsgraph.hh"
57# include "DEG_depsgraph_build.hh"
58
59# include "WM_api.hh"
60# include "WM_types.hh"
61
62static std::optional<std::string> rna_VolumeRender_path(const PointerRNA * /*ptr*/)
63{
64 return "render";
65}
66
67static std::optional<std::string> rna_VolumeDisplay_path(const PointerRNA * /*ptr*/)
68{
69 return "display";
70}
71
72/* Updates */
73
74static void rna_Volume_update_display(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
75{
76 Volume *volume = (Volume *)ptr->owner_id;
78}
79
80static void rna_Volume_update_filepath(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
81{
82 Volume *volume = (Volume *)ptr->owner_id;
83 BKE_volume_unload(volume);
86}
87
88static void rna_Volume_update_is_sequence(Main *bmain, Scene *scene, PointerRNA *ptr)
89{
90 rna_Volume_update_filepath(bmain, scene, ptr);
92}
93
94static void rna_Volume_velocity_grid_set(PointerRNA *ptr, const char *value)
95{
96 Volume *volume = (Volume *)ptr->data;
97 if (!BKE_volume_set_velocity_grid_by_name(volume, value)) {
98 WM_global_reportf(RPT_ERROR, "Could not find grid with name %s", value);
99 }
101}
102
103/* Grid */
104
105static void rna_VolumeGrid_name_get(PointerRNA *ptr, char *value)
106{
107 auto *grid = static_cast<const blender::bke::VolumeGridData *>(ptr->data);
108 strcpy(value, blender::bke::volume_grid::get_name(*grid).c_str());
109}
110
111static int rna_VolumeGrid_name_length(PointerRNA *ptr)
112{
113 auto *grid = static_cast<const blender::bke::VolumeGridData *>(ptr->data);
114 return blender::bke::volume_grid::get_name(*grid).size();
115}
116
117static int rna_VolumeGrid_data_type_get(PointerRNA *ptr)
118{
119 const auto *grid = static_cast<const blender::bke::VolumeGridData *>(ptr->data);
121}
122
123static int rna_VolumeGrid_channels_get(PointerRNA *ptr)
124{
125 const auto *grid = static_cast<const blender::bke::VolumeGridData *>(ptr->data);
127}
128
129static void rna_VolumeGrid_matrix_object_get(PointerRNA *ptr, float *value)
130{
131 auto *grid = static_cast<const blender::bke::VolumeGridData *>(ptr->data);
133}
134
135static bool rna_VolumeGrid_is_loaded_get(PointerRNA *ptr)
136{
137 auto *grid = static_cast<const blender::bke::VolumeGridData *>(ptr->data);
139}
140
141static bool rna_VolumeGrid_load(ID * /*id*/, DummyVolumeGridData *dummy_grid)
142{
143 auto *grid = reinterpret_cast<const blender::bke::VolumeGridData *>(dummy_grid);
146}
147
148static void rna_VolumeGrid_unload(ID * /*id*/, DummyVolumeGridData * /*dummy_grid*/)
149{
150 /* This is handled transparently. The grid is unloaded automatically if it's not used and the
151 * memory cache is full. */
152}
153
154/* Grids Iterator */
155
156static void rna_Volume_grids_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
157{
158 Volume *volume = static_cast<Volume *>(ptr->data);
159 int num_grids = BKE_volume_num_grids(volume);
160 iter->internal.count.ptr = volume;
161 iter->internal.count.item = 0;
162 iter->valid = (iter->internal.count.item < num_grids);
163}
164
165static void rna_Volume_grids_next(CollectionPropertyIterator *iter)
166{
167 Volume *volume = static_cast<Volume *>(iter->internal.count.ptr);
168 int num_grids = BKE_volume_num_grids(volume);
169 iter->internal.count.item++;
170 iter->valid = (iter->internal.count.item < num_grids);
171}
172
173static void rna_Volume_grids_end(CollectionPropertyIterator * /*iter*/) {}
174
175static PointerRNA rna_Volume_grids_get(CollectionPropertyIterator *iter)
176{
177 Volume *volume = static_cast<Volume *>(iter->internal.count.ptr);
178 const blender::bke::VolumeGridData *grid = BKE_volume_grid_get(volume,
179 iter->internal.count.item);
180 return RNA_pointer_create_with_parent(iter->parent, &RNA_VolumeGrid, (void *)grid);
181}
182
183static int rna_Volume_grids_length(PointerRNA *ptr)
184{
185 Volume *volume = static_cast<Volume *>(ptr->data);
186 return BKE_volume_num_grids(volume);
187}
188
189/* Active Grid */
190
191static void rna_VolumeGrids_active_index_range(
192 PointerRNA *ptr, int *min, int *max, int * /*softmin*/, int * /*softmax*/)
193{
194 Volume *volume = (Volume *)ptr->data;
195 int num_grids = BKE_volume_num_grids(volume);
196
197 *min = 0;
198 *max = max_ii(0, num_grids - 1);
199}
200
201static int rna_VolumeGrids_active_index_get(PointerRNA *ptr)
202{
203 Volume *volume = (Volume *)ptr->data;
204 int num_grids = BKE_volume_num_grids(volume);
205 return clamp_i(volume->active_grid, 0, max_ii(num_grids - 1, 0));
206}
207
208static void rna_VolumeGrids_active_index_set(PointerRNA *ptr, int value)
209{
210 Volume *volume = (Volume *)ptr->data;
211 volume->active_grid = value;
212}
213
214/* Loading */
215
216static bool rna_VolumeGrids_is_loaded_get(PointerRNA *ptr)
217{
218 Volume *volume = (Volume *)ptr->data;
219 return BKE_volume_is_loaded(volume);
220}
221
222/* Error Message */
223
224static void rna_VolumeGrids_error_message_get(PointerRNA *ptr, char *value)
225{
226 Volume *volume = (Volume *)ptr->data;
227 strcpy(value, BKE_volume_grids_error_msg(volume));
228}
229
230static int rna_VolumeGrids_error_message_length(PointerRNA *ptr)
231{
232 Volume *volume = (Volume *)ptr->data;
233 return strlen(BKE_volume_grids_error_msg(volume));
234}
235
236/* Frame Filepath */
237static void rna_VolumeGrids_frame_filepath_get(PointerRNA *ptr, char *value)
238{
239 Volume *volume = (Volume *)ptr->data;
240 strcpy(value, BKE_volume_grids_frame_filepath(volume));
241}
242
243static int rna_VolumeGrids_frame_filepath_length(PointerRNA *ptr)
244{
245 Volume *volume = (Volume *)ptr->data;
246 return strlen(BKE_volume_grids_frame_filepath(volume));
247}
248
249static bool rna_Volume_load(Volume *volume, Main *bmain)
250{
251 return BKE_volume_load(volume, bmain);
252}
253
254static bool rna_Volume_save(Volume *volume, Main *bmain, ReportList *reports, const char *filepath)
255{
256 return BKE_volume_save(volume, bmain, reports, filepath);
257}
258
259#else
260
262{
263 StructRNA *srna;
264 PropertyRNA *prop;
265
266 srna = RNA_def_struct(brna, "VolumeGrid", nullptr);
267 RNA_def_struct_sdna(srna, "DummyVolumeGridData");
268 RNA_def_struct_ui_text(srna, "Volume Grid", "3D volume grid");
269 RNA_def_struct_ui_icon(srna, ICON_VOLUME_DATA);
270
271 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
274 prop, "rna_VolumeGrid_name_get", "rna_VolumeGrid_name_length", nullptr);
275 RNA_def_property_ui_text(prop, "Name", "Volume grid name");
277
278 prop = RNA_def_property(srna, "data_type", PROP_ENUM, PROP_NONE);
280 RNA_def_property_enum_funcs(prop, "rna_VolumeGrid_data_type_get", nullptr, nullptr);
282 RNA_def_property_ui_text(prop, "Data Type", "Data type of voxel values");
284
285 prop = RNA_def_property(srna, "channels", PROP_INT, PROP_UNSIGNED);
287 RNA_def_property_int_funcs(prop, "rna_VolumeGrid_channels_get", nullptr, nullptr);
288 RNA_def_property_ui_text(prop, "Channels", "Number of dimensions of the grid data type");
289
290 prop = RNA_def_property(srna, "matrix_object", PROP_FLOAT, PROP_MATRIX);
293 RNA_def_property_float_funcs(prop, "rna_VolumeGrid_matrix_object_get", nullptr, nullptr);
295 prop, "Matrix Object", "Transformation matrix from voxel index to object space");
296
297 prop = RNA_def_property(srna, "is_loaded", PROP_BOOLEAN, PROP_NONE);
299 RNA_def_property_boolean_funcs(prop, "rna_VolumeGrid_is_loaded_get", nullptr);
300 RNA_def_property_ui_text(prop, "Is Loaded", "Grid tree is loaded in memory");
301 /* API */
302 FunctionRNA *func;
303 PropertyRNA *parm;
304
305 func = RNA_def_function(srna, "load", "rna_VolumeGrid_load");
306 RNA_def_function_ui_description(func, "Load grid tree from file");
308 parm = RNA_def_boolean(func, "success", false, "", "True if grid tree was successfully loaded");
309 RNA_def_function_return(func, parm);
310
311 func = RNA_def_function(srna, "unload", "rna_VolumeGrid_unload");
314 func, "Unload grid tree and voxel data from memory, leaving only metadata");
315}
316
318{
319 StructRNA *srna;
320 PropertyRNA *prop;
321
322 RNA_def_property_srna(cprop, "VolumeGrids");
323 srna = RNA_def_struct(brna, "VolumeGrids", nullptr);
324 RNA_def_struct_sdna(srna, "Volume");
325 RNA_def_struct_ui_text(srna, "Volume Grids", "3D volume grids");
326
327 prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
329 "rna_VolumeGrids_active_index_get",
330 "rna_VolumeGrids_active_index_set",
331 "rna_VolumeGrids_active_index_range");
332 RNA_def_property_ui_text(prop, "Active Grid Index", "Index of active volume grid");
333 RNA_def_property_update(prop, 0, "rna_Volume_update_display");
334
335 prop = RNA_def_property(srna, "error_message", PROP_STRING, PROP_NONE);
338 prop, "rna_VolumeGrids_error_message_get", "rna_VolumeGrids_error_message_length", nullptr);
340 prop, "Error Message", "If loading grids failed, error message with details");
341
342 prop = RNA_def_property(srna, "is_loaded", PROP_BOOLEAN, PROP_NONE);
344 RNA_def_property_boolean_funcs(prop, "rna_VolumeGrids_is_loaded_get", nullptr);
345 RNA_def_property_ui_text(prop, "Is Loaded", "List of grids and metadata are loaded in memory");
346
347 prop = RNA_def_property(srna, "frame", PROP_INT, PROP_NONE);
348 RNA_def_property_int_sdna(prop, nullptr, "runtime->frame");
351 "Frame",
352 "Frame number that volume grids will be loaded at, based on scene time "
353 "and volume parameters");
354
355 prop = RNA_def_property(srna, "frame_filepath", PROP_STRING, PROP_FILEPATH);
359 "rna_VolumeGrids_frame_filepath_get",
360 "rna_VolumeGrids_frame_filepath_length",
361 nullptr);
362
364 "Frame File Path",
365 "Volume file used for loading the volume at the current frame. Empty "
366 "if the volume has not be loaded or the frame only exists in memory.");
367
368 /* API */
369 FunctionRNA *func;
370 PropertyRNA *parm;
371
372 func = RNA_def_function(srna, "load", "rna_Volume_load");
373 RNA_def_function_ui_description(func, "Load list of grids and metadata from file");
375 parm = RNA_def_boolean(func, "success", false, "", "True if grid list was successfully loaded");
376 RNA_def_function_return(func, parm);
377
378 func = RNA_def_function(srna, "unload", "BKE_volume_unload");
379 RNA_def_function_ui_description(func, "Unload all grid and voxel data from memory");
380
381 func = RNA_def_function(srna, "save", "rna_Volume_save");
382 RNA_def_function_ui_description(func, "Save grids and metadata to file");
384 parm = RNA_def_string_file_path(func, "filepath", nullptr, 0, "", "File path to save to");
386 parm = RNA_def_boolean(func, "success", false, "", "True if grid list was successfully loaded");
387 RNA_def_function_return(func, parm);
388}
389
391{
392 StructRNA *srna;
393 PropertyRNA *prop;
394
395 srna = RNA_def_struct(brna, "VolumeDisplay", nullptr);
396 RNA_def_struct_ui_text(srna, "Volume Display", "Volume object display settings for 3D viewport");
397 RNA_def_struct_sdna(srna, "VolumeDisplay");
398 RNA_def_struct_path_func(srna, "rna_VolumeDisplay_path");
399
400 prop = RNA_def_property(srna, "density", PROP_FLOAT, PROP_NONE);
402 RNA_def_property_range(prop, 0.00001, FLT_MAX);
403 RNA_def_property_ui_range(prop, 0.1, 100.0, 1, 3);
404 RNA_def_property_ui_text(prop, "Density", "Thickness of volume display in the viewport");
405 RNA_def_property_update(prop, 0, "rna_Volume_update_display");
406
407 static const EnumPropertyItem wireframe_type_items[] = {
408 {VOLUME_WIREFRAME_NONE, "NONE", 0, "None", "Don't display volume in wireframe mode"},
410 "BOUNDS",
411 0,
412 "Bounds",
413 "Display single bounding box for the entire grid"},
415 "BOXES",
416 0,
417 "Boxes",
418 "Display bounding boxes for nodes in the volume tree"},
420 "POINTS",
421 0,
422 "Points",
423 "Display points for nodes in the volume tree"},
424 {0, nullptr, 0, nullptr, nullptr},
425 };
426
427 static const EnumPropertyItem wireframe_detail_items[] = {
429 "COARSE",
430 0,
431 "Coarse",
432 "Display one box or point for each intermediate tree node"},
434 "FINE",
435 0,
436 "Fine",
437 "Display box for each leaf node containing 8" BLI_STR_UTF8_MULTIPLICATION_SIGN "8 voxels"},
438 {0, nullptr, 0, nullptr, nullptr},
439 };
440
441 static const EnumPropertyItem interpolation_method_items[] = {
442 {VOLUME_DISPLAY_INTERP_LINEAR, "LINEAR", 0, "Linear", "Good smoothness and speed"},
444 "CUBIC",
445 0,
446 "Cubic",
447 "Smoothed high quality interpolation, but slower"},
448 {VOLUME_DISPLAY_INTERP_CLOSEST, "CLOSEST", 0, "Closest", "No interpolation"},
449 {0, nullptr, 0, nullptr, nullptr},
450 };
451
452 static const EnumPropertyItem axis_slice_position_items[] = {
454 "AUTO",
455 0,
456 "Auto",
457 "Adjust slice direction according to the view direction"},
458 {VOLUME_SLICE_AXIS_X, "X", 0, "X", "Slice along the X axis"},
459 {VOLUME_SLICE_AXIS_Y, "Y", 0, "Y", "Slice along the Y axis"},
460 {VOLUME_SLICE_AXIS_Z, "Z", 0, "Z", "Slice along the Z axis"},
461 {0, nullptr, 0, nullptr, nullptr},
462 };
463
464 prop = RNA_def_property(srna, "wireframe_type", PROP_ENUM, PROP_NONE);
465 RNA_def_property_enum_items(prop, wireframe_type_items);
466 RNA_def_property_ui_text(prop, "Wireframe", "Type of wireframe display");
467 RNA_def_property_update(prop, 0, "rna_Volume_update_display");
468
469 prop = RNA_def_property(srna, "wireframe_detail", PROP_ENUM, PROP_NONE);
470 RNA_def_property_enum_items(prop, wireframe_detail_items);
471 RNA_def_property_ui_text(prop, "Wireframe Detail", "Amount of detail for wireframe display");
472 RNA_def_property_update(prop, 0, "rna_Volume_update_display");
473
474 prop = RNA_def_property(srna, "interpolation_method", PROP_ENUM, PROP_NONE);
475 RNA_def_property_enum_items(prop, interpolation_method_items);
477 prop, "Interpolation", "Interpolation method to use for volumes in solid mode");
478 RNA_def_property_update(prop, 0, "rna_Volume_update_display");
479
480 prop = RNA_def_property(srna, "use_slice", PROP_BOOLEAN, PROP_NONE);
481 RNA_def_property_boolean_sdna(prop, nullptr, "axis_slice_method", VOLUME_AXIS_SLICE_SINGLE);
482 RNA_def_property_ui_text(prop, "Slice", "Perform a single slice of the domain object");
483 RNA_def_property_update(prop, 0, "rna_Volume_update_display");
484
485 prop = RNA_def_property(srna, "slice_axis", PROP_ENUM, PROP_NONE);
486 RNA_def_property_enum_items(prop, axis_slice_position_items);
487 RNA_def_property_ui_text(prop, "Axis", "");
488 RNA_def_property_update(prop, 0, "rna_Volume_update_display");
489
490 prop = RNA_def_property(srna, "slice_depth", PROP_FLOAT, PROP_FACTOR);
491 RNA_def_property_range(prop, 0.0, 1.0);
492 RNA_def_property_ui_range(prop, 0.0, 1.0, 0.1, 3);
493 RNA_def_property_ui_text(prop, "Position", "Position of the slice");
494 RNA_def_property_update(prop, 0, "rna_Volume_update_display");
495}
496
498{
499 StructRNA *srna;
500 PropertyRNA *prop;
501
502 srna = RNA_def_struct(brna, "VolumeRender", nullptr);
503 RNA_def_struct_ui_text(srna, "Volume Render", "Volume object render settings");
504 RNA_def_struct_sdna(srna, "VolumeRender");
505 RNA_def_struct_path_func(srna, "rna_VolumeRender_path");
506
507 static const EnumPropertyItem precision_items[] = {
508 {VOLUME_PRECISION_FULL, "FULL", 0, "Full", "Use 32-bit floating-point numbers for all data"},
509 {VOLUME_PRECISION_HALF, "HALF", 0, "Half", "Use 16-bit floating-point numbers for all data"},
510 {VOLUME_PRECISION_VARIABLE, "VARIABLE", 0, "Variable", "Use variable bit quantization"},
511 {0, nullptr, 0, nullptr, nullptr},
512 };
513
514 prop = RNA_def_property(srna, "precision", PROP_ENUM, PROP_NONE);
515 RNA_def_property_enum_items(prop, precision_items);
517 "Precision",
518 "Specify volume data precision. Lower values reduce memory consumption "
519 "at the cost of detail.");
520 RNA_def_property_update(prop, 0, "rna_Volume_update_display");
521
522 static const EnumPropertyItem space_items[] = {
524 "OBJECT",
525 0,
526 "Object",
527 "Keep volume opacity and detail the same regardless of object scale"},
529 "WORLD",
530 0,
531 "World",
532 "Specify volume step size and density in world space"},
533 {0, nullptr, 0, nullptr, nullptr},
534 };
535
536 prop = RNA_def_property(srna, "space", PROP_ENUM, PROP_NONE);
539 prop, "Space", "Specify volume density and step size in object or world space");
540 RNA_def_property_update(prop, 0, "rna_Volume_update_display");
541
542 prop = RNA_def_property(srna, "step_size", PROP_FLOAT, PROP_DISTANCE);
545 RNA_def_property_ui_range(prop, 0.0, 100.0, 1, 3);
547 "Step Size",
548 "Distance between volume samples. Lower values render more detail at "
549 "the cost of performance. If set to zero, the step size is "
550 "automatically determined based on voxel size.");
551 RNA_def_property_update(prop, 0, "rna_Volume_update_display");
552
553 prop = RNA_def_property(srna, "clipping", PROP_FLOAT, PROP_NONE);
554 RNA_def_property_float_sdna(prop, nullptr, "clipping");
555 RNA_def_property_range(prop, 0.0, 1.0);
556 RNA_def_property_ui_range(prop, 0.0, 1.0, 0.1, 3);
558 prop,
559 "Clipping",
560 "Value under which voxels are considered empty space to optimize rendering");
561 RNA_def_property_update(prop, 0, "rna_Volume_update_display");
562}
563
564static void rna_def_volume(BlenderRNA *brna)
565{
566 StructRNA *srna;
567 PropertyRNA *prop;
568
569 srna = RNA_def_struct(brna, "Volume", "ID");
570 RNA_def_struct_ui_text(srna, "Volume", "Volume data-block for 3D volume grids");
571 RNA_def_struct_ui_icon(srna, ICON_VOLUME_DATA);
572
573 /* File */
574 prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH);
577 RNA_def_property_ui_text(prop, "File Path", "Volume file used by this Volume data-block");
578 RNA_def_property_update(prop, 0, "rna_Volume_update_filepath");
579
580 prop = RNA_def_property(srna, "packed_file", PROP_POINTER, PROP_NONE);
581 RNA_def_property_pointer_sdna(prop, nullptr, "packedfile");
582 RNA_def_property_ui_text(prop, "Packed File", "");
583
584 /* Sequence */
585 prop = RNA_def_property(srna, "is_sequence", PROP_BOOLEAN, PROP_NONE);
588 prop, "Sequence", "Whether the cache is separated in a series of files");
589 RNA_def_property_update(prop, 0, "rna_Volume_update_is_sequence");
590
591 prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_TIME);
595 prop, "Start Frame", "Global starting frame of the sequence, assuming first has a #1");
596 RNA_def_property_update(prop, 0, "rna_Volume_update_filepath");
597
598 prop = RNA_def_property(srna, "frame_duration", PROP_INT, PROP_NONE);
601 RNA_def_property_ui_text(prop, "Frames", "Number of frames of the sequence to use");
602 RNA_def_property_update(prop, 0, "rna_Volume_update_filepath");
603
604 prop = RNA_def_property(srna, "frame_offset", PROP_INT, PROP_NONE);
606 prop, "Offset", "Offset the number of the frame to use in the animation");
607 RNA_def_property_update(prop, 0, "rna_Volume_update_filepath");
608
609 static const EnumPropertyItem sequence_mode_items[] = {
610 {VOLUME_SEQUENCE_CLIP, "CLIP", 0, "Clip", "Hide frames outside the specified frame range"},
612 "EXTEND",
613 0,
614 "Extend",
615 "Repeat the start frame before, and the end frame after the frame range"},
616 {VOLUME_SEQUENCE_REPEAT, "REPEAT", 0, "Repeat", "Cycle the frames in the sequence"},
618 "PING_PONG",
619 0,
620 "Ping-Pong",
621 "Repeat the frames, reversing the playback direction every other cycle"},
622 {0, nullptr, 0, nullptr, nullptr},
623 };
624
625 prop = RNA_def_property(srna, "sequence_mode", PROP_ENUM, PROP_NONE);
627 RNA_def_property_enum_items(prop, sequence_mode_items);
628 RNA_def_property_ui_text(prop, "Sequence Mode", "Sequence playback mode");
630 RNA_def_property_update(prop, 0, "rna_Volume_update_filepath");
631
632 /* Grids */
633 prop = RNA_def_property(srna, "grids", PROP_COLLECTION, PROP_NONE);
634 RNA_def_property_struct_type(prop, "VolumeGrid");
635 RNA_def_property_ui_text(prop, "Grids", "3D volume grids");
637 "rna_Volume_grids_begin",
638 "rna_Volume_grids_next",
639 "rna_Volume_grids_end",
640 "rna_Volume_grids_get",
641 "rna_Volume_grids_length",
642 nullptr,
643 nullptr,
644 nullptr);
645 rna_def_volume_grids(brna, prop);
646
647 /* Materials */
648 prop = RNA_def_property(srna, "materials", PROP_COLLECTION, PROP_NONE);
649 RNA_def_property_collection_sdna(prop, nullptr, "mat", "totcol");
650 RNA_def_property_struct_type(prop, "Material");
651 RNA_def_property_ui_text(prop, "Materials", "");
652 RNA_def_property_srna(prop, "IDMaterials"); /* see rna_ID.cc */
654 nullptr,
655 nullptr,
656 nullptr,
657 nullptr,
658 nullptr,
659 nullptr,
660 nullptr,
661 "rna_IDMaterials_assign_int");
662
663 /* Display */
664 prop = RNA_def_property(srna, "display", PROP_POINTER, PROP_NONE);
665 RNA_def_property_pointer_sdna(prop, nullptr, "display");
666 RNA_def_property_struct_type(prop, "VolumeDisplay");
667 RNA_def_property_ui_text(prop, "Display", "Volume display settings for 3D viewport");
668
669 /* Render */
670 prop = RNA_def_property(srna, "render", PROP_POINTER, PROP_NONE);
671 RNA_def_property_pointer_sdna(prop, nullptr, "render");
672 RNA_def_property_struct_type(prop, "VolumeRender");
673 RNA_def_property_ui_text(prop, "Render", "Volume render settings for 3D viewport");
674
675 /* Velocity. */
676 prop = RNA_def_property(srna, "velocity_grid", PROP_STRING, PROP_NONE);
677 RNA_def_property_string_sdna(prop, nullptr, "velocity_grid");
678 RNA_def_property_string_funcs(prop, nullptr, nullptr, "rna_Volume_velocity_grid_set");
680 prop,
681 "Velocity Grid",
682 "Name of the velocity field, or the base name if the velocity is split into multiple grids");
683
684 prop = RNA_def_property(srna, "velocity_unit", PROP_ENUM, PROP_NONE);
685 RNA_def_property_enum_sdna(prop, nullptr, "velocity_unit");
688 prop,
689 "Velocity Unit",
690 "Define how the velocity vectors are interpreted with regard to time, 'frame' means "
691 "the delta time is 1 frame, 'second' means the delta time is 1 / FPS");
694
695 prop = RNA_def_property(srna, "velocity_scale", PROP_FLOAT, PROP_NONE);
696 RNA_def_property_float_sdna(prop, nullptr, "velocity_scale");
697 RNA_def_property_range(prop, 0.0f, FLT_MAX);
698 RNA_def_property_ui_text(prop, "Velocity Scale", "Factor to control the amount of motion blur");
699
700 /* Scalar grids for velocity. */
701 prop = RNA_def_property(srna, "velocity_x_grid", PROP_STRING, PROP_NONE);
702 RNA_def_property_string_sdna(prop, nullptr, "runtime->velocity_x_grid");
705 "Velocity X Grid",
706 "Name of the grid for the X axis component of the velocity field if it "
707 "was split into multiple grids");
708
709 prop = RNA_def_property(srna, "velocity_y_grid", PROP_STRING, PROP_NONE);
710 RNA_def_property_string_sdna(prop, nullptr, "runtime->velocity_y_grid");
713 "Velocity Y Grid",
714 "Name of the grid for the Y axis component of the velocity field if it "
715 "was split into multiple grids");
716
717 prop = RNA_def_property(srna, "velocity_z_grid", PROP_STRING, PROP_NONE);
718 RNA_def_property_string_sdna(prop, nullptr, "runtime->velocity_z_grid");
721 "Velocity Z Grid",
722 "Name of the grid for the Z axis component of the velocity field if it "
723 "was split into multiple grids");
724
725 /* Common */
727}
728
730{
734 rna_def_volume(brna);
735}
736
737#endif
Volume data-block.
bool BKE_volume_is_loaded(const Volume *volume)
int BKE_volume_num_grids(const Volume *volume)
bool BKE_volume_save(const Volume *volume, const Main *bmain, ReportList *reports, const char *filepath)
bool BKE_volume_load(const Volume *volume, const Main *bmain)
const char * BKE_volume_grids_frame_filepath(const Volume *volume)
const blender::bke::VolumeGridData * BKE_volume_grid_get(const Volume *volume, int grid_index)
void BKE_volume_unload(Volume *volume)
const char * BKE_volume_grids_error_msg(const Volume *volume)
bool BKE_volume_set_velocity_grid_by_name(Volume *volume, blender::StringRef base_name)
@ VOLUME_GRID_VECTOR_FLOAT
@ VOLUME_GRID_MASK
@ VOLUME_GRID_VECTOR_DOUBLE
@ VOLUME_GRID_VECTOR_INT
@ VOLUME_GRID_UNKNOWN
@ VOLUME_GRID_DOUBLE
@ VOLUME_GRID_BOOLEAN
@ VOLUME_GRID_INT
@ VOLUME_GRID_INT64
@ VOLUME_GRID_POINTS
@ VOLUME_GRID_FLOAT
MINLINE int max_ii(int a, int b)
MINLINE int clamp_i(int value, int min, int max)
#define BLI_STR_UTF8_MULTIPLICATION_SIGN
#define BLT_I18NCONTEXT_ID_VOLUME
#define BLT_I18NCONTEXT_UNIT
void DEG_id_tag_update(ID *id, unsigned int flags)
void DEG_relations_tag_update(Main *bmain)
@ ID_RECALC_SYNC_TO_EVAL
Definition DNA_ID.h:1026
#define MAXFRAMEF
#define MINAFRAMEF
@ VOLUME_SPACE_WORLD
@ VOLUME_SPACE_OBJECT
@ VOLUME_WIREFRAME_NONE
@ VOLUME_WIREFRAME_BOXES
@ VOLUME_WIREFRAME_POINTS
@ VOLUME_WIREFRAME_BOUNDS
@ VOLUME_DISPLAY_INTERP_CLOSEST
@ VOLUME_DISPLAY_INTERP_LINEAR
@ VOLUME_DISPLAY_INTERP_CUBIC
@ VOLUME_AXIS_SLICE_SINGLE
@ VOLUME_SEQUENCE_REPEAT
@ VOLUME_SEQUENCE_CLIP
@ VOLUME_SEQUENCE_EXTEND
@ VOLUME_SEQUENCE_PING_PONG
@ VOLUME_SLICE_AXIS_Y
@ VOLUME_SLICE_AXIS_X
@ VOLUME_SLICE_AXIS_AUTO
@ VOLUME_SLICE_AXIS_Z
@ VOLUME_PRECISION_FULL
@ VOLUME_PRECISION_VARIABLE
@ VOLUME_PRECISION_HALF
@ VOLUME_WIREFRAME_COARSE
@ VOLUME_WIREFRAME_FINE
@ PARM_REQUIRED
Definition RNA_types.hh:511
@ FUNC_USE_REPORTS
Definition RNA_types.hh:805
@ FUNC_USE_MAIN
Definition RNA_types.hh:803
@ FUNC_USE_SELF_ID
Definition RNA_types.hh:792
@ PROP_FLOAT
Definition RNA_types.hh:152
@ PROP_BOOLEAN
Definition RNA_types.hh:150
@ PROP_ENUM
Definition RNA_types.hh:154
@ PROP_INT
Definition RNA_types.hh:151
@ PROP_STRING
Definition RNA_types.hh:153
@ PROP_POINTER
Definition RNA_types.hh:155
@ PROP_COLLECTION
Definition RNA_types.hh:156
PropertyFlag
Definition RNA_types.hh:286
@ PROP_ANIMATABLE
Definition RNA_types.hh:305
@ PROP_PATH_SUPPORTS_BLEND_RELATIVE
Definition RNA_types.hh:430
@ PROP_EDITABLE
Definition RNA_types.hh:292
@ PROP_TIME
Definition RNA_types.hh:241
@ PROP_MATRIX
Definition RNA_types.hh:253
@ PROP_DISTANCE
Definition RNA_types.hh:244
@ PROP_NONE
Definition RNA_types.hh:221
@ PROP_FACTOR
Definition RNA_types.hh:239
@ PROP_UNSIGNED
Definition RNA_types.hh:237
@ PROP_FILEPATH
Definition RNA_types.hh:224
#define NC_GEOM
Definition WM_types.hh:390
#define ND_DATA
Definition WM_types.hh:506
ReportList * reports
Definition WM_types.hh:1025
float4x4 get_transform_matrix(const VolumeGridData &grid)
std::string get_name(const VolumeGridData &grid)
int get_channels_num(VolumeGridType type)
std::string error_message_from_load(const VolumeGridData &grid)
void load(const VolumeGridData &grid)
VolumeGridType get_type(const VolumeGridData &grid)
bool is_loaded(const VolumeGridData &grid)
MatBase< float, 4, 4 > float4x4
PointerRNA RNA_pointer_create_with_parent(const PointerRNA &parent, StructRNA *type, void *data)
void rna_def_animdata_common(StructRNA *srna)
const EnumPropertyItem rna_enum_velocity_unit_items[]
void RNA_def_property_boolean_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t booleanbit)
void RNA_def_struct_name_property(StructRNA *srna, PropertyRNA *prop)
void RNA_def_property_pointer_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_struct_path_func(StructRNA *srna, const char *path)
void RNA_def_property_string_funcs(PropertyRNA *prop, const char *get, const char *length, const char *set)
void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret)
void RNA_def_property_float_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
void RNA_def_property_string_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_property_srna(PropertyRNA *prop, const char *type)
void RNA_def_property_collection_funcs(PropertyRNA *prop, const char *begin, const char *next, const char *end, const char *get, const char *length, const char *lookupint, const char *lookupstring, const char *assignint)
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
void RNA_def_property_boolean_funcs(PropertyRNA *prop, const char *get, const char *set)
void RNA_def_property_multi_array(PropertyRNA *prop, int dimension, const int length[])
void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item)
void RNA_def_struct_sdna(StructRNA *srna, const char *structname)
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier, const char *call)
void RNA_def_property_range(PropertyRNA *prop, double min, double max)
void RNA_def_property_struct_type(PropertyRNA *prop, const char *type)
void RNA_def_property_collection_sdna(PropertyRNA *prop, const char *structname, const char *propname, const char *lengthpropname)
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *func)
const int rna_matrix_dimsize_4x4[]
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype)
void RNA_def_property_enum_funcs(PropertyRNA *prop, const char *get, const char *set, const char *item)
StructRNA * RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
void RNA_def_function_flag(FunctionRNA *func, int flag)
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_def_property_enum_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_property_int_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
PropertyRNA * RNA_def_string_file_path(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
void RNA_def_struct_ui_icon(StructRNA *srna, int icon)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
void RNA_def_property_translation_context(PropertyRNA *prop, const char *context)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_def_property_float_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_property_ui_range(PropertyRNA *prop, double min, double max, double step, int precision)
void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
static const EnumPropertyItem space_items[]
static void rna_def_volume_display(BlenderRNA *brna)
static void rna_def_volume(BlenderRNA *brna)
const EnumPropertyItem rna_enum_volume_grid_data_type_items[]
Definition rna_volume.cc:25
static void rna_def_volume_render(BlenderRNA *brna)
static void rna_def_volume_grids(BlenderRNA *brna, PropertyRNA *cprop)
static void rna_def_volume_grid(BlenderRNA *brna)
void RNA_def_volume(BlenderRNA *brna)
#define min(a, b)
Definition sort.cc:36
#define FLT_MAX
Definition stdcycles.h:14
union CollectionPropertyIterator::@251313231040372062304153161337117373343066046335 internal
Definition DNA_ID.h:404
max
Definition text_draw.cc:251
void WM_main_add_notifier(uint type, void *reference)
void WM_global_reportf(eReportType type, const char *format,...)
PointerRNA * ptr
Definition wm_files.cc:4227