diff options
Diffstat (limited to 'source/blender/blenkernel/intern/editmesh.c')
-rw-r--r-- | source/blender/blenkernel/intern/editmesh.c | 60 |
1 files changed, 54 insertions, 6 deletions
diff --git a/source/blender/blenkernel/intern/editmesh.c b/source/blender/blenkernel/intern/editmesh.c index 472de1f3c77..b908df267c4 100644 --- a/source/blender/blenkernel/intern/editmesh.c +++ b/source/blender/blenkernel/intern/editmesh.c @@ -96,7 +96,8 @@ BMEditMesh *BKE_editmesh_from_object(Object *ob) return ((Mesh *)ob->data)->edit_mesh; } -static void editmesh_tessface_calc_intern(BMEditMesh *em) +static void editmesh_tessface_calc_intern(BMEditMesh *em, + const struct BMeshCalcTessellation_Params *params) { /* allocating space before calculating the tessellation */ @@ -130,12 +131,13 @@ static void editmesh_tessface_calc_intern(BMEditMesh *em) em->tottri = looptris_tot; /* after allocating the em->looptris, we're ready to tessellate */ - BM_mesh_calc_tessellation(em->bm, em->looptris); + BM_mesh_calc_tessellation_ex(em->bm, em->looptris, params); } -void BKE_editmesh_looptri_calc(BMEditMesh *em) +void BKE_editmesh_looptri_calc_ex(BMEditMesh *em, + const struct BMeshCalcTessellation_Params *params) { - editmesh_tessface_calc_intern(em); + editmesh_tessface_calc_intern(em, params); /* commented because editbmesh_build_data() ensures we get tessfaces */ #if 0 @@ -149,12 +151,58 @@ void BKE_editmesh_looptri_calc(BMEditMesh *em) #endif } -void BKE_editmesh_looptri_calc_with_partial(BMEditMesh *em, struct BMPartialUpdate *bmpinfo) +void BKE_editmesh_looptri_calc(BMEditMesh *em) +{ + BKE_editmesh_looptri_calc_ex(em, + &(const struct BMeshCalcTessellation_Params){ + .face_normals = false, + }); +} + +/** + * Performing the face normal calculation at the same time as tessellation + * gives a reasonable performance boost (approx ~20% faster). + */ +void BKE_editmesh_looptri_and_normals_calc(BMEditMesh *em) +{ + BKE_editmesh_looptri_calc_ex(em, + &(const struct BMeshCalcTessellation_Params){ + .face_normals = true, + }); + BM_mesh_normals_update_ex(em->bm, + &(const struct BMeshNormalsUpdate_Params){ + .face_normals = false, + }); +} + +void BKE_editmesh_looptri_calc_with_partial_ex(BMEditMesh *em, + struct BMPartialUpdate *bmpinfo, + const struct BMeshCalcTessellation_Params *params) { BLI_assert(em->tottri == poly_to_tri_count(em->bm->totface, em->bm->totloop)); BLI_assert(em->looptris != NULL); - BM_mesh_calc_tessellation_with_partial(em->bm, em->looptris, bmpinfo); + BM_mesh_calc_tessellation_with_partial_ex(em->bm, em->looptris, bmpinfo, params); +} + +void BKE_editmesh_looptri_calc_with_partial(BMEditMesh *em, struct BMPartialUpdate *bmpinfo) +{ + BKE_editmesh_looptri_calc_with_partial_ex(em, bmpinfo, false); +} + +void BKE_editmesh_looptri_and_normals_calc_with_partial(BMEditMesh *em, + struct BMPartialUpdate *bmpinfo) +{ + BKE_editmesh_looptri_calc_with_partial_ex(em, + bmpinfo, + &(const struct BMeshCalcTessellation_Params){ + .face_normals = true, + }); + BM_mesh_normals_update_with_partial_ex(em->bm, + bmpinfo, + &(const struct BMeshNormalsUpdate_Params){ + .face_normals = false, + }); } void BKE_editmesh_free_derivedmesh(BMEditMesh *em) |