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:
authorHans Goudey <h.goudey@me.com>2022-06-23 20:00:25 +0300
committerHans Goudey <h.goudey@me.com>2022-06-23 20:00:25 +0300
commit54182e4925de4ee7e49e4351479e79cb257acc73 (patch)
treed598250e653ee2e61f875b113ce4f41f87e4a084 /source/blender/blenkernel/intern/mesh_runtime.cc
parent3e5a4d14124029dd3ccb111de2db299bb405d668 (diff)
Mesh: Add an explicit "positions changed" function
We store various lazily calculated caches on meshes, some of which depend on the vertex positions staying the same. The current API to invalidate these caches is a bit confusing. With an explicit set of functions modeled after the functions in `BKE_node_tree_update.h`, it becomes clear which function to call. This may become more important if more lazy caches are added in the future. Differential Revision: https://developer.blender.org/D14760
Diffstat (limited to 'source/blender/blenkernel/intern/mesh_runtime.cc')
-rw-r--r--source/blender/blenkernel/intern/mesh_runtime.cc25
1 files changed, 20 insertions, 5 deletions
diff --git a/source/blender/blenkernel/intern/mesh_runtime.cc b/source/blender/blenkernel/intern/mesh_runtime.cc
index 90e9a2a2ff6..d4bc47d5fd4 100644
--- a/source/blender/blenkernel/intern/mesh_runtime.cc
+++ b/source/blender/blenkernel/intern/mesh_runtime.cc
@@ -244,11 +244,8 @@ bool BKE_mesh_runtime_clear_edit_data(Mesh *mesh)
void BKE_mesh_runtime_clear_geometry(Mesh *mesh)
{
- if (mesh->runtime.bvh_cache) {
- bvhcache_free(mesh->runtime.bvh_cache);
- mesh->runtime.bvh_cache = nullptr;
- }
- MEM_SAFE_FREE(mesh->runtime.looptris.array);
+ BKE_mesh_tag_coords_changed(mesh);
+
/* TODO(sergey): Does this really belong here? */
if (mesh->runtime.subdiv_ccg != nullptr) {
BKE_subdiv_ccg_destroy(mesh->runtime.subdiv_ccg);
@@ -259,6 +256,24 @@ void BKE_mesh_runtime_clear_geometry(Mesh *mesh)
MEM_SAFE_FREE(mesh->runtime.subsurf_face_dot_tags);
}
+void BKE_mesh_tag_coords_changed(Mesh *mesh)
+{
+ BKE_mesh_normals_tag_dirty(mesh);
+ MEM_SAFE_FREE(mesh->runtime.looptris.array);
+ if (mesh->runtime.bvh_cache) {
+ bvhcache_free(mesh->runtime.bvh_cache);
+ mesh->runtime.bvh_cache = nullptr;
+ }
+}
+
+void BKE_mesh_tag_coords_changed_uniformly(Mesh *mesh)
+{
+ BKE_mesh_tag_coords_changed(mesh);
+ /* The normals didn't change, since all vertices moved by the same amount. */
+ BKE_mesh_poly_normals_clear_dirty(mesh);
+ BKE_mesh_vertex_normals_clear_dirty(mesh);
+}
+
/** \} */
/* -------------------------------------------------------------------- */