From ac52c79cb19ac85e06651a7b9af2e54efcd45a97 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 2 Nov 2011 19:24:30 +0000 Subject: RenderEngine/Nodes: system to check for shading nodes compatibility * Scene.use_shading_nodes property to check if RenderEngine is using new shading nodes system, and RenderEngine.bl_use_shading_nodes to set this. * Add mechanism for tagging nodes as being compatible with the old/new system. --- source/blender/blenkernel/intern/scene.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'source/blender/blenkernel/intern/scene.c') diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 6b3786663df..c902bee80a8 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -72,6 +72,8 @@ #include "BKE_sound.h" +#include "RE_engine.h" + //XXX #include "BIF_previewrender.h" //XXX #include "BIF_editseq.h" @@ -1127,3 +1129,10 @@ Base *_setlooper_base_step(Scene **sce_iter, Base *base) return NULL; } + +int scene_use_new_shading_nodes(Scene *scene) +{ + RenderEngineType *type= RE_engines_find(scene->r.engine); + return (type->flag & RE_USE_SHADING_NODES); +} + -- cgit v1.2.3 From 723e129252f82cc81faa8834a68c79e4439ee8fa Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 2 Nov 2011 20:56:52 +0000 Subject: Depsgraph/Python: callbacks and properties to detect datablock changes * Adds two new python handlers: scene_update_pre() and scene_update_post() These run before and after Blender does a scene update on making modifications to the scene. * Datablocks now have an is_updated property. This will be set to true in the above callbacks if the datablock was tagged to be updated. This works for the most common datablocks used for rendering: object, material, world, lamsp, texture, mesh, curve. * Datablock collections also have an is_updated property. If this is set, it means one datablock of this type was added, removed or modified. It's also useful as a quick check to avoid looping over all datablocks. * RenderEngine.view_update() can also check these properties, for interactive viewport rendering. http://wiki.blender.org/index.php/Dev:2.6/Source/Render/UpdateAPI --- source/blender/blenkernel/intern/scene.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'source/blender/blenkernel/intern/scene.c') diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index c902bee80a8..b25120c0fff 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -992,6 +992,8 @@ void scene_update_tagged(Main *bmain, Scene *scene) { 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 @@ -1011,10 +1013,19 @@ void scene_update_tagged(Main *bmain, Scene *scene) if (scene->physics_settings.quick_cache_step) BKE_ptcache_quick_cache_all(bmain, scene); + DAG_ids_check_recalc(bmain); + + 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)) +{ + DAG_ids_clear_recalc(bmain); +} + /* applies changes right away, does all sets too */ void scene_update_for_newframe(Main *bmain, Scene *sce, unsigned int lay) { @@ -1039,6 +1050,8 @@ void scene_update_for_newframe(Main *bmain, Scene *sce, unsigned int lay) * 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 @@ -1052,6 +1065,7 @@ void scene_update_for_newframe(Main *bmain, Scene *sce, unsigned int lay) 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); } -- cgit v1.2.3 From fa8fffac1c498dc37a372e63324da48ca15c0907 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 3 Nov 2011 10:03:08 +0000 Subject: Depsgraph/Python: ensure datablocks with animation data get tagged as being updated on frame change. --- source/blender/blenkernel/intern/scene.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source/blender/blenkernel/intern/scene.c') diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index b25120c0fff..7ba0a642cdd 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -1067,6 +1067,8 @@ void scene_update_for_newframe(Main *bmain, Scene *sce, unsigned int lay) /* 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); + + DAG_ids_clear_recalc(bmain); } /* return default layer, also used to patch old files */ -- cgit v1.2.3 From d53989bda6e5b30f41846554c3a68ee695b031f2 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 3 Nov 2011 16:41:48 +0000 Subject: 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. --- source/blender/blenkernel/intern/scene.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) (limited to 'source/blender/blenkernel/intern/scene.c') diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 7ba0a642cdd..a9de75dc7d0 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -990,18 +990,22 @@ static void scene_update_tagged_recursive(Main *bmain, Scene *scene, Scene *scen /* this is called in main loop, doing tagged updates before redraw */ void scene_update_tagged(Main *bmain, Scene *scene) { - DAG_ids_flush_tagged(bmain); - + /* 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); + 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 @@ void scene_update_tagged(Main *bmain, Scene *scene) 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 @@ void scene_update_for_newframe(Main *bmain, Scene *sce, unsigned int lay) 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 @@ void scene_update_for_newframe(Main *bmain, Scene *sce, unsigned int lay) 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 @@ void scene_update_for_newframe(Main *bmain, Scene *sce, unsigned int lay) 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); } -- cgit v1.2.3