[Bf-blender-cvs] [f34fc60] master: Libquery: fix missing image pointers from Mesh's UV layers.

Bastien Montagne noreply at git.blender.org
Fri Jul 8 18:20:06 CEST 2016


Commit: f34fc60aa4b8682c3e3b13907dad4407a1f91b2a
Author: Bastien Montagne
Date:   Fri Jul 8 17:28:28 2016 +0200
Branches: master
https://developer.blender.org/rBf34fc60aa4b8682c3e3b13907dad4407a1f91b2a

Libquery: fix missing image pointers from Mesh's UV layers.

Not really happy with this, could lead to a **lot** of callback executions...
But libquery foreach looper must go over **all** ID pointers,
otherwise remapping & co is broken!

A possible fix for future would be to have 'image slots' defined at root of poly/facetex layers,
and just a (short) index in each face/poly item - would also save a reasonable amount of memory...

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

M	source/blender/blenkernel/intern/library_query.c

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

diff --git a/source/blender/blenkernel/intern/library_query.c b/source/blender/blenkernel/intern/library_query.c
index d068a39..fbf4575 100644
--- a/source/blender/blenkernel/intern/library_query.c
+++ b/source/blender/blenkernel/intern/library_query.c
@@ -45,6 +45,7 @@
 #include "DNA_linestyle_types.h"
 #include "DNA_material_types.h"
 #include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
 #include "DNA_meta_types.h"
 #include "DNA_movieclip_types.h"
 #include "DNA_mask_types.h"
@@ -492,6 +493,31 @@ void BKE_library_foreach_ID_link(ID *id, LibraryIDLinkCallback callback, void *u
 				for (i = 0; i < mesh->totcol; i++) {
 					CALLBACK_INVOKE(mesh->mat[i], IDWALK_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_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_USER_ONE);
+							}
+						}
+					}
+				}
 				break;
 			}




More information about the Bf-blender-cvs mailing list