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:
authorBastien Montagne <montagne29@wanadoo.fr>2013-09-10 19:26:12 +0400
committerBastien Montagne <montagne29@wanadoo.fr>2013-09-10 19:26:12 +0400
commit135f6a72d42d704468dd29c470390df52b905d1b (patch)
tree99c70d8191e1f22beeb87d3df3a7291af50a138b /source/blender/makesrna/intern/rna_mesh.c
parent44c7a87ada3ae260f14bbd25a26bd89341f1543f (diff)
Split normals API, to get per-vertex per-face normals, useful to export sharp edges in a compatible way.
Many thanks to Campbell and Brecht for reviews.
Diffstat (limited to 'source/blender/makesrna/intern/rna_mesh.c')
-rw-r--r--source/blender/makesrna/intern/rna_mesh.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c
index ead702a56a6..2820a7a3aa9 100644
--- a/source/blender/makesrna/intern/rna_mesh.c
+++ b/source/blender/makesrna/intern/rna_mesh.c
@@ -320,6 +320,20 @@ static void rna_MEdge_crease_set(PointerRNA *ptr, float value)
medge->crease = (char)(CLAMPIS(value * 255.0f, 0, 255));
}
+static void rna_MeshLoop_normal_get(PointerRNA *ptr, float *values)
+{
+ Mesh *me = rna_mesh(ptr);
+ MLoop *ml = (MLoop *)ptr->data;
+ const float (*vec)[3] = CustomData_get(&me->ldata, (int)(ml - me->mloop), CD_NORMAL);
+
+ if (!vec) {
+ zero_v3(values);
+ }
+ else {
+ copy_v3_v3(values, (const float *)vec);
+ }
+}
+
static void rna_MeshPolygon_normal_get(PointerRNA *ptr, float *values)
{
Mesh *me = rna_mesh(ptr);
@@ -1838,6 +1852,16 @@ static void rna_def_mloop(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_int_funcs(prop, "rna_MeshLoop_index_get", NULL, NULL);
RNA_def_property_ui_text(prop, "Index", "Index of this loop");
+
+ prop = RNA_def_property(srna, "normal", PROP_FLOAT, PROP_DIRECTION);
+ RNA_def_property_array(prop, 3);
+ RNA_def_property_range(prop, -1.0f, 1.0f);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_float_funcs(prop, "rna_MeshLoop_normal_get", NULL, NULL);
+ RNA_def_property_ui_text(prop, "Loop Normal",
+ "Local space unit length split normal vector of this vertex for this polygon "
+ "(only computed on demand!)");
+
}
static void rna_def_mpolygon(BlenderRNA *brna)