[Bf-blender-cvs] [7a9ad029dd1] blender2.8: Remove TexFace, per-face images

Campbell Barton noreply at git.blender.org
Wed May 24 15:38:40 CEST 2017


Commit: 7a9ad029dd1d1afe42d54c9c181de887636db7c0
Author: Campbell Barton
Date:   Wed May 24 23:14:32 2017 +1000
Branches: blender2.8
https://developer.blender.org/rB7a9ad029dd1d1afe42d54c9c181de887636db7c0

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.

===================================================================

M	release/scripts/startup/bl_ui/properties_data_modifier.py
M	release/scripts/startup/bl_ui/properties_material.py
M	source/blender/blenkernel/BKE_material.h
M	source/blender/blenkernel/intern/customdata.c
M	source/blender/blenkernel/intern/library_query.c
M	source/blender/blenkernel/intern/material.c
M	source/blender/blenloader/intern/readfile.c
M	source/blender/blenloader/intern/versioning_legacy.c
M	source/blender/bmesh/intern/bmesh_operators.h
M	source/blender/bmesh/operators/bmo_similar.c
M	source/blender/collada/EffectExporter.cpp
M	source/blender/collada/ExportSettings.h
M	source/blender/collada/ImageExporter.cpp
M	source/blender/collada/ImageExporter.h
M	source/blender/collada/MeshImporter.cpp
M	source/blender/collada/MeshImporter.h
M	source/blender/collada/collada.cpp
M	source/blender/collada/collada.h
M	source/blender/editors/include/ED_uvedit.h
M	source/blender/editors/io/io_collada.c
M	source/blender/editors/mesh/editmesh_select.c
M	source/blender/editors/object/object_bake.c
M	source/blender/editors/space_image/space_image.c
M	source/blender/editors/transform/transform_conversions.c
M	source/blender/editors/uvedit/uvedit_buttons.c
M	source/blender/editors/uvedit/uvedit_draw.c
M	source/blender/editors/uvedit/uvedit_ops.c
M	source/blender/editors/uvedit/uvedit_unwrap_ops.c
M	source/blender/gpu/intern/gpu_draw.c
M	source/blender/makesdna/DNA_material_types.h
M	source/blender/makesdna/DNA_meshdata_types.h
M	source/blender/makesdna/DNA_modifier_types.h
M	source/blender/makesrna/intern/rna_material.c
M	source/blender/makesrna/intern/rna_mesh.c
M	source/blender/makesrna/intern/rna_modifier.c
M	source/blender/makesrna/intern/rna_scene_api.c
M	source/blender/modifiers/intern/MOD_uvproject.c
M	source/blender/python/bmesh/bmesh_py_types_meshdata.c
M	source/blender/render/extern/include/RE_multires_bake.h
M	source/blender/render/intern/source/bake.c
M	source/blender/render/intern/source/multires_bake.c
M	source/blender/render/intern/source/shadeinput.c
M	source/blender/render/intern/source/shadeoutput.c
M	source/blenderplayer/bad_level_call_stubs/stubs.c
M	source/gameengine/Converter/BL_BlenderDataConversion.cpp
M	source/gameengine/Ketsji/KX_BlenderMaterial.cpp
M	source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp

===================================================================

diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index d72855fab6b..e2c828e5469 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -989,7 +989,6 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
 
         split = layout.split()
         col = split.column()
-        col.prop(md, "use_image_override")
         col.prop(md, "projector_count", text="Projectors")
         for proj in md.projectors:
             col.prop(proj, "object", text="")
diff --git a/release/scripts/startup/bl_ui/properties_material.py b/release/scripts/startup/bl_ui/properties_material.py
index 568921cb8f0..0f747999ae2 100644
--- a/release/scripts/startup/bl_ui/properties_material.py
+++ b/release/scripts/startup/bl_ui/properties_material.py
@@ -794,11 +794,6 @@ class MATERIAL_PT_options(MaterialButtonsPanel, Panel):
         row.prop(mat, "use_light_group_local", text="Local")
 
         col = split.column()
-        col.prop(mat, "use_face_texture")
-        sub = col.column()
-        sub.active = mat.use_face_texture
-        sub.prop(mat, "use_face_texture_alpha")
-        col.separator()
         col.prop(mat, "use_vertex_color_paint")
         col.prop(mat, "use_vertex_color_light")
         col.prop(mat, "use_object_color")
@@ -806,6 +801,9 @@ class MATERIAL_PT_options(MaterialButtonsPanel, Panel):
         if simple_material(base_mat):
             col.prop(mat, "pass_index")
 
+        col.label("Edit Image")
+        col.template_ID(mat, "edit_image")
+
 
 class MATERIAL_PT_shadow(MaterialButtonsPanel, Panel):
     bl_label = "Shadow"
