diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-01-08 16:52:38 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-01-08 16:52:38 +0300 |
commit | a868e8623ca7218dfa363962e178293f4a8f0690 (patch) | |
tree | 2c0e08b1b9b810b60c7b19d9dac4fd6e2fb41c36 /source/blender/makesrna/intern | |
parent | 7079047538da71961102478a23cccdbd62c7cf9d (diff) |
- RNA support for returning copied strings from functions, flagging strings as PROP_THICK_WRAP does this.
- scene.render_data.frame_path(frame=num), returns the output path for rending images of video.
- scene.render_data.file_extension, readonly attribute, gives the extension ".jpg", ".mov" etc
- player support was guessing names, use the above functions to get the actual names used, accounting for #'s replacing numbers.
Diffstat (limited to 'source/blender/makesrna/intern')
-rw-r--r-- | source/blender/makesrna/intern/makesrna.c | 21 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_define.c | 7 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_internal.h | 3 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_scene.c | 29 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_scene_api.c | 24 |
5 files changed, 74 insertions, 10 deletions
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index aa7939c644f..a03903eb652 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -1238,9 +1238,12 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA ptrstr= "*"; else if(dparm->prop==func->c_ret) ptrstr= ((dparm->prop->type == PROP_POINTER) && !(dparm->prop->flag & PROP_RNAPTR))? "*": ""; - else if ((dparm->prop->flag & PROP_RETURN)) - ptrstr= ((dparm->prop->type == PROP_POINTER) && !(dparm->prop->flag & PROP_RNAPTR))? "**": "*"; - else + else if ((dparm->prop->flag & PROP_RETURN)) { + if ((dparm->prop->flag & PROP_THICK_WRAP) && (dparm->prop->type == PROP_STRING)) + ptrstr= ""; + else + ptrstr= ((dparm->prop->type == PROP_POINTER) && !(dparm->prop->flag & PROP_RNAPTR))? "**": "*"; + } else ptrstr= (dparm->prop->type == PROP_POINTER)? "*": ""; fprintf(f, "\t%s%s %s%s;\n", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop), ptrstr, dparm->prop->identifier); @@ -1276,8 +1279,12 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA else fprintf(f, "\t%s= %s((%s%s**)_data);\n", dparm->prop->identifier, ptrstr, rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop)); } - else - fprintf(f, "\t%s= %s((%s%s*)_data);\n", dparm->prop->identifier, ptrstr, rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop)); + else { + if ((dparm->prop->flag & PROP_THICK_WRAP) && (dparm->prop->type == PROP_STRING)) + fprintf(f, "\t%s= %s((%s%s)_data);\n", dparm->prop->identifier, ptrstr, rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop)); + else + fprintf(f, "\t%s= %s((%s%s*)_data);\n", dparm->prop->identifier, ptrstr, rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop)); + } if(dparm->next) fprintf(f, "\t_data+= %d;\n", rna_parameter_size(dparm->prop)); @@ -1614,7 +1621,9 @@ static void rna_generate_static_parameter_prototypes(BlenderRNA *brna, StructRNA if(!first) fprintf(f, ", "); first= 0; - if((dparm->prop->flag & PROP_RETURN)) + if((dparm->prop->type == PROP_STRING && dparm->prop->flag & PROP_THICK_WRAP)) + ptrstr= ""; + else if(dparm->prop->flag & PROP_RETURN) ptrstr= "*"; else ptrstr= ""; diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index 767752af0ea..ed10c0819fd 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -2470,7 +2470,12 @@ int rna_parameter_size(PropertyRNA *parm) case PROP_FLOAT: return sizeof(float); case PROP_STRING: - return sizeof(char *); + /* return valyes dont store a pointer to the original */ + if(parm->flag & PROP_THICK_WRAP) { + StringPropertyRNA *sparm= (StringPropertyRNA*)parm; + return sizeof(char) * sparm->maxlength; + } else + return sizeof(char *); case PROP_POINTER: { #ifdef RNA_RUNTIME if(parm->flag & PROP_RNAPTR) diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index 91443e8f9fa..b154647e10e 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -225,7 +225,8 @@ void RNA_api_material(StructRNA *srna); void RNA_api_mesh(struct StructRNA *srna); void RNA_api_object(struct StructRNA *srna); void RNA_api_pose_channel(struct StructRNA *srna); -void RNA_api_scene(struct StructRNA *srna); +void RNA_api_scene(struct StructRNA *srna); +void RNA_api_scene_render(struct StructRNA *srna); void RNA_api_text(struct StructRNA *srna); void RNA_api_ui_layout(struct StructRNA *srna); void RNA_api_wm(struct StructRNA *srna); diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index b8a85b6521b..8830583045b 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -101,6 +101,7 @@ EnumPropertyItem snap_element_items[] = { #include "BKE_pointcache.h" #include "BKE_scene.h" #include "BKE_depsgraph.h" +#include "BKE_image.h" #include "BKE_mesh.h" #include "BLI_threads.h" @@ -359,6 +360,21 @@ static void rna_SceneRenderData_file_format_set(PointerRNA *ptr, int value) #endif } +static int rna_SceneRender_file_ext_length(PointerRNA *ptr) +{ + RenderData *rd= (RenderData*)ptr->data; + char ext[8]; + + BKE_add_image_extension(ext, rd->imtype); + return strlen(ext); +} + +static void rna_SceneRender_file_ext_get(PointerRNA *ptr, char *str) +{ + RenderData *rd= (RenderData*)ptr->data; + BKE_add_image_extension(str, rd->imtype); +} + void rna_SceneRenderData_jpeg2k_preset_update(RenderData *rd) { rd->subimtype &= ~(R_JPEG2K_12BIT|R_JPEG2K_16BIT | R_JPEG2K_CINE_PRESET|R_JPEG2K_CINE_48FPS); @@ -2100,7 +2116,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Color Management", "Use color profiles and gamma corrected imaging pipeline"); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS|NC_MATERIAL|ND_SHADING, NULL); - prop= RNA_def_property(srna, "file_extensions", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "use_file_extension", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "scemode", R_EXTENSION); RNA_def_property_ui_text(prop, "File Extensions", "Add the file format extensions to the rendered file name (eg: filename + .jpg)"); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); @@ -2111,7 +2127,13 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_enum_funcs(prop, NULL, "rna_SceneRenderData_file_format_set", NULL); RNA_def_property_ui_text(prop, "File Format", "File format to save the rendered images as."); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); - + + prop= RNA_def_property(srna, "file_extension", PROP_STRING, PROP_NONE); + RNA_def_property_string_funcs(prop, "rna_SceneRender_file_ext_get", "rna_SceneRender_file_ext_length", NULL); + RNA_def_property_ui_text(prop, "Extension", "The file extension used for saving renders."); + RNA_def_struct_name_property(srna, prop); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + prop= RNA_def_property(srna, "free_image_textures", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "scemode", R_FREE_IMAGE); RNA_def_property_ui_text(prop, "Free Image Textures", "Free all image texture from memory after render, to save memory before compositing."); @@ -2317,6 +2339,9 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_boolean_funcs(prop, "rna_SceneRenderData_use_game_engine_get", NULL); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Use Game Engine", "Current rendering engine is a game engine."); + + /* Scene API */ + RNA_api_scene_render(srna); } diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c index 4efbed167a6..84dc3e6971e 100644 --- a/source/blender/makesrna/intern/rna_scene_api.c +++ b/source/blender/makesrna/intern/rna_scene_api.c @@ -36,12 +36,15 @@ #include "DNA_anim_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" +#include "BKE_utildefines.h" #ifdef RNA_RUNTIME #include "BKE_animsys.h" #include "BKE_scene.h" +#include "BKE_image.h" #include "BKE_depsgraph.h" +#include "BKE_writeavi.h" #include "ED_object.h" #include "ED_anim_api.h" @@ -84,6 +87,14 @@ static KeyingSet *rna_Scene_add_keying_set(Scene *sce, ReportList *reports, } } +static void rna_SceneRender_get_frame_path(RenderData *rd, int frame, char *name) +{ + if(BKE_imtype_is_movie(rd->imtype)) + BKE_makeanimstring(name, rd); + else + BKE_makepicstring(name, rd->pic, (frame==INT_MIN) ? rd->cfra : frame, rd->imtype, rd->scemode & R_EXTENSION); +} + #else void RNA_api_scene(StructRNA *srna) @@ -113,5 +124,18 @@ void RNA_api_scene(StructRNA *srna) RNA_def_boolean(func, "insertkey_visual", 0, "Insert Keyframes - Visual", "Insert keyframes based on 'visual transforms'."); } +void RNA_api_scene_render(StructRNA *srna) +{ + FunctionRNA *func; + PropertyRNA *parm; + + func= RNA_def_function(srna, "frame_path", "rna_SceneRender_get_frame_path"); + RNA_def_function_ui_description(func, "Set scene frame updating all objects immediately."); + parm= RNA_def_int(func, "frame", INT_MIN, INT_MIN, INT_MAX, "", "Frame number to use, if unset the current frame will be used.", MINAFRAME, MAXFRAME); + parm= RNA_def_string(func, "name", "", FILE_MAX, "File Name", "the resulting filename from the scenes render settings."); + RNA_def_property_flag(parm, PROP_THICK_WRAP); /* needed for string return value */ + RNA_def_function_return_mark(func, parm); +} + #endif |