Fix example Rotate/Scale snap fields (scalar InputFloat returns value first); DragFloat fields; test all ops

This commit is contained in:
4DBug committed 2026-10-17 06:27:56 -05:00
1 parent e29213986e
commit 3723e1302a
2 files changed
+18 -7

No files matched your search

+7 -7
View File
@@ -40,9 +40,9 @@ local function EditTransform(Matrix)
local Tr, Rt, Sc = {}, {}, {}
ImGuizmo.DecomposeMatrixToComponents(Matrix, Tr, Rt, Sc)
local Edited = ImGui.InputFloat3("Tr", Tr)
Edited = ImGui.InputFloat3("Rt", Rt) or Edited
Edited = ImGui.InputFloat3("Sc", Sc) or Edited
local Edited = ImGui.DragFloat3("Tr", Tr, 0.1)
Edited = ImGui.DragFloat3("Rt", Rt, 1) or Edited
Edited = ImGui.DragFloat3("Sc", Sc, 0.01) or Edited
if Edited then ImGuizmo.RecomposeMatrixFromComponents(Tr, Rt, Sc, Matrix) end
if Operation ~= OP.SCALE then
@@ -54,11 +54,11 @@ local function EditTransform(Matrix)
_, UseSnap = ImGui.Checkbox("Snap", UseSnap)
ImGui.SameLine()
if Operation == OP.ROTATE then
_, AngleSnap = ImGui.InputFloat("Angle Snap", AngleSnap)
AngleSnap = ImGui.DragFloat("Angle Snap", AngleSnap, 1)
elseif Operation == OP.SCALE then
_, ScaleSnap = ImGui.InputFloat("Scale Snap", ScaleSnap)
ScaleSnap = ImGui.DragFloat("Scale Snap", ScaleSnap, 0.01)
else
ImGui.InputFloat3("Snap Value", Snap)
ImGui.DragFloat3("Snap Value", Snap, 0.1)
end
_, BoundSizing = ImGui.Checkbox("Bound Sizing", BoundSizing)
@@ -66,7 +66,7 @@ local function EditTransform(Matrix)
ImGui.PushID(3)
_, BoundSizingSnap = ImGui.Checkbox("Bound Snap", BoundSizingSnap)
ImGui.SameLine()
ImGui.InputFloat3("Snap", BoundsSnap)
ImGui.DragFloat3("Snap", BoundsSnap, 0.01)
ImGui.PopID()
end
_, ShowGrid = ImGui.Checkbox("Show Grid", ShowGrid)
+11
View File
@@ -11,4 +11,15 @@ cat tests/example_prelude.luau examples/roblox/main.client.luau > "$ex"
out=$(python3 tools/core/tools/test/run.py --module ImGuizmo=ImGuizmo.lua --main "$ex" --frames 30 --roblox 2>&1)
rm -f "$ex"
if echo "$out" | grep -q "^OK"; then echo "PASS example"; else echo "FAIL example"; echo "$out" | tail -20; fail=1; fi
# every operation x snap x bounds (random mouse input drags over the gizmo)
for op in TRANSLATE ROTATE SCALE UNIVERSAL; do for snap in false true; do for bounds in false true; do
ex=$(mktemp --suffix=.luau)
cat tests/example_prelude.luau examples/roblox/main.client.luau | sed \
-e "s/^local Operation, Mode = OP.TRANSLATE/local Operation, Mode = OP.$op/" \
-e "s/^local UseSnap, ShowGrid = false/local UseSnap, ShowGrid = $snap/" \
-e "s/^local BoundSizing, BoundSizingSnap = false, false/local BoundSizing, BoundSizingSnap = $bounds, $bounds/" > "$ex"
out=$(python3 tools/core/tools/test/run.py --module ImGuizmo=ImGuizmo.lua --main "$ex" --frames 30 --roblox 2>&1)
rm -f "$ex"
if echo "$out" | grep -q "^OK"; then echo "PASS example $op snap=$snap bounds=$bounds"; else echo "FAIL example $op snap=$snap bounds=$bounds"; echo "$out" | tail -20; fail=1; fi
done; done; done
exit $fail