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
Pen: Preferences > Tablet > View speed for the pen's orbit, pan and zoom; one-frame pen tap test (GonzaloHernandez3D on Reddit)
islandmede55130743fe8
diff --git a/changes/fix-pen-ui-clicks-orbit.md b/changes/fix-pen-ui-clicks-orbit.mdnew file mode 100644index 00000000..e07cc2cf--- /dev/null+++ b/changes/fix-pen-ui-clicks-orbit.md@@ -0,0 +1,21 @@+---+whats_new: **Pen view speed**: **Preferences > Tablet > View speed** sets how fast the pen turns, pans and zooms the+ view, apart from the mouse. Turn it down if the view spins too fast with a tablet. Thanks to GonzaloHernandez3D on Reddit.+added: **View speed** (Preferences > Tablet): how far the pen turns, pans and zooms the view per pixel, 0.10 to 2.00+ (1.00, the default, moves it as the mouse does). A tablet spreads its whole area over the screen, so a short pen+ movement crosses many pixels and orbiting seemed far faster than with the mouse (Huion on Windows; thanks to+ GonzaloHernandez3D on Reddit). Saved in the preferences; Tablet defaults sets it back to 1.00.+fixed: Pen taps on menus and buttons work the first time, also a tap within one frame or right after the pen comes into+ range, with Windows Ink and with Huion's extra mouse events (reported by GonzaloHernandez3D on Reddit; fixed by the+ pen click rework in 0.10.9, now covered by a test).+testers:+ - Windows with a Huion or XP-Pen tablet: tap File, View, Help and a brush with the pen, each once: each opens or+ picks the first time, also right after bringing the pen in from out of range.+ - Same tablet: drag on the background with the pen tip, then Preferences > Tablet > View speed 0.40 and drag again:+ the view turns less than half as far; the mouse turns it as before.+---+Root causes: the missed taps were SDL 3.2's stuck pen-mouse state and the driver's unreleased presses (#95, #13),+fixed on main after the report (10-31 to 11-02); tests/ui/pen_quick_taps.sfui replays the report with one-frame taps+(new `pen_tap` verb). Orbit: SDL 3.2.30 gives pen and mouse in the same window pixels (per-monitor DPI aware, no+relative mode), and the test proves the same drag turns the view by the same angle with either; the difference is the+tablet's absolute mapping, hence the setting.diff --git a/docs/tablet.md b/docs/tablet.mdindex aeffa6b7..1ca3ea6d 100644--- a/docs/tablet.md+++ b/docs/tablet.md@@ -14,6 +14,9 @@ Open **Preferences > Tablet** to check the pen and tune it:in its own mouse mode (Wacom: Mapping > Mode > Mouse; XP-Pen and Huion: Relative / Mouse mode). While the pen isin range SculptForge draws the arrow at the brush and hides the system's, which sits where the pen is on thetablet; clicks land at the arrow. Off (pen mode, the default): the cursor is where the pen is.+- **View speed**: how far the pen turns, pans and zooms the view per pixel, 0.10 to 2.00; 1.00 (the default) moves+ it as the mouse does. A tablet spreads its whole area over the screen, so a short pen movement crosses many+ pixels: if orbiting with the pen spins the model too fast, turn it down. The mouse keeps its own speed.- **Pressure meter**: the pressure the tablet reports, and what brushes get after the curve below.- **Draw-test area**: draw in it with the pen; the stroke is as thick as the brush pressure and the line alongthe bottom plots the pressure along the stroke. Good for checking a light touch and a full press.@@ -106,7 +109,7 @@ The settings and the curve are in `src/core/Tablet.h` (unit tests: `tests/test_thandling and the preferences panel in `src/app/Tablet.cpp`. UI tests drive a simulated pen with real SDL penevents plus the mouse events SDL 3.2 synthesizes from them (which the app ignores: it makes the pen's mouse eventsitself, `App::penMouseEvents`): `pen_stroke`, `pen_drag_item`, `pen_button`, `pen_hover`, `pen_enter`, `pen_drag`,-`pen_pressure`, `pen_out`, `pen_new`, `pen_lost`, `pen_stream`, `sdl_pen_mouse`, `tablet_plug` and `tablet_unplug`+`pen_pressure`, `pen_tap`, `pen_out`, `pen_new`, `pen_lost`, `pen_stream`, `sdl_pen_mouse`, `tablet_plug` and `tablet_unplug`(documented in `src/app/UiTest.cpp`); `tests/ui/pen_ui_windows.sfui` replays #95 (pen taps on brushes, out ofrange and back, a second brush, back to the canvas) for Windows Ink, a Huion-style pen + mouse stream, SDL's stuckpen state and Wintab-style mouse input; `tests/ui/tablet.sfui`diff --git a/src/app/App.cpp b/src/app/App.cppindex 835c0fdf..4f3573c1 100644--- a/src/app/App.cpp+++ b/src/app/App.cpp@@ -1945,6 +1945,11 @@ void App::onMouseMove(float x, float y, float dx, float dy, bool fromPen) {return;}}+ // Preferences > Tablet > View speed: the pen's view drags (tip or side button) by its own amount per pixel.+ if (fromPen && (drag_ == Drag::Orbit || drag_ == Drag::Pan || drag_ == Drag::Zoom)) {+ dx *= uiPrefs_.tablet.viewSpeed;+ dy *= uiPrefs_.tablet.viewSpeed;+ }switch (drag_) {case Drag::Stroke: strokeTo(x, y); break;case Drag::Orbit: orbitBy(x, y, dx, dy); break;diff --git a/src/app/I18nSimplifiedChinese.cpp b/src/app/I18nSimplifiedChinese.cppindex 2e024c4c..4700e7ff 100644--- a/src/app/I18nSimplifiedChinese.cpp+++ b/src/app/I18nSimplifiedChinese.cpp@@ -572,6 +572,11 @@ constexpr Entry kSimplifiedChinese[] = {{"Mouse & pen", "鼠标与笔"},{"Mouse mode (relative)", "鼠标模式(相对)"},{"Mouse mode", "鼠标模式"},+ {"View speed", "视图速度"},+ {"View speed %.2f", "视图速度 %.2f"},+ {"How far the pen turns, pans and zooms the view, against the mouse's 1.00. A tablet spreads its whole area over "+ "the screen, so a short pen movement crosses many pixels: if the view spins too fast with the pen, turn this down.",+ "笔旋转、平移和缩放视图的幅度,相对于鼠标的 1.00。数位板把整个区域映射到屏幕上,笔移动一小段就会跨过很多像素:如果用笔时视图转得过快,请调低此值。"},{"Pressure curve", "压力曲线"},{"Pressure test", "压力测试"},{"Pressure meter", "压力计"},@@ -3069,9 +3074,9 @@ constexpr Entry kSimplifiedChinese[] = {{"What the pen's eraser end does. Invert: brushes subtract, like holding Alt (with Ctrl it erases mask). Erase ""mask: removes mask wherever it draws.","笔尾橡皮擦的功能。反转:笔刷改为减去,如同按住 Alt(搭配 Ctrl 则擦除遮罩)。擦除遮罩:在绘制处移除遮罩。"},- {"Eraser: Invert; lower button: Right-click; upper button: Invert (Alt); third button: Pan view. The curve and "- "Mouse mode stay.",- "橡皮擦:反转;下方按钮:右键单击;上方按钮:反转 (Alt);第三个按钮:平移视图。曲线与鼠标模式保持不变。"},+ {"Eraser: Invert; lower button: Right-click; upper button: Invert (Alt); third button: Pan view; View speed 1.00. "+ "The curve and Mouse mode stay.",+ "橡皮擦:反转;下方按钮:右键单击;上方按钮:反转 (Alt);第三个按钮:平移视图;视图速度 1.00。曲线与鼠标模式保持不变。"},{"These settings save themselves.", "这些设置会自动保存。"},// --- UserGuide.cpp (tools/i18n/coverage.py) ---{"Go back to the page you were reading.", "回到你正在阅读的页面。"},diff --git a/src/app/I18nSpanish.cpp b/src/app/I18nSpanish.cppindex 3cbb366c..54653c4c 100644--- a/src/app/I18nSpanish.cpp+++ b/src/app/I18nSpanish.cpp@@ -701,6 +701,13 @@ constexpr Entry kSpanish[] = {{"Mouse & pen", "Ratón y lápiz"},{"Mouse mode (relative)", "Modo ratón (relativo)"},{"Mouse mode", "Modo ratón"},+ {"View speed", "Velocidad de vista"},+ {"View speed %.2f", "Velocidad de vista %.2f"},+ {"How far the pen turns, pans and zooms the view, against the mouse's 1.00. A tablet spreads its whole area over "+ "the screen, so a short pen movement crosses many pixels: if the view spins too fast with the pen, turn this down.",+ "Cuánto gira, desplaza y acerca la vista el lápiz, frente al 1.00 del ratón. Una tableta reparte toda su área "+ "sobre la pantalla, así que un movimiento corto del lápiz recorre muchos píxeles: si la vista gira demasiado rápido "+ "con el lápiz, bájalo."},{"Pressure curve", "Curva de presión"},{"Pressure test", "Prueba de presión"},{"Pressure meter", "Medidor de presión"},@@ -3497,10 +3504,10 @@ constexpr Entry kSpanish[] = {"mask: removes mask wherever it draws.","Lo que hace la goma del lápiz. Invertir: los pinceles restan, como mantener Alt (con Ctrl borra máscara). ""Borrar máscara: quita máscara por donde dibuja."},- {"Eraser: Invert; lower button: Right-click; upper button: Invert (Alt); third button: Pan view. The curve and "- "Mouse mode stay.",+ {"Eraser: Invert; lower button: Right-click; upper button: Invert (Alt); third button: Pan view; View speed 1.00. "+ "The curve and Mouse mode stay.","Borrador: Invertir; botón inferior: Clic derecho; botón superior: Invertir (Alt); tercer botón: Desplazar "- "vista. La curva y el modo Ratón se quedan."},+ "vista; Velocidad de vista 1.00. La curva y el modo Ratón se quedan."},// --- UserGuide.cpp (tools/i18n/coverage.py) ---{"Go back to the page you were reading.", "Vuelve a la página que estabas leyendo."},{"Back (Alt+Left)", "Atrás (Alt+Izquierda)"},diff --git a/src/app/I18nTraditionalChinese.cpp b/src/app/I18nTraditionalChinese.cppindex b33f8707..f624323e 100644--- a/src/app/I18nTraditionalChinese.cpp+++ b/src/app/I18nTraditionalChinese.cpp@@ -572,6 +572,11 @@ constexpr Entry kTraditionalChinese[] = {{"Mouse & pen", "滑鼠與筆"},{"Mouse mode (relative)", "滑鼠模式(相對)"},{"Mouse mode", "滑鼠模式"},+ {"View speed", "視圖速度"},+ {"View speed %.2f", "視圖速度 %.2f"},+ {"How far the pen turns, pans and zooms the view, against the mouse's 1.00. A tablet spreads its whole area over "+ "the screen, so a short pen movement crosses many pixels: if the view spins too fast with the pen, turn this down.",+ "筆旋轉、平移和縮放視圖的幅度,相對於滑鼠的 1.00。繪圖板把整個區域對應到螢幕上,筆移動一小段就會跨過很多像素:如果用筆時視圖轉得過快,請調低此值。"},{"Pressure curve", "壓力曲線"},{"Pressure test", "壓力測試"},{"Pressure meter", "壓力計"},@@ -3069,9 +3074,9 @@ constexpr Entry kTraditionalChinese[] = {{"What the pen's eraser end does. Invert: brushes subtract, like holding Alt (with Ctrl it erases mask). Erase ""mask: removes mask wherever it draws.","筆尾橡皮擦的功能。反轉:筆刷改為減去,如同按住 Alt(搭配 Ctrl 則擦除遮罩)。擦除遮罩:在繪製處移除遮罩。"},- {"Eraser: Invert; lower button: Right-click; upper button: Invert (Alt); third button: Pan view. The curve and "- "Mouse mode stay.",- "橡皮擦:反轉;下方按鈕:右鍵按一下;上方按鈕:反轉 (Alt);第三個按鈕:平移視圖。曲線與滑鼠模式保持不變。"},+ {"Eraser: Invert; lower button: Right-click; upper button: Invert (Alt); third button: Pan view; View speed 1.00. "+ "The curve and Mouse mode stay.",+ "橡皮擦:反轉;下方按鈕:右鍵按一下;上方按鈕:反轉 (Alt);第三個按鈕:平移視圖;視圖速度 1.00。曲線與滑鼠模式保持不變。"},{"These settings save themselves.", "這些設定會自動儲存。"},// --- UserGuide.cpp (tools/i18n/coverage.py) ---{"Go back to the page you were reading.", "回到你正在閱讀的頁面。"},diff --git a/src/app/Tablet.cpp b/src/app/Tablet.cppindex 5bbc3ced..8afc3450 100644--- a/src/app/Tablet.cpp+++ b/src/app/Tablet.cpp@@ -531,6 +531,13 @@ void App::drawTabletSection() {"lifting it and putting it down elsewhere leaves the cursor where it was. Off (Pen mode): the cursor ""is where the pen is.",path);+ ImGui::SetNextItemWidth(-FLT_MIN);+ ui::SliderInside("##tablet_view_speed", &t.viewSpeed, 0.1f, 2.0f, "View speed %.2f");+ ui::HelpText("View speed", nullptr,+ "How far the pen turns, pans and zooms the view, against the mouse's 1.00. A tablet spreads its "+ "whole area over the screen, so a short pen movement crosses many pixels: if the view spins too "+ "fast with the pen, turn this down.",+ path);// --- Live pressure ---const float raw = penTracker_.raw(), curved = t.curve.apply(raw);@@ -710,7 +717,7 @@ void App::drawTabletSection() {t.mouseMode = mouseMode;}ui::HelpText("Tablet defaults", nullptr, "Eraser: Invert; lower button: Right-click; upper button: Invert (Alt); third "- "button: Pan view. The curve and Mouse mode stay.", path);+ "button: Pan view; View speed 1.00. The curve and Mouse mode stay.", path);ImGui::PushStyleColor(ImGuiCol_Text, col(ui::color::textDim));ImGui::PushTextWrapPos(0.0f);ImGui::TextUnformatted(tr("These settings save themselves."));diff --git a/src/app/UiTest.cpp b/src/app/UiTest.cppindex d9a47989..68ae6812 100644--- a/src/app/UiTest.cpp+++ b/src/app/UiTest.cpp@@ -1169,6 +1169,7 @@ double Demo::query(const std::string& name, bool& known) const {if (name == "brush_pressure") return app_.strokePressure();if (name == "stroking") return app_.drag_ == App::Drag::Stroke ? 1.0 : 0.0;if (name == "tablet_mouse_mode") return app_.uiPrefs_.tablet.mouseMode ? 1.0 : 0.0;+ if (name == "tablet_view_speed") return double(app_.uiPrefs_.tablet.viewSpeed);if (name == "perf_trace") return perftrace::on() ? 1.0 : 0.0; // Help > Record a performance traceif (name == "perf_trace_long_frames" || name == "perf_trace_strokes" || name == "perf_trace_commands") {std::ifstream in(std::filesystem::path(std::u8string(reinterpret_cast<const char8_t*>(perftrace::path().data()),@@ -2649,6 +2650,28 @@ bool Demo::parseStep(int line, const std::vector<std::string>& w, std::string& e++testPen_;});wait(0.1f);+ } else if (verb == "pen_tap") {+ // pen_tap LABEL [enter]: a quick tap on the item, down and up within one frame (a pen's tap is often shorter+ // than a frame at 240 samples a second); enter: the pen only now comes into range there, no hover before it.+ if (!need(1)) return false;+ const std::string label = w[1];+ const bool enter = std::find(w.begin() + 2, w.end(), "enter") != w.end();+ auto centre = std::make_shared<ImVec2>();+ steps_.push_back([this, line, label, centre](float t) {+ if (findItem(label, *centre)) return true;+ if (t > 3.0f) fail(line, notFound(label));+ return t > 3.0f;+ });+ run([this, centre, enter] {+ if (enter && penIn_) penProximity(false);+ if (!penIn_) penProximity(true);+ penMove(centre->x, centre->y);+ penTouch(true, false);+ penPressure(0.3f);+ penTouch(false, false);+ penPressure(0.0f);+ });+ wait(0.1f);} else if (verb == "pen_button") {if (!need(2)) return false;const int button = int(num(1, 1));@@ -3286,7 +3309,7 @@ bool Demo::loadScript(const std::string& path, std::string& error) {"click_part", "drag", "button_drag", "drag_landmark", "gizmo_hover", "gizmo_drag", "stroke_popup_item","drag_item", "drag_path", "release", "orbit", "camera", "zoom", "camera_distance", "brush_size", "look","run", "wait", "wait_idle", "wait_for", "wait_value", "pen_stroke", "pen_drag_item", "pen_button", "pen_hover",- "pen_enter", "pen_drag", "pen_pressure", "pen_new", "pen_out", "pen_rest", "wheel", "mouse_move",+ "pen_enter", "pen_drag", "pen_pressure", "pen_new", "pen_out", "pen_rest", "pen_tap", "wheel", "mouse_move","touch_stroke", "touch_pinch", "classic_keys", "input_style"};if (!allowed.count(verb)) {error = scriptName_ + ":" + std::to_string(n) + ": '" + verb +diff --git a/src/core/Tablet.cpp b/src/core/Tablet.cppindex 56a8f51c..66f44c18 100644--- a/src/core/Tablet.cpp+++ b/src/core/Tablet.cpp@@ -74,6 +74,7 @@ Json toJson(const TabletSettings& t) {for (PenAction a : t.buttons) buttons.push(std::string(penActionId(a)));j.set("buttons", buttons);j.set("mouseMode", t.mouseMode);+ j.set("viewSpeed", double(t.viewSpeed));return j;}@@ -98,6 +99,7 @@ void fromJson(const Json& j, TabletSettings& t) {if (a != PenAction::EraseMask) t.buttons[i] = a;}t.mouseMode = j["mouseMode"].asBool(t.mouseMode);+ t.viewSpeed = std::clamp(float(j["viewSpeed"].asNumber(t.viewSpeed)), 0.1f, 2.0f);}void PenPressureTracker::sample(float pressure) {diff --git a/src/core/Tablet.h b/src/core/Tablet.hindex 6bac3132..6751193d 100644--- a/src/core/Tablet.h+++ b/src/core/Tablet.h@@ -62,6 +62,10 @@ struct TabletSettings {// Mouse mode (#54): the tablet driver is set to move the cursor relatively, like a mouse, so the pen's// reported position isn't where the cursor is (PenCursor).bool mouseMode = false;+ // How far the pen turns, pans and zooms the view per pixel, against the mouse's 1 (0.1 - 2). A tablet maps+ // its whole area onto the screen, so a short pen movement crosses many pixels and the view seemed to spin+ // (GonzaloHernandez3D, Huion on Windows): turn it down to taste.+ float viewSpeed = 1.0f;};Json toJson(const TabletSettings& t);diff --git a/tests/test_tablet.cpp b/tests/test_tablet.cppindex 3ff382d5..66a3e06a 100644--- a/tests/test_tablet.cpp+++ b/tests/test_tablet.cpp@@ -254,6 +254,21 @@ TEST(tablet_settings_mouse_mode_round_trip) {CHECK(!d.mouseMode);}+TEST(tablet_settings_view_speed_round_trip) {+ TabletSettings t;+ CHECK(near(t.viewSpeed, 1.0f)); // the pen navigates as the mouse until turned down+ t.viewSpeed = 0.4f;+ TabletSettings back;+ fromJson(toJson(t), back);+ CHECK(near(back.viewSpeed, 0.4f));+ Json j;+ std::string err;+ CHECK(Json::parse(R"({"viewSpeed":0})", j, err)); // out of range: clamped, the view still moves+ TabletSettings d;+ fromJson(j, d);+ CHECK(near(d.viewSpeed, 0.1f));+}+// A pen without a pressure axis (Windows Ink off) sends 0 while touching: after a few motions it draws at full// pressure instead of never starting the stroke; a pen with pressure never does.TEST(pen_pressure_tracker_no_pressure_axis) {diff --git a/tests/ui/pen_quick_taps.sfui b/tests/ui/pen_quick_taps.sfuinew file mode 100644index 00000000..b24c0efd--- /dev/null+++ b/tests/ui/pen_quick_taps.sfui@@ -0,0 +1,98 @@+# A Huion tablet on Windows (GonzaloHernandez3D on Reddit, with a Razer Tartarus keypad): menus and buttons took+# several pen taps before one worked (the mouse's first click always did), and orbiting with the pen turned the+# view far faster than the mouse. Every pen tap below is a single tap, down and up within one frame, often with the+# pen only just come into range over the item; each must work the first time. Then the same drag on the+# background turns the view by the same angle with the pen tip and with the mouse, unless Preferences > Tablet >+# View speed says otherwise.+run new_sphere subdivisions=4+key f++# Huion's stream: the pen's events plus the driver's own mouse events (a press at each touch, never released).+pen_stream huion+sdl_pen_mouse on+pen_tap "Clay##brush.clay" enter+expect_value brush_type == 1+pen_tap "Inflate##brush.inflate"+expect_value brush_type == 4+pen_tap "Standard##brush.standard" enter+expect_value brush_type == 0+expect_value ui_left_down == 0++# A menu and one of its items, tap after tap, the pen leaving range between them.+pen_tap "View##menu.view" enter+wait 0.2+expect "Floor grid##render"+pen_tap "Floor grid##render"+expect_value floor_grid == 1+key escape # (the toggle keeps its menu open)+pen_out+pen_tap "View##menu.view" enter+wait 0.2+expect "Floor grid##render"+pen_tap "Floor grid##render" enter+expect_value floor_grid == 0+key escape+pen_tap "Help##menu.help" enter+wait 0.2+expect "User Guide##help.guide"+key escape+expect_value ui_left_down == 0++# Windows Ink alone (SDL's pen mouse events, which the app ignores): the same taps.+pen_stream ink+pen_tap "Clay##brush.clay" enter+expect_value brush_type == 1+pen_tap "View##menu.view" enter+wait 0.2+expect "Floor grid##render"+pen_tap "Floor grid##render"+expect_value floor_grid == 1+key escape+pen_tap "View##menu.view"+wait 0.2+pen_tap "Floor grid##render"+expect_value floor_grid == 0+key escape+pen_out++# Orbit: the pen tip on the background turns the view by the same angle per pixel as the mouse, with each stream.+run ui_look look=classic layout=classic # (its background beside the model, as pen_navigation.sfui)+snapshot+camera 0 0+drag 0.12 0.3 0.12 0.5+remember camera_pitch mouse+expect_value camera_pitch < -20+expect_value moved == 0+camera 0 0+pen_drag 0.12 0.3 0.12 0.5+expect_value camera_pitch >= $mouse-0.5+expect_value camera_pitch <= $mouse+0.5+pen_out+pen_stream huion+camera 0 0+pen_drag 0.12 0.3 0.12 0.5+expect_value camera_pitch >= $mouse-0.5+expect_value camera_pitch <= $mouse+0.5+expect_value moved == 0+pen_out+pen_stream ink+expect_value stroking == 0++# Preferences > Tablet > View speed turned down: the pen turns the view that much less, the mouse as before.+expect_value tablet_view_speed == 1+click "Preferences##palette.preferences"+click "Tablet##preferences.tablet"+drag_item "##tablet_view_speed" -2000 0+expect_value tablet_view_speed < 0.11+shot view-speed+key escape+camera 0 0+pen_drag 0.12 0.3 0.12 0.5+expect_value camera_pitch < 0+expect_value camera_pitch > $mouse*0.15+pen_out+camera 0 0+drag 0.12 0.3 0.12 0.5+expect_value camera_pitch >= $mouse-0.5+expect_value camera_pitch <= $mouse+0.5+expect_value moved == 0