diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-11-03 03:16:10 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-11-03 03:16:10 +0400 |
commit | 5fbf3b813cd5473070f3c3bd6572ad504b83dc74 (patch) | |
tree | f9cb28d79cf31d8ea85014ef5d70c80190fb3333 /source | |
parent | 439f57d361322bbe521cfd3e60dfd6534ca22c6d (diff) | |
parent | 4293f4738ce0ea1bb81260b12a6b64f98b6a3468 (diff) |
svn merge -r41458:41480 ^/trunk/blender
Diffstat (limited to 'source')
78 files changed, 1372 insertions, 217 deletions
diff --git a/source/blender/blenkernel/BKE_depsgraph.h b/source/blender/blenkernel/BKE_depsgraph.h index 59b7712a5a4..0b0637fb42a 100644 --- a/source/blender/blenkernel/BKE_depsgraph.h +++ b/source/blender/blenkernel/BKE_depsgraph.h @@ -120,6 +120,12 @@ void DAG_ids_flush_update(struct Main *bmain, int time); void DAG_id_tag_update(struct ID *id, short flag); /* flush all tagged updates */ void DAG_ids_flush_tagged(struct Main *bmain); + /* 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 */ +void DAG_id_type_tag(struct Main *bmain, short idtype); +int DAG_id_type_tagged(struct Main *bmain, short idtype); /* (re)-create dependency graph for armature pose */ void DAG_pose_sort(struct Object *ob); diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index a819a464d3f..7509205e968 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -130,7 +130,7 @@ typedef struct bNodeType { char name[32]; float width, minwidth, maxwidth; float height, minheight, maxheight; - short nclass, flag; + short nclass, flag, compatibility; /* templates for static sockets */ bNodeSocketTemplate *inputs, *outputs; @@ -230,8 +230,13 @@ typedef struct bNodeType { #define NODE_CLASS_PARTICLES 25 #define NODE_CLASS_TRANSFORM 30 #define NODE_CLASS_COMBINE 31 +#define NODE_CLASS_SHADER 40 #define NODE_CLASS_LAYOUT 100 +/* nodetype->compatibility */ +#define NODE_OLD_SHADING 1 +#define NODE_NEW_SHADING 2 + /* enum values for input/output */ #define SOCK_IN 1 #define SOCK_OUT 2 @@ -388,6 +393,7 @@ void node_type_exec_new(struct bNodeType *ntype, void (*newexecfunc)(void *data, int thread, struct bNode *, void *nodedata, struct bNodeStack **, struct bNodeStack **)); void node_type_gpu(struct bNodeType *ntype, int (*gpufunc)(struct GPUMaterial *mat, struct bNode *node, struct GPUNodeStack *in, struct GPUNodeStack *out)); void node_type_gpu_ext(struct bNodeType *ntype, int (*gpuextfunc)(struct GPUMaterial *mat, struct bNode *node, void *nodedata, struct GPUNodeStack *in, struct GPUNodeStack *out)); +void node_type_compatibility(struct bNodeType *ntype, short compatibility); /* ************** COMMON NODES *************** */ diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h index 5c214b2892a..4806a288cee 100644 --- a/source/blender/blenkernel/BKE_scene.h +++ b/source/blender/blenkernel/BKE_scene.h @@ -88,6 +88,8 @@ int scene_check_setscene(struct Main *bmain, struct Scene *sce); 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); @@ -98,6 +100,8 @@ int get_render_child_particle_number(struct RenderData *r, int num); int get_render_shadow_samples(struct RenderData *r, int samples); float get_render_aosss_error(struct RenderData *r, float error); +int scene_use_new_shading_nodes(struct Scene *scene); + #ifdef __cplusplus } #endif diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 13abf18e20c..981c20d6165 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -43,9 +43,11 @@ #include "BLI_utildefines.h" #include "DNA_anim_types.h" +#include "DNA_lamp_types.h" #include "DNA_material_types.h" #include "DNA_scene_types.h" #include "DNA_texture_types.h" +#include "DNA_world_types.h" #include "BKE_animsys.h" #include "BKE_action.h" @@ -2291,7 +2293,7 @@ void BKE_animsys_evaluate_all_animation (Main *main, Scene *scene, float ctime) EVAL_ANIM_NODETREE_IDS(main->tex.first, Tex, ADT_RECALC_ANIM); /* lamps */ - EVAL_ANIM_IDS(main->lamp.first, ADT_RECALC_ANIM); + EVAL_ANIM_NODETREE_IDS(main->lamp.first, Lamp, ADT_RECALC_ANIM); /* materials */ EVAL_ANIM_NODETREE_IDS(main->mat.first, Material, ADT_RECALC_ANIM); @@ -2331,7 +2333,7 @@ void BKE_animsys_evaluate_all_animation (Main *main, Scene *scene, float ctime) EVAL_ANIM_IDS(main->object.first, 0); /* worlds */ - EVAL_ANIM_IDS(main->world.first, ADT_RECALC_ANIM); + EVAL_ANIM_NODETREE_IDS(main->world.first, World, ADT_RECALC_ANIM); /* scenes */ EVAL_ANIM_NODETREE_IDS(main->scene.first, Scene, ADT_RECALC_ANIM); diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index c9df8a135fe..9d51571346f 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -1761,9 +1761,22 @@ void DAG_scene_sort(Main *bmain, Scene *sce) sce->recalc |= SCE_PRV_CHANGED; /* test for 3d preview */ } +static void lib_id_recalc_tag(Main *bmain, ID *id) +{ + id->flag |= LIB_ID_RECALC; + bmain->id_tag_update[id->name[0]] = 1; +} + +static void lib_id_recalc_data_tag(Main *bmain, ID *id) +{ + id->flag |= LIB_ID_RECALC_DATA; + bmain->id_tag_update[id->name[0]] = 1; +} + /* node was checked to have lasttime != curtime and is if type ID_OB */ static void flush_update_node(DagNode *node, unsigned int layer, int curtime) { + Main *bmain= G.main; DagAdjList *itA; Object *ob, *obc; int oldflag, changed=0; @@ -1789,20 +1802,24 @@ static void flush_update_node(DagNode *node, unsigned int layer, int curtime) if(itA->type & DAG_RL_OB_OB) { //printf("ob %s changes ob %s\n", ob->id.name, obc->id.name); obc->recalc |= OB_RECALC_OB; + lib_id_recalc_tag(bmain, &obc->id); } if(itA->type & DAG_RL_OB_DATA) { //printf("ob %s changes obdata %s\n", ob->id.name, obc->id.name); obc->recalc |= OB_RECALC_DATA; + lib_id_recalc_data_tag(bmain, &obc->id); } } if(ob->recalc & OB_RECALC_DATA) { if(itA->type & DAG_RL_DATA_OB) { //printf("obdata %s changes ob %s\n", ob->id.name, obc->id.name); obc->recalc |= OB_RECALC_OB; + lib_id_recalc_tag(bmain, &obc->id); } if(itA->type & DAG_RL_DATA_DATA) { //printf("obdata %s changes obdata %s\n", ob->id.name, obc->id.name); obc->recalc |= OB_RECALC_DATA; + lib_id_recalc_data_tag(bmain, &obc->id); } } if(oldflag!=obc->recalc) changed= 1; @@ -1833,6 +1850,7 @@ static void flush_update_node(DagNode *node, unsigned int layer, int curtime) if(itA->type & (DAG_RL_OB_DATA|DAG_RL_DATA_DATA)) { // printf("parent %s changes ob %s\n", ob->id.name, obc->id.name); obc->recalc |= OB_RECALC_DATA; + lib_id_recalc_data_tag(bmain, &obc->id); } } } @@ -1872,6 +1890,7 @@ static unsigned int flush_layer_node(Scene *sce, DagNode *node, int curtime) /* node was checked to have lasttime != curtime , and is of type ID_OB */ static void flush_pointcache_reset(Scene *scene, DagNode *node, int curtime, int reset) { + Main *bmain= G.main; DagAdjList *itA; Object *ob; @@ -1883,8 +1902,10 @@ static void flush_pointcache_reset(Scene *scene, DagNode *node, int curtime, int ob= (Object*)(itA->node->ob); if(reset || (ob->recalc & OB_RECALC_ALL)) { - if(BKE_ptcache_object_reset(scene, ob, PTCACHE_RESET_DEPSGRAPH)) + if(BKE_ptcache_object_reset(scene, ob, PTCACHE_RESET_DEPSGRAPH)) { ob->recalc |= OB_RECALC_DATA; + lib_id_recalc_data_tag(bmain, &ob->id); + } flush_pointcache_reset(scene, itA->node, curtime, 1); } @@ -2001,8 +2022,10 @@ void DAG_scene_flush_update(Main *bmain, Scene *sce, unsigned int lay, const sho ob= (Object*)(itA->node->ob); if(ob->recalc & OB_RECALC_ALL) { - if(BKE_ptcache_object_reset(sce, ob, PTCACHE_RESET_DEPSGRAPH)) + if(BKE_ptcache_object_reset(sce, ob, PTCACHE_RESET_DEPSGRAPH)) { ob->recalc |= OB_RECALC_DATA; + lib_id_recalc_data_tag(bmain, &ob->id); + } flush_pointcache_reset(sce, itA->node, lasttime, 1); } @@ -2204,6 +2227,12 @@ static void dag_object_time_update_flags(Object *ob) } } } + + if(ob->recalc & OB_RECALC_OB) + lib_id_recalc_tag(G.main, &ob->id); + if(ob->recalc & OB_RECALC_DATA) + lib_id_recalc_data_tag(G.main, &ob->id); + } /* flag all objects that need recalc, for changes in time for example */ /* do_time: make this optional because undo resets objects to their animated locations without this */ @@ -2362,6 +2391,9 @@ void DAG_on_visible_update(Main *bmain, const short do_time) DAG_scene_update_flags(bmain, scene, lay, do_time); scene->lay_updated |= lay; } + + /* hack to get objects updating on layer changes */ + DAG_id_type_tag(bmain, ID_OB); } static void dag_id_flush_update__isDependentTexture(void *userData, Object *UNUSED(ob), ID **idpoin) @@ -2408,6 +2440,7 @@ static void dag_id_flush_update(Scene *sce, ID *id) for(obt=bmain->object.first; obt; obt= obt->id.next) { if(!(ob && obt == ob) && obt->data == id) { obt->recalc |= OB_RECALC_DATA; + lib_id_recalc_data_tag(bmain, &obt->id); BKE_ptcache_object_reset(sce, obt, PTCACHE_RESET_DEPSGRAPH); } } @@ -2421,8 +2454,10 @@ static void dag_id_flush_update(Scene *sce, ID *id) data.is_dependent= 0; modifiers_foreachIDLink(obt, dag_id_flush_update__isDependentTexture, &data); - if (data.is_dependent) + if (data.is_dependent) { obt->recalc |= OB_RECALC_DATA; + lib_id_recalc_data_tag(bmain, &obt->id); + } /* particle settings can use the texture as well */ if(obt->particlesystem.first) { @@ -2435,7 +2470,8 @@ static void dag_id_flush_update(Scene *sce, ID *id) mtex = *mtexp; if(mtex && mtex->tex == (Tex*)id) { obt->recalc |= OB_RECALC_DATA; - + lib_id_recalc_data_tag(bmain, &obt->id); + if(mtex->mapto & PAMAP_INIT) psys->recalc |= PSYS_RECALC_RESET; if(mtex->mapto & PAMAP_CHILD) @@ -2455,6 +2491,8 @@ static void dag_id_flush_update(Scene *sce, ID *id) Key *key= ob_get_key(obt); if(!(ob && obt == ob) && ((ID *)key == id)) { obt->flag |= (OB_RECALC_OB|OB_RECALC_DATA); + lib_id_recalc_tag(bmain, &obt->id); + lib_id_recalc_data_tag(bmain, &obt->id); BKE_ptcache_object_reset(sce, obt, PTCACHE_RESET_DEPSGRAPH); } } @@ -2479,7 +2517,7 @@ void DAG_ids_flush_tagged(Main *bmain) ListBase *lbarray[MAX_LIBARRAY]; Scene *sce; unsigned int lay; - int a, have_tag = 0; + int a, do_flush = 0; dag_current_scene_layers(bmain, &sce, &lay); @@ -2497,23 +2535,64 @@ void DAG_ids_flush_tagged(Main *bmain) 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) { + if(id->flag & (LIB_ID_RECALC|LIB_ID_RECALC_DATA)) { dag_id_flush_update(sce, id); - id->flag &= ~LIB_ID_RECALC; + do_flush = 1; } } + } + } + + /* flush changes to other objects */ + if(do_flush) + DAG_scene_flush_update(bmain, sce, lay, 0); +} + +void DAG_ids_check_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; - have_tag = 1; + /* 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]]) { + /* do editors update */ + dag_editors_update(bmain, NULL); + return; } } +} - if(have_tag) { - /* clear tags */ - memset(bmain->id_tag_update, 0, sizeof(bmain->id_tag_update)); - /* flush changes to other objects */ - DAG_scene_flush_update(bmain, sce, lay, 0); +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); + } } + + memset(bmain->id_tag_update, 0, sizeof(bmain->id_tag_update)); } void DAG_id_tag_update(ID *id, short flag) @@ -2523,8 +2602,14 @@ void DAG_id_tag_update(ID *id, short flag) if(id==NULL) return; /* tag ID for update */ - id->flag |= LIB_ID_RECALC; - bmain->id_tag_update[id->name[0]] = 1; + if(flag) { + if(flag & OB_RECALC_OB) + lib_id_recalc_tag(bmain, id); + if(flag & (OB_RECALC_DATA|PSYS_RECALC)) + lib_id_recalc_data_tag(bmain, id); + } + else + lib_id_recalc_tag(bmain, id); /* flag is for objects and particle systems */ if(flag) { @@ -2556,6 +2641,16 @@ void DAG_id_tag_update(ID *id, short flag) } } +void DAG_id_type_tag(struct Main *bmain, short idtype) +{ + bmain->id_tag_update[((char*)&idtype)[0]] = 1; +} + +int DAG_id_type_tagged(Main *bmain, short idtype) +{ + return bmain->id_tag_update[((char*)&idtype)[0]]; +} + #if 0 // UNUSED /* recursively descends tree, each node only checked once */ /* node is checked to be of type object */ diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index 85e00bcea06..034f4a96879 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -703,14 +703,7 @@ static const char *world_adrcodes_to_paths (int adrcode, int *array_index) return "mist.start"; case WO_MISTHI: return "mist.height"; - - /* Star Color is unused -- recommend removal */ - /* case WO_STAR_R: - *array_index= 0; return "stars.color"; - case WO_STAR_G: - *array_index= 1; return "stars.color"; - case WO_STAR_B: - *array_index= 2; return "stars.color"; */ + case WO_STAR_R: case WO_STAR_G: case WO_STAR_B: diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 824e59a82c5..f35f034387b 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -43,10 +43,11 @@ #include <string.h> #include <limits.h> +#include "DNA_action_types.h" #include "DNA_anim_types.h" #include "DNA_node_types.h" +#include "DNA_node_types.h" #include "DNA_scene_types.h" -#include "DNA_action_types.h" #include "BLI_string.h" #include "BLI_math.h" @@ -1751,6 +1752,10 @@ void node_type_gpu_ext(struct bNodeType *ntype, int (*gpuextfunc)(struct GPUMate ntype->gpuextfunc = gpuextfunc; } +void node_type_compatibility(struct bNodeType *ntype, short compatibility) +{ + ntype->compatibility = compatibility; +} static bNodeType *is_nodetype_registered(ListBase *typelist, int type) { diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 29bb25915b9..bd004ce21f2 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -87,6 +87,7 @@ #include "BKE_tessmesh.h" #include "BKE_mball.h" #include "BKE_modifier.h" +#include "BKE_node.h" #include "BKE_object.h" #include "BKE_paint.h" #include "BKE_particle.h" @@ -878,6 +879,9 @@ Lamp *copy_lamp(Lamp *la) } lan->curfalloff = curvemapping_copy(la->curfalloff); + + if(la->nodetree) + lan->nodetree= ntreeCopyTree(la->nodetree); if(la->preview) lan->preview = BKE_previewimg_copy(la->preview); @@ -904,6 +908,9 @@ Lamp *localize_lamp(Lamp *la) lan->curfalloff = curvemapping_copy(la->curfalloff); + if(la->nodetree) + lan->nodetree= ntreeLocalize(la->nodetree); + lan->preview= NULL; return lan; @@ -979,6 +986,12 @@ void free_lamp(Lamp *la) BKE_free_animdata((ID *)la); curvemapping_free(la->curfalloff); + + /* is no lib link block, but lamp extension */ + if(la->nodetree) { + ntreeFreeTree(la->nodetree); + MEM_freeN(la->nodetree); + } BKE_previewimg_free(&la->preview); BKE_icon_delete(&la->id); diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 6b3786663df..b25120c0fff 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" @@ -990,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 @@ -1009,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) { @@ -1037,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 @@ -1050,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); } @@ -1127,3 +1143,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); +} + diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c index 5797c6c3f15..c7d2763774d 100644 --- a/source/blender/blenkernel/intern/world.c +++ b/source/blender/blenkernel/intern/world.c @@ -42,12 +42,14 @@ #include "BLI_utildefines.h" #include "BLI_bpath.h" -#include "BKE_world.h" -#include "BKE_library.h" #include "BKE_animsys.h" #include "BKE_global.h" -#include "BKE_main.h" #include "BKE_icons.h" +#include "BKE_library.h" +#include "BKE_library.h" +#include "BKE_main.h" +#include "BKE_node.h" +#include "BKE_world.h" void free_world(World *wrld) { @@ -63,6 +65,12 @@ void free_world(World *wrld) BKE_free_animdata((ID *)wrld); + /* is no lib link block, but world extension */ + if(wrld->nodetree) { + ntreeFreeTree(wrld->nodetree); + MEM_freeN(wrld->nodetree); + } + BKE_icon_delete((struct ID*)wrld); wrld->id.icon_id = 0; } @@ -119,6 +127,9 @@ World *copy_world(World *wrld) id_us_plus((ID *)wrldn->mtex[a]->tex); } } + + if(wrld->nodetree) + wrldn->nodetree= ntreeCopyTree(wrld->nodetree); if(wrld->preview) wrldn->preview = BKE_previewimg_copy(wrld->preview); @@ -143,6 +154,9 @@ World *localize_world(World *wrld) } } + if(wrld->nodetree) + wrldn->nodetree= ntreeLocalize(wrld->nodetree); + wrldn->preview= NULL; return wrldn; diff --git a/source/blender/blenlib/BLI_callbacks.h b/source/blender/blenlib/BLI_callbacks.h index 5322ce04a2e..7e4fad54cda 100644 --- a/source/blender/blenlib/BLI_callbacks.h +++ b/source/blender/blenlib/BLI_callbacks.h @@ -47,6 +47,8 @@ typedef enum { BLI_CB_EVT_LOAD_POST, BLI_CB_EVT_SAVE_PRE, BLI_CB_EVT_SAVE_POST, + BLI_CB_EVT_SCENE_UPDATE_PRE, + BLI_CB_EVT_SCENE_UPDATE_POST, BLI_CB_EVT_TOT } eCbEvent; diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt index 2f6b6f7cb26..da7801e350a 100644 --- a/source/blender/blenlib/CMakeLists.txt +++ b/source/blender/blenlib/CMakeLists.txt @@ -154,4 +154,8 @@ if(WITH_OPENMP) add_definitions(-DPARALLEL=1) endif() +if(WITH_XDG_USER_DIRS) + add_definitions(-DWITH_XDG_USER_DIRS) +endif() + blender_add_lib(bf_blenlib "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index ab3de94d77c..e7031c943c1 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -53,7 +53,7 @@ #include "GHOST_Path-api.h" #if defined WIN32 && !defined _LIBC -# include "BLI_fnmatch.h" /* use fnmatch included in blenlib */ +# include "BLI_fnmatch.h" /* use fnmatch included in blenlib */ #else # ifndef _GNU_SOURCE # define _GNU_SOURCE @@ -62,35 +62,34 @@ #endif #ifdef WIN32 -#include <io.h> - -#ifdef _WIN32_IE -#undef _WIN32_IE -#endif -#define _WIN32_IE 0x0501 -#include <windows.h> -#include <shlobj.h> - -#include "BLI_winstuff.h" - +# include <io.h> +# ifdef _WIN32_IE +# undef _WIN32_IE +# endif +# define _WIN32_IE 0x0501 +# include <windows.h> +# include <shlobj.h> +# include "BLI_winstuff.h" #else /* non windows */ - -#ifdef WITH_BINRELOC -#include "binreloc.h" -#endif - +# ifdef WITH_BINRELOC +# include "binreloc.h" +# endif #endif /* WIN32 */ /* standard paths */ #ifdef WIN32 -#define BLENDER_USER_FORMAT "%s\\Blender Foundation\\Blender\\%s" -#define BLENDER_SYSTEM_FORMAT "%s\\Blender Foundation\\Blender\\%s" +# define BLENDER_USER_FORMAT "%s\\Blender Foundation\\Blender\\%s" +# define BLENDER_SYSTEM_FORMAT "%s\\Blender Foundation\\Blender\\%s" #elif defined(__APPLE__) -#define BLENDER_USER_FORMAT "%s/Blender/%s" -#define BLENDER_SYSTEM_FORMAT "%s/Blender/%s" -#else -#define BLENDER_USER_FORMAT "%s/.blender/%s" -#define BLENDER_SYSTEM_FORMAT "%s/blender/%s" +# define BLENDER_USER_FORMAT "%s/Blender/%s" +# define BLENDER_SYSTEM_FORMAT "%s/Blender/%s" +#else /* UNIX */ +# ifndef WITH_XDG_USER_DIRS /* oldschool unix ~/.blender/ */ +# define BLENDER_USER_FORMAT "%s/.blender/%s" +# else /* new XDG ~/blender/.config/ */ +# define BLENDER_USER_FORMAT "%s/blender/%s" +# endif // WITH_XDG_USER_DIRS +# define BLENDER_SYSTEM_FORMAT "%s/blender/%s" #endif /* local */ @@ -798,10 +797,18 @@ void BLI_getlastdir(const char* dir, char *last, const size_t maxlen) as default location to save documents */ const char *BLI_getDefaultDocumentFolder(void) { - #if !defined(WIN32) +#ifndef WIN32 + +#ifdef WITH_XDG_USER_DIRS + const char *xdg_documents_dir= getenv("XDG_DOCUMENTS_DIR"); + if (xdg_documents_dir) { + return xdg_documents_dir; + } +#endif + return getenv("HOME"); - #else /* Windows */ +#else /* Windows */ const char * ret; static char documentfolder[MAXPATHLEN]; HRESULT hResult; @@ -826,7 +833,7 @@ const char *BLI_getDefaultDocumentFolder(void) } return NULL; - #endif +#endif /* WIN32 */ } /* NEW stuff, to be cleaned up when fully migrated */ diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index c1b92094433..fe89f6882d4 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -142,6 +142,8 @@ #include "BLO_readfile.h" #include "BLO_undofile.h" +#include "RE_engine.h" + #include "readfile.h" #include "PIL_time.h" @@ -2182,6 +2184,7 @@ static void lib_verify_nodetree(Main *main, int UNUSED(open)) for(ntree= main->nodetree.first; ntree; ntree= ntree->id.next) if (ntree->update) ntreeUpdateTree(ntree); + for (i=0; i < NUM_NTREE_TYPES; ++i) { ntreetype= ntreeGetType(i); if (ntreetype && ntreetype->foreach_nodetree) @@ -2507,6 +2510,9 @@ static void lib_link_lamp(FileData *fd, Main *main) } la->ipo= newlibadr_us(fd, la->id.lib, la->ipo); // XXX depreceated - old animation system + + if(la->nodetree) + lib_link_ntree(fd, &la->id, la->nodetree); la->id.flag -= LIB_NEEDLINK; } @@ -2528,6 +2534,10 @@ static void direct_link_lamp(FileData *fd, Lamp *la) la->curfalloff= newdataadr(fd, la->curfalloff); if(la->curfalloff) direct_link_curvemapping(fd, la->curfalloff); + + la->nodetree= newdataadr(fd, la->nodetree); + if(la->nodetree) + direct_link_nodetree(fd, la->nodetree); la->preview = direct_link_preview_image(fd, la->preview); } @@ -2680,6 +2690,9 @@ static void lib_link_world(FileData *fd, Main *main) mtex->object= newlibadr(fd, wrld->id.lib, mtex->object); } } + + if(wrld->nodetree) + lib_link_ntree(fd, &wrld->id, wrld->nodetree); wrld->id.flag -= LIB_NEEDLINK; } @@ -2697,6 +2710,11 @@ static void direct_link_world(FileData *fd, World *wrld) for(a=0; a<MAX_MTEX; a++) { wrld->mtex[a]= newdataadr(fd, wrld->mtex[a]); } + + wrld->nodetree= newdataadr(fd, wrld->nodetree); + if(wrld->nodetree) + direct_link_nodetree(fd, wrld->nodetree); + wrld->preview = direct_link_preview_image(fd, wrld->preview); } @@ -5068,6 +5086,10 @@ static void lib_link_screen(FileData *fd, Main *main) if(snode->id) { if(GS(snode->id->name)==ID_MA) snode->nodetree= ((Material *)snode->id)->nodetree; + else if(GS(snode->id->name)==ID_WO) + snode->nodetree= ((World *)snode->id)->nodetree; + else if(GS(snode->id->name)==ID_LA) + snode->nodetree= ((Lamp *)snode->id)->nodetree; else if(GS(snode->id->name)==ID_SCE) snode->nodetree= ((Scene *)snode->id)->nodetree; else if(GS(snode->id->name)==ID_TE) @@ -5155,6 +5177,7 @@ void lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *curscene) if(sl->spacetype==SPACE_VIEW3D) { View3D *v3d= (View3D*) sl; BGpic *bgpic; + ARegion *ar; if(v3d->scenelock) v3d->camera= NULL; /* always get from scene */ @@ -5190,6 +5213,15 @@ void lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *curscene) /* not very nice, but could help */ if((v3d->layact & v3d->lay)==0) v3d->layact= v3d->lay; + /* free render engines for now */ + for(ar= sa->regionbase.first; ar; ar= ar->next) { + RegionView3D *rv3d= ar->regiondata; + + if(rv3d && rv3d->render_engine) { + RE_engine_free(rv3d->render_engine); + rv3d->render_engine= NULL; + } + } } else if(sl->spacetype==SPACE_IPO) { SpaceIpo *sipo= (SpaceIpo *)sl; @@ -5328,6 +5360,7 @@ static void direct_link_region(FileData *fd, ARegion *ar, int spacetype) rv3d->depths= NULL; rv3d->ri= NULL; + rv3d->render_engine= NULL; rv3d->sms= NULL; rv3d->smooth_timer= NULL; } @@ -5469,6 +5502,10 @@ static void direct_link_screen(FileData *fd, bScreen *sc) v3d->afterdraw_xray.first= v3d->afterdraw_xray.last= NULL; v3d->afterdraw_xraytransp.first= v3d->afterdraw_xraytransp.last= NULL; v3d->properties_storage= NULL; + + /* render can be quite heavy, set to wire on load */ + if(v3d->drawtype == OB_RENDER) + v3d->drawtype = OB_WIRE; view3d_split_250(v3d, &sl->regionbase); } @@ -10762,7 +10799,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) Object *ob=main->object.first; while (ob) { /* shaded mode disabled for now */ - if (ob->dt == OB_SHADED) ob->dt = OB_TEXTURE; + if (ob->dt == OB_MATERIAL) ob->dt = OB_TEXTURE; ob=ob->id.next; } } @@ -10777,7 +10814,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) for(sl= sa->spacedata.first; sl; sl= sl->next) { if(sl->spacetype==SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; - if (v3d->drawtype == OB_SHADED) v3d->drawtype = OB_SOLID; + if (v3d->drawtype == OB_MATERIAL) v3d->drawtype = OB_SOLID; } } } @@ -12772,6 +12809,9 @@ static void expand_lamp(FileData *fd, Main *mainvar, Lamp *la) if (la->adt) expand_animdata(fd, mainvar, la->adt); + + if(la->nodetree) + expand_nodetree(fd, mainvar, la->nodetree); } static void expand_lattice(FileData *fd, Main *mainvar, Lattice *lt) @@ -12799,6 +12839,9 @@ static void expand_world(FileData *fd, Main *mainvar, World *wrld) if (wrld->adt) expand_animdata(fd, mainvar, wrld->adt); + + if(wrld->nodetree) + expand_nodetree(fd, mainvar, wrld->nodetree); } diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index dad246516a9..270885f9df1 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -1860,6 +1860,12 @@ static void write_worlds(WriteData *wd, ListBase *idbase) for(a=0; a<MAX_MTEX; a++) { if(wrld->mtex[a]) writestruct(wd, DATA, "MTex", 1, wrld->mtex[a]); } + + /* nodetree is integral part of lamps, no libdata */ + if(wrld->nodetree) { + writestruct(wd, DATA, "bNodeTree", 1, wrld->nodetree); + write_nodetree(wd, wrld->nodetree); + } write_previews(wd, wrld->preview); } @@ -1889,6 +1895,12 @@ static void write_lamps(WriteData *wd, ListBase *idbase) if(la->curfalloff) write_curvemapping(wd, la->curfalloff); + /* nodetree is integral part of lamps, no libdata */ + if(la->nodetree) { + writestruct(wd, DATA, "bNodeTree", 1, la->nodetree); + write_nodetree(wd, la->nodetree); + } + write_previews(wd, la->preview); } diff --git a/source/blender/editors/include/ED_node.h b/source/blender/editors/include/ED_node.h index b6cb59e2f4a..18bb4975da9 100644 --- a/source/blender/editors/include/ED_node.h +++ b/source/blender/editors/include/ED_node.h @@ -51,7 +51,7 @@ void ED_node_changed_update(struct ID *id, struct bNode *node); void ED_node_generic_update(struct Main *bmain, struct bNodeTree *ntree, struct bNode *node); /* node_edit.c */ -void ED_node_shader_default(struct Material *ma); +void ED_node_shader_default(struct Scene *scene, struct ID *id); void ED_node_composit_default(struct Scene *sce); void ED_node_texture_default(struct Tex *tex); void ED_node_link_intersect_test(struct ScrArea *sa, int test); diff --git a/source/blender/editors/include/ED_render.h b/source/blender/editors/include/ED_render.h index 651c298ad5e..8c0fa3a89a3 100644 --- a/source/blender/editors/include/ED_render.h +++ b/source/blender/editors/include/ED_render.h @@ -44,6 +44,8 @@ void ED_operatortypes_render(void); /* render_shading.c */ 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 bContext *C, struct Main *bmain); /* render_preview.c */ diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index c5fecfe23ab..3067059c448 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -867,6 +867,7 @@ void OBJECT_OT_group_instance_add(wmOperatorType *ot) /* note: now unlinks constraints as well */ void ED_base_object_free_and_unlink(Main *bmain, Scene *scene, Base *base) { + DAG_id_type_tag(bmain, ID_OB); BLI_remlink(&scene->base, base); free_libblock_us(&bmain->object, base->object); if(scene->basact==base) scene->basact= NULL; diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 838a4386248..fa2076457a0 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -146,6 +146,7 @@ static int object_hide_view_clear_exec(bContext *C, wmOperator *UNUSED(op)) } } if (changed) { + DAG_id_type_tag(bmain, ID_OB); DAG_scene_sort(bmain, scene); WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); } @@ -198,6 +199,7 @@ static int object_hide_view_set_exec(bContext *C, wmOperator *op) CTX_DATA_END; if (changed) { + DAG_id_type_tag(bmain, ID_OB); DAG_scene_sort(bmain, scene); WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, CTX_data_scene(C)); diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index 49bdb103139..9da160948cc 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -420,6 +420,12 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre base->object->data= la; } } + + if(la && la->nodetree && sp->pr_method==PR_NODE_RENDER) { + /* two previews, they get copied by wmJob */ + ntreeInitPreview(origla->nodetree, sp->sizex, sp->sizey); + ntreeInitPreview(la->nodetree, sp->sizex, sp->sizey); + } } else if(id_type==ID_WO) { World *wrld= NULL, *origwrld= (World *)id; @@ -432,6 +438,12 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre sce->lay= 1<<MA_SKY; sce->world= wrld; + + if(wrld && wrld->nodetree && sp->pr_method==PR_NODE_RENDER) { + /* two previews, they get copied by wmJob */ + ntreeInitPreview(wrld->nodetree, sp->sizex, sp->sizey); + ntreeInitPreview(origwrld->nodetree, sp->sizex, sp->sizey); + } } return sce; @@ -566,6 +578,18 @@ static void shader_preview_updatejob(void *spv) if(sp->texcopy && tex->nodetree && sp->texcopy->nodetree) ntreeLocalSync(sp->texcopy->nodetree, tex->nodetree); } + else if( GS(sp->id->name) == ID_WO) { + World *wrld= (World *)sp->id; + + if(sp->worldcopy && wrld->nodetree && sp->worldcopy->nodetree) + ntreeLocalSync(sp->worldcopy->nodetree, wrld->nodetree); + } + else if( GS(sp->id->name) == ID_LA) { + Lamp *la= (Lamp *)sp->id; + + if(sp->lampcopy && la->nodetree && sp->lampcopy->nodetree) + ntreeLocalSync(sp->lampcopy->nodetree, la->nodetree); + } } } } diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c index 248cae2413a..73264ddf20e 100644 --- a/source/blender/editors/render/render_shading.c +++ b/source/blender/editors/render/render_shading.c @@ -26,7 +26,6 @@ * \ingroup edrend */ - #include <stdlib.h> #include <string.h> @@ -77,6 +76,7 @@ #include "ED_curve.h" #include "ED_mesh.h" +#include "ED_node.h" #include "ED_render.h" #include "ED_screen.h" @@ -363,16 +363,24 @@ void OBJECT_OT_material_slot_copy(wmOperatorType *ot) static int new_material_exec(bContext *C, wmOperator *UNUSED(op)) { + Scene *scene= CTX_data_scene(C); Material *ma= CTX_data_pointer_get_type(C, "material", &RNA_Material).data; PointerRNA ptr, idptr; PropertyRNA *prop; /* add or copy material */ - if(ma) + if(ma) { ma= copy_material(ma); - else + } + else { ma= add_material("Material"); + if(scene_use_new_shading_nodes(scene)) { + ED_node_shader_default(scene, &ma->id); + ma->use_nodes= 1; + } + } + /* hook into UI */ uiIDContextProperty(C, &ptr, &prop); @@ -455,16 +463,24 @@ void TEXTURE_OT_new(wmOperatorType *ot) static int new_world_exec(bContext *C, wmOperator *UNUSED(op)) { + Scene *scene= CTX_data_scene(C); World *wo= CTX_data_pointer_get_type(C, "world", &RNA_World).data; PointerRNA ptr, idptr; PropertyRNA *prop; /* add or copy world */ - if(wo) + if(wo) { wo= copy_world(wo); - else + } + else { wo= add_world("World"); + if(scene_use_new_shading_nodes(scene)) { + ED_node_shader_default(scene, &wo->id); + wo->use_nodes= 1; + } + } + /* hook into UI */ uiIDContextProperty(C, &ptr, &prop); diff --git a/source/blender/editors/render/render_update.c b/source/blender/editors/render/render_update.c index e80c3d85670..72ea79fae7e 100644 --- a/source/blender/editors/render/render_update.c +++ b/source/blender/editors/render/render_update.c @@ -56,11 +56,110 @@ #include "GPU_material.h" +#include "RE_engine.h" + #include "ED_node.h" #include "ED_render.h" #include "render_intern.h" // own include +/***************************** Render Engines ********************************/ + +void ED_render_engine_update_tagged(bContext *C, Main *bmain) +{ + /* viewport rendering update on data changes, happens after depsgraph + * updates if there was any change. context is set to the 3d view */ + bScreen *sc, *prev_sc= CTX_wm_screen(C); + ScrArea *sa, *prev_sa= CTX_wm_area(C); + ARegion *ar, *prev_ar= CTX_wm_region(C); + + for(sc=bmain->screen.first; sc; sc=sc->id.next) { + for(sa=sc->areabase.first; sa; sa=sa->next) { + if(sa->spacetype != SPACE_VIEW3D) + continue; + + for(ar=sa->regionbase.first; ar; ar=ar->next) { + RegionView3D *rv3d; + RenderEngine *engine; + + if(ar->regiontype != RGN_TYPE_WINDOW) + continue; + + rv3d= ar->regiondata; + engine= rv3d->render_engine; + + if(engine && (engine->flag & RE_ENGINE_DO_UPDATE)) { + CTX_wm_screen_set(C, sc); + CTX_wm_area_set(C, sa); + CTX_wm_region_set(C, ar); + + engine->flag &= ~RE_ENGINE_DO_UPDATE; + engine->type->view_update(engine, C); + } + } + } + } + + CTX_wm_screen_set(C, prev_sc); + CTX_wm_area_set(C, prev_sa); + CTX_wm_region_set(C, prev_ar); +} + +void ED_render_engine_changed(Main *bmain) +{ + /* on changing the render engine type, clear all running render engines */ + bScreen *sc; + ScrArea *sa; + ARegion *ar; + + for(sc=bmain->screen.first; sc; sc=sc->id.next) { + for(sa=sc->areabase.first; sa; sa=sa->next) { + if(sa->spacetype != SPACE_VIEW3D) + continue; + + for(ar=sa->regionbase.first; ar; ar=ar->next) { + RegionView3D *rv3d; + + if(ar->regiontype != RGN_TYPE_WINDOW) + continue; + + rv3d= ar->regiondata; + + if(rv3d->render_engine) { + RE_engine_free(rv3d->render_engine); + rv3d->render_engine= NULL; + } + } + } + } +} + +static void tag_render_engines(Main *bmain) +{ + /* tag running render engines for update later on */ + bScreen *sc; + ScrArea *sa; + ARegion *ar; + + for(sc=bmain->screen.first; sc; sc=sc->id.next) { + for(sa=sc->areabase.first; sa; sa=sa->next) { + if(sa->spacetype != SPACE_VIEW3D) + continue; + + for(ar=sa->regionbase.first; ar; ar=ar->next) { + RegionView3D *rv3d; + + if(ar->regiontype != RGN_TYPE_WINDOW) + continue; + + rv3d= ar->regiondata; + if(rv3d->render_engine) + rv3d->render_engine->flag |= RE_ENGINE_DO_UPDATE; + } + } + } +} + /***************************** 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 * @@ -135,6 +234,7 @@ static void texture_changed(Main *bmain, Tex *tex) /* 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)); @@ -143,6 +243,7 @@ static void texture_changed(Main *bmain, Tex *tex) /* 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)); @@ -220,8 +321,10 @@ static void scene_changed(Main *bmain, Scene *UNUSED(scene)) void ED_render_id_flush_update(Main *bmain, ID *id) { - if(!id) + if(!id) { + tag_render_engines(bmain); return; + } switch(GS(id->name)) { case ID_MA: diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 9b3d12b159d..c682e42c35b 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -210,7 +210,8 @@ typedef struct StrokeCache { int first_time; /* Beginning of stroke may do some things special */ - bglMats *mats; + /* from ED_view3d_ob_project_mat_get() */ + float projection_mat[4][4]; /* Clean this up! */ ViewContext *vc; @@ -424,7 +425,8 @@ static int sculpt_brush_test_cube(SculptBrushTest *test, float co[3], float loca } } -static float frontface(Brush *brush, float sculpt_normal[3], short no[3], float fno[3]) +static float frontface(Brush *brush, const float sculpt_normal[3], + const short no[3], const float fno[3]) { if (brush->flag & BRUSH_FRONTFACE) { float dot; @@ -674,7 +676,11 @@ static float brush_strength(Sculpt *sd, StrokeCache *cache, float feather) } /* Return a multiplier for brush strength on a particular vertex. */ -static float tex_strength(SculptSession *ss, Brush *br, float *point, const float len) +static float tex_strength(SculptSession *ss, Brush *br, float point[3], + const float len, + const float sculpt_normal[3], + const short vno[3], + const float fno[3]) { MTex *mtex = &br->mtex; float avg= 1; @@ -692,7 +698,8 @@ static float tex_strength(SculptSession *ss, Brush *br, float *point, const floa } else if(ss->texcache) { float rotation = -mtex->rot; - float x, y, point_2d[3]; + float symm_point[3], point_2d[2]; + float x, y; float radius; /* if the active area is being applied for symmetry, flip it @@ -700,12 +707,13 @@ static float tex_strength(SculptSession *ss, Brush *br, float *point, const floa position in order to project it. This insures that the brush texture will be oriented correctly. */ - flip_coord(point_2d, point, ss->cache->mirror_symmetry_pass); + flip_coord(symm_point, point, ss->cache->mirror_symmetry_pass); if (ss->cache->radial_symmetry_pass) - mul_m4_v3(ss->cache->symm_rot_mat_inv, point_2d); + mul_m4_v3(ss->cache->symm_rot_mat_inv, symm_point); - projectf(ss->cache->mats, point_2d, point_2d); + ED_view3d_project_float(ss->cache->vc->ar, symm_point, point_2d, + ss->cache->projection_mat); /* if fixed mode, keep coordinates relative to mouse */ if(mtex->brush_map_mode == MTEX_MAP_MODE_FIXED) { @@ -761,7 +769,10 @@ static float tex_strength(SculptSession *ss, Brush *br, float *point, const floa avg += br->texture_sample_bias; - avg *= brush_curve_strength(br, len, ss->cache->radius); /* Falloff curve */ + /* Falloff curve */ + avg *= brush_curve_strength(br, len, ss->cache->radius); + + avg *= frontface(br, sculpt_normal, vno, fno); return avg; } @@ -999,7 +1010,8 @@ static void do_mesh_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *node, BLI_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_UNIQUE) { if(sculpt_brush_test(&test, vd.co)) { - const float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist)*frontface(brush, ss->cache->view_normal, vd.no, vd.fno); + const float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist, + ss->cache->view_normal, vd.no, vd.fno); float avg[3], val[3]; neighbor_average(ss, avg, vd.vert_indices[vd.i]); @@ -1092,7 +1104,8 @@ static void do_multires_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *no fno= data[index].no; if(sculpt_brush_test(&test, co)) { - const float fade = bstrength*tex_strength(ss, brush, co, test.dist)*frontface(brush, ss->cache->view_normal, NULL, fno); + const float fade = bstrength*tex_strength(ss, brush, co, test.dist, + ss->cache->view_normal, NULL, fno); float *avg, val[3]; float n; @@ -1188,9 +1201,9 @@ static void do_draw_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { if (sculpt_brush_test(&test, vd.co)) { - //if(sculpt_brush_test_cyl(&test, vd.co, ss->cache->location, area_normal)) { /* offset vertex */ - float fade = tex_strength(ss, brush, vd.co, test.dist)*frontface(brush, area_normal, vd.no, vd.fno); + float fade = tex_strength(ss, brush, vd.co, test.dist, + area_normal, vd.no, vd.fno); mul_v3_v3fl(proxy[vd.i], offset, fade); @@ -1244,7 +1257,8 @@ static void do_crease_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { if(sculpt_brush_test(&test, vd.co)) { /* offset vertex */ - const float fade = tex_strength(ss, brush, vd.co, test.dist)*frontface(brush, area_normal, vd.no, vd.fno); + const float fade = tex_strength(ss, brush, vd.co, test.dist, + area_normal, vd.no, vd.fno); float val1[3]; float val2[3]; @@ -1285,7 +1299,8 @@ static void do_pinch_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { if(sculpt_brush_test(&test, vd.co)) { - float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist)*frontface(brush, ss->cache->view_normal, vd.no, vd.fno); + float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist, + ss->cache->view_normal, vd.no, vd.fno); float val[3]; sub_v3_v3v3(val, test.location, vd.co); @@ -1345,7 +1360,8 @@ static void do_grab_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { if(sculpt_brush_test(&test, origco[vd.i])) { - const float fade = bstrength*tex_strength(ss, brush, origco[vd.i], test.dist)*frontface(brush, an, origno[vd.i], NULL); + const float fade = bstrength*tex_strength(ss, brush, origco[vd.i], test.dist, + an, origno[vd.i], NULL); mul_v3_v3fl(proxy[vd.i], grab_delta, fade); @@ -1386,7 +1402,8 @@ static void do_nudge_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { if(sculpt_brush_test(&test, vd.co)) { - const float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist)*frontface(brush, an, vd.no, vd.fno); + const float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist, + an, vd.no, vd.fno); mul_v3_v3fl(proxy[vd.i], cono, fade); @@ -1435,7 +1452,8 @@ static void do_snake_hook_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int to BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { if(sculpt_brush_test(&test, vd.co)) { - const float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist)*frontface(brush, an, vd.no, vd.fno); + const float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist, + an, vd.no, vd.fno); mul_v3_v3fl(proxy[vd.i], grab_delta, fade); @@ -1483,7 +1501,8 @@ static void do_thumb_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { if(sculpt_brush_test(&test, origco[vd.i])) { - const float fade = bstrength*tex_strength(ss, brush, origco[vd.i], test.dist)*frontface(brush, an, origno[vd.i], NULL); + const float fade = bstrength*tex_strength(ss, brush, origco[vd.i], test.dist, + an, origno[vd.i], NULL); mul_v3_v3fl(proxy[vd.i], cono, fade); @@ -1529,7 +1548,8 @@ static void do_rotate_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { if(sculpt_brush_test(&test, origco[vd.i])) { - const float fade = bstrength*tex_strength(ss, brush, origco[vd.i], test.dist)*frontface(brush, an, origno[vd.i], NULL); + const float fade = bstrength*tex_strength(ss, brush, origco[vd.i], test.dist, + an, origno[vd.i], NULL); mul_v3_m3v3(proxy[vd.i], m, origco[vd.i]); sub_v3_v3(proxy[vd.i], origco[vd.i]); @@ -1583,7 +1603,8 @@ static void do_layer_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { if(sculpt_brush_test(&test, origco[vd.i])) { - const float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist)*frontface(brush, area_normal, vd.no, vd.fno); + const float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist, + area_normal, vd.no, vd.fno); float *disp= &layer_disp[vd.i]; float val[3]; @@ -1634,7 +1655,8 @@ static void do_inflate_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totno BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { if(sculpt_brush_test(&test, vd.co)) { - const float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist)*frontface(brush, ss->cache->view_normal, vd.no, vd.fno); + const float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist, + ss->cache->view_normal, vd.no, vd.fno); float val[3]; if(vd.fno) copy_v3_v3(val, vd.fno); @@ -1966,7 +1988,8 @@ static void do_flatten_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totno sub_v3_v3v3(val, intr, vd.co); if (plane_trim(ss->cache, brush, val)) { - const float fade = bstrength*tex_strength(ss, brush, vd.co, sqrt(test.dist))*frontface(brush, an, vd.no, vd.fno); + const float fade = bstrength*tex_strength(ss, brush, vd.co, sqrt(test.dist), + an, vd.no, vd.fno); mul_v3_v3fl(proxy[vd.i], val, fade); @@ -2039,7 +2062,9 @@ static void do_clay_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) sub_v3_v3v3(val, intr, vd.co); if (plane_trim(ss->cache, brush, val)) { - const float fade = bstrength*tex_strength(ss, brush, vd.co, sqrt(test.dist))*frontface(brush, an, vd.no, vd.fno); + const float fade = bstrength*tex_strength(ss, brush, vd.co, + sqrt(test.dist), + an, vd.no, vd.fno); mul_v3_v3fl(proxy[vd.i], val, fade); @@ -2130,7 +2155,9 @@ static void do_clay_tubes_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int to sub_v3_v3v3(val, intr, vd.co); if (plane_trim(ss->cache, brush, val)) { - const float fade = bstrength*tex_strength(ss, brush, vd.co, ss->cache->radius*test.dist)*frontface(brush, an, vd.no, vd.fno); + const float fade = bstrength*tex_strength(ss, brush, vd.co, + ss->cache->radius*test.dist, + an, vd.no, vd.fno); mul_v3_v3fl(proxy[vd.i], val, fade); @@ -2191,7 +2218,9 @@ static void do_fill_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) sub_v3_v3v3(val, intr, vd.co); if (plane_trim(ss->cache, brush, val)) { - const float fade = bstrength*tex_strength(ss, brush, vd.co, sqrt(test.dist))*frontface(brush, an, vd.no, vd.fno); + const float fade = bstrength*tex_strength(ss, brush, vd.co, + sqrt(test.dist), + an, vd.no, vd.fno); mul_v3_v3fl(proxy[vd.i], val, fade); @@ -2251,7 +2280,9 @@ static void do_scrape_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod sub_v3_v3v3(val, intr, vd.co); if (plane_trim(ss->cache, brush, val)) { - const float fade = bstrength*tex_strength(ss, brush, vd.co, sqrt(test.dist))*frontface(brush, an, vd.no, vd.fno); + const float fade = bstrength*tex_strength(ss, brush, vd.co, + sqrt(test.dist), + an, vd.no, vd.fno); mul_v3_v3fl(proxy[vd.i], val, fade); @@ -2800,8 +2831,6 @@ static void sculpt_cache_free(StrokeCache *cache) { if(cache->face_norms) MEM_freeN(cache->face_norms); - if(cache->mats) - MEM_freeN(cache->mats); MEM_freeN(cache); } @@ -2905,8 +2934,8 @@ static void sculpt_update_cache_invariants(bContext* C, Sculpt *sd, SculptSessio cache->brush = brush; - cache->mats = MEM_callocN(sizeof(bglMats), "sculpt bglMats"); - view3d_get_transformation(vc->ar, vc->rv3d, vc->obact, cache->mats); + /* cache projection matrix */ + ED_view3d_ob_project_mat_get(cache->vc->rv3d, ob, cache->projection_mat); ED_view3d_global_to_vector(cache->vc->rv3d, cache->vc->rv3d->twmat[3], cache->true_view_normal); /* Initialize layer brush displacements and persistent coords */ diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index fd7a6ee21fd..c2a2f319c28 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -36,11 +36,13 @@ #include "MEM_guardedalloc.h" #include "DNA_node_types.h" +#include "DNA_lamp_types.h" #include "DNA_material_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_space_types.h" #include "DNA_screen_types.h" +#include "DNA_world_types.h" #include "BLI_math.h" #include "BLI_blenlib.h" @@ -97,7 +99,13 @@ void ED_node_changed_update(ID *id, bNode *node) if(treetype==NTREE_SHADER) { DAG_id_tag_update(id, 0); - WM_main_add_notifier(NC_MATERIAL|ND_SHADING_DRAW, id); + + if(GS(id->name) == ID_MA) + WM_main_add_notifier(NC_MATERIAL|ND_SHADING_DRAW, id); + else if(GS(id->name) == ID_LA) + WM_main_add_notifier(NC_LAMP|ND_LIGHTING_DRAW, id); + else if(GS(id->name) == ID_WO) + WM_main_add_notifier(NC_WORLD|ND_WORLD_DRAW, id); } else if(treetype==NTREE_COMPOSIT) { nodeUpdate(edittree, node); diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 4c98028644a..c1e50c112fa 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -39,11 +39,13 @@ #include "MEM_guardedalloc.h" #include "DNA_ID.h" -#include "DNA_object_types.h" +#include "DNA_lamp_types.h" #include "DNA_material_types.h" #include "DNA_node_types.h" +#include "DNA_object_types.h" #include "DNA_particle_types.h" #include "DNA_scene_types.h" +#include "DNA_world_types.h" #include "BLI_math.h" #include "BLI_blenlib.h" @@ -267,36 +269,61 @@ bNode *node_tree_get_editgroup(bNodeTree *nodetree) /* assumes nothing being done in ntree yet, sets the default in/out node */ /* called from shading buttons or header */ -void ED_node_shader_default(Material *ma) +void ED_node_shader_default(Scene *UNUSED(scene), ID *id) { bNode *in, *out; bNodeSocket *fromsock, *tosock; + bNodeTree *ntree; bNodeTemplate ntemp; + int output_type, shader_type; - /* but lets check it anyway */ - if(ma->nodetree) { - if (G.f & G_DEBUG) - printf("error in shader initialize\n"); - return; + ntree= ntreeAddTree("Shader Nodetree", NTREE_SHADER, 0); + + switch(GS(id->name)) { + case ID_MA: { + Material *ma= (Material*)id; + ma->nodetree = ntree; + + output_type = SH_NODE_OUTPUT; + shader_type = SH_NODE_MATERIAL; + break; + } + case ID_WO: { + World *wo= (World*)id; + wo->nodetree = ntree; + + output_type = SH_NODE_OUTPUT; + shader_type = SH_NODE_MATERIAL; + break; + } + case ID_LA: { + Lamp *la= (Lamp*)id; + la->nodetree = ntree; + + output_type = SH_NODE_OUTPUT; + shader_type = SH_NODE_MATERIAL; + break; + } + default: + printf("ED_node_shader_default called on wrong ID type.\n"); + return; } - ma->nodetree= ntreeAddTree("Shader Nodetree", NTREE_SHADER, 0); - - ntemp.type = SH_NODE_OUTPUT; - out= nodeAddNode(ma->nodetree, &ntemp); + ntemp.type = output_type; + out= nodeAddNode(ntree, &ntemp); out->locx= 300.0f; out->locy= 300.0f; - ntemp.type = SH_NODE_MATERIAL; - in= nodeAddNode(ma->nodetree, &ntemp); + ntemp.type = shader_type; + in= nodeAddNode(ntree, &ntemp); in->locx= 10.0f; in->locy= 300.0f; - nodeSetActive(ma->nodetree, in); + nodeSetActive(ntree, in); /* only a link from color to color */ fromsock= in->outputs.first; tosock= out->inputs.first; - nodeAddLink(ma->nodetree, in, fromsock, out, tosock); + nodeAddLink(ntree, in, fromsock, out, tosock); - ntreeUpdateTree(ma->nodetree); + ntreeUpdateTree(ntree); } /* assumes nothing being done in ntree yet, sets the default in/out node */ @@ -387,6 +414,14 @@ void node_tree_from_ID(ID *id, bNodeTree **ntree, bNodeTree **edittree, int *tre *ntree= ((Material*)id)->nodetree; if(treetype) *treetype= NTREE_SHADER; } + else if(idtype == ID_LA) { + *ntree= ((Lamp*)id)->nodetree; + if(treetype) *treetype= NTREE_SHADER; + } + else if(idtype == ID_WO) { + *ntree= ((World*)id)->nodetree; + if(treetype) *treetype= NTREE_SHADER; + } else if(idtype == ID_SCE) { *ntree= ((Scene*)id)->nodetree; if(treetype) *treetype= NTREE_COMPOSIT; @@ -428,11 +463,25 @@ void snode_set_context(SpaceNode *snode, Scene *scene) if(snode->treetype==NTREE_SHADER) { /* need active object, or we allow pinning... */ - if(ob) { - Material *ma= give_current_material(ob, ob->actcol); - if(ma) { - snode->from= &ob->id; - snode->id= &ma->id; + if(snode->shaderfrom == SNODE_SHADER_OBJECT) { + if(ob) { + if(ob->type == OB_LAMP) { + snode->from= &ob->id; + snode->id= ob->data; + } + else { + Material *ma= give_current_material(ob, ob->actcol); + if(ma) { + snode->from= &ob->id; + snode->id= &ma->id; + } + } + } + } + else { /* SNODE_SHADER_WORLD */ + if(scene->world) { + snode->from= NULL; + snode->id= &scene->world->id; } } } @@ -526,7 +575,7 @@ void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node) /* tree specific activate calls */ if(ntree->type==NTREE_SHADER) { /* when we select a material, active texture is cleared, for buttons */ - if(node->id && GS(node->id->name)==ID_MA) + if(node->id && ELEM3(GS(node->id->name), ID_MA, ID_LA, ID_WO)) nodeClearActiveID(ntree, ID_TE); if(node->type==SH_NODE_OUTPUT) { diff --git a/source/blender/editors/space_node/node_header.c b/source/blender/editors/space_node/node_header.c index 68f5dd6bf14..42b5dafa3e1 100644 --- a/source/blender/editors/space_node/node_header.c +++ b/source/blender/editors/space_node/node_header.c @@ -46,9 +46,10 @@ #include "BKE_context.h" #include "BKE_global.h" -#include "BKE_screen.h" -#include "BKE_node.h" #include "BKE_main.h" +#include "BKE_node.h" +#include "BKE_scene.h" +#include "BKE_screen.h" #include "RNA_access.h" @@ -168,10 +169,11 @@ static int node_tree_has_type(int treetype, int nodetype) static void node_add_menu(bContext *C, uiLayout *layout, void *arg_nodeclass) { Main *bmain= CTX_data_main(C); + Scene *scene= CTX_data_scene(C); SpaceNode *snode= CTX_wm_space_node(C); bNodeTree *ntree; int nodeclass= GET_INT_FROM_POINTER(arg_nodeclass); - int event; + int event, compatibility= 0; ntree = snode->nodetree; @@ -179,6 +181,13 @@ static void node_add_menu(bContext *C, uiLayout *layout, void *arg_nodeclass) uiItemS(layout); return; } + + if(ntree->type == NTREE_SHADER) { + if(scene_use_new_shading_nodes(scene)) + compatibility= NODE_NEW_SHADING; + else + compatibility= NODE_OLD_SHADING; + } if (nodeclass==NODE_CLASS_GROUP) { bNodeTree *ngroup; @@ -210,14 +219,16 @@ static void node_add_menu(bContext *C, uiLayout *layout, void *arg_nodeclass) uiLayoutSetFunc(layout, do_node_add_static, NULL); for (ntype=ntreeGetType(ntree->type)->node_types.first; ntype; ntype=ntype->next) { - if(ntype->nclass==nodeclass && ntype->name) - uiItemV(layout, ntype->name, 0, ntype->type); + if (ntype->nclass==nodeclass && ntype->name) + if (!compatibility || (ntype->compatibility & compatibility)) + uiItemV(layout, ntype->name, 0, ntype->type); } } } static void node_menu_add(const bContext *C, Menu *menu) { + Scene *scene= CTX_data_scene(C); SpaceNode *snode= CTX_wm_space_node(C); uiLayout *layout= menu->layout; @@ -227,11 +238,15 @@ static void node_menu_add(const bContext *C, Menu *menu) if(snode->treetype==NTREE_SHADER) { uiItemMenuF(layout, IFACE_("Input"), 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_INPUT)); uiItemMenuF(layout, IFACE_("Output"), 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OUTPUT)); + if(scene_use_new_shading_nodes(scene)) { + uiItemMenuF(layout, IFACE_("Shader"), 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_SHADER)); + uiItemMenuF(layout, IFACE_("Texture"), 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_TEXTURE)); + } uiItemMenuF(layout, IFACE_("Color"), 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OP_COLOR)); uiItemMenuF(layout, IFACE_("Vector"), 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OP_VECTOR)); uiItemMenuF(layout, IFACE_("Convertor"), 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_CONVERTOR)); uiItemMenuF(layout, IFACE_("Group"), 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_GROUP)); - uiItemMenuF(layout, IFACE_("Dynamic"), 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OP_DYNAMIC)); + //uiItemMenuF(layout, IFACE_("Dynamic"), 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OP_DYNAMIC)); uiItemMenuF(layout, IFACE_("Layout"), 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_LAYOUT)); } else if(snode->treetype==NTREE_COMPOSIT) { diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c index 35b8666f274..1a808e8ee5f 100644 --- a/source/blender/editors/space_node/space_node.c +++ b/source/blender/editors/space_node/space_node.c @@ -32,10 +32,12 @@ #include <string.h> #include <stdio.h> +#include "DNA_lamp_types.h" +#include "DNA_material_types.h" #include "DNA_node_types.h" #include "DNA_object_types.h" -#include "DNA_material_types.h" #include "DNA_scene_types.h" +#include "DNA_world_types.h" #include "MEM_guardedalloc.h" @@ -268,9 +270,21 @@ static void node_area_refresh(const struct bContext *C, struct ScrArea *sa) if(snode->nodetree) { if(snode->treetype==NTREE_SHADER) { - Material *ma= (Material *)snode->id; - if(ma->use_nodes) - ED_preview_shader_job(C, sa, snode->id, NULL, NULL, 100, 100, PR_NODE_RENDER); + if(GS(snode->id->name) == ID_MA) { + Material *ma= (Material *)snode->id; + if(ma->use_nodes) + ED_preview_shader_job(C, sa, snode->id, NULL, NULL, 100, 100, PR_NODE_RENDER); + } + else if(GS(snode->id->name) == ID_LA) { + Lamp *la= (Lamp *)snode->id; + if(la->use_nodes) + ED_preview_shader_job(C, sa, snode->id, NULL, NULL, 100, 100, PR_NODE_RENDER); + } + else if(GS(snode->id->name) == ID_WO) { + World *wo= (World *)snode->id; + if(wo->use_nodes) + ED_preview_shader_job(C, sa, snode->id, NULL, NULL, 100, 100, PR_NODE_RENDER); + } } else if(snode->treetype==NTREE_COMPOSIT) { Scene *scene= (Scene *)snode->id; @@ -426,6 +440,10 @@ static void node_region_listener(ARegion *ar, wmNotifier *wmn) case NC_NODE: ED_region_tag_redraw(ar); break; + case NC_OBJECT: + if(wmn->data==ND_OB_SHADING) + ED_region_tag_redraw(ar); + break; case NC_ID: if(wmn->action == NA_RENAME) ED_region_tag_redraw(ar); diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index a4dc1a8b012..cd8739559a1 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -107,7 +107,7 @@ /* this condition has been made more complex since editmode can draw textures */ #define CHECK_OB_DRAWTEXTURE(vd, dt) \ -((vd->drawtype==OB_TEXTURE && dt>OB_SOLID) || \ + ((vd->drawtype==OB_TEXTURE && dt>OB_SOLID) || \ (vd->drawtype==OB_SOLID && vd->flag2 & V3D_SOLID_TEX)) static void draw_bounding_volume(Scene *scene, Object *ob); @@ -2779,8 +2779,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D totface = dm->getNumTessFaces(dm); /* vertexpaint, faceselect wants this, but it doesnt work for shaded? */ - if(dt!=OB_SHADED) - glFrontFace((ob->transflag&OB_NEG_SCALE)?GL_CW:GL_CCW); + glFrontFace((ob->transflag&OB_NEG_SCALE)?GL_CW:GL_CCW); // Unwanted combination. if (is_paint_sel) draw_wire = 0; @@ -2897,7 +2896,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D dm->drawLooseEdges(dm); } } - else if(dt==OB_SHADED) { + else if(dt==OB_PAINT) { if(ob==OBACT) { if(ob && ob->mode & OB_MODE_WEIGHT_PAINT) { /* enforce default material settings */ @@ -6038,7 +6037,9 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) } /* maximum drawtype */ - dt= MIN2(v3d->drawtype, ob->dt); + dt= v3d->drawtype; + if(dt==OB_RENDER) dt= OB_SOLID; + dt= MIN2(dt, ob->dt); if(v3d->zbuf==0 && dt>OB_WIRE) dt= OB_WIRE; dtx= 0; @@ -6053,7 +6054,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) dt= OB_SOLID; } else { - dt= OB_SHADED; + dt= OB_PAINT; } glEnable(GL_DEPTH_TEST); diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 0a69abe88c6..04acc7e9b4d 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -56,6 +56,7 @@ #include "WM_api.h" #include "WM_types.h" +#include "RE_engine.h" #include "RNA_access.h" @@ -344,6 +345,9 @@ static SpaceLink *view3d_duplicate(SpaceLink *sl) v3do->lay= v3dn->localvd->lay; v3do->lay &= 0xFFFFFF; } + + if(v3dn->drawtype == OB_RENDER) + v3dn->drawtype = OB_SOLID; /* copy or clear inside new stuff */ @@ -550,6 +554,9 @@ static void view3d_main_area_free(ARegion *ar) if(rv3d->ri) { // XXX BIF_view3d_previewrender_free(rv3d); } + + if(rv3d->render_engine) + RE_engine_free(rv3d->render_engine); if(rv3d->depths) { if(rv3d->depths->depths) MEM_freeN(rv3d->depths->depths); @@ -574,6 +581,7 @@ static void *view3d_main_area_duplicate(void *poin) new->depths= NULL; new->ri= NULL; + new->render_engine= NULL; new->gpd= NULL; new->sms= NULL; new->smooth_timer= NULL; diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 6b5e7792e85..96031a7b3d3 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -62,6 +62,7 @@ #include "BKE_screen.h" #include "BKE_unit.h" +#include "RE_engine.h" #include "RE_pipeline.h" // make_stars #include "IMB_imbuf_types.h" @@ -2518,6 +2519,62 @@ static void draw_viewport_fps(Scene *scene, ARegion *ar) BLF_draw_default_ascii(22, ar->winy-17, 0.0f, printable, sizeof(printable)-1); } +static int view3d_main_area_draw_engine(const bContext *C, ARegion *ar) +{ + Scene *scene= CTX_data_scene(C); + View3D *v3d = CTX_wm_view3d(C); + RegionView3D *rv3d= CTX_wm_region_view3d(C); + RenderEngineType *type; + + if(!rv3d->render_engine) { + type= RE_engines_find(scene->r.engine); + + if(!(type->view_update && type->view_draw)) + return 0; + + rv3d->render_engine= RE_engine_create(type); + type->view_update(rv3d->render_engine, C); + } + + view3d_main_area_setup_view(scene, v3d, ar, NULL, NULL); + + glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); + + ED_region_pixelspace(ar); + + type= rv3d->render_engine->type; + type->view_draw(rv3d->render_engine, C); + + return 1; +} + +static void view3d_main_area_draw_engine_info(RegionView3D *rv3d, ARegion *ar) +{ + rcti rect; + const int header_height = 18; + + if(!rv3d->render_engine || !rv3d->render_engine->text) + return; + + /* background box */ + rect= ar->winrct; + rect.xmin= 0; + rect.ymin= ar->winrct.ymax - ar->winrct.ymin - header_height; + rect.xmax= ar->winrct.xmax - ar->winrct.xmin; + rect.ymax= ar->winrct.ymax - ar->winrct.ymin; + + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); + glColor4f(0.0f, 0.0f, 0.0f, 0.25f); + glRecti(rect.xmin, rect.ymin, rect.xmax+1, rect.ymax+1); + glDisable(GL_BLEND); + + /* text */ + UI_ThemeColor(TH_TEXT_HI); + UI_DrawString(12, rect.ymin + 5, rv3d->render_engine->text); +} + /* warning: this function has duplicate drawing in ED_view3d_draw_offscreen() */ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const char **grid_unit) { @@ -2728,6 +2785,11 @@ static void view3d_main_area_draw_info(const bContext *C, ARegion *ar, const cha else draw_view_icon(rv3d); + if(rv3d->render_engine) { + view3d_main_area_draw_engine_info(rv3d, ar); + return; + } + if((U.uiflag & USER_SHOW_FPS) && screen->animtimer) { draw_viewport_fps(scene, ar); } @@ -2755,9 +2817,12 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar) View3D *v3d = CTX_wm_view3d(C); const char *grid_unit= NULL; - view3d_main_area_draw_objects(C, ar, &grid_unit); - - ED_region_pixelspace(ar); + /* draw viewport using external renderer? */ + if(!(v3d->drawtype == OB_RENDER && view3d_main_area_draw_engine(C, ar))) { + /* draw viewport using opengl */ + view3d_main_area_draw_objects(C, ar, &grid_unit); + ED_region_pixelspace(ar); + } view3d_main_area_draw_info(C, ar, grid_unit); diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h index d2c7d49e5f9..6f2933d154b 100644 --- a/source/blender/makesdna/DNA_ID.h +++ b/source/blender/makesdna/DNA_ID.h @@ -235,6 +235,7 @@ typedef struct PreviewImage { #define LIB_PRE_EXISTING 2048 /* runtime */ #define LIB_ID_RECALC 4096 +#define LIB_ID_RECALC_DATA 8192 #ifdef __cplusplus } diff --git a/source/blender/makesdna/DNA_lamp_types.h b/source/blender/makesdna/DNA_lamp_types.h index e36573473f3..91930f5766e 100644 --- a/source/blender/makesdna/DNA_lamp_types.h +++ b/source/blender/makesdna/DNA_lamp_types.h @@ -37,10 +37,11 @@ #define MAX_MTEX 18 #endif -struct MTex; -struct CurveMapping; struct AnimData; +struct bNodeTree; +struct CurveMapping; struct Ipo; +struct MTex; typedef struct Lamp { ID id; @@ -98,11 +99,14 @@ typedef struct Lamp { struct Ipo *ipo; // XXX depreceated... old animation system struct MTex *mtex[18]; /* MAX_MTEX */ - short pr_texture; - char pad6[6]; + short pr_texture, use_nodes; + char pad6[4]; /* preview */ struct PreviewImage *preview; + + /* nodes */ + struct bNodeTree *nodetree; } Lamp; /* **************** LAMP ********************* */ diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h index fb0fd3fa174..3bc7eb85ac4 100644 --- a/source/blender/makesdna/DNA_object_types.h +++ b/source/blender/makesdna/DNA_object_types.h @@ -385,8 +385,11 @@ typedef struct DupliObject { #define OB_BOUNDBOX 1 #define OB_WIRE 2 #define OB_SOLID 3 -#define OB_SHADED 4 +#define OB_MATERIAL 4 #define OB_TEXTURE 5 +#define OB_RENDER 6 + +#define OB_PAINT 100 /* temporary used in draw code */ /* dtx: flags, char! */ #define OB_AXIS 2 diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index 37c2ea56e76..0c7943ce056 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -400,7 +400,9 @@ typedef struct SpaceNode { struct bNodeTree *nodetree, *edittree; int treetype; /* treetype: as same nodetree->type */ short texfrom; /* texfrom object, world or brush */ + short shaderfrom; /* shader from object or world */ short recalc; /* currently on 0/1, for auto compo */ + short pad[3]; ListBase linkdrag; /* temporary data for modal linking operator */ struct bGPdata *gpd; /* grease-pencil data */ @@ -418,6 +420,10 @@ typedef struct SpaceNode { #define SNODE_TEX_WORLD 1 #define SNODE_TEX_BRUSH 2 +/* snode->shaderfrom */ +#define SNODE_SHADER_OBJECT 0 +#define SNODE_SHADER_WORLD 1 + typedef struct SpaceLogic { SpaceLink *next, *prev; ListBase regionbase; /* storage of regions for inactive spaces */ diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h index d94d4318725..aaf4186945e 100644 --- a/source/blender/makesdna/DNA_view3d_types.h +++ b/source/blender/makesdna/DNA_view3d_types.h @@ -39,6 +39,7 @@ struct SpaceLink; struct Base; struct BoundBox; struct RenderInfo; +struct RenderEngine; struct bGPdata; struct SmoothViewStore; struct wmTimer; @@ -115,6 +116,7 @@ typedef struct RegionView3D { struct RegionView3D *localvd; /* allocated backup of its self while in localview */ struct RenderInfo *ri; + struct RenderEngine *render_engine; struct ViewDepths *depths; /* animated smooth view */ @@ -164,8 +166,8 @@ typedef struct View3D { int layact; /** - * The drawing mode for the 3d display. Set to OB_WIRE, OB_SOLID, - * OB_SHADED or OB_TEXTURE */ + * The drawing mode for the 3d display. Set to OB_BOUNDBOX, OB_WIRE, OB_SOLID, + * OB_TEXTURE, OB_MATERIAL or OB_RENDER */ short drawtype; short ob_centre_cursor; /* optional bool for 3d cursor to define center */ short scenelock, around; diff --git a/source/blender/makesdna/DNA_world_types.h b/source/blender/makesdna/DNA_world_types.h index 500851e23b8..0c455022db4 100644 --- a/source/blender/makesdna/DNA_world_types.h +++ b/source/blender/makesdna/DNA_world_types.h @@ -34,6 +34,7 @@ #include "DNA_ID.h" struct AnimData; +struct bNodeTree; struct Ipo; struct MTex; @@ -95,7 +96,7 @@ typedef struct World { float misi, miststa, mistdist, misthi; - float starr, starg, starb, stark; + float starr, starg, starb, stark; /* Deprecated */ float starsize, starmindist; float stardist, starcolnoise; @@ -120,11 +121,14 @@ typedef struct World { struct Ipo *ipo; // XXX depreceated... old animation system struct MTex *mtex[18]; /* MAX_MTEX */ - short pr_texture, pad[3]; + short pr_texture, use_nodes, pad[2]; /* previews */ struct PreviewImage *preview; + /* nodes */ + struct bNodeTree *nodetree; + } World; /* **************** WORLD ********************* */ @@ -182,7 +186,7 @@ typedef struct World { #define WOMAP_HORIZ 2 #define WOMAP_ZENUP 4 #define WOMAP_ZENDOWN 8 -#define WOMAP_MIST 16 +#define WOMAP_MIST 16 /* Deprecated */ /* flag */ #define WO_DS_EXPAND (1<<0) diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index 194c3e8d18e..e4692d32338 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -486,6 +486,16 @@ static void rna_def_ID(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_LIB_EXCEPTION); RNA_def_property_ui_text(prop, "Tag", "Tools can use this to tag data (initial state is undefined)"); + prop= RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", LIB_ID_RECALC); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Is Updated", "Datablock is tagged for recalculation"); + + prop= RNA_def_property(srna, "is_updated_data", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", LIB_ID_RECALC_DATA); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Is Updated Data", "Datablock data is tagged for recalculation"); + prop= RNA_def_property(srna, "library", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "lib"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); diff --git a/source/blender/makesrna/intern/rna_lamp.c b/source/blender/makesrna/intern/rna_lamp.c index 572559546c8..629711fcf96 100644 --- a/source/blender/makesrna/intern/rna_lamp.c +++ b/source/blender/makesrna/intern/rna_lamp.c @@ -46,6 +46,7 @@ #include "BKE_main.h" #include "BKE_texture.h" +#include "ED_node.h" #include "WM_api.h" #include "WM_types.h" @@ -145,6 +146,15 @@ static void rna_Lamp_spot_size_set(PointerRNA *ptr, float value) la->spotsize= RAD2DEGF(value); } +static void rna_Lamp_use_nodes_update(Main *blain, Scene *scene, PointerRNA *ptr) +{ + Lamp *la= (Lamp*)ptr->data; + + if(la->use_nodes && la->nodetree==NULL) + ED_node_shader_default(scene, &la->id); + + rna_Lamp_update(blain, scene, ptr); +} #else @@ -366,6 +376,17 @@ static void rna_def_lamp(BlenderRNA *brna) RNA_def_property_boolean_negative_sdna(prop, NULL, "mode", LA_NO_DIFF); RNA_def_property_ui_text(prop, "Diffuse", "Lamp does diffuse shading"); RNA_def_property_update(prop, 0, "rna_Lamp_update"); + + /* nodes */ + prop= RNA_def_property(srna, "node_tree", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "nodetree"); + RNA_def_property_ui_text(prop, "Node Tree", "Node tree for node based lamps"); + + prop= RNA_def_property(srna, "use_nodes", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "use_nodes", 1); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_ui_text(prop, "Use Nodes", "Use shader nodes to render the lamp"); + RNA_def_property_update(prop, 0, "rna_Lamp_use_nodes_update"); /* common */ rna_def_animdata_common(srna); diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index 3f7cdf8d204..1b80e33b40c 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -62,6 +62,7 @@ #include "BKE_particle.h" #include "BKE_font.h" #include "BKE_node.h" +#include "BKE_depsgraph.h" #include "BKE_speaker.h" #include "DNA_armature_types.h" @@ -548,6 +549,33 @@ void rna_Main_actions_tag(Main *bmain, int value) { tag_main_lb(&bmain->action, void rna_Main_particles_tag(Main *bmain, int value) { tag_main_lb(&bmain->particle, value); } void rna_Main_gpencil_tag(Main *bmain, int value) { tag_main_lb(&bmain->gpencil, value); } +static int rna_Main_cameras_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_CA); } +static int rna_Main_scenes_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_SCE); } +static int rna_Main_objects_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_OB); } +static int rna_Main_materials_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_MA); } +static int rna_Main_node_groups_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_NT); } +static int rna_Main_meshes_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_ME); } +static int rna_Main_lamps_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_LA); } +static int rna_Main_libraries_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_LI); } +static int rna_Main_screens_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_SCR); } +static int rna_Main_window_managers_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_WM); } +static int rna_Main_images_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_IM); } +static int rna_Main_lattices_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_LT); } +static int rna_Main_curves_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_CU); } +static int rna_Main_metaballs_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_MB); } +static int rna_Main_fonts_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_VF); } +static int rna_Main_textures_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_TE); } +static int rna_Main_brushes_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_BR); } +static int rna_Main_worlds_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_WO); } +static int rna_Main_groups_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_GR); } +static int rna_Main_texts_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_TXT); } +static int rna_Main_speakers_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_SPK); } +static int rna_Main_sounds_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_SO); } +static int rna_Main_armatures_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_AR); } +static int rna_Main_actions_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_AC); } +static int rna_Main_particles_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_PA); } +static int rna_Main_gpencil_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_GD); } + #else void RNA_api_main(StructRNA *srna) @@ -574,6 +602,7 @@ void RNA_def_main_cameras(BlenderRNA *brna, PropertyRNA *cprop) StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; + PropertyRNA *prop; RNA_def_property_srna(cprop, "BlendDataCameras"); srna= RNA_def_struct(brna, "BlendDataCameras", NULL); @@ -597,6 +626,10 @@ void RNA_def_main_cameras(BlenderRNA *brna, PropertyRNA *cprop) func= RNA_def_function(srna, "tag", "rna_Main_cameras_tag"); parm= RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_property_flag(parm, PROP_REQUIRED); + + prop= RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_boolean_funcs(prop, "rna_Main_cameras_is_updated_get", NULL); } void RNA_def_main_scenes(BlenderRNA *brna, PropertyRNA *cprop) @@ -604,6 +637,7 @@ void RNA_def_main_scenes(BlenderRNA *brna, PropertyRNA *cprop) StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; + PropertyRNA *prop; RNA_def_property_srna(cprop, "BlendDataScenes"); srna= RNA_def_struct(brna, "BlendDataScenes", NULL); @@ -623,6 +657,10 @@ void RNA_def_main_scenes(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Remove a scene from the current blendfile"); parm= RNA_def_pointer(func, "scene", "Scene", "", "Scene to remove"); RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + + prop= RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_boolean_funcs(prop, "rna_Main_scenes_is_updated_get", NULL); } void RNA_def_main_objects(BlenderRNA *brna, PropertyRNA *cprop) @@ -630,6 +668,7 @@ void RNA_def_main_objects(BlenderRNA *brna, PropertyRNA *cprop) StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; + PropertyRNA *prop; RNA_def_property_srna(cprop, "BlendDataObjects"); srna= RNA_def_struct(brna, "BlendDataObjects", NULL); @@ -657,6 +696,10 @@ void RNA_def_main_objects(BlenderRNA *brna, PropertyRNA *cprop) func= RNA_def_function(srna, "tag", "rna_Main_objects_tag"); parm= RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_property_flag(parm, PROP_REQUIRED); + + prop= RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_boolean_funcs(prop, "rna_Main_objects_is_updated_get", NULL); } void RNA_def_main_materials(BlenderRNA *brna, PropertyRNA *cprop) @@ -664,6 +707,7 @@ void RNA_def_main_materials(BlenderRNA *brna, PropertyRNA *cprop) StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; + PropertyRNA *prop; RNA_def_property_srna(cprop, "BlendDataMaterials"); srna= RNA_def_struct(brna, "BlendDataMaterials", NULL); @@ -687,12 +731,17 @@ void RNA_def_main_materials(BlenderRNA *brna, PropertyRNA *cprop) func= RNA_def_function(srna, "tag", "rna_Main_materials_tag"); parm= RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_property_flag(parm, PROP_REQUIRED); + + prop= RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_boolean_funcs(prop, "rna_Main_materials_is_updated_get", NULL); } void RNA_def_main_node_groups(BlenderRNA *brna, PropertyRNA *cprop) { StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; + PropertyRNA *prop; static EnumPropertyItem node_nodetree_items[] = { {0, "SHADER", 0, "Shader", ""}, @@ -724,12 +773,17 @@ void RNA_def_main_node_groups(BlenderRNA *brna, PropertyRNA *cprop) func= RNA_def_function(srna, "tag", "rna_Main_node_groups_tag"); parm= RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_property_flag(parm, PROP_REQUIRED); + + prop= RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_boolean_funcs(prop, "rna_Main_node_groups_is_updated_get", NULL); } void RNA_def_main_meshes(BlenderRNA *brna, PropertyRNA *cprop) { StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; + PropertyRNA *prop; RNA_def_property_srna(cprop, "BlendDataMeshes"); srna= RNA_def_struct(brna, "BlendDataMeshes", NULL); @@ -753,12 +807,17 @@ void RNA_def_main_meshes(BlenderRNA *brna, PropertyRNA *cprop) func= RNA_def_function(srna, "tag", "rna_Main_meshes_tag"); parm= RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_property_flag(parm, PROP_REQUIRED); + + prop= RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_boolean_funcs(prop, "rna_Main_meshes_is_updated_get", NULL); } void RNA_def_main_lamps(BlenderRNA *brna, PropertyRNA *cprop) { StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; + PropertyRNA *prop; RNA_def_property_srna(cprop, "BlendDataLamps"); srna= RNA_def_struct(brna, "BlendDataLamps", NULL); @@ -784,6 +843,10 @@ void RNA_def_main_lamps(BlenderRNA *brna, PropertyRNA *cprop) func= RNA_def_function(srna, "tag", "rna_Main_lamps_tag"); parm= RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_property_flag(parm, PROP_REQUIRED); + + prop= RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_boolean_funcs(prop, "rna_Main_lamps_is_updated_get", NULL); } void RNA_def_main_libraries(BlenderRNA *brna, PropertyRNA *cprop) @@ -791,6 +854,7 @@ void RNA_def_main_libraries(BlenderRNA *brna, PropertyRNA *cprop) StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; + PropertyRNA *prop; RNA_def_property_srna(cprop, "BlendDataLibraries"); srna= RNA_def_struct(brna, "BlendDataLibraries", NULL); @@ -800,6 +864,10 @@ void RNA_def_main_libraries(BlenderRNA *brna, PropertyRNA *cprop) func= RNA_def_function(srna, "tag", "rna_Main_libraries_tag"); parm= RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_property_flag(parm, PROP_REQUIRED); + + prop= RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_boolean_funcs(prop, "rna_Main_libraries_is_updated_get", NULL); } void RNA_def_main_screens(BlenderRNA *brna, PropertyRNA *cprop) @@ -807,6 +875,7 @@ void RNA_def_main_screens(BlenderRNA *brna, PropertyRNA *cprop) StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; + PropertyRNA *prop; RNA_def_property_srna(cprop, "BlendDataScreens"); srna= RNA_def_struct(brna, "BlendDataScreens", NULL); @@ -816,6 +885,10 @@ void RNA_def_main_screens(BlenderRNA *brna, PropertyRNA *cprop) func= RNA_def_function(srna, "tag", "rna_Main_screens_tag"); parm= RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_property_flag(parm, PROP_REQUIRED); + + prop= RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_boolean_funcs(prop, "rna_Main_screens_is_updated_get", NULL); } void RNA_def_main_window_managers(BlenderRNA *brna, PropertyRNA *cprop) @@ -823,6 +896,7 @@ void RNA_def_main_window_managers(BlenderRNA *brna, PropertyRNA *cprop) StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; + PropertyRNA *prop; RNA_def_property_srna(cprop, "BlendDataWindowManagers"); srna= RNA_def_struct(brna, "BlendDataWindowManagers", NULL); @@ -832,12 +906,17 @@ void RNA_def_main_window_managers(BlenderRNA *brna, PropertyRNA *cprop) func= RNA_def_function(srna, "tag", "rna_Main_window_managers_tag"); parm= RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_property_flag(parm, PROP_REQUIRED); + + prop= RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_boolean_funcs(prop, "rna_Main_window_managers_is_updated_get", NULL); } void RNA_def_main_images(BlenderRNA *brna, PropertyRNA *cprop) { StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; + PropertyRNA *prop; RNA_def_property_srna(cprop, "BlendDataImages"); srna= RNA_def_struct(brna, "BlendDataImages", NULL); @@ -876,6 +955,10 @@ void RNA_def_main_images(BlenderRNA *brna, PropertyRNA *cprop) func= RNA_def_function(srna, "tag", "rna_Main_images_tag"); parm= RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_property_flag(parm, PROP_REQUIRED); + + prop= RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_boolean_funcs(prop, "rna_Main_images_is_updated_get", NULL); } void RNA_def_main_lattices(BlenderRNA *brna, PropertyRNA *cprop) @@ -883,6 +966,7 @@ void RNA_def_main_lattices(BlenderRNA *brna, PropertyRNA *cprop) StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; + PropertyRNA *prop; RNA_def_property_srna(cprop, "BlendDataLattices"); srna= RNA_def_struct(brna, "BlendDataLattices", NULL); @@ -906,12 +990,17 @@ void RNA_def_main_lattices(BlenderRNA *brna, PropertyRNA *cprop) func= RNA_def_function(srna, "tag", "rna_Main_lattices_tag"); parm= RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_property_flag(parm, PROP_REQUIRED); + + prop= RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_boolean_funcs(prop, "rna_Main_lattices_is_updated_get", NULL); } void RNA_def_main_curves(BlenderRNA *brna, PropertyRNA *cprop) { StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; + PropertyRNA *prop; RNA_def_property_srna(cprop, "BlendDataCurves"); srna= RNA_def_struct(brna, "BlendDataCurves", NULL); @@ -937,12 +1026,17 @@ void RNA_def_main_curves(BlenderRNA *brna, PropertyRNA *cprop) func= RNA_def_function(srna, "tag", "rna_Main_curves_tag"); parm= RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_property_flag(parm, PROP_REQUIRED); + + prop= RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_boolean_funcs(prop, "rna_Main_curves_is_updated_get", NULL); } void RNA_def_main_metaballs(BlenderRNA *brna, PropertyRNA *cprop) { StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; + PropertyRNA *prop; RNA_def_property_srna(cprop, "BlendDataMetaBalls"); srna= RNA_def_struct(brna, "BlendDataMetaBalls", NULL); @@ -966,12 +1060,17 @@ void RNA_def_main_metaballs(BlenderRNA *brna, PropertyRNA *cprop) func= RNA_def_function(srna, "tag", "rna_Main_metaballs_tag"); parm= RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_property_flag(parm, PROP_REQUIRED); + + prop= RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_boolean_funcs(prop, "rna_Main_metaballs_is_updated_get", NULL); } void RNA_def_main_fonts(BlenderRNA *brna, PropertyRNA *cprop) { StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; + PropertyRNA *prop; RNA_def_property_srna(cprop, "BlendDataFonts"); srna= RNA_def_struct(brna, "BlendDataFonts", NULL); @@ -996,12 +1095,17 @@ void RNA_def_main_fonts(BlenderRNA *brna, PropertyRNA *cprop) func= RNA_def_function(srna, "tag", "rna_Main_fonts_tag"); parm= RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_property_flag(parm, PROP_REQUIRED); + + prop= RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_boolean_funcs(prop, "rna_Main_fonts_is_updated_get", NULL); } void RNA_def_main_textures(BlenderRNA *brna, PropertyRNA *cprop) { StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; + PropertyRNA *prop; RNA_def_property_srna(cprop, "BlendDataTextures"); srna= RNA_def_struct(brna, "BlendDataTextures", NULL); @@ -1027,12 +1131,17 @@ void RNA_def_main_textures(BlenderRNA *brna, PropertyRNA *cprop) func= RNA_def_function(srna, "tag", "rna_Main_textures_tag"); parm= RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_property_flag(parm, PROP_REQUIRED); + + prop= RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_boolean_funcs(prop, "rna_Main_textures_is_updated_get", NULL); } void RNA_def_main_brushes(BlenderRNA *brna, PropertyRNA *cprop) { StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; + PropertyRNA *prop; RNA_def_property_srna(cprop, "BlendDataBrushes"); srna= RNA_def_struct(brna, "BlendDataBrushes", NULL); @@ -1056,6 +1165,10 @@ void RNA_def_main_brushes(BlenderRNA *brna, PropertyRNA *cprop) func= RNA_def_function(srna, "tag", "rna_Main_brushes_tag"); parm= RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_property_flag(parm, PROP_REQUIRED); + + prop= RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_boolean_funcs(prop, "rna_Main_brushes_is_updated_get", NULL); } void RNA_def_main_worlds(BlenderRNA *brna, PropertyRNA *cprop) @@ -1063,6 +1176,7 @@ void RNA_def_main_worlds(BlenderRNA *brna, PropertyRNA *cprop) StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; + PropertyRNA *prop; RNA_def_property_srna(cprop, "BlendDataWorlds"); srna= RNA_def_struct(brna, "BlendDataWorlds", NULL); @@ -1086,6 +1200,10 @@ void RNA_def_main_worlds(BlenderRNA *brna, PropertyRNA *cprop) func= RNA_def_function(srna, "tag", "rna_Main_worlds_tag"); parm= RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_property_flag(parm, PROP_REQUIRED); + + prop= RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_boolean_funcs(prop, "rna_Main_worlds_is_updated_get", NULL); } void RNA_def_main_groups(BlenderRNA *brna, PropertyRNA *cprop) @@ -1093,6 +1211,7 @@ void RNA_def_main_groups(BlenderRNA *brna, PropertyRNA *cprop) StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; + PropertyRNA *prop; RNA_def_property_srna(cprop, "BlendDataGroups"); srna= RNA_def_struct(brna, "BlendDataGroups", NULL); @@ -1115,6 +1234,10 @@ void RNA_def_main_groups(BlenderRNA *brna, PropertyRNA *cprop) func= RNA_def_function(srna, "tag", "rna_Main_groups_tag"); parm= RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_property_flag(parm, PROP_REQUIRED); + + prop= RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_boolean_funcs(prop, "rna_Main_groups_is_updated_get", NULL); } void RNA_def_main_speakers(BlenderRNA *brna, PropertyRNA *cprop) @@ -1122,6 +1245,7 @@ void RNA_def_main_speakers(BlenderRNA *brna, PropertyRNA *cprop) StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; + PropertyRNA *prop; RNA_def_property_srna(cprop, "BlendDataSpeakers"); srna= RNA_def_struct(brna, "BlendDataSpeakers", NULL); @@ -1145,6 +1269,10 @@ void RNA_def_main_speakers(BlenderRNA *brna, PropertyRNA *cprop) func= RNA_def_function(srna, "tag", "rna_Main_speakers_tag"); parm= RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_property_flag(parm, PROP_REQUIRED); + + prop= RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_boolean_funcs(prop, "rna_Main_speakers_is_updated_get", NULL); } void RNA_def_main_texts(BlenderRNA *brna, PropertyRNA *cprop) @@ -1152,6 +1280,7 @@ void RNA_def_main_texts(BlenderRNA *brna, PropertyRNA *cprop) StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; + PropertyRNA *prop; RNA_def_property_srna(cprop, "BlendDataTexts"); srna= RNA_def_struct(brna, "BlendDataTexts", NULL); @@ -1184,6 +1313,10 @@ void RNA_def_main_texts(BlenderRNA *brna, PropertyRNA *cprop) func= RNA_def_function(srna, "tag", "rna_Main_texts_tag"); parm= RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_property_flag(parm, PROP_REQUIRED); + + prop= RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_boolean_funcs(prop, "rna_Main_texts_is_updated_get", NULL); } void RNA_def_main_sounds(BlenderRNA *brna, PropertyRNA *cprop) @@ -1191,6 +1324,7 @@ void RNA_def_main_sounds(BlenderRNA *brna, PropertyRNA *cprop) StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; + PropertyRNA *prop; RNA_def_property_srna(cprop, "BlendDataSounds"); srna= RNA_def_struct(brna, "BlendDataSounds", NULL); @@ -1202,6 +1336,10 @@ void RNA_def_main_sounds(BlenderRNA *brna, PropertyRNA *cprop) func= RNA_def_function(srna, "tag", "rna_Main_sounds_tag"); parm= RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_property_flag(parm, PROP_REQUIRED); + + prop= RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_boolean_funcs(prop, "rna_Main_sounds_is_updated_get", NULL); } void RNA_def_main_armatures(BlenderRNA *brna, PropertyRNA *cprop) @@ -1209,6 +1347,7 @@ void RNA_def_main_armatures(BlenderRNA *brna, PropertyRNA *cprop) StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; + PropertyRNA *prop; RNA_def_property_srna(cprop, "BlendDataArmatures"); srna= RNA_def_struct(brna, "BlendDataArmatures", NULL); @@ -1232,12 +1371,17 @@ void RNA_def_main_armatures(BlenderRNA *brna, PropertyRNA *cprop) func= RNA_def_function(srna, "tag", "rna_Main_armatures_tag"); parm= RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_property_flag(parm, PROP_REQUIRED); + + prop= RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_boolean_funcs(prop, "rna_Main_armatures_is_updated_get", NULL); } void RNA_def_main_actions(BlenderRNA *brna, PropertyRNA *cprop) { StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; + PropertyRNA *prop; RNA_def_property_srna(cprop, "BlendDataActions"); srna= RNA_def_struct(brna, "BlendDataActions", NULL); @@ -1261,12 +1405,17 @@ void RNA_def_main_actions(BlenderRNA *brna, PropertyRNA *cprop) func= RNA_def_function(srna, "tag", "rna_Main_actions_tag"); parm= RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_property_flag(parm, PROP_REQUIRED); + + prop= RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_boolean_funcs(prop, "rna_Main_actions_is_updated_get", NULL); } void RNA_def_main_particles(BlenderRNA *brna, PropertyRNA *cprop) { StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; + PropertyRNA *prop; RNA_def_property_srna(cprop, "BlendDataParticles"); srna= RNA_def_struct(brna, "BlendDataParticles", NULL); @@ -1290,6 +1439,10 @@ void RNA_def_main_particles(BlenderRNA *brna, PropertyRNA *cprop) func= RNA_def_function(srna, "tag", "rna_Main_particles_tag"); parm= RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_property_flag(parm, PROP_REQUIRED); + + prop= RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_boolean_funcs(prop, "rna_Main_particles_is_updated_get", NULL); } void RNA_def_main_gpencil(BlenderRNA *brna, PropertyRNA *cprop) @@ -1297,6 +1450,7 @@ void RNA_def_main_gpencil(BlenderRNA *brna, PropertyRNA *cprop) StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; + PropertyRNA *prop; RNA_def_property_srna(cprop, "BlendDataGreasePencils"); srna= RNA_def_struct(brna, "BlendDataGreasePencils", NULL); @@ -1306,6 +1460,10 @@ void RNA_def_main_gpencil(BlenderRNA *brna, PropertyRNA *cprop) func= RNA_def_function(srna, "tag", "rna_Main_gpencil_tag"); parm= RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_property_flag(parm, PROP_REQUIRED); + + prop= RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_boolean_funcs(prop, "rna_Main_gpencil_is_updated_get", NULL); } #endif diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index 990d3b89bce..57770be57eb 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -269,13 +269,14 @@ static void rna_Material_use_specular_ramp_set(PointerRNA *ptr, int value) ma->ramp_spec= add_colorband(0); } -static void rna_Material_use_nodes_set(PointerRNA *ptr, int value) +static void rna_Material_use_nodes_update(Main *bmain, Scene *scene, PointerRNA *ptr) { Material *ma= (Material*)ptr->data; - ma->use_nodes= value; if(ma->use_nodes && ma->nodetree==NULL) - ED_node_shader_default(ma); + ED_node_shader_default(scene, &ma->id); + + rna_Material_update(bmain, scene, ptr); } static EnumPropertyItem *rna_Material_texture_coordinates_itemf(bContext *UNUSED(C), PointerRNA *ptr, @@ -1954,9 +1955,9 @@ void RNA_def_material(BlenderRNA *brna) prop= RNA_def_property(srna, "use_nodes", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "use_nodes", 1); - RNA_def_property_boolean_funcs(prop, NULL, "rna_Material_use_nodes_set"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_ui_text(prop, "Use Nodes", "Use shader nodes to render the material"); - RNA_def_property_update(prop, 0, "rna_Material_update"); + RNA_def_property_update(prop, 0, "rna_Material_use_nodes_update"); prop= RNA_def_property(srna, "active_node_material", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "Material"); diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 96c23effdfb..1445cf3b537 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -56,7 +56,7 @@ #include "MEM_guardedalloc.h" EnumPropertyItem nodetree_type_items[] = { - {NTREE_SHADER, "MATERIAL", ICON_MATERIAL, "Material", "Material nodes" }, + {NTREE_SHADER, "SHADER", ICON_MATERIAL, "Shader", "Shader nodes" }, {NTREE_TEXTURE, "TEXTURE", ICON_TEXTURE, "Texture", "Texture nodes" }, {NTREE_COMPOSIT, "COMPOSITING", ICON_RENDERLAYERS, "Compositing", "Compositing nodes" }, {0, NULL, 0, NULL, NULL} @@ -189,7 +189,7 @@ static StructRNA *rna_NodeTree_refine(struct PointerRNA *ptr) case NTREE_TEXTURE: return &RNA_TextureNodeTree; default: - return &RNA_UnknownType; + return &RNA_NodeTree; } } @@ -232,6 +232,8 @@ static StructRNA *rna_NodeSocket_refine(PointerRNA *ptr) case SOCK_RGBA: return &RNA_NodeSocketRGBA; break; + case SOCK_SHADER: + return &RNA_NodeSocketShader; } #undef SUBTYPE @@ -2998,6 +3000,7 @@ void RNA_def_nodetree(BlenderRNA *brna) #undef SUBTYPE rna_def_node_socket_subtype(brna, SOCK_BOOLEAN, 0, "NodeSocketBoolean", "Boolean Node Socket"); rna_def_node_socket_subtype(brna, SOCK_RGBA, 0, "NodeSocketRGBA", "RGBA Node Socket"); + rna_def_node_socket_subtype(brna, SOCK_SHADER, 0, "NodeSocketShader", "Shader Closure Node Socket"); rna_def_node(brna); rna_def_node_link(brna); diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index b7886571988..05dc8ac0c99 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -287,6 +287,8 @@ static void rna_Object_layer_update__internal(Main *bmain, Scene *scene, Base *b else { DAG_scene_sort(bmain, scene); } + + DAG_id_type_tag(bmain, ID_OB); } static void rna_Object_layer_update(Main *bmain, Scene *scene, PointerRNA *ptr) @@ -1794,7 +1796,6 @@ static void rna_def_object(BlenderRNA *brna) {OB_BOUNDBOX, "BOUNDS", 0, "Bounds", "Draw the bounding box of the object"}, {OB_WIRE, "WIRE", 0, "Wire", "Draw the object as a wireframe"}, {OB_SOLID, "SOLID", 0, "Solid", "Draw the object as a solid (if solid drawing is enabled in the viewport)"}, - // disabled {OB_SHADED, "SHADED", 0, "Shaded", ""}, {OB_TEXTURE, "TEXTURED", 0, "Textured", "Draw the object with textures (if textures are enabled in the viewport)"}, {0, NULL, 0, NULL, NULL}}; diff --git a/source/blender/makesrna/intern/rna_render.c b/source/blender/makesrna/intern/rna_render.c index 1498d161209..530d162b1fe 100644 --- a/source/blender/makesrna/intern/rna_render.c +++ b/source/blender/makesrna/intern/rna_render.c @@ -48,12 +48,39 @@ #include "BKE_context.h" #include "BKE_report.h" -/* RenderEngine */ +/* RenderEngine Callbacks */ + +void engine_tag_redraw(RenderEngine *engine) +{ + engine->flag |= RE_ENGINE_DO_DRAW; +} + +void engine_tag_update(RenderEngine *engine) +{ + engine->flag |= RE_ENGINE_DO_UPDATE; +} + +static void engine_update(RenderEngine *engine, Main *bmain, Scene *scene) +{ + extern FunctionRNA rna_RenderEngine_update_func; + PointerRNA ptr; + ParameterList list; + FunctionRNA *func; + + RNA_pointer_create(NULL, engine->type->ext.srna, engine, &ptr); + func= &rna_RenderEngine_update_func; + + RNA_parameter_list_create(&list, &ptr, func); + RNA_parameter_set_lookup(&list, "data", &bmain); + RNA_parameter_set_lookup(&list, "scene", &scene); + engine->type->ext.call(NULL, &ptr, func, &list); + + RNA_parameter_list_free(&list); +} static void engine_render(RenderEngine *engine, struct Scene *scene) { extern FunctionRNA rna_RenderEngine_render_func; - PointerRNA ptr; ParameterList list; FunctionRNA *func; @@ -68,6 +95,40 @@ static void engine_render(RenderEngine *engine, struct Scene *scene) RNA_parameter_list_free(&list); } +static void engine_view_update(RenderEngine *engine, const struct bContext *context) +{ + extern FunctionRNA rna_RenderEngine_view_update_func; + PointerRNA ptr; + ParameterList list; + FunctionRNA *func; + + RNA_pointer_create(NULL, engine->type->ext.srna, engine, &ptr); + func= &rna_RenderEngine_view_update_func; + + RNA_parameter_list_create(&list, &ptr, func); + RNA_parameter_set_lookup(&list, "context", &context); + engine->type->ext.call(NULL, &ptr, func, &list); + + RNA_parameter_list_free(&list); +} + +static void engine_view_draw(RenderEngine *engine, const struct bContext *context) +{ + extern FunctionRNA rna_RenderEngine_view_draw_func; + PointerRNA ptr; + ParameterList list; + FunctionRNA *func; + + RNA_pointer_create(NULL, engine->type->ext.srna, engine, &ptr); + func= &rna_RenderEngine_view_draw_func; + + RNA_parameter_list_create(&list, &ptr, func); + RNA_parameter_set_lookup(&list, "context", &context); + engine->type->ext.call(NULL, &ptr, func, &list); + + RNA_parameter_list_free(&list); +} + /* RenderEngine registration */ static void rna_RenderEngine_unregister(Main *UNUSED(bmain), StructRNA *type) @@ -87,7 +148,7 @@ static StructRNA *rna_RenderEngine_register(Main *bmain, ReportList *reports, vo RenderEngineType *et, dummyet = {NULL}; RenderEngine dummyengine= {NULL}; PointerRNA dummyptr; - int have_function[1]; + int have_function[4]; /* setup dummy engine & engine type to store static properties in */ dummyengine.type= &dummyet; @@ -122,13 +183,22 @@ static StructRNA *rna_RenderEngine_register(Main *bmain, ReportList *reports, vo et->ext.free= free; RNA_struct_blender_type_set(et->ext.srna, et); - et->render= (have_function[0])? engine_render: NULL; + et->update= (have_function[0])? engine_update: NULL; + et->render= (have_function[1])? engine_render: NULL; + et->view_update= (have_function[2])? engine_view_update: NULL; + et->view_draw= (have_function[3])? engine_view_draw: NULL; BLI_addtail(&R_engines, et); return et->ext.srna; } +static void **rna_RenderEngine_instance(PointerRNA *ptr) +{ + RenderEngine *engine = ptr->data; + return &engine->py_instance; +} + static StructRNA* rna_RenderEngine_refine(PointerRNA *ptr) { RenderEngine *engine= (RenderEngine*)ptr->data; @@ -203,14 +273,39 @@ static void rna_def_render_engine(BlenderRNA *brna) RNA_def_struct_sdna(srna, "RenderEngine"); RNA_def_struct_ui_text(srna, "Render Engine", "Render engine"); RNA_def_struct_refine_func(srna, "rna_RenderEngine_refine"); - RNA_def_struct_register_funcs(srna, "rna_RenderEngine_register", "rna_RenderEngine_unregister", NULL); + RNA_def_struct_register_funcs(srna, "rna_RenderEngine_register", "rna_RenderEngine_unregister", "rna_RenderEngine_instance"); + + /* final render callbacks */ + func= RNA_def_function(srna, "update", NULL); + RNA_def_function_ui_description(func, "Export scene data for render"); + RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL); + RNA_def_pointer(func, "data", "BlendData", "", ""); + RNA_def_pointer(func, "scene", "Scene", "", ""); - /* render */ func= RNA_def_function(srna, "render", NULL); RNA_def_function_ui_description(func, "Render scene into an image"); - RNA_def_function_flag(func, FUNC_REGISTER); + RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL); RNA_def_pointer(func, "scene", "Scene", "", ""); + /* viewport render callbacks */ + func= RNA_def_function(srna, "view_update", NULL); + RNA_def_function_ui_description(func, "Update on data changes for viewport render"); + RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL); + RNA_def_pointer(func, "context", "Context", "", ""); + + func= RNA_def_function(srna, "view_draw", NULL); + RNA_def_function_ui_description(func, "Draw viewport render"); + RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL); + RNA_def_pointer(func, "context", "Context", "", ""); + + /* tag for redraw */ + RNA_def_function(srna, "tag_redraw", "engine_tag_redraw"); + RNA_def_function_ui_description(func, "Request redraw for viewport rendering"); + + /* tag for update */ + RNA_def_function(srna, "tag_update", "engine_tag_update"); + RNA_def_function_ui_description(func, "Request update call for viewport rendering"); + func= RNA_def_function(srna, "begin_result", "RE_engine_begin_result"); prop= RNA_def_int(func, "x", 0, 0, INT_MAX, "X", "", 0, INT_MAX); RNA_def_property_flag(prop, PROP_REQUIRED); @@ -251,9 +346,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); @@ -270,6 +372,10 @@ static void rna_def_render_engine(BlenderRNA *brna) RNA_def_property_boolean_negative_sdna(prop, NULL, "type->flag", RE_USE_POSTPROCESS); RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL); + prop= RNA_def_property(srna, "bl_use_shading_nodes", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "type->flag", RE_USE_SHADING_NODES); + RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL); + RNA_define_verify_sdna(1); } diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 968e7264cf7..9abc7a7c192 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -42,6 +42,7 @@ #include "BKE_tessmesh.h" /* Include for Bake Options */ +#include "RE_engine.h" #include "RE_pipeline.h" #ifdef WITH_QUICKTIME @@ -57,6 +58,8 @@ #include <libavformat/avformat.h> #endif +#include "ED_render.h" + #include "WM_api.h" #include "WM_types.h" @@ -775,6 +778,11 @@ static int rna_RenderSettings_engine_get(PointerRNA *ptr) return 0; } +static void rna_RenderSettings_engine_update(Main *bmain, Scene *UNUSED(unused), PointerRNA *UNUSED(ptr)) +{ + ED_render_engine_changed(bmain); +} + static void rna_Scene_glsl_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { Scene *scene= (Scene*)ptr->id.data; @@ -832,6 +840,12 @@ static int rna_RenderSettings_multiple_engines_get(PointerRNA *UNUSED(ptr)) return (BLI_countlist(&R_engines) > 1); } +static int rna_RenderSettings_use_shading_nodes_get(PointerRNA *ptr) +{ + Scene *scene= (Scene*)ptr->id.data; + return scene_use_new_shading_nodes(scene); +} + static int rna_RenderSettings_use_game_engine_get(PointerRNA *ptr) { RenderData *rd= (RenderData*)ptr->data; @@ -3214,13 +3228,18 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_enum_funcs(prop, "rna_RenderSettings_engine_get", "rna_RenderSettings_engine_set", "rna_RenderSettings_engine_itemf"); RNA_def_property_ui_text(prop, "Engine", "Engine to use for rendering"); - RNA_def_property_update(prop, NC_WINDOW, NULL); + RNA_def_property_update(prop, NC_WINDOW, "rna_RenderSettings_engine_update"); prop= RNA_def_property(srna, "has_multiple_engines", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_funcs(prop, "rna_RenderSettings_multiple_engines_get", NULL); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Multiple Engines", "More than one rendering engine is available"); + prop= RNA_def_property(srna, "use_shading_nodes", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs(prop, "rna_RenderSettings_use_shading_nodes_get", NULL); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Use Shading Nodes", "Active render engine uses new shading nodes system"); + prop= RNA_def_property(srna, "use_game_engine", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_funcs(prop, "rna_RenderSettings_use_game_engine_get", NULL); RNA_def_property_clear_flag(prop, PROP_EDITABLE); diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c index 345ebb2cd80..250c61ed5f4 100644 --- a/source/blender/makesrna/intern/rna_scene_api.c +++ b/source/blender/makesrna/intern/rna_scene_api.c @@ -69,6 +69,7 @@ static void rna_Scene_frame_set(Scene *scene, int frame, float subframe) static void rna_Scene_update_tagged(Scene *scene) { scene_update_tagged(G.main, scene); + scene_clear_tagged(G.main, scene); } static void rna_SceneRender_get_frame_path(RenderData *rd, int frame, char *name) diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 51faccc0d6c..0dc4ca343fe 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -47,6 +47,9 @@ #include "WM_api.h" #include "WM_types.h" +#include "RE_engine.h" +#include "RE_pipeline.h" + #include "RNA_enum_types.h" EnumPropertyItem space_type_items[] = { @@ -98,8 +101,8 @@ EnumPropertyItem viewport_shade_items[] = { {OB_BOUNDBOX, "BOUNDBOX", ICON_BBOX, "Bounding Box", "Display the object's local bounding boxes only"}, {OB_WIRE, "WIREFRAME", ICON_WIRE, "Wireframe", "Display the object as wire edges"}, {OB_SOLID, "SOLID", ICON_SOLID, "Solid", "Display the object solid, lit with default OpenGL lights"}, - //{OB_SHADED, "SHADED", ICON_SMOOTH, "Shaded", "Display the object solid, with preview shading interpolated at vertices"}, {OB_TEXTURE, "TEXTURED", ICON_POTATO, "Textured", "Display the object solid, with face-assigned textures"}, + {OB_RENDER, "RENDERED", ICON_SMOOTH, "Rendered", "Display render preview"}, {0, NULL, 0, NULL, NULL}}; #ifdef RNA_RUNTIME @@ -313,6 +316,25 @@ static void rna_SpaceView3D_layer_update(Main *bmain, Scene *UNUSED(scene), Poin DAG_on_visible_update(bmain, FALSE); } +static void rna_SpaceView3D_viewport_shade_update(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + View3D *v3d= (View3D*)(ptr->data); + ScrArea *sa= rna_area_from_space(ptr); + + if(v3d->drawtype != OB_RENDER) { + ARegion *ar; + + for(ar=sa->regionbase.first; ar; ar=ar->next) { + RegionView3D *rv3d = ar->regiondata; + + if(rv3d && rv3d->render_engine) { + RE_engine_free(rv3d->render_engine); + rv3d->render_engine= NULL; + } + } + } +} + static void rna_SpaceView3D_pivot_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) { if (U.uiflag & USER_LOCKAROUND) { @@ -423,6 +445,29 @@ static void rna_RegionView3D_view_matrix_set(PointerRNA *ptr, const float *value ED_view3d_from_m4((float (*)[4])values, rv3d->ofs, rv3d->viewquat, &rv3d->dist); } +static EnumPropertyItem *rna_SpaceView3D_viewport_shade_itemf(bContext *UNUSED(C), PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *free) +{ + Scene *scene = ((bScreen*)ptr->id.data)->scene; + RenderEngineType *type = RE_engines_find(scene->r.engine); + + EnumPropertyItem *item= NULL; + int totitem= 0; + + RNA_enum_items_add_value(&item, &totitem, viewport_shade_items, OB_BOUNDBOX); + RNA_enum_items_add_value(&item, &totitem, viewport_shade_items, OB_WIRE); + RNA_enum_items_add_value(&item, &totitem, viewport_shade_items, OB_SOLID); + RNA_enum_items_add_value(&item, &totitem, viewport_shade_items, OB_TEXTURE); + + if(type->view_draw) { + RNA_enum_items_add_value(&item, &totitem, viewport_shade_items, OB_RENDER); + } + + RNA_enum_item_end(&item, &totitem); + *free= 1; + + return item; +} + /* Space Image Editor */ static PointerRNA rna_SpaceImageEditor_uvedit_get(PointerRNA *ptr) @@ -1227,8 +1272,9 @@ static void rna_def_space_view3d(BlenderRNA *brna) prop= RNA_def_property(srna, "viewport_shade", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "drawtype"); RNA_def_property_enum_items(prop, viewport_shade_items); + RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_SpaceView3D_viewport_shade_itemf"); RNA_def_property_ui_text(prop, "Viewport Shading", "Method to display/shade objects in the 3D View"); - RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL); + RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, "rna_SpaceView3D_viewport_shade_update"); prop= RNA_def_property(srna, "local_view", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "localvd"); @@ -2459,6 +2505,11 @@ static void rna_def_space_node(BlenderRNA *brna) {SNODE_TEX_BRUSH, "BRUSH", ICON_BRUSH_DATA, "Brush", "Edit texture nodes from Brush"}, {0, NULL, 0, NULL, NULL}}; + static EnumPropertyItem shader_type_items[] = { + {SNODE_SHADER_OBJECT, "OBJECT", ICON_OBJECT_DATA, "Object", "Edit shader nodes from Object"}, + {SNODE_SHADER_WORLD, "WORLD", ICON_WORLD_DATA, "World", "Edit shader nodes from World"}, + {0, NULL, 0, NULL, NULL}}; + static EnumPropertyItem backdrop_channels_items[] = { {0, "COLOR", ICON_IMAGE_RGB, "Color", "Draw image with RGB colors"}, {SNODE_USE_ALPHA, "COLOR_ALPHA", ICON_IMAGE_RGB_ALPHA, "Color and Alpha", @@ -2482,6 +2533,12 @@ static void rna_def_space_node(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Texture Type", "Type of data to take texture from"); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_NODE, NULL); + prop= RNA_def_property(srna, "shader_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "shaderfrom"); + RNA_def_property_enum_items(prop, shader_type_items); + RNA_def_property_ui_text(prop, "Shader Type", "Type of data to take shader from"); + RNA_def_property_update(prop, NC_SPACE|ND_SPACE_NODE, NULL); + prop= RNA_def_property(srna, "id", PROP_POINTER, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "ID", "Datablock whose nodes are being edited"); diff --git a/source/blender/makesrna/intern/rna_world.c b/source/blender/makesrna/intern/rna_world.c index 22570460093..d421aff7157 100644 --- a/source/blender/makesrna/intern/rna_world.c +++ b/source/blender/makesrna/intern/rna_world.c @@ -46,6 +46,8 @@ #include "BKE_main.h" #include "BKE_texture.h" +#include "ED_node.h" + #include "WM_api.h" static PointerRNA rna_World_lighting_get(PointerRNA *ptr) @@ -119,6 +121,15 @@ static void rna_World_stars_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Po WM_main_add_notifier(NC_WORLD|ND_WORLD_STARS, wo); } +static void rna_World_use_nodes_update(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + World *wrld= (World*)ptr->data; + + if(wrld->use_nodes && wrld->nodetree==NULL) + ED_node_shader_default(scene, &wrld->id); + + rna_World_update(bmain, scene, ptr); +} #else @@ -161,11 +172,6 @@ static void rna_def_world_mtex(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Zenith Down", "Affect the color of the zenith below"); RNA_def_property_update(prop, 0, "rna_World_update"); - /* unused - prop= RNA_def_property(srna, "map_mist", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mapto", WOMAP_MIST); - RNA_def_property_ui_text(prop, "Mist", "Causes the texture to affect the intensity of the mist");*/ - prop= RNA_def_property(srna, "texture_coords", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "texco"); RNA_def_property_enum_items(prop, texco_items); @@ -393,7 +399,7 @@ static void rna_def_world_mist(BlenderRNA *brna) prop= RNA_def_property(srna, "intensity", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "misi"); RNA_def_property_range(prop, 0, 1); - RNA_def_property_ui_text(prop, "Intensity", "Intensity of the mist effect"); + RNA_def_property_ui_text(prop, "Minimum", "Overall minimum intensity of the mist effect"); RNA_def_property_update(prop, 0, "rna_World_update"); prop= RNA_def_property(srna, "start", PROP_FLOAT, PROP_DISTANCE); @@ -461,13 +467,6 @@ static void rna_def_world_stars(BlenderRNA *brna) RNA_def_property_range(prop, 0, 1); RNA_def_property_ui_text(prop, "Color Randomization", "Randomize star colors"); RNA_def_property_update(prop, 0, "rna_World_stars_update"); - - /* unused - prop= RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR); - RNA_def_property_float_sdna(prop, NULL, "starr"); - RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Color", "Stars color"); - RNA_def_property_update(prop, 0, "rna_World_update");*/ } void RNA_def_world(BlenderRNA *brna) @@ -564,6 +563,17 @@ void RNA_def_world(BlenderRNA *brna) RNA_def_property_pointer_funcs(prop, "rna_World_stars_get", NULL, NULL, NULL); RNA_def_property_ui_text(prop, "Stars", "World stars settings"); + /* nodes */ + prop= RNA_def_property(srna, "node_tree", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "nodetree"); + RNA_def_property_ui_text(prop, "Node Tree", "Node tree for node based worlds"); + + prop= RNA_def_property(srna, "use_nodes", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "use_nodes", 1); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_ui_text(prop, "Use Nodes", "Use shader nodes to render the world"); + RNA_def_property_update(prop, 0, "rna_World_use_nodes_update"); + rna_def_lighting(brna); rna_def_world_mist(brna); rna_def_world_stars(brna); diff --git a/source/blender/nodes/intern/node_common.c b/source/blender/nodes/intern/node_common.c index c43c1b36a84..11dcf44a288 100644 --- a/source/blender/nodes/intern/node_common.c +++ b/source/blender/nodes/intern/node_common.c @@ -980,6 +980,7 @@ void register_node_type_frame(ListBase *lb) node_type_base(ntype, NODE_FRAME, "Frame", NODE_CLASS_LAYOUT, NODE_BACKGROUND); node_type_size(ntype, 150, 100, 0); + node_type_compatibility(ntype, NODE_OLD_SHADING|NODE_NEW_SHADING); ntype->needs_free = 1; nodeRegisterType(lb, ntype); diff --git a/source/blender/nodes/shader/node_shader_tree.c b/source/blender/nodes/shader/node_shader_tree.c index a83b32097df..d0ae17914ca 100644 --- a/source/blender/nodes/shader/node_shader_tree.c +++ b/source/blender/nodes/shader/node_shader_tree.c @@ -32,8 +32,10 @@ #include <string.h> +#include "DNA_lamp_types.h" #include "DNA_material_types.h" #include "DNA_node_types.h" +#include "DNA_world_types.h" #include "BLI_listbase.h" #include "BLI_math.h" @@ -56,11 +58,20 @@ static void foreach_nodetree(Main *main, void *calldata, bNodeTreeCallback func) { Material *ma; - for(ma= main->mat.first; ma; ma= ma->id.next) { - if(ma->nodetree) { + Lamp *la; + World *wo; + + for(ma= main->mat.first; ma; ma= ma->id.next) + if(ma->nodetree) func(calldata, &ma->id, ma->nodetree); - } - } + + for(la= main->lamp.first; la; la= la->id.next) + if(la->nodetree) + func(calldata, &la->id, la->nodetree); + + for(wo= main->world.first; wo; wo= wo->id.next) + if(wo->nodetree) + func(calldata, &wo->id, wo->nodetree); } static void local_sync(bNodeTree *localtree, bNodeTree *ntree) diff --git a/source/blender/nodes/shader/node_shader_util.c b/source/blender/nodes/shader/node_shader_util.c index 3b0211a53ee..1acb04c9b41 100644 --- a/source/blender/nodes/shader/node_shader_util.c +++ b/source/blender/nodes/shader/node_shader_util.c @@ -205,6 +205,8 @@ void node_gpu_stack_from_data(struct GPUNodeStack *gs, int type, bNodeStack *ns) gs->type= GPU_VEC3; else if (type == SOCK_RGBA) gs->type= GPU_VEC4; + else if (type == SOCK_SHADER) + gs->type= GPU_VEC4; else gs->type= GPU_NONE; diff --git a/source/blender/nodes/shader/nodes/node_shader_camera.c b/source/blender/nodes/shader/nodes/node_shader_camera.c index 15332bfa066..c7882a6e0e2 100644 --- a/source/blender/nodes/shader/nodes/node_shader_camera.c +++ b/source/blender/nodes/shader/nodes/node_shader_camera.c @@ -62,6 +62,7 @@ void register_node_type_sh_camera(ListBase *lb) static bNodeType ntype; node_type_base(&ntype, SH_NODE_CAMERA, "Camera Data", NODE_CLASS_INPUT, 0); + node_type_compatibility(&ntype, NODE_OLD_SHADING); node_type_socket_templates(&ntype, NULL, sh_node_camera_out); node_type_size(&ntype, 95, 95, 120); node_type_storage(&ntype, "node_camera", NULL, NULL); diff --git a/source/blender/nodes/shader/nodes/node_shader_curves.c b/source/blender/nodes/shader/nodes/node_shader_curves.c index 9c441e45656..7ac05bb28bf 100644 --- a/source/blender/nodes/shader/nodes/node_shader_curves.c +++ b/source/blender/nodes/shader/nodes/node_shader_curves.c @@ -74,6 +74,7 @@ void register_node_type_sh_curve_vec(ListBase *lb) static bNodeType ntype; node_type_base(&ntype, SH_NODE_CURVE_VEC, "Vector Curves", NODE_CLASS_OP_VECTOR, NODE_OPTIONS); + node_type_compatibility(&ntype, NODE_OLD_SHADING); node_type_socket_templates(&ntype, sh_node_curve_vec_in, sh_node_curve_vec_out); node_type_size(&ntype, 200, 140, 320); node_type_init(&ntype, node_shader_init_curve_vec); @@ -128,6 +129,7 @@ void register_node_type_sh_curve_rgb(ListBase *lb) static bNodeType ntype; node_type_base(&ntype, SH_NODE_CURVE_RGB, "RGB Curves", NODE_CLASS_OP_COLOR, NODE_OPTIONS); + node_type_compatibility(&ntype, NODE_OLD_SHADING); node_type_socket_templates(&ntype, sh_node_curve_rgb_in, sh_node_curve_rgb_out); node_type_size(&ntype, 200, 140, 320); node_type_init(&ntype, node_shader_init_curve_rgb); diff --git a/source/blender/nodes/shader/nodes/node_shader_dynamic.c b/source/blender/nodes/shader/nodes/node_shader_dynamic.c index d41ddecbab3..51ddb865c54 100644 --- a/source/blender/nodes/shader/nodes/node_shader_dynamic.c +++ b/source/blender/nodes/shader/nodes/node_shader_dynamic.c @@ -766,6 +766,7 @@ void register_node_type_sh_dynamic(ListBase *lb) static bNodeType ntype; node_type_base(&ntype, NODE_DYNAMIC, "Dynamic", NODE_CLASS_OP_DYNAMIC, NODE_OPTIONS, NULL, NULL); + node_type_compatibility(&ntype, NODE_OLD_SHADING); node_type_size(&ntype, 150, 60, 300); node_type_init(&ntype, node_dynamic_init_cb); node_type_storage(&ntype, "NodeScriptDict", node_dynamic_free_storage_cb, node_dynamic_copy_cb); @@ -781,6 +782,7 @@ void register_node_type_sh_dynamic(ListBase *lb) static bNodeType ntype; node_type_base(&ntype, NODE_DYNAMIC, "Dynamic", NODE_CLASS_OP_DYNAMIC, 0); + node_type_compatibility(&ntype, NODE_OLD_SHADING); nodeRegisterType(lb, &ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_geom.c b/source/blender/nodes/shader/nodes/node_shader_geom.c index 1b073f6415b..dedc25092c1 100644 --- a/source/blender/nodes/shader/nodes/node_shader_geom.c +++ b/source/blender/nodes/shader/nodes/node_shader_geom.c @@ -139,6 +139,7 @@ void register_node_type_sh_geom(ListBase *lb) static bNodeType ntype; node_type_base(&ntype, SH_NODE_GEOMETRY, "Geometry", NODE_CLASS_INPUT, NODE_OPTIONS); + node_type_compatibility(&ntype, NODE_OLD_SHADING); node_type_socket_templates(&ntype, NULL, sh_node_geom_out); node_type_size(&ntype, 120, 80, 160); node_type_init(&ntype, node_shader_init_geometry); diff --git a/source/blender/nodes/shader/nodes/node_shader_hueSatVal.c b/source/blender/nodes/shader/nodes/node_shader_hueSatVal.c index db717c48a88..7fb31d80ffc 100644 --- a/source/blender/nodes/shader/nodes/node_shader_hueSatVal.c +++ b/source/blender/nodes/shader/nodes/node_shader_hueSatVal.c @@ -85,6 +85,7 @@ void register_node_type_sh_hue_sat(ListBase *lb) static bNodeType ntype; node_type_base(&ntype, SH_NODE_HUE_SAT, "Hue Saturation Value", NODE_CLASS_OP_COLOR, NODE_OPTIONS); + node_type_compatibility(&ntype, NODE_OLD_SHADING); node_type_socket_templates(&ntype, sh_node_hue_sat_in, sh_node_hue_sat_out); node_type_size(&ntype, 150, 80, 250); node_type_exec(&ntype, node_shader_exec_hue_sat); diff --git a/source/blender/nodes/shader/nodes/node_shader_invert.c b/source/blender/nodes/shader/nodes/node_shader_invert.c index 44d26bfff4e..066ff14a870 100644 --- a/source/blender/nodes/shader/nodes/node_shader_invert.c +++ b/source/blender/nodes/shader/nodes/node_shader_invert.c @@ -77,6 +77,7 @@ void register_node_type_sh_invert(ListBase *lb) static bNodeType ntype; node_type_base(&ntype, SH_NODE_INVERT, "Invert", NODE_CLASS_OP_COLOR, NODE_OPTIONS); + node_type_compatibility(&ntype, NODE_OLD_SHADING); node_type_socket_templates(&ntype, sh_node_invert_in, sh_node_invert_out); node_type_size(&ntype, 90, 80, 100); node_type_exec(&ntype, node_shader_exec_invert); diff --git a/source/blender/nodes/shader/nodes/node_shader_mapping.c b/source/blender/nodes/shader/nodes/node_shader_mapping.c index 7ec30952ea1..862c52187dc 100644 --- a/source/blender/nodes/shader/nodes/node_shader_mapping.c +++ b/source/blender/nodes/shader/nodes/node_shader_mapping.c @@ -91,6 +91,7 @@ void register_node_type_sh_mapping(ListBase *lb) static bNodeType ntype; node_type_base(&ntype, SH_NODE_MAPPING, "Mapping", NODE_CLASS_OP_VECTOR, NODE_OPTIONS); + node_type_compatibility(&ntype, NODE_OLD_SHADING); node_type_socket_templates(&ntype, sh_node_mapping_in, sh_node_mapping_out); node_type_size(&ntype, 240, 160, 320); node_type_init(&ntype, node_shader_init_mapping); diff --git a/source/blender/nodes/shader/nodes/node_shader_material.c b/source/blender/nodes/shader/nodes/node_shader_material.c index 408b7b0ea48..f93928d8884 100644 --- a/source/blender/nodes/shader/nodes/node_shader_material.c +++ b/source/blender/nodes/shader/nodes/node_shader_material.c @@ -305,6 +305,7 @@ void register_node_type_sh_material(ListBase *lb) static bNodeType ntype; node_type_base(&ntype, SH_NODE_MATERIAL, "Material", NODE_CLASS_INPUT, NODE_OPTIONS|NODE_PREVIEW); + node_type_compatibility(&ntype, NODE_OLD_SHADING); node_type_socket_templates(&ntype, sh_node_material_in, sh_node_material_out); node_type_size(&ntype, 120, 80, 240); node_type_init(&ntype, node_shader_init_material); @@ -320,6 +321,7 @@ void register_node_type_sh_material_ext(ListBase *lb) static bNodeType ntype; node_type_base(&ntype, SH_NODE_MATERIAL_EXT, "Extended Material", NODE_CLASS_INPUT, NODE_OPTIONS|NODE_PREVIEW); + node_type_compatibility(&ntype, NODE_OLD_SHADING); node_type_socket_templates(&ntype, sh_node_material_ext_in, sh_node_material_ext_out); node_type_size(&ntype, 120, 80, 240); node_type_init(&ntype, node_shader_init_material); diff --git a/source/blender/nodes/shader/nodes/node_shader_math.c b/source/blender/nodes/shader/nodes/node_shader_math.c index 6faad500793..13ee1f79fe6 100644 --- a/source/blender/nodes/shader/nodes/node_shader_math.c +++ b/source/blender/nodes/shader/nodes/node_shader_math.c @@ -241,6 +241,7 @@ void register_node_type_sh_math(ListBase *lb) static bNodeType ntype; node_type_base(&ntype, SH_NODE_MATH, "Math", NODE_CLASS_CONVERTOR, NODE_OPTIONS); + node_type_compatibility(&ntype, NODE_OLD_SHADING); node_type_socket_templates(&ntype, sh_node_math_in, sh_node_math_out); node_type_size(&ntype, 120, 110, 160); node_type_label(&ntype, node_math_label); diff --git a/source/blender/nodes/shader/nodes/node_shader_mixRgb.c b/source/blender/nodes/shader/nodes/node_shader_mixRgb.c index 463146ec59c..7aed6bce4c4 100644 --- a/source/blender/nodes/shader/nodes/node_shader_mixRgb.c +++ b/source/blender/nodes/shader/nodes/node_shader_mixRgb.c @@ -78,6 +78,7 @@ void register_node_type_sh_mix_rgb(ListBase *lb) static bNodeType ntype; node_type_base(&ntype, SH_NODE_MIX_RGB, "Mix", NODE_CLASS_OP_COLOR, NODE_OPTIONS); + node_type_compatibility(&ntype, NODE_OLD_SHADING); node_type_socket_templates(&ntype, sh_node_mix_rgb_in, sh_node_mix_rgb_out); node_type_size(&ntype, 100, 60, 150); node_type_label(&ntype, node_blend_label); diff --git a/source/blender/nodes/shader/nodes/node_shader_normal.c b/source/blender/nodes/shader/nodes/node_shader_normal.c index 0038570c5b1..c23c6d328cf 100644 --- a/source/blender/nodes/shader/nodes/node_shader_normal.c +++ b/source/blender/nodes/shader/nodes/node_shader_normal.c @@ -84,6 +84,7 @@ void register_node_type_sh_normal(ListBase *lb) static bNodeType ntype; node_type_base(&ntype, SH_NODE_NORMAL, "Normal", NODE_CLASS_OP_VECTOR, NODE_OPTIONS); + node_type_compatibility(&ntype, NODE_OLD_SHADING); node_type_socket_templates(&ntype, sh_node_normal_in, sh_node_normal_out); node_type_init(&ntype, node_shader_init_normal); node_type_exec(&ntype, node_shader_exec_normal); diff --git a/source/blender/nodes/shader/nodes/node_shader_output.c b/source/blender/nodes/shader/nodes/node_shader_output.c index 98a23534f90..ea7fae8f961 100644 --- a/source/blender/nodes/shader/nodes/node_shader_output.c +++ b/source/blender/nodes/shader/nodes/node_shader_output.c @@ -83,6 +83,7 @@ void register_node_type_sh_output(ListBase *lb) static bNodeType ntype; node_type_base(&ntype, SH_NODE_OUTPUT, "Output", NODE_CLASS_OUTPUT, NODE_PREVIEW); + node_type_compatibility(&ntype, NODE_OLD_SHADING); node_type_socket_templates(&ntype, sh_node_output_in, NULL); node_type_size(&ntype, 80, 60, 200); node_type_exec(&ntype, node_shader_exec_output); diff --git a/source/blender/nodes/shader/nodes/node_shader_rgb.c b/source/blender/nodes/shader/nodes/node_shader_rgb.c index db2e9905a01..1a0b4ea616b 100644 --- a/source/blender/nodes/shader/nodes/node_shader_rgb.c +++ b/source/blender/nodes/shader/nodes/node_shader_rgb.c @@ -71,6 +71,7 @@ void register_node_type_sh_rgb(ListBase *lb) static bNodeType ntype; node_type_base(&ntype, SH_NODE_RGB, "RGB", NODE_CLASS_INPUT, NODE_OPTIONS); + node_type_compatibility(&ntype, NODE_OLD_SHADING); node_type_socket_templates(&ntype, NULL, sh_node_rgb_out); node_type_init(&ntype, node_shader_init_rgb); node_type_size(&ntype, 140, 80, 140); diff --git a/source/blender/nodes/shader/nodes/node_shader_sepcombRGB.c b/source/blender/nodes/shader/nodes/node_shader_sepcombRGB.c index 77d8cdf033a..4f409bb3ec1 100644 --- a/source/blender/nodes/shader/nodes/node_shader_sepcombRGB.c +++ b/source/blender/nodes/shader/nodes/node_shader_sepcombRGB.c @@ -61,6 +61,7 @@ void register_node_type_sh_seprgb(ListBase *lb) static bNodeType ntype; node_type_base(&ntype, SH_NODE_SEPRGB, "Separate RGB", NODE_CLASS_CONVERTOR, 0); + node_type_compatibility(&ntype, NODE_OLD_SHADING); node_type_socket_templates(&ntype, sh_node_seprgb_in, sh_node_seprgb_out); node_type_size(&ntype, 80, 40, 140); node_type_exec(&ntype, node_shader_exec_seprgb); @@ -100,6 +101,7 @@ void register_node_type_sh_combrgb(ListBase *lb) static bNodeType ntype; node_type_base(&ntype, SH_NODE_COMBRGB, "Combine RGB", NODE_CLASS_CONVERTOR, NODE_OPTIONS); + node_type_compatibility(&ntype, NODE_OLD_SHADING); node_type_socket_templates(&ntype, sh_node_combrgb_in, sh_node_combrgb_out); node_type_size(&ntype, 80, 40, 140); node_type_exec(&ntype, node_shader_exec_combrgb); diff --git a/source/blender/nodes/shader/nodes/node_shader_squeeze.c b/source/blender/nodes/shader/nodes/node_shader_squeeze.c index ec2c1860597..16a9ae8aedc 100644 --- a/source/blender/nodes/shader/nodes/node_shader_squeeze.c +++ b/source/blender/nodes/shader/nodes/node_shader_squeeze.c @@ -67,6 +67,7 @@ void register_node_type_sh_squeeze(ListBase *lb) static bNodeType ntype; node_type_base(&ntype, SH_NODE_SQUEEZE, "Squeeze Value", NODE_CLASS_CONVERTOR, NODE_OPTIONS); + node_type_compatibility(&ntype, NODE_OLD_SHADING); node_type_socket_templates(&ntype, sh_node_squeeze_in, sh_node_squeeze_out); node_type_size(&ntype, 120, 110, 160); node_type_storage(&ntype, "node_squeeze", NULL, NULL); diff --git a/source/blender/nodes/shader/nodes/node_shader_texture.c b/source/blender/nodes/shader/nodes/node_shader_texture.c index 199af9a69a9..588cdc1da83 100644 --- a/source/blender/nodes/shader/nodes/node_shader_texture.c +++ b/source/blender/nodes/shader/nodes/node_shader_texture.c @@ -136,6 +136,7 @@ void register_node_type_sh_texture(ListBase *lb) static bNodeType ntype; node_type_base(&ntype, SH_NODE_TEXTURE, "Texture", NODE_CLASS_INPUT, NODE_OPTIONS|NODE_PREVIEW); + node_type_compatibility(&ntype, NODE_OLD_SHADING); node_type_socket_templates(&ntype, sh_node_texture_in, sh_node_texture_out); node_type_size(&ntype, 120, 80, 240); node_type_exec(&ntype, node_shader_exec_texture); diff --git a/source/blender/nodes/shader/nodes/node_shader_valToRgb.c b/source/blender/nodes/shader/nodes/node_shader_valToRgb.c index bc418a7c416..4d41e62b242 100644 --- a/source/blender/nodes/shader/nodes/node_shader_valToRgb.c +++ b/source/blender/nodes/shader/nodes/node_shader_valToRgb.c @@ -76,6 +76,7 @@ void register_node_type_sh_valtorgb(ListBase *lb) static bNodeType ntype; node_type_base(&ntype, SH_NODE_VALTORGB, "ColorRamp", NODE_CLASS_CONVERTOR, NODE_OPTIONS); + node_type_compatibility(&ntype, NODE_OLD_SHADING); node_type_socket_templates(&ntype, sh_node_valtorgb_in, sh_node_valtorgb_out); node_type_size(&ntype, 240, 200, 300); node_type_init(&ntype, node_shader_init_valtorgb); @@ -116,6 +117,7 @@ void register_node_type_sh_rgbtobw(ListBase *lb) static bNodeType ntype; node_type_base(&ntype, SH_NODE_RGBTOBW, "RGB to BW", NODE_CLASS_CONVERTOR, 0); + node_type_compatibility(&ntype, NODE_OLD_SHADING); node_type_socket_templates(&ntype, sh_node_rgbtobw_in, sh_node_rgbtobw_out); node_type_size(&ntype, 80, 40, 120); node_type_exec(&ntype, node_shader_exec_rgbtobw); diff --git a/source/blender/nodes/shader/nodes/node_shader_value.c b/source/blender/nodes/shader/nodes/node_shader_value.c index 95ee54e225d..4a8aa6c9cf4 100644 --- a/source/blender/nodes/shader/nodes/node_shader_value.c +++ b/source/blender/nodes/shader/nodes/node_shader_value.c @@ -71,6 +71,7 @@ void register_node_type_sh_value(ListBase *lb) static bNodeType ntype; node_type_base(&ntype, SH_NODE_VALUE, "Value", NODE_CLASS_INPUT, NODE_OPTIONS); + node_type_compatibility(&ntype, NODE_OLD_SHADING); node_type_socket_templates(&ntype, NULL, sh_node_value_out); node_type_init(&ntype, node_shader_init_value); node_type_size(&ntype, 80, 50, 120); diff --git a/source/blender/nodes/shader/nodes/node_shader_vectMath.c b/source/blender/nodes/shader/nodes/node_shader_vectMath.c index 4282b40cb4d..b3f995dcdce 100644 --- a/source/blender/nodes/shader/nodes/node_shader_vectMath.c +++ b/source/blender/nodes/shader/nodes/node_shader_vectMath.c @@ -135,6 +135,7 @@ void register_node_type_sh_vect_math(ListBase *lb) static bNodeType ntype; node_type_base(&ntype, SH_NODE_VECT_MATH, "Vector Math", NODE_CLASS_CONVERTOR, NODE_OPTIONS); + node_type_compatibility(&ntype, NODE_OLD_SHADING); node_type_socket_templates(&ntype, sh_node_vect_math_in, sh_node_vect_math_out); node_type_size(&ntype, 80, 75, 140); node_type_label(&ntype, node_vect_math_label); diff --git a/source/blender/python/intern/bpy_app_handlers.c b/source/blender/python/intern/bpy_app_handlers.c index 7008aeda074..e7f74569f1a 100644 --- a/source/blender/python/intern/bpy_app_handlers.c +++ b/source/blender/python/intern/bpy_app_handlers.c @@ -47,6 +47,8 @@ static PyStructSequence_Field app_cb_info_fields[]= { {(char *)"load_post", NULL}, {(char *)"save_pre", NULL}, {(char *)"save_post", NULL}, + {(char *)"scene_update_pre", NULL}, + {(char *)"scene_update_post", NULL}, {NULL} }; diff --git a/source/blender/python/mathutils/mathutils_Quaternion.c b/source/blender/python/mathutils/mathutils_Quaternion.c index 7eb39509e6b..f892c25f67e 100644 --- a/source/blender/python/mathutils/mathutils_Quaternion.c +++ b/source/blender/python/mathutils/mathutils_Quaternion.c @@ -39,6 +39,7 @@ #define QUAT_SIZE 4 static PyObject *quat__apply_to_copy(PyNoArgsFunction quat_func, QuaternionObject *self); +static void quat__axis_angle_sanitize(float axis[3], float *angle); static PyObject *Quaternion_copy(QuaternionObject *self); //-----------------------------METHODS------------------------------ @@ -141,6 +142,39 @@ static PyObject *Quaternion_to_matrix(QuaternionObject *self) return newMatrixObject(mat, 3, 3, Py_NEW, NULL); } +//----------------------------Quaternion.toMatrix()------------------ +PyDoc_STRVAR(Quaternion_to_axis_angle_doc, +".. method:: to_axis_angle()\n" +"\n" +" Return the axis, angle representation of the quaternion.\n" +"\n" +" :return: axis, angle.\n" +" :rtype: (:class:`Vector`, float) pair\n" +); +static PyObject *Quaternion_to_axis_angle(QuaternionObject *self) +{ + PyObject *ret; + + float tquat[4]; + + float axis[3]; + float angle; + + if (BaseMath_ReadCallback(self) == -1) + return NULL; + + normalize_qt_qt(tquat, self->quat); + quat_to_axis_angle(axis, &angle, tquat); + + quat__axis_angle_sanitize(axis, &angle); + + ret= PyTuple_New(2); + PyTuple_SET_ITEM(ret, 0, newVectorObject(axis, 3, Py_NEW, NULL)); + PyTuple_SET_ITEM(ret, 1, PyFloat_FromDouble(angle)); + return ret; +} + + //----------------------------Quaternion.cross(other)------------------ PyDoc_STRVAR(Quaternion_cross_doc, ".. method:: cross(other)\n" @@ -881,12 +915,18 @@ static PyObject *Quaternion_getMagnitude(QuaternionObject *self, void *UNUSED(cl static PyObject *Quaternion_getAngle(QuaternionObject *self, void *UNUSED(closure)) { float tquat[4]; + float angle; if (BaseMath_ReadCallback(self) == -1) return NULL; normalize_qt_qt(tquat, self->quat); - return PyFloat_FromDouble(2.0f * (saacos(tquat[0]))); + + angle= 2.0f * saacos(tquat[0]); + + quat__axis_angle_sanitize(NULL, &angle); + + return PyFloat_FromDouble(angle); } static int Quaternion_setAngle(QuaternionObject *self, PyObject *value, void *UNUSED(closure)) @@ -895,7 +935,7 @@ static int Quaternion_setAngle(QuaternionObject *self, PyObject *value, void *UN float len; float axis[3], angle_dummy; - double angle; + float angle; if (BaseMath_ReadCallback(self) == -1) return -1; @@ -913,13 +953,7 @@ static int Quaternion_setAngle(QuaternionObject *self, PyObject *value, void *UN angle= angle_wrap_rad(angle); - /* If the axis of rotation is 0,0,0 set it to 1,0,0 - for zero-degree rotations */ - if ( EXPP_FloatsAreEqual(axis[0], 0.0f, 10) && - EXPP_FloatsAreEqual(axis[1], 0.0f, 10) && - EXPP_FloatsAreEqual(axis[2], 0.0f, 10) - ) { - axis[0] = 1.0f; - } + quat__axis_angle_sanitize(axis, &angle); axis_angle_to_quat(self->quat, axis, angle); mul_qt_fl(self->quat, len); @@ -935,21 +969,15 @@ static PyObject *Quaternion_getAxisVec(QuaternionObject *self, void *UNUSED(clos float tquat[4]; float axis[3]; - float angle; + float angle_dummy; if (BaseMath_ReadCallback(self) == -1) return NULL; normalize_qt_qt(tquat, self->quat); - quat_to_axis_angle(axis, &angle, tquat); + quat_to_axis_angle(axis, &angle_dummy, tquat); - /* If the axis of rotation is 0,0,0 set it to 1,0,0 - for zero-degree rotations */ - if ( EXPP_FloatsAreEqual(axis[0], 0.0f, 10) && - EXPP_FloatsAreEqual(axis[1], 0.0f, 10) && - EXPP_FloatsAreEqual(axis[2], 0.0f, 10) - ) { - axis[0] = 1.0f; - } + quat__axis_angle_sanitize(axis, NULL); return (PyObject *) newVectorObject(axis, 3, Py_NEW, NULL); } @@ -971,6 +999,8 @@ static int Quaternion_setAxisVec(QuaternionObject *self, PyObject *value, void * if (mathutils_array_parse(axis, 3, 3, value, "quat.axis = other") == -1) return -1; + quat__axis_angle_sanitize(axis, &angle); + axis_angle_to_quat(self->quat, axis, angle); mul_qt_fl(self->quat, len); @@ -1029,6 +1059,33 @@ static PyObject *quat__apply_to_copy(PyNoArgsFunction quat_func, QuaternionObjec } } +/* axis vector suffers from precission errors, use this function to ensure */ +static void quat__axis_angle_sanitize(float axis[3], float *angle) +{ + if (axis) { + if ( !finite(axis[0]) || + !finite(axis[1]) || + !finite(axis[2])) + { + axis[0]= 1.0f; + axis[1]= 0.0f; + axis[2]= 0.0f; + } + else if ( EXPP_FloatsAreEqual(axis[0], 0.0f, 10) && + EXPP_FloatsAreEqual(axis[1], 0.0f, 10) && + EXPP_FloatsAreEqual(axis[2], 0.0f, 10) + ) { + axis[0] = 1.0f; + } + } + + if (angle) { + if (!finite(*angle)) { + *angle= 0.0f; + } + } +} + //-----------------------METHOD DEFINITIONS ---------------------- static struct PyMethodDef Quaternion_methods[] = { /* in place only */ @@ -1048,6 +1105,7 @@ static struct PyMethodDef Quaternion_methods[] = { /* return converted representation */ {"to_euler", (PyCFunction) Quaternion_to_euler, METH_VARARGS, Quaternion_to_euler_doc}, {"to_matrix", (PyCFunction) Quaternion_to_matrix, METH_NOARGS, Quaternion_to_matrix_doc}, + {"to_axis_angle", (PyCFunction) Quaternion_to_axis_angle, METH_NOARGS, Quaternion_to_axis_angle_doc}, /* operation between 2 or more types */ {"cross", (PyCFunction) Quaternion_cross, METH_O, Quaternion_cross_doc}, diff --git a/source/blender/render/extern/include/RE_engine.h b/source/blender/render/extern/include/RE_engine.h index 1326ed495ec..e521479bbcd 100644 --- a/source/blender/render/extern/include/RE_engine.h +++ b/source/blender/render/extern/include/RE_engine.h @@ -46,10 +46,18 @@ struct Scene; /* External Engine */ +/* RenderEngineType.flag */ #define RE_INTERNAL 1 #define RE_GAME 2 #define RE_USE_PREVIEW 4 #define RE_USE_POSTPROCESS 8 +#define RE_USE_SHADING_NODES 16 + +/* RenderEngine.flag */ +#define RE_ENGINE_ANIMATION 1 +#define RE_ENGINE_PREVIEW 2 +#define RE_ENGINE_DO_DRAW 4 +#define RE_ENGINE_DO_UPDATE 8 extern ListBase R_engines; @@ -61,17 +69,25 @@ typedef struct RenderEngineType { char name[64]; int flag; + void (*update)(struct RenderEngine *engine, struct Main *bmain, struct Scene *scene); void (*render)(struct RenderEngine *engine, struct Scene *scene); + void (*view_update)(struct RenderEngine *engine, const struct bContext *context); + void (*view_draw)(struct RenderEngine *engine, const struct bContext *context); + /* RNA integration */ ExtensionRNA ext; } RenderEngineType; typedef struct RenderEngine { RenderEngineType *type; + void *py_instance; + + int flag; struct Render *re; ListBase fullresult; + char *text; } RenderEngine; RenderEngine *RE_engine_create(RenderEngineType *type); diff --git a/source/blender/render/intern/include/render_types.h b/source/blender/render/intern/include/render_types.h index aa2dd29814e..ae4e55b9b88 100644 --- a/source/blender/render/intern/include/render_types.h +++ b/source/blender/render/intern/include/render_types.h @@ -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 diff --git a/source/blender/render/intern/source/external_engine.c b/source/blender/render/intern/source/external_engine.c index a4d1e502f13..b37da67f743 100644 --- a/source/blender/render/intern/source/external_engine.c +++ b/source/blender/render/intern/source/external_engine.c @@ -61,7 +61,7 @@ static RenderEngineType internal_render_type = { NULL, NULL, "BLENDER_RENDER", "Blender Render", RE_INTERNAL, - NULL, + NULL, NULL, NULL, NULL, {NULL, NULL, NULL}}; #ifdef WITH_GAMEENGINE @@ -69,7 +69,7 @@ static RenderEngineType internal_render_type = { static RenderEngineType internal_game_type = { NULL, NULL, "BLENDER_GAME", "Blender Game", RE_INTERNAL|RE_GAME, - NULL, + NULL, NULL, NULL, NULL, {NULL, NULL, NULL}}; #endif @@ -125,6 +125,15 @@ RenderEngine *RE_engine_create(RenderEngineType *type) void RE_engine_free(RenderEngine *engine) { +#ifdef WITH_PYTHON + if(engine->py_instance) { + BPY_DECREF(engine->py_instance); + } +#endif + + if(engine->text) + MEM_freeN(engine->text); + MEM_freeN(engine); } @@ -216,6 +225,19 @@ void RE_engine_update_stats(RenderEngine *engine, const char *stats, const char re->i.infostr= NULL; re->i.statstr= NULL; } + + /* set engine text */ + if(engine->text) { + MEM_freeN(engine->text); + engine->text= NULL; + } + + if(stats && stats[0] && info && info[0]) + engine->text= BLI_sprintfN("%s | %s", stats, info); + else if(info && info[0]) + engine->text= BLI_strdup(info); + else if(stats && stats[0]) + engine->text= BLI_strdup(stats); } void RE_engine_update_progress(RenderEngine *engine, float progress) @@ -265,11 +287,18 @@ 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); - type->render(engine, re->scene); - + if(type->update) + type->update(engine, re->main, re->scene); + if(type->render) + type->render(engine, re->scene); free_render_result(&engine->fullresult, engine->fullresult.first); diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 64b36c1fd12..8d72be1684c 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -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; } diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index 8261198ef78..389049d9e59 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -55,6 +55,8 @@ #include "GPU_draw.h" #include "GPU_extensions.h" +#include "RE_engine.h" + #include "WM_api.h" #include "WM_types.h" #include "wm.h" @@ -113,6 +115,19 @@ static int wm_area_test_invalid_backbuf(ScrArea *sa) return 1; } +static void wm_region_test_render_do_draw(ScrArea *sa, ARegion *ar) +{ + if(sa->spacetype == SPACE_VIEW3D) { + RegionView3D *rv3d = ar->regiondata; + RenderEngine *engine = (rv3d)? rv3d->render_engine: NULL; + + if(engine && (engine->flag & RE_ENGINE_DO_DRAW)) { + ar->do_draw = 1; + engine->flag &= ~RE_ENGINE_DO_DRAW; + } + } +} + /********************** draw all **************************/ /* - reference method, draw all each time */ @@ -205,7 +220,7 @@ static void wm_method_draw_overlap_all(bContext *C, wmWindow *win, int exchange) for(sa= screen->areabase.first; sa; sa= sa->next) for(ar= sa->regionbase.first; ar; ar= ar->next) if(ar->swinid && !wm_area_test_invalid_backbuf(sa)) - ED_region_tag_redraw(ar); + ED_region_tag_redraw(ar); /* flush overlapping regions */ if(screen->regionbase.first) { @@ -662,13 +677,28 @@ static int wm_draw_update_test_window(wmWindow *win) { ScrArea *sa; ARegion *ar; + int do_draw= 0; for(ar= win->screen->regionbase.first; ar; ar= ar->next) { if(ar->do_draw_overlay) { wm_tag_redraw_overlay(win, ar); ar->do_draw_overlay= 0; } + if(ar->swinid && ar->do_draw) + do_draw= 1; + } + + for(sa= win->screen->areabase.first; sa; sa= sa->next) { + for(ar=sa->regionbase.first; ar; ar= ar->next) { + wm_region_test_render_do_draw(sa, ar); + + if(ar->swinid && ar->do_draw) + do_draw = 1; + } } + + if(do_draw) + return 1; if(win->screen->do_refresh) return 1; @@ -681,15 +711,6 @@ static int wm_draw_update_test_window(wmWindow *win) if(win->screen->do_draw_drag) return 1; - for(ar= win->screen->regionbase.first; ar; ar= ar->next) - if(ar->swinid && ar->do_draw) - return 1; - - for(sa= win->screen->areabase.first; sa; sa= sa->next) - for(ar=sa->regionbase.first; ar; ar= ar->next) - if(ar->swinid && ar->do_draw) - return 1; - return 0; } diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 65e65450167..03b0d637de1 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -59,6 +59,7 @@ #include "ED_fileselect.h" #include "ED_info.h" +#include "ED_render.h" #include "ED_screen.h" #include "ED_view3d.h" #include "ED_util.h" @@ -311,6 +312,7 @@ void wm_event_do_notifiers(bContext *C) /* XXX make lock in future, or separated derivedmesh users in scene */ if(!G.rendering) { /* depsgraph & animation: update tagged datablocks */ + Main *bmain = CTX_data_main(C); /* copied to set's in scene_update_tagged_recursive() */ win->screen->scene->customdata_mask= win_combine_v3d_datamask; @@ -318,7 +320,11 @@ void wm_event_do_notifiers(bContext *C) /* XXX, hack so operators can enforce datamasks [#26482], gl render */ win->screen->scene->customdata_mask |= win->screen->scene->customdata_mask_modal; - scene_update_tagged(CTX_data_main(C), win->screen->scene); + scene_update_tagged(bmain, win->screen->scene); + + ED_render_engine_update_tagged(C, bmain); + + scene_clear_tagged(bmain, win->screen->scene); } } diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c index 94dc6a93cc4..d184abfea09 100644 --- a/source/blenderplayer/bad_level_call_stubs/stubs.c +++ b/source/blenderplayer/bad_level_call_stubs/stubs.c @@ -72,6 +72,7 @@ struct Object; struct PBVHNode; struct Render; struct RenderEngine; +struct RenderEngineType; struct RenderLayer; struct RenderResult; struct ScrArea; @@ -213,6 +214,7 @@ struct ImBuf *ED_space_image_buffer(struct SpaceImage *sima){return (struct ImBu void ED_screen_set_scene(struct bContext *C, struct Scene *scene){} void ED_area_tag_redraw_regiontype(struct ScrArea *sa, int regiontype){} +void ED_render_engine_changed(struct Main *bmain) {} struct PTCacheEdit *PE_get_current(struct Scene *scene, struct Object *ob){return (struct PTCacheEdit *) NULL;} void PE_current_changed(struct Scene *scene, struct Object *ob){} @@ -406,6 +408,7 @@ void RE_engines_exit() {} void RE_engine_report(struct RenderEngine *engine, int type, const char *msg) {} ListBase R_engines = {NULL, NULL}; void RE_engine_free(struct RenderEngine *engine) {} +struct RenderEngineType *RE_engines_find(const char *idname) {} /* python */ struct wmOperatorType *WM_operatortype_find(const char *idname, int quiet){return (struct wmOperatorType *) NULL;} |