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
Alpha options (#76), Blender Alt mask (#77), View > Lock camera (#62)
islandmed547397953bf4
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex ba2f40e8..3bf9186c 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -27,11 +27,23 @@ All notable changes to SculptForge are listed here. The format followsInsiders repository and posts to #insiders (`.github/workflows/insider-preview.yml`).### Fixed+- Blender style: Alt+left-drag on the model masks and Ctrl+Alt+left-drag unmasks, as Blender 5.1+'s default+ sculpt keymap does, instead of turning the view (#77, reported by TheRedWaxPolice). Beside the model Alt+drag still+ turns the view, and Alt+Shift+drag pans anywhere. Shift+F (Strength) sets the brush's Intensity instead of Smooth's.- UI test runs remove their temporary settings folder when they pass (thousands of runs had filled `/tmp`).- Custom and Community brushes (Clay Slab and other presets) show the whole alpha at Focal Shift -100, as thebuilt-in brushes do since #60: the stamp reaches its square's corners instead of being cut by the preset's roundtip (#75, reported by rodrigomoretto). At the default Focal Shift presets look as before; saved presets are unchanged.### Added+- Alpha options in the Alpha palette (#76, requested by rodrigomoretto): **Follow stroke direction** turns the alpha+ along the stroke with Blender's Rake smoothing (the direction is taken again every 20 pixels), **Angle** and **Angle+ jitter** turn it by a fixed or a random amount per dab, and **Tile across / down** repeat it 1 to 8 times inside+ the brush. They work with custom and Community brushes, are kept per brush, and the preview shows the tiling.+ Scripts: `brush_alpha_options`.+- **View > Lock camera** (Shift+L, the same switch as Preferences > Input > Start strokes off the model) and a+ **CAMERA LOCKED** chip in the status bar while it is on (#62 follow-up).+- Blender style: **Preferences > Input > Emulate 3 Button Mouse** (off by default): Alt+left-drag turns the view+ everywhere, as before.- Each brush keeps its own settings (#78, requested by dCo3lh0 and on Discord): Draw Size, Z Intensity, Falloff, RGBIntensity, the stroke (with Spray's scatter and Lazy Stroke's radius) and the alpha follow the brush, custom andCommunity brushes included. Switching back brings back the values that brush had this session; a brush not used yetdiff --git a/CMakeLists.txt b/CMakeLists.txtindex aff42cc5..fa9aaec5 100644--- a/CMakeLists.txt+++ b/CMakeLists.txt@@ -59,6 +59,7 @@ add_library(sculptforge_core STATICsrc/core/Json.cppsrc/core/BrushRecipe.cppsrc/core/BrushSettings.cpp+ src/core/AlphaOptions.cppsrc/core/BrushLibrary.cppsrc/core/Image.cppsrc/core/ImageTo3D.cppdiff --git a/docs/guide/navigation.md b/docs/guide/navigation.mdindex 2e6fc9f1..4363f044 100644--- a/docs/guide/navigation.md+++ b/docs/guide/navigation.md@@ -32,9 +32,10 @@ camera.> the model follows the cursor. The right-shelf Move, Zoom and Rotate buttons work as in ZBrush.> **Blender:** with **Preferences > Input > Style** on **Blender**, middle-drag rotates, <kbd>Shift</kbd>+middle-drag-> pans and <kbd>Ctrl</kbd>+middle-drag zooms. With a pen or a trackpad, <kbd>Alt</kbd>+left-drag does the same-> (add <kbd>Shift</kbd> to pan, <kbd>Ctrl</kbd> to zoom), anywhere on the canvas, as Blender's Emulate 3 Button-> Mouse. The numpad views, <kbd>Numpad .</kbd> and <kbd>Home</kbd> frame as in Blender. See+> pans and <kbd>Ctrl</kbd>+middle-drag zooms. With a pen or a trackpad, <kbd>Alt</kbd>+left-drag beside the model+> does the same (add <kbd>Shift</kbd> to pan, anywhere; <kbd>Ctrl</kbd> to zoom); on the model it masks, as in+> Blender 5.1 and later. Turn on **Preferences > Input > Emulate 3 Button Mouse** to make <kbd>Alt</kbd>+left-drag+> turn the view everywhere, as that Blender preference does. The numpad views, <kbd>Numpad .</kbd> and <kbd>Home</kbd> frame as in Blender. See> [Blender keys](shortcuts.md#blender-keys).## Mouse and pen@@ -52,7 +53,7 @@ camera.| 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 Part | <kbd>Numpad .</kbd> || Frame one Part | <kbd>Shift</kbd>+<kbd>Alt</kbd>+click it, or triple-click another Part (it becomes the active Part) |-| Sculpt from the background | Turn on **Preferences > Input > Start strokes off the model**, or press <kbd>Shift</kbd>+<kbd>L</kbd> (**Toggle strokes off the model**): a left-drag that starts beside the model sculpts once it reaches the surface |+| Sculpt from the background | Turn on **Preferences > Input > Start strokes off the model**, **View > Lock camera**, or press <kbd>Shift</kbd>+<kbd>L</kbd>: a left-drag that starts beside the model sculpts once it reaches the surface || 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: drag up to come closer, down to back away. With the ZBrush-style keys (**Preferences > Input**)@@ -62,7 +63,8 @@ they go the ZBrush way: drag up to zoom out, down to zoom in.Quick Menu. With it on, <kbd>Space</kbd> no longer opens the Quick Menu (a right click still does), and a space typed ina text field is never taken.-**Start strokes off the model** is off by default. With it on (a label at the top of the canvas says so), a+**Start strokes off the model** (also **View > Lock camera**) is off by default. With it on (a label at the top of+the canvas says so, and in the SculptForge layout the status bar shows **CAMERA LOCKED**), aleft-drag on the background no longer rotates: it waits, and the brush starts where the cursor first reaches themodel, so strokes that begin at the silhouette never turn the view by accident. <kbd>Ctrl</kbd> (mask) and<kbd>Shift</kbd> (smooth) strokes start the same way, and a <kbd>Ctrl</kbd>+click on the background still invertsdiff --git a/docs/guide/sculpting.md b/docs/guide/sculpting.mdindex ed66d3ad..8b3c4968 100644--- a/docs/guide/sculpting.md+++ b/docs/guide/sculpting.md@@ -381,9 +381,24 @@ points up the screen; with **Drag Stamp** it follows the drag direction instead.From a script: `brush_set_alpha name=square`, or `brush_set_alpha path=bark.png invert=true`.+### Alpha options++Under the preview in the **Alpha** palette:++| Option | What it does |+|---|---|+| **Follow stroke direction** | The alpha turns with the stroke, its top pointing the way you draw: scales, stitches and hair line up along the stroke. Small wobbles are smoothed out, as with Blender's Rake: the direction is taken again each time the cursor has gone 20 pixels. |+| **Angle** | Turns the alpha by a fixed angle (-180 to 180 degrees, counter-clockwise), on its own or on top of the stroke's direction. |+| **Angle jitter** | Turns each dab by a random angle, up to this many degrees either way, to break up repeats. |+| **Tile across** / **Tile down** | Repeats the alpha 1 to 8 times across and down inside the brush; the preview shows the result. |++They work with every brush, custom and Community brushes included, and each brush keeps its own (see+[Each brush keeps its own settings](#each-brush-keeps-its-own-settings)). From a script:+`brush_alpha_options follow_stroke=true angle=30 angle_jitter=10 tile_x=2 tile_y=2`.+> **ZBrush:** there is no alpha library browser with hundreds of alphas yet, and alpha options such as-> MidValue, Rf (radial fade) or tiling are not available. Any grayscale image works, including alphas you-> already have as PNG.+> MidValue or Rf (radial fade) are not available. Any grayscale image works, including alphas you already have as+> PNG.## Vector displacement brushesdiff --git a/docs/guide/shortcuts.md b/docs/guide/shortcuts.mdindex 55e3d1b9..d06173a3 100644--- a/docs/guide/shortcuts.md+++ b/docs/guide/shortcuts.md@@ -111,7 +111,6 @@ generated from SculptForge's action registry, the same source as the Controls wi| Save UI... | <kbd>Ctrl</kbd>+<kbd>Alt</kbd>+<kbd>Shift</kbd>+<kbd>I</kbd> | Save the layout, shortcuts and interface preferences to a file you can share. || Shelves | <kbd>Tab</kbd> | Hide or show the shelves and trays around the canvas. || Store Config | <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>I</kbd> | Keep the current layout, shortcuts and interface preferences for future sessions. Like ZBrush, SculptForge never saves them on its own. |-| Toggle strokes off the model | <kbd>Shift</kbd>+<kbd>L</kbd> | Turn Preferences > Input > Start strokes off the model on or off: with it on, a left-drag on the background sculpts once it reaches the model instead of turning the view (#62). |### Render@@ -178,6 +177,12 @@ generated from SculptForge's action registry, the same source as the Controls wi|---|---|---|| UV Editor | <kbd>Alt</kbd>+<kbd>U</kbd> | Open the UV Editor: the Part's UV layout in 2D over the UDIM tiles. Select vertices, edges, faces or islands (here or on the model), move, rotate and scale them, mark seams, unwrap, pack, set texel density and lay islands into trim sheet strips. Stretch and texel density show live on the model while you edit. |+### View++| Action | Keys | What it does |+|---|---|---|+| Lock camera | <kbd>Shift</kbd>+<kbd>L</kbd> | Lock the camera for left-drags: a drag that starts on the background sculpts once it reaches the model instead of turning the view (Preferences > Input > Start strokes off the model, #62). The status bar shows CAMERA LOCKED while it is on. Right-drag or Alt+drag still move the view. Shift+L turns it on and off. |+<!-- END GENERATED: shortcuts -->## Mouse and pen gestures@@ -301,15 +306,16 @@ style, turns zoom drags around (the mouse wheel stays as it is).## Blender keysWith **Preferences > Input > Style** on **Blender** (also at the top of the Controls window, <kbd>F1</kbd>), the-view and the sculpt keys work as in Blender 4.2 and later, Sculpt Mode. Compared with the table above, these+view and the sculpt keys work as in Blender 4.2 and later, Sculpt Mode (with 5.1's Alt mask). Compared with the table above, thesechange in the Blender style:| To | Blender style ||---|---|-| Rotate | Middle-drag, or <kbd>Alt</kbd>+left-drag (pens, trackpads: Blender's Emulate 3 Button Mouse), or left-drag beside the model |+| Rotate | Middle-drag, or <kbd>Alt</kbd>+left-drag beside the model (everywhere with **Preferences > Input > Emulate 3 Button Mouse**, for pens and trackpads), or left-drag beside the model || Pan | <kbd>Shift</kbd>+middle-drag, or <kbd>Alt</kbd>+<kbd>Shift</kbd>+left-drag || Zoom | Mouse wheel, <kbd>Ctrl</kbd>+middle-drag (up: closer), <kbd>Alt</kbd>+<kbd>Ctrl</kbd>+left-drag, <kbd>Numpad Plus</kbd> / <kbd>Numpad Minus</kbd> || Invert the brush (subtract) | Hold <kbd>Ctrl</kbd> while sculpting |+| Mask / unmask | <kbd>Alt</kbd>+drag / <kbd>Ctrl</kbd>+<kbd>Alt</kbd>+drag on the model (Blender 5.1 and later), or the Mask brush (<kbd>M</kbd>) || Smooth | Hold <kbd>Shift</kbd> while sculpting || Front, right, top view | <kbd>Numpad 1</kbd>, <kbd>Numpad 3</kbd>, <kbd>Numpad 7</kbd>; with <kbd>Ctrl</kbd>: back, left, bottom || Orthographic on or off | <kbd>Numpad 5</kbd> (the axis views turn it on until you rotate again) |diff --git a/docs/guide/whats-new.md b/docs/guide/whats-new.mdindex 00e1b9f8..5607ca23 100644--- a/docs/guide/whats-new.md+++ b/docs/guide/whats-new.md@@ -5,6 +5,18 @@ chapter opens by itself the first time you start a new version; you can always f**Help > What's New**. Every detail is in the[changelog](https://github.com/islandmed/SculptForge/blob/main/CHANGELOG.md).+## Version 0.10.8++- **Alpha options** (**Alpha** palette): **Follow stroke direction** turns the alpha along the stroke, smoothed as+ Blender's Rake does; **Angle** and **Angle jitter** turn it by a fixed or a random amount; **Tile** repeats it+ inside the brush. They work with custom and Community brushes too, and each brush keeps its own (#76). See+ [Alpha options](sculpting.md#alpha-options).+- **Blender style: Alt+drag masks** on the model and Ctrl+Alt+drag unmasks, as in Blender 5.1 and later; beside the+ model Alt+drag still turns the view. **Preferences > Input > Emulate 3 Button Mouse** makes Alt+drag turn the view+ everywhere. Shift+F now sets the brush's Intensity, not Smooth's (#77).+- **View > Lock camera** (<kbd>Shift</kbd>+<kbd>L</kbd>): drags that start beside the model sculpt instead of+ turning the view, and the status bar shows **CAMERA LOCKED** while it is on (#62).+## Version 0.10.7- **A clearer membership card**: the three memberships side by side with what each one gets you, in your look'sdiff --git a/src/app/App.cpp b/src/app/App.cppindex afc385b5..622222f9 100644--- a/src/app/App.cpp+++ b/src/app/App.cpp@@ -1416,8 +1416,9 @@ void App::onMouseDown(float x, float y, Uint8 button) {}}-// Blender: middle-drag orbits, Shift+middle pans, Ctrl+middle zooms; Alt+left-drag is the emulated middle button-// (pens, trackpads); the right button drags the same way. True when the press started navigating.+// Blender: middle-drag orbits, Shift+middle pans, Ctrl+middle zooms; Alt+left-drag beside the model (anywhere with+// Emulate 3 Button Mouse) is the emulated middle button (pens, trackpads); the right button drags the same way. True+// when the press started navigating.bool App::mayaNavigationDown(Uint8 button) {const SDL_Keymod keys = SDL_GetModState(); // the keyboard itself, before inputMods' Maya mappingif (!(keys & SDL_KMOD_ALT) || ctrlDown(keys) || (keys & SDL_KMOD_SHIFT)) return false; // Alt alone navigates@@ -1431,7 +1432,12 @@ bool App::mayaNavigationDown(Uint8 button) {bool App::blenderNavigationDown(Uint8 button) {const SDL_Keymod keys = SDL_GetModState(); // the keyboard itself: blenderMods turns Ctrl into the invert- const bool emulated = button == SDL_BUTTON_LEFT && (keys & SDL_KMOD_ALT);+ // Alt+left: Blender 5.1+ masks with it on the model (blenderMods, #77); beside the model, or always with+ // Preferences > Input > Emulate 3 Button Mouse, it is the emulated middle button.+ RayHit hit;+ const bool emulated = button == SDL_BUTTON_LEFT && (keys & SDL_KMOD_ALT) &&+ (uiPrefs_.emulate3Button || (keys & SDL_KMOD_SHIFT) || previewLod_ >= 0 ||+ !pick(mouseX_, mouseY_, hit)); // (Alt+Shift: unbound in Blender, pans here anywhere)if (button != SDL_BUTTON_MIDDLE && button != SDL_BUTTON_RIGHT && !emulated) return false;drag_ = (keys & SDL_KMOD_SHIFT) ? Drag::Pan : ctrlDown(keys) ? Drag::Zoom : Drag::Orbit;return true;@@ -1888,6 +1894,7 @@ void App::dabAt(float x, float y, float pressure) {if (strokeRadiusProbe_) strokeRadiusProbe_->push_back(st.radiusPx);}const Camera& cam = dabView_ ? dabView_->camera : camera_;+ const glm::vec2 pathPoint(x, y); // (before any scatter: the rake follows the stroke itself)const BrushRecipe* recipe = st.recipe;if (recipe && recipe->jitter > 0.0f) {// Deterministic per-stroke scatter (xorshift).@@ -1935,6 +1942,15 @@ void App::dabAt(float x, float y, float pressure) {return;}p.alpha = st.alpha;+ // Alpha options (#76): the fixed angle, the jitter and (Follow stroke direction) Blender's Rake, on top of+ // Spray's own turn. Custom and Community brushes get them too: dabRecipe turns their alpha by alphaUp.+ if (!haveLastDab_) {+ alphaRake_.reset(pathPoint);+ alphaSeed_ = 0x9e3779b9u;+ }+ alphaRake_.update(pathPoint);+ dabAngle_ += alphaDabAngle(st.alphaOptions, alphaRake_, alphaSeed_);+ lastDabAngle_ = dabAngle_;p.alphaUp = cam.orientation() * glm::vec3(-std::sin(dabAngle_), std::cos(dabAngle_), 0.0f); // screenUpVectorp.vdm = st.vdm;p.strokeDelta = haveLastDab_ ? hit.position - lastDabHit_ : glm::vec3(0.0f);diff --git a/src/app/App.h b/src/app/App.hindex 074bbdbc..72d6059c 100644--- a/src/app/App.h+++ b/src/app/App.h@@ -290,6 +290,7 @@ private:bool pressureSize = false, pressureStrength = true, invert = false, frontFacesOnly = false;bool connectedOnly = false, viewFalloff = false; // the falloff options (Brush palette)bool mask = false, paint = false, sculpt = true, visible = true;+ AlphaOptions alphaOptions; // Follow stroke direction, Angle, Angle jitter (#76; Tile is the alpha's own)BrushType brush = BrushType::Standard;StrokeType strokeType = StrokeType::Dots;Symmetry symmetry;@@ -568,6 +569,13 @@ private:glm::vec3 dragAnchorHit_{0.0f};float dabRadiusScale_ = 1.0f, dabStrengthScale_ = 1.0f, dabAngle_ = 0.0f; // per-dab overridesbool alphaInvert_ = false;+ // Alpha options (#76, core/AlphaOptions.h): the Alpha palette's Follow stroke direction, Angle, Angle jitter and+ // Tile, kept per brush (#78). The rake and the jitter's seed start again with each stroke (dabAt).+ AlphaOptions alphaOptions_;+ AlphaRake alphaRake_;+ uint32_t alphaSeed_ = 1;+ float lastDabAngle_ = 0.0f; // radians (UI tests: last_dab_angle)+ void drawAlphaOptions();std::mutex alphaMutex_;std::string pendingAlphaPath_; // set by the file dialog thread// Vector displacement brushes (PanelVdm.cpp, core/Vdm.h): the Brush palette's Vector Displacement section,@@ -1549,6 +1557,8 @@ public:private:void initBrushSettings();void syncBrushSettings(); // every frame, outside strokes+ void syncAlphaTile(); // the brush's Tile onto the current alpha+ void registerAlphaOptionsCommand(); // brush_alpha_options (#76)std::string brushSettingsPath() const;BrushSettingsStore brushSettings_;std::string brushSettingsKey_; // the brush the live values belong todiff --git a/src/app/AsyncStroke.cpp b/src/app/AsyncStroke.cppindex 9e3ce384..ecc75e06 100644--- a/src/app/AsyncStroke.cpp+++ b/src/app/AsyncStroke.cpp@@ -314,6 +314,7 @@ App::DabSettings App::dabSettings() const {st.focal = focalShift_;st.maskStrength = maskStrength_;st.sprayScatter = sprayScatter_;+ st.alphaOptions = alphaOptions_;st.pressureSize = pressureSize_;st.pressureStrength = pressureStrength_;st.invert = strokeInvert_;diff --git a/src/app/BrushSettingsUi.cpp b/src/app/BrushSettingsUi.cppindex ebe42205..119ee96c 100644--- a/src/app/BrushSettingsUi.cpp+++ b/src/app/BrushSettingsUi.cpp@@ -10,6 +10,7 @@#include "core/Image.h"#include <algorithm>+#include <cmath>#include <cctype>#include <filesystem>@@ -47,6 +48,7 @@ BrushToolSettings App::liveBrushSettings() const {s.alphaName = a.empty() ? std::string("Round") : a.name;s.alphaPath = a.empty() ? std::string() : a.path;s.alphaInvert = !s.alphaPath.empty() && a.inverted;+ s.alphaOptions = alphaOptions_;return s;}@@ -60,6 +62,7 @@ void App::applyBrushSettings(const BrushToolSettings& in) {strokeType_ = s.stroke;sprayScatter_ = s.sprayScatter;lazyMouse_.radius = s.lazyRadius;+ alphaOptions_ = s.alphaOptions;// The alpha, loaded only when it differs; one that can't be loaded any more (a moved image) leaves the current.const BrushToolSettings live = liveBrushSettings();if (lower(live.alphaName) == lower(s.alphaName) && live.alphaPath == s.alphaPath && live.alphaInvert == s.alphaInvert)@@ -83,6 +86,7 @@ void App::initBrushSettings() {brushSettingsOn_ = !recording && !options_.benchmark && options_.timelapsePath.empty() &&options_.renderPath.empty() && options_.measureIdle <= 0.0f && options_.measureStroke <= 0.0f;brushSettingsKey_ = currentBrushKey();+ registerAlphaOptionsCommand();if (!brushSettingsOn_) return;std::string err;if (const std::string path = brushSettingsPath(); !path.empty() && !brushSettings_.load(path, err))@@ -91,11 +95,45 @@ void App::initBrushSettings() {}void App::syncBrushSettings() {- if (!brushSettingsOn_ || drag_ != Drag::None || doc_.sculptor.strokeActive()) return;+ if (drag_ != Drag::None || doc_.sculptor.strokeActive()) return;+ syncAlphaTile();+ if (!brushSettingsOn_) return;const std::string key = currentBrushKey();if (key == brushSettingsKey_) return;applyBrushSettings(brushSettings_.switchBrush(brushSettingsKey_, key, liveBrushSettings()));brushSettingsKey_ = key;+ syncAlphaTile();+}++void App::syncAlphaTile() { // Tile lives on the alpha (a new alpha starts at 1 x 1): the brush's option wins+ alphaOptions_.clamp();+ doc_.brushAlpha.tileX = alphaOptions_.tileX;+ doc_.brushAlpha.tileY = alphaOptions_.tileY;+}++void App::registerAlphaOptionsCommand() {+ using T = ParamSpec::Type;+ commands_.add({"brush_alpha_options",+ "The brush's alpha options (Alpha palette; kept per brush): follow the stroke's direction, a fixed "+ "angle, a random angle per dab, and tiling. Omitted options stay as they are.",+ {{"follow_stroke", T::Bool, "Turn the alpha along the stroke (smoothed over 20 pixels).", false},+ {"angle", T::Number, "Fixed angle in degrees, -180..180 (counter-clockwise).", false},+ {"angle_jitter", T::Number, "Random turn per dab, up to this many degrees either way (0..180).", false},+ {"tile_x", T::Number, "Repeat the alpha this many times across the dab (1..8).", false},+ {"tile_y", T::Number, "Repeat the alpha this many times down the dab (1..8).", false}},+ [this](Document&, const Args& a) -> CommandResult {+ AlphaOptions& o = alphaOptions_;+ o.followStroke = argBool(a, "follow_stroke", o.followStroke);+ o.angle = float(argNumber(a, "angle", o.angle));+ o.jitter = float(argNumber(a, "angle_jitter", o.jitter));+ o.tileX = int(std::lround(argNumber(a, "tile_x", o.tileX)));+ o.tileY = int(std::lround(argNumber(a, "tile_y", o.tileY)));+ syncAlphaTile();+ return {true, std::string("Alpha: ") + (o.followStroke ? "follows the stroke, " : "") + "angle " ++ std::to_string(int(std::lround(o.angle))) + ", jitter " ++ std::to_string(int(std::lround(o.jitter))) + ", tile " ++ std::to_string(o.tileX) + " x " + std::to_string(o.tileY)};+ }});}void App::saveBrushSettings() {diff --git a/src/app/Config.cpp b/src/app/Config.cppindex 93ecfd8e..cd09a572 100644--- a/src/app/Config.cpp+++ b/src/app/Config.cpp@@ -80,6 +80,7 @@ Json toJson(const UiPrefs& p) {j.set("emulateNumpad", p.emulateNumpad);j.set("rightClickQuickMenu", p.rightClickQuickMenu);j.set("spaceCamera", p.spaceCamera);+ j.set("emulate3Button", p.emulate3Button);j.set("mayaZoomHorizontal", p.mayaZoomHorizontal);j.set("invertZoom", p.invertZoom);j.set("alongNormal", std::string(p.alongNormal == 1 ? "always" : p.alongNormal == 2 ? "never" : "invert_key"));@@ -132,6 +133,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.emulate3Button = j["emulate3Button"].asBool(p.emulate3Button);p.mayaZoomHorizontal = j["mayaZoomHorizontal"].asBool(p.mayaZoomHorizontal);p.invertZoom = j["invertZoom"].asBool(p.invertZoom);if (j["alongNormal"].isString()) {diff --git a/src/app/Config.h b/src/app/Config.hindex 72e0a278..7d863f55 100644--- a/src/app/Config.h+++ b/src/app/Config.h@@ -40,6 +40,9 @@ struct UiPrefs {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)+ // Blender style (#77): off, as Blender 5.1+'s default keymap, Alt+left-drag on the model masks (Ctrl+Alt unmasks)+ // and turns the view only beside the model; on (Blender's Emulate 3 Button Mouse) it always turns the view.+ bool emulate3Button = false;// Zoom drags (#32): the Maya style zooms with a sideways drag (right = in), as Maya's own dolly; false makes it// vertical as the other styles. invertZoom turns every zoom drag around.bool mayaZoomHorizontal = true;diff --git a/src/app/Input.cpp b/src/app/Input.cppindex 64a79801..4a957624 100644--- a/src/app/Input.cpp+++ b/src/app/Input.cpp@@ -155,20 +155,27 @@ void App::registerInputActions() {"and with Ctrl held too a drag zooms (#43). Off by default: in ZBrush, Space opens the Quick Menu (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.emulate_3_button", "Emulate 3 Button Mouse", nullptr, "Preferences > Input", "",+ "Blender style: Alt+left-drag always turns the view (Shift pans, Ctrl zooms), as Blender's Emulate 3 Button "+ "Mouse preference does, for pens and trackpads. Off (as Blender's default keymap, 5.1 and later): Alt+left-drag "+ "on the model masks and Ctrl+Alt+left-drag unmasks; beside the model it still turns the view (#77).",+ [this] { uiPrefs_.emulate3Button = !uiPrefs_.emulate3Button; }, [this] { return uiPrefs_.emulate3Button; });add("input.air_strokes", "Start strokes off the model", nullptr, "Preferences > Input", "","A left-drag that starts on the background begins a brush stroke instead of turning the view; the brush ""touches the model once the cursor reaches it (#62). Ctrl (mask) and Shift (smooth) work the same way, and ""a Ctrl+click on the background still inverts the mask. The view still turns with a right-drag or a pen ""button set to Right click, pans with Alt+drag or a middle-drag, and moves with Space held if Hold Space is "- "on; with Blender or Maya keys, Alt+left-drag orbits. Shift+L turns it on and off.",+ "on; with Maya keys, Alt+left-drag orbits, with Blender keys beside the model. Shift+L (View > Lock camera) "+ "turns it on and off.",[this] { uiPrefs_.airStrokes = !uiPrefs_.airStrokes; }, [this] { return uiPrefs_.airStrokes; });- add("input.toggle_air_strokes", "Toggle strokes off the model", nullptr, "Preferences > Input", "Shift+L",- "Turn Preferences > Input > Start strokes off the model on or off: with it on, a left-drag on the background "- "sculpts once it reaches the model instead of turning the view (#62).",+ add("input.toggle_air_strokes", "Lock camera", nullptr, "View", "Shift+L",+ "Lock the camera for left-drags: a drag that starts on the background sculpts once it reaches the model "+ "instead of turning the view (Preferences > Input > Start strokes off the model, #62). The status bar shows "+ "CAMERA LOCKED while it is on. Right-drag or Alt+drag still move the view. Shift+L turns it on and off.",[this] {uiPrefs_.airStrokes = !uiPrefs_.airStrokes;- status_ = uiPrefs_.airStrokes ? "Strokes start off the model: right-drag or Alt+drag to move the view"- : "Strokes off the model: off (a drag on the background turns the view)";+ status_ = uiPrefs_.airStrokes ? "Camera locked: drags start strokes; right-drag or Alt+drag to move the view"+ : "Camera unlocked: a drag on the background turns the view";},[this] { return uiPrefs_.airStrokes; });add("input.surface_cursor", "Cursor follows surface", nullptr, "Preferences > Input", "",@@ -345,10 +352,14 @@ void App::frameActiveSubtool() {SDL_Keymod App::blenderMods(SDL_Keymod keyboard) const {// What the sculpting code reads: Alt inverts, Ctrl masks, Shift smooths (the ZBrush meanings). Blender inverts- // with Ctrl and masks with the Mask brush; its Alt is the emulated middle button, so it means nothing here.+ // with Ctrl and masks with the Mask brush, or (5.1+, #77) with Alt held: Alt+drag masks, Ctrl+Alt+drag unmasks.+ // With Emulate 3 Button Mouse, Alt is the emulated middle button and means nothing here.SDL_Keymod out = keyboard & SDL_KMOD_SHIFT;const bool ctrl = (keyboard & (SDL_KMOD_CTRL | SDL_KMOD_GUI)) != 0;- if (maskBrushActive()) {+ if ((keyboard & SDL_KMOD_ALT) && !uiPrefs_.emulate3Button) {+ out = SDL_KMOD_LCTRL; // the mask brush, as ZBrush's Ctrl (not with Shift: that would hide)+ if (ctrl) out = SDL_Keymod(out | SDL_KMOD_LALT); // ... unmasking, as ZBrush's Ctrl+Alt+ } else if (maskBrushActive()) {if (!(keyboard & SDL_KMOD_SHIFT)) out |= SDL_KMOD_LCTRL; // Shift still smooths the surfaceif (ctrl) out |= SDL_KMOD_LALT; // Ctrl unmasks} else if (ctrl) {@@ -443,6 +454,11 @@ void App::drawInputSection() {if (ui::Checkbox("Hold Space and drag to move the camera##input.space_camera", &spaceCamera))uiPrefs_.spaceCamera = spaceCamera;ui::HelpAction(*this, "input.space_camera");+ if (blenderStyle()) {+ bool emulate = uiPrefs_.emulate3Button;+ if (ui::Checkbox("Emulate 3 Button Mouse##input.emulate_3_button", &emulate)) uiPrefs_.emulate3Button = emulate;+ ui::HelpAction(*this, "input.emulate_3_button");+ }if (mayaStyle()) {int zoom = uiPrefs_.mayaZoomHorizontal ? 0 : 1;ImGui::TextDisabled("%s", tr("Zoom drag"));diff --git a/src/app/Palettes.cpp b/src/app/Palettes.cppindex dbc41cdc..02d61c72 100644--- a/src/app/Palettes.cpp+++ b/src/app/Palettes.cpp@@ -615,6 +615,9 @@ void App::drawPalette_Render() {ImGui::Checkbox(tr("Show Splats"), &renderSettings_.showSplats);ImGui::EndDisabled();ui::HelpAction(*this, "view.splats");+ bool lockCamera = uiPrefs_.airStrokes; // #62: drags on the background start strokes (Shift+L)+ if (ui::Checkbox("Lock camera##view.lock_camera", &lockCamera)) uiPrefs_.airStrokes = lockCamera;+ ui::HelpAction(*this, "input.toggle_air_strokes");drawBackgroundControls("render");actionRow(*this, {"view.frame", "view.fullscreen"});actionRow(*this, {"ui.lightbox", "ui.console"}); // (the SculptForge layout's View menu: they left the shelf)diff --git a/src/app/PanelBrushes.cpp b/src/app/PanelBrushes.cppindex e17e3d61..68eab9ed 100644--- a/src/app/PanelBrushes.cpp+++ b/src/app/PanelBrushes.cpp@@ -58,7 +58,7 @@ void App::drawAlphaSection() {ImGui::SetCursorPosX(ImGui::GetCursorPosX() + (ImGui::GetContentRegionAvail().x - big) * 0.5f);const ImVec2 p0 = ImGui::GetCursorScreenPos();ImGui::Dummy(ImVec2(big, big));- if (ImTextureID tex = thumbs_.alpha(alpha))+ if (ImTextureID tex = alpha.tiled() ? ImTextureID{} : thumbs_.alpha(alpha)) // (a tiled alpha: drawn as it stamps)ImGui::GetWindowDrawList()->AddImage(tex, p0, ImVec2(p0.x + big, p0.y + big));elsepreview(ImGui::GetWindowDrawList(), alpha, p0, big, 40);@@ -66,10 +66,43 @@ void App::drawAlphaSection() {ImGui::SetCursorPosX(ImGui::GetCursorPosX() + (ImGui::GetContentRegionAvail().x - nameSize.x) * 0.5f);ImGui::TextUnformatted(alpha.name.c_str());+ drawAlphaOptions();// Built-in and library alphas, then Load image... and Invert loaded image (Pickers.cpp), as in the alpha picker.drawAlphaGrid(*this, GridMode::Palette);}+// Alpha options (#76): how the alpha turns and repeats on each dab, kept per brush (#78).+void App::drawAlphaOptions() {+ AlphaOptions& o = alphaOptions_;+ ui::Checkbox("Follow stroke direction##alpha.follow_stroke", &o.followStroke);+ ui::HelpText("Follow stroke direction", nullptr,+ "The alpha turns with the stroke: its top points the way you are drawing, for scales, stitches and "+ "hair that line up along the stroke. Small wobbles are smoothed out (the direction is taken every "+ "20 pixels, as Blender's Rake does). Angle still adds its turn.",+ "Alpha");+ ImGui::SetNextItemWidth(-1);+ ui::SliderInside("##alpha_angle", &o.angle, -180.0f, 180.0f, "Angle %.0f");+ ui::HelpText("Angle", nullptr, "Turn the alpha by a fixed angle in degrees (counter-clockwise); Ctrl+click to type.",+ "Alpha");+ ImGui::SetNextItemWidth(-1);+ ui::SliderInside("##alpha_angle_jitter", &o.jitter, 0.0f, 180.0f, "Angle jitter %.0f");+ ui::HelpText("Angle jitter", nullptr,+ "Turn each dab by a random angle, up to this many degrees either way: breaks up repeats in skin, "+ "rock and noise alphas.",+ "Alpha");+ const float half = (ImGui::GetContentRegionAvail().x - ImGui::GetStyle().ItemSpacing.x) * 0.5f;+ ImGui::SetNextItemWidth(half);+ float tileX = float(o.tileX), tileY = float(o.tileY);+ if (ui::SliderInside("##alpha_tile_x", &tileX, 1.0f, 8.0f, "Tile across %.0f")) o.tileX = int(std::lround(tileX));+ ui::HelpText("Tile across", nullptr, "Repeat the alpha this many times across the brush (1 = once).", "Alpha");+ ImGui::SameLine();+ ImGui::SetNextItemWidth(-1);+ if (ui::SliderInside("##alpha_tile_y", &tileY, 1.0f, 8.0f, "Tile down %.0f")) o.tileY = int(std::lround(tileY));+ ui::HelpText("Tile down", nullptr, "Repeat the alpha this many times down the brush (1 = once).", "Alpha");+ syncAlphaTile();+ ImGui::Dummy(ImVec2(0, 2.0f * uiScale_));+}+// SnakeHook: pull the region under the click along with the cursor, like Move,// but re-centred on the pulled tip every step so it can be dragged out into horns.void App::snakeHookTo(float x, float y) {diff --git a/src/app/Pickers.cpp b/src/app/Pickers.cppindex daeea1c0..f98572db 100644--- a/src/app/Pickers.cpp+++ b/src/app/Pickers.cpp@@ -1009,7 +1009,9 @@ bool pickerOpen() { return st().open || st().slider >= 0; }void PickerUi::sizePopup(App& app, Slider which) {State& s = st();s.slider = int(which);- s.sliderSmooth = app.activeBrush() == BrushType::Smooth;+ // Smooth's own Intensity when Smooth is the brush or (ZBrush) Shift is held. Not Shift in the Blender style:+ // there Shift+F is the brush's Strength, as in Blender, and Shift has no smoothing meaning for a key.+ s.sliderSmooth = app.blenderStyle() ? app.brush_ == BrushType::Smooth : app.activeBrush() == BrushType::Smooth;// The brush cursor's own position (SDL's window coordinates, the brush ring's centre) rather than ImGui's// MousePos: on Windows ImGui's comes from the global cursor minus the window position while no button is held,// and pen drivers' stray mouse events move it too, so the slider opened away from the cursor (#9).diff --git a/src/app/Shell.cpp b/src/app/Shell.cppindex e947616f..3e6a07dc 100644--- a/src/app/Shell.cpp+++ b/src/app/Shell.cpp@@ -1397,6 +1397,8 @@ void App::drawStatusBar(const ShellGeometry& g) {char fps[16];std::snprintf(fps, sizeof fps, "%3.0f", fpsShown_);mods.push_back({ICON_LC_ACTIVITY, "fps", fps});+ // View > Lock camera (#62, Shift+L): left-drags on the background start strokes instead of turning the view.+ if (uiPrefs_.airStrokes) mods.push_back({ICON_LC_LOCK, "camera", upper(tr("Camera locked")), true});}ImFont* labelFont = theme::look.id != 0 && fontMonoTiny_ ? fontMonoTiny_ : fontTiny_ ? fontTiny_ : monoSmall;auto moduleW = [&](const StatusModule& m) {@@ -1412,6 +1414,7 @@ void App::drawStatusBar(const ShellGeometry& g) {const float sepW = style == Status::Terminal ? textW(monoSmall, " | ") : style == Status::TitleBlock ? 0.0f : 16.0f * s;// Drop the least important modules (from the file name inwards) until they fit beside the menus.std::vector<int> shown = {0, 1, 2, 3, 4};+ if (mods.size() > 5) shown.insert(shown.begin() + 1, 5); // Camera locked, beside the mode (never dropped)auto total = [&] {float w = 0.0f;for (size_t k = 0; k < shown.size(); ++k) w += moduleW(mods[size_t(shown[k])]) + (k ? sepW : 0.0f);@@ -1424,6 +1427,7 @@ void App::drawStatusBar(const ShellGeometry& g) {for (size_t k = 0; k < shown.size(); ++k) {const StatusModule& m = mods[size_t(shown[k])];const float w = moduleW(m);+ ImGui::LogText("%s", m.value.c_str()); // (UI tests read the bar)if (k) {if (style == Status::Terminal) textAt(monoSmall, mx, theme::textDim, " | ");mx += sepW;diff --git a/src/app/UiTest.cpp b/src/app/UiTest.cppindex 6a394acc..c2ff5ee8 100644--- a/src/app/UiTest.cpp+++ b/src/app/UiTest.cpp@@ -461,12 +461,21 @@ double Demo::query(const std::string& name, bool& known) const {if (name == "draw_size") return std::round(app_.radiusPx_);if (name == "brush_settings_saved") return double(app_.brushSettingsStore().savedCount()); // (#78)if (name == "share_brush_size") return app_.brushSettingsStore().shareSizeIntensity ? 1.0 : 0.0;+ if (name == "alpha_follow") return app_.alphaOptions_.followStroke ? 1.0 : 0.0; // alpha options (#76)+ if (name == "alpha_angle") return std::round(app_.alphaOptions_.angle);+ if (name == "alpha_tile_x") return double(app_.doc_.brushAlpha.tileX);+ if (name == "alpha_tile_y") return double(app_.doc_.brushAlpha.tileY);+ if (name == "last_dab_angle") { // degrees, -180..180: the alpha's turn on the last dab+ const float d = std::remainder(glm::degrees(app_.lastDabAngle_), 360.0f);+ return std::round(d);+ }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 == "look") return double(app_.uiPrefs_.look.look); // 0 Classic, 1 Forge Terminal, 2 Phosphor, 3 Blueprintif (name == "shell_layout") return double(app_.uiPrefs_.shellLayout); // 0 ZBrush-style, 1 SculptForgeif (name == "air_strokes") return app_.uiPrefs_.airStrokes ? 1.0 : 0.0;+ if (name == "emulate_3_button") return app_.uiPrefs_.emulate3Button ? 1.0 : 0.0; // Blender style (#77)if (name == "space_held") return app_.spaceHeld_ ? 1.0 : 0.0;if (name == "radial_open") return app_.radial_.menu >= 0 ? 1.0 : 0.0;if (name == "radial_menu") return double(app_.radial_.menu); // -1: none opendiff --git a/src/core/AlphaOptions.cpp b/src/core/AlphaOptions.cppnew file mode 100644index 00000000..4aa4f67a--- /dev/null+++ b/src/core/AlphaOptions.cpp@@ -0,0 +1,48 @@+// SculptForge - open source digital sculpting+// SPDX-License-Identifier: GPL-3.0-or-later+#include "core/AlphaOptions.h"++#include <algorithm>+#include <cmath>++namespace sf {++void AlphaOptions::clamp() {+ angle = std::clamp(angle, -180.0f, 180.0f);+ jitter = std::clamp(jitter, 0.0f, 180.0f);+ tileX = std::clamp(tileX, 1, 8);+ tileY = std::clamp(tileY, 1, 8);+}++void AlphaRake::reset(glm::vec2 at) {+ last_ = at;+ angle_ = 0.0f;+ known_ = false;+}++bool AlphaRake::update(glm::vec2 at) {+ const glm::vec2 d = at - last_;+ if (glm::dot(d, d) >= kRakeStep * kRakeStep) {+ // The alpha's top, (-sin a, cos a) with y up, along the motion (d.x, -d.y): a = atan2(-d.x, -d.y).+ angle_ = std::atan2(-d.x, -d.y);+ last_ = at;+ known_ = true;+ }+ return known_;+}++float alphaDabAngle(const AlphaOptions& o, const AlphaRake& rake, uint32_t& seed) {+ float a = glm::radians(o.angle);+ if (o.followStroke) a += rake.angle();+ if (o.jitter > 0.0f) {+ if (seed == 0) seed = 1;+ seed ^= seed << 13;+ seed ^= seed >> 17;+ seed ^= seed << 5;+ const float r = float(seed & 0xffff) / 65535.0f * 2.0f - 1.0f;+ a += glm::radians(o.jitter) * r;+ }+ return a;+}++} // namespace sfdiff --git a/src/core/AlphaOptions.h b/src/core/AlphaOptions.hnew file mode 100644index 00000000..7a835c32--- /dev/null+++ b/src/core/AlphaOptions.h@@ -0,0 +1,47 @@+// SculptForge - open source digital sculpting+// SPDX-License-Identifier: GPL-3.0-or-later+//+// Alpha options (#76): how a brush's alpha turns on each dab. Follow stroke direction turns the alpha's top along+// the stroke, smoothed as Blender's Rake is (the direction is taken again only once the cursor has gone 20 pixels+// from where it was last taken); Angle turns it by a fixed amount and Angle jitter by a random one per dab. Tile+// (BrushAlpha::tileX / tileY) repeats the alpha inside the dab. Kept per brush (core/BrushSettings.h).+#pragma once++#include <glm/glm.hpp>++#include <cstdint>++namespace sf {++struct AlphaOptions {+ bool followStroke = false;+ float angle = 0.0f; // degrees, -180..180 (counter-clockwise on screen)+ float jitter = 0.0f; // degrees, 0..180: each dab turns by up to this much either way+ int tileX = 1, tileY = 1; // 1..8++ bool operator==(const AlphaOptions&) const = default;+ void clamp();+};++// Blender's Rake for the alpha: the stroke's direction on screen, taken again each time the cursor has moved+// kRakeStep pixels from the point it was last taken at (smaller wobbles don't turn the alpha).+class AlphaRake {+public:+ static constexpr float kRakeStep = 20.0f;+ void reset(glm::vec2 at);+ // A dab at `at` (window pixels, y down). True when the direction is known (the cursor has gone kRakeStep).+ bool update(glm::vec2 at);+ float angle() const { return angle_; } // radians, the dab angle that puts the alpha's top along the stroke+ bool known() const { return known_; }++private:+ glm::vec2 last_{0.0f};+ float angle_ = 0.0f;+ bool known_ = false;+};++// The dab's alpha angle (radians; App::dabAt's convention: 0 = the alpha's top at the top of the screen, counter-+// clockwise positive) from the options, the rake's direction and the per-stroke random `seed` (xorshift, advanced).+float alphaDabAngle(const AlphaOptions& o, const AlphaRake& rake, uint32_t& seed);++} // namespace sfdiff --git a/src/core/BrushAlpha.cpp b/src/core/BrushAlpha.cppindex b6594154..b36e08dc 100644--- a/src/core/BrushAlpha.cpp+++ b/src/core/BrushAlpha.cpp@@ -282,6 +282,15 @@ const Generated kGenerated[] = {float BrushAlpha::sample(float u, float v) const {if (u < -1.0f || u > 1.0f || v < -1.0f || v > 1.0f) return 0.0f;+ if (tiled()) { // each tile shows the whole alpha: its own -1..1 square+ auto wrap = [](float t, int n) {+ const float s = (t * 0.5f + 0.5f) * float(n);+ const float f = std::min(s - std::floor(s), 1.0f);+ return f * 2.0f - 1.0f;+ };+ u = wrap(u, tileX);+ v = wrap(v, tileY);+ }if (empty()) return brushFalloff(std::sqrt(u * u + v * v), 1.0f);// Bilinear lookup; pixel centres span the -1..1 square.const float px = std::clamp((u * 0.5f + 0.5f) * float(width) - 0.5f, 0.0f, float(width - 1));@@ -297,7 +306,7 @@ float BrushAlpha::sample(float u, float v) const {float BrushAlpha::stamp(float u, float v, float focal) const {const float d = std::sqrt(u * u + v * v);- if (empty()) return d < 1.0f ? brushFalloff(d, 1.0f, focal) : 0.0f;+ if (empty() && !tiled()) return d < 1.0f ? brushFalloff(d, 1.0f, focal) : 0.0f;const float a = sample(u, v);return a > 0.0f ? a * alphaFalloff(d, 1.0f, focal) : 0.0f;}diff --git a/src/core/BrushAlpha.h b/src/core/BrushAlpha.hindex faa08abe..b6e46db8 100644--- a/src/core/BrushAlpha.h+++ b/src/core/BrushAlpha.h@@ -26,6 +26,9 @@ struct BrushAlpha {// bring it back (core/BrushSettings.h). Empty for the built-ins.std::string path;bool inverted = false;+ // Tile (#76, core/AlphaOptions.h): the alpha repeated tileX x tileY times inside the stamp (1 x 1: once).+ int tileX = 1, tileY = 1;+ bool tiled() const { return tileX > 1 || tileY > 1; }bool empty() const { return values.empty(); }// u, v in brush-local -1..1 (v points up); 0 outside the stamp.diff --git a/src/core/BrushSettings.cpp b/src/core/BrushSettings.cppindex beb588f5..ecfef62c 100644--- a/src/core/BrushSettings.cpp+++ b/src/core/BrushSettings.cpp@@ -31,6 +31,7 @@ void BrushToolSettings::clamp() {sprayScatter = std::clamp(sprayScatter, 0.0f, 4.0f);lazyRadius = std::clamp(lazyRadius, 0.0f, 400.0f);if (int(stroke) < 0 || stroke >= StrokeType::Count) stroke = StrokeType::Dots;+ alphaOptions.clamp();}Json BrushToolSettings::toJson() const {@@ -45,6 +46,14 @@ Json BrushToolSettings::toJson() const {j.set("alpha", alphaName);if (!alphaPath.empty()) j.set("alpha_path", alphaPath);if (alphaInvert) j.set("alpha_invert", true);+ const AlphaOptions& a = alphaOptions;+ if (a.followStroke) j.set("alpha_follow_stroke", true);+ if (a.angle != 0.0f) j.set("alpha_angle", double(a.angle));+ if (a.jitter != 0.0f) j.set("alpha_angle_jitter", double(a.jitter));+ if (a.tileX != 1 || a.tileY != 1) {+ j.set("alpha_tile_x", a.tileX);+ j.set("alpha_tile_y", a.tileY);+ }return j;}@@ -63,6 +72,12 @@ void BrushToolSettings::applyJson(const Json& j) {alphaPath = j["alpha_path"].isString() ? j["alpha_path"].asString() : std::string();alphaInvert = j["alpha_invert"].asBool(false);}+ AlphaOptions& a = alphaOptions;+ a.followStroke = j["alpha_follow_stroke"].asBool(a.followStroke);+ readFloat(j, "alpha_angle", a.angle);+ readFloat(j, "alpha_angle_jitter", a.jitter);+ a.tileX = int(j["alpha_tile_x"].asNumber(a.tileX));+ a.tileY = int(j["alpha_tile_y"].asNumber(a.tileY));clamp();}diff --git a/src/core/BrushSettings.h b/src/core/BrushSettings.hindex 2203d800..b4dd22a8 100644--- a/src/core/BrushSettings.h+++ b/src/core/BrushSettings.h@@ -7,6 +7,7 @@// so nothing jumps the first time. Reset Brush to Default puts back the shipped values.#pragma once+#include "core/AlphaOptions.h"#include "core/Json.h"#include "core/Stroke.h"@@ -27,6 +28,7 @@ struct BrushToolSettings {std::string alphaName = "Round";std::string alphaPath;bool alphaInvert = false;+ AlphaOptions alphaOptions; // Follow stroke direction, Angle, Angle jitter, Tile (#76)bool operator==(const BrushToolSettings&) const = default;void clamp();diff --git a/tests/test_alpha_options.cpp b/tests/test_alpha_options.cppnew file mode 100644index 00000000..585945c8--- /dev/null+++ b/tests/test_alpha_options.cpp@@ -0,0 +1,116 @@+// SculptForge - open source digital sculpting+// SPDX-License-Identifier: GPL-3.0-or-later+//+// #76: alpha options (core/AlphaOptions.h): Follow stroke direction (Blender's Rake smoothing), Angle, Angle jitter+// and Tile, kept per brush (core/BrushSettings.h).+#include "TestHarness.h"++#include "core/AlphaOptions.h"+#include "core/BrushAlpha.h"+#include "core/BrushSettings.h"++#include <cmath>++using namespace sf;++namespace {+bool near(float a, float b, float eps = 1e-3f) { return std::abs(a - b) <= eps; }+// The direction the alpha's top points on screen for a dab angle (App::dabAt: (-sin a, cos a), y up).+glm::vec2 topOnScreen(float a) { return {-std::sin(a), -std::cos(a)}; } // window pixels, y down+} // namespace++TEST(alpha_rake_follows_stroke_direction) {+ AlphaRake rake;+ rake.reset({100, 100});+ CHECK(!rake.update({110, 100})); // under 20 px: not known yet+ CHECK(rake.update({125, 100})); // moving right+ glm::vec2 top = topOnScreen(rake.angle());+ CHECK(near(top.x, 1.0f) && near(top.y, 0.0f));+ // Wobbles under 20 px don't turn it.+ const float before = rake.angle();+ rake.update({130, 108});+ CHECK(rake.angle() == before);+ // Turning down the screen: the top points down once the cursor has gone 20 px.+ rake.update({125, 160});+ top = topOnScreen(rake.angle());+ CHECK(near(top.x, 0.0f, 0.1f) && top.y > 0.99f);+ // Moving up the screen is the plain upright alpha.+ rake.reset({0, 0});+ rake.update({0, -40});+ CHECK(near(rake.angle(), 0.0f));+}++TEST(alpha_dab_angle_fixed_jitter_and_follow) {+ AlphaRake rake;+ rake.reset({0, 0});+ rake.update({40, 0}); // right: -90 degrees+ uint32_t seed = 7;+ AlphaOptions o;+ CHECK(alphaDabAngle(o, rake, seed) == 0.0f);+ o.angle = 30.0f;+ CHECK(near(alphaDabAngle(o, rake, seed), glm::radians(30.0f)));+ o.followStroke = true;+ CHECK(near(alphaDabAngle(o, rake, seed), glm::radians(30.0f - 90.0f)));+ o.followStroke = false;+ o.jitter = 20.0f;+ bool varied = false;+ float first = alphaDabAngle(o, rake, seed);+ for (int i = 0; i < 50; ++i) {+ const float a = alphaDabAngle(o, rake, seed);+ CHECK(a >= glm::radians(10.0f) - 1e-5f && a <= glm::radians(50.0f) + 1e-5f);+ varied = varied || !near(a, first);+ }+ CHECK(varied);+ // The same seed gives the same jitter (strokes repeat exactly, as verify replays them).+ uint32_t s1 = 0x9e3779b9u, s2 = 0x9e3779b9u;+ CHECK(alphaDabAngle(o, rake, s1) == alphaDabAngle(o, rake, s2));+}++TEST(alpha_tile_repeats_inside_the_stamp) {+ BrushAlpha a;+ a.name = "Half";+ a.width = a.height = 8;+ a.values.assign(64, 0.0f);+ for (int y = 0; y < 8; ++y)+ for (int x = 0; x < 4; ++x) a.values[size_t(y * 8 + x)] = 1.0f; // left half white+ CHECK(a.sample(-0.5f, 0.0f) > 0.9f && a.sample(0.5f, 0.0f) < 0.1f);+ a.tileX = 2;+ // Two copies across: each tile's left half is white.+ CHECK(a.sample(-0.75f, 0.0f) > 0.9f && a.sample(-0.25f, 0.0f) < 0.1f);+ CHECK(a.sample(0.25f, 0.0f) > 0.9f && a.sample(0.75f, 0.0f) < 0.1f);+ CHECK(a.sample(1.5f, 0.0f) == 0.0f); // still nothing outside the stamp+ // The round (empty) alpha tiles too: four soft dots, each brightest at its own centre.+ BrushAlpha r;+ r.tileX = r.tileY = 2;+ CHECK(r.stamp(-0.5f, 0.5f, -1.0f) > 0.9f);+ CHECK(r.stamp(0.0f, 0.0f, -1.0f) < 0.1f);+ CHECK(BrushAlpha{}.stamp(0.0f, 0.0f, 0.0f) > 0.99f); // untiled: unchanged+}++TEST(alpha_options_saved_per_brush) {+ BrushToolSettings s;+ s.alphaOptions.followStroke = true;+ s.alphaOptions.angle = -45.0f;+ s.alphaOptions.jitter = 15.0f;+ s.alphaOptions.tileX = 3;+ s.alphaOptions.tileY = 2;+ BrushToolSettings back;+ back.applyJson(s.toJson());+ CHECK(back == s);+ // Older files have none: the defaults. Out-of-range values are clamped.+ BrushToolSettings plain;+ plain.applyJson(BrushToolSettings{}.toJson());+ CHECK(plain.alphaOptions == AlphaOptions{});+ Json j;+ std::string err;+ CHECK(Json::parse(R"({"alpha_tile_x": 40, "alpha_angle": 900, "alpha_angle_jitter": -5})", j, err));+ BrushToolSettings c;+ c.applyJson(j);+ CHECK(c.alphaOptions.tileX == 8 && c.alphaOptions.angle == 180.0f && c.alphaOptions.jitter == 0.0f);+ // Switching brushes carries each brush's options.+ BrushSettingsStore store;+ store.switchBrush("builtin:Standard", "builtin:Clay", s);+ BrushToolSettings clay = s;+ clay.alphaOptions = {};+ CHECK(store.switchBrush("builtin:Clay", "builtin:Standard", clay).alphaOptions == s.alphaOptions);+}diff --git a/tests/ui/air_strokes.sfui b/tests/ui/air_strokes.sfuiindex 5835ce05..b93fc2fd 100644--- a/tests/ui/air_strokes.sfui+++ b/tests/ui/air_strokes.sfui@@ -87,3 +87,23 @@ expect_value air_strokes == 0expect_value shortcut_conflicts == 0drag_path -0.3 0.5 0.5 0.5expect_value camera_yaw != $yaw2++# View > Lock camera is the same switch, and the status bar says CAMERA LOCKED while it is on (#62 follow-up).+run ui_look look=forge layout=sculptforge+wait 0.2+expect_no_text CAMERA LOCKED+click "View##menu.view"+hold ctrl+hover "Lock camera##view.lock_camera"+expect_help "Shift+L"+hold none+click "Lock camera##view.lock_camera"+expect_value air_strokes == 1+key escape+wait 0.1+expect_text CAMERA LOCKED+shot lock_camera+key shift+l+expect_value air_strokes == 0+wait 0.1+expect_no_text CAMERA LOCKEDdiff --git a/tests/ui/alpha_options.sfui b/tests/ui/alpha_options.sfuinew file mode 100644index 00000000..3ba7c9a1--- /dev/null+++ b/tests/ui/alpha_options.sfui@@ -0,0 +1,64 @@+# #76: alpha options in the Alpha palette. Follow stroke direction turns the alpha along the stroke (Blender's Rake+# smoothing), Angle adds a fixed turn, Tile repeats the alpha in the dab; all kept per brush (#78), and custom+# (recipe) brushes turn their alpha the same way.+run ui_look look=classic layout=zbrush # written for the Classic look and the ZBrush-style palette bar and shelves+run new_sphere subdivisions=4+key f+click "Standard##brush.standard"+run brush_set_alpha name=scales+wait 0.1+click "Alpha##palette.alpha"+expect "Follow stroke direction##alpha.follow_stroke"+hold ctrl+hover "Follow stroke direction##alpha.follow_stroke"+expect_help "Rake"+hold none+click "Follow stroke direction##alpha.follow_stroke"+expect_value alpha_follow == 1+click "Alpha##palette.alpha"++# Left to right: the alpha's top points right (-90); right to left: left (90).+stroke 0.2 0.5 0.8 0.5+expect_value last_dab_angle >= -91+expect_value last_dab_angle <= -89+stroke 0.8 0.45 0.2 0.45+expect_value last_dab_angle >= 89+expect_value last_dab_angle <= 91+shot follow_stroke++# A fixed angle on its own, and on top of the stroke's direction.+run brush_alpha_options follow_stroke=false angle=30+stroke 0.2 0.5 0.8 0.5+expect_value last_dab_angle == 30+run brush_alpha_options follow_stroke=true angle=30+stroke 0.2 0.5 0.8 0.5+expect_value last_dab_angle == -60++# Tile, and every option is the brush's own.+run brush_alpha_options tile_x=3 tile_y=2+wait 0.1+expect_value alpha_tile_x == 3+expect_value alpha_tile_y == 2+click "Alpha##palette.alpha"+shot tiled+click "Alpha##palette.alpha"+click "Clay##brush.clay"+wait 0.1+run brush_alpha_options follow_stroke=false angle=0 tile_x=1 tile_y=1+wait 0.1+expect_value alpha_tile_x == 1+click "Standard##brush.standard"+wait 0.1+expect_value alpha_follow == 1+expect_value alpha_angle == 30+expect_value alpha_tile_x == 3++# A custom brush follows the stroke too.+run brush_create name="Rake Test" depth=0.4+wait 0.1+run brush_alpha_options follow_stroke=true angle=0 tile_x=1 tile_y=1+snapshot+stroke 0.2 0.5 0.8 0.5+expect_value last_dab_angle >= -91+expect_value last_dab_angle <= -89+expect_value moved > 0diff --git a/tests/ui/blender_keys.sfui b/tests/ui/blender_keys.sfuiindex 4f30e83e..2424b8f9 100644--- a/tests/ui/blender_keys.sfui+++ b/tests/ui/blender_keys.sfui@@ -61,9 +61,19 @@ expect_text Draw Sizekey escapekey shift+fexpect_text Intensity-key escape+expect_no_text Smooth Intensity # Blender's Shift+F is the brush's Strength, not Smooth's (#77)+key 3+key 0+key enter+expect_value z_intensity == 30+key u+key 5+key 0+key enter+expect_value z_intensity == 50-# --- Sculpting: a plain drag adds, Ctrl+drag subtracts, Alt+drag navigates instead of sculpting ---+# --- Sculpting: a plain drag adds, Ctrl+drag subtracts; Alt+drag on the model masks and Ctrl+Alt+drag unmasks+# (Blender 5.1+, #77); Alt+drag beside the model and Alt+Shift+drag navigate ---snapshotstroke 0.3 0.5 0.7 0.5expect_value moved_out > 0@@ -80,7 +90,38 @@ hold altstroke 0.3 0.5 0.7 0.5hold noneexpect_value moved == 0+expect_value camera_yaw == $y0+expect_value masked > 100+remember masked am+hold ctrl+alt+stroke 0.3 0.5 0.7 0.5+hold none+expect_value masked < $am+expect_value camera_yaw == $y0+key alt+m+expect_value masked == 0+hold alt+drag_path -0.3 0.5 -0.1 0.2+hold none+expect_value camera_yaw != $y0+expect_value masked == 0+key home+# Preferences > Input > Emulate 3 Button Mouse: Alt+left-drag turns the view on the model too.+click "Preferences##palette.preferences" # (Input is still open from the top of the script)+click "Emulate 3 Button Mouse##input.emulate_3_button"+expect_value emulate_3_button == 1+key escape+remember camera_yaw y0+hold alt+stroke 0.3 0.5 0.7 0.5+hold none+expect_value moved == 0+expect_value masked == 0expect_value camera_yaw != $y0+click "Preferences##palette.preferences" # (Input is still open from the top of the script)+click "Emulate 3 Button Mouse##input.emulate_3_button"+expect_value emulate_3_button == 0+key escaperemember camera_pan p0hold alt+shiftstroke 0.3 0.5 0.7 0.5diff --git a/tests/ui/whats_new.sfui b/tests/ui/whats_new.sfuiindex 6b70eb9d..503623b9 100644--- a/tests/ui/whats_new.sfui+++ b/tests/ui/whats_new.sfui@@ -5,8 +5,9 @@ click "Help##palette.help"click "What's New##help.whats_new"expect_value guide_open == 1expect_guide whats-new.md+expect_text "Version 0.10.8"+expect_text "Alpha options"expect_text "Version 0.10.7"-expect_text "A new look"expect_text "Version 0.10.6"expect_text "Version 0.10.5"expect_text "Version 0.10.4"