Blender  V2.93
rna_cachefile.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  * The Original Code is Copyright (C) 2016 Blender Foundation.
17  * All rights reserved.
18  */
19 
24 #include "DNA_cachefile_types.h"
25 #include "DNA_scene_types.h"
26 
27 #include "RNA_access.h"
28 #include "RNA_define.h"
29 #include "RNA_enum_types.h"
30 
31 #include "rna_internal.h"
32 
33 #ifdef RNA_RUNTIME
34 
35 # include "BLI_string.h"
36 
37 # include "BKE_cachefile.h"
38 
39 # include "DEG_depsgraph.h"
40 
41 # include "WM_api.h"
42 # include "WM_types.h"
43 
44 # ifdef WITH_ALEMBIC
45 # include "ABC_alembic.h"
46 # endif
47 
48 static void rna_CacheFile_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
49 {
50  CacheFile *cache_file = (CacheFile *)ptr->data;
51 
54 }
55 
56 static void rna_CacheFile_object_paths_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
57 {
58  CacheFile *cache_file = (CacheFile *)ptr->data;
59  rna_iterator_listbase_begin(iter, &cache_file->object_paths, NULL);
60 }
61 
62 #else
63 
64 /* cachefile.object_paths */
66 {
67  StructRNA *srna = RNA_def_struct(brna, "AlembicObjectPath", NULL);
68  RNA_def_struct_sdna(srna, "AlembicObjectPath");
69  RNA_def_struct_ui_text(srna, "Object Path", "Path of an object inside of an Alembic archive");
70  RNA_def_struct_ui_icon(srna, ICON_NONE);
71 
73 
74  PropertyRNA *prop = RNA_def_property(srna, "path", PROP_STRING, PROP_NONE);
75  RNA_def_property_ui_text(prop, "Path", "Object path");
76  RNA_def_struct_name_property(srna, prop);
77 
79 }
80 
81 /* cachefile.object_paths */
83 {
84  RNA_def_property_srna(cprop, "AlembicObjectPaths");
85  StructRNA *srna = RNA_def_struct(brna, "AlembicObjectPaths", NULL);
86  RNA_def_struct_sdna(srna, "CacheFile");
87  RNA_def_struct_ui_text(srna, "Object Paths", "Collection of object paths");
88 }
89 
90 static void rna_def_cachefile(BlenderRNA *brna)
91 {
92  StructRNA *srna = RNA_def_struct(brna, "CacheFile", "ID");
93  RNA_def_struct_sdna(srna, "CacheFile");
94  RNA_def_struct_ui_text(srna, "CacheFile", "");
95  RNA_def_struct_ui_icon(srna, ICON_FILE);
96 
98 
99  PropertyRNA *prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH);
100  RNA_def_property_ui_text(prop, "File Path", "Path to external displacements file");
101  RNA_def_property_update(prop, 0, "rna_CacheFile_update");
102 
103  prop = RNA_def_property(srna, "is_sequence", PROP_BOOLEAN, PROP_NONE);
105  prop, "Sequence", "Whether the cache is separated in a series of files");
106  RNA_def_property_update(prop, 0, "rna_CacheFile_update");
107 
108  /* ----------------- For Scene time ------------------- */
109 
110  prop = RNA_def_property(srna, "override_frame", PROP_BOOLEAN, PROP_NONE);
112  "Override Frame",
113  "Whether to use a custom frame for looking up data in the cache file,"
114  " instead of using the current scene frame");
115  RNA_def_property_update(prop, 0, "rna_CacheFile_update");
116 
117  prop = RNA_def_property(srna, "frame", PROP_FLOAT, PROP_NONE);
118  RNA_def_property_float_sdna(prop, NULL, "frame");
121  "Frame",
122  "The time to use for looking up the data in the cache file,"
123  " or to determine which file to use in a file sequence");
124  RNA_def_property_update(prop, 0, "rna_CacheFile_update");
125 
126  prop = RNA_def_property(srna, "frame_offset", PROP_FLOAT, PROP_NONE);
127  RNA_def_property_float_sdna(prop, NULL, "frame_offset");
130  "Frame Offset",
131  "Subtracted from the current frame to use for "
132  "looking up the data in the cache file, or to "
133  "determine which file to use in a file sequence");
134  RNA_def_property_update(prop, 0, "rna_CacheFile_update");
135 
136  /* ----------------- Axis Conversion ----------------- */
137 
138  prop = RNA_def_property(srna, "forward_axis", PROP_ENUM, PROP_NONE);
139  RNA_def_property_enum_sdna(prop, NULL, "forward_axis");
141  RNA_def_property_ui_text(prop, "Forward", "");
142  RNA_def_property_update(prop, 0, "rna_CacheFile_update");
143 
144  prop = RNA_def_property(srna, "up_axis", PROP_ENUM, PROP_NONE);
145  RNA_def_property_enum_sdna(prop, NULL, "up_axis");
147  RNA_def_property_ui_text(prop, "Up", "");
148  RNA_def_property_update(prop, 0, "rna_CacheFile_update");
149 
150  prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_NONE);
151  RNA_def_property_float_sdna(prop, NULL, "scale");
152  RNA_def_property_range(prop, 0.0001f, 1000.0f);
154  prop,
155  "Scale",
156  "Value by which to enlarge or shrink the object with respect to the world's origin"
157  " (only applicable through a Transform Cache constraint)");
158  RNA_def_property_update(prop, 0, "rna_CacheFile_update");
159 
160  /* object paths */
161  prop = RNA_def_property(srna, "object_paths", PROP_COLLECTION, PROP_NONE);
162  RNA_def_property_collection_sdna(prop, NULL, "object_paths", NULL);
164  "rna_CacheFile_object_paths_begin",
165  "rna_iterator_listbase_next",
166  "rna_iterator_listbase_end",
167  "rna_iterator_listbase_get",
168  NULL,
169  NULL,
170  NULL,
171  NULL);
172  RNA_def_property_struct_type(prop, "AlembicObjectPath");
173  RNA_def_property_srna(prop, "AlembicObjectPaths");
175  prop, "Object Paths", "Paths of the objects inside the Alembic archive");
176 
177  /* ----------------- Alembic Velocity Attribute ----------------- */
178 
179  prop = RNA_def_property(srna, "velocity_name", PROP_STRING, PROP_NONE);
181  "Velocity Attribute",
182  "Name of the Alembic attribute used for generating motion blur data");
183  RNA_def_property_update(prop, 0, "rna_CacheFile_update");
185 
186  static const EnumPropertyItem velocity_unit_items[] = {
187  {CACHEFILE_VELOCITY_UNIT_SECOND, "SECOND", 0, "Second", ""},
188  {CACHEFILE_VELOCITY_UNIT_FRAME, "FRAME", 0, "Frame", ""},
189  {0, NULL, 0, NULL, NULL},
190  };
191 
192  prop = RNA_def_property(srna, "velocity_unit", PROP_ENUM, PROP_NONE);
193  RNA_def_property_enum_sdna(prop, NULL, "velocity_unit");
194  RNA_def_property_enum_items(prop, velocity_unit_items);
196  prop,
197  "Velocity Unit",
198  "Define how the velocity vectors are interpreted with regard to time, 'frame' means "
199  "the delta time is 1 frame, 'second' means the delta time is 1 / FPS");
200  RNA_def_property_update(prop, 0, "rna_CacheFile_update");
202 
204 
205  rna_def_cachefile_object_paths(brna, prop);
206 
208 }
209 
211 {
212  rna_def_cachefile(brna);
214 }
215 
216 #endif
#define UNUSED(x)
void DEG_id_tag_update(struct ID *id, int flag)
@ ID_RECALC_COPY_ON_WRITE
Definition: DNA_ID.h:654
@ CACHEFILE_VELOCITY_UNIT_SECOND
@ CACHEFILE_VELOCITY_UNIT_FRAME
#define MAXFRAME
@ PROP_FLOAT
Definition: RNA_types.h:75
@ PROP_BOOLEAN
Definition: RNA_types.h:73
@ PROP_ENUM
Definition: RNA_types.h:77
@ PROP_STRING
Definition: RNA_types.h:76
@ PROP_COLLECTION
Definition: RNA_types.h:79
@ PROP_ANIMATABLE
Definition: RNA_types.h:188
@ PROP_NONE
Definition: RNA_types.h:113
@ PROP_FILEPATH
Definition: RNA_types.h:116
#define ND_DRAW
Definition: WM_types.h:362
#define NC_OBJECT
Definition: WM_types.h:280
Scene scene
void rna_iterator_listbase_begin(CollectionPropertyIterator *iter, ListBase *lb, IteratorSkipFunc skip)
Definition: rna_access.c:4823
void rna_def_animdata_common(StructRNA *srna)
void RNA_def_cachefile(BlenderRNA *brna)
static void rna_def_cachefile(BlenderRNA *brna)
Definition: rna_cachefile.c:90
static void rna_def_alembic_object_path(BlenderRNA *brna)
Definition: rna_cachefile.c:65
static void rna_def_cachefile_object_paths(BlenderRNA *brna, PropertyRNA *cprop)
Definition: rna_cachefile.c:82
void RNA_define_lib_overridable(const bool make_overridable)
Definition: rna_define.c:760
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
Definition: rna_define.c:1676
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_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_property_update(PropertyRNA *prop, int noteflag, const char *func)
Definition: rna_define.c:2927
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype)
Definition: rna_define.c:1279
void RNA_def_struct_name_property(struct StructRNA *srna, struct PropertyRNA *prop)
Definition: rna_define.c:1122
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_enum_sdna(PropertyRNA *prop, const char *structname, const char *propname)
Definition: rna_define.c:2623
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
const EnumPropertyItem rna_enum_object_axis_items[]
Definition: rna_object.c:302
ListBase object_paths
Definition: BKE_main.h:116
void * data
Definition: RNA_types.h:52
void WM_main_add_notifier(unsigned int type, void *reference)
PointerRNA * ptr
Definition: wm_files.c:3157