Welcome to mirror list, hosted at ThFree Co, Russian Federation.

rna_volume.c « intern « makesrna « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b03d6082cea2d2985f9d534e94ff3005b8582472 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
/*
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */

/** \file
 * \ingroup RNA
 */

#include <stdlib.h>

#include "RNA_access.h"
#include "RNA_define.h"
#include "RNA_enum_types.h"

#include "rna_internal.h"

#include "DNA_scene_types.h"
#include "DNA_volume_types.h"

#include "BKE_volume.h"

#include "BLI_math_base.h"

#ifdef RNA_RUNTIME

#  include "DEG_depsgraph.h"
#  include "DEG_depsgraph_build.h"

#  include "WM_api.h"
#  include "WM_types.h"

/* Updates */

static void rna_Volume_update_display(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
  Volume *volume = (Volume *)ptr->owner_id;
  WM_main_add_notifier(NC_GEOM | ND_DATA, volume);
}

static void rna_Volume_update_filepath(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
  Volume *volume = (Volume *)ptr->owner_id;
  BKE_volume_unload(volume);
  DEG_id_tag_update(&volume->id, ID_RECALC_COPY_ON_WRITE);
  WM_main_add_notifier(NC_GEOM | ND_DATA, volume);
}

static void rna_Volume_update_is_sequence(Main *bmain, Scene *scene, PointerRNA *ptr)
{
  rna_Volume_update_filepath(bmain, scene, ptr);
  DEG_relations_tag_update(bmain);
}

/* Grid */

static void rna_VolumeGrid_name_get(PointerRNA *ptr, char *value)
{
  VolumeGrid *grid = ptr->data;
  strcpy(value, BKE_volume_grid_name(grid));
}

static int rna_VolumeGrid_name_length(PointerRNA *ptr)
{
  VolumeGrid *grid = ptr->data;
  return strlen(BKE_volume_grid_name(grid));
}

static int rna_VolumeGrid_data_type_get(PointerRNA *ptr)
{
  const VolumeGrid *grid = ptr->data;
  return BKE_volume_grid_type(grid);
}

static int rna_VolumeGrid_channels_get(PointerRNA *ptr)
{
  const VolumeGrid *grid = ptr->data;
  return BKE_volume_grid_channels(grid);
}

static void rna_VolumeGrid_matrix_object_get(PointerRNA *ptr, float *value)
{
  VolumeGrid *grid = ptr->data;
  BKE_volume_grid_transform_matrix(grid, (float(*)[4])value);
}

static bool rna_VolumeGrid_is_loaded_get(PointerRNA *ptr)
{
  VolumeGrid *grid = ptr->data;
  return BKE_volume_grid_is_loaded(grid);
}

static bool rna_VolumeGrid_load(ID *id, VolumeGrid *grid)
{
  return BKE_volume_grid_load((Volume *)id, grid);
}

static void rna_VolumeGrid_unload(ID *id, VolumeGrid *grid)
{
  BKE_volume_grid_unload((Volume *)id, grid);
}

/* Grids Iterator */

static void rna_Volume_grids_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
  Volume *volume = ptr->data;
  int num_grids = BKE_volume_num_grids(volume);
  iter->internal.count.ptr = volume;
  iter->internal.count.item = 0;
  iter->valid = (iter->internal.count.item < num_grids);
}

static void rna_Volume_grids_next(CollectionPropertyIterator *iter)
{
  Volume *volume = iter->internal.count.ptr;
  int num_grids = BKE_volume_num_grids(volume);
  iter->internal.count.item++;
  iter->valid = (iter->internal.count.item < num_grids);
}

static void rna_Volume_grids_end(CollectionPropertyIterator *UNUSED(iter))
{
}

static PointerRNA rna_Volume_grids_get(CollectionPropertyIterator *iter)
{
  Volume *volume = iter->internal.count.ptr;
  const VolumeGrid *grid = BKE_volume_grid_get(volume, iter->internal.count.item);
  return rna_pointer_inherit_refine(&iter->parent, &RNA_VolumeGrid, (void *)grid);
}

