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
Gizmo All mode (Shift+W): move, rotate and scale handles at once (idea: fenix on Discord; @fenixpoints, #118)
islandmed5a0bf95d73fc
diff --git a/changes/feat-gizmo-all.md b/changes/feat-gizmo-all.mdnew file mode 100644index 00000000..3c05c2a0--- /dev/null+++ b/changes/feat-gizmo-all.md@@ -0,0 +1,13 @@+---+whats_new: **Gizmo, All**: **Shift+W** (or **All** beside Rotate) puts move, rotate and scale handles on one gizmo: arrows and squares inside the rings, boxes past them to stretch, four outer tabs to scale evenly.+highlight: One gizmo with move, rotate and scale handles+added: **Gizmo All mode** (Shift+W, top shelf, Sculpt > Symmetry & Gizmo; the `gizmo_mode` command): move, rotate and+ scale handles at once, with clear priorities where they cross and no overlaps at any zoom or UI scale. Snapping,+ the readout, posing with a mask, Alt+drag for the pivot and one undo step per drag work as in the single modes.+ Idea by fenix on Discord (thanks @fenixpoints, #118).+testers:+ - Windows at 100% and 200% scaling: Shift+W on a model; hover every handle (each turns yellow on its own), drag an arrow, a ring, a box and an outer tab; each drag is one Ctrl+Z.+ - Any OS: mask half a model, Alt+click a joint, Shift+drag a ring in All mode: 15 degree steps, the masked half stays.+ - Any OS: orbit until an axis points at you: its box hides instead of sitting on the rings; orbit back, it returns.+---+Key: Shift+W, not T (T is the Brushes radial menu in every input style; tests/ui/radial_menu.sfui keeps it free).diff --git a/docs/guide/gizmo.md b/docs/guide/gizmo.mdindex 4df87413..aaf0e62f 100644--- a/docs/guide/gizmo.md+++ b/docs/guide/gizmo.md@@ -6,7 +6,7 @@ pivot at the shoulder and swing the arm. It works, with the same keys.-## The three modes+## The modesPress a key, or click the button on the top shelf (they're also in **Sculpt > Symmetry & Gizmo**):@@ -15,6 +15,7 @@ Press a key, or click the button on the top shelf (they're also in **Sculpt > Sy| <kbd>W</kbd> | **Move** | An **arrow** moves along that axis. A **square** moves in its plane. The **ring in the centre** moves freely in the view plane || <kbd>E</kbd> | **Scale** | A **box** stretches along that axis. The **disc in the centre** scales evenly: drag right or up to grow, left or down to shrink || <kbd>R</kbd> | **Rotate** | A **ring** turns about that axis. The **outer white ring** turns about the view direction |+| <kbd>Shift</kbd>+<kbd>W</kbd> | **All** | Every handle at once: see [All handles at once](#all-handles-at-once) || <kbd>Q</kbd> | **Draw** | Back to sculpting: brushes work again and the gizmo goes away |Pressing the same key again also goes back to Draw. X is red, Y green and Z blue; the handle under the cursor@@ -25,6 +26,25 @@ While you drag, the amount shows beside the gizmo (the distance, the angle or thdraws the swept angle as a slice. Each drag is **one undo step** (<kbd>Ctrl</kbd>+<kbd>Z</kbd>), and the gizmogoes back with it.+### All handles at once++**All** (<kbd>Shift</kbd>+<kbd>W</kbd>, or **All** beside Rotate) puts move, rotate and scale on one gizmo, so you+can place, turn and size a part without switching modes:++- Short **arrows** and **squares** inside the rings move, and the **ring in the centre** moves freely, as in Move.+- The **rings** turn about each axis and the **white ring** around them turns in the view, as in Rotate.+- A **box** on an axis line, just outside the rings, stretches along that axis. It hides while its axis points+ straight at you (it would sit on the rings); turn the view a little to bring it back.+- The four **gold tabs** on the outside scale evenly: drag right or up to grow, left or down to shrink.++++Where handles cross, the one you see on top is the one you get: the centre first, then the boxes and the tabs,+then an arrow or a square over a ring. Snapping, the readout, posing with a mask, <kbd>Alt</kbd>+drag for the+pivot and one undo step per drag all work as in the single modes. Scripts switch modes with+`gizmo_mode mode=all` (or `move`, `scale`, `rotate`, `draw`); like every action, **All** can take another key in+**Edit > Preferences > Hotkeys**.+### SnappingHold <kbd>Shift</kbd> while dragging to snap:diff --git a/docs/guide/images/gizmo-all.jpg b/docs/guide/images/gizmo-all.jpgnew file mode 100644index 00000000..68d43edeBinary files /dev/null and b/docs/guide/images/gizmo-all.jpg differdiff --git a/docs/guide/shortcuts.md b/docs/guide/shortcuts.mdindex 93b1ab11..f4174a2b 100644--- a/docs/guide/shortcuts.md+++ b/docs/guide/shortcuts.md@@ -161,6 +161,7 @@ generated from SculptForge's action registry, the same source as the Controls wi| Action | Keys | What it does ||---|---|---|+| All | <kbd>Shift</kbd>+<kbd>W</kbd> | Gizmo, All: move, rotate and scale handles at once. Arrows and squares move, the centre moves in the view, rings turn, the boxes past the rings stretch along an axis and the four outer tabs scale evenly. Shift snaps. Shift+W again: back to Draw. || Back view | <kbd>Ctrl</kbd>+<kbd>Numpad 1</kbd> | Look at the model from behind (orthographic). || Bottom view | <kbd>Ctrl</kbd>+<kbd>Numpad 7</kbd> | Look up at the model from below (orthographic). || Draw | <kbd>Q</kbd> | Draw mode: brushes sculpt and paint (leaves the Gizmo). |diff --git a/src/app/App.h b/src/app/App.hindex 0c088676..22d24ecf 100644--- a/src/app/App.h+++ b/src/app/App.h@@ -7,6 +7,7 @@#include "app/Actions.h"#include "app/AssetLibrary.h"#include "app/AxisGizmo.h"+#include "app/GizmoAll.h"#include "app/CommandPalette.h"#include "app/Config.h"#include "app/Console.h"@@ -2139,9 +2140,9 @@ private:friend class UserGuide; // reads the UI scale, writes the status lineUserGuide guide_;// ---- end User Guide (G) ----- // ---- Transform gizmo (Gizmo.cpp, core/MeshTransform.h): W Move, E Scale, R Rotate, Q back to Draw ----+ // ---- Transform gizmo (Gizmo.cpp, core/MeshTransform.h): W Move, E Scale, R Rotate, Shift+W All, Q back to Draw ----public:- enum class GizmoMode { Off, Move, Scale, Rotate };+ enum class GizmoMode { Off, Move, Scale, Rotate, All }; // All: every handle at onceenum class GizmoHandle {None,MoveX, MoveY, MoveZ, // axis arrows@@ -2171,6 +2172,7 @@ private:bool gizmoProject(const glm::vec3& p, ImVec2& out) const; // false behind the camerabool partProject(const glm::vec3& p, ImVec2& out) const; // a point of the active Part's meshGizmoHandle gizmoHandleAt(float x, float y) const;+ gizmo_all::Screen gizmoAllScreen() const; // All mode's handles on screen (app/GizmoAll.h picks among them)bool gizmoHandleScreen(GizmoHandle h, ImVec2& out) const; // a point to grab handle h (UI tests)std::vector<int> gizmoTargets() const; // Parts a drag transforms (the active one, or All)void gizmoAfterUndo(bool redo); // the gizmo goes back (or forward) with its own stepsdiff --git a/src/app/Config.cpp b/src/app/Config.cppindex 93af069a..3ad7b3e4 100644--- a/src/app/Config.cpp+++ b/src/app/Config.cpp@@ -875,7 +875,7 @@ void App::initActions() {registerLineGradientActions(); // Color > Line Gradient (LineGradient.cpp)registerStencilActions(); // Alpha > Stencil (StencilOverlay.cpp)registerPbrUiActions(); // material channels, solo view, map export (PanelPbr.cpp)- registerGizmoActions(); // Q W E R: Draw, and the Transform gizmo's Move, Scale, Rotate (Gizmo.cpp)+ registerGizmoActions(); // Q W E R: Draw, and the Transform gizmo's Move, Scale, Rotate; Shift+W All (Gizmo.cpp)registerBakeUiActions(); // Tool > Bake (PanelBake.cpp)registerUvEditorActions(); // UV Editor (PanelUvEditor.cpp)registerRetopoUiActions(); // Geometry > QRemesh, Part > ProjectAll (PanelRetopo.cpp)diff --git a/src/app/Gizmo.cpp b/src/app/Gizmo.cppindex 8e6c76f0..af463402 100644--- a/src/app/Gizmo.cpp+++ b/src/app/Gizmo.cpp@@ -1,8 +1,9 @@// SculptForge - open source digital sculpting// SPDX-License-Identifier: GPL-3.0-or-later//-// Transform gizmo (Move W / Scale E / Rotate R, Q back to Draw): a gizmo at the pivot with axis arrows, plane-// squares and a free-move centre (Move), rings and a view ring (Rotate), axis boxes and a uniform centre (Scale).+// Transform gizmo (Move W / Scale E / Rotate R / All Shift+W, Q back to Draw): a gizmo at the pivot with axis arrows,+// plane squares and a free-move centre (Move), rings and a view ring (Rotate), axis boxes and a uniform centre (Scale);+// All has every handle at once (short arrows inside the rings, scale boxes just outside, even-scale tabs outermost).// Dragging a handle transforms the active Part, or only its unmasked part (posing), through a// TransformSession (core/MeshTransform.h): every frame recomputes from the drag's start, so nothing drifts, and// the release makes one undo step per Part. Shift snaps (15 degrees, the grid, 10%), Alt+drag moves the pivot@@ -28,7 +29,12 @@ constexpr float kViewRing = 1.22f; // the view ring, relative to the othersconstexpr float kPickPx = 8.0f;constexpr float kSnapDegrees = 15.0f;+namespace ga = gizmo_all;+using H = App::GizmoHandle;+static_assert(int(H::MoveView) == ga::MoveView && int(H::RotateView) == ga::RotateView &&+ int(H::ScaleUniform) == ga::ScaleUniform && int(H::Count) == ga::ScaleUniform + 1,+ "app/GizmoAll.h numbers the handles as App::GizmoHandle");int axisOf(H h) {switch (h) {@@ -147,6 +153,10 @@ void App::registerGizmoActions() {add("tool.rotate", "Rotate", ICON_LC_ROTATE_CW, "Transform", "R", mode(GizmoMode::Rotate), is(GizmoMode::Rotate),"Gizmo, Rotate: drag a ring to turn about that axis, the outer ring to turn in the view. Mask the body ""and put the pivot at a joint to pose a limb. Shift snaps to 15 degrees. R again: back to Draw.");+ add("tool.gizmo_all", "All", ICON_LC_AXIS_3D, "Transform", "Shift+W", mode(GizmoMode::All), is(GizmoMode::All),+ "Gizmo, All: move, rotate and scale handles at once. Arrows and squares move, the centre moves in the view, "+ "rings turn, the boxes past the rings stretch along an axis and the four outer tabs scale evenly. Shift "+ "snaps. Shift+W again: back to Draw.");add("gizmo.reset_pivot", "Reset", ICON_LC_LOCATE_FIXED, kPath, "", [this] { resetGizmoPivot(); }, nullptr,"Put the gizmo back at the centre of what moves (the Part, or its unmasked part) with world axes.");add("gizmo.snap_pivot", "To Surface", ICON_LC_CROSSHAIR, kPath, "",@@ -179,6 +189,18 @@ void App::registerGizmoActions() {[this] { return gizmo_.folder; },"Transform the visible Parts in the active Part's folder together (Parts list folders). Each Part gets its ""own undo step.");+ commands_.add({"gizmo_mode", "Sets the Transform gizmo's mode (needs the app, not the CLI).",+ {{"mode", ParamSpec::Type::String, "draw (no gizmo), move, scale, rotate or all (every handle at once).", true}},+ [this](Document&, const Args& a) -> CommandResult {+ const std::string m = argString(a, "mode");+ const GizmoMode mode = m == "move" ? GizmoMode::Move : m == "scale" ? GizmoMode::Scale+ : m == "rotate" ? GizmoMode::Rotate : m == "all" ? GizmoMode::All+ : m == "draw" || m == "off" ? GizmoMode::Off : GizmoMode(-1);+ if (int(mode) < 0) return {false, "mode is draw, move, scale, rotate or all"};+ if (drag_ == Drag::Gizmo) return {false, "A gizmo drag is under way"};+ setGizmoMode(mode);+ return {true, "Gizmo: " + m};+ }});}void App::setGizmoMode(GizmoMode mode) {@@ -189,6 +211,7 @@ void App::setGizmoMode(GizmoMode mode) {status_ = mode == GizmoMode::Move ? "Move: drag the arrows, squares or centre (Alt+drag: the gizmo only)": mode == GizmoMode::Scale ? "Scale: drag a box or the centre (Shift: 10% steps)": mode == GizmoMode::Rotate ? "Rotate: drag a ring (Shift: 15 degrees); mask first to pose a part"+ : mode == GizmoMode::All ? "All: arrows and squares move, rings turn, boxes and the outer tabs scale": "Draw";if (mode != GizmoMode::Off) {doc_.syncBvh();@@ -294,6 +317,7 @@ bool App::partProject(const glm::vec3& p, ImVec2& out) const {App::GizmoHandle App::gizmoHandleAt(float x, float y) const {if (!gizmoActive()) return H::None;+ if (gizmo_.mode == GizmoMode::All) return H(ga::pick(gizmoAllScreen(), glm::vec2(x, y)));const glm::vec3 c = gizmo_.pivot;const glm::mat3 f = gizmoFrame();const float L = gizmoWorldSize(), pick = kPickPx * uiScale_;@@ -359,6 +383,17 @@ App::GizmoHandle App::gizmoHandleAt(float x, float y) const {return best;}+gizmo_all::Screen App::gizmoAllScreen() const {+ auto project = [this](const glm::vec3& p, glm::vec2& out) {+ ImVec2 q;+ if (!gizmoProject(p, q)) return false;+ out = glm::vec2(q.x, q.y);+ return true;+ };+ return ga::layout(project, gizmo_.pivot, gizmoFrame(), gizmoWorldSize(), -camera_.forward(), kRadiusPx * uiScale_,+ uiScale_);+}+bool App::gizmoHandleScreen(GizmoHandle h, ImVec2& out) const {// Look along the handle for a point where it is the one picked.const glm::vec3 c = gizmo_.pivot;@@ -368,6 +403,24 @@ bool App::gizmoHandleScreen(GizmoHandle h, ImVec2& out) const {std::vector<glm::vec3> tries;ImVec2 pc;if (!gizmoProject(c, pc)) return false;+ const bool all = gizmo_.mode == GizmoMode::All;+ if (all && h == H::ScaleUniform) {+ // Lowest-right tab first: the history strip and the panels sit along the top and the left of the view.+ const ga::Screen sc = gizmoAllScreen();+ glm::vec2 tabs[4];+ for (int k = 0; k < 4; ++k) tabs[k] = ga::tabPoint(sc, k);+ std::sort(tabs, tabs + 4, [](glm::vec2 a, glm::vec2 b) { return a.x + a.y > b.x + b.y; });+ for (const glm::vec2& p : tabs) {+ out = ImVec2(p.x, p.y);+ if (gizmoHandleAt(out.x, out.y) == h) return true;+ }+ return false;+ }+ if (all && isScale(h)) {+ const ga::Screen::Axis& a = gizmoAllScreen().axis[axis];+ out = ImVec2(a.boxAt.x, a.boxAt.y);+ return a.box && gizmoHandleAt(out.x, out.y) == h;+ }if (h == H::MoveView || h == H::ScaleUniform) {out = pc;return gizmoHandleAt(out.x, out.y) == h;@@ -375,7 +428,7 @@ bool App::gizmoHandleScreen(GizmoHandle h, ImVec2& out) const {if (h == H::RotateView) {for (int k = 0; k < 16; ++k) {const float t = float(k) / 16.0f * 6.2831853f + 0.4f;- const float r = kRadiusPx * kViewRing * uiScale_;+ const float r = kRadiusPx * (all ? ga::kViewRing : kViewRing) * uiScale_;const ImVec2 p(pc.x + r * std::cos(t), pc.y - r * std::sin(t));if (gizmoHandleAt(p.x, p.y) == h) {out = p;@@ -404,9 +457,11 @@ bool App::gizmoHandleScreen(GizmoHandle h, ImVec2& out) const {}if (h >= H::PlaneYZ && h <= H::PlaneXY) {const glm::vec3 u = f[(axis + 1) % 3], v = f[(axis + 2) % 3];- return gizmoProject(c + (u + v) * (0.38f * L), out) && gizmoHandleAt(out.x, out.y) == h;+ const float mid = all ? (ga::kPlaneLo + ga::kPlaneHi) * 0.5f : 0.38f;+ return gizmoProject(c + (u + v) * (mid * L), out) && gizmoHandleAt(out.x, out.y) == h;}- for (float s : {0.75f, 0.9f, 0.6f, 0.45f}) {+ static constexpr float kAlong[2][4] = {{0.75f, 0.9f, 0.6f, 0.45f}, {0.45f, 0.35f, 0.55f, 0.28f}}; // (All: short arrows)+ for (float s : kAlong[all ? 1 : 0]) {if (gizmoProject(c + f[axis] * (s * L), out) && gizmoHandleAt(out.x, out.y) == h) return true;}return false;@@ -800,6 +855,8 @@ void App::drawGizmo() {};const float thick = 2.6f * s;const ImU32 shadow = IM_COL32(0, 0, 0, 110);+ const bool all = gizmo_.mode == GizmoMode::All;+ const float viewRing = all ? ga::kViewRing : kViewRing;if (gizmo_.mode == GizmoMode::Move || gizmo_.mode == GizmoMode::Scale) {const bool move = gizmo_.mode == GizmoMode::Move;@@ -883,8 +940,8 @@ void App::drawGizmo() {}}const ImU32 vc = gizmo_.hover == H::RotateView ? kHot : IM_COL32(222, 222, 222, dragging ? 110 : 220);- dl->AddCircle(pc, kRadiusPx * kViewRing * s, shadow, 96, thick + 2.0f * s);- dl->AddCircle(pc, kRadiusPx * kViewRing * s, vc, 96, thick);+ dl->AddCircle(pc, kRadiusPx * viewRing * s, shadow, 96, thick + 2.0f * s);+ dl->AddCircle(pc, kRadiusPx * viewRing * s, vc, 96, thick);if (dragging && isRotate(gizmo_.handle) && !gizmo_.tangent) {// The swept angle as a pie, so the turn reads at a glance.const glm::vec3 a = gizmo_.handle == H::RotateView ? camera_.forward() : f[axisOf(gizmo_.handle)];@@ -892,7 +949,7 @@ void App::drawGizmo() {const float signedAng = glm::dot(glm::vec3(gizmo_.current.rotate.x, gizmo_.current.rotate.y, gizmo_.current.rotate.z), a) < 0 ? -ang : ang;std::vector<ImVec2> pie{pc};const int steps = std::max(2, int(std::abs(signedAng) / 4.0f));- const float radius = gizmo_.handle == H::RotateView ? L * kViewRing : L;+ const float radius = gizmo_.handle == H::RotateView ? L * viewRing : L;for (int k = 0; k <= steps; ++k) {const glm::quat q = glm::angleAxis(glm::radians(signedAng) * float(k) / float(steps), a);ImVec2 p;@@ -905,11 +962,58 @@ void App::drawGizmo() {}}}+ if (all) {+ // Over the rings: plane squares, the short arrows (far ones first) with their scale boxes past the rings, the+ // even-scale tabs outside the view ring, the free-move centre.+ const ga::Screen sc = gizmoAllScreen();+ auto im = [](glm::vec2 p) { return ImVec2(p.x, p.y); };+ int planes[3] = {0, 1, 2}; // far ones first, as ga::pick stacks them+ std::sort(planes, planes + 3, [&](int a, int b) { return sc.axis[a].planeDepth < sc.axis[b].planeDepth; });+ for (int i : planes) {+ if (!sc.axis[i].plane) continue;+ const ImVec2 q[4] = {im(sc.axis[i].quad[0]), im(sc.axis[i].quad[1]), im(sc.axis[i].quad[2]), im(sc.axis[i].quad[3])};+ const H h = H(int(H::PlaneYZ) + i);+ const ImU32 col = colorFor(h, i);+ dl->AddConvexPolyFilled(q, 4, (col & 0x00ffffff) | (gizmo_.hover == h ? 0x90000000u : 0x50000000u));+ dl->AddPolyline(q, 4, col, ImDrawFlags_Closed, 1.5f * s);+ }+ int order[3] = {0, 1, 2};+ std::sort(order, order + 3, [&](int a, int b) { return sc.axis[a].depth < sc.axis[b].depth; });+ for (int i : order) {+ const ga::Screen::Axis& ax = sc.axis[i];+ if (ax.arrow) {+ const ImU32 col = colorFor(H(int(H::MoveX) + i), i);+ const glm::vec2 dir = glm::normalize(ax.tip - ax.from), nrm(-dir.y, dir.x);+ const glm::vec2 base = ax.tip - dir * (ga::kHeadPx * s), w = nrm * (5.0f * s);+ dl->AddLine(im(ax.from), im(base), shadow, thick + 2.0f * s);+ dl->AddLine(im(ax.from), im(base), col, thick);+ dl->AddTriangleFilled(im(ax.tip), im(base + w), im(base - w), col);+ }+ if (ax.box) {+ const float h2 = ga::kBoxPx * s;+ const ImVec2 lo(ax.boxAt.x - h2, ax.boxAt.y - h2), hi(ax.boxAt.x + h2, ax.boxAt.y + h2);+ dl->AddRectFilled(lo, hi, colorFor(H(int(H::ScaleX) + i), i));+ dl->AddRect(lo, hi, shadow, 0.0f, 0, 1.0f);+ }+ }+ const float tabR = ga::kTabs * kRadiusPx * s;+ const ImU32 tc = gizmo_.hover == H::ScaleUniform ? kHot : IM_COL32(240, 206, 96, dragging ? 140 : 255);+ for (int k = 0; k < 4; ++k) {+ const float t = 0.7853982f + float(k) * 1.5707963f; // (screen y points down: the arc about -t)+ dl->PathArcTo(pc, tabR, -t - ga::kTabHalf, -t + ga::kTabHalf, 12);+ dl->PathStroke(shadow, 0, thick + 4.0f * s);+ dl->PathArcTo(pc, tabR, -t - ga::kTabHalf, -t + ga::kTabHalf, 12);+ dl->PathStroke(tc, 0, thick + 1.5f * s);+ }+ const ImU32 cc = gizmo_.hover == H::MoveView ? kHot : IM_COL32(240, 206, 96, dragging ? 140 : 255);+ dl->AddCircle(pc, 10.0f * s, shadow, 32, thick + 2.0f * s);+ dl->AddCircle(pc, 10.0f * s, cc, 32, thick);+ }// The pivot.dl->AddCircleFilled(pc, 3.5f * s, IM_COL32(255, 255, 255, 230), 16);dl->AddCircle(pc, 3.5f * s, shadow, 16, 1.0f);if (!gizmo_.readout.empty()) {- const ImVec2 at(pc.x + 18.0f * s, pc.y + kRadiusPx * s * 0.55f);+ const ImVec2 at(pc.x + 18.0f * s, pc.y + kRadiusPx * s * (all ? ga::kTabs + 0.12f : 0.55f)); // (All: below it all)const ImVec2 size = ImGui::CalcTextSize(gizmo_.readout.c_str());dl->AddRectFilled(ImVec2(at.x - 5 * s, at.y - 3 * s), ImVec2(at.x + size.x + 5 * s, at.y + size.y + 3 * s),IM_COL32(20, 20, 22, 210), 4.0f * s);@@ -934,9 +1038,9 @@ void App::drawGizmoPanel() {}void App::drawGizmoContents(bool compact) {- ui::Segmented(*this, {"tool.draw", "tool.move", "tool.scale", "tool.rotate"});+ ui::Segmented(*this, {"tool.draw", "tool.move", "tool.scale", "tool.rotate", "tool.gizmo_all"});if (!compact && !gizmoActive()) {- ImGui::TextDisabled(tr("Q W E R: Draw, Move, Scale, Rotate"));+ ImGui::TextDisabled(tr("Q W E R: Draw, Move, Scale, Rotate; Shift+W: All"));return;}// Pivot.diff --git a/src/app/GizmoAll.h b/src/app/GizmoAll.hnew file mode 100644index 00000000..a5546ff9--- /dev/null+++ b/src/app/GizmoAll.h@@ -0,0 +1,171 @@+// SculptForge - open source digital sculpting+// SPDX-License-Identifier: GPL-3.0-or-later+//+// The Transform gizmo's All mode (Shift+W; fenix on Discord's idea): move, rotate and scale handles at once. Where the+// handles sit, in arrow lengths from the pivot, and which one a point on screen picks. Nothing overlaps at any zoom or+// UI scale: short arrows and plane squares inside the rings, the scale boxes on the axis lines just past the rings+// (hidden while their axis points at the viewer, where they would sit on a ring), the view ring, and outermost four+// even-scale tabs on the screen diagonals. Pure arithmetic (no ImGui), so the priorities can be unit tested.+#pragma once++#include <glm/glm.hpp>++#include <algorithm>+#include <cmath>+#include <vector>++namespace sf {++namespace gizmo_all {++constexpr float kShaftLo = 0.2f, kShaftHi = 0.6f; // the arrows (their heads go on, on screen)+constexpr float kHeadPx = 12.0f;+constexpr float kPlaneLo = 0.26f, kPlaneHi = 0.42f; // the plane squares, between the arrows+constexpr float kBox = 1.16f; // the scale boxes, past the rings (at 1)+constexpr float kBoxMin = 0.6f; // ...shown while the axis is at least this long on screen+constexpr float kBoxPx = 5.0f; // half size+constexpr float kViewRing = 1.3f;+constexpr float kTabs = 1.44f; // the even-scale tabs' radius+constexpr float kTabHalf = 0.21f; // radians each side of a diagonal+constexpr float kCentrePx = 12.0f; // the free-move centre+constexpr float kPickPx = 8.0f;++// The handles, numbered as App::GizmoHandle.+enum Handle {+ None, MoveX, MoveY, MoveZ, PlaneYZ, PlaneXZ, PlaneXY, MoveView, RotateX, RotateY, RotateZ, RotateView,+ ScaleX, ScaleY, ScaleZ, ScaleUniform+};++// The gizmo as the view shows it, in pixels (screen y grows downwards).+struct Screen {+ glm::vec2 centre{0.0f};+ float unit = 105.0f; // one arrow length on screen, face-on (the rings' radius)+ float scale = 1.0f; // the UI scale+ struct Axis {+ bool arrow = false; // false: pointing at the viewer+ glm::vec2 from{0.0f}, tip{0.0f};+ float depth = 0.0f; // toward the viewer: the arrow (and box) in front draws over the others+ float planeDepth = 0.0f; // the same for the plane square+ bool box = false;+ glm::vec2 boxAt{0.0f};+ bool plane = false; // the square in the plane across this axis (false: seen edge-on)+ glm::vec2 quad[4];+ std::vector<glm::vec2> ring; // the ring about this axis, closed+ std::vector<bool> ringFront; // per point: on the half facing the viewer+ } axis[3];+};++inline float segmentDistance(glm::vec2 p, glm::vec2 a, glm::vec2 b) {+ const glm::vec2 v = b - a;+ const float l2 = glm::dot(v, v);+ const float t = l2 > 0.0f ? std::clamp(glm::dot(p - a, v) / l2, 0.0f, 1.0f) : 0.0f;+ return glm::length(p - (a + v * t));+}++inline bool insideQuad(glm::vec2 p, const glm::vec2 q[4]) {+ bool in = false;+ for (int i = 0, j = 3; i < 4; j = i++)+ if ((q[i].y > p.y) != (q[j].y > p.y) && p.x < (q[j].x - q[i].x) * (p.y - q[i].y) / (q[j].y - q[i].y) + q[i].x)+ in = !in;+ return in;+}++// A point on even-scale tab k (0 upper right, then counter-clockwise).+inline glm::vec2 tabPoint(const Screen& s, int k) {+ const float t = 0.7853982f + float(k) * 1.5707963f, r = kTabs * s.unit;+ return s.centre + glm::vec2(r * std::cos(t), -r * std::sin(t));+}++// The gizmo at pivot c with axes f (columns), L world units to an arrow's length, as `project` (world point ->+// pixels, false behind the camera) shows it; toEye points at the viewer. An axis pointing at the viewer hides its+// arrow and its box (the box would sit on the rings).+template <class Project>+Screen layout(Project project, const glm::vec3& c, const glm::mat3& f, float L, const glm::vec3& toEye, float unit,+ float scale) {+ Screen out;+ out.unit = unit;+ out.scale = scale;+ if (!project(c, out.centre)) return out;+ for (int i = 0; i < 3; ++i) {+ Screen::Axis& a = out.axis[i];+ a.depth = glm::dot(f[i], toEye);+ a.planeDepth = glm::dot(f[(i + 1) % 3] + f[(i + 2) % 3], toEye);+ glm::vec2 hi, end;+ if (project(c + f[i] * (kShaftLo * L), a.from) && project(c + f[i] * (kShaftHi * L), hi)) {+ const float len = glm::length(hi - a.from);+ a.arrow = len >= 10.0f * scale;+ if (a.arrow) a.tip = hi + (hi - a.from) / len * (kHeadPx * scale);+ }+ a.box = project(c + f[i] * L, end) && glm::length(end - out.centre) >= kBoxMin * unit &&+ project(c + f[i] * (kBox * L), a.boxAt);+ const glm::vec3 u = f[(i + 1) % 3], v = f[(i + 2) % 3];+ const float lo = kPlaneLo * L, top = kPlaneHi * L;+ a.plane = std::abs(glm::dot(f[i], toEye)) >= 0.15f && project(c + u * lo + v * lo, a.quad[0]) &&+ project(c + u * top + v * lo, a.quad[1]) && project(c + u * top + v * top, a.quad[2]) &&+ project(c + u * lo + v * top, a.quad[3]);+ for (int k = 0; k <= 64; ++k) {+ const float t = float(k) / 64.0f * 6.2831853f;+ const glm::vec3 r = u * std::cos(t) + v * std::sin(t);+ glm::vec2 p;+ if (!project(c + r * L, p)) continue;+ a.ring.push_back(p);+ a.ringFront.push_back(glm::dot(r, toEye) > -0.05f);+ }+ }+ return out;+}++// The handle under p, as the drawing stacks them: the centre, the scale boxes and the even-scale tabs each win anywhere+// on themselves; then an arrow on its line; a plane square anywhere inside it; an arrow within the pick distance;+// then the nearest ring (back halves count further away). Where two arrows or two squares cover each other (their+// axes in line on screen) the one in front, drawn on top, is picked.+inline Handle pick(const Screen& s, glm::vec2 p) {+ const float pickPx = kPickPx * s.scale;+ const float r = glm::length(p - s.centre);+ if (r < kCentrePx * s.scale) return MoveView;+ for (int i = 0; i < 3; ++i) {+ const float half = (kBoxPx + 3.0f) * s.scale;+ const Screen::Axis& a = s.axis[i];+ if (a.box && std::abs(p.x - a.boxAt.x) < half && std::abs(p.y - a.boxAt.y) < half) return Handle(ScaleX + i);+ }+ if (std::abs(r - kTabs * s.unit) < pickPx * 0.75f) {+ const float q = 1.5707963f, ang = std::atan2(s.centre.y - p.y, p.x - s.centre.x) - q * 0.5f;+ if (std::abs(ang - q * std::round(ang / q)) < kTabHalf + 0.05f) return ScaleUniform;+ }+ int arrow = -1;+ float arrowD = pickPx;+ for (int i = 0; i < 3; ++i) {+ if (!s.axis[i].arrow) continue;+ const float d = segmentDistance(p, s.axis[i].from, s.axis[i].tip);+ if (d < arrowD - 1.0f || (d < arrowD + 1.0f && arrow >= 0 && s.axis[i].depth > s.axis[arrow].depth)) {+ arrowD = std::min(d, arrowD);+ arrow = i;+ }+ }+ if (arrow >= 0 && arrowD < pickPx * 0.5f) return Handle(MoveX + arrow);+ int plane = -1;+ for (int i = 0; i < 3; ++i)+ if (s.axis[i].plane && insideQuad(p, s.axis[i].quad) && (plane < 0 || s.axis[i].planeDepth > s.axis[plane].planeDepth))+ plane = i;+ if (plane >= 0) return Handle(PlaneYZ + plane);+ if (arrow >= 0) return Handle(MoveX + arrow);+ Handle best = None;+ float bestD = pickPx;+ auto consider = [&](Handle h, float d) {+ if (d < bestD) {+ bestD = d;+ best = h;+ }+ };+ for (int i = 0; i < 3; ++i) {+ const Screen::Axis& a = s.axis[i];+ for (size_t k = 1; k < a.ring.size(); ++k)+ consider(Handle(RotateX + i), segmentDistance(p, a.ring[k - 1], a.ring[k]) + (a.ringFront[k] ? 0.0f : pickPx * 0.6f));+ }+ consider(RotateView, std::abs(r - kViewRing * s.unit));+ return best;+}++} // namespace gizmo_all++} // namespace sfdiff --git a/src/app/I18nSimplifiedChinese.cpp b/src/app/I18nSimplifiedChinese.cppindex 322d81e8..f3967dc9 100644--- a/src/app/I18nSimplifiedChinese.cpp+++ b/src/app/I18nSimplifiedChinese.cpp@@ -1229,6 +1229,11 @@ constexpr Entry kSimplifiedChinese[] = {"snaps to 10% steps. E again: back to Draw.","操纵器,缩放:拖动方块沿轴拉伸,拖动中心等比例缩放(向右或向上:放大)。Shift 以 10% 为一级贴齐。再按 E:回到绘""制。"},+ {"Gizmo, All: move, rotate and scale handles at once. Arrows and squares move, the centre moves in the view, "+ "rings turn, the boxes past the rings stretch along an axis and the four outer tabs scale evenly. Shift snaps. "+ "Shift+W again: back to Draw.",+ "操纵器,全部:同时提供移动、旋转和缩放控制点。箭头和方块用于移动,中心在视图中移动,圆环用于旋转,圆环外的方块沿轴"+ "拉伸,外侧四个标签等比缩放。Shift 贴齐。再按 Shift+W:回到绘制。"},{"Gizmo, Rotate: drag a ring to turn about that axis, the outer ring to turn in the view. Mask the body and put ""the pivot at a joint to pose a limb. Shift snaps to 15 degrees. R again: back to Draw.","操纵器,旋转:拖动圆环绕该轴旋转,拖动外环在视图中旋转。遮罩身体并将枢轴点放在关节上即可摆出肢体姿势。Shift 以 "@@ -4040,8 +4045,8 @@ constexpr Entry kSimplifiedChinese[] = {"从当前视图把图片投射到模型上作为表面细节(使用当前图层)。"},{"Proof mode measures how responsive sculpting is on this computer. For each mesh size it builds a sphere with subdivision levels, then plays a scripted pen stroke through the same code your pen goes through (240 samples a second), with a normal and a large brush, and turns the view.","证明模式会测量这台电脑上雕刻的响应速度。针对每种网格大小,它会创建带细分级别的球体,再通过与你的笔相同的代码路径(每秒 240 个采样)播放预设的笔触,使用普通和大号笔刷,并旋转视图。"},- {"Q W E R: Draw, Move, Scale, Rotate",- "Q W E R:绘制、移动、缩放、旋转"},+ {"Q W E R: Draw, Move, Scale, Rotate; Shift+W: All",+ "Q W E R:绘制、移动、缩放、旋转;Shift+W:全部"},{"Quad Remesh (default): clean quads ready for sculpting and subdividing, with one subdivision level holding the detail. Voxel remesh: an even, watertight triangle surface. Off: the model as the service made it.","四边形重拓扑(默认):干净的四边面,可直接雕刻和细分,并用一个细分级别保留细节。体素重新网格化:均匀、封闭的三角面。关闭:保留服务生成的原始模型。"},{"Quad Remesh 2",diff --git a/src/app/I18nSpanish.cpp b/src/app/I18nSpanish.cppindex 95c0ceec..28143152 100644--- a/src/app/I18nSpanish.cpp+++ b/src/app/I18nSpanish.cpp@@ -1435,6 +1435,12 @@ constexpr Entry kSpanish[] = {"snaps to 10% steps. E again: back to Draw.","Gizmo, Escalar: arrastra una caja para estirar en un eje o el centro para escalar por igual (derecha o arriba: ""más grande). Mayús ajusta a pasos del 10%. E otra vez: vuelve a Dibujar."},+ {"Gizmo, All: move, rotate and scale handles at once. Arrows and squares move, the centre moves in the view, "+ "rings turn, the boxes past the rings stretch along an axis and the four outer tabs scale evenly. Shift snaps. "+ "Shift+W again: back to Draw.",+ "Gizmo, Todo: asas de mover, rotar y escalar a la vez. Las flechas y los cuadrados mueven, el centro mueve en la "+ "vista, los anillos giran, las cajas tras los anillos estiran a lo largo de un eje y las cuatro pestañas "+ "exteriores escalan por igual. Mayús ajusta. Mayús+W otra vez: vuelve a Dibujar."},{"Gizmo, Rotate: drag a ring to turn about that axis, the outer ring to turn in the view. Mask the body and put ""the pivot at a joint to pose a limb. Shift snaps to 15 degrees. R again: back to Draw.","Gizmo, Rotar: arrastra un anillo para girar sobre ese eje, el anillo exterior para girar en la vista. "@@ -4483,8 +4489,8 @@ constexpr Entry kSpanish[] = {"Proyecta la imagen sobre el modelo desde la vista actual como detalle de superficie (usa la capa activa)."},{"Proof mode measures how responsive sculpting is on this computer. For each mesh size it builds a sphere with subdivision levels, then plays a scripted pen stroke through the same code your pen goes through (240 samples a second), with a normal and a large brush, and turns the view.","El modo prueba mide lo ágil que es esculpir en este ordenador. Para cada tamaño de malla crea una esfera con niveles de subdivisión, reproduce un trazo de lápiz programado por el mismo código que usa tu lápiz (240 muestras por segundo), con un pincel normal y uno grande, y gira la vista."},- {"Q W E R: Draw, Move, Scale, Rotate",- "Q W E R: Dibujar, Mover, Escalar, Rotar"},+ {"Q W E R: Draw, Move, Scale, Rotate; Shift+W: All",+ "Q W E R: Dibujar, Mover, Escalar, Rotar; Shift+W: Todo"},{"Quad Remesh (default): clean quads ready for sculpting and subdividing, with one subdivision level holding the detail. Voxel remesh: an even, watertight triangle surface. Off: the model as the service made it.","Quad Remesh (predeterminado): cuadriláteros limpios listos para esculpir y subdividir, con un nivel de subdivisión que guarda el detalle. Remallado vóxel: una superficie de triángulos uniforme y cerrada. Desactivado: el modelo tal como lo hizo el servicio."},{"Quad Remesh 2",diff --git a/src/app/I18nTraditionalChinese.cpp b/src/app/I18nTraditionalChinese.cppindex 76d5a4e1..6d3f2e6f 100644--- a/src/app/I18nTraditionalChinese.cpp+++ b/src/app/I18nTraditionalChinese.cpp@@ -1229,6 +1229,11 @@ constexpr Entry kTraditionalChinese[] = {"snaps to 10% steps. E again: back to Draw.","操縱器,縮放:拖曳方塊沿軸拉伸,拖曳中心等比例縮放(向右或向上:放大)。Shift 以 10% 為一級貼齊。再按 E:回到繪""製。"},+ {"Gizmo, All: move, rotate and scale handles at once. Arrows and squares move, the centre moves in the view, "+ "rings turn, the boxes past the rings stretch along an axis and the four outer tabs scale evenly. Shift snaps. "+ "Shift+W again: back to Draw.",+ "操縱器,全部:同時提供移動、旋轉與縮放控制點。箭頭與方塊用於移動,中心在視圖中移動,圓環用於旋轉,圓環外的方塊沿軸"+ "拉伸,外側四個標籤等比縮放。Shift 貼齊。再按 Shift+W:回到繪製。"},{"Gizmo, Rotate: drag a ring to turn about that axis, the outer ring to turn in the view. Mask the body and put ""the pivot at a joint to pose a limb. Shift snaps to 15 degrees. R again: back to Draw.","操縱器,旋轉:拖曳圓環繞該軸旋轉,拖曳外環在視圖中旋轉。遮罩身體並將樞紐點放在關節上即可擺出肢體姿勢。Shift 以 "@@ -4038,8 +4043,8 @@ constexpr Entry kTraditionalChinese[] = {"從目前視角把圖片投射到模型上作為表面細節(使用目前的圖層)。"},{"Proof mode measures how responsive sculpting is on this computer. For each mesh size it builds a sphere with subdivision levels, then plays a scripted pen stroke through the same code your pen goes through (240 samples a second), with a normal and a large brush, and turns the view.","證明模式會測量這台電腦上雕刻的反應速度。針對每種網格大小,它會建立帶細分層級的球體,再以與你的筆相同的程式路徑(每秒 240 個取樣)播放預錄的筆觸,使用一般與大型筆刷,並旋轉視角。"},- {"Q W E R: Draw, Move, Scale, Rotate",- "Q W E R:繪製、移動、縮放、旋轉"},+ {"Q W E R: Draw, Move, Scale, Rotate; Shift+W: All",+ "Q W E R:繪製、移動、縮放、旋轉;Shift+W:全部"},{"Quad Remesh (default): clean quads ready for sculpting and subdividing, with one subdivision level holding the detail. Voxel remesh: an even, watertight triangle surface. Off: the model as the service made it.","四邊形重拓樸(預設):乾淨的四邊面,可直接雕刻與細分,並以一個細分層級保留細節。體素重新網格化:均勻、封閉的三角面。關閉:保留服務產生的原始模型。"},{"Quad Remesh 2",diff --git a/src/app/Shell.cpp b/src/app/Shell.cppindex 933a468c..07adda6e 100644--- a/src/app/Shell.cpp+++ b/src/app/Shell.cpp@@ -279,7 +279,8 @@ float pointsReadoutW(const Document& doc) { return kPointsReadoutW + (visibleMicbool segmentPair(const std::string& a, const std::string& b) {auto group = [](const std::string& id) {if (id == "draw.sculpt" || id == "draw.paint") return 1;- if (id == "tool.draw" || id == "tool.move" || id == "tool.scale" || id == "tool.rotate") return 5;+ if (id == "tool.draw" || id == "tool.move" || id == "tool.scale" || id == "tool.rotate" || id == "tool.gizmo_all")+ return 5;if (id == "draw.raise" || id == "draw.lower") return 2;if (id.rfind("transform.symmetry_", 0) == 0) return 3;if (id.rfind("draw.pressure_", 0) == 0) return 4;@@ -1758,7 +1759,7 @@ void App::drawStatusBar(const ShellGeometry& g) {std::vector<StatusModule> mods;{const char* mode = paintMode_ ? "Paint" : "Sculpt";- for (const char* t : {"tool.move", "tool.scale", "tool.rotate"})+ for (const char* t : {"tool.move", "tool.scale", "tool.rotate", "tool.gizmo_all"})if (const Action* a = actions_.find(t); a && a->checked && a->checked()) mode = a->label.c_str();mods.push_back({ICON_LC_SQUARE_TERMINAL, "mode", upper(tr(mode)), true});std::string brush = brushName(brush_);diff --git a/src/app/Ui.cpp b/src/app/Ui.cppindex 793dbb28..0b4843c1 100644--- a/src/app/Ui.cpp+++ b/src/app/Ui.cpp@@ -163,7 +163,8 @@ void ManagedBadge() {bool IsModeAction(std::string_view id) {auto starts = [&](std::string_view p) { return id.substr(0, p.size()) == p; };- if (id == "tool.draw" || id == "tool.move" || id == "tool.scale" || id == "tool.rotate") return true;+ if (id == "tool.draw" || id == "tool.move" || id == "tool.scale" || id == "tool.rotate" || id == "tool.gizmo_all")+ return true;if (id == "draw.sculpt" || id == "draw.paint") return true;if (starts("brush.pen_")) return false; // a brush's pen pressure switches (#122): choices, not brush picksreturn starts("brush.") || starts("mask.") || starts("select.");diff --git a/src/app/UiLayout.cpp b/src/app/UiLayout.cppindex c2d391ac..8ac0f560 100644--- a/src/app/UiLayout.cpp+++ b/src/app/UiLayout.cpp@@ -33,7 +33,7 @@ UiLayout standardLayout() {l.rightTray = {"tool"};l.openSubpalettes = {"tool.part"};l.topShelf = {"ui.library", "sep", "tool.draw", "tool.move", "tool.scale",- "tool.rotate", "sep", "draw.sculpt", "draw.paint", "sep",+ "tool.rotate", "tool.gizmo_all", "sep", "draw.sculpt", "draw.paint", "sep","draw.raise", "draw.lower", "draw.rgb", "draw.paint_vertex", "draw.paint_texture", "draw.new_texture", "sep", "widget.draw_size","widget.strength", "row", "ui.brush_lab", "draw.front_faces", "sep","draw.dynamic", "widget.dyntopo_detail", "sep",@@ -60,7 +60,7 @@ UiLayout standardLayout(int shellLayout) {// dynamic topology, symmetry). Library, Brush Lab, Front, the pressure options and the triangle counts moved to// the menus (Sculpt > Draw) and the status bar.l.topShelf = {"draw.sculpt", "draw.paint", "sep",- "tool.draw", "tool.move", "tool.scale", "tool.rotate", "sep",+ "tool.draw", "tool.move", "tool.scale", "tool.rotate", "tool.gizmo_all", "sep","draw.raise", "draw.lower", "draw.rgb", "draw.paint_vertex", "draw.paint_texture","draw.new_texture", "sep", "widget.draw_size", "widget.strength", "sep","draw.dynamic", "widget.dyntopo_detail", "sep",diff --git a/src/app/UiTest.cpp b/src/app/UiTest.cppindex 01ecbde8..a514d189 100644--- a/src/app/UiTest.cpp+++ b/src/app/UiTest.cpp@@ -188,7 +188,7 @@// camera_ortho, mask_brush (Blender's Mask brush on), shortcut_conflicts (keys two actions// claim), brush_type (BrushType// index, -1 for a custom brush or Paint), last_dab_x / last_dab_y (window pixels), paint_r, recent_colors (the left shelf's recent paint colours)-// gizmo_mode (0 Draw, 1 Move, 2 Scale, 3 Rotate), gizmo_hover (handle under the cursor,+// gizmo_mode (0 Draw, 1 Move, 2 Scale, 3 Rotate, 4 All), gizmo_hover (handle under the cursor,// 0 = none, in gizmo_drag's order from 1), gizmo_falloff, pivot_x / pivot_y / pivot_z,// center_x / center_y / center_z and size_x / size_y / size_z (active mesh bounds)// bake_running, baked_maps (maps in the last bake), bake_size, bake_files (files it wrote),diff --git a/src/app/UserGuide.cpp b/src/app/UserGuide.cppindex 90f59e6e..fae06c64 100644--- a/src/app/UserGuide.cpp+++ b/src/app/UserGuide.cpp@@ -477,7 +477,7 @@ std::string UserGuide::chapterFor(const std::string& palette, const std::string&if (starts("Script")) return "scripting.md";if (starts("Library > Packs") || starts("Macros") || idStarts("pack.") || idStarts("macro.")) return "packs-and-macros.md";if (starts("Transform > Gizmo") || idStarts("gizmo.") || actionId == "tool.draw" || actionId == "tool.move" ||- actionId == "tool.scale" || actionId == "tool.rotate")+ actionId == "tool.scale" || actionId == "tool.rotate" || actionId == "tool.gizmo_all")return "gizmo.md";if (starts("Transform")) return idStarts("transform.symmetry") ? "sculpting.md" : "navigation.md";if (starts("Preferences > Integrations")) return "discord.md";diff --git a/tests/test_gizmo_all.cpp b/tests/test_gizmo_all.cppnew file mode 100644index 00000000..3514b26c--- /dev/null+++ b/tests/test_gizmo_all.cpp@@ -0,0 +1,141 @@+// SculptForge - open source digital sculpting+// SPDX-License-Identifier: GPL-3.0-or-later+//+// The Transform gizmo's All mode (app/GizmoAll.h): which handle a point picks where handles meet, and that from any+// view and at 100% and 200% UI scale every shown handle has a spot where it is the one picked (none hides another).+#include "TestHarness.h"++#include "app/GizmoAll.h"++#include <glm/glm.hpp>+#include <glm/gtc/matrix_transform.hpp>++#include <cmath>++using namespace sf;+using namespace sf::gizmo_all;++namespace {++// An orthographic view turned by yaw then pitch (degrees), the gizmo at (400, 300), `scale` the UI scale.+struct View {+ glm::mat3 rot;+ float unit, scale;+ glm::vec3 toEye() const { return glm::transpose(rot) * glm::vec3(0, 0, 1); }+ Screen screen(const glm::mat3& frame = glm::mat3(1.0f)) const {+ auto project = [this](const glm::vec3& p, glm::vec2& out) {+ const glm::vec3 v = rot * p;+ out = glm::vec2(400.0f + v.x * unit, 300.0f - v.y * unit);+ return true;+ };+ return layout(project, glm::vec3(0.0f), frame, 1.0f, toEye(), unit, scale);+ }+};++View view(float yaw, float pitch, float scale = 1.0f) {+ const glm::mat4 r = glm::rotate(glm::mat4(1.0f), glm::radians(pitch), glm::vec3(1, 0, 0)) *+ glm::rotate(glm::mat4(1.0f), glm::radians(yaw), glm::vec3(0, 1, 0));+ return {glm::mat3(r), 105.0f * scale, scale};+}++glm::vec2 lerp(glm::vec2 a, glm::vec2 b, float t) { return a + (b - a) * t; }++} // namespace++TEST(gizmo_all_centre_box_tab_and_ring_priorities) {+ const View v = view(30.0f, -25.0f);+ const Screen s = v.screen();+ // The centre is free move, though rings seen nearly edge-on cross it.+ CHECK(pick(s, s.centre) == MoveView);+ CHECK(pick(s, s.centre + glm::vec2(8.0f, -6.0f)) == MoveView);+ // The scale boxes sit past the rings; anywhere on a box (and a little round it) is that box.+ for (int i = 0; i < 3; ++i) {+ if (!s.axis[i].box) continue;+ CHECK(pick(s, s.axis[i].boxAt) == Handle(ScaleX + i));+ CHECK(pick(s, s.axis[i].boxAt + glm::vec2(6.5f, -6.5f)) == Handle(ScaleX + i));+ CHECK(glm::length(s.axis[i].boxAt - s.centre) > s.unit * kBoxMin * kBox);+ }+ // The even-scale tabs on the diagonals; the same radius between them picks nothing.+ for (int k = 0; k < 4; ++k) CHECK(pick(s, tabPoint(s, k)) == ScaleUniform);+ CHECK(pick(s, s.centre + glm::vec2(0.0f, -kTabs * s.unit)) == None);+ // The view ring between the boxes and the tabs.+ CHECK(pick(s, s.centre + glm::vec2(-kViewRing * s.unit, 0.0f)) == RotateView);+ // An arrow wins over a ring crossing it; off the arrow the ring is picked.+ for (int i = 0; i < 3; ++i)+ if (s.axis[i].arrow) CHECK(pick(s, lerp(s.axis[i].from, s.axis[i].tip, 0.5f)) == Handle(MoveX + i));+}++TEST(gizmo_all_box_hides_when_its_axis_points_at_the_viewer) {+ const Screen front = view(0.0f, 0.0f).screen(); // Z points at the viewer+ CHECK(!front.axis[2].box);+ CHECK(!front.axis[2].arrow);+ CHECK(front.axis[0].box && front.axis[1].box);+ // Along the hidden axis, a point near the centre is the centre, not a scale box sitting on top of it.+ CHECK(pick(front, front.centre + glm::vec2(2.0f, 2.0f)) == MoveView);+ // A point on the X ring (seen edge-on, a vertical line) below the centre: that ring.+ CHECK(pick(front, front.centre + glm::vec2(0.0f, 0.85f * front.unit)) == RotateX);+ // Above the centre the Y arrow lies over the same line and wins.+ CHECK(pick(front, front.centre + glm::vec2(0.0f, -0.4f * front.unit)) == MoveY);+}++TEST(gizmo_all_every_handle_reachable_from_any_view_and_ui_scale) {+ // Handles must not hide each other: each one shown has a spot where it is picked.+ int views = 0;+ for (float scale : {1.0f, 2.0f})+ for (float yaw = -180.0f; yaw < 180.0f; yaw += 20.0f)+ for (float pitch = -80.0f; pitch <= 80.0f; pitch += 20.0f) {+ const View v = view(yaw, pitch, scale);+ const Screen s = v.screen();+ ++views;+ CHECK(pick(s, s.centre) == MoveView);+ bool tab = false;+ for (int k = 0; k < 4; ++k) tab = tab || pick(s, tabPoint(s, k)) == ScaleUniform;+ CHECK(tab);+ bool viewRing = false;+ for (int k = 0; k < 32 && !viewRing; ++k) {+ const float t = float(k) / 32.0f * 6.2831853f;+ viewRing = pick(s, s.centre + glm::vec2(std::cos(t), std::sin(t)) * (kViewRing * s.unit)) == RotateView;+ }+ CHECK(viewRing);+ for (int i = 0; i < 3; ++i) {+ const Screen::Axis& a = s.axis[i];+ if (a.box) CHECK(pick(s, a.boxAt) == Handle(ScaleX + i));+ if (a.arrow) { // picked on its line, unless an arrow in front lies over it (drawn on top)+ bool arrow = false, covered = true;+ for (float t : {0.5f, 0.3f, 0.7f, 0.9f}) {+ const Handle h = pick(s, lerp(a.from, a.tip, t));+ arrow = arrow || h == Handle(MoveX + i);+ covered = covered && h >= MoveX && h <= MoveZ && s.axis[h - MoveX].depth > a.depth;+ }+ CHECK(arrow || covered);+ }+ if (a.plane) { // somewhere inside it, unless arrows or a square in front cover it+ bool plane = false, covered = true;+ for (float u : {0.2f, 0.5f, 0.8f})+ for (float w : {0.2f, 0.5f, 0.8f}) {+ const glm::vec2 q = lerp(lerp(a.quad[0], a.quad[1], u), lerp(a.quad[3], a.quad[2], u), w);+ const Handle h = pick(s, q);+ plane = plane || h == Handle(PlaneYZ + i);+ covered = covered && ((h >= MoveX && h <= MoveZ) ||+ (h >= PlaneYZ && h <= PlaneXY && s.axis[h - PlaneYZ].planeDepth > a.planeDepth));+ }+ CHECK(plane || covered);+ }+ bool ring = false;+ for (size_t k = 0; k < a.ring.size() && !ring; ++k) ring = pick(s, a.ring[k]) == Handle(RotateX + i);+ CHECK(ring);+ // The arrow head stays inside the rings, the box outside them, with a gap.+ if (a.arrow) CHECK(glm::length(a.tip - s.centre) < s.unit * 0.8f);+ }+ }+ CHECK(views > 300);+}++TEST(gizmo_all_turned_axes) {+ // Surface orientation: the axes turned with the surface, the same rules hold.+ const glm::mat3 f = glm::mat3(glm::rotate(glm::mat4(1.0f), 0.7f, glm::normalize(glm::vec3(1, 2, 0.5f))));+ const Screen s = view(15.0f, -35.0f, 2.0f).screen(f);+ CHECK(pick(s, s.centre) == MoveView);+ for (int i = 0; i < 3; ++i)+ if (s.axis[i].box) CHECK(pick(s, s.axis[i].boxAt) == Handle(ScaleX + i));+}diff --git a/tests/ui/gizmo_all.sfui b/tests/ui/gizmo_all.sfuinew file mode 100644index 00000000..7f7df93a--- /dev/null+++ b/tests/ui/gizmo_all.sfui@@ -0,0 +1,140 @@+# Transform gizmo, All mode (Shift+W; fenix on Discord's idea): move, rotate and scale handles at once. Every handle+# is reachable and lights up, each drag does what its single mode does (axis-locked moves, Shift snapping, the+# readout, one undo step), posing with a mask and a pivot at the joint, Alt+drag moving only the gizmo, the+# gizmo_mode command, and the handles at 100% and 200% UI scale on a posed arm.+run new_sphere subdivisions=5 ; transform scale=3,0.7,0.7 pivot=origin ; part_rename to=Arm+key f+orbit -70 -45+remember center_x cx0+remember center_y cy0+remember center_z cz0+remember size_y sy0++# Shift+W: All. Its button lights up beside Move, Scale and Rotate; Shift+W again goes back to Draw.+key shift+w+expect_value gizmo_mode == 4+expect "Gizmo/Apply"+expect_status All:+key shift+w+expect_value gizmo_mode == 0+click "All##tool.gizmo_all"+expect_value gizmo_mode == 4+shot all-mode++# Every handle has a spot where it is the one under the cursor (it lights up), numbered as gizmo_hover counts.+gizmo_hover move_x+expect_value gizmo_hover == 1+gizmo_hover plane_xz+expect_value gizmo_hover == 5+gizmo_hover move_view+expect_value gizmo_hover == 7+gizmo_hover rotate_y+expect_value gizmo_hover == 9+gizmo_hover rotate_view+expect_value gizmo_hover == 11+gizmo_hover scale_x+expect_value gizmo_hover == 12+shot all-hover-scale-box+gizmo_hover scale_uniform+expect_value gizmo_hover == 15+shot all-hover-scale-tab++# An arrow moves along its axis only, as one undo step; the gizmo goes back with it.+snapshot+gizmo_drag move_x 90 0+expect_value moved > 1000+expect_value center_y == $cy0+expect_value center_z == $cz0+expect_status Gizmo Move+expect_value pivot_x > 0.2+key ctrl+z+expect_value moved == 0+expect_value pivot_x < 0.001++# Shift snaps a move to the grid (0.2 for a model this size).+hold shift+gizmo_drag move_y 0 -70+hold none+expect_value center_y > 0.19+key ctrl+z++# A box stretches along its axis, the outer tabs scale evenly; the status repeats the readout.+gizmo_drag scale_y 0 -60+expect_value size_y > $sy0*1.2+remember size_x sx0+expect_value size_x == $sx0+expect_status Gizmo Scale Y 1+key ctrl+z+expect_value size_y == $sy0+gizmo_drag scale_uniform 50 -50+expect_value size_y > $sy0*1.2+key ctrl+z+expect_value size_y == $sy0++# The view ring turns in the view.+gizmo_drag rotate_view 0 -80+expect_value moved > 1000+expect_status Gizmo Rotate+key ctrl+z++# Alt+drag an arrow: only the gizmo moves.+hold alt+gizmo_drag move_x 80 0+hold none+expect_value moved == 0+expect_value pivot_x > 0.3+click "Reset##gizmo.reset_pivot"++# Pose the forearm in All mode: mask the upper arm, Alt+click the elbow, turn a ring, Shift for 15 degree steps.+run mask_rect x0=-1 y0=-1 x1=0 y1=1+wait 0.1+expect_value pivot_x > 1+hold alt+click_part Arm 0.5 0.5+hold none+expect_status Pivot on Arm+snapshot+hold shift+gizmo_drag rotate_z 0 -90 0.5 keep+shot all-posing-mid-drag+release+hold none+expect_status .0 deg+expect_value moved > 1000+expect_value moved_masked == 0+expect_status Gizmo Rotate+run mask_clear+wait 0.2+gizmo_hover rotate_z+expect_value gizmo_hover == 10+shot posed-100++# 200% UI scale: the same handles, twice the size, still apart.+ui_scale 200+wait 0.2+gizmo_hover scale_x+expect_value gizmo_hover == 12+gizmo_hover move_view+expect_value gizmo_hover == 7+gizmo_hover scale_uniform+expect_value gizmo_hover == 15+shot posed-200+ui_scale 100+wait 0.2++# Scripts and the console: gizmo_mode.+run gizmo_mode mode=move+expect_value gizmo_mode == 1+run gizmo_mode mode=all+expect_value gizmo_mode == 4+run gizmo_mode mode=draw+expect_value gizmo_mode == 0+expect_not "Gizmo/Apply"++# Ctrl held: the button explains itself; its key is bindable like the others.+hold ctrl+hover "All##tool.gizmo_all"+expect_help "at once"+hold none+expect_shortcut tool.gizmo_all Shift+W+diff --git a/tools/guide/make_images.py b/tools/guide/make_images.pyindex 85f56a1a..32e25284 100644--- a/tools/guide/make_images.py+++ b/tools/guide/make_images.py@@ -83,6 +83,7 @@ FEATURE_CROPS = {"capture-from-view": ("kelvinlet_capture/capture_window", (440, 140, 1200, 640), 760),"fill-layer-panel": ("fill_layers/fill-layer-panel", (1280, 60, 1600, 960), 320),"gizmo-pose": ("gizmo/posing-mid-drag", (110, 200, 1000, 860), 890),+ "gizmo-all": ("gizmo_all/all-hover-scale-box", (415, 305, 905, 650), 490),"pbr-viewport": ("pbr_viewport/pbr-photo-studio", (0, 0, 1600, 960), MAX_WIDTH),"pbr-environment": ("pbr_viewport/pbr-outdoor-background", (100, 85, 1215, 870), 960),"pbr-brush-material": ("pbr_channels/brush-material", (280, 20, 640, 960), 360),