Skip to content

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

AI off: Mesh > From Image, no Generate 3D; Voxel Remesh slider 32-512; a resting pen no longer blocks the mouse

islandmed69a541c4875f
diff --git a/changes/fix-small-1105.md b/changes/fix-small-1105.md
new file mode 100644
index 00000000..9bb9cd6f
--- /dev/null
+++ b/changes/fix-small-1105.md
@@ -0,0 +1,36 @@
+---
+whats_new: **AI off means off in the menus too**: with **Edit > Preferences > AI > Enable AI features** off, the
+ Mesh menu's section is **From Image** (Relief, Inflate, Stamp) instead of Generate 3D.
+whats_new: **Voxel Remesh up to 512**: the **Tool > Remesh** Resolution slider now goes from 32 to 512, as the
+ `remesh` command does.
+whats_new: **A pen resting on the tablet no longer blocks the mouse or trackpad**: lay the pen down and the cursor,
+ the shelf buttons (the mirror's X too) and the menus answer the mouse at once.
+fixed: With **Edit > Preferences > AI > Enable AI features** off, the Mesh menu still showed a **Generate 3D** section; it
+ is now **From Image** and holds only the offline Relief, Inflate and Stamp (the AI entries were already gone).
+ The status messages after opening an image point there too (reported by ebarranco on Discord).
+fixed: A pen lying still in range (laid on the tablet, or held still above it) kept sending a hair of tilt and
+ sub-pixel motion, and each event counted as the pen in use: the mouse and trackpad could neither move the cursor
+ nor click for as long as it lay there, and the pen pulled the cursor back to itself. With a Wacom, a SpaceMouse
+ and a trackpad on a Mac the window seemed frozen and the mirror's X out of reach (reported by phoenix on
+ Discord). Only touching, buttons, coming into range, pressure and real movement count now.
+changed: **Tool > Remesh > Voxel Remesh**: the Resolution slider goes from 32 to 512 (was 64 to 400), as the
+ `remesh resolution=` command does (asked by fxrtst on Discord). 512 is safe on 8 GB: a 28M-triangle scan in
+ about 8 s (14 s on 4 cores) into about 760k triangles; a round 2M sculpt in about 3 s into about 2.5M triangles,
+ 2.2 GB at the peak.
+testers:
+ - Any OS: Edit > Preferences > AI > Enable AI features off; open the Mesh menu: a From Image section (Relief,
+ Inflate, Stamp), no Generate 3D anywhere (menus, shelves, the F3 search). On again: Generate 3D is back.
+ - Any OS: Tool > Remesh: drag Resolution to 512 and Voxel Remesh a sculpt; it finishes in seconds, the app stays
+ responsive.
+ - macOS / Windows with a tablet: sculpt a few strokes with the pen, lay the pen on the tablet (still in range),
+ then use the mouse or trackpad: the cursor follows it within a second and clicking X on the shelf toggles the
+ mirror. Pick the pen back up: it takes the cursor again at once.
+---
+Reviewer notes:
+- Mirror freeze review (phoenix): the symmetry toggle is a plain flag; strokes copy it per batch (AsyncStroke
+ dabSettings), fused batches group dabs by symmetry (SculptBatch batchable), Move/Grab keeps the mirrors it began
+ with. The only wait in a stroke is StrokeSolver::wait (logs every 2 s since 0.11.1). No lock found that several
+ devices could trigger. What did block input: strayMouseMotion's 1 s "pen in use" window was restarted by every pen
+ event, including a resting pen's noise, and an accepted mouse move ended the pen's proximity, so the next noise
+ event re-claimed the cursor. tests/ui/mirror_stress.sfui (pen_rest on) fails at line 61 without the fix.
+- lastPenNs_ now counts on clickClockNs() (SDL ticks in the app, the script's time in UI tests).
diff --git a/docs/guide/geometry.md b/docs/guide/geometry.md
index 827de090..bd9ee0c0 100644
--- a/docs/guide/geometry.md
+++ b/docs/guide/geometry.md
@@ -66,8 +66,11 @@ Use it to:
- even out stretched triangles after heavy Move or Tendril work;
- clean up scans, splat conversions and AI-generated models before sculpting.
-The **Resolution** slider next to the button sets how many voxels span the longest side of the model (64 to 400 in
-the palette, default 200). Higher keeps more detail and makes more triangles.
+The **Resolution** slider next to the button sets how many voxels span the longest side of the model (32 to 512, as
+the `remesh` command; default 200). Higher keeps more detail and makes more triangles. 512 is safe on an 8 GB
+computer: a 28M-triangle scan remeshes at 512 in about 8 s (14 s on 4 cores) into about 760,000 triangles; a round
+2M-triangle sculpt, which fills its box, in about 3 s (5 s on 4 cores) into about 2.5 million triangles, with about
+2 GB of memory at its peak.
![Wireframe of a model before and after a voxel remesh](images/remesh.jpg)
diff --git a/docs/guide/interface.md b/docs/guide/interface.md
index d05f0d5a..c70f0781 100644
--- a/docs/guide/interface.md
+++ b/docs/guide/interface.md
@@ -163,7 +163,7 @@ turn on **Edit > Preferences > Interface > Palettes strictly A-Z (strict order)*
| **Brush** | Sculpt > Brush | AI Brush (Brush Lab), Community brushes, Paste brush, your custom brushes, Front faces only, Invert (Alt), the recipe editor for a custom brush, and every brush as a thumbnail grid with a filter |
| **Color** | Paint | The Paint brush, RGB while sculpting, the paint colour and swatches, Fill, Fill masked, Cavity, Clear, Show vertex paint |
| **Draw** | Sculpt > Draw & Tablet | Size, Intensity, Colour intensity, Falloff, Sculpt/Paint, Add/Sub, Rgb, Front, and the tablet options (Pressure > strength, Pressure > size) with a pen readout |
-| **Generate** | Mesh > Generate 3D | Generate 3D (image or text to 3D), Relief, Inflate and Stamp from an image, and the AI brush provider settings |
+| **Generate** | Mesh > Generate 3D (Mesh > From Image while Edit > Preferences > AI is off) | Generate 3D (image or text to 3D), Relief, Inflate and Stamp from an image, and the AI brush provider settings; with AI off only Relief, Inflate and Stamp |
| **Material** | Render > Materials | The Lit Sphere materials (Soft Clay, the default, first), your own (**Load Lit Sphere...**) and Studio, Base colour, Smooth / Flat shading for the scene and the active Part |
| **Preferences** | Edit > Preferences | Config, Interface, Input, Hotkeys, Display, Library, Tablet, Performance, Updates and Autosave sub-palettes (see [Customizing the interface](#customizing-the-interface)) |
| **Render** | View | Wireframe, Show Mesh, Show Vertex Paint, Show Mask, Show Face Groups, Show Splats, Background, Frame, Fullscreen |
diff --git a/src/app/App.cpp b/src/app/App.cpp
index 894382cd..a63f5ccc 100644
--- a/src/app/App.cpp
+++ b/src/app/App.cpp
@@ -1348,6 +1348,7 @@ void App::buildUiFonts(float scale) {
void App::handleEvent(const SDL_Event& event) {
if (dropPenMouseEvent(event)) return; // the pen's mouse events are made here, not by SDL (#95, Tablet.cpp)
+ penNoise_ = penRestNoise(event); // a resting pen's tilt and jitter (Tablet.cpp)
penMouseEvents(event, true); // a pen leaving lets go of the tip's button first
dispatchEvent(event);
penMouseEvents(event, false); // the tip's mouse events, after the pen's own
@@ -1355,6 +1356,7 @@ void App::handleEvent(const SDL_Event& event) {
void App::dispatchEvent(const SDL_Event& event) {
if (strayMouseMotion(event)) return; // neither the canvas nor the UI follows a driver's stray mouse events
+ if (event.type == SDL_EVENT_MOUSE_MOTION && event.motion.which != SDL_PEN_MOUSEID) mouseSincePen_ = true;
if (sixDofPointerEvent(event)) return; // nor a SpaceMouse that also says it is a mouse (SpaceMouse.cpp)
if ((event.type >= SDL_EVENT_KEY_DOWN && event.type < SDL_EVENT_JOYSTICK_AXIS_MOTION &&
event.type != SDL_EVENT_KEYMAP_CHANGED && event.type != SDL_EVENT_KEYBOARD_ADDED &&
@@ -1634,7 +1636,7 @@ void App::onMouseDown(float x, float y, Uint8 button) {
// don't sculpt it: brushes work on the active Part only.)
// Not from a pen: quick taps of a stippling pen counted as a triple-click and switched the Part. Nor while
// a pen hovers: a Wacom side button set to Double Click (the Intuos 3 default) and a tap made one (Discord).
- const bool penNear = penInProximity_ && SDL_GetTicksNS() - lastPenNs_ < 1000000000ull;
+ const bool penNear = penInProximity_ && clickClockNs() - lastPenNs_ < 1000000000ull;
if (mouseClicks_ >= 3 && !lastInputPen_ && !wintabPen_ && !penNear && !(mod & (SDL_KMOD_SHIFT | SDL_KMOD_CTRL | SDL_KMOD_ALT | SDL_KMOD_GUI)) &&
insertType_.empty() && doc_.partCount() > 1) {
const int target = pickPart(x, y);
@@ -2558,7 +2560,7 @@ void App::openPath(const std::string& path) {
if (Image::isImagePath(path)) {
if (loadReferenceImage(path)) {
if (ai::aiEnabled()) showImageTo3D_ = true;
- else status_ = "Image loaded: Relief, Inflate or Stamp it from Mesh > Generate 3D";
+ else status_ = "Image loaded: Relief, Inflate or Stamp it from Mesh > From Image";
}
} else if (ext == ".sfbrush") {
installBrushFile(path);
diff --git a/src/app/App.h b/src/app/App.h
index d6c8e8b0..db1bbf43 100644
--- a/src/app/App.h
+++ b/src/app/App.h
@@ -2227,7 +2227,13 @@ private:
float penMouseX_ = 0.0f, penMouseY_ = 0.0f; // the pen's last position (window pixels, before mouse mode)
PenCursor penCursor_; // where the pen puts the cursor (Preferences > Tablet > Mouse mode)
bool penInProximity_ = false, penTouching_ = false, penEraser_ = false;
- Uint64 lastPenNs_ = 0; // when the last pen event arrived (see onMouseMove)
+ Uint64 lastPenNs_ = 0; // when the pen last did something (see onMouseMove; not a resting pen's noise)
+ // A pen resting in range (laid on the tablet, held still above it) still sends tilt and sub-pixel motion: that
+ // noise doesn't count as the pen in use, so the mouse and trackpad work beside it (phoenix 11-05, Tablet.cpp).
+ bool penRestNoise(const SDL_Event& e);
+ bool penNoise_ = false; // the event being handled is such noise
+ bool mouseSincePen_ = false; // the mouse moved the cursor since the pen last did something
+ float penActiveX_ = 0.0f, penActiveY_ = 0.0f; // where it did (window pixels)
Uint64 lastPenTouchNs_ = 0; // when the pen tip last touched down or lifted (strayMouseMotion)
uint32_t penButtons_ = 0; // bit N: pen button N is held
int penNavButton_ = 0; // the pen button driving a view drag (0: none)
diff --git a/src/app/Demo.cpp b/src/app/Demo.cpp
index 56a55742..21255d9c 100644
--- a/src/app/Demo.cpp
+++ b/src/app/Demo.cpp
@@ -215,6 +215,7 @@ void Demo::update(float dt) {
SDL_Log("t=%.2f step=%zu brushlab=(%.0f,%.0f) mouse=(%.0f,%.0f) down=%d", clock_, step_, w->Pos.x, w->Pos.y, mouse_.x,
mouse_.y, int(buttonDown_));
stride_ = 1;
+ if (penResting_) penRestNoise(); // (UiTest.cpp)
if (!stepLines_.empty()) { // SF_UI_PROFILE: the frame just drawn belongs to the step that was running
const auto now = std::chrono::steady_clock::now();
if (lastUpdate_.time_since_epoch().count() != 0 && step_ < stepLines_.size())
diff --git a/src/app/Demo.h b/src/app/Demo.h
index 8a63ec36..0cf0d921 100644
--- a/src/app/Demo.h
+++ b/src/app/Demo.h
@@ -184,6 +184,12 @@ private:
// sdl_pen_mouse / pen_lost). A Huion-style driver also sends mouse events of its own (pen_stream huion).
bool sdlPenMouse_ = true;
bool huionStream_ = false;
+ // pen_rest on: the pen lies still in range and, as a real one does, sends a hair of tilt and sub-pixel motion
+ // every frame (phoenix 11-05) until pen_rest off.
+ bool penResting_ = false;
+ ImVec2 penRestAt_{0, 0};
+ int penRestFrame_ = 0;
+ void penRestNoise();
static constexpr SDL_MouseID kDriverMouse = 7; // the driver's own mouse device
// `snapshot` saves the active mesh; moved* values compare against it. `remember` keeps values for $NAME.
std::vector<glm::vec3> basePositions_, baseNormals_;
diff --git a/src/app/I18nSpanish.cpp b/src/app/I18nSpanish.cpp
index c35a17dc..8ff765fe 100644
--- a/src/app/I18nSpanish.cpp
+++ b/src/app/I18nSpanish.cpp
@@ -97,6 +97,7 @@ constexpr Entry kSpanish[] = {
{"Camera", "Cámara"},
{"Import / Export", "Importar / Exportar"},
{"From an image", "A partir de una imagen"},
+ {"From Image", "Desde imagen"},
{"Voxel Remesh", "Remallado por vóxeles"},
{"Quick Remesh", "Remallado rápido"},
{"Modify Topology", "Modificar topología"},
diff --git a/src/app/I18nTraditionalChinese.cpp b/src/app/I18nTraditionalChinese.cpp
index 2289e0c9..0f8b7ff5 100644
--- a/src/app/I18nTraditionalChinese.cpp
+++ b/src/app/I18nTraditionalChinese.cpp
@@ -96,6 +96,7 @@ constexpr Entry kTraditionalChinese[] = {
{"Camera", "相機"},
{"Import / Export", "匯入/匯出"},
{"From an image", "從影像建立"},
+ {"From Image", "從影像"},
{"Voxel Remesh", "體素重新網格化"},
{"Modify Topology", "修改拓樸"},
{"Game Ready", "適用於遊戲"},
diff --git a/src/app/Palettes.cpp b/src/app/Palettes.cpp
index 22dfa571..ee7e1bc8 100644
--- a/src/app/Palettes.cpp
+++ b/src/app/Palettes.cpp
@@ -87,6 +87,19 @@ int taskMenuOf(std::string_view paletteId) {
return -1;
}
+const char* taskSectionTitle(const TaskMenuDef& menu, int k) {
+ if (std::string_view(menu.sections[k]) == "generate" && !ai::aiEnabled()) return "From Image";
+ if (menu.titles[k]) return menu.titles[k];
+ const PaletteDef* p = findPalette(menu.sections[k]);
+ return p ? p->name : menu.sections[k];
+}
+
+const char* taskSectionIcon(const TaskMenuDef& menu, int k) {
+ if (std::string_view(menu.sections[k]) == "generate" && !ai::aiEnabled()) return ICON_LC_IMAGE;
+ const PaletteDef* p = findPalette(menu.sections[k]);
+ return p ? p->icon : "";
+}
+
namespace {
// The hairline under each sub-palette header: opaque, a clear step above panelBg so the closed list reads as rows.
@@ -821,7 +834,7 @@ void App::drawPalette_Tool() {
}
ImGui::SameLine();
ImGui::SetNextItemWidth(-1);
- tray::SliderInt("##voxres", &voxelResolution_, 64, 400, "Resolution %d");
+ tray::SliderInt("##voxres", &voxelResolution_, 32, 512, "Resolution %d"); // as the remesh command (fxrtst 11-05)
ui::HelpText("Resolution", nullptr, "Voxels across the model: higher keeps more detail and makes more triangles.",
"Tool > Remesh");
if (voxelRemesh_) {
diff --git a/src/app/PanelPhone.cpp b/src/app/PanelPhone.cpp
index 856c255a..5867acdc 100644
--- a/src/app/PanelPhone.cpp
+++ b/src/app/PanelPhone.cpp
@@ -173,7 +173,7 @@ void App::handlePhoneCapture(const link::PhoneEvent& e) {
return;
}
if (!ai::aiEnabled()) { // Preferences > AI is off: the photo stays the reference image
- status_ = "Photo received (" + where + "): Relief, Inflate or Stamp it from Mesh > Generate 3D";
+ status_ = "Photo received (" + where + "): Relief, Inflate or Stamp it from Mesh > From Image";
return;
}
showImageTo3D_ = true;
diff --git a/src/app/Shell.cpp b/src/app/Shell.cpp
index 381efc6d..c7259474 100644
--- a/src/app/Shell.cpp
+++ b/src/app/Shell.cpp
@@ -1679,7 +1679,7 @@ void App::drawTaskMenu() {
for (int k = 0; k < sections; ++k) {
const PaletteDef* p = findPalette(menu.sections[k]);
if (!p) continue;
- const std::string title = tr(menu.titles[k] ? menu.titles[k] : p->name);
+ const std::string title = tr(taskSectionTitle(menu, k));
const bool current = dropdown_ == p->id;
const bool inTray = std::count(layout_.leftTray.begin(), layout_.leftTray.end(), p->id) +
std::count(layout_.rightTray.begin(), layout_.rightTray.end(), p->id) >
@@ -1691,7 +1691,7 @@ void App::drawTaskMenu() {
if (current || hovered) dl->AddRectFilled(a, b, theme::u32(current ? theme::selection : theme::headerHover, current ? 1.0f : 0.6f));
if (current) dl->AddRectFilled(a, ImVec2(a.x + 2.0f * s, b.y), theme::u32(theme::accent));
const float ty = std::floor(a.y + (rowH - ImGui::GetFontSize()) * 0.5f);
- dl->AddText(ImVec2(a.x + 10.0f * s, ty), theme::u32(current ? theme::accent : theme::textDim), p->icon);
+ dl->AddText(ImVec2(a.x + 10.0f * s, ty), theme::u32(current ? theme::accent : theme::textDim), taskSectionIcon(menu, k));
dl->AddText(ImVec2(a.x + 34.0f * s, ty), theme::u32(current ? theme::textBright : theme::text), title.c_str());
if (inTray) dl->AddText(ImVec2(b.x - 22.0f * s, ty), theme::u32(theme::textDim), ICON_LC_PANEL_RIGHT);
if (clicked) {
diff --git a/src/app/Shell.h b/src/app/Shell.h
index 13afe4b0..9af59d12 100644
--- a/src/app/Shell.h
+++ b/src/app/Shell.h
@@ -38,6 +38,10 @@ struct TaskMenuDef {
};
const TaskMenuDef* taskMenus(int& count);
int taskMenuOf(std::string_view paletteId); // index into taskMenus, -1 when none
+// Section k's name in its menu: Mesh's "Generate 3D" is "From Image" while Preferences > AI is off (only the offline
+// Relief, Inflate and Stamp are left there).
+const char* taskSectionTitle(const TaskMenuDef& menu, int k);
+const char* taskSectionIcon(const TaskMenuDef& menu, int k); // (an image for From Image, not the AI sparkles)
// ui::ActionButton's Tile look: a brush thumbnail with its name (brush actions), or a large icon over a
// small caption (right shelf). Returns true when clicked.
diff --git a/src/app/Tablet.cpp b/src/app/Tablet.cpp
index b72db748..c88989dc 100644
--- a/src/app/Tablet.cpp
+++ b/src/app/Tablet.cpp
@@ -102,6 +102,7 @@ void App::penMouseEvents(const SDL_Event& e, bool before) {
break;
case SDL_EVENT_PEN_MOTION:
if (penMouseDown_ && e.pmotion.which != penMouseOwner_) break;
+ if (penNoise_ && mouseSincePen_) break; // a resting pen doesn't pull the cursor back from the mouse
sendPenMouse(SDL_EVENT_MOUSE_MOTION, e.pmotion.x, e.pmotion.y, e.pmotion.windowID);
if (!penMouseDown_) {
// A hovering pen presses nothing. Should the UI still hold a left button (a driver's press whose
@@ -130,7 +131,7 @@ bool App::strayMouseMotion(const SDL_Event& e) const {
if (!motion && !left) return false;
if (dragFromPen_ && drag_ != Drag::None) return true;
if (left) return penInProximity_ && (penTouching_ || clickClockNs() - lastPenTouchNs_ < 100000000ull);
- return penInProximity_ && SDL_GetTicksNS() - lastPenNs_ < 1000000000ull;
+ return penInProximity_ && clickClockNs() - lastPenNs_ < 1000000000ull;
}
// ImGui's SDL backend also reads the system cursor every frame while no button is held (the cursor minus the window
@@ -140,7 +141,7 @@ void App::keepImGuiOnPen() {
ImGuiIO& io = ImGui::GetIO();
const bool soft = penSoftCursor();
io.MouseDrawCursor = soft && !viewportCursorWanted(); // over the view the brush ring is the cursor
- if (!soft && (!penInProximity_ || SDL_GetTicksNS() - lastPenNs_ >= 1000000000ull)) return;
+ if (!soft && (!penInProximity_ || clickClockNs() - lastPenNs_ >= 1000000000ull)) return;
io.AddMousePosEvent(mouseX_, mouseY_);
}
@@ -181,8 +182,37 @@ void App::mapPenPosition(SDL_Event& e) {
}
}
+// A pen resting in range (laid on the tablet, or held still above it) keeps sending events: tilt and rotation that
+// change by a hair, and motion of a fraction of a pixel. Each of them used to count as the pen in use, so for as
+// long as it lay there the mouse and trackpad could neither move the cursor nor click (strayMouseMotion, a second
+// after the last pen event): with a Wacom, a SpaceMouse and a trackpad on a Mac, the window seemed frozen and the
+// mirror's X out of reach (phoenix, Discord 11-05). Now only touching, buttons, coming into range, pressure and
+// motion of more than kRestPx count; the rest is noise.
+bool App::penRestNoise(const SDL_Event& e) {
+ constexpr float kRestPx = 1.5f;
+ switch (e.type) {
+ case SDL_EVENT_PEN_AXIS: return !(penTouching_ && e.paxis.axis == SDL_PEN_AXIS_PRESSURE);
+ case SDL_EVENT_PEN_MOTION:
+ // (Whether or not the mouse took the cursor since: that ends the pen's proximity, onMouseMove.)
+ if (!penTouching_ && std::hypot(e.pmotion.x - penActiveX_, e.pmotion.y - penActiveY_) < kRestPx)
+ return true;
+ penActiveX_ = e.pmotion.x;
+ penActiveY_ = e.pmotion.y;
+ return false;
+ case SDL_EVENT_PEN_DOWN:
+ case SDL_EVENT_PEN_UP:
+ penActiveX_ = e.ptouch.x;
+ penActiveY_ = e.ptouch.y;
+ return false;
+ default: return false;
+ }
+}
+
void App::handlePenEvent(const SDL_Event& e) {
- lastPenNs_ = SDL_GetTicksNS();
+ if (!penNoise_) {
+ lastPenNs_ = clickClockNs(); // (UI tests: the script's time, as the 1 s rules below count it)
+ mouseSincePen_ = false;
+ }
switch (e.type) {
case SDL_EVENT_PEN_PROXIMITY_IN:
// A pen coming into range while a pen drag is still open: it left without saying so (some drivers never
@@ -215,7 +245,7 @@ void App::handlePenEvent(const SDL_Event& e) {
lastPenTouchNs_ = clickClockNs();
break;
case SDL_EVENT_PEN_MOTION:
- penSeen_ = penInProximity_ = true;
+ if (!penNoise_) penSeen_ = penInProximity_ = true; // (a resting pen doesn't take the cursor back)
penId_ = e.pmotion.which;
penTracker_.motion();
break;
@@ -356,7 +386,7 @@ void App::wintabEvent(const SDL_Event& e) {
e.button.which != SDL_PEN_MOUSEID);
if (!mouse || !wintab_.isOpen()) return;
const Uint64 now = SDL_GetTicksNS();
- if (penInProximity_ && now - lastPenNs_ < 1000000000ull) return; // Windows Ink is on: SDL's pen events count
+ if (penInProximity_ && clickClockNs() - lastPenNs_ < 1000000000ull) return; // Windows Ink is on: SDL's pen events count
WintabPressure::Sample s;
if (wintab_.poll(s)) {
wintabNs_ = now;
diff --git a/src/app/UiTest.cpp b/src/app/UiTest.cpp
index 5701ff08..747a2ab3 100644
--- a/src/app/UiTest.cpp
+++ b/src/app/UiTest.cpp
@@ -220,6 +220,8 @@
// pen_pressure P a pressure sample from the hovering pen (e.g. a stale value before a stroke)
// pen_enter U V the pen comes into range at a point on the model (put down elsewhere, no hover)
// pen_out the pen leaves proximity
+// pen_rest on|off the pen lies still in range, sending tilt and sub-pixel motion every frame (a Wacom
+// laid on the tablet); the mouse and trackpad work beside it
// tablet_plug [NAME] a tablet plugged in while running (default name: a generic HID mouse); its pen gets
// a new id
// tablet_unplug ... and unplugged
@@ -2474,6 +2476,14 @@ bool Demo::parseStep(int line, const std::vector<std::string>& w, std::string& e
} else if (verb == "pen_out") {
run([this] { penProximity(false); });
wait(0.05f);
+ } else if (verb == "pen_rest") {
+ if (!need(1)) return false;
+ run([this, on = w[1] != "off"] {
+ if (on && !penIn_) penProximity(true);
+ penRestAt_ = penAt_;
+ penResting_ = on;
+ });
+ wait(0.05f);
} else if (verb == "shot") {
if (!need(1)) return false;
const std::string name = w[1];
@@ -2561,6 +2571,23 @@ void Demo::penMove(float x, float y) {
if (huionStream_) mouseMotion(x, y, kDriverMouse); // ... and the driver moves it too
}
+void Demo::penRestNoise() {
+ if (!penIn_ || penDown_) return;
+ if (std::hypot(penAt_.x - penRestAt_.x, penAt_.y - penRestAt_.y) > 2.0f) penRestAt_ = penAt_; // laid down elsewhere
+ const float jitter = (++penRestFrame_ & 1) ? 0.4f : -0.4f;
+ penMove(penRestAt_.x + jitter, penRestAt_.y);
+ SDL_Event e{};
+ e.type = SDL_EVENT_PEN_AXIS;
+ e.paxis.windowID = SDL_GetWindowID(app_.window_);
+ e.paxis.which = testPen_;
+ e.paxis.pen_state = penState_;
+ e.paxis.x = penAt_.x;
+ e.paxis.y = penAt_.y;
+ e.paxis.axis = SDL_PEN_AXIS_XTILT;
+ e.paxis.value = 20.0f + jitter;
+ app_.handleEvent(e);
+}
+
void Demo::penPressure(float pressure) {
SDL_Event e{};
e.type = SDL_EVENT_PEN_AXIS;
diff --git a/tests/ui/ai_switch.sfui b/tests/ui/ai_switch.sfui
index 5cb84aaf..be23299b 100644
--- a/tests/ui/ai_switch.sfui
+++ b/tests/ui/ai_switch.sfui
@@ -27,6 +27,18 @@ expect "Relief"
expect_not "Generate 3D##ui.generate3d"
shot ai-generate-off
+# The Mesh menu names that section by what is left in it (ebarranco 11-05: "Generate 3D" showed with AI off).
+run ui_look look=forge scheme=neutral layout=sculptforge
+wait 0.2
+click "Mesh##menu.mesh"
+expect "From Image##section.generate"
+expect_not "Generate 3D##section.generate"
+expect_not "Generate 3D##ui.generate3d"
+shot ai-mesh-menu-off
+key escape
+run ui_look look=classic layout=classic
+wait 0.2
+
# The command palette finds the switch, not the AI tools.
key f3
type "##Command palette" "brush ai"
@@ -46,6 +58,15 @@ click "Preferences##palette.preferences" # close the popup first
click "AI Brush"
expect "Brush Lab"
click "AI Brush"
+run ui_look look=forge scheme=neutral layout=sculptforge
+wait 0.2
+click "Mesh##menu.mesh"
+expect "Generate 3D##section.generate"
+expect_not "From Image##section.generate"
+shot ai-mesh-menu-on
+key escape
+run ui_look look=classic layout=classic
+wait 0.2
# First run: the welcome asks.
key f3
diff --git a/tests/ui/mirror_stress.sfui b/tests/ui/mirror_stress.sfui
new file mode 100644
index 00000000..52e774f8
--- /dev/null
+++ b/tests/ui/mirror_stress.sfui
@@ -0,0 +1,127 @@
+# Mirror with every input at once (phoenix, Discord 11-05: macOS, Wacom Intuos Pro + SpaceMouse Compact + trackpad,
+# "froze and wouldn't allow me to use the mirror function"). Symmetry X toggled mid-stroke, the SpaceMouse cap and
+# trackpad pinches while the pen or mouse holds a stroke, pen strokes with stray mouse events: every stroke ends,
+# is one undo step, the app keeps drawing, and X still toggles from the key and the shelf afterwards.
+run ui_look look=classic layout=classic # written for the Classic look and the classic palette bar and shelves
+run new_sphere subdivisions=5
+expect_value symmetry_x == 1
+
+# A held mouse stroke: X off and on again mid-stroke, the cap twisted (held still: Hold during strokes), a trackpad
+# pinch, then more stroke and the release.
+key f
+camera 0 0
+snapshot
+drag_path 0.3 0.45 0.5 0.5 keep
+expect_value stroking == 1
+key x
+spacemouse 0 0 0 0 0 0.8 0.2
+touch_pinch 0.5 0.5 1.5 0 0 0 trackpad
+key x
+drag_path 0.5 0.5 0.7 0.55 keep
+spacemouse_button 2
+release
+wait_idle
+expect_value stroking == 0
+expect_value symmetry_x == 1
+expect_value moved > 0
+key ctrl+z
+expect_value moved == 0
+
+# Pen strokes over and over, X toggled between them by key, the cap turning, the trackpad pinching, a stray mouse
+# event inside each stroke (Windows Ink / macOS send the pointer's own beside the pen's).
+key f
+camera 0 0
+snapshot
+pen_drag 0.35 0.45 0.65 0.5 0.3 stray 0.2 0.2
+key x
+spacemouse 0 0 0 0 0 0.6 0.1
+pen_drag 0.35 0.55 0.65 0.5 0.3 stray 0.8 0.8
+touch_pinch 0.5 0.5 0.8 10 0 0 trackpad
+key x
+pen_drag 0.4 0.4 0.6 0.6 0.3 stray 0.1 0.9
+spacemouse_button 1
+key x
+pen_drag 0.6 0.4 0.4 0.6 0.3
+key x
+wait_idle
+expect_value stroking == 0
+expect_value symmetry_x == 1
+key ctrl+z
+key ctrl+z
+key ctrl+z
+key ctrl+z
+expect_value moved == 0
+
+# The pen laid on the tablet, still in range: a real one keeps sending a hair of tilt and sub-pixel motion. That
+# kept the mouse and trackpad from moving the cursor or clicking for as long as it lay there (the frozen window,
+# the X out of reach). A second after the pen last moved, the mouse works beside it.
+pen_rest on
+wait 1.1
+click "X##transform.symmetry_x"
+expect_value symmetry_x == 0
+click "X##transform.symmetry_x"
+expect_value symmetry_x == 1
+
+# Hold during strokes off: the cap turns the view under a pen stroke while X is toggled; still one stroke, one undo.
+click "Preferences##palette.preferences"
+click "Input##preferences.input"
+click "Hold during strokes##spacemouse.hold"
+key escape
+key f
+camera 0 0
+snapshot
+spacemouse_hold 0 0 0 0 0 0.5
+pen_drag 0.3 0.45 0.7 0.55 0.5
+key x
+pen_drag 0.3 0.55 0.7 0.45 0.5
+spacemouse_hold 0 0 0 0 0 0
+wait_idle
+expect_value stroking == 0
+expect_value symmetry_x == 0
+key ctrl+z
+key ctrl+z
+expect_value moved == 0
+wait 1.1 # (a second after the pen last moved: the mouse's again, #13)
+click "Preferences##palette.preferences"
+click "Hold during strokes##spacemouse.hold"
+key escape
+
+# Predictive Strokes: the dabs run on the stroke thread, which the main thread waits for at the release (the one
+# wait a stroke has). The same interleave there.
+key f3
+type "##Command palette" "predictive strokes"
+key enter
+expect_value predictive_strokes == 1
+key f
+camera 0 0
+snapshot
+drag_path 0.3 0.45 0.5 0.5 keep
+key x
+spacemouse 0 0 0 0 0 0.8 0.2
+touch_pinch 0.5 0.5 1.5 0 0 0 trackpad
+key x
+drag_path 0.5 0.5 0.7 0.55 keep
+release
+pen_drag 0.35 0.45 0.65 0.5 0.3 stray 0.2 0.2
+wait_idle
+expect_value stroking == 0
+expect_value symmetry_x == 0
+key ctrl+z
+key ctrl+z
+expect_value moved == 0
+wait 1.1 # (a second after the pen last moved: the mouse's again, #13)
+key f3
+type "##Command palette" "predictive strokes"
+key enter
+expect_value predictive_strokes == 0
+
+# Afterwards (the pen still resting in range) the mirror still answers the mouse: the shelf's X turns it on and off.
+click "X##transform.symmetry_x"
+expect_value symmetry_x == 1
+click "X##transform.symmetry_x"
+expect_value symmetry_x == 0
+key x
+expect_value symmetry_x == 1
+shot mirror-stress-after
+pen_rest off
+pen_out