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.

Backface culling (#68), a crosshair over the view (#73), tablet mouse mode follows the system cursor (#72), a radial menu on the right button and plain-press mouse pies (#74); docs for #67 #68 #69 #72 #73 #74

islandmed520ef5f46ed3
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 88619e7a..b9389c81 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -85,9 +85,37 @@ All notable changes to SculptForge are listed here. The format follows
bar and footer of every website page, the donate page (members get private channels), the README and
CONTRIBUTING.md (questions on Discord; bugs still go to GitHub issues).
+- Backface culling (#68): **Tool > Display > Backface culling** skips the back faces of every Part, closed or open,
+ from any view: you see through the openings of open meshes, and brushes and picking work only on the faces drawn.
+ Off by default; Store Config keeps it, projects keep their own. An 8M-triangle open mesh seen from behind: 3.1 ms
+ -> 0.7 ms a frame; a closed 20M sculpt is unchanged (its hidden back faces were already skipped).
+- Viewport cursor (#73): a crosshair over the 3D view where brushes act; the arrow (or the resize, text and link
+ cursors) over panels, menus, popups and gizmo handles. **Preferences > Interface > Viewport cursor**: Crosshair
+ (default) or Arrow.
+- A radial menu on the right mouse button (#74): **Preferences > Input > Radial Menus** offers **Right mouse
+ button**; a plain right-drag then opens the pie (as Maya's marking menus) and the view turns with
+ <kbd>Shift</kbd>+right-drag or the style's other ways (the panel says which). Off by default.
+
### Fixed
- Maya input style (#32): <kbd>Ctrl</kbd>+<kbd>Alt</kbd>+<kbd>Shift</kbd>+drag erases the mask instead of starting
the <kbd>Ctrl</kbd>+<kbd>Shift</kbd> visibility selection.
+- Smooth on Quad Remesh results (#69): smoothing averaged every neighbour along a triangle edge, quad diagonals
+ included, so a vertex at one end of a diagonal was pulled along it and the quads sheared into zigzags. Smooth (the
+ brush, Shift, recipes' smoothing and Tool > Deformation > Smooth) now averages the polygon's own edges. 30 smooth
+ strokes on a remeshed sphere: corner angle error 3.9 -> 3.3 degrees (it was 8.8); on the lion head 8.7 -> 9.7
+ (was 19.5). Triangle meshes are unchanged.
+- Keep Masked remeshing (#67): Voxel Remesh with Keep Masked failed on real models ("Couldn't cut the remeshed
+ surface cleanly") at every resolution, because the voxel surface touches itself where parts of a model meet (a
+ lion's mane) and the join refused any such surface. Those spots are now fine; a mask edge that touches itself is
+ tidied at those corners, masked spots smaller than the new polygons are remeshed, narrow gaps between masked areas
+ are kept, and the strip is widened where the join folds (the status line says when the mask was tidied). When it
+ still can't be joined, the message says what to change (blur or grow the mask, by how much, or unmask where parts
+ overlap). Lion head and marble bust, four masks, two resolutions: 0 of 16 joined before, 16 of 16 now.
+- Tablet mouse mode (#72): after lifting the pen and putting it down elsewhere, the brush and the system arrow moved
+ together but apart, and clicks landed at the brush. In mouse mode the system cursor is now the one cursor for the
+ brush and the panels (read with every pen position; the pen adds pressure and tilt).
+- Radial menus on mouse buttons open only on a plain press (#74): <kbd>Alt</kbd>+middle pans, <kbd>Alt</kbd>+right
+ zooms (Maya style) and <kbd>Shift</kbd>+right turns the view, whatever menu is on the button.
## [0.10.5] - 2026-11-01
### Added
diff --git a/docs/guide/geometry.md b/docs/guide/geometry.md
index 37858c21..450bcdda 100644
--- a/docs/guide/geometry.md
+++ b/docs/guide/geometry.md
@@ -89,8 +89,10 @@ What happens to your data:
- **Keep Masked** (off by default): masked areas keep their triangles exactly, detail included, and only the rest
is remeshed. The new surface is joined to the masked area along the mask's edge by a narrow strip of triangles,
so the model stays closed. A triangle counts as masked when all three of its corners are at least half masked.
- If the mask's edge is too ragged or too thin to join up at this resolution, the status line says so and nothing
- changes (smooth or grow the mask, or raise the resolution). Command: `remesh keep_masked=true`.
+ A ragged mask edge is tidied by itself (#67): where it touches itself the corner triangles are remeshed, masked
+ spots smaller than the new polygons are remeshed with the rest, and narrow gaps between masked areas are kept;
+ the status line says when it did. If it still can't be joined, the status line says what to change (blur or grow
+ the mask, or unmask where two parts overlap) and nothing changes. Command: `remesh keep_masked=true`.
To remesh several Parts into one, first combine them with **Merge visible...** or **Merge down...** in
[Parts](parts.md#merge-parts).
diff --git a/docs/guide/interface.md b/docs/guide/interface.md
index 61497aa9..cacb9d0a 100644
--- a/docs/guide/interface.md
+++ b/docs/guide/interface.md
@@ -426,6 +426,7 @@ Config keeps it.
| Setting | Default | What it does |
|---|---|---|
| **Language** | English | The interface language: **English** or **Español** (see below) |
+| **Viewport cursor** | Crosshair | The pointer over the 3D view: a crosshair, or the arrow (#73). Panels, menus and popups always show the arrow |
| **Popup Info (Ctrl+hover help)** | On | Ctrl-hover help boxes |
| **Popup Info opacity** | 0.97 | How solid the help box is |
| **Tooltip delay** | 0.5 s | How long to point at an icon-only button before its name appears |
diff --git a/docs/guide/performance.md b/docs/guide/performance.md
index 838ccd77..3b13b563 100644
--- a/docs/guide/performance.md
+++ b/docs/guide/performance.md
@@ -99,7 +99,10 @@ setting is also in the <kbd>F3</kbd> command palette (type "antialiasing", "fast
instead of failing: hide other Parts or step down a subdivision level.
- **Closed meshes draw faster.** Parts of a mesh that face away from you are skipped when the mesh is closed
(no holes or hidden parts) and you look at it from outside. A mesh with holes, hidden polygons, or a view from
- inside it draws everything, which can take about twice as long on huge meshes.
+ inside it draws everything, which can take about twice as long on huge meshes. **Tool > Display > Backface
+ culling** (#68, off by default) skips the back faces of any mesh, open or closed, from any view: an open scan
+ seen from behind then draws almost nothing (8M triangles: 3.1 ms down to 0.7 ms a frame), and you see through its
+ openings. Brushes then work only on the faces drawn.
- **Undo** keeps only what each stroke changed, so a stroke on a 33 million triangle mesh undoes in a few tens of
milliseconds, and the history holds many such strokes within its 1 GB.
diff --git a/docs/guide/sculpting.md b/docs/guide/sculpting.md
index c4e72936..70824b17 100644
--- a/docs/guide/sculpting.md
+++ b/docs/guide/sculpting.md
@@ -175,7 +175,9 @@ bumps but leaves the form where it is (a Taubin smooth, one step in and a slight
the Smooth brush use; letting go of <kbd>Shift</kbd> mid-stroke then switches to the plain one. Saved with the
project.
-On a micro level (see [Micro levels](micro-levels.md)) Smooth is always the plain one for now.
+On a micro level (see [Micro levels](micro-levels.md)) Smooth is always the plain one for now. On a quad mesh
+(after Quad Remesh, or an imported quad model) Smooth follows the quads' own edges, never their diagonals, so the
+quads keep their shape (#69).
![The Draw palette](images/draw-palette.jpg)
@@ -258,9 +260,12 @@ Both keys are free in every input style. Make your own in **Preferences > Input
- Click an item to give it your own **label** and **icon**, or **Change action**. The arrows reorder items (the
first points up, the rest go clockwise); the cross removes one.
- **Key** sets the key that opens the menu (it is an ordinary shortcut, so **Preferences > Hotkeys** lists it
- too). The button next to it can also open the menu while held: the middle, back or forward mouse button, or one
- of the pen's side buttons. That button then stops doing what it did before (a pen button's
- Preferences > Tablet mapping, the middle button's pan).
+ too). The button next to it can also open the menu while held: the middle, right, back or forward mouse button,
+ or one of the pen's side buttons. That button then stops doing what it did before (a pen button's
+ Preferences > Tablet mapping, the middle button's pan, the right button's turn). A mouse button opens the menu
+ only with no modifier key held (#74): <kbd>Alt</kbd>+middle still pans, <kbd>Alt</kbd>+right still zooms in the
+ Maya style, and <kbd>Shift</kbd>+right-drag still turns the view, so a menu on the right button never leaves you
+ without a way to turn it (the panel says how).
- **Export...** saves the menu as a small `.json` file to share; **Import...** loads one. A menu file holds only
action names, never anything that runs: names this version doesn't know are left out.
- **Restore default menus** brings back Brushes and Masking.
@@ -599,7 +604,8 @@ also have a **Pressure curve** setting that makes them respond to a light or a f
lower button right-click to rotate the view, upper button **Invert**, third button **Pan view**). A side button
can open a [radial menu](#radial-menus) instead (Preferences > Input > Radial Menus).
- **Mouse mode (relative)**, for a tablet whose driver is set to mouse mode: the pen moves the cursor by how far
- it moves, and putting it down elsewhere on the tablet leaves the cursor where it was.
+ it moves, and putting it down elsewhere on the tablet leaves the cursor where it was. The brush follows the
+ system cursor the driver moves, so brush, arrow and clicks always agree (#72).
**Store Config** (<kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>I</kbd>) keeps these settings. Setup notes for Windows
Ink, macOS and Linux are in
diff --git a/docs/guide/whats-new.md b/docs/guide/whats-new.md
index 52dd77a5..7936a179 100644
--- a/docs/guide/whats-new.md
+++ b/docs/guide/whats-new.md
@@ -52,6 +52,18 @@ chapter opens by itself the first time you start a new version; you can always f
- **The SculptForge Discord** (**Help > Join the Discord...**): the official community, for questions, tips and
work in progress. It is also on the support card, in the welcome note and on the website. Bugs still go to
**Help > Report a problem** (GitHub issues).
+- **Backface culling** (#68, **Tool > Display**): don't draw the back faces of the model, for speed on open meshes
+ and to see through their openings. Brushes then work only on what you see. Off by default.
+- **A crosshair over the view** (#73): the pointer is a crosshair where brushes act and the arrow over the panels.
+ **Preferences > Interface > Viewport cursor** brings the arrow back.
+- **A radial menu on the right button** (#74): choose **Right mouse button** for a menu in **Preferences > Input >
+ Radial Menus**; turn the view with <kbd>Shift</kbd>+right-drag then. A menu on a mouse button now opens only
+ without modifier keys, so <kbd>Alt</kbd>+middle still pans.
+- **Fixed: Smooth on quad meshes** (#69): smoothing a Quad Remesh result no longer shears the quads into zigzags.
+- **Fixed: Keep Masked remeshing** (#67): Voxel Remesh with Keep Masked works on real sculpts, tidies awkward mask
+ edges by itself, and says what to change when it can't.
+- **Fixed: tablet mouse mode** (#72): the brush stays on the system cursor after the pen is lifted and put down
+ elsewhere, and clicks land where the arrow is.
## Version 0.10.5
diff --git a/src/app/App.cpp b/src/app/App.cpp
index 37716167..f4827f0c 100644
--- a/src/app/App.cpp
+++ b/src/app/App.cpp
@@ -329,6 +329,10 @@ void App::shutdown() {
ImGui_ImplOpenGL3_Shutdown();
ImGui_ImplSDL3_Shutdown();
ImGui::DestroyContext();
+ for (SDL_Cursor*& c : cursors_) {
+ if (c) SDL_DestroyCursor(c);
+ c = nullptr;
+ }
renderer_.shutdown();
if (glContext_) SDL_GL_DestroyContext(glContext_);
if (window_) SDL_DestroyWindow(window_);
@@ -424,6 +428,7 @@ int App::runUiTest(int w, int h, int fps) {
if (ImGuiContext* g = ImGui::GetCurrentContext()) demo_->setFrameText(g->LogBuffer.c_str());
ImGui::LogFinish();
ImGui::Render();
+ updateMouseCursor();
prewarmTexturePaint(); // dense textured meshes: ready the area under the hovering Paint brush (PanelPbr.cpp)
const auto syncStart = std::chrono::steady_clock::now();
@@ -590,6 +595,7 @@ int App::runRecording() {
drawUi();
demo_->drawOverlay();
ImGui::Render();
+ updateMouseCursor();
syncScene();
++frames;
@@ -964,6 +970,7 @@ int App::run() {
drawUi();
drawHardwareProfileOverlay();
ImGui::Render();
+ updateMouseCursor();
mark();
buildGhost(); // the dabs not on the GPU yet, drawn as a preview (predictive strokes)
@@ -1148,7 +1155,75 @@ bool App::pick(float x, float y, RayHit& hit) const {
if (!doc_.activeSubtoolInfo().visible) return false; // you can't sculpt what you can't see
glm::vec3 origin, dir;
canvasRay(x, y, origin, dir);
- return surfaceRaycast(doc_.mesh, doc_.bvh, origin, dir, hit); // (the micro surface on a micro level)
+ return frontRaycast(origin, dir, hit);
+}
+
+// The surface under a ray as drawn: with Backface culling on (#68) a back face isn't drawn, so the ray goes on
+// through it to the next face it meets (a brush through the opening of an open mesh works on the far side).
+bool App::frontRaycast(const glm::vec3& origin, const glm::vec3& dir, RayHit& hit) const {
+ if (!surfaceRaycast(doc_.mesh, doc_.bvh, origin, dir, hit)) return false; // (the micro surface on a micro level)
+ if (!renderSettings_.backfaceCulling) return true;
+ glm::vec3 o = origin;
+ for (int i = 0; i < 16 && glm::dot(hit.normal, dir) > 0.0f; ++i) {
+ const glm::vec3 d = glm::normalize(dir);
+ o = hit.position + d * std::max(1e-6f, 1e-5f * glm::distance(origin, hit.position)); // just past it
+ if (!surfaceRaycast(doc_.mesh, doc_.bvh, o, dir, hit)) return false;
+ }
+ return glm::dot(hit.normal, dir) <= 0.0f;
+}
+
+// The crosshair (#73): over the 3D view, where a click sculpts, paints or masks, or while a stroke runs (it may
+// drag over a panel). Not over the panels or windows floating above the view (ImGui has the pointer), a gizmo
+// handle, while the view turns or pans, or where ImGui asks for a cursor of its own (a resize handle on the edge).
+bool App::viewportCursorWanted() const {
+ if (uiPrefs_.viewportCursor != 0) return false;
+ if (drag_ == Drag::Stroke || drag_ == Drag::MaskCanvas || drag_ == Drag::AirStroke) return true;
+ if (drag_ != Drag::None) return false;
+ if (ImGui::GetIO().WantCaptureMouse || !canvasRect().contains(mouseX_, mouseY_)) return false;
+ if (ImGui::GetMouseCursor() != ImGuiMouseCursor_Arrow) return false;
+ if (gizmoActive() && gizmo_.hover != GizmoHandle::None) return false;
+ return true;
+}
+
+// The system cursor, set here rather than by ImGui's backend (which knows no crosshair, and would not put its own
+// back after another was set): ImGui's choice, or the crosshair over the view. Decided after the frame's UI, from
+// that frame's hover state, so a window floating over the view never makes it flicker. SDL_SetCursor runs only
+// when the kind changes.
+void App::updateMouseCursor() {
+ ImGuiIO& io = ImGui::GetIO();
+ io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange;
+ const ImGuiMouseCursor ui = ImGui::GetMouseCursor();
+ cursorKind_ = viewportCursorWanted() ? kCursorCrosshair : ui == ImGuiMouseCursor_None || io.MouseDrawCursor ? kCursorHidden : int(ui);
+ if (cursorKind_ == cursorShown_) return;
+ cursorShown_ = cursorKind_;
+ if (cursorKind_ == kCursorHidden) {
+ SDL_HideCursor();
+ return;
+ }
+ SDL_SystemCursor id = SDL_SYSTEM_CURSOR_DEFAULT;
+ switch (cursorKind_) {
+ case kCursorCrosshair: id = SDL_SYSTEM_CURSOR_CROSSHAIR; break;
+ case ImGuiMouseCursor_TextInput: id = SDL_SYSTEM_CURSOR_TEXT; break;
+ case ImGuiMouseCursor_ResizeAll: id = SDL_SYSTEM_CURSOR_MOVE; break;
+ case ImGuiMouseCursor_ResizeNS: id = SDL_SYSTEM_CURSOR_NS_RESIZE; break;
+ case ImGuiMouseCursor_ResizeEW: id = SDL_SYSTEM_CURSOR_EW_RESIZE; break;
+ case ImGuiMouseCursor_ResizeNESW: id = SDL_SYSTEM_CURSOR_NESW_RESIZE; break;
+ case ImGuiMouseCursor_ResizeNWSE: id = SDL_SYSTEM_CURSOR_NWSE_RESIZE; break;
+ case ImGuiMouseCursor_Hand: id = SDL_SYSTEM_CURSOR_POINTER; break;
+ case ImGuiMouseCursor_Wait: id = SDL_SYSTEM_CURSOR_WAIT; break;
+ case ImGuiMouseCursor_Progress: id = SDL_SYSTEM_CURSOR_PROGRESS; break;
+ case ImGuiMouseCursor_NotAllowed: id = SDL_SYSTEM_CURSOR_NOT_ALLOWED; break;
+ default: break;
+ }
+ const size_t slot = size_t(id) < std::size(cursors_) ? size_t(id) : 0;
+ if (!cursors_[slot]) cursors_[slot] = SDL_CreateSystemCursor(id);
+ if (!cursors_[slot] && id != SDL_SYSTEM_CURSOR_DEFAULT) { // (a system without this one: the arrow)
+ if (!cursors_[0]) cursors_[0] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_DEFAULT);
+ if (cursors_[0]) SDL_SetCursor(cursors_[0]);
+ } else if (cursors_[slot]) {
+ SDL_SetCursor(cursors_[slot]);
+ }
+ SDL_ShowCursor();
}
BrushType App::activeBrush() const {
diff --git a/src/app/App.h b/src/app/App.h
index a1b71574..e6767cf0 100644
--- a/src/app/App.h
+++ b/src/app/App.h
@@ -1683,7 +1683,17 @@ private:
bool dropPenMouseEvent(const SDL_Event& e) const; // SDL's version-dependent clicks for pen buttons
bool strayMouseMotion(const SDL_Event& e) const; // a driver's mouse motion beside the pen's (Tablet.cpp)
void keepImGuiOnPen(); // after ImGui_ImplSDL3_NewFrame (Tablet.cpp)
- void mapPenPosition(SDL_Event& e); // mouse mode: the pen moves the cursor relatively (Tablet.cpp)
+ bool systemCursorInWindow(float& x, float& y) const; // mouse mode (#72): the system cursor, window pixels
+ void mapPenPosition(SDL_Event& e);
+ // The system cursor (#73): ImGui's (resize handles, text fields, links) over the panels, a crosshair over the
+ // 3D view where a brush acts (Preferences > Interface > Viewport cursor). Called after each ImGui::Render.
+ void updateMouseCursor();
+ bool viewportCursorWanted() const;
+ bool frontRaycast(const glm::vec3& origin, const glm::vec3& dir, RayHit& hit) const; // as drawn (#68)
+ static constexpr int kCursorCrosshair = 100, kCursorHidden = -1;
+ int cursorKind_ = 0; // what updateMouseCursor last set: an ImGuiMouseCursor, kCursorCrosshair or kCursorHidden
+ SDL_Cursor* cursors_[16] = {}; // system cursors by SDL_SystemCursor, made when first needed
+ int cursorShown_ = -2; // (the kind on screen, so SDL_SetCursor runs only on a change) // mouse mode: the pen moves the cursor relatively (Tablet.cpp)
void handlePenEvent(const SDL_Event& e);
void penButton(int button, bool down, float x, float y);
void penLeft(); // out of proximity: ends what the pen was doing
@@ -1695,6 +1705,8 @@ private:
void drawTabletSection(); // Preferences > Tablet
void detectPenName();
PenPressureTracker penTracker_;
+ bool testSystemCursor_ = false; // UI tests: a system cursor set by the script (os_cursor), else none
+ float testSystemCursorX_ = 0.0f, testSystemCursorY_ = 0.0f;
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)
diff --git a/src/app/AsyncStroke.cpp b/src/app/AsyncStroke.cpp
index f661563d..9e3ce384 100644
--- a/src/app/AsyncStroke.cpp
+++ b/src/app/AsyncStroke.cpp
@@ -339,7 +339,7 @@ bool App::pickWith(const DabView& view, float x, float y, RayHit& hit) const {
if (!view.settings.visible) return false;
glm::vec3 origin, dir;
view.camera.screenRay(x - view.canvas.x, y - view.canvas.y, view.canvas.w, view.canvas.h, origin, dir);
- return surfaceRaycast(doc_.mesh, doc_.bvh, origin, dir, hit);
+ return frontRaycast(origin, dir, hit);
}
glm::vec2 App::predictedPointer() const {
diff --git a/src/app/Bench.cpp b/src/app/Bench.cpp
index 66dc44fd..027f5572 100644
--- a/src/app/Bench.cpp
+++ b/src/app/Bench.cpp
@@ -84,6 +84,8 @@ int runAppBenchmark(BenchCommandLine cl) {
camera.frame(m.bounds());
RenderSettings settings;
settings.motionProxy = moving;
+ // SF_BENCH_CULL=1: Tool > Display > Backface culling on (#68).
+ settings.backfaceCulling = std::getenv("SF_BENCH_CULL") && std::string(std::getenv("SF_BENCH_CULL")) == "1";
renderer.syncScene(scene(m));
const int warmup = 5, frames = 120;
Clock::time_point t;
diff --git a/src/app/Config.cpp b/src/app/Config.cpp
index b1b75a50..d0b05210 100644
--- a/src/app/Config.cpp
+++ b/src/app/Config.cpp
@@ -75,6 +75,8 @@ Json toJson(const UiPrefs& p) {
j.set("draftStrokes", p.draftStrokes);
j.set("dyntopoConstantDetail", p.dyntopoConstantDetail);
j.set("flatShading", p.flatShading);
+ j.set("viewportCursor", double(p.viewportCursor));
+ j.set("backfaceCulling", p.backfaceCulling);
j.set("background", std::string(p.gradientBackground ? "gradient" : "flat"));
Json bg = Json::array();
for (int i = 0; i < 3; ++i) bg.push(double(p.backgroundColor[i]));
@@ -128,6 +130,8 @@ void fromJson(const Json& j, UiPrefs& p) {
p.draftStrokes = j["draftStrokes"].asBool(p.draftStrokes);
p.dyntopoConstantDetail = j["dyntopoConstantDetail"].asBool(p.dyntopoConstantDetail);
p.flatShading = j["flatShading"].asBool(p.flatShading);
+ p.viewportCursor = std::clamp(int(j["viewportCursor"].asNumber(p.viewportCursor)), 0, 1);
+ p.backfaceCulling = j["backfaceCulling"].asBool(p.backfaceCulling);
if (j["background"].isString()) p.gradientBackground = j["background"].asString() != "flat";
if (const Json& bg = j["backgroundColor"]; bg.size() == 3)
for (int i = 0; i < 3; ++i) p.backgroundColor[i] = std::clamp(float(bg[size_t(i)].asNumber(p.backgroundColor[i])), 0.0f, 1.0f);
@@ -731,6 +735,7 @@ bool App::readUiConfig(const std::string& path, std::string& err) {
doc_.sculptor.dyntopo.constantDetail = uiPrefs_.dyntopoConstantDetail;
doc_.sculptor.dyntopo.smoothRemesh = uiPrefs_.dyntopoSmoothRemesh;
renderSettings_.flatShading = uiPrefs_.flatShading;
+ renderSettings_.backfaceCulling = uiPrefs_.backfaceCulling;
renderSettings_.gradientBackground = uiPrefs_.gradientBackground;
renderSettings_.backgroundColor = uiPrefs_.backgroundColor;
return true;
@@ -1090,6 +1095,19 @@ void drawInterfaceSection(App& app) {
"Clay Block...) stay as they are. Store Config keeps it for the next start.",
"Preferences > Interface");
}
+ // Viewport cursor (#73).
+ ImGui::AlignTextToFramePadding();
+ ImGui::TextUnformatted(tr("Viewport cursor"));
+ const char* const kCursors[] = {"Crosshair##viewport_cursor", "Arrow##viewport_cursor"};
+ for (int i = 0; i < 2; ++i) {
+ ImGui::SameLine();
+ if (ImGui::RadioButton(tr(kCursors[i]), p.viewportCursor == i)) p.viewportCursor = i;
+ ui::HelpText("Viewport cursor", nullptr,
+ "The pointer over the 3D view: a crosshair (the default, as in most sculpting apps) or the arrow. "
+ "Panels, menus and popups always show the arrow (or their own resize and text cursors). Store "
+ "Config keeps it.",
+ "Preferences > Interface");
+ }
ImGui::Checkbox(tr("Popup Info (Ctrl+hover help)"), &p.popupInfo);
ui::HelpText("Popup Info", nullptr,
"Hold Ctrl and point at any control to see what it does and its shortcut. Ctrl+Alt shows a command's "
diff --git a/src/app/Config.h b/src/app/Config.h
index 701f6244..d2daea8f 100644
--- a/src/app/Config.h
+++ b/src/app/Config.h
@@ -58,6 +58,12 @@ struct UiPrefs {
// Preferences > Interface > Timeline position (#63): the Sculpt Timeline strip along the top of the viewport
// (true, the default: clear of the brush shelf below it) or its bottom.
bool timelineTop = true;
+ // Preferences > Interface > Viewport cursor (#73): the system cursor over the 3D view, 0 = crosshair (the
+ // default, as most sculpting apps), 1 = the arrow. Panels, menus and popups always show their own.
+ int viewportCursor = 0;
+ // Tool > Display > Backface culling (#68): skip the back faces of every Part (faster on dense meshes; see
+ // through open meshes). Off by default; a preference, projects keep their own.
+ bool backfaceCulling = false;
TabletSettings tablet; // Preferences > Tablet: pressure curve, eraser, pen buttons
SpaceMouseSettings spaceMouse; // Preferences > Input > SpaceMouse
// Preferences > Performance (PanelPerformance.cpp).
diff --git a/src/app/Palettes.cpp b/src/app/Palettes.cpp
index a173630a..c5792872 100644
--- a/src/app/Palettes.cpp
+++ b/src/app/Palettes.cpp
@@ -721,6 +721,13 @@ void App::drawPalette_Tool() {
ImGui::SameLine();
ImGui::Checkbox(tr("Groups##display"), &renderSettings_.showPolygroups);
ui::HelpAction(*this, "view.polygroups");
+ if (ImGui::Checkbox(tr("Backface culling##display"), &renderSettings_.backfaceCulling))
+ uiPrefs_.backfaceCulling = renderSettings_.backfaceCulling; // the default for the next session
+ ui::HelpText("Backface culling", nullptr,
+ "Don't draw the back faces of the model: faster on dense meshes, and you see through the openings "
+ "of open meshes (a scan, a garment) instead of their inside. Brushes then work only on faces you "
+ "can see. Off by default; Store Config keeps it, projects keep their own.",
+ "Tool > Display");
ImGui::ColorEdit3(tr("Material colour"), &renderSettings_.baseColor.x, ImGuiColorEditFlags_NoInputs);
ui::HelpText("Material colour", nullptr, "Colour of the Studio material (the clay colour).", "Tool > Display");
drawShadingControls();
diff --git a/src/app/PanelProject.cpp b/src/app/PanelProject.cpp
index a1b7aa53..aca137d6 100644
--- a/src/app/PanelProject.cpp
+++ b/src/app/PanelProject.cpp
@@ -265,6 +265,7 @@ void App::storeProjectSettings() {
render.set("show_splats", renderSettings_.showSplats);
render.set("splat_opacity", double(renderSettings_.splatOpacity));
render.set("flat_shading", renderSettings_.flatShading);
+ render.set("backface_culling", renderSettings_.backfaceCulling);
render.set("background", std::string(renderSettings_.gradientBackground ? "gradient" : "flat"));
render.set("background_color", vec3Json(renderSettings_.backgroundColor));
render.set("matcap", renderSettings_.matcap < 0 ? std::string() : std::string(matcapName(renderSettings_.matcap)));
@@ -362,6 +363,7 @@ void App::applyProjectSettings() {
readFloat(r, "splat_opacity", renderSettings_.splatOpacity);
// Projects from before the setting: the preferred shading.
renderSettings_.flatShading = r["flat_shading"].asBool(uiPrefs_.flatShading);
+ renderSettings_.backfaceCulling = r["backface_culling"].asBool(uiPrefs_.backfaceCulling);
// Viewport shading; projects from before it: Lit Sphere.
{
RenderSettings& v = renderSettings_;
diff --git a/src/app/RadialMenu.cpp b/src/app/RadialMenu.cpp
index 4bade484..35ab0836 100644
--- a/src/app/RadialMenu.cpp
+++ b/src/app/RadialMenu.cpp
@@ -267,7 +267,11 @@ bool App::radialMouseEvent(const SDL_Event& e) {
return true;
}
if (e.button.which == SDL_PEN_MOUSEID) return false; // pen buttons come through radialPenButton
+ // Only a plain press opens a menu (#74): with Alt, Ctrl, Shift or the system key held the button keeps its
+ // navigation or tool binding (Alt+middle pans, Alt+right zooms in the Maya style, Shift+right turns the view).
+ if (SDL_GetModState() & (SDL_KMOD_SHIFT | SDL_KMOD_CTRL | SDL_KMOD_ALT | SDL_KMOD_GUI)) return false;
const RadialButton b = button == SDL_BUTTON_MIDDLE ? RadialButton::MouseMiddle
+ : button == SDL_BUTTON_RIGHT ? RadialButton::MouseRight
: button == SDL_BUTTON_X1 ? RadialButton::MouseBack
: button == SDL_BUTTON_X2 ? RadialButton::MouseForward
: RadialButton::None;
@@ -499,8 +503,21 @@ void App::drawRadialMenusSection() {
}
ui::HelpText("Button", nullptr,
"A mouse or pen button that opens this menu while held, besides the key. It then stops doing "
- "what it did before (a pen button's Preferences > Tablet mapping, the middle button's pan).",
+ "what it did before (a pen button's Preferences > Tablet mapping, the middle button's pan, the "
+ "right button's turn). Mouse buttons open it only when no modifier key is held: Alt+middle still "
+ "pans, Alt+right still zooms (Maya style), Shift+right still turns the view.",
path);
+ if (m.button == RadialButton::MouseRight) {
+ // The view must stay reachable (#74): say how it turns now.
+ const char* how = blenderStyle() ? "middle-drag (or Alt+left-drag)"
+ : mayaStyle() ? "Alt+left-drag"
+ : uiPrefs_.airStrokes ? "Shift+right-drag (Start strokes off the model is on, so a left-drag "
+ "beside the model sculpts)"
+ : "Shift+right-drag, or a left-drag beside the model";
+ ImGui::PushTextWrapPos(0.0f);
+ ImGui::TextDisabled("Right-drag opens this menu. Turn the view with %s.", how);
+ ImGui::PopTextWrapPos();
+ }
// Items: one row each (the action, up / down / remove); the selected one also shows its own label and icon,
// and Change action.
diff --git a/src/app/Tablet.cpp b/src/app/Tablet.cpp
index 4654267e..625505e2 100644
--- a/src/app/Tablet.cpp
+++ b/src/app/Tablet.cpp
@@ -62,9 +62,41 @@ void App::keepImGuiOnPen() {
// how far it moves, like a mouse. Every pen position, the pen's own events and SDL's mouse events for the pen, goes
// through penCursor_ before anything reads it (#54: lifting the pen and putting it down elsewhere made the cursor
// jump back). The mouse moving the cursor in between moves where the pen carries on from.
+//
+// #72: in mouse mode the driver moves the system cursor itself, so the system cursor is the one cursor, for the
+// brush circle and the panels alike; each pen position is replaced by it (the pen adds pressure and tilt). A
+// cursor of our own, moved by the pen's motion, drifted from the system's after the pen was lifted and put down
+// elsewhere, and clicks landed at the brush instead of the arrow.
+bool App::systemCursorInWindow(float& x, float& y) const {
+ if (demo_) { // UI tests: the system cursor a script set (os_cursor), or none
+ if (!testSystemCursor_) return false;
+ x = testSystemCursorX_;
+ y = testSystemCursorY_;
+ return true;
+ }
+ if (!window_) return false;
+ float gx = 0.0f, gy = 0.0f;
+ int wx = 0, wy = 0;
+ SDL_GetGlobalMouseState(&gx, &gy);
+ if (!SDL_GetWindowPosition(window_, &wx, &wy)) return false;
+ x = gx - float(wx);
+ y = gy - float(wy);
+ return std::isfinite(x) && std::isfinite(y);
+}
+
void App::mapPenPosition(SDL_Event& e) {
penCursor_.mouseMode = uiPrefs_.tablet.mouseMode;
const Uint64 now = SDL_GetTicksNS();
+ if (penCursor_.mouseMode) {
+ float sx = 0.0f, sy = 0.0f;
+ const bool penPosition = e.type == SDL_EVENT_PEN_DOWN || e.type == SDL_EVENT_PEN_UP || e.type == SDL_EVENT_PEN_MOTION ||
+ e.type == SDL_EVENT_PEN_AXIS || e.type == SDL_EVENT_PEN_BUTTON_DOWN ||
+ e.type == SDL_EVENT_PEN_BUTTON_UP ||
+ ((e.type == SDL_EVENT_MOUSE_MOTION) && e.motion.which == SDL_PEN_MOUSEID) ||
+ ((e.type == SDL_EVENT_MOUSE_BUTTON_DOWN || e.type == SDL_EVENT_MOUSE_BUTTON_UP) &&
+ e.button.which == SDL_PEN_MOUSEID);
+ if (penPosition && systemCursorInWindow(sx, sy)) penCursor_.systemCursor(sx, sy);
+ }
switch (e.type) {
case SDL_EVENT_PEN_PROXIMITY_IN:
case SDL_EVENT_PEN_PROXIMITY_OUT: penCursor_.proximity(); break;
diff --git a/src/app/UiTest.cpp b/src/app/UiTest.cpp
index 3b48ad56..fc529e95 100644
--- a/src/app/UiTest.cpp
+++ b/src/app/UiTest.cpp
@@ -85,7 +85,9 @@
// symmetry_copies (copies every stroke makes), cursor_copies (brush cursors drawn),
// symmetry_pivot_x (local symmetry's centre), timeline_top (1: the strip at the top),
// timeline_y / axis_gizmo_y (their tops / centre, fractions of the canvas from its top),
-// tablet_mouse_mode (Preferences > Tablet > Mouse mode),
+// tablet_mouse_mode (Preferences > Tablet > Mouse mode), os_cursor_x / os_cursor_y,
+// ui_mouse_x / ui_mouse_y (where ImGui sees the pointer), backface_culling, drawn_triangles,
+// viewport_cursor (the system cursor: 0 arrow, 1 text, 7 hand, 100 crosshair; #73),
// smooth_keep_volume (Brush > Smooth keeps volume), stroke_keep_volume (1 when Smooth
// dabs keep the volume now: the option, flipped by letting go of Shift mid-stroke),
// moved_out (summed movement along the snapshot's normals: > 0 out, < 0 in),
@@ -177,6 +179,7 @@
// 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
+// os_cursor U V | off where the system cursor is (a tablet driver in mouse mode moves it, #72); off: unknown
// mouse_move U V a plain mouse (not the pen) moves to a point on the model, e.g. the stray mouse
// events Windows Ink sends beside the pen's
//
@@ -689,6 +692,17 @@ 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 == "backface_culling") return app_.renderSettings_.backfaceCulling ? 1.0 : 0.0;
+ if (name == "draw_ms") return app_.benchmarkDrawMs(30); // the 3D view drawn 30 times: ms per frame
+ if (name == "drawn_triangles") { // the 3D view drawn once more now: the triangles it drew
+ app_.benchmarkDrawMs(0);
+ return double(app_.renderer_.lastDrawnTriangles());
+ }
+ if (name == "viewport_cursor") return app_.cursorKind_; // the system cursor: 0 arrow, 100 crosshair (#73)
+ if (name == "os_cursor_x") return app_.testSystemCursorX_;
+ if (name == "os_cursor_y") return app_.testSystemCursorY_;
+ if (name == "ui_mouse_x") return ImGui::GetIO().MousePos.x; // where the panels see the pointer
+ if (name == "ui_mouse_y") return ImGui::GetIO().MousePos.y;
if (name == "cursor_x") return app_.mouseX_;
if (name == "cursor_y") return app_.mouseY_;
if (name == "surface_cursor") return app_.surfaceCursorShown_ ? 1.0 : 0.0;
@@ -1767,6 +1781,19 @@ bool Demo::parseStep(int line, const std::vector<std::string>& w, std::string& e
if (!penIn_) penProximity(true);
penPressure(p);
});
+ } else if (verb == "os_cursor") {
+ // Where the system cursor is, as a tablet driver in mouse mode moves it (#72): `os_cursor U V` on the model,
+ // `os_cursor off` (the default) for a system that can't say.
+ if (!need(1)) return false;
+ const bool off = w[1] == "off";
+ if (!off && !need(2)) return false;
+ run([this, off, u = off ? 0.0f : num(1, 0.5f), v = off ? 0.0f : num(2, 0.5f)] {
+ app_.testSystemCursor_ = !off;
+ if (off) return;
+ const ImVec2 p = onModel(u, v);
+ app_.testSystemCursorX_ = p.x;
+ app_.testSystemCursorY_ = p.y;
+ });
} else if (verb == "mouse_move") {
if (!need(2)) return false;
run([this, u = num(1, 0.5f), v = num(2, 0.5f)] {
diff --git a/src/core/RadialMenu.cpp b/src/core/RadialMenu.cpp
index e5f3bc5f..7110b232 100644
--- a/src/core/RadialMenu.cpp
+++ b/src/core/RadialMenu.cpp
@@ -25,6 +25,7 @@ constexpr ButtonName kButtons[int(RadialButton::Count)] = {
{"pen_lower", "Pen lower button"},
{"pen_upper", "Pen upper button"},
{"pen_third", "Pen third button"},
+ {"mouse_right", "Right mouse button"},
};
// An id from a file: a string of sensible length the vocabulary knows, or "".
diff --git a/src/core/RadialMenu.h b/src/core/RadialMenu.h
index 3fa9c7ef..c3b15a76 100644
--- a/src/core/RadialMenu.h
+++ b/src/core/RadialMenu.h
@@ -26,7 +26,10 @@ constexpr size_t kRadialIdMax = 96; // bytes in an action or icon id (longe
constexpr size_t kRadialFileMax = 64 * 1024; // an imported menu file larger than this is refused unread
// What opens a menu besides its key: a mouse button or a pen side button, held like the key.
-enum class RadialButton { None, MouseMiddle, MouseBack, MouseForward, PenLower, PenUpper, PenThird, Count };
+// MouseRight (#74): a plain right-drag opens the menu instead of turning the view (Maya's marking menus); the
+// view then turns with Shift+right-drag or the style's other ways. Mouse buttons open a menu only with no modifier
+// held (Alt+middle still pans, Alt+right zooms in the Maya style). Stored by id, so the order may change.
+enum class RadialButton { None, MouseMiddle, MouseBack, MouseForward, PenLower, PenUpper, PenThird, MouseRight, Count };
const char* radialButtonId(RadialButton b); // "mouse_middle" ... (stored in ui.json)
const char* radialButtonLabel(RadialButton b); // "Middle mouse button" ... (Preferences > Input > Radial Menus)
RadialButton radialButtonFromId(std::string_view id); // unknown: None
diff --git a/src/core/Tablet.cpp b/src/core/Tablet.cpp
index 6c93b9ee..3a10b8f7 100644
--- a/src/core/Tablet.cpp
+++ b/src/core/Tablet.cpp
@@ -112,9 +112,27 @@ void PenCursor::cursorAt(float x, float y) {
anchored_ = false;
}
+void PenCursor::systemCursor(float x, float y) {
+ if (!std::isfinite(x) || !std::isfinite(y)) return;
+ systemX_ = x;
+ systemY_ = y;
+ haveSystem_ = true;
+}
+
void PenCursor::map(float& x, float& y, uint64_t nowNs) {
if (!std::isfinite(x) || !std::isfinite(y)) return;
- if (mouseMode) {
+ const bool system = haveSystem_;
+ haveSystem_ = false; // (one reading per position)
+ if (mouseMode && system) {
+ // The system cursor is the one cursor; the pen only adds pressure and tilt. Should the system stop
+ // saying where it is, the pen carries on from here.
+ offsetX_ = systemX_ - x;
+ offsetY_ = systemY_ - y;
+ anchored_ = true;
+ lastNs_ = nowNs;
+ x = systemX_;
+ y = systemY_;
+ } else if (mouseMode) {
// A pen that comes back (into range, or after a pause) moves the cursor on from where it is.
if (!anchored_ || nowNs - lastNs_ > kLiftedNs) {
offsetX_ = haveCursor_ ? cursorX_ - x : 0.0f;
diff --git a/src/core/Tablet.h b/src/core/Tablet.h
index c8075fb8..667f9c5f 100644
--- a/src/core/Tablet.h
+++ b/src/core/Tablet.h
@@ -104,13 +104,20 @@ public:
void proximity() { anchored_ = false; }
// Something else (the mouse) moved the cursor to x, y.
void cursorAt(float x, float y);
+ // Where the system cursor is (window pixels), read just before the next map(). In mouse mode the driver moves
+ // the system cursor itself, so that is the cursor: map() returns it for the brush and the panels alike (#72:
+ // a cursor of our own, moved by the pen's motion, drifted away from the system's after the pen was lifted and
+ // put down elsewhere, and clicks landed at the brush, not the arrow). Without one (a system that can't say),
+ // the pen's motion moves the cursor on from where it was.
+ void systemCursor(float x, float y);
// A pen position (window pixels) at time nowNs -> the cursor's position, in place.
void map(float& x, float& y, uint64_t nowNs);
private:
float offsetX_ = 0.0f, offsetY_ = 0.0f; // mouse mode: cursor = pen + offset
float cursorX_ = 0.0f, cursorY_ = 0.0f;
- bool haveCursor_ = false, anchored_ = false;
+ float systemX_ = 0.0f, systemY_ = 0.0f;
+ bool haveCursor_ = false, anchored_ = false, haveSystem_ = false;
uint64_t lastNs_ = 0;
};
diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp
index 30fb1f8e..094d3e6c 100644
--- a/src/render/Renderer.cpp
+++ b/src/render/Renderer.cpp
@@ -2617,6 +2617,7 @@ void Renderer::endCapture(std::vector<uint8_t>& rgba) {
void Renderer::draw(const Camera& camera, int targetWidth, int targetHeight, const RenderSettings& settings,
const Viewport& viewport) {
syncMatcaps();
+ forceBackfaces_ = settings.backfaceCulling && !thumbnailPass_; // (#68; thumbnails show the whole Part)
// Known state before the clears: a scissor box, colour mask or depth mask left over from another pass (UI,
// overlays, calibration) makes glClear partial. Some drivers (NVIDIA on Windows, #29) then show old frames
// under the cursor and stale depth hides the mesh.
@@ -2775,6 +2776,22 @@ void Renderer::cull(const MeshSlot& s, const CullView& frame, bool proxy) {
proxy = proxy && s.proxyCount.size() == s.drawCount.size() && s.proxyBounds.size() == s.drawCount.size();
CullView v = frame;
const glm::vec3 e = v.eye;
+ // Backface culling on (#68): back faces go on any mesh from any view, the GPU skipping each one and whole
+ // clusters facing away going first (in perspective: an orthographic view has no eye to judge them from).
+ if (forceBackfaces_) {
+ v.backfaces = !v.ortho;
+ cullBackfaces_ = true;
+ const size_t n = std::min(s.bounds.size(), s.drawCount.size());
+ for (uint32_t c = 0; c < n; ++c) {
+ if (s.drawCount[c] == 0 || !insideFrustum(v, s.bounds[c])) continue;
+ if (proxy && s.proxyCount[c] > 0 && !s.proxyStale[c]) {
+ if (!facingAway(v, s.proxyBounds[c])) proxyClusters_.push_back(c);
+ } else if (!facingAway(v, s.bounds[c])) {
+ drawClusters_.push_back(c);
+ }
+ }
+ return;
+ }
v.backfaces = !v.ortho && s.closed && s.volume > 0.0 && !s.anyHidden && s.box.valid() &&
(e.x < s.box.min.x || e.y < s.box.min.y || e.z < s.box.min.z || e.x > s.box.max.x || e.y > s.box.max.y ||
e.z > s.box.max.z);
diff --git a/src/render/Renderer.h b/src/render/Renderer.h
index cd271e02..74d43cf1 100644
--- a/src/render/Renderer.h
+++ b/src/render/Renderer.h
@@ -37,6 +37,9 @@ struct RenderSettings {
bool dimInactive = true; // SubTools other than the active one render slightly darker (ZBrush style)
bool motionProxy = false; // the view is moving (Fast Navigation): draw big meshes' lighter proxy (render/Clusters.h)
bool flatShading = false; // the scene's shading (Material palette): faceted; SubTools can override (core/Document.h)
+ // Backface culling (#68, Tool > Display): back faces are never drawn, on any mesh (closed or not, from any
+ // view). Off: they are skipped only where they can't show (a closed mesh seen from outside, Renderer::cull).
+ bool backfaceCulling = false;
// The view's background: the charcoal radial gradient (default) or one flat display (sRGB) colour (#21).
bool gradientBackground = true;
glm::vec3 backgroundColor{0.165f, 0.165f, 0.173f};
@@ -394,6 +397,7 @@ private:
std::vector<uint32_t> extraClusters_[4]; // drawSlot: clusters a ghost dab reaches (1), a draft moved (2), both
uint32_t draftId_ = 0; // setDraftNormals
bool cullBackfaces_ = false; // the last cull(): back faces can't show (so the GPU may skip them too)
+ bool forceBackfaces_ = false; // this frame: RenderSettings::backfaceCulling (#68), back faces never drawn
std::vector<uint32_t> cullScratch_;
size_t lastDrawn_ = 0;
// The frame draw() is drawing: matrices, the view's rectangle (x, y, w, h) and its culling.
diff --git a/tests/test_tablet.cpp b/tests/test_tablet.cpp
index 520cb867..8b3c0bae 100644
--- a/tests/test_tablet.cpp
+++ b/tests/test_tablet.cpp
@@ -168,6 +168,40 @@ TEST(pen_cursor_mouse_mode_moves_relatively) {
CHECK(near(x, 25.0f) && near(y, 10.0f));
}
+TEST(pen_cursor_mouse_mode_follows_the_system_cursor) {
+ // #72: in mouse mode the driver moves the system cursor; when the system says where it is, that is the cursor
+ // for every pen position (no cursor of our own to drift from it).
+ PenCursor c;
+ c.mouseMode = true;
+ c.cursorAt(400.0f, 300.0f);
+ c.proximity();
+ float x = 100.0f, y = 50.0f;
+ c.systemCursor(400.0f, 300.0f);
+ c.map(x, y, 1000);
+ CHECK(near(x, 400.0f) && near(y, 300.0f));
+ // The pen lifted, put down at another point, the driver's cursor moved elsewhere meanwhile: the system's.
+ c.proximity();
+ x = 900.0f, y = 700.0f;
+ c.systemCursor(250.0f, 120.0f);
+ c.map(x, y, 2000);
+ CHECK(near(x, 250.0f) && near(y, 120.0f));
+ // The driver moves its cursor less (or more) than the pen moved on the tablet: still the system's.
+ x = 950.0f, y = 700.0f;
+ c.systemCursor(260.0f, 121.0f);
+ c.map(x, y, 3000);
+ CHECK(near(x, 260.0f) && near(y, 121.0f));
+ // One reading per position: without a new one the pen carries on from the last (a system that can't say).
+ x = 960.0f, y = 705.0f;
+ c.map(x, y, 4000);
+ CHECK(near(x, 270.0f) && near(y, 126.0f));
+ // Pen mode ignores the system cursor (#54's case: the driver's mouse events land slightly off the pen).
+ c.mouseMode = false;
+ x = 50.0f, y = 60.0f;
+ c.systemCursor(300.0f, 300.0f);
+ c.map(x, y, 5000);
+ CHECK(near(x, 50.0f) && near(y, 60.0f));
+}
+
TEST(tablet_settings_mouse_mode_round_trip) {
TabletSettings t;
CHECK(!t.mouseMode);
diff --git a/tests/ui/backface_culling.sfui b/tests/ui/backface_culling.sfui
new file mode 100644
index 00000000..ee11b7ed
--- /dev/null
+++ b/tests/ui/backface_culling.sfui
@@ -0,0 +1,51 @@
+# Backface culling (#68): Tool > Display > Backface culling skips the back faces of every Part, also on open meshes
+# (which otherwise draw both sides). Off by default. Brushes then work only on faces that are drawn.
+run new_plane resolution=64
+expect_value backface_culling == 0
+camera 0 -60
+wait 0.6
+expect_value drawn_triangles > 0
+remember drawn_triangles top_off
+camera 0 60
+wait 0.6
+expect_value drawn_triangles == $top_off
+shot back-off
+
+click "Tool##palette.tool"
+click "Display##tool.display"
+expect "Backface culling##display"
+click "Backface culling##display"
+expect_value backface_culling == 1
+shot tool-display
+key escape
+camera 0 60
+wait 0.6
+expect_value drawn_triangles == 0
+shot back-on
+camera 0 -60
+wait 0.6
+expect_value drawn_triangles == $top_off
+
+# From below, the plane isn't drawn, so a stroke there finds nothing to sculpt.
+camera 0 60
+wait 0.6
+snapshot
+stroke 0.4 0.5 0.6 0.5
+expect_value moved == 0
+camera 0 -60
+wait 0.6
+stroke 0.4 0.5 0.6 0.5
+expect_value moved > 0
+key ctrl+z
+
+# A closed mesh looks the same either way.
+run new_sphere subdivisions=4
+camera 20 10
+wait 0.6
+remember drawn_triangles sphere_on
+click "Tool##palette.tool"
+click "Backface culling##display"
+expect_value backface_culling == 0
+key escape
+wait 0.6
+expect_value drawn_triangles >= $sphere_on
diff --git a/tests/ui/data/radial/right_button.json b/tests/ui/data/radial/right_button.json
new file mode 100644
index 00000000..9077041f
--- /dev/null
+++ b/tests/ui/data/radial/right_button.json
@@ -0,0 +1,13 @@
+{
+ "format": "sculptforge-radial-menu",
+ "version": 1,
+ "menu": {
+ "name": "Right button",
+ "button": "mouse_right",
+ "slots": [
+ {"action": "brush.smooth"},
+ {"action": "brush.inflate"},
+ {"action": "brush.pinch"}
+ ]
+ }
+}
diff --git a/tests/ui/radial_buttons.sfui b/tests/ui/radial_buttons.sfui
new file mode 100644
index 00000000..79f211ab
--- /dev/null
+++ b/tests/ui/radial_buttons.sfui
@@ -0,0 +1,60 @@
+# Radial menus on mouse buttons (#74): a plain press of the button opens the pie; with a modifier held the button
+# keeps its navigation (Alt+middle pans). A menu on the right button opens on a plain right-drag, while Alt+right
+# still zooms in the Maya style and Shift+right still turns the view in the ZBrush style.
+run new_sphere subdivisions=4
+
+# The middle button (sculpting.json): a plain press opens the pie, a right flick runs Inflate.
+radial_import data/radial/sculpting.json
+expect_value radial_menus == 3
+button_drag middle 0.5 0.5 0.57 0.5 0.3
+expect_value radial_open == 0
+expect_value radial_ran == 1
+expect_value brush_type == 4
+
+# Alt+middle pans the view, with no pie.
+remember camera_pan pan0
+hold alt
+button_drag middle 0.5 0.5 0.6 0.55 0.3
+hold none
+expect_value radial_open == 0
+expect_value camera_pan > $pan0+0.01
+
+# The right button (right_button.json): a plain right-drag opens the pie and runs the flicked item (a left flick:
+# Pinch), and the view doesn't turn.
+radial_import data/radial/right_button.json
+expect_value radial_menus == 4
+remember camera_yaw yaw0
+button_drag right 0.5 0.5 0.43 0.5 0.3
+expect_value radial_open == 0
+expect_value brush_type == 7
+expect_value camera_yaw >= $yaw0-0.0001
+expect_value camera_yaw <= $yaw0+0.0001
+
+# ZBrush style: Shift+right-drag still turns the view (the way to orbit while the right button opens the pie).
+hold shift
+button_drag right 0.5 0.5 0.62 0.5 0.3
+hold none
+expect_value radial_open == 0
+expect_value camera_yaw != $yaw0
+
+# Maya style: Alt+right zooms (horizontal drag) instead of opening the pie.
+click "Preferences##palette.preferences"
+click "Input##preferences.input"
+click "Maya##input.style_maya"
+expect_value input_style == 3
+key escape
+remember camera_distance dist0
+hold alt
+button_drag right 0.5 0.5 0.65 0.5 0.3
+hold none
+expect_value radial_open == 0
+expect_value camera_distance != $dist0
+# A plain right-drag still opens the pie in the Maya style (Maya's marking menus).
+button_drag right 0.5 0.5 0.57 0.5 0.3
+expect_value radial_open == 0
+expect_value brush_type == 4
+
+# Back to the ZBrush style for later tests.
+click "Preferences##palette.preferences"
+click "ZBrush-style##input.style_zbrush"
+key escape
diff --git a/tests/ui/tablet.sfui b/tests/ui/tablet.sfui
index 7d47f131..82f86f8d 100644
--- a/tests/ui/tablet.sfui
+++ b/tests/ui/tablet.sfui
@@ -170,6 +170,38 @@ remember cursor_x mouse_x
pen_enter 0.9 0.1
expect_value cursor_x >= $mouse_x-0.5
expect_value cursor_x <= $mouse_x+0.5
+# #72: the driver moves the system cursor itself, and that is the one cursor for the brush and the panels. The pen
+# lifted, the cursor moved elsewhere, the pen put down at another point: brush, panels and system cursor agree.
+pen_out
+os_cursor 0.3 0.6
+remember os_cursor_x os_x
+remember os_cursor_y os_y
+pen_enter 0.85 0.2
+expect_value cursor_x >= $os_x-1.5
+expect_value cursor_x <= $os_x+1.5
+expect_value cursor_y >= $os_y-1.5
+expect_value cursor_y <= $os_y+1.5
+expect_value ui_mouse_x >= $os_x-1.5
+expect_value ui_mouse_x <= $os_x+1.5
+os_cursor 0.4 0.55
+remember os_cursor_x os_x
+remember os_cursor_y os_y
+pen_hover 0.9 0.15
+expect_value cursor_x >= $os_x-1.5
+expect_value cursor_x <= $os_x+1.5
+expect_value ui_mouse_y >= $os_y-1.5
+expect_value ui_mouse_y <= $os_y+1.5
+pen_out
+mouse_move 0.65 0.35
+os_cursor 0.65 0.35
+remember os_cursor_x os_x
+remember os_cursor_y os_y
+pen_enter 0.1 0.9
+expect_value cursor_x >= $os_x-1.5
+expect_value cursor_x <= $os_x+1.5
+expect_value ui_mouse_x >= $os_x-1.5
+expect_value ui_mouse_x <= $os_x+1.5
+os_cursor off
# Pen mode again: the cursor is where the pen is.
pen_out
click "Preferences##palette.preferences"
diff --git a/tests/ui/viewport_cursor.sfui b/tests/ui/viewport_cursor.sfui
new file mode 100644
index 00000000..87191436
--- /dev/null
+++ b/tests/ui/viewport_cursor.sfui
@@ -0,0 +1,35 @@
+# The viewport cursor (#73): a crosshair over the 3D view where brushes act, the arrow over panels, menus and
+# popups (and their own resize and text cursors there). Preferences > Interface > Viewport cursor: Crosshair (the
+# default) or Arrow.
+run new_sphere subdivisions=3
+hover_model 0.5 0.5
+wait 0.1
+expect_value viewport_cursor == 100
+hover "Tool##palette.tool"
+expect_value viewport_cursor == 0
+hover_model 0.3 0.6
+wait 0.1
+expect_value viewport_cursor == 100
+# The pen hovering over the view: the crosshair too.
+pen_hover 0.5 0.5
+wait 0.1
+expect_value viewport_cursor == 100
+pen_out
+
+# A window floating over the view (Preferences) has the arrow; the view beside it the crosshair.
+click "Preferences##palette.preferences"
+click "Interface##preferences.interface"
+expect "Crosshair##viewport_cursor"
+hover "Arrow##viewport_cursor"
+expect_value viewport_cursor == 0
+click "Arrow##viewport_cursor"
+key escape
+hover_model 0.5 0.5
+wait 0.1
+expect_value viewport_cursor == 0
+click "Preferences##palette.preferences"
+click "Crosshair##viewport_cursor"
+key escape
+hover_model 0.5 0.5
+wait 0.1
+expect_value viewport_cursor == 100