patch [#34103] use booleans for extensions testing.
[blender.git] / source / blender / makesrna / intern / rna_render.c
1 /*
2  * ***** BEGIN GPL LICENSE BLOCK *****
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  *
18  * Contributor(s): Blender Foundation (2009)
19  *
20  * ***** END GPL LICENSE BLOCK *****
21  */
22
23 /** \file blender/makesrna/intern/rna_render.c
24  *  \ingroup RNA
25  */
26
27 #include <stdlib.h>
28
29 #include "DNA_scene_types.h"
30
31 #include "BLI_utildefines.h"
32 #include "BLI_path_util.h"
33
34 #include "RNA_define.h"
35 #include "RNA_enum_types.h"
36
37 #include "rna_internal.h"
38
39 #include "RE_engine.h"
40 #include "RE_pipeline.h"
41
42
43 #ifdef RNA_RUNTIME
44
45 #include "MEM_guardedalloc.h"
46
47 #include "RNA_access.h"
48
49 #include "BKE_context.h"
50 #include "BKE_report.h"
51
52 /* RenderEngine Callbacks */
53
54 static void engine_tag_redraw(RenderEngine *engine)
55 {
56         engine->flag |= RE_ENGINE_DO_DRAW;
57 }
58
59 static void engine_tag_update(RenderEngine *engine)
60 {
61         engine->flag |= RE_ENGINE_DO_UPDATE;
62 }
63
64 static void engine_update(RenderEngine *engine, Main *bmain, Scene *scene)
65 {
66         extern FunctionRNA rna_RenderEngine_update_func;
67         PointerRNA ptr;
68         ParameterList list;
69         FunctionRNA *func;
70
71         RNA_pointer_create(NULL, engine->type->ext.srna, engine, &ptr);
72         func = &rna_RenderEngine_update_func;
73
74         RNA_parameter_list_create(&list, &ptr, func);
75         RNA_parameter_set_lookup(&list, "data", &bmain);
76         RNA_parameter_set_lookup(&list, "scene", &scene);
77         engine->type->ext.call(NULL, &ptr, func, &list);
78
79         RNA_parameter_list_free(&list);
80 }
81
82 static void engine_render(RenderEngine *engine, struct Scene *scene)
83 {
84         extern FunctionRNA rna_RenderEngine_render_func;
85         PointerRNA ptr;
86         ParameterList list;
87         FunctionRNA *func;
88
89         RNA_pointer_create(NULL, engine->type->ext.srna, engine, &ptr);
90         func = &rna_RenderEngine_render_func;
91
92         RNA_parameter_list_create(&list, &ptr, func);
93         RNA_parameter_set_lookup(&list, "scene", &scene);
94         engine->type->ext.call(NULL, &ptr, func, &list);
95
96         RNA_parameter_list_free(&list);
97 }
98
99 static void engine_view_update(RenderEngine *engine, const struct bContext *context)
100 {
101         extern FunctionRNA rna_RenderEngine_view_update_func;
102         PointerRNA ptr;
103         ParameterList list;
104         FunctionRNA *func;
105
106         RNA_pointer_create(NULL, engine->type->ext.srna, engine, &ptr);
107         func = &rna_RenderEngine_view_update_func;
108
109         RNA_parameter_list_create(&list, &ptr, func);
110         RNA_parameter_set_lookup(&list, "context", &context);
111         engine->type->ext.call(NULL, &ptr, func, &list);
112
113         RNA_parameter_list_free(&list);
114 }
115
116 static void engine_view_draw(RenderEngine *engine, const struct bContext *context)
117 {
118         extern FunctionRNA rna_RenderEngine_view_draw_func;
119         PointerRNA ptr;
120         ParameterList list;
121         FunctionRNA *func;
122
123         RNA_pointer_create(NULL, engine->type->ext.srna, engine, &ptr);
124         func = &rna_RenderEngine_view_draw_func;
125
126         RNA_parameter_list_create(&list, &ptr, func);
127         RNA_parameter_set_lookup(&list, "context", &context);
128         engine->type->ext.call(NULL, &ptr, func, &list);
129
130         RNA_parameter_list_free(&list);
131 }
132
133 static void engine_update_script_node(RenderEngine *engine, struct bNodeTree *ntree, struct bNode *node)
134 {
135         extern FunctionRNA rna_RenderEngine_update_script_node_func;
136         PointerRNA ptr, nodeptr;
137         ParameterList list;
138         FunctionRNA *func;
139
140         RNA_pointer_create(NULL, engine->type->ext.srna, engine, &ptr);
141         RNA_pointer_create((ID *)ntree, &RNA_Node, node, &nodeptr);
142         func = &rna_RenderEngine_update_script_node_func;
143
144         RNA_parameter_list_create(&list, &ptr, func);
145         RNA_parameter_set_lookup(&list, "node", &nodeptr);
146         engine->type->ext.call(NULL, &ptr, func, &list);
147
148         RNA_parameter_list_free(&list);
149 }
150
151 /* RenderEngine registration */
152
153 static void rna_RenderEngine_unregister(Main *UNUSED(bmain), StructRNA *type)
154 {
155         RenderEngineType *et = RNA_struct_blender_type_get(type);
156
157         if (!et)
158                 return;
159         
160         RNA_struct_free_extension(type, &et->ext);
161         BLI_freelinkN(&R_engines, et);
162         RNA_struct_free(&BLENDER_RNA, type);
163 }
164
165 static StructRNA *rna_RenderEngine_register(Main *bmain, ReportList *reports, void *data, const char *identifier,
166                                             StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
167 {
168         RenderEngineType *et, dummyet = {NULL};
169         RenderEngine dummyengine = {NULL};
170         PointerRNA dummyptr;
171         int have_function[5];
172
173         /* setup dummy engine & engine type to store static properties in */
174         dummyengine.type = &dummyet;
175         RNA_pointer_create(NULL, &RNA_RenderEngine, &dummyengine, &dummyptr);
176
177         /* validate the python class */
178         if (validate(&dummyptr, data, have_function) != 0)
179                 return NULL;
180
181         if (strlen(identifier) >= sizeof(dummyet.idname)) {
182                 BKE_reportf(reports, RPT_ERROR, "Registering render engine class: '%s' is too long, maximum length is %d",
183                             identifier, (int)sizeof(dummyet.idname));
184                 return NULL;
185         }
186
187         /* check if we have registered this engine type before, and remove it */
188         for (et = R_engines.first; et; et = et->next) {
189                 if (strcmp(et->idname, dummyet.idname) == 0) {
190                         if (et->ext.srna)
191                                 rna_RenderEngine_unregister(bmain, et->ext.srna);
192                         break;
193                 }
194         }
195         
196         /* create a new engine type */
197         et = MEM_callocN(sizeof(RenderEngineType), "python render engine");
198         memcpy(et, &dummyet, sizeof(dummyet));
199
200         et->ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, et->idname, &RNA_RenderEngine);
201         et->ext.data = data;
202         et->ext.call = call;
203         et->ext.free = free;
204         RNA_struct_blender_type_set(et->ext.srna, et);
205
206         et->update = (have_function[0]) ? engine_update : NULL;
207         et->render = (have_function[1]) ? engine_render : NULL;
208         et->view_update = (have_function[2]) ? engine_view_update : NULL;
209         et->view_draw = (have_function[3]) ? engine_view_draw : NULL;
210         et->update_script_node = (have_function[4]) ? engine_update_script_node : NULL;
211
212         BLI_addtail(&R_engines, et);
213
214         return et->ext.srna;
215 }
216
217 static void **rna_RenderEngine_instance(PointerRNA *ptr)
218 {
219         RenderEngine *engine = ptr->data;
220         return &engine->py_instance;
221 }
222
223 static StructRNA *rna_RenderEngine_refine(PointerRNA *ptr)
224 {
225         RenderEngine *engine = (RenderEngine *)ptr->data;
226         return (engine->type && engine->type->ext.srna) ? engine->type->ext.srna : &RNA_RenderEngine;
227 }
228
229 static void rna_RenderResult_layers_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
230 {
231         RenderResult *rr = (RenderResult *)ptr->data;
232         rna_iterator_listbase_begin(iter, &rr->layers, NULL);
233 }
234
235 static void rna_RenderLayer_passes_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
236 {
237         RenderLayer *rl = (RenderLayer *)ptr->data;
238         rna_iterator_listbase_begin(iter, &rl->passes, NULL);
239 }
240
241 static int rna_RenderLayer_rect_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION])
242 {
243         RenderLayer *rl = (RenderLayer *)ptr->data;
244
245         length[0] = rl->rectx * rl->recty;
246         length[1] = 4;
247
248         return length[0] * length[1];
249 }
250
251 static void rna_RenderLayer_rect_get(PointerRNA *ptr, float *values)
252 {
253         RenderLayer *rl = (RenderLayer *)ptr->data;
254         memcpy(values, rl->rectf, sizeof(float) * rl->rectx * rl->recty * 4);
255 }
256
257 void rna_RenderLayer_rect_set(PointerRNA *ptr, const float *values)
258 {
259         RenderLayer *rl = (RenderLayer *)ptr->data;
260         memcpy(rl->rectf, values, sizeof(float) * rl->rectx * rl->recty * 4);
261 }
262
263 static int rna_RenderPass_rect_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION])
264 {
265         RenderPass *rpass = (RenderPass *)ptr->data;
266
267         length[0] = rpass->rectx * rpass->recty;
268         length[1] = rpass->channels;
269
270         return length[0] * length[1];
271 }
272
273 static void rna_RenderPass_rect_get(PointerRNA *ptr, float *values)
274 {
275         RenderPass *rpass = (RenderPass *)ptr->data;
276         memcpy(values, rpass->rect, sizeof(float) * rpass->rectx * rpass->recty * rpass->channels);
277 }
278
279 void rna_RenderPass_rect_set(PointerRNA *ptr, const float *values)
280 {
281         RenderPass *rpass = (RenderPass *)ptr->data;
282         memcpy(rpass->rect, values, sizeof(float) * rpass->rectx * rpass->recty * rpass->channels);
283 }
284
285 #else /* RNA_RUNTIME */
286
287 static void rna_def_render_engine(BlenderRNA *brna)
288 {
289         StructRNA *srna;
290         PropertyRNA *prop;
291         FunctionRNA *func;
292         
293         srna = RNA_def_struct(brna, "RenderEngine", NULL);
294         RNA_def_struct_sdna(srna, "RenderEngine");
295         RNA_def_struct_ui_text(srna, "Render Engine", "Render engine");
296         RNA_def_struct_refine_func(srna, "rna_RenderEngine_refine");
297         RNA_def_struct_register_funcs(srna, "rna_RenderEngine_register", "rna_RenderEngine_unregister",
298                                       "rna_RenderEngine_instance");
299
300         /* final render callbacks */
301         func = RNA_def_function(srna, "update", NULL);
302         RNA_def_function_ui_description(func, "Export scene data for render");
303         RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE);
304         RNA_def_pointer(func, "data", "BlendData", "", "");
305         RNA_def_pointer(func, "scene", "Scene", "", "");
306
307         func = RNA_def_function(srna, "render", NULL);
308         RNA_def_function_ui_description(func, "Render scene into an image");
309         RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE);
310         RNA_def_pointer(func, "scene", "Scene", "", "");
311
312         /* viewport render callbacks */
313         func = RNA_def_function(srna, "view_update", NULL);
314         RNA_def_function_ui_description(func, "Update on data changes for viewport render");
315         RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE);
316         RNA_def_pointer(func, "context", "Context", "", "");
317
318         func = RNA_def_function(srna, "view_draw", NULL);
319         RNA_def_function_ui_description(func, "Draw viewport render");
320         RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
321         RNA_def_pointer(func, "context", "Context", "", "");
322
323         /* shader script callbacks */
324         func = RNA_def_function(srna, "update_script_node", NULL);
325         RNA_def_function_ui_description(func, "Compile shader script node");
326         RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE);
327         prop = RNA_def_pointer(func, "node", "Node", "", "");
328         RNA_def_property_flag(prop, PROP_RNAPTR);
329
330         /* tag for redraw */
331         RNA_def_function(srna, "tag_redraw", "engine_tag_redraw");
332         RNA_def_function_ui_description(func, "Request redraw for viewport rendering");
333
334         /* tag for update */
335         RNA_def_function(srna, "tag_update", "engine_tag_update");
336         RNA_def_function_ui_description(func, "Request update call for viewport rendering");
337
338         func = RNA_def_function(srna, "begin_result", "RE_engine_begin_result");
339         prop = RNA_def_int(func, "x", 0, 0, INT_MAX, "X", "", 0, INT_MAX);
340         RNA_def_property_flag(prop, PROP_REQUIRED);
341         prop = RNA_def_int(func, "y", 0, 0, INT_MAX, "Y", "", 0, INT_MAX);
342         RNA_def_property_flag(prop, PROP_REQUIRED);
343         prop = RNA_def_int(func, "w", 0, 0, INT_MAX, "Width", "", 0, INT_MAX);
344         RNA_def_property_flag(prop, PROP_REQUIRED);
345         prop = RNA_def_int(func, "h", 0, 0, INT_MAX, "Height", "", 0, INT_MAX);
346         RNA_def_property_flag(prop, PROP_REQUIRED);
347         RNA_def_string(func, "layer", "", 0, "Layer", "Single layer to get render result for");  /* NULL ok here */
348         prop = RNA_def_pointer(func, "result", "RenderResult", "Result", "");
349         RNA_def_function_return(func, prop);
350
351         func = RNA_def_function(srna, "update_result", "RE_engine_update_result");
352         prop = RNA_def_pointer(func, "result", "RenderResult", "Result", "");
353         RNA_def_property_flag(prop, PROP_REQUIRED);
354
355         func = RNA_def_function(srna, "end_result", "RE_engine_end_result");
356         prop = RNA_def_pointer(func, "result", "RenderResult", "Result", "");
357         RNA_def_property_flag(prop, PROP_REQUIRED);
358         RNA_def_boolean(func, "cancel", 0, "Cancel", "Don't merge back results");
359
360         func = RNA_def_function(srna, "test_break", "RE_engine_test_break");
361         prop = RNA_def_boolean(func, "do_break", 0, "Break", "");
362         RNA_def_function_return(func, prop);
363
364         func = RNA_def_function(srna, "update_stats", "RE_engine_update_stats");
365         prop = RNA_def_string(func, "stats", "", 0, "Stats", "");
366         RNA_def_property_flag(prop, PROP_REQUIRED);
367         prop = RNA_def_string(func, "info", "", 0, "Info", "");
368         RNA_def_property_flag(prop, PROP_REQUIRED);
369
370         func = RNA_def_function(srna, "update_progress", "RE_engine_update_progress");
371         prop = RNA_def_float(func, "progress", 0, 0.0f, 1.0f, "", "Percentage of render that's done", 0.0f, 1.0f);
372         RNA_def_property_flag(prop, PROP_REQUIRED);
373
374         func = RNA_def_function(srna, "update_memory_stats", "RE_engine_update_memory_stats");
375         RNA_def_float(func, "memory_used", 0, 0.0f, FLT_MAX, "", "Current memory usage in megabytes", 0.0f, FLT_MAX);
376         RNA_def_float(func, "memory_peak", 0, 0.0f, FLT_MAX, "", "Peak memory usage in megabytes", 0.0f, FLT_MAX);
377         RNA_def_property_flag(prop, PROP_REQUIRED);
378
379         func = RNA_def_function(srna, "report", "RE_engine_report");
380         prop = RNA_def_enum_flag(func, "type", wm_report_items, 0, "Type", "");
381         RNA_def_property_flag(prop, PROP_REQUIRED);
382         prop = RNA_def_string(func, "message", "", 0, "Report Message", "");
383         RNA_def_property_flag(prop, PROP_REQUIRED);
384
385         RNA_define_verify_sdna(0);
386
387         prop = RNA_def_property(srna, "is_animation", PROP_BOOLEAN, PROP_NONE);
388         RNA_def_property_boolean_sdna(prop, NULL, "flag", RE_ENGINE_ANIMATION);
389
390         prop = RNA_def_property(srna, "is_preview", PROP_BOOLEAN, PROP_NONE);
391         RNA_def_property_boolean_sdna(prop, NULL, "flag", RE_ENGINE_PREVIEW);
392
393         prop = RNA_def_property(srna, "camera_override", PROP_POINTER, PROP_NONE);
394         RNA_def_property_pointer_sdna(prop, NULL, "camera_override");
395         RNA_def_property_struct_type(prop, "Object");
396
397         prop = RNA_def_property(srna, "tile_x", PROP_INT, PROP_UNSIGNED);
398         RNA_def_property_int_sdna(prop, NULL, "tile_x");
399         prop = RNA_def_property(srna, "tile_y", PROP_INT, PROP_UNSIGNED);
400         RNA_def_property_int_sdna(prop, NULL, "tile_y");
401
402         prop = RNA_def_property(srna, "resolution_x", PROP_INT, PROP_NONE);
403         RNA_def_property_int_sdna(prop, NULL, "resolution_x");
404         RNA_def_property_clear_flag(prop, PROP_EDITABLE);
405
406         prop = RNA_def_property(srna, "resolution_y", PROP_INT, PROP_NONE);
407         RNA_def_property_int_sdna(prop, NULL, "resolution_y");
408         RNA_def_property_clear_flag(prop, PROP_EDITABLE);
409
410         prop = RNA_def_property(srna, "use_highlight_tiles", PROP_BOOLEAN, PROP_NONE);
411         RNA_def_property_boolean_sdna(prop, NULL, "flag", RE_ENGINE_HIGHLIGHT_TILES);
412
413         /* registration */
414
415         prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);
416         RNA_def_property_string_sdna(prop, NULL, "type->idname");
417         RNA_def_property_flag(prop, PROP_REGISTER | PROP_NEVER_CLAMP);
418
419         prop = RNA_def_property(srna, "bl_label", PROP_STRING, PROP_NONE);
420         RNA_def_property_string_sdna(prop, NULL, "type->name");
421         RNA_def_property_flag(prop, PROP_REGISTER);
422
423         prop = RNA_def_property(srna, "bl_use_preview", PROP_BOOLEAN, PROP_NONE);
424         RNA_def_property_boolean_sdna(prop, NULL, "type->flag", RE_USE_PREVIEW);
425         RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
426
427         prop = RNA_def_property(srna, "bl_use_postprocess", PROP_BOOLEAN, PROP_NONE);
428         RNA_def_property_boolean_negative_sdna(prop, NULL, "type->flag", RE_USE_POSTPROCESS);
429         RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
430
431         prop = RNA_def_property(srna, "bl_use_shading_nodes", PROP_BOOLEAN, PROP_NONE);
432         RNA_def_property_boolean_sdna(prop, NULL, "type->flag", RE_USE_SHADING_NODES);
433         RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
434
435         RNA_define_verify_sdna(1);
436 }
437
438 static void rna_def_render_result(BlenderRNA *brna)
439 {
440         StructRNA *srna;
441         FunctionRNA *func;
442         PropertyRNA *parm;
443         
444         srna = RNA_def_struct(brna, "RenderResult", NULL);
445         RNA_def_struct_ui_text(srna, "Render Result", "Result of rendering, including all layers and passes");
446
447         func = RNA_def_function(srna, "load_from_file", "RE_result_load_from_file");
448         RNA_def_function_ui_description(func, "Copies the pixels of this render result from an image file");
449         RNA_def_function_flag(func, FUNC_USE_REPORTS);
450         parm = RNA_def_string_file_name(func, "filename", "", FILE_MAX, "File Name",
451                                         "Filename to load into this render tile, must be no smaller than "
452                                         "the render result");
453         RNA_def_property_flag(parm, PROP_REQUIRED);
454
455         RNA_define_verify_sdna(0);
456
457         parm = RNA_def_property(srna, "resolution_x", PROP_INT, PROP_NONE);
458         RNA_def_property_int_sdna(parm, NULL, "rectx");
459         RNA_def_property_clear_flag(parm, PROP_EDITABLE);
460
461         parm = RNA_def_property(srna, "resolution_y", PROP_INT, PROP_NONE);
462         RNA_def_property_int_sdna(parm, NULL, "recty");
463         RNA_def_property_clear_flag(parm, PROP_EDITABLE);
464
465         parm = RNA_def_property(srna, "layers", PROP_COLLECTION, PROP_NONE);
466         RNA_def_property_struct_type(parm, "RenderLayer");
467         RNA_def_property_collection_funcs(parm, "rna_RenderResult_layers_begin", "rna_iterator_listbase_next",
468                                           "rna_iterator_listbase_end", "rna_iterator_listbase_get",
469                                           NULL, NULL, NULL, NULL);
470
471         RNA_define_verify_sdna(1);
472 }
473
474 static void rna_def_render_layer(BlenderRNA *brna)
475 {
476         StructRNA *srna;
477         PropertyRNA *prop;
478         FunctionRNA *func;
479         
480         srna = RNA_def_struct(brna, "RenderLayer", NULL);
481         RNA_def_struct_ui_text(srna, "Render Layer", "");
482
483         func = RNA_def_function(srna, "load_from_file", "RE_layer_load_from_file");
484         RNA_def_function_ui_description(func, "Copies the pixels of this renderlayer from an image file");
485         RNA_def_function_flag(func, FUNC_USE_REPORTS);
486         prop = RNA_def_string(func, "filename", "", 0, "Filename",
487                               "Filename to load into this render tile, must be no smaller than the renderlayer");
488         RNA_def_property_flag(prop, PROP_REQUIRED);
489         RNA_def_int(func, "x", 0, 0, INT_MAX, "Offset X",
490                     "Offset the position to copy from if the image is larger than the render layer", 0, INT_MAX);
491         RNA_def_int(func, "y", 0, 0, INT_MAX, "Offset Y",
492                     "Offset the position to copy from if the image is larger than the render layer", 0, INT_MAX);
493
494         RNA_define_verify_sdna(0);
495
496         rna_def_render_layer_common(srna, 0);
497
498         prop = RNA_def_property(srna, "passes", PROP_COLLECTION, PROP_NONE);
499         RNA_def_property_struct_type(prop, "RenderPass");
500         RNA_def_property_collection_funcs(prop, "rna_RenderLayer_passes_begin", "rna_iterator_listbase_next",
501                                           "rna_iterator_listbase_end", "rna_iterator_listbase_get",
502                                           NULL, NULL, NULL, NULL);
503
504         prop = RNA_def_property(srna, "rect", PROP_FLOAT, PROP_NONE);
505         RNA_def_property_flag(prop, PROP_DYNAMIC);
506         RNA_def_property_multi_array(prop, 2, NULL);
507         RNA_def_property_dynamic_array_funcs(prop, "rna_RenderLayer_rect_get_length");
508         RNA_def_property_float_funcs(prop, "rna_RenderLayer_rect_get", "rna_RenderLayer_rect_set", NULL);
509
510         RNA_define_verify_sdna(1);
511 }
512
513 static void rna_def_render_pass(BlenderRNA *brna)
514 {
515         StructRNA *srna;
516         PropertyRNA *prop;
517
518         static EnumPropertyItem pass_type_items[] = {
519                 {SCE_PASS_COMBINED, "COMBINED", 0, "Combined", ""},
520                 {SCE_PASS_Z, "Z", 0, "Z", ""},
521                 {SCE_PASS_RGBA, "COLOR", 0, "Color", ""},
522                 {SCE_PASS_DIFFUSE, "DIFFUSE", 0, "Diffuse", ""},
523                 {SCE_PASS_SPEC, "SPECULAR", 0, "Specular", ""},
524                 {SCE_PASS_SHADOW, "SHADOW", 0, "Shadow", ""},
525                 {SCE_PASS_AO, "AO", 0, "AO", ""},
526                 {SCE_PASS_REFLECT, "REFLECTION", 0, "Reflection", ""},
527                 {SCE_PASS_NORMAL, "NORMAL", 0, "Normal", ""},
528                 {SCE_PASS_VECTOR, "VECTOR", 0, "Vector", ""},
529                 {SCE_PASS_REFRACT, "REFRACTION", 0, "Refraction", ""},
530                 {SCE_PASS_INDEXOB, "OBJECT_INDEX", 0, "Object Index", ""},
531                 {SCE_PASS_UV, "UV", 0, "UV", ""},
532                 {SCE_PASS_MIST, "MIST", 0, "Mist", ""},
533                 {SCE_PASS_EMIT, "EMIT", 0, "Emit", ""},
534                 {SCE_PASS_ENVIRONMENT, "ENVIRONMENT", 0, "Environment", ""},
535                 {SCE_PASS_INDEXMA, "MATERIAL_INDEX", 0, "Material Index", ""},
536                 {SCE_PASS_DIFFUSE_DIRECT, "DIFFUSE_DIRECT", 0, "Diffuse Direct", ""},
537                 {SCE_PASS_DIFFUSE_INDIRECT, "DIFFUSE_INDIRECT", 0, "Diffuse Indirect", ""},
538                 {SCE_PASS_DIFFUSE_COLOR, "DIFFUSE_COLOR", 0, "Diffuse Color", ""},
539                 {SCE_PASS_GLOSSY_DIRECT, "GLOSSY_DIRECT", 0, "Glossy Direct", ""},
540                 {SCE_PASS_GLOSSY_INDIRECT, "GLOSSY_INDIRECT", 0, "Glossy Indirect", ""},
541                 {SCE_PASS_GLOSSY_COLOR, "GLOSSY_COLOR", 0, "Glossy Color", ""},
542                 {SCE_PASS_TRANSM_DIRECT, "TRANSMISSION_DIRECT", 0, "Transmission Direct", ""},
543                 {SCE_PASS_TRANSM_INDIRECT, "TRANSMISSION_INDIRECT", 0, "Transmission Indirect", ""},
544                 {SCE_PASS_TRANSM_COLOR, "TRANSMISSION_COLOR", 0, "Transmission Color", ""},
545                 {0, NULL, 0, NULL, NULL}
546         };
547         
548         srna = RNA_def_struct(brna, "RenderPass", NULL);
549         RNA_def_struct_ui_text(srna, "Render Pass", "");
550
551         RNA_define_verify_sdna(0);
552
553         prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
554         RNA_def_property_string_sdna(prop, NULL, "name");
555         RNA_def_property_clear_flag(prop, PROP_EDITABLE);
556         RNA_def_struct_name_property(srna, prop);
557
558         prop = RNA_def_property(srna, "channel_id", PROP_STRING, PROP_NONE);
559         RNA_def_property_string_sdna(prop, NULL, "chan_id");
560         RNA_def_property_clear_flag(prop, PROP_EDITABLE);
561
562         prop = RNA_def_property(srna, "channels", PROP_INT, PROP_NONE);
563         RNA_def_property_int_sdna(prop, NULL, "channels");
564         RNA_def_property_clear_flag(prop, PROP_EDITABLE);
565
566         prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
567         RNA_def_property_enum_sdna(prop, NULL, "passtype");
568         RNA_def_property_enum_items(prop, pass_type_items);
569         RNA_def_property_clear_flag(prop, PROP_EDITABLE);
570
571         prop = RNA_def_property(srna, "rect", PROP_FLOAT, PROP_NONE);
572         RNA_def_property_flag(prop, PROP_DYNAMIC);
573         RNA_def_property_multi_array(prop, 2, NULL);
574         RNA_def_property_dynamic_array_funcs(prop, "rna_RenderPass_rect_get_length");
575         RNA_def_property_float_funcs(prop, "rna_RenderPass_rect_get", "rna_RenderPass_rect_set", NULL);
576
577         RNA_define_verify_sdna(1);
578 }
579
580 void RNA_def_render(BlenderRNA *brna)
581 {
582         rna_def_render_engine(brna);
583         rna_def_render_result(brna);
584         rna_def_render_layer(brna);
585         rna_def_render_pass(brna);
586 }
587
588 #endif /* RNA_RUNTIME */