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
Corner view axes you can read at a glance: lettered X / Y / Z circles, rings for the negative ends, depth-faded, on a soft disc
islandmedc73b233d13f6
diff --git a/changes/feat-view-axes-readable.md b/changes/feat-view-axes-readable.mdnew file mode 100644index 00000000..cc1c048d--- /dev/null+++ b/changes/feat-view-axes-readable.md@@ -0,0 +1,20 @@+---+whats_new: **Easier to read view axes**: the corner axes now show **X**, **Y** and **Z** in filled circles, with+ smaller rings for the opposite ends; the ends pointing away are smaller and fainter, on a soft disc that reads on+ dark and light backgrounds. Click an end for that view, click it again for the opposite view, drag on the disc to+ orbit; an exact view's name ("Front view", "Top view"...) shows under it.+highlight: Clearer corner axes: lettered, depth-shaded, click twice for the opposite view+changed: **Corner axes** (Draw > Camera > Axes): positive ends are filled, lettered circles (X / Y / Z), negative+ ends smaller rings (their letter under the pointer); far ends are smaller and fainter and the nearest is drawn on+ top; a translucent disc behind them (stronger under the pointer) keeps them readable on any background. A second+ click on the end facing you snaps to the opposite view, a drag on the disc orbits, and the name of an exact side+ view shows under the axes. No brush ring over the axes. Small / Medium / Large and the UI scale still apply.+testers:+ - Any OS, dark and light backgrounds (Preferences > Display > Flat Colour, a light grey): the axes read at a glance;+ the end pointing at you is the biggest and on top.+ - Click +Z: Front view (named under the axes); click it again: Back view. Same for X and Y.+ - Drag on the disc between the ends: the view orbits; no brush ring shows over the axes.+ - Windows at 150% and 200% scaling, Draw > Camera > Gizmo size Small / Medium / Large: the letters stay readable+ and every end still clicks.+---+Original look (our palette, our layout); no cube, no figure. Before/after shots in REPORT.md.diff --git a/docs/guide/navigation.md b/docs/guide/navigation.mdindex 5c58c519..52a397de 100644--- a/docs/guide/navigation.md+++ b/docs/guide/navigation.md@@ -18,9 +18,13 @@ shrink with depth. The front, side and top views (<kbd>Numpad 1</kbd>, <kbd>3</korthographic until you rotate again, as in Blender.The X / Y / Z gizmo in the top left of the canvas (**Sculpt > Draw & Tablet > Camera > Axes**) shows the world axes as the camera-sees them. Click an end to look from that side, as in Blender: **X** the right view, **Y** the top, **Z** the front,-and the plain dot at the other end of each axis the left, bottom or back view. These are orthographic like the-numpad views. The end under the pointer gets a ring.+sees them, on a soft disc that keeps them readable on dark and light backgrounds. The positive ends are filled+circles with their letter, the negative ends smaller rings; the ends pointing away from you are smaller and fainter,+and the nearest is drawn on top. Click an end to look from that side, as in Blender: **X** the right view, **Y** the+top, **Z** the front, and the ring at the other end of each axis the left, bottom or back view. Click the same end+again for the opposite view (Front, then Back). These are orthographic like the numpad views. The end under the+pointer gets a ring (a negative end shows its letter), and on an exact side view its name shows under the axes.+Drag on the disc between the ends to orbit.**Sculpt > Draw & Tablet > Camera > Gizmo size** makes the axes **Small**, **Medium** (the default) or **Large**; they grow with theUI scale too, and clicking an end works at every size. **View Figure** (beside **Axes**, off until you turn it on)diff --git a/src/app/App.cpp b/src/app/App.cppindex d5e9a485..8fa66b5c 100644--- a/src/app/App.cpp+++ b/src/app/App.cpp@@ -2930,7 +2930,8 @@ void App::drawUi() {if (((!ImGui::GetIO().WantCaptureMouse && canvasRect().contains(mouse.x, mouse.y)) || drag_ == Drag::Stroke || sliderRing) &&!hideBrushCursor_ && radial_.menu < 0 && !strokePopup_.open && drag_ != Drag::Select && drag_ != Drag::Guide && // (no ring under a pie or the stroke popup)aiLinkStateValue() != 2 && aiLinkStateValue() != 4 && // (nor over a live-mode question: it is drawn above windows)- (!ringOff || drag_ == Drag::Stroke || ctrlDown(inputMods())))+ (!ringOff || drag_ == Drag::Stroke || ctrlDown(inputMods())) &&+ (drag_ == Drag::Stroke || !overViewNavigator(mouse.x, mouse.y))) // (nor over the corner axes: a click there navigates)drawBrushCursor();drawSelectionOverlay();drawBrushLibraryPopups();@@ -4071,32 +4072,57 @@ bool App::drawSurfaceCursor(ImDrawList* dl, float x, float y, float radiusPx, flreturn true;}-std::array<AxisGizmoEnd, 6> App::axisGizmoLayout() const {- // Top left of the canvas, below the timeline strip when that is at the top (timelineTopInset_).+glm::vec2 App::axisGizmoCentre() const {+ // Top left of the canvas, below the timeline strip when that is at the top (timelineTopInset_); the disc's edge+ // 10 px from the canvas edges.const CanvasRect canvas = canvasRect();- const float s = 34.0f * axisGizmoUnit();- return axisGizmoEnds(glm::mat3(camera_.view()),- glm::vec2(canvas.x + s + 18.0f * uiScale_, canvas.y + timelineTopInset_ + s + 18.0f * uiScale_), s);+ const float r = kAxisGizmoDisc * axisGizmoUnit() + 10.0f * uiScale_;+ return glm::vec2(canvas.x + r, canvas.y + timelineTopInset_ + r);+}++std::array<AxisGizmoEnd, 6> App::axisGizmoLayout() const {+ return axisGizmoEnds(glm::mat3(camera_.view()), axisGizmoCentre(), kAxisGizmoLength * axisGizmoUnit());}float App::axisGizmoUnit() const { return uiScale_ * axisGizmoScale(uiPrefs_.axisGizmoSize); }-float App::viewFigureRadius() const { return 34.0f * axisGizmoUnit(); }+float App::axisGizmoLabelHeight() const { return ImGui::GetFontSize() * 0.85f + 8.0f * uiScale_; }++bool App::viewBackgroundLight() const {+ // The corner of the view: the gradient's edge, or the flat colour (both display sRGB).+ const glm::vec3 c = renderSettings_.gradientBackground ? renderSettings_.gradientEdge : renderSettings_.backgroundColor;+ return glm::dot(c, glm::vec3(0.2126f, 0.7152f, 0.0722f)) > 0.5f;+}++float App::viewFigureRadius() const { return kAxisGizmoLength * axisGizmoUnit(); }glm::vec2 App::viewFigureCentre() const {- // In the axes' place when they are off, else just below them.+ // In the axes' place when they are off, else just below them (and the view's name under them).const CanvasRect canvas = canvasRect();const float r = viewFigureRadius();- const float top = canvas.y + timelineTopInset_ + 18.0f * uiScale_;- const float below = uiPrefs_.showAxes ? 2.0f * 34.0f * axisGizmoUnit() + 14.0f * uiScale_ : 0.0f;- return glm::vec2(canvas.x + 18.0f * uiScale_ + 34.0f * axisGizmoUnit(), top + below + r);+ const float x = canvas.x + 18.0f * uiScale_ + r;+ if (!uiPrefs_.showAxes) return glm::vec2(x, canvas.y + timelineTopInset_ + 18.0f * uiScale_ + r);+ const glm::vec2 c = axisGizmoCentre();+ return glm::vec2(x, c.y + kAxisGizmoDisc * axisGizmoUnit() + axisGizmoLabelHeight() + r);+}++bool App::overViewNavigator(float x, float y) const {+ if (uiPrefs_.showAxes && axisGizmoOnDisc(axisGizmoCentre(), kAxisGizmoDisc * axisGizmoUnit(), x, y)) return true;+ return uiPrefs_.showViewFigure && glm::length(glm::vec2(x, y) - viewFigureCentre()) <= viewFigureRadius();}bool App::axisGizmoMouseDown(float x, float y) {- // A click on an end snaps to that side view, orthographic (#43, as in Blender's navigation gizmo); a click on- // the View Figure to the side view nearest the current one.+ // A click on an end snaps to that side view, orthographic (#43, as in Blender's navigation gizmo), a second click+ // on it to the opposite side; a drag on the disc behind the ends orbits; a click on the View Figure snaps to+ // the side view nearest the current one.const auto ends = axisGizmoLayout();- int hit = uiPrefs_.showAxes ? axisGizmoHit(ends, x, y, 9.0f * axisGizmoUnit()) : -1;+ const float unit = axisGizmoUnit();+ int hit = uiPrefs_.showAxes ? axisGizmoSnapEnd(ends, axisGizmoHit(ends, x, y, kAxisGizmoHitRadius * unit)) : -1;+ if (hit < 0 && uiPrefs_.showAxes && axisGizmoOnDisc(axisGizmoCentre(), kAxisGizmoDisc * unit, x, y)) {+ drag_ = Drag::Orbit;+ rightClick_.pending = false;+ return true;+ }if (hit < 0 && uiPrefs_.showViewFigure &&glm::length(glm::vec2(x, y) - viewFigureCentre()) <= viewFigureRadius())hit = axisGizmoFacing(ends);@@ -4106,33 +4132,78 @@ bool App::axisGizmoMouseDown(float x, float y) {}void App::drawAxisGizmo() {- // The world axes as the camera sees them, under the UI: red X, green Y, blue Z, a labelled ball at the- // positive end and a plain one at the negative end; the ends pointing away are drawn first and dimmer. A click- // on an end snaps to that side (axisGizmoMouseDown); the end under the mouse gets a ring.+ // The world axes as the camera sees them, under the UI, on a soft disc that reads on any background (stronger+ // under the pointer): red X, green Y, blue Z; the positive ends are filled circles with their letter, the+ // negative ends smaller rings (their letter under the pointer). Drawn back to front: the ends pointing away are+ // smaller and fainter, the near ones on top. A click on an end snaps to that side (axisGizmoMouseDown), a+ // second click to the opposite side; the end under the pointer gets a ring. On an exact side view its name+ // shows under the disc.ImDrawList* dl = ImGui::GetBackgroundDrawList();const float unit = axisGizmoUnit();auto ends = axisGizmoLayout();- const glm::vec2 c = (ends[0].at + ends[3].at) * 0.5f;+ const glm::vec2 c = axisGizmoCentre();+ const ImVec2 centre(c.x, c.y);+ const float discR = kAxisGizmoDisc * unit;const ImVec2 mouse = ImGui::GetIO().MousePos;- const int hover = ImGui::GetIO().WantCaptureMouse ? -1 : axisGizmoHit(ends, mouse.x, mouse.y, 9.0f * unit);+ const bool free = !ImGui::GetIO().WantCaptureMouse;+ const int hover = free ? axisGizmoHit(ends, mouse.x, mouse.y, kAxisGizmoHitRadius * unit) : -1;+ const bool onDisc = free && (hover >= 0 || axisGizmoOnDisc(c, discR, mouse.x, mouse.y));+ const bool light = viewBackgroundLight();+ const int aligned = axisGizmoAligned(ends);const AxisGizmoEnd hovered = hover >= 0 ? ends[size_t(hover)] : AxisGizmoEnd{};++ // The disc: lighter than a dark background, darker than a light one; a hairline edge gives it a shape.+ const ImU32 tint = light ? IM_COL32(0, 0, 0, 0) : IM_COL32(255, 255, 255, 0);+ auto withAlpha = [](ImU32 col, float a) {+ return (col & 0x00ffffffu) | (ImU32(std::clamp(a, 0.0f, 1.0f) * 255.0f + 0.5f) << 24);+ };+ dl->AddCircleFilled(centre, discR, withAlpha(tint, onDisc ? 0.17f : light ? 0.08f : 0.07f), 48);+ dl->AddCircle(centre, discR, withAlpha(tint, onDisc ? 0.22f : 0.10f), 48, 1.0f * uiScale_);+std::sort(ends.begin(), ends.end(), [](const AxisGizmoEnd& a, const AxisGizmoEnd& b) { return a.depth < b.depth; });- static constexpr ImU32 colours[3] = {IM_COL32(230, 80, 80, 255), IM_COL32(110, 200, 90, 255), IM_COL32(80, 140, 240, 255)};+ static constexpr ImU32 colours[3] = {IM_COL32(236, 84, 92, 255), IM_COL32(124, 196, 64, 255), IM_COL32(64, 140, 236, 255)};static constexpr const char* names[3] = {"X", "Y", "Z"};+ ImFont* font = fontBold_ ? fontBold_ : ImGui::GetFont();+ // The letters shrink with the circles (Small) but never grow past the UI font.+ const float fontSize = ImGui::GetFontSize() * 0.92f * std::min(1.0f, unit / std::max(uiScale_, 0.01f));+ auto letter = [&](ImVec2 at, int axis, ImU32 col) {+ const ImVec2 ts = font->CalcTextSizeA(fontSize, FLT_MAX, 0.0f, names[axis]);+ dl->AddText(font, fontSize, ImVec2(std::round(at.x - ts.x * 0.5f), std::round(at.y - ts.y * 0.5f)), col, names[axis]);+ };for (const AxisGizmoEnd& e : ends) {const ImVec2 tip(e.at.x, e.at.y);- ImU32 col = e.depth < -0.2f ? (colours[e.axis] & 0x00ffffffu) | 0x90000000u : colours[e.axis];- if (e.negative) col = (col & 0xff000000u) | ((col & 0x00fefefeu) >> 1); // the negative end: darker- else dl->AddLine(ImVec2(c.x, c.y), tip, col, 2.0f * unit);- dl->AddCircleFilled(tip, (e.negative ? 5.5f : 7.0f) * unit, col);- if (hover >= 0 && e.axis == hovered.axis && e.negative == hovered.negative)- dl->AddCircle(tip, 9.0f * unit, IM_COL32(255, 255, 255, 220), 0, 1.5f * unit);- if (e.negative) continue;- // The letter shrinks with the ball (Small) but never grows past the UI font.- const float fontSize = ImGui::GetFontSize() * std::min(1.0f, unit / std::max(uiScale_, 0.01f));- const ImVec2 ts = ImGui::GetFont()->CalcTextSizeA(fontSize, FLT_MAX, 0.0f, names[e.axis]);- dl->AddText(ImGui::GetFont(), fontSize, ImVec2(tip.x - ts.x * 0.5f, tip.y - ts.y * 0.5f), IM_COL32(20, 20, 22, 255),- names[e.axis]);+ const float alpha = axisGizmoEndAlpha(e.depth);+ const float r = axisGizmoEndRadius(e, unit);+ const ImU32 col = withAlpha(colours[e.axis], alpha);+ const bool isHover = hover >= 0 && e.axis == hovered.axis && e.negative == hovered.negative;+ if (e.negative) {+ // A ring: the axis colour round a dim fill, so it reads as "the other end" on any background.+ dl->AddCircleFilled(tip, r, isHover ? col : withAlpha(colours[e.axis], 0.28f * alpha), 24);+ dl->AddCircle(tip, r, col, 24, 1.6f * unit);+ if (isHover) letter(tip, e.axis, IM_COL32(16, 16, 20, 255));+ } else {+ // The shaft stops at the circle's edge, so its letter stays clean.+ const glm::vec2 d = e.at - c;+ const float len = glm::length(d);+ if (len > r + 1.0f) {+ const glm::vec2 end = c + d * ((len - r) / len);+ dl->AddLine(centre, ImVec2(end.x, end.y), col, 2.0f * unit);+ }+ dl->AddCircleFilled(tip, r, col, 24);+ letter(tip, e.axis, withAlpha(IM_COL32(16, 16, 20, 255), alpha));+ }+ if (isHover) dl->AddCircle(tip, r + 2.0f * unit, light ? IM_COL32(20, 20, 24, 220) : IM_COL32(255, 255, 255, 230), 24, 1.5f * unit);+ }++ // The view's name on an exact side view ("Front view"), small, under the disc.+ if (aligned >= 0) {+ const AxisGizmoView v = axisGizmoView(aligned % 3, aligned >= 3);+ const char* text = tr(v.label);+ const float size = ImGui::GetFontSize() * 0.85f;+ const ImVec2 ts = ImGui::GetFont()->CalcTextSizeA(size, FLT_MAX, 0.0f, text);+ const ImVec2 at(std::round(c.x - ts.x * 0.5f), std::round(c.y + discR + 4.0f * uiScale_));+ dl->AddText(ImGui::GetFont(), size, ImVec2(at.x + 1.0f, at.y + 1.0f), light ? IM_COL32(255, 255, 255, 110) : IM_COL32(0, 0, 0, 150), text);+ dl->AddText(ImGui::GetFont(), size, at, light ? IM_COL32(30, 30, 34, 230) : IM_COL32(232, 232, 236, 220), text);}}diff --git a/src/app/App.h b/src/app/App.hindex 0dcea562..2b2b8d54 100644--- a/src/app/App.h+++ b/src/app/App.h@@ -1766,8 +1766,12 @@ private:bool rememberWindow_ = false;void drawAxisGizmo();std::array<AxisGizmoEnd, 6> axisGizmoLayout() const; // the gizmo's ends on screen now (AxisGizmo.h)- bool axisGizmoMouseDown(float x, float y); // a click on an end: that side view (#43)+ glm::vec2 axisGizmoCentre() const; // the centre of its disc+ bool axisGizmoMouseDown(float x, float y); // a click on an end: that side view (#43); on the disc: orbitfloat axisGizmoUnit() const; // UI scale times Draw > Camera > Gizmo size+ float axisGizmoLabelHeight() const; // the room under the disc for the view's name+ bool overViewNavigator(float x, float y) const; // on the axes' disc or the View Figure (no brush ring there)+ bool viewBackgroundLight() const; // the 3D view's background is light (the gizmo's disc darkens)glm::vec2 viewFigureCentre() const; // Draw > Camera > View Figure: where it sits, how bigfloat viewFigureRadius() const;void drawViewFigure();diff --git a/src/app/AxisGizmo.h b/src/app/AxisGizmo.hindex ca12cec5..4bb74a24 100644--- a/src/app/AxisGizmo.h+++ b/src/app/AxisGizmo.h@@ -2,8 +2,10 @@// SPDX-License-Identifier: GPL-3.0-or-later//// The axis gizmo in the canvas corner (Draw > Camera > Axes, #31): where its six ends sit on screen for a view,-// which end a click lands on, and the side view each end snaps to (#43, as in Blender); its size (Small / Medium /-// Large) and the View Figure's snap to the nearest side. Pure arithmetic (no ImGui), so it can be unit tested.+// which end a click lands on, and the side view each end snaps to (#43, as in Blender); a second click on the end+// already facing you snaps to the opposite side; how big and how faded each end is by its depth (the far ones+// smaller and fainter); the disc behind it (a drag there orbits); its size (Small / Medium / Large) and the View+// Figure's snap to the nearest side. Pure arithmetic (no ImGui), so it can be unit tested.#pragma once#include <glm/glm.hpp>@@ -46,17 +48,50 @@ inline int axisGizmoHit(const std::array<AxisGizmoEnd, 6>& ends, float x, float// The view a click on an end snaps to: looking from that end towards the centre (+X: the right side, +Y: the// top, +Z: the front). The action id and the camera's yaw and pitch in degrees, as Input.cpp's view actions.+// `label` names the view (the action's own label, translated with tr()) under the gizmo when the view is exactly it.struct AxisGizmoView {const char* action;float yaw, pitch;+ const char* label;};inline AxisGizmoView axisGizmoView(int axis, bool negative) {- static constexpr AxisGizmoView views[6] = {{"view.right", 90.0f, 0.0f}, {"view.top", 0.0f, -90.0f},- {"view.front", 0.0f, 0.0f}, {"view.left", -90.0f, 0.0f},- {"view.bottom", 0.0f, 90.0f}, {"view.back", 180.0f, 0.0f}};+ static constexpr AxisGizmoView views[6] = {+ {"view.right", 90.0f, 0.0f, "Right view"}, {"view.top", 0.0f, -90.0f, "Top view"},+ {"view.front", 0.0f, 0.0f, "Front view"}, {"view.left", -90.0f, 0.0f, "Left view"},+ {"view.bottom", 0.0f, 90.0f, "Bottom view"}, {"view.back", 180.0f, 0.0f, "Back view"}};return views[(negative ? 3 : 0) + (axis < 0 || axis > 2 ? 0 : axis)];}+// Sizes in unscaled pixels at Medium, multiplied by the unit (UI scale x Gizmo size, axisGizmoScale): the axes'+// length, a positive end's filled circle and a negative end's ring (both at the nearest depth), the click radius+// around an end and the disc behind the whole gizmo.+constexpr float kAxisGizmoLength = 34.0f;+constexpr float kAxisGizmoBall = 9.0f;+constexpr float kAxisGizmoRing = 6.0f;+constexpr float kAxisGizmoHitRadius = 10.0f;+constexpr float kAxisGizmoDisc = 47.0f;++// Depth cues: an end pointing straight at the viewer is full size and opaque; one pointing straight away is 78% of+// the size and 50% opaque, so front and back read at a glance.+inline float axisGizmoEndRadius(const AxisGizmoEnd& e, float unit) {+ const float d = glm::clamp(e.depth, -1.0f, 1.0f);+ return (e.negative ? kAxisGizmoRing : kAxisGizmoBall) * (0.89f + 0.11f * d) * unit;+}+inline float axisGizmoEndAlpha(float depth) { return 0.75f + 0.25f * glm::clamp(depth, -1.0f, 1.0f); }++// Within the disc behind the gizmo (`centre`, `radius` pixels): a press there that misses the ends orbits the view.+inline bool axisGizmoOnDisc(glm::vec2 centre, float radius, float x, float y) {+ const glm::vec2 d = glm::vec2(x, y) - centre;+ return glm::dot(d, d) <= radius * radius;+}++// The end a click on end `hit` snaps to: that end, or its opposite when the view already looks from it (a second+// click on Front shows the back).+inline int axisGizmoSnapEnd(const std::array<AxisGizmoEnd, 6>& ends, int hit) {+ if (hit < 0 || hit > 5) return -1;+ return ends[size_t(hit)].depth > 0.999f ? (hit + 3) % 6 : hit;+}+// Draw > Camera > Gizmo size: 0 Small, 1 Medium (the size before 0.10.8, the default), 2 Large. Multiplies the// gizmo's length, balls and click radius on top of the UI scale.inline float axisGizmoScale(int size) { return size <= 0 ? 0.65f : size == 1 ? 1.0f : 1.4f; }@@ -69,4 +104,10 @@ inline int axisGizmoFacing(const std::array<AxisGizmoEnd, 6>& ends) {return best;}+// The end the view looks exactly from (a side view: its name shows under the gizmo), or -1 between views.+inline int axisGizmoAligned(const std::array<AxisGizmoEnd, 6>& ends) {+ const int facing = axisGizmoFacing(ends);+ return ends[size_t(facing)].depth > 0.9995f ? facing : -1;+}+} // namespace sfdiff --git a/src/app/UiTest.cpp b/src/app/UiTest.cppindex 0e26cc52..c0ed0818 100644--- a/src/app/UiTest.cpp+++ b/src/app/UiTest.cpp@@ -41,7 +41,10 @@// pen: with the pen, hovering (its tip taps for click)// drag_landmark N DX DY [S] left-drag Make sculptable's face landmark N (0-7, FaceLandmarks order) by DX DY pixels// orbit DX DY right-drag on the background, in pixels (with the held modifiers)-// axis_click +x|-x|+y|-y|+z|-z click that end of the axis gizmo in the canvas corner (it snaps to that side view)+// axis_click +x|-x|+y|-y|+z|-z click that end of the axis gizmo in the canvas corner (it snaps to that side view;+// again on the end facing you: the opposite side)+// axis_drag DX DY left-drag from a spot on the axis gizmo's disc clear of its ends, by DX DY unscaled pixels+// axis_hover +x|...|-z|disc rest the pointer on that end of the axis gizmo, or on its disc clear of the ends// button_drag middle|right X0 Y0 X1 Y1 [S] drag with that button in window fractions (with the held modifiers)// expect_shortcut ACTION KEYS the action's effective keys, e.g. expect_shortcut view.front Numpad 1// camera YAW PITCH set the view's angles in degrees (0 0 = the front view), e.g. for guide screenshots@@ -105,6 +108,7 @@// symmetry_copies (copies every stroke makes), cursor_copies (brush cursors drawn),// symmetry_pivot_x (local symmetry's centre), timeline_top (1: the strip at the top),// timeline_y / axis_gizmo_y (their tops / centre, fractions of the canvas from its top),+// axis_view (the side view named under the axis gizmo: 0-5 = +x +y +z -x -y -z, -1 none),// style_window_min (ImGui's minimum window height, unscaled px: 32 in every look),// tablet_mouse_mode (Preferences > Tablet > Mouse mode),// ui_mouse_x / ui_mouse_y (where ImGui sees the pointer), backface_culling, drawn_triangles,@@ -976,6 +980,8 @@ double Demo::query(const std::string& name, bool& known) const {// Draw > Camera > Gizmo size and View Figure: the axes' length in unscaled px (34 at Medium), the figure shown.if (name == "axis_gizmo_length") return double(34.0f * app_.axisGizmoUnit() / std::max(app_.uiScale_, 0.01f));if (name == "view_figure") return app_.uiPrefs_.showViewFigure ? 1.0 : 0.0;+ // The side view the axis gizmo names under it (0-5: +X +Y +Z -X -Y -Z, as axis_click), -1 between views.+ if (name == "axis_view") return double(axisGizmoAligned(app_.axisGizmoLayout()));if (name == "timeline_y" || name == "axis_gizmo_y") {const auto c = app_.canvasRect();if (name == "timeline_y")@@ -1330,6 +1336,54 @@ bool Demo::parseStep(int line, const std::vector<std::string>& w, std::string& estroke([at](float) { return *at; }, 0.2f);run([this] { SDL_SetModState(held_); });wait(0.1f);+ } else if (verb == "axis_drag" || verb == "axis_hover") {+ // axis_drag DX DY: a left-drag starting on the gizmo's disc where no end is (it orbits the view);+ // axis_hover END|disc: the pointer resting on an end or the disc (the hover look, for shots)+ if (!need(verb == "axis_drag" ? 2 : 1)) return false;+ static const char* const names[6] = {"+x", "+y", "+z", "-x", "-y", "-z"};+ int end = -1;+ if (verb == "axis_hover" && w[1] != "disc") {+ const auto found = std::find_if(std::begin(names), std::end(names), [&](const char* n) { return w[1] == n; });+ if (found == std::end(names)) {+ error = "axis_hover takes +x, -x, +y, -y, +z, -z or disc";+ return false;+ }+ end = int(found - std::begin(names));+ }+ const float dx = verb == "axis_drag" ? num(1, 0.0f) : 0.0f, dy = verb == "axis_drag" ? num(2, 0.0f) : 0.0f;+ auto from = std::make_shared<ImVec2>();+ run([this, from, end] {+ const auto ends = app_.axisGizmoLayout();+ const float unit = app_.axisGizmoUnit();+ if (end >= 0) {+ *from = ImVec2(ends[size_t(end)].at.x, ends[size_t(end)].at.y);+ return;+ }+ // The spot on the disc farthest from every end, three quarters of the way out.+ const glm::vec2 c = app_.axisGizmoCentre();+ float best = -1.0f;+ for (int i = 0; i < 24; ++i) {+ const float a = float(i) * 6.2831853f / 24.0f;+ const glm::vec2 p = c + glm::vec2(std::cos(a), std::sin(a)) * (kAxisGizmoDisc * 0.75f * unit);+ float nearest = 1e9f;+ for (const AxisGizmoEnd& e : ends) nearest = std::min(nearest, glm::length(e.at - p));+ if (nearest > best) {+ best = nearest;+ *from = ImVec2(p.x, p.y);+ }+ }+ });+ if (verb == "axis_hover") {+ run([this, from] { mouseMotion(from->x, from->y); });+ wait(0.15f);+ } else {+ stroke([this, from, dx, dy](float u) {+ const float s = app_.uiScale_;+ return ImVec2(from->x + dx * s * u, from->y + dy * s * u);+ }, 0.4f);+ run([this] { SDL_SetModState(held_); });+ wait(0.1f);+ }} else if (verb == "view_figure_click") {// view_figure_click [DX DY]: click the View Figure (Draw > Camera), DX DY its radii from the centreconst float dx = num(1, 0.0f), dy = num(2, 0.0f);diff --git a/tests/test_axis_gizmo.cpp b/tests/test_axis_gizmo.cppindex 16d129bc..fccdb56b 100644--- a/tests/test_axis_gizmo.cpp+++ b/tests/test_axis_gizmo.cpp@@ -10,6 +10,7 @@#include <glm/glm.hpp>+#include <cmath>#include <cstring>using namespace sf;@@ -80,3 +81,73 @@ TEST(view_figure_snaps_to_the_nearest_side) {facing = axisGizmoFacing(axisGizmoEnds(glm::mat3(c.view()), glm::vec2(0.0f), 30.0f));CHECK(std::strcmp(axisGizmoView(facing % 3, facing >= 3).action, "view.top") == 0);}++TEST(axis_gizmo_click_on_each_end_snaps_to_its_view_then_the_opposite) {+ // From a three-quarter view a click on each end picks that end's view; from there a second click on the same+ // spot (now that end faces you) picks the opposite view.+ for (int i = 0; i < 6; ++i) {+ Camera c;+ c.yaw = glm::radians(35.0f);+ c.pitch = glm::radians(-25.0f);+ auto ends = axisGizmoEnds(glm::mat3(c.view()), glm::vec2(100.0f, 100.0f), 34.0f);+ const int first = axisGizmoSnapEnd(ends, axisGizmoHit(ends, ends[size_t(i)].at.x, ends[size_t(i)].at.y, 10.0f));+ CHECK(first == i);+ const AxisGizmoView v = axisGizmoView(i % 3, i >= 3);+ c.yaw = glm::radians(v.yaw);+ c.pitch = glm::radians(v.pitch);+ ends = axisGizmoEnds(glm::mat3(c.view()), glm::vec2(100.0f, 100.0f), 34.0f);+ CHECK(axisGizmoAligned(ends) == i);+ CHECK(axisGizmoSnapEnd(ends, axisGizmoHit(ends, ends[size_t(i)].at.x, ends[size_t(i)].at.y, 10.0f)) == (i + 3) % 6);+ }+ CHECK(axisGizmoSnapEnd(axisGizmoEnds(glm::mat3(1.0f), glm::vec2(0.0f), 34.0f), -1) == -1);+}++TEST(axis_gizmo_names_only_exact_side_views) {+ Camera c; // the front view+ CHECK(axisGizmoAligned(axisGizmoEnds(glm::mat3(c.view()), glm::vec2(0.0f), 34.0f)) == 2);+ CHECK(std::strcmp(axisGizmoView(2, false).label, "Front view") == 0);+ CHECK(std::strcmp(axisGizmoView(1, false).label, "Top view") == 0);+ c.yaw = glm::radians(3.0f);+ CHECK(axisGizmoAligned(axisGizmoEnds(glm::mat3(c.view()), glm::vec2(0.0f), 34.0f)) == -1);+}++TEST(axis_gizmo_far_ends_are_smaller_and_fainter) {+ Camera c;+ c.yaw = glm::radians(30.0f);+ c.pitch = glm::radians(-20.0f);+ const auto ends = axisGizmoEnds(glm::mat3(c.view()), glm::vec2(0.0f), 34.0f);+ for (int i = 0; i < 3; ++i) {+ // The near end of each axis is drawn bigger and more opaque than the same kind of end pointing away.+ AxisGizmoEnd near = ends[size_t(i)], far = near;+ near.depth = std::abs(near.depth);+ far.depth = -near.depth;+ if (near.depth > 0.05f) {+ CHECK(axisGizmoEndRadius(near, 1.0f) > axisGizmoEndRadius(far, 1.0f));+ CHECK(axisGizmoEndAlpha(near.depth) > axisGizmoEndAlpha(far.depth));+ }+ // A positive end (filled, lettered) is always bigger than a negative one (a ring) at the same depth.+ AxisGizmoEnd neg = ends[size_t(i)];+ neg.negative = true;+ CHECK(axisGizmoEndRadius(ends[size_t(i)], 1.0f) > axisGizmoEndRadius(neg, 1.0f));+ }+ CHECK(axisGizmoEndAlpha(-1.0f) >= 0.45f); // still visible from behind+}++TEST(axis_gizmo_disc_holds_every_end_at_every_size) {+ // The disc behind the gizmo (a drag there orbits) covers each end's circle, at every size and UI scale, so a+ // press on the gizmo either hits an end or lands on the disc.+ Camera c;+ for (float yaw : {0.0f, 30.0f, 90.0f, 135.0f})+ for (int size = 0; size < 3; ++size)+ for (float uiScale : {1.0f, 1.5f, 2.0f}) {+ c.yaw = glm::radians(yaw);+ c.pitch = glm::radians(-20.0f);+ const float unit = uiScale * axisGizmoScale(size);+ const glm::vec2 centre(300.0f, 300.0f);+ const auto ends = axisGizmoEnds(glm::mat3(c.view()), centre, kAxisGizmoLength * unit);+ for (const AxisGizmoEnd& e : ends)+ CHECK(glm::length(e.at - centre) + kAxisGizmoHitRadius * unit <= kAxisGizmoDisc * unit + 0.01f);+ CHECK(axisGizmoOnDisc(centre, kAxisGizmoDisc * unit, 300.0f + 44.0f * unit, 300.0f));+ CHECK(!axisGizmoOnDisc(centre, kAxisGizmoDisc * unit, 300.0f + 49.0f * unit, 300.0f));+ }+}diff --git a/tests/ui/view_axes.sfui b/tests/ui/view_axes.sfuinew file mode 100644index 00000000..fa425ae1--- /dev/null+++ b/tests/ui/view_axes.sfui@@ -0,0 +1,132 @@+# The corner view axes (Tony 11-06, "the view figure needs more distinguishing features"): filled X / Y / Z circles,+# smaller rings for the negative ends, far ends smaller and fainter, a soft disc behind them. A click on an end snaps+# to that view, a second click to the opposite one, a drag on the disc orbits; the exact view's name shows under it.+# Shots: dark and light backgrounds, UI scale 100 / 150 / 200 %, Small / Medium / Large, several views.+run ui_look look=classic layout=classic # written for the Classic look and the classic palette bar and shelves+run new_sphere subdivisions=4+key f+expect_value axis_gizmo_length == 34+expect_value axis_view == 2+shot front_dark_100_medium++# A click on +Z while looking from +Z: the back view; again on +Z (now pointing away): the front.+axis_click +z+expect_value axis_view == 5+expect_value camera_aligned == 1+expect_value camera_pitch == 0+shot back_dark_100_medium+axis_click +z+expect_value axis_view == 2+expect_value camera_yaw == 0++# +Y: the top; +Y again: the bottom; -Y (now facing you): the top again.+axis_click +y+expect_value axis_view == 1+expect_value camera_pitch == -90+shot top_dark_100_medium+axis_click +y+expect_value axis_view == 4+expect_value camera_pitch == 90+axis_click -y+expect_value axis_view == 1++# Every end from a three-quarter view snaps to its own side.+camera 35 -25+expect_value axis_view == -1+shot three_quarter_dark_100_medium+axis_hover +x+shot three_quarter_hover_x+axis_hover -z+shot three_quarter_hover_neg_z+axis_hover disc+shot three_quarter_hover_disc+axis_click -x+expect_value axis_view == 3+expect_value camera_yaw == -90+camera 35 -25+axis_click -z+expect_value axis_view == 5+camera 35 -25+axis_click +x+expect_value axis_view == 0++# A drag on the disc (clear of the ends) orbits: the view leaves the side view and turns.+axis_drag 40 0+expect_value axis_view == -1+expect_value camera_aligned == 0++shot after_disc_drag++# Sizes x UI scale: a click on an end still lands at every size.+camera 35 -25+click "Draw##palette.draw"+click "Small##view.gizmo_small"+key escape+shot three_quarter_dark_100_small+click "Draw##palette.draw"+click "Large##view.gizmo_large"+key escape+shot three_quarter_dark_100_large+axis_click +y+expect_value axis_view == 1+ui_scale 150+expect_value ui_scale == 150+camera 35 -25+click "Draw##palette.draw"+click "Medium##view.gizmo_medium"+key escape+shot three_quarter_dark_150_medium+axis_click -x+expect_value axis_view == 3+shot left_dark_150_medium+ui_scale 200+camera 35 -25+shot three_quarter_dark_200_medium+axis_click +z+expect_value axis_view == 2+shot front_dark_200_medium+click "Draw##palette.draw"+click "Small##view.gizmo_small"+key escape+camera 35 -25+shot three_quarter_dark_200_small+axis_click +x+expect_value axis_view == 0+click "Draw##palette.draw"+click "Large##view.gizmo_large"+key escape+camera 35 -25+shot three_quarter_dark_200_large+axis_drag -30 20+expect_value axis_view == -1++# A light background: the disc darkens instead, the name stays readable.+ui_scale 100+click "Draw##palette.draw"+click "Medium##view.gizmo_medium"+key escape+run set_background color=215,215,218+camera 35 -25+shot three_quarter_light_100_medium+axis_hover +y+shot three_quarter_light_hover_y+axis_click +y+expect_value axis_view == 1+shot top_light_100_medium+ui_scale 150+camera 35 -25+shot three_quarter_light_150_medium+ui_scale 200+axis_click +z+shot front_light_200_medium+expect_value axis_view == 2++# With the View Figure on, it sits below the axes and the view's name.+ui_scale 100+run set_background mode=gradient+click "Draw##palette.draw"+click "View Figure##draw.view_figure"+key escape+shot with_view_figure+view_figure_click+expect_value camera_aligned == 1