diff options
author | Hans Goudey <h.goudey@me.com> | 2022-02-21 19:40:59 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-02-21 19:40:59 +0300 |
commit | a81cc5cbcb6c9e9ef4bee610ac1d325d33884e98 (patch) | |
tree | 3c641452be81e8f2f1b97108fa08eb1381d3e2f1 /source/blender/python/mathutils | |
parent | 869dd2e6998f7c89f9c18cb90aaa38ac0b9ac91f (diff) |
Fix: Avoid potential use of dirty normals
Instead of accessing the `CD_NORMAL` layer directly,
use the proper API for accessing mesh normals. Even if the
layer exists, the values might be incorrect due to a deformation.
Related to ef0e21f0ae71d, 969c4a45ce09100e, and T95839.
Diffstat (limited to 'source/blender/python/mathutils')
-rw-r--r-- | source/blender/python/mathutils/mathutils_bvhtree.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/source/blender/python/mathutils/mathutils_bvhtree.c b/source/blender/python/mathutils/mathutils_bvhtree.c index 588d3753eab..28687ce2d13 100644 --- a/source/blender/python/mathutils/mathutils_bvhtree.c +++ b/source/blender/python/mathutils/mathutils_bvhtree.c @@ -1180,10 +1180,8 @@ static PyObject *C_BVHTree_FromObject(PyObject *UNUSED(cls), PyObject *args, PyO tree = BLI_bvhtree_new((int)tris_len, epsilon, PY_BVH_TREE_TYPE_DEFAULT, PY_BVH_AXIS_DEFAULT); if (tree) { orig_index = MEM_mallocN(sizeof(*orig_index) * (size_t)tris_len, __func__); - CustomData *pdata = &mesh->pdata; - orig_normal = CustomData_get_layer(pdata, CD_NORMAL); /* can be NULL */ - if (orig_normal) { - orig_normal = MEM_dupallocN(orig_normal); + if (!BKE_mesh_poly_normals_are_dirty(mesh)) { + orig_normal = MEM_dupallocN(BKE_mesh_poly_normals_ensure(mesh)); } for (i = 0; i < tris_len; i++, lt++) { |