From 819152527fd425fef54107bd6841887ace51e66e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 15 Jun 2021 14:51:48 +1000 Subject: BMesh: assert that face normals have been updated for tessellation This catches missing normal updates that may cause invalid tessellation. --- source/blender/bmesh/intern/bmesh_mesh_tessellate.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'source/blender/bmesh') diff --git a/source/blender/bmesh/intern/bmesh_mesh_tessellate.c b/source/blender/bmesh/intern/bmesh_mesh_tessellate.c index ca1218c97f6..2f9d5758385 100644 --- a/source/blender/bmesh/intern/bmesh_mesh_tessellate.c +++ b/source/blender/bmesh/intern/bmesh_mesh_tessellate.c @@ -58,6 +58,13 @@ BLI_INLINE void mesh_calc_tessellation_for_face_impl(BMLoop *(*looptris)[3], MemArena **pf_arena_p, const bool face_normal) { +#ifdef DEBUG + /* The face normal is used for projecting faces into 2D space for tessellation. + * Invalid normals may result in invalid tessellation. + * Either `face_normal` should be true or normals should be updated first. */ + BLI_assert(face_normal || BM_face_is_normal_valid(efa)); +#endif + switch (efa->len) { case 3: { /* `0 1 2` -> `0 1 2` */ -- cgit v1.2.3