static int rna_Volume_grids_length(PointerRNA *ptr)
{
  Volume *volume = ptr->data;
  return BKE_volume_num_grids(volume);
}

/* Active Grid */

static void rna_VolumeGrids_active_index_range(
    PointerRNA *ptr, int *min, int *max, int *UNUSED(softmin), int *UNUSED(softmax))
{
  Volume *volume = (Volume *)ptr->data;
  int num_grids = BKE_volume_num_grids(volume);

  *min = 0;
  *max = max_ii(0, num_grids - 1);
}

static int rna_VolumeGrids_active_index_get(PointerRNA *ptr)
{
  Volume *volume = (Volume *)ptr->data;
  int num_grids = BKE_volume_num_grids(volume);
  return clamp_i(volume->active_grid, 0, max_ii(num_grids - 1, 0));
}

static void rna_VolumeGrids_active_index_set(PointerRNA *ptr, int value)
{
  Volume *volume = (Volume *)ptr->data;
  volume->active_grid = value;
}

/* Loading */

static bool rna_VolumeGrids_is_loaded_get(PointerRNA *ptr)
{
  Volume *volume = (Volume *)ptr->data;
  return BKE_volume_is_loaded(volume);
}

/* Error Message */

static void rna_VolumeGrids_error_message_get(PointerRNA *ptr, char *value)
{
  Volume *volume = (Volume *)ptr->data;
  strcpy(value, BKE_volume_grids_error_msg(volume));
}

static int rna_VolumeGrids_error_message_length(PointerRNA *ptr)
{
  Volume *volume = (Volume *)ptr->data;
  return strlen(BKE_volume_grids_error_msg(volume));
}

/* Frame Filepath */
static void rna_VolumeGrids_frame_filepath_get(PointerRNA *ptr, char *value)
{
  Volume *volume = (Volume *)ptr->data;
  strcpy(value, BKE_volume_grids_frame_filepath(volume));
}

static int rna_VolumeGrids_frame_filepath_length(PointerRNA *ptr)
{
  Volume *volume = (Volume *)ptr->data;
  return strlen(BKE_volume_grids_frame_filepath(volume));
}

#else

