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:
authorCampbell Barton <ideasman42@gmail.com>2014-03-30 04:08:33 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-03-30 04:08:33 +0400
commit1f58bfb8bebf207d3020ff474ac5e018c8179f25 (patch)
treecf365a66923b4a03bcfbf6ef43d07ccf6309a19e /source/blender/modifiers
parent23ef10c705a21d86e06f64d7af06fddbd9a42928 (diff)
Code cleanup: de-duplicate cotangent weight function & add arg sizes
Diffstat (limited to 'source/blender/modifiers')
-rw-r--r--source/blender/modifiers/intern/MOD_laplaciandeform.c28
-rw-r--r--source/blender/modifiers/intern/MOD_laplaciansmooth.c35
-rw-r--r--source/blender/modifiers/intern/MOD_meshdeform.c2
3 files changed, 15 insertions, 50 deletions
diff --git a/source/blender/modifiers/intern/MOD_laplaciandeform.c b/source/blender/modifiers/intern/MOD_laplaciandeform.c
index 8e2a58b2236..31bae2a192e 100644
--- a/source/blender/modifiers/intern/MOD_laplaciandeform.c
+++ b/source/blender/modifiers/intern/MOD_laplaciandeform.c
@@ -138,24 +138,6 @@ static void deleteLaplacianSystem(LaplacianSystem *sys)
MEM_SAFE_FREE(sys);
}
-static float cotan_weight(const float v1[3], const float v2[3], const float v3[3])
-{
- float a[3], b[3], c[3], clen;
-
- sub_v3_v3v3(a, v2, v1);
- sub_v3_v3v3(b, v3, v1);
- cross_v3_v3v3(c, a, b);
-
- clen = len_v3(c);
-
- if (clen > FLT_EPSILON) {
- return dot_v3v3(a, b) / clen;
- }
- else {
- return 0.0f;
- }
-}
-
static void createFaceRingMap(
const int mvert_tot, const MFace *mface, const int mface_tot,
MeshElemMap **r_map, int **r_indices)
@@ -306,9 +288,9 @@ static void initLaplacianMatrix(LaplacianSystem *sys)
if (has_4_vert) {
- w2 = (cotan_weight(v4, v1, v2) + cotan_weight(v3, v1, v2)) / 2.0f;
- w3 = (cotan_weight(v2, v3, v1) + cotan_weight(v4, v1, v3)) / 2.0f;
- w4 = (cotan_weight(v2, v4, v1) + cotan_weight(v3, v4, v1)) / 2.0f;
+ w2 = (cotangent_tri_weight_v3(v4, v1, v2) + cotangent_tri_weight_v3(v3, v1, v2)) / 2.0f;
+ w3 = (cotangent_tri_weight_v3(v2, v3, v1) + cotangent_tri_weight_v3(v4, v1, v3)) / 2.0f;
+ w4 = (cotangent_tri_weight_v3(v2, v4, v1) + cotangent_tri_weight_v3(v3, v4, v1)) / 2.0f;
sys->delta[idv1][0] -= v4[0] * w4;
sys->delta[idv1][1] -= v4[1] * w4;
@@ -321,8 +303,8 @@ static void initLaplacianMatrix(LaplacianSystem *sys)
nlMatrixAdd(idv1, idv4, -w4);
}
else {
- w2 = cotan_weight(v3, v1, v2);
- w3 = cotan_weight(v2, v3, v1);
+ w2 = cotangent_tri_weight_v3(v3, v1, v2);
+ w3 = cotangent_tri_weight_v3(v2, v3, v1);
w4 = 0.0f;
}
diff --git a/source/blender/modifiers/intern/MOD_laplaciansmooth.c b/source/blender/modifiers/intern/MOD_laplaciansmooth.c
index 130013af75b..e494fbf23fd 100644
--- a/source/blender/modifiers/intern/MOD_laplaciansmooth.c
+++ b/source/blender/modifiers/intern/MOD_laplaciansmooth.c
@@ -88,7 +88,6 @@ static CustomDataMask required_data_mask(Object *ob, ModifierData *md);
static bool is_disabled(ModifierData *md, int useRenderParams);
static float average_area_quad_v3(float *v1, float *v2, float *v3, float *v4);
static float compute_volume(float (*vertexCos)[3], MFace *mfaces, int numFaces);
-static float cotan_weight(float *v1, float *v2, float *v3);
static LaplacianSystem *init_laplacian_system(int a_numEdges, int a_numFaces, int a_numVerts);
static void copy_data(ModifierData *md, ModifierData *target);
static void delete_laplacian_system(LaplacianSystem *sys);
@@ -204,22 +203,6 @@ static float average_area_quad_v3(float *v1, float *v2, float *v3, float *v4)
return areaq / 2.0f;
}
-static float cotan_weight(float *v1, float *v2, float *v3)
-{
- float a[3], b[3], c[3], clen;
-
- sub_v3_v3v3(a, v2, v1);
- sub_v3_v3v3(b, v3, v1);
- cross_v3_v3v3(c, a, b);
-
- clen = len_v3(c);
-
- if (clen == 0.0f)
- return 0.0f;
-
- return dot_v3v3(a, b) / clen;
-}
-
static float compute_volume(float (*vertexCos)[3], MFace *mfaces, int numFaces)
{
float vol = 0.0f;
@@ -367,17 +350,17 @@ static void init_laplacian_matrix(LaplacianSystem *sys)
v3 = sys->vertexCos[idv3];
v4 = sys->vertexCos[idv4];
- w2 = cotan_weight(v4, v1, v2) + cotan_weight(v3, v1, v2);
- w3 = cotan_weight(v2, v3, v1) + cotan_weight(v4, v1, v3);
- w4 = cotan_weight(v2, v4, v1) + cotan_weight(v3, v4, v1);
+ w2 = cotangent_tri_weight_v3(v4, v1, v2) + cotangent_tri_weight_v3(v3, v1, v2);
+ w3 = cotangent_tri_weight_v3(v2, v3, v1) + cotangent_tri_weight_v3(v4, v1, v3);
+ w4 = cotangent_tri_weight_v3(v2, v4, v1) + cotangent_tri_weight_v3(v3, v4, v1);
sys->vweights[idv1] += (w2 + w3 + w4) / 4.0f;
}
}
else {
- w1 = cotan_weight(v1, v2, v3) / 2.0f;
- w2 = cotan_weight(v2, v3, v1) / 2.0f;
- w3 = cotan_weight(v3, v1, v2) / 2.0f;
+ w1 = cotangent_tri_weight_v3(v1, v2, v3) / 2.0f;
+ w2 = cotangent_tri_weight_v3(v2, v3, v1) / 2.0f;
+ w3 = cotangent_tri_weight_v3(v3, v1, v2) / 2.0f;
sys->fweights[i][0] = sys->fweights[i][0] + w1;
sys->fweights[i][1] = sys->fweights[i][1] + w2;
@@ -430,9 +413,9 @@ static void fill_laplacian_matrix(LaplacianSystem *sys)
v3 = sys->vertexCos[idv3];
v4 = sys->vertexCos[idv4];
- w2 = cotan_weight(v4, v1, v2) + cotan_weight(v3, v1, v2);
- w3 = cotan_weight(v2, v3, v1) + cotan_weight(v4, v1, v3);
- w4 = cotan_weight(v2, v4, v1) + cotan_weight(v3, v4, v1);
+ w2 = cotangent_tri_weight_v3(v4, v1, v2) + cotangent_tri_weight_v3(v3, v1, v2);
+ w3 = cotangent_tri_weight_v3(v2, v3, v1) + cotangent_tri_weight_v3(v4, v1, v3);
+ w4 = cotangent_tri_weight_v3(v2, v4, v1) + cotangent_tri_weight_v3(v3, v4, v1);
w2 = w2 / 4.0f;
w3 = w3 / 4.0f;
diff --git a/source/blender/modifiers/intern/MOD_meshdeform.c b/source/blender/modifiers/intern/MOD_meshdeform.c
index 61dcc1fbb9d..e8eb9c5675d 100644
--- a/source/blender/modifiers/intern/MOD_meshdeform.c
+++ b/source/blender/modifiers/intern/MOD_meshdeform.c
@@ -130,7 +130,7 @@ static void updateDepgraph(ModifierData *md, DagForest *forest,
}
}
-static float meshdeform_dynamic_bind(MeshDeformModifierData *mmd, float (*dco)[3], float *vec)
+static float meshdeform_dynamic_bind(MeshDeformModifierData *mmd, float (*dco)[3], float vec[3])
{
MDefCell *cell;
MDefInfluence *inf;