diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/BKE_mesh.h | 12 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/cloth.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/dynamicpaint.c | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/geometry_component_mesh.cc | 6 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/mesh.cc | 7 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/mesh_runtime.cc | 25 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/multires_reshape_apply_base.c | 2 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt.c | 2 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt_undo.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_mesh.c | 9 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_boolean.cc | 2 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_ocean.c | 2 | ||||
-rw-r--r-- | source/blender/nodes/geometry/nodes/node_geo_scale_elements.cc | 6 |
13 files changed, 57 insertions, 24 deletions
diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h index 23ec69babc8..8e038a1d3d9 100644 --- a/source/blender/blenkernel/BKE_mesh.h +++ b/source/blender/blenkernel/BKE_mesh.h @@ -52,6 +52,18 @@ extern "C" { # define BKE_MESH_OMP_LIMIT 10000 #endif +/* mesh_runtime.cc */ + +/** + * Call after changing vertex positions to tag lazily calculated caches for recomputation. + */ +void BKE_mesh_tag_coords_changed(struct Mesh *mesh); + +/** + * Call after moving every mesh vertex by the same translation. + */ +void BKE_mesh_tag_coords_changed_uniformly(struct Mesh *mesh); + /* *** mesh.c *** */ struct BMesh *BKE_mesh_to_bmesh_ex(const struct Mesh *me, diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index ab9a27a3996..8622174231c 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -1171,7 +1171,7 @@ static Mesh *cloth_make_rest_mesh(ClothModifierData *clmd, Mesh *mesh) for (unsigned i = 0; i < mesh->totvert; i++, verts++) { copy_v3_v3(mvert[i].co, verts->xrest); } - BKE_mesh_normals_tag_dirty(new_mesh); + BKE_mesh_tag_coords_changed(new_mesh); return new_mesh; } diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index e5bb70f8cda..a4262e08e39 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -2024,13 +2024,13 @@ static Mesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData *pmd, Object * settings.use_threading = (sData->total_points > 1000); BLI_task_parallel_range( 0, sData->total_points, &data, dynamic_paint_apply_surface_wave_cb, &settings); - BKE_mesh_normals_tag_dirty(result); + BKE_mesh_tag_coords_changed(result); } /* displace */ if (surface->type == MOD_DPAINT_SURFACE_T_DISPLACE) { dynamicPaint_applySurfaceDisplace(surface, result); - BKE_mesh_normals_tag_dirty(result); + BKE_mesh_tag_coords_changed(result); } } } diff --git a/source/blender/blenkernel/intern/geometry_component_mesh.cc b/source/blender/blenkernel/intern/geometry_component_mesh.cc index 8a021e596bd..88ea1af8a8d 100644 --- a/source/blender/blenkernel/intern/geometry_component_mesh.cc +++ b/source/blender/blenkernel/intern/geometry_component_mesh.cc @@ -864,11 +864,11 @@ static void set_vertex_position(MVert &vert, float3 position) copy_v3_v3(vert.co, position); } -static void tag_normals_dirty_when_writing_position(GeometryComponent &component) +static void tag_component_positions_changed(GeometryComponent &component) { Mesh *mesh = get_mesh_from_component_for_write(component); if (mesh != nullptr) { - BKE_mesh_normals_tag_dirty(mesh); + BKE_mesh_tag_coords_changed(mesh); } } @@ -1213,7 +1213,7 @@ static ComponentAttributeProviders create_attribute_providers_for_mesh() point_access, make_derived_read_attribute<MVert, float3, get_vertex_position>, make_derived_write_attribute<MVert, float3, get_vertex_position, set_vertex_position>, - tag_normals_dirty_when_writing_position); + tag_component_positions_changed); static NormalAttributeProvider normal; diff --git a/source/blender/blenkernel/intern/mesh.cc b/source/blender/blenkernel/intern/mesh.cc index 7c86aff6624..ffbd824712a 100644 --- a/source/blender/blenkernel/intern/mesh.cc +++ b/source/blender/blenkernel/intern/mesh.cc @@ -1684,7 +1684,7 @@ void BKE_mesh_transform(Mesh *me, const float mat[4][4], bool do_keys) mul_m3_v3(m3, *lnors); } } - BKE_mesh_normals_tag_dirty(me); + BKE_mesh_tag_coords_changed(me); } void BKE_mesh_translate(Mesh *me, const float offset[3], const bool do_keys) @@ -1706,6 +1706,7 @@ void BKE_mesh_translate(Mesh *me, const float offset[3], const bool do_keys) } } } + BKE_mesh_tag_coords_changed_uniformly(me); } void BKE_mesh_tessface_ensure(Mesh *mesh) @@ -1904,7 +1905,7 @@ void BKE_mesh_vert_coords_apply(Mesh *mesh, const float (*vert_coords)[3]) for (int i = 0; i < mesh->totvert; i++, mv++) { copy_v3_v3(mv->co, vert_coords[i]); } - BKE_mesh_normals_tag_dirty(mesh); + BKE_mesh_tag_coords_changed(mesh); } void BKE_mesh_vert_coords_apply_with_mat4(Mesh *mesh, @@ -1918,7 +1919,7 @@ void BKE_mesh_vert_coords_apply_with_mat4(Mesh *mesh, for (int i = 0; i < mesh->totvert; i++, mv++) { mul_v3_m4v3(mv->co, mat, vert_coords[i]); } - BKE_mesh_normals_tag_dirty(mesh); + BKE_mesh_tag_coords_changed(mesh); } void BKE_mesh_calc_normals_split_ex(Mesh *mesh, MLoopNorSpaceArray *r_lnors_spacearr) 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); +} + /** \} */ /* -------------------------------------------------------------------- */ diff --git a/source/blender/blenkernel/intern/multires_reshape_apply_base.c b/source/blender/blenkernel/intern/multires_reshape_apply_base.c index 837b64affa8..f7d29806353 100644 --- a/source/blender/blenkernel/intern/multires_reshape_apply_base.c +++ b/source/blender/blenkernel/intern/multires_reshape_apply_base.c @@ -156,7 +156,7 @@ void multires_reshape_apply_base_refit_base_mesh(MultiresReshapeContext *reshape /* Vertices were moved around, need to update normals after all the vertices are updated * Probably this is possible to do in the loop above, but this is rather tricky because * we don't know all needed vertices' coordinates there yet. */ - BKE_mesh_normals_tag_dirty(base_mesh); + BKE_mesh_tag_coords_changed(base_mesh); } void multires_reshape_apply_base_refine_from_base(MultiresReshapeContext *reshape_context) diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 94ae5459d19..0ec75525bc0 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -3116,7 +3116,7 @@ void SCULPT_vertcos_to_key(Object *ob, KeyBlock *kb, const float (*vertCos)[3]) for (a = 0; a < me->totvert; a++, mvert++) { copy_v3_v3(mvert->co, vertCos[a]); } - BKE_mesh_normals_tag_dirty(me); + BKE_mesh_tag_coords_changed(me); } /* Apply new coords on active key block, no need to re-allocate kb->data here! */ diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index e82f14b1ca7..f50e942f795 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -855,7 +855,7 @@ static void sculpt_undo_restore_list(bContext *C, Depsgraph *depsgraph, ListBase if (tag_update) { Mesh *mesh = ob->data; - BKE_mesh_normals_tag_dirty(mesh); + BKE_mesh_tag_coords_changed(mesh); BKE_sculptsession_free_deformMats(ss); } diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index fd548ea6a56..2cdcae53677 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -295,6 +295,13 @@ static void rna_Mesh_update_facemask(Main *bmain, Scene *scene, PointerRNA *ptr) rna_Mesh_update_draw(bmain, scene, ptr); } +static void rna_Mesh_update_positions_tag(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + Mesh *mesh = (Mesh *)ptr->data; + BKE_mesh_tag_coords_changed(mesh); + rna_Mesh_update_data_legacy_deg_tag_all(bmain, scene, ptr); +} + /** \} */ /* -------------------------------------------------------------------- */ @@ -1727,7 +1734,7 @@ static void rna_def_mvert(BlenderRNA *brna) prop = RNA_def_property(srna, "co", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_ui_text(prop, "Location", ""); - RNA_def_property_update(prop, 0, "rna_Mesh_update_data_legacy_deg_tag_all"); + RNA_def_property_update(prop, 0, "rna_Mesh_update_positions_tag"); prop = RNA_def_property(srna, "normal", PROP_FLOAT, PROP_DIRECTION); RNA_def_property_array(prop, 3); diff --git a/source/blender/modifiers/intern/MOD_boolean.cc b/source/blender/modifiers/intern/MOD_boolean.cc index 5739de1c65c..deafe795061 100644 --- a/source/blender/modifiers/intern/MOD_boolean.cc +++ b/source/blender/modifiers/intern/MOD_boolean.cc @@ -146,7 +146,7 @@ static Mesh *get_quick_mesh( mul_m4_v3(omat, mv->co); } - BKE_mesh_normals_tag_dirty(result); + BKE_mesh_tag_coords_changed(result); } break; diff --git a/source/blender/modifiers/intern/MOD_ocean.c b/source/blender/modifiers/intern/MOD_ocean.c index b5411eee883..75708851030 100644 --- a/source/blender/modifiers/intern/MOD_ocean.c +++ b/source/blender/modifiers/intern/MOD_ocean.c @@ -469,7 +469,7 @@ static Mesh *doOcean(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mes } } - BKE_mesh_normals_tag_dirty(mesh); + BKE_mesh_tag_coords_changed(mesh); if (allocated_ocean) { BKE_ocean_free(omd->ocean); diff --git a/source/blender/nodes/geometry/nodes/node_geo_scale_elements.cc b/source/blender/nodes/geometry/nodes/node_geo_scale_elements.cc index 698efa8865d..d674f611c9f 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_scale_elements.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_scale_elements.cc @@ -183,8 +183,7 @@ static void scale_vertex_islands_uniformly(Mesh &mesh, } }); - /* Positions have changed, so the normals will have to be recomputed. */ - BKE_mesh_normals_tag_dirty(&mesh); + BKE_mesh_tag_coords_changed(&mesh); } static void scale_vertex_islands_on_axis(Mesh &mesh, @@ -228,8 +227,7 @@ static void scale_vertex_islands_on_axis(Mesh &mesh, } }); - /* Positions have changed, so the normals will have to be recomputed. */ - BKE_mesh_normals_tag_dirty(&mesh); + BKE_mesh_tag_coords_changed(&mesh); } static Vector<ElementIsland> prepare_face_islands(const Mesh &mesh, const IndexMask face_selection) |