Blender V5.0
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, "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 "BLI_math_base.h"
55
56# include "BKE_volume.hh"
57
58# include "DEG_depsgraph.hh"
59# include "DEG_depsgraph_build.hh"
60
61# include "WM_api.hh"
62# include "WM_types.hh"
63
64static std::optional<std::string> rna_VolumeRender_path(const PointerRNA * /*ptr*/)
65{
66 return "render";
67}
68
69static std::optional<std::string> rna_VolumeDisplay_path(const PointerRNA * /*ptr*/)
70{
71 return "display";
72}
73
74/* Updates */
75
76static void rna_Volume_update_display(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
77{
78 Volume *volume = (Volume *)ptr->owner_id;
80}
81
82static void rna_Volume_update_filepath(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
83{
84 Volume *volume = (Volume *)ptr->owner_id;
85 BKE_volume_unload(volume);
88}
89
90static void rna_Volume_update_is_sequence(Main *bmain, Scene *scene, PointerRNA *ptr)
91{
92 rna_Volume_update_filepath(bmain, scene, ptr);
94}
95
96static void rna_Volume_velocity_grid_set(PointerRNA *ptr, const char *value)
97{
98 Volume *volume = (Volume *)ptr->data;
99 if (!BKE_volume_set_velocity_grid_by_name(volume, value)) {
100 WM_global_reportf(RPT_ERROR, "Could not find grid with name %s", value);
101 }
103}
104
105/* Grid */
106
107static void rna_VolumeGrid_name_get(PointerRNA *ptr, char *value)
108{
109 auto *grid = static_cast<const blender::bke::VolumeGridData *>(ptr->data);
110 strcpy(value, blender::bke::volume_grid::get_name(*grid).c_str());
111}
112
113static int rna_VolumeGrid_name_length(PointerRNA *ptr)
114{
115 auto *grid = static_cast<const blender::bke::VolumeGridData *>(ptr->data);
116 return blender::bke::volume_grid::get_name(*grid).size();
117}
118
119static int rna_VolumeGrid_data_type_get(PointerRNA *ptr)
120{
121 const auto *grid = static_cast<const blender::bke::VolumeGridData *>(ptr->data);
123}
124
125static int rna_VolumeGrid_channels_get(PointerRNA *ptr)
126{
127 const auto *grid = static_cast<const blender::bke::VolumeGridData *>(ptr->data);
129}
130
131static void rna_VolumeGrid_matrix_object_get(PointerRNA *ptr, float *value)
132{
133 auto *grid = static_cast<const blender::bke::VolumeGridData *>(ptr->data);
135}
136
137static bool rna_VolumeGrid_is_loaded_get(PointerRNA *ptr)
138{
139 auto *grid = static_cast<const blender::bke::VolumeGridData *>(ptr->data);
141}
142
143static bool rna_VolumeGrid_load(ID * /*id*/, DummyVolumeGridData *dummy_grid)
144{
145 auto *grid = reinterpret_cast<const blender::bke::VolumeGridData *>(dummy_grid);
148}
149
150static void rna_VolumeGrid_unload(ID * /*id*/, DummyVolumeGridData * /*dummy_grid*/)
151{
152 /* This is handled transparently. The grid is unloaded automatically if it's not used and the
153 * memory cache is full. */
154}
155
156/* Grids Iterator */
157
158static void rna_Volume_grids_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
159{
160 Volume *volume = static_cast<Volume *>(ptr->data);
161 int num_grids = BKE_volume_num_grids(volume);
162 iter->internal.count.ptr = volume;
163 iter->internal.count.item = 0;
164 iter->valid = (iter->internal.count.item < num_grids);
165}
166
167static void rna_Volume_grids_next(CollectionPropertyIterator *iter)
168{
169 Volume *volume = static_cast<Volume *>(iter->internal.count.ptr);
170 int num_grids = BKE_volume_num_grids(volume);
171 iter->internal.count.item++;
172 iter->valid = (iter->internal.count.item < num_grids);
173}
174
175static void rna_Volume_grids_end(CollectionPropertyIterator * /*iter*/) {}
176
177static PointerRNA rna_Volume_grids_get(CollectionPropertyIterator *iter)
178{
179 Volume *volume = static_cast<Volume *>(iter->internal.count.ptr);
180 const blender::bke::VolumeGridData *grid = BKE_volume_grid_get(volume,
181 iter->internal.count.item);
182 return RNA_pointer_create_with_parent(iter->parent, &RNA_VolumeGrid, (void *)grid);
183}
184
185static int rna_Volume_grids_length(PointerRNA *ptr)
186{
187 Volume *volume = static_cast<Volume *>(ptr->data);
188 return BKE_volume_num_grids(volume);
189}
190
191/* Active Grid */
192
193static void rna_VolumeGrids_active_index_range(
194 PointerRNA *ptr, int *min, int *max, int * /*softmin*/, int * /*softmax*/)
195{
196 Volume *volume = (Volume *)ptr->data;
197 int num_grids = BKE_volume_num_grids(volume);
198
199 *min = 0;
200 *max = max_ii(0, num_grids - 1);
201}
202
203static int rna_VolumeGrids_active_index_get(PointerRNA *ptr)
204{
205 Volume *volume = (Volume *)ptr->data;
206 int num_grids = BKE_volume_num_grids(volume);
207 return clamp_i(volume->active_grid, 0, max_ii(num_grids - 1, 0));
208}
209
210static void rna_VolumeGrids_active_index_set(PointerRNA *ptr, int value)
211{
212 Volume *volume = (Volume *)ptr->data;
213 volume->active_grid = value;
214}
215
216/* Loading */
217
218static bool rna_VolumeGrids_is_loaded_get(PointerRNA *ptr)
219{
220 Volume *volume = (Volume *)ptr->data;
221 return BKE_volume_is_loaded(volume);
222}
223
224/* Error Message */
225
226static void rna_VolumeGrids_error_message_get(PointerRNA *ptr, char *value)
227{
228 Volume *volume = (Volume *)ptr->data;
229 strcpy(value, BKE_volume_grids_error_msg(volume));
230}
231
232static int rna_VolumeGrids_error_message_length(PointerRNA *ptr)
233{
234 Volume *volume = (Volume *)ptr->data;
235 return strlen(BKE_volume_grids_error_msg(volume));
236}
237
238/* Frame Filepath */
239static void rna_VolumeGrids_frame_filepath_get(PointerRNA *ptr, char *value)
240{
241 Volume *volume = (Volume *)ptr->data;
242 strcpy(value, BKE_volume_grids_frame_filepath(volume));
243}
244
245static int rna_VolumeGrids_frame_filepath_length(PointerRNA *ptr)
246{
247 Volume *volume = (Volume *)ptr->data;
248 return strlen(BKE_volume_grids_frame_filepath(volume));
249}
250
251static bool rna_Volume_load(Volume *volume, Main *bmain)
252{
253 return BKE_volume_load(volume, bmain);
254}
255
256static bool rna_Volume_save(Volume *volume, Main *bmain, ReportList *reports, const char *filepath)
257{
258 return BKE_volume_save(volume, bmain, reports, filepath);
259}
260
261#else
262
264{
265 StructRNA *srna;
266 PropertyRNA *prop;
267
268 srna = RNA_def_struct(brna, "VolumeGrid", nullptr);
269 RNA_def_struct_sdna(srna, "DummyVolumeGridData");
270 RNA_def_struct_ui_text(srna, "Volume Grid", "3D volume grid");
271 RNA_def_struct_ui_icon(srna, ICON_VOLUME_DATA);
272
273 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
276 prop, "rna_VolumeGrid_name_get", "rna_VolumeGrid_name_length", nullptr);
277 RNA_def_property_ui_text(prop, "Name", "Volume grid name");
279
280 prop = RNA_def_property(srna, "data_type", PROP_ENUM, PROP_NONE);
282 RNA_def_property_enum_funcs(prop, "rna_VolumeGrid_data_type_get", nullptr, nullptr);
284 RNA_def_property_ui_text(prop, "Data Type", "Data type of voxel values");
286
287 prop = RNA_def_property(srna, "channels", PROP_INT, PROP_UNSIGNED);
289 RNA_def_property_int_funcs(prop, "rna_VolumeGrid_channels_get", nullptr, nullptr);
290 RNA_def_property_ui_text(prop, "Channels", "Number of dimensions of the grid data type");
291
292 prop = RNA_def_property(srna, "matrix_object", PROP_FLOAT, PROP_MATRIX);
295 RNA_def_property_float_funcs(prop, "rna_VolumeGrid_matrix_object_get", nullptr, nullptr);
297 prop, "Matrix Object", "Transformation matrix from voxel index to object space");
298
299 prop = RNA_def_property(srna, "is_loaded", PROP_BOOLEAN, PROP_NONE);
301 RNA_def_property_boolean_funcs(prop, "rna_VolumeGrid_is_loaded_get", nullptr);
302 RNA_def_property_ui_text(prop, "Is Loaded", "Grid tree is loaded in memory");
303 /* API */
304 FunctionRNA *func;
305 PropertyRNA *parm;
306
307 func = RNA_def_function(srna, "load", "rna_VolumeGrid_load");
308 RNA_def_function_ui_description(func, "Load grid tree from file");
310 parm = RNA_def_boolean(func, "success", false, "", "True if grid tree was successfully loaded");
311 RNA_def_function_return(func, parm);
312
313 func = RNA_def_function(srna, "unload", "rna_VolumeGrid_unload");
316 func, "Unload grid tree and voxel data from memory, leaving only metadata");
317}
318
320{
321 StructRNA *srna;
322 PropertyRNA *prop;
323
324 RNA_def_property_srna(cprop, "VolumeGrids");
325 srna = RNA_def_struct(brna, "VolumeGrids", nullptr);
326 RNA_def_struct_sdna(srna, "Volume");
327 RNA_def_struct_ui_text(srna, "Volume Grids", "3D volume grids");
328
329 prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
331 "rna_VolumeGrids_active_index_get",
332 "rna_VolumeGrids_active_index_set",
333 "rna_VolumeGrids_active_index_range");
334 RNA_def_property_ui_text(prop, "Active Grid Index", "Index of active volume grid");
335 RNA_def_property_update(prop, 0, "rna_Volume_update_display");
336
337 prop = RNA_def_property(srna, "error_message", PROP_STRING, PROP_NONE);
340 prop, "rna_VolumeGrids_error_message_get", "rna_VolumeGrids_error_message_length", nullptr);
342 prop, "Error Message", "If loading grids failed, error message with details");
343
344 prop = RNA_def_property(srna, "is_loaded", PROP_BOOLEAN, PROP_NONE);
346 RNA_def_property_boolean_funcs(prop, "rna_VolumeGrids_is_loaded_get", nullptr);
347 RNA_def_property_ui_text(prop, "Is Loaded", "List of grids and metadata are loaded in memory");
348
349 prop = RNA_def_property(srna, "frame", PROP_INT, PROP_NONE);
350 RNA_def_property_int_sdna(prop, nullptr, "runtime->frame");
353 "Frame",
354 "Frame number that volume grids will be loaded at, based on scene time "
355 "and volume parameters");
356
357 prop = RNA_def_property(srna, "frame_filepath", PROP_STRING, PROP_FILEPATH);
361 "rna_VolumeGrids_frame_filepath_get",
362 "rna_VolumeGrids_frame_filepath_length",
363 nullptr);
364
366 "Frame File Path",
367 "Volume file used for loading the volume at the current frame. Empty "
368 "if the volume has not be loaded or the frame only exists in memory.");
369
370 /* API */
371 FunctionRNA *func;
372 PropertyRNA *parm;
373
374 func = RNA_def_function(srna, "load", "rna_Volume_load");
375 RNA_def_function_ui_description(func, "Load list of grids and metadata from file");
377 parm = RNA_def_boolean(func, "success", false, "", "True if grid list was successfully loaded");
378 RNA_def_function_return(func, parm);
379
380 func = RNA_def_function(srna, "unload", "BKE_volume_unload");
381 RNA_def_function_ui_description(func, "Unload all grid and voxel data from memory");
382
383 func = RNA_def_function(srna, "save", "rna_Volume_save");
384 RNA_def_function_ui_description(func, "Save grids and metadata to file");
386 parm = RNA_def_string_file_path(func, "filepath", nullptr, 0, "", "File path to save to");
388 parm = RNA_def_boolean(func, "success", false, "", "True if grid list was successfully loaded");
389 RNA_def_function_return(func, parm);
390}
391
393{
394 StructRNA *srna;
395 PropertyRNA *prop;
396
397 srna = RNA_def_struct(brna, "VolumeDisplay", nullptr);
398 RNA_def_struct_ui_text(srna, "Volume Display", "Volume object display settings for 3D viewport");
399 RNA_def_struct_sdna(srna, "VolumeDisplay");
400 RNA_def_struct_path_func(srna, "rna_VolumeDisplay_path");
401
402 prop = RNA_def_property(srna, "density", PROP_FLOAT, PROP_NONE);
404 RNA_def_property_range(prop, 0.00001, FLT_MAX);
405 RNA_def_property_ui_range(prop, 0.1, 100.0, 1, 3);
406 RNA_def_property_ui_text(prop, "Density", "Thickness of volume display in the viewport");
407 RNA_def_property_update(prop, 0, "rna_Volume_update_display");
408
409 static const EnumPropertyItem wireframe_type_items[] = {
410 {VOLUME_WIREFRAME_NONE, "NONE", 0, "None", "Don't display volume in wireframe mode"},
412 "BOUNDS",
413 0,
414 "Bounds",
415 "Display single bounding box for the entire grid"},
417 "BOXES",
418 0,
419 "Boxes",
420 "Display bounding boxes for nodes in the volume tree"},
422 "POINTS",
423 0,
424 "Points",
425 "Display points for nodes in the volume tree"},
426 {0, nullptr, 0, nullptr, nullptr},
427 };
428
429 static const EnumPropertyItem wireframe_detail_items[] = {
431 "COARSE",
432 0,
433 "Coarse",
434 "Display one box or point for each intermediate tree node"},
436 "FINE",
437 0,
438 "Fine",
439 "Display box for each leaf node containing 8" BLI_STR_UTF8_MULTIPLICATION_SIGN "8 voxels"},
440 {0, nullptr, 0, nullptr, nullptr},
441 };
442
443 static const EnumPropertyItem interpolation_method_items[] = {
444 {VOLUME_DISPLAY_INTERP_LINEAR, "LINEAR", 0, "Linear", "Good smoothness and speed"},
446 "CUBIC",
447 0,
448 "Cubic",
449 "Smoothed high quality interpolation, but slower"},
450 {VOLUME_DISPLAY_INTERP_CLOSEST, "CLOSEST", 0, "Closest", "No interpolation"},
451 {0, nullptr, 0, nullptr, nullptr},
452 };
453
454 static const EnumPropertyItem axis_slice_position_items[] = {
456 "AUTO",
457 0,
458 "Auto",
459 "Adjust slice direction according to the view direction"},
460 {VOLUME_SLICE_AXIS_X, "X", 0, "X", "Slice along the X axis"},
461 {VOLUME_SLICE_AXIS_Y, "Y", 0, "Y", "Slice along the Y axis"},
462 {VOLUME_SLICE_AXIS_Z, "Z", 0, "Z", "Slice along the Z axis"},
463 {0, nullptr, 0, nullptr, nullptr},
464 };
465
466 prop = RNA_def_property(srna, "wireframe_type", PROP_ENUM, PROP_NONE);
467 RNA_def_property_enum_items(prop, wireframe_type_items);
468 RNA_def_property_ui_text(prop, "Wireframe", "Type of wireframe display");
469 RNA_def_property_update(prop, 0, "rna_Volume_update_display");
470
471 prop = RNA_def_property(srna, "wireframe_detail", PROP_ENUM, PROP_NONE);
472 RNA_def_property_enum_items(prop, wireframe_detail_items);
473 RNA_def_property_ui_text(prop, "Wireframe Detail", "Amount of detail for wireframe display");
474 RNA_def_property_update(prop, 0, "rna_Volume_update_display");
475
476 prop = RNA_def_property(srna, "interpolation_method", PROP_ENUM, PROP_NONE);
477 RNA_def_property_enum_items(prop, interpolation_method_items);
479 prop, "Interpolation", "Interpolation method to use for volumes in solid mode");
480 RNA_def_property_update(prop, 0, "rna_Volume_update_display");
481
482 prop = RNA_def_property(srna, "use_slice", PROP_BOOLEAN, PROP_NONE);
483 RNA_def_property_boolean_sdna(prop, nullptr, "axis_slice_method", VOLUME_AXIS_SLICE_SINGLE);
484 RNA_def_property_ui_text(prop, "Slice", "Perform a single slice of the domain object");
485 RNA_def_property_update(prop, 0, "rna_Volume_update_display");
486
487 prop = RNA_def_property(srna, "slice_axis", PROP_ENUM, PROP_NONE);
488 RNA_def_property_enum_items(prop, axis_slice_position_items);
489 RNA_def_property_ui_text(prop, "Axis", "");
490 RNA_def_property_update(prop, 0, "rna_Volume_update_display");
491
492 prop = RNA_def_property(srna, "slice_depth", PROP_FLOAT, PROP_FACTOR);
493 RNA_def_property_range(prop, 0.0, 1.0);
494 RNA_def_property_ui_range(prop, 0.0, 1.0, 0.1, 3);
495 RNA_def_property_ui_text(prop, "Position", "Position of the slice");
496 RNA_def_property_update(prop, 0, "rna_Volume_update_display");
497}
498
500{
501 StructRNA *srna;
502 PropertyRNA *prop;
503
504 srna = RNA_def_struct(brna, "VolumeRender", nullptr);
505 RNA_def_struct_ui_text(srna, "Volume Render", "Volume object render settings");
506 RNA_def_struct_sdna(srna, "VolumeRender");
507 RNA_def_struct_path_func(srna, "rna_VolumeRender_path");
508
509 static const EnumPropertyItem precision_items[] = {
510 {VOLUME_PRECISION_FULL, "FULL", 0, "Full", "Use 32-bit floating-point numbers for all data"},
511 {VOLUME_PRECISION_HALF, "HALF", 0, "Half", "Use 16-bit floating-point numbers for all data"},
512 {VOLUME_PRECISION_VARIABLE, "VARIABLE", 0, "Variable", "Use variable bit quantization"},
513 {0, nullptr, 0, nullptr, nullptr},
514 };
515
516 prop = RNA_def_property(srna, "precision", PROP_ENUM, PROP_NONE);
517 RNA_def_property_enum_items(prop, precision_items);
519 "Precision",
520 "Specify volume data precision. Lower values reduce memory consumption "
521 "at the cost of detail.");
522 RNA_def_property_update(prop, 0, "rna_Volume_update_display");
523
524 static const EnumPropertyItem space_items[] = {
526 "OBJECT",
527 0,
528 "Object",
529 "Keep volume opacity and detail the same regardless of object scale"},
531 "WORLD",
532 0,
533 "World",
534 "Specify volume step size and density in world space"},
535 {0, nullptr, 0, nullptr, nullptr},
536 };
537
538 prop = RNA_def_property(srna, "space", PROP_ENUM, PROP_NONE);
541 prop, "Space", "Specify volume density and step size in object or world space");
542 RNA_def_property_update(prop, 0, "rna_Volume_update_display");
543
544 prop = RNA_def_property(srna, "step_size", PROP_FLOAT, PROP_DISTANCE);
547 RNA_def_property_ui_range(prop, 0.0, 100.0, 1, 3);
549 "Step Size",
550 "Distance between volume samples. Lower values render more detail at "
551 "the cost of performance. If set to zero, the step size is "
552 "automatically determined based on voxel size.");
553 RNA_def_property_update(prop, 0, "rna_Volume_update_display");
554
555 prop = RNA_def_property(srna, "clipping", PROP_FLOAT, PROP_NONE);
556 RNA_def_property_float_sdna(prop, nullptr, "clipping");
557 RNA_def_property_range(prop, 0.0, 1.0);
558 RNA_def_property_ui_range(prop, 0.0, 1.0, 0.1, 3);
560 prop,
561 "Clipping",
562 "Value under which voxels are considered empty space to optimize rendering");
563 RNA_def_property_update(prop, 0, "rna_Volume_update_display");
564}
565
566static void rna_def_volume(BlenderRNA *brna)
567{
568 StructRNA *srna;
569 PropertyRNA *prop;
570
571 srna = RNA_def_struct(brna, "Volume", "ID");
572 RNA_def_struct_ui_text(srna, "Volume", "Volume data-block for 3D volume grids");
573 RNA_def_struct_ui_icon(srna, ICON_VOLUME_DATA);
574
575 /* File */
576 prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH);
579 RNA_def_property_ui_text(prop, "File Path", "Volume file used by this Volume data-block");
580 RNA_def_property_update(prop, 0, "rna_Volume_update_filepath");
581
582 prop = RNA_def_property(srna, "packed_file", PROP_POINTER, PROP_NONE);
583 RNA_def_property_pointer_sdna(prop, nullptr, "packedfile");
584 RNA_def_property_ui_text(prop, "Packed File", "");
585
586 /* Sequence */
587 prop = RNA_def_property(srna, "is_sequence", PROP_BOOLEAN, PROP_NONE);
590 prop, "Sequence", "Whether the cache is separated in a series of files");
591 RNA_def_property_update(prop, 0, "rna_Volume_update_is_sequence");
592
593 prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_TIME);
597 prop, "Start Frame", "Global starting frame of the sequence, assuming first has a #1");
598 RNA_def_property_update(prop, 0, "rna_Volume_update_filepath");
599
600 prop = RNA_def_property(srna, "frame_duration", PROP_INT, PROP_NONE);
603 RNA_def_property_ui_text(prop, "Frames", "Number of frames of the sequence to use");
604 RNA_def_property_update(prop, 0, "rna_Volume_update_filepath");
605
606 prop = RNA_def_property(srna, "frame_offset", PROP_INT, PROP_NONE);
608 prop, "Offset", "Offset the number of the frame to use in the animation");
609 RNA_def_property_update(prop, 0, "rna_Volume_update_filepath");
610
611 static const EnumPropertyItem sequence_mode_items[] = {
612 {VOLUME_SEQUENCE_CLIP, "CLIP", 0, "Clip", "Hide frames outside the specified frame range"},
614 "EXTEND",
615 0,
616 "Extend",
617 "Repeat the start frame before, and the end frame after the frame range"},
618 {VOLUME_SEQUENCE_REPEAT, "REPEAT", 0, "Repeat", "Cycle the frames in the sequence"},
620 "PING_PONG",
621 0,
622 "Ping-Pong",
623 "Repeat the frames, reversing the playback direction every other cycle"},
624 {0, nullptr, 0, nullptr, nullptr},
625 };
626
627 prop = RNA_def_property(srna, "sequence_mode", PROP_ENUM, PROP_NONE);
629 RNA_def_property_enum_items(prop, sequence_mode_items);
630 RNA_def_property_ui_text(prop, "Sequence Mode", "Sequence playback mode");
632 RNA_def_property_update(prop, 0, "rna_Volume_update_filepath");
633
634 /* Grids */
635 prop = RNA_def_property(srna, "grids", PROP_COLLECTION, PROP_NONE);
636 RNA_def_property_struct_type(prop, "VolumeGrid");
637 RNA_def_property_ui_text(prop, "Grids", "3D volume grids");
639 "rna_Volume_grids_begin",
640 "rna_Volume_grids_next",
641 "rna_Volume_grids_end",
642 "rna_Volume_grids_get",
643 "rna_Volume_grids_length",
644 nullptr,
645 nullptr,
646 nullptr);
647 rna_def_volume_grids(brna, prop);
648
649 /* Materials */
650 prop = RNA_def_property(srna, "materials", PROP_COLLECTION, PROP_NONE);
651 RNA_def_property_collection_sdna(prop, nullptr, "mat", "totcol");
652 RNA_def_property_struct_type(prop, "Material");
653 RNA_def_property_ui_text(prop, "Materials", "");
654 RNA_def_property_srna(prop, "IDMaterials"); /* see rna_ID.cc */
656 nullptr,
657 nullptr,
658 nullptr,
659 nullptr,
660 nullptr,
661 nullptr,
662 nullptr,
663 "rna_IDMaterials_assign_int");
664
665 /* Display */
666 prop = RNA_def_property(srna, "display", PROP_POINTER, PROP_NONE);
667 RNA_def_property_pointer_sdna(prop, nullptr, "display");
668 RNA_def_property_struct_type(prop, "VolumeDisplay");
669 RNA_def_property_ui_text(prop, "Display", "Volume display settings for 3D viewport");
670
671 /* Render */
672 prop = RNA_def_property(srna, "render", PROP_POINTER, PROP_NONE);
673 RNA_def_property_pointer_sdna(prop, nullptr, "render");
674 RNA_def_property_struct_type(prop, "VolumeRender");
675 RNA_def_property_ui_text(prop, "Render", "Volume render settings for 3D viewport");
676
677 /* Velocity. */
678 prop = RNA_def_property(srna, "velocity_grid", PROP_STRING, PROP_NONE);
679 RNA_def_property_string_sdna(prop, nullptr, "velocity_grid");
680 RNA_def_property_string_funcs(prop, nullptr, nullptr, "rna_Volume_velocity_grid_set");
682 prop,
683 "Velocity Grid",
684 "Name of the velocity field, or the base name if the velocity is split into multiple grids");
685
686 prop = RNA_def_property(srna, "velocity_unit", PROP_ENUM, PROP_NONE);
687 RNA_def_property_enum_sdna(prop, nullptr, "velocity_unit");
690 prop,
691 "Velocity Unit",
692 "Define how the velocity vectors are interpreted with regard to time, 'frame' means "
693 "the delta time is 1 frame, 'second' means the delta time is 1 / FPS");
696
697 prop = RNA_def_property(srna, "velocity_scale", PROP_FLOAT, PROP_NONE);
698 RNA_def_property_float_sdna(prop, nullptr, "velocity_scale");
699 RNA_def_property_range(prop, 0.0f, FLT_MAX);
700 RNA_def_property_ui_text(prop, "Velocity Scale", "Factor to control the amount of motion blur");
701
702 /* Scalar grids for velocity. */
703 prop = RNA_def_property(srna, "velocity_x_grid", PROP_STRING, PROP_NONE);
704 RNA_def_property_string_sdna(prop, nullptr, "runtime->velocity_x_grid");
707 "Velocity X Grid",
708 "Name of the grid for the X axis component of the velocity field if it "
709 "was split into multiple grids");
710
711 prop = RNA_def_property(srna, "velocity_y_grid", PROP_STRING, PROP_NONE);
712 RNA_def_property_string_sdna(prop, nullptr, "runtime->velocity_y_grid");
715 "Velocity Y Grid",
716 "Name of the grid for the Y axis component of the velocity field if it "
717 "was split into multiple grids");
718
719 prop = RNA_def_property(srna, "velocity_z_grid", PROP_STRING, PROP_NONE);
720 RNA_def_property_string_sdna(prop, nullptr, "runtime->velocity_z_grid");
723 "Velocity Z Grid",
724 "Name of the grid for the Z axis component of the velocity field if it "
725 "was split into multiple grids");
726
727 /* Common */
729}
730
732{
736 rna_def_volume(brna);
737}
738
739#endif
@ RPT_ERROR
Definition BKE_report.hh:39
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:1118
#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:545
@ FUNC_USE_REPORTS
Definition RNA_types.hh:914
@ FUNC_USE_MAIN
Definition RNA_types.hh:912
@ FUNC_USE_SELF_ID
Definition RNA_types.hh:889
@ PROP_FLOAT
Definition RNA_types.hh:164
@ PROP_BOOLEAN
Definition RNA_types.hh:162
@ PROP_ENUM
Definition RNA_types.hh:166
@ PROP_INT
Definition RNA_types.hh:163
@ PROP_STRING
Definition RNA_types.hh:165
@ PROP_POINTER
Definition RNA_types.hh:167
@ PROP_COLLECTION
Definition RNA_types.hh:168
PropertyFlag
Definition RNA_types.hh:300
@ PROP_ANIMATABLE
Definition RNA_types.hh:319
@ PROP_PATH_SUPPORTS_BLEND_RELATIVE
Definition RNA_types.hh:456
@ PROP_EDITABLE
Definition RNA_types.hh:306
@ PROP_TIME
Definition RNA_types.hh:253
@ PROP_MATRIX
Definition RNA_types.hh:265
@ PROP_DISTANCE
Definition RNA_types.hh:256
@ PROP_NONE
Definition RNA_types.hh:233
@ PROP_FACTOR
Definition RNA_types.hh:251
@ PROP_UNSIGNED
Definition RNA_types.hh:249
@ PROP_FILEPATH
Definition RNA_types.hh:236
#define NC_GEOM
Definition WM_types.hh:393
#define ND_DATA
Definition WM_types.hh:509
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::@220100362304005352221007113371015217044252346141 internal
Definition DNA_ID.h:414
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:4238