From 7a9ad029dd1d1afe42d54c9c181de887636db7c0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 24 May 2017 23:14:32 +1000 Subject: Remove TexFace, per-face images TexFace complicates the now more popular shading pipeline by having per-face images, see: T51382 for details. To keep the ability to select a per-material edit-image (used with UV-mapping workflow), the material now stores an image which will be set when changing images in edit-mode. This is used as a bake-target when not using Cycles too. --- source/blender/modifiers/intern/MOD_uvproject.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'source/blender/modifiers') diff --git a/source/blender/modifiers/intern/MOD_uvproject.c b/source/blender/modifiers/intern/MOD_uvproject.c index 1e6de0fb52b..10e174415e5 100644 --- a/source/blender/modifiers/intern/MOD_uvproject.c +++ b/source/blender/modifiers/intern/MOD_uvproject.c @@ -46,6 +46,7 @@ #include "BKE_camera.h" #include "BKE_library_query.h" +#include "BKE_material.h" #include "BKE_mesh.h" #include "BKE_DerivedMesh.h" @@ -59,7 +60,7 @@ static void initData(ModifierData *md) { UVProjectModifierData *umd = (UVProjectModifierData *) md; - umd->flags = 0; + umd->num_projectors = 1; umd->aspectx = umd->aspecty = 1.0f; umd->scalex = umd->scaley = 1.0f; @@ -136,7 +137,6 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, Image *image = umd->image; MPoly *mpoly, *mp; MLoop *mloop; - const bool override_image = (umd->flags & MOD_UVPROJECT_OVERRIDEIMAGE) != 0; Projector projectors[MOD_UVPROJECT_MAXPROJECTORS]; int num_projectors = 0; char uvname[MAX_CUSTOMDATA_LAYER_NAME]; @@ -243,9 +243,14 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, mpoly = dm->getPolyArray(dm); mloop = dm->getLoopArray(dm); + Image **ob_image_array = NULL; + if (image) { + ob_image_array = BKE_object_material_edit_image_get_array(ob); + } + /* apply coords as UVs, and apply image if tfaces are new */ for (i = 0, mp = mpoly; i < numPolys; ++i, ++mp, ++mt) { - if (override_image || !image || (mtexpoly == NULL || mt->tpage == image)) { + if (!image || (mtexpoly == NULL || (mp->mat_nr < ob->totcol ? ob_image_array[mp->mat_nr] : NULL) == image)) { if (num_projectors == 1) { if (projectors[0].uci) { unsigned int fidx = mp->totloop - 1; @@ -308,13 +313,13 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, } } } - - if (override_image && mtexpoly) { - mt->tpage = image; - } } MEM_freeN(coords); + + if (ob_image_array) { + MEM_freeN(ob_image_array); + } if (free_uci) { int j; -- cgit v1.2.3