Revision: 36729 http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=36729 Author: blendix Date: 2011-05-17 14:26:45 +0000 (Tue, 17 May 2011) Log Message: ----------- Render API: first step in updating RenderEngine to work according to: http://wiki.blender.org/index.php/Dev:2.5/Source/Render/RenderEngineAPI
Modified Paths: -------------- branches/cycles/intern/cycles/blender/addon/__init__.py branches/cycles/intern/cycles/blender/addon/engine.py branches/cycles/source/blender/blenkernel/BKE_depsgraph.h branches/cycles/source/blender/blenkernel/BKE_scene.h branches/cycles/source/blender/blenkernel/intern/depsgraph.c branches/cycles/source/blender/blenkernel/intern/scene.c branches/cycles/source/blender/editors/include/ED_render.h branches/cycles/source/blender/editors/render/CMakeLists.txt branches/cycles/source/blender/editors/render/render_shading.c branches/cycles/source/blender/editors/space_view3d/space_view3d.c branches/cycles/source/blender/editors/space_view3d/view3d_draw.c branches/cycles/source/blender/makesrna/intern/rna_render.c branches/cycles/source/blender/makesrna/intern/rna_scene_api.c branches/cycles/source/blender/render/CMakeLists.txt branches/cycles/source/blender/render/SConscript branches/cycles/source/blender/render/extern/include/RE_engine.h branches/cycles/source/blender/render/intern/pipeline/engine.c branches/cycles/source/blender/windowmanager/intern/wm_event_system.c branches/cycles/source/blenderplayer/bad_level_call_stubs/stubs.c Added Paths: ----------- branches/cycles/source/blender/editors/render/render_update.c Modified: branches/cycles/intern/cycles/blender/addon/__init__.py =================================================================== --- branches/cycles/intern/cycles/blender/addon/__init__.py 2011-05-17 14:18:02 UTC (rev 36728) +++ branches/cycles/intern/cycles/blender/addon/__init__.py 2011-05-17 14:26:45 UTC (rev 36729) @@ -47,17 +47,30 @@ def __del__(self): engine.free(self) - def render(self, scene): - engine.create(self, scene, True) - engine.render(self, scene) + # final render + def update(self, data, scene): + engine.create(self, data, scene) + engine.update(self, data, scene) - def draw(self, scene): + def render(self): + engine.render(self) + + # preview render + # def preview_update(self, context, id): + # pass + # + # def preview_render(self): + # pass + + # viewport render + def view_update(self, context): if not self.session: - engine.create(self, scene, False) - engine.draw(self, scene) + engine.create(self, context.blend_data, context.scene, + context.region, context.space_data, context.region_data) + engine.update(self, context.blend_data, context.scene) - def update(self, scene): - engine.update(self, scene) + def view_draw(self, context): + engine.draw(self, context.region, context.space_data, context.region_data) def register(): properties.register() Modified: branches/cycles/intern/cycles/blender/addon/engine.py =================================================================== --- branches/cycles/intern/cycles/blender/addon/engine.py 2011-05-17 14:18:02 UTC (rev 36728) +++ branches/cycles/intern/cycles/blender/addon/engine.py 2011-05-17 14:26:45 UTC (rev 36729) @@ -23,20 +23,18 @@ import os.path lib.init(os.path.dirname(__file__)) -def create(engine, scene, offline): +def create(engine, data, scene, region = 0, v3d = 0, rv3d = 0): from cycles import libcycles_blender as lib - data = bpy.data.as_pointer() + + data = data.as_pointer() scene = scene.as_pointer() + if region: + region = region.as_pointer() + if v3d: + v3d = v3d.as_pointer() + if rv3d: + rv3d = rv3d.as_pointer() - if not offline and bpy.context.area.type == 'VIEW_3D': - region = bpy.context.region.as_pointer() - v3d = bpy.context.space_data.as_pointer() - rv3d = bpy.context.region_data.as_pointer() - else: - region = 0 - v3d = 0 - rv3d = 0 - engine.session = lib.create(engine.as_pointer(), data, scene, region, v3d, rv3d) def free(engine): @@ -46,19 +44,18 @@ lib.free(engine.session) del engine.session -def render(engine, scene): +def render(engine): from cycles import libcycles_blender as lib lib.render(engine.session) -def update(engine, scene): +def update(engine, data, scene): from cycles import libcycles_blender as lib lib.sync(engine.session) -def draw(engine, scene): +def draw(engine, region, v3d, rv3d): from cycles import libcycles_blender as lib - v3d = bpy.context.space_data.as_pointer() - rv3d = bpy.context.region_data.as_pointer() - region = bpy.context.region + v3d = v3d.as_pointer() + rv3d = rv3d.as_pointer() # draw render image status, substatus = lib.draw(engine.session, v3d, rv3d) Modified: branches/cycles/source/blender/blenkernel/BKE_depsgraph.h =================================================================== --- branches/cycles/source/blender/blenkernel/BKE_depsgraph.h 2011-05-17 14:18:02 UTC (rev 36728) +++ branches/cycles/source/blender/blenkernel/BKE_depsgraph.h 2011-05-17 14:26:45 UTC (rev 36729) @@ -121,7 +121,8 @@ void DAG_id_tag_update(struct ID *id, short flag); /* flush all tagged updates */ void DAG_ids_flush_tagged(struct Main *bmain); - /* clear ID recalc flags */ + /* check and clear ID recalc flags */ +void DAG_ids_check_recalc(struct Main *bmain); void DAG_ids_clear_recalc(struct Main *bmain); /* test if any of this id type is tagged for update */ int DAG_id_type_tagged(struct Main *bmain, short idtype); Modified: branches/cycles/source/blender/blenkernel/BKE_scene.h =================================================================== --- branches/cycles/source/blender/blenkernel/BKE_scene.h 2011-05-17 14:18:02 UTC (rev 36728) +++ branches/cycles/source/blender/blenkernel/BKE_scene.h 2011-05-17 14:26:45 UTC (rev 36729) @@ -90,6 +90,8 @@ float BKE_curframe(struct Scene *scene); void scene_update_tagged(struct Main *bmain, struct Scene *sce); +void scene_clear_tagged(struct Main *bmain, struct Scene *sce); + void scene_update_for_newframe(struct Main *bmain, struct Scene *sce, unsigned int lay); void scene_add_render_layer(struct Scene *sce); Modified: branches/cycles/source/blender/blenkernel/intern/depsgraph.c =================================================================== --- branches/cycles/source/blender/blenkernel/intern/depsgraph.c 2011-05-17 14:18:02 UTC (rev 36728) +++ branches/cycles/source/blender/blenkernel/intern/depsgraph.c 2011-05-17 14:26:45 UTC (rev 36729) @@ -2508,10 +2508,10 @@ DAG_scene_flush_update(bmain, sce, lay, 0); } -void DAG_ids_clear_recalc(Main *bmain) +void DAG_ids_check_recalc(Main *bmain) { ListBase *lbarray[MAX_LIBARRAY]; - int a, first_tag = 1; + int a; /* loop over all ID types */ a = set_listbasepointers(bmain, lbarray); @@ -2524,11 +2524,28 @@ looping over all ID's in case there are no tags */ if(id && bmain->id_tag_update[id->name[0]]) { /* do editors update */ - if(first_tag) { - dag_editors_update(bmain, NULL); - first_tag = 0; - } + dag_editors_update(bmain, NULL); + return; + } + } +} + +void DAG_ids_clear_recalc(Main *bmain) +{ + ListBase *lbarray[MAX_LIBARRAY]; + int a; + + /* loop over all ID types */ + a = set_listbasepointers(bmain, lbarray); + + while(a--) { + ListBase *lb = lbarray[a]; + ID *id = lb->first; + + /* we tag based on first ID type character to avoid + looping over all ID's in case there are no tags */ + if(id && bmain->id_tag_update[id->name[0]]) { for(; id; id=id->next) if(id->flag & (LIB_ID_RECALC|LIB_ID_RECALC_DATA)) id->flag &= ~(LIB_ID_RECALC|LIB_ID_RECALC_DATA); Modified: branches/cycles/source/blender/blenkernel/intern/scene.c =================================================================== --- branches/cycles/source/blender/blenkernel/intern/scene.c 2011-05-17 14:18:02 UTC (rev 36728) +++ branches/cycles/source/blender/blenkernel/intern/scene.c 2011-05-17 14:26:45 UTC (rev 36729) @@ -989,13 +989,18 @@ if (scene->physics_settings.quick_cache_step) BKE_ptcache_quick_cache_all(bmain, scene); - - DAG_ids_clear_recalc(bmain); + DAG_ids_check_recalc(bmain); + /* in the future this should handle updates for all datablocks, not only objects and scenes. - brecht */ } +void scene_clear_tagged(Main *bmain, Scene *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) { Modified: branches/cycles/source/blender/editors/include/ED_render.h =================================================================== --- branches/cycles/source/blender/editors/include/ED_render.h 2011-05-17 14:18:02 UTC (rev 36728) +++ branches/cycles/source/blender/editors/include/ED_render.h 2011-05-17 14:26:45 UTC (rev 36729) @@ -45,7 +45,7 @@ void ED_render_id_flush_update(struct Main *bmain, struct ID *id); void ED_render_engine_changed(struct Main *bmain); -void ED_render_engine_update_tagged(struct Main *bmain); +void ED_render_engine_update_tagged(struct bContext *C, struct Main *bmain); /* render_preview.c */ Modified: branches/cycles/source/blender/editors/render/CMakeLists.txt =================================================================== --- branches/cycles/source/blender/editors/render/CMakeLists.txt 2011-05-17 14:18:02 UTC (rev 36728) +++ branches/cycles/source/blender/editors/render/CMakeLists.txt 2011-05-17 14:26:45 UTC (rev 36729) @@ -41,6 +41,7 @@ render_ops.c render_preview.c render_shading.c + render_update.c render_intern.h ) Modified: branches/cycles/source/blender/editors/render/render_shading.c =================================================================== --- branches/cycles/source/blender/editors/render/render_shading.c 2011-05-17 14:18:02 UTC (rev 36728) +++ branches/cycles/source/blender/editors/render/render_shading.c 2011-05-17 14:26:45 UTC (rev 36729) @@ -88,244 +88,6 @@ #include "render_intern.h" // own include -/***************************** Updates *********************************** - * ED_render_id_flush_update gets called from DAG_id_tag_update, to do * - * editor level updates when the ID changes. when these ID blocks are in * - * the dependency graph, we can get rid of the manual dependency checks */ - -static int mtex_use_tex(MTex **mtex, int tot, Tex *tex) -{ - int a; - - if(!mtex) - return 0; - - for(a=0; a<tot; a++) - if(mtex[a] && mtex[a]->tex == tex) - return 1; - - return 0; -} - -static int nodes_use_tex(bNodeTree *ntree, Tex *tex) -{ - bNode *node; - - for(node=ntree->nodes.first; node; node= node->next) { - if(node->id) { - if(node->id == (ID*)tex) { - return 1; - } - else if(node->type==NODE_GROUP) { - if(nodes_use_tex((bNodeTree *)node->id, tex)) - return 1; - } - } - } - - return 0; -} - -static void material_changed(Main *UNUSED(bmain), Material *ma) -{ - /* icons */ - BKE_icon_changed(BKE_icon_getid(&ma->id)); - - /* glsl */ - if(ma->gpumaterial.first) - GPU_material_free(ma); -} - -static void texture_changed(Main *bmain, Tex *tex) -{ - Material *ma; - Lamp *la; - World *wo; - - /* icons */ - BKE_icon_changed(BKE_icon_getid(&tex->id)); - - /* find materials */ - for(ma=bmain->mat.first; ma; ma=ma->id.next) { - if(mtex_use_tex(ma->mtex, MAX_MTEX, tex)); - else if(ma->use_nodes && ma->nodetree && nodes_use_tex(ma->nodetree, tex)); - else continue; - - BKE_icon_changed(BKE_icon_getid(&ma->id)); - - if(ma->gpumaterial.first) - GPU_material_free(ma); - } - - /* find lamps */ - for(la=bmain->lamp.first; la; la=la->id.next) { - if(mtex_use_tex(la->mtex, MAX_MTEX, tex)); - else if(la->nodetree && nodes_use_tex(la->nodetree, tex)); - else continue; - - BKE_icon_changed(BKE_icon_getid(&la->id)); - } - - /* find worlds */ - for(wo=bmain->world.first; wo; wo=wo->id.next) { - if(mtex_use_tex(wo->mtex, MAX_MTEX, tex)); - else if(wo->nodetree && nodes_use_tex(wo->nodetree, tex)); - else continue; - - BKE_icon_changed(BKE_icon_getid(&wo->id)); - } -} - -static void lamp_changed(Main *bmain, Lamp *la) -{ - Object *ob; - Material *ma; - - /* icons */ @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs