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:
authorLuca Rood <dev@lucarood.com>2017-01-10 22:46:31 +0300
committerLuca Rood <dev@lucarood.com>2017-01-11 01:29:22 +0300
commit0bb57759ecb6fd5a73828ee8ab56456084732f3e (patch)
tree9623efd4e90d73e6d6aac5a5d6126a9cdf5008c8
parent5e1d438d5e7a4f70c1db67314cf213ee48f3d9ee (diff)
Replace "cent" functions from math_geom with "mid" ones from math_vector
-rw-r--r--source/blender/blenkernel/intern/mesh_evaluate.c24
-rw-r--r--source/blender/blenlib/BLI_math_geom.h4
-rw-r--r--source/blender/blenlib/BLI_math_vector.h1
-rw-r--r--source/blender/blenlib/intern/math_geom.c24
-rw-r--r--source/blender/blenlib/intern/math_vector.c10
-rw-r--r--source/blender/bmesh/intern/bmesh_interp.c2
-rw-r--r--source/blender/modifiers/intern/MOD_surfacedeform.c8
-rw-r--r--source/blender/render/intern/source/occlusion.c4
8 files changed, 30 insertions, 47 deletions
diff --git a/source/blender/blenkernel/intern/mesh_evaluate.c b/source/blender/blenkernel/intern/mesh_evaluate.c
index a3fe73e4b11..f9eba118383 100644
--- a/source/blender/blenkernel/intern/mesh_evaluate.c
+++ b/source/blender/blenkernel/intern/mesh_evaluate.c
@@ -1909,19 +1909,19 @@ void BKE_mesh_calc_poly_center(
const MVert *mvarray, float r_cent[3])
{
if (mpoly->totloop == 3) {
- cent_tri_v3(r_cent,
- mvarray[loopstart[0].v].co,
- mvarray[loopstart[1].v].co,
- mvarray[loopstart[2].v].co
- );
+ mid_v3_v3v3v3(r_cent,
+ mvarray[loopstart[0].v].co,
+ mvarray[loopstart[1].v].co,
+ mvarray[loopstart[2].v].co
+ );
}
else if (mpoly->totloop == 4) {
- cent_quad_v3(r_cent,
- mvarray[loopstart[0].v].co,
- mvarray[loopstart[1].v].co,
- mvarray[loopstart[2].v].co,
- mvarray[loopstart[3].v].co
- );
+ mid_v3_v3v3v3v3(r_cent,
+ mvarray[loopstart[0].v].co,
+ mvarray[loopstart[1].v].co,
+ mvarray[loopstart[2].v].co,
+ mvarray[loopstart[3].v].co
+ );
}
else {
mesh_calc_ngon_center(mpoly, loopstart, mvarray, r_cent);
@@ -1978,7 +1978,7 @@ static float mesh_calc_poly_planar_area_centroid(
tri_area = area_tri_signed_v3(v1, v2, v3, normal);
total_area += tri_area;
- cent_tri_v3(tri_cent, v1, v2, v3);
+ mid_v3_v3v3v3(tri_cent, v1, v2, v3);
madd_v3_v3fl(r_cent, tri_cent, tri_area);
copy_v3_v3(v2, v3);
diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h
index cd141c959c8..c6475037ac2 100644
--- a/source/blender/blenlib/BLI_math_geom.h
+++ b/source/blender/blenlib/BLI_math_geom.h
@@ -44,10 +44,6 @@ extern "C" {
/********************************** Polygons *********************************/
-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]);
float normal_poly_v3(float r[3], const float verts[][3], unsigned int nr);
diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h
index d15fe1a95dc..8e0884ba347 100644
--- a/source/blender/blenlib/BLI_math_vector.h
+++ b/source/blender/blenlib/BLI_math_vector.h
@@ -234,6 +234,7 @@ void mid_v3_v3v3(float r[3], const float a[3], const float b[3]);
void mid_v2_v2v2(float r[2], const float a[2], const float b[2]);
void mid_v3_v3v3v3(float v[3], const float v1[3], const float v2[3], const float v3[3]);
void mid_v3_v3v3v3v3(float v[3], const float v1[3], const float v2[3], const float v3[3], const float v4[3]);
+void mid_v3_v3_array(float r[3], const float (*vec_arr)[3], const unsigned int nbr);
void mid_v3_v3v3_angle_weighted(float r[3], const float a[3], const float b[3]);
void mid_v3_angle_weighted(float r[3]);
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c
index 9d0e390c253..6707fab2527 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -37,30 +37,6 @@
/********************************** Polygons *********************************/
-void cent_tri_v3(float cent[3], const float v1[3], const float v2[3], const float v3[3])
-{
- cent[0] = (v1[0] + v2[0] + v3[0]) / 3.0f;
- cent[1] = (v1[1] + v2[1] + v3[1]) / 3.0f;
- cent[2] = (v1[2] + v2[2] + v3[2]) / 3.0f;
-}
-
-void cent_quad_v3(float cent[3], const float v1[3], const float v2[3], const float v3[3], const float v4[3])
-{
- cent[0] = 0.25f * (v1[0] + v2[0] + v3[0] + v4[0]);
- cent[1] = 0.25f * (v1[1] + v2[1] + v3[1] + v4[1]);
- 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];
diff --git a/source/blender/blenlib/intern/math_vector.c b/source/blender/blenlib/intern/math_vector.c
index 95d5c9fde87..dfecc3b556a 100644
--- a/source/blender/blenlib/intern/math_vector.c
+++ b/source/blender/blenlib/intern/math_vector.c
@@ -280,6 +280,16 @@ void mid_v3_v3v3v3v3(float v[3], const float v1[3], const float v2[3], const flo
v[2] = (v1[2] + v2[2] + v3[2] + v4[2]) / 4.0f;
}
+void mid_v3_v3_array(float r[3], const float (*vec_arr)[3], const unsigned int nbr)
+{
+ const float factor = 1.0f / (float)nbr;
+ zero_v3(r);
+
+ for (unsigned int i = 0; i < nbr; i++) {
+ madd_v3_v3fl(r, vec_arr[i], factor);
+ }
+}
+
/**
* Specialized function for calculating normals.
* fastpath for:
diff --git a/source/blender/bmesh/intern/bmesh_interp.c b/source/blender/bmesh/intern/bmesh_interp.c
index f51013c3f1c..20ee31251e8 100644
--- a/source/blender/bmesh/intern/bmesh_interp.c
+++ b/source/blender/bmesh/intern/bmesh_interp.c
@@ -339,7 +339,7 @@ static bool mdisp_in_mdispquad(
compute_mdisp_quad(l_dst, l_dst_f_center, v1, v2, v3, v4, e1, e2);
/* expand quad a bit */
- cent_quad_v3(c, v1, v2, v3, v4);
+ mid_v3_v3v3v3v3(c, v1, v2, v3, v4);
sub_v3_v3(v1, c); sub_v3_v3(v2, c);
sub_v3_v3(v3, c); sub_v3_v3(v4, c);
diff --git a/source/blender/modifiers/intern/MOD_surfacedeform.c b/source/blender/modifiers/intern/MOD_surfacedeform.c
index d153ed951ef..5e78cd8f2a1 100644
--- a/source/blender/modifiers/intern/MOD_surfacedeform.c
+++ b/source/blender/modifiers/intern/MOD_surfacedeform.c
@@ -512,7 +512,7 @@ BLI_INLINE SDefBindWeightData *computeBindWeights(SDefBindCalcData * const data,
}
/* Compute poly's parametric data */
- cent_poly_v3(bpoly->centroid, bpoly->coords, poly->totloop);
+ mid_v3_v3_array(bpoly->centroid, bpoly->coords, poly->totloop);
normal_poly_v3(bpoly->normal, bpoly->coords, poly->totloop);
/* Compute poly skew angle and axis */
@@ -893,7 +893,7 @@ static void bindVert(void *userdata, void *UNUSED(userdata_chunk), const int ind
copy_v3_v3(v2, data->mvert[sdbind->vert_inds[1]].co);
copy_v3_v3(v3, bpoly->centroid);
- cent_tri_v3(cent, v1, v2, v3);
+ mid_v3_v3v3v3(cent, v1, v2, v3);
normal_tri_v3(norm, v1, v2, v3);
add_v3_v3v3(tmp_vec, point_co, bpoly->normal);
@@ -930,7 +930,7 @@ static void bindVert(void *userdata, void *UNUSED(userdata_chunk), const int ind
copy_v3_v3(v2, data->mvert[sdbind->vert_inds[1]].co);
copy_v3_v3(v3, data->mvert[sdbind->vert_inds[2]].co);
- cent_tri_v3(cent, v1, v2, v3);
+ mid_v3_v3v3v3(cent, v1, v2, v3);
normal_tri_v3(norm, v1, v2, v3);
add_v3_v3v3(tmp_vec, point_co, bpoly->normal);
@@ -1133,7 +1133,7 @@ static void surfacedeformModifier_do(ModifierData *md, float (*vertexCos)[3], in
/* ---------- centroid mode ---------- */
else if (sdbind->mode == MOD_SDEF_MODE_CENTROID) {
float cent[3];
- cent_poly_v3(cent, coords, sdbind->numverts);
+ mid_v3_v3_array(cent, coords, sdbind->numverts);
madd_v3_v3fl(temp, mvert[sdbind->vert_inds[0]].co, sdbind->vert_weights[0]);
madd_v3_v3fl(temp, mvert[sdbind->vert_inds[1]].co, sdbind->vert_weights[1]);
diff --git a/source/blender/render/intern/source/occlusion.c b/source/blender/render/intern/source/occlusion.c
index b3d31e3b93a..ddcd2e84520 100644
--- a/source/blender/render/intern/source/occlusion.c
+++ b/source/blender/render/intern/source/occlusion.c
@@ -329,7 +329,7 @@ static void occ_face(const OccFace *face, float co[3], float normal[3], float *a
if (vlr->v4)
mid_v3_v3v3(co, vlr->v1->co, vlr->v3->co);
else
- cent_tri_v3(co, vlr->v1->co, vlr->v2->co, vlr->v3->co);
+ mid_v3_v3v3v3(co, vlr->v1->co, vlr->v2->co, vlr->v3->co);
if (obi->flag & R_TRANSFORMED)
mul_m4_v3(obi->mat, co);
@@ -1245,7 +1245,7 @@ static void *exec_strandsurface_sample(void *data)
normal_quad_v3(n, co1, co2, co3, co4);
}
else {
- cent_tri_v3(co, co1, co2, co3);
+ mid_v3_v3v3v3(co, co1, co2, co3);
normal_tri_v3(n, co1, co2, co3);
}
negate_v3(n);