[Bf-blender-cvs] [68f5ce1] surface-deform-modifier: Add cent_poly_v3 function
Luca Rood
noreply at git.blender.org
Wed Nov 30 02:09:46 CET 2016
Commit: 68f5ce194b8d547a6c20b9651b1a39d21f222b28
Author: Luca Rood
Date: Sun Nov 27 00:44:48 2016 -0200
Branches: surface-deform-modifier
https://developer.blender.org/rB68f5ce194b8d547a6c20b9651b1a39d21f222b28
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 9039225..3e2a00c 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 654c2ae..5ff8c90 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