Skip to content

Commit

Permalink
Broke.
Browse files Browse the repository at this point in the history
  • Loading branch information
fire committed Oct 3, 2024
1 parent ddd5ac6 commit fdc6b29
Showing 1 changed file with 11 additions and 59 deletions.
70 changes: 11 additions & 59 deletions modules/geometry3/remesh_operator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,40 +183,6 @@ DCurve3Ptr ExtractLoopV(g3::DMesh3Ptr mesh, std::vector<int> vertices) {
// }
// }

//static void EdgeLengthStats(DMesh3Ptr mesh, double &minEdgeLen,
// double &maxEdgeLen, double &avgEdgeLen,
// int samples = 0) {
// minEdgeLen = std::numeric_limits<double>::max();
// maxEdgeLen = std::numeric_limits<double>::max();
// avgEdgeLen = 0;
// int avg_count = 0;
// int MaxID = mesh->MaxEdgeID();
//
// // if we are only taking some samples, use a prime-modulo-loop instead of
// // random
// int nPrime = (samples == 0) ? 1 : nPrime = 31337;
// int max_count = (samples == 0) ? MaxID : samples;
//
// Vector3d a, b;
// int eid = 0;
// int count = 0;
// do {
// if (mesh->IsEdge(eid)) {
// mesh->GetEdgeV(eid, a, b);
// double len = (b - a).norm();
// if (len < minEdgeLen)
// minEdgeLen = len;
// if (len > maxEdgeLen)
// maxEdgeLen = len;
// avgEdgeLen += len;
// avg_count++;
// }
// eid = (eid + nPrime) % MaxID;
// } while (eid != 0 && count++ < max_count);
//
// avgEdgeLen /= (double)avg_count;
//}

// https://github.com/gradientspace/geometry3Sharp/blob/master/mesh/MeshConstraintUtil.cs
// void preserve_group_region_border_loops(DMesh3Ptr mesh) {
// int set_id = 1;
Expand All @@ -240,7 +206,7 @@ Array geometry3_process(Array p_mesh) {
::Vector<int32_t> bones_array = p_mesh[Mesh::ARRAY_BONES];
::Vector<float> weights_array = p_mesh[Mesh::ARRAY_WEIGHTS];
if (normal_array.size()) {
g3_mesh->EnableVertexNormals(Vector3f(0.0, 0.0, 1.0));
g3_mesh->EnableVertexNormals(Vector3f(0.0, 1.0, 0.0));
}
if (color_array.size()) {
g3_mesh->EnableVertexColors(Vector3f(1.0, 1.0, 1.0));
Expand Down Expand Up @@ -310,35 +276,21 @@ Array geometry3_process(Array p_mesh) {
g3_mesh->AppendTriangle(new_tri);
}
Remesher r(g3_mesh);
// broke compactinplace
// g3_mesh->CompactInPlace();
g3::MeshConstraintsPtr cons = std::make_shared<MeshConstraints>();
// PreserveAllBoundaryEdges(cons, g3_mesh);
//r.SetExternalConstraints(cons);
//r.SetProjectionTarget(MeshProjectionTarget::AutoPtr(g3_mesh, true));
//PreserveBoundaryLoops(cons, g3_mesh);
// http://www.gradientspace.com/tutorials/2018/7/5/remeshing-and-constraints
int iterations = 1;
//double avg_edge_len = 0.5;
// double min_edge_len = 0.0;
// double max_edge_len = 0.0;
// EdgeLengthStats(g3_mesh, min_edge_len, max_edge_len, avg_edge_len);
// print_line(vformat("target edge len %.2f", avg_edge_len));
// r.SetTargetEdgeLength(avg_edge_len);
r.Precompute();
for (int k = 0; k < iterations; ++k) {
r.BasicRemeshPass();
print_line("remesh pass " + itos(k));
}
// print_line("remesh done");
// RemoveFinTriangles(g3_mesh, true);
// std::cout << g3_mesh->MeshInfoString();
MeshConstraintUtil.FixAllBoundaryEdges(r); // Leaves fins.

Check failure on line 279 in modules/geometry3/remesh_operator.cpp

View workflow job for this annotation

GitHub Actions / 🏁 Windows / Editor (target=editor, tests=yes)

'MeshConstraintUtil': undeclared identifier
r.SetTargetEdgeLength(0.75);
r.SmoothSpeedT = 0.5;
int iterations = 20;
r.Precompute();
for (int k = 0; k < iterations; ++k) {
r.BasicRemeshPass();
print_line("remesh pass " + itos(k));
}
print_line("remesh done");
vertex_array.clear();
index_array.clear();
uv1_array.clear();
normal_array.clear();
color_array.clear();

for (int32_t vertex_i = 0; vertex_i < g3_mesh->MaxVertexID(); vertex_i++) {
NewVertexInfo v = g3_mesh->GetVertexAll(vertex_i);

Expand Down

0 comments on commit fdc6b29

Please sign in to comment.