RenderEngine: add .is_animation and .is_preview properties to detect if it's
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Wed, 2 Nov 2011 13:36:28 +0000 (13:36 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Wed, 2 Nov 2011 13:36:28 +0000 (13:36 +0000)
an animation or preview render that is being done.

source/blender/makesrna/intern/rna_render.c
source/blender/render/extern/include/RE_engine.h
source/blender/render/intern/include/render_types.h
source/blender/render/intern/source/external_engine.c
source/blender/render/intern/source/pipeline.c

index 1498d16..9b53b47 100644 (file)
@@ -251,9 +251,16 @@ static void rna_def_render_engine(BlenderRNA *brna)
        prop= RNA_def_string(func, "message", "", 0, "Report Message", "");
        RNA_def_property_flag(prop, PROP_REQUIRED);
 
-       /* registration */
        RNA_define_verify_sdna(0);
 
+       prop= RNA_def_property(srna, "is_animation", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "flag", RE_ENGINE_ANIMATION);
+
+       prop= RNA_def_property(srna, "is_preview", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "flag", RE_ENGINE_PREVIEW);
+
+       /* registration */
+
        prop= RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);
        RNA_def_property_string_sdna(prop, NULL, "type->idname");
        RNA_def_property_flag(prop, PROP_REGISTER|PROP_NEVER_CLAMP);
index 1326ed4..344ef30 100644 (file)
@@ -46,11 +46,16 @@ struct Scene;
 
 /* External Engine */
 
+/* RenderEngineType.flag */
 #define RE_INTERNAL                            1
 #define RE_GAME                                        2
 #define RE_USE_PREVIEW                 4
 #define RE_USE_POSTPROCESS             8
 
+/* RenderEngine.flag */
+#define RE_ENGINE_ANIMATION            1
+#define RE_ENGINE_PREVIEW              2
+
 extern ListBase R_engines;
 
 typedef struct RenderEngineType {
@@ -70,6 +75,8 @@ typedef struct RenderEngineType {
 typedef struct RenderEngine {
        RenderEngineType *type;
 
+       int flag;
+
        struct Render *re;
        ListBase fullresult;
 } RenderEngine;
index aa2dd29..ae4e55b 100644 (file)
@@ -601,6 +601,7 @@ typedef struct LampRen {
 #define R_NEED_TANGENT 16
 #define R_BAKE_TRACE   32
 #define R_BAKING               64
+#define R_ANIMATION            128
 
 /* vlakren->flag (vlak = face in dutch) char!!! */
 #define R_SMOOTH               1
index a4d1e50..a621432 100644 (file)
@@ -265,6 +265,11 @@ int RE_engine_render(Render *re, int do_all)
        engine = RE_engine_create(type);
        engine->re= re;
 
+       if(re->flag & R_ANIMATION)
+               engine->flag |= RE_ENGINE_ANIMATION;
+       if(re->r.scemode & R_PREVIEWBUTS)
+               engine->flag |= RE_ENGINE_PREVIEW;
+
        if((re->r.scemode & (R_NO_FRAME_UPDATE|R_PREVIEWBUTS))==0)
                scene_update_for_newframe(re->main, re->scene, re->lay);
 
index 64b36c1..8d72be1 100644 (file)
@@ -3085,6 +3085,8 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri
        /* is also set by caller renderwin.c */
        G.rendering= 1;
 
+       re->flag |= R_ANIMATION;
+
        if(BKE_imtype_is_movie(scene->r.imtype))
                if(!mh->start_movie(scene, &re->r, re->rectx, re->recty, re->reports))
                        G.afbreek= 1;
@@ -3193,6 +3195,8 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri
 
        scene->r.cfra= cfrao;
 
+       re->flag &= ~R_ANIMATION;
+
        /* UGLY WARNING */
        G.rendering= 0;
 }