[Bf-blender-cvs] [784614655f5] master: Fix T53343: Custom Normal Data Transfer Crashes when some vertexes have no faces.

Bastien Montagne noreply at git.blender.org
Sun Nov 19 20:44:47 CET 2017


Commit: 784614655f55f81eec04c2b898e8ab8dbb99a3ec
Author: Bastien Montagne
Date:   Sun Nov 19 20:42:55 2017 +0100
Branches: master
https://developer.blender.org/rB784614655f55f81eec04c2b898e8ab8dbb99a3ec

Fix T53343: Custom Normal Data Transfer Crashes when some vertexes have no faces.

Odd nobody noticed this earlier, was obvious bug in code logic here... :/

To be backported to 2.79a.

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

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

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

diff --git a/source/blender/blenkernel/intern/mesh_remap.c b/source/blender/blenkernel/intern/mesh_remap.c
index b0580f75044..f321c94bf00 100644
--- a/source/blender/blenkernel/intern/mesh_remap.c
+++ b/source/blender/blenkernel/intern/mesh_remap.c
@@ -1482,6 +1482,7 @@ void BKE_mesh_remap_calc_loops_from_dm(
 
 							for (i = vert_to_refelem_map_src[nearest.index].count; i--;) {
 								const int index_src = vert_to_refelem_map_src[nearest.index].indices[i];
+								BLI_assert(index_src != -1);
 								const float dot = dot_v3v3(nors_src[index_src], *nor_dst);
 
 								pidx_src = (mode == MREMAP_MODE_LOOP_NEAREST_LOOPNOR) ?
@@ -1522,7 +1523,12 @@ void BKE_mesh_remap_calc_loops_from_dm(
 									}
 								}
 							}
-							if (mode == MREMAP_MODE_LOOP_NEAREST_POLYNOR) {
+							if (best_index_src == -1) {
+								/* We found no item to map back from closest vertex... */
+								best_nor_dot = -1.0f;
+								hit_dist = FLT_MAX;
+							}
+							else if (mode == MREMAP_MODE_LOOP_NEAREST_POLYNOR) {
 								/* Our best_index_src is a poly one for now!
 								 * Have to find its loop matching our closest vertex. */
 								mp_src = &polys_src[best_index_src];



More information about the Bf-blender-cvs mailing list