static void rna_def_volume_grid(BlenderRNA *brna)
{
  StructRNA *srna;
  PropertyRNA *prop;

  srna = RNA_def_struct(brna, "VolumeGrid", NULL);
  RNA_def_struct_ui_text(srna, "Volume Grid", "3D volume grid");
  RNA_def_struct_ui_icon(srna, ICON_VOLUME_DATA);

  prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
  RNA_def_property_clear_flag(prop, PROP_EDITABLE);
  RNA_def_property_string_funcs(
      prop, "rna_VolumeGrid_name_get", "rna_VolumeGrid_name_length", NULL);
  RNA_def_property_ui_text(prop, "Name", "Volume grid name");

  static const EnumPropertyItem data_type_items[] = {
      {VOLUME_GRID_BOOLEAN, "BOOLEAN", 0, "Boolean", "Boolean"},
      {VOLUME_GRID_FLOAT, "FLOAT", 0, "Float", "Single precision float"},
      {VOLUME_GRID_DOUBLE, "DOUBLE", 0, "Double", "Double precision"},
      {VOLUME_GRID_INT, "INT", 0, "Integer", "32 bit integer"},
      {VOLUME_GRID_INT64, "INT64", 0, "Integer 64 bit", "64 bit integer"},
      {VOLUME_GRID_MASK, "MASK", 0, "Mask", "No data, boolean mask of active voxels"},
      {VOLUME_GRID_STRING, "STRING", 0, "String", "Text string"},
      {VOLUME_GRID_VECTOR_FLOAT, "VECTOR_FLOAT", 0, "Float Vector", "3D float vector"},
      {VOLUME_GRID_VECTOR_DOUBLE, "VECTOR_DOUBLE", 0, "Double Vector", "3D double vector"},
      {VOLUME_GRID_VECTOR_INT, "VECTOR_INT", 0, "Integer Vector", "3D integer vector"},
      {VOLUME_GRID_POINTS,
       "POINTS",
       0,
       "Points (Unsupported)",
       "Points grid, currently unsupported by volume objects"},
      {VOLUME_GRID_UNKNOWN, "UNKNOWN", 0, "Unknown", "Unsupported data type"},
      {0, NULL, 0, NULL, NULL},
  };

  prop = RNA_def_property(srna, "data_type", PROP_ENUM, PROP_NONE);
  RNA_def_property_clear_flag(prop, PROP_EDITABLE);
  RNA_def_property_enum_funcs(prop, "rna_VolumeGrid_data_type_get", NULL, NULL);
  RNA_def_property_enum_items(prop, data_type_items);
  RNA_def_property_ui_text(prop, "Data Type", "Data type of voxel values");

  prop = RNA_def_property(srna, "channels", PROP_INT, PROP_UNSIGNED);
  RNA_def_property_clear_flag(prop, PROP_EDITABLE);
  RNA_def_property_int_funcs(prop, "rna_VolumeGrid_channels_get", NULL, NULL);
  RNA_def_property_ui_text(prop, "Channels", "Number of dimensions of the grid data type");

  prop = RNA_def_property(srna, "matrix_object", PROP_FLOAT, PROP_MATRIX);
  RNA_def_property_clear_flag(prop, PROP_EDITABLE);
  RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4);
  RNA_def_property_float_funcs(prop, "rna_VolumeGrid_matrix_object_get", NULL, NULL);
  RNA_def_property_ui_text(
      prop, "Matrix Object", "Transformation matrix from voxel index to object space");

  prop = RNA_def_property(srna, "is_loaded", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_clear_flag(prop, PROP_EDITABLE);
  RNA_def_property_boolean_funcs(prop, "rna_VolumeGrid_is_loaded_get", NULL);
  RNA_def_property_ui_text(prop, "Is Loaded", "Grid tree is loaded in memory");

  /* API */
  FunctionRNA *func;
  PropertyRNA *parm;

  func = RNA_def_function(srna, "load", "rna_VolumeGrid_load");
  RNA_def_function_ui_description(func, "Load grid tree from file");
  RNA_def_function_flag(func, FUNC_USE_SELF_ID);
  parm = RNA_def_boolean(func, "success", 0, "", "True if grid tree was successfully loaded");
  RNA_def_function_return(func, parm);

  func = RNA_def_function(srna, "unload", "rna_VolumeGrid_unload");
  RNA_def_function_flag(func, FUNC_USE_SELF_ID);
  RNA_def_function_ui_description(
      func, "Unload grid tree and voxel data from memory, leaving only metadata");
}

