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