diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-07-27 22:17:21 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-07-27 22:17:21 +0400 |
commit | 9dc819a56d72cbdbd45994472fe85d3c3dcd8338 (patch) | |
tree | d3e10d799e866c920779a092d0065748f0dae8ef /source/blender/makesrna | |
parent | d0422dec359e7e10938bc43e93b4fa590f2de3a2 (diff) |
readonly face normal option eg.
me.faces[0].normal
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r-- | source/blender/makesrna/intern/rna_mesh.c | 19 |
1 files changed, 19 insertions, 0 deletions
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) |