diff options
author | Philipp Oeser <info@graphics-engineer.com> | 2020-10-14 17:16:37 +0300 |
---|---|---|
committer | Philipp Oeser <info@graphics-engineer.com> | 2020-10-18 11:56:39 +0300 |
commit | e1cd6fae342519048819231137f25cd8b6d2ee45 (patch) | |
tree | 4b020297d36f19ff41aa019f480117c51a24ca1c /source/blender | |
parent | 9c7fda6de3e828be40999c960bce2dc89e54b7cb (diff) |
Avoid Assert in BKE_mesh_calc_loop_tangent_ex
Code could call CustomData_get_layer_index_n with a negative index (if
no active and/or render UV layers are found). This would assert since
rBe86785c51445.
Spotted while looking into T81398.
Differential Revision: https://developer.blender.org/D9212
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/intern/mesh_tangent.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/source/blender/blenkernel/intern/mesh_tangent.c b/source/blender/blenkernel/intern/mesh_tangent.c index d6f945cf34f..c8f15fef71a 100644 --- a/source/blender/blenkernel/intern/mesh_tangent.c +++ b/source/blender/blenkernel/intern/mesh_tangent.c @@ -724,7 +724,9 @@ void BKE_mesh_calc_loop_tangent_ex(const MVert *mvert, *tangent_mask_curr_p = tangent_mask_curr; /* Update active layer index */ - int act_uv_index = CustomData_get_layer_index_n(loopdata, CD_MLOOPUV, act_uv_n); + int act_uv_index = (act_uv_n != -1) ? + CustomData_get_layer_index_n(loopdata, CD_MLOOPUV, act_uv_n) : + -1; if (act_uv_index != -1) { int tan_index = CustomData_get_named_layer_index( loopdata, CD_TANGENT, loopdata->layers[act_uv_index].name); @@ -732,7 +734,9 @@ void BKE_mesh_calc_loop_tangent_ex(const MVert *mvert, } /* else tangent has been built from orco */ /* Update render layer index */ - int ren_uv_index = CustomData_get_layer_index_n(loopdata, CD_MLOOPUV, ren_uv_n); + int ren_uv_index = (ren_uv_n != -1) ? + CustomData_get_layer_index_n(loopdata, CD_MLOOPUV, ren_uv_n) : + -1; if (ren_uv_index != -1) { int tan_index = CustomData_get_named_layer_index( loopdata, CD_TANGENT, loopdata->layers[ren_uv_index].name); |