Blender V5.3
MOD_laplaciansmooth.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2005 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include "BLI_math_geom_c.hh"
10#include "BLI_utildefines.hh"
11
12#include "BLT_translation.hh"
13
14#include "DNA_mesh_types.h"
15#include "DNA_meshdata_types.h"
16#include "DNA_screen_types.h"
17
18#include "MEM_guardedalloc.h"
19
20#include "BKE_deform.hh"
21#include "BKE_modifier.hh"
22
24#include "UI_resources.hh"
25
26#include "RNA_prototypes.hh"
27#include "RNA_types.hh"
28
29#include "MOD_ui_common.hh"
30#include "MOD_util.hh"
31
32#include "eigen_capi.h"
33
34namespace blender {
35
36namespace {
37
38struct LaplacianSystem {
39 float *eweights = nullptr; /* Length weights per Edge */
40 float (*fweights)[3] = nullptr; /* Cotangent weights per face */
41 float *ring_areas = nullptr; /* Total area per ring. */
42 float *vlengths = nullptr; /* Total sum of lengths(edges) per vertex. */
43 float *vweights = nullptr; /* Total sum of weights per vertex. */
44 int verts_num = 0; /* Number of verts. */
45 short *ne_fa_num = nullptr; /* Number of neighbors faces around vertex. */
46 short *ne_ed_num = nullptr; /* Number of neighbors Edges around vertex. */
47 bool *zerola = nullptr; /* Is zero area or length. */
48
49 /* Pointers to data. */
50 float (*vertexCos)[3] = nullptr;
51 Span<int2> edges = {};
52 OffsetIndices<int> faces = {};
53 Span<int> corner_verts = {};
54 LinearSolver *context = nullptr;
55
56 /* Data. */
57 float min_area = 0.0f;
58 float vert_centroid[3] = {};
59};
60
61}; // namespace
62
64{
65 MEM_SAFE_DELETE(sys->eweights);
66 MEM_SAFE_DELETE(sys->fweights);
67 MEM_SAFE_DELETE(sys->ne_ed_num);
68 MEM_SAFE_DELETE(sys->ne_fa_num);
69 MEM_SAFE_DELETE(sys->ring_areas);
70 MEM_SAFE_DELETE(sys->vlengths);
71 MEM_SAFE_DELETE(sys->vweights);
72 MEM_SAFE_DELETE(sys->zerola);
73
74 if (sys->context) {
75 EIG_linear_solver_delete(sys->context);
76 }
77 sys->vertexCos = nullptr;
78 MEM_delete(sys);
79}
80
81static void memset_laplacian_system(LaplacianSystem *sys, int val)
82{
83 memset(sys->eweights, val, sizeof(float) * sys->edges.size());
84 memset(sys->fweights, val, sizeof(float[3]) * sys->corner_verts.size());
85 memset(sys->ne_ed_num, val, sizeof(short) * sys->verts_num);
86 memset(sys->ne_fa_num, val, sizeof(short) * sys->verts_num);
87 memset(sys->ring_areas, val, sizeof(float) * sys->verts_num);
88 memset(sys->vlengths, val, sizeof(float) * sys->verts_num);
89 memset(sys->vweights, val, sizeof(float) * sys->verts_num);
90 memset(sys->zerola, val, sizeof(bool) * sys->verts_num);
91}
92
93static LaplacianSystem *init_laplacian_system(int a_numEdges, int a_numLoops, int a_numVerts)
94{
95 LaplacianSystem *sys;
96 sys = MEM_new<LaplacianSystem>(__func__);
97 sys->verts_num = a_numVerts;
98
99 sys->eweights = MEM_new_array_zeroed<float>(a_numEdges, __func__);
100 sys->fweights = MEM_new_array_zeroed<float[3]>(a_numLoops, __func__);
101 sys->ne_ed_num = MEM_new_array_zeroed<short>(sys->verts_num, __func__);
102 sys->ne_fa_num = MEM_new_array_zeroed<short>(sys->verts_num, __func__);
103 sys->ring_areas = MEM_new_array_zeroed<float>(sys->verts_num, __func__);
104 sys->vlengths = MEM_new_array_zeroed<float>(sys->verts_num, __func__);
105 sys->vweights = MEM_new_array_zeroed<float>(sys->verts_num, __func__);
106 sys->zerola = MEM_new_array_zeroed<bool>(sys->verts_num, __func__);
107
108 return sys;
109}
110
111static float compute_volume(const float center[3],
112 float (*vertexCos)[3],
113 const OffsetIndices<int> faces,
114 const Span<int> corner_verts)
115{
116 float vol = 0.0f;
117
118 for (const int i : faces.index_range()) {
119 const IndexRange face = faces[i];
120 int corner_first = face.start();
121 int corner_prev = corner_first + 1;
122 int corner_curr = corner_first + 2;
123 int corner_term = corner_first + face.size();
124
125 for (; corner_curr != corner_term; corner_prev = corner_curr, corner_curr++) {
126 vol += volume_tetrahedron_signed_v3(center,
127 vertexCos[corner_verts[corner_first]],
128 vertexCos[corner_verts[corner_prev]],
129 vertexCos[corner_verts[corner_curr]]);
130 }
131 }
132
133 return fabsf(vol);
134}
135
136static void volume_preservation(LaplacianSystem *sys, float vini, float vend, short flag)
137{
138 float beta;
139 int i;
140
141 if (vend != 0.0f) {
142 beta = pow(vini / vend, 1.0f / 3.0f);
143 for (i = 0; i < sys->verts_num; i++) {
144 if (flag & MOD_LAPLACIANSMOOTH_X) {
145 sys->vertexCos[i][0] = (sys->vertexCos[i][0] - sys->vert_centroid[0]) * beta +
146 sys->vert_centroid[0];
147 }
148 if (flag & MOD_LAPLACIANSMOOTH_Y) {
149 sys->vertexCos[i][1] = (sys->vertexCos[i][1] - sys->vert_centroid[1]) * beta +
150 sys->vert_centroid[1];
151 }
152 if (flag & MOD_LAPLACIANSMOOTH_Z) {
153 sys->vertexCos[i][2] = (sys->vertexCos[i][2] - sys->vert_centroid[2]) * beta +
154 sys->vert_centroid[2];
155 }
156 }
157 }
158}
159
161{
162 float *v1, *v2;
163 float w1, w2, w3;
164 float areaf;
165 int i;
166 uint idv1, idv2;
167
168 for (i = 0; i < sys->edges.size(); i++) {
169 idv1 = sys->edges[i][0];
170 idv2 = sys->edges[i][1];
171
172 v1 = sys->vertexCos[idv1];
173 v2 = sys->vertexCos[idv2];
174
175 sys->ne_ed_num[idv1] = sys->ne_ed_num[idv1] + 1;
176 sys->ne_ed_num[idv2] = sys->ne_ed_num[idv2] + 1;
177 w1 = len_v3v3(v1, v2);
178 if (w1 < sys->min_area) {
179 sys->zerola[idv1] = true;
180 sys->zerola[idv2] = true;
181 }
182 else {
183 w1 = 1.0f / w1;
184 }
185
186 sys->eweights[i] = w1;
187 }
188
189 const Span<int> corner_verts = sys->corner_verts;
190
191 for (const int i : sys->faces.index_range()) {
192 const IndexRange face = sys->faces[i];
193 int corner_next = face.start();
194 int corner_term = corner_next + face.size();
195 int corner_prev = corner_term - 2;
196 int corner_curr = corner_term - 1;
197
198 for (; corner_next != corner_term;
199 corner_prev = corner_curr, corner_curr = corner_next, corner_next++)
200 {
201 const float *v_prev = sys->vertexCos[corner_verts[corner_prev]];
202 const float *v_curr = sys->vertexCos[corner_verts[corner_curr]];
203 const float *v_next = sys->vertexCos[corner_verts[corner_next]];
204
205 sys->ne_fa_num[corner_verts[corner_curr]] += 1;
206
207 areaf = area_tri_v3(v_prev, v_curr, v_next);
208
209 if (areaf < sys->min_area) {
210 sys->zerola[corner_verts[corner_curr]] = true;
211 }
212
213 sys->ring_areas[corner_verts[corner_prev]] += areaf;
214 sys->ring_areas[corner_verts[corner_curr]] += areaf;
215 sys->ring_areas[corner_verts[corner_next]] += areaf;
216
217 w1 = cotangent_tri_weight_v3(v_curr, v_next, v_prev) / 2.0f;
218 w2 = cotangent_tri_weight_v3(v_next, v_prev, v_curr) / 2.0f;
219 w3 = cotangent_tri_weight_v3(v_prev, v_curr, v_next) / 2.0f;
220
221 sys->fweights[corner_curr][0] += w1;
222 sys->fweights[corner_curr][1] += w2;
223 sys->fweights[corner_curr][2] += w3;
224
225 sys->vweights[corner_verts[corner_curr]] += w2 + w3;
226 sys->vweights[corner_verts[corner_next]] += w1 + w3;
227 sys->vweights[corner_verts[corner_prev]] += w1 + w2;
228 }
229 }
230 for (i = 0; i < sys->edges.size(); i++) {
231 idv1 = sys->edges[i][0];
232 idv2 = sys->edges[i][1];
233 /* if is boundary, apply scale-dependent umbrella operator only with neighbors in boundary */
234 if (sys->ne_ed_num[idv1] != sys->ne_fa_num[idv1] &&
235 sys->ne_ed_num[idv2] != sys->ne_fa_num[idv2])
236 {
237 sys->vlengths[idv1] += sys->eweights[i];
238 sys->vlengths[idv2] += sys->eweights[i];
239 }
240 }
241}
242
244{
245 int i;
246 uint idv1, idv2;
247
248 const Span<int> corner_verts = sys->corner_verts;
249
250 for (const int i : sys->faces.index_range()) {
251 const IndexRange face = sys->faces[i];
252 int corner_next = face.start();
253 int corner_term = corner_next + face.size();
254 int corner_prev = corner_term - 2;
255 int corner_curr = corner_term - 1;
256
257 for (; corner_next != corner_term;
258 corner_prev = corner_curr, corner_curr = corner_next, corner_next++)
259 {
260
261 /* Is ring if number of faces == number of edges around vertex. */
262 if (sys->ne_ed_num[corner_verts[corner_curr]] == sys->ne_fa_num[corner_verts[corner_curr]] &&
263 sys->zerola[corner_verts[corner_curr]] == false)
264 {
265 EIG_linear_solver_matrix_add(sys->context,
266 corner_verts[corner_curr],
267 corner_verts[corner_next],
268 sys->fweights[corner_curr][2] *
269 sys->vweights[corner_verts[corner_curr]]);
270 EIG_linear_solver_matrix_add(sys->context,
271 corner_verts[corner_curr],
272 corner_verts[corner_prev],
273 sys->fweights[corner_curr][1] *
274 sys->vweights[corner_verts[corner_curr]]);
275 }
276 if (sys->ne_ed_num[corner_verts[corner_next]] == sys->ne_fa_num[corner_verts[corner_next]] &&
277 sys->zerola[corner_verts[corner_next]] == false)
278 {
279 EIG_linear_solver_matrix_add(sys->context,
280 corner_verts[corner_next],
281 corner_verts[corner_curr],
282 sys->fweights[corner_curr][2] *
283 sys->vweights[corner_verts[corner_next]]);
284 EIG_linear_solver_matrix_add(sys->context,
285 corner_verts[corner_next],
286 corner_verts[corner_prev],
287 sys->fweights[corner_curr][0] *
288 sys->vweights[corner_verts[corner_next]]);
289 }
290 if (sys->ne_ed_num[corner_verts[corner_prev]] == sys->ne_fa_num[corner_verts[corner_prev]] &&
291 sys->zerola[corner_verts[corner_prev]] == false)
292 {
293 EIG_linear_solver_matrix_add(sys->context,
294 corner_verts[corner_prev],
295 corner_verts[corner_curr],
296 sys->fweights[corner_curr][1] *
297 sys->vweights[corner_verts[corner_prev]]);
298 EIG_linear_solver_matrix_add(sys->context,
299 corner_verts[corner_prev],
300 corner_verts[corner_next],
301 sys->fweights[corner_curr][0] *
302 sys->vweights[corner_verts[corner_prev]]);
303 }
304 }
305 }
306
307 for (i = 0; i < sys->edges.size(); i++) {
308 idv1 = sys->edges[i][0];
309 idv2 = sys->edges[i][1];
310 /* Is boundary */
311 if (sys->ne_ed_num[idv1] != sys->ne_fa_num[idv1] &&
312 sys->ne_ed_num[idv2] != sys->ne_fa_num[idv2] && sys->zerola[idv1] == false &&
313 sys->zerola[idv2] == false)
314 {
316 sys->context, idv1, idv2, sys->eweights[i] * sys->vlengths[idv1]);
318 sys->context, idv2, idv1, sys->eweights[i] * sys->vlengths[idv2]);
319 }
320 }
321}
322
323static void validate_solution(LaplacianSystem *sys, short flag, float lambda, float lambda_border)
324{
325 int i;
326 float lam;
327 float vini = 0.0f, vend = 0.0f;
328
330 vini = compute_volume(sys->vert_centroid, sys->vertexCos, sys->faces, sys->corner_verts);
331 }
332 for (i = 0; i < sys->verts_num; i++) {
333 if (sys->zerola[i] == false) {
334 lam = sys->ne_ed_num[i] == sys->ne_fa_num[i] ? (lambda >= 0.0f ? 1.0f : -1.0f) :
335 (lambda_border >= 0.0f ? 1.0f : -1.0f);
336 if (flag & MOD_LAPLACIANSMOOTH_X) {
337 sys->vertexCos[i][0] += lam * (float(EIG_linear_solver_variable_get(sys->context, 0, i)) -
338 sys->vertexCos[i][0]);
339 }
340 if (flag & MOD_LAPLACIANSMOOTH_Y) {
341 sys->vertexCos[i][1] += lam * (float(EIG_linear_solver_variable_get(sys->context, 1, i)) -
342 sys->vertexCos[i][1]);
343 }
344 if (flag & MOD_LAPLACIANSMOOTH_Z) {
345 sys->vertexCos[i][2] += lam * (float(EIG_linear_solver_variable_get(sys->context, 2, i)) -
346 sys->vertexCos[i][2]);
347 }
348 }
349 }
351 vend = compute_volume(sys->vert_centroid, sys->vertexCos, sys->faces, sys->corner_verts);
352 volume_preservation(sys, vini, vend, flag);
353 }
354}
355
357 LaplacianSmoothModifierData *smd, Object *ob, Mesh *mesh, float (*vertexCos)[3], int verts_num)
358{
359 LaplacianSystem *sys;
360 const MDeformVert *dvert = nullptr;
361 const MDeformVert *dv = nullptr;
362 float w, wpaint;
363 int i, iter;
364 int defgrp_index;
365 const bool invert_vgroup = (smd->flag & MOD_LAPLACIANSMOOTH_INVERT_VGROUP) != 0;
366
367 sys = init_laplacian_system(mesh->edges_num, mesh->corners_num, verts_num);
368 if (!sys) {
369 return;
370 }
371
372 sys->edges = mesh->edges();
373 sys->faces = mesh->faces();
374 sys->corner_verts = mesh->corner_verts();
375 sys->vertexCos = vertexCos;
376 sys->min_area = 0.00001f;
377 MOD_get_vgroup(ob, mesh, smd->defgrp_name, &dvert, &defgrp_index);
378
379 sys->vert_centroid[0] = 0.0f;
380 sys->vert_centroid[1] = 0.0f;
381 sys->vert_centroid[2] = 0.0f;
383
384 sys->context = EIG_linear_least_squares_solver_new(verts_num, verts_num, 3);
385
387
388 for (iter = 0; iter < smd->repeat; iter++) {
389 for (i = 0; i < verts_num; i++) {
390 EIG_linear_solver_variable_set(sys->context, 0, i, vertexCos[i][0]);
391 EIG_linear_solver_variable_set(sys->context, 1, i, vertexCos[i][1]);
392 EIG_linear_solver_variable_set(sys->context, 2, i, vertexCos[i][2]);
393 if (iter == 0) {
394 add_v3_v3(sys->vert_centroid, vertexCos[i]);
395 }
396 }
397 if (iter == 0 && verts_num > 0) {
398 mul_v3_fl(sys->vert_centroid, 1.0f / float(verts_num));
399 }
400
401 dv = dvert;
402 for (i = 0; i < verts_num; i++) {
403 EIG_linear_solver_right_hand_side_add(sys->context, 0, i, vertexCos[i][0]);
404 EIG_linear_solver_right_hand_side_add(sys->context, 1, i, vertexCos[i][1]);
405 EIG_linear_solver_right_hand_side_add(sys->context, 2, i, vertexCos[i][2]);
406 if (iter == 0) {
407 if (dv) {
408 wpaint = invert_vgroup ? 1.0f - BKE_defvert_find_weight(dv, defgrp_index) :
409 BKE_defvert_find_weight(dv, defgrp_index);
410 dv++;
411 }
412 else {
413 wpaint = 1.0f;
414 }
415
416 if (sys->zerola[i] == false) {
418 w = sys->vweights[i];
419 sys->vweights[i] = (w == 0.0f) ? 0.0f : -fabsf(smd->lambda) * wpaint / w;
420 w = sys->vlengths[i];
421 sys->vlengths[i] = (w == 0.0f) ? 0.0f : -fabsf(smd->lambda_border) * wpaint * 2.0f / w;
422 if (sys->ne_ed_num[i] == sys->ne_fa_num[i]) {
423 EIG_linear_solver_matrix_add(sys->context, i, i, 1.0f + fabsf(smd->lambda) * wpaint);
424 }
425 else {
427 sys->context, i, i, 1.0f + fabsf(smd->lambda_border) * wpaint * 2.0f);
428 }
429 }
430 else {
431 w = sys->vweights[i] * sys->ring_areas[i];
432 sys->vweights[i] = (w == 0.0f) ? 0.0f : -fabsf(smd->lambda) * wpaint / (4.0f * w);
433 w = sys->vlengths[i];
434 sys->vlengths[i] = (w == 0.0f) ? 0.0f : -fabsf(smd->lambda_border) * wpaint * 2.0f / w;
435
436 if (sys->ne_ed_num[i] == sys->ne_fa_num[i]) {
437 EIG_linear_solver_matrix_add(sys->context,
438 i,
439 i,
440 1.0f + fabsf(smd->lambda) * wpaint /
441 (4.0f * sys->ring_areas[i]));
442 }
443 else {
445 sys->context, i, i, 1.0f + fabsf(smd->lambda_border) * wpaint * 2.0f);
446 }
447 }
448 }
449 else {
450 EIG_linear_solver_matrix_add(sys->context, i, i, 1.0f);
451 }
452 }
453 }
454
455 if (iter == 0) {
457 }
458
459 if (EIG_linear_solver_solve(sys->context)) {
460 validate_solution(sys, smd->flag, smd->lambda, smd->lambda_border);
461 }
462 }
463 EIG_linear_solver_delete(sys->context);
464 sys->context = nullptr;
465
467}
468
469static void init_data(ModifierData *md)
470{
471 LaplacianSmoothModifierData *smd = reinterpret_cast<LaplacianSmoothModifierData *>(md);
473}
474
475static bool is_disabled(const Scene * /*scene*/, ModifierData *md, bool /*use_render_params*/)
476{
477 LaplacianSmoothModifierData *smd = reinterpret_cast<LaplacianSmoothModifierData *>(md);
478 short flag;
479
481
482 /* disable if modifier is off for X, Y and Z or if factor is 0 */
483 if (flag == 0) {
484 return true;
485 }
486
487 return false;
488}
489
490static void required_data_mask(ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
491{
492 LaplacianSmoothModifierData *smd = reinterpret_cast<LaplacianSmoothModifierData *>(md);
493
494 /* Ask for vertex-groups if we need them. */
495 if (smd->defgrp_name[0] != '\0') {
496 r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
497 }
498}
499
501 const ModifierEvalContext *ctx,
502 Mesh *mesh,
503 MutableSpan<float3> positions)
504{
505 if (positions.is_empty()) {
506 return;
507 }
508
510 ctx->object,
511 mesh,
512 reinterpret_cast<float (*)[3]>(positions.data()),
513 positions.size());
514}
515
516static void panel_draw(const bContext * /*C*/, Panel *panel)
517{
518 ui::Layout &layout = *panel->layout;
520
521 PointerRNA ob_ptr;
523
524 layout.use_property_split_set(true);
525
526 layout.prop(ptr, "iterations", UI_ITEM_NONE, std::nullopt, ICON_NONE);
527
528 ui::Layout &row = layout.row(true, IFACE_("Axis"));
529 row.prop(ptr, "use_x", toggles_flag, std::nullopt, ICON_NONE);
530 row.prop(ptr, "use_y", toggles_flag, std::nullopt, ICON_NONE);
531 row.prop(ptr, "use_z", toggles_flag, std::nullopt, ICON_NONE);
532
533 layout.prop(ptr, "lambda_factor", UI_ITEM_NONE, std::nullopt, ICON_NONE);
534 layout.prop(ptr, "lambda_border", UI_ITEM_NONE, std::nullopt, ICON_NONE);
535
536 layout.prop(ptr, "use_volume_preserve", UI_ITEM_NONE, std::nullopt, ICON_NONE);
537 layout.prop(ptr, "use_normalized", UI_ITEM_NONE, std::nullopt, ICON_NONE);
538
539 modifier_vgroup_ui(layout, ptr, &ob_ptr, "vertex_group", "invert_vertex_group", std::nullopt);
540
541 modifier_error_message_draw(layout, ptr);
542}
543
544static void panel_register(ARegionType *region_type)
545{
547}
548
550 /*idname*/ "LaplacianSmooth",
551 /*name*/ N_("LaplacianSmooth"),
552 /*struct_name*/ "LaplacianSmoothModifierData",
553 /*struct_size*/ sizeof(LaplacianSmoothModifierData),
554 /*srna*/ &RNA_LaplacianSmoothModifier,
557 /*icon*/ ICON_MOD_SMOOTH,
558
559 /*copy_data*/ BKE_modifier_copydata_generic,
560
561 /*deform_verts*/ deform_verts,
562 /*deform_matrices*/ nullptr,
563 /*deform_verts_EM*/ nullptr,
564 /*deform_matrices_EM*/ nullptr,
565 /*modify_mesh*/ nullptr,
566 /*modify_geometry_set*/ nullptr,
567
568 /*init_data*/ init_data,
569 /*required_data_mask*/ required_data_mask,
570 /*free_data*/ nullptr,
571 /*is_disabled*/ is_disabled,
572 /*update_depsgraph*/ nullptr,
573 /*depends_on_time*/ nullptr,
574 /*depends_on_normals*/ nullptr,
575 /*foreach_ID_link*/ nullptr,
576 /*foreach_tex_link*/ nullptr,
577 /*free_runtime_data*/ nullptr,
578 /*panel_register*/ panel_register,
579 /*blend_write*/ nullptr,
580 /*blend_read*/ nullptr,
581 /*foreach_cache*/ nullptr,
582 /*foreach_working_space_color*/ nullptr,
583};
584
585} // namespace blender
support for deformation groups and hooks.
#define IFACE_(msgid)
Read Blender memory allocation and freeing.
#define UI_ITEM_NONE
#define INIT_DEFAULT_STRUCT_AFTER(struct_dst, member)
#define CD_MASK_MDEFORMVERT
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition btQuadWord.h:119
constexpr int64_t size() const
constexpr int64_t start() const
constexpr int64_t size() const
Definition BLI_span.hh:499
constexpr bool is_empty() const
Definition BLI_span.hh:515
constexpr T * data() const
Definition BLI_span.hh:545
#define pow
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)
LinearSolver * EIG_linear_least_squares_solver_new(int num_rows, int num_columns, int num_right_hand_sides)
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)
ccl_device_inline float beta(const float x, const float y)
Definition math_base.h:708
BMesh Iterators.
PointerRNA * modifier_panel_get_property_pointers(Panel *panel, PointerRNA *r_ob_ptr)
unsigned int uint
Definition BKE_text.h:55
static void memset_laplacian_system(LaplacianSystem *sys, int val)
void MOD_get_vgroup(const Object *ob, const Mesh *mesh, const char *name, const MDeformVert **dvert, int *defgrp_index)
Definition MOD_util.cc:158
static void init_laplacian_matrix(LaplacianSystem *sys)
@ eModifierType_LaplacianSmooth
static void init_data(ModifierData *md)
static LaplacianSystem * init_laplacian_system(int a_numEdges, int a_numLoops, int a_numVerts)
static void volume_preservation(BMOperator *op, float vini, float vend, int usex, int usey, int usez)
MINLINE void mul_v3_fl(float r[3], float f)
static void delete_laplacian_system(LaplacianSystem *sys)
static void required_data_mask(ModifierData *, CustomData_MeshMasks *r_cddata_masks)
void modifier_error_message_draw(ui::Layout &layout, PointerRNA *ptr)
float BKE_defvert_find_weight(const MDeformVert *dvert, int defgroup)
Definition deform.cc:779
void modifier_vgroup_ui(ui::Layout &layout, PointerRNA *ptr, PointerRNA *ob_ptr, const StringRefNull vgroup_prop, const std::optional< StringRefNull > invert_vgroup_prop, const std::optional< StringRefNull > text)
@ MOD_LAPLACIANSMOOTH_NORMALIZED
@ MOD_LAPLACIANSMOOTH_INVERT_VGROUP
@ MOD_LAPLACIANSMOOTH_PRESERVE_VOLUME
static void panel_register(ARegionType *region_type)
static float compute_volume(const float center[3], float(*vertexCos)[3], const OffsetIndices< int > faces, const Span< int > corner_verts)
@ eModifierTypeFlag_SupportsEditmode
@ eModifierTypeFlag_AcceptsMesh
ModifierTypeInfo modifierType_LaplacianSmooth
static void laplaciansmoothModifier_do(LaplacianSmoothModifierData *smd, Object *ob, Mesh *mesh, float(*vertexCos)[3], int verts_num)
MINLINE void add_v3_v3(float r[3], const float a[3])
float cotangent_tri_weight_v3(const float v1[3], const float v2[3], const float v3[3])
Definition math_geom.cc:202
ATTR_WARN_UNUSED_RESULT const BMVert * v2
float area_tri_v3(const float v1[3], const float v2[3], const float v3[3])
Definition math_geom.cc:104
PanelType * modifier_panel_register(ARegionType *region_type, ModifierType type, PanelDrawFn draw)
static void panel_draw(const bContext *, Panel *panel)
static void deform_verts(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh, MutableSpan< float3 > positions)
static void fill_laplacian_matrix(LaplacianSystem *sys)
static bool is_disabled(const Scene *, ModifierData *md, bool)
MINLINE float len_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
static void validate_solution(LaplacianSystem *sys, int usex, int usey, int usez, int preserve_volume)
float volume_tetrahedron_signed_v3(const float v1[3], const float v2[3], const float v3[3], const float v4[3])
Definition math_geom.cc:263
void * MEM_new_array_zeroed(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
void BKE_modifier_copydata_generic(const ModifierData *md, ModifierData *md_dst, int flag)
#define fabsf
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
ui::Layout * layout
void use_property_split_set(bool is_sep)
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< StringRef > name_opt, int icon, std::optional< StringRef > placeholder=std::nullopt)
Layout & row(bool align)
#define N_(msgid)