6.6 KiB
Here is the revised architectural specification incorporating your exact adjustments for your architect agent:
Architectural Spec: Dual-Layer Prop Scaling System (Revised)
Status: implemented and user verified (2026-09-22).
This specification outlines the architecture for supporting prop scaling across two layers: permanent template scaling in the Prop Editor and contextual instance scaling in the Sandbox Stage.
1. System Architecture & Division of Responsibilities
┌─────────────────────────────────────────────────────────┐
│ PROP EDITOR (Phase 9) │
│ • Permanent template geometry mutation │
│ • Vertex & radius coordinate transformations │
│ • Anchor offset auto-scaling │
│ • Stickman guide silhouette (Default: OFF) │
└────────────────────────────┬────────────────────────────┘
│ Saves .prop file
▼
┌─────────────────────────────────────────────────────────┐
│ SANDBOX STAGE (Phase 10) │
│ • Contextual instance scaling via corner gizmos only │
│ • Locked aspect ratio (uniform scaling) │
│ • Physics mass decoupled from visual scale │
└────────────────────────────┴────────────────────────────┘
| Layer | Target Entity | Operation Type | Scaling Behavior | Data Persistence |
|---|---|---|---|---|
| Prop Editor | Template Asset (.prop) |
Permanent geometry mutation | Bakes scale into raw vector vertices, radii, and anchor offsets. | Persists into .prop file. |
| Sandbox Stage | Object Instance (PropBlock) |
Node transform scaling | Pure gizmo scaling with locked aspect ratio. | Persists into .scene file (scale: { x, y }). |
2. Prop Editor Implementation (Template Sizing)
A. Document Geometry Scale Tool
-
Scope: Modifies raw geometry arrays (
pointsfor polygons/lines,radiusfor circles) in the shape stack. -
Anchor Recalculation: All registered anchor offset positions (
x,y) automatically multiply by the scale factor so grip, pivot, and emitter points maintain exact relative alignment. -
Normalize Size Action: Adds a canvas action (📏 Normalize Size) alongside 🎯 Center Prop that computes the bounding box union of all shapes and uniformly scales the document to fit within a standard
96 \times 96\text{ px}canvas box.
B. Stickman Visual Reference Silhouette
-
Overlay Guide: Renders a semi-transparent 1:1 Stickman figure silhouette on the canvas background for scale context against full character rigs (
\approx 336 \times 940\text{ px}). -
Default State: Toggleable via the UI / canvas controls and defaults to OFF.
-
View Aid Only: Non-selectable, non-interactive visual guide that is excluded from
.propfile serialization.
3. Sandbox Stage Implementation (Instance Sizing)
A. Gizmo-Driven Scaling (No UI SpinBoxes / No Presets)
-
Corner Scale Handles: Extends
StageGizmosinEDITmode to render corner cross handles on selected prop bounding boxes. -
Aspect Ratio Locking: Dragging any corner handle scales the object while strictly locking the aspect ratio (uniform scaling).
-
Streamlined UI: No numeric scale SpinBoxes or preset buttons (
S/M/L) are added to the stage UI; all scaling is performed intuitively directly on the canvas via gizmo manipulation.
B. Mode Lifecycle & Physics Rules
-
Decoupled Mass Contract: Scaling a prop adjusts node visual geometry (
Polygon2D,Line2D) and collision bounds (CollisionPolygon2D,CollisionShape2D). RigidBodymassremains independent, governed strictly by the assigned Material Preset (Wood, Metal, Rubber, Cardboard). -
Lifecycle State Handling (
PLAY\rightarrowEDIT): Transitioning fromPLAYback toEDITmode restores the authoredpositionandrotationand zeroes linear/angular velocity, but does not reset or alter the node scale. The authored scale set during editing is retained as-is.
4. Implementation Roadmap
- Phase A (Prop Editor Tooling):
-
Implement document-wide geometry and anchor scaling logic in
PropEditor. -
Add the toggleable Stickman Reference Silhouette (default OFF) and "Normalize Size" canvas button.
- Phase B (Sandbox Gizmo Scaling):
-
Extend
StageGizmoswith corner scale handles that lock aspect ratio during drag operations. -
Ensure
StageSelectionAABB bounding boxes recalculate accurately to account for scaled instances.
- Phase C (Persistence & Verification):
-
Verify scene save/load serialization of scaled
PropBlockinstances. -
Confirm that
EDIT\rightarrowPLAY\rightarrowEDITmode switches restore authored position/rotation while keeping object scale intact.
5. Verified final Prop Editor controls
The Arrange mode top bar presents these controls in order:
- Transform Whole Prop
- Normalize Size
- Center Prop
- Show Stickman Guide
The numeric scale textbox and Apply Scale button were removed. Transform Whole Prop previews and commits whole-document move, rotation, and uniform resize gestures around the canonical origin. Grid Snap rounds move deltas, Ctrl snaps rotation to 15-degree increments, editable anchors follow the geometry, and Esc cancels an active preview. Normalize Size fits the shape-point bounds to a 96 px maximum dimension. Transform Whole Prop and Normalize Size are hidden in Reshape and Attach; Center Prop and Show Stickman Guide remain available in all modes.
Sandbox instance scaling remains a separate prop-only uniform corner-gizmo operation. It retains the authored scene scale, preset-governed mass, and PLAY-to-EDIT position/rotation restoration behavior.