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
Preferences > Input > Hold Space and drag to move the camera (#43, off by default): Space+left orbits, Space+right/middle pans, Space+Ctrl zooms, never while typing; unit and UI tests (key_down / key_up harness verbs)
islandmedcee1da979a3a
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 59c5e294..f71bae86 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -28,6 +28,9 @@ All notable changes to SculptForge are listed here. The format followstriangles exactly; the rest is rebuilt and, for the remeshers, joined to them along the mask's edge with astrip of triangles so the model stays closed (`keep_masked=true` on `remesh`, `decimate`, `qremesh`).- Triple-click another SubTool in the viewport to make it the active one and frame it (#43).+- **Preferences > Input > Hold Space and drag to move the camera** (#43, off by default since ZBrush's Space opens+ the QuickMenu): with Space held, left-drag rotates, right- or middle-drag pans and Ctrl+drag zooms, anywhere on+ the canvas; never while typing in a text field.- SubTool thumbnails in the SubTool list (#43), drawn from each SubTool's existing GPU buffers (no upload, themotion proxy on dense meshes), one per frame at most and only once a change has settled, never during a stroke.diff --git a/docs/guide/interface.md b/docs/guide/interface.mdindex d37aa327..07bf7320 100644--- a/docs/guide/interface.md+++ b/docs/guide/interface.md@@ -442,7 +442,9 @@ the numpad views and Blender's sculpt-mode keys (see [Blender keys](shortcuts.mdstyle, **Emulate Numpad** makes the number row work as the numpad, and **Import Blender keymap...** takes the keysfrom a keymap you exported in Blender. **Right click opens the QuickMenu** (on by default, in every style) opensthe [QuickMenu](sculpting.md#the-quickmenu) with a right click on the canvas; a right drag navigates either-way. **Cursor follows surface** (on by default) lays the brush rings on the model under the pointer (see+way. **Hold Space and drag to move the camera** (off by default) turns <kbd>Space</kbd> into a camera key: held,+left-drag rotates, right- or middle-drag pans and <kbd>Ctrl</kbd>+drag zooms (see+[Navigation](navigation.md#mouse-and-pen)). **Cursor follows surface** (on by default) lays the brush rings on the model under the pointer (see[Draw Size and Focal Shift](sculpting.md#draw-size-z-intensity-rgb-intensity-and-focal-shift)); off, they are flat circles on the screen. **Rotation** chooses free rotation (ZBrush) or a turntable. See[Coming from ZBrush](coming-from-zbrush.md).diff --git a/docs/guide/navigation.md b/docs/guide/navigation.mdindex 0bc201dc..d21885a9 100644--- a/docs/guide/navigation.md+++ b/docs/guide/navigation.md@@ -51,10 +51,15 @@ camera.| Orthographic on or off | <kbd>Numpad 5</kbd> || Turn in 15 degree steps | <kbd>Numpad 4</kbd> / <kbd>Numpad 6</kbd> (around), <kbd>Numpad 8</kbd> / <kbd>Numpad 2</kbd> (over); <kbd>Numpad 9</kbd>: the other side || Frame the active SubTool | <kbd>Numpad .</kbd> |+| Frame one SubTool | <kbd>Shift</kbd>+<kbd>Alt</kbd>+click it, or triple-click another SubTool (it becomes the active SubTool) |+| Move the camera with Space held | Turn on **Preferences > Input > Hold Space and drag to move the camera**, then hold <kbd>Space</kbd>: left-drag rotates, right- or middle-drag pans, <kbd>Ctrl</kbd>+drag zooms, anywhere on the canvas (on the model too) |Zoom drags go the ZBrush way: drag up to zoom out, down to zoom in. The SculptForge input style(**Preferences > Input**) reverses them: drag up to come closer.-| Frame one SubTool | <kbd>Shift</kbd>+<kbd>Alt</kbd>+click it, or triple-click another SubTool (it becomes the active SubTool) |++**Hold Space and drag to move the camera** is off by default, because in ZBrush <kbd>Space</kbd> opens the+QuickMenu. With it on, <kbd>Space</kbd> no longer opens the QuickMenu (a right click still does), and a space typed in+a text field is never taken."Background" means any part of the canvas where the cursor isn't over the model. A left-drag that starts onthe model sculpts instead, so with a pen or a one-button mouse, start rotations beside the model. When thediff --git a/src/app/App.cpp b/src/app/App.cppindex 314b6405..32c25ef4 100644--- a/src/app/App.cpp+++ b/src/app/App.cpp@@ -2,6 +2,7 @@// SPDX-License-Identifier: GPL-3.0-or-later#include "app/App.h"#include "app/ShellQuote.h"+#include "app/SpaceCamera.h"#include "app/AsyncStroke.h"#include "app/Calibration.h"#include "app/CrashLog.h"@@ -1063,6 +1064,9 @@ void App::handleEvent(const SDL_Event& event) {case SDL_EVENT_WINDOW_CLOSE_REQUESTED:if (e.window.windowID == SDL_GetWindowID(window_)) requestQuit();break;+ case SDL_EVENT_WINDOW_FOCUS_LOST:+ spaceHeld_ = false; // Space let go in another window never reaches us+ break;case SDL_EVENT_PEN_PROXIMITY_IN:case SDL_EVENT_PEN_PROXIMITY_OUT:case SDL_EVENT_PEN_DOWN:@@ -1095,11 +1099,17 @@ void App::handleEvent(const SDL_Event& event) {if (!io.WantCaptureMouse && canvasRect().contains(e.wheel.mouse_x, e.wheel.mouse_y)) camera_.zoom(e.wheel.y);break;case SDL_EVENT_KEY_DOWN:+ if (e.key.key == SDLK_SPACE && !e.key.repeat && // hold Space and drag: the camera (#43; not while typing)+ spaceCameraKeyDown(uiPrefs_.spaceCamera, io.WantTextInput || io.WantCaptureKeyboard)) {+ spaceHeld_ = true;+ break;+ }if (!io.WantCaptureKeyboard && !e.key.repeat) onKey(e.key.key, e.key.mod);else if (!io.WantCaptureKeyboard && (e.key.key == SDLK_LEFTBRACKET || e.key.key == SDLK_RIGHTBRACKET))onKey(e.key.key, e.key.mod);break;case SDL_EVENT_KEY_UP:+ if (e.key.key == SDLK_SPACE) spaceHeld_ = false;if (e.key.key == SDLK_SPACE) quickMenuKeyUp(); // a held Space closes the QuickMenu when let gobreak;case SDL_EVENT_DROP_FILE:@@ -1146,6 +1156,18 @@ void App::onMouseDown(float x, float y, Uint8 button) {rightClick_.x = x;rightClick_.y = y;rightClick_.dx = rightClick_.dy = 0.0f;+ if (spaceHeld_) { // Preferences > Input > Hold Space and drag to move the camera (#43)+ switch (spaceCameraMove(button, ctrlDown(SDL_GetModState()))) {+ case SpaceCameraMove::Orbit: drag_ = Drag::Orbit; break;+ case SpaceCameraMove::Pan: drag_ = Drag::Pan; break;+ case SpaceCameraMove::Zoom: drag_ = Drag::Zoom; break;+ case SpaceCameraMove::None: break;+ }+ if (drag_ != Drag::None) {+ rightClick_.pending = false;+ return;+ }+ }if (blenderStyle() && blenderNavigationDown(button)) return; // middle / Alt+left / right drags navigateif (mayaStyle() && mayaNavigationDown(button)) return; // Alt+left / middle / right: orbit / pan / zoomif (button == SDL_BUTTON_LEFT) {diff --git a/src/app/App.h b/src/app/App.hindex 0281625b..295a80c1 100644--- a/src/app/App.h+++ b/src/app/App.h@@ -969,6 +969,7 @@ private:int subtoolClickTarget_ = -1;bool subtoolClickFrame_ = false; // Shift+Alt+click: frame the SubTool as wellint mouseClicks_ = 1; // SDL's click count of the press being handled (3 = a triple-click, #43)+ bool spaceHeld_ = false; // Space is down with Preferences > Input > Hold Space to move the camera on (#43)float subtoolClickX_ = 0.0f, subtoolClickY_ = 0.0f;uint32_t renamingSubtool_ = 0; // SubTool id being renamed inline (0: none)uint32_t listedActiveSubtool_ = 0; // the list scrolls to the active SubTool when it changesdiff --git a/src/app/Config.cpp b/src/app/Config.cppindex 1bee3ab9..4f4b8c33 100644--- a/src/app/Config.cpp+++ b/src/app/Config.cpp@@ -52,6 +52,7 @@ Json toJson(const UiPrefs& p) {j.set("inputStyle", std::string(p.inputStyle == 3 ? "maya" : p.inputStyle == 2 ? "blender" : p.inputStyle == 1 ? "sculptforge" : "zbrush"));j.set("emulateNumpad", p.emulateNumpad);j.set("rightClickQuickMenu", p.rightClickQuickMenu);+ j.set("spaceCamera", p.spaceCamera);j.set("cursorFollowsSurface", p.cursorFollowsSurface);j.set("showAxes", p.showAxes);j.set("alphabeticalPalettes", p.alphabeticalPalettes);@@ -90,6 +91,7 @@ void fromJson(const Json& j, UiPrefs& p) {}p.emulateNumpad = j["emulateNumpad"].asBool(p.emulateNumpad);p.rightClickQuickMenu = j["rightClickQuickMenu"].asBool(p.rightClickQuickMenu);+ p.spaceCamera = j["spaceCamera"].asBool(p.spaceCamera);p.cursorFollowsSurface = j["cursorFollowsSurface"].asBool(p.cursorFollowsSurface);p.showAxes = j["showAxes"].asBool(p.showAxes);p.alphabeticalPalettes = j["alphabeticalPalettes"].asBool(p.alphabeticalPalettes);diff --git a/src/app/Config.h b/src/app/Config.hindex 746dc117..a66de5e4 100644--- a/src/app/Config.h+++ b/src/app/Config.h@@ -34,6 +34,7 @@ struct UiPrefs {// 2 Blender (middle-drag orbit, numpad views, Blender's sculpt keys; Input.cpp)bool emulateNumpad = false; // Blender style: the 1-9 and 0 keys above the letters act as the numpad (laptops)bool rightClickQuickMenu = true; // a right click on the canvas (no drag) opens the QuickMenu, as in ZBrush (#22)+ bool spaceCamera = false; // hold Space and drag to move the camera (#43; off: Space opens the QuickMenu)bool showAxes = true; // Draw > Camera > Axes: the X / Y / Z gizmo in the canvas corner (#31)bool cursorFollowsSurface = true; // the brush ring lies on the surface under the pointer, as in SculptGL (#25)TabletSettings tablet; // Preferences > Tablet: pressure curve, eraser, pen buttonsdiff --git a/src/app/Demo.h b/src/app/Demo.hindex 00af8b85..075ab826 100644--- a/src/app/Demo.h+++ b/src/app/Demo.h@@ -97,7 +97,8 @@ private:void fail(int line, const std::string& message);bool parseStep(int line, const std::vector<std::string>& words, std::string& error);void testClick(int line, const std::string& label, int button, bool doubleClick);- void testKey(int line, const std::string& combo);+ // phase: 0 press and release, 1 press only (key_down), 2 release only (key_up).+ void testKey(int line, const std::string& combo, int phase = 0);void testKeyNow(SDL_Keycode key, SDL_Keymod mods);double query(const std::string& name, bool& known) const;diff --git a/src/app/Input.cpp b/src/app/Input.cppindex 0f5da332..625eabef 100644--- a/src/app/Input.cpp+++ b/src/app/Input.cpp@@ -145,6 +145,11 @@ void App::registerInputActions() {"does too). A right drag still turns, pans or zooms the view. A pen button set to Right click works the same.",[this] { uiPrefs_.rightClickQuickMenu = !uiPrefs_.rightClickQuickMenu; },[this] { return uiPrefs_.rightClickQuickMenu; });+ add("input.space_camera", "Hold Space and drag to move the camera", nullptr, "Preferences > Input", "",+ "While Space is held, a drag on the canvas moves the camera: left-drag turns it, right- or middle-drag pans, "+ "and with Ctrl held too a drag zooms (#43). Off by default: in ZBrush, Space opens the QuickMenu (with this "+ "on, a right click still does). Typing a space in a text field is never taken.",+ [this] { uiPrefs_.spaceCamera = !uiPrefs_.spaceCamera; }, [this] { return uiPrefs_.spaceCamera; });add("input.surface_cursor", "Cursor follows surface", nullptr, "Preferences > Input", "","The brush ring lies on the model under the pointer, turned to the surface and pressed onto its bumps, at ""the brush's real size there (as in SculptGL), with a short line along the surface's direction. With "@@ -413,6 +418,10 @@ void App::drawInputSection() {if (ui::Checkbox("Right click opens the QuickMenu##input.right_click_menu", &rightClickMenu))uiPrefs_.rightClickQuickMenu = rightClickMenu;ui::HelpAction(*this, "input.right_click_menu");+ bool spaceCamera = uiPrefs_.spaceCamera;+ if (ui::Checkbox("Hold Space and drag to move the camera##input.space_camera", &spaceCamera))+ uiPrefs_.spaceCamera = spaceCamera;+ ui::HelpAction(*this, "input.space_camera");bool surfaceCursor = uiPrefs_.cursorFollowsSurface;if (ui::Checkbox("Cursor follows surface##input.surface_cursor", &surfaceCursor))uiPrefs_.cursorFollowsSurface = surfaceCursor;diff --git a/src/app/SpaceCamera.h b/src/app/SpaceCamera.hnew file mode 100644index 00000000..1ac79d7d--- /dev/null+++ b/src/app/SpaceCamera.h@@ -0,0 +1,24 @@+// SculptForge - open source digital sculpting+// SPDX-License-Identifier: GPL-3.0-or-later+//+// Hold Space and drag to move the camera (#43; Preferences > Input, off by default since ZBrush's Space opens+// the QuickMenu): what a press does while Space is held.+#pragma once++namespace sf {++enum class SpaceCameraMove { None, Orbit, Pan, Zoom };++// `button`: 1 left, 2 middle, 3 right (SDL's numbering). Space+left orbits, Space+right or middle pans, and with+// Ctrl held as well any of them zooms.+inline SpaceCameraMove spaceCameraMove(int button, bool ctrl) {+ if (button < 1 || button > 3) return SpaceCameraMove::None;+ if (ctrl) return SpaceCameraMove::Zoom;+ return button == 1 ? SpaceCameraMove::Orbit : SpaceCameraMove::Pan;+}++// Whether a Space press starts holding: never while a text field has the keyboard (typing a space), and only with+// the preference on.+inline bool spaceCameraKeyDown(bool enabled, bool typing) { return enabled && !typing; }++} // namespace sfdiff --git a/src/app/UiTest.cpp b/src/app/UiTest.cppindex d2cf471e..6ec9dcde 100644--- a/src/app/UiTest.cpp+++ b/src/app/UiTest.cpp@@ -14,6 +14,7 @@// key COMBO e.g. enter, escape, ctrl+z, ctrl+shift+z, 3, comma, backtick, tab, f3, space, minus,// home, numpad1, ctrl+numpad7, numpad., numpadplus// hold MODS ctrl / shift / alt / ctrl+shift ... or none (for strokes and drags)+// key_down KEY / key_up KEY press a key and keep it down over the next steps / let it go (e.g. space)// stroke U0 V0 U1 V1 [S] brush stroke across the model (fractions of its on-screen bounds)// view_drag X0 Y0 X1 Y1 [S] left-drag in the viewport at window fractions, gliding there first like stroke (same// point twice = a click)@@ -113,7 +114,7 @@// 2 DragDot, 3 Spray, 4 LazyMouse), vdms (VDM brush maps), vdm_files (.sfvdm in the library)// z_intensity, smooth_intensity, rgb_intensity (0-100), focal_shift (-100..100), draw_size,// size_popup_open (the S / U / I / O slider), size_knob_x / size_knob_y (its knob, pixels),-// quickmenu_open, right_click_menu, lazy_mouse, input_style (0 ZBrush, 1 SculptForge, 2 Blender), turntable,+// quickmenu_open, right_click_menu, space_camera, space_held, lazy_mouse, input_style (0 ZBrush, 1 SculptForge, 2 Blender), turntable,// camera_ortho, mask_brush (Blender's Mask brush on), shortcut_conflicts (keys two actions// claim), brush_type (BrushType// index, -1 for a custom brush or Paint), last_dab_x / last_dab_y (window pixels), paint_r@@ -416,6 +417,8 @@ double Demo::query(const std::string& name, bool& known) const {if (name == "draw_size") return std::round(app_.radiusPx_);if (name == "quickmenu_open") return app_.quickMenu_.open ? 1.0 : 0.0;if (name == "right_click_menu") return app_.uiPrefs_.rightClickQuickMenu ? 1.0 : 0.0;+ if (name == "space_camera") return app_.uiPrefs_.spaceCamera ? 1.0 : 0.0;+ if (name == "space_held") return app_.spaceHeld_ ? 1.0 : 0.0;if (name == "size_popup_open" || name == "size_knob_x" || name == "size_knob_y") {ImVec2 knob(-1.0f, -1.0f);const bool open = PickerUi::sliderKnob(knob);@@ -691,7 +694,7 @@ void Demo::testClick(int line, const std::string& label, int button, bool doublewait(0.1f);}-void Demo::testKey(int line, const std::string& combo) {+void Demo::testKey(int line, const std::string& combo, int phase) {std::string keyName;const SDL_Keymod mods = parseMods(combo, &keyName);std::string lower = keyName;@@ -713,7 +716,7 @@ void Demo::testKey(int line, const std::string& combo) {run([this, line, keyName] { fail(line, "unknown key \"" + keyName + "\""); });return;}- steps_.push_back([this, mods, key](float) {+ steps_.push_back([this, mods, key, phase](float) {const SDL_Keymod before = SDL_GetModState();SDL_SetModState(mods | held_);SDL_Event e{};@@ -723,11 +726,11 @@ void Demo::testKey(int line, const std::string& combo) {e.key.scancode = SDL_GetScancodeFromKey(key, nullptr);e.key.mod = mods | held_;e.key.down = true;- app_.handleEvent(e);+ if (phase != 2) app_.handleEvent(e);e.type = SDL_EVENT_KEY_UP;e.key.down = false;e.key.mod = held_; // the combo's modifiers are released with the key- app_.handleEvent(e);+ if (phase != 1) app_.handleEvent(e);SDL_SetModState(before);return true;});@@ -827,6 +830,9 @@ bool Demo::parseStep(int line, const std::vector<std::string>& w, std::string& e} else if (verb == "key") {if (!need(1)) return false;testKey(line, w[1]);+ } else if (verb == "key_down" || verb == "key_up") { // a key held down over the next steps, then let go+ if (!need(1)) return false;+ testKey(line, w[1], verb == "key_down" ? 1 : 2);} else if (verb == "hold") {if (!need(1)) return false;const SDL_Keymod mods = w[1] == "none" ? SDL_KMOD_NONE : parseMods(w[1]);diff --git a/tests/test_space_camera.cpp b/tests/test_space_camera.cppnew file mode 100644index 00000000..496e7582--- /dev/null+++ b/tests/test_space_camera.cpp@@ -0,0 +1,23 @@+// SculptForge - open source digital sculpting+// SPDX-License-Identifier: GPL-3.0-or-later+// Hold Space and drag to move the camera (#43): what each press does, and when Space counts as held.+#include "TestHarness.h"++#include "app/SpaceCamera.h"++using namespace sf;++TEST(space_camera_buttons) {+ CHECK(spaceCameraMove(1, false) == SpaceCameraMove::Orbit); // left turns+ CHECK(spaceCameraMove(3, false) == SpaceCameraMove::Pan); // right pans+ CHECK(spaceCameraMove(2, false) == SpaceCameraMove::Pan); // middle pans+ for (int b = 1; b <= 3; ++b) CHECK(spaceCameraMove(b, true) == SpaceCameraMove::Zoom); // Ctrl zooms+ CHECK(spaceCameraMove(4, false) == SpaceCameraMove::None); // side buttons are left alone+ CHECK(spaceCameraMove(0, true) == SpaceCameraMove::None);+}++TEST(space_camera_key) {+ CHECK(spaceCameraKeyDown(true, false));+ CHECK(!spaceCameraKeyDown(false, false)); // off by default (ZBrush's Space opens the QuickMenu)+ CHECK(!spaceCameraKeyDown(true, true)); // typing a space in a text field+}diff --git a/tests/ui/space_camera.sfui b/tests/ui/space_camera.sfuinew file mode 100644index 00000000..9babcdd0--- /dev/null+++ b/tests/ui/space_camera.sfui@@ -0,0 +1,56 @@+# #43: Preferences > Input > Hold Space and drag to move the camera (off by default: Space opens the QuickMenu).+run new_sphere subdivisions=4+key f++# Off: Space opens the QuickMenu, as in ZBrush.+expect_value space_camera == 0+key space+expect_value quickmenu_open == 1+key escape+expect_value quickmenu_open == 0++# On: Space no longer opens the QuickMenu; held, a left drag on the model orbits instead of sculpting.+click "Preferences##palette.preferences"+click "Input##preferences.input"+hold ctrl+hover "Hold Space and drag to move the camera##input.space_camera"+expect_help "Space"+hold none+click "Hold Space and drag to move the camera##input.space_camera"+expect_value space_camera == 1+key escape+camera 0 0+key space+expect_value quickmenu_open == 0+remember camera_yaw yaw0+key_down space+expect_value space_held == 1+view_drag 0.45 0.5 0.6 0.5+expect_value camera_yaw != $yaw0+expect_value can_undo == 0++# Space+right drag pans; Space+Ctrl+drag zooms.+remember camera_pan pan0+button_drag right 0.45 0.5 0.45 0.6+expect_value camera_pan != $pan0+remember camera_distance d0+hold ctrl+view_drag 0.45 0.5 0.45 0.6+hold none+expect_value camera_distance != $d0+expect_value can_undo == 0+key_up space+expect_value space_held == 0+shot space_camera++# Let go: a drag on the model sculpts again.+stroke 0.3 0.5 0.6 0.5+expect_value can_undo == 1++# Typing a space in a text field never holds it.+key f3+expect_value command_palette_open == 1+key_down space+expect_value space_held == 0+key_up space+key escape