Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2021-06-14 15:56:03 +0300
committerCampbell Barton <ideasman42@gmail.com>2021-06-14 16:01:19 +0300
commit8a1860bd9aecddf611b64e3e842bdc8c76f15cc6 (patch)
tree52afad79ca08551fa22bb35d082719299f0476ef /source/blender/editors
parent6bef2559047461794eb3ff27de15f4caf5ddcf1e (diff)
BMesh: support face-normal calculation in normal & looptri functions
Support calculating face normals when tessellating. When this is done before updating vertex normals it gives ~20% performance improvement. Now vertex normal calculation only needs to perform a single pass on the mesh vertices when called after tessellation. Extended versions of normal & looptri update functions have been added: - BM_mesh_calc_tessellation_ex - BM_mesh_normals_update_ex Most callers don't need to be aware of this detail by using: - BKE_editmesh_looptri_and_normals_calc - BKE_editmesh_looptri_and_normals_calc_with_partial - EDBM_update also takes advantage of this, where calling EDBM_update with calc_looptri & calc_normals enabled uses the faster normal updating logic.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/include/ED_mesh.h3
-rw-r--r--source/blender/editors/mesh/editmesh_utils.c24
-rw-r--r--source/blender/editors/object/object_edit.c4
-rw-r--r--source/blender/editors/object/object_hook.c3
-rw-r--r--source/blender/editors/object/object_relations.c3
-rw-r--r--source/blender/editors/transform/transform_convert_mesh.c6
-rw-r--r--source/blender/editors/transform/transform_convert_mesh_skin.c3
7 files changed, 28 insertions, 18 deletions
diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h
index b76c35c7d7a..0e2be5eb568 100644
--- a/source/blender/editors/include/ED_mesh.h
+++ b/source/blender/editors/include/ED_mesh.h
@@ -36,6 +36,7 @@ struct BMFace;
struct BMLoop;
struct BMVert;
struct BMesh;
+struct BMeshNormalsUpdate_Params;
struct Base;
struct Depsgraph;
struct ID;
@@ -76,6 +77,8 @@ struct BMFace *EDBM_verts_mirror_get_face(struct BMEditMesh *em, struct BMFace *
void EDBM_verts_mirror_cache_clear(struct BMEditMesh *em, struct BMVert *v);
void EDBM_verts_mirror_cache_end(struct BMEditMesh *em);
+void EDBM_mesh_normals_update_ex(struct BMEditMesh *em,
+ const struct BMeshNormalsUpdate_Params *params);
void EDBM_mesh_normals_update(struct BMEditMesh *em);
void EDBM_mesh_clear(struct BMEditMesh *em);
diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c
index c8f8f12ba90..071ca818120 100644
--- a/source/blender/editors/mesh/editmesh_utils.c
+++ b/source/blender/editors/mesh/editmesh_utils.c
@@ -1405,9 +1405,17 @@ bool EDBM_mesh_reveal(BMEditMesh *em, bool select)
/** \name Update API
* \{ */
+void EDBM_mesh_normals_update_ex(BMEditMesh *em, const struct BMeshNormalsUpdate_Params *params)
+{
+ BM_mesh_normals_update_ex(em->bm, params);
+}
+
void EDBM_mesh_normals_update(BMEditMesh *em)
{
- BM_mesh_normals_update(em->bm);
+ EDBM_mesh_normals_update_ex(em,
+ &(const struct BMeshNormalsUpdate_Params){
+ .face_normals = true,
+ });
}
void EDBM_stats_update(BMEditMesh *em)
@@ -1449,12 +1457,18 @@ void EDBM_update(Mesh *mesh, const struct EDBMUpdate_Params *params)
DEG_id_tag_update(&mesh->id, ID_RECALC_GEOMETRY);
WM_main_add_notifier(NC_GEOM | ND_DATA, &mesh->id);
- if (params->calc_normals) {
- EDBM_mesh_normals_update(em);
+ if (params->calc_normals && params->calc_looptri) {
+ /* Calculating both has some performance gains. */
+ BKE_editmesh_looptri_and_normals_calc(em);
}
+ else {
+ if (params->calc_normals) {
+ EDBM_mesh_normals_update(em);
+ }
- if (params->calc_looptri) {
- BKE_editmesh_looptri_calc(em);
+ if (params->calc_looptri) {
+ BKE_editmesh_looptri_calc(em);
+ }
}
if (params->is_destructive) {
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index 5be572baec5..c8923bb55c1 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -794,9 +794,7 @@ bool ED_object_editmode_enter_ex(Main *bmain, Scene *scene, Object *ob, int flag
BMEditMesh *em = BKE_editmesh_from_object(ob);
if (LIKELY(em)) {
- /* order doesn't matter */
- EDBM_mesh_normals_update(em);
- BKE_editmesh_looptri_calc(em);
+ BKE_editmesh_looptri_and_normals_calc(em);
}
WM_main_add_notifier(NC_SCENE | ND_MODE | NS_EDITMODE_MESH, NULL);
diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c
index d56ee17a73f..7122fd09892 100644
--- a/source/blender/editors/object/object_hook.c
+++ b/source/blender/editors/object/object_hook.c
@@ -350,8 +350,7 @@ static bool object_hook_index_array(Main *bmain,
em = me->edit_mesh;
- EDBM_mesh_normals_update(em);
- BKE_editmesh_looptri_calc(em);
+ BKE_editmesh_looptri_and_normals_calc(em);
/* check selected vertices first */
if (return_editmesh_indexar(em, r_tot, r_indexar, r_cent) == 0) {
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index f3433833b5f..cdf12bcb5df 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -153,8 +153,7 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op)
em = me->edit_mesh;
- EDBM_mesh_normals_update(em);
- BKE_editmesh_looptri_calc(em);
+ BKE_editmesh_looptri_and_normals_calc(em);
/* Make sure the evaluated mesh is updated.
*
diff --git a/source/blender/editors/transform/transform_convert_mesh.c b/source/blender/editors/transform/transform_convert_mesh.c
index 422370cb13b..4c674136b6a 100644
--- a/source/blender/editors/transform/transform_convert_mesh.c
+++ b/source/blender/editors/transform/transform_convert_mesh.c
@@ -1842,13 +1842,11 @@ void recalcData_mesh(TransInfo *t)
* It's impractical to calculate this ahead of time.
* Further, the down side of using partial updates when their not needed is negligible. */
if (em->bm->totvert == em->bm->totvertsel) {
- EDBM_mesh_normals_update(em);
- BKE_editmesh_looptri_calc(em);
+ BKE_editmesh_looptri_and_normals_calc(em);
}
else {
BMPartialUpdate *partial_update_cache = tc_mesh_ensure_partial_update(t, tc);
- BM_mesh_normals_update_with_partial(em->bm, partial_update_cache);
- BKE_editmesh_looptri_calc_with_partial(em, partial_update_cache);
+ BKE_editmesh_looptri_and_normals_calc_with_partial(em, partial_update_cache);
}
}
}
diff --git a/source/blender/editors/transform/transform_convert_mesh_skin.c b/source/blender/editors/transform/transform_convert_mesh_skin.c
index 7c61da31f72..69b44998980 100644
--- a/source/blender/editors/transform/transform_convert_mesh_skin.c
+++ b/source/blender/editors/transform/transform_convert_mesh_skin.c
@@ -300,8 +300,7 @@ void recalcData_mesh_skin(TransInfo *t)
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
DEG_id_tag_update(tc->obedit->data, ID_RECALC_GEOMETRY);
BMEditMesh *em = BKE_editmesh_from_object(tc->obedit);
- EDBM_mesh_normals_update(em);
- BKE_editmesh_looptri_calc(em);
+ BKE_editmesh_looptri_and_normals_calc(em);
}
}
/** \} */