Cleanup: Remove unnecessary dirty normal tags
These were redundant for one of a few reasons: - A call to `BKE_mesh_tag_coords_changed` was correct instead - A mesh has dirty normals when created from scratch anyway - The call was redundant with `BKE_mesh_runtime_clear_geometry`
This commit is contained in:
parent
192cd76b7c
commit
90fb1cc4e6
|
@ -39,7 +39,7 @@ bool BKE_mesh_runtime_ensure_edit_data(struct Mesh *mesh);
|
|||
void BKE_mesh_runtime_reset_edit_data(struct Mesh *mesh);
|
||||
|
||||
/**
|
||||
* Clear and any derived caches associated with the mesh geometry data. Examples include BVH
|
||||
* Clear and free any derived caches associated with the mesh geometry data. Examples include BVH
|
||||
* caches, normals, triangulation, etc. This should be called when replacing a mesh's geometry
|
||||
* directly or making other large changes to topology. It does not need to be called on new meshes.
|
||||
*
|
||||
|
|
|
@ -149,8 +149,8 @@ struct MeshRuntime {
|
|||
* #CustomData because they can be calculated on a `const` mesh, and adding custom data layers on
|
||||
* a `const` mesh is not thread-safe.
|
||||
*/
|
||||
bool vert_normals_dirty = false;
|
||||
bool poly_normals_dirty = false;
|
||||
bool vert_normals_dirty = true;
|
||||
bool poly_normals_dirty = true;
|
||||
float (*vert_normals)[3] = nullptr;
|
||||
float (*poly_normals)[3] = nullptr;
|
||||
|
||||
|
|
|
@ -91,10 +91,6 @@ static void mesh_init_data(ID *id)
|
|||
|
||||
mesh->runtime = new blender::bke::MeshRuntime();
|
||||
|
||||
/* A newly created mesh does not have normals, so tag them dirty. This will be cleared
|
||||
* by #BKE_mesh_vertex_normals_clear_dirty or #BKE_mesh_poly_normals_ensure. */
|
||||
BKE_mesh_normals_tag_dirty(mesh);
|
||||
|
||||
mesh->face_sets_color_seed = BLI_hash_int(PIL_check_seconds_timer_i() & UINT_MAX);
|
||||
}
|
||||
|
||||
|
@ -163,13 +159,6 @@ static void mesh_copy_data(Main *bmain, ID *id_dst, const ID *id_src, const int
|
|||
|
||||
mesh_dst->mselect = (MSelect *)MEM_dupallocN(mesh_dst->mselect);
|
||||
|
||||
/* Set normal layers dirty. They should be dirty by default on new meshes anyway, but being
|
||||
* explicit about it is safer. Alternatively normal layers could be copied if they aren't dirty,
|
||||
* avoiding recomputation in some cases. However, a copied mesh is often changed anyway, so that
|
||||
* idea is not clearly better. With proper reference counting, all custom data layers could be
|
||||
* copied as the cost would be much lower. */
|
||||
BKE_mesh_normals_tag_dirty(mesh_dst);
|
||||
|
||||
/* TODO: Do we want to add flag to prevent this? */
|
||||
if (mesh_src->key && (flag & LIB_ID_COPY_SHAPEKEY)) {
|
||||
BKE_id_copy_ex(bmain, &mesh_src->key->id, (ID **)&mesh_dst->key, flag);
|
||||
|
@ -363,10 +352,6 @@ static void mesh_blend_read_data(BlendDataReader *reader, ID *id)
|
|||
BLI_endian_switch_uint32_array(tf->col, 4);
|
||||
}
|
||||
}
|
||||
|
||||
/* We don't expect to load normals from files, since they are derived data. */
|
||||
BKE_mesh_normals_tag_dirty(mesh);
|
||||
BKE_mesh_assert_normals_dirty_or_calculated(mesh);
|
||||
}
|
||||
|
||||
static void mesh_blend_read_lib(BlendLibReader *reader, ID *id)
|
||||
|
|
|
@ -688,9 +688,6 @@ int ED_mesh_join_objects_exec(bContext *C, wmOperator *op)
|
|||
me->ldata = ldata;
|
||||
me->pdata = pdata;
|
||||
|
||||
/* Tag normals dirty because vertex positions could be changed from the original. */
|
||||
BKE_mesh_normals_tag_dirty(me);
|
||||
|
||||
/* old material array */
|
||||
for (a = 1; a <= ob->totcol; a++) {
|
||||
ma = ob->mat[a - 1];
|
||||
|
|
|
@ -220,7 +220,6 @@ static int sculpt_symmetrize_exec(bContext *C, wmOperator *op)
|
|||
BKE_mesh_mirror_apply_mirror_on_axis(bmain, mesh, sd->symmetrize_direction, dist);
|
||||
|
||||
ED_sculpt_undo_geometry_end(ob);
|
||||
BKE_mesh_normals_tag_dirty(mesh);
|
||||
BKE_mesh_batch_cache_dirty_tag(ob->data, BKE_MESH_BATCH_DIRTY_ALL);
|
||||
|
||||
break;
|
||||
|
|
|
@ -797,7 +797,6 @@ void BlenderStrokeRenderer::GenerateStrokeMesh(StrokeGroup *group, bool hasTex)
|
|||
} // loop over strokes
|
||||
|
||||
BKE_object_materials_test(freestyle_bmain, object_mesh, (ID *)mesh);
|
||||
BKE_mesh_normals_tag_dirty(mesh);
|
||||
|
||||
#if 0 // XXX
|
||||
BLI_assert(mesh->totvert == vertex_index);
|
||||
|
|
|
@ -147,6 +147,7 @@ static void read_mverts(CDStreamConfig &config, const AbcMeshData &mesh_data)
|
|||
mesh_data.ceil_positions != nullptr &&
|
||||
mesh_data.ceil_positions->size() == positions->size()) {
|
||||
read_mverts_interp(mverts, positions, mesh_data.ceil_positions, config.weight);
|
||||
BKE_mesh_tag_coords_changed(config.mesh);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -162,6 +163,8 @@ void read_mverts(Mesh &mesh, const P3fArraySamplePtr positions, const N3fArraySa
|
|||
|
||||
copy_zup_from_yup(mvert.co, pos_in.getValue());
|
||||
}
|
||||
BKE_mesh_tag_coords_changed(&mesh);
|
||||
|
||||
if (normals) {
|
||||
float(*vert_normals)[3] = BKE_mesh_vertex_normals_for_write(&mesh);
|
||||
for (const int64_t i : IndexRange(normals->size())) {
|
||||
|
@ -246,7 +249,6 @@ static void read_mpolys(CDStreamConfig &config, const AbcMeshData &mesh_data)
|
|||
static void process_no_normals(CDStreamConfig &config)
|
||||
{
|
||||
/* Absence of normals in the Alembic mesh is interpreted as 'smooth'. */
|
||||
BKE_mesh_normals_tag_dirty(config.mesh);
|
||||
}
|
||||
|
||||
static void process_loop_normals(CDStreamConfig &config, const N3fArraySamplePtr loop_normals_ptr)
|
||||
|
|
|
@ -613,14 +613,12 @@ void USDMeshReader::process_normals_vertex_varying(Mesh *mesh)
|
|||
void USDMeshReader::process_normals_face_varying(Mesh *mesh)
|
||||
{
|
||||
if (normals_.empty()) {
|
||||
BKE_mesh_normals_tag_dirty(mesh);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Check for normals count mismatches to prevent crashes. */
|
||||
if (normals_.size() != mesh->totloop) {
|
||||
std::cerr << "WARNING: loop normal count mismatch for mesh " << mesh->id.name << std::endl;
|
||||
BKE_mesh_normals_tag_dirty(mesh);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -658,14 +656,12 @@ void USDMeshReader::process_normals_face_varying(Mesh *mesh)
|
|||
void USDMeshReader::process_normals_uniform(Mesh *mesh)
|
||||
{
|
||||
if (normals_.empty()) {
|
||||
BKE_mesh_normals_tag_dirty(mesh);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Check for normals count mismatches to prevent crashes. */
|
||||
if (normals_.size() != mesh->totpoly) {
|
||||
std::cerr << "WARNING: uniform normal count mismatch for mesh " << mesh->id.name << std::endl;
|
||||
BKE_mesh_normals_tag_dirty(mesh);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -706,6 +702,7 @@ void USDMeshReader::read_mesh_sample(ImportSettings *settings,
|
|||
mvert.co[1] = positions_[i][1];
|
||||
mvert.co[2] = positions_[i][2];
|
||||
}
|
||||
BKE_mesh_tag_coords_changed(mesh);
|
||||
|
||||
read_vertex_creases(mesh, motionSampleTime);
|
||||
}
|
||||
|
@ -718,10 +715,6 @@ void USDMeshReader::read_mesh_sample(ImportSettings *settings,
|
|||
else if (normal_interpolation_ == pxr::UsdGeomTokens->uniform) {
|
||||
process_normals_uniform(mesh);
|
||||
}
|
||||
else {
|
||||
/* Default */
|
||||
BKE_mesh_normals_tag_dirty(mesh);
|
||||
}
|
||||
}
|
||||
|
||||
/* Process point normals after reading polys. */
|
||||
|
|
|
@ -716,7 +716,6 @@ static void rna_MeshPolygon_flip(ID *id, MPoly *mp)
|
|||
BKE_mesh_polygon_flip(mp, loops, &me->ldata);
|
||||
BKE_mesh_tessface_clear(me);
|
||||
BKE_mesh_runtime_clear_geometry(me);
|
||||
BKE_mesh_normals_tag_dirty(me);
|
||||
}
|
||||
|
||||
static void rna_MeshLoopTriangle_verts_get(PointerRNA *ptr, int *values)
|
||||
|
|
|
@ -169,7 +169,6 @@ static void rna_Mesh_flip_normals(Mesh *mesh)
|
|||
BKE_mesh_polys_flip(
|
||||
BKE_mesh_polys(mesh), BKE_mesh_loops_for_write(mesh), &mesh->ldata, mesh->totpoly);
|
||||
BKE_mesh_tessface_clear(mesh);
|
||||
BKE_mesh_normals_tag_dirty(mesh);
|
||||
BKE_mesh_runtime_clear_geometry(mesh);
|
||||
|
||||
DEG_id_tag_update(&mesh->id, 0);
|
||||
|
|
Loading…
Reference in New Issue