[Bf-blender-cvs] [ce6227b] cloth-improvements: Add cent_poly_v3 function

Luca Rood noreply at git.blender.org
Fri Dec 9 17:38:55 CET 2016


Commit: ce6227b6beefc2b58f900397318492bc529cd99c
Author: Luca Rood
Date:   Sun Nov 27 00:44:48 2016 -0200
Branches: cloth-improvements
https://developer.blender.org/rBce6227b6beefc2b58f900397318492bc529cd99c

Add cent_poly_v3 function

===================================================================

M	source/blender/blenlib/BLI_math_geom.h
M	source/blender/blenlib/intern/math_geom.c

===================================================================

diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h
index 514b030..46e780c 100644
--- a/source/blender/blenlib/BLI_math_geom.h
+++ b/source/blender/blenlib/BLI_math_geom.h
@@ -46,6 +46,7 @@ extern "C" {
 
 void cent_tri_v3(float r[3], const float a[3], const float b[3], const float c[3]);
 void cent_quad_v3(float r[3], const float a[3], const float b[3], const float c[3], const float d[3]);
+void cent_poly_v3(float cent[3], const float verts[][3], unsigned int nr);
 
 float normal_tri_v3(float r[3], const float a[3], const float b[3], const float c[3]);
 float normal_quad_v3(float r[3], const float a[3], const float b[3], const float c[3], const float d[3]);
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c
index f31d093..2610fbd 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -51,6 +51,16 @@ void cent_quad_v3(float cent[3], const float v1[3], const float v2[3], const flo
 	cent[2] = 0.25f * (v1[2] + v2[2] + v3[2] + v4[2]);
 }
 
+void cent_poly_v3(float cent[3], const float verts[][3], unsigned int nr)
+{
+	unsigned int i;
+	zero_v3(cent);
+
+	for (i = 0; i < nr; i++) {
+		madd_v3_v3fl(cent, verts[i], 1.0f / (float)nr);
+	}
+}
+
 void cross_tri_v3(float n[3], const float v1[3], const float v2[3], const float v3[3])
 {
 	float n1[3], n2[3];




More information about the Bf-blender-cvs mailing list