Blender  V3.3
rna_volume.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
7 #include <stdlib.h>
8 
9 #include "RNA_access.h"
10 #include "RNA_define.h"
11 #include "RNA_enum_types.h"
12 
13 #include "rna_internal.h"
14 
15 #include "DNA_scene_types.h"
16 #include "DNA_volume_types.h"
17 
18 #include "BKE_volume.h"
19 
20 #include "BLI_math_base.h"
21 
23  {VOLUME_GRID_BOOLEAN, "BOOLEAN", 0, "Boolean", "Boolean"},
24  {VOLUME_GRID_FLOAT, "FLOAT", 0, "Float", "Single precision float"},
25  {VOLUME_GRID_DOUBLE, "DOUBLE", 0, "Double", "Double precision"},
26  {VOLUME_GRID_INT, "INT", 0, "Integer", "32-bit integer"},
27  {VOLUME_GRID_INT64, "INT64", 0, "Integer 64-bit", "64-bit integer"},
28  {VOLUME_GRID_MASK, "MASK", 0, "Mask", "No data, boolean mask of active voxels"},
29  {VOLUME_GRID_VECTOR_FLOAT, "VECTOR_FLOAT", 0, "Float Vector", "3D float vector"},
30  {VOLUME_GRID_VECTOR_DOUBLE, "VECTOR_DOUBLE", 0, "Double Vector", "3D double vector"},
31  {VOLUME_GRID_VECTOR_INT, "VECTOR_INT", 0, "Integer Vector", "3D integer vector"},
33  "POINTS",
34  0,
35  "Points (Unsupported)",
36  "Points grid, currently unsupported by volume objects"},
37  {VOLUME_GRID_UNKNOWN, "UNKNOWN", 0, "Unknown", "Unsupported data type"},
38  {0, NULL, 0, NULL, NULL},
39 };
40 
41 #ifdef RNA_RUNTIME
42 
43 # include "DEG_depsgraph.h"
44 # include "DEG_depsgraph_build.h"
45 
46 # include "WM_api.h"
47 # include "WM_types.h"
48 
49 static char *rna_VolumeRender_path(const PointerRNA *UNUSED(ptr))
50 {
51  return BLI_strdup("render");
52 }
53 
54 static char *rna_VolumeDisplay_path(const PointerRNA *UNUSED(ptr))
55 {
56  return BLI_strdup("display");
57 }
58 
59 /* Updates */
60 
61 static void rna_Volume_update_display(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
62 {
63  Volume *volume = (Volume *)ptr->owner_id;
65 }
66 
67 static void rna_Volume_update_filepath(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
68 {
69  Volume *volume = (Volume *)ptr->owner_id;
70  BKE_volume_unload(volume);
73 }
74 
75 static void rna_Volume_update_is_sequence(Main *bmain, Scene *scene, PointerRNA *ptr)
76 {
77  rna_Volume_update_filepath(bmain, scene, ptr);
79 }
80 
81 static void rna_Volume_velocity_grid_set(PointerRNA *ptr, const char *value)
82 {
83  Volume *volume = (Volume *)ptr->data;
84  if (!BKE_volume_set_velocity_grid_by_name(volume, value)) {
85  WM_reportf(RPT_ERROR, "Could not find grid with name %s", value);
86  }
88 }
89 
90 /* Grid */
91 
92 static void rna_VolumeGrid_name_get(PointerRNA *ptr, char *value)
93 {
94  VolumeGrid *grid = ptr->data;
95  strcpy(value, BKE_volume_grid_name(grid));
96 }
97 
98 static int rna_VolumeGrid_name_length(PointerRNA *ptr)
99 {
100  VolumeGrid *grid = ptr->data;
101  return strlen(BKE_volume_grid_name(grid));
102 }
103 
104 static int rna_VolumeGrid_data_type_get(PointerRNA *ptr)
105 {
106  const VolumeGrid *grid = ptr->data;
107  return BKE_volume_grid_type(grid);
108 }
109 
110 static int rna_VolumeGrid_channels_get(PointerRNA *ptr)
111 {
112  const VolumeGrid *grid = ptr->data;
113  return BKE_volume_grid_channels(grid);
114 }
115 
116 static void rna_VolumeGrid_matrix_object_get(PointerRNA *ptr, float *value)
117 {
118  VolumeGrid *grid = ptr->data;
119  BKE_volume_grid_transform_matrix(grid, (float(*)[4])value);
120 }
121 
122 static bool rna_VolumeGrid_is_loaded_get(PointerRNA *ptr)
123 {
124  VolumeGrid *grid = ptr->data;
125  return BKE_volume_grid_is_loaded(grid);
126 }
127 
128 static bool rna_VolumeGrid_load(ID *id, VolumeGrid *grid)
129 {
130  return BKE_volume_grid_load((Volume *)id, grid);
131 }
132 
133 static void rna_VolumeGrid_unload(ID *id, VolumeGrid *grid)
134 {
135  BKE_volume_grid_unload((Volume *)id, grid);
136 }
137 
138 /* Grids Iterator */
139 
140 static void rna_Volume_grids_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
141 {
142  Volume *volume = ptr->data;
143  int num_grids = BKE_volume_num_grids(volume);
144  iter->internal.count.ptr = volume;
145  iter->internal.count.item = 0;
146  iter->valid = (iter->internal.count.item < num_grids);
147 }
148 
149 static void rna_Volume_grids_next(CollectionPropertyIterator *iter)
150 {
151  Volume *volume = iter->internal.count.ptr;
152  int num_grids = BKE_volume_num_grids(volume);
153  iter->internal.count.item++;
154  iter->valid = (iter->internal.count.item < num_grids);
155 }
156 
157 static void rna_Volume_grids_end(CollectionPropertyIterator *UNUSED(iter))
158 {
159 }
160 
161 static PointerRNA rna_Volume_grids_get(CollectionPropertyIterator *iter)
162 {
163  Volume *volume = iter->internal.count.ptr;
164  const VolumeGrid *grid = BKE_volume_grid_get_for_read(volume, iter->internal.count.item);
165  return rna_pointer_inherit_refine(&iter->parent, &RNA_VolumeGrid, (void *)grid);
166 }
167 
168 static int rna_Volume_grids_length(PointerRNA *ptr)
169 {
170  Volume *volume = ptr->data;
171  return BKE_volume_num_grids(volume);
172 }
173 
174 /* Active Grid */
175 
176 static void rna_VolumeGrids_active_index_range(
177  PointerRNA *ptr, int *min, int *max, int *UNUSED(softmin), int *UNUSED(softmax))
178 {
179  Volume *volume = (Volume *)ptr->data;
180  int num_grids = BKE_volume_num_grids(volume);
181 
182  *min = 0;
183  *max = max_ii(0, num_grids - 1);
184 }
185 
186 static int rna_VolumeGrids_active_index_get(PointerRNA *ptr)
187 {
188  Volume *volume = (Volume *)ptr->data;
189  int num_grids = BKE_volume_num_grids(volume);
190  return clamp_i(volume->active_grid, 0, max_ii(num_grids - 1, 0));
191 }
192 
193 static void rna_VolumeGrids_active_index_set(PointerRNA *ptr, int value)
194 {
195  Volume *volume = (Volume *)ptr->data;
196  volume->active_grid = value;
197 }
198 
199 /* Loading */
200 
201 static bool rna_VolumeGrids_is_loaded_get(PointerRNA *ptr)
202 {
203  Volume *volume = (Volume *)ptr->data;
204  return BKE_volume_is_loaded(volume);
205 }
206 
207 /* Error Message */
208 
209 static void rna_VolumeGrids_error_message_get(PointerRNA *ptr, char *value)
210 {
211  Volume *volume = (Volume *)ptr->data;
212  strcpy(value, BKE_volume_grids_error_msg(volume));
213 }
214 
215 static int rna_VolumeGrids_error_message_length(PointerRNA *ptr)
216 {
217  Volume *volume = (Volume *)ptr->data;
218  return strlen(BKE_volume_grids_error_msg(volume));
219 }
220 
221 /* Frame Filepath */
222 static void rna_VolumeGrids_frame_filepath_get(PointerRNA *ptr, char *value)
223 {
224  Volume *volume = (Volume *)ptr->data;
225  strcpy(value, BKE_volume_grids_frame_filepath(volume));
226 }
227 
228 static int rna_VolumeGrids_frame_filepath_length(PointerRNA *ptr)
229 {
230  Volume *volume = (Volume *)ptr->data;
231  return strlen(BKE_volume_grids_frame_filepath(volume));
232 }
233 
234 static bool rna_Volume_load(Volume *volume, Main *bmain)
235 {
236  return BKE_volume_load(volume, bmain);
237 }
238 
239 static bool rna_Volume_save(Volume *volume, Main *bmain, ReportList *reports, const char *filepath)
240 {
241  return BKE_volume_save(volume, bmain, reports, filepath);
242 }
243 
244 #else
245 
246 static void rna_def_volume_grid(BlenderRNA *brna)
247 {
248  StructRNA *srna;
249  PropertyRNA *prop;
250 
251  srna = RNA_def_struct(brna, "VolumeGrid", NULL);
252  RNA_def_struct_ui_text(srna, "Volume Grid", "3D volume grid");
253  RNA_def_struct_ui_icon(srna, ICON_VOLUME_DATA);
254 
255  prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
258  prop, "rna_VolumeGrid_name_get", "rna_VolumeGrid_name_length", NULL);
259  RNA_def_property_ui_text(prop, "Name", "Volume grid name");
260  RNA_def_struct_name_property(srna, prop);
261 
262  prop = RNA_def_property(srna, "data_type", PROP_ENUM, PROP_NONE);
264  RNA_def_property_enum_funcs(prop, "rna_VolumeGrid_data_type_get", NULL, NULL);
266  RNA_def_property_ui_text(prop, "Data Type", "Data type of voxel values");
267 
268  prop = RNA_def_property(srna, "channels", PROP_INT, PROP_UNSIGNED);
270  RNA_def_property_int_funcs(prop, "rna_VolumeGrid_channels_get", NULL, NULL);
271  RNA_def_property_ui_text(prop, "Channels", "Number of dimensions of the grid data type");
272 
273  prop = RNA_def_property(srna, "matrix_object", PROP_FLOAT, PROP_MATRIX);
276  RNA_def_property_float_funcs(prop, "rna_VolumeGrid_matrix_object_get", NULL, NULL);
278  prop, "Matrix Object", "Transformation matrix from voxel index to object space");
279 
280  prop = RNA_def_property(srna, "is_loaded", PROP_BOOLEAN, PROP_NONE);
282  RNA_def_property_boolean_funcs(prop, "rna_VolumeGrid_is_loaded_get", NULL);
283  RNA_def_property_ui_text(prop, "Is Loaded", "Grid tree is loaded in memory");
284 
285  /* API */
286  FunctionRNA *func;
287  PropertyRNA *parm;
288 
289  func = RNA_def_function(srna, "load", "rna_VolumeGrid_load");
290  RNA_def_function_ui_description(func, "Load grid tree from file");
292  parm = RNA_def_boolean(func, "success", 0, "", "True if grid tree was successfully loaded");
293  RNA_def_function_return(func, parm);
294 
295  func = RNA_def_function(srna, "unload", "rna_VolumeGrid_unload");
298  func, "Unload grid tree and voxel data from memory, leaving only metadata");
299 }
300 
301 static void rna_def_volume_grids(BlenderRNA *brna, PropertyRNA *cprop)
302 {
303  StructRNA *srna;
304  PropertyRNA *prop;
305 
306  RNA_def_property_srna(cprop, "VolumeGrids");
307  srna = RNA_def_struct(brna, "VolumeGrids", NULL);
308  RNA_def_struct_sdna(srna, "Volume");
309  RNA_def_struct_ui_text(srna, "Volume Grids", "3D volume grids");
310 
311  prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
313  "rna_VolumeGrids_active_index_get",
314  "rna_VolumeGrids_active_index_set",
315  "rna_VolumeGrids_active_index_range");
316  RNA_def_property_ui_text(prop, "Active Grid Index", "Index of active volume grid");
317  RNA_def_property_update(prop, 0, "rna_Volume_update_display");
318 
319  prop = RNA_def_property(srna, "error_message", PROP_STRING, PROP_NONE);
322  prop, "rna_VolumeGrids_error_message_get", "rna_VolumeGrids_error_message_length", NULL);
324  prop, "Error Message", "If loading grids failed, error message with details");
325 
326  prop = RNA_def_property(srna, "is_loaded", PROP_BOOLEAN, PROP_NONE);
328  RNA_def_property_boolean_funcs(prop, "rna_VolumeGrids_is_loaded_get", NULL);
329  RNA_def_property_ui_text(prop, "Is Loaded", "List of grids and metadata are loaded in memory");
330 
331  prop = RNA_def_property(srna, "frame", PROP_INT, PROP_NONE);
332  RNA_def_property_int_sdna(prop, NULL, "runtime.frame");
335  "Frame",
336  "Frame number that volume grids will be loaded at, based on scene time "
337  "and volume parameters");
338 
339  prop = RNA_def_property(srna, "frame_filepath", PROP_STRING, PROP_FILEPATH);
342  prop, "rna_VolumeGrids_frame_filepath_get", "rna_VolumeGrids_frame_filepath_length", NULL);
343 
345  "Frame File Path",
346  "Volume file used for loading the volume at the current frame. Empty "
347  "if the volume has not be loaded or the frame only exists in memory");
348 
349  /* API */
350  FunctionRNA *func;
351  PropertyRNA *parm;
352 
353  func = RNA_def_function(srna, "load", "rna_Volume_load");
354  RNA_def_function_ui_description(func, "Load list of grids and metadata from file");
356  parm = RNA_def_boolean(func, "success", 0, "", "True if grid list was successfully loaded");
357  RNA_def_function_return(func, parm);
358 
359  func = RNA_def_function(srna, "unload", "BKE_volume_unload");
360  RNA_def_function_ui_description(func, "Unload all grid and voxel data from memory");
361 
362  func = RNA_def_function(srna, "save", "rna_Volume_save");
363  RNA_def_function_ui_description(func, "Save grids and metadata to file");
365  parm = RNA_def_string_file_path(func, "filepath", NULL, 0, "", "File path to save to");
367  parm = RNA_def_boolean(func, "success", 0, "", "True if grid list was successfully loaded");
368  RNA_def_function_return(func, parm);
369 }
370 
372 {
373  StructRNA *srna;
374  PropertyRNA *prop;
375 
376  srna = RNA_def_struct(brna, "VolumeDisplay", NULL);
377  RNA_def_struct_ui_text(srna, "Volume Display", "Volume object display settings for 3D viewport");
378  RNA_def_struct_sdna(srna, "VolumeDisplay");
379  RNA_def_struct_path_func(srna, "rna_VolumeDisplay_path");
380 
381  prop = RNA_def_property(srna, "density", PROP_FLOAT, PROP_NONE);
383  RNA_def_property_range(prop, 0.00001, FLT_MAX);
384  RNA_def_property_ui_range(prop, 0.1, 100.0, 1, 3);
385  RNA_def_property_ui_text(prop, "Density", "Thickness of volume display in the viewport");
386  RNA_def_property_update(prop, 0, "rna_Volume_update_display");
387 
388  static const EnumPropertyItem wireframe_type_items[] = {
389  {VOLUME_WIREFRAME_NONE, "NONE", 0, "None", "Don't display volume in wireframe mode"},
391  "BOUNDS",
392  0,
393  "Bounds",
394  "Display single bounding box for the entire grid"},
396  "BOXES",
397  0,
398  "Boxes",
399  "Display bounding boxes for nodes in the volume tree"},
401  "POINTS",
402  0,
403  "Points",
404  "Display points for nodes in the volume tree"},
405  {0, NULL, 0, NULL, NULL},
406  };
407 
408  static const EnumPropertyItem wireframe_detail_items[] = {
410  "COARSE",
411  0,
412  "Coarse",
413  "Display one box or point for each intermediate tree node"},
415  "FINE",
416  0,
417  "Fine",
418  "Display box for each leaf node containing 8x8 voxels"},
419  {0, NULL, 0, NULL, NULL},
420  };
421 
422  static const EnumPropertyItem interpolation_method_items[] = {
423  {VOLUME_DISPLAY_INTERP_LINEAR, "LINEAR", 0, "Linear", "Good smoothness and speed"},
425  "CUBIC",
426  0,
427  "Cubic",
428  "Smoothed high quality interpolation, but slower"},
429  {VOLUME_DISPLAY_INTERP_CLOSEST, "CLOSEST", 0, "Closest", "No interpolation"},
430  {0, NULL, 0, NULL, NULL},
431  };
432 
433  static const EnumPropertyItem axis_slice_position_items[] = {
435  "AUTO",
436  0,
437  "Auto",
438  "Adjust slice direction according to the view direction"},
439  {VOLUME_SLICE_AXIS_X, "X", 0, "X", "Slice along the X axis"},
440  {VOLUME_SLICE_AXIS_Y, "Y", 0, "Y", "Slice along the Y axis"},
441  {VOLUME_SLICE_AXIS_Z, "Z", 0, "Z", "Slice along the Z axis"},
442  {0, NULL, 0, NULL, NULL},
443  };
444 
445  prop = RNA_def_property(srna, "wireframe_type", PROP_ENUM, PROP_NONE);
446  RNA_def_property_enum_items(prop, wireframe_type_items);
447  RNA_def_property_ui_text(prop, "Wireframe", "Type of wireframe display");
448  RNA_def_property_update(prop, 0, "rna_Volume_update_display");
449 
450  prop = RNA_def_property(srna, "wireframe_detail", PROP_ENUM, PROP_NONE);
451  RNA_def_property_enum_items(prop, wireframe_detail_items);
452  RNA_def_property_ui_text(prop, "Wireframe Detail", "Amount of detail for wireframe display");
453  RNA_def_property_update(prop, 0, "rna_Volume_update_display");
454 
455  prop = RNA_def_property(srna, "interpolation_method", PROP_ENUM, PROP_NONE);
456  RNA_def_property_enum_items(prop, interpolation_method_items);
458  prop, "Interpolation", "Interpolation method to use for volumes in solid mode");
459  RNA_def_property_update(prop, 0, "rna_Volume_update_display");
460 
461  prop = RNA_def_property(srna, "use_slice", PROP_BOOLEAN, PROP_NONE);
462  RNA_def_property_boolean_sdna(prop, NULL, "axis_slice_method", VOLUME_AXIS_SLICE_SINGLE);
463  RNA_def_property_ui_text(prop, "Slice", "Perform a single slice of the domain object");
464  RNA_def_property_update(prop, 0, "rna_Volume_update_display");
465 
466  prop = RNA_def_property(srna, "slice_axis", PROP_ENUM, PROP_NONE);
467  RNA_def_property_enum_items(prop, axis_slice_position_items);
468  RNA_def_property_ui_text(prop, "Axis", "");
469  RNA_def_property_update(prop, 0, "rna_Volume_update_display");
470 
471  prop = RNA_def_property(srna, "slice_depth", PROP_FLOAT, PROP_FACTOR);
472  RNA_def_property_range(prop, 0.0, 1.0);
473  RNA_def_property_ui_range(prop, 0.0, 1.0, 0.1, 3);
474  RNA_def_property_ui_text(prop, "Position", "Position of the slice");
475  RNA_def_property_update(prop, 0, "rna_Volume_update_display");
476 }
477 
479 {
480  StructRNA *srna;
481  PropertyRNA *prop;
482 
483  srna = RNA_def_struct(brna, "VolumeRender", NULL);
484  RNA_def_struct_ui_text(srna, "Volume Render", "Volume object render settings");
485  RNA_def_struct_sdna(srna, "VolumeRender");
486  RNA_def_struct_path_func(srna, "rna_VolumeRender_path");
487 
488  static const EnumPropertyItem precision_items[] = {
489  {VOLUME_PRECISION_FULL, "FULL", 0, "Full", "Full float (Use 32 bit for all data)"},
490  {VOLUME_PRECISION_HALF, "HALF", 0, "Half", "Half float (Use 16 bit for all data)"},
491  {VOLUME_PRECISION_VARIABLE, "VARIABLE", 0, "Variable", "Use variable bit quantization"},
492  {0, NULL, 0, NULL, NULL},
493  };
494 
495  prop = RNA_def_property(srna, "precision", PROP_ENUM, PROP_NONE);
496  RNA_def_property_enum_items(prop, precision_items);
498  "Precision",
499  "Specify volume data precision. Lower values reduce memory consumption "
500  "at the cost of detail");
501  RNA_def_property_update(prop, 0, "rna_Volume_update_display");
502 
503  static const EnumPropertyItem space_items[] = {
505  "OBJECT",
506  0,
507  "Object",
508  "Keep volume opacity and detail the same regardless of object scale"},
510  "WORLD",
511  0,
512  "World",
513  "Specify volume step size and density in world space"},
514  {0, NULL, 0, NULL, NULL},
515  };
516 
517  prop = RNA_def_property(srna, "space", PROP_ENUM, PROP_NONE);
520  prop, "Space", "Specify volume density and step size in object or world space");
521  RNA_def_property_update(prop, 0, "rna_Volume_update_display");
522 
523  prop = RNA_def_property(srna, "step_size", PROP_FLOAT, PROP_DISTANCE);
525  RNA_def_property_range(prop, 0.0, FLT_MAX);
526  RNA_def_property_ui_range(prop, 0.0, 100.0, 1, 3);
528  "Step Size",
529  "Distance between volume samples. Lower values render more detail at "
530  "the cost of performance. If set to zero, the step size is "
531  "automatically determined based on voxel size");
532  RNA_def_property_update(prop, 0, "rna_Volume_update_display");
533 
534  prop = RNA_def_property(srna, "clipping", PROP_FLOAT, PROP_NONE);
535  RNA_def_property_float_sdna(prop, NULL, "clipping");
536  RNA_def_property_range(prop, 0.0, 1.0);
537  RNA_def_property_ui_range(prop, 0.0, 1.0, 0.1, 3);
539  prop,
540  "Clipping",
541  "Value under which voxels are considered empty space to optimize rendering");
542  RNA_def_property_update(prop, 0, "rna_Volume_update_display");
543 }
544 
545 static void rna_def_volume(BlenderRNA *brna)
546 {
547  StructRNA *srna;
548  PropertyRNA *prop;
549 
550  srna = RNA_def_struct(brna, "Volume", "ID");
551  RNA_def_struct_ui_text(srna, "Volume", "Volume data-block for 3D volume grids");
552  RNA_def_struct_ui_icon(srna, ICON_VOLUME_DATA);
553 
554  /* File */
555  prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH);
557  RNA_def_property_ui_text(prop, "File Path", "Volume file used by this Volume data-block");
558  RNA_def_property_update(prop, 0, "rna_Volume_update_filepath");
559 
560  prop = RNA_def_property(srna, "packed_file", PROP_POINTER, PROP_NONE);
561  RNA_def_property_pointer_sdna(prop, NULL, "packedfile");
562  RNA_def_property_ui_text(prop, "Packed File", "");
563 
564  /* Sequence */
565  prop = RNA_def_property(srna, "is_sequence", PROP_BOOLEAN, PROP_NONE);
568  prop, "Sequence", "Whether the cache is separated in a series of files");
569  RNA_def_property_update(prop, 0, "rna_Volume_update_is_sequence");
570 
571  prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_TIME);
575  prop, "Start Frame", "Global starting frame of the sequence, assuming first has a #1");
576  RNA_def_property_update(prop, 0, "rna_Volume_update_filepath");
577 
578  prop = RNA_def_property(srna, "frame_duration", PROP_INT, PROP_NONE);
581  RNA_def_property_ui_text(prop, "Frames", "Number of frames of the sequence to use");
582  RNA_def_property_update(prop, 0, "rna_Volume_update_filepath");
583 
584  prop = RNA_def_property(srna, "frame_offset", PROP_INT, PROP_NONE);
586  prop, "Offset", "Offset the number of the frame to use in the animation");
587  RNA_def_property_update(prop, 0, "rna_Volume_update_filepath");
588 
589  static const EnumPropertyItem sequence_mode_items[] = {
590  {VOLUME_SEQUENCE_CLIP, "CLIP", 0, "Clip", "Hide frames outside the specified frame range"},
592  "EXTEND",
593  0,
594  "Extend",
595  "Repeat the start frame before, and the end frame after the frame range"},
596  {VOLUME_SEQUENCE_REPEAT, "REPEAT", 0, "Repeat", "Cycle the frames in the sequence"},
598  "PING_PONG",
599  0,
600  "Ping-Pong",
601  "Repeat the frames, reversing the playback direction every other cycle"},
602  {0, NULL, 0, NULL, NULL},
603  };
604 
605  prop = RNA_def_property(srna, "sequence_mode", PROP_ENUM, PROP_NONE);
607  RNA_def_property_enum_items(prop, sequence_mode_items);
608  RNA_def_property_ui_text(prop, "Sequence Mode", "Sequence playback mode");
609  RNA_def_property_update(prop, 0, "rna_Volume_update_filepath");
610 
611  /* Grids */
612  prop = RNA_def_property(srna, "grids", PROP_COLLECTION, PROP_NONE);
613  RNA_def_property_struct_type(prop, "VolumeGrid");
614  RNA_def_property_ui_text(prop, "Grids", "3D volume grids");
616  "rna_Volume_grids_begin",
617  "rna_Volume_grids_next",
618  "rna_Volume_grids_end",
619  "rna_Volume_grids_get",
620  "rna_Volume_grids_length",
621  NULL,
622  NULL,
623  NULL);
624  rna_def_volume_grids(brna, prop);
625 
626  /* Materials */
627  prop = RNA_def_property(srna, "materials", PROP_COLLECTION, PROP_NONE);
628  RNA_def_property_collection_sdna(prop, NULL, "mat", "totcol");
629  RNA_def_property_struct_type(prop, "Material");
630  RNA_def_property_ui_text(prop, "Materials", "");
631  RNA_def_property_srna(prop, "IDMaterials"); /* see rna_ID.c */
633  prop, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "rna_IDMaterials_assign_int");
634 
635  /* Display */
636  prop = RNA_def_property(srna, "display", PROP_POINTER, PROP_NONE);
637  RNA_def_property_pointer_sdna(prop, NULL, "display");
638  RNA_def_property_struct_type(prop, "VolumeDisplay");
639  RNA_def_property_ui_text(prop, "Display", "Volume display settings for 3D viewport");
640 
641  /* Render */
642  prop = RNA_def_property(srna, "render", PROP_POINTER, PROP_NONE);
643  RNA_def_property_pointer_sdna(prop, NULL, "render");
644  RNA_def_property_struct_type(prop, "VolumeRender");
645  RNA_def_property_ui_text(prop, "Render", "Volume render settings for 3D viewport");
646 
647  /* Velocity. */
648  prop = RNA_def_property(srna, "velocity_grid", PROP_STRING, PROP_NONE);
649  RNA_def_property_string_sdna(prop, NULL, "velocity_grid");
650  RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Volume_velocity_grid_set");
652  prop,
653  "Velocity Grid",
654  "Name of the velocity field, or the base name if the velocity is split into multiple grids");
655 
656  prop = RNA_def_property(srna, "velocity_unit", PROP_ENUM, PROP_NONE);
657  RNA_def_property_enum_sdna(prop, NULL, "velocity_unit");
660  prop,
661  "Velocity Unit",
662  "Define how the velocity vectors are interpreted with regard to time, 'frame' means "
663  "the delta time is 1 frame, 'second' means the delta time is 1 / FPS");
665 
666  prop = RNA_def_property(srna, "velocity_scale", PROP_FLOAT, PROP_NONE);
667  RNA_def_property_float_sdna(prop, NULL, "velocity_scale");
668  RNA_def_property_range(prop, 0.0f, FLT_MAX);
669  RNA_def_property_ui_text(prop, "Velocity Scale", "Factor to control the amount of motion blur");
670 
671  /* Scalar grids for velocity. */
672  prop = RNA_def_property(srna, "velocity_x_grid", PROP_STRING, PROP_NONE);
673  RNA_def_property_string_sdna(prop, NULL, "runtime.velocity_x_grid");
676  "Velocity X Grid",
677  "Name of the grid for the X axis component of the velocity field if it "
678  "was split into multiple grids");
679 
680  prop = RNA_def_property(srna, "velocity_y_grid", PROP_STRING, PROP_NONE);
681  RNA_def_property_string_sdna(prop, NULL, "runtime.velocity_y_grid");
684  "Velocity Y Grid",
685  "Name of the grid for the Y axis component of the velocity field if it "
686  "was split into multiple grids");
687 
688  prop = RNA_def_property(srna, "velocity_z_grid", PROP_STRING, PROP_NONE);
689  RNA_def_property_string_sdna(prop, NULL, "runtime.velocity_z_grid");
692  "Velocity Z Grid",
693  "Name of the grid for the Z axis component of the velocity field if it "
694  "was split into multiple grids");
695 
696  /* Common */
698 }
699 
701 {
702  rna_def_volume_grid(brna);
704  rna_def_volume_render(brna);
705  rna_def_volume(brna);
706 }
707 
708 #endif
Volume data-block.
const VolumeGrid * BKE_volume_grid_get_for_read(const struct Volume *volume, int grid_index)
VolumeGridType BKE_volume_grid_type(const struct VolumeGrid *grid)
@ VOLUME_GRID_VECTOR_FLOAT
Definition: BKE_volume.h:98
@ VOLUME_GRID_MASK
Definition: BKE_volume.h:97
@ VOLUME_GRID_VECTOR_DOUBLE
Definition: BKE_volume.h:99
@ VOLUME_GRID_VECTOR_INT
Definition: BKE_volume.h:100
@ VOLUME_GRID_UNKNOWN
Definition: BKE_volume.h:91
@ VOLUME_GRID_DOUBLE
Definition: BKE_volume.h:94
@ VOLUME_GRID_BOOLEAN
Definition: BKE_volume.h:92
@ VOLUME_GRID_INT
Definition: BKE_volume.h:95
@ VOLUME_GRID_INT64
Definition: BKE_volume.h:96
@ VOLUME_GRID_POINTS
Definition: BKE_volume.h:101
@ VOLUME_GRID_FLOAT
Definition: BKE_volume.h:93
void BKE_volume_grid_transform_matrix(const struct VolumeGrid *grid, float mat[4][4])
void BKE_volume_unload(struct Volume *volume)
Definition: volume.cc:930
bool BKE_volume_save(const struct Volume *volume, const struct Main *bmain, struct ReportList *reports, const char *filepath)
const char * BKE_volume_grids_frame_filepath(const struct Volume *volume)
int BKE_volume_grid_channels(const struct VolumeGrid *grid)
void BKE_volume_grid_unload(const struct Volume *volume, const struct VolumeGrid *grid)
bool BKE_volume_grid_is_loaded(const struct VolumeGrid *grid)
const char * BKE_volume_grid_name(const struct VolumeGrid *grid)
int BKE_volume_num_grids(const struct Volume *volume)
const char * BKE_volume_grids_error_msg(const struct Volume *volume)
bool BKE_volume_is_loaded(const struct Volume *volume)
bool BKE_volume_set_velocity_grid_by_name(struct Volume *volume, const char *base_name)
Definition: volume.cc:796
bool BKE_volume_grid_load(const struct Volume *volume, const struct VolumeGrid *grid)
bool BKE_volume_load(const struct Volume *volume, const struct Main *bmain)
MINLINE int max_ii(int a, int b)
MINLINE int clamp_i(int value, int min, int max)
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL() ATTR_MALLOC
Definition: string.c:42
#define UNUSED(x)
void DEG_id_tag_update(struct ID *id, int flag)
void DEG_relations_tag_update(struct Main *bmain)
@ ID_RECALC_COPY_ON_WRITE
Definition: DNA_ID.h:834
#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.h:352
@ FUNC_USE_REPORTS
Definition: RNA_types.h:663
@ FUNC_USE_MAIN
Definition: RNA_types.h:661
@ FUNC_USE_SELF_ID
Definition: RNA_types.h:650
@ PROP_FLOAT
Definition: RNA_types.h:61
@ PROP_BOOLEAN
Definition: RNA_types.h:59
@ PROP_ENUM
Definition: RNA_types.h:63
@ PROP_INT
Definition: RNA_types.h:60
@ PROP_STRING
Definition: RNA_types.h:62
@ PROP_POINTER
Definition: RNA_types.h:64
@ PROP_COLLECTION
Definition: RNA_types.h:65
@ PROP_ANIMATABLE
Definition: RNA_types.h:202
@ PROP_EDITABLE
Definition: RNA_types.h:189
@ PROP_TIME
Definition: RNA_types.h:146
@ PROP_MATRIX
Definition: RNA_types.h:158
@ PROP_DISTANCE
Definition: RNA_types.h:149
@ PROP_NONE
Definition: RNA_types.h:126
@ PROP_FACTOR
Definition: RNA_types.h:144
@ PROP_UNSIGNED
Definition: RNA_types.h:142
@ PROP_FILEPATH
Definition: RNA_types.h:129
#define NC_GEOM
Definition: WM_types.h:343
#define ND_DATA
Definition: WM_types.h:456
Scene scene
PointerRNA rna_pointer_inherit_refine(PointerRNA *ptr, StructRNA *type, void *data)
Definition: rna_access.c:186
void rna_def_animdata_common(StructRNA *srna)
const EnumPropertyItem rna_enum_velocity_unit_items[]
Definition: rna_cachefile.c:17
void RNA_def_property_pointer_sdna(PropertyRNA *prop, const char *structname, const char *propname)
Definition: rna_define.c:2740
void RNA_def_struct_path_func(StructRNA *srna, const char *path)
Definition: rna_define.c:1193
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, bool default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3493
void RNA_def_property_boolean_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t bit)
Definition: rna_define.c:2236
void RNA_def_property_string_funcs(PropertyRNA *prop, const char *get, const char *length, const char *set)
Definition: rna_define.c:3285
void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret)
Definition: rna_define.c:4312
void RNA_def_property_float_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
Definition: rna_define.c:3126
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
Definition: rna_define.c:1645
void RNA_def_property_string_sdna(PropertyRNA *prop, const char *structname, const char *propname)
Definition: rna_define.c:2695
PropertyRNA * RNA_def_string_file_path(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, int maxlen, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3711
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier, const char *call)
Definition: rna_define.c:4273
void RNA_def_property_srna(PropertyRNA *prop, const char *type)
Definition: rna_define.c:3474
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)
Definition: rna_define.c:3420
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
Definition: rna_define.c:1237
void RNA_def_property_boolean_funcs(PropertyRNA *prop, const char *get, const char *set)
Definition: rna_define.c:2944
void RNA_def_property_multi_array(PropertyRNA *prop, int dimension, const int length[])
Definition: rna_define.c:1598
void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item)
Definition: rna_define.c:1872
void RNA_def_struct_sdna(StructRNA *srna, const char *structname)
Definition: rna_define.c:1048
void RNA_def_property_range(PropertyRNA *prop, double min, double max)
Definition: rna_define.c:1737
void RNA_def_property_struct_type(PropertyRNA *prop, const char *type)
Definition: rna_define.c:1772
void RNA_def_property_collection_sdna(PropertyRNA *prop, const char *structname, const char *propname, const char *lengthpropname)
Definition: rna_define.c:2769
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
Definition: rna_define.c:4347
void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *func)
Definition: rna_define.c:2900
const int rna_matrix_dimsize_4x4[]
Definition: rna_define.c:1595
void RNA_def_property_enum_funcs(PropertyRNA *prop, const char *get, const char *set, const char *item)
Definition: rna_define.c:3224
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype)
Definition: rna_define.c:1257
void RNA_def_struct_name_property(struct StructRNA *srna, struct PropertyRNA *prop)
Definition: rna_define.c:1103
void RNA_def_function_flag(FunctionRNA *func, int flag)
Definition: rna_define.c:4342
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
Definition: rna_define.c:1495
StructRNA * RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
Definition: rna_define.c:1028
void RNA_def_property_enum_sdna(PropertyRNA *prop, const char *structname, const char *propname)
Definition: rna_define.c:2601
void RNA_def_property_int_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
Definition: rna_define.c:3028
void RNA_def_struct_ui_icon(StructRNA *srna, int icon)
Definition: rna_define.c:1245
void RNA_def_property_float_sdna(PropertyRNA *prop, const char *structname, const char *propname)
Definition: rna_define.c:2493
void RNA_def_property_ui_range(PropertyRNA *prop, double min, double max, double step, int precision)
Definition: rna_define.c:1664
void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const char *propname)
Definition: rna_define.c:2343
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
Definition: rna_define.c:1518
static const EnumPropertyItem space_items[]
static void rna_def_volume_display(BlenderRNA *brna)
Definition: rna_volume.c:371
static void rna_def_volume(BlenderRNA *brna)
Definition: rna_volume.c:545
const EnumPropertyItem rna_enum_volume_grid_data_type_items[]
Definition: rna_volume.c:22
static void rna_def_volume_render(BlenderRNA *brna)
Definition: rna_volume.c:478
static void rna_def_volume_grids(BlenderRNA *brna, PropertyRNA *cprop)
Definition: rna_volume.c:301
static void rna_def_volume_grid(BlenderRNA *brna)
Definition: rna_volume.c:246
void RNA_def_volume(BlenderRNA *brna)
Definition: rna_volume.c:700
#define min(a, b)
Definition: sort.c:35
union CollectionPropertyIterator::@1147 internal
void * ptr
Definition: RNA_types.h:398
Definition: DNA_ID.h:368
Definition: BKE_main.h:121
void * data
Definition: RNA_types.h:38
struct ID * owner_id
Definition: RNA_types.h:36
int active_grid
float max
void WM_main_add_notifier(unsigned int type, void *reference)
void WM_reportf(eReportType type, const char *format,...)
PointerRNA * ptr
Definition: wm_files.c:3480