Blender  V2.93
rna_volume.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
21 #include <stdlib.h>
22 
23 #include "RNA_access.h"
24 #include "RNA_define.h"
25 #include "RNA_enum_types.h"
26 
27 #include "rna_internal.h"
28 
29 #include "DNA_scene_types.h"
30 #include "DNA_volume_types.h"
31 
32 #include "BKE_volume.h"
33 
34 #include "BLI_math_base.h"
35 
36 #ifdef RNA_RUNTIME
37 
38 # include "DEG_depsgraph.h"
39 # include "DEG_depsgraph_build.h"
40 
41 # include "WM_api.h"
42 # include "WM_types.h"
43 
44 /* Updates */
45 
46 static void rna_Volume_update_display(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
47 {
48  Volume *volume = (Volume *)ptr->owner_id;
50 }
51 
52 static void rna_Volume_update_filepath(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
53 {
54  Volume *volume = (Volume *)ptr->owner_id;
55  BKE_volume_unload(volume);
58 }
59 
60 static void rna_Volume_update_is_sequence(Main *bmain, Scene *scene, PointerRNA *ptr)
61 {
62  rna_Volume_update_filepath(bmain, scene, ptr);
64 }
65 
66 /* Grid */
67 
68 static void rna_VolumeGrid_name_get(PointerRNA *ptr, char *value)
69 {
70  VolumeGrid *grid = ptr->data;
71  strcpy(value, BKE_volume_grid_name(grid));
72 }
73 
74 static int rna_VolumeGrid_name_length(PointerRNA *ptr)
75 {
76  VolumeGrid *grid = ptr->data;
77  return strlen(BKE_volume_grid_name(grid));
78 }
79 
80 static int rna_VolumeGrid_data_type_get(PointerRNA *ptr)
81 {
82  const VolumeGrid *grid = ptr->data;
83  return BKE_volume_grid_type(grid);
84 }
85 
86 static int rna_VolumeGrid_channels_get(PointerRNA *ptr)
87 {
88  const VolumeGrid *grid = ptr->data;
89  return BKE_volume_grid_channels(grid);
90 }
91 
92 static void rna_VolumeGrid_matrix_object_get(PointerRNA *ptr, float *value)
93 {
94  VolumeGrid *grid = ptr->data;
95  BKE_volume_grid_transform_matrix(grid, (float(*)[4])value);
96 }
97 
98 static bool rna_VolumeGrid_is_loaded_get(PointerRNA *ptr)
99 {
100  VolumeGrid *grid = ptr->data;
101  return BKE_volume_grid_is_loaded(grid);
102 }
103 
104 static bool rna_VolumeGrid_load(ID *id, VolumeGrid *grid)
105 {
106  return BKE_volume_grid_load((Volume *)id, grid);
107 }
108 
109 static void rna_VolumeGrid_unload(ID *id, VolumeGrid *grid)
110 {
111  BKE_volume_grid_unload((Volume *)id, grid);
112 }
113 
114 /* Grids Iterator */
115 
116 static void rna_Volume_grids_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
117 {
118  Volume *volume = ptr->data;
119  int num_grids = BKE_volume_num_grids(volume);
120  iter->internal.count.ptr = volume;
121  iter->internal.count.item = 0;
122  iter->valid = (iter->internal.count.item < num_grids);
123 }
124 
125 static void rna_Volume_grids_next(CollectionPropertyIterator *iter)
126 {
127  Volume *volume = iter->internal.count.ptr;
128  int num_grids = BKE_volume_num_grids(volume);
129  iter->internal.count.item++;
130  iter->valid = (iter->internal.count.item < num_grids);
131 }
132 
133 static void rna_Volume_grids_end(CollectionPropertyIterator *UNUSED(iter))
134 {
135 }
136 
137 static PointerRNA rna_Volume_grids_get(CollectionPropertyIterator *iter)
138 {
139  Volume *volume = iter->internal.count.ptr;
140  const VolumeGrid *grid = BKE_volume_grid_get_for_read(volume, iter->internal.count.item);
141  return rna_pointer_inherit_refine(&iter->parent, &RNA_VolumeGrid, (void *)grid);
142 }
143 
144 static int rna_Volume_grids_length(PointerRNA *ptr)
145 {
146  Volume *volume = ptr->data;
147  return BKE_volume_num_grids(volume);
148 }
149 
150 /* Active Grid */
151 
152 static void rna_VolumeGrids_active_index_range(
153  PointerRNA *ptr, int *min, int *max, int *UNUSED(softmin), int *UNUSED(softmax))
154 {
155  Volume *volume = (Volume *)ptr->data;
156  int num_grids = BKE_volume_num_grids(volume);
157 
158  *min = 0;
159  *max = max_ii(0, num_grids - 1);
160 }
161 
162 static int rna_VolumeGrids_active_index_get(PointerRNA *ptr)
163 {
164  Volume *volume = (Volume *)ptr->data;
165  int num_grids = BKE_volume_num_grids(volume);
166  return clamp_i(volume->active_grid, 0, max_ii(num_grids - 1, 0));
167 }
168 
169 static void rna_VolumeGrids_active_index_set(PointerRNA *ptr, int value)
170 {
171  Volume *volume = (Volume *)ptr->data;
172  volume->active_grid = value;
173 }
174 
175 /* Loading */
176 
177 static bool rna_VolumeGrids_is_loaded_get(PointerRNA *ptr)
178 {
179  Volume *volume = (Volume *)ptr->data;
180  return BKE_volume_is_loaded(volume);
181 }
182 
183 /* Error Message */
184 
185 static void rna_VolumeGrids_error_message_get(PointerRNA *ptr, char *value)
186 {
187  Volume *volume = (Volume *)ptr->data;
188  strcpy(value, BKE_volume_grids_error_msg(volume));
189 }
190 
191 static int rna_VolumeGrids_error_message_length(PointerRNA *ptr)
192 {
193  Volume *volume = (Volume *)ptr->data;
194  return strlen(BKE_volume_grids_error_msg(volume));
195 }
196 
197 /* Frame Filepath */
198 static void rna_VolumeGrids_frame_filepath_get(PointerRNA *ptr, char *value)
199 {
200  Volume *volume = (Volume *)ptr->data;
201  strcpy(value, BKE_volume_grids_frame_filepath(volume));
202 }
203 
204 static int rna_VolumeGrids_frame_filepath_length(PointerRNA *ptr)
205 {
206  Volume *volume = (Volume *)ptr->data;
207  return strlen(BKE_volume_grids_frame_filepath(volume));
208 }
209 
210 static bool rna_Volume_load(Volume *volume, Main *bmain)
211 {
212  return BKE_volume_load(volume, bmain);
213 }
214 
215 static bool rna_Volume_save(Volume *volume, Main *bmain, ReportList *reports, const char *filepath)
216 {
217  return BKE_volume_save(volume, bmain, reports, filepath);
218 }
219 
220 #else
221 
222 static void rna_def_volume_grid(BlenderRNA *brna)
223 {
224  StructRNA *srna;
225  PropertyRNA *prop;
226 
227  srna = RNA_def_struct(brna, "VolumeGrid", NULL);
228  RNA_def_struct_ui_text(srna, "Volume Grid", "3D volume grid");
229  RNA_def_struct_ui_icon(srna, ICON_VOLUME_DATA);
230 
231  prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
234  prop, "rna_VolumeGrid_name_get", "rna_VolumeGrid_name_length", NULL);
235  RNA_def_property_ui_text(prop, "Name", "Volume grid name");
236 
237  static const EnumPropertyItem data_type_items[] = {
238  {VOLUME_GRID_BOOLEAN, "BOOLEAN", 0, "Boolean", "Boolean"},
239  {VOLUME_GRID_FLOAT, "FLOAT", 0, "Float", "Single precision float"},
240  {VOLUME_GRID_DOUBLE, "DOUBLE", 0, "Double", "Double precision"},
241  {VOLUME_GRID_INT, "INT", 0, "Integer", "32-bit integer"},
242  {VOLUME_GRID_INT64, "INT64", 0, "Integer 64-bit", "64-bit integer"},
243  {VOLUME_GRID_MASK, "MASK", 0, "Mask", "No data, boolean mask of active voxels"},
244  {VOLUME_GRID_STRING, "STRING", 0, "String", "Text string"},
245  {VOLUME_GRID_VECTOR_FLOAT, "VECTOR_FLOAT", 0, "Float Vector", "3D float vector"},
246  {VOLUME_GRID_VECTOR_DOUBLE, "VECTOR_DOUBLE", 0, "Double Vector", "3D double vector"},
247  {VOLUME_GRID_VECTOR_INT, "VECTOR_INT", 0, "Integer Vector", "3D integer vector"},
249  "POINTS",
250  0,
251  "Points (Unsupported)",
252  "Points grid, currently unsupported by volume objects"},
253  {VOLUME_GRID_UNKNOWN, "UNKNOWN", 0, "Unknown", "Unsupported data type"},
254  {0, NULL, 0, NULL, NULL},
255  };
256 
257  prop = RNA_def_property(srna, "data_type", PROP_ENUM, PROP_NONE);
259  RNA_def_property_enum_funcs(prop, "rna_VolumeGrid_data_type_get", NULL, NULL);
260  RNA_def_property_enum_items(prop, data_type_items);
261  RNA_def_property_ui_text(prop, "Data Type", "Data type of voxel values");
262 
263  prop = RNA_def_property(srna, "channels", PROP_INT, PROP_UNSIGNED);
265  RNA_def_property_int_funcs(prop, "rna_VolumeGrid_channels_get", NULL, NULL);
266  RNA_def_property_ui_text(prop, "Channels", "Number of dimensions of the grid data type");
267 
268  prop = RNA_def_property(srna, "matrix_object", PROP_FLOAT, PROP_MATRIX);
271  RNA_def_property_float_funcs(prop, "rna_VolumeGrid_matrix_object_get", NULL, NULL);
273  prop, "Matrix Object", "Transformation matrix from voxel index to object space");
274 
275  prop = RNA_def_property(srna, "is_loaded", PROP_BOOLEAN, PROP_NONE);
277  RNA_def_property_boolean_funcs(prop, "rna_VolumeGrid_is_loaded_get", NULL);
278  RNA_def_property_ui_text(prop, "Is Loaded", "Grid tree is loaded in memory");
279 
280  /* API */
281  FunctionRNA *func;
282  PropertyRNA *parm;
283 
284  func = RNA_def_function(srna, "load", "rna_VolumeGrid_load");
285  RNA_def_function_ui_description(func, "Load grid tree from file");
287  parm = RNA_def_boolean(func, "success", 0, "", "True if grid tree was successfully loaded");
288  RNA_def_function_return(func, parm);
289 
290  func = RNA_def_function(srna, "unload", "rna_VolumeGrid_unload");
293  func, "Unload grid tree and voxel data from memory, leaving only metadata");
294 }
295 
296 static void rna_def_volume_grids(BlenderRNA *brna, PropertyRNA *cprop)
297 {
298  StructRNA *srna;
299  PropertyRNA *prop;
300 
301  RNA_def_property_srna(cprop, "VolumeGrids");
302  srna = RNA_def_struct(brna, "VolumeGrids", NULL);
303  RNA_def_struct_sdna(srna, "Volume");
304  RNA_def_struct_ui_text(srna, "Volume Grids", "3D volume grids");
305 
306  prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
308  "rna_VolumeGrids_active_index_get",
309  "rna_VolumeGrids_active_index_set",
310  "rna_VolumeGrids_active_index_range");
311  RNA_def_property_ui_text(prop, "Active Grid Index", "Index of active volume grid");
312  RNA_def_property_update(prop, 0, "rna_Volume_update_display");
313 
314  prop = RNA_def_property(srna, "error_message", PROP_STRING, PROP_NONE);
317  prop, "rna_VolumeGrids_error_message_get", "rna_VolumeGrids_error_message_length", NULL);
319  prop, "Error Message", "If loading grids failed, error message with details");
320 
321  prop = RNA_def_property(srna, "is_loaded", PROP_BOOLEAN, PROP_NONE);
323  RNA_def_property_boolean_funcs(prop, "rna_VolumeGrids_is_loaded_get", NULL);
324  RNA_def_property_ui_text(prop, "Is Loaded", "List of grids and metadata are loaded in memory");
325 
326  prop = RNA_def_property(srna, "frame", PROP_INT, PROP_NONE);
327  RNA_def_property_int_sdna(prop, NULL, "runtime.frame");
330  "Frame",
331  "Frame number that volume grids will be loaded at, based on scene time "
332  "and volume parameters");
333 
334  prop = RNA_def_property(srna, "frame_filepath", PROP_STRING, PROP_FILEPATH);
337  prop, "rna_VolumeGrids_frame_filepath_get", "rna_VolumeGrids_frame_filepath_length", NULL);
338 
340  "Frame File Path",
341  "Volume file used for loading the volume at the current frame. Empty "
342  "if the volume has not be loaded or the frame only exists in memory");
343 
344  /* API */
345  FunctionRNA *func;
346  PropertyRNA *parm;
347 
348  func = RNA_def_function(srna, "load", "rna_Volume_load");
349  RNA_def_function_ui_description(func, "Load list of grids and metadata from file");
351  parm = RNA_def_boolean(func, "success", 0, "", "True if grid list was successfully loaded");
352  RNA_def_function_return(func, parm);
353 
354  func = RNA_def_function(srna, "unload", "BKE_volume_unload");
355  RNA_def_function_ui_description(func, "Unload all grid and voxel data from memory");
356 
357  func = RNA_def_function(srna, "save", "rna_Volume_save");
358  RNA_def_function_ui_description(func, "Save grids and metadata to file");
360  parm = RNA_def_string_file_path(func, "filepath", NULL, 0, "", "File path to save to");
362  parm = RNA_def_boolean(func, "success", 0, "", "True if grid list was successfully loaded");
363  RNA_def_function_return(func, parm);
364 }
365 
367 {
368  StructRNA *srna;
369  PropertyRNA *prop;
370 
371  srna = RNA_def_struct(brna, "VolumeDisplay", NULL);
372  RNA_def_struct_ui_text(srna, "Volume Display", "Volume object display settings for 3D viewport");
373  RNA_def_struct_sdna(srna, "VolumeDisplay");
374 
375  prop = RNA_def_property(srna, "density", PROP_FLOAT, PROP_NONE);
377  RNA_def_property_range(prop, 0.00001, FLT_MAX);
378  RNA_def_property_ui_range(prop, 0.1, 100.0, 1, 3);
379  RNA_def_property_ui_text(prop, "Density", "Thickness of volume display in the viewport");
380  RNA_def_property_update(prop, 0, "rna_Volume_update_display");
381 
382  static const EnumPropertyItem wireframe_type_items[] = {
383  {VOLUME_WIREFRAME_NONE, "NONE", 0, "None", "Don't display volume in wireframe mode"},
385  "BOUNDS",
386  0,
387  "Bounds",
388  "Display single bounding box for the entire grid"},
390  "BOXES",
391  0,
392  "Boxes",
393  "Display bounding boxes for nodes in the volume tree"},
395  "POINTS",
396  0,
397  "Points",
398  "Display points for nodes in the volume tree"},
399  {0, NULL, 0, NULL, NULL},
400  };
401 
402  static const EnumPropertyItem wireframe_detail_items[] = {
404  "COARSE",
405  0,
406  "Coarse",
407  "Display one box or point for each intermediate tree node"},
409  "FINE",
410  0,
411  "Fine",
412  "Display box for each leaf node containing 8x8 voxels"},
413  {0, NULL, 0, NULL, NULL},
414  };
415 
416  static const EnumPropertyItem interpolation_method_items[] = {
417  {VOLUME_DISPLAY_INTERP_LINEAR, "LINEAR", 0, "Linear", "Good smoothness and speed"},
419  "CUBIC",
420  0,
421  "Cubic",
422  "Smoothed high quality interpolation, but slower"},
423  {VOLUME_DISPLAY_INTERP_CLOSEST, "CLOSEST", 0, "Closest", "No interpolation"},
424  {0, NULL, 0, NULL, NULL},
425  };
426 
427  static const EnumPropertyItem axis_slice_position_items[] = {
429  "AUTO",
430  0,
431  "Auto",
432  "Adjust slice direction according to the view direction"},
433  {VOLUME_SLICE_AXIS_X, "X", 0, "X", "Slice along the X axis"},
434  {VOLUME_SLICE_AXIS_Y, "Y", 0, "Y", "Slice along the Y axis"},
435  {VOLUME_SLICE_AXIS_Z, "Z", 0, "Z", "Slice along the Z axis"},
436  {0, NULL, 0, NULL, NULL},
437  };
438 
439  prop = RNA_def_property(srna, "wireframe_type", PROP_ENUM, PROP_NONE);
440  RNA_def_property_enum_items(prop, wireframe_type_items);
441  RNA_def_property_ui_text(prop, "Wireframe", "Type of wireframe display");
442  RNA_def_property_update(prop, 0, "rna_Volume_update_display");
443 
444  prop = RNA_def_property(srna, "wireframe_detail", PROP_ENUM, PROP_NONE);
445  RNA_def_property_enum_items(prop, wireframe_detail_items);
446  RNA_def_property_ui_text(prop, "Wireframe Detail", "Amount of detail for wireframe display");
447  RNA_def_property_update(prop, 0, "rna_Volume_update_display");
448 
449  prop = RNA_def_property(srna, "interpolation_method", PROP_ENUM, PROP_NONE);
450  RNA_def_property_enum_items(prop, interpolation_method_items);
452  prop, "Interpolation", "Interpolation method to use for volumes in solid mode");
453  RNA_def_property_update(prop, 0, "rna_Volume_update_display");
454 
455  prop = RNA_def_property(srna, "use_slice", PROP_BOOLEAN, PROP_NONE);
456  RNA_def_property_boolean_sdna(prop, NULL, "axis_slice_method", VOLUME_AXIS_SLICE_SINGLE);
457  RNA_def_property_ui_text(prop, "Slice", "Perform a single slice of the domain object");
458  RNA_def_property_update(prop, 0, "rna_Volume_update_display");
459 
460  prop = RNA_def_property(srna, "slice_axis", PROP_ENUM, PROP_NONE);
461  RNA_def_property_enum_items(prop, axis_slice_position_items);
462  RNA_def_property_ui_text(prop, "Axis", "");
463  RNA_def_property_update(prop, 0, "rna_Volume_update_display");
464 
465  prop = RNA_def_property(srna, "slice_depth", PROP_FLOAT, PROP_FACTOR);
466  RNA_def_property_range(prop, 0.0, 1.0);
467  RNA_def_property_ui_range(prop, 0.0, 1.0, 0.1, 3);
468  RNA_def_property_ui_text(prop, "Position", "Position of the slice");
469  RNA_def_property_update(prop, 0, "rna_Volume_update_display");
470 }
471 
473 {
474  StructRNA *srna;
475  PropertyRNA *prop;
476 
477  srna = RNA_def_struct(brna, "VolumeRender", NULL);
478  RNA_def_struct_ui_text(srna, "Volume Render", "Volume object render settings");
479  RNA_def_struct_sdna(srna, "VolumeRender");
480 
481  static const EnumPropertyItem space_items[] = {
483  "OBJECT",
484  0,
485  "Object",
486  "Keep volume opacity and detail the same regardless of object scale"},
488  "WORLD",
489  0,
490  "World",
491  "Specify volume step size and density in world space"},
492  {0, NULL, 0, NULL, NULL},
493  };
494 
495  prop = RNA_def_property(srna, "space", PROP_ENUM, PROP_NONE);
498  prop, "Space", "Specify volume density and step size in object or world space");
499  RNA_def_property_update(prop, 0, "rna_Volume_update_display");
500 
501  prop = RNA_def_property(srna, "step_size", PROP_FLOAT, PROP_DISTANCE);
503  RNA_def_property_range(prop, 0.0, FLT_MAX);
504  RNA_def_property_ui_range(prop, 0.0, 100.0, 1, 3);
506  "Step Size",
507  "Distance between volume samples. Lower values render more detail at "
508  "the cost of performance. If set to zero, the step size is "
509  "automatically determined based on voxel size");
510  RNA_def_property_update(prop, 0, "rna_Volume_update_display");
511 
512  prop = RNA_def_property(srna, "clipping", PROP_FLOAT, PROP_NONE);
513  RNA_def_property_float_sdna(prop, NULL, "clipping");
514  RNA_def_property_range(prop, 0.0, 1.0);
515  RNA_def_property_ui_range(prop, 0.0, 1.0, 0.1, 3);
517  prop,
518  "Clipping",
519  "Value under which voxels are considered empty space to optimize rendering");
520  RNA_def_property_update(prop, 0, "rna_Volume_update_display");
521 }
522 
523 static void rna_def_volume(BlenderRNA *brna)
524 {
525  StructRNA *srna;
526  PropertyRNA *prop;
527 
528  srna = RNA_def_struct(brna, "Volume", "ID");
529  RNA_def_struct_ui_text(srna, "Volume", "Volume data-block for 3D volume grids");
530  RNA_def_struct_ui_icon(srna, ICON_VOLUME_DATA);
531 
532  /* File */
533  prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH);
535  RNA_def_property_ui_text(prop, "File Path", "Volume file used by this Volume data-block");
536  RNA_def_property_update(prop, 0, "rna_Volume_update_filepath");
537 
538  prop = RNA_def_property(srna, "packed_file", PROP_POINTER, PROP_NONE);
539  RNA_def_property_pointer_sdna(prop, NULL, "packedfile");
540  RNA_def_property_ui_text(prop, "Packed File", "");
541 
542  /* Sequence */
543  prop = RNA_def_property(srna, "is_sequence", PROP_BOOLEAN, PROP_NONE);
546  prop, "Sequence", "Whether the cache is separated in a series of files");
547  RNA_def_property_update(prop, 0, "rna_Volume_update_is_sequence");
548 
549  prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_TIME);
553  prop, "Start Frame", "Global starting frame of the sequence, assuming first has a #1");
554  RNA_def_property_update(prop, 0, "rna_Volume_update_filepath");
555 
556  prop = RNA_def_property(srna, "frame_duration", PROP_INT, PROP_NONE);
559  RNA_def_property_ui_text(prop, "Frames", "Number of frames of the sequence to use");
560  RNA_def_property_update(prop, 0, "rna_Volume_update_filepath");
561 
562  prop = RNA_def_property(srna, "frame_offset", PROP_INT, PROP_NONE);
564  prop, "Offset", "Offset the number of the frame to use in the animation");
565  RNA_def_property_update(prop, 0, "rna_Volume_update_filepath");
566 
567  static const EnumPropertyItem sequence_mode_items[] = {
568  {VOLUME_SEQUENCE_CLIP, "CLIP", 0, "Clip", "Hide frames outside the specified frame range"},
570  "EXTEND",
571  0,
572  "Extend",
573  "Repeat the start frame before, and the end frame after the frame range"},
574  {VOLUME_SEQUENCE_REPEAT, "REPEAT", 0, "Repeat", "Cycle the frames in the sequence"},
576  "PING_PONG",
577  0,
578  "Ping-Pong",
579  "Repeat the frames, reversing the playback direction every other cycle"},
580  {0, NULL, 0, NULL, NULL},
581  };
582 
583  prop = RNA_def_property(srna, "sequence_mode", PROP_ENUM, PROP_NONE);
585  RNA_def_property_enum_items(prop, sequence_mode_items);
586  RNA_def_property_ui_text(prop, "Sequence Mode", "Sequence playback mode");
587  RNA_def_property_update(prop, 0, "rna_Volume_update_filepath");
588 
589  /* Grids */
590  prop = RNA_def_property(srna, "grids", PROP_COLLECTION, PROP_NONE);
591  RNA_def_property_struct_type(prop, "VolumeGrid");
592  RNA_def_property_ui_text(prop, "Grids", "3D volume grids");
594  "rna_Volume_grids_begin",
595  "rna_Volume_grids_next",
596  "rna_Volume_grids_end",
597  "rna_Volume_grids_get",
598  "rna_Volume_grids_length",
599  NULL,
600  NULL,
601  NULL);
602  rna_def_volume_grids(brna, prop);
603 
604  /* Materials */
605  prop = RNA_def_property(srna, "materials", PROP_COLLECTION, PROP_NONE);
606  RNA_def_property_collection_sdna(prop, NULL, "mat", "totcol");
607  RNA_def_property_struct_type(prop, "Material");
608  RNA_def_property_ui_text(prop, "Materials", "");
609  RNA_def_property_srna(prop, "IDMaterials"); /* see rna_ID.c */
611  prop, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "rna_IDMaterials_assign_int");
612 
613  /* Display */
614  prop = RNA_def_property(srna, "display", PROP_POINTER, PROP_NONE);
615  RNA_def_property_pointer_sdna(prop, NULL, "display");
616  RNA_def_property_struct_type(prop, "VolumeDisplay");
617  RNA_def_property_ui_text(prop, "Display", "Volume display settings for 3D viewport");
618 
619  /* Render */
620  prop = RNA_def_property(srna, "render", PROP_POINTER, PROP_NONE);
621  RNA_def_property_pointer_sdna(prop, NULL, "render");
622  RNA_def_property_struct_type(prop, "VolumeRender");
623  RNA_def_property_ui_text(prop, "Render", "Volume render settings for 3D viewport");
624 
625  /* Common */
627 }
628 
630 {
631  rna_def_volume_grid(brna);
633  rna_def_volume_render(brna);
634  rna_def_volume(brna);
635 }
636 
637 #endif
Volume datablock.
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:107
@ VOLUME_GRID_MASK
Definition: BKE_volume.h:105
@ VOLUME_GRID_VECTOR_DOUBLE
Definition: BKE_volume.h:108
@ VOLUME_GRID_VECTOR_INT
Definition: BKE_volume.h:109
@ VOLUME_GRID_UNKNOWN
Definition: BKE_volume.h:99
@ VOLUME_GRID_DOUBLE
Definition: BKE_volume.h:102
@ VOLUME_GRID_BOOLEAN
Definition: BKE_volume.h:100
@ VOLUME_GRID_INT
Definition: BKE_volume.h:103
@ VOLUME_GRID_INT64
Definition: BKE_volume.h:104
@ VOLUME_GRID_POINTS
Definition: BKE_volume.h:110
@ VOLUME_GRID_FLOAT
Definition: BKE_volume.h:101
@ VOLUME_GRID_STRING
Definition: BKE_volume.h:106
void BKE_volume_grid_transform_matrix(const struct VolumeGrid *grid, float mat[4][4])
void BKE_volume_unload(struct Volume *volume)
Definition: volume.cc:849
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_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)
#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:654
#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_WIREFRAME_COARSE
@ VOLUME_WIREFRAME_FINE
@ PARM_REQUIRED
Definition: RNA_types.h:337
@ FUNC_USE_REPORTS
Definition: RNA_types.h:578
@ FUNC_USE_MAIN
Definition: RNA_types.h:576
@ FUNC_USE_SELF_ID
Definition: RNA_types.h:565
@ PROP_FLOAT
Definition: RNA_types.h:75
@ PROP_BOOLEAN
Definition: RNA_types.h:73
@ PROP_ENUM
Definition: RNA_types.h:77
@ PROP_INT
Definition: RNA_types.h:74
@ PROP_STRING
Definition: RNA_types.h:76
@ PROP_POINTER
Definition: RNA_types.h:78
@ PROP_COLLECTION
Definition: RNA_types.h:79
@ PROP_ANIMATABLE
Definition: RNA_types.h:188
@ PROP_EDITABLE
Definition: RNA_types.h:175
@ PROP_TIME
Definition: RNA_types.h:133
@ PROP_MATRIX
Definition: RNA_types.h:144
@ PROP_DISTANCE
Definition: RNA_types.h:135
@ PROP_NONE
Definition: RNA_types.h:113
@ PROP_FACTOR
Definition: RNA_types.h:131
@ PROP_UNSIGNED
Definition: RNA_types.h:129
@ PROP_FILEPATH
Definition: RNA_types.h:116
#define NC_GEOM
Definition: WM_types.h:294
#define ND_DATA
Definition: WM_types.h:408
Scene scene
PointerRNA rna_pointer_inherit_refine(PointerRNA *ptr, StructRNA *type, void *data)
Definition: rna_access.c:196
void rna_def_animdata_common(StructRNA *srna)
void RNA_def_property_pointer_sdna(PropertyRNA *prop, const char *structname, const char *propname)
Definition: rna_define.c:2762
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, bool default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3481
void RNA_def_property_boolean_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t bit)
Definition: rna_define.c:2257
void RNA_def_property_string_funcs(PropertyRNA *prop, const char *get, const char *length, const char *set)
Definition: rna_define.c:3312
void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret)
Definition: rna_define.c:4302
void RNA_def_property_float_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
Definition: rna_define.c:3153
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
Definition: rna_define.c:1676
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:3699
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier, const char *call)
Definition: rna_define.c:4262
void RNA_def_property_srna(PropertyRNA *prop, const char *type)
Definition: rna_define.c:3462
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:3408
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
Definition: rna_define.c:1259
void RNA_def_property_boolean_funcs(PropertyRNA *prop, const char *get, const char *set)
Definition: rna_define.c:2971
void RNA_def_property_multi_array(PropertyRNA *prop, int dimension, const int length[])
Definition: rna_define.c:1629
void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item)
Definition: rna_define.c:1892
void RNA_def_struct_sdna(StructRNA *srna, const char *structname)
Definition: rna_define.c:1067
void RNA_def_property_range(PropertyRNA *prop, double min, double max)
Definition: rna_define.c:1757
void RNA_def_property_struct_type(PropertyRNA *prop, const char *type)
Definition: rna_define.c:1792
void RNA_def_property_collection_sdna(PropertyRNA *prop, const char *structname, const char *propname, const char *lengthpropname)
Definition: rna_define.c:2791
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
Definition: rna_define.c:4337
void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *func)
Definition: rna_define.c:2927
const int rna_matrix_dimsize_4x4[]
Definition: rna_define.c:1626
void RNA_def_property_enum_funcs(PropertyRNA *prop, const char *get, const char *set, const char *item)
Definition: rna_define.c:3251
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype)
Definition: rna_define.c:1279
void RNA_def_function_flag(FunctionRNA *func, int flag)
Definition: rna_define.c:4332
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
Definition: rna_define.c:1517
StructRNA * RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
Definition: rna_define.c:1047
void RNA_def_property_int_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
Definition: rna_define.c:3055
void RNA_def_struct_ui_icon(StructRNA *srna, int icon)
Definition: rna_define.c:1267
void RNA_def_property_float_sdna(PropertyRNA *prop, const char *structname, const char *propname)
Definition: rna_define.c:2515
void RNA_def_property_ui_range(PropertyRNA *prop, double min, double max, double step, int precision)
Definition: rna_define.c:1706
void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const char *propname)
Definition: rna_define.c:2364
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
Definition: rna_define.c:1547
static const EnumPropertyItem space_items[]
static void rna_def_volume_display(BlenderRNA *brna)
Definition: rna_volume.c:366
static void rna_def_volume(BlenderRNA *brna)
Definition: rna_volume.c:523
static void rna_def_volume_render(BlenderRNA *brna)
Definition: rna_volume.c:472
static void rna_def_volume_grids(BlenderRNA *brna, PropertyRNA *cprop)
Definition: rna_volume.c:296
static void rna_def_volume_grid(BlenderRNA *brna)
Definition: rna_volume.c:222
void RNA_def_volume(BlenderRNA *brna)
Definition: rna_volume.c:629
#define min(a, b)
Definition: sort.c:51
union CollectionPropertyIterator::@1099 internal
void * ptr
Definition: RNA_types.h:383
Definition: DNA_ID.h:273
Definition: BKE_main.h:116
void * data
Definition: RNA_types.h:52
struct ID * owner_id
Definition: RNA_types.h:50
int active_grid
float max
void WM_main_add_notifier(unsigned int type, void *reference)
PointerRNA * ptr
Definition: wm_files.c:3157