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.
C++ 3d3d-sculptingcppdear-imguidigital-sculptingfbxgame-developmentgaussian-splattinggltfimage-to-3dmcpopenglopenusdsculptingtext-to-3dunreal-engine
Implicit vertex adjacency on levels made by Divide: rings and triangle lists worked out from the level topology (mesh 62 -> 34 B/triangle, identical results)
islandmedef85a1117475
diff --git a/src/core/Mesh.cpp b/src/core/Mesh.cppindex 7e654d68..da6bc097 100644--- a/src/core/Mesh.cpp+++ b/src/core/Mesh.cpp@@ -126,6 +126,21 @@ void Mesh::sanitizeAttributes() {void Mesh::rebuildTopology() {sanitizeAttributes();const size_t nv = positions.size();+ finishTopology(); // (the stamps, normals and dirty bits first: they don't depend on the adjacency)++ // A level made by Divide: its adjacency follows from the level's topology.+ implicit_.reset();+ if (multires) {+ const std::shared_ptr<const SubdivTopology>& tp = multires->levels[size_t(multires->current)].topo;+ if (tp && subdivImplicitAdjacency(*tp, triangles)) implicit_ = tp;+ }+ if (implicit_) {+ std::vector<uint32_t>().swap(adjOffsets_);+ std::vector<uint32_t>().swap(adjList_);+ std::vector<uint32_t>().swap(vtOffsets_);+ std::vector<uint32_t>().swap(vtList_);+ return;+ }vtOffsets_.assign(nv + 1, 0);for (const auto& t : triangles)@@ -165,7 +180,10 @@ void Mesh::rebuildTopology() {std::copy(r.begin(), r.end(), adjList_.begin() + adjOffsets_[v]);}});+}+void Mesh::finishTopology() {+ const size_t nv = positions.size();vertStamp_.assign(nv, 0);stamp_ = 0;normals.resize(nv);@@ -176,6 +194,101 @@ void Mesh::rebuildTopology() {facesDirty = true;}+namespace {++inline void sortSmall(uint32_t* a, uint32_t n) {+ for (uint32_t i = 1; i < n; ++i) {+ const uint32_t x = a[i];+ uint32_t j = i;+ for (; j > 0 && a[j - 1] > x; --j) a[j] = a[j - 1];+ a[j] = x;+ }+}++inline uint32_t uniqueSmall(uint32_t* a, uint32_t n) {+ uint32_t k = 0;+ for (uint32_t i = 0; i < n; ++i)+ if (k == 0 || a[k - 1] != a[i]) a[k++] = a[i];+ return k;+}++} // namespace++IndexRing Mesh::implicitTriangles(uint32_t v) const {+ // Fine vertices are the coarse vertices, then one per coarse edge, then one per polygon; each polygon's fine+ // triangles are laid out as generateFaces does (Catmull-Clark: corner i -> triangles 2i, 2i + 1 of the+ // polygon, the first holding side i's edge point, the second side i - 1's; Loop: corner i -> triangle i,+ // the edge points' triangle last).+ const SubdivTopology& tp = *implicit_;+ const uint32_t nv = tp.coarseVertices, ne = uint32_t(tp.edges.size());+ constexpr uint32_t kNone = SubdivTopology::kNone;+ IndexRing r;+ auto add = [&](size_t f) { r.buf_[r.size_++] = uint32_t(f); };+ if (v < nv) {+ uint32_t polys[IndexRing::kCapacity];+ uint32_t n = 0;+ for (uint32_t k = tp.vertEdgeOffsets[v]; k < tp.vertEdgeOffsets[v + 1]; ++k) {+ const glm::uvec2 f = tp.edgeFaces[tp.vertEdges[k]];+ polys[n++] = f.x;+ if (f.y != kNone) polys[n++] = f.y;+ }+ sortSmall(polys, n);+ n = uniqueSmall(polys, n);+ for (uint32_t k = 0; k < n; ++k) {+ const uint32_t p = polys[k], o = tp.polyOffsets[p], sides = tp.polyOffsets[p + 1] - o;+ uint32_t i = 0;+ while (i + 1 < sides && tp.polyVerts[o + i] != v) ++i;+ if (tp.catmullClark) {+ add(2 * size_t(o + i));+ add(2 * size_t(o + i) + 1);+ } else {+ add(4 * size_t(p) + i);+ }+ }+ } else if (v < nv + ne) {+ const uint32_t e = v - nv;+ const glm::uvec2 f = tp.edgeFaces[e];+ const uint32_t polys[2] = {std::min(f.x, f.y), f.y == kNone ? kNone : std::max(f.x, f.y)};+ for (uint32_t p : polys) {+ if (p == kNone) break;+ const uint32_t o = tp.polyOffsets[p], sides = tp.polyOffsets[p + 1] - o;+ uint32_t s = 0;+ while (s + 1 < sides && tp.polyEdges[o + s] != e) ++s;+ if (tp.catmullClark) {+ const size_t a = 2 * size_t(o + s), b = 2 * size_t(o + (s + 1) % sides) + 1;+ add(std::min(a, b));+ add(std::max(a, b));+ } else {+ const size_t a = 4 * size_t(p) + s, b = 4 * size_t(p) + (s + 1) % 3;+ add(std::min(a, b));+ add(std::max(a, b));+ add(4 * size_t(p) + 3);+ }+ }+ } else {+ const uint32_t p = v - nv - ne;+ for (size_t t = tp.firstFineTriangle(p), end = tp.firstFineTriangle(p + 1); t < end; ++t) add(t);+ }+ return r;+}++IndexRing Mesh::implicitNeighbors(uint32_t v) const {+ const IndexRing tris = implicitTriangles(v);+ uint32_t all[2 * IndexRing::kCapacity];+ uint32_t n = 0;+ for (uint32_t t : tris) {+ const glm::uvec3& tri = triangles[t];+ for (int c = 0; c < 3; ++c)+ if (tri[c] != v) all[n++] = tri[c];+ }+ sortSmall(all, n);+ n = uniqueSmall(all, n);+ IndexRing r;+ std::copy(all, all + n, r.buf_);+ r.size_ = n;+ return r;+}+uint32_t Mesh::nextStamp() {if (++stamp_ == 0) {std::fill(vertStamp_.begin(), vertStamp_.end(), 0);@@ -385,7 +498,7 @@ size_t Mesh::memoryBytes() const {bytes(adjList_) + bytes(vtOffsets_) + bytes(vtList_) + bytes(vertStamp_) + bytes(scratchVerts_) + bytes(dirtyBlocks) + bytes(dirtyBits);for (const auto& l : layers) n += bytes(l.delta);for (const auto& l : paintLayers) n += bytes(l.color) + bytes(l.alpha);- return n;+ return n; // (implicit adjacency: the level topology is counted with the subdivision levels)}static void laplacianStep(Mesh& m, float lambda, std::vector<glm::vec3>& next) {diff --git a/src/core/Mesh.h b/src/core/Mesh.hindex b5cab46c..376409ff 100644--- a/src/core/Mesh.h+++ b/src/core/Mesh.h@@ -18,6 +18,31 @@ namespace sf {struct PaintTexture;struct MultiresStack;+struct SubdivTopology;++// The vertices or triangles around a vertex (Mesh::neighbors, Mesh::vertexTriangles), in ascending order: a view+// of the mesh's adjacency lists or, where the mesh's adjacency is implicit, the list itself. Use it like a span+// (but don't keep a pointer into it past its lifetime).+class IndexRing {+public:+ static constexpr uint32_t kCapacity = 64;+ IndexRing() = default;+ IndexRing(const uint32_t* b, const uint32_t* e) : ptr_(b), size_(uint32_t(e - b)) {}+ const uint32_t* data() const { return ptr_ ? ptr_ : buf_; }+ const uint32_t* begin() const { return data(); }+ const uint32_t* end() const { return data() + size_; }+ size_t size() const { return size_; }+ bool empty() const { return size_ == 0; }+ uint32_t operator[](size_t i) const { return data()[i]; }+ uint32_t front() const { return data()[0]; }+ uint32_t back() const { return data()[size_ - 1]; }++private:+ friend class Mesh;+ const uint32_t* ptr_ = nullptr; // null: the indices are in buf_+ uint32_t size_ = 0;+ uint32_t buf_[kCapacity]; // (not initialised: only the first size_ are used)+};struct AABB {glm::vec3 min{std::numeric_limits<float>::max()};@@ -159,18 +184,24 @@ public:size_t vertexCount() const { return positions.size(); }size_t triangleCount() const { return triangles.size(); }- // Must be called after the triangle list or vertex count changes.+ // Must be called after the triangle list or vertex count changes. A mesh that is the current level of its+ // subdivision stack, made by Divide, gets implicit adjacency (implicitAdjacency).void rebuildTopology();void recomputeAllNormals();// Recompute normals of the faces around `verts` and of every vertex they touch.void updateNormals(std::span<const uint32_t> verts);- std::span<const uint32_t> neighbors(uint32_t v) const {+ // The vertices sharing an edge with `v`, and the triangles around it, in ascending order.+ IndexRing neighbors(uint32_t v) const {+ if (implicit_) return implicitNeighbors(v);return {adjList_.data() + adjOffsets_[v], adjList_.data() + adjOffsets_[v + 1]};}- std::span<const uint32_t> vertexTriangles(uint32_t v) const {+ IndexRing vertexTriangles(uint32_t v) const {+ if (implicit_) return implicitTriangles(v);return {vtList_.data() + vtOffsets_[v], vtList_.data() + vtOffsets_[v + 1]};}+ // True when the adjacency follows from the subdivision level this mesh is (see rebuildTopology).+ bool implicitAdjacency() const { return bool(implicit_); }AABB bounds() const;// Bytes this mesh holds (every array, topology included; not the shared texture or subdivision stack).@@ -210,9 +241,16 @@ public:private:uint32_t nextStamp();+ void finishTopology();+ IndexRing implicitTriangles(uint32_t v) const;+ IndexRing implicitNeighbors(uint32_t v) const;+ // Vertex adjacency (CSR), or, on a mesh that is a level made by Divide (whose triangles are the ones its+ // subdivision topology generates), that topology: the triangles and rings around a vertex are worked out from+ // the coarse polygons around it instead of stored, which saves about 28 bytes per triangle.std::vector<uint32_t> adjOffsets_, adjList_;std::vector<uint32_t> vtOffsets_, vtList_;+ std::shared_ptr<const SubdivTopology> implicit_;// updateNormals: vertices already gathered this call (== stamp_), the gathered ones, per-block parts.std::vector<uint32_t> vertStamp_;diff --git a/src/core/Multires.cpp b/src/core/Multires.cppindex daab0be5..ef1b58c4 100644--- a/src/core/Multires.cpp+++ b/src/core/Multires.cpp@@ -183,6 +183,7 @@ std::shared_ptr<SubdivTopology> buildCoarse(const std::vector<glm::uvec3>& trianconst uint32_t u = pairing.empty() ? kNone : pairing[t];const glm::uvec3& a = triangles[t];if (u == kNone) {+ if (a.x == a.y || a.y == a.z || a.x == a.z) tp->nonManifold = true; // degenerate: no implicit adjacencyfor (uint32_t c = 0; c < 3; ++c) {tp->polyVerts.push_back(a[c]);}@@ -400,6 +401,14 @@ bool matchesGenerated(const SubdivTopology& tp, const std::vector<glm::uvec3>& treturn same;}+} // namespace++bool subdivImplicitAdjacency(const SubdivTopology& tp, const std::vector<glm::uvec3>& triangles) {+ return tp.generated && !tp.nonManifold && tp.maxValence <= IndexRing::kCapacity / 2 && matchesGenerated(tp, triangles);+}++namespace {+// True when the child maps number the fine vertices as a generated level does.bool canonicalChildren(const SubdivTopology& tp) {const uint32_t nv = tp.coarseVertices, ne = uint32_t(tp.edges.size());diff --git a/src/core/Multires.h b/src/core/Multires.hindex 905b3483..c62cda11 100644--- a/src/core/Multires.h+++ b/src/core/Multires.h@@ -81,7 +81,7 @@ struct SubdivTopology {std::vector<uint32_t> vertexChild, edgeChild, faceChild;std::vector<uint32_t> fineParentPoly, fineParentTri;std::vector<uint8_t> fineCode;- bool nonManifold = false; // some coarse edge has more than two polygons+ bool nonManifold = false; // some coarse edge has more than two polygons, or a polygon repeats a corneruint32_t maxValence = 0; // most edges at one coarse vertexstatic constexpr uint32_t kNone = ~0u;@@ -104,6 +104,10 @@ struct SubdivTopology {size_t bytes() const;};+// True when a mesh with these triangles can work out its adjacency from `tp` (Mesh::implicitAdjacency): a+// generated level of a manifold mesh without very high valences, whose triangles are the generated ones.+bool subdivImplicitAdjacency(const SubdivTopology& tp, const std::vector<glm::uvec3>& triangles);+// The fine triangles of a generated level, in order, and (Catmull-Clark) their quad pairs (each corner of a// polygon becomes one quad: triangles 2i and 2i + 1).void generateFaces(const SubdivTopology& tp, std::vector<glm::uvec3>& triangles, std::vector<uint32_t>* quadPartners);diff --git a/src/core/Project.cpp b/src/core/Project.cppindex 59da6379..2cad04b3 100644--- a/src/core/Project.cpp+++ b/src/core/Project.cpp@@ -208,7 +208,10 @@ void writeMesh(Writer& w, const std::string& prefix, const Mesh& m, Json& out, s// Reads a mesh from its `mesh` and `layers` manifest entries (size-checked against the blobs). `levelData`: a// subdivision level's arrays, kept without topology or normals; a generated level's have no triangles.-bool readMesh(Reader& r, const Json& mj, const Json& lj, Mesh& m, std::string& error, bool levelData = false) {+// `topology` false: the caller calls finishMesh once the mesh has its subdivision levels (so it gets the+// adjacency they give).+bool readMesh(Reader& r, const Json& mj, const Json& lj, Mesh& m, std::string& error, bool levelData = false,+ bool topology = true) {const size_t nv = countOf(mj["vertex_count"]), nt = countOf(mj["triangle_count"]);if (nv == size_t(-1) || nt == size_t(-1)) {error = "Project mesh has no valid vertex/triangle count";@@ -260,8 +263,9 @@ bool readMesh(Reader& r, const Json& mj, const Json& lj, Mesh& m, std::string& eerror = r.error;return false;}- if (levelData) {+ if (levelData || !topology) {if (!m.layers.empty()) m.evaluateAll();+ if (!topology) m.sanitizeAttributes();return true;}m.rebuildTopology();@@ -270,6 +274,11 @@ bool readMesh(Reader& r, const Json& mj, const Json& lj, Mesh& m, std::string& ereturn true;}+void finishMesh(Mesh& m) {+ m.rebuildTopology();+ m.recomputeAllNormals();+}+// Paint layers (core/PaintLayer.h) are their own SubTool key, "paint_layers", next to "mesh":// readers that don't know it load `mesh.colors`, the composited (flattened) paint.Json writePaintLayers(Writer& w, const std::string& prefix, const Mesh& m) {@@ -741,10 +750,11 @@ bool loadProject(const std::string& path, Document& doc, std::string& error) {if (s.name.empty()) s.name = "SubTool";s.visible = sj["visible"].asBool(true);s.gozName = sj["goz_name"].asString();- if (!readMesh(r, sj["mesh"], sj["layers"], s.mesh, error)) return false;+ if (!readMesh(r, sj["mesh"], sj["layers"], s.mesh, error, false, false)) return false;if (!readPaintLayers(r, sj["paint_layers"], s.mesh, error)) return false;if (!readTexture(r, sj["texture"], s.mesh, error)) return false;if (!readSubdiv(r, sj["subdiv"], s.mesh, error, version < 5)) return false;+ finishMesh(s.mesh);s.activeLayer = int(sj["active_layer"].asNumber(-1));subtools.push_back(std::move(s));}diff --git a/tests/test_mesh_memory.cpp b/tests/test_mesh_memory.cppnew file mode 100644index 00000000..4e779808--- /dev/null+++ b/tests/test_mesh_memory.cpp@@ -0,0 +1,191 @@+// SculptForge - open source digital sculpting+// SPDX-License-Identifier: GPL-3.0-or-later+//+// Memory per triangle (v0.6): levels made by Divide keep no triangles or child maps (generated topology), the+// working mesh of such a level works out its adjacency from the level's topology (implicit adjacency) and gets+// exactly the lists the stored adjacency would give, and the stack keeps positions or details, not both.+#include "TestHarness.h"++#include "core/Benchmark.h"+#include "core/Commands.h"+#include "core/Multires.h"+#include "core/Primitives.h"+#include "core/Project.h"++#include <filesystem>++using namespace sf;++namespace {++const CommandRegistry& registry() {+ static CommandRegistry r;+ return r;+}++CommandResult run(Document& d, const std::string& name, const Args& a = {}) {+ CommandResult r = registry().execute(d, name, a);+ if (!r.ok) std::printf(" (%s: %s)\n", name.c_str(), r.message.c_str());+ return r;+}++// The same mesh with stored (CSR) adjacency.+Mesh explicitCopy(const Mesh& m) {+ Mesh e = m;+ e.multires.reset();+ e.rebuildTopology();+ return e;+}++// Every vertex's ring and triangle list match the stored adjacency's, element for element.+bool sameAdjacency(const Mesh& a, const Mesh& b) {+ if (a.vertexCount() != b.vertexCount()) return false;+ for (uint32_t v = 0; v < a.vertexCount(); ++v) {+ const IndexRing na = a.neighbors(v), nb = b.neighbors(v), ta = a.vertexTriangles(v), tb = b.vertexTriangles(v);+ if (!std::equal(na.begin(), na.end(), nb.begin(), nb.end()) || !std::equal(ta.begin(), ta.end(), tb.begin(), tb.end())) {+ std::printf(" vertex %u differs (%zu/%zu neighbours, %zu/%zu triangles)\n", v, na.size(), nb.size(), ta.size(), tb.size());+ return false;+ }+ }+ return true;+}++Document divided(Mesh base, int levels) {+ Document d = makeDoc(std::move(base));+ for (int i = 0; i < levels; ++i) run(d, "subdiv_divide");+ return d;+}++} // namespace++TEST(implicit_adjacency_matches_the_stored_lists) {+ // Catmull-Clark on quads; on quads mixed with triangles; with a boundary (an open cube); Loop on triangles.+ Mesh mixed = makeCube(3);+ for (uint32_t t = 0; t < 12; t += 2) mixed.quadPartners[t] = mixed.quadPartners[t + 1] = Mesh::kNoQuad;+ mixed.rebuildTopology();+ Mesh open = makeCube(3);+ {+ std::vector<glm::uvec3> kept;+ std::vector<uint32_t> quads;+ for (uint32_t t = 0; t < open.triangleCount(); ++t) {+ const glm::vec3 c = (open.positions[open.triangles[t].x] + open.positions[open.triangles[t].y] + open.positions[open.triangles[t].z]) / 3.0f;+ if (c.y > 0.99f) continue; // no top face+ kept.push_back(open.triangles[t]);+ }+ Mesh m;+ m.positions = open.positions;+ m.triangles = kept;+ for (uint32_t t = 0; t + 1 < kept.size(); t += 2) m.pairQuad(t, t + 1); // makeCube writes quads as pairs+ m.rebuildTopology();+ m.recomputeAllNormals();+ open = std::move(m);+ }+ struct Case {+ const char* name;+ Mesh base;+ };+ std::vector<Case> cases;+ cases.push_back({"quads", makeCube(2)});+ cases.push_back({"quads and triangles", mixed});+ cases.push_back({"open", open});+ cases.push_back({"triangles (Loop)", makeIcosphere(1)});+ for (const Case& c : cases) {+ Document d = divided(c.base, 2);+ std::printf(" %s: %zu triangles, implicit %d\n", c.name, d.mesh.triangleCount(), int(d.mesh.implicitAdjacency()));+ CHECK(subdivLevelCount(d.mesh) == 3);+ CHECK(d.mesh.implicitAdjacency());+ CHECK(sameAdjacency(d.mesh, explicitCopy(d.mesh)));+ // A lower level (from the level cache or rebuilt) is a generated level too, except the base.+ CHECK(run(d, "subdiv_level", {{"level", 2.0}}).ok);+ CHECK(d.mesh.implicitAdjacency());+ CHECK(sameAdjacency(d.mesh, explicitCopy(d.mesh)));+ CHECK(run(d, "subdiv_level", {{"level", 1.0}}).ok);+ CHECK(!d.mesh.implicitAdjacency());+ }+}++TEST(implicit_adjacency_falls_back_to_stored_lists) {+ // A pole with more triangles than an IndexRing holds: stored lists, and still correct.+ Mesh fan;+ const int n = 40;+ fan.positions.push_back(glm::vec3(0, 1, 0));+ fan.positions.push_back(glm::vec3(0, -1, 0));+ for (int i = 0; i < n; ++i) {+ const float a = float(i) * 6.2831853f / float(n);+ fan.positions.push_back(glm::vec3(std::cos(a), 0, std::sin(a)));+ }+ for (int i = 0; i < n; ++i) {+ const uint32_t a = 2 + uint32_t(i), b = 2 + uint32_t((i + 1) % n);+ fan.triangles.push_back({0, b, a});+ fan.triangles.push_back({1, a, b});+ }+ fan.rebuildTopology();+ fan.recomputeAllNormals();+ Document d = divided(fan, 1);+ CHECK(subdivLevelCount(d.mesh) == 2);+ CHECK(!d.mesh.implicitAdjacency());+ CHECK(d.mesh.neighbors(0).size() == size_t(n));+ // Changed topology (a triangle flipped, same counts): the stack is dropped or the lists are stored again.+ Document e = divided(makeCube(2), 1);+ CHECK(e.mesh.implicitAdjacency());+ std::swap(e.mesh.triangles[0].y, e.mesh.triangles[0].z);+ e.mesh.rebuildTopology();+ CHECK(!e.mesh.implicitAdjacency());+ CHECK(sameAdjacency(e.mesh, explicitCopy(e.mesh)));+}++TEST(implicit_adjacency_sculpts_like_stored_lists) {+ // The same strokes on a mesh with implicit and with stored adjacency give bit-identical shapes.+ Document a = divided(makeCube(2), 3);+ Document b = makeDoc(explicitCopy(a.mesh));+ CHECK(a.mesh.implicitAdjacency() && !b.mesh.implicitAdjacency());+ for (Document* d : {&a, &b}) {+ CHECK(run(*d, "stroke", {{"points", "-0.3,0.2,2 0.3,0.25,2"}, {"brush", "Standard"}, {"radius", 0.3}}).ok);+ CHECK(run(*d, "stroke", {{"points", "0.1,-0.4,2 0.2,0.4,2"}, {"brush", "Smooth"}, {"radius", 0.3}}).ok);+ }+ CHECK(a.mesh.positions == b.mesh.positions);+ CHECK(a.mesh.normals == b.mesh.normals);+}++TEST(divided_levels_store_little) {+ // A 400k sphere with levels (as the benchmark builds): the stack and the working mesh stay small.+ Mesh m = makeBenchSphere(400000);+ const double nt = double(m.triangleCount());+ const double stack = double(subdivBytes(m)) / nt, mesh = double(m.memoryBytes()) / nt;+ std::printf(" stack %.1f B/triangle, mesh %.1f B/triangle\n", stack, mesh);+ CHECK(m.implicitAdjacency());+ CHECK(stack < 32.0); // was 74+ CHECK(mesh < 36.0); // was 62+ // Every generated level stores no triangles; the top keeps its positions but no detail.+ for (int i = 1; i < subdivLevelCount(m); ++i) {+ CHECK(subdivLevel(m, i).topo->generated);+ CHECK(subdivLevelData(m, i).triangles.empty());+ CHECK(!subdivLevel(m, i).detail);+ }+}++TEST(divided_levels_project_round_trip) {+ // Format 6 keeps no triangles or child maps for generated levels; they come back generated, with implicit+ // adjacency, and the same shapes at every level.+ Document d = divided(makeCube(3), 3);+ CHECK(run(d, "stroke", {{"points", "-0.3,0.2,2 0.3,0.25,2"}, {"brush", "Standard"}, {"radius", 0.3}}).ok);+ CHECK(run(d, "subdiv_level", {{"level", 2.0}}).ok);+ CHECK(run(d, "stroke", {{"points", "0,0,2"}, {"brush", "Inflate"}, {"radius", 0.5}}).ok);+ const std::string path = (std::filesystem::temp_directory_path() / "sf_mesh_memory.sfproj").string();+ std::string err;+ CHECK(run(d, "save_project", {{"path", path}}).ok);+ Document e;+ CHECK(loadProject(path, e, err));+ CHECK(subdivLevelText(e.mesh) == "SDiv 2/4");+ CHECK(e.mesh.implicitAdjacency());+ CHECK(e.mesh.positions == d.mesh.positions);+ for (int level : {4, 1, 3}) {+ CHECK(run(d, "subdiv_level", {{"level", double(level)}}).ok);+ CHECK(run(e, "subdiv_level", {{"level", double(level)}}).ok);+ CHECK(e.mesh.positions == d.mesh.positions);+ CHECK(e.mesh.triangles == d.mesh.triangles);+ CHECK(e.mesh.quadPartners == d.mesh.quadPartners);+ }+ for (int i = 1; i < subdivLevelCount(e.mesh); ++i) CHECK(subdivLevel(e.mesh, i).topo->generated);+ std::filesystem::remove(path);+}