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
Make sculptable UI: Splats palette section, background job, crop box and face landmark review
islandmedaf011513cc46
diff --git a/CMakeLists.txt b/CMakeLists.txtindex b10c5ee5..44e185df 100644--- a/CMakeLists.txt+++ b/CMakeLists.txt@@ -194,6 +194,7 @@ if(SCULPTFORGE_BUILD_APP)src/app/Gizmo.cppsrc/app/PanelBake.cppsrc/app/PanelRetopo.cpp+ src/app/PanelSculptable.cppsrc/app/PanelPerformance.cppsrc/app/PanelGoz.cppsrc/app/PanelBlender.cppdiff --git a/src/app/App.cpp b/src/app/App.cppindex c9ee75b9..187424c1 100644--- a/src/app/App.cpp+++ b/src/app/App.cpp@@ -344,6 +344,7 @@ int App::runUiTest(int w, int h, int fps) {pollAutoUv();pollBake();pollQRemesh();+ pollSculptable();updateCameraAspect();Demo::beginFrame();@@ -501,6 +502,7 @@ int App::runRecording() {pollAutoUv();pollBake();pollQRemesh();+ pollSculptable();updateCameraAspect();Demo::beginFrame();@@ -568,6 +570,7 @@ int App::run() {pollAutoUv();pollBake();pollQRemesh();+ pollSculptable();int fbW = 0, fbH = 0, winW = 0, winH = 0;SDL_GetWindowSizeInPixels(window_, &fbW, &fbH);@@ -689,6 +692,7 @@ void App::onMouseDown(float x, float y, Uint8 button) {if (maskSelectMouseDown(x, y, mod)) return;if (gizmoMouseDown(x, y, mod)) return; // Gizmo 3D handles, pivot clicks (Gizmo.cpp)if (guideMouseDown(x, y, mod)) return; // the QRemesh Guides brush (PanelRetopo.cpp)+ if (sculptableMouseDown(x, y)) return; // Make sculptable: landmarks, crop box (PanelSculptable.cpp)// Alt+click on another SubTool selects it (ZBrush); Alt+drag stays an inverted stroke or a pan.// Shift+Alt+click selects and frames it (ZBrush), the active one too.const bool frameClick = (mod & SDL_KMOD_ALT) && (mod & SDL_KMOD_SHIFT) && !ctrlDown(mod);@@ -772,6 +776,7 @@ void App::onMouseMove(float x, float y, float dx, float dy, bool fromPen) {case Drag::Select: selectionMove(x, y); break;case Drag::Gizmo: gizmoDragTo(x, y); break;case Drag::Guide: guideDragTo(x, y); break;+ case Drag::Sculptable: sculptableMouseMove(x, y); break;case Drag::None: break;}}@@ -814,6 +819,7 @@ void App::onMouseUp() {if (drag_ == Drag::MaskCanvas) maskCanvasRelease();if (drag_ == Drag::SubToolClick) subtoolClickRelease();if (drag_ == Drag::Guide) guideRelease();+ if (drag_ == Drag::Sculptable) sculptableMouseUp();gizmoRelease();drag_ = Drag::None;dragFromPen_ = false;@@ -1062,6 +1068,7 @@ void App::runCommand(const std::string& name, const Args& args) {clearLods();playingLayer_ = -1;}+ if (r.ok && name == "splat_to_mesh") renderSettings_.showSplats = false; // the new SubTool shows; the splats stayif (r.ok && name == "save_obj" && !doc_.mesh.layers.empty())status_ += " (OBJ stores the current blend; export GLB to keep layers as blend shapes)";if (!r.ok) SDL_Log("%s failed: %s", name.c_str(), r.message.c_str());@@ -1306,8 +1313,9 @@ void App::drawUi() {const ImVec2 mouse(mouseX_, mouseY_);drawGizmo(); // Gizmo 3D handles and panel (Gizmo.cpp)drawQRemeshGuides(); // QRemesh Guides curves (PanelRetopo.cpp)+ drawSculptableOverlay(); // Make sculptable: crop box, face landmarks (PanelSculptable.cpp)// In Gizmo mode (and with the QRemesh Guides brush) the brush ring shows only while Ctrl masks or Shift smooths.- const bool ringOff = gizmoActive() || (guidesMode_ && !(inputMods() & SDL_KMOD_SHIFT));+ const bool ringOff = gizmoActive() || (guidesMode_ && !(inputMods() & SDL_KMOD_SHIFT)) || sculptableHot();if (((!ImGui::GetIO().WantCaptureMouse && canvasRect().contains(mouse.x, mouse.y)) || drag_ == Drag::Stroke) &&!hideBrushCursor_ && drag_ != Drag::Select && drag_ != Drag::Guide &&(!ringOff || drag_ == Drag::Stroke || ctrlDown(inputMods())))@@ -2190,6 +2198,11 @@ void App::drawPalette_Splats() {ImGui::TextWrapped("Open or drop a .ply capture (Polycam, Luma, Postshot, Scaniverse...) to sculpt against it.");ImGui::PopStyleColor();if (ImGui::Button("Sculpt to splats", ImVec2(-1, 0))) runCommand("mesh_to_splats");+ if (ImGui::Button("Try a test head##splats", ImVec2(-1, 0))) runCommand("splat_test_capture", {{"kind", std::string("head")}});+ ui::HelpText("Try a test head", nullptr,+ "Load a built-in test capture (a stylised head as Gaussian splats, with a few floaters) to try Make "+ "sculptable without a scan of your own. splat_test_capture kind=object loads a mug instead.",+ "Splats");return;}ImGui::Text("%zu splats (SH %d)", doc_.splats.size(), doc_.splats.shDegree);@@ -2207,16 +2220,11 @@ void App::drawPalette_Splats() {if (ImGui::Button("Fit", ImVec2(third, 0))) runCommand("splat_transform", {{"fit", true}});if (ImGui::IsItemHovered()) ImGui::SetTooltip("Centre and scale to the sculpt");if (ImGui::Button("Clean floaters", ImVec2(-1, 0))) runCommand("splat_clean", {{"min_opacity", 0.1}, {"keep", 0.97}});- if (ImGui::Button("Convert to mesh", ImVec2(ImGui::GetContentRegionAvail().x * 0.5f, 0)))- runCommand("splat_to_mesh", {{"resolution", double(splatMeshResolution_)}});- if (ImGui::IsItemHovered()) ImGui::SetTooltip("Build a watertight sculpting mesh from the capture (undoable)");- ImGui::SameLine();- ImGui::SetNextItemWidth(-1);- ImGui::SliderInt("##splatres", &splatMeshResolution_, 64, 400, "res %d");const float half = (ImGui::GetContentRegionAvail().x - ImGui::GetStyle().ItemSpacing.x) * 0.5f;if (ImGui::Button("Save splats...", ImVec2(half, 0))) saveFileDialog(FileAction::SaveSplats);ImGui::SameLine();if (ImGui::Button("Clear##splats", ImVec2(half, 0))) runCommand("splat_clear");+ drawSculptableSection(); // Make sculptable (PanelSculptable.cpp)}void App::drawBrushCursor() {diff --git a/src/app/App.h b/src/app/App.hindex b61b7661..817c76cd 100644--- a/src/app/App.h+++ b/src/app/App.h@@ -99,7 +99,7 @@ public:void queueFile(FileAction action, std::string path);private:- enum class Drag { None, Stroke, Orbit, Pan, Zoom, Roll, MaskCanvas, SubToolClick, Select, Gizmo, Guide };+ enum class Drag { None, Stroke, Orbit, Pan, Zoom, Roll, MaskCanvas, SubToolClick, Select, Gizmo, Guide, Sculptable };void handleEvent(const SDL_Event& e);void onMouseDown(float x, float y, Uint8 button);@@ -271,7 +271,6 @@ private:bool remeshGenerated_ = true;int voxelResolution_ = 200;bool keepTexture_ = true; // Keep Texture: remeshes carry a painted texture over (core/TextureTransfer.h)- int splatMeshResolution_ = 192;int remeshResolution_ = 256;std::future<ai::GeneratorResult> pendingGenerator_;std::shared_ptr<ai::GenerationProgress> generatorProgress_;@@ -477,6 +476,25 @@ private:int lastStrokeFrames = 0;bool gpuOutOfMemory = false;} perf_;+ // Splats > Make sculptable (PanelSculptable.cpp, core/Sculptable.h): splat capture -> sculptable SubTool on a+ // worker thread; the crop box and the face landmark review in the viewport.+ void registerSculptableUiActions();+ void drawSculptableSection();+ void startSculptable(int stage); // 0 all, 1 the scan for review, 2 finish the reviewed scan+ void pollSculptable();+ bool sculptableBusy() const;+ Args sculptableArgs(int stage) const;+ void setSculptableCrop(bool on);+ void runSculptableGuides(Args args); // face_guides, keeping the landmarks it reports+ void drawSculptableOverlay();+ bool sculptableMouseDown(float x, float y); // true if it took the click (a landmark, a crop handle)+ void sculptableMouseMove(float x, float y);+ void sculptableMouseUp();+ bool sculptableReviewActive() const;+ bool sculptableHot() const; // the cursor is on a landmark dot or crop handle (no brush ring), or placing landmarks+ bool sculptableLandmarkScreen(int i, ImVec2& out) const; // UI tests: where landmark i is drawn+ double sculptableTestValue(const std::string& name); // NaN for names it doesn't know+ std::shared_ptr<struct SculptableUiState> sculptable_;// Geometry > QRemesh (quad retopology on a worker thread) and SubTool > Project (ProjectAll); PanelRetopo.cpp.void registerRetopoUiActions();void drawQRemeshContents();diff --git a/src/app/Config.cpp b/src/app/Config.cppindex cfe48b64..223d57ef 100644--- a/src/app/Config.cpp+++ b/src/app/Config.cpp@@ -365,6 +365,7 @@ void App::initActions() {registerGizmoActions(); // Q W E R: Draw, and the Gizmo 3D's Move, Scale, Rotate (Gizmo.cpp)registerBakeUiActions(); // Tool > Bake (PanelBake.cpp)registerRetopoUiActions(); // Geometry > QRemesh, SubTool > ProjectAll (PanelRetopo.cpp)+ registerSculptableUiActions(); // Splats > Make sculptable (PanelSculptable.cpp)registerVdmActions(); // Brush > Vector Displacement (PanelVdm.cpp)registerPerformanceUiActions(); // Preferences > Performance (PanelPerformance.cpp)registerInputActions(); // ZBrush keys: U I O, Space, L, V, Ctrl+A / I / H / W..., the input style (Input.cpp)diff --git a/src/app/PanelSculptable.cpp b/src/app/PanelSculptable.cppnew file mode 100644index 00000000..b34d2e55--- /dev/null+++ b/src/app/PanelSculptable.cpp@@ -0,0 +1,642 @@+// SculptForge - open source digital sculpting+// SPDX-License-Identifier: GPL-3.0-or-later+//+// Splats > Make sculptable (core/Sculptable.h): one click from a Gaussian-splat capture to a clean, sculptable+// SubTool with the capture's colours. The options (Detail, polygon preset, Face loops, colour, crop box) sit in+// the Splats palette; the work runs on a worker thread with a progress bar and Cancel.+//+// With Review on, it stops after the scan: the face landmarks show as dots on the model with the guide loops+// QRemesh will follow. Drag a dot to move it (its mirror follows), or Place by hand when no face was found;+// Finish remeshes along the guides. The crop box is drawn in the viewport; drag its face handles. The console+// shows each run as splat_to_mesh / face_guides script lines.+#include "app/App.h"+#include "app/Demo.h"+#include "app/Ui.h"++#include "core/Sculptable.h"++#include <IconsLucide.h>++#include <algorithm>+#include <cmath>+#include <cstdio>+#include <thread>++namespace sf {++namespace {++constexpr const char* kPath = "Splats > Make sculptable";++const char* const kPresetLabels[3] = {"Game", "Film", "Sculpt"};+const SculptablePreset kPresets[3] = {SculptablePreset::Game, SculptablePreset::Film, SculptablePreset::SculptBase};++// What to click next when placing landmarks by hand (index order of FaceLandmarks::point).+const char* const kLandmarkPrompts[FaceLandmarks::kCount] = {+ "the outer corner of the eye on the left of the screen", "the inner corner of that eye",+ "the inner corner of the other eye", "its outer corner",+ "the tip of the nose", "the mouth corner on the left",+ "the other mouth corner", "the chin"};++std::string vecText(const glm::vec3& v) {+ char buf[96];+ std::snprintf(buf, sizeof buf, "%.4g %.4g %.4g", double(v.x), double(v.y), double(v.z));+ return buf;+}++// The nearest world axis when within ~40 degrees, so a roughly front view gives an exact front.+glm::vec3 snapAxis(const glm::vec3& v) {+ const glm::vec3 a = glm::abs(v);+ const int k = a.x >= a.y && a.x >= a.z ? 0 : a.y >= a.z ? 1 : 2;+ if (a[k] < 0.76f) return glm::normalize(v);+ glm::vec3 out(0.0f);+ out[k] = v[k] > 0.0f ? 1.0f : -1.0f;+ return out;+}++} // namespace++struct SculptableUiState {+ // Options (the Splats palette).+ int detail = 256;+ int preset = 0; // kPresets+ bool faceLoops = true;+ bool review = false;+ int color = 0; // 0 polypaint, 1 texture+ bool keepScan = true;+ bool crop = false;+ AABB box;+ float minOpacity = 0.2f;+ int close = 2;+ bool fillHoles = true;+ bool keepParts = false;++ // The running job.+ struct Job {+ int stage = 0; // 0 all, 1 scan, 2 finish+ std::future<bool> done;+ std::shared_ptr<std::atomic<float>> progress;+ std::shared_ptr<std::atomic<bool>> cancel;+ std::shared_ptr<SculptableResult> result;+ std::shared_ptr<std::string> error;+ Args args;+ uint32_t scanId = 0;+ size_t scanTriangles = 0;+ };+ std::unique_ptr<Job> job;++ // Review: the scan SubTool, its landmarks and the frame they were found in.+ bool reviewing = false;+ uint32_t scanId = 0;+ FaceLandmarks landmarks;+ FaceFrame frame;+ int placing = -1; // placing by hand: the landmark the next click sets (-1: not placing)+ int dragLandmark = -1;+ int dragHandle = -1; // crop box face handle: axis * 2 + (0 min, 1 max)+ ImVec2 dragStart{0, 0};+ AABB dragBox;+};++bool App::sculptableBusy() const { return sculptable_ && sculptable_->job; }++void App::registerSculptableUiActions() {+ if (!sculptable_) sculptable_ = std::make_shared<SculptableUiState>();+ auto add = [this](const char* id, const char* label, std::function<void()> run, std::function<bool()> enabled,+ std::function<bool()> checked, const char* description, const char* command) {+ Action a;+ a.id = id;+ a.label = label;+ a.palette = kPath;+ a.run = std::move(run);+ a.enabled = std::move(enabled);+ a.checked = std::move(checked);+ a.description = description;+ if (command) a.command = command;+ actions_.add(std::move(a));+ };+ add("splats.make_sculptable", "Make sculptable", [this] { startSculptable(sculptable_->review ? 1 : 0); },+ [this] { return !doc_.splats.empty() && !sculptableBusy(); }, nullptr,+ "Turn the capture into a clean, sculptable SubTool with its colours, in one go: a watertight surface (floaters "+ "dropped, holes filled), quad topology at the chosen polygon budget with edge loops round the eyes and mouth "+ "when it is a face, and polypaint or a texture. The splats stay (hidden). Runs in the background; Cancel stops it.",+ "splat_to_mesh");+ add("splats.sculptable_finish", "Finish", [this] { startSculptable(2); },+ [this] { return sculptable_->reviewing && !sculptableBusy(); }, nullptr,+ "QRemesh the scan along the face guides you checked, then colour it: the sculptable SubTool appears next to "+ "the scan (which is hidden).",+ nullptr);+ add("splats.sculptable_place", "Place by hand",+ [this] {+ sculptable_->placing = 0;+ status_ = std::string("Click ") + kLandmarkPrompts[0];+ },+ [this] { return sculptable_->reviewing && !sculptableBusy(); }, [this] { return sculptable_->placing >= 0; },+ "Place the face landmarks yourself, one click each: the eye corners, the nose tip, the mouth corners and the "+ "chin (the panel says which is next). For faces the automatic search misses.",+ nullptr);+ add("splats.sculptable_crop", "Crop Box", [this] { setSculptableCrop(!sculptable_->crop); },+ [this] { return !doc_.splats.empty(); }, [this] { return sculptable_->crop; },+ "Only the splats inside the box count: drag the box's face handles in the viewport to cut away the ground, "+ "the background or a stand.",+ nullptr);+}++void App::setSculptableCrop(bool on) {+ SculptableUiState& s = *sculptable_;+ s.crop = on && !doc_.splats.empty();+ if (s.crop && !s.box.valid()) {+ s.box = doc_.splats.bounds(0.98f);+ const glm::vec3 pad = s.box.extent() * 0.05f;+ s.box.min -= pad;+ s.box.max += pad;+ }+ status_ = s.crop ? "Crop Box: drag its face handles; only splats inside count" : "Crop Box off";+}++Args App::sculptableArgs(int stage) const {+ const SculptableUiState& s = *sculptable_;+ Args a{{"detail", double(s.detail)}, {"preset", std::string(sculptablePresetName(kPresets[s.preset]))}};+ if (!s.faceLoops) a["face_guides"] = std::string("off");+ else {+ // The face is looked for from the current view (snapped to the nearest axis view).+ const glm::vec3 front = snapAxis(-camera_.forward());+ glm::vec3 up = snapAxis(camera_.orientation() * glm::vec3(0, 1, 0));+ if (std::abs(glm::dot(front, up)) > 0.5f) up = std::abs(front.y) > 0.9f ? glm::vec3(0, 0, -1) : glm::vec3(0, 1, 0);+ if (front != glm::vec3(0, 0, 1)) a["front"] = vecText(front);+ if (up != glm::vec3(0, 1, 0)) a["up"] = vecText(up);+ }+ if (s.color == 1) a["color"] = std::string("texture");+ if (!s.keepScan) a["keep_scan"] = false;+ if (s.crop && s.box.valid()) a["crop"] = vecText(s.box.min) + " " + vecText(s.box.max);+ if (std::abs(s.minOpacity - 0.2f) > 1e-4f) a["min_opacity"] = double(s.minOpacity);+ if (s.close != 2) a["close"] = double(s.close);+ if (!s.fillHoles) a["fill_holes"] = false;+ if (s.keepParts) a["keep_parts"] = true;+ if (stage == 1) a["stage"] = std::string("scan");+ if (stage == 2) a["stage"] = std::string("finish");+ return a;+}++void App::startSculptable(int stage) {+ SculptableUiState& s = *sculptable_;+ if (s.job) return;+ if (doc_.sculptor.strokeActive()) endStroke();+ Args args = sculptableArgs(stage);+ if (stage == 2) { // the frame the face was found in, whatever the view is now+ args.erase("front");+ args.erase("up");+ if (s.frame.front != glm::vec3(0, 0, 1)) args["front"] = vecText(s.frame.front);+ if (s.frame.up != glm::vec3(0, 1, 0)) args["up"] = vecText(s.frame.up);+ }+ SculptableOptions o;+ std::string err;+ if (!sculptableOptionsFromArgs(args, o, err)) {+ status_ = err;+ return;+ }+ auto job = std::make_unique<SculptableUiState::Job>();+ job->stage = stage;+ job->progress = std::make_shared<std::atomic<float>>(0.0f);+ job->cancel = std::make_shared<std::atomic<bool>>(false);+ job->result = std::make_shared<SculptableResult>();+ job->error = std::make_shared<std::string>();+ if (stage == 2) {+ // Remesh the scan SubTool under review (its guides as they are now).+ int index = -1;+ for (int i = 0; i < doc_.subtoolCount(); ++i)+ if (doc_.subtools[size_t(i)].id == s.scanId) index = i;+ if (index < 0) {+ status_ = "The scan SubTool is gone; Make sculptable again";+ s.reviewing = false;+ return;+ }+ if (index != doc_.activeSubtool) doc_.selectSubtool(index);+ job->result->scan = doc_.mesh;+ job->result->guides = doc_.qremeshGuides;+ job->result->landmarks = s.landmarks;+ const AABB b = doc_.mesh.bounds();+ job->result->surface.cell = std::max({b.extent().x, b.extent().y, b.extent().z}) / float(std::max(o.surface.resolution, 32));+ job->scanId = s.scanId;+ job->scanTriangles = doc_.mesh.triangleCount();+ s.placing = -1;+ // The console line carries the landmarks, so the script repeats what was reviewed.+ if (s.landmarks.valid) args["landmarks"] = faceLandmarksJson(s.landmarks);+ } else if (doc_.splats.empty()) {+ status_ = "No splats loaded";+ return;+ }+ job->args = args;+ if (stage != 2) s.frame = o.frame;+ std::promise<bool> promise;+ job->done = promise.get_future();+ std::thread([promise = std::move(promise), cloud = std::make_shared<SplatCloud>(doc_.splats), o, stage,+ progress = job->progress, cancel = job->cancel, result = job->result, error = job->error]() mutable {+ auto report = [&](float a, float b) {+ return SculptableProgress([&, a, b](float f) {+ progress->store(a + (b - a) * f);+ return !cancel->load();+ });+ };+ bool ok = true;+ if (stage == 0) ok = makeSculptableScan(*cloud, o, *result, *error, report(0.0f, 0.45f)) &&+ finishSculptable(*cloud, o, *result, *error, report(0.45f, 1.0f));+ else if (stage == 1) ok = makeSculptableScan(*cloud, o, *result, *error, report(0.0f, 1.0f));+ else ok = finishSculptable(*cloud, o, *result, *error, report(0.0f, 1.0f));+ if (cancel->load()) {+ ok = false;+ *error = "Make sculptable cancelled";+ }+ promise.set_value(ok);+ }).detach();+ s.job = std::move(job);+ status_ = stage == 2 ? "Make sculptable: remeshing along the face guides..." : "Make sculptable: building the surface...";+}++void App::pollSculptable() {+ if (!sculptable_ || !sculptable_->job) return;+ SculptableUiState& s = *sculptable_;+ if (s.job->done.wait_for(std::chrono::seconds(0)) != std::future_status::ready) {+ status_ = "Make sculptable: " + std::to_string(int(s.job->progress->load() * 100.0f)) + "%";+ return;+ }+ const std::unique_ptr<SculptableUiState::Job> job = std::move(s.job);+ if (!job->done.get()) {+ status_ = *job->error;+ lastCommandOk_ = false;+ return;+ }+ if (doc_.sculptor.strokeActive()) endStroke();+ CommandResult r{true, {}};+ SculptableResult& res = *job->result;+ if (job->stage == 0) {+ r.message = applySculptable(doc_, res, s.keepScan);+ s.reviewing = false;+ } else if (job->stage == 1) {+ s.landmarks = res.landmarks;+ r.message = applySculptableScan(doc_, res);+ s.reviewing = true;+ s.scanId = doc_.activeSubtoolInfo().id;+ if (!s.landmarks.valid && s.faceLoops) {+ s.placing = 0;+ r.message += ". Place the landmarks by hand: click " + std::string(kLandmarkPrompts[0]);+ }+ } else {+ int index = -1;+ for (int i = 0; i < doc_.subtoolCount(); ++i)+ if (doc_.subtools[size_t(i)].id == job->scanId) index = i;+ if (index < 0 || doc_.subtoolMesh(index).triangleCount() != job->scanTriangles) {+ status_ = "Make sculptable skipped: the scan SubTool changed meanwhile";+ return;+ }+ r.message = applySculptableFinish(doc_, res, index, s.keepScan);+ s.reviewing = false;+ }+ renderSettings_.showSplats = false; // the splats stay, hidden (Splats > Show brings them back)+ status_ = r.message;+ lastCommandOk_ = true;+ clearLods();+ playingLayer_ = -1;+ if (!onScreen(doc_.mesh.bounds())) camera_.frame(sceneBounds());+ updateTitle();+ consoleEcho("splat_to_mesh", job->args, r);+}++void App::drawSculptableSection() {+ if (!sculptable_) sculptable_ = std::make_shared<SculptableUiState>();+ SculptableUiState& s = *sculptable_;+ const ImGuiStyle& style = ImGui::GetStyle();+ ImGui::SeparatorText("From scan");+ Demo::pushScope("Make sculptable"); // UI tests: "Make sculptable/<label>"+ struct PopScope {+ ~PopScope() { Demo::popScope(); }+ } popScope;+ const float full = ImGui::GetContentRegionAvail().x;+ const float half = (full - style.ItemSpacing.x) * 0.5f;+ const float third = (full - 2.0f * style.ItemSpacing.x) / 3.0f;++ if (s.job) {+ ImGui::ProgressBar(s.job->progress->load(), ImVec2(half, 0), s.job->stage == 2 ? "Remeshing..." : "Working...");+ ui::HelpText("Make sculptable", nullptr, "Working in the background; the new SubTool appears when it's done.", kPath);+ ImGui::SameLine();+ if (ImGui::Button("Cancel##sculptable", ImVec2(-1, 0))) s.job->cancel->store(true);+ ui::HelpText("Cancel", nullptr, "Stop Make sculptable; nothing changes.", kPath);+ } else if (s.reviewing) {+ ui::ActionButton(*this, "splats.sculptable_finish", ImVec2(half, 0));+ ImGui::SameLine();+ if (ImGui::Button("Back##sculptable", ImVec2(-1, 0))) {+ s.reviewing = false;+ s.placing = -1;+ status_ = "Review closed; the scan SubTool stays";+ }+ ui::HelpText("Back", nullptr, "Leave the review without remeshing (the scan SubTool stays as it is).", kPath);+ ImGui::PushStyleColor(ImGuiCol_Text, ImGui::GetStyleColorVec4(ImGuiCol_TextDisabled));+ if (s.placing >= 0) ImGui::TextWrapped("Click %s.", kLandmarkPrompts[s.placing]);+ else if (s.landmarks.valid) ImGui::TextWrapped("Drag the dots to move the landmarks (the other side follows). The lines are the loops QRemesh will follow.");+ else ImGui::TextWrapped("No face found: Place by hand, or Finish without face loops.");+ ImGui::PopStyleColor();+ ui::ActionButton(*this, "splats.sculptable_place", ImVec2(half, 0));+ ImGui::SameLine();+ if (ImGui::Button("Find again##sculptable", ImVec2(-1, 0))) {+ Args a{{"target", double(sculptablePresetQuads(kPresets[s.preset]))}};+ const Args view = sculptableArgs(0);+ for (const char* k : {"front", "up"})+ if (view.contains(k)) a[k] = view.at(k);+ runSculptableGuides(a);+ }+ ui::HelpText("Find again", nullptr, "Look for the face again from the current view (turn the view to face it first).", kPath);+ } else {+ ImGui::BeginDisabled(doc_.splats.empty());+ ui::ActionButton(*this, "splats.make_sculptable", ImVec2(-1, 0));+ ImGui::EndDisabled();+ }++ ImGui::BeginDisabled(s.job != nullptr || s.reviewing);+ ImGui::SetNextItemWidth(-1);+ ImGui::SliderInt("##sculptdetail", &s.detail, 96, 512, "Detail %d");+ ui::HelpText("Detail", nullptr,+ "How finely the surface follows the capture: voxels across the subject. Higher keeps thinner parts and "+ "more detail but takes longer (about 5 s at 384 for a million splats).",+ kPath);+ for (int i = 0; i < 3; ++i) {+ if (i) ImGui::SameLine();+ const bool on = s.preset == i;+ if (on) ImGui::PushStyleColor(ImGuiCol_Button, ImGui::GetStyleColorVec4(ImGuiCol_ButtonActive));+ if (ImGui::Button((std::string(kPresetLabels[i]) + "##sculptpreset").c_str(), ImVec2(i == 2 ? -1.0f : third, 0))) s.preset = i;+ if (on) ImGui::PopStyleColor();+ static const char* help[3] = {+ "Game: about 4,000 quads, light enough for real-time characters and props.",+ "Film: about 12,000 quads, for close-ups and smooth deformation.",+ "Sculpt: a 2,000-quad base with 2 subdivision levels, the scan's detail projected onto the top level, "+ "ready to sculpt with levels."};+ ui::HelpText(kPresetLabels[i], nullptr, help[i], kPath);+ }+ ImGui::Checkbox("Face loops", &s.faceLoops);+ ui::HelpText("Face loops", nullptr,+ "When the capture is a head, find the eyes, nose, mouth and chin as seen from the current view and "+ "give QRemesh edge loops round the eyes and mouth and along the nasolabial folds, mirrored across "+ "the face (animation topology). Turn the view to face it first.",+ kPath);+ ImGui::SameLine(half + style.ItemSpacing.x);+ ImGui::BeginDisabled(!s.faceLoops);+ ImGui::Checkbox("Review##sculptable", &s.review);+ ImGui::EndDisabled();+ ui::HelpText("Review", nullptr,+ "Stop after the scan to check the face landmarks and the loops: drag a dot to move it, or place them "+ "by hand, then Finish.",+ kPath);+ ImGui::RadioButton("Polypaint##sculptcolor", &s.color, 0);+ ui::HelpText("Polypaint", nullptr, "The capture's colours go into the vertices (polypaint): more polygons, more colour detail.", kPath);+ ImGui::SameLine(half + style.ItemSpacing.x);+ ImGui::RadioButton("Texture##sculptcolor", &s.color, 1);+ ui::HelpText("Texture", nullptr,+ "Auto UV the result and bake the capture's colours into a 2K texture (sharp colour on a light mesh, "+ "for games and exports).",+ kPath);+ ImGui::Checkbox("Keep scan", &s.keepScan);+ ui::HelpText("Keep scan", nullptr,+ "Keep the dense voxel surface as a hidden \"<name> Scan\" SubTool, to ProjectAll more detail from later.",+ kPath);+ ImGui::SameLine(half + style.ItemSpacing.x);+ ui::ActionButton(*this, "splats.sculptable_crop", ImVec2(-1, 0));+ if (ImGui::TreeNode("More##sculptable")) {+ ImGui::SetNextItemWidth(-1);+ ui::SliderInside("##sculptopacity", &s.minOpacity, 0.0f, 0.9f, "Min Opacity %.2f");+ ui::HelpText("Min Opacity", nullptr, "Splats fainter than this are ignored (haze and floaters are usually faint).", kPath);+ ImGui::SetNextItemWidth(-1);+ ImGui::SliderInt("##sculptclose", &s.close, 0, 8, "Close Gaps %d");+ ui::HelpText("Close Gaps", nullptr, "Seal gaps up to this many voxels between splats.", kPath);+ ImGui::Checkbox("Fill holes", &s.fillHoles);+ ui::HelpText("Fill holes", nullptr,+ "Fill big holes such as the open bottom of a subject standing on a table (space boxed in on five "+ "sides counts as inside). Turn off for open cavities like a cup.",+ kPath);+ ImGui::SameLine(half + style.ItemSpacing.x);+ ImGui::Checkbox("All pieces", &s.keepParts);+ ui::HelpText("All pieces", nullptr, "Keep every solid piece instead of only the largest (floaters come back too).", kPath);+ ImGui::TreePop();+ }+ ImGui::EndDisabled();+}++void App::runSculptableGuides(Args args) {+ runCommand("face_guides", args);+ const std::string& m = status_;+ const size_t at = m.find("landmarks {");+ if (lastCommandOk_ && at != std::string::npos) {+ std::string err;+ FaceLandmarks lm;+ if (faceLandmarksFromJson(m.substr(at + 10), lm, err)) sculptable_->landmarks = lm;+ }+ if (args.contains("front") || !args.contains("landmarks")) {+ FaceFrame f;+ glm::vec3 v;+ if (args.contains("front") && std::sscanf(std::get<std::string>(args.at("front")).c_str(), "%f %f %f", &v.x, &v.y, &v.z) == 3) f.front = v;+ if (args.contains("up") && std::sscanf(std::get<std::string>(args.at("up")).c_str(), "%f %f %f", &v.x, &v.y, &v.z) == 3) f.up = v;+ if (f.orthonormalize()) sculptable_->frame = f;+ }+}++namespace {++void boxCorners(const AABB& b, glm::vec3 out[8]) {+ for (int k = 0; k < 8; ++k) out[k] = glm::vec3(k & 1 ? b.max.x : b.min.x, k & 2 ? b.max.y : b.min.y, k & 4 ? b.max.z : b.min.z);+}++glm::vec3 faceCentre(const AABB& b, int handle) {+ glm::vec3 c = b.center();+ const int axis = handle / 2;+ c[axis] = handle % 2 ? b.max[axis] : b.min[axis];+ return c;+}++} // namespace++bool App::sculptableLandmarkScreen(int i, ImVec2& out) const {+ if (!sculptable_ || !sculptable_->reviewing || !sculptable_->landmarks.valid || i < 0 || i >= FaceLandmarks::kCount) return false;+ return gizmoProject(sculptable_->landmarks.point(i), out);+}++bool App::sculptableReviewActive() const {+ return sculptable_ && sculptable_->reviewing && doc_.activeSubtoolInfo().id == sculptable_->scanId;+}++bool App::sculptableHot() const {+ if (!sculptable_) return false;+ const SculptableUiState& s = *sculptable_;+ if (s.dragLandmark >= 0 || s.dragHandle >= 0 || (sculptableReviewActive() && s.placing >= 0)) return true;+ const float reach = 9.0f * uiScale_;+ ImVec2 q;+ if (sculptableReviewActive() && s.landmarks.valid)+ for (int i = 0; i < FaceLandmarks::kCount; ++i)+ if (gizmoProject(s.landmarks.point(i), q) && std::hypot(q.x - mouseX_, q.y - mouseY_) < reach) return true;+ if (s.crop && s.box.valid() && renderSettings_.showSplats && !doc_.splats.empty())+ for (int h = 0; h < 6; ++h)+ if (gizmoProject(faceCentre(s.box, h), q) && std::hypot(q.x - mouseX_, q.y - mouseY_) < reach) return true;+ return false;+}++void App::drawSculptableOverlay() {+ if (!sculptable_) return;+ SculptableUiState& s = *sculptable_;+ ImDrawList* dl = ImGui::GetBackgroundDrawList();+ const CanvasRect cr = canvasRect();+ dl->PushClipRect(ImVec2(cr.x, cr.y), ImVec2(cr.x + cr.w, cr.y + cr.h), true);+ const float u = uiScale_;+ if (s.crop && s.box.valid() && !doc_.splats.empty() && renderSettings_.showSplats) {+ glm::vec3 c[8];+ boxCorners(s.box, c);+ ImVec2 p[8];+ bool ok = true;+ for (int k = 0; k < 8; ++k) ok &= gizmoProject(c[k], p[k]);+ if (ok) {+ const ImU32 col = IM_COL32(255, 200, 80, 220);+ for (int k = 0; k < 8; ++k)+ for (int bit = 1; bit < 8; bit <<= 1)+ if (!(k & bit)) dl->AddLine(p[k], p[k | bit], col, 1.5f * u);+ for (int h = 0; h < 6; ++h) {+ ImVec2 q;+ if (!gizmoProject(faceCentre(s.box, h), q)) continue;+ const bool hot = s.dragHandle == h || (s.dragHandle < 0 && std::hypot(q.x - mouseX_, q.y - mouseY_) < 9.0f * u);+ dl->AddCircleFilled(q, (hot ? 7.0f : 5.5f) * u, hot ? IM_COL32(255, 240, 160, 255) : col);+ dl->AddCircle(q, (hot ? 7.0f : 5.5f) * u, IM_COL32(40, 30, 10, 255), 16, 1.0f * u);+ }+ }+ }+ if (sculptableReviewActive() && s.landmarks.valid) {+ for (int i = 0; i < FaceLandmarks::kCount; ++i) {+ ImVec2 q;+ if (!gizmoProject(s.landmarks.point(i), q)) continue;+ const bool hot = s.dragLandmark == i || (s.dragLandmark < 0 && std::hypot(q.x - mouseX_, q.y - mouseY_) < 9.0f * u);+ dl->AddCircleFilled(q, (hot ? 7.0f : 5.0f) * u, hot ? IM_COL32(255, 255, 255, 255) : IM_COL32(90, 220, 255, 255));+ dl->AddCircle(q, (hot ? 7.0f : 5.0f) * u, IM_COL32(10, 30, 40, 255), 16, 1.0f * u);+ }+ }+ if (sculptableReviewActive() && s.placing >= 0) {+ // The landmarks placed so far, and the prompt by the cursor.+ for (int i = 0; i < s.placing; ++i) {+ ImVec2 q;+ if (gizmoProject(s.landmarks.point(i), q)) dl->AddCircleFilled(q, 5.0f * u, IM_COL32(90, 220, 255, 255));+ }+ if (cr.contains(mouseX_, mouseY_))+ dl->AddText(ImVec2(mouseX_ + 14.0f * u, mouseY_ + 10.0f * u), IM_COL32(255, 255, 255, 230), kLandmarkPrompts[s.placing]);+ }+ dl->PopClipRect();+}++bool App::sculptableMouseDown(float x, float y) {+ if (!sculptable_ || sculptable_->job) return false;+ SculptableUiState& s = *sculptable_;+ const float reach = 9.0f * uiScale_;+ if (sculptableReviewActive() && s.placing >= 0) {+ RayHit hit;+ if (!pick(x, y, hit)) return false; // the background navigates+ s.landmarks.point(s.placing) = hit.position;+ if (++s.placing < FaceLandmarks::kCount) {+ status_ = std::string("Click ") + kLandmarkPrompts[s.placing];+ } else {+ s.placing = -1;+ s.landmarks.valid = true;+ runSculptableGuides({{"landmarks", faceLandmarksJson(s.landmarks)},+ {"target", double(sculptablePresetQuads(kPresets[s.preset]))}});+ }+ drag_ = Drag::Sculptable; // the click is taken+ return true;+ }+ if (sculptableReviewActive() && s.landmarks.valid)+ for (int i = 0; i < FaceLandmarks::kCount; ++i) {+ ImVec2 q;+ if (gizmoProject(s.landmarks.point(i), q) && std::hypot(q.x - x, q.y - y) < reach) {+ s.dragLandmark = i;+ drag_ = Drag::Sculptable;+ return true;+ }+ }+ if (s.crop && s.box.valid() && renderSettings_.showSplats && !doc_.splats.empty())+ for (int h = 0; h < 6; ++h) {+ ImVec2 q;+ if (gizmoProject(faceCentre(s.box, h), q) && std::hypot(q.x - x, q.y - y) < reach) {+ s.dragHandle = h;+ s.dragStart = ImVec2(x, y);+ s.dragBox = s.box;+ drag_ = Drag::Sculptable;+ return true;+ }+ }+ return false;+}++void App::sculptableMouseMove(float x, float y) {+ SculptableUiState& s = *sculptable_;+ if (s.dragLandmark >= 0) {+ RayHit hit;+ if (pick(x, y, hit)) s.landmarks.point(s.dragLandmark) = hit.position;+ return;+ }+ if (s.dragHandle >= 0) {+ // Move the face along its axis by the drag's length along the axis as seen on screen.+ const int axis = s.dragHandle / 2;+ const glm::vec3 p0 = faceCentre(s.dragBox, s.dragHandle);+ const float len = 0.1f * glm::length(s.dragBox.extent());+ glm::vec3 p1 = p0;+ p1[axis] += len;+ ImVec2 a, b;+ if (!gizmoProject(p0, a) || !gizmoProject(p1, b)) return;+ const glm::vec2 d(b.x - a.x, b.y - a.y);+ const float d2 = glm::dot(d, d);+ if (d2 < 1.0f) return; // the axis points at the viewer: drag another handle+ const float t = glm::dot(glm::vec2(x - s.dragStart.x, y - s.dragStart.y), d) / d2 * len;+ AABB box = s.dragBox;+ const float minSize = 0.02f * glm::length(s.dragBox.extent());+ if (s.dragHandle % 2) box.max[axis] = std::max(s.dragBox.max[axis] + t, box.min[axis] + minSize);+ else box.min[axis] = std::min(s.dragBox.min[axis] + t, box.max[axis] - minSize);+ s.box = box;+ }+}++void App::sculptableMouseUp() {+ SculptableUiState& s = *sculptable_;+ if (s.dragLandmark >= 0) {+ // The partner on the other side follows (mirrored across the face's middle), then the guides are rebuilt.+ const int i = s.dragLandmark;+ s.dragLandmark = -1;+ static const int partner[FaceLandmarks::kCount] = {3, 2, 1, 0, -1, 6, 5, -1};+ FaceFrame f = s.frame;+ if (partner[i] >= 0 && f.orthonormalize()) {+ const glm::vec3 r = f.right();+ const float mid = 0.5f * (glm::dot(s.landmarks.noseTip, r) + glm::dot(s.landmarks.chin, r));+ const glm::vec3 p = s.landmarks.point(i);+ s.landmarks.point(partner[i]) = p - 2.0f * (glm::dot(p, r) - mid) * r;+ }+ Args a{{"landmarks", faceLandmarksJson(s.landmarks)}, {"target", double(sculptablePresetQuads(kPresets[s.preset]))}};+ if (f.front != glm::vec3(0, 0, 1)) a["front"] = vecText(f.front);+ if (f.up != glm::vec3(0, 1, 0)) a["up"] = vecText(f.up);+ runSculptableGuides(a);+ }+ if (s.dragHandle >= 0) {+ s.dragHandle = -1;+ char buf[160];+ std::snprintf(buf, sizeof buf, "Crop Box %.3g x %.3g x %.3g", double(s.box.extent().x), double(s.box.extent().y),+ double(s.box.extent().z));+ status_ = buf;+ }+}++double App::sculptableTestValue(const std::string& name) {+ if (!sculptable_) sculptable_ = std::make_shared<SculptableUiState>();+ const SculptableUiState& s = *sculptable_;+ if (name == "sculptable_running") return s.job ? 1.0 : 0.0;+ if (name == "sculptable_review") return s.reviewing ? 1.0 : 0.0;+ if (name == "sculptable_landmarks") return s.landmarks.valid ? double(FaceLandmarks::kCount) : s.placing >= 0 ? double(s.placing) : 0.0;+ if (name == "sculptable_placing") return double(s.placing);+ if (name == "sculptable_crop") return s.crop ? 1.0 : 0.0;+ if (name == "sculptable_crop_height") return s.crop && s.box.valid() ? double(s.box.extent().y) : 0.0;+ if (name == "show_splats") return renderSettings_.showSplats ? 1.0 : 0.0;+ if (name.rfind("landmark_", 0) == 0 && name.size() > 11) { // landmark_x_4 / landmark_y_4 / landmark_z_4: mesh space+ const int axis = name.size() > 9 ? name[9] - 'x' : -1;+ const int i = std::atoi(name.c_str() + std::min<size_t>(name.size(), 11));+ if (axis >= 0 && axis < 3 && i >= 0 && i < FaceLandmarks::kCount) return double(s.landmarks.point(i)[axis]);+ }+ return std::nan("");+}++} // namespace sfdiff --git a/src/app/UiTest.cpp b/src/app/UiTest.cppindex d559a97d..f755ef0c 100644--- a/src/app/UiTest.cpp+++ b/src/app/UiTest.cpp@@ -24,6 +24,7 @@// move_view rotate_x rotate_y rotate_z rotate_view scale_x scale_y scale_z scale_uniform;// keep: leave the button down (a shot mid-drag), then `release`// gizmo_hover HANDLE move the mouse onto a Gizmo 3D handle (it lights up, for screenshots)+// drag_landmark N DX DY [S] left-drag Make sculptable's face landmark N (0-7, FaceLandmarks order) by DX DY pixels// orbit DX DY right-drag on the background, in pixels (with the held modifiers)// camera YAW PITCH set the view's angles in degrees (0 0 = the front view), e.g. for guide screenshots// run COMMANDS sculptforge-cli commands, e.g. run new_sphere subdivisions=4@@ -84,6 +85,9 @@// center_x / center_y / center_z and size_x / size_y / size_z (active mesh bounds)// bake_running, baked_maps (maps in the last bake), bake_size, bake_files (files it wrote),// normal_map_preview (1 when the active SubTool shows its baked normal map)+// sculptable_running, sculptable_review, sculptable_landmarks (8 when placed),+// sculptable_placing (next landmark to click, -1), sculptable_crop, sculptable_crop_height,+// show_splats, landmark_x_N / landmark_y_N / landmark_z_N (face landmark N, mesh space)// (mesh values are the active SubTool's)// snapshot remember the active mesh's vertices (for the moved* values)// remember VALUE NAME keep VALUE's current value as $NAME@@ -260,6 +264,7 @@ double Demo::query(const std::string& name, bool& known) const {if (name == "active_texture_layer") return hasTexture(m) && !m.texture->layers.empty() ? double(m.texture->activeLayer) : -1.0;if (name == "auto_uv_running") return app_.autoUv_ ? 1.0 : 0.0;if (const double v = app_.bakeTestValue(name); !std::isnan(v)) return v;+ if (const double v = app_.sculptableTestValue(name); !std::isnan(v)) return v;if (name == "qremesh_running") return app_.qremesh_ ? 1.0 : 0.0;if (name == "qremesh_guides") return double(app_.doc_.qremeshGuides.size());if (name == "qremesh_guide_loops") {@@ -524,7 +529,21 @@ bool Demo::parseStep(int line, const std::vector<std::string>& w, std::string& econst std::string label = w[1];steps_.push_back([this, line, label](float t) {ImVec2 to;- if (findItem(label, to)) {+ bool visible = false;+ ImVec4 clip;+ if (findItem(label, to, &visible, &clip)) {+ // Scrolled out of its panel: wheel the panel towards it first (as click does).+ if (!visible && clip.z > clip.x && clip.w > clip.y && t <= 2.0f) {+ mouseMotion((clip.x + clip.z) * 0.5f, (clip.y + clip.w) * 0.5f);+ SDL_Event e{};+ e.type = SDL_EVENT_MOUSE_WHEEL;+ e.wheel.windowID = SDL_GetWindowID(app_.window_);+ e.wheel.y = to.y > clip.w ? -1.0f : 1.0f;+ e.wheel.mouse_x = mouse_.x;+ e.wheel.mouse_y = mouse_.y;+ app_.handleEvent(e);+ return false;+ }mouseMotion(to.x, to.y);return true;}@@ -646,6 +665,30 @@ bool Demo::parseStep(int line, const std::vector<std::string>& w, std::string& ereturn false;});wait(0.1f);+ } else if (verb == "drag_landmark") {+ if (!need(3)) return false;+ const int index = int(num(1, 0));+ const float dx = num(2, 0), dy = num(3, 0), seconds = num(4, 0.4f);+ auto start = std::make_shared<ImVec2>();+ steps_.push_back([this, line, index, dx, dy, seconds, start](float t) {+ if (t == 0.0f) {+ if (!app_.sculptableLandmarkScreen(index, *start)) {+ fail(line, "face landmark " + std::to_string(index) + " is not shown (Make sculptable's review)");+ return true;+ }+ mouseMotion(start->x, start->y);+ return false;+ }+ if (!buttonDown_ && t < seconds) mouseButton(true, SDL_BUTTON_LEFT);+ const float u = std::min(t / seconds, 1.0f);+ mouseMotion(start->x + dx * u, start->y + dy * u);+ if (t >= seconds) {+ mouseButton(false, SDL_BUTTON_LEFT);+ return true;+ }+ return false;+ });+ wait(0.1f);} else if (verb == "gizmo_drag" || verb == "gizmo_hover") {static const char* kHandles[] = {"move_x", "move_y", "move_z", "plane_yz", "plane_xz","plane_xy", "move_view", "rotate_x", "rotate_y", "rotate_z",@@ -838,7 +881,8 @@ bool Demo::parseStep(int line, const std::vector<std::string>& w, std::string& econst bool idle = !busy(app_.pendingBrush_) && !busy(app_.pendingGenerator_) && !busy(app_.pendingModels_) &&!busy(app_.pendingUnreal_) && !busy(app_.pendingComfyCheck_) && !app_.galleryBusy() &&!app_.thumbs_.busy() && !app_.libraryScanner_.busy() && !app_.autoUv_ &&- !app_.bakeBusy() && !app_.qremesh_ && !app_.voxelRemesh_ && !app_.updateJob_;+ !app_.bakeBusy() && !app_.qremesh_ && !app_.voxelRemesh_ && !app_.updateJob_ &&+ !app_.sculptableBusy();*idleFrames = idle ? *idleFrames + 1 : 0;if (*idleFrames >= 4) return true;if (idle) return false;diff --git a/src/core/Sculptable.cpp b/src/core/Sculptable.cppindex 2d1850f0..3a6a77bf 100644--- a/src/core/Sculptable.cpp+++ b/src/core/Sculptable.cpp@@ -197,6 +197,57 @@ size_t fixAmbiguousCubes(std::vector<float>& f, const ivec3& dims, float iso) {return fixed;}+// Keeps only the largest 6-connected piece of the set cells. Returns how many pieces there were; `removed` gets+// the number of cells dropped. `scratch` is a same-sized work array.+int keepLargestPiece(std::vector<uint8_t>& cells, const ivec3& dims, std::vector<uint8_t>& scratch, size_t& removed) {+ const size_t n = cells.size();+ scratch.assign(n, 0);+ std::vector<uint32_t> stack;+ size_t bestCount = 0, total = 0;+ uint32_t bestSeed = 0;+ int pieces = 0;+ const int64_t sy = dims.x, sz = int64_t(dims.x) * dims.y;+ for (size_t seed = 0; seed < n; ++seed) {+ if (!cells[seed] || scratch[seed]) continue;+ scratch[seed] = 1;+ stack.assign(1, uint32_t(seed));+ size_t count = 0;+ while (!stack.empty()) {+ const uint32_t i = stack.back();+ stack.pop_back();+ ++count;+ const int x = int(i % uint32_t(dims.x));+ const int y = int((i / uint32_t(dims.x)) % uint32_t(dims.y));+ const int z = int(i / uint32_t(sz));+ const int64_t offsets[6] = {-1, 1, -sy, sy, -sz, sz};+ const bool valid[6] = {x > 0, x + 1 < dims.x, y > 0, y + 1 < dims.y, z > 0, z + 1 < dims.z};+ for (int k = 0; k < 6; ++k) {+ if (!valid[k]) continue;+ const uint32_t j = uint32_t(int64_t(i) + offsets[k]);+ if (cells[j] && !scratch[j]) {+ scratch[j] = 1;+ stack.push_back(j);+ }+ }+ }+ ++pieces;+ total += count;+ if (count > bestCount) {+ bestCount = count;+ bestSeed = uint32_t(seed);+ }+ }+ removed = total - bestCount;+ if (pieces > 1) {+ std::fill(scratch.begin(), scratch.end(), 0);+ scratch[bestSeed] = 1;+ stack.assign(1, bestSeed);+ flood(cells, dims, stack, scratch);+ cells.swap(scratch);+ }+ return pieces;+}+struct SplatKernel {vec3 p{0.0f};float alpha = 0.0f;@@ -274,7 +325,19 @@ bool splatSurface(const SplatCloud& cloud, const SplatSurfaceOptions& o, Mesh& oif (candidates.empty())return fail(st.cropped ? "No splats inside the crop box" : "No splats are opaque enough - lower the minimum opacity");+ // The percentile box only finds the far outliers: everything within a quarter of its size around it counts+ // (a nose tip or a raised hand is an extreme along its axis, not an outlier).AABB box = trimmedBounds(candidatePos, std::clamp(o.keepFraction, 0.5f, 1.0f));+ {+ const vec3 reach = 0.25f * box.extent();+ AABB wide = box;+ wide.min -= reach;+ wide.max += reach;+ AABB fit;+ for (const vec3& p : candidatePos)+ if (inside(wide, p)) fit.expand(p);+ if (fit.valid()) box = fit;+ }const float boxSize = std::max({box.extent().x, box.extent().y, box.extent().z});if (!(boxSize > 0.0f)) return fail("The splats have no extent");box.min -= box.extent() * 0.02f + vec3(1e-6f);@@ -386,6 +449,13 @@ bool splatSurface(const SplatCloud& cloud, const SplatSurfaceOptions& o, Mesh& omorph(wall, dims, closeRadius, true);if (!tick(progress, 0.62f)) return fail("Cancelled");+ // Floaters go first: shell pieces apart from the subject would box in the empty space around it.+ if (!o.keepAllParts) {+ std::vector<uint8_t> scratch;+ size_t removed = 0;+ st.pieces = keepLargestPiece(wall, dims, scratch, removed);+ st.floaterVoxels = removed;+ }std::vector<uint8_t> block = wall;if (o.fillHoles) {// Count the axis directions in which each empty cell sees the shell; 5 or 6 of 6 = enclosed.@@ -439,55 +509,15 @@ bool splatSurface(const SplatCloud& cloud, const SplatSurfaceOptions& o, Mesh& omorph(solid, dims, closeRadius, false);if (!tick(progress, 0.72f)) return fail("Cancelled");- // Pieces: count each, keep the largest (unless keepAllParts).- std::vector<uint8_t>& visited = outside; // reuse- std::fill(visited.begin(), visited.end(), 0);- size_t bestCount = 0, total = 0;- uint32_t bestSeed = 0;- for (size_t seed = 0; seed < n; ++seed) {- if (!solid[seed] || visited[seed]) continue;- visited[seed] = 1;- stack.assign(1, uint32_t(seed));- // Count while flooding.- size_t count = 0;- const int64_t sy = dims.x, sz = int64_t(dims.x) * dims.y;- while (!stack.empty()) {- const uint32_t i = stack.back();- stack.pop_back();- ++count;- const int x = int(i % uint32_t(dims.x));- const int y = int((i / uint32_t(dims.x)) % uint32_t(dims.y));- const int z = int(i / uint32_t(sz));- const int64_t offsets[6] = {-1, 1, -sy, sy, -sz, sz};- const bool valid[6] = {x > 0, x + 1 < dims.x, y > 0, y + 1 < dims.y, z > 0, z + 1 < dims.z};- for (int k = 0; k < 6; ++k) {- if (!valid[k]) continue;- const uint32_t j = uint32_t(int64_t(i) + offsets[k]);- if (solid[j] && !visited[j]) {- visited[j] = 1;- stack.push_back(j);- }- }- }- ++st.pieces;- total += count;- if (count > bestCount) {- bestCount = count;- bestSeed = uint32_t(seed);- }- }- if (bestCount == 0) return fail("No closed surface was found - try more Detail, a lower opacity or a bigger crop box");- if (!o.keepAllParts && st.pieces > 1) {- std::fill(visited.begin(), visited.end(), 0);- visited[bestSeed] = 1;- stack.assign(1, bestSeed);- flood(solid, dims, stack, visited);- solid.swap(visited);- st.floaterVoxels = total - bestCount;- st.solidVoxels = bestCount;- } else {- st.solidVoxels = total;+ // Pieces: keep the largest (unless keepAllParts).+ std::vector<uint8_t>& visited = outside; // reuse as scratch+ if (!o.keepAllParts) {+ size_t removed = 0;+ st.pieces = std::max(st.pieces, keepLargestPiece(solid, dims, visited, removed));+ st.floaterVoxels += removed;}+ st.solidVoxels = size_t(std::count(solid.begin(), solid.end(), uint8_t(1)));+ if (st.solidVoxels == 0) return fail("No closed surface was found - try more Detail, a lower opacity or a bigger crop box");st.solidSeconds = secondsSince(t1);if (!tick(progress, 0.78f)) return fail("Cancelled");@@ -526,6 +556,19 @@ SplatColorSampler::SplatColorSampler(const SplatCloud& cloud, float radius, floab.expand(p);}if (pos.empty()) return;+ // At least about two splats across: with fine Detail the voxels get smaller than the splats, and a radius+ // of a voxel or two would average too few of them (mottled colour).+ {+ std::vector<float> sizes;+ const float s = cloud.transformScale();+ const size_t step = std::max<size_t>(1, cloud.size() / 20000);+ for (size_t i = 0; i < cloud.size(); i += step)+ if (cloud.opacities[i] >= minOpacity) sizes.push_back(std::max({cloud.scales[i].x, cloud.scales[i].y, cloud.scales[i].z}) * s);+ if (!sizes.empty()) {+ std::nth_element(sizes.begin(), sizes.begin() + std::ptrdiff_t(sizes.size() / 2), sizes.end());+ radius_ = std::max(radius_, 2.5f * sizes[sizes.size() / 2]);+ }+ }cell_ = radius_;const vec3 ext = b.extent() + vec3(1e-6f);// At most ~32M cells.@@ -601,18 +644,43 @@ size_t colorFromSplats(Mesh& mesh, const SplatColorSampler& sampler) {const size_t nv = mesh.vertexCount();if (mesh.normals.size() != nv) mesh.recomputeAllNormals();std::vector<glm::vec3>& colors = mesh.ensureColors();- std::atomic<size_t> missed{0};+ std::vector<uint8_t> found(nv, 0);parallelFor(nv, [&](size_t b, size_t e) {- size_t m = 0;for (size_t v = b; v < e; ++v) {- bool found = false;- colors[v] = sampler.sample(mesh.positions[v], mesh.normals[v], &found);- m += found ? 0 : 1;+ bool ok = false;+ colors[v] = sampler.sample(mesh.positions[v], mesh.normals[v], &ok);+ found[v] = ok ? 1 : 0;}- missed += m;}, 2048);+ const size_t missed = size_t(std::count(found.begin(), found.end(), uint8_t(0)));+ // Vertices with no splat near (a hole in the capture) take their coloured neighbours' mean, spreading inwards.+ for (int pass = 0; pass < 64 && missed > 0; ++pass) {+ std::vector<glm::vec3> sum(nv, glm::vec3(0.0f));+ std::vector<uint32_t> count(nv, 0);+ for (const glm::uvec3& t : mesh.triangles)+ for (int k = 0; k < 3; ++k) {+ const uint32_t a = t[k];+ if (found[a]) continue;+ for (int j = 1; j < 3; ++j) {+ const uint32_t b = t[(k + j) % 3];+ if (found[b] == 1) {+ sum[a] += colors[b];+ ++count[a];+ }+ }+ }+ bool any = false;+ for (size_t v = 0; v < nv; ++v)+ if (!found[v] && count[v]) {+ colors[v] = sum[v] / float(count[v]);+ found[v] = 2; // coloured this pass: a source from the next pass on+ any = true;+ }+ for (uint8_t& f : found) f = f ? 1 : 0;+ if (!any) break;+ }mesh.markAllDirty();- return missed.load();+ return missed;}void textureFromSplats(Mesh& mesh, const SplatColorSampler& sampler, int size) {@@ -1213,7 +1281,7 @@ std::string SculptableResult::report() const {} else if (!faceNote.empty()) {s += " (" + faceNote + ")";}- if (uncolored > 0) s += ", " + std::to_string(uncolored) + " vertices had no colour nearby";+ if (uncolored > 0) s += ", " + std::to_string(uncolored) + " vertices with no splats near took their neighbours' colour";return s;}@@ -1337,11 +1405,21 @@ bool finishSculptable(const SplatCloud& cloud, const SculptableOptions& o, Sculpreturn tick(progress, 1.0f) || (error = "Cancelled", false);}-std::string applySculptable(Document& doc, SculptableResult& res, bool keepScan) {- const std::string base = doc.splats.name.empty() ? std::string("Scan") : doc.splats.name;- // An untouched starting sphere makes way (hidden, not deleted).+namespace {++// An untouched starting sphere makes way for the scan (hidden, not deleted).+void hideStartingSphere(Document& doc) {if (doc.subtoolCount() == 1 && !doc.undo.canUndo() && doc.mesh.layers.empty() && !doc.mesh.hasColors())doc.activeSubtoolInfo().visible = false;+}++std::string captureName(const Document& doc) { return doc.splats.name.empty() ? std::string("Scan") : doc.splats.name; }++} // namespace++std::string applySculptable(Document& doc, SculptableResult& res, bool keepScan) {+ const std::string base = captureName(doc);+ hideStartingSphere(doc);if (keepScan) {const int s = doc.addSubtool(std::move(res.scan), doc.uniqueSubtoolName(base + " Scan"), false);doc.subtools[size_t(s)].visible = false;@@ -1354,6 +1432,55 @@ std::string applySculptable(Document& doc, SculptableResult& res, bool keepScan)return report;}+std::string applySculptableScan(Document& doc, SculptableResult& res) {+ hideStartingSphere(doc);+ const size_t splats = res.surface.used;+ doc.addSubtool(std::move(res.scan), doc.uniqueSubtoolName(captureName(doc) + " Scan"), true);+ doc.qremeshGuides = res.guides;+ doc.modified = true;+ char buf[160];+ std::snprintf(buf, sizeof buf, "Scan: %zu triangles from %zu splats in %.1f s", doc.mesh.triangleCount(), splats, res.seconds);+ std::string msg = buf;+ if (res.landmarks.valid) {+ size_t loops = 0;+ for (const QRemeshGuide& g : res.guides) loops += g.closed;+ msg += "; face guides: " + std::to_string(loops) + " loops; landmarks " + faceLandmarksJson(res.landmarks);+ } else if (!res.faceNote.empty()) {+ msg += " (" + res.faceNote + ")";+ }+ return msg;+}++std::string applySculptableFinish(Document& doc, SculptableResult& res, int scanIndex, bool keepScan) {+ if (scanIndex < 0 || scanIndex >= doc.subtoolCount()) scanIndex = doc.activeSubtool;+ // "Head Scan" -> "Head", "Head Scan 2" -> "Head 2"; another name gets " Quads".+ const std::string name = doc.subtools[size_t(scanIndex)].name;+ std::string base = name + " Quads";+ if (const size_t at = name.rfind(" Scan"); at != std::string::npos && at > 0) {+ const std::string rest = name.substr(at + 5);+ if (rest.empty() || (rest.size() > 1 && rest[0] == ' ' && rest.find_first_not_of("0123456789", 1) == std::string::npos))+ base = name.substr(0, at) + rest;+ }+ const size_t faces = res.mesh.triangleCount() - res.mesh.quadCount();+ const int levels = subdivLevelCount(res.mesh);+ const uint32_t scanId = doc.subtools[size_t(scanIndex)].id;+ doc.addSubtool(std::move(res.mesh), doc.uniqueSubtoolName(base), true, scanIndex + 1);+ doc.qremeshGuides = res.guides;+ for (int i = 0; i < doc.subtoolCount(); ++i) {+ if (doc.subtools[size_t(i)].id != scanId) continue;+ if (keepScan) doc.subtools[size_t(i)].visible = false;+ else doc.removeSubtool(i);+ break;+ }+ doc.modified = true;+ char buf[200];+ std::snprintf(buf, sizeof buf, "Made sculptable: %zu polygons%s in %.1f s", faces,+ levels > 1 ? (", " + std::to_string(levels) + " levels").c_str() : "", res.seconds);+ std::string msg = buf;+ if (!res.guides.empty()) msg += ", along " + std::to_string(res.guides.size()) + " face guides";+ return msg;+}+// ---------------------------------------------------------------------------------------------------------// Test subjects// ---------------------------------------------------------------------------------------------------------@@ -1582,8 +1709,9 @@ bool parseBox(const std::string& s, AABB& out) {return true;}-// Options from command arguments; false with `error` on a bad value.-bool sculptableOptions(const Args& a, SculptableOptions& o, std::string& error) {+} // namespace++bool sculptableOptionsFromArgs(const Args& a, SculptableOptions& o, std::string& error) {SplatSurfaceOptions& s = o.surface;s.resolution = int(argNumber(a, "detail", argNumber(a, "resolution", s.resolution)));s.minOpacity = float(argNumber(a, "min_opacity", s.minOpacity));@@ -1645,8 +1773,6 @@ bool sculptableOptions(const Args& a, SculptableOptions& o, std::string& error)return true;}-} // namespace-void registerSculptableCommands(CommandRegistry& reg) {reg.add({"splat_to_mesh","Make sculptable: turn the Gaussian-splat capture into a clean, sculptable SubTool with the capture's "@@ -1680,7 +1806,7 @@ void registerSculptableCommands(CommandRegistry& reg) {[](Document& doc, const Args& a) -> CommandResult {SculptableOptions o;std::string err;- if (!sculptableOptions(a, o, err)) return {false, err};+ if (!sculptableOptionsFromArgs(a, o, err)) return {false, err};const std::string stage = argString(a, "stage", "all");if (stage != "all" && stage != "scan" && stage != "finish") return {false, "stage must be all, scan or finish"};SculptableResult res;@@ -1697,33 +1823,11 @@ void registerSculptableCommands(CommandRegistry& reg) {res.surface.cell = std::max({b.extent().x, b.extent().y, b.extent().z}) / float(std::max(o.surface.resolution, 32));if (doc.splats.empty() && o.color != SculptableColor::None) o.color = SculptableColor::None;if (!finishSculptable(doc.splats, o, res, err)) return {false, err};- const int scanIndex = doc.activeSubtool;- const std::string name = doc.activeSubtoolInfo().name;- const std::string base = name.size() > 5 && name.ends_with(" Scan") ? name.substr(0, name.size() - 5) : name;- doc.addSubtool(std::move(res.mesh), doc.uniqueSubtoolName(base), true);- doc.qremeshGuides = res.guides;- if (argBool(a, "keep_scan", true)) doc.subtools[size_t(scanIndex)].visible = false;- else doc.removeSubtool(scanIndex);- doc.modified = true;- const size_t faces = doc.mesh.triangleCount() - doc.mesh.quadCount();- return {true, "Made sculptable: " + std::to_string(faces) + " polygons" +- (res.guides.empty() ? std::string() : " along " + std::to_string(res.guides.size()) + " guides")};+ return {true, applySculptableFinish(doc, res, doc.activeSubtool, argBool(a, "keep_scan", true))};}if (doc.splats.empty()) return {false, "No splats loaded"};if (!makeSculptableScan(doc.splats, o, res, err)) return {false, err};- if (stage == "scan") {- const std::string base = doc.splats.name.empty() ? std::string("Scan") : doc.splats.name;- if (doc.subtoolCount() == 1 && !doc.undo.canUndo() && doc.mesh.layers.empty() && !doc.mesh.hasColors())- doc.activeSubtoolInfo().visible = false;- doc.addSubtool(std::move(res.scan), doc.uniqueSubtoolName(base + " Scan"), true);- doc.qremeshGuides = res.guides;- doc.modified = true;- std::string msg = "Scan: " + std::to_string(doc.mesh.triangleCount()) + " triangles from " +- std::to_string(res.surface.used) + " splats";- if (res.landmarks.valid) msg += "; face guides: " + std::to_string(res.guides.size()) + "; landmarks " + faceLandmarksJson(res.landmarks);- else if (!res.faceNote.empty()) msg += " (" + res.faceNote + ")";- return {true, msg};- }+ if (stage == "scan") return {true, applySculptableScan(doc, res)};if (!finishSculptable(doc.splats, o, res, err)) return {false, err};return {true, applySculptable(doc, res, argBool(a, "keep_scan", true))};}});diff --git a/src/core/Sculptable.h b/src/core/Sculptable.hindex 74e220be..9d993ad6 100644--- a/src/core/Sculptable.h+++ b/src/core/Sculptable.h@@ -24,6 +24,7 @@// All of it runs on a worker thread in the app (progress and Cancel); the splat_to_mesh command runs it inline.#pragma once+#include "core/Commands.h"#include "core/Mesh.h"#include "core/QRemesh.h"#include "core/QRemeshGuides.h"@@ -97,7 +98,8 @@ private:std::vector<uint32_t> cellStart_; // CSR: splats of cell c are [cellStart_[c], cellStart_[c + 1])};-// Sets the polypaint of every vertex from the splats. Returns how many vertices found no splat nearby.+// Sets the polypaint of every vertex from the splats. Vertices with no splat near take their neighbours' colour;+// returns how many there were.size_t colorFromSplats(Mesh& mesh, const SplatColorSampler& sampler);// Bakes the splat colour into a size x size texture on the mesh's UVs (it must have UVs); painting then goes// into the texture.@@ -207,6 +209,16 @@ SplatCloud makeTestCapture(const Mesh& mesh, const TestCaptureOptions& options);// ProjectAll from again) when `keepScan`, then "<name>" made active. An untouched starting sphere is hidden.// Returns the status message.std::string applySculptable(Document& doc, SculptableResult& result, bool keepScan);+// Stage 1 into the scene: the scan as "<name> Scan", made active, with the face guides. Returns the status message+// (with the landmarks as JSON when a face was found).+std::string applySculptableScan(Document& doc, SculptableResult& result);+// Stage 2 into the scene: the result next to the active scan SubTool `scanIndex` (hidden, or removed without+// `keepScan`), named like it without " Scan", made active. Returns the status message.+std::string applySculptableFinish(Document& doc, SculptableResult& result, int scanIndex, bool keepScan);++// The options of a splat_to_mesh command line (the app builds its runs from the same arguments, so the console+// shows what it did). False with `error` on a bad value.+bool sculptableOptionsFromArgs(const Args& args, SculptableOptions& options, std::string& error);// splat_to_mesh, face_guides, splat_test_capture.void registerSculptableCommands(CommandRegistry& registry);diff --git a/tests/test_sculptable.cpp b/tests/test_sculptable.cppindex 53772be6..d21f3811 100644--- a/tests/test_sculptable.cpp+++ b/tests/test_sculptable.cpp@@ -106,7 +106,9 @@ TEST(sculptable_floaters_and_crop) {CHECK(st.pieces > 1 && st.floaterVoxels > 0);CHECK(watertight(m));const AABB b = m.bounds();- CHECK(b.max.x < 1.1f && b.min.x > -1.1f && b.max.y < 1.1f && b.min.y > -1.1f);+ // The floaters are 2.2 or more from the centre; the grid is coarse here (it spans them), so allow a voxel or two.+ const float slack = 1.0f + 2.0f * st.cell;+ CHECK(b.max.x < slack && b.min.x > -slack && b.max.y < slack && b.min.y > -slack);// Keep every piece: the floaters come back.o.keepAllParts = true;@@ -143,6 +145,7 @@ TEST(sculptable_fills_open_bottom) {CHECK(volume(filled) > 3.0); // nearly the whole sphere (4.19) minus the cut capo.fillHoles = false;CHECK(splatSurface(c, o, hollow, err));+ if (volume(hollow) >= 1.0) std::printf(" hollow volume %.3f, filled %.3f\n", volume(hollow), volume(filled));CHECK(volume(hollow) < 1.0); // without it the flood leaks in: only a thin shell}diff --git a/tests/ui/make_sculptable.sfui b/tests/ui/make_sculptable.sfuinew file mode 100644index 00000000..2dddc685--- /dev/null+++ b/tests/ui/make_sculptable.sfui@@ -0,0 +1,101 @@+# Make sculptable (Splats palette): the built-in test head capture -> one click -> a quad SubTool with face loops and+# the capture's colours next to the hidden scan; then the review: the face landmarks as dots, one dragged (its mirror+# follows and the loops are rebuilt), Finish. The crop box toggles; F3 finds the action.+run splat_test_capture kind=head count=150000+wait 0.5+expect_value splats > 150000+expect "Make sculptable/Make sculptable"+shot capture++# Ctrl-hover help on the new controls.+hold ctrl+wait 0.2+hover "Make sculptable/Make sculptable"+expect_help "sculptable SubTool"+hover "Make sculptable/##sculptdetail"+expect_help "voxels across"+hover "Make sculptable/Face loops"+expect_help "nasolabial"+hover "Make sculptable/Review##sculptable"+expect_help "landmarks"+hover "Make sculptable/Texture##sculptcolor"+expect_help "Auto UV"+hover "Make sculptable/Crop Box"+expect_help "face handles"+hold none++# The crop box shows round the capture.+click "Make sculptable/Crop Box"+expect_value sculptable_crop == 1+shot crop-box+click "Make sculptable/Crop Box"+expect_value sculptable_crop == 0++# One click: the game preset, face loops found from the front view.+click "Make sculptable/Make sculptable"+wait_idle 120+expect_status "Made sculptable"+expect_status "face guides: 6 loops"+expect_value subtools == 3+expect_value visible_subtools == 1+expect_value show_splats == 0+expect_value quad_percent >= 97+expect_value colored > 0+expect_value qremesh_guide_loops == 6+camera 0 0+shot result+click "PolyF##view.polyf"+shot result-polyf+click "PolyF##view.polyf"++# Review: Film density, stop after the scan to check the landmarks.+click "Show##splats"+expect_value show_splats == 1+click "Make sculptable/Review##sculptable"+click "Make sculptable/Film##sculptpreset"+click "Make sculptable/Make sculptable"+wait_idle 120+expect_value sculptable_review == 1+expect_value sculptable_landmarks == 8+expect_value qremesh_guide_loops == 6+expect_status "face guides: 6 loops"+expect "Make sculptable/Finish"+camera 0 0+shot review+# Drag the left mouth corner further left: the right one follows (mirrored), the loops are rebuilt.+remember landmark_x_5 left+remember landmark_x_6 right+drag_landmark 5 -14 0+expect_status "Face guides"+expect_value landmark_x_5 < $left+expect_value landmark_x_6 > $right+expect_value qremesh_guide_loops == 6+shot review-nudged+click "Make sculptable/Finish"+wait_idle 120+expect_status "Made sculptable"+expect_status "along"+expect_value sculptable_review == 0+expect_value quad_percent >= 97+expect_value subtools == 5+expect_value visible_subtools == 2+camera 0 0+click "PolyF##view.polyf"+shot film-polyf+click "PolyF##view.polyf"++# Place by hand: Review again, then click the eight landmarks on the scan.+click "Make sculptable/Make sculptable"+wait_idle 120+expect_value sculptable_review == 1+click "Make sculptable/Place by hand"+expect_value sculptable_placing == 0+expect_status "outer corner"+click "Make sculptable/Back##sculptable"+expect_value sculptable_review == 0++# F3 finds it.+key f3+type "##Command palette" "make sculptable"+expect_text "Make sculptable"+key escape