46 float r_adj_prev[3]) = 0;
78 fair_verts_ex(affected_verts,
int(depth), vertex_weight, loop_weight);
90 void fair_setup_fairing(
const int v,
101 const int j = vert_col_map.
lookup(
v);
105 for (
int j = 0; j < 3; j++) {
115 const int l_index = vlmap_elem[
l];
119 fair_setup_fairing(other_vert,
122 w_i * w_ij * multiplier,
128 fair_setup_fairing(
v,
131 -1 * w_i * w_ij_sum * multiplier,
138 void fair_verts_ex(
const bool affected_verts[],
144 int affected_verts_num = 0;
146 if (!affected_verts[
i]) {
149 vert_col_map.
add(
i, affected_verts_num);
150 affected_verts_num++;
160 for (
auto item : vert_col_map.
items()) {
161 const int v = item.key;
162 const int col = item.value;
163 fair_setup_fairing(
v,
col, solver, 1.0f, order, vert_col_map, vertex_weight, loop_weight);
170 for (
auto item : vert_col_map.
items()) {
171 const int v = item.key;
172 const int col = item.value;
173 for (
int j = 0; j < 3; j++) {
192 faces = mesh->faces();
195 vlmap_ = mesh->vert_to_corner_map();
201 co_[
i] = deform_positions[
i];
206 co_[
i] = positions[
i];
215 float r_adj_prev[3])
override
245 vertex_weights_.resize(totvert);
246 for (
int i = 0;
i < totvert;
i++) {
249 vertex_weights_[
i] = 1.0f / tot_loop;
259 return vertex_weights_[index];
273 vertex_weights_.resize(totvert);
274 for (
int i = 0;
i < totvert;
i++) {
279 const float acute_threshold =
M_PI_2;
283 const int l_index = vlmap_elem[
l];
285 float b[3], c[3], d[3];
289 calc_circumcenter(d, a,
b, c);
306 vertex_weights_[
i] = area != 0.0f ? 1.0f / area : 1e12;
312 return vertex_weights_[index];
318 void calc_circumcenter(
float r[3],
const float a[3],
const float b[3],
const float c[3])
326 float ab_cross_ac[3];
358 const bool affected_verts[],
364 fairing_context.
fair_verts(affected_verts, depth, uniform_vertex_weights, uniform_loop_weights);
369 fairing_context.
fair_verts(affected_verts, depth, voronoi_vertex_weights, uniform_loop_weights);
374 const bool affected_verts[],
378 if (!deform_vert_positions.
is_empty()) {
379 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])
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
ItemIterator items() const &
constexpr bool is_empty() const
constexpr IndexRange index_range() const
LinearSolver * EIG_linear_solver_new(int num_rows, int num_columns, int num_right_hand_sides)
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)
int2 face_find_adjacent_verts(const IndexRange face, const Span< int > corner_verts, const int vert)
VecBase< int32_t, 2 > int2
VecBase< float, 3 > float3