Skip to content

Free, open-source 3D sculpting for Linux, macOS and Windows: dense meshes, remeshing, painting, built-in AI (image/text to 3D), Send to Unreal, game-ready LODs, Gaussian splats and OpenUSD.

QRemesh 2: big interior faces kept (no holes on closed surfaces), projected cross-field rounds only around zeros of order two or more; closed loops stay on legacy for now (SF_QR2_LOOPS=1 tries QRemesh 2)

islandmed2ff5d27e38b6
diff --git a/src/core/QRemesh2.cpp b/src/core/QRemesh2.cpp
index e10e8a4b..b9c519a1 100644
--- a/src/core/QRemesh2.cpp
+++ b/src/core/QRemesh2.cpp
@@ -552,6 +552,7 @@ Poly extractLattice(const Proxy& p, const Frames& fr, const GridMap& map, float
size_t onB = 0;
for (uint32_t v : f) onB += openCl[v];
if (f.size() <= 32 && onB != f.size()) continue;
+ if (onB * 10 < f.size() * 6 && f.size() <= 400) continue; // kept whole above
if (onB == 0 || onB == f.size()) continue;
const size_t n = f.size();
size_t start = 0;
@@ -575,9 +576,14 @@ Poly extractLattice(const Proxy& p, const Frames& fr, const GridMap& map, float
}
std::vector<uint32_t> remap(nc, kNone);
for (auto& f : faces) {
- if (f.size() < 3 || f.size() > 32) {
- if (std::getenv("SF_QREMESH_TIMING") && f.size() > 32) std::fprintf(stderr, " v2 dropped a face of %zu sides\n", f.size());
- continue;
+ if (f.size() < 3) continue;
+ if (f.size() > 32) { // the outside of an open surface, or a big hole in a closed one (kept, split later)
+ size_t onB = 0;
+ for (uint32_t v : f) onB += openCl[v];
+ if (onB * 10 >= f.size() * 6 || f.size() > 400) {
+ if (std::getenv("SF_QREMESH_TIMING")) std::fprintf(stderr, " v2 dropped a face of %zu sides\n", f.size());
+ continue;
+ }
}
if (f.size() >= 5) { // the outside traces along the open edges only; a face by them is kept (else a hole)
size_t onB = 0;
@@ -1135,8 +1141,8 @@ bool remeshPieceV2(const WorkMesh& piece, int axis, double wantQuads, const QRem
const std::vector<QRemeshGuide>& guides, const std::function<bool(float)>& report,
FieldPieceResult& out, bool& cancelled) {
for (const QRemeshGuide& g : guides)
- if (g.closed || (axis >= 0 && g.points.size() >= 2 && std::abs(g.points.front()[axis]) < 1e-5f * diag &&
- std::abs(g.points.back()[axis]) < 1e-5f * diag)) { // a loop across the symmetry plane, halved
+ if (!std::getenv("SF_QR2_LOOPS") && (g.closed || (axis >= 0 && g.points.size() >= 2 && std::abs(g.points.front()[axis]) < 1e-5f * diag &&
+ std::abs(g.points.back()[axis]) < 1e-5f * diag))) { // a loop across the symmetry plane, halved
// Closed loops (round an eye) don't yet come out clean in the map; the legacy method handles them.
out.why = "closed guide loop";
return false;
diff --git a/src/core/QRemesh2Field.cpp b/src/core/QRemesh2Field.cpp
index 788a4d8a..a73a0e3c 100644
--- a/src/core/QRemesh2Field.cpp
+++ b/src/core/QRemesh2Field.cpp
@@ -271,7 +271,39 @@ bool solveCrossField(const Proxy& p, const Frames& f, const Curvature& curv, con
const double sigma = nfree < nt ? tune_sigma * meanDiag : std::max(bn, 1e-3 * meanDiag);
std::vector<cd> rhsk(nfree);
static const int projected = std::getenv("SF_QR2_PROJ") ? std::atoi(std::getenv("SF_QR2_PROJ")) : 30;
+ std::vector<double> local; // per free triangle: the projected rounds' weight (empty: not run)
for (int round = 0; round < 6 + projected; ++round) {
+ if (round == 6) {
+ // Zeros of order two or more (four poles merged by symmetry, as inside a closed guide loop) are
+ // split by projected rounds around them, strongly there and lightly elsewhere; none: done.
+ CrossField probe;
+ probe.theta.resize(nt);
+ for (size_t t = 0; t < nt; ++t) {
+ const cd v = fixed[t] ? z[t] : x[fid[t]];
+ probe.theta[t] = std::abs(v) > 1e-30 ? float(std::arg(v) / 4.0) : 0.0f;
+ }
+ computeMatching(p, f, probe);
+ std::vector<int> ring(nt, -1);
+ std::vector<uint32_t> queue;
+ for (uint32_t t = 0; t < nt; ++t)
+ for (int k = 0; k < 3; ++k)
+ if (std::abs(probe.vertexIndex[p.T[t][k]]) >= 2 && ring[t] < 0) ring[t] = 0, queue.push_back(t);
+ if (queue.empty()) break;
+ for (size_t qi = 0; qi < queue.size(); ++qi) {
+ const uint32_t t = queue[qi];
+ if (ring[t] >= 30) continue;
+ for (int k = 0; k < 3; ++k) {
+ const uint32_t o = p.opp[3 * t + uint32_t(k)];
+ if (o == kNone || ring[o / 3] >= 0) continue;
+ ring[o / 3] = ring[t] + 1;
+ queue.push_back(o / 3);
+ }
+ }
+ const double strong = std::max(bn, 1e-3 * meanDiag) * 4.0;
+ local.assign(nfree, sigma);
+ for (uint32_t i = 0; i < nfree; ++i)
+ if (ring[freeTris[i]] >= 0) local[i] = strong;
+ }
double xn = 0.0;
for (const cd& v : x) xn += std::norm(v);
xn = std::sqrt(xn / double(nfree)) + 1e-300;
@@ -282,7 +314,7 @@ bool solveCrossField(const Proxy& p, const Frames& f, const Curvature& curv, con
else
for (uint32_t i = 0; i < nfree; ++i) {
const double m = std::abs(x[i]);
- rhsk[i] = sigma * (m > 1e-12 ? x[i] / m : cd(0.0, 0.0)) * 4.0 + b[i];
+ rhsk[i] = local[i] * (m > 1e-12 ? x[i] / m : cd(0.0, 0.0)) + b[i];
}
std::vector<cd> nx(x);
its += pcg<cd>([&](const std::vector<cd>& in, std::vector<cd>& o) { A.mul(in, o); }, &mg, A.diag, rhsk, nx,