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
VDM stamp rotation (#136): Follow stroke direction, Angle and Angle jitter for Drag Stamp / Slide Stamp; brush files keep alpha Angle and jitter
islandmed3ee93f1a1875
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 271741e4..62fb1734 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -15,6 +15,11 @@ All notable changes to SculptForge are listed here. The format followsthat layer, masked or not, like a stroke (#133, thanks Devon0209): the base mesh stays, the layer's weight dialsthe move in and out, undo works. With Base mesh active they move the base and every layer, as before.### Added+- **Rotation for vector displacement stamps** (#136, thanks DonnieAlex): with the VDM brush, **Sculpt > Brush > Vector+ Displacement > Stamp rotation** has Follow stroke direction (Drag Stamp turns with the drag; off, the drag only+ sizes the stamp), Angle and Angle jitter (a random turn per stamp), kept per brush like the alpha options.+- Brush files keep the alpha's **Angle** and **Angle jitter** as well as Follow stroke direction: Save Brush Settings+ on a custom brush writes all three into it, so shared brushes (brush codes, .sfpack) turn their alpha the same way.- **Maya style view keys** (#134, thanks RodTDai): hold Alt, then add Ctrl, and a left drag rolls the view (left /right); Alt+F frames the active Part; Alt+H resets the view (front, upright, perspective, everything in view). Ctrlfirst (or both together) still masks with Ctrl+Alt, on the model and beside it.diff --git a/REPLY.md b/REPLY.mdnew file mode 100644index 00000000..d69a4d35--- /dev/null+++ b/REPLY.md@@ -0,0 +1,15 @@+# Reply draft for #136 (not posted; post at the release that ships feat/vdm-rotation, then close)++Vector displacement stamps can now be rotated (out now, in the latest update). With the VDM brush picked, **Sculpt > Brush > Vector Displacement** has a **Stamp rotation** section under the map's preview:++- **Follow stroke direction**: on by default, so Drag Stamp turns the stamp with your drag as before. Turn it off and the drag only sets the size: every stamp keeps the fixed angle, however you drag.+- **Angle**: a fixed turn, -180 to 180 degrees. It works on its own or on top of the drag's direction. Slide Stamp uses it too.+- **Angle jitter**: each stamp gets a random turn, up to that many degrees either way. Handy for scattered horns, rivets or scales that shouldn't all face the same way.++The VDM brush keeps its own settings, separate from the alpha brushes, and **Save Brush Settings** keeps them for next time.++On sharing: brush files used to keep only Follow stroke direction. Now **Save Brush Settings** on a custom brush also writes its alpha **Angle** and **Angle jitter** into the brush file, so a brush you share as a brush code or in a .sfpack turns its alpha the same way for whoever installs it.++Guide: https://sculptforge.app/guide/sculpting.html#stamp-rotation++Thanks for the request!diff --git a/docs/brushes.md b/docs/brushes.mdindex 5dd9fa66..8723c3e7 100644--- a/docs/brushes.md+++ b/docs/brushes.md@@ -45,6 +45,7 @@ A `.sfbrush` file is a JSON object:| `cavityMask` | -1 … 1 | Only cavities (positive) or only ridges (negative) || `alpha` (optional) | a built-in alpha's name, e.g. `"Rivets"` | The alpha the brush starts with the first time it is picked (written only when set; an unknown name is dropped) || `alphaFollow` (optional) | `true` / `false` | That alpha turns along the stroke (written only when true) |+| `alphaAngle`, `alphaAngleJitter` (optional) | -180 … 180; 0 … 180 (degrees) | Alpha > Angle and Angle jitter the brush starts with (written only when not 0) |Missing keys take neutral defaults, out-of-range values are clamped, and unknown keys are ignored when loading(the gallery is stricter, see below). `sculptforge-cli --list` shows the same parameters under `brush_create`.diff --git a/docs/guide/sculpting.md b/docs/guide/sculpting.mdindex 4f93252b..27704510 100644--- a/docs/guide/sculpting.md+++ b/docs/guide/sculpting.md@@ -471,7 +471,10 @@ Under the preview in **Sculpt > Alpha**:| **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:+[Each brush keeps its own settings](#each-brush-keeps-its-own-settings)). **Save Brush Settings** on a custom brush+also writes Follow stroke direction, Angle and Angle jitter into its brush file, so a brush you share (a brush code,+a .sfpack) turns its alpha the same way for everyone. Vector displacement stamps have the same options: see+[Stamp rotation](#stamp-rotation). From a script:`brush_alpha_options follow_stroke=true angle=30 angle_jitter=10 tile_x=2 tile_y=2`.## Vector displacement brushes@@ -503,6 +506,21 @@ overhang, as nothing made with a height ever can.and each stamp is one undo step. Sculpt layers record it like any stroke.- The **Dots** stroke works too: each dab adds the shape again, for rows of studs or scales.+#### Stamp rotation++While the VDM brush is the brush, **Stamp rotation** sits under the map's preview, with the same three options as+[Alpha options](#alpha-options):++| Option | What it does |+|---|---|+| **Follow stroke direction** | On (the default): Drag Stamp turns the stamp with the drag, and a Dots stroke turns it along the stroke. Off: the drag only sets the size, and every stamp keeps Angle's turn (horns that all stand the same way however you drag). |+| **Angle** | A fixed turn, -180 to 180 degrees counter-clockwise, on its own or on top of the drag's direction. Slide Stamp takes it too (it slides the stamp without turning it). |+| **Angle jitter** | Each stamp turns by a random angle, up to this many degrees either way: scattered horns, rivets or scales that don't all face the same way. |++The VDM brush keeps its own, separate from the alpha brushes'; **Save Brush Settings** keeps them for next time,+and a custom brush saves them in its brush file, so they travel in brush codes and [packs](packs-and-macros.md). From a+script: `brush_alpha_options follow_stroke=false angle=45 angle_jitter=20`.+> **Tip:** a VDM moves points sideways, so it needs points to move: on a coarse mesh the shape breaks up into> spikes. Divide first (the model above has 330 000 triangles), and stamp at the highest> [subdivision level](subdivision-levels.md); stepping down and back up keeps the stamp. Use Front faces onlydiff --git a/src/app/App.cpp b/src/app/App.cppindex cbb7f079..2ee3650c 100644--- a/src/app/App.cpp+++ b/src/app/App.cpp@@ -2112,6 +2112,8 @@ void App::beginStroke(float x, float y, const RayHit& hit) {beginAlongNormal(hit, radiusPx_ * camera_.worldPerPixel(hit.position, canvasHeight()));return;}+ if (strokeType_ == StrokeType::DragRect || strokeType_ == StrokeType::DragDot)+ stampJitter_ = alphaJitterAngle(alphaOptions_.jitter, stampSeed_);if (strokeType_ == StrokeType::DragRect) {dragAnchor_ = glm::vec2(x, y);dragAnchorHit_ = hit.position;diff --git a/src/app/App.h b/src/app/App.hindex f63d9d86..bc20b5ce 100644--- a/src/app/App.h+++ b/src/app/App.h@@ -789,8 +789,12 @@ private:AlphaOptions alphaOptions_;AlphaRake alphaRake_;uint32_t alphaSeed_ = 1;+ // Drag Stamp / Slide Stamp (#136): Angle jitter's turn for this stroke's one stamp, from a seed that carries on+ // from stroke to stroke (each stamp gets its own turn).+ float stampJitter_ = 0.0f;+ uint32_t stampSeed_ = 0x2545f491u;float lastDabAngle_ = 0.0f; // radians (UI tests: last_dab_angle)- void drawAlphaOptions();+ void drawAlphaOptions(bool vdm = false); // vdm: Brush > Vector Displacement's rows (no Tile, #136)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,diff --git a/src/app/BrushSettingsUi.cpp b/src/app/BrushSettingsUi.cppindex 54bd64e0..5cb4e1c6 100644--- a/src/app/BrushSettingsUi.cpp+++ b/src/app/BrushSettingsUi.cpp@@ -123,12 +123,17 @@ void App::syncBrushSettings() {void App::recipeAlpha(BrushToolSettings& s) const {if (doc_.activeBrush < 0 || doc_.activeBrush >= int(doc_.brushes.size())) return;const BrushRecipe& r = doc_.brushes[size_t(doc_.activeBrush)];- if (r.alpha.empty() && r.origin.pack.empty()) return;- s.alphaName = r.alpha.empty() ? std::string("Round") : r.alpha;- s.alphaPath.clear();- s.alphaInvert = false;+ const bool turns = r.alphaFollow || r.alphaAngle != 0.0f || r.alphaJitter != 0.0f; // (a shared brush's own turn, #136)+ if (r.alpha.empty() && r.origin.pack.empty() && !turns) return;+ if (!r.alpha.empty() || !r.origin.pack.empty()) {+ s.alphaName = r.alpha.empty() ? std::string("Round") : r.alpha;+ s.alphaPath.clear();+ s.alphaInvert = false;+ s.alphaOptions.tileX = s.alphaOptions.tileY = 1;+ }s.alphaOptions.followStroke = r.alphaFollow;- s.alphaOptions.tileX = s.alphaOptions.tileY = 1;+ s.alphaOptions.angle = r.alphaAngle;+ s.alphaOptions.jitter = r.alphaJitter;}void App::recipePenPressure(BrushToolSettings& s) const {@@ -229,6 +234,18 @@ void App::registerAlphaOptionsCommand() {void App::saveBrushSettings() {syncBrushSettings(); // (the live values belong to the brush picked now)brushSettings_.store(brushSettingsKey_, liveBrushSettings());+ if (BrushRecipe* r = doc_.activeBrush >= 0 && doc_.activeBrush < int(doc_.brushes.size())+ ? &doc_.brushes[size_t(doc_.activeBrush)]+ : nullptr;+ r && (r->alphaFollow != alphaOptions_.followStroke || r->alphaAngle != alphaOptions_.angle ||+ r->alphaJitter != alphaOptions_.jitter)) {+ r->alphaFollow = alphaOptions_.followStroke; // the brush's .sfbrush (and so its packs and codes) keeps them (#136)+ r->alphaAngle = alphaOptions_.angle;+ r->alphaJitter = alphaOptions_.jitter;+ r->clamp();+ saveBrushEdits(doc_.activeBrush);+ watchActiveBrush(); // (saved now: the autosave has nothing left to do)+ }std::string err;const std::string path = brushSettingsPath();if (!brushSettingsOn_ || path.empty()) status_ = "Brush settings kept for this session";diff --git a/src/app/PanelBrushes.cpp b/src/app/PanelBrushes.cppindex 82bec41a..a8308576 100644--- a/src/app/PanelBrushes.cpp+++ b/src/app/PanelBrushes.cpp@@ -72,24 +72,44 @@ void App::drawAlphaSection() {}// Alpha options (#76): how the alpha turns and repeats on each dab, kept per brush (#78).-void App::drawAlphaOptions() {+void App::drawAlphaOptions(bool vdm) {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");+ const char* where = vdm ? "Brush > Vector Displacement" : "Alpha";+ if (vdm) {+ ImGui::SeparatorText("Stamp rotation");+ ui::Checkbox("Follow stroke direction##vdm.follow_stroke", &o.followStroke);+ ui::HelpText("Follow stroke direction", nullptr,+ "The stamp turns with you: with Drag Stamp its top points the way you drag; in a dots stroke it "+ "turns along the stroke. Off, Drag Stamp only sets the size and the stamp keeps Angle's turn. "+ "Slide Stamp never turns while you slide it.",+ where);+ } else {+ 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.",+ where);+ }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");+ ui::SliderInside(vdm ? "##vdm_angle" : "##alpha_angle", &o.angle, -180.0f, 180.0f, "Angle %.0f");+ ui::HelpText("Angle", nullptr,+ vdm ? "Turn the stamp by a fixed angle in degrees (counter-clockwise), on top of the drag's turn when "+ "Follow stroke direction is on; Ctrl+click to type."+ : "Turn the alpha by a fixed angle in degrees (counter-clockwise); Ctrl+click to type.",+ where);ImGui::SetNextItemWidth(-1);- ui::SliderInside("##alpha_angle_jitter", &o.jitter, 0.0f, 180.0f, "Angle jitter %.0f");+ ui::SliderInside(vdm ? "##vdm_angle_jitter" : "##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");+ vdm ? "Turn each stamp by a random angle, up to this many degrees either way: scattered horns, "+ "scales or rivets that don't all face the same way."+ : "Turn each dab by a random angle, up to this many degrees either way: breaks up repeats in "+ "skin, rock and noise alphas.",+ where);+ if (vdm) {+ ImGui::Dummy(ImVec2(0, 2.0f * uiScale_));+ return;+ }const float half = (ImGui::GetContentRegionAvail().x - ImGui::GetStyle().ItemSpacing.x) * 0.5f;ImGui::SetNextItemWidth(half);float tileX = float(o.tileX), tileY = float(o.tileY);@@ -160,7 +180,11 @@ void App::dragRectTo(float x, float y) {p.viewFalloff = uiPrefs_.viewFalloff;p.focal = focalShift_;p.alpha = &doc_.brushAlpha;- p.alphaUp = glm::normalize(q * glm::vec3(drag.x, -drag.y, 0.0f)); // the alpha's top follows the drag+ // The stamp's top follows the drag (a VDM's only with Follow stroke direction, #136), turned by Angle and jitter.+ const bool follow = strokeBrush_ != BrushType::Vdm || alphaOptions_.followStroke;+ const float a = alphaStampAngle(alphaOptions_, follow, drag, stampJitter_);+ lastDabAngle_ = a;+ p.alphaUp = q * glm::vec3(-std::sin(a), std::cos(a), 0.0f); // (screenUpVector)p.vdm = doc_.brushVdm.get();if (strokePaint_) paintAt(p); // restoreStroke reverted the previous stamp's colours tooif (!strokeSculpt_) return;diff --git a/src/app/PanelVdm.cpp b/src/app/PanelVdm.cppindex 1b8759ec..9f93433d 100644--- a/src/app/PanelVdm.cpp+++ b/src/app/PanelVdm.cpp@@ -146,7 +146,8 @@ void App::dragDotTo(float x, float y) {p.viewFalloff = uiPrefs_.viewFalloff;p.focal = focalShift_;p.alpha = &doc_.brushAlpha;- p.alphaUp = screenUpVector(0.0f);+ lastDabAngle_ = alphaStampAngle(alphaOptions_, false, {}, stampJitter_); // Angle and jitter (#136); it slides, not turns+ p.alphaUp = screenUpVector(lastDabAngle_);p.vdm = doc_.brushVdm.get();lastDabScreen_ = glm::vec2(x, y);if (strokePaint_) paintAt(p); // restoreStroke reverted the previous stamp's colours too@@ -176,6 +177,8 @@ void App::drawVdmSection() {}if (!vdmBrushActive()) {actionButton(*this, "brush.vdm");+ } else {+ drawAlphaOptions(true); // the VDM brush's own Follow / Angle / Angle jitter (#136)}drawVdmGrid(*this, GridMode::Palette);diff --git a/src/app/UiTest.cpp b/src/app/UiTest.cppindex a6eb90de..5701ff08 100644--- a/src/app/UiTest.cpp+++ b/src/app/UiTest.cpp@@ -565,6 +565,13 @@ double Demo::query(const std::string& name, bool& known) const {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_jitter") return std::round(app_.alphaOptions_.jitter);+ if (name == "recipe_alpha_angle" || name == "recipe_alpha_jitter" || name == "recipe_alpha_follow") { // its .sfbrush's (#136)+ const BrushRecipe* r = app_.activeRecipe();+ if (!r) return -999.0;+ if (name == "recipe_alpha_follow") return r->alphaFollow ? 1.0 : 0.0;+ return std::round(name == "recipe_alpha_angle" ? r->alphaAngle : r->alphaJitter);+ }if (name == "brush_sort") return double(int(listSortFromId(app_.uiPrefs_.brushSort))); // 0 A-Z, 1 Recent, 2 Packif (name == "alpha_sort") return double(int(listSortFromId(app_.uiPrefs_.alphaSort)));if (name == "material_sort") return double(int(listSortFromId(app_.uiPrefs_.materialSort)));diff --git a/src/core/AlphaOptions.cpp b/src/core/AlphaOptions.cppindex 4aa4f67a..5a83c0ac 100644--- a/src/core/AlphaOptions.cpp+++ b/src/core/AlphaOptions.cpp@@ -8,8 +8,8 @@namespace sf {void AlphaOptions::clamp() {- angle = std::clamp(angle, -180.0f, 180.0f);- jitter = std::clamp(jitter, 0.0f, 180.0f);+ angle = std::isfinite(angle) ? std::clamp(angle, -180.0f, 180.0f) : 0.0f;+ jitter = std::isfinite(jitter) ? std::clamp(jitter, 0.0f, 180.0f) : 0.0f;tileX = std::clamp(tileX, 1, 8);tileY = std::clamp(tileY, 1, 8);}@@ -31,17 +31,25 @@ bool AlphaRake::update(glm::vec2 at) {return known_;}+float alphaJitterAngle(float jitterDeg, uint32_t& seed) {+ if (!(jitterDeg > 0.0f)) return 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;+ return glm::radians(jitterDeg) * r;+}+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 + alphaJitterAngle(o.jitter, seed);+}++float alphaStampAngle(const AlphaOptions& o, bool followDrag, glm::vec2 drag, float jitter) {+ float a = glm::radians(o.angle) + jitter;+ if (followDrag && glm::dot(drag, drag) > 0.0f) a += std::atan2(-drag.x, -drag.y); // (as AlphaRake::update)return a;}diff --git a/src/core/AlphaOptions.h b/src/core/AlphaOptions.hindex 7a835c32..f6a1bd66 100644--- a/src/core/AlphaOptions.h+++ b/src/core/AlphaOptions.h@@ -43,5 +43,10 @@ private:// 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);+// A random turn (radians) up to `jitterDeg` either way, advancing `seed`; 0 when jitterDeg is 0.+float alphaJitterAngle(float jitterDeg, uint32_t& seed);+// A drag stamp's angle (Drag Stamp, Slide Stamp: one stamp per stroke, #136): the drag's direction on screen+// (window pixels, y down) when `followDrag`, plus Angle and the stroke's `jitter` (from alphaJitterAngle).+float alphaStampAngle(const AlphaOptions& o, bool followDrag, glm::vec2 drag, float jitter);} // namespace sfdiff --git a/src/core/BrushRecipe.cpp b/src/core/BrushRecipe.cppindex a7c37417..d1f96fb1 100644--- a/src/core/BrushRecipe.cpp+++ b/src/core/BrushRecipe.cpp@@ -132,6 +132,8 @@ void BrushRecipe::clamp() {for (const auto& p : recipeParams())if (p.kind == K::Float)if (float* f = floatField(*this, p.key)) *f = std::clamp(*f, p.min, p.max);+ alphaAngle = std::isfinite(alphaAngle) ? std::clamp(alphaAngle, -180.0f, 180.0f) : 0.0f;+ alphaJitter = std::isfinite(alphaJitter) ? std::clamp(alphaJitter, 0.0f, 180.0f) : 0.0f;if (name.empty()) name = "Custom Brush";if (name.size() > 64) name.resize(64);if (description.size() > 500) description.resize(500);@@ -146,6 +148,8 @@ Json BrushRecipe::toJson() const {if (viewFalloff) j.set("viewFalloff", true);if (!alpha.empty()) j.set("alpha", alpha);if (alphaFollow) j.set("alphaFollow", true);+ if (alphaAngle != 0.0f) j.set("alphaAngle", std::round(double(alphaAngle) * 1000.0) / 1000.0);+ if (alphaJitter != 0.0f) j.set("alphaAngleJitter", std::round(double(alphaJitter) * 1000.0) / 1000.0);if (pressureSize != PenPressure::Global) j.set("penPressureSize", penPressureId(pressureSize));if (pressureStrength != PenPressure::Global) j.set("penPressureStrength", penPressureId(pressureStrength));for (const auto& p : recipeParams()) {@@ -169,6 +173,8 @@ void BrushRecipe::applyJson(const Json& j) {if (j["connectedOnly"].isBool()) connectedOnly = j["connectedOnly"].asBool();if (j["viewFalloff"].isBool()) viewFalloff = j["viewFalloff"].asBool();if (j["alphaFollow"].isBool()) alphaFollow = j["alphaFollow"].asBool();+ if (j["alphaAngle"].isNumber()) alphaAngle = float(j["alphaAngle"].asNumber());+ if (j["alphaAngleJitter"].isNumber()) alphaJitter = float(j["alphaAngleJitter"].asNumber());if (j["penPressureSize"].isString()) pressureSize = penPressureFromId(j["penPressureSize"].asString());if (j["penPressureStrength"].isString()) pressureStrength = penPressureFromId(j["penPressureStrength"].asString());if (j["alpha"].isString()) {diff --git a/src/core/BrushRecipe.h b/src/core/BrushRecipe.hindex 609a6c6e..b54f1a2a 100644--- a/src/core/BrushRecipe.h+++ b/src/core/BrushRecipe.h@@ -79,6 +79,8 @@ struct BrushRecipe {// alpha is on. Written to the JSON only when set. An unknown name is dropped.std::string alpha;bool alphaFollow = false; // the alpha turns along the stroke (Alpha > Follow stroke direction) on that first pick+ float alphaAngle = 0.0f; // Alpha > Angle (degrees, -180..180) and Angle jitter (0..180) on that first pick (#136);+ float alphaJitter = 0.0f; // written only when not 0. Save Brush Settings writes all three from the brush's live ones// Pen pressure > Size / Strength for this brush (#122, core/PenPressure.h): what it starts with, and what Brush// Lab sets. Written to the JSON only when not Use global.PenPressure pressureSize = PenPressure::Global;diff --git a/src/core/BrushSettings.cpp b/src/core/BrushSettings.cppindex 517cad2f..f3eb9828 100644--- a/src/core/BrushSettings.cpp+++ b/src/core/BrushSettings.cpp@@ -49,7 +49,7 @@ Json BrushToolSettings::toJson() const {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);+ j.set("alpha_follow_stroke", a.followStroke); // (always: the VDM brush's default is on)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) {@@ -101,6 +101,7 @@ BrushToolSettings BrushSettingsStore::switchBrush(const std::string& from, constconst BrushToolSettings own = shipped(to); // ...except pen pressure, the brush's own (a grab brush's Size off)next.pressureSize = own.pressureSize;next.pressureStrength = own.pressureStrength;+ if (to == brushSettingsKey(brushName(BrushType::Vdm))) next.alphaOptions = own.alphaOptions; // (turns with the drag)}if (shareSizeIntensity) {next.radiusPx = current.radiusPx;@@ -129,7 +130,10 @@ BrushToolSettings BrushSettingsStore::reset(const std::string& key) {BrushToolSettings BrushSettingsStore::shipped(const std::string& key) {BrushToolSettings s;- if (key == "builtin:Vdm") s.stroke = StrokeType::DragRect; // stamps a VDM where you drag (PanelVdm.cpp)+ if (key == brushSettingsKey(brushName(BrushType::Vdm))) {+ s.stroke = StrokeType::DragRect; // stamps a VDM where you drag (PanelVdm.cpp)+ s.alphaOptions.followStroke = true; // ...turned by the drag, as before the VDM's own Angle options (#136)+ }for (BrushType t : {BrushType::Move, BrushType::KelvinGrab, BrushType::KelvinTwist, BrushType::KelvinScale,BrushType::SnakeHook, BrushType::KelvinSnake})if (key == brushSettingsKey(brushName(t))) s.pressureSize = PenPressure::Off;diff --git a/tests/test_alpha_options.cpp b/tests/test_alpha_options.cppindex 585945c8..80fc58cf 100644--- a/tests/test_alpha_options.cpp+++ b/tests/test_alpha_options.cpp@@ -114,3 +114,28 @@ TEST(alpha_options_saved_per_brush) {clay.alphaOptions = {};CHECK(store.switchBrush("builtin:Clay", "builtin:Standard", clay).alphaOptions == s.alphaOptions);}++// #136: a drag stamp's turn (Drag Stamp / Slide Stamp, alphas and VDMs): the drag's direction when it follows,+// Angle on top, and the stroke's jitter.+TEST(alpha_stamp_angle) {+ AlphaOptions o;+ const float right = glm::degrees(alphaStampAngle(o, true, glm::vec2(10.0f, 0.0f), 0.0f));+ CHECK(std::fabs(right + 90.0f) < 0.01f); // dragged right: the top points right (as the rake)+ CHECK(alphaStampAngle(o, false, glm::vec2(10.0f, 0.0f), 0.0f) == 0.0f);+ o.angle = 30.0f;+ CHECK(std::fabs(glm::degrees(alphaStampAngle(o, false, glm::vec2(10.0f, 0.0f), 0.0f)) - 30.0f) < 0.01f);+ CHECK(std::fabs(glm::degrees(alphaStampAngle(o, true, glm::vec2(10.0f, 0.0f), 0.0f)) + 60.0f) < 0.01f);+ CHECK(alphaStampAngle(o, true, glm::vec2(0.0f), 0.25f) == glm::radians(30.0f) + 0.25f); // no drag yet+ // Jitter: within the range, different stamp to stamp, none at 0.+ uint32_t seed = 7;+ CHECK(alphaJitterAngle(0.0f, seed) == 0.0f && seed == 7);+ const float a = alphaJitterAngle(20.0f, seed), b = alphaJitterAngle(20.0f, seed);+ CHECK(a != b);+ CHECK(std::fabs(a) <= glm::radians(20.0f) && std::fabs(b) <= glm::radians(20.0f));+ // NaN from a damaged file never reaches a stamp.+ AlphaOptions bad;+ bad.angle = std::nanf("");+ bad.jitter = std::nanf("");+ bad.clamp();+ CHECK(bad.angle == 0.0f && bad.jitter == 0.0f);+}diff --git a/tests/test_brush_packs.cpp b/tests/test_brush_packs.cppindex 4efaaa71..0d64930f 100644--- a/tests/test_brush_packs.cpp+++ b/tests/test_brush_packs.cpp@@ -56,6 +56,17 @@ TEST(brush_recipe_alpha_keys_round_trip) {r.alphaFollow = true;const BrushRecipe back = BrushRecipe::fromJson(r.toJson());CHECK(back.alpha == "Stitches" && back.alphaFollow);+ // Angle and Angle jitter too (#136), clamped as the Alpha palette's sliders are.+ r.alphaAngle = 42.5f;+ r.alphaJitter = 20.0f;+ const BrushRecipe turned = BrushRecipe::fromJson(r.toJson());+ CHECK(turned.alphaAngle == 42.5f && turned.alphaJitter == 20.0f);+ Json wild = r.toJson();+ wild.set("alphaAngle", 900.0);+ wild.set("alphaAngleJitter", -4.0);+ const BrushRecipe clamped = BrushRecipe::fromJson(wild);+ CHECK(clamped.alphaAngle == 180.0f && clamped.alphaJitter == 0.0f);+ r.alphaAngle = r.alphaJitter = 0.0f;// Lenient names, as brush_set_alpha takes them; unknown names are dropped.Json j = r.toJson();j.set("alpha", "fabric_weave");diff --git a/tests/test_brush_settings.cpp b/tests/test_brush_settings.cppindex c4e80857..928f4005 100644--- a/tests/test_brush_settings.cpp+++ b/tests/test_brush_settings.cpp@@ -7,6 +7,7 @@#include "core/BrushRecipe.h"#include "core/BrushSettings.h"+#include "core/Sculpt.h"#include <cstdio>#include <filesystem>@@ -86,7 +87,28 @@ TEST(brush_settings_save_load_reset) {const BrushToolSettings def = loaded.reset("custom:Clay Slab");CHECK(def == BrushToolSettings{});CHECK(!loaded.hasSaved("custom:Clay Slab"));- CHECK(BrushSettingsStore::shipped("builtin:Vdm").stroke == StrokeType::DragRect);+ // The VDM brush (by its real key: the brush is named "VDM") ships with Drag Stamp, turned by the drag (#136).+ const std::string vdmKey = brushSettingsKey(brushName(BrushType::Vdm));+ CHECK(BrushSettingsStore::shipped(vdmKey).stroke == StrokeType::DragRect);+ CHECK(BrushSettingsStore::shipped(vdmKey).alphaOptions.followStroke);+ {+ // ...also on first use after a brush with it off, and in files saved before the VDM had the option.+ BrushSettingsStore fresh;+ BrushToolSettings clay;+ CHECK(fresh.switchBrush("builtin:Clay", vdmKey, clay).alphaOptions.followStroke);+ Json old;+ std::string e;+ CHECK(Json::parse(R"({"brushes": {"builtin:VDM": {"stroke": "drag_dot"}}})", old, e));+ fresh.applyJson(old);+ BrushToolSettings got;+ CHECK(fresh.savedFor(vdmKey, got) && got.alphaOptions.followStroke && got.stroke == StrokeType::DragDot);+ // Turned off and saved, it stays off.+ got.alphaOptions.followStroke = false;+ fresh.store(vdmKey, got);+ BrushSettingsStore again;+ again.applyJson(fresh.toJson());+ CHECK(again.savedFor(vdmKey, got) && !got.alphaOptions.followStroke);+ }// After the reset the session doesn't bring back the old values either.BrushToolSettings live;live.radiusPx = 99.0f;diff --git a/tests/test_packs.cpp b/tests/test_packs.cppindex 68c894b2..f68b3be5 100644--- a/tests/test_packs.cpp+++ b/tests/test_packs.cpp@@ -579,6 +579,44 @@ TEST(pack_write_round_trip) {CHECK(!parseKeymapFile("{\"format\":\"sculptforge-keymap\",\"version\":1,\"shortcuts\":{\"a\":3}}", back, err));}+// #136: a shared brush keeps its alpha's Follow stroke direction, Angle and Angle jitter: made into a .sfpack,+// installed, and loaded into the library.+TEST(pack_brush_keeps_alpha_options) {+ TempRoot root("sf_pack_alpha_options");+ const fs::path src = root.dir / "src";+ fs::create_directories(src);+ BrushRecipe b;+ b.name = "Turned Stitch";+ b.alpha = "Stitches";+ b.alphaFollow = true;+ b.alphaAngle = -35.0f;+ b.alphaJitter = 12.5f;+ std::ofstream(src / "Turned Stitch.sfbrush") << b.toJson().dump(true);+ PackManifest m;+ m.id = "turned";+ m.name = "Turned";+ m.version = "1.0";+ m.author = "Me";+ m.license = "CC0-1.0";+ std::string err;+ const std::string out = (root.dir / "Turned.sfpack").string();+ CHECK(writePack(out, m, {{PackItemType::Brush, (src / "Turned Stitch.sfbrush").string(), "", {}}}, "", "", err));+ PackReview r;+ CHECK(reviewPack(out, r, err));+ CHECK(installPack(r, err));+ BrushLibraryPaths paths;+ applyPacksToBrushLibrary(paths);+ Document doc;+ loadBrushLibrary(doc, paths);+ const BrushRecipe* got = nullptr;+ for (const BrushRecipe& x : doc.brushes)+ if (x.name == "Turned Stitch") got = &x;+ CHECK(got != nullptr);+ if (!got) return;+ CHECK(got->alpha == "Stitches" && got->alphaFollow);+ CHECK(got->alphaAngle == -35.0f && got->alphaJitter == 12.5f);+}+TEST(pack_commands) {TempRoot root("sf_pack_cmds");const fs::path src = root.dir / "layout";diff --git a/tests/ui/vdm_rotation.sfui b/tests/ui/vdm_rotation.sfuinew file mode 100644index 00000000..437bd9b1--- /dev/null+++ b/tests/ui/vdm_rotation.sfui@@ -0,0 +1,93 @@+# #136: rotation for VDM stamps. With the VDM brush, Brush > Vector Displacement shows Follow stroke direction,+# Angle and Angle jitter (the Alpha palette's options, kept per brush): Drag Stamp turns with the drag only while+# Follow is on (the VDM brush ships with it on), Angle adds a fixed turn, jitter a random one per stamp; Slide Stamp+# takes Angle and jitter. A custom brush's Save Brush Settings writes the three into its .sfbrush (packs, codes).+run ui_look look=classic layout=classic # written for the Classic look and the classic palette bar and shelves+run new_sphere subdivisions=6+click "Brush##palette.brush"+click "Brush/##totray"+wait 0.3+click "Vector Displacement##brush.vdm"+expect_not "Follow stroke direction##vdm.follow_stroke" # (only while the VDM brush is the brush)+click "Horn##vdm0"+expect_value brush_type == 14+expect_value stroke_type == 1+expect "Follow stroke direction##vdm.follow_stroke"+expect_value alpha_follow == 1+hold ctrl+hover "Follow stroke direction##vdm.follow_stroke"+expect_help Drag Stamp+hold none+wait_idle 30+shot rows++# Drag Stamp, dragged right: the Horn's top points right (-90), as before.+stroke 0.5 0.5 0.62 0.5+expect_value last_dab_angle >= -91+expect_value last_dab_angle <= -89+key ctrl+z++# Follow off: the drag only sizes it; Angle turns it. Follow on: Angle on top of the drag.+click "Follow stroke direction##vdm.follow_stroke"+expect_value alpha_follow == 0+run brush_alpha_options angle=30+snapshot+stroke 0.5 0.5 0.62 0.5+expect_value moved > 100+expect_value last_dab_angle == 30+wait_idle 30+shot fixed-angle+key ctrl+z+run brush_alpha_options follow_stroke=true+stroke 0.5 0.5 0.62 0.5+expect_value last_dab_angle == -60+key ctrl+z++# Angle jitter: each stamp its own turn, within the range around Angle.+run brush_alpha_options follow_stroke=false angle=0 angle_jitter=90+stroke 0.5 0.5 0.62 0.5+remember last_dab_angle first+expect_value last_dab_angle >= -90+expect_value last_dab_angle <= 90+stroke 0.3 0.4 0.42 0.4+expect_value last_dab_angle != $first+expect_value last_dab_angle >= -90+expect_value last_dab_angle <= 90+wait_idle 30+shot jitter+key ctrl+z+key ctrl+z++# Slide Stamp: Angle (and jitter) turn it; sliding moves it without turning it.+run brush_alpha_options angle=45 angle_jitter=0+click "Stroke##palette.stroke"+click "Slide Stamp##stroke"+key escape+expect_value stroke_type == 2+stroke 0.4 0.4 0.6 0.55+expect_value last_dab_angle == 45+key ctrl+z++# The VDM brush keeps its own; another brush keeps its own.+click "Clay##brush.clay"+wait 0.1+run brush_alpha_options angle=0+click "Horn##vdm0"+wait 0.1+expect_value alpha_angle == 45+expect_value alpha_follow == 0+click "Clay##brush.clay"+wait 0.1+expect_value alpha_angle == 0++# A custom brush: Save Brush Settings writes Follow, Angle and Angle jitter into its brush file.+run brush_create name="Turn Test" depth=0.4+wait 0.1+run brush_alpha_options follow_stroke=true angle=-20 angle_jitter=15+expect_value recipe_alpha_angle == 0+click "Brush##palette.brush"+click "Save Brush Settings##brush.save_settings"+expect_value recipe_alpha_follow == 1+expect_value recipe_alpha_angle == -20+expect_value recipe_alpha_jitter == 15+expect_value library_files >= 1