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:
Diffstat (limited to 'source/blender/bmesh/operators/bmo_smooth_laplacian.c')
-rw-r--r--source/blender/bmesh/operators/bmo_smooth_laplacian.c61
1 files changed, 10 insertions, 51 deletions
diff --git a/source/blender/bmesh/operators/bmo_smooth_laplacian.c b/source/blender/bmesh/operators/bmo_smooth_laplacian.c
index 4a367a8fd6f..6b91d5fded9 100644
--- a/source/blender/bmesh/operators/bmo_smooth_laplacian.c
+++ b/source/blender/bmesh/operators/bmo_smooth_laplacian.c
@@ -29,10 +29,10 @@
#include "DNA_meshdata_types.h"
#include "BLI_array.h"
-#include "BLI_heap.h"
#include "BLI_math.h"
#include "BLI_math_geom.h"
#include "BLI_smallhash.h"
+#include "BLI_heap.h"
#include "BKE_customdata.h"
#include "BKE_mesh.h"
@@ -69,7 +69,6 @@ struct BLaplacianSystem {
};
typedef struct BLaplacianSystem LaplacianSystem;
-static float compute_volume(BMesh *bm);
static float cotan_weight(float *v1, float *v2, float *v3);
static int vert_is_boundary(BMVert *v);
static LaplacianSystem *init_laplacian_system(int a_numEdges, int a_numFaces, int a_numVerts);
@@ -85,7 +84,6 @@ static void delete_void_pointer(void *data)
{
if (data) {
MEM_freeN(data);
- data = NULL;
}
}
@@ -180,7 +178,7 @@ static void init_laplacian_matrix(LaplacianSystem *sys)
float *v1, *v2, *v3, *v4;
float w1, w2, w3, w4;
int i, j;
- int has_4_vert;
+ bool has_4_vert;
unsigned int idv1, idv2, idv3, idv4, idv[4];
BMEdge *e;
BMFace *f;
@@ -297,7 +295,7 @@ static void fill_laplacian_matrix(LaplacianSystem *sys)
float *v1, *v2, *v3, *v4;
float w2, w3, w4;
int i, j;
- int has_4_vert;
+ bool has_4_vert;
unsigned int idv1, idv2, idv3, idv4, idv[4];
BMEdge *e;
@@ -416,45 +414,6 @@ static int vert_is_boundary(BMVert *v)
return 0;
}
-static float compute_volume(BMesh *bm)
-{
- float vol = 0.0f;
- float x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4;
- int i;
- BMFace *f;
- BMIter fiter;
- BMIter vi;
- BMVert *vn;
- BMVert *vf[4];
-
- BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) {
- BM_ITER_ELEM_INDEX (vn, &vi, f, BM_VERTS_OF_FACE, i) {
- vf[i] = vn;
- }
- x1 = vf[0]->co[0];
- y1 = vf[0]->co[1];
- z1 = vf[0]->co[2];
-
- x2 = vf[1]->co[0];
- y2 = vf[1]->co[1];
- z2 = vf[1]->co[2];
-
- x3 = vf[2]->co[0];
- y3 = vf[2]->co[1];
- z3 = vf[2]->co[2];
-
- vol += (1.0f / 6.0f) * (0.0f - x3 * y2 * z1 + x2 * y3 * z1 + x3 * y1 * z2 - x1 * y3 * z2 - x2 * y1 * z3 + x1 * y2 * z3);
-
- if (i == 4) {
- x4 = vf[3]->co[0];
- y4 = vf[3]->co[1];
- z4 = vf[3]->co[2];
- vol += (1.0f / 6.0f) * (x1 * y3 * z4 - x1 * y4 * z3 - x3 * y1 * z4 + x3 * z1 * y4 + y1 * x4 * z3 - x4 * y3 * z1);
- }
- }
- return fabs(vol);
-}
-
static void volume_preservation(BMOperator *op, float vini, float vend, int usex, int usey, int usez)
{
float beta;
@@ -510,7 +469,7 @@ static void validate_solution(LaplacianSystem *sys, int usex, int usey, int usez
}
if (preserve_volume) {
- vini = compute_volume(sys->bm);
+ vini = BM_mesh_calc_volume(sys->bm);
}
BMO_ITER (v, &siter, sys->op->slots_in, "verts", BM_VERT) {
m_vertex_id = BM_elem_index_get(v);
@@ -527,7 +486,7 @@ static void validate_solution(LaplacianSystem *sys, int usex, int usey, int usez
}
}
if (preserve_volume) {
- vend = compute_volume(sys->bm);
+ vend = BM_mesh_calc_volume(sys->bm);
volume_preservation(sys->op, vini, vend, usex, usey, usez);
}
@@ -537,8 +496,8 @@ void bmo_smooth_laplacian_vert_exec(BMesh *bm, BMOperator *op)
{
int i;
int m_vertex_id;
- int usex, usey, usez, preserve_volume;
- float lambda, lambda_border;
+ bool usex, usey, usez, preserve_volume;
+ float lambda_factor, lambda_border;
float w;
BMOIter siter;
BMVert *v;
@@ -553,7 +512,7 @@ void bmo_smooth_laplacian_vert_exec(BMesh *bm, BMOperator *op)
memset_laplacian_system(sys, 0);
BM_mesh_elem_index_ensure(bm, BM_VERT);
- lambda = BMO_slot_float_get(op->slots_in, "lambda");
+ lambda_factor = BMO_slot_float_get(op->slots_in, "lambda_factor");
lambda_border = BMO_slot_float_get(op->slots_in, "lambda_border");
sys->min_area = 0.00001f;
usex = BMO_slot_bool_get(op->slots_in, "use_x");
@@ -592,12 +551,12 @@ void bmo_smooth_laplacian_vert_exec(BMesh *bm, BMOperator *op)
i = m_vertex_id;
if (sys->zerola[i] == 0) {
w = sys->vweights[i] * sys->ring_areas[i];
- sys->vweights[i] = (w == 0.0f) ? 0.0f : -lambda / (4.0f * w);
+ sys->vweights[i] = (w == 0.0f) ? 0.0f : -lambda_factor / (4.0f * w);
w = sys->vlengths[i];
sys->vlengths[i] = (w == 0.0f) ? 0.0f : -lambda_border * 2.0f / w;
if (!vert_is_boundary(v)) {
- nlMatrixAdd(i, i, 1.0f + lambda / (4.0f * sys->ring_areas[i]));
+ nlMatrixAdd(i, i, 1.0f + lambda_factor / (4.0f * sys->ring_areas[i]));
}
else {
nlMatrixAdd(i, i, 1.0f + lambda_border * 2.0f);