24#define SMOOTH_LAPLACIAN_MAX_EDGE_PERCENTAGE 1.8f
25#define SMOOTH_LAPLACIAN_MIN_EDGE_PERCENTAGE 0.15f
56 LaplacianSystem *sys,
int usex,
int usey,
int usez,
int preserve_volume);
58 BMOperator *op,
float vini,
float vend,
int usex,
int usey,
int usez);
85 memset(sys->
eweights, val,
sizeof(
float) * sys->numEdges);
86 memset(sys->
fweights, val,
sizeof(
float[3]) * sys->numLoops);
87 memset(sys->
ring_areas, val,
sizeof(
float) * sys->numVerts);
88 memset(sys->
vlengths, val,
sizeof(
float) * sys->numVerts);
89 memset(sys->
vweights, val,
sizeof(
float) * sys->numVerts);
90 memset(sys->
zerola, val,
sizeof(
bool) * sys->numVerts);
98 sys->numEdges = a_numEdges;
99 sys->numLoops = a_numLoops;
100 sys->numVerts = a_numVerts;
102 sys->
eweights =
static_cast<float *
>(
103 MEM_callocN(
sizeof(
float) * sys->numEdges,
"ModLaplSmoothEWeight"));
109 sys->
fweights =
static_cast<float(*)[3]
>(
110 MEM_callocN(
sizeof(
float[3]) * sys->numLoops,
"ModLaplSmoothFWeight"));
117 MEM_callocN(
sizeof(
float) * sys->numVerts,
"ModLaplSmoothRingAreas"));
123 sys->
vlengths =
static_cast<float *
>(
124 MEM_callocN(
sizeof(
float) * sys->numVerts,
"ModLaplSmoothVlengths"));
130 sys->
vweights =
static_cast<float *
>(
131 MEM_callocN(
sizeof(
float) * sys->numVerts,
"ModLaplSmoothVweights"));
137 sys->
zerola =
static_cast<bool *
>(
138 MEM_callocN(
sizeof(
bool) * sys->numVerts,
"ModLaplSmoothZeloa"));
176 const float *v1 =
e->v1->
co;
177 const float *
v2 =
e->v2->
co;
194 uint l_curr_index = 0;
198 l_curr_index += f->
len;
211 const float *co_prev = l_iter->
prev->
v->
co;
212 const float *co_curr = l_iter->
v->
co;
213 const float *co_next = l_iter->
next->
v->
co;
215 const float areaf =
area_tri_v3(co_prev, co_curr, co_next);
217 if (areaf < sys->min_area) {
218 sys->
zerola[vi_curr] =
true;
229 sys->
fweights[l_curr_index][0] += w1;
230 sys->
fweights[l_curr_index][1] += w2;
231 sys->
fweights[l_curr_index][2] += w3;
236 }
while ((
void)(l_curr_index += 1), (l_iter = l_iter->
next) != l_first);
248 uint l_curr_index = 0;
252 l_curr_index += f->
len;
306 }
while ((
void)(l_curr_index += 1), (l_iter = l_iter->
next) != l_first);
314 if (sys->
zerola[idv1] ==
false && sys->
zerola[idv2] ==
false) {
343 BMOperator *op,
float vini,
float vend,
int usex,
int usey,
int usez)
350 beta =
pow(vini / vend, 1.0f / 3.0f);
366 LaplacianSystem *sys,
int usex,
int usey,
int usez,
int preserve_volume)
371 float *vi1, *vi2, ve1[3], ve2[3];
399 if (preserve_volume) {
404 if (sys->
zerola[m_vertex_id] ==
false) {
416 if (preserve_volume) {
426 bool usex, usey, usez, preserve_volume;
427 float lambda_factor, lambda_border;
474 if ((sys->
zerola[i] ==
false) &&
480 sys->
vweights[i] = (
w == 0.0f) ? 0.0f : -lambda_factor / (4.0f *
w);
482 sys->
vlengths[i] = (
w == 0.0f) ? 0.0f : -lambda_border * 2.0f /
w;
float area_tri_v3(const float v1[3], const float v2[3], const float v3[3])
float cotangent_tri_weight_v3(const float v1[3], const float v2[3], const float v3[3])
MINLINE float len_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
Read Guarded memory(de)allocation.
#define BM_FACE_FIRST_LOOP(p)
#define BM_elem_index_get(ele)
#define BM_elem_flag_test(ele, hflag)
#define BM_ITER_ELEM(ele, iter, data, itype)
#define BM_ITER_MESH(ele, iter, bm, itype)
#define BM_ITER_MESH_INDEX(ele, iter, bm, itype, indexvar)
ATTR_WARN_UNUSED_RESULT BMesh * bm
void BM_mesh_elem_index_ensure(BMesh *bm, const char htype)
float BMO_slot_float_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name)
#define BMO_ITER(ele, iter, slot_args, slot_name, restrict_flag)
bool BMO_slot_bool_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name)
double BM_mesh_calc_volume(BMesh *bm, bool is_signed)
BLI_INLINE bool BM_edge_is_boundary(const BMEdge *e) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
ATTR_WARN_UNUSED_RESULT const BMVert * v2
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
ATTR_WARN_UNUSED_RESULT const BMVert * v
static void delete_void_pointer(void *data)
void bmo_smooth_laplacian_vert_exec(BMesh *bm, BMOperator *op)
static void init_laplacian_matrix(LaplacianSystem *sys)
static void delete_laplacian_system(LaplacianSystem *sys)
static LaplacianSystem * init_laplacian_system(int a_numEdges, int a_numLoops, int a_numVerts)
static bool vert_is_boundary(BMVert *v)
static void validate_solution(LaplacianSystem *sys, int usex, int usey, int usez, int preserve_volume)
#define SMOOTH_LAPLACIAN_MAX_EDGE_PERCENTAGE
static void memset_laplacian_system(LaplacianSystem *sys, int val)
#define SMOOTH_LAPLACIAN_MIN_EDGE_PERCENTAGE
static void volume_preservation(BMOperator *op, float vini, float vend, int usex, int usey, int usez)
static void fill_laplacian_matrix(LaplacianSystem *sys)
BLaplacianSystem LaplacianSystem
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
pow(value.r - subtrahend, 2.0)") .do_static_compilation(true)
draw_view in_light_buf[] float
LinearSolver * EIG_linear_least_squares_solver_new(int num_rows, int num_columns, int num_rhs)
void EIG_linear_solver_variable_set(LinearSolver *solver, int rhs, int index, double value)
void EIG_linear_solver_right_hand_side_add(LinearSolver *solver, int rhs, int index, double value)
void EIG_linear_solver_variable_unlock(LinearSolver *solver, int index)
void EIG_linear_solver_delete(LinearSolver *solver)
double EIG_linear_solver_variable_get(LinearSolver *solver, int rhs, int index)
void EIG_linear_solver_matrix_add(LinearSolver *solver, int row, int col, double value)
bool EIG_linear_solver_solve(LinearSolver *solver)
void EIG_linear_solver_variable_lock(LinearSolver *solver, int index)
void MEM_freeN(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
struct BMOpSlot slots_in[BMO_OP_MAX_SLOTS]
ccl_device_inline float beta(float x, float y)