static void rna_def_volume_grids(BlenderRNA *brna, PropertyRNA *cprop)
{
  StructRNA *srna;
  PropertyRNA *prop;

  RNA_def_property_srna(cprop, "VolumeGrids");
  srna = RNA_def_struct(brna, "VolumeGrids", NULL);
  RNA_def_struct_sdna(srna, "Volume");
  RNA_def_struct_ui_text(srna, "Volume Grids", "3D volume grids");

  prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
  RNA_def_property_int_funcs(prop,
                             "rna_VolumeGrids_active_index_get",
                             "rna_VolumeGrids_active_index_set",
                             "rna_VolumeGrids_active_index_range");
  RNA_def_property_ui_text(prop, "Active Grid Index", "Index of active volume grid");
  RNA_def_property_update(prop, 0, "rna_Volume_update_display");

  prop = RNA_def_property(srna, "error_message", PROP_STRING, PROP_NONE);
  RNA_def_property_clear_flag(prop, PROP_EDITABLE);
  RNA_def_property_string_funcs(
      prop, "rna_VolumeGrids_error_message_get", "rna_VolumeGrids_error_message_length", NULL);
  RNA_def_property_ui_text(
      prop, "Error Message", "If loading grids failed, error message with details");

  prop = RNA_def_property(srna, "is_loaded", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_clear_flag(prop, PROP_EDITABLE);
  RNA_def_property_boolean_funcs(prop, "rna_VolumeGrids_is_loaded_get", NULL);
  RNA_def_property_ui_text(prop, "Is Loaded", "List of grids and metadata are loaded in memory");

  prop = RNA_def_property(srna, "frame", PROP_INT, PROP_NONE);
  RNA_def_property_int_sdna(prop, NULL, "runtime.frame");
  RNA_def_property_clear_flag(prop, PROP_EDITABLE);
  RNA_def_property_ui_text(prop,
                           "Frame",
                           "Frame number that volume grids will be loaded at, based on scene time "
                           "and volume parameters");

  prop = RNA_def_property(srna, "frame_filepath", PROP_STRING, PROP_FILEPATH);
  RNA_def_property_clear_flag(prop, PROP_EDITABLE);
  RNA_def_property_string_funcs(
      prop, "rna_VolumeGrids_frame_filepath_get", "rna_VolumeGrids_frame_filepath_length", NULL);

  RNA_def_property_ui_text(prop,
                           "Frame File Path",
                           "Volume file used for loading the volume at the current frame. Empty "
                           "if the volume has not be loaded or the frame only exists in memory");

  /* API */
  FunctionRNA *func;
  PropertyRNA *parm;

  func = RNA_def_function(srna, "load", "BKE_volume_load");
  RNA_def_function_ui_description(func, "Load list of grids and metadata from file");
  RNA_def_function_flag(func, FUNC_USE_MAIN);
  parm = RNA_def_boolean(func, "success", 0, "", "True if grid list was successfully loaded");
  RNA_def_function_return(func, parm);

  func = RNA_def_function(srna, "unload", "BKE_volume_unload");
  RNA_def_function_ui_description(func, "Unload all grid and voxel data from memory");
}

static void rna_def_volume_display(BlenderRNA *brna)
{
  StructRNA *srna;
  PropertyRNA *prop;

  srna = RNA_def_struct(brna, "VolumeDisplay", NULL);
  RNA_def_struct_ui_text(srna, "Volume Display", "Volume object display settings for 3d viewport");
  RNA_def_struct_sdna(srna, "VolumeDisplay");

  prop = RNA_def_property(srna, "density", PROP_FLOAT, PROP_NONE);
  RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
  RNA_def_property_range(prop, 0.00001, FLT_MAX);
  RNA_def_property_ui_range(prop, 0.1, 100.0, 1, 3);
  RNA_def_property_ui_text(prop, "Density", "Thickness of volume drawing in the viewport");
  RNA_def_property_update(prop, 0, "rna_Volume_update_display");

  static const EnumPropertyItem wireframe_type_items[] = {
      {VOLUME_WIREFRAME_NONE, "NONE", 0, "None", "Don't display volume in wireframe mode"},
      {VOLUME_WIREFRAME_BOUNDS,
       "BOUNDS",
       0,
       "Bounds",
       "Display single bounding box for the entire grid"},
      {VOLUME_WIREFRAME_BOXES,
       "BOXES",
       0,
       "Boxes",
       "Display bounding boxes for nodes in the volume tree"},
      {VOLUME_WIREFRAME_POINTS,
       "POINTS",
       0,
       "Points",
       "Display points for nodes in the volume tree"},
      {0, NULL, 0, NULL, NULL},
  };

  static const EnumPropertyItem wireframe_detail_items[] = {
      {VOLUME_WIREFRAME_COARSE,
       "COARSE",
       0,
       "Coarse",
       "Display one box or point for each intermediate tree node"},
      {VOLUME_WIREFRAME_FINE,
       "FINE",
       0,
       "Fine",
       "Display box for each leaf node containing 8x8 voxels"},
      {0, NULL, 0, NULL, NULL},
  };

  prop = RNA_def_property(srna, "wireframe_type", PROP_ENUM, PROP_NONE);
  RNA_def_property_enum_items(prop, wireframe_type_items);
  RNA_def_property_ui_text(prop, "Wireframe", "Type of wireframe display");
  RNA_def_property_update(prop, 0, "rna_Volume_update_display");

  prop = RNA_def_property(srna, "wireframe_detail", PROP_ENUM, PROP_NONE);
  RNA_def_property_enum_items(prop, wireframe_detail_items);
  RNA_def_property_ui_text(prop, "Wireframe Detail", "Amount of detail for wireframe display");
  RNA_def_property_update(prop, 0, "rna_Volume_update_display");
}

static void rna_def_volume_render(BlenderRNA *brna)
{
  StructRNA *srna;
  PropertyRNA *prop;

  srna = RNA_def_struct(brna, "VolumeRender", NULL);
  RNA_def_struct_ui_text(srna, "Volume Render", "Volume object render settings");
  RNA_def_struct_sdna(srna, "VolumeRender");

  static const EnumPropertyItem space_items[] = {
      {VOLUME_SPACE_OBJECT,
       "OBJECT",
       0,
       "Object",
       "Keep volume opacity and detail the same regardless of object scale"},
      {VOLUME_SPACE_WORLD,
       "WORLD",
       0,
       "World",
       "Specify volume step size and density in world space"},
      {0, NULL, 0, NULL, NULL},
  };

  prop = RNA_def_property(srna, "space", PROP_ENUM, PROP_NONE);
  RNA_def_property_enum_items(prop, space_items);
  RNA_def_property_ui_text(
      prop, "Space", "Specify volume density and step size  in object or world space");
  RNA_def_property_update(prop, 0, "rna_Volume_update_display");

  prop = RNA_def_property(srna, "step_size", PROP_FLOAT, PROP_DISTANCE);
  RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
  RNA_def_property_range(prop, 0.0, FLT_MAX);
  RNA_def_property_ui_range(prop, 0.0, 100.0, 1, 3);
  RNA_def_property_ui_text(prop,
                           "Step Size",
                           "Distance between volume samples. Lower values render more detail at "
                           "the cost of performance. If set to zero, the step size is "
                           "automatically determined based on voxel size");
  RNA_def_property_update(prop, 0, "rna_Volume_update_display");

  prop = RNA_def_property(srna, "clipping", PROP_FLOAT, PROP_NONE);
  RNA_def_property_float_sdna(prop, NULL, "clipping");
  RNA_def_property_range(prop, 0.0, 1.0);
  RNA_def_property_ui_range(prop, 0.0, 1.0, 0.1, 3);
  RNA_def_property_ui_text(
      prop,
      "Clipping",
      "Value under which voxels are considered empty space to optimize rendering");
  RNA_def_property_update(prop, 0, "rna_Volume_update_display");
}

static void rna_def_volume(BlenderRNA *brna)
{
  StructRNA *srna;
  PropertyRNA *prop;

  srna = RNA_def_struct(brna, "Volume", "ID");
  RNA_def_struct_ui_text(srna, "Volume", "Volume data-block for 3D volume grids");
  RNA_def_struct_ui_icon(srna, ICON_VOLUME_DATA);

  /* File */
  prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH);
  RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
  RNA_def_property_ui_text(prop, "File Path", "Volume file used by this Volume data-block");
  RNA_def_property_update(prop, 0, "rna_Volume_update_filepath");

  prop = RNA_def_property(srna, "packed_file", PROP_POINTER, PROP_NONE);
  RNA_def_property_pointer_sdna(prop, NULL, "packedfile");
  RNA_def_property_ui_text(prop, "Packed File", "");

  /* Sequence */
  prop = RNA_def_property(srna, "is_sequence", PROP_BOOLEAN, PROP_NONE);
  RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
  RNA_def_property_ui_text(
      prop, "Sequence", "Whether the cache is separated in a series of files");
  RNA_def_property_update(prop, 0, "rna_Volume_update_is_sequence");

  prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_TIME);
  RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
  RNA_def_property_range(prop, MINAFRAMEF, MAXFRAMEF);
  RNA_def_property_ui_text(
      prop, "Start Frame", "Global starting frame of the sequence, assuming first has a #1");
  RNA_def_property_update(prop, 0, "rna_Volume_update_filepath");

  prop = RNA_def_property(srna, "frame_duration", PROP_INT, PROP_NONE);
  RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
  RNA_def_property_range(prop, 0, MAXFRAMEF);
  RNA_def_property_ui_text(prop, "Frames", "Number of frames of the sequence to use");
  RNA_def_property_update(prop, 0, "rna_Volume_update_filepath");

  prop = RNA_def_property(srna, "frame_offset", PROP_INT, PROP_NONE);
  RNA_def_property_ui_text(
      prop, "Offset", "Offset the number of the frame to use in the animation");
  RNA_def_property_update(prop, 0, "rna_Volume_update_filepath");

  static const EnumPropertyItem sequence_mode_items[] = {
      {VOLUME_SEQUENCE_CLIP, "CLIP", 0, "Clip", "Hide frames outside the specified frame range"},
      {VOLUME_SEQUENCE_EXTEND,
       "EXTEND",
       0,
       "Extend",
       "Repeat the start frame before, and the end frame after the frame range"},
      {VOLUME_SEQUENCE_REPEAT, "REPEAT", 0, "Repeat", "Cycle the frames in the sequence"},
      {VOLUME_SEQUENCE_PING_PONG,
       "PING_PONG",
       0,
       "Ping-Pong",
       "Repeat the frames, reversing the playback direction every other cycle"},
      {0, NULL, 0, NULL, NULL},
  };

  prop = RNA_def_property(srna, "sequence_mode", PROP_ENUM, PROP_NONE);
  RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
  RNA_def_property_enum_items(prop, sequence_mode_items);
  RNA_def_property_ui_text(prop, "Sequence Mode", "Sequence playback mode");
  RNA_def_property_update(prop, 0, "rna_Volume_update_filepath");

  /* Grids */
  prop = RNA_def_property(srna, "grids", PROP_COLLECTION, PROP_NONE);
  RNA_def_property_struct_type(prop, "VolumeGrid");
  RNA_def_property_ui_text(prop, "Grids", "3D volume grids");
  RNA_def_property_collection_funcs(prop,
                                    "rna_Volume_grids_begin",
                                    "rna_Volume_grids_next",
                                    "rna_Volume_grids_end",
                                    "rna_Volume_grids_get",
                                    "rna_Volume_grids_length",
                                    NULL,
                                    NULL,
                                    NULL);
  rna_def_volume_grids(brna, prop);

  /* Materials */
  prop = RNA_def_property(srna, "materials", PROP_COLLECTION, PROP_NONE);
  RNA_def_property_collection_sdna(prop, NULL, "mat", "totcol");
  RNA_def_property_struct_type(prop, "Material");
  RNA_def_property_ui_text(prop, "Materials", "");
  RNA_def_property_srna(prop, "IDMaterials"); /* see rna_ID.c */
  RNA_def_property_collection_funcs(
      prop, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "rna_IDMaterials_assign_int");

  /* Display */
  prop = RNA_def_property(srna, "display", PROP_POINTER, PROP_NONE);
  RNA_def_property_pointer_sdna(prop, NULL, "display");
  RNA_def_property_struct_type(prop, "VolumeDisplay");
  RNA_def_property_ui_text(prop, "Display", "Volume display settings for 3d viewport");

  /* Render */
  prop = RNA_def_property(srna, "render", PROP_POINTER, PROP_NONE);
  RNA_def_property_pointer_sdna(prop, NULL, "render");
  RNA_def_property_struct_type(prop, "VolumeRender");
  RNA_def_property_ui_text(prop, "Render", "Volume render settings for 3d viewport");

  /* Common */
  rna_def_animdata_common(srna);
}

void RNA_def_volume(BlenderRNA *brna)
{
  rna_def_volume_grid(brna);
  rna_def_volume_display(brna);
  rna_def_volume_render(brna);
  rna_def_volume(brna);
}

#endif