Mesh: Make vertex normal property read-only

This commit makes the `MeshVertex.normal` property read-only.
In practice it already was, since the value could be overwritten at any
time if code requests updated normals, so this just clarifies that
position and avoids misleading users.

Differential Revision: https://developer.blender.org/D14696
This commit is contained in:
Hans Goudey 2022-04-25 14:50:57 -05:00
parent 8e1b16534d
commit 891268aa82
Notes: blender-bot 2023-02-14 09:02:41 +01:00
Referenced by issue #97018, Meshes vertex normals changed via Python API are not used by dupli vert instances
1 changed files with 2 additions and 16 deletions

View File

@ -313,18 +313,6 @@ static void rna_MeshVertex_normal_get(PointerRNA *ptr, float *value)
copy_v3_v3(value, vert_normals[index]);
}
static void rna_MeshVertex_normal_set(PointerRNA *ptr, const float *value)
{
Mesh *mesh = rna_mesh(ptr);
float(*vert_normals)[3] = BKE_mesh_vertex_normals_for_write(mesh);
const int index = (MVert *)ptr->data - mesh->mvert;
BLI_assert(index >= 0);
BLI_assert(index < mesh->totvert);
copy_v3_v3(vert_normals[index], value);
}
static float rna_MeshVertex_bevel_weight_get(PointerRNA *ptr)
{
MVert *mvert = (MVert *)ptr->data;
@ -1740,11 +1728,9 @@ static void rna_def_mvert(BlenderRNA *brna)
RNA_def_property_update(prop, 0, "rna_Mesh_update_data_legacy_deg_tag_all");
prop = RNA_def_property(srna, "normal", PROP_FLOAT, PROP_DIRECTION);
// RNA_def_property_float_sdna(prop, NULL, "no");
RNA_def_property_array(prop, 3);
RNA_def_property_range(prop, -1.0f, 1.0f);
RNA_def_property_float_funcs(
prop, "rna_MeshVertex_normal_get", "rna_MeshVertex_normal_set", NULL);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_float_funcs(prop, "rna_MeshVertex_normal_get", NULL, NULL);
RNA_def_property_ui_text(prop, "Normal", "Vertex Normal");
prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);