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
SpaceMouse echo: the wheel held 0.3 s after the cap rests, not 1.5 s
islandmed2dbc33a9cd19
diff --git a/changes/fix-spacemouse-tilt.md b/changes/fix-spacemouse-tilt.mdindex 45dbe480..c06fb196 100644--- a/changes/fix-spacemouse-tilt.md+++ b/changes/fix-spacemouse-tilt.md@@ -1,9 +1,10 @@---fixed: **SpaceMouse**: turning the cap slowly no longer ends in a zoom that flies the view away (3DxWare's scrolling got- through while the cap was inside the dead zone, and its momentum after the cap was let go). Thanks @fenixpoints.+ through while the cap was inside the dead zone, and just after the cap was let go). Thanks @fenixpoints.testers:- macOS with 3DxWare installed: twist and tilt the cap slowly, then let go; the view only turns, never zooms.- - Any OS: right after letting go of the cap the mouse cursor moves at once; the mouse wheel zooms again after about 1.5 s.+ - Any OS: right after letting go of the cap the mouse cursor moves at once; the mouse wheel zooms again+ after 0.3 s (a wheel turned in that moment is ignored: tell us if that gets in the way).---fenix (Discord 11-06, SpaceMouse Compact, macOS): a slow rotation of the cap first turned the view, then zoomed itaway. tests/ui/spacemouse_tilt.sfui fails without the fix (distance 6.34 -> 2.98).diff --git a/src/app/App.h b/src/app/App.hindex e9678149..a6092b8c 100644--- a/src/app/App.h+++ b/src/app/App.h@@ -2558,7 +2558,7 @@ private:// and wheel meanwhile are the driver's echo of it (3DxWare's mouse emulation), not the user (spaceMouseEcho).bool spaceMousePushed_ = false;// Seconds since the cap was last stirred (spaceMouseStirred: inside the dead zone too) at the last read, and when- // that read was: the driver's scrolling (momentum) lasts kSpaceMouseEchoHold past it.+ // that read was: the driver's scroll may trail it by kSpaceMouseEchoHold past it.float spaceMouseQuiet_ = 1e9f;Uint64 spaceMouseReadNs_ = 0;bool spaceMouseEcho(const SDL_Event& e) const;diff --git a/src/app/Demo.h b/src/app/Demo.hindex d3ae6f48..b5d906eb 100644--- a/src/app/Demo.h+++ b/src/app/Demo.h@@ -207,7 +207,7 @@ private:// spacemouse_echo on: while the virtual cap is pushed, a SpaceMouse driver that doesn't know the app (3DxWare's// defaults) moves the system pointer and scrolls the wheel every frame (fenix, Discord 11-06).// spacemouse_echo scroll: as macOS 3DxWare scrolls for an app it doesn't know: the wheel from the cap's first stir- // (inside the app's dead zone), by the cap's push, and on with the scroll's momentum for a second after it is let+ // (inside the app's dead zone), by the cap's push, and on for a quarter second after it is let// go; no pointer motion (a slow tilt zoomed the view away, fenix 11-06).bool spaceMouseEcho_ = false, spaceMouseScrollEcho_ = false;float scrollMomentum_ = 0.0f, scrollMomentumLeft_ = 0.0f;diff --git a/src/app/SpaceMouse.cpp b/src/app/SpaceMouse.cppindex db7e9963..c4c12702 100644--- a/src/app/SpaceMouse.cpp+++ b/src/app/SpaceMouse.cpp@@ -227,7 +227,7 @@ void App::regrabAfterViewMove() {// A SpaceMouse driver that doesn't know SculptForge (3DxWare's defaults) also moves the system pointer or scrolls the// wheel while the cap is pushed: the cursor jumped from the pen to wherever the driver put it, and the wheel zoomed// toward it (fenix, Discord 11-06). While the cap moves the view, only the pen and touch move the cursor; a mouse's-// buttons still click. It starts inside the dead zone and its scrolling's momentum outlasts the cap: a slow tilt+// buttons still click. It starts inside the dead zone and its last scroll events may trail the cap: a slow tilt// zoomed the view away (fenix, 11-06), so the echo counts from the cap's first stir, its wheel until kSpaceMouseEchoHold// after.bool App::spaceMouseEcho(const SDL_Event& e) const {@@ -240,7 +240,7 @@ bool App::spaceMouseEcho(const SDL_Event& e) const {// the frame reads the axes.)if (!spaceMouse_) return false;if (spaceMousePushed_ || spaceMouseStirred(readAxes(spaceMouse_), uiPrefs_.spaceMouse)) return true;- // Only the scrolling outlasts the cap (momentum): a mouse picked up as the cap is let go moves the cursor at once.+ // Only the scrolling may trail the cap: a mouse picked up as the cap is let go moves the cursor at once.if (e.type != SDL_EVENT_MOUSE_WHEEL) return false;// (Plus the time since that read: a loop that slept while idle reads the cap again only after this event.)const float sinceRead = spaceMouseReadNs_ ? float(double(SDL_GetTicksNS() - spaceMouseReadNs_) * 1e-9) : 0.0f;diff --git a/src/app/UiTest.cpp b/src/app/UiTest.cppindex bbb57a30..4a0446a4 100644--- a/src/app/UiTest.cpp+++ b/src/app/UiTest.cpp@@ -287,7 +287,7 @@// spacemouse_echo on|off while the cap is pushed, the system pointer drifts and the wheel scrolls every frame, as// a SpaceMouse driver does for an app it doesn't know (3DxWare's defaults; fenix 11-06);// scroll: only the wheel, from the cap's first stir (inside the dead zone) and on for a-// second after it is let go (macOS momentum; fenix's slow tilt, 11-06)+// quarter second after it is let go (stragglers; fenix's slow tilt, 11-06)// spacemouse_unplug unplug it// expect_value spacemouse_connected (1 when the app opened it), spacemouse_moving (1 while it moves the view)// ui_scale PERCENT | auto Preferences > Interface > UI scale (applied live, #87); display_scale PERCENT: the display's@@ -2971,7 +2971,7 @@ void Demo::spaceMouseEchoFrame(float dt) {if (std::abs(a) > std::abs(push)) push = a;if (std::abs(push) > 0.01f) {scrollMomentum_ = push * 3.0f; // wheel steps per frame, as the driver's scrolling accelerates- scrollMomentumLeft_ = 1.0f;+ scrollMomentumLeft_ = 0.25f;} else {scrollMomentumLeft_ -= dt;if (scrollMomentumLeft_ <= 0.0f) return;diff --git a/src/core/SpaceMouse.h b/src/core/SpaceMouse.hindex 72acc6f8..ad9471d3 100644--- a/src/core/SpaceMouse.h+++ b/src/core/SpaceMouse.h@@ -70,11 +70,13 @@ constexpr float kSpaceMouseZoomRate = 6.0f; // Camera::zoom steps (x0.46 of theconstexpr float kSpaceMouseMaxStep = 0.1f; // seconds: a stalled frame doesn't throw the view// A SpaceMouse driver that doesn't know the app (3DxWare's defaults) scrolls the wheel and moves the system pointer-// from the cap's first stir, well inside our dead zone, and macOS carries its scrolling on (momentum) after the cap-// is let go: a slow tilt zoomed the view away (fenix, Discord 11-06). The cap counts as stirred past half the dead+// from the cap's first stir, well inside our dead zone, and its last scroll events may come just after the cap is+// let go: a slow tilt zoomed the view away (fenix, Discord 11-06). The cap counts as stirred past half the dead// zone (a cap that rests a little off centre has its dead zone raised, so its own noise never counts): pointer and// wheel events from anything but the pen are the driver's echo meanwhile, the wheel also for this long after.-constexpr float kSpaceMouseEchoHold = 1.5f; // seconds+// Short: a real wheel turned this soon after the cap is dropped too (SDL gives the driver's scroll and the mouse's the+// same id). Longer only if a real driver's scroll is seen to go on after the cap rests.+constexpr float kSpaceMouseEchoHold = 0.3f; // secondsbool spaceMouseStirred(const std::array<float, kSmAxes>& axes, const SpaceMouseSettings& s);// An axis value (-1 .. 1) after the dead zone: 0 inside it, rescaled so the rest of the travel still reaches 1.diff --git a/tests/ui/spacemouse_pen.sfui b/tests/ui/spacemouse_pen.sfuiindex ebf9233a..01751063 100644--- a/tests/ui/spacemouse_pen.sfui+++ b/tests/ui/spacemouse_pen.sfui@@ -112,11 +112,11 @@ pen_liftpen_rest offkey ctrl+z-# Without the cap pushed the mouse and its wheel work as ever (the wheel once the driver's scroll momentum would be-# over, kSpaceMouseEchoHold after the cap last moved: spacemouse_tilt.sfui).+# Without the cap pushed the mouse and its wheel work as ever (the wheel kSpaceMouseEchoHold, 0.3 s, after the cap+# last moved: spacemouse_tilt.sfui).pen_outspacemouse_echo off-wait 1.5+wait 0.4key fremember camera_distance d3wheel 0.5 0.5 2diff --git a/tests/ui/spacemouse_tilt.sfui b/tests/ui/spacemouse_tilt.sfuiindex 95b77728..3ae24e9d 100644--- a/tests/ui/spacemouse_tilt.sfui+++ b/tests/ui/spacemouse_tilt.sfui@@ -17,7 +17,7 @@ spacemouse 0 0 0 0.06 0 0 1.0expect_value camera_pitch == 0expect_value camera_distance >= $d0-0.0001expect_value camera_distance <= $d0+0.0001-# ... then past it, held, and let go; the driver's scroll carries on for a second after.+# ... then past it, held, and let go; the driver's scroll straggles on a moment after.spacemouse 0 0 0 0.3 0 0 2.0wait 1.2expect_value camera_pitch < -10