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/object | |
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/object')
-rw-r--r-- | source/blender/editors/object/object_add.c | 16 | ||||
-rw-r--r-- | source/blender/editors/object/object_bake.c | 324 | ||||
-rw-r--r-- | source/blender/editors/object/object_edit.c | 62 | ||||
-rw-r--r-- | source/blender/editors/object/object_relations.c | 119 | ||||
-rw-r--r-- | source/blender/editors/object/object_select.c | 39 |
5 files changed, 39 insertions, 521 deletions
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 6f9f18d301e..7327c563104 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -115,8 +115,6 @@ #include "UI_resources.h" -#include "GPU_lamp.h" - #include "object_intern.h" /* this is an exact copy of the define in rna_lamp.c @@ -1019,7 +1017,7 @@ static int object_lamp_add_exec(bContext *C, wmOperator *op) la = (Lamp *)ob->data; la->type = type; - if (BKE_scene_use_new_shading_nodes(scene)) { + if (BKE_scene_uses_cycles(scene)) { ED_node_shader_default(C, &la->id); la->use_nodes = true; } @@ -1184,17 +1182,6 @@ void OBJECT_OT_speaker_add(wmOperatorType *ot) /**************************** Delete Object *************************/ -static void object_delete_check_glsl_update(Object *ob) -{ - /* some objects could affect on GLSL shading, make sure GLSL settings - * are being tagged to be updated when object is removing from scene - */ - if (ob->type == OB_LAMP) { - if (ob->gpulamp.first) - GPU_lamp_free(ob); - } -} - /* remove base from a specific scene */ /* note: now unlinks constraints as well */ void ED_object_base_free_and_unlink(Main *bmain, Scene *scene, Object *ob) @@ -1210,7 +1197,6 @@ void ED_object_base_free_and_unlink(Main *bmain, Scene *scene, Object *ob) DEG_id_tag_update_ex(bmain, &ob->id, DEG_TAG_BASE_FLAGS_UPDATE); - object_delete_check_glsl_update(ob); BKE_collections_object_remove(bmain, &scene->id, ob, true); } diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c index a38b9959dab..b10b35618fb 100644 --- a/source/blender/editors/object/object_bake.c +++ b/source/blender/editors/object/object_bake.c @@ -79,9 +79,26 @@ #include "ED_object.h" #include "ED_screen.h" +#include "ED_uvedit.h" #include "object_intern.h" +static Image *bake_object_image_get(Object *ob, int mat_nr) +{ + Image *image = NULL; + ED_object_get_active_image(ob, mat_nr + 1, &image, NULL, NULL, NULL); + return image; +} + +static Image **bake_object_image_get_array(Object *ob) +{ + Image **image_array = MEM_mallocN(sizeof(Material *) * ob->totcol, __func__); + for (int i = 0; i < ob->totcol; i++) { + image_array[i] = bake_object_image_get(ob, i); + } + return image_array; +} + /* ****************** multires BAKING ********************** */ /* holder of per-object data needed for bake job @@ -108,8 +125,6 @@ typedef struct { bool use_lores_mesh; /* Use low-resolution mesh when baking displacement maps */ int number_of_rays; /* Number of rays to be cast when doing AO baking */ float bias; /* Bias between object and start ray point when doing AO baking */ - int raytrace_structure; /* Optimization structure to be used for AO baking */ - int octree_resolution; /* Reslution of octotree when using octotree optimization structure */ int threads; /* Number of threads to be used for baking */ float user_scale; /* User scale used to scale displacement when baking derivative map. */ } MultiresBakeJob; @@ -167,7 +182,7 @@ static bool multiresbake_check(bContext *C, wmOperator *op) else { a = me->totpoly; while (ok && a--) { - Image *ima = BKE_object_material_edit_image_get(ob, me->mpoly[a].mat_nr); + Image *ima = bake_object_image_get(ob, me->mpoly[a].mat_nr); if (!ima) { BKE_report(op->reports, RPT_ERROR, "You should have active texture to use multires baker"); @@ -334,12 +349,12 @@ static int multiresbake_image_exec_locked(bContext *C, wmOperator *op) if (scene->r.bake_mode == RE_BAKE_NORMALS) { clear_flag = CLEAR_TANGENT_NORMAL; } - else if (ELEM(scene->r.bake_mode, RE_BAKE_DISPLACEMENT, RE_BAKE_DERIVATIVE)) { + else if (scene->r.bake_mode == RE_BAKE_DISPLACEMENT) { clear_flag = CLEAR_DISPLACEMENT; } { - Image **ob_image_array = BKE_object_material_edit_image_get_array(ob); + Image **ob_image_array = bake_object_image_get_array(ob); clear_images_poly(ob_image_array, ob->totcol, clear_flag); MEM_freeN(ob_image_array); } @@ -361,14 +376,12 @@ static int multiresbake_image_exec_locked(bContext *C, wmOperator *op) bkr.use_lores_mesh = scene->r.bake_flag & R_BAKE_LORES_MESH; bkr.bias = scene->r.bake_biasdist; bkr.number_of_rays = scene->r.bake_samples; - bkr.raytrace_structure = scene->r.raytrace_structure; - bkr.octree_resolution = scene->r.ocres; bkr.threads = BKE_scene_num_threads(scene); bkr.user_scale = (scene->r.bake_flag & R_BAKE_USERSCALE) ? scene->r.bake_user_scale : -1.0f; //bkr.reports= op->reports; /* create low-resolution DM (to bake to) and hi-resolution DM (to bake from) */ - bkr.ob_image.array = BKE_object_material_edit_image_get_array(ob); + bkr.ob_image.array = bake_object_image_get_array(ob); bkr.ob_image.len = ob->totcol; bkr.hires_dm = multiresbake_create_hiresdm(scene, ob, &bkr.tot_lvl, &bkr.simple); @@ -406,8 +419,6 @@ static void init_multiresbake_job(bContext *C, MultiresBakeJob *bkj) bkj->bake_clear = scene->r.bake_flag & R_BAKE_CLEAR; bkj->bias = scene->r.bake_biasdist; bkj->number_of_rays = scene->r.bake_samples; - bkj->raytrace_structure = scene->r.raytrace_structure; - bkj->octree_resolution = scene->r.ocres; bkj->threads = BKE_scene_num_threads(scene); bkj->user_scale = (scene->r.bake_flag & R_BAKE_USERSCALE) ? scene->r.bake_user_scale : -1.0f; //bkj->reports = op->reports; @@ -423,7 +434,7 @@ static void init_multiresbake_job(bContext *C, MultiresBakeJob *bkj) data = MEM_callocN(sizeof(MultiresBakerJobData), "multiresBaker derivedMesh_data"); - data->ob_image.array = BKE_object_material_edit_image_get_array(ob); + data->ob_image.array = bake_object_image_get_array(ob); data->ob_image.len = ob->totcol; /* create low-resolution DM (to bake to) and hi-resolution DM (to bake from) */ @@ -451,7 +462,7 @@ static void multiresbake_startjob(void *bkv, short *stop, short *do_update, floa if (bkj->mode == RE_BAKE_NORMALS) { clear_flag = CLEAR_TANGENT_NORMAL; } - else if (ELEM(bkj->mode, RE_BAKE_DISPLACEMENT, RE_BAKE_DERIVATIVE)) { + else if (bkj->mode == RE_BAKE_DISPLACEMENT) { clear_flag = CLEAR_DISPLACEMENT; } @@ -488,8 +499,6 @@ static void multiresbake_startjob(void *bkv, short *stop, short *do_update, floa bkr.bias = bkj->bias; bkr.number_of_rays = bkj->number_of_rays; - bkr.raytrace_structure = bkj->raytrace_structure; - bkr.octree_resolution = bkj->octree_resolution; bkr.threads = bkj->threads; RE_multires_bake_images(&bkr); @@ -566,203 +575,6 @@ static int multiresbake_image_exec(bContext *C, wmOperator *op) /* ****************** render BAKING ********************** */ -/* threaded break test */ -static int thread_break(void *UNUSED(arg)) -{ - return G.is_break; -} - -typedef struct BakeRender { - Render *re; - Main *main; - Scene *scene; - ViewLayer *view_layer; - struct Object *actob; - int result, ready; - - ReportList *reports; - - short *stop; - short *do_update; - float *progress; - - ListBase threads; - - /* backup */ - short prev_wo_amb_occ; - short prev_r_raytrace; - - /* for redrawing */ - ScrArea *sa; -} BakeRender; - -/* use by exec and invoke */ -static int test_bake_internal(bContext *C, ReportList *reports) -{ - Scene *scene = CTX_data_scene(C); - - if ((scene->r.bake_flag & R_BAKE_TO_ACTIVE) && CTX_data_active_object(C) == NULL) { - BKE_report(reports, RPT_ERROR, "No active object"); - } - else if (scene->r.bake_mode == RE_BAKE_AO && scene->world == NULL) { - BKE_report(reports, RPT_ERROR, "No world set up"); - } - else { - return 1; - } - - return 0; -} - -static void init_bake_internal(BakeRender *bkr, bContext *C) -{ - Scene *scene = CTX_data_scene(C); - ViewLayer *view_layer = CTX_data_view_layer(C); - bScreen *sc = CTX_wm_screen(C); - - /* get editmode results */ - ED_object_editmode_load(CTX_data_edit_object(C)); - - bkr->sa = sc ? BKE_screen_find_big_area(sc, SPACE_IMAGE, 10) : NULL; /* can be NULL */ - bkr->main = CTX_data_main(C); - bkr->scene = scene; - bkr->view_layer = view_layer; - bkr->actob = (scene->r.bake_flag & R_BAKE_TO_ACTIVE) ? OBACT(view_layer) : NULL; - bkr->re = RE_NewRender("_Bake View_"); - - if (scene->r.bake_mode == RE_BAKE_AO) { - /* If raytracing or AO is disabled, switch it on temporarily for baking. */ - bkr->prev_wo_amb_occ = (scene->world->mode & WO_AMB_OCC) != 0; - scene->world->mode |= WO_AMB_OCC; - } - if (scene->r.bake_mode == RE_BAKE_AO || bkr->actob) { - bkr->prev_r_raytrace = (scene->r.mode & R_RAYTRACE) != 0; - scene->r.mode |= R_RAYTRACE; - } -} - -static void finish_bake_internal(BakeRender *bkr) -{ - Image *ima; - - RE_Database_Free(bkr->re); - - /* restore raytrace and AO */ - if (bkr->scene->r.bake_mode == RE_BAKE_AO) - if (bkr->prev_wo_amb_occ == 0) - bkr->scene->world->mode &= ~WO_AMB_OCC; - - if (bkr->scene->r.bake_mode == RE_BAKE_AO || bkr->actob) - if (bkr->prev_r_raytrace == 0) - bkr->scene->r.mode &= ~R_RAYTRACE; - - /* force OpenGL reload and mipmap recalc */ - if ((bkr->scene->r.bake_flag & R_BAKE_VCOL) == 0) { - for (ima = G.main->image.first; ima; ima = ima->id.next) { - ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL); - - /* some of the images could have been changed during bake, - * so recreate mipmaps regardless bake result status - */ - if (ima->ok == IMA_OK_LOADED) { - if (ibuf) { - if (ibuf->userflags & IB_BITMAPDIRTY) { - GPU_free_image(ima); - imb_freemipmapImBuf(ibuf); - } - - /* invalidate display buffers for changed images */ - if (ibuf->userflags & IB_BITMAPDIRTY) - ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID; - } - } - - /* freed when baking is done, but if its canceled we need to free here */ - if (ibuf) { - if (ibuf->userdata) { - BakeImBufuserData *userdata = (BakeImBufuserData *) ibuf->userdata; - if (userdata->mask_buffer) - MEM_freeN(userdata->mask_buffer); - if (userdata->displacement_buffer) - MEM_freeN(userdata->displacement_buffer); - MEM_freeN(userdata); - ibuf->userdata = NULL; - } - } - - BKE_image_release_ibuf(ima, ibuf, NULL); - DEG_id_tag_update(&ima->id, 0); - } - } - - if (bkr->scene->r.bake_flag & R_BAKE_VCOL) { - /* update all tagged meshes */ - Mesh *me; - BLI_assert(BLI_thread_is_main()); - for (me = G.main->mesh.first; me; me = me->id.next) { - if (me->id.tag & LIB_TAG_DOIT) { - DEG_id_tag_update(&me->id, OB_RECALC_DATA); - BKE_mesh_tessface_clear(me); - } - } - } - -} - -static void *do_bake_render(void *bake_v) -{ - BakeRender *bkr = bake_v; - - bkr->result = RE_bake_shade_all_selected(bkr->re, bkr->scene->r.bake_mode, bkr->actob, NULL, bkr->progress); - bkr->ready = 1; - - return NULL; -} - -static void bake_startjob(void *bkv, short *stop, short *do_update, float *progress) -{ - BakeRender *bkr = bkv; - Scene *scene = bkr->scene; - Main *bmain = bkr->main; - - bkr->stop = stop; - bkr->do_update = do_update; - bkr->progress = progress; - - RE_test_break_cb(bkr->re, NULL, thread_break); - G.is_break = false; /* BKE_blender_test_break uses this global */ - - RE_Database_Baking(bkr->re, bmain, scene, bkr->view_layer, scene->lay, scene->r.bake_mode, bkr->actob); - - /* baking itself is threaded, cannot use test_break in threads. we also update optional imagewindow */ - bkr->result = RE_bake_shade_all_selected(bkr->re, scene->r.bake_mode, bkr->actob, bkr->do_update, bkr->progress); -} - -static void bake_update(void *bkv) -{ - BakeRender *bkr = bkv; - - if (bkr->sa && bkr->sa->spacetype == SPACE_IMAGE) { /* in case the user changed while baking */ - SpaceImage *sima = bkr->sa->spacedata.first; - if (sima) - sima->image = RE_bake_shade_get_image(); - } -} - -static void bake_freejob(void *bkv) -{ - BakeRender *bkr = bkv; - finish_bake_internal(bkr); - - if (bkr->result == BAKE_RESULT_NO_OBJECTS) - BKE_report(bkr->reports, RPT_ERROR, "No objects or images found to bake to"); - else if (bkr->result == BAKE_RESULT_FEEDBACK_LOOP) - BKE_report(bkr->reports, RPT_WARNING, "Circular reference in texture stack"); - - MEM_freeN(bkr); - G.is_rendering = false; -} - /* catch esc */ static int objects_bake_render_modal(bContext *C, wmOperator *UNUSED(op), const wmEvent *event) { @@ -780,7 +592,7 @@ static int objects_bake_render_modal(bContext *C, wmOperator *UNUSED(op), const static bool is_multires_bake(Scene *scene) { - if (ELEM(scene->r.bake_mode, RE_BAKE_NORMALS, RE_BAKE_DISPLACEMENT, RE_BAKE_DERIVATIVE, RE_BAKE_AO)) + if (ELEM(scene->r.bake_mode, RE_BAKE_NORMALS, RE_BAKE_DISPLACEMENT, RE_BAKE_AO)) return scene->r.bake_flag & R_BAKE_MULTIRES; return 0; @@ -791,44 +603,7 @@ static int objects_bake_render_invoke(bContext *C, wmOperator *op, const wmEvent Scene *scene = CTX_data_scene(C); int result = OPERATOR_CANCELLED; - if (is_multires_bake(scene)) { - result = multiresbake_image_exec(C, op); - } - else { - /* only one render job at a time */ - if (WM_jobs_test(CTX_wm_manager(C), scene, WM_JOB_TYPE_OBJECT_BAKE_TEXTURE)) - return OPERATOR_CANCELLED; - - if (test_bake_internal(C, op->reports) == 0) { - return OPERATOR_CANCELLED; - } - else { - BakeRender *bkr = MEM_callocN(sizeof(BakeRender), "render bake"); - wmJob *wm_job; - - init_bake_internal(bkr, C); - bkr->reports = op->reports; - - /* setup job */ - wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, "Texture Bake", - WM_JOB_EXCL_RENDER | WM_JOB_PRIORITY | WM_JOB_PROGRESS, WM_JOB_TYPE_OBJECT_BAKE_TEXTURE); - WM_jobs_customdata_set(wm_job, bkr, bake_freejob); - WM_jobs_timer(wm_job, 0.5, NC_IMAGE, 0); /* TODO - only draw bake image, can we enforce this */ - WM_jobs_callbacks(wm_job, bake_startjob, NULL, bake_update, NULL); - - G.is_break = false; - G.is_rendering = true; - - WM_jobs_start(CTX_wm_manager(C), wm_job); - - WM_cursor_wait(0); - - /* add modal handler for ESC */ - WM_event_add_modal_handler(C, op); - } - - result = OPERATOR_RUNNING_MODAL; - } + result = multiresbake_image_exec(C, op); WM_event_add_notifier(C, NC_SCENE | ND_RENDER_RESULT, scene); @@ -838,56 +613,11 @@ static int objects_bake_render_invoke(bContext *C, wmOperator *op, const wmEvent static int bake_image_exec(bContext *C, wmOperator *op) { - Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); int result = OPERATOR_CANCELLED; - if (is_multires_bake(scene)) { - result = multiresbake_image_exec_locked(C, op); - } - else { - if (test_bake_internal(C, op->reports) == 0) { - return OPERATOR_CANCELLED; - } - else { - ListBase threads; - BakeRender bkr = {NULL}; - - init_bake_internal(&bkr, C); - bkr.reports = op->reports; - - RE_test_break_cb(bkr.re, NULL, thread_break); - G.is_break = false; /* BKE_blender_test_break uses this global */ - - RE_Database_Baking(bkr.re, bmain, scene, bkr.view_layer, scene->lay, scene->r.bake_mode, - (scene->r.bake_flag & R_BAKE_TO_ACTIVE) ? OBACT(bkr.view_layer) : NULL); - - /* baking itself is threaded, cannot use test_break in threads */ - BLI_threadpool_init(&threads, do_bake_render, 1); - bkr.ready = 0; - BLI_threadpool_insert(&threads, &bkr); - - while (bkr.ready == 0) { - PIL_sleep_ms(50); - if (bkr.ready) - break; - - /* used to redraw in 2.4x but this is just for exec in 2.5 */ - if (!G.background) - BKE_blender_test_break(); - } - BLI_threadpool_end(&threads); - - if (bkr.result == BAKE_RESULT_NO_OBJECTS) - BKE_report(op->reports, RPT_ERROR, "No valid images found to bake to"); - else if (bkr.result == BAKE_RESULT_FEEDBACK_LOOP) - BKE_report(op->reports, RPT_ERROR, "Circular reference in texture stack"); - - finish_bake_internal(&bkr); - - result = OPERATOR_FINISHED; - } - } + BLI_assert(is_multires_bake(scene)); + result = multiresbake_image_exec_locked(C, op); WM_event_add_notifier(C, NC_SCENE | ND_RENDER_RESULT, scene); diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 2550c4006f2..d051e42cb32 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -1295,68 +1295,6 @@ void OBJECT_OT_shade_smooth(wmOperatorType *ot) /* ********************** */ -static void UNUSED_FUNCTION(image_aspect) (Scene *scene, ViewLayer *view_layer, Object *obedit) -{ - /* all selected objects with an image map: scale in image aspect */ - Base *base; - Object *ob; - Material *ma; - Tex *tex; - float x, y, space; - int a, b, done; - - if (obedit) return; - if (ID_IS_LINKED(scene)) return; - - for (base = FIRSTBASE(view_layer); base; base = base->next) { - if (TESTBASELIB(base)) { - ob = base->object; - done = false; - - for (a = 1; a <= ob->totcol; a++) { - ma = give_current_material(ob, a); - if (ma) { - for (b = 0; b < MAX_MTEX; b++) { - if (ma->mtex[b] && ma->mtex[b]->tex) { - tex = ma->mtex[b]->tex; - if (tex->type == TEX_IMAGE && tex->ima) { - ImBuf *ibuf = BKE_image_acquire_ibuf(tex->ima, NULL, NULL); - - /* texturespace */ - space = 1.0; - if (ob->type == OB_MESH) { - float size[3]; - BKE_mesh_texspace_get(ob->data, NULL, NULL, size); - space = size[0] / size[1]; - } - else if (ELEM(ob->type, OB_CURVE, OB_FONT, OB_SURF)) { - float size[3]; - BKE_curve_texspace_get(ob->data, NULL, NULL, size); - space = size[0] / size[1]; - } - - x = ibuf->x / space; - y = ibuf->y; - - if (x > y) ob->size[0] = ob->size[1] * x / y; - else ob->size[1] = ob->size[0] * y / x; - - done = true; - DEG_id_tag_update(&ob->id, OB_RECALC_OB); - - BKE_image_release_ibuf(tex->ima, ibuf, NULL); - } - } - if (done) break; - } - } - if (done) break; - } - } - } - -} - static const EnumPropertyItem *object_mode_set_itemsf( bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) { diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 3cef80db032..d2ac0f77c78 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -1773,7 +1773,6 @@ static void single_obdata_users(Main *bmain, Scene *scene, ViewLayer *view_layer Mesh *me; Lattice *lat; ID *id; - int a; FOREACH_OBJECT_FLAG_BEGIN(scene, view_layer, flag, ob) { @@ -1786,11 +1785,6 @@ static void single_obdata_users(Main *bmain, Scene *scene, ViewLayer *view_layer switch (ob->type) { case OB_LAMP: ob->data = la = ID_NEW_SET(ob->data, BKE_lamp_copy(bmain, ob->data)); - for (a = 0; a < MAX_MTEX; a++) { - if (la->mtex[a]) { - ID_NEW_REMAP(la->mtex[a]->object); - } - } break; case OB_CAMERA: ob->data = ID_NEW_SET(ob->data, BKE_camera_copy(bmain, ob->data)); @@ -1870,11 +1864,10 @@ static void single_object_action_users(Scene *scene, ViewLayer *view_layer, cons FOREACH_OBJECT_FLAG_END; } -static void single_mat_users(Main *bmain, Scene *scene, ViewLayer *view_layer, const int flag, const bool do_textures) +static void single_mat_users(Main *bmain, Scene *scene, ViewLayer *view_layer, const int flag) { Material *ma, *man; - Tex *tex; - int a, b; + int a; FOREACH_OBJECT_FLAG_BEGIN(scene, view_layer, flag, ob) { @@ -1890,19 +1883,6 @@ static void single_mat_users(Main *bmain, Scene *scene, ViewLayer *view_layer, c man->id.us = 0; assign_material(ob, man, a, BKE_MAT_ASSIGN_USERPREF); - - if (do_textures) { - for (b = 0; b < MAX_MTEX; b++) { - if (ma->mtex[b] && (tex = ma->mtex[b]->tex)) { - if (tex->id.us > 1) { - id_us_min(&tex->id); - tex = BKE_texture_copy(bmain, tex); - BKE_animdata_copy_id_action(&tex->id, false); - man->mtex[b]->tex = tex; - } - } - } - } } } } @@ -1911,66 +1891,6 @@ static void single_mat_users(Main *bmain, Scene *scene, ViewLayer *view_layer, c FOREACH_OBJECT_FLAG_END; } -static void do_single_tex_user(Main *bmain, Tex **from) -{ - Tex *tex, *texn; - - tex = *from; - if (tex == NULL) return; - - if (tex->id.newid) { - *from = (Tex *)tex->id.newid; - id_us_plus(tex->id.newid); - id_us_min(&tex->id); - } - else if (tex->id.us > 1) { - texn = ID_NEW_SET(tex, BKE_texture_copy(bmain, tex)); - BKE_animdata_copy_id_action(&texn->id, false); - tex->id.newid = (ID *)texn; - id_us_min(&tex->id); - *from = texn; - } -} - -static void single_tex_users_expand(Main *bmain) -{ - /* only when 'parent' blocks are LIB_TAG_NEW */ - Material *ma; - Lamp *la; - World *wo; - int b; - - for (ma = bmain->mat.first; ma; ma = ma->id.next) { - if (ma->id.tag & LIB_TAG_NEW) { - for (b = 0; b < MAX_MTEX; b++) { - if (ma->mtex[b] && ma->mtex[b]->tex) { - do_single_tex_user(bmain, &(ma->mtex[b]->tex)); - } - } - } - } - - for (la = bmain->lamp.first; la; la = la->id.next) { - if (la->id.tag & LIB_TAG_NEW) { - for (b = 0; b < MAX_MTEX; b++) { - if (la->mtex[b] && la->mtex[b]->tex) { - do_single_tex_user(bmain, &(la->mtex[b]->tex)); - } - } - } - } - - for (wo = bmain->world.first; wo; wo = wo->id.next) { - if (wo->id.tag & LIB_TAG_NEW) { - for (b = 0; b < MAX_MTEX; b++) { - if (wo->mtex[b] && wo->mtex[b]->tex) { - do_single_tex_user(bmain, &(wo->mtex[b]->tex)); - } - } - } - } -} - static void single_mat_users_expand(Main *bmain) { /* only when 'parent' blocks are LIB_TAG_NEW */ @@ -1978,8 +1898,6 @@ static void single_mat_users_expand(Main *bmain) Mesh *me; Curve *cu; MetaBall *mb; - Material *ma; - int a; for (ob = bmain->object.first; ob; ob = ob->id.next) if (ob->id.tag & LIB_TAG_NEW) @@ -1996,13 +1914,6 @@ static void single_mat_users_expand(Main *bmain) for (mb = bmain->mball.first; mb; mb = mb->id.next) if (mb->id.tag & LIB_TAG_NEW) new_id_matar(bmain, mb->mat, mb->totcol); - - /* material imats */ - for (ma = bmain->mat.first; ma; ma = ma->id.next) - if (ma->id.tag & LIB_TAG_NEW) - for (a = 0; a < MAX_MTEX; a++) - if (ma->mtex[a]) - ID_NEW_REMAP(ma->mtex[a]->object); } /* used for copying scenes */ @@ -2014,7 +1925,6 @@ void ED_object_single_users(Main *bmain, Scene *scene, const bool full, const bo single_obdata_users(bmain, scene, NULL, 0); single_object_action_users(scene, NULL, 0); single_mat_users_expand(bmain); - single_tex_users_expand(bmain); } /* Relink nodetrees' pointers that have been duplicated. */ @@ -2201,12 +2111,6 @@ static void make_local_material_tag(Material *ma) make_local_animdata_tag(BKE_animdata_from_id(&ma->id)); /* About nodetrees: root one is made local together with material, others we keep linked for now... */ - - for (int a = 0; a < MAX_MTEX; a++) { - if (ma->mtex[a] && ma->mtex[a]->tex) { - ma->mtex[a]->tex->id.tag &= ~LIB_TAG_PRE_EXISTING; - } - } } } @@ -2216,7 +2120,6 @@ static int make_local_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); ParticleSystem *psys; Material *ma, ***matarar; - Lamp *la; const int mode = RNA_enum_get(op->ptr, "type"); int a; @@ -2267,16 +2170,6 @@ static int make_local_exec(bContext *C, wmOperator *op) } } } - - if (ob->type == OB_LAMP) { - BLI_assert(ob->data != NULL); - la = ob->data; - for (a = 0; a < MAX_MTEX; a++) { - if (la->mtex[a] && la->mtex[a]->tex) { - la->id.tag &= ~LIB_TAG_PRE_EXISTING; - } - } - } } if (ELEM(mode, MAKE_LOCAL_SELECT_OBDATA, MAKE_LOCAL_SELECT_OBDATA_MATERIAL) && ob->data != NULL) { @@ -2553,13 +2446,9 @@ static int make_single_user_exec(bContext *C, wmOperator *op) } if (RNA_boolean_get(op->ptr, "material")) { - single_mat_users(bmain, scene, view_layer, flag, RNA_boolean_get(op->ptr, "texture")); + single_mat_users(bmain, scene, view_layer, flag); } -#if 0 /* can't do this separate from materials */ - if (RNA_boolean_get(op->ptr, "texture")) - single_mat_users(scene, flag, true); -#endif if (RNA_boolean_get(op->ptr, "animation")) { single_object_action_users(scene, view_layer, flag); } @@ -2601,8 +2490,6 @@ void OBJECT_OT_make_single_user(wmOperatorType *ot) RNA_def_boolean(ot->srna, "object", 0, "Object", "Make single user objects"); RNA_def_boolean(ot->srna, "obdata", 0, "Object Data", "Make single user object data"); RNA_def_boolean(ot->srna, "material", 0, "Materials", "Make materials local to each data-block"); - RNA_def_boolean(ot->srna, "texture", 0, "Textures", - "Make textures local to each material (needs 'Materials' to be set too)"); RNA_def_boolean(ot->srna, "animation", 0, "Object Animation", "Make animation data local to each object"); } diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c index d958381efe7..d0d0418c861 100644 --- a/source/blender/editors/object/object_select.c +++ b/source/blender/editors/object/object_select.c @@ -203,7 +203,6 @@ enum { OBJECT_SELECT_LINKED_IPO = 1, OBJECT_SELECT_LINKED_OBDATA, OBJECT_SELECT_LINKED_MATERIAL, - OBJECT_SELECT_LINKED_TEXTURE, OBJECT_SELECT_LINKED_DUPGROUP, OBJECT_SELECT_LINKED_PARTICLE, OBJECT_SELECT_LINKED_LIBRARY, @@ -214,7 +213,6 @@ static const EnumPropertyItem prop_select_linked_types[] = { //{OBJECT_SELECT_LINKED_IPO, "IPO", 0, "Object IPO", ""}, // XXX deprecated animation system stuff... {OBJECT_SELECT_LINKED_OBDATA, "OBDATA", 0, "Object Data", ""}, {OBJECT_SELECT_LINKED_MATERIAL, "MATERIAL", 0, "Material", ""}, - {OBJECT_SELECT_LINKED_TEXTURE, "TEXTURE", 0, "Texture", ""}, {OBJECT_SELECT_LINKED_DUPGROUP, "DUPGROUP", 0, "Dupligroup", ""}, {OBJECT_SELECT_LINKED_PARTICLE, "PARTICLE", 0, "Particle System", ""}, {OBJECT_SELECT_LINKED_LIBRARY, "LIBRARY", 0, "Library", ""}, @@ -240,7 +238,7 @@ static bool object_select_all_by_obdata(bContext *C, void *obdata) return changed; } -static bool object_select_all_by_material_texture(bContext *C, int use_texture, Material *mat, Tex *tex) +static bool object_select_all_by_material(bContext *C, Material *mat) { bool changed = false; @@ -249,27 +247,14 @@ static bool object_select_all_by_material_texture(bContext *C, int use_texture, if (((base->flag & BASE_SELECTED) == 0) && ((base->flag & BASE_SELECTABLED) != 0)) { Object *ob = base->object; Material *mat1; - int a, b; + int a; for (a = 1; a <= ob->totcol; a++) { mat1 = give_current_material(ob, a); - if (!use_texture) { - if (mat1 == mat) { - ED_object_base_select(base, BA_SELECT); - changed = true; - } - } - else if (mat1 && use_texture) { - for (b = 0; b < MAX_MTEX; b++) { - if (mat1->mtex[b]) { - if (tex == mat1->mtex[b]->tex) { - ED_object_base_select(base, BA_SELECT); - changed = true; - break; - } - } - } + if (mat1 == mat) { + ED_object_base_select(base, BA_SELECT); + changed = true; } } } @@ -373,7 +358,7 @@ void ED_object_select_linked_by_id(bContext *C, ID *id) changed = object_select_all_by_obdata(C, id); } else if (idtype == ID_MA) { - changed = object_select_all_by_material_texture(C, false, (Material *)id, NULL); + changed = object_select_all_by_material(C, (Material *)id); } else if (idtype == ID_LI) { changed = object_select_all_by_library(C, (Library *) id); @@ -420,21 +405,13 @@ static int object_select_linked_exec(bContext *C, wmOperator *op) changed = object_select_all_by_obdata(C, ob->data); } - else if (nr == OBJECT_SELECT_LINKED_MATERIAL || nr == OBJECT_SELECT_LINKED_TEXTURE) { + else if (nr == OBJECT_SELECT_LINKED_MATERIAL) { Material *mat = NULL; - Tex *tex = NULL; - bool use_texture = false; mat = give_current_material(ob, ob->actcol); if (mat == NULL) return OPERATOR_CANCELLED; - if (nr == OBJECT_SELECT_LINKED_TEXTURE) { - use_texture = true; - - if (mat->mtex[(int)mat->texact]) tex = mat->mtex[(int)mat->texact]->tex; - if (tex == NULL) return OPERATOR_CANCELLED; - } - changed = object_select_all_by_material_texture(C, use_texture, mat, tex); + changed = object_select_all_by_material(C, mat); } else if (nr == OBJECT_SELECT_LINKED_DUPGROUP) { if (ob->dup_group == NULL) |