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
Voxel / Quick Remesh cap open borders (no holed shell; uncappable Parts stay with a reason); UV Editor toolbar wraps at big UI scales, Frame no longer over Colours
islandmed1bbdd9e07d43
diff --git a/CMakeLists.txt b/CMakeLists.txtindex dd75a02e..4371dc18 100644--- a/CMakeLists.txt+++ b/CMakeLists.txt@@ -866,6 +866,8 @@ if(SCULPTFORGE_BUILD_TESTS)if(TEST ui_ui_scale)set_tests_properties(ui_ui_scale PROPERTIES LABELS "ui;dpi")endif()+ # The UV Editor toolbar on a 4K screen (scales 1.0, 1.5 and 2.4): wrapped, nothing cut off, each control its own click.+ sculptforge_ui_test(uv_editor_scales_4k uv_editor_scales --size 3840x2160)# The Library on a 1280x720 screen (#80): its close button stays on screen.sculptforge_ui_test(library_small_screen_720 library_small_screen --size 1280x720)# #107: every look's right tray on a 1280x720 screen; #105: a Windows laptop at 150-200 % (2560x1600 at 200 % isdiff --git a/changes/fix-remesh-open-uv-scale.md b/changes/fix-remesh-open-uv-scale.mdnew file mode 100644index 00000000..e249a4cd--- /dev/null+++ b/changes/fix-remesh-open-uv-scale.md@@ -0,0 +1,29 @@+---+whats_new: **Remeshing an open Part stays solid**: **Quick Remesh** and **Tool > Remesh > Voxel Remesh** cap open+ borders (the Stylised Head's neck, a cut) before remeshing, so the result is one closed surface, not a shell full of+ holes. A Part that can't be made solid stays as it is, and the status bar says why.+whats_new: **UV Editor at large UI scales**: the toolbar wraps on a 4K screen at 240 %, so **On model: Colours /+ Checker** and **Frame** are all visible and each takes its own click.+fixed: **Quick Remesh** and **Tool > Remesh > Voxel Remesh** of an open Part (the Stylised Head starter, open at the+ neck, especially after a Move pull near the neck) gave a thin shell full of holes: the outside flowed in through the+ opening. Open borders are now capped before the voxels are made (only for the remesh; the Part's own surface is+ not touched), and a Part that still isn't a closed solid (borders that can't be capped) is left unchanged with a+ message pointing to **Tool > Geometry > Close Holes**, instead of a broken result.+fixed: **UV Editor** at UI scale 2.4 (a 4K screen): the **On model: Colours / Checker** row was cut off and **Frame**+ was drawn over it, so clicking Frame toggled Colours. The toolbar now measures each control (in the interface+ language) and wraps onto more lines when it needs to; every control is where it is drawn.+testers:+ - Any OS: File > New from starter mesh > Stylised Head; Move brush, pull the front of the neck down and forward;+ Tool > Remesh > Voxel Remesh at Resolution 123: a closed head, no holes (turn the view to look into the neck).+ Ctrl+Z, then Quick Remesh on and Shift+R: the same.+ - Windows / Linux on a 4K screen: Edit > Preferences > Interface > UI scale 240 %; Alt+U opens the UV Editor:+ the toolbar wraps, nothing is cut off; click Colours, Checker and Frame: each does its own thing.+---+Reviewer notes:+- Voxel.cpp voxelRemesh: open edges (undirected count 1, so flipped triangles don't hide them) -> closeHoles on a+ positions+triangles copy (refine off: no new vertices; attributes still transfer from the original). Then, only for+ open input, a leak check: solid cells < half the capped mesh's volume in cells -> empty result + reason. Closed+ meshes take exactly the old path.+- tests: test_quick_remesh.cpp voxel_remesh_open_starter_head_stays_solid (Stylised Head, unpulled and Move-pulled,+ res 64/123/200: closed, one piece, volume within 8 % of the capped head) and voxel_remesh_uncappable_open_mesh_says_why;+ tests/ui/remesh_open_mesh.sfui (both buttons in the app), tests/ui/uv_editor_scales.sfui (+ _4k at 3840x2160).diff --git a/src/app/PanelUvEditor.cpp b/src/app/PanelUvEditor.cppindex 79fc8973..7fd364ab 100644--- a/src/app/PanelUvEditor.cpp+++ b/src/app/PanelUvEditor.cpp@@ -174,6 +174,11 @@ struct UvEditorState {};std::unique_ptr<Job> job;int unwraps = 0; // finished (UI tests)+ int frames = 0; // Frame clicks and F presses (UI tests: uv_frames)+ // The toolbar's items as drawn last frame and the window's right edge (UI tests: uv_toolbar_overlap / _clipped).+ struct Box { ImVec2 Min, Max; };+ std::vector<Box> toolbarItems;+ float toolbarRight = 0.0f;double frameMs = 0.0; // what the last frame of the window cost on the CPU (UI tests: uv_frame_ms)};@@ -373,6 +378,7 @@ struct UvEditorUi {s.zoom = std::min(s.viewSize.x / size.x, s.viewSize.y / size.y) * 0.88f;}void frameAll() {+ ++s.frames;const Mesh& m = mesh();if (!s.selCorners.empty() && !app.doc_.uvSelection.empty()) {frame(s.selLo, s.selHi);@@ -981,12 +987,21 @@ void App::drawUvEditor() {const CanvasRect cr = canvasRect();ImGui::SetNextWindowPos(ImVec2(cr.x + cr.w * 0.34f, cr.y + 6 * scale), ImGuiCond_FirstUseEver);ImGui::SetNextWindowSize(ImVec2(cr.w * 0.66f - 6 * scale, cr.h - 12 * scale), ImGuiCond_FirstUseEver);- ImGui::SetNextWindowSizeConstraints(ImVec2(520 * scale, 360 * scale), ImVec2(FLT_MAX, FLT_MAX));+ // Never bigger than the canvas (a small window at a big UI scale), and pulled back inside the screen.+ const ImVec2 screen = ImGui::GetIO().DisplaySize;+ ImGui::SetNextWindowSizeConstraints(ImVec2(std::min(520 * scale, cr.w), std::min(360 * scale, cr.h)),+ ImVec2(FLT_MAX, FLT_MAX));ImGui::SetNextWindowBgAlpha(1.0f);if (!ImGui::Begin("UV Editor", &showUvEditor_, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoScrollbar)) {ImGui::End();return;}+ {+ const ImVec2 pos = ImGui::GetWindowPos(), size = ImGui::GetWindowSize();+ const ImVec2 to(std::max(0.0f, std::min(pos.x, screen.x - size.x)), std::max(0.0f, std::min(pos.y, screen.y - size.y)));+ if (to.x != pos.x || to.y != pos.y) ImGui::SetWindowPos(to);+ if (size.x > screen.x || size.y > screen.y) ImGui::SetWindowSize(ImVec2(std::min(size.x, screen.x), std::min(size.y, screen.y)));+ }Mesh& m = doc_.mesh;const ImGuiStyle& style = ImGui::GetStyle();@@ -994,9 +1009,14 @@ void App::drawUvEditor() {ImGui::AlignTextToFramePadding();ImGui::TextDisabled("%s", tr("Select"));ImGui::SameLine();+ const ImVec2 segmentsMin = ImGui::GetCursorScreenPos();ui::Segmented(*this, {"uv.mode_vertex", "uv.mode_edge", "uv.mode_face", "uv.mode_island"}, 248 * scale);- // The rest of the toolbar wraps onto a second line when the window is narrow.- const float frameW = 74 * scale;+ s.toolbarItems.assign(1, {segmentsMin, ImGui::GetItemRectMax()});+ auto toolbarItem = [&] { s.toolbarItems.push_back({ImGui::GetItemRectMin(), ImGui::GetItemRectMax()}); };+ // The rest of the toolbar wraps onto more lines when the window is narrow or the interface is scaled up (4K at+ // 2.4): every item measured as drawn, in the interface language, with room kept for Frame at the right.+ const float frameW = std::max(74 * scale, ImGui::CalcTextSize(tr("Frame")).x + ImGui::GetFrameHeight() ++ style.FramePadding.x * 2);const float rowStart = ImGui::GetCursorPosX();auto nextOnLine = [&](float itemW, float gap) {ImGui::SameLine(0, gap);@@ -1005,11 +1025,15 @@ void App::drawUvEditor() {ImGui::SetCursorPosX(rowStart);}};+ auto checkboxW = [&](const char* label) {+ return ImGui::GetFrameHeight() + style.ItemInnerSpacing.x + ImGui::CalcTextSize(tr(label), nullptr, true).x;+ };nextOnLine(130 * scale, 14 * scale);ImGui::SetNextItemWidth(130 * scale);const char* colorLabels[4];for (int i = 0; i < 4; ++i) colorLabels[i] = tr(kColorLabels[i]);if (ImGui::Combo("##uvcolor", &s.color, colorLabels, 4)) s.colorsDirty = true;+ toolbarItem();ui::HelpText("Colours", nullptr,"What the faces show, here and on the model: Islands (a colour each), Stretch (green: true to the surface; ""yellow to red: stretched or squashed; magenta: folded over), Density (texel density; blue: fewer texels than the "@@ -1020,21 +1044,29 @@ void App::drawUvEditor() {const char* imageLabels[3];for (int i = 0; i < 3; ++i) imageLabels[i] = tr(kImageLabels[i]);ImGui::Combo("##uvimage", &s.image, imageLabels, 3);+ toolbarItem();ui::HelpText("Image", nullptr, "Behind the layout: nothing, a checker, or the painted texture (tile 1001).", kPath);- nextOnLine(ImGui::CalcTextSize("Model").x + ImGui::GetFrameHeight() * 2, 14 * scale);+ // "On model" stays with its first checkbox; the second wraps on its own.+ nextOnLine(ImGui::CalcTextSize(tr("On model")).x + style.ItemSpacing.x + checkboxW("Colours##uvmodel"), 14 * scale);ImGui::AlignTextToFramePadding();ImGui::TextDisabled("%s", tr("On model"));ImGui::SameLine();if (ui::Checkbox("Colours##uvmodel", &s.modelColors)) s.colorsDirty = true;+ toolbarItem();ui::HelpText("Colours on the model", nullptr,"Show the same colours on the model (islands, stretch, density and the selection), live while you edit.",kPath);- ImGui::SameLine();+ nextOnLine(checkboxW("Checker##uvchecker"), style.ItemSpacing.x);if (ui::Checkbox("Checker##uvchecker", &s.modelChecker)) s.colorsDirty = true;+ toolbarItem();ui::HelpText("Checker on the model", nullptr,"A checker on the model's UVs (tinted per UDIM tile): squares that stay square mean no stretch.", kPath);- ImGui::SameLine(ImGui::GetContentRegionAvail().x + ImGui::GetCursorPosX() - frameW);+ // Frame at the right end of the last line (there is always room: nextOnLine kept it).+ ImGui::SameLine(std::max(ImGui::GetContentRegionAvail().x + ImGui::GetCursorPosX() - frameW,+ ImGui::GetCursorPosX()));ui::ActionButton(*this, "uv.frame", ImVec2(frameW, 0));+ toolbarItem();+ s.toolbarRight = ImGui::GetWindowPos().x + ImGui::GetWindowContentRegionMax().x;// Sidebar on the right, the view in the rest.const float sideW = 236 * scale;@@ -1621,6 +1653,22 @@ double App::uvEditorTestValue(const std::string& name) {if (name == "uv_pack_columns") return double(uvPackColumns_); // the Pack fieldsif (name == "uv_pack_rows") return double(uvPackRows_);if (name == "uv_frame_ms") return uvEditor_ ? uvEditor_->frameMs : 0.0;+ if (name == "uv_frames") return uvEditor_ ? double(uvEditor_->frames) : 0.0; // Frame clicks and F presses+ if (name == "uv_model_colors") return uvEditor_ && uvEditor_->modelColors ? 1.0 : 0.0;+ if (name == "uv_model_checker") return uvEditor_ && uvEditor_->modelChecker ? 1.0 : 0.0;+ if (name == "uv_toolbar_overlap" || name == "uv_toolbar_clipped") { // toolbar items on top of each other / cut off+ double n = 0;+ if (!uvEditor_) return n;+ const auto& r = uvEditor_->toolbarItems;+ for (size_t i = 0; i < r.size(); ++i) {+ if (name == "uv_toolbar_clipped") n += r[i].Max.x > uvEditor_->toolbarRight + 0.5f;+ else+ for (size_t j = i + 1; j < r.size(); ++j)+ n += r[i].Min.x < r[j].Max.x - 0.5f && r[j].Min.x < r[i].Max.x - 0.5f && r[i].Min.y < r[j].Max.y - 0.5f &&+ r[j].Min.y < r[i].Max.y - 0.5f;+ }+ return n;+ }if (name == "uv_tool") return uvEditor_ ? double(uvEditor_->tool) : 0.0;if (name == "uv_view_triangles") return uvEditor_ ? double(uvEditor_->gpu.triangles()) : 0.0;if (name == "uv_overlay") return uvEditorOverlay(doc_.activePartInfo().id) && !uvEditor_->overlay.colors.empty() ? 1.0 : 0.0;diff --git a/src/app/UiTest.cpp b/src/app/UiTest.cppindex 747a2ab3..d60dfd15 100644--- a/src/app/UiTest.cpp+++ b/src/app/UiTest.cpp@@ -88,7 +88,8 @@// "SculptForge has a new look" card),// parts (count), part_thumbnails (Part panel thumbnails rendered), active_part (index, 0 = top), visible_parts,// extract_preview (1 while an Extract preview waits for Accept), open_edges (edges of-// the active Part with one triangle: 0 = watertight),+// the active Part with one triangle: 0 = watertight), solid_volume (the active Part's+// volume with its open borders capped),// edited_parts (Parts with undo history), user_brushes (brushes in the// user library), library_files (.sfbrush files in it; UI tests get an empty// one in --ui-out/brush-library), ui_config (1 once ui.json is written: the preferences save themselves, or Save Layout),@@ -273,6 +274,7 @@#include "app/Ui.h"#include "core/BrushLibrary.h"+#include "core/CloseHoles.h"#include "core/ListSort.h"#include "core/LitSphere.h"#include "core/Multires.h"@@ -843,6 +845,22 @@ double Demo::query(const std::string& name, bool& known) const {for (int k = 0; k < 3; ++k) ++edges[{std::min(t[k], t[(k + 1) % 3]), std::max(t[k], t[(k + 1) % 3])}];return double(std::count_if(edges.begin(), edges.end(), [](const auto& e) { return e.second == 1; }));}+ if (name == "solid_volume") { // the active Part's volume with its open borders capped (as Voxel Remesh caps them)+ Mesh capped;+ capped.positions = m.positions;+ capped.triangles = m.triangles;+ CloseHolesOptions o;+ o.refine = false;+ o.newGroup = false;+ CloseHolesStats stats;+ std::string error;+ closeHoles(capped, o, stats, error);+ double v = 0.0;+ for (const glm::uvec3& t : capped.triangles)+ v += glm::dot(glm::dvec3(capped.positions[t.x]),+ glm::cross(glm::dvec3(capped.positions[t.y]), glm::dvec3(capped.positions[t.z])));+ return v / 6.0;+ }if (name == "visible_parts")return double(std::count_if(doc.parts.begin(), doc.parts.end(), [](const Part& s) { return s.visible; }));if (name == "edited_parts") { // Parts with undo history (the active one's lives in doc.undo)diff --git a/src/core/Voxel.cpp b/src/core/Voxel.cppindex 5e200d43..6ec67f06 100644--- a/src/core/Voxel.cpp+++ b/src/core/Voxel.cpp@@ -5,7 +5,9 @@#include <algorithm>#include <array>#include <cmath>+#include <numeric>+#include "core/CloseHoles.h"#include "core/ThreadPool.h"namespace sf {@@ -111,6 +113,66 @@ void blurAxis(std::vector<float>& f, const glm::ivec3& dims, int axis) {}// Closest point to `p` on triangle abc (Ericson, Real-Time Collision Detection 5.1.5).+// An edge with one triangle (undirected, so flipped triangles don't hide it).+bool hasOpenEdges(const Mesh& mesh) {+ std::vector<uint64_t> edges;+ edges.reserve(mesh.triangleCount() * 3);+ for (const glm::uvec3& t : mesh.triangles)+ for (int k = 0; k < 3; ++k) {+ const uint32_t a = t[k], b = t[(k + 1) % 3];+ edges.push_back(uint64_t(std::min(a, b)) << 32 | std::max(a, b));+ }+ std::sort(edges.begin(), edges.end());+ for (size_t i = 0; i < edges.size();) {+ size_t j = i + 1;+ while (j < edges.size() && edges[j] == edges[i]) ++j;+ if (j - i == 1) return true;+ i = j;+ }+ return false;+}++// Drops the pieces of a surface-nets mesh (quads as triangle pairs t, t + 1) with fewer than `maxTriangles`+// triangles, when a bigger one is left: single-voxel specks where a sign flips next to a cap.+void dropSpecks(Mesh& m, size_t maxTriangles) {+ std::vector<uint32_t> parent(m.vertexCount());+ std::iota(parent.begin(), parent.end(), 0u);+ auto find = [&](uint32_t a) {+ while (parent[a] != a) a = parent[a] = parent[parent[a]];+ return a;+ };+ for (const glm::uvec3& t : m.triangles) {+ parent[find(t.y)] = find(t.x);+ parent[find(t.z)] = find(t.x);+ }+ std::vector<uint32_t> size(m.vertexCount(), 0);+ for (const glm::uvec3& t : m.triangles) ++size[find(t.x)];+ if (std::count_if(size.begin(), size.end(), [&](uint32_t c) { return c >= maxTriangles; }) == 0) return;+ std::vector<glm::uvec3> kept;+ kept.reserve(m.triangles.size());+ for (const glm::uvec3& t : m.triangles)+ if (size[find(t.x)] >= maxTriangles) kept.push_back(t);+ if (kept.size() == m.triangles.size()) return;+ std::vector<uint32_t> remap(m.vertexCount(), ~0u);+ std::vector<glm::vec3> positions;+ for (glm::uvec3& t : kept)+ for (int k = 0; k < 3; ++k) {+ uint32_t& r = remap[t[k]];+ if (r == ~0u) {+ r = uint32_t(positions.size());+ positions.push_back(m.positions[t[k]]);+ }+ t[k] = r;+ }+ Mesh out;+ out.positions = std::move(positions);+ out.triangles = std::move(kept);+ for (uint32_t t = 0; t + 1 < out.triangles.size(); t += 2) out.pairQuad(t, t + 1); // (a piece drops whole quads)+ out.rebuildTopology();+ out.recomputeAllNormals();+ m = std::move(out);+}+glm::vec3 closestOnTriangle(const glm::vec3& p, const glm::vec3& a, const glm::vec3& b, const glm::vec3& c) {const glm::vec3 ab = b - a, ac = c - a, ap = p - a;const float d1 = glm::dot(ab, ap), d2 = glm::dot(ac, ap);@@ -505,8 +567,23 @@ std::vector<float> insideDistanceField(const Mesh& mesh, const VoxelGrid& grid,return f;}-Mesh voxelRemesh(const Mesh& mesh, int resolution, std::string* error, const std::function<bool(float)>& progress) {+Mesh voxelRemesh(const Mesh& source, int resolution, std::string* error, const std::function<bool(float)>& progress) {VoxelGrid grid;+ // An open Part (a starter head's neck, an extracted shell): the flood fill would pour in through the opening and+ // leave only a thin, holed shell. Its borders are capped first, on a copy of just the positions and triangles.+ Mesh capped;+ const bool open = hasOpenEdges(source);+ if (open) {+ capped.positions = source.positions;+ capped.triangles = source.triangles;+ CloseHolesOptions o;+ o.refine = false; // (the voxels smooth the cap; no new vertices to carry attributes to)+ o.newGroup = false;+ CloseHolesStats stats;+ std::string ignored;+ closeHoles(capped, o, stats, ignored);+ }+ const Mesh& mesh = open ? capped : source;if (mesh.triangleCount() == 0 || !makeVoxelGrid(mesh.bounds(), resolution, 4, grid)) {if (error) *error = mesh.triangleCount() == 0 ? "The mesh is empty" : "Resolution too high for this mesh";return {};@@ -521,18 +598,35 @@ Mesh voxelRemesh(const Mesh& mesh, int resolution, std::string* error, const stdstd::vector<uint8_t> solid = solidifyShell(grid, 0.5f, 1, true);std::vector<float>().swap(grid.values);if (!step(0.25f)) return {};+ if (open) {+ // Still open after capping (a border cut by non-manifold or flipped edges, a cap that folds): the outside+ // reached the inside and the solid is little more than the shell. Nothing is better than a surface full of holes.+ double volume = 0.0;+ for (const glm::uvec3& t : mesh.triangles)+ volume += glm::dot(glm::dvec3(mesh.positions[t.x]),+ glm::cross(glm::dvec3(mesh.positions[t.y]), glm::dvec3(mesh.positions[t.z])));+ const double cells = std::abs(volume) / 6.0 / (double(grid.cell) * grid.cell * grid.cell);+ const size_t inside = size_t(std::count(solid.begin(), solid.end(), uint8_t(1)));+ if (cells > 64.0 && double(inside) < 0.5 * cells) {+ if (error)+ *error = "Remesh: the Part has open borders that couldn't be capped, so it isn't a closed solid and the "+ "remesh would be full of holes; the Part is unchanged. Close it first (Tool > Geometry > Close Holes)";+ return {};+ }+ }// Mesh the signed distance to the original surface (positive inside), not the blocky occupancy: the result// lands on the original surface with no voxel terracing.const std::vector<float> field = insideDistanceField(mesh, grid, solid, 3.0f);std::vector<uint8_t>().swap(solid);if (!step(0.6f)) return {};Mesh out = meshFromField(grid, field, 0.0f, 2);+ if (open) dropSpecks(out, 64); // (a few voxels: never detail at a remesh resolution)if (out.triangleCount() == 0 && error) *error = "Remesh produced no surface";if (!step(0.9f)) return {};// Mask and vertex paint follow the nearest original vertex; face groups, hidden// flags and UVs don't survive a rebuild (everything becomes visible group 0).// The original's quads don't either: the new surface is all quads of its own.- transferVertexAttributes(mesh, out);+ transferVertexAttributes(source, out);step(1.0f);return out;}diff --git a/src/core/Voxel.h b/src/core/Voxel.hindex 3ff8cd41..ed3e4874 100644--- a/src/core/Voxel.h+++ b/src/core/Voxel.h@@ -55,7 +55,8 @@ std::vector<float> insideDistanceField(const Mesh& mesh, const VoxelGrid& grid,void rasterizeMeshShell(const Mesh& mesh, VoxelGrid& grid);// Rebuilds the mesh as an even, watertight surface (`resolution` cells across-// its longest side). Overlapping parts are merged. Sculpt layers are baked.+// its longest side). Overlapping parts are merged. Sculpt layers are baked. Open borders (a neck, a cut) are capped+// first; a mesh that still isn't solid gives an empty result and `error` says why (never a surface full of holes).// Mask and colours transfer from the nearest original vertex; face groups,// hidden flags and UVs reset (all visible, group 0, no UVs); the original's// quads are dropped and the result is all quads of its own. `progress` (0..1) returning false cancels (empty result).diff --git a/tests/test_quick_remesh.cpp b/tests/test_quick_remesh.cppindex 1b9ce36e..4daa279a 100644--- a/tests/test_quick_remesh.cpp+++ b/tests/test_quick_remesh.cpp@@ -3,9 +3,15 @@// Tool > Remesh > Remesh after each stroke (#121): which strokes stretched the surface enough to remesh.#include "TestHarness.h"+#include "core/CloseHoles.h"#include "core/Primitives.h"#include "core/QuickRemesh.h"+#include "core/StarterMeshes.h"+#include "core/Voxel.h"+#include <algorithm>+#include <chrono>+#include <cstdio>#include <vector>using namespace sf;@@ -22,6 +28,51 @@ template <class F> std::vector<glm::vec3> moveVertices(Mesh& mesh, const std::vereturn before;}+double meshVolume(const Mesh& m) {+ double v = 0.0;+ for (const glm::uvec3& t : m.triangles)+ v += glm::dot(glm::dvec3(m.positions[t.x]), glm::cross(glm::dvec3(m.positions[t.y]), glm::dvec3(m.positions[t.z])));+ return v / 6.0;+}++// Pieces of a mesh (connected by shared vertices).+size_t pieces(const Mesh& m) {+ std::vector<uint32_t> parent(m.vertexCount());+ for (uint32_t i = 0; i < parent.size(); ++i) parent[i] = i;+ auto find = [&](uint32_t a) {+ while (parent[a] != a) a = parent[a] = parent[parent[a]];+ return a;+ };+ for (const glm::uvec3& t : m.triangles) {+ parent[find(t.y)] = find(t.x);+ parent[find(t.z)] = find(t.x);+ }+ size_t n = 0;+ for (uint32_t i = 0; i < parent.size(); ++i) n += find(i) == i;+ return n;+}++// The Stylised Head starter's head (open at the neck), divided once.+Mesh stylisedHead() {+ Document d;+ std::string error;+ const StarterMesh* starter = findStarterMesh("stylised-head");+ CHECK(starter && loadStarterMesh(*starter, d, 1, error));+ int best = 0;+ for (int i = 0; i < d.partCount(); ++i)+ if (d.partMesh(i).triangleCount() > d.partMesh(best).triangleCount()) best = i;+ return d.partMesh(best);+}++// A Move pull: the vertices within `radius` of `at` follow `delta` with a smooth falloff.+void movePull(Mesh& m, glm::vec3 at, float radius, glm::vec3 delta) {+ for (glm::vec3& p : m.positions) {+ const float d = glm::distance(p, at) / radius;+ if (d < 1.0f) p += delta * (1.0f - d * d) * (1.0f - d * d);+ }+ m.recomputeAllNormals();+}+} // namespaceTEST(quick_remesh_no_stroke_no_stretch) {@@ -80,3 +131,70 @@ TEST(quick_remesh_vertices_out_of_range_are_skipped) {const std::vector<glm::vec3> before{glm::vec3(0.0f)};CHECK(strokeStretch(mesh, moved, before).edges == 0);}++// Launch clips (11-05): Quick Remesh and Voxel Remesh of the Stylised Head (open at the neck) after a Move pull near+// the neck gave a thin shell full of holes (the outside flooded in through the neck). Now the neck is capped first:+// one closed piece about as big as the head (it was 6-17 % of its volume in 3-17 pieces).+TEST(voxel_remesh_open_starter_head_stays_solid) {+ Mesh head = stylisedHead();+ CHECK(!boundaryLoops(head).empty()); // (open at the neck)+ const AABB box = head.bounds();+ const float size = glm::length(box.extent());+ // Near the neck: the lowest tenth, at the front; pulled forward and down.+ glm::vec3 neck(box.center().x, box.min.y + 0.1f * box.extent().y, box.max.z);+ float bestD = 1e30f;+ glm::vec3 at = neck;+ for (const glm::vec3& p : head.positions)+ if (const float d = glm::distance(p, neck); d < bestD) bestD = d, at = p;+ for (int pulled = 0; pulled < 2; ++pulled) {+ if (pulled) movePull(head, at, 0.15f * size, glm::vec3(0.0f, -0.05f, 0.12f) * size);+ Mesh closed = head;+ CloseHolesOptions o;+ o.refine = false;+ CloseHolesStats stats;+ std::string err;+ CHECK(closeHoles(closed, o, stats, err));+ const double expected = std::abs(meshVolume(closed));+ for (int res : {123, 64, 200}) {+ const auto t0 = std::chrono::steady_clock::now();+ Mesh r = voxelRemesh(head, res, &err);+ const double ms = std::chrono::duration<double, std::milli>(std::chrono::steady_clock::now() - t0).count();+ std::printf(" stylised head%s res %d: %zu triangles, volume %.3f of the capped head, %zu piece(s), %.0f ms\n",+ pulled ? " pulled" : "", res, r.triangleCount(), meshVolume(r) / expected, pieces(r), ms);+ CHECK(r.triangleCount() > 1000);+ CHECK(boundaryLoops(r).empty());+ CHECK(pieces(r) == 1);+ CHECK(std::abs(meshVolume(r) / expected - 1.0) < 0.1);+ }+ }+}++// A mesh that can't be made solid keeps the original: an empty result and a reason, never a holed shell. A sphere+// with its top cut off and a fin on one edge of the opening: that edge has two triangles, so the border is no loop+// Close Holes can cap, and the outside floods in.+TEST(voxel_remesh_uncappable_open_mesh_says_why) {+ Mesh bowl = makeIcosphere(4);+ std::vector<glm::uvec3> kept;+ for (const glm::uvec3& t : bowl.triangles)+ if ((bowl.positions[t.x].y + bowl.positions[t.y].y + bowl.positions[t.z].y) / 3.0f <= 0.6f) kept.push_back(t);+ bowl.triangles = kept;+ bowl.rebuildTopology();+ std::string err;+ Mesh r = voxelRemesh(bowl, 64, &err);+ CHECK(r.triangleCount() > 1000 && err.empty()); // (capped: solid)+ CHECK(boundaryLoops(r).empty() && pieces(r) == 1);+ CHECK(meshVolume(r) > 3.5); // (the unit sphere less a thin cap: 4.19 less about 0.44)++ const std::vector<std::vector<uint32_t>> loops = boundaryLoops(bowl);+ CHECK(loops.size() == 1);+ Mesh fin = bowl;+ const uint32_t a = loops[0][0], b = loops[0][1];+ fin.positions.push_back((fin.positions[a] + fin.positions[b]) * 0.5f + glm::vec3(0.0f, 0.3f, 0.0f));+ fin.triangles.push_back(glm::uvec3(a, b, uint32_t(fin.positions.size() - 1))); // (a -> b twice)+ fin.rebuildTopology();+ CHECK(boundaryLoops(fin).empty()); // (nothing Close Holes could cap)+ err.clear();+ CHECK(voxelRemesh(fin, 64, &err).triangleCount() == 0);+ CHECK(err.find("open borders") != std::string::npos);+ CHECK(err.find("unchanged") != std::string::npos);+}diff --git a/tests/ui/remesh_open_mesh.sfui b/tests/ui/remesh_open_mesh.sfuinew file mode 100644index 00000000..b3e7ccd4--- /dev/null+++ b/tests/ui/remesh_open_mesh.sfui@@ -0,0 +1,47 @@+# Voxel Remesh and Quick Remesh of an open Part (launch clips 11-05): the Stylised Head starter is open at the neck;+# after a Move pull near the neck both remeshes gave a thin shell full of holes. Now the neck is capped first: a+# closed head about as big as before, one undo step each.+run ui_look look=classic layout=classic+run new_starter_mesh name=stylised-head+key f+camera 0 0+click "Move##brush.move"+stroke 0.42 0.95 0.5 1.0+expect_value open_edges > 0+remember solid_volume v+remember triangles before+shot pulled+camera 0 70+shot pulled_below+camera 0 0++# Tool > Remesh > Voxel Remesh.+click "Remesh##tool.remesh"+click "Voxel Remesh##geometry.remesh"+wait_idle 120+expect_status Remeshed+expect_value open_edges == 0+expect_value solid_volume > $v*0.93+expect_value solid_volume < $v*1.07+shot voxel_remesh+camera 0 70+shot voxel_remesh_below+camera 0 0+key ctrl+z+expect_value triangles == $before++# Quick Remesh (Shift+R).+click "Quick Remesh##remesh.quick"+key shift+r+wait_idle 120+expect_status Quick Remesh: remeshed+expect_value open_edges == 0+expect_value solid_volume > $v*0.93+expect_value solid_volume < $v*1.07+shot quick_remesh+camera 0 70+shot quick_remesh_below+camera 0 0+key ctrl+z+expect_value triangles == $before+click "Quick Remesh##remesh.quick"diff --git a/tests/ui/uv_editor_scales.sfui b/tests/ui/uv_editor_scales.sfuinew file mode 100644index 00000000..26f7b971--- /dev/null+++ b/tests/ui/uv_editor_scales.sfui@@ -0,0 +1,71 @@+# UV Editor toolbar at UI scales 1.0, 1.5 and 2.4 (a 4K screen at 240 %; launch clips 11-05): the "On model: Colours /+# Checker" row and Frame wrap instead of being cut off or drawn over each other, and each control takes its own+# click (Frame used to land on Colours). CMake also runs it at 3840x2160 (ui_uv_editor_scales_4k).+run new_sphere subdivisions=3+run uv_seam op=angle angle=50++ui_scale 100+key alt+u+expect_value uv_editor_open == 1+expect_value uv_toolbar_overlap == 0+expect_value uv_toolbar_clipped == 0+expect_value uv_model_colors == 1+expect_value uv_model_checker == 1+remember uv_frames f+click "UV Editor/Colours##uvmodel"+expect_value uv_model_colors == 0+expect_value uv_model_checker == 1+click "UV Editor/Checker##uvchecker"+expect_value uv_model_checker == 0+expect_value uv_model_colors == 0+click "UV Editor/Frame"+expect_value uv_frames == $f+1+expect_value uv_model_colors == 0+expect_value uv_model_checker == 0+click "UV Editor/Colours##uvmodel"+click "UV Editor/Checker##uvchecker"+shot scale_100+key alt+u+expect_value uv_editor_open == 0++ui_scale 150+key alt+u+expect_value uv_editor_open == 1+expect_value uv_toolbar_overlap == 0+expect_value uv_toolbar_clipped == 0+remember uv_frames f+click "UV Editor/Colours##uvmodel"+expect_value uv_model_colors == 0+expect_value uv_model_checker == 1+click "UV Editor/Checker##uvchecker"+expect_value uv_model_checker == 0+click "UV Editor/Frame"+expect_value uv_frames == $f+1+expect_value uv_model_colors == 0+expect_value uv_model_checker == 0+click "UV Editor/Colours##uvmodel"+click "UV Editor/Checker##uvchecker"+shot scale_150+key alt+u++ui_scale 240+key alt+u+expect_value uv_editor_open == 1+expect_value uv_toolbar_overlap == 0+expect_value uv_toolbar_clipped == 0+remember uv_frames f+click "UV Editor/Colours##uvmodel"+expect_value uv_model_colors == 0+expect_value uv_model_checker == 1+click "UV Editor/Checker##uvchecker"+expect_value uv_model_checker == 0+click "UV Editor/Frame"+expect_value uv_frames == $f+1+expect_value uv_model_colors == 0+expect_value uv_model_checker == 0+click "UV Editor/Colours##uvmodel"+click "UV Editor/Checker##uvchecker"+expect_value uv_model_colors == 1+expect_value uv_model_checker == 1+shot scale_240+ui_scale 100