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
Content pass: 60 brushes in six built-in packs, A-Z sorting with a Sort menu, one Masking panel
islandmed1d0062f3d1fe
diff --git a/CMakeLists.txt b/CMakeLists.txtindex 463d9b69..42030db0 100644--- a/CMakeLists.txt+++ b/CMakeLists.txt@@ -62,6 +62,7 @@ add_library(sculptforge_core STATICsrc/core/Pack.cppsrc/core/Json.cppsrc/core/BrushRecipe.cpp+ src/core/BrushPacks.cppsrc/core/BrushSettings.cppsrc/core/AlphaOptions.cppsrc/core/BrushLibrary.cppdiff --git a/changes/feat-content-pass.md b/changes/feat-content-pass.mdnew file mode 100644index 00000000..f852b702--- /dev/null+++ b/changes/feat-content-pass.md@@ -0,0 +1,38 @@+---+whats_new: **Brush packs**: sixty new built-in brushes in six packs (Clay & Form, Hard Surface, Organic & Skin,+ Cloth & Folds, Damage & Wear, Ornament), each with its own alpha and a one-line description; see+ [Brush packs](brush-packs.md).+whats_new: **A-Z everywhere**: brushes, alphas, materials and the Library list A-Z; **Sort** switches to the most+ recently used first or (brushes, alphas) by pack. Alphas get a filter field.+whats_new: **Masking panel**: **Tool > Masking** is one panel of buttons with pictures: the Shapes, **Mask by**+ (cavity, peaks, face group, colour, facing, border) and **Adjust** (grow, shrink, sharpen, blur, invert, clear,+ all).+highlight: Sixty new brushes in six built-in packs+highlight: Mask by peaks, colour and facing in a new Masking panel+added: **Brush packs**: 60 built-in brushes in six packs (Clay & Form, Hard Surface, Organic & Skin, Cloth & Folds,+ Damage & Wear, Ornament), made from SculptForge's own recipe engine and procedural alphas. A pack brush picked the+ first time brings its alpha (and turns it along the stroke where that helps). Guide chapter+ [Brush packs](docs/guide/brush-packs.md).+added: Six new procedural alphas: **Cobblestone**, **Leather Grain**, **Hex Plates**, **Knit**, **Bolt** and+ **Chips** (21 built-in alphas in all).+added: **Sort** menu on the brush grid and list, the Alpha palette, the Material picker and the Library: A-Z (the+ default), Recent, and Pack (brushes, alphas). Saved in the preferences. The Alpha palette gets a filter field.+added: **Mask by peaks**, **Mask by colour** and **Mask by facing** (`mask_by_peaks`, `mask_by_color`,+ `mask_by_facing`), and `brush_use name=...` to pick a library or pack brush from scripts and macros.+added: Brush recipes (.sfbrush, brush codes) may name a built-in `alpha` and `alphaFollow`; older files are+ unchanged.+changed: **Tool > Masking** is one panel of buttons with pictures and a hint each: Shapes, Mask by and Adjust,+ with their options under **Mask by options**.+changed: Brushes, alphas, materials and Library files list A-Z by default (alphas and materials were in a fixed+ order; Library projects were newest first, which is still one click away under **Sort: Recent**).+testers:+ - Brush palette: the grid shows Built-in, Custom, then Brush packs, A-Z. **Sort: A-Z > Pack** shows one section+ per pack. Pick **Rivet Row** and stroke across the model: a row of rivets along the stroke.+ - Pick **Seam Stitch** on a sphere and drag a curve: the stitches follow the curve.+ - Alpha palette: A-Z with Round first; type "st" in the filter: only Cobblestone, Rock Strata and Stitches stay.+ - Tool > Masking: hold Ctrl over each button for its hint; **By facing** masks the front of a sphere from the front+ view; paint a red patch, set the colour to red and **By colour** masks just the patch.+ - Windows at 150% scaling: the Masking buttons' pictures and labels fit, nothing overlaps.+---+Content pass from the 11-03 reviewer video ("missing a ton of stuff", "build these brushes myself", "not much+masking", "alphas not alphabetical").diff --git a/docs/brushes.md b/docs/brushes.mdindex 0568e4dc..5dd9fa66 100644--- a/docs/brushes.md+++ b/docs/brushes.md@@ -43,6 +43,8 @@ A `.sfbrush` file is a JSON object:| `pressureCurve` | 0.3 … 3 | Tablet response || `frontFacesOnly` | `true` / `false` | Protects the far side of thin parts || `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) |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/brush-packs.md b/docs/guide/brush-packs.mdnew file mode 100644index 00000000..1405bd76--- /dev/null+++ b/docs/guide/brush-packs.md@@ -0,0 +1,144 @@+# Brush packs++SculptForge comes with sixty ready-tuned brushes in six packs, on top of the built-in brushes. Each one is a+brush recipe (see [Brush Lab](brush-lab.md)) with its own alpha where it needs one, so you can use them as they are,+or open one in Brush Lab and make your own version. Every brush, alpha and preview here is made by SculptForge itself:+the recipe engine, procedural alphas and the same clay-ball thumbnails as the brush picker.++## Find and pick a pack brush++- **Sculpt > Brush**: the grid shows **Built-in**, **Custom**, then **Brush packs**. **Sort: A-Z > Pack** shows one+ section per pack. The filter field finds a brush by name.+- **B** opens the brush picker: type the first letters of the name, then the orange key.+- **Custom brushes** in **Sculpt > Brush** lists every pack brush with its pack's name beside it.+- Scripts and macros: `brush_use name="Rivet Row"`; `brush_list` shows every brush with its pack.++The first time you pick a pack brush it brings its own alpha (Rivet Row brings **Rivets**, turned along the+stroke); brushes without one go back to the plain round tip. From then on the brush keeps whatever you change, as every+brush does (**Sculpt > Brush > Save Brush Settings** keeps it for good, **Reset Brush to Default** brings back the pack's).++Pack brushes are read-only like the other built-ins: changing one in Brush Lab saves your own copy, which replaces it+in the lists until you delete it.++Textures (pores, stitches, weave, rivets) need enough polygons to show: subdivide, or turn on+[Dynamic topology](dynamic-topology.md), until the brush's detail is several polygons wide.++## Clay & Form++Block in, build up and refine big forms: clay strokes, planes, and smooth blends.++++| Brush | What it does | Alpha |+|---|---|---|+| **Block Former** | Big, flat-topped clay strokes that stack fast, for blocking in primary forms. | Square |+| **Soft Clay** | Gentle round clay that builds in thin layers and blends into the surface. | |+| **Clay Strip** | Narrow, crisp strips of clay with a hard edge, for muscle fibres and planes. | Square |+| **Plane Cutter** | Shaves the surface down to flat planes, for stylised forms and stone. | |+| **Volume Fill** | Fills low areas up to the stroke's plane and leaves the high points alone. | |+| **Level Out** | Presses hills and valleys onto one plane and softens the result, to calm busy areas. | |+| **Swell** | Puffs the surface out along its own normals, for cheeks, bellies and soft volumes. | |+| **Form Smoother** | Relaxes lumps while keeping the big shape, for a clean pass after blocking. | |+| **Clay Drag** | Smears soft clay along the stroke like a thumb pushing it, for blending transitions. | |+| **Edge Definer** | Pinches a crisp edge into the surface where two planes meet. | |++## Hard Surface++Crisp planes, panel lines, bevels, rivets and bolts for props, armour and machines.++++| Brush | What it does | Alpha |+|---|---|---|+| **Panel Line** | Cuts a clean, narrow groove for panel gaps and seams. | |+| **Flat Plane** | Presses a perfectly flat face with a hard edge, for machined surfaces. | Square |+| **Bevel Scrape** | Scrapes high points into a bevel along an edge, for chamfers. | |+| **Raised Plate** | Builds a flat, square-edged plate on the surface, for armour and hull panels. | Square |+| **Rivet Row** | Stamps rows of round rivet heads along the stroke. | Rivets |+| **Bolt Head** | Stamps a hexagonal bolt on a washer; space the dabs out or click once. | Bolt |+| **Hex Armour** | Raises a honeycomb of hexagonal plates, for sci-fi armour and shells. | Hex Plates |+| **Vent Slots** | Cuts parallel slots like a vent grille; drag across the slots. | Wrinkles |+| **Grid Studs** | An even grid of small studs, for grip textures and tread plates. | Dot Grid |+| **Hard Cut** | Cuts the surface flat below the stroke, for sharp silhouettes and clean cuts. | Square |++## Organic & Skin++Pores, wrinkles, folds, veins and scales for creatures and portraits.++++| Brush | What it does | Alpha |+|---|---|---|+| **Fine Pores** | Small, evenly scattered pores for faces and close-ups. | Pores |+| **Deep Pores** | Bigger, deeper pores for noses, cheeks and rough skin. | Pores |+| **Crow's Feet** | Fine fanned wrinkle lines, for eye corners and knuckles. | Wrinkles |+| **Skin Fold** | Soft rolls of heavy skin, for necks, bellies and brows. | Skin Folds |+| **Crease Line** | A sharp, deep crease with pinched sides, for eyelids, lips and nasal folds. | |+| **Vein** | Raises thin, soft-edged veins along the stroke. | |+| **Reptile Scales** | Overlapping rows of rounded scales, for lizards, dragons and fish. | Scales |+| **Leather Hide** | Pebbled grain with fine creases, for leather, elephant and rhino skin. | Leather Grain |+| **Muscle Fibre** | Long soft ridges along the stroke, for muscle striation and sinew. | Hair Strands |+| **Flesh Pinch** | Pulls soft flesh together into a ridge, for lips, knuckles and wrinkles that bunch. | |++## Cloth & Folds++Folds, seams, stitches, weave and knit for clothing and soft goods.++++| Brush | What it does | Alpha |+|---|---|---|+| **Fold Ridge** | Raises a rounded fold of cloth with soft sides. | |+| **Fold Valley** | Carves the soft valley between two folds. | |+| **Tension Crease** | A sharp crease where cloth pulls tight, for armpits, elbows and seams under strain. | |+| **Seam Stitch** | A sewn seam with cross stitches; drag along the seam. | Stitches |+| **Woven Cloth** | Threads woven over and under, for canvas, denim and sacking. | Fabric Weave |+| **Knitted Wool** | Rows of V-shaped loops, for jumpers, scarves and chunky knits. | Knit |+| **Hem Edge** | A flat, square-edged band along the stroke, for hems, cuffs and straps. | Square |+| **Cloth Drape** | Drags the surface along the stroke so folds flow and hang, for drapery. | |+| **Wrinkle Bunch** | Small compressed wrinkles where cloth gathers, at waists and wrists. | |+| **Padded Quilt** | Puffs soft panels up between the stroke's edges, for quilting and padding. | Square |++## Damage & Wear++Cracks, chips, dents, scratches and erosion for weathered stone, wood and metal.++++| Brush | What it does | Alpha |+|---|---|---|+| **Dry Cracks** | A web of thin cracks, for dry earth, old paint and stone. | Cracks |+| **Deep Fissure** | One deep, jagged split, for broken rock and ice. | |+| **Edge Chips** | Knocks angular chips out of edges only; flat areas stay whole. | Chips |+| **Dents** | Soft, scattered dents, for beaten metal and hammered surfaces. | |+| **Scratches** | Thin, sharp scratches along the stroke, for scuffed metal and wood. | |+| **Eroded Stone** | Breaks the surface up with noise, for weathered rock and sandstone. | |+| **Rock Layers** | Stepped, broken strata, for cliffs and layered stone. | Rock Strata |+| **Cobbles** | Packed rounded stones with grooves between, for paths and old walls. | Cobblestone |+| **Wood Grain** | Rough furrows and ridges, for bark and weathered planks; drag along the grain. | Bark |+| **Worn Edges** | Softens and rounds only the sharp ridges, as years of handling do. | |++## Ornament++Beads, ropes, filigree, studs and carved patterns for jewellery, trims and decoration.++++| Brush | What it does | Alpha |+|---|---|---|+| **Bead Chain** | A row of round beads along the stroke, for jewellery and trims. | |+| **Rope Twist** | A twisted rope or cord, for borders and rigging. | Hair Strands |+| **Filigree Line** | A thin, raised wire line, for filigree and engraved borders. | |+| **Engrave** | Cuts a fine, crisp line, for engraving, runes and lettering. | |+| **Stud Row** | Rounded studs spaced along the stroke, for belts, doors and armour trims. | |+| **Raised Band** | A flat, raised band with clean edges, for bezels, rims and mouldings. | |+| **Scroll Relief** | Soft, rounded relief that builds up slowly, for carved scrolls and leaves. | |+| **Scale Mail** | Rows of small scales, for armour, roof tiles and feathers. | |+| **Gem Setting** | A raised round setting with a crisp rim, for cabochons and gem seats. | |+| **Dot Texture** | Fine even dots, for stippling, punched leather and decorative fields. | Dot Grid |++## New alphas++Six procedural alphas came with the packs and work with any brush (**Sculpt > Alpha**): **Cobblestone**,+**Leather Grain**, **Hex Plates**, **Knit**, **Bolt** and **Chips**. **Sculpt > Alpha** lists every alpha A-Z (Round, the+plain tip, first), has a filter field, and **Sort** for the most recently used first or by pack.diff --git a/docs/guide/images/brush-packs/clay-form.jpg b/docs/guide/images/brush-packs/clay-form.jpgnew file mode 100644index 00000000..2f8e55c6Binary files /dev/null and b/docs/guide/images/brush-packs/clay-form.jpg differdiff --git a/docs/guide/images/brush-packs/cloth-folds.jpg b/docs/guide/images/brush-packs/cloth-folds.jpgnew file mode 100644index 00000000..0fcaa93fBinary files /dev/null and b/docs/guide/images/brush-packs/cloth-folds.jpg differdiff --git a/docs/guide/images/brush-packs/damage-wear.jpg b/docs/guide/images/brush-packs/damage-wear.jpgnew file mode 100644index 00000000..5e724bdcBinary files /dev/null and b/docs/guide/images/brush-packs/damage-wear.jpg differdiff --git a/docs/guide/images/brush-packs/hard-surface.jpg b/docs/guide/images/brush-packs/hard-surface.jpgnew file mode 100644index 00000000..befe54deBinary files /dev/null and b/docs/guide/images/brush-packs/hard-surface.jpg differdiff --git a/docs/guide/images/brush-packs/organic-skin.jpg b/docs/guide/images/brush-packs/organic-skin.jpgnew file mode 100644index 00000000..dcc8f7e4Binary files /dev/null and b/docs/guide/images/brush-packs/organic-skin.jpg differdiff --git a/docs/guide/images/brush-packs/ornament.jpg b/docs/guide/images/brush-packs/ornament.jpgnew file mode 100644index 00000000..9ea719c7Binary files /dev/null and b/docs/guide/images/brush-packs/ornament.jpg differdiff --git a/docs/guide/images/masking-panel.jpg b/docs/guide/images/masking-panel.jpgnew file mode 100644index 00000000..dabeeab3Binary files /dev/null and b/docs/guide/images/masking-panel.jpg differdiff --git a/docs/guide/index.md b/docs/guide/index.mdindex 447727cc..5c4b2aa7 100644--- a/docs/guide/index.md+++ b/docs/guide/index.md@@ -38,6 +38,7 @@ Read it inside SculptForge (**Help > User Guide**, or <kbd>Shift</kbd>+<kbd>F1</8. [Sculpting and brushes](sculpting.md)9. [Brush Lab and sharing brushes](brush-lab.md)+ - [Brush packs: sixty built-in brushes](brush-packs.md)10. [Masking](masking.md)11. [Face Groups and visibility](face-groups.md)12. [Selection sets and morph targets](selection-sets.md)diff --git a/docs/guide/masking.md b/docs/guide/masking.mdindex ac1e021d..b7d7ef4d 100644--- a/docs/guide/masking.md+++ b/docs/guide/masking.md@@ -2,8 +2,8 @@A mask protects part of the model from change. Masked areas are drawn darker, and every brush, the Paintbrush and colour fills leave them alone. This chapter covers painting masks with <kbd>Ctrl</kbd>, masking-with a lasso or rectangle, the background gestures, and the **Tool > Masking** controls for inverting, blurring, growing and building masks-from cavities, face groups or the mesh border.+with a lasso or rectangle, the background gestures, and the **Tool > Masking** panel for inverting, blurring, growing and building masks+from cavities, peaks, face groups, vertex paint, the direction the surface faces or the mesh border.@@ -100,30 +100,57 @@ A drag starts after the cursor moves a few pixels, so a slightly shaky click stior **Mask Rectangle**, a <kbd>Ctrl</kbd> + drag on the background draws that shape; to clear the mask, draw it awayfrom the model, or use **Clear**.-## The Masking sub-palette+## The Masking panel-Open **Tool > Masking** (the Tool palette is in the right tray by default). Every button is one undo step.+Open **Tool > Masking** (the Tool palette is in the right tray by default). It has three rows of buttons, each+with a picture of what it does (the masked part dark, as in the viewport); hold <kbd>Ctrl</kbd> over a button for+its hint. Every button is one undo step.-| Control | What it does | Command |+++**Shapes**: what <kbd>Ctrl</kbd> + drag does.++| Button | What it does | Command ||---|---|---|-| **Show mask** | Darken masked areas in the viewport. | |-| **Mask Pen** / **Mask Lasso** / **Mask Rectangle** | What <kbd>Ctrl</kbd> + drag does: paint with the brush, or mask inside a lasso or rectangle. | `mask_lasso` / `mask_rect` |-| **Mask Strength** | How much each mask stroke or selection masks (0.01 to 1), and the mask value **By cavity** gives the deepest cavities. | |-| **Clear** | Unmask everything. | `mask_clear` |+| **Mask Pen** | Paint the mask with the brush; <kbd>Ctrl</kbd>+<kbd>Alt</kbd> erases. | |+| **Mask Lasso** | Mask what is inside a free shape you draw. | `mask_lasso` |+| **Mask Rectangle** | Mask what is inside a rectangle. | `mask_rect` |++**Front faces only** (lasso and rectangle) masks only what faces you. **Mask Strength** is how much each stroke,+shape or **Mask by** button masks (0.01 to 1).++**Mask by**: build a whole mask at once. Each one replaces the current mask.++| Button | What it masks | Command |+|---|---|---|+| **By cavity** | Concave areas: creases, folds, pores. | `mask_by_cavity` |+| **By peaks** | Convex areas: ridges, peaks and sharp edges (the opposite of By cavity). | `mask_by_peaks` |+| **By face group** | One face group (the number under **Mask by options**). | `mask_by_polygroup` |+| **By colour** | Vertex paint close to the main colour (the left shelf's swatch); unpainted clay counts as white. | `mask_by_color` |+| **By facing** | Surface that faces the camera (or up, or down) within an angle: the front of a face, the top of a rock. | `mask_by_facing` |+| **By border** | The open edges of the mesh and the rings of edges inside them, so sculpting keeps the border in place. A closed mesh has no open edges, and the status bar says so. | `mask_border` |++**Adjust**: change the mask there is.++| Button | What it does | Command |+|---|---|---|+| **Grow** / **Shrink** | Expand or contract the masked region by one ring of edges per pass. | `mask_grow` / `mask_shrink` |+| **Sharpen** / **Blur** | Tighten or soften the mask's edges. | `mask_sharpen` / `mask_blur` || **Invert** | Masked becomes free and free becomes masked. | `mask_invert` |+| **Clear** | Unmask everything. | `mask_clear` || **All** | Mask every visible vertex. | `mask_all` |-| **Blur** | Soften the mask edges by averaging with neighbouring vertices. | `mask_blur` |-| **Sharpen** | Tighten soft edges, pushing values toward fully masked or free. | `mask_sharpen` |-| **Grow** | Expand the masked region by one ring of edges per pass. | `mask_grow` |-| **Shrink** | Contract the masked region by one ring of edges per pass. | `mask_shrink` |-| **passes** | How many times Blur, Sharpen, Grow and Shrink run (1 to 20 here, default 1). | `iterations=` |-| **By cavity** | Mask concave areas (creases, folds, pores), replacing the current mask. | `mask_by_cavity` |-| **threshold** | How concave a spot must be for **By cavity** (-0.2 to 0.5, default 0.02). 0 masks anything concave; higher values keep only deep creases. | `threshold=` |-| **By face group** | Mask one face group, replacing the current mask. The number field next to it is the face group id. | `mask_by_polygroup` |-| **By border** | Mask the open edges of the mesh (edges with only one face) and the rings of edges inside them, replacing the current mask, so sculpting keeps the border in place. Uses **Mask Strength**. A closed mesh has no open edges, and the status bar says so. | `mask_border` |-| **Rings** | How wide **By border** masks, in rings of edges from the border (1 to 20, default 2; 1 masks the border vertices only). | `rings=` |-| **Face Group borders** | **By border** also masks where face groups meet. | `polygroups=true` |-| **Soft** | **By border** fades the mask from the border towards the innermost ring. | `soft=true` |++**Passes** sets how many times Grow, Shrink, Sharpen and Blur run (1 to 20). **Mask by options** holds the rest:++| Option | For | |+|---|---|---|+| **Cavity / peaks threshold** | How deep a crease (By cavity) or sharp a ridge (By peaks) must be (-0.2 to 0.5, default 0.02). 0 takes anything; higher keeps only the strongest. | `threshold=` |+| **Face group** | The face group id By face group masks. | `group=` |+| **Colour tolerance** | How different a colour may be and still count for By colour (0.01 to 1, default 0.15). | `tolerance=` |+| **Faces the camera / up / down** and **Angle** | The direction By facing compares with, and how far the surface may turn from it (default 60 degrees). | `x= y= z= angle=` |+| **Border rings** | How wide By border masks, in rings of edges (1 to 20, default 2). | `rings=` |+| **Face Group borders** | By border also masks where face groups meet. | `polygroups=true` |+| **Soft** | By border fades the mask from the border towards the innermost ring. | `soft=true` |Mask operations only change visible parts of the model; hidden parts keep their mask. **Clear** is theexception and frees everything.@@ -155,7 +182,7 @@ The quickest way works without knowing the group's number:**By face group** masks a group by its id. The viewport doesn't show ids, but the console does: isolate thegroup, then open the console (<kbd>`</kbd>) and read the `isolate_face group group=N` line. Enter that number in-the field next to **By face group** and click it.+**Mask by options > Face group** and click **By face group**.### Sculpt without breaking the borderdiff --git a/src/app/App.h b/src/app/App.hindex b1963139..e74be35c 100644--- a/src/app/App.h+++ b/src/app/App.h@@ -562,6 +562,7 @@ private:// Ctrl+click on the background inverts it, Ctrl+drag there clears it.// With MaskLasso / MaskRect, Ctrl+drag draws the shape instead.void drawMaskingSection();+ bool maskButton(const char* id, const char* hint, int art, float width, bool selected = false);void beginMaskStroke(float x, float y);void maskCanvasMove(float x, float y);void maskCanvasRelease();@@ -573,6 +574,9 @@ private:int maskIterations_ = 1;float cavityThreshold_ = 0.02f;int maskGroup_ = 0;+ float maskColorTolerance_ = 0.15f; // Tool > Masking > By colour+ int maskFacingDir_ = 0; // By facing: 0 the camera, 1 up, 2 down+ float maskFacingAngle_ = 60.0f;int maskBorderRings_ = 2; // Tool > Masking > By border: width in edge rings (#61)bool maskBorderGroups_ = false; // ... polygroup borders toobool maskBorderSoft_ = false; // ... fading inwards@@ -1750,6 +1754,7 @@ public:private:void initBrushSettings();void syncBrushSettings(); // every frame, outside strokes+ void recipeAlpha(BrushToolSettings& s) const; // the active recipe's own alpha (brush packs) into `s`void syncAlphaTile(); // the brush's Tile onto the current alphavoid registerAlphaOptionsCommand(); // brush_alpha_options (#76)std::string brushSettingsPath() const;diff --git a/src/app/AssetLibrary.h b/src/app/AssetLibrary.hindex 6b63eeb6..c9905188 100644--- a/src/app/AssetLibrary.h+++ b/src/app/AssetLibrary.h@@ -124,7 +124,7 @@ private:// --- Thumbnail cache keys (spec: fnv1a64(kind|absPath|size|mtime|version)) ----constexpr int kThumbnailVersion = 4; // bump when thumbnails are rendered differently+constexpr int kThumbnailVersion = 5; // bump when thumbnails are rendered differentlyuint64_t fnv1a64(std::string_view data, uint64_t seed = 0xcbf29ce484222325ull);std::string hex64(uint64_t v); // 16 lower-case hex digits// Key of a file's thumbnail: changes when the file is rewritten (size or time) or the renderer changes.diff --git a/src/app/BrushPreview.cpp b/src/app/BrushPreview.cppindex c4d82f8f..014a6938 100644--- a/src/app/BrushPreview.cpp+++ b/src/app/BrushPreview.cpp@@ -3,6 +3,7 @@#include "app/BrushPreview.h"#include "app/AssetLibrary.h"+#include "core/BrushAlpha.h"#include "core/Document.h"#include "core/PathStroke.h"#include "core/Primitives.h"@@ -100,7 +101,10 @@ std::unique_ptr<Mesh> sculptBrushPreview(const BrushRecipe* recipe, int type) {d.setMesh(makeIcosphere(kBallDetail, kBallRadius));const float r = 0.17f;if (recipe) {- stroke(d, recipe, BrushType::Standard, frontCurve(), r, 0.9f);+ if (!recipe->alpha.empty()) BrushAlpha::builtin(recipe->alpha, d.brushAlpha); // (as its first pick has)+ // A textured brush (alpha or pattern) strokes wider, so its texture reads at thumbnail size.+ const bool textured = !recipe->alpha.empty() || recipe->pattern != BrushRecipe::Pattern::None;+ stroke(d, recipe, BrushType::Standard, frontCurve(), textured ? 0.26f : r, 0.9f);return sceneMesh(d);}// Each brush gets a mark of its own shape that shows what it does, so the shelf tells them apart at a glancediff --git a/src/app/BrushSettingsUi.cpp b/src/app/BrushSettingsUi.cppindex 119ee96c..ec6f3e1a 100644--- a/src/app/BrushSettingsUi.cpp+++ b/src/app/BrushSettingsUi.cpp@@ -100,11 +100,25 @@ void App::syncBrushSettings() {if (!brushSettingsOn_) return;const std::string key = currentBrushKey();if (key == brushSettingsKey_) return;- applyBrushSettings(brushSettings_.switchBrush(brushSettingsKey_, key, liveBrushSettings()));+ const bool firstUse = !brushSettings_.known(key);+ BrushToolSettings next = brushSettings_.switchBrush(brushSettingsKey_, key, liveBrushSettings());+ if (firstUse) recipeAlpha(next); // a brush-pack brush starts with its own alpha (or none), not the last brush's+ applyBrushSettings(next);brushSettingsKey_ = key;syncAlphaTile();}+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;+ s.alphaOptions.followStroke = r.alphaFollow;+ s.alphaOptions.tileX = s.alphaOptions.tileY = 1;+}+void App::syncAlphaTile() { // Tile lives on the alpha (a new alpha starts at 1 x 1): the brush's option winsalphaOptions_.clamp();doc_.brushAlpha.tileX = alphaOptions_.tileX;@@ -149,7 +163,9 @@ void App::saveBrushSettings() {void App::resetBrushSettings() {syncBrushSettings();const bool wasSaved = brushSettings_.hasSaved(brushSettingsKey_);- applyBrushSettings(brushSettings_.reset(brushSettingsKey_));+ BrushToolSettings shipped = brushSettings_.reset(brushSettingsKey_);+ recipeAlpha(shipped); // (a pack brush's own alpha is part of its defaults)+ applyBrushSettings(shipped);std::string err;if (wasSaved && brushSettingsOn_ && !brushSettingsPath().empty() && !brushSettings_.save(brushSettingsPath(), err))status_ = err;diff --git a/src/app/Config.cpp b/src/app/Config.cppindex 483648c0..7326f847 100644--- a/src/app/Config.cpp+++ b/src/app/Config.cpp@@ -15,6 +15,7 @@#include "app/Ui.h"#include "app/I18n.h"#include "core/Bake.h"+#include "core/ListSort.h"#include "core/Micro.h"#include "core/Multires.h"#include "core/Script.h"@@ -88,6 +89,10 @@ Json toJson(const UiPrefs& p) {j.set("inputStyle", std::string(p.inputStyle == 3 ? "maya" : p.inputStyle == 2 ? "blender" : p.inputStyle == 1 ? "sculptforge" : "zbrush"));j.set("emulateNumpad", p.emulateNumpad);j.set("rightClickQuickMenu", p.rightClickQuickMenu);+ j.set("brushSort", p.brushSort);+ j.set("alphaSort", p.alphaSort);+ j.set("materialSort", p.materialSort);+ j.set("librarySort", p.librarySort);j.set("spaceCamera", p.spaceCamera);j.set("emulate3Button", p.emulate3Button);j.set("mayaZoomHorizontal", p.mayaZoomHorizontal);@@ -150,6 +155,9 @@ void fromJson(const Json& j, UiPrefs& p) {}p.emulateNumpad = j["emulateNumpad"].asBool(p.emulateNumpad);p.rightClickQuickMenu = j["rightClickQuickMenu"].asBool(p.rightClickQuickMenu);+ for (auto [key, v] : {std::pair{"brushSort", &p.brushSort}, std::pair{"alphaSort", &p.alphaSort},+ std::pair{"materialSort", &p.materialSort}, std::pair{"librarySort", &p.librarySort}})+ if (j[key].isString()) *v = listSortId(listSortFromId(j[key].asString()));p.spaceCamera = j["spaceCamera"].asBool(p.spaceCamera);p.emulate3Button = j["emulate3Button"].asBool(p.emulate3Button);p.mayaZoomHorizontal = j["mayaZoomHorizontal"].asBool(p.mayaZoomHorizontal);diff --git a/src/app/Config.h b/src/app/Config.hindex b3f2d1cb..3fd50ca3 100644--- a/src/app/Config.h+++ b/src/app/Config.h@@ -42,6 +42,8 @@ struct UiPrefs {bool inputStyleSaved = false; // ui.json named the style (not saved itself): an install from before 0.10.4// without it had the ZBrush-style keys and keeps them (PanelProject.cpp)bool emulateNumpad = false; // Blender style: the 1-9 and 0 keys above the letters act as the numpad (laptops)+ // The order of the asset lists (core/ListSort.h ids "az", "recent", "pack"): brushes, alphas, materials, Library.+ std::string brushSort = "az", alphaSort = "az", materialSort = "az", librarySort = "az";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)diff --git a/src/app/I18nSpanish.cpp b/src/app/I18nSpanish.cppindex 88105735..e2f8588a 100644--- a/src/app/I18nSpanish.cpp+++ b/src/app/I18nSpanish.cpp@@ -441,6 +441,15 @@ constexpr Entry kSpanish[] = {{"Shrink", "Contraer"},{"By cavity", "Por cavidad"},{"By face group", "Por grupo de caras"},+ {"By peaks", "Por crestas"},+ {"By colour", "Por color"},+ {"By facing", "Por orientación"},+ {"By border", "Por borde"},+ {"Shapes", "Formas"},+ {"Mask by", "Enmascarar por"},+ {"Adjust", "Ajustar"},+ {"Mask by options", "Opciones de Enmascarar por"},+ {"Face group %d", "Grupo de caras %d"},{"Passes", "Pasadas"},{"Mask Strength", "Fuerza de la máscara"},{"Threshold", "Umbral"},diff --git a/src/app/LightBox.cpp b/src/app/LightBox.cppindex 89e45e34..279627d4 100644--- a/src/app/LightBox.cpp+++ b/src/app/LightBox.cpp@@ -7,6 +7,7 @@#include "app/Pickers.h"#include "app/Ui.h"#include "app/I18n.h"+#include "core/ListSort.h"#include "core/Matcap.h"#include "core/Primitives.h"#include "core/Project.h"@@ -361,6 +362,18 @@ std::vector<AssetEntry> LightBox::entries(App& app) {place_.folder, libraryTabId(tab), [tab](const std::string& p) { return fileKindForTab(tab, p); },tab == LibraryTab::QuickSave || tab == LibraryTab::Project))out.insert(out.end(), list->begin(), list->end());+ // Files in the chosen order (A-Z by default, or the newest first; folders stay first, A-Z). QuickSaves are+ // always newest first: their names are their times.+ if (tab != LibraryTab::QuickSave && place_.folder != app.library_.starter) {+ const bool recent = listSortFromId(app.uiPrefs_.librarySort) == ListSort::Recent;+ const auto files = std::stable_partition(out.begin(), out.end(), [](const AssetEntry& e) {+ return e.kind == AssetKind::Up || e.kind == AssetKind::Folder;+ });+ std::stable_sort(files, out.end(), [recent](const AssetEntry& a, const AssetEntry& b) {+ if (recent && a.mtime != b.mtime) return a.mtime > b.mtime;+ return naturalLess(a.name, b.name);+ });+ }}if (filter_[0]) {const std::string f = lower(filter_);@@ -707,7 +720,8 @@ void LightBox::drawHeader(App& app, float width) {buttonW(ICON_LC_SMARTPHONE) + 8.0f * scale;const float feedbackW =buttonW(compactFeedback ? ICON_LC_MESSAGE_SQUARE_PLUS : ICON_LC_MESSAGE_SQUARE_PLUS " Fixes & suggestions");- return saveW + filterW + rowsW + folderW + feedbackW + 4 * 8.0f * scale;+ const float sortW = buttonW("Sort: Recent") + 8.0f * scale;+ return saveW + filterW + sortW + rowsW + folderW + feedbackW + 4 * 8.0f * scale;};// The close button is pinned to the right edge (#80: on a 720p screen the group ran past it and hid it); the// rest gets what is left between the tabs and it, clipped if even the compact group doesn't fit.@@ -729,6 +743,8 @@ void LightBox::drawHeader(App& app, float width) {ImGui::InputTextWithHint("##lbfilter", tr(ICON_LC_SEARCH " Filter"), filter_, sizeof filter_);ui::HelpText("Filter", nullptr, "Show only the items whose names contain this text.", "Library");ImGui::SameLine(0, 8 * scale);+ SortMenu("lbsort", app.uiPrefs_.librarySort, false);+ ImGui::SameLine(0, 8 * scale);for (int r = 1; r <= 4; ++r) {const bool on = app.layout_.lightboxRows == r;char label[16];diff --git a/src/app/PanelBrushLibrary.cpp b/src/app/PanelBrushLibrary.cppindex e06bed7d..762f91db 100644--- a/src/app/PanelBrushLibrary.cpp+++ b/src/app/PanelBrushLibrary.cpp@@ -7,7 +7,9 @@// clipboard, and saving Brush Lab edits to the user library automatically.#include "app/App.h"+#include "app/Pickers.h"#include "core/BrushLibrary.h"+#include "core/ListSort.h"#include <imgui.h>@@ -40,7 +42,7 @@ const char* brushTag(const BrushRecipe& b) {case BrushSource::Project: return "project";case BrushSource::Session: return "unsaved";case BrushSource::User: return b.origin.overrides != BrushSource::Session ? "yours" : nullptr;- case BrushSource::Builtin: return nullptr;+ case BrushSource::Builtin: return b.origin.pack.empty() ? nullptr : b.origin.pack.c_str(); // a built-in pack}return nullptr;}@@ -75,7 +77,8 @@ std::string fileUrl(const std::string& path) {// Where a brush comes from, in words (list tooltips, picker Quick Info).std::string brushOriginText(const BrushRecipe& b) {switch (b.origin.source) {- case BrushSource::Builtin: return "Built-in brush";+ case BrushSource::Builtin:+ return b.origin.pack.empty() ? std::string("Built-in brush") : "Built-in brush pack " + b.origin.pack + " (Brush > Sort > Pack)";case BrushSource::User:return b.origin.overrides != BrushSource::Session? std::string("Your version - replaces the ") + brushSourceName(b.origin.overrides) +@@ -212,7 +215,11 @@ void App::drawCustomBrushes() {int actionIndex = -1;if (ImGui::BeginListBox("##custom", ImVec2(-1, ImGui::GetTextLineHeightWithSpacing() * 5.5f))) {const ImGuiStyle& style = ImGui::GetStyle();- for (int i = 0; i < int(doc_.brushes.size()); ++i) {+ std::vector<ListSortKey> keys; // in the brush lists' order (A-Z by default)+ for (const BrushRecipe& b : doc_.brushes)+ keys.push_back({b.name, b.origin.pack, brushRecentRank("recipe:" + b.name), builtinBrushPackRank(b.origin.pack)});+ for (const size_t at : listSortOrder(keys, listSortFromId(uiPrefs_.brushSort))) {+ const int i = int(at);const BrushRecipe& b = doc_.brushes[size_t(i)];const char* tag = brushTag(b);const float tagWidth = tag ? ImGui::CalcTextSize(tag).x + style.ItemSpacing.x : 0.0f;diff --git a/src/app/PanelMasking.cpp b/src/app/PanelMasking.cppindex ad8240eb..f67d2c9e 100644--- a/src/app/PanelMasking.cpp+++ b/src/app/PanelMasking.cpp@@ -204,12 +204,223 @@ bool App::drawHeldBrushGrid(HeldBrush held, bool strokes) {return picked;}+namespace {++// The little pictures on the Masking panel's buttons: a clay ball (or the shape of the selection), the masked part+// dark as the viewport shows it, so each button shows what it does before it is pressed.+enum class MaskArt { Pen, Lasso, Rect, Cavity, Peaks, FaceGroup, Colour, Facing, Border, Grow, Shrink, Sharpen, Blur,+ Invert, Clear, All };++constexpr ImU32 kClay = IM_COL32(196, 178, 160, 255), kClayShade = IM_COL32(150, 134, 120, 255),+ kMasked = IM_COL32(52, 50, 56, 255), kLine = IM_COL32(240, 136, 46, 255);++void drawBall(ImDrawList* dl, ImVec2 c, float r) {+ dl->AddCircleFilled(c, r, kClayShade, 40);+ dl->AddCircleFilled(ImVec2(c.x - r * 0.12f, c.y - r * 0.12f), r * 0.86f, kClay, 40);+}++void drawMaskArt(ImDrawList* dl, ImVec2 c, float r, MaskArt art) {+ const float t = std::max(1.5f, r * 0.09f); // line width+ switch (art) {+ case MaskArt::Pen: {+ drawBall(dl, c, r);+ ImVec2 pts[12];+ for (int i = 0; i < 12; ++i) {+ const float u = float(i) / 11.0f;+ pts[i] = ImVec2(c.x + (u - 0.5f) * r * 1.3f, c.y + std::sin(u * 6.2832f) * r * 0.3f);+ }+ dl->AddPolyline(pts, 12, kMasked, 0, r * 0.32f);+ break;+ }+ case MaskArt::Lasso: {+ drawBall(dl, c, r);+ ImVec2 pts[16];+ for (int i = 0; i < 16; ++i) {+ const float a = float(i) / 16.0f * 6.2832f;+ const float k = 0.55f + 0.12f * std::sin(a * 3.0f);+ pts[i] = ImVec2(c.x + std::cos(a) * r * k, c.y + std::sin(a) * r * k * 0.8f);+ }+ dl->AddConvexPolyFilled(pts, 16, kMasked);+ dl->AddPolyline(pts, 16, kLine, ImDrawFlags_Closed, t * 0.7f);+ break;+ }+ case MaskArt::Rect:+ drawBall(dl, c, r);+ dl->AddRectFilled(ImVec2(c.x - r * 0.55f, c.y - r * 0.4f), ImVec2(c.x + r * 0.55f, c.y + r * 0.4f), kMasked);+ dl->AddRect(ImVec2(c.x - r * 0.55f, c.y - r * 0.4f), ImVec2(c.x + r * 0.55f, c.y + r * 0.4f), kLine, 0, 0,+ t * 0.7f);+ break;+ case MaskArt::Cavity: // the creases masked+ drawBall(dl, c, r);+ for (int k = -1; k <= 1; ++k) {+ ImVec2 pts[9];+ for (int i = 0; i < 9; ++i) {+ const float u = float(i) / 8.0f - 0.5f;+ pts[i] = ImVec2(c.x + u * r * 1.4f, c.y + float(k) * r * 0.42f + u * u * r * 0.6f);+ }+ dl->AddPolyline(pts, 9, kMasked, 0, t * 1.6f);+ }+ break;+ case MaskArt::Peaks: { // ridges masked: bumps whose tops are dark+ drawBall(dl, c, r);+ for (int k = 0; k < 3; ++k) {+ const ImVec2 b(c.x + (float(k) - 1.0f) * r * 0.55f, c.y + r * 0.35f);+ dl->AddTriangleFilled(ImVec2(b.x - r * 0.26f, b.y), ImVec2(b.x + r * 0.26f, b.y),+ ImVec2(b.x, b.y - r * 0.7f), kClayShade);+ dl->AddTriangleFilled(ImVec2(b.x - r * 0.1f, b.y - r * 0.43f), ImVec2(b.x + r * 0.1f, b.y - r * 0.43f),+ ImVec2(b.x, b.y - r * 0.7f), kMasked);+ }+ break;+ }+ case MaskArt::FaceGroup: // two groups, one masked+ dl->PathArcTo(c, r, 1.5708f, 4.7124f, 20);+ dl->PathFillConvex(IM_COL32(120, 170, 210, 255));+ dl->PathArcTo(c, r, -1.5708f, 1.5708f, 20);+ dl->PathFillConvex(kMasked);+ dl->AddLine(ImVec2(c.x, c.y - r), ImVec2(c.x, c.y + r), kLine, t * 0.6f);+ break;+ case MaskArt::Colour: // a painted patch masked+ drawBall(dl, c, r);+ dl->AddCircleFilled(ImVec2(c.x + r * 0.15f, c.y + r * 0.1f), r * 0.48f, IM_COL32(200, 60, 40, 255), 24);+ dl->AddCircleFilled(ImVec2(c.x + r * 0.15f, c.y + r * 0.1f), r * 0.48f, IM_COL32(52, 50, 56, 190), 24);+ dl->AddCircle(ImVec2(c.x + r * 0.15f, c.y + r * 0.1f), r * 0.48f, IM_COL32(200, 60, 40, 255), 24, t * 0.8f);+ break;+ case MaskArt::Facing: // what faces you masked, the sides free+ drawBall(dl, c, r);+ dl->AddCircleFilled(c, r * 0.58f, kMasked, 32);+ dl->AddLine(ImVec2(c.x, c.y + r * 0.95f), ImVec2(c.x, c.y + r * 0.2f), kLine, t * 0.7f);+ dl->AddTriangleFilled(ImVec2(c.x - r * 0.14f, c.y + r * 0.32f), ImVec2(c.x + r * 0.14f, c.y + r * 0.32f),+ ImVec2(c.x, c.y + r * 0.12f), kLine);+ break;+ case MaskArt::Border: // an open disc, its rim masked+ dl->AddCircleFilled(c, r, kMasked, 40);+ dl->AddCircle(c, r, kClayShade, 40, t * 0.6f);+ dl->AddCircleFilled(c, r * 0.58f, kClay, 40);+ dl->AddCircle(c, r * 0.58f, kLine, 40, t * 0.5f);+ break;+ case MaskArt::Grow:+ case MaskArt::Shrink: {+ drawBall(dl, c, r);+ const bool grow = art == MaskArt::Grow;+ dl->AddCircleFilled(c, r * (grow ? 0.62f : 0.32f), kMasked, 32);+ dl->AddCircle(c, r * (grow ? 0.32f : 0.62f), kLine, 32, t * 0.6f);+ break;+ }+ case MaskArt::Sharpen:+ case MaskArt::Blur: {+ drawBall(dl, c, r);+ if (art == MaskArt::Sharpen) {+ dl->AddCircleFilled(c, r * 0.55f, kMasked, 32);+ } else {+ for (int i = 6; i >= 0; --i) // soft edge: stacked translucent rings+ dl->AddCircleFilled(c, r * (0.3f + 0.07f * float(i)), IM_COL32(52, 50, 56, 70), 32);+ }+ break;+ }+ case MaskArt::Invert:+ dl->AddCircleFilled(c, r, kMasked, 40);+ dl->AddCircle(c, r, kClayShade, 40, t * 0.6f);+ dl->AddCircleFilled(c, r * 0.55f, kClay, 32);+ dl->PathArcTo(c, r * 0.55f, -1.5708f, 1.5708f, 16);+ dl->PathFillConvex(kMasked);+ dl->PathArcTo(c, r, 1.5708f, 4.7124f, 20);+ dl->PathArcTo(c, r * 0.55f, 4.7124f, 1.5708f, 16);+ dl->PathStroke(kLine, 0, t * 0.5f);+ break;+ case MaskArt::Clear:+ drawBall(dl, c, r);+ break;+ case MaskArt::All:+ dl->AddCircleFilled(c, r, kMasked, 40);+ dl->AddCircle(c, r, kClayShade, 40, t * 0.6f); // (its outline: dark on a dark button)+ break;+ }+}++} // namespace++// A Masking button with its picture above the label (2 lines at most); the hint is the tooltip and the F1 help.+bool App::maskButton(const char* id, const char* hint, int art, float width, bool selected) {+ const std::string idText = tr(id);+ std::string label = idText.substr(0, idText.find("##"));+ const float lineH = ImGui::GetTextLineHeight();+ const float pic = std::min(width - 6.0f, 60.0f * uiScale_);+ const ImVec2 p = ImGui::GetCursorScreenPos();+ const bool clicked = ImGui::InvisibleButton(idText.c_str(), ImVec2(width, pic + lineH * 2.0f + 6.0f));+ const bool hovered = ImGui::IsItemHovered();+ ImDrawList* dl = ImGui::GetWindowDrawList();+ const ImVec2 b0 = p, b1(p.x + width, p.y + pic + lineH * 2.0f + 6.0f);+ dl->AddRectFilled(b0, b1, ImGui::GetColorU32(hovered ? ImGuiCol_ButtonHovered : ImGuiCol_FrameBg),+ ImGui::GetStyle().FrameRounding);+ if (selected) dl->AddRect(b0, b1, ImGui::GetColorU32(ImGuiCol_CheckMark), ImGui::GetStyle().FrameRounding, 0, 2.0f);+ const float r = pic * 0.42f;+ drawMaskArt(dl, ImVec2(p.x + width * 0.5f, p.y + 3.0f + pic * 0.5f), r, MaskArt(art));+ // The label, centred, wrapped onto a second line at a space when it doesn't fit.+ std::string line1 = label, line2;+ if (ImGui::CalcTextSize(label.c_str()).x > width - 4.0f)+ if (const size_t sp = label.rfind(' '); sp != std::string::npos) {+ line1 = label.substr(0, sp);+ line2 = label.substr(sp + 1);+ }+ float y = p.y + pic + 3.0f;+ for (const std::string* l : {&line1, &line2}) {+ if (l->empty()) continue;+ const float w = ImGui::CalcTextSize(l->c_str()).x;+ dl->PushClipRect(b0, b1, true);+ dl->AddText(ImVec2(std::round(p.x + std::max(2.0f, (width - w) * 0.5f)), y), ImGui::GetColorU32(ImGuiCol_Text),+ l->c_str());+ dl->PopClipRect();+ y += lineH;+ }+ ImGui::LogText(" %s", label.c_str()); // drawn directly: tell the log (UI tests read it) too+ ui::HelpText(label.c_str(), nullptr, tr(hint), "Tool > Masking");+ return clicked;+}+void App::drawMaskingSection() {ImGui::Checkbox(tr("Show mask"), &renderSettings_.showMask);ImGui::SameLine();ImGui::TextDisabled("%s", tr(maskShape_ == SelectShape::Pen ? "(Ctrl paints, Ctrl+Alt erases)": "(Ctrl masks, Ctrl+Alt unmasks)"));- ui::Segmented(*this, {"mask.pen", "mask.lasso", "mask.rect"});+ const ImGuiStyle& style = ImGui::GetStyle();+ const float avail = ImGui::GetContentRegionAvail().x;+ const int columns = avail > 300.0f * uiScale_ ? 4 : 3;+ const float cell = (avail - float(columns - 1) * style.ItemSpacing.x) / float(columns);+ int column = 0;+ auto next = [&] {+ if (column++ % columns != 0) ImGui::SameLine();+ };+ auto group = [&](const char* title) {+ ImGui::Dummy(ImVec2(0, 2));+ ImGui::SeparatorText(tr(title));+ column = 0;+ };++ // Shapes: what Ctrl+drag draws.+ group("Shapes");+ struct Shape {+ const char* action;+ const char* id;+ MaskArt art;+ SelectShape shape;+ const char* hint;+ };+ const Shape shapes[] = {+ {"mask.pen", "Mask Pen##mask.pen", MaskArt::Pen, SelectShape::Pen,+ "Ctrl+drag paints the mask with the brush; Ctrl+Alt+drag erases it. Ctrl+click on the model blurs it."},+ {"mask.lasso", "Mask Lasso##mask.lasso", MaskArt::Lasso, SelectShape::Lasso,+ "Ctrl+drag draws a lasso (any free shape): what is inside gets masked (Ctrl+Alt: unmasked)."},+ {"mask.rect", "Mask Rectangle##mask.rect", MaskArt::Rect, SelectShape::Rect,+ "Ctrl+drag draws a rectangle: what is inside gets masked (Ctrl+Alt: unmasked)."},+ };+ for (const Shape& sh : shapes) {+ next();+ if (maskButton(sh.id, sh.hint, int(sh.art), cell, maskShape_ == sh.shape))+ if (const Action* a = actions_.find(sh.action); a && a->run) {+ actions_.touch(a->id);+ a->run();+ }+ }if (maskShape_ != SelectShape::Pen) { // #91.3ImGui::Checkbox(tr("Front faces only##mask"), &maskFrontFacesOnly_);ui::HelpText("Front faces only", nullptr,@@ -220,64 +431,115 @@ void App::drawMaskingSection() {ImGui::SetNextItemWidth(-1);ui::SliderInside("##maskstrength", &maskStrength_, 0.01f, 1.0f, "Mask Strength %.2f");- const ImGuiStyle& style = ImGui::GetStyle();- const float third = (ImGui::GetContentRegionAvail().x - 2 * style.ItemSpacing.x) / 3.0f;- const float half = (ImGui::GetContentRegionAvail().x - style.ItemSpacing.x) * 0.5f;- if (ImGui::Button(tr("Clear##mask"), ImVec2(third, 0))) runCommand("mask_clear");- if (ImGui::IsItemHovered()) ImGui::SetTooltip("%s", tr("Unmask everything (Mask Pen: Ctrl + drag background)"));- ImGui::SameLine();- if (ImGui::Button(tr("Invert##mask"), ImVec2(third, 0))) runCommand("mask_invert");- if (ImGui::IsItemHovered()) ImGui::SetTooltip("%s", tr("Ctrl + click background"));- ImGui::SameLine();- if (ImGui::Button(tr("All##mask"), ImVec2(third, 0))) runCommand("mask_all");-- const Args passes = {{"iterations", double(maskIterations_)}};- if (ImGui::Button(tr("Blur##mask"), ImVec2(half, 0))) runCommand("mask_blur", passes);- ImGui::SameLine();- if (ImGui::Button(tr("Sharpen##mask"), ImVec2(half, 0))) runCommand("mask_sharpen", passes);- if (ImGui::Button(tr("Grow##mask"), ImVec2(half, 0))) runCommand("mask_grow", passes);- ImGui::SameLine();- if (ImGui::Button(tr("Shrink##mask"), ImVec2(half, 0))) runCommand("mask_shrink", passes);- ImGui::SetNextItemWidth(-1);- tray::SliderInt("##maskpasses", &maskIterations_, 1, 20, "Passes %d");-- if (ImGui::Button(tr("By cavity"), ImVec2(half, 0)))- runCommand("mask_by_cavity", {{"strength", double(maskStrength_)}, {"threshold", double(cavityThreshold_)}});- if (ImGui::IsItemHovered()) ImGui::SetTooltip("%s", tr("Mask creases and folds (replaces the mask; uses the mask strength)"));- ImGui::SameLine();- ImGui::SetNextItemWidth(-1);- ui::SliderInside("##cavitythreshold", &cavityThreshold_, -0.2f, 0.5f, "Threshold %.2f");- if (ImGui::Button(tr("By face group"), ImVec2(half, 0)))+ // Mask by: whole-mesh masks from the shape, the paint, the groups and the border. Each replaces the mask.+ group("Mask by");+ const float strength = maskStrength_;+ next();+ if (maskButton("By cavity##mask", "Mask creases and folds (replaces the mask; uses the mask strength)",+ int(MaskArt::Cavity), cell))+ runCommand("mask_by_cavity", {{"strength", double(strength)}, {"threshold", double(cavityThreshold_)}});+ next();+ if (maskButton("By peaks##mask", "Mask ridges, peaks and sharp edges (replaces the mask; uses the mask strength)",+ int(MaskArt::Peaks), cell))+ runCommand("mask_by_peaks", {{"strength", double(strength)}, {"threshold", double(cavityThreshold_)}});+ next();+ if (maskButton("By face group##mask", "Mask one face group (replaces the mask)", int(MaskArt::FaceGroup), cell))runCommand("mask_by_polygroup", {{"group", double(maskGroup_)}});- if (ImGui::IsItemHovered()) ImGui::SetTooltip("%s", tr("Mask one face group (replaces the mask)"));- ImGui::SameLine();- // The group id as a drag field the size of the button beside it (Ctrl+click or double-click types a number),- // rather than an input with tiny - and + buttons.- ImGui::SetNextItemWidth(-1);- if (ImGui::DragInt("##maskgroup", &maskGroup_, 0.1f, 0, 1 << 30, tr("Group %d"), ImGuiSliderFlags_AlwaysClamp))- maskGroup_ = std::max(0, maskGroup_);-+ next();+ if (maskButton("By colour##mask",+ "Mask where the vertex paint is close to the main colour (the left shelf's swatch); Tolerance "+ "sets how close.",+ int(MaskArt::Colour), cell)) {+ const glm::vec3 c = linearToSrgb(doc_.paintColor);+ runCommand("mask_by_color", {{"r", double(c.x)},+ {"g", double(c.y)},+ {"b", double(c.z)},+ {"tolerance", double(maskColorTolerance_)},+ {"strength", double(strength)}});+ }+ next();+ if (maskButton("By facing##mask",+ "Mask what faces the camera (or faces up or down; Facing below), within the angle: e.g. the front "+ "of a face, or the top of a rock.",+ int(MaskArt::Facing), cell)) {+ const glm::vec3 dir = maskFacingDir_ == 1 ? glm::vec3(0, 1, 0)+ : maskFacingDir_ == 2 ? glm::vec3(0, -1, 0)+ : -camera_.forward();+ runCommand("mask_by_facing", {{"x", double(dir.x)},+ {"y", double(dir.y)},+ {"z", double(dir.z)},+ {"angle", double(maskFacingAngle_)},+ {"strength", double(strength)}});+ }+ next();// Mask from the mesh border (#61): open edges, optionally polygroup borders, a few rings wide.- if (ImGui::Button("By border##mask", ImVec2(half, 0)))+ if (maskButton("By border##mask",+ "Mask the open edges of the mesh and the edge rings inside them, so sculpting never moves the "+ "border. Replaces the mask and uses the mask strength. A closed mesh has no open edges.",+ int(MaskArt::Border), cell))runCommand("mask_border", {{"rings", double(maskBorderRings_)},{"polygroups", maskBorderGroups_},{"soft", maskBorderSoft_},- {"strength", double(maskStrength_)}});- ui::HelpText("By border", nullptr,- "Mask the open edges of the mesh and the edge rings inside them, so sculpting never moves the "- "border (Blender: Mask from mesh boundary). Replaces the mask and uses the mask strength. A closed "- "mesh has no open edges.",- "Tool > Masking");- ImGui::SameLine();+ {"strength", double(strength)}});++ // Adjust the mask there is.+ group("Adjust");+ const Args passes = {{"iterations", double(maskIterations_)}};+ struct Op {+ const char* id;+ const char* hint;+ MaskArt art;+ const char* command;+ bool passes;+ };+ const Op ops[] = {+ {"Grow##mask", "Expand the masked region by one edge ring per pass.", MaskArt::Grow, "mask_grow", true},+ {"Shrink##mask", "Contract the masked region by one edge ring per pass.", MaskArt::Shrink, "mask_shrink", true},+ {"Sharpen##mask", "Tighten soft mask edges (Ctrl+Alt+click on the model).", MaskArt::Sharpen, "mask_sharpen",+ true},+ {"Blur##mask", "Soften the mask edges (Ctrl+click on the model).", MaskArt::Blur, "mask_blur", true},+ {"Invert##mask", "Swap masked and free (Ctrl + click background).", MaskArt::Invert, "mask_invert", false},+ {"Clear##mask", "Unmask everything (Mask Pen: Ctrl + drag background)", MaskArt::Clear, "mask_clear", false},+ {"All##mask", "Mask every visible vertex.", MaskArt::All, "mask_all", false},+ };+ for (const Op& op : ops) {+ next();+ if (maskButton(op.id, op.hint, int(op.art), cell)) runCommand(op.command, op.passes ? passes : Args{});+ }ImGui::SetNextItemWidth(-1);- tray::SliderInt("##maskborderrings", &maskBorderRings_, 1, 20, "Rings %d");- ui::Checkbox("Face Group borders##maskborder", &maskBorderGroups_);- ui::HelpText("Face Group borders", nullptr,- "By border also masks where face groups meet.", "Tool > Masking");- ImGui::SameLine();- ui::Checkbox("Soft##maskborder", &maskBorderSoft_);- ui::HelpText("Soft", nullptr, "By border fades the mask from the border towards the innermost ring.",- "Tool > Masking");+ tray::SliderInt("##maskpasses", &maskIterations_, 1, 20, "Passes %d");++ // The options of the Mask by buttons.+ if (ImGui::TreeNodeEx(tr("Mask by options##mask"), ImGuiTreeNodeFlags_SpanAvailWidth | ImGuiTreeNodeFlags_DefaultOpen)) {+ const float half = (ImGui::GetContentRegionAvail().x - style.ItemSpacing.x) * 0.5f;+ ImGui::SetNextItemWidth(-1);+ ui::SliderInside("##cavitythreshold", &cavityThreshold_, -0.2f, 0.5f, "Cavity / peaks threshold %.2f");+ ui::HelpText("Threshold", nullptr,+ "How deep a crease (By cavity) or how sharp a ridge (By peaks) must be: 0 takes anything, higher "+ "only the strongest.",+ "Tool > Masking");+ // The group id as a drag field (Ctrl+click or double-click types a number).+ ImGui::SetNextItemWidth(-1);+ if (ImGui::DragInt("##maskgroup", &maskGroup_, 0.1f, 0, 1 << 30, tr("Face group %d"), ImGuiSliderFlags_AlwaysClamp))+ maskGroup_ = std::max(0, maskGroup_);+ ImGui::SetNextItemWidth(-1);+ ui::SliderInside("##maskcolortol", &maskColorTolerance_, 0.01f, 1.0f, "Colour tolerance %.2f");+ ImGui::SetNextItemWidth(half);+ const char* facing[] = {"Faces the camera", "Faces up", "Faces down"};+ ImGui::Combo("##maskfacing", &maskFacingDir_, facing, 3);+ ImGui::SameLine();+ ImGui::SetNextItemWidth(-1);+ ui::SliderInside("##maskfacingangle", &maskFacingAngle_, 5.0f, 180.0f, "Angle %.0f");+ ImGui::SetNextItemWidth(-1);+ tray::SliderInt("##maskborderrings", &maskBorderRings_, 1, 20, "Border rings %d");+ ui::Checkbox("Face Group borders##maskborder", &maskBorderGroups_);+ ui::HelpText("Face Group borders", nullptr, "By border also masks where face groups meet.", "Tool > Masking");+ ImGui::SameLine();+ ui::Checkbox("Soft##maskborder", &maskBorderSoft_);+ ui::HelpText("Soft", nullptr, "By border fades the mask from the border towards the innermost ring.",+ "Tool > Masking");+ ImGui::TreePop();+ }}} // namespace sfdiff --git a/src/app/Pickers.cpp b/src/app/Pickers.cppindex fc6f16fb..e96dd6ed 100644--- a/src/app/Pickers.cpp+++ b/src/app/Pickers.cpp@@ -10,6 +10,8 @@#include "app/AssetLibrary.h"#include "app/Ui.h"#include "core/BrushLibrary.h"+#include "core/BrushPacks.h"+#include "core/ListSort.h"#include "core/Matcap.h"#include <IconsLucide.h>@@ -18,6 +20,7 @@#include <algorithm>#include <filesystem>+#include <functional>#include <array>#include <cctype>#include <cmath>@@ -109,7 +112,25 @@ struct State {// Recently used brushes (ids, newest first).std::vector<std::string> recent;std::string lastActive;+ // The same for alphas (names) and materials (matcap indices as text), for the lists' Recent order.+ std::vector<std::string> recentAlphas, recentMaterials;+ std::string lastAlpha, lastMaterial;};++void touchRecent(std::vector<std::string>& list, std::string& last, const std::string& id) {+ if (id == last) return;+ if (!last.empty()) {+ list.erase(std::remove(list.begin(), list.end(), id), list.end());+ list.insert(list.begin(), id);+ if (list.size() > 12) list.resize(12);+ }+ last = id;+}+int recentRank(const std::vector<std::string>& list, const std::string& id) {+ const auto it = std::find(list.begin(), list.end(), id);+ return it == list.end() ? -1 : int(it - list.begin());+}+State& st() {static State s;return s;@@ -300,6 +321,43 @@ bool AssetTile(const char* id, ImTextureID texture, const char* glyph, const stdreturn clicked;}+float SortMenuWidth() { // the widest Sort button and the gap before it+ const ImGuiStyle& st = ImGui::GetStyle();+ return ImGui::CalcTextSize("Sort: Recent").x + st.FramePadding.x * 2.0f + st.ItemSpacing.x + 2.0f;+}++int brushRecentRank(const std::string& id) { return recentRank(st().recent, id); }++int builtinBrushPackRank(const std::string& pack) {+ const auto& packs = builtinBrushPacks();+ const auto it = std::find(packs.begin(), packs.end(), pack);+ return it == packs.end() ? -1 : int(it - packs.begin());+}++bool SortMenu(const char* id, std::string& pref, bool packs) {+ const ListSort cur = listSortFromId(pref);+ char label[64];+ std::snprintf(label, sizeof label, "Sort: %s##%s", listSortLabel(cur), id);+ if (ImGui::SmallButton(label)) ImGui::OpenPopup(id);+ ui::HelpText("Sort", nullptr,+ packs ? "The order of this list: A-Z (the default), the most recently used first, or grouped by pack."+ : "The order of this list: A-Z (the default) or the most recently changed first.",+ nullptr);+ bool changed = false;+ if (ImGui::BeginPopup(id)) {+ for (int i = 0; i < int(ListSort::Count); ++i) {+ const ListSort m = ListSort(i);+ if (m == ListSort::Pack && !packs) continue;+ if (ImGui::MenuItem((std::string(listSortLabel(m)) + "##" + id).c_str(), nullptr, m == cur) && m != cur) {+ pref = listSortId(m);+ changed = true;+ }+ }+ ImGui::EndPopup();+ }+ return changed;+}+void AssetTileHoverGlow() {Glow& g = glow();if (g.frame != ImGui::GetFrameCount() || !g.tex || ImGui::IsPopupOpen(nullptr, ImGuiPopupFlags_AnyPopupId)) return;@@ -447,6 +505,7 @@ std::vector<BrushItem> PickerUi::brushItems(App& app, bool libraryFiles) {b.name = r.name;b.path = r.origin.path;b.description = r.description;+ b.pack = r.origin.pack;switch (r.origin.source) {case BrushSource::Studio:b.tag = "studio";@@ -562,16 +621,28 @@ void drawBrushGrid(App& app, GridMode mode) {static char paletteFilter[64] = "";if (!popup) {- ImGui::SetNextItemWidth(-1);+ ImGui::SetNextItemWidth(-SortMenuWidth());ImGui::InputTextWithHint("##brushfilter", ICON_LC_SEARCH " Filter brushes", paletteFilter,sizeof paletteFilter);+ ImGui::SameLine();+ SortMenu("brushsort", app.uiPrefs_.brushSort);}const std::string typed = popup ? s.typed : typedName(paletteFilter);std::vector<std::string> names;for (const auto& it : items)names.push_back(it.name);bool substring = false;- const std::vector<size_t> shown = filterByTyped(names, typed, &substring);+ std::vector<size_t> shown = filterByTyped(names, typed, &substring);+ // The chosen order (A-Z by default): the letter badges and Enter follow it.+ const ListSort sort = listSortFromId(app.uiPrefs_.brushSort);+ {+ std::vector<ListSortKey> keys;+ for (size_t i : shown)+ keys.push_back({items[i].name, items[i].pack, recentRank(s.recent, items[i].id()), builtinBrushPackRank(items[i].pack)});+ std::vector<size_t> sorted;+ for (size_t k : listSortOrder(keys, sort)) sorted.push_back(shown[k]);+ shown = std::move(sorted);+ }const auto badges = popup ? letterBadges(names, shown, typed) : std::vector<std::pair<char, size_t>>{};// Letter keys (pop-up only; the palette has a filter field instead).@@ -602,6 +673,8 @@ void drawBrushGrid(App& app, GridMode mode) {// What was typed, or how to type.if (typed.empty()) {ImGui::TextDisabled("Type a letter to narrow the brushes, then press its orange key");+ ImGui::SameLine();+ SortMenu("brushsortpop", app.uiPrefs_.brushSort);} else {std::string shownTyped = typed;for (auto& c : shownTyped)@@ -729,18 +802,31 @@ void drawBrushGrid(App& app, GridMode mode) {break;}}+ // Sections: the built-in brushes, your own and other custom brushes, then the brush packs (one section per+ // pack when sorted by pack), then library files not loaded yet.struct Section {- const char* title;- bool (*match)(const BrushItem&);+ std::string title;+ std::function<bool(const BrushItem&)> match;};- const Section sections[] = {+ std::vector<Section> sections = {{"Built-in",[](const BrushItem& b) {return b.kind == BrushItem::Kind::Type || b.kind == BrushItem::Kind::Paint || b.kind == BrushItem::Kind::Guides;}},- {"Custom", [](const BrushItem& b) { return b.kind == BrushItem::Kind::Recipe; }},- {"Library", [](const BrushItem& b) { return b.kind == BrushItem::Kind::File; }},+ {"Custom", [](const BrushItem& b) { return b.kind == BrushItem::Kind::Recipe && b.pack.empty(); }},};+ if (sort == ListSort::Pack) {+ std::vector<std::string> packs;+ for (size_t i : shown)+ if (items[i].kind == BrushItem::Kind::Recipe && !items[i].pack.empty() &&+ std::find(packs.begin(), packs.end(), items[i].pack) == packs.end())+ packs.push_back(items[i].pack);+ for (const std::string& p : packs)+ sections.push_back({p, [p](const BrushItem& b) { return b.kind == BrushItem::Kind::Recipe && b.pack == p; }});+ } else {+ sections.push_back({"Brush packs", [](const BrushItem& b) { return b.kind == BrushItem::Kind::Recipe && !b.pack.empty(); }});+ }+ sections.push_back({"Library", [](const BrushItem& b) { return b.kind == BrushItem::Kind::File; }});if (popup) {// The grid scrolls inside the pop-up when there are many custom brushes.const float rowH = tile + ImGui::GetFontSize() + 4.0f + ImGui::GetStyle().ItemSpacing.y;@@ -754,10 +840,12 @@ void drawBrushGrid(App& app, GridMode mode) {for (size_t i : shown)if (sec.match(items[i])) in.push_back(i);if (in.empty()) continue;- sectionHeader(sec.title);+ sectionHeader(sec.title.c_str());+ if (const std::string help = builtinBrushPackHelp(sec.title); !help.empty())+ ui::HelpText(sec.title.c_str(), nullptr, help.c_str(), "Brush packs");int column = 0;for (size_t i : in)- drawItem(i, column, sec.title);+ drawItem(i, column, sec.title.c_str());}if (shown.empty()) ImGui::TextDisabled("No brush matches \"%s\"", typed.c_str());if (popup) ImGui::EndChild();@@ -839,63 +927,103 @@ void drawAlphaGrid(App& app, GridMode mode) {drawVdmGrid(app, mode);ImGui::Dummy(ImVec2(0, 4));}+ State& s = st();const float tile = 64.0f * app.uiScale_;- const int columns = columnsFor(tile, mode);const BrushAlpha& current = app.doc_.brushAlpha;- sectionHeader("Built-in");- int column = 0;+ static char filter[64] = "";+ ImGui::SetNextItemWidth(mode == GridMode::Popup ? 200.0f * app.uiScale_ : -SortMenuWidth());+ ImGui::InputTextWithHint("##alphafilter", ICON_LC_SEARCH " Filter alphas", filter, sizeof filter);+ ImGui::SameLine();+ SortMenu("alphasort", app.uiPrefs_.alphaSort);+ const int columns = columnsFor(tile, mode);++ // Every alpha in one list: the built-ins, the loaded image, the library's Alphas folder and the packs'.+ struct Entry {+ enum class Kind { Builtin, Current, File, Pack } kind;+ std::string name, help, path, pack, group;+ int builtin = -1;+ };+ std::vector<Entry> entries;for (int i = 0; i < int(BrushAlpha::builtins().size()); ++i) {- tileGrid(column, columns);const std::string& name = builtinAlpha(i).name;- const std::string help = BrushAlpha::builtinHelp(name);- const bool on = lower(current.name) == lower(name) || (i == 0 && current.empty());- const ImTextureID tex = app.thumbs_.alpha(builtinAlpha(i));- if (AssetTile((name + "##alpha").c_str(), tex, ICON_LC_CIRCLE_DASHED, name.c_str(), tile, on))- app.runCommand("brush_set_alpha", {{"name", name}});- quickInfo(tex, ICON_LC_CIRCLE_DASHED, name.c_str(), help.c_str());- ui::HelpText(name.c_str(), nullptr, help.c_str(), "Alpha");+ entries.push_back({Entry::Kind::Builtin, name, BrushAlpha::builtinHelp(name), "", "", "Built-in", i});}- // The loaded image alpha, then images in the library's Alphas folder.- const bool custom = !current.empty() && lower(current.name) != "square" && lower(current.name) != "noise";- std::vector<AssetEntry> files;+ const bool custom = !current.empty() && !current.path.empty();+ if (custom)+ entries.push_back({Entry::Kind::Current, current.name, "The loaded image alpha (white = full effect).",+ current.path, "", "Images"});if (!app.library_.user.empty()) {const std::string dir = app.library_.user + "/Alphas";if (const auto* list = app.libraryScanner_.get(dir, "alpha", [](const std::string& p) {return isImageFile(p) ? AssetKind::AlphaFile : AssetKind::Folder;}))for (const auto& e : *list)- if (e.kind == AssetKind::AlphaFile) files.push_back(e);+ if (e.kind == AssetKind::AlphaFile && !(custom && lower(e.name) == lower(current.name)))+ entries.push_back({Entry::Kind::File, e.name, "Image in your library's Alphas folder.", e.path, "",+ "Images"});+ }+ for (const PackContentItem& it : app.packAlphas()) // tagged with the pack's name+ entries.push_back({Entry::Kind::Pack, it.label(), "From the pack " + it.packName + ".", it.file, it.packName,+ it.packName});++ const std::string f = lower(filter);+ std::vector<ListSortKey> keys;+ std::vector<size_t> kept;+ for (size_t i = 0; i < entries.size(); ++i) {+ if (!f.empty() && lower(entries[i].name).find(f) == std::string::npos) continue;+ kept.push_back(i);+ // Round is "no alpha": it stays first in every order (the pack order puts it with the built-ins).+ const Entry& e = entries[i];+ ListSortKey k{e.name, e.kind == Entry::Kind::Builtin ? std::string() : "\x01" + e.group,+ recentRank(s.recentAlphas, lower(e.name))};+ if (e.builtin == 0) k.name = std::string(1, '\0');+ keys.push_back(std::move(k));}- if (custom || !files.empty()) {- sectionHeader("Images");- column = 0;- if (custom) {- tileGrid(column, columns);- const ImTextureID tex = app.thumbs_.alpha(current);- AssetTile((current.name + "##alphacur").c_str(), tex, ICON_LC_CIRCLE_DASHED, current.name, tile, true);- quickInfo(tex, ICON_LC_CIRCLE_DASHED, current.name, "The loaded image alpha (white = full effect).");+ const ListSort sort = listSortFromId(app.uiPrefs_.alphaSort);+ std::vector<size_t> order;+ for (size_t k : listSortOrder(keys, sort)) order.push_back(kept[k]);+ if (sort == ListSort::Recent) { // Round first, then the recent ones+ const auto round = std::find_if(order.begin(), order.end(), [&](size_t i) { return entries[i].builtin == 0; });+ if (round != order.end()) std::rotate(order.begin(), round, round + 1);+ }++ int column = 0;+ std::string group = "\x02";+ if (sort != ListSort::Pack) sectionHeader("Alphas");+ for (size_t i : order) {+ const Entry& e = entries[i];+ if (sort == ListSort::Pack && e.group != group) {+ group = e.group;+ sectionHeader(group.c_str());+ column = 0;}- for (const auto& e : files) {- if (custom && lower(e.name) == lower(current.name)) continue;- tileGrid(column, columns);- const ImTextureID tex = app.thumbs_.file(e.path);- if (AssetTile((e.name + "##alphafile").c_str(), tex, ICON_LC_IMAGE, e.name, tile, false))- app.runCommand("brush_set_alpha", {{"path", e.path}, {"invert", app.alphaInvert_}});- quickInfo(tex, ICON_LC_IMAGE, e.name, "Image in your library's Alphas folder.", e.path);+ tileGrid(column, columns);+ bool on = false;+ ImTextureID tex = ImTextureID(0);+ const char* glyph = ICON_LC_IMAGE;+ switch (e.kind) {+ case Entry::Kind::Builtin:+ on = (current.path.empty() && lower(current.name) == lower(e.name)) || (e.builtin == 0 && current.empty());+ tex = app.thumbs_.alpha(builtinAlpha(e.builtin));+ glyph = ICON_LC_CIRCLE_DASHED;+ break;+ case Entry::Kind::Current:+ on = true;+ tex = app.thumbs_.alpha(current);+ glyph = ICON_LC_CIRCLE_DASHED;+ break;+ default: tex = app.thumbs_.file(e.path); break;}- }- if (!app.packAlphas().empty()) { // alphas from installed packs, tagged with the pack's name- sectionHeader("Packs");- column = 0;- for (const PackContentItem& it : app.packAlphas()) {- tileGrid(column, columns);- const std::string label = it.label();- const ImTextureID tex = app.thumbs_.file(it.file);- if (AssetTile((label + "##alphapack" + it.file).c_str(), tex, ICON_LC_IMAGE, label, tile, false))- app.runCommand("brush_set_alpha", {{"path", it.file}, {"invert", app.alphaInvert_}});- quickInfo(tex, ICON_LC_IMAGE, label, ("From the pack " + it.packName + ".").c_str(), it.file);+ const std::string id = e.name + "##alpha" + std::to_string(int(e.kind)) + e.path;+ if (AssetTile(id.c_str(), tex, glyph, e.name, tile, on)) {+ if (e.kind == Entry::Kind::Builtin) app.runCommand("brush_set_alpha", {{"name", e.name}});+ else if (e.kind != Entry::Kind::Current)+ app.runCommand("brush_set_alpha", {{"path", e.path}, {"invert", app.alphaInvert_}});}+ quickInfo(tex, glyph, e.name, e.help, e.path);+ ui::HelpText(e.name.c_str(), nullptr, e.help.c_str(), "Alpha");}+ if (order.empty()) ImGui::TextDisabled("No alpha matches \"%s\"", filter);ImGui::Dummy(ImVec2(0, 2));if (ImGui::Button(ICON_LC_FOLDER_OPEN " Load image...", ImVec2(mode == GridMode::Popup ? 0.0f : -1.0f, 0)))SDL_ShowOpenFileDialog(App::onAlphaChosen, &app, app.window_, kAlphaFilters, 2, nullptr, false);@@ -916,9 +1044,17 @@ void drawMaterialGrid(App& app, GridMode mode) {int hovered = -2;const int active = s.previewing ? s.savedMatcap : app.renderSettings_.matcap;app.materialListShown(); // just opened: pick up images added to the MatCaps folder meanwhile+ SortMenu("materialsort", app.uiPrefs_.materialSort, false);+ std::vector<int> list; // the Lit Spheres and Studio (-1), in the chosen order (A-Z by default)+ std::vector<ListSortKey> keys;for (int k = 0; k <= matcapCount(); ++k) {- const int i = k < matcapCount() ? matcapInListOrder(k) : -1; // the MatCaps (the default first), then Studio+ const int i = k < matcapCount() ? matcapInListOrder(k) : -1;if (i >= 0 && !isMatcapListed(i)) continue; // removed+ list.push_back(i);+ keys.push_back({i < 0 ? "Studio" : matcapName(i), "", recentRank(s.recentMaterials, std::to_string(i))});+ }+ for (size_t o : listSortOrder(keys, listSortFromId(app.uiPrefs_.materialSort))) {+ const int i = list[o];tileGrid(column, columns);const char* name = i < 0 ? "Studio" : matcapName(i);const ImTextureID tex = app.thumbs_.material(i);@@ -1048,6 +1184,9 @@ void drawPickers(App& app) {}}+ touchRecent(s.recentAlphas, s.lastAlpha, lower(app.doc_.brushAlpha.empty() ? std::string("round") : app.doc_.brushAlpha.name));+ if (!s.previewing) touchRecent(s.recentMaterials, s.lastMaterial, std::to_string(app.renderSettings_.matcap));+if (s.open) {// Pickers own the keyboard while open (letters choose brushes; Esc closes).ImGui::SetNextFrameWantCaptureKeyboard(true);diff --git a/src/app/Pickers.h b/src/app/Pickers.hindex 5751dc49..88aec2a3 100644--- a/src/app/Pickers.h+++ b/src/app/Pickers.h@@ -43,6 +43,7 @@ struct BrushItem {std::string path; // .sfbrush (File)std::string description;std::string tag; // "gallery", "studio", "unsaved"... (Recipe)+ std::string pack; // the brush pack it belongs to (a built-in or installed pack's recipe), or ""std::string id() const; // stable across frames: "type:Clay", "recipe:Dragon Scales", "file:<path>"};@@ -60,6 +61,16 @@ struct PickerUi {static bool sliderKnob(ImVec2& knob);};+// The sort menu of an asset list: a small "A-Z v" button that opens A-Z, Recent and (with `packs`) Pack. `pref`+// holds the core/ListSort.h id and is saved with the preferences. Returns true when the order changed.+bool SortMenu(const char* id, std::string& pref, bool packs = true);+float SortMenuWidth(); // room to leave for it beside a filter field++// Where a brush (BrushItem::id) is in the recently used list (0 = last used), -1 when not in it; the place of a+// built-in brush pack in the packs' order, -1 for other packs.+int brushRecentRank(const std::string& id);+int builtinBrushPackRank(const std::string& pack);+// Action id of a brush for the shelves ("brush.clay", "brush.paint", "brush.recipe.<name>").std::string brushActionId(const BrushItem& item);const char* brushTypeDescription(int brushType); // BrushType, or kPaintBrushdiff --git a/src/app/UiTest.cpp b/src/app/UiTest.cppindex ae235b3a..e582bfef 100644--- a/src/app/UiTest.cpp+++ b/src/app/UiTest.cpp@@ -171,6 +171,8 @@// phone_running (1 while the phone link listens), phone_uploads (uploads under way),// phone_captures (captures received), phone_face_frames, phone_face_fps, phone_recording,// phone_take_frames, phone_ar_version (AR models published), phone_ar_busy+// brush_sort / alpha_sort / material_sort / library_sort (0 A-Z, 1 Recent, 2 Pack),+// builtin_pack_brushes (built-in brush-pack brushes loaded), alpha_index (0 Round, -1 an image)// (mesh values are the active SubTool's)// snapshot remember the active mesh's vertices (for the moved* values)// remember VALUE NAME keep VALUE's current value as $NAME@@ -250,6 +252,7 @@#include "app/Ui.h"#include "core/BrushLibrary.h"+#include "core/ListSort.h"#include "core/Matcap.h"#include "core/Multires.h"#include "core/Script.h"@@ -510,6 +513,23 @@ 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 == "brush_sort") return double(int(listSortFromId(app_.uiPrefs_.brushSort))); // 0 A-Z, 1 Recent, 2 Pack+ if (name == "alpha_sort") return double(int(listSortFromId(app_.uiPrefs_.alphaSort)));+ if (name == "material_sort") return double(int(listSortFromId(app_.uiPrefs_.materialSort)));+ if (name == "library_sort") return double(int(listSortFromId(app_.uiPrefs_.librarySort)));+ if (name == "builtin_pack_brushes") // built-in brush-pack brushes loaded+ return double(std::count_if(app_.doc_.brushes.begin(), app_.doc_.brushes.end(), [](const BrushRecipe& r) {+ return r.origin.source == BrushSource::Builtin && !r.origin.pack.empty();+ }));+ if (name == "alpha_index") { // the alpha's place among the built-ins (0 = Round), -1 for an image+ const BrushAlpha& a = app_.doc_.brushAlpha;+ if (a.empty()) return 0.0;+ if (!a.path.empty()) return -1.0;+ const auto& all = BrushAlpha::builtins();+ for (size_t i = 0; i < all.size(); ++i)+ if (all[i].name == a.name) return double(i);+ return -1.0;+ }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 dabdiff --git a/src/app/UserGuide.cpp b/src/app/UserGuide.cppindex be6ab8fe..677f7ba2 100644--- a/src/app/UserGuide.cpp+++ b/src/app/UserGuide.cpp@@ -445,6 +445,7 @@ std::string UserGuide::chapterFor(const std::string& palette, const std::string&if (starts("Tool > Geometry > Quad Remesh") || starts("Tool > Geometry > QRemesh") || starts("Tool > Parts > Project") ||starts("Tool > Part > Project"))return "retopology.md";+ if (starts("Brush packs")) return "brush-packs.md";if (starts("Tool > Parts") || starts("Tool > Part")) return "parts.md";if (starts("Tool > Forge Spheres") || starts("Tool > Forge Spheres")) return "forge-spheres.md";if (starts("Tool > Layers")) return "layers.md";diff --git a/src/core/Benchmark.cpp b/src/core/Benchmark.cppindex 0deae298..64990069 100644--- a/src/core/Benchmark.cpp+++ b/src/core/Benchmark.cpp@@ -227,7 +227,7 @@ StrokeStats runStroke(Document& doc, const BenchBrush& b, int dabs, const BenchGconst std::vector<BrushRecipe> recipes = builtinBrushRecipes();const BrushRecipe* recipe = nullptr;for (const auto& r : recipes)- if (r.pattern != BrushRecipe::Pattern::None) recipe = &r;+ if (r.pattern != BrushRecipe::Pattern::None && r.origin.pack.empty()) recipe = &r; // (the classic seven)if (!recipe && !recipes.empty()) recipe = &recipes.front();if (b.kind == Kind::Paint) m.ensureColors();sc.beginStroke(m, b.name);diff --git a/src/core/BrushAlpha.cpp b/src/core/BrushAlpha.cppindex b36e08dc..39765bcb 100644--- a/src/core/BrushAlpha.cpp+++ b/src/core/BrushAlpha.cpp@@ -276,6 +276,85 @@ const Generated kGenerated[] = {return (1.0f - smooth01(std::hypot(u - cx, v - cy) / (cell * 0.32f))) * squareEdge(u, v);});}},+ {"Cobblestone", "Rounded stones packed together with grooves between, for paths, walls and rough ground.",+ [] {+ return generate("Cobblestone", [](float u, float v) {+ float f1, f2;+ uint32_t id = 0;+ worley(u * 3.2f + 40.0f, v * 3.2f + 40.0f, 91, f1, f2, &id);+ const float edge = smooth01((f2 - f1) / 0.32f); // 0 in the grooves, 1 inside a stone+ const float dome = std::sqrt(std::max(0.0f, edge)) * (0.8f + 0.2f * float(id & 0xffu) / 255.0f);+ const float rough = fbm(u * 10.0f + 3.0f, v * 10.0f, 93) * 0.15f;+ return std::clamp(dome * 0.85f + rough * edge, 0.0f, 1.0f) * squareEdge(u, v);+ });+ }},+ {"Leather Grain", "Fine irregular creases between small pebbled bumps, for leather, hide and elephant skin.",+ [] {+ return generate("Leather Grain", [](float u, float v) {+ float f1, f2;+ worley(u * 11.0f + 7.0f, v * 11.0f + 7.0f, 95, f1, f2);+ const float pebble = smooth01((f2 - f1) / 0.22f);+ float g1, g2;+ worley(u * 4.0f + 13.0f, v * 4.0f + 13.0f, 97, g1, g2);+ const float crease = smooth01((g2 - g1) / 0.06f); // a sparse web of deeper creases+ return std::clamp(pebble * 0.7f * crease + 0.15f * fbm(u * 20.0f, v * 20.0f, 99), 0.0f, 1.0f) *+ squareEdge(u, v);+ });+ }},+ {"Hex Plates", "A honeycomb of flat hexagonal plates with bevelled gaps, for armour, sci-fi panels and shells.",+ [] {+ return generate("Hex Plates", [](float u, float v) {+ const float scale = 3.0f; // plates across+ float x = (u + 1.0f) * scale, y = (v + 1.0f) * scale;+ // Nearest centre on a hex lattice (two offset rectangular grids).+ const float w = 1.0f, h = 1.7320508f;+ auto near = [&](float ox, float oy) {+ const float cx = (std::floor((x - ox) / w) + 0.5f) * w + ox;+ const float cy = (std::floor((y - oy) / h) + 0.5f) * h + oy;+ return glm::vec2(x - cx, y - cy);+ };+ glm::vec2 a = near(0.0f, 0.0f), b = near(0.5f, h * 0.5f);+ const glm::vec2 d = glm::dot(a, a) < glm::dot(b, b) ? a : b;+ // Hexagon distance (flat sides left and right).+ const glm::vec2 q = glm::abs(d);+ const float hex = std::max(q.x, q.x * 0.5f + q.y * 0.8660254f);+ return smooth01((0.5f - hex) / 0.09f) * squareEdge(u, v);+ });+ }},+ {"Knit", "Rows of interlocking V-shaped loops, for knitted wool and chunky fabric.",+ [] {+ return generate("Knit", [](float u, float v) {+ const float cols = 5.0f, rows = 7.0f;+ const float x = (u + 1.0f) * cols * 0.5f, y = (v + 1.0f) * rows * 0.5f;+ const float fx = x - std::floor(x) - 0.5f, fy = y - std::floor(y);+ // Each stitch is two leaning loops meeting at the bottom like a V.+ const float lx = std::abs(fx) - 0.25f - 0.15f * (fy - 0.5f);+ const float loop = std::sqrt(std::max(0.0f, 1.0f - (lx * lx) / 0.04f - (fy - 0.5f) * (fy - 0.5f) / 0.36f));+ return loop * squareEdge(u, v);+ });+ }},+ {"Bolt", "One hexagonal bolt head on a round washer, for machines and hard-surface props (stamp it).",+ [] {+ return generate("Bolt", [](float u, float v) {+ const float r = std::hypot(u, v);+ const float washer = 0.45f * (1.0f - smooth01((r - 0.82f) / 0.06f));+ const glm::vec2 q = glm::abs(glm::vec2(u, v));+ const float hex = std::max(q.x * 0.8660254f + q.y * 0.5f, q.y);+ const float head = (1.0f - smooth01((hex - 0.55f) / 0.04f)) * (0.85f + 0.15f * (1.0f - r));+ return std::max(washer, head);+ });+ }},+ {"Chips", "Broken, angular chips knocked out of an edge, for worn stone, wood and painted metal.",+ [] {+ return generate("Chips", [](float u, float v) {+ float f1, f2;+ uint32_t id = 0;+ worley(u * 4.5f + 60.0f, v * 4.5f + 60.0f, 101, f1, f2, &id);+ if ((id & 3u) == 0u) return 0.0f; // a quarter of the cells stay whole+ const float facet = 1.0f - smooth01(f1 / (0.35f + 0.2f * float((id >> 2) & 0xffu) / 255.0f));+ return std::clamp(facet * 1.6f, 0.0f, 1.0f) * roundEdge(u, v);+ });+ }},};} // namespacediff --git a/src/core/BrushAlpha.h b/src/core/BrushAlpha.hindex b6e46db8..3ccc1350 100644--- a/src/core/BrushAlpha.h+++ b/src/core/BrushAlpha.h@@ -16,7 +16,8 @@ class CommandRegistry;// alpha is the plain round smoothstep falloff, so brushes behave exactly as// without one. Built-ins: Round (empty), Square, Noise and twelve patterns made// in code (Pores, Cracks, Scales, Rivets, Stitches, Fabric Weave, Bark, Rock-// Strata, Wrinkles, Skin Folds, Hair Strands, Dot Grid; #43); anything else comes+// Strata, Wrinkles, Skin Folds, Hair Strands, Dot Grid; #43; Cobblestone, Leather+// Grain, Hex Plates, Knit, Bolt, Chips for the brush packs); anything else comes// from an image's luminance (transparent pixels count as black).struct BrushAlpha {std::string name = "Round";diff --git a/src/core/BrushPacks.cpp b/src/core/BrushPacks.cppnew file mode 100644index 00000000..6ffb7c2b--- /dev/null+++ b/src/core/BrushPacks.cpp@@ -0,0 +1,303 @@+// SculptForge - open source digital sculpting+// SPDX-License-Identifier: GPL-3.0-or-later+#include "core/BrushPacks.h"++#include <utility>++namespace sf {++namespace {++using Dir = BrushRecipe::Direction;+using Plane = BrushRecipe::Plane;+using Pat = BrushRecipe::Pattern;++struct PackInfo {+ const char* name;+ const char* help;+};++const PackInfo kPacks[] = {+ {"Clay & Form", "Block in, build up and refine big forms: clay strokes, planes, and smooth blends."},+ {"Hard Surface", "Crisp planes, panel lines, bevels, rivets and bolts for props, armour and machines."},+ {"Organic & Skin", "Pores, wrinkles, folds, veins and scales for creatures and portraits."},+ {"Cloth & Folds", "Folds, seams, stitches, weave and knit for clothing and soft goods."},+ {"Damage & Wear", "Cracks, chips, dents, scratches and erosion for weathered stone, wood and metal."},+ {"Ornament", "Beads, ropes, filigree, studs and carved patterns for jewellery, trims and decoration."},+};++// Adds brushes to `out` for one pack: b("Name", "One line.", [](BrushRecipe& r) { ... }).+struct PackBuilder {+ std::vector<BrushRecipe>& out;+ const char* pack;+ template <class F>+ void operator()(const char* name, const char* description, F&& tune) {+ BrushRecipe r;+ r.name = name;+ r.description = description;+ r.origin.pack = pack;+ tune(r);+ r.clamp();+ out.push_back(std::move(r));+ }+};++void clayAndForm(PackBuilder b) {+ b("Block Former", "Big, flat-topped clay strokes that stack fast, for blocking in primary forms.", [](BrushRecipe& r) {+ r.depth = 0.35f; r.plane = Plane::Clay; r.planeAmount = 0.7f; r.hardness = 0.25f; r.alpha = "Square";+ r.spacing = 0.15f; r.smooth = 0.1f;+ });+ b("Soft Clay", "Gentle round clay that builds in thin layers and blends into the surface.", [](BrushRecipe& r) {+ r.depth = 0.22f; r.plane = Plane::Clay; r.planeAmount = 0.5f; r.smooth = 0.15f; r.pressureCurve = 0.8f;+ });+ b("Clay Strip", "Narrow, crisp strips of clay with a hard edge, for muscle fibres and planes.", [](BrushRecipe& r) {+ r.depth = 0.25f; r.plane = Plane::Clay; r.planeAmount = 0.7f; r.hardness = 0.3f; r.alpha = "Square";+ r.alphaFollow = true; r.spacing = 0.12f; r.smooth = 0.08f;+ });+ b("Plane Cutter", "Shaves the surface down to flat planes, for stylised forms and stone.", [](BrushRecipe& r) {+ r.depth = -0.1f; r.plane = Plane::Scrape; r.planeAmount = 1.0f; r.hardness = 0.7f; r.spacing = 0.08f;+ });+ b("Volume Fill", "Fills low areas up to the stroke's plane and leaves the high points alone.", [](BrushRecipe& r) {+ r.depth = 0.1f; r.plane = Plane::Fill; r.planeAmount = 0.9f; r.hardness = 0.3f; r.smooth = 0.1f;+ });+ b("Level Out", "Presses hills and valleys onto one plane and softens the result, to calm busy areas.",+ [](BrushRecipe& r) {+ r.depth = 0.0f; r.plane = Plane::Flatten; r.planeAmount = 0.8f; r.smooth = 0.35f; r.hardness = 0.3f;+ });+ b("Swell", "Puffs the surface out along its own normals, for cheeks, bellies and soft volumes.", [](BrushRecipe& r) {+ r.direction = Dir::Inflate; r.depth = 0.35f; r.smooth = 0.1f; r.hardness = 0.1f;+ });+ b("Form Smoother", "Relaxes lumps while keeping the big shape, for a clean pass after blocking.", [](BrushRecipe& r) {+ r.depth = 0.0f; r.smooth = 0.75f; r.plane = Plane::Flatten; r.planeAmount = 0.8f; r.hardness = 0.2f;+ });+ b("Clay Drag", "Smears soft clay along the stroke like a thumb pushing it, for blending transitions.",+ [](BrushRecipe& r) {+ r.depth = 0.12f; r.drag = 0.7f; r.plane = Plane::Clay; r.planeAmount = 0.4f; r.smooth = 0.1f;+ });+ b("Edge Definer", "Pinches a crisp edge into the surface where two planes meet.", [](BrushRecipe& r) {+ r.depth = 0.2f; r.pinch = 0.45f; r.hardness = 0.5f; r.tipSharpness = 0.3f; r.spacing = 0.1f;+ });+}++void hardSurface(PackBuilder b) {+ b("Panel Line", "Cuts a clean, narrow groove for panel gaps and seams.", [](BrushRecipe& r) {+ r.depth = -0.4f; r.pinch = 0.25f; r.hardness = 0.4f; r.tipSharpness = 0.3f; r.spacing = 0.08f;+ r.frontFacesOnly = true;+ });+ b("Flat Plane", "Presses a perfectly flat face with a hard edge, for machined surfaces.", [](BrushRecipe& r) {+ r.depth = 0.0f; r.plane = Plane::Flatten; r.planeAmount = 1.0f; r.hardness = 0.95f; r.alpha = "Square";+ r.spacing = 0.06f;+ });+ b("Bevel Scrape", "Scrapes high points into a bevel along an edge, for chamfers.", [](BrushRecipe& r) {+ r.depth = -0.05f; r.plane = Plane::Scrape; r.planeAmount = 1.0f; r.hardness = 0.7f; r.pinch = 0.0f;+ r.spacing = 0.06f;+ });+ b("Raised Plate", "Builds a flat, square-edged plate on the surface, for armour and hull panels.",+ [](BrushRecipe& r) {+ r.depth = 0.2f; r.plane = Plane::Clay; r.planeAmount = 0.6f; r.hardness = 0.35f; r.alpha = "Square";+ r.spacing = 0.12f; r.smooth = 0.08f;+ });+ b("Rivet Row", "Stamps rows of round rivet heads along the stroke.", [](BrushRecipe& r) {+ r.depth = 0.45f; r.alpha = "Rivets"; r.alphaFollow = true; r.hardness = 0.9f; r.spacing = 0.95f;+ r.frontFacesOnly = true;+ });+ b("Bolt Head", "Stamps a hexagonal bolt on a washer; space the dabs out or click once.", [](BrushRecipe& r) {+ r.depth = 0.8f; r.alpha = "Bolt"; r.hardness = 0.95f; r.spacing = 1.6f; r.frontFacesOnly = true;+ });+ b("Hex Armour", "Raises a honeycomb of hexagonal plates, for sci-fi armour and shells.", [](BrushRecipe& r) {+ r.depth = 0.3f; r.alpha = "Hex Plates"; r.hardness = 0.9f; r.spacing = 0.7f; r.frontFacesOnly = true;+ });+ b("Vent Slots", "Cuts parallel slots like a vent grille; drag across the slots.", [](BrushRecipe& r) {+ r.depth = -0.7f; r.alpha = "Wrinkles"; r.alphaFollow = true; r.hardness = 0.95f; r.pinch = 0.4f;+ r.spacing = 0.5f; r.frontFacesOnly = true;+ });+ b("Grid Studs", "An even grid of small studs, for grip textures and tread plates.", [](BrushRecipe& r) {+ r.depth = 0.6f; r.alpha = "Dot Grid"; r.hardness = 0.9f; r.spacing = 0.8f; r.frontFacesOnly = true;+ });+ b("Hard Cut", "Cuts the surface flat below the stroke, for sharp silhouettes and clean cuts.", [](BrushRecipe& r) {+ r.depth = -0.1f; r.plane = Plane::Scrape; r.planeAmount = 0.8f; r.hardness = 0.6f; r.alpha = "Square";+ r.spacing = 0.05f;+ });+}++void organicAndSkin(PackBuilder b) {+ b("Fine Pores", "Small, evenly scattered pores for faces and close-ups.", [](BrushRecipe& r) {+ r.depth = -0.5f; r.alpha = "Pores"; r.spacing = 0.45f; r.jitter = 0.35f; r.frontFacesOnly = true;+ });+ b("Deep Pores", "Bigger, deeper pores for noses, cheeks and rough skin.", [](BrushRecipe& r) {+ r.depth = -0.6f; r.alpha = "Pores"; r.pattern = Pat::Pores; r.patternScale = 0.3f; r.patternAmount = 0.5f;+ r.spacing = 0.3f; r.jitter = 0.3f; r.frontFacesOnly = true;+ });+ b("Crow's Feet", "Fine fanned wrinkle lines, for eye corners and knuckles.", [](BrushRecipe& r) {+ r.depth = -0.6f; r.alpha = "Wrinkles"; r.alphaFollow = true; r.spacing = 0.4f; r.frontFacesOnly = true;+ });+ b("Skin Fold", "Soft rolls of heavy skin, for necks, bellies and brows.", [](BrushRecipe& r) {+ r.depth = 0.6f; r.alpha = "Skin Folds"; r.alphaFollow = true; r.smooth = 0.1f; r.spacing = 0.35f;+ });+ b("Crease Line", "A sharp, deep crease with pinched sides, for eyelids, lips and nasal folds.", [](BrushRecipe& r) {+ r.depth = -0.6f; r.pinch = 0.45f; r.tipSharpness = 0.5f; r.hardness = 0.2f; r.spacing = 0.08f;+ });+ b("Vein", "Raises thin, soft-edged veins along the stroke.", [](BrushRecipe& r) {+ r.direction = Dir::Inflate; r.depth = 0.4f; r.pinch = 0.5f; r.tipSharpness = 0.5f; r.smooth = 0.15f;+ r.spacing = 0.06f;+ });+ b("Reptile Scales", "Overlapping rows of rounded scales, for lizards, dragons and fish.", [](BrushRecipe& r) {+ r.depth = 0.4f; r.alpha = "Scales"; r.alphaFollow = true; r.hardness = 0.5f; r.spacing = 0.7f;+ r.frontFacesOnly = true;+ });+ b("Leather Hide", "Pebbled grain with fine creases, for leather, elephant and rhino skin.", [](BrushRecipe& r) {+ r.depth = 0.5f; r.alpha = "Leather Grain"; r.spacing = 0.6f; r.jitter = 0.2f; r.frontFacesOnly = true;+ });+ b("Muscle Fibre", "Long soft ridges along the stroke, for muscle striation and sinew.", [](BrushRecipe& r) {+ r.depth = 0.5f; r.alpha = "Hair Strands"; r.alphaFollow = true; r.smooth = 0.1f; r.spacing = 0.3f;+ });+ b("Flesh Pinch", "Pulls soft flesh together into a ridge, for lips, knuckles and wrinkles that bunch.",+ [](BrushRecipe& r) {+ r.depth = 0.1f; r.pinch = 0.9f; r.smooth = 0.1f; r.hardness = 0.1f;+ });+}++void clothAndFolds(PackBuilder b) {+ b("Fold Ridge", "Raises a rounded fold of cloth with soft sides.", [](BrushRecipe& r) {+ r.depth = 0.45f; r.pinch = 0.45f; r.tipSharpness = 0.2f; r.smooth = 0.1f; r.spacing = 0.06f;+ });+ b("Fold Valley", "Carves the soft valley between two folds.", [](BrushRecipe& r) {+ r.depth = -0.4f; r.pinch = 0.3f; r.smooth = 0.15f; r.spacing = 0.06f;+ });+ b("Tension Crease", "A sharp crease where cloth pulls tight, for armpits, elbows and seams under strain.",+ [](BrushRecipe& r) {+ r.depth = -0.4f; r.pinch = 0.45f; r.tipSharpness = 0.5f; r.hardness = 0.3f; r.spacing = 0.08f;+ });+ b("Seam Stitch", "A sewn seam with cross stitches; drag along the seam.", [](BrushRecipe& r) {+ r.depth = 0.55f; r.alpha = "Stitches"; r.alphaFollow = true; r.hardness = 0.8f; r.spacing = 0.85f;+ r.frontFacesOnly = true;+ });+ b("Woven Cloth", "Threads woven over and under, for canvas, denim and sacking.", [](BrushRecipe& r) {+ r.depth = 0.45f; r.alpha = "Fabric Weave"; r.spacing = 0.6f; r.frontFacesOnly = true;+ });+ b("Knitted Wool", "Rows of V-shaped loops, for jumpers, scarves and chunky knits.", [](BrushRecipe& r) {+ r.depth = 0.55f; r.alpha = "Knit"; r.alphaFollow = true; r.spacing = 0.6f; r.frontFacesOnly = true;+ });+ b("Hem Edge", "A flat, square-edged band along the stroke, for hems, cuffs and straps.", [](BrushRecipe& r) {+ r.depth = 0.15f; r.plane = Plane::Clay; r.planeAmount = 0.6f; r.hardness = 0.3f; r.alpha = "Square";+ r.alphaFollow = true; r.spacing = 0.12f; r.smooth = 0.08f;+ });+ b("Cloth Drape", "Drags the surface along the stroke so folds flow and hang, for drapery.", [](BrushRecipe& r) {+ r.depth = 0.05f; r.drag = 0.4f; r.smooth = 0.2f; r.hardness = 0.1f;+ });+ b("Wrinkle Bunch", "Small compressed wrinkles where cloth gathers, at waists and wrists.", [](BrushRecipe& r) {+ r.depth = -0.3f; r.pattern = Pat::Ridges; r.patternScale = 0.3f; r.patternAmount = 0.9f; r.pinch = 0.4f;+ r.spacing = 0.1f;+ });+ b("Padded Quilt", "Puffs soft panels up between the stroke's edges, for quilting and padding.", [](BrushRecipe& r) {+ r.direction = Dir::Inflate; r.depth = 0.3f; r.alpha = "Square"; r.hardness = 0.2f; r.smooth = 0.2f;+ r.spacing = 0.15f;+ });+}++void damageAndWear(PackBuilder b) {+ b("Dry Cracks", "A web of thin cracks, for dry earth, old paint and stone.", [](BrushRecipe& r) {+ r.depth = -0.7f; r.alpha = "Cracks"; r.spacing = 0.6f; r.jitter = 0.2f; r.frontFacesOnly = true;+ });+ b("Deep Fissure", "One deep, jagged split, for broken rock and ice.", [](BrushRecipe& r) {+ r.depth = -0.7f; r.pinch = 0.6f; r.pattern = Pat::Cracks; r.patternScale = 0.6f; r.patternAmount = 0.5f;+ r.tipSharpness = 0.6f; r.jitter = 0.15f; r.spacing = 0.05f;+ });+ b("Edge Chips", "Knocks angular chips out of edges only; flat areas stay whole.", [](BrushRecipe& r) {+ r.depth = -0.8f; r.alpha = "Chips"; r.cavityMask = -0.5f; r.spacing = 0.5f; r.jitter = 0.3f;+ });+ b("Dents", "Soft, scattered dents, for beaten metal and hammered surfaces.", [](BrushRecipe& r) {+ r.depth = -0.4f; r.hardness = 0.1f; r.spacing = 0.9f; r.jitter = 0.6f; r.pressureCurve = 0.8f;+ });+ b("Scratches", "Thin, sharp scratches along the stroke, for scuffed metal and wood.", [](BrushRecipe& r) {+ r.depth = -0.35f; r.pinch = 0.3f; r.tipSharpness = 0.6f; r.hardness = 0.35f; r.jitter = 0.1f;+ r.spacing = 0.08f;+ });+ b("Eroded Stone", "Breaks the surface up with noise, for weathered rock and sandstone.", [](BrushRecipe& r) {+ r.depth = -0.3f; r.pattern = Pat::Noise; r.patternScale = 0.35f; r.patternAmount = 0.9f;+ r.plane = Plane::Scrape; r.planeAmount = 0.3f; r.spacing = 0.2f;+ });+ b("Rock Layers", "Stepped, broken strata, for cliffs and layered stone.", [](BrushRecipe& r) {+ r.depth = 0.55f; r.alpha = "Rock Strata"; r.hardness = 0.6f; r.spacing = 0.5f;+ });+ b("Cobbles", "Packed rounded stones with grooves between, for paths and old walls.", [](BrushRecipe& r) {+ r.depth = 0.55f; r.alpha = "Cobblestone"; r.spacing = 0.7f; r.frontFacesOnly = true;+ });+ b("Wood Grain", "Rough furrows and ridges, for bark and weathered planks; drag along the grain.",+ [](BrushRecipe& r) {+ r.depth = -0.55f; r.alpha = "Bark"; r.alphaFollow = true; r.spacing = 0.4f; r.frontFacesOnly = true;+ });+ b("Worn Edges", "Softens and rounds only the sharp ridges, as years of handling do.", [](BrushRecipe& r) {+ r.depth = -0.4f; r.smooth = 0.4f; r.cavityMask = -0.6f; r.hardness = 0.2f;+ });+}++void ornament(PackBuilder b) {+ b("Bead Chain", "A row of round beads along the stroke, for jewellery and trims.", [](BrushRecipe& r) {+ r.direction = Dir::Inflate; r.depth = 0.6f; r.hardness = 0.6f; r.tipSharpness = 0.0f; r.spacing = 0.9f;+ r.frontFacesOnly = true;+ });+ b("Rope Twist", "A twisted rope or cord, for borders and rigging.", [](BrushRecipe& r) {+ r.depth = 0.6f; r.alpha = "Hair Strands"; r.alphaFollow = true; r.pinch = 0.3f; r.spacing = 0.12f;+ });+ b("Filigree Line", "A thin, raised wire line, for filigree and engraved borders.", [](BrushRecipe& r) {+ r.depth = 0.45f; r.pinch = 0.3f; r.tipSharpness = 0.3f; r.hardness = 0.4f; r.spacing = 0.08f;+ });+ b("Engrave", "Cuts a fine, crisp line, for engraving, runes and lettering.", [](BrushRecipe& r) {+ r.depth = -0.35f; r.pinch = 0.3f; r.tipSharpness = 0.5f; r.hardness = 0.4f; r.spacing = 0.08f;+ r.frontFacesOnly = true;+ });+ b("Stud Row", "Rounded studs spaced along the stroke, for belts, doors and armour trims.", [](BrushRecipe& r) {+ r.depth = 0.5f; r.hardness = 0.85f; r.spacing = 1.3f; r.frontFacesOnly = true;+ });+ b("Raised Band", "A flat, raised band with clean edges, for bezels, rims and mouldings.", [](BrushRecipe& r) {+ r.depth = 0.25f; r.plane = Plane::Clay; r.planeAmount = 0.6f; r.hardness = 0.3f; r.pinch = 0.0f;+ r.spacing = 0.1f; r.smooth = 0.08f;+ });+ b("Scroll Relief", "Soft, rounded relief that builds up slowly, for carved scrolls and leaves.", [](BrushRecipe& r) {+ r.depth = 0.3f; r.plane = Plane::Clay; r.planeAmount = 0.6f; r.smooth = 0.25f; r.hardness = 0.25f;+ r.pressureCurve = 1.3f;+ });+ b("Scale Mail", "Rows of small scales, for armour, roof tiles and feathers.", [](BrushRecipe& r) {+ r.depth = 0.3f; r.pattern = Pat::Scales; r.patternScale = 0.2f; r.patternAmount = 1.0f; r.hardness = 0.6f;+ r.spacing = 0.25f; r.frontFacesOnly = true;+ });+ b("Gem Setting", "A raised round setting with a crisp rim, for cabochons and gem seats.", [](BrushRecipe& r) {+ r.direction = Dir::Inflate; r.depth = 0.7f; r.plane = Plane::Flatten; r.planeAmount = 0.4f;+ r.hardness = 0.95f; r.spacing = 2.0f; r.frontFacesOnly = true;+ });+ b("Dot Texture", "Fine even dots, for stippling, punched leather and decorative fields.", [](BrushRecipe& r) {+ r.depth = -0.55f; r.alpha = "Dot Grid"; r.spacing = 0.7f; r.frontFacesOnly = true;+ });+}++} // namespace++const std::vector<std::string>& builtinBrushPacks() {+ static const std::vector<std::string> names = [] {+ std::vector<std::string> v;+ for (const PackInfo& p : kPacks) v.emplace_back(p.name);+ return v;+ }();+ return names;+}++std::string builtinBrushPackHelp(const std::string& pack) {+ for (const PackInfo& p : kPacks)+ if (pack == p.name) return p.help;+ return {};+}++std::vector<BrushRecipe> builtinPackRecipes() {+ std::vector<BrushRecipe> out;+ out.reserve(60);+ clayAndForm({out, kPacks[0].name});+ hardSurface({out, kPacks[1].name});+ organicAndSkin({out, kPacks[2].name});+ clothAndFolds({out, kPacks[3].name});+ damageAndWear({out, kPacks[4].name});+ ornament({out, kPacks[5].name});+ return out;+}++} // namespace sfdiff --git a/src/core/BrushPacks.h b/src/core/BrushPacks.hnew file mode 100644index 00000000..6c848865--- /dev/null+++ b/src/core/BrushPacks.h@@ -0,0 +1,24 @@+// SculptForge - open source digital sculpting+// SPDX-License-Identifier: GPL-3.0-or-later+//+// The built-in brush packs: sixty tuned recipes in six named packs (Clay & Form, Hard Surface, Organic & Skin,+// Cloth & Folds, Damage & Wear, Ornament), made only from SculptForge's own recipe engine and procedural alphas.+// They ship with the app as built-in brushes (BrushSource::Builtin) with origin.pack set to the pack's name, so+// the brush lists can show and sort them by pack. Guide: docs/guide/brush-packs.md.+#pragma once++#include "core/BrushRecipe.h"++#include <string>+#include <vector>++namespace sf {++// The pack names, in the order the guide and the lists show them.+const std::vector<std::string>& builtinBrushPacks();+// One line on what a pack is for (empty for unknown names).+std::string builtinBrushPackHelp(const std::string& pack);+// Every pack brush (clamped, origin.pack set; origin.source left for builtinBrushRecipes to set).+std::vector<BrushRecipe> builtinPackRecipes();++} // namespace sfdiff --git a/src/core/BrushRecipe.cpp b/src/core/BrushRecipe.cppindex d1728fa1..95706859 100644--- a/src/core/BrushRecipe.cpp+++ b/src/core/BrushRecipe.cpp@@ -2,6 +2,9 @@// SPDX-License-Identifier: GPL-3.0-or-later#include "core/BrushRecipe.h"+#include "core/BrushAlpha.h"+#include "core/BrushPacks.h"+#include <algorithm>#include <cmath>#include <filesystem>@@ -141,6 +144,8 @@ Json BrushRecipe::toJson() const {j.set("description", r.description);if (connectedOnly) j.set("connectedOnly", true);if (viewFalloff) j.set("viewFalloff", true);+ if (!alpha.empty()) j.set("alpha", alpha);+ if (alphaFollow) j.set("alphaFollow", true);for (const auto& p : recipeParams()) {switch (p.kind) {case K::Float: j.set(p.key, std::round(double(*floatField(r, p.key)) * 1000.0) / 1000.0); break;@@ -161,6 +166,11 @@ void BrushRecipe::applyJson(const Json& j) {if (j["description"].isString()) description = j["description"].asString();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["alpha"].isString()) {+ BrushAlpha a;+ alpha = BrushAlpha::builtin(j["alpha"].asString(), a) && !a.empty() ? a.name : std::string();+ }for (const auto& p : recipeParams()) {const Json& v = j[p.key];if (v.isNull()) continue;@@ -346,6 +356,7 @@ std::vector<BrushRecipe> builtinBrushRecipes() {r.hardness = 0.4f;add(r);}+ for (BrushRecipe& r : builtinPackRecipes()) add(std::move(r));return out;}diff --git a/src/core/BrushRecipe.h b/src/core/BrushRecipe.hindex 254b4291..6a683fdd 100644--- a/src/core/BrushRecipe.h+++ b/src/core/BrushRecipe.h@@ -74,6 +74,11 @@ struct BrushRecipe {bool viewFalloff = false;float cavityMask = 0.0f; // -1..1: >0 only affects cavities, <0 only ridges/peaks+ // The built-in alpha (core/BrushAlpha.h) the brush starts with the first time it is picked; empty = whatever+ // 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+// Library bookkeeping, not part of the recipe: never written by toJson().BrushOrigin origin;@@ -107,6 +112,7 @@ const std::vector<RecipeParam>& recipeParams();// additionalProperties, ranges given in descriptions).Json recipeJsonSchema();+// The built-ins: the seven classic recipes, then the brush packs (core/BrushPacks.h; origin.pack names the pack).std::vector<BrushRecipe> builtinBrushRecipes();} // namespace sfdiff --git a/src/core/BrushSettings.h b/src/core/BrushSettings.hindex 8b57dd18..cb8de129 100644--- a/src/core/BrushSettings.h+++ b/src/core/BrushSettings.h@@ -55,6 +55,8 @@ public:BrushToolSettings reset(const std::string& key);static BrushToolSettings shipped(const std::string& key); // the Vector Displacement brush stamps with DragRectbool hasSaved(const std::string& key) const { return saved_.count(key) != 0; }+ // Used this session or saved: switchBrush brings its own values back (otherwise it takes the current ones).+ bool known(const std::string& key) const { return session_.count(key) != 0 || saved_.count(key) != 0; }size_t savedCount() const { return saved_.size(); }Json toJson() const; // the saved settings and shareSizeIntensity (the session's values are not written)diff --git a/src/core/Commands.cpp b/src/core/Commands.cppindex 86e5c407..7b729f5c 100644--- a/src/core/Commands.cpp+++ b/src/core/Commands.cpp@@ -51,6 +51,7 @@#include "io/UsdIO.h"#include <algorithm>+#include <cctype>#include <filesystem>#include <glm/gtc/matrix_transform.hpp>#include <sstream>@@ -597,10 +598,28 @@ CommandRegistry::CommandRegistry() {std::string out;for (size_t i = 0; i < doc.brushes.size(); ++i)out += (i ? "\n" : "") + std::to_string(i) + ": " + doc.brushes[i].name + " [" +- brushSourceName(doc.brushes[i].origin.source) + "] - " + doc.brushes[i].description;+ brushSourceName(doc.brushes[i].origin.source) ++ (doc.brushes[i].origin.pack.empty() ? "" : ", " + doc.brushes[i].origin.pack) + "] - " ++ doc.brushes[i].description;return {true, out};}});+ add({"brush_use", "Make a custom brush (a built-in pack brush, one from the library or a pack) the active brush.",+ {{"name", T::String, "Brush name, as brush_list shows it (case doesn't matter).", true}},+ [](Document& doc, const Args& a) -> CommandResult {+ auto low = [](std::string t) {+ for (char& c : t) c = char(std::tolower(static_cast<unsigned char>(c)));+ return t;+ };+ const std::string want = low(argString(a, "name"));+ for (size_t i = 0; i < doc.brushes.size(); ++i)+ if (low(doc.brushes[i].name) == want) {+ doc.activeBrush = int(i);+ return {true, "Brush: " + doc.brushes[i].name};+ }+ return {false, "No such brush: " + argString(a, "name") + " (brush_list shows them)"};+ }});+add({"brush_save", "Save a custom brush as a shareable .sfbrush file.",{{"path", T::String, "Output .sfbrush path.", true},{"name", T::String, "Brush name (defaults to the active brush).", false}},diff --git a/src/core/ListSort.h b/src/core/ListSort.hnew file mode 100644index 00000000..8bea6f16--- /dev/null+++ b/src/core/ListSort.h@@ -0,0 +1,103 @@+// SculptForge - open source digital sculpting+// SPDX-License-Identifier: GPL-3.0-or-later+//+// The order of the asset lists (brushes, alphas, materials, the Library): A-Z by default, the most recently used+// first, or grouped by pack (then A-Z). Names compare ignoring case, with numbers in number order ("Brush 2"+// before "Brush 10"). Pure functions, so the order can be tested without the UI.+#pragma once++#include <algorithm>+#include <cctype>+#include <climits>+#include <cstddef>+#include <cstdint>+#include <string>+#include <vector>++namespace sf {++enum class ListSort { AZ, Recent, Pack, Count };++inline const char* listSortLabel(ListSort s) {+ switch (s) {+ case ListSort::AZ: return "A-Z";+ case ListSort::Recent: return "Recent";+ case ListSort::Pack: return "Pack";+ default: return "";+ }+}+inline const char* listSortId(ListSort s) { // preferences+ switch (s) {+ case ListSort::Recent: return "recent";+ case ListSort::Pack: return "pack";+ default: return "az";+ }+}+inline ListSort listSortFromId(const std::string& id) {+ return id == "recent" ? ListSort::Recent : id == "pack" ? ListSort::Pack : ListSort::AZ;+}++// Natural, case-insensitive "a < b".+inline bool naturalLess(const std::string& a, const std::string& b) {+ size_t i = 0, j = 0;+ while (i < a.size() && j < b.size()) {+ const unsigned char ca = static_cast<unsigned char>(a[i]), cb = static_cast<unsigned char>(b[j]);+ if (std::isdigit(ca) && std::isdigit(cb)) {+ size_t ei = i, ej = j;+ while (ei < a.size() && a[ei] == '0') ++ei; // leading zeros don't count+ while (ej < b.size() && b[ej] == '0') ++ej;+ size_t ni = ei, nj = ej;+ while (ni < a.size() && std::isdigit(static_cast<unsigned char>(a[ni]))) ++ni;+ while (nj < b.size() && std::isdigit(static_cast<unsigned char>(b[nj]))) ++nj;+ if (ni - ei != nj - ej) return ni - ei < nj - ej;+ const int c = a.compare(ei, ni - ei, b, ej, nj - ej);+ if (c != 0) return c < 0;+ i = ni;+ j = nj;+ continue;+ }+ const int la = std::tolower(ca), lb = std::tolower(cb);+ if (la != lb) return la < lb;+ ++i;+ ++j;+ }+ if ((a.size() - i) != (b.size() - j)) return a.size() - i < b.size() - j;+ return a < b; // equal ignoring case: a stable, deterministic tie-break+}++struct ListSortKey {+ std::string name;+ std::string pack; // "" = not from a pack (sorts first under Pack)+ int recent = -1; // 0 = used last, 1 = before that ...; -1 = not used recently+ int packRank = -1; // the pack's place in a fixed order (built-in packs); -1 = A-Z by pack name after those+};++// The indices of `keys` in display order.+inline std::vector<size_t> listSortOrder(const std::vector<ListSortKey>& keys, ListSort mode) {+ std::vector<size_t> order(keys.size());+ for (size_t i = 0; i < order.size(); ++i) order[i] = i;+ auto byName = [&](size_t a, size_t b) { return naturalLess(keys[a].name, keys[b].name); };+ switch (mode) {+ case ListSort::Recent:+ std::stable_sort(order.begin(), order.end(), [&](size_t a, size_t b) {+ const int ra = keys[a].recent < 0 ? INT32_MAX : keys[a].recent;+ const int rb = keys[b].recent < 0 ? INT32_MAX : keys[b].recent;+ return ra != rb ? ra < rb : byName(a, b);+ });+ break;+ case ListSort::Pack:+ std::stable_sort(order.begin(), order.end(), [&](size_t a, size_t b) {+ const ListSortKey &ka = keys[a], &kb = keys[b];+ if (ka.pack.empty() != kb.pack.empty()) return ka.pack.empty();+ const int ra = ka.packRank < 0 ? INT32_MAX : ka.packRank, rb = kb.packRank < 0 ? INT32_MAX : kb.packRank;+ if (ra != rb) return ra < rb;+ if (ka.pack != kb.pack) return naturalLess(ka.pack, kb.pack);+ return byName(a, b);+ });+ break;+ default: std::stable_sort(order.begin(), order.end(), byName); break;+ }+ return order;+}++} // namespace sfdiff --git a/src/core/Masking.cpp b/src/core/Masking.cppindex e82c3ce6..22cba542 100644--- a/src/core/Masking.cpp+++ b/src/core/Masking.cpp@@ -3,6 +3,7 @@#include "core/Masking.h"#include "core/Commands.h"+#include "core/Polypaint.h"#include "core/ScreenSelect.h"#include "core/Sculpt.h"#include "core/ThreadPool.h"@@ -199,6 +200,46 @@ bool maskByCavity(Mesh& mesh, float strength, float threshold) {});}+bool maskByPeaks(Mesh& mesh, float strength, float threshold) {+ const uint32_t n = static_cast<uint32_t>(mesh.vertexCount());+ if (n == 0) return false;+ strength = std::clamp(strength, 0.0f, 1.0f);+ std::vector<float> raw(n), cav(n);+ for (uint32_t v = 0; v < n; ++v) raw[v] = vertexConcavity(mesh, v);+ for (uint32_t v = 0; v < n; ++v) cav[v] = 0.5f * raw[v] + 0.5f * neighbourAverage(mesh, raw, v);+ constexpr float kRamp = 0.15f; // (as maskByCavity)+ return maskPass(mesh, [&](const std::vector<float>&, uint32_t v) {+ return strength * smoothstep01(threshold, threshold + kRamp, -cav[v]);+ });+}++bool maskByColor(Mesh& mesh, const glm::vec3& color, float tolerance, float strength, bool add) {+ if (mesh.vertexCount() == 0) return false;+ tolerance = std::clamp(tolerance, 0.001f, 1.0f);+ strength = std::clamp(strength, 0.0f, 1.0f);+ const glm::vec3 c = glm::clamp(color, glm::vec3(0.0f), glm::vec3(1.0f));+ return maskPass(mesh, [&](const std::vector<float>& m, uint32_t v) {+ const float d = glm::distance(mesh.colorAt(v, glm::vec3(1.0f)), c) / 1.7320508f;+ const float w = strength * (1.0f - smoothstep01(tolerance * 0.8f, tolerance, d));+ return add ? std::max(m[v], w) : w;+ });+}++bool maskByFacing(Mesh& mesh, const glm::vec3& direction, float angleDeg, float strength, bool add) {+ if (mesh.vertexCount() == 0 || mesh.normals.size() != mesh.vertexCount()) return false;+ const float len = glm::length(direction);+ if (!(len > 1e-9f)) return false;+ const glm::vec3 dir = direction / len;+ angleDeg = std::clamp(angleDeg, 1.0f, 180.0f);+ strength = std::clamp(strength, 0.0f, 1.0f);+ const float full = std::max(0.0f, angleDeg - 15.0f); // fully masked inside this angle+ return maskPass(mesh, [&](const std::vector<float>& m, uint32_t v) {+ const float a = std::acos(std::clamp(glm::dot(mesh.normals[v], dir), -1.0f, 1.0f)) * 57.29578f;+ const float w = strength * (1.0f - smoothstep01(full, angleDeg, a));+ return add ? std::max(m[v], w) : w;+ });+}+bool maskByPolygroup(Mesh& mesh, uint32_t group, bool add) {const uint32_t n = static_cast<uint32_t>(mesh.vertexCount());if (n == 0) return false;@@ -417,6 +458,48 @@ void registerMaskingCommands(CommandRegistry& registry) {return maskByCavity(m, float(argNumber(a, "strength", 1.0)),std::clamp(float(argNumber(a, "threshold", 0.02)), -1.0f, 1.0f));});+ add("mask_by_peaks", "Mask by Peaks",+ "Mask convex areas (ridges, peaks, sharp edges), replacing the current mask - e.g. to work only in the "+ "valleys, or to protect edges.",+ {{"strength", T::Number, "Mask value on the sharpest peaks (0-1). Default 1.", false},+ {"threshold", T::Number,+ "Convexity above which vertices get masked (-1 to 1; 0 = anything convex, higher = only sharp ridges). "+ "Default 0.02.",+ false}},+ [](Mesh& m, const Args& a) {+ return maskByPeaks(m, float(argNumber(a, "strength", 1.0)),+ std::clamp(float(argNumber(a, "threshold", 0.02)), -1.0f, 1.0f));+ });+ add("mask_by_color", "Mask by Colour",+ "Mask the vertices whose vertex paint is close to a colour (unpainted meshes are white).",+ {{"color", T::String, "The colour by name or #rrggbb (or give r, g, b).", false},+ {"r", T::Number, "Red 0-1 (sRGB), instead of color.", false},+ {"g", T::Number, "Green 0-1 (sRGB).", false},+ {"b", T::Number, "Blue 0-1 (sRGB).", false},+ {"tolerance", T::Number, "How different a colour may be and still count (0-1). Default 0.15.", false},+ {"strength", T::Number, "Mask value (0-1). Default 1.", false},+ {"add", T::Bool, "Add to the current mask instead of replacing it. Default false.", false}},+ [](Mesh& m, const Args& a) {+ glm::vec3 c(1.0f);+ std::string err;+ if (!colorArg(a, c, err)) return false;+ return maskByColor(m, c, float(argNumber(a, "tolerance", 0.15)), float(argNumber(a, "strength", 1.0)),+ argBool(a, "add", false));+ });+ add("mask_by_facing", "Mask by Facing",+ "Mask the vertices whose surface faces a direction (within an angle): e.g. 0 0 1 masks what faces the front "+ "view, 0 1 0 what faces up.",+ {{"x", T::Number, "Direction x.", true},+ {"y", T::Number, "Direction y.", true},+ {"z", T::Number, "Direction z.", true},+ {"angle", T::Number, "Largest angle from the direction, in degrees (1-180). Default 60.", false},+ {"strength", T::Number, "Mask value (0-1). Default 1.", false},+ {"add", T::Bool, "Add to the current mask instead of replacing it. Default false.", false}},+ [](Mesh& m, const Args& a) {+ const glm::vec3 d(float(argNumber(a, "x", 0)), float(argNumber(a, "y", 0)), float(argNumber(a, "z", 1)));+ return maskByFacing(m, d, float(argNumber(a, "angle", 60)), float(argNumber(a, "strength", 1.0)),+ argBool(a, "add", false));+ });add("mask_by_polygroup", "Mask by Face Group","Mask the vertices of one face group (meshes without face groups are all group 0).",{{"group", T::Number, "Face Group id.", true},diff --git a/src/core/Masking.h b/src/core/Masking.hindex 7fae910f..4110bd46 100644--- a/src/core/Masking.h+++ b/src/core/Masking.h@@ -40,6 +40,16 @@ float vertexConcavity(const Mesh& mesh, uint32_t v);// Masks concave areas: vertices whose concavity exceeds `threshold` get up to// `strength` (0-1), with a soft ramp above the threshold. Replaces the mask.bool maskByCavity(Mesh& mesh, float strength, float threshold);+// Masks convex areas (ridges, peaks, edges): the mirror of maskByCavity, for vertices whose concavity is below+// -threshold. Replaces the mask.+bool maskByPeaks(Mesh& mesh, float strength, float threshold);+// Masks vertices whose vertex paint is within `tolerance` (0-1, distance in RGB / sqrt 3) of `color`, with a soft+// ramp over the last fifth. A mesh without vertex paint is all white. With `add` the mask grows, else it is replaced.+bool maskByColor(Mesh& mesh, const glm::vec3& color, float tolerance, float strength, bool add);+// Masks vertices whose normal points within `angleDeg` (1-180) of `direction` (any length), with a soft ramp+// over the last 15 degrees, e.g. the view direction reversed to mask what faces the camera, or +Y for what faces+// up. With `add` the mask grows, else it is replaced.+bool maskByFacing(Mesh& mesh, const glm::vec3& direction, float angleDeg, float strength, bool add);// Masks every vertex touching a visible triangle of polygroup `group`.// With `add` the existing mask is kept, otherwise it is replaced.bool maskByPolygroup(Mesh& mesh, uint32_t group, bool add);@@ -79,7 +89,7 @@ bool symmetryCopiesArg(const Args& a, const Mesh& mesh, std::vector<SymCopy>& costd::vector<ParamSpec> radialSymmetryParams();// Registers mask_clear, mask_all, mask_invert, mask_blur, mask_sharpen,-// mask_grow, mask_shrink, mask_by_cavity, mask_by_polygroup, mask_border,+// mask_grow, mask_shrink, mask_by_cavity, mask_by_peaks, mask_by_color, mask_by_facing, mask_by_polygroup, mask_border,// mask_rect and mask_lasso.void registerMaskingCommands(CommandRegistry& registry);diff --git a/src/core/Polypaint.cpp b/src/core/Polypaint.cppindex 5cb9a1ec..1430c343 100644--- a/src/core/Polypaint.cpp+++ b/src/core/Polypaint.cpp@@ -233,8 +233,6 @@ glm::vec3 sampleColor(const Mesh& mesh, uint32_t triangle, const glm::vec3& poinreturn mesh.colorAt(t.x) * (1.0f - wb - wc) + mesh.colorAt(t.y) * wb + mesh.colorAt(t.z) * wc;}-namespace {-// A colour from "color" (any parseColor form) or numeric "r"/"g"/"b" (sRGB 0..1).// Returns false with `error` empty when no colour was given.bool colorArg(const Args& a, glm::vec3& linear, std::string& error) {@@ -253,6 +251,8 @@ bool colorArg(const Args& a, glm::vec3& linear, std::string& error) {return false;}+namespace {+// Undo step for a whole-mesh colour edit, pushed before the edit: the old// colours, or a mesh snapshot when there is no polypaint yet, so undo removes// the attribute again instead of leaving the mesh painted white.diff --git a/src/core/Polypaint.h b/src/core/Polypaint.hindex 82fc470b..79f44a9b 100644--- a/src/core/Polypaint.h+++ b/src/core/Polypaint.h@@ -7,6 +7,7 @@#pragma once#include "core/BVH.h"+#include "core/Commands.h"#include "core/Mesh.h"#include "core/Sculpt.h"@@ -21,6 +22,9 @@ class CommandRegistry;// 0..255) or a basic name ("red", "skin", ...). The text is a display (sRGB)// colour; `linear` receives the linear value Mesh::colors stores.bool parseColor(const std::string& text, glm::vec3& linear);+// A command's colour: "color" (any parseColor form) or numeric "r"/"g"/"b" (sRGB 0..1). False with `error` empty+// when no colour was given.+bool colorArg(const Args& a, glm::vec3& linear, std::string& error);// "#rrggbb" (sRGB) for a linear colour.std::string colorToHex(const glm::vec3& linear);// The tint the active colour gives a Lit Sphere material on a mesh with no vertex paint (as ZBrush's maindiff --git a/tests/test_brush_packs.cpp b/tests/test_brush_packs.cppnew file mode 100644index 00000000..34b333a2--- /dev/null+++ b/tests/test_brush_packs.cpp@@ -0,0 +1,156 @@+// SculptForge - open source digital sculpting+// SPDX-License-Identifier: GPL-3.0-or-later+//+// The built-in brush packs (core/BrushPacks.h), the procedural alphas they use, the recipe's alpha keys and the+// asset lists' order (core/ListSort.h). Every pack brush must leave a visible, clean mark on the preview ball.+#include "TestHarness.h"++#include "app/BrushPreview.h"+#include "core/BrushAlpha.h"+#include "core/BrushPacks.h"+#include "core/BrushRecipe.h"+#include "core/ListSort.h"++#include <algorithm>+#include <chrono>+#include <cmath>+#include <cstdio>+#include <cstdlib>+#include <map>+#include <set>++using namespace sf;++TEST(brush_packs_six_packs_of_ten) {+ const std::vector<BrushRecipe> all = builtinBrushRecipes();+ const std::vector<BrushRecipe> packs = builtinPackRecipes();+ CHECK(builtinBrushPacks().size() == 6);+ CHECK(packs.size() == 60);+ CHECK(all.size() == 7 + packs.size()); // the classic seven first+ std::map<std::string, int> perPack;+ std::set<std::string> names;+ for (const BrushRecipe& r : all) {+ CHECK(names.insert(r.name).second); // unique names+ CHECK(r.origin.source == BrushSource::Builtin);+ }+ for (const BrushRecipe& r : packs) {+ ++perPack[r.origin.pack];+ CHECK(!builtinBrushPackHelp(r.origin.pack).empty());+ CHECK(!r.description.empty() && r.description.size() <= 110); // one line+ CHECK(r.description.back() == '.');+ if (!r.alpha.empty()) {+ BrushAlpha a;+ CHECK(BrushAlpha::builtin(r.alpha, a) && a.name == r.alpha);+ }+ }+ for (const std::string& p : builtinBrushPacks()) CHECK(perPack[p] == 10);+}++TEST(brush_recipe_alpha_keys_round_trip) {+ BrushRecipe r;+ r.name = "Test";+ r.alpha = "Stitches";+ r.alphaFollow = true;+ const BrushRecipe back = BrushRecipe::fromJson(r.toJson());+ CHECK(back.alpha == "Stitches" && back.alphaFollow);+ // Lenient names, as brush_set_alpha takes them; unknown names are dropped.+ Json j = r.toJson();+ j.set("alpha", "fabric_weave");+ CHECK(BrushRecipe::fromJson(j).alpha == "Fabric Weave");+ j.set("alpha", "no such alpha");+ CHECK(BrushRecipe::fromJson(j).alpha.empty());+ // Recipes without them write neither key (older files and brush codes stay byte for byte as they were).+ BrushRecipe plain;+ const std::string text = plain.toJson().dump();+ CHECK(text.find("alpha") == std::string::npos);+}++TEST(brush_alphas_builtin_set) {+ const auto& all = BrushAlpha::builtins();+ CHECK(all.size() == 21); // Round, Square, Noise, the twelve patterns and the six for the packs+ std::set<std::string> names;+ for (const BrushAlpha& a : all) CHECK(names.insert(a.name).second);+ for (const char* name : {"Cobblestone", "Leather Grain", "Hex Plates", "Knit", "Bolt", "Chips"}) {+ BrushAlpha a;+ CHECK(BrushAlpha::builtin(name, a));+ CHECK(!a.empty());+ CHECK(!BrushAlpha::builtinHelp(name).empty());+ double sum = 0.0;+ float hi = 0.0f;+ for (float v : a.values) {+ CHECK(v >= 0.0f && v <= 1.0f);+ sum += v;+ hi = std::max(hi, v);+ }+ const double mean = sum / double(a.values.size());+ CHECK(hi > 0.6f); // a real stamp, not a faint smudge+ CHECK(mean > 0.03 && mean < 0.8); // a pattern, neither empty nor a flat plate+ CHECK(a.sample(0.99f, 0.99f) < 0.3f); // fades out at the corners: no hard square edge+ }+}++// The quality bar for every pack brush: a mark that is clearly visible on the preview ball (at least 0.5% of+// its radius) but no tower (at most ~28%), no folded triangles (stricter than the classic seven, two of which fold), and a stroke that sculpts in under 400 ms on the ~82k triangle ball.+TEST(brush_packs_every_brush_leaves_a_clean_mark) {+ double slowestMs = 0.0, totalMs = 0.0;+ std::string slowest;+ const bool all = std::getenv("SF_PACK_METRICS") != nullptr; // print every brush, the classic seven too+ for (const BrushRecipe& r : all ? builtinBrushRecipes() : builtinPackRecipes()) {+ const auto t0 = std::chrono::steady_clock::now();+ const std::unique_ptr<Mesh> m = sculptBrushPreview(&r, 0);+ const double ms = std::chrono::duration<double, std::milli>(std::chrono::steady_clock::now() - t0).count();+ CHECK(m != nullptr);+ if (!m) continue;+ float lift = 0.0f;+ size_t moved = 0;+ for (const glm::vec3& p : m->positions) {+ const float d = std::abs(glm::length(p) - kBallRadius);+ lift = std::max(lift, d);+ if (d > 0.001f) ++moved;+ }+ int folded = 0;+ for (const glm::uvec3& t : m->triangles) {+ const glm::vec3 a = m->positions[t.x], b = m->positions[t.y], c = m->positions[t.z];+ const glm::vec3 n = glm::cross(b - a, c - a);+ if (glm::length(n) > 1e-12f && glm::dot(glm::normalize(n), glm::normalize(a + b + c)) < -0.5f) ++folded;+ }+ if (all || lift < 0.0045f || lift > 0.25f || moved < 200 || folded > 0)+ std::printf(" %s (%s): lift %.4f, moved %zu, folded %d\n", r.name.c_str(), r.origin.pack.c_str(), lift,+ moved, folded);+ CHECK(lift >= 0.0045f);+ CHECK(lift <= 0.25f); // no towers: a stroke builds at most about a quarter of the ball's radius+ CHECK(moved >= 200);+ CHECK(folded == 0);+ totalMs += ms;+ if (ms > slowestMs) {+ slowestMs = ms;+ slowest = r.name;+ }+ }+ std::printf(" 60 pack brush strokes: %.0f ms in all, slowest %s %.0f ms\n", totalMs, slowest.c_str(), slowestMs);+ CHECK(slowestMs < 400.0);+}++TEST(list_sort_orders) {+ CHECK(naturalLess("brush 2", "Brush 10"));+ CHECK(!naturalLess("Brush 10", "brush 2"));+ CHECK(naturalLess("alpha", "Beta"));+ CHECK(naturalLess("Bark", "bark") != naturalLess("bark", "Bark")); // a strict, deterministic order+ std::vector<ListSortKey> keys = {+ {"Wrinkle", "", -1}, {"bolt Head", "Hard Surface", 1}, {"Clay 10", "Clay & Form", -1},+ {"Clay 2", "Clay & Form", 0}, {"Mine", "Zeta Pack", -1},+ };+ keys[1].packRank = 1;+ keys[2].packRank = keys[3].packRank = 0;+ auto names = [&](ListSort s) {+ std::string out;+ for (size_t i : listSortOrder(keys, s)) out += keys[i].name + ";";+ return out;+ };+ CHECK(names(ListSort::AZ) == "bolt Head;Clay 2;Clay 10;Mine;Wrinkle;");+ CHECK(names(ListSort::Recent) == "Clay 2;bolt Head;Clay 10;Mine;Wrinkle;");+ // No pack first, then the built-in packs in their order, then other packs A-Z; A-Z inside each.+ CHECK(names(ListSort::Pack) == "Wrinkle;Clay 2;Clay 10;bolt Head;Mine;");+ CHECK(listSortFromId(listSortId(ListSort::Pack)) == ListSort::Pack);+ CHECK(listSortFromId("nonsense") == ListSort::AZ);+}diff --git a/tests/test_brushes.cpp b/tests/test_brushes.cppindex 8401737e..f003e5f8 100644--- a/tests/test_brushes.cpp+++ b/tests/test_brushes.cpp@@ -599,9 +599,9 @@ TEST(spray_and_spacing_are_deterministic) {}TEST(alpha_generated_builtins) {- // #43: twelve patterns made in code (no image files), after Round, Square and Noise.+ // #43: twelve patterns made in code (no image files), after Round, Square and Noise, and six for the brush packs.const auto& all = BrushAlpha::builtins();- CHECK(all.size() == 15);+ CHECK(all.size() == 21);CHECK(all[0].empty() && all[0].name == "Round" && all[1].name == "Square" && all[2].name == "Noise");for (size_t i = 3; i < all.size(); ++i) {const BrushAlpha& a = all[i];diff --git a/tests/test_masking.cpp b/tests/test_masking.cppindex b8932b33..c28938fa 100644--- a/tests/test_masking.cpp+++ b/tests/test_masking.cpp@@ -479,3 +479,58 @@ TEST(mask_border_polygroup_borders) {// Without polygroups the closed sphere still has no border to mask.CHECK(registry().execute(d, "mask_border").message.find("No open edges") != std::string::npos);}++TEST(mask_by_peaks_finds_ridges) {+ // The same banded sphere as above: the band's upper and lower rims (where the surface steps in) are ridges.+ Mesh m = makeIcosphere(5);+ for (glm::vec3& p : m.positions)+ if (std::abs(p.y) < 0.3f) p *= 0.85f;+ m.recomputeAllNormals();+ Document d = makeDoc(std::move(m));+ CHECK(registry().execute(d, "mask_by_peaks", {{"strength", 1.0}, {"threshold", 0.02}}).ok);+ bool capsFree = true, ridgeMasked = false, valleyFree = true;+ for (uint32_t v = 0; v < d.mesh.vertexCount(); ++v) {+ const float y = std::abs(d.mesh.positions[v].y);+ const float r = glm::length(d.mesh.positions[v]);+ if (y > 0.6f) capsFree &= d.mesh.mask[v] < 0.25f; // a smooth ball is barely convex+ if (r > 0.95f && y > 0.28f && y < 0.36f) ridgeMasked |= d.mesh.mask[v] > 0.5f;+ if (r < 0.9f && y < 0.15f) valleyFree &= d.mesh.mask[v] < 0.5f; // the middle of the band+ }+ CHECK(capsFree);+ CHECK(ridgeMasked);+ CHECK(valleyFree);+ CHECK(registry().execute(d, "undo").ok);+ CHECK(countMasked(d.mesh, 0.0f) == 0);+}++TEST(mask_by_color_and_facing) {+ Document d = makeDoc(makeIcosphere(4));+ Mesh& m = d.mesh;+ // Unpainted meshes are white: white masks everything, red nothing.+ CHECK(registry().execute(d, "mask_by_color", {{"r", 1.0}, {"g", 1.0}, {"b", 1.0}}).ok);+ CHECK(countMasked(m) == m.vertexCount());+ CHECK(registry().execute(d, "mask_by_color", {{"r", 1.0}, {"g", 0.0}, {"b", 0.0}}).ok);+ CHECK(countMasked(m, 0.0f) == 0);+ // Paint the top red: By colour masks just it, and add keeps what was masked.+ m.ensureColors(glm::vec3(1.0f));+ for (uint32_t v = 0; v < m.vertexCount(); ++v)+ if (m.positions[v].y > 0.5f) m.colors[v] = glm::vec3(0.9f, 0.05f, 0.05f);+ CHECK(registry().execute(d, "mask_by_color", {{"r", 1.0}, {"g", 0.0}, {"b", 0.0}, {"tolerance", 0.2}}).ok);+ bool exact = true;+ for (uint32_t v = 0; v < m.vertexCount(); ++v) exact &= (m.mask[v] > 0.99f) == (m.positions[v].y > 0.5f);+ CHECK(exact);++ // By facing: +z within 45 degrees is the front cap only; add grows it with the top.+ CHECK(registry().execute(d, "mask_by_facing", {{"x", 0.0}, {"y", 0.0}, {"z", 1.0}, {"angle", 45.0}}).ok);+ bool front = true;+ for (uint32_t v = 0; v < m.vertexCount(); ++v) {+ const glm::vec3 n = glm::normalize(m.positions[v]);+ if (n.z > 0.88f) front &= m.mask[v] > 0.99f; // within 30 degrees: fully masked+ if (n.z < 0.7f) front &= m.mask[v] == 0.0f; // beyond 45 degrees: free+ }+ CHECK(front);+ const size_t frontCount = countMasked(m, 0.0f);+ CHECK(registry().execute(d, "mask_by_facing", {{"x", 0.0}, {"y", 2.0}, {"z", 0.0}, {"angle", 45.0}, {"add", true}}).ok);+ CHECK(countMasked(m, 0.0f) > frontCount);+ CHECK(!registry().execute(d, "mask_by_facing", {{"x", 0.0}, {"y", 0.0}}).ok); // z is required+}diff --git a/tests/ui/brush_packs.sfui b/tests/ui/brush_packs.sfuinew file mode 100644index 00000000..5937a571--- /dev/null+++ b/tests/ui/brush_packs.sfui@@ -0,0 +1,73 @@+# Content pass: the brush lists are A-Z by default with a Sort menu (A-Z, Recent, Pack), the six built-in brush+# packs load, and a pack brush picked the first time brings its own alpha (Rivet Row: Rivets, turned along the+# stroke; Soft Clay: none).+run ui_look look=classic layout=zbrush+run new_sphere subdivisions=6+key f+expect_value builtin_pack_brushes == 60+expect_value brush_sort == 0+expect_value alpha_index == 0++# A pack brush brings its alpha the first time; a stroke with it sculpts.+run brush_use name="rivet row"+wait 0.2+expect_value alpha_index == 6+expect_value alpha_follow == 1+snapshot+stroke 0.3 0.5 0.7 0.5+expect_value moved > 50+run brush_use name="Soft Clay"+wait 0.2+expect_value alpha_index == 0+expect_value alpha_follow == 0+# Back to Rivet Row: it keeps what it had this session.+run brush_use name="Rivet Row"+wait 0.2+expect_value alpha_index == 6+run_fails brush_use name="No Such Brush"++click "Brush##palette.brush"+expect "Sort: A-Z##brushsort"+expect_text Brush packs+hold ctrl+hover "Sort: A-Z##brushsort"+expect_help most recently used+hold none+click "Sort: A-Z##brushsort"+click "Pack##brushsort"+expect_value brush_sort == 2+expect "Sort: Pack##brushsort"+expect_text Clay & Form+expect_text Hard Surface+expect_text Organic & Skin+expect_text Cloth & Folds+expect_text Damage & Wear+expect_text Ornament+wait_idle 180+shot brush_palette_packs++# Alphas: A-Z with Round (no alpha) first, a filter, and the same Sort menu.+click "Brush##palette.brush"+click "Alpha##palette.alpha"+expect "Sort: A-Z##alphasort"+type "##alphafilter" bo+expect "Bolt##alpha0"+expect_not "Cracks##alpha0"+key backspace+key backspace+expect "Cracks##alpha0"+wait_idle 60+shot alpha_palette_az+click "Sort: A-Z##alphasort"+click "Pack##alphasort"+expect_value alpha_sort == 2+click "Alpha##palette.alpha"++# Materials sort A-Z or by recent use.+click "Material##palette.material"+expect "Sort: A-Z##materialsort"+click "Sort: A-Z##materialsort"+expect "Recent##materialsort"+expect_not "Pack##materialsort"+click "Recent##materialsort"+expect_value material_sort == 1diff --git a/tests/ui/masking_panel.sfui b/tests/ui/masking_panel.sfuinew file mode 100644index 00000000..c7cdcf35--- /dev/null+++ b/tests/ui/masking_panel.sfui@@ -0,0 +1,61 @@+# Content pass: Tool > Masking is one panel of buttons with pictures: the Shapes (pen, lasso, rectangle) with a hint+# each, Mask by (cavity, peaks, face group, colour, facing, border) and Adjust (grow, shrink, sharpen, blur,+# invert, clear, all), each running its mask_* command with one undo step.+run new_sphere subdivisions=5+camera 0 0+key f+click "Masking"+expect "Mask Pen##mask.pen"+expect "Mask Lasso##mask.lasso"+expect "Mask Rectangle##mask.rect"+expect "By cavity##mask"+expect "By peaks##mask"+expect "By face group##mask"+expect "By colour##mask"+expect "By facing##mask"+expect "By border##mask"+expect "Grow##mask"+expect "Shrink##mask"+expect "Sharpen##mask"+expect "Blur##mask"+expect "Invert##mask"+expect "Clear##mask"+expect "All##mask"+hold ctrl+hover "Mask Lasso##mask.lasso"+expect_help free shape+hover "By facing##mask"+expect_help faces the camera+hold none+wait_idle 30+shot masking_panel++# Shapes pick the Ctrl+drag shape.+click "Mask Lasso##mask.lasso"+expect "Front faces only##mask"+click "Mask Pen##mask.pen"+expect_not "Front faces only##mask"++# By facing (the camera looks at the front): the front of the ball, not the back.+click "By facing##mask"+expect_value masked > 2000+expect_value masked < 7000+click "Invert##mask"+expect_value masked > 3000+click "Clear##mask"+expect_value masked == 0+click "All##mask"+expect_value masked > 10000+shot masking_panel_adjust+click "Shrink##mask"+click "Clear##mask"++# A smooth ball has no sharp ridges; unpainted clay is white, so By colour with white masks all of it.+click "By peaks##mask"+expect_value masked == 0+run set_color r=1 g=1 b=1+click "By colour##mask"+expect_value masked == 10242+click "Clear##mask"+expect_value masked == 0+expect_value can_undo == 1