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.
This commit is contained in:
Bastien Montagne 2017-11-19 20:42:55 +01:00
parent 0a69e3b307
commit 784614655f
Notes: blender-bot 2023-02-14 10:29:32 +01:00
Referenced by issue #53683, 2.79a release
Referenced by issue #53343, Custom Normal Data Transfer Crashes when some vertexes have no faces
1 changed files with 7 additions and 1 deletions

View File

@ -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];