diff options
author | Ton Roosendaal <ton@blender.org> | 2018-04-19 18:34:44 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-04-19 18:35:25 +0300 |
commit | 51b796ff1528c52cc8b4079fab1003671652a4d9 (patch) | |
tree | 0dfc2d2dabe5e77959264f5b6667897569290a41 /source/blender/editors/space_buttons | |
parent | 785e8a636a293941a4295e669cb5aeecfafae039 (diff) |
Remove Blender Internal and legacy viewport from Blender 2.8.
Brecht authored this commit, but he gave me the honours to actually
do it. Here it goes; Blender Internal. Bye bye, you did great!
* Point density, voxel data, ocean, environment map textures were removed,
as these only worked within BI rendering. Note that the ocean modifier
and the Cycles point density shader node continue to work.
* Dynamic paint using material shading was removed, as this only worked
with BI. If we ever wanted to support this again probably it should go
through the baking API.
* GPU shader export through the Python API was removed. This only worked
for the old BI GLSL shaders, which no longer exists. Doing something
similar for Eevee would be significantly more complicated because it
uses a lot of multiplass rendering and logic outside the shader, it's
probably impractical.
* Collada material import / export code is mostly gone, as it only worked
for BI materials. We need to add Cycles / Eevee material support at some
point.
* The mesh noise operator was removed since it only worked with BI
material texture slots. A displacement modifier can be used instead.
* The delete texture paint slot operator was removed since it only worked
for BI material texture slots. Could be added back with node support.
* Not all legacy viewport features are supported in the new viewport, but
their code was removed. If we need to bring anything back we can look at
older git revisions.
* There is some legacy viewport code that I could not remove yet, and some
that I probably missed.
* Shader node execution code was left mostly intact, even though it is not
used anywhere now. We may eventually use this to replace the texture
nodes with Cycles / Eevee shader nodes.
* The Cycles Bake panel now includes settings for baking multires normal
and displacement maps. The underlying code needs to be merged properly,
and we plan to add back support for multires AO baking and add support
to Cycles baking for features like vertex color, displacement, and other
missing baking features.
* This commit removes DNA and the Python API for BI material, lamp, world
and scene settings. This breaks a lot of addons.
* There is more DNA that can be removed or renamed, where Cycles or Eevee
are reusing some old BI properties but the names are not really correct
anymore.
* Texture slots for materials, lamps and world were removed. They remain
for brushes, particles and freestyle linestyles.
* 'BLENDER_RENDER' remains in the COMPAT_ENGINES of UI panels. Cycles and
other renderers use this to find all panels to show, minus a few panels
that they have their own replacement for.
Diffstat (limited to 'source/blender/editors/space_buttons')
3 files changed, 29 insertions, 394 deletions
diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index 8866c6b6c40..b7ba8b5e065 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -279,7 +279,7 @@ static int buttons_context_path_modifier(ButsContextPath *path) return 0; } -static int buttons_context_path_material(ButsContextPath *path, bool for_texture, bool new_shading) +static int buttons_context_path_material(ButsContextPath *path) { Object *ob; PointerRNA *ptr = &path->ptr[path->len - 1]; @@ -297,18 +297,6 @@ static int buttons_context_path_material(ButsContextPath *path, bool for_texture ma = give_current_material(ob, ob->actcol); RNA_id_pointer_create(&ma->id, &path->ptr[path->len]); path->len++; - - if (for_texture && give_current_material_texture_node(ma)) - return 1; - - if (!new_shading) { - /* Only try to get mat from node in case of old shading system (see T40331). */ - ma = give_node_material(ma); - if (ma) { - RNA_id_pointer_create(&ma->id, &path->ptr[path->len]); - path->len++; - } - } return 1; } } @@ -441,132 +429,38 @@ static int buttons_context_path_brush(const bContext *C, ButsContextPath *path) static int buttons_context_path_texture(const bContext *C, ButsContextPath *path, ButsContextTexture *ct) { - if (ct) { - /* new shading system */ - PointerRNA *ptr = &path->ptr[path->len - 1]; - ID *id; - - /* if we already have a (pinned) texture, we're done */ - if (RNA_struct_is_a(ptr->type, &RNA_Texture)) - return 1; - - if (!ct->user) - return 0; - - id = ct->user->id; - - if (id) { - if (GS(id->name) == ID_BR) - buttons_context_path_brush(C, path); - else if (GS(id->name) == ID_MA) - buttons_context_path_material(path, false, true); - else if (GS(id->name) == ID_WO) - buttons_context_path_world(path); - else if (GS(id->name) == ID_LA) - buttons_context_path_data(path, OB_LAMP); - else if (GS(id->name) == ID_PA) - buttons_context_path_particle(path); - else if (GS(id->name) == ID_OB) - buttons_context_path_object(path); - else if (GS(id->name) == ID_LS) - buttons_context_path_linestyle(path); - } + PointerRNA *ptr = &path->ptr[path->len - 1]; + ID *id; - if (ct->texture) { - RNA_id_pointer_create(&ct->texture->id, &path->ptr[path->len]); - path->len++; - } + if (!ct) + return 0; + /* if we already have a (pinned) texture, we're done */ + if (RNA_struct_is_a(ptr->type, &RNA_Texture)) return 1; - } - else { - /* old shading system */ - Material *ma; - Lamp *la; - World *wo; - ParticleSystem *psys; - FreestyleLineStyle *ls; - Tex *tex; - PointerRNA *ptr = &path->ptr[path->len - 1]; - - /* if we already have a (pinned) texture, we're done */ - if (RNA_struct_is_a(ptr->type, &RNA_Texture)) { - return 1; - } - /* try world */ - else if ((path->tex_ctx == SB_TEXC_WORLD) && buttons_context_path_world(path)) { - wo = path->ptr[path->len - 1].data; - - if (wo && GS(wo->id.name) == ID_WO) { - tex = give_current_world_texture(wo); - - RNA_id_pointer_create(&tex->id, &path->ptr[path->len]); - path->len++; - return 1; - } - } - /* try particles */ - else if ((path->tex_ctx == SB_TEXC_PARTICLES) && buttons_context_path_particle(path)) { - if (path->ptr[path->len - 1].type == &RNA_ParticleSettings) { - ParticleSettings *part = path->ptr[path->len - 1].data; - - tex = give_current_particle_texture(part); - RNA_id_pointer_create(&tex->id, &path->ptr[path->len]); - path->len++; - return 1; - } - else { - psys = path->ptr[path->len - 1].data; - - if (psys && psys->part && GS(psys->part->id.name) == ID_PA) { - tex = give_current_particle_texture(psys->part); - - RNA_id_pointer_create(&tex->id, &path->ptr[path->len]); - path->len++; - return 1; - } - } - } - /* try material */ - else if ((path->tex_ctx == SB_TEXC_MATERIAL) && buttons_context_path_material(path, true, false)) { - ma = path->ptr[path->len - 1].data; - - if (ma) { - tex = give_current_material_texture(ma); - RNA_id_pointer_create(&tex->id, &path->ptr[path->len]); - path->len++; - return 1; - } - } - /* try lamp */ - else if ((path->tex_ctx == SB_TEXC_LAMP) && buttons_context_path_data(path, OB_LAMP)) { - la = path->ptr[path->len - 1].data; - - if (la) { - tex = give_current_lamp_texture(la); - - RNA_id_pointer_create(&tex->id, &path->ptr[path->len]); - path->len++; - return 1; - } - } - /* try linestyle */ - else if ((path->tex_ctx == SB_TEXC_LINESTYLE) && buttons_context_path_linestyle(path)) { - ls = path->ptr[path->len - 1].data; + if (!ct->user) + return 0; + + id = ct->user->id; - if (ls) { - tex = give_current_linestyle_texture(ls); + if (id) { + if (GS(id->name) == ID_BR) + buttons_context_path_brush(C, path); + else if (GS(id->name) == ID_PA) + buttons_context_path_particle(path); + else if (GS(id->name) == ID_OB) + buttons_context_path_object(path); + else if (GS(id->name) == ID_LS) + buttons_context_path_linestyle(path); + } - RNA_id_pointer_create(&tex->id, &path->ptr[path->len]); - path->len++; - return 1; - } - } + if (ct->texture) { + RNA_id_pointer_create(&ct->texture->id, &path->ptr[path->len]); + path->len++; } - /* no path to a texture possible */ - return 0; + return 1; } #ifdef WITH_FREESTYLE @@ -606,7 +500,6 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma memset(path, 0, sizeof(*path)); path->flag = flag; - path->tex_ctx = sbuts->texture_context; const bool use_scene_settings = BKE_workspace_use_scene_settings_get(workspace); @@ -679,7 +572,7 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma found = buttons_context_path_particle(path); break; case BCONTEXT_MATERIAL: - found = buttons_context_path_material(path, false, (sbuts->texuser != NULL)); + found = buttons_context_path_material(path); break; case BCONTEXT_TEXTURE: found = buttons_context_path_texture(C, path, sbuts->texuser); @@ -737,7 +630,7 @@ void buttons_context_compute(const bContext *C, SpaceButs *sbuts) path = sbuts->path; - /* We need to set Scene path now! Else, buttons_texture_context_compute() might not get a valid scene. */ + /* Set scene path. */ buttons_context_path(C, path, BCONTEXT_SCENE, pflag); buttons_texture_context_compute(C, sbuts); @@ -890,13 +783,8 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r ButsContextTexture *ct = sbuts->texuser; if (ct) { - /* new shading system */ CTX_data_pointer_set(result, &ct->texture->id, &RNA_Texture, ct->texture); } - else { - /* old shading system */ - set_pointer_type(path, result, &RNA_Texture); - } return 1; } @@ -920,7 +808,7 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r ButsContextTexture *ct = sbuts->texuser; if (!ct) - return -1; /* old shading system (found but not available) */ + return -1; if (ct->user && ct->user->ptr.data) { ButsTextureUser *user = ct->user; @@ -933,7 +821,7 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r ButsContextTexture *ct = sbuts->texuser; if (!ct) - return -1; /* old shading system (found but not available) */ + return -1; if (ct->user && ct->user->ptr.data) { ButsTextureUser *user = ct->user; @@ -953,21 +841,6 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r return 1; } - else { - /* old shading system */ - PointerRNA *ptr; - - if ((ptr = get_pointer_type(path, &RNA_Material))) { - Material *ma = ptr->data; - - if (ma) { - bNode *node = give_current_material_texture_node(ma); - CTX_data_pointer_set(result, &ma->nodetree->id, &RNA_Node, node); - } - } - - return 1; - } } else if (CTX_data_equals(member, "texture_slot")) { ButsContextTexture *ct = sbuts->texuser; @@ -983,38 +856,6 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r else if (ct) { return 0; /* new shading system */ } - else if ((ptr = get_pointer_type(path, &RNA_Material))) { - Material *ma = ptr->data; - - /* if we have a node material, get slot from material in material node */ - if (ma && ma->use_nodes && ma->nodetree) { - /* if there's an active texture node in the node tree, - * then that texture is in context directly, without a texture slot */ - if (give_current_material_texture_node(ma)) - return 0; - - ma = give_node_material(ma); - if (ma) - CTX_data_pointer_set(result, &ma->id, &RNA_MaterialTextureSlot, ma->mtex[(int)ma->texact]); - else - return 0; - } - else if (ma) { - CTX_data_pointer_set(result, &ma->id, &RNA_MaterialTextureSlot, ma->mtex[(int)ma->texact]); - } - } - else if ((ptr = get_pointer_type(path, &RNA_Lamp))) { - Lamp *la = ptr->data; - - if (la) - CTX_data_pointer_set(result, &la->id, &RNA_LampTextureSlot, la->mtex[(int)la->texact]); - } - else if ((ptr = get_pointer_type(path, &RNA_World))) { - World *wo = ptr->data; - - if (wo) - CTX_data_pointer_set(result, &wo->id, &RNA_WorldTextureSlot, wo->mtex[(int)wo->texact]); - } else if ((ptr = get_pointer_type(path, &RNA_FreestyleLineStyle))) { FreestyleLineStyle *ls = ptr->data; diff --git a/source/blender/editors/space_buttons/buttons_intern.h b/source/blender/editors/space_buttons/buttons_intern.h index e6d19caad47..84c935dd737 100644 --- a/source/blender/editors/space_buttons/buttons_intern.h +++ b/source/blender/editors/space_buttons/buttons_intern.h @@ -64,7 +64,6 @@ typedef struct ButsContextPath { PointerRNA ptr[8]; int len; int flag; - int tex_ctx; int collection_ctx; } ButsContextPath; diff --git a/source/blender/editors/space_buttons/buttons_texture.c b/source/blender/editors/space_buttons/buttons_texture.c index 809480baece..df06eee3fd5 100644 --- a/source/blender/editors/space_buttons/buttons_texture.c +++ b/source/blender/editors/space_buttons/buttons_texture.c @@ -41,8 +41,6 @@ #include "DNA_brush_types.h" #include "DNA_ID.h" -#include "DNA_lamp_types.h" -#include "DNA_material_types.h" #include "DNA_node_types.h" #include "DNA_object_types.h" #include "DNA_object_force_types.h" @@ -50,13 +48,11 @@ #include "DNA_scene_types.h" #include "DNA_screen_types.h" #include "DNA_space_types.h" -#include "DNA_world_types.h" #include "DNA_linestyle_types.h" #include "BKE_context.h" #include "BKE_layer.h" #include "BKE_linestyle.h" -#include "BKE_material.h" #include "BKE_modifier.h" #include "BKE_node.h" #include "BKE_paint.h" @@ -79,172 +75,6 @@ #include "buttons_intern.h" // own include -/****************** "Old Shading" Texture Context ****************/ - -bool ED_texture_context_check_world(const bContext *C) -{ - Scene *scene = CTX_data_scene(C); - return (scene && scene->world); -} - -bool ED_texture_context_check_material(const bContext *C) -{ - Object *ob = CTX_data_active_object(C); - return (ob && (ob->totcol != 0)); -} - -bool ED_texture_context_check_lamp(const bContext *C) -{ - Object *ob = CTX_data_active_object(C); - return (ob && (ob->type == OB_LAMP)); -} - -bool ED_texture_context_check_particles(const bContext *C) -{ - Object *ob = CTX_data_active_object(C); - return (ob && ob->particlesystem.first); -} - -bool ED_texture_context_check_linestyle(const bContext *C) -{ -#ifdef WITH_FREESTYLE - Scene *scene = CTX_data_scene(C); - ViewLayer *active_view_layer; - FreestyleConfig *config; - FreestyleLineSet *lineset; - FreestyleLineStyle *linestyle; - - if (scene && (scene->r.mode & R_EDGE_FRS)) { - active_view_layer = BLI_findlink(&scene->view_layers, scene->active_view_layer); - config = &active_view_layer->freestyle_config; - if (config->mode == FREESTYLE_CONTROL_EDITOR_MODE) { - lineset = BKE_freestyle_lineset_get_active(config); - if (lineset) { - linestyle = lineset->linestyle; - return linestyle && (linestyle->flag & LS_TEXTURE); - } - } - } -#else - (void)C; -#endif - return false; -} - -static void texture_context_check_modifier_foreach(void *userData, Object *UNUSED(ob), ModifierData *UNUSED(md), - const char *UNUSED(propname)) -{ - *((bool *)userData) = true; -} - -bool ED_texture_context_check_others(const bContext *C) -{ - /* We cannot rely on sbuts->texuser here, as it is NULL when in "old" tex handling, non-OTHERS tex context. */ - Object *ob = CTX_data_active_object(C); - - /* object */ - if (ob) { - /* Tex force field. */ - if (ob->pd && ob->pd->forcefield == PFIELD_TEXTURE) { - return true; - } - - /* modifiers */ - { - bool check = false; - modifiers_foreachTexLink(ob, texture_context_check_modifier_foreach, &check); - if (check) { - return true; - } - } - } - - /* brush */ - if (BKE_paint_brush(BKE_paint_get_active_from_context(C))) { - return true; - } - - return false; -} - -static void set_texture_context(const bContext *C, SpaceButs *sbuts) -{ - Scene *scene = CTX_data_scene(C); - - if (BKE_scene_use_new_shading_nodes(scene)) { - return; /* No texture context in new shading mode */ - } - - { - bool valid_world = ED_texture_context_check_world(C); - bool valid_material = ED_texture_context_check_material(C); - bool valid_lamp = ED_texture_context_check_lamp(C); - bool valid_particles = ED_texture_context_check_particles(C); - bool valid_linestyle = ED_texture_context_check_linestyle(C); - bool valid_others = ED_texture_context_check_others(C); - - /* this is similar to direct user action, no need to keep "better" ctxt in _prev */ - if ((sbuts->mainb == BCONTEXT_WORLD) && valid_world) { - sbuts->texture_context = sbuts->texture_context_prev = SB_TEXC_WORLD; - } - else if ((sbuts->mainb == BCONTEXT_MATERIAL) && valid_material) { - sbuts->texture_context = sbuts->texture_context_prev = SB_TEXC_MATERIAL; - } - else if ((sbuts->mainb == BCONTEXT_DATA) && valid_lamp) { - sbuts->texture_context = sbuts->texture_context_prev = SB_TEXC_LAMP; - } - else if ((sbuts->mainb == BCONTEXT_PARTICLE) && valid_particles) { - sbuts->texture_context = sbuts->texture_context_prev = SB_TEXC_PARTICLES; - } - else if ((sbuts->mainb == BCONTEXT_VIEW_LAYER) && valid_linestyle) { - sbuts->texture_context = sbuts->texture_context_prev = SB_TEXC_LINESTYLE; - } - else if ((ELEM(sbuts->mainb, BCONTEXT_MODIFIER, BCONTEXT_PHYSICS)) && valid_others) { - sbuts->texture_context = sbuts->texture_context_prev = SB_TEXC_OTHER; - } - /* Else, try to revive a previous "better" ctxt... */ - else if ((sbuts->texture_context_prev != sbuts->texture_context) && - (((sbuts->texture_context_prev == SB_TEXC_WORLD) && valid_world) || - ((sbuts->texture_context_prev == SB_TEXC_MATERIAL) && valid_material) || - ((sbuts->texture_context_prev == SB_TEXC_LAMP) && valid_lamp) || - ((sbuts->texture_context_prev == SB_TEXC_PARTICLES) && valid_particles) || - ((sbuts->texture_context_prev == SB_TEXC_LINESTYLE) && valid_linestyle) || - ((sbuts->texture_context_prev == SB_TEXC_OTHER) && valid_others))) - { - sbuts->texture_context = sbuts->texture_context_prev; - } - /* Else, just be sure that current context is valid! */ - else if (((sbuts->texture_context == SB_TEXC_WORLD) && !valid_world) || - ((sbuts->texture_context == SB_TEXC_MATERIAL) && !valid_material) || - ((sbuts->texture_context == SB_TEXC_LAMP) && !valid_lamp) || - ((sbuts->texture_context == SB_TEXC_PARTICLES) && !valid_particles) || - ((sbuts->texture_context == SB_TEXC_LINESTYLE) && !valid_linestyle) || - ((sbuts->texture_context == SB_TEXC_OTHER) && !valid_others)) - { - /* this is default fallback, do keep "better" ctxt in _prev */ - sbuts->texture_context_prev = sbuts->texture_context; - if (valid_material) { - sbuts->texture_context = SB_TEXC_MATERIAL; - } - else if (valid_lamp) { - sbuts->texture_context = SB_TEXC_LAMP; - } - else if (valid_particles) { - sbuts->texture_context = SB_TEXC_PARTICLES; - } - else if (valid_linestyle) { - sbuts->texture_context = SB_TEXC_LINESTYLE; - } - else if (valid_world) { - sbuts->texture_context = SB_TEXC_WORLD; - } - else if (valid_others) { - sbuts->texture_context = SB_TEXC_OTHER; - } - } - } -} - /************************* Texture User **************************/ static void buttons_texture_user_property_add(ListBase *users, ID *id, @@ -322,9 +152,6 @@ static void buttons_texture_users_from_context(ListBase *users, const bContext * { Scene *scene = NULL; Object *ob = NULL; - Material *ma = NULL; - Lamp *la = NULL; - World *wrld = NULL; WorkSpace *workspace = NULL; FreestyleLineStyle *linestyle = NULL; Brush *brush = NULL; @@ -337,12 +164,6 @@ static void buttons_texture_users_from_context(ListBase *users, const bContext * scene = (Scene *)pinid; else if (GS(pinid->name) == ID_OB) ob = (Object *)pinid; - else if (GS(pinid->name) == ID_LA) - la = (Lamp *)pinid; - else if (GS(pinid->name) == ID_WO) - wrld = (World *)pinid; - else if (GS(pinid->name) == ID_MA) - ma = (Material *)pinid; else if (GS(pinid->name) == ID_BR) brush = (Brush *)pinid; else if (GS(pinid->name) == ID_LS) @@ -360,7 +181,6 @@ static void buttons_texture_users_from_context(ListBase *users, const bContext * brush = BKE_paint_brush(BKE_paint_get_active_from_context(C)); if (workspace == NULL) { - wrld = scene->world; linestyle = BKE_linestyle_active_from_scene(scene); workspace = CTX_wm_workspace(C); } @@ -369,20 +189,9 @@ static void buttons_texture_users_from_context(ListBase *users, const bContext * ob = OBACT(view_layer); } - if (ob && ob->type == OB_LAMP && !la) - la = ob->data; - if (ob && !ma) - ma = give_current_material(ob, ob->actcol); - /* fill users */ BLI_listbase_clear(users); - if (ma && !limited_mode) - buttons_texture_users_find_nodetree(users, &ma->id, ma->nodetree, N_("Material")); - if (la && !limited_mode) - buttons_texture_users_find_nodetree(users, &la->id, la->nodetree, N_("Lamp")); - if (wrld && !limited_mode) - buttons_texture_users_find_nodetree(users, &wrld->id, wrld->nodetree, N_("World")); if (linestyle && !limited_mode) buttons_texture_users_find_nodetree(users, &linestyle->id, linestyle->nodetree, N_("Line Style")); @@ -451,21 +260,8 @@ void buttons_texture_context_compute(const bContext *C, SpaceButs *sbuts) /* gather available texture users in context. runs on every draw of * properties editor, before the buttons are created. */ ButsContextTexture *ct = sbuts->texuser; - Scene *scene = CTX_data_scene(C); ID *pinid = sbuts->pinid; - set_texture_context(C, sbuts); - - if (!((sbuts->texture_context == SB_TEXC_OTHER) || BKE_scene_use_new_shading_nodes(scene))) { - if (ct) { - BLI_freelistN(&ct->users); - MEM_freeN(ct); - sbuts->texuser = NULL; - } - - return; - } - if (!ct) { ct = MEM_callocN(sizeof(ButsContextTexture), "ButsContextTexture"); sbuts->texuser = ct; @@ -699,4 +495,3 @@ void uiTemplateTextureShow(uiLayout *layout, bContext *C, PointerRNA *ptr, Prope UI_but_func_set(but, template_texture_show, user->ptr.data, user->prop); } } - |