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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWillian Padovani Germano <wpgermano@gmail.com>2008-09-19 02:33:49 +0400
committerWillian Padovani Germano <wpgermano@gmail.com>2008-09-19 02:33:49 +0400
commit6ff74f45279aeea88fa9a93ba0ced726fdeafc5a (patch)
treea08f2ad3bd979a4707658ae79490874e010c632e
parentec6bd008c1899986c619ce1976709eac1c1c1e0c (diff)
== Python Script Links ==
Bug #17599: Summary: Python constraints, good in 2.46 not working anymore in 2.47 http://projects.blender.org/tracker/?func=detail&atid=125&aid=17599&group_id=9 Improved my old hack to avoid frame changed scriptlinks from running when rendering stills, should fix this bug. It also causes REDRAW scriptlinks to be executed during renders, but that conforms to how FRAMECHANGED ones work. BTW: this can still be improved. The current system meant to disable all Python functionality at once needs imo to be replaced by one that allows to enable / disable per feature (scriptlinks, pyconstraints, pynodes, etc.). A better way to inform scriptlinks about what is going on (render, anim, render anim, etc.) would also help. Will discuss with others.
-rw-r--r--source/blender/blenkernel/BKE_bad_level_calls.h2
-rw-r--r--source/blender/blenkernel/bad_level_call_stubs/stubs.c2
-rw-r--r--source/blender/blenkernel/intern/scene.c6
-rw-r--r--source/blender/python/BPY_extern.h2
-rw-r--r--source/blender/python/BPY_interface.c11
-rw-r--r--source/blender/python/api2_2x/sceneRender.c17
-rw-r--r--source/blender/src/renderwin.c15
-rw-r--r--source/creator/creator.c19
8 files changed, 30 insertions, 44 deletions
diff --git a/source/blender/blenkernel/BKE_bad_level_calls.h b/source/blender/blenkernel/BKE_bad_level_calls.h
index 8dee9a27f49..0b623526562 100644
--- a/source/blender/blenkernel/BKE_bad_level_calls.h
+++ b/source/blender/blenkernel/BKE_bad_level_calls.h
@@ -141,7 +141,7 @@ short pupmenu(char *instr); // will be general callback
/* scene.c */
#include "DNA_sequence_types.h"
void free_editing(struct Editing *ed); // scenes and sequences problem...
-void BPY_do_all_scripts (short int event);
+void BPY_do_all_scripts (short int event, short int anim);
int BPY_call_importloader(char *name);
diff --git a/source/blender/blenkernel/bad_level_call_stubs/stubs.c b/source/blender/blenkernel/bad_level_call_stubs/stubs.c
index f4beca262d7..ae336d0fc26 100644
--- a/source/blender/blenkernel/bad_level_call_stubs/stubs.c
+++ b/source/blender/blenkernel/bad_level_call_stubs/stubs.c
@@ -201,7 +201,7 @@ short pupmenu(char *instr){ return 0;} // will be general callback
/* scene.c */
#include "DNA_sequence_types.h"
void free_editing(struct Editing *ed){} // scenes and sequences problem...
-void BPY_do_all_scripts (short int event){}
+void BPY_do_all_scripts (short int event, short int anim){}
/*editmesh_lib.c*/
void EM_select_face(struct EditFace *efa, int sel) {}
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 553107dd264..701e8ecb311 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -350,7 +350,7 @@ void set_scene_bg(Scene *sce)
/* no full animation update, this to enable render code to work (render code calls own animation updates) */
/* do we need FRAMECHANGED in set_scene? */
-// if (G.f & G_DOSCRIPTLINKS) BPY_do_all_scripts(SCRIPT_FRAMECHANGED);
+// if (G.f & G_DOSCRIPTLINKS) BPY_do_all_scripts(SCRIPT_FRAMECHANGED, 0);
}
/* called from creator.c */
@@ -570,8 +570,8 @@ void scene_update_for_newframe(Scene *sce, unsigned int lay)
/* object ipos are calculated in where_is_object */
do_all_data_ipos();
- if (G.f & G_DOSCRIPTLINKS) BPY_do_all_scripts(SCRIPT_FRAMECHANGED);
-
+ if (G.f & G_DOSCRIPTLINKS) BPY_do_all_scripts(SCRIPT_FRAMECHANGED, 0);
+
/* sets first, we allow per definition current scene to have dependencies on sets */
for(sce= sce->set; sce; sce= sce->set)
scene_update(sce, lay);
diff --git a/source/blender/python/BPY_extern.h b/source/blender/python/BPY_extern.h
index 4b96ef3fdf0..146093d6b99 100644
--- a/source/blender/python/BPY_extern.h
+++ b/source/blender/python/BPY_extern.h
@@ -100,7 +100,7 @@ extern "C" {
void BPY_clear_bad_scriptlinks( struct Text *byebye );
int BPY_has_onload_script( void );
- void BPY_do_all_scripts( short event );
+ void BPY_do_all_scripts( short event, short anim );
int BPY_check_all_scriptlinks( struct Text *text );
void BPY_do_pyscript( struct ID *id, short event );
void BPY_free_scriptlink( struct ScriptLink *slink );
diff --git a/source/blender/python/BPY_interface.c b/source/blender/python/BPY_interface.c
index 041ba069928..c0dab4df651 100644
--- a/source/blender/python/BPY_interface.c
+++ b/source/blender/python/BPY_interface.c
@@ -2163,8 +2163,14 @@ void BPY_clear_bad_scriptlinks( struct Text *byebye )
* For the scene, only the current active scene the scripts are
* executed (if any).
*****************************************************************************/
-void BPY_do_all_scripts( short event )
+void BPY_do_all_scripts( short event, short anim )
{
+ /* during stills rendering we disable FRAMECHANGED events */
+ static char disable_frame_changed = 0;
+
+ if ((event == SCRIPT_FRAMECHANGED) && disable_frame_changed)
+ return;
+
DoAllScriptsFromList( &( G.main->object ), event );
DoAllScriptsFromList( &( G.main->lamp ), event );
DoAllScriptsFromList( &( G.main->camera ), event );
@@ -2180,9 +2186,12 @@ void BPY_do_all_scripts( short event )
* "import sys; sys.setcheckinterval(sys.maxint)" */
if (event == SCRIPT_RENDER) {
_Py_CheckInterval = PyInt_GetMax();
+ if (!anim)
+ disable_frame_changed = 1;
}
else if (event == SCRIPT_POSTRENDER) {
_Py_CheckInterval = 100; /* Python default */
+ disable_frame_changed = 0;
}
return;
diff --git a/source/blender/python/api2_2x/sceneRender.c b/source/blender/python/api2_2x/sceneRender.c
index 22e165cbe9f..7958e66b44f 100644
--- a/source/blender/python/api2_2x/sceneRender.c
+++ b/source/blender/python/api2_2x/sceneRender.c
@@ -481,7 +481,6 @@ PyObject *RenderData_Render( BPy_RenderData * self )
set_scene( oldsce );
}
else { /* background mode (blender -b file.blend -P script) */
- int slink_flag = 0;
Render *re= RE_NewRender(G.scene->id.name);
int end_frame = G.scene->r.efra;
@@ -492,20 +491,14 @@ PyObject *RenderData_Render( BPy_RenderData * self )
G.scene->r.efra = G.scene->r.sfra;
- if (G.f & G_DOSCRIPTLINKS) {
- BPY_do_all_scripts(SCRIPT_RENDER);
- G.f &= ~G_DOSCRIPTLINKS; /* avoid FRAMECHANGED events*/
- slink_flag = 1;
- }
+ if (G.f & G_DOSCRIPTLINKS)
+ BPY_do_all_scripts(SCRIPT_RENDER, 0);
tstate = PyEval_SaveThread();
RE_BlenderAnim(re, G.scene, G.scene->r.sfra, G.scene->r.efra);
- if (slink_flag) {
- G.f |= G_DOSCRIPTLINKS;
- BPY_do_all_scripts(SCRIPT_POSTRENDER);
- }
+ BPY_do_all_scripts(SCRIPT_POSTRENDER, 0);
G.scene->r.efra = end_frame;
}
@@ -603,13 +596,13 @@ PyObject *RenderData_RenderAnim( BPy_RenderData * self )
"start frame must be less or equal to end frame");
if (G.f & G_DOSCRIPTLINKS)
- BPY_do_all_scripts(SCRIPT_RENDER);
+ BPY_do_all_scripts(SCRIPT_RENDER, 1);
tstate = PyEval_SaveThread();
RE_BlenderAnim(re, G.scene, G.scene->r.sfra, G.scene->r.efra);
if (G.f & G_DOSCRIPTLINKS)
- BPY_do_all_scripts(SCRIPT_POSTRENDER);
+ BPY_do_all_scripts(SCRIPT_POSTRENDER, 1);
}
PyEval_RestoreThread(tstate);
diff --git a/source/blender/src/renderwin.c b/source/blender/src/renderwin.c
index 33484500328..c26eedd26fd 100644
--- a/source/blender/src/renderwin.c
+++ b/source/blender/src/renderwin.c
@@ -1274,16 +1274,9 @@ void BIF_store_spare(void)
/* set up display, render an image or scene */
void BIF_do_render(int anim)
{
- int slink_flag = 0;
+ if (G.f & G_DOSCRIPTLINKS)
+ BPY_do_all_scripts(SCRIPT_RENDER, anim);
- if (G.f & G_DOSCRIPTLINKS) {
- BPY_do_all_scripts(SCRIPT_RENDER);
- if (!anim) { /* avoid FRAMECHANGED slink in render callback */
- G.f &= ~G_DOSCRIPTLINKS;
- slink_flag = 1;
- }
- }
-
BIF_store_spare();
do_render(anim);
@@ -1294,8 +1287,8 @@ void BIF_do_render(int anim)
}
if(G.scene->r.dither_intensity != 0.0f)
BIF_redraw_render_rect();
- if (slink_flag) G.f |= G_DOSCRIPTLINKS;
- if (G.f & G_DOSCRIPTLINKS) BPY_do_all_scripts(SCRIPT_POSTRENDER);
+
+ if (G.f & G_DOSCRIPTLINKS) BPY_do_all_scripts(SCRIPT_POSTRENDER, anim);
}
void do_ogl_view3d_render(Render *re, View3D *v3d, int winx, int winy)
diff --git a/source/creator/creator.c b/source/creator/creator.c
index f27dee946ed..ac81557110f 100644
--- a/source/creator/creator.c
+++ b/source/creator/creator.c
@@ -618,23 +618,14 @@ int main(int argc, char **argv)
if (G.scene) {
if (a < argc) {
int frame= MIN2(MAXFRAME, MAX2(1, atoi(argv[a])));
- int slink_flag= 0;
Render *re= RE_NewRender(G.scene->id.name);
- if (G.f & G_DOSCRIPTLINKS) {
- BPY_do_all_scripts(SCRIPT_RENDER);
- /* avoid FRAMECHANGED slink event
- * (should only be triggered in anims): */
- G.f &= ~G_DOSCRIPTLINKS;
- slink_flag= 1;
- }
+ if (G.f & G_DOSCRIPTLINKS)
+ BPY_do_all_scripts(SCRIPT_RENDER, 0);
RE_BlenderAnim(re, G.scene, frame, frame);
- if (slink_flag) {
- G.f |= G_DOSCRIPTLINKS;
- BPY_do_all_scripts(SCRIPT_POSTRENDER);
- }
+ BPY_do_all_scripts(SCRIPT_POSTRENDER, 0);
}
} else {
printf("\nError: no blend loaded. cannot use '-f'.\n");
@@ -645,12 +636,12 @@ int main(int argc, char **argv)
Render *re= RE_NewRender(G.scene->id.name);
if (G.f & G_DOSCRIPTLINKS)
- BPY_do_all_scripts(SCRIPT_RENDER);
+ BPY_do_all_scripts(SCRIPT_RENDER, 1);
RE_BlenderAnim(re, G.scene, G.scene->r.sfra, G.scene->r.efra);
if (G.f & G_DOSCRIPTLINKS)
- BPY_do_all_scripts(SCRIPT_POSTRENDER);
+ BPY_do_all_scripts(SCRIPT_POSTRENDER, 1);
} else {
printf("\nError: no blend loaded. cannot use '-a'.\n");
}