diff options
-rw-r--r-- | release/io/export_ply.py | 12 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_mesh.c | 19 |
2 files changed, 23 insertions, 8 deletions
diff --git a/release/io/export_ply.py b/release/io/export_ply.py index 6fdf4bf41b9..3668693db16 100644 --- a/release/io/export_ply.py +++ b/release/io/export_ply.py @@ -130,12 +130,10 @@ def write(filename, scene, ob, \ smooth = f.smooth - # XXX need face normals - """ if not smooth: - normal = tuple(f.no) + normal = tuple(f.normal) normal_key = rvec3d(normal) - """ + if faceUV: uv = active_uv_layer[i] uv = uv.uv1, uv.uv2, uv.uv3, uv.uv4 # XXX - crufty :/ @@ -149,12 +147,10 @@ def write(filename, scene, ob, \ pf= ply_faces[i] for j, vidx in enumerate(f_verts): v = mesh_verts[vidx] - """ + if smooth: - normal= tuple(v.no) + normal= tuple(v.normal) normal_key = rvec3d(normal) - """ - normal_key = None # XXX if faceUV: uvcoord= uv[j][0], 1.0-uv[j][1] diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index 3a7015b65be..525814f1f5e 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -39,6 +39,7 @@ #include "DNA_scene_types.h" #include "BLI_editVert.h" +#include "BLI_arithb.h" #include "BKE_customdata.h" #include "BKE_depsgraph.h" @@ -110,6 +111,17 @@ static void rna_MEdge_crease_set(PointerRNA *ptr, float value) medge->crease= (char)(CLAMPIS(value*255.0f, 0, 255)); } +static void rna_MeshFace_normal_get(PointerRNA *ptr, float *values) +{ + Mesh *me= (Mesh*)ptr->id.data; + MFace *mface= (MFace*)ptr->data; + + if(mface->v4) + CalcNormFloat4(me->mvert[mface->v1].co, me->mvert[mface->v2].co, me->mvert[mface->v3].co, me->mvert[mface->v4].co, values); + else + CalcNormFloat(me->mvert[mface->v1].co, me->mvert[mface->v2].co, me->mvert[mface->v3].co, values); +} + /* notice red and blue are swapped */ static void rna_MeshColor_color1_get(PointerRNA *ptr, float *values) { @@ -892,6 +904,13 @@ static void rna_def_mface(BlenderRNA *brna) prop= RNA_def_property(srna, "smooth", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_SMOOTH); RNA_def_property_ui_text(prop, "Smooth", ""); + + prop= RNA_def_property(srna, "normal", PROP_FLOAT, PROP_VECTOR); + 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_MeshFace_normal_get", NULL, NULL); + RNA_def_property_ui_text(prop, "face normal", "local space unit length normal vector for this face"); } static void rna_def_mtface(BlenderRNA *brna) |