49 float r_adj_prev[3]) = 0;
81 fair_verts_ex(affected_verts,
int(depth), vertex_weight, loop_weight);
93 void fair_setup_fairing(
const int v,
104 const int j = vert_col_map.
lookup(
v);
108 for (
int j = 0; j < 3; j++) {
118 const int l_index = vlmap_elem[
l];
122 fair_setup_fairing(other_vert,
125 w_i * w_ij * multiplier,
131 fair_setup_fairing(
v,
134 -1 * w_i * w_ij_sum * multiplier,
141 void fair_verts_ex(
const bool affected_verts[],
147 int affected_verts_num = 0;
148 for (
int i = 0; i <
totvert_; i++) {
149 if (!affected_verts[i]) {
152 vert_col_map.
add(i, affected_verts_num);
153 affected_verts_num++;
163 for (
auto item : vert_col_map.items()) {
164 const int v = item.key;
165 const int col = item.value;
166 fair_setup_fairing(
v,
col, solver, 1.0f, order, vert_col_map, vertex_weight, loop_weight);
173 for (
auto item : vert_col_map.items()) {
174 const int v = item.key;
175 const int col = item.value;
176 for (
int j = 0; j < 3; j++) {
195 faces = mesh->faces();
198 vlmap_ = mesh->vert_to_corner_map();
201 co_.resize(mesh->verts_num);
203 for (
int i = 0; i < mesh->verts_num; i++) {
204 co_[i] = deform_positions[i];
208 for (
int i = 0; i < mesh->verts_num; i++) {
209 co_[i] = positions[i];
218 float r_adj_prev[3])
override
223 const int2 adjacent_verts = bke::mesh::face_find_adjacent_verts(face,
corner_verts_, vert);
248 vertex_weights_.resize(totvert);
249 for (
int i = 0; i < totvert; i++) {
252 vertex_weights_[i] = 1.0f / tot_loop;
262 return vertex_weights_[index];
276 vertex_weights_.resize(totvert);
277 for (
int i = 0; i < totvert; i++) {
282 const float acute_threshold =
M_PI_2;
286 const int l_index = vlmap_elem[
l];
288 float b[3], c[3], d[3];
292 calc_circumcenter(d, a,
b, c);
309 vertex_weights_[i] = area != 0.0f ? 1.0f / area : 1e12;
315 return vertex_weights_[index];
321 void calc_circumcenter(
float r[3],
const float a[3],
const float b[3],
const float c[3])
329 float ab_cross_ac[3];
361 const bool affected_verts[],
367 fairing_context.
fair_verts(affected_verts, depth, uniform_vertex_weights, uniform_loop_weights);
372 fairing_context.
fair_verts(affected_verts, depth, voronoi_vertex_weights, uniform_loop_weights);
377 const bool affected_verts[],
381 if (!deform_vert_positions.
is_empty()) {
382 deform_positions_span = deform_vert_positions;
float area_tri_v3(const float v1[3], const float v2[3], const float v3[3])
MINLINE float len_squared_v3(const float v[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void mul_v3_fl(float r[3], float f)
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3])
float angle_v3v3v3(const float a[3], const float b[3], const float c[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void add_v3_v3(float r[3], const float a[3])
Read Guarded memory(de)allocation.
ATTR_WARN_UNUSED_RESULT const BMLoop * l
ATTR_WARN_UNUSED_RESULT const BMVert * v
Span< int > vertex_loop_map_get(const int v)
blender::GroupedSpan< int > vlmap_
virtual ~FairingContext()=default
void fair_verts(const bool affected_verts[], const eMeshFairingDepth depth, const VertexWeight &vertex_weight, const LoopWeight &loop_weight)
virtual void adjacents_coords_from_loop(const int loop, float r_adj_next[3], float r_adj_prev[3])=0
float * vertex_deformation_co_get(const int v)
virtual int other_vertex_index_from_loop(const int loop, const int v)=0
virtual float weight_at_index(const int index) const =0
virtual ~LoopWeight()=default
void adjacents_coords_from_loop(const int loop, float r_adj_next[3], float r_adj_prev[3]) override
Span< int > corner_edges_
blender::OffsetIndices< int > faces
int other_vertex_index_from_loop(const int loop, const int v) override
Span< blender::int2 > edges_
MeshFairingContext(Mesh *mesh, MutableSpan< float3 > deform_positions)
Span< int > loop_to_face_map_
Span< int > corner_verts_
virtual float weight_at_index(const int index) const =0
virtual ~VertexWeight()=default
float weight_at_index(const int index) const override
VoronoiVertexWeight(FairingContext &fairing_context)
bool add(const Key &key, const Value &value)
const Value & lookup(const Key &key) const
bool contains(const Key &key) const
constexpr bool is_empty() const
constexpr IndexRange index_range() const
local_group_size(16, 16) .push_constant(Type b
LinearSolver * EIG_linear_solver_new(int num_rows, int num_columns, int num_rhs)
void EIG_linear_solver_right_hand_side_add(LinearSolver *solver, int rhs, int index, double value)
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 BKE_mesh_prefair_and_fair_verts(Mesh *mesh, blender::MutableSpan< float3 > deform_vert_positions, const bool affected_verts[], const eMeshFairingDepth depth)
static void prefair_and_fair_verts(FairingContext &fairing_context, const bool affected_verts[], const eMeshFairingDepth depth)
int edge_other_vert(const int2 edge, const int vert)