Blender V4.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
9#include <cstdlib>
10
11#include "RNA_access.hh"
12#include "RNA_define.hh"
13#include "RNA_enum_types.hh"
14
15#include "rna_internal.hh"
16
17#include "DNA_scene_types.h"
18#include "DNA_volume_types.h"
19
20#include "BKE_volume.hh"
21
22#include "BLI_math_base.h"
24
25#include "BLT_translation.hh"
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, "Float 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
52struct DummyVolumeGridData;
53
54#ifdef RNA_RUNTIME
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_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_inherit_refine(&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);
358 "rna_VolumeGrids_frame_filepath_get",
359 "rna_VolumeGrids_frame_filepath_length",
360 nullptr);
361
363 "Frame File Path",
364 "Volume file used for loading the volume at the current frame. Empty "
365 "if the volume has not be loaded or the frame only exists in memory.");
366
367 /* API */
368 FunctionRNA *func;
369 PropertyRNA *parm;
370
371 func = RNA_def_function(srna, "load", "rna_Volume_load");
372 RNA_def_function_ui_description(func, "Load list of grids and metadata from file");
374 parm = RNA_def_boolean(func, "success", false, "", "True if grid list was successfully loaded");
375 RNA_def_function_return(func, parm);
376
377 func = RNA_def_function(srna, "unload", "BKE_volume_unload");
378 RNA_def_function_ui_description(func, "Unload all grid and voxel data from memory");
379
380 func = RNA_def_function(srna, "save", "rna_Volume_save");
381 RNA_def_function_ui_description(func, "Save grids and metadata to file");
383 parm = RNA_def_string_file_path(func, "filepath", nullptr, 0, "", "File path to save to");
385 parm = RNA_def_boolean(func, "success", false, "", "True if grid list was successfully loaded");
386 RNA_def_function_return(func, parm);
387}
388
390{
391 StructRNA *srna;
392 PropertyRNA *prop;
393
394 srna = RNA_def_struct(brna, "VolumeDisplay", nullptr);
395 RNA_def_struct_ui_text(srna, "Volume Display", "Volume object display settings for 3D viewport");
396 RNA_def_struct_sdna(srna, "VolumeDisplay");
397 RNA_def_struct_path_func(srna, "rna_VolumeDisplay_path");
398
399 prop = RNA_def_property(srna, "density", PROP_FLOAT, PROP_NONE);
401 RNA_def_property_range(prop, 0.00001, FLT_MAX);
402 RNA_def_property_ui_range(prop, 0.1, 100.0, 1, 3);
403 RNA_def_property_ui_text(prop, "Density", "Thickness of volume display in the viewport");
404 RNA_def_property_update(prop, 0, "rna_Volume_update_display");
405
406 static const EnumPropertyItem wireframe_type_items[] = {
407 {VOLUME_WIREFRAME_NONE, "NONE", 0, "None", "Don't display volume in wireframe mode"},
409 "BOUNDS",
410 0,
411 "Bounds",
412 "Display single bounding box for the entire grid"},
414 "BOXES",
415 0,
416 "Boxes",
417 "Display bounding boxes for nodes in the volume tree"},
419 "POINTS",
420 0,
421 "Points",
422 "Display points for nodes in the volume tree"},
423 {0, nullptr, 0, nullptr, nullptr},
424 };
425
426 static const EnumPropertyItem wireframe_detail_items[] = {
428 "COARSE",
429 0,
430 "Coarse",
431 "Display one box or point for each intermediate tree node"},
433 "FINE",
434 0,
435 "Fine",
436 "Display box for each leaf node containing 8" BLI_STR_UTF8_MULTIPLICATION_SIGN "8 voxels"},
437 {0, nullptr, 0, nullptr, nullptr},
438 };
439
440 static const EnumPropertyItem interpolation_method_items[] = {
441 {VOLUME_DISPLAY_INTERP_LINEAR, "LINEAR", 0, "Linear", "Good smoothness and speed"},
443 "CUBIC",
444 0,
445 "Cubic",
446 "Smoothed high quality interpolation, but slower"},
447 {VOLUME_DISPLAY_INTERP_CLOSEST, "CLOSEST", 0, "Closest", "No interpolation"},
448 {0, nullptr, 0, nullptr, nullptr},
449 };
450
451 static const EnumPropertyItem axis_slice_position_items[] = {
453 "AUTO",
454 0,
455 "Auto",
456 "Adjust slice direction according to the view direction"},
457 {VOLUME_SLICE_AXIS_X, "X", 0, "X", "Slice along the X axis"},
458 {VOLUME_SLICE_AXIS_Y, "Y", 0, "Y", "Slice along the Y axis"},
459 {VOLUME_SLICE_AXIS_Z, "Z", 0, "Z", "Slice along the Z axis"},
460 {0, nullptr, 0, nullptr, nullptr},
461 };
462
463 prop = RNA_def_property(srna, "wireframe_type", PROP_ENUM, PROP_NONE);
464 RNA_def_property_enum_items(prop, wireframe_type_items);
465 RNA_def_property_ui_text(prop, "Wireframe", "Type of wireframe display");
466 RNA_def_property_update(prop, 0, "rna_Volume_update_display");
467
468 prop = RNA_def_property(srna, "wireframe_detail", PROP_ENUM, PROP_NONE);
469 RNA_def_property_enum_items(prop, wireframe_detail_items);
470 RNA_def_property_ui_text(prop, "Wireframe Detail", "Amount of detail for wireframe display");
471 RNA_def_property_update(prop, 0, "rna_Volume_update_display");
472
473 prop = RNA_def_property(srna, "interpolation_method", PROP_ENUM, PROP_NONE);
474 RNA_def_property_enum_items(prop, interpolation_method_items);
476 prop, "Interpolation", "Interpolation method to use for volumes in solid mode");
477 RNA_def_property_update(prop, 0, "rna_Volume_update_display");
478
479 prop = RNA_def_property(srna, "use_slice", PROP_BOOLEAN, PROP_NONE);
480 RNA_def_property_boolean_sdna(prop, nullptr, "axis_slice_method", VOLUME_AXIS_SLICE_SINGLE);
481 RNA_def_property_ui_text(prop, "Slice", "Perform a single slice of the domain object");
482 RNA_def_property_update(prop, 0, "rna_Volume_update_display");
483
484 prop = RNA_def_property(srna, "slice_axis", PROP_ENUM, PROP_NONE);
485 RNA_def_property_enum_items(prop, axis_slice_position_items);
486 RNA_def_property_ui_text(prop, "Axis", "");
487 RNA_def_property_update(prop, 0, "rna_Volume_update_display");
488
489 prop = RNA_def_property(srna, "slice_depth", PROP_FLOAT, PROP_FACTOR);
490 RNA_def_property_range(prop, 0.0, 1.0);
491 RNA_def_property_ui_range(prop, 0.0, 1.0, 0.1, 3);
492 RNA_def_property_ui_text(prop, "Position", "Position of the slice");
493 RNA_def_property_update(prop, 0, "rna_Volume_update_display");
494}
495
497{
498 StructRNA *srna;
499 PropertyRNA *prop;
500
501 srna = RNA_def_struct(brna, "VolumeRender", nullptr);
502 RNA_def_struct_ui_text(srna, "Volume Render", "Volume object render settings");
503 RNA_def_struct_sdna(srna, "VolumeRender");
504 RNA_def_struct_path_func(srna, "rna_VolumeRender_path");
505
506 static const EnumPropertyItem precision_items[] = {
507 {VOLUME_PRECISION_FULL, "FULL", 0, "Full", "Full float (Use 32 bit for all data)"},
508 {VOLUME_PRECISION_HALF, "HALF", 0, "Half", "Half float (Use 16 bit for all data)"},
509 {VOLUME_PRECISION_VARIABLE, "VARIABLE", 0, "Variable", "Use variable bit quantization"},
510 {0, nullptr, 0, nullptr, nullptr},
511 };
512
513 prop = RNA_def_property(srna, "precision", PROP_ENUM, PROP_NONE);
514 RNA_def_property_enum_items(prop, precision_items);
516 "Precision",
517 "Specify volume data precision. Lower values reduce memory consumption "
518 "at the cost of detail.");
519 RNA_def_property_update(prop, 0, "rna_Volume_update_display");
520
521 static const EnumPropertyItem space_items[] = {
523 "OBJECT",
524 0,
525 "Object",
526 "Keep volume opacity and detail the same regardless of object scale"},
528 "WORLD",
529 0,
530 "World",
531 "Specify volume step size and density in world space"},
532 {0, nullptr, 0, nullptr, nullptr},
533 };
534
535 prop = RNA_def_property(srna, "space", PROP_ENUM, PROP_NONE);
538 prop, "Space", "Specify volume density and step size in object or world space");
539 RNA_def_property_update(prop, 0, "rna_Volume_update_display");
540
541 prop = RNA_def_property(srna, "step_size", PROP_FLOAT, PROP_DISTANCE);
544 RNA_def_property_ui_range(prop, 0.0, 100.0, 1, 3);
546 "Step Size",
547 "Distance between volume samples. Lower values render more detail at "
548 "the cost of performance. If set to zero, the step size is "
549 "automatically determined based on voxel size.");
550 RNA_def_property_update(prop, 0, "rna_Volume_update_display");
551
552 prop = RNA_def_property(srna, "clipping", PROP_FLOAT, PROP_NONE);
553 RNA_def_property_float_sdna(prop, nullptr, "clipping");
554 RNA_def_property_range(prop, 0.0, 1.0);
555 RNA_def_property_ui_range(prop, 0.0, 1.0, 0.1, 3);
557 prop,
558 "Clipping",
559 "Value under which voxels are considered empty space to optimize rendering");
560 RNA_def_property_update(prop, 0, "rna_Volume_update_display");
561}
562
563static void rna_def_volume(BlenderRNA *brna)
564{
565 StructRNA *srna;
566 PropertyRNA *prop;
567
568 srna = RNA_def_struct(brna, "Volume", "ID");
569 RNA_def_struct_ui_text(srna, "Volume", "Volume data-block for 3D volume grids");
570 RNA_def_struct_ui_icon(srna, ICON_VOLUME_DATA);
571
572 /* File */
573 prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH);
575 RNA_def_property_ui_text(prop, "File Path", "Volume file used by this Volume data-block");
576 RNA_def_property_update(prop, 0, "rna_Volume_update_filepath");
577
578 prop = RNA_def_property(srna, "packed_file", PROP_POINTER, PROP_NONE);
579 RNA_def_property_pointer_sdna(prop, nullptr, "packedfile");
580 RNA_def_property_ui_text(prop, "Packed File", "");
581
582 /* Sequence */
583 prop = RNA_def_property(srna, "is_sequence", PROP_BOOLEAN, PROP_NONE);
586 prop, "Sequence", "Whether the cache is separated in a series of files");
587 RNA_def_property_update(prop, 0, "rna_Volume_update_is_sequence");
588
589 prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_TIME);
593 prop, "Start Frame", "Global starting frame of the sequence, assuming first has a #1");
594 RNA_def_property_update(prop, 0, "rna_Volume_update_filepath");
595
596 prop = RNA_def_property(srna, "frame_duration", PROP_INT, PROP_NONE);
599 RNA_def_property_ui_text(prop, "Frames", "Number of frames of the sequence to use");
600 RNA_def_property_update(prop, 0, "rna_Volume_update_filepath");
601
602 prop = RNA_def_property(srna, "frame_offset", PROP_INT, PROP_NONE);
604 prop, "Offset", "Offset the number of the frame to use in the animation");
605 RNA_def_property_update(prop, 0, "rna_Volume_update_filepath");
606
607 static const EnumPropertyItem sequence_mode_items[] = {
608 {VOLUME_SEQUENCE_CLIP, "CLIP", 0, "Clip", "Hide frames outside the specified frame range"},
610 "EXTEND",
611 0,
612 "Extend",
613 "Repeat the start frame before, and the end frame after the frame range"},
614 {VOLUME_SEQUENCE_REPEAT, "REPEAT", 0, "Repeat", "Cycle the frames in the sequence"},
616 "PING_PONG",
617 0,
618 "Ping-Pong",
619 "Repeat the frames, reversing the playback direction every other cycle"},
620 {0, nullptr, 0, nullptr, nullptr},
621 };
622
623 prop = RNA_def_property(srna, "sequence_mode", PROP_ENUM, PROP_NONE);
625 RNA_def_property_enum_items(prop, sequence_mode_items);
626 RNA_def_property_ui_text(prop, "Sequence Mode", "Sequence playback mode");
627 RNA_def_property_update(prop, 0, "rna_Volume_update_filepath");
628
629 /* Grids */
630 prop = RNA_def_property(srna, "grids", PROP_COLLECTION, PROP_NONE);
631 RNA_def_property_struct_type(prop, "VolumeGrid");
632 RNA_def_property_ui_text(prop, "Grids", "3D volume grids");
634 "rna_Volume_grids_begin",
635 "rna_Volume_grids_next",
636 "rna_Volume_grids_end",
637 "rna_Volume_grids_get",
638 "rna_Volume_grids_length",
639 nullptr,
640 nullptr,
641 nullptr);
642 rna_def_volume_grids(brna, prop);
643
644 /* Materials */
645 prop = RNA_def_property(srna, "materials", PROP_COLLECTION, PROP_NONE);
646 RNA_def_property_collection_sdna(prop, nullptr, "mat", "totcol");
647 RNA_def_property_struct_type(prop, "Material");
648 RNA_def_property_ui_text(prop, "Materials", "");
649 RNA_def_property_srna(prop, "IDMaterials"); /* see rna_ID.cc */
651 nullptr,
652 nullptr,
653 nullptr,
654 nullptr,
655 nullptr,
656 nullptr,
657 nullptr,
658 "rna_IDMaterials_assign_int");
659
660 /* Display */
661 prop = RNA_def_property(srna, "display", PROP_POINTER, PROP_NONE);
662 RNA_def_property_pointer_sdna(prop, nullptr, "display");
663 RNA_def_property_struct_type(prop, "VolumeDisplay");
664 RNA_def_property_ui_text(prop, "Display", "Volume display settings for 3D viewport");
665
666 /* Render */
667 prop = RNA_def_property(srna, "render", PROP_POINTER, PROP_NONE);
668 RNA_def_property_pointer_sdna(prop, nullptr, "render");
669 RNA_def_property_struct_type(prop, "VolumeRender");
670 RNA_def_property_ui_text(prop, "Render", "Volume render settings for 3D viewport");
671
672 /* Velocity. */
673 prop = RNA_def_property(srna, "velocity_grid", PROP_STRING, PROP_NONE);
674 RNA_def_property_string_sdna(prop, nullptr, "velocity_grid");
675 RNA_def_property_string_funcs(prop, nullptr, nullptr, "rna_Volume_velocity_grid_set");
677 prop,
678 "Velocity Grid",
679 "Name of the velocity field, or the base name if the velocity is split into multiple grids");
680
681 prop = RNA_def_property(srna, "velocity_unit", PROP_ENUM, PROP_NONE);
682 RNA_def_property_enum_sdna(prop, nullptr, "velocity_unit");
685 prop,
686 "Velocity Unit",
687 "Define how the velocity vectors are interpreted with regard to time, 'frame' means "
688 "the delta time is 1 frame, 'second' means the delta time is 1 / FPS");
691
692 prop = RNA_def_property(srna, "velocity_scale", PROP_FLOAT, PROP_NONE);
693 RNA_def_property_float_sdna(prop, nullptr, "velocity_scale");
694 RNA_def_property_range(prop, 0.0f, FLT_MAX);
695 RNA_def_property_ui_text(prop, "Velocity Scale", "Factor to control the amount of motion blur");
696
697 /* Scalar grids for velocity. */
698 prop = RNA_def_property(srna, "velocity_x_grid", PROP_STRING, PROP_NONE);
699 RNA_def_property_string_sdna(prop, nullptr, "runtime->velocity_x_grid");
702 "Velocity X Grid",
703 "Name of the grid for the X axis component of the velocity field if it "
704 "was split into multiple grids");
705
706 prop = RNA_def_property(srna, "velocity_y_grid", PROP_STRING, PROP_NONE);
707 RNA_def_property_string_sdna(prop, nullptr, "runtime->velocity_y_grid");
710 "Velocity Y Grid",
711 "Name of the grid for the Y axis component of the velocity field if it "
712 "was split into multiple grids");
713
714 prop = RNA_def_property(srna, "velocity_z_grid", PROP_STRING, PROP_NONE);
715 RNA_def_property_string_sdna(prop, nullptr, "runtime->velocity_z_grid");
718 "Velocity Z Grid",
719 "Name of the grid for the Z axis component of the velocity field if it "
720 "was split into multiple grids");
721
722 /* Common */
724}
725
727{
731 rna_def_volume(brna);
732}
733
734#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)
bool BKE_volume_set_velocity_grid_by_name(Volume *volume, const char *base_name)
const char * BKE_volume_grids_error_msg(const Volume *volume)
@ 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:1085
#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:397
@ FUNC_USE_REPORTS
Definition RNA_types.hh:680
@ FUNC_USE_MAIN
Definition RNA_types.hh:678
@ FUNC_USE_SELF_ID
Definition RNA_types.hh:667
@ PROP_FLOAT
Definition RNA_types.hh:67
@ PROP_BOOLEAN
Definition RNA_types.hh:65
@ PROP_ENUM
Definition RNA_types.hh:69
@ PROP_INT
Definition RNA_types.hh:66
@ PROP_STRING
Definition RNA_types.hh:68
@ PROP_POINTER
Definition RNA_types.hh:70
@ PROP_COLLECTION
Definition RNA_types.hh:71
PropertyFlag
Definition RNA_types.hh:201
@ PROP_ANIMATABLE
Definition RNA_types.hh:220
@ PROP_EDITABLE
Definition RNA_types.hh:207
@ PROP_TIME
Definition RNA_types.hh:156
@ PROP_MATRIX
Definition RNA_types.hh:168
@ PROP_DISTANCE
Definition RNA_types.hh:159
@ PROP_NONE
Definition RNA_types.hh:136
@ PROP_FACTOR
Definition RNA_types.hh:154
@ PROP_UNSIGNED
Definition RNA_types.hh:152
@ PROP_FILEPATH
Definition RNA_types.hh:139
#define NC_GEOM
Definition WM_types.hh:360
#define ND_DATA
Definition WM_types.hh:475
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)
PointerRNA rna_pointer_inherit_refine(const PointerRNA *ptr, StructRNA *type, void *data)
void rna_def_animdata_common(StructRNA *srna)
const EnumPropertyItem rna_enum_velocity_unit_items[]
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_boolean_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t bit)
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_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:27
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.c:32
#define FLT_MAX
Definition stdcycles.h:14
union CollectionPropertyIterator::@1329 internal
Definition DNA_ID.h:413
ID * owner_id
Definition RNA_types.hh:40
void * data
Definition RNA_types.hh:42
void WM_main_add_notifier(uint type, void *reference)
void WM_reportf(eReportType type, const char *format,...)
PointerRNA * ptr
Definition wm_files.cc:4126