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>2016-02-28 17:29:56 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2016-02-28 17:29:56 +0300
commit877f44162853664791f0ff4fa93f856384d0eed7 (patch)
treeed924b94bebd5cec0ad5455b7e90d481b63ad80a /source/blender/makesrna/intern/rna_mesh.c
parentea76ec2866d11156b689287f4190dfe4e79314b2 (diff)
BKE_mesh: add polygon flipping tools.
Those new functions invert the winding of polygons, effectively inverting their normals. A helper was also added to allow swapping two items in customdata layers. Being able to invert normals outside of BMesh area is very important in several places, like IO scripts or customnormals modifiers... Reviewers: campbellbarton Differential Revision: https://developer.blender.org/D1814
Diffstat (limited to 'source/blender/makesrna/intern/rna_mesh.c')
-rw-r--r--source/blender/makesrna/intern/rna_mesh.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c
index 686f8331ac4..1d734864833 100644
--- a/source/blender/makesrna/intern/rna_mesh.c
+++ b/source/blender/makesrna/intern/rna_mesh.c
@@ -418,6 +418,14 @@ static float rna_MeshPolygon_area_get(PointerRNA *ptr)
return BKE_mesh_calc_poly_area(mp, me->mloop + mp->loopstart, me->mvert);
}
+static void rna_MeshPolygon_flip(ID *id, MPoly *mp)
+{
+ Mesh *me = (Mesh *)id;
+
+ BKE_mesh_polygon_flip(mp, me->mloop, &me->ldata);
+ BKE_mesh_tessface_clear(me);
+}
+
static void rna_MeshTessFace_normal_get(PointerRNA *ptr, float *values)
{
Mesh *me = rna_mesh(ptr);
@@ -2138,6 +2146,7 @@ static void rna_def_mpolygon(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
+ FunctionRNA *func;
srna = RNA_def_struct(brna, "MeshPolygon", NULL);
RNA_def_struct_sdna(srna, "MPoly");
@@ -2216,6 +2225,11 @@ static void rna_def_mpolygon(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_int_funcs(prop, "rna_MeshPolygon_index_get", NULL, NULL);
RNA_def_property_ui_text(prop, "Index", "Index of this polygon");
+
+ func = RNA_def_function(srna, "flip", "rna_MeshPolygon_flip");
+ RNA_def_function_flag(func, FUNC_USE_SELF_ID);
+ RNA_def_function_ui_description(func, "Invert winding of this polygon (flip its normal)");
+
}
/* mesh.loop_uvs */