diff --git a/source/blender/blenkernel/BKE_material.h b/source/blender/blenkernel/BKE_material.h
index 8ae5c2b3c45..0a5d37631d1 100644
--- a/source/blender/blenkernel/BKE_material.h
+++ b/source/blender/blenkernel/BKE_material.h
@@ -86,6 +86,10 @@ short BKE_object_material_slot_find_index(struct Object *ob, struct Material *ma
 bool  BKE_object_material_slot_add(struct Object *ob);
 bool  BKE_object_material_slot_remove(struct Object *ob);
 
+struct Image  *BKE_object_material_edit_image_get(struct Object *ob, short mat_nr);
+struct Image **BKE_object_material_edit_image_get_array(struct Object *ob);
+bool           BKE_object_material_edit_image_set(struct Object *ob, short mat_nr, struct Image *image);
+
 void BKE_texpaint_slot_refresh_cache(struct Scene *scene, struct Material *ma);
 void BKE_texpaint_slots_refresh_object(struct Scene *scene, struct Object *ob);
 
@@ -114,9 +118,6 @@ void free_matcopybuf(void);
 void copy_matcopybuf(struct Material *ma);
 void paste_matcopybuf(struct Material *ma);
 
-/* handle backward compatibility for tface/materials called from doversion */	
-int do_version_tface(struct Main *main);
-
 #ifdef __cplusplus
 }
 #endif
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index 7c3f0ac630d..96b15a22554 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -419,7 +419,7 @@ static void layerSwap_tface(void *data, const int *corner_indices)
 
 static void layerDefault_tface(void *data, int count)
 {
-	static MTFace default_tf = {{{0, 0}, {1, 0}, {1, 1}, {0, 1}}, NULL,
+	static MTFace default_tf = {{{0, 0}, {1, 0}, {1, 1}, {0, 1}},
 		                        0, 0, TF_DYNAMIC | TF_CONVERTED, 0, 0};
 	MTFace *tf = (MTFace *)data;
 	int i;
diff --git a/source/blender/blenkernel/intern/library_query.c b/source/blender/blenkernel/intern/library_query.c
index 3c8d1c6d888..0c89a5bea42 100644
--- a/source/blender/blenkernel/intern/library_query.c
+++ b/source/blender/blenkernel/intern/library_query.c
@@ -643,31 +643,6 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call
 				for (i = 0; i < mesh->totcol; i++) {
 					CALLBACK_INVOKE(mesh->mat[i], IDWALK_CB_USER);
 				}
-
-				/* XXX Really not happy with this - probably texface should rather use some kind of
-				 * 'texture slots' and just set indices in each poly/face item - would also save some memory.
-				 * Maybe a nice TODO for blender2.8? */
-				if (mesh->mtface || mesh->mtpoly) {
-					for (i = 0; i < mesh->pdata.totlayer; i++) {
-						if (mesh->pdata.layers[i].type == CD_MTEXPOLY) {
-							MTexPoly *txface = (MTexPoly *)mesh->pdata.layers[i].data;
-
-							for (int j = 0; j < mesh->totpoly; j++, txface++) {
-								CALLBACK_INVOKE(txface->tpage, IDWALK_CB_USER_ONE);
-							}
-						}
-					}
-
-					for (i = 0; i < mesh->fdata.totlayer; i++) {
-						if (mesh->fdata.layers[i].type == CD_MTFACE) {
-							MTFace *tface = (MTFace *)mesh->fdata.layers[i].data;
-
-							for (int j = 0; j < mesh->totface; j++, tface++) {
-								CALLBACK_INVOKE(tface->tpage, IDWALK_CB_USER_ONE);
-							}
-						}
-					}
-				}
 				break;
 			}
 
@@ -710,6 +685,7 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call
 					library_foreach_ID_as_subdata_link((ID **)&material->nodetree, callback, user_data, flag, &data);
 				}
 				CALLBACK_INVOKE(material->group, IDWALK_CB_USER);
+				CALLBACK_INVOKE(material->edit_image, IDWALK_CB_USER);
 				break;
 			}
 
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index fb4aec0a380..61e3ede3e8a 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -229,6 +229,7 @@ Material *BKE_material_copy(Main *bmain, Material *ma)
 	man = BKE_libblock_copy(bmain, &ma->id);
 	
 	id_lib_extern((ID *)man->group);
+	id_lib_extern((ID *)man->edit_image);
 	
 	for (a = 0; a < MAX_MTEX; a++) {
 		if (ma->mtex[a]) {
@@ -944,7 +945,7 @@ static void do_init_render_material(Material *ma, int r_mode, float *amb)
 	if (needtang) ma->mode |= MA_NORMAP_TANG;
 	else ma->mode &= ~MA_NORMAP_TANG;
 	
-	if (ma->mode & (MA_VERTEXCOL | MA_VERTEXCOLP | MA_FACETEXTURE)) {
+	if (ma->mode & (MA_VERTEXCOL | MA_VERTEXCOLP)) {
 		needuv = 1;
 		if (r_mode & R_OSA) ma->texco |= TEXCO_OSA;     /* for texfaces */
 	}
@@ -1767,501 +1768,30 @@ void paste_matcopybuf(Material *ma)
 	ma->nodetree = ntreeCopyTree_ex(matcopybuf.nodetree, G.main, false);
 }
 
-
-/*********************** texface to material convert functions **********************/
-/* encode all the TF information into a single int */
-static int encode_tfaceflag(MTFace *tf, int convertall)
-{
-	/* calculate the flag */
-	int flag = tf->mode;
-
-	/* options that change the material offline render */
-	if (!convertall) {
-		flag &= ~TF_OBCOL;
-	}
-
-	/* clean flags that are not being converted */
-	flag &= ~TF_TEX;
-	flag &= ~TF_SHAREDVERT;
-	flag &= ~TF_SHAREDCOL;
-	flag &= ~TF_CONVERTED;
-
-	/* light tface flag is ignored in GLSL mode */
-	flag &= ~TF_LIGHT;
-	
-	/* 15 is how big the flag can be - hardcoded here and in decode_tfaceflag() */
-	flag |= tf->transp << 15;
-	
-	/* increase 1 so flag 0 is different than no flag yet */
-	return flag + 1;
-}
-
-/* set the material options based in the tface flag */
-static void decode_tfaceflag(Material *ma, int flag, int convertall)
+struct Image *BKE_object_material_edit_image_get(Object *ob, short mat_nr)
 {
-	int alphablend;
-	GameSettings *game = &ma->game;
-
-	/* flag is shifted in 1 to make 0 != no flag yet (see encode_tfaceflag) */
-	flag -= 1;
-
-	alphablend = flag >> 15;  /* encoded in the encode_tfaceflag function */
-	(*game).flag = 0;
-	
-	/* General Material Options */
-	if ((flag & TF_DYNAMIC) == 0) (*game).flag    |= GEMAT_NOPHYSICS;
-	
-	/* Material Offline Rendering Properties */
-	if (convertall) {
-		if (flag & TF_OBCOL) ma->shade_flag |= MA_OBCOLOR;
-	}
-	
-	/* Special Face Properties */
-	if ((flag & TF_TWOSIDE) == 0) (*game).flag |= GEMAT_BACKCULL;
-	if (flag & TF_INVISIBLE) (*game).flag |= GEMAT_INVISIBLE;
-	if (flag & TF_BMFONT) (*game).flag |= GEMAT_TEXT;
-	
-	/* Face Orientation */
-	if (flag & TF_BILLBOARD) (*game).face_orientation |= GEMAT_HALO;
-	else if (flag & TF_BILLBOARD2) (*game).face_orientation |= GEMAT_BILLBOARD;
-	else if (flag & TF_SHADOW) (*game).face_orientation |= GEMAT_SHADOW;
-	
-	/* Alpha Blend */
-	if (flag & TF_ALPHASORT && ELEM(alphablend, TF_ALPHA, TF_ADD)) (*game).alpha_blend = GEMAT_ALPHA_SORT;
-	else if (alphablend & TF_ALPHA) (*game).alpha_blend = GEMAT_ALPHA;
-	else if (alphablend & TF_ADD) (*game).alpha_blend = GEMAT_ADD;
-	else if (alphablend & TF_CLIP) (*game).alpha_blend = GEMAT_CLIP;
+	Material *ma = give_current_material(ob, mat_nr + 1);
+	return ma ? ma->edit_image : NULL;
 }
 
-/* boolean check to see if the mesh needs a material */
-static int check_tfaceneedmaterial(int flag)
+struct Image **BKE_object_material_edit_image_get_array(Object *ob)
 {
-	/* check if the flags we have are not deprecated != than default material options
-	 * also if only flags are visible and collision see if all objects using this mesh have this option in physics */
-
-	/* flag is shifted in 1 to make 0 != no flag yet (see encode_tfaceflag) */
-	flag -= 1;
-
-	/* deprecated flags */
-	flag &= ~TF_OBCOL;
-	flag &= ~TF_SHAREDVERT;
-	flag &= ~TF_SHAREDCOL;
-
-	/* light tface flag is ignored in GLSL mode */
-	flag &= ~TF_LIGHT;
-	
-	/* automatic detected if tex image has alpha */
-	flag &= ~(TF_ALPHA << 15);
-	/* automatic detected if using texture */
-	flag &= ~TF_TEX;
-
-	/* settings for the default NoMaterial */
-	if (flag == TF_DYNAMIC)
-		return 0;
-
-	else
-		return 1;
-}
-
-/* return number of digits of an integer */
-/* XXX to be optmized or replaced by an equivalent blender internal function */
-static int integer_getdigits(int number)
-{
-	int i = 0;
-	if (number == 0) return 1;
-
-	while (number != 0) {
-		number = (int)(number / 10);
-		i++;
-	}
-	return i;
-}
-
-static void calculate_tface_materialname(char *matname, char *newname, int flag)
-{
-	/* if flag has only light and collision and material matches those values
-	 * you can do strcpy(name, mat_name);
-	 * otherwise do: */
-	int digits = integer_getdigits(flag);
-	/* clamp the old name, remove the MA prefix and add the .TF.flag suffix
-	 * e.g. matname = "MALoooooooooooooongName"; newname = "Looooooooo

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list