Revision: 41502
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=41502
Author:   blendix
Date:     2011-11-03 16:41:48 +0000 (Thu, 03 Nov 2011)
Log Message:
-----------
Depsgraph: more tweaking for update acces from python API

* Move scene_update_pre callback before depsgraph flusing so it works better
  when you do modifications on objects then.
* Fix missing update after making modifications in frame_change_pre, recalc
  flags were not being flushed.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/scene.c

Modified: trunk/blender/source/blender/blenkernel/intern/scene.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/scene.c      2011-11-03 
16:16:19 UTC (rev 41501)
+++ trunk/blender/source/blender/blenkernel/intern/scene.c      2011-11-03 
16:41:48 UTC (rev 41502)
@@ -990,18 +990,22 @@
 /* this is called in main loop, doing tagged updates before redraw */
 void scene_update_tagged(Main *bmain, Scene *scene)
 {
+       /* keep this first */
+       BLI_exec_cb(bmain, &scene->id, BLI_CB_EVT_SCENE_UPDATE_PRE);
+
+       /* flush recalc flags to dependencies */
        DAG_ids_flush_tagged(bmain);
 
-       BLI_exec_cb(bmain, &scene->id, BLI_CB_EVT_SCENE_UPDATE_PRE);
-
        scene->physics_settings.quick_cache_step= 0;
 
        /* update all objects: drivers, matrices, displists, etc. flags set
-          by depgraph or manual, no layer check here, gets correct flushed */
+          by depgraph or manual, no layer check here, gets correct flushed
 
+          in the future this should handle updates for all datablocks, not
+          only objects and scenes. - brecht */
        scene_update_tagged_recursive(bmain, scene, scene);
 
-       /* recalc scene animation data here (for sequencer) */
+       /* extra call here to recalc scene animation (for sequencer) */
        {
                AnimData *adt= BKE_animdata_from_id(&scene->id);
                float ctime = BKE_curframe(scene);
@@ -1010,15 +1014,15 @@
                        BKE_animsys_evaluate_animdata(scene, &scene->id, adt, 
ctime, 0);
        }
        
+       /* quick point cache updates */
        if (scene->physics_settings.quick_cache_step)
                BKE_ptcache_quick_cache_all(bmain, scene);
 
+       /* notify editors about recalc */
        DAG_ids_check_recalc(bmain);
 
+       /* keep this last */
        BLI_exec_cb(bmain, &scene->id, BLI_CB_EVT_SCENE_UPDATE_POST);
-
-       /* in the future this should handle updates for all datablocks, not
-          only objects and scenes. - brecht */
 }
 
 void scene_clear_tagged(Main *bmain, Scene *UNUSED(scene))
@@ -1033,7 +1037,8 @@
        Scene *sce_iter;
 
        /* keep this first */
-       BLI_exec_cb(bmain, (ID *)sce, BLI_CB_EVT_FRAME_CHANGE_PRE);
+       BLI_exec_cb(bmain, &sce->id, BLI_CB_EVT_FRAME_CHANGE_PRE);
+       BLI_exec_cb(bmain, &sce->id, BLI_CB_EVT_SCENE_UPDATE_PRE);
 
        sound_set_cfra(sce->r.cfra);
        
@@ -1045,13 +1050,15 @@
                        DAG_scene_sort(bmain, sce_iter);
        }
 
+       /* flush recalc flags to dependencies, if we were only changing a frame
+          this would not be necessary, but if a user or a script has modified
+          some datablock before scene_update_tagged was called, we need the 
flush */
+       DAG_ids_flush_tagged(bmain);
 
        /* Following 2 functions are recursive
         * so dont call within 'scene_update_tagged_recursive' */
        DAG_scene_update_flags(bmain, sce, lay, TRUE);   // only stuff that 
moves or needs display still
 
-       BLI_exec_cb(bmain, (ID *)sce, BLI_CB_EVT_SCENE_UPDATE_PRE);
-
        /* All 'standard' (i.e. without any dependencies) animation is handled 
here,
         * with an 'local' to 'macro' order of evaluation. This should ensure 
that
         * settings stored nestled within a hierarchy (i.e. settings in a 
Texture block
@@ -1065,8 +1072,8 @@
        scene_update_tagged_recursive(bmain, sce, sce);
 
        /* keep this last */
-       BLI_exec_cb(bmain, (ID *)sce, BLI_CB_EVT_SCENE_UPDATE_POST);
-       BLI_exec_cb(bmain, (ID *)sce, BLI_CB_EVT_FRAME_CHANGE_POST);
+       BLI_exec_cb(bmain, &sce->id, BLI_CB_EVT_SCENE_UPDATE_POST);
+       BLI_exec_cb(bmain, &sce->id, BLI_CB_EVT_FRAME_CHANGE_POST);
 
        DAG_ids_clear_recalc(bmain);
 }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to