6 Commits
Author SHA1 Message Date
EmilandClaude Sonnet 5 cd8f221ddd Fix real bugs from independent review (docs/review-handoff.md)
A second AI session read the whole codebase in parallel (read-only, no
code changes) and left a handoff doc. Addressed the correctness findings:

- PhysicsWorld.Sync's early return compared _bodies.Count to live.Count,
  not their contents — same size, different membership (destroy one
  tracked GameObject, gain one untracked-because-no-collider one; or any
  Restore where the scene has both a Rigidbody+collider object and a
  Rigidbody-without-one) skipped cleanup entirely, leaking the native
  Box3D body forever. Fixed by checking the actual stale set. Two new
  regression tests reproduce the review's own two scenarios via a new
  Lingua_GetBodyCount native export, asserting on the native table's own
  count rather than PhysicsWorld's C#-side bookkeeping.
- TryCreateBody stored handle -1 (native shim refused: invalid world, or
  its 8192-slot body table full) as if it were real — every later
  GetBodyTransform on it silently teleported the GameObject to the
  origin with a degenerate rotation, no error anywhere. Now checked and
  warned once, same as the missing-collider case.
- PluginHost.Load didn't roll back anything when Configure threw partway
  through: Schedule.Add/Events.Subscribe registrations it already made
  stayed forever, and its ALC was never unloaded — neither loaded (no
  _loaded entry) nor cleanly unloadable. Fixed with try/catch: best-effort
  Shutdown (the only thing that knows which services this plugin
  provided), RemoveAllFrom on both Schedule and EventBus, best-effort ALC
  unload, rethrow. New fixture plugin (sandbox.failing-configure, mirrors
  sandbox.echo's own real-load pattern) registers a system against a
  shared Ping component then throws, so FailedConfigureRollbackTests can
  assert the dangling system actually stops firing — an earlier version
  tried to prove this via AssemblyLoadContext.All instead, which passed
  even against the deliberately-reverted buggy code (the ALC turned out
  to get collected either way once its only references went out of
  scope); watching the dangling system is what actually distinguishes
  rolled-back from not, confirmed by deliberately reverting the fix and
  watching this specific test fail before restoring it.
- Engine.Host's "r <id>" left a plugin unloaded on a failed reload with
  no honest indication of that, and retrying threw "not loaded" instead
  of ever reaching Load again. Added PluginHost.IsLoaded so the handler
  only calls Unload when there's something to unload, and the failure
  message now says the plugin is unloaded, not just "failed."
- AssetService.ReloadWithRetry's `when (attempt < 4)` guard meant the
  5th and final IOException fell out of the loop and propagated from a
  discarded fire-and-forget Task — no log, no event, nothing. Now logged.
- EditorState.Selected kept pointing at a GameObject Restore had already
  destroyed after ExitPlay, so Inspector/gizmo would silently keep
  editing something no longer in the world. EditorPlugin.DrawUi now
  compares IsPlaying against its own previous frame (not just reacting to
  the Stop button) so this is caught whether Play was exited via the
  button or the "stop" stdin command — the same stdin-vs-real-control gap
  already hit once earlier this session — and re-resolves the selection
  by name.
- README.md and kernel-contract.md's Event Bus/Time rows had fallen a
  milestone behind (still said "no asset system yet" and "no fixed-step
  accumulator yet" after both shipped).

Full suite: 98 tests.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N1qPfzq8TDCUMFMV3UwV5N
2026-09-02 20:57:08 +03:00
EmilandClaude Sonnet 5 e0e6c1d503 M3: real 3D translate gizmo — the "полноценный 3D-пайплайн" it was chosen for
TranslateGizmo draws three axis handles at the selected GameObject's
world position by projecting real 3D points through the real camera's
View/Projection (GizmoMath.WorldToScreen) onto ImGui's foreground draw
list. Nothing OpenGL-side draws lines yet, so this isn't 3D geometry
in the GL sense — but it IS driven by the actual camera matrices, which
is what the earlier scoped-2D-vs-full-3D-pipeline choice was actually
about: a handle dragged in screen space has to map onto a real 3D axis,
and that only means something once there's a real camera to project
through. The screenshot below shows exactly that — the axes aren't
screen-perpendicular, because the camera at (0,3,6) looking at the
origin means they shouldn't be.

Dragging a handle re-projects the mouse delta onto the axis's own
screen-space direction (GizmoMath.ProjectDragOntoAxis) and writes the
result back through GizmoMath.WorldToLocalPosition, which inverts the
parent's WorldMatrix rather than writing LocalPosition directly — a
parent with non-identity scale or rotation means "move 1 world unit"
and "add 1 to LocalPosition" are different amounts, and
samples/WindowDemo's ChildQuad (parented under a (2,2,1)-scaled Quad)
is exactly that case.

Split the actual math into GizmoMath (Engine.Editor.Contracts, no GL/
ImGui/mouse dependency) so it's unit-testable without a window or a real
mouse — neither exists in a headless test run, and dragging is exactly
the kind of interaction that's easy to get subtly wrong (screen-space
ratio direction, perspective sign, parent-scale correctness) without
something to check it against beyond eyeballing a screenshot. New
Engine.Editor.Tests project, 8 tests: screen-center projection, a
behind-camera point returning null, drag-ratio math on both an
axis-aligned and a diagonal screen direction, and the parent-scale/
parent-translation inverse-transform cases. All 8 passed on the first
run — including the non-uniform-scale case, the one most likely to be
subtly wrong.

Full suite: 73 tests, all green (65 previous + 8 new).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N1qPfzq8TDCUMFMV3UwV5N
2026-09-02 16:30:54 +03:00
EmilandClaude Sonnet 5 d7fcc20f5e M3: Play/Stop — Engine.Host stops ticking Stage.Update outside Play mode
IPlayModeController (Engine.Editor.Contracts) wraps IWorld.Snapshot()/
Restore() as EnterPlay/ExitPlay — the entire mechanism is that one
snapshot, per Snapshot's own doc comment. Exposed as a service, not just
something engine.editor's UI calls directly, so a future non-UI driver
(a test harness, a headless "play for N frames" CLI command) can drive
Play mode without depending on ImGui.

Engine.Host now looks up IPlayModeController once and checks IsPlaying
every frame before running Stage.Update: Edit mode still renders the
scene (so the view isn't frozen and the editor UI stays responsive) but
never ticks it, same distinction Unity draws between its Scene and Game
views. A project with no engine.editor loaded sees no behavior change —
Update runs unconditionally, same as before this existed.

Added "play"/"stop" as stdin commands alongside the existing "r" and
"screenshot", both real controls (not just test scaffolding) for driving
Play mode without a mouse — which is also how this got verified: an
interactive run sent "play", screenshotted, sent "stop", and the log
shows "Entered Play mode in 13.2ms", the real editor path exercising the
same under-100ms budget WorldSnapshotTests already proves at the kernel
level. The Lingua Editor panel's button/label flip Play/(Edit mode) to
Stop/(Playing) correctly across both screenshots.

Also fixes a real layout bug hit while verifying this: SetNextWindowPos
with ImGuiCond.FirstUseEver only applies with no prior imgui.ini entry
for that window title, and this project had already accumulated one from
earlier runs (all three panels stacked exactly on top of each other) —
gave each panel its own default position and .gitignore'd imgui.ini,
which is per-machine session state, not source.

Full suite still green: 65 tests.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N1qPfzq8TDCUMFMV3UwV5N
2026-09-02 16:26:23 +03:00
EmilandClaude Sonnet 5 20e0f8c53f M3: reflection-based Inspector — edit any component's fields live
InspectorPanel shows EditorState.Selected's Transform (Position/Scale as
draggable Vector3 widgets, Rotation shown read-only as a quaternion — a
real rotate control needs Euler conversion or a gizmo, out of scope for
just the Inspector) and, below it, every attached Component's public
fields via reflection. No per-component-type drawer code exists anywhere:
int/float/bool/string/Vector3 fields get a live-editable widget, anything
else falls back to a read-only ToString(), and a brand new component type
in any plugin gets an Inspector for free the moment it's attached — that
genericity is the entire reason to do this by reflection instead of a
registry.

Field edits write straight back through FieldInfo.SetValue, same gap
GameObject.AddComponent's doc comment already names: components are plain
fields with nothing to intercept a direct mutation, so this needs no
SystemAccessScope declaration any more than a hand-written `component.
Value = 5` would.

EditorPlugin now defaults EditorState.Selected to the first root once,
if nothing's been clicked yet — an empty Inspector on every fresh launch
had nothing useful to show. Verified by screenshot: Inspector displays
"Quad"'s real Position (0,0,0) and Scale (2,2,1), matching scene.json
exactly, plus a QuadRenderer header correctly showing "(no fields)" since
it has none yet.

Full suite still green: 65 tests.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N1qPfzq8TDCUMFMV3UwV5N
2026-09-02 16:21:26 +03:00
EmilandClaude Sonnet 5 bccb8c3ba7 M3: Hierarchy panel — click a GameObject to select it
HierarchyPanel walks IWorld.Roots/GameObject.Children recursively as
ImGui tree nodes, clicking one sets EditorState.Selected — the shared
selection the not-yet-built Inspector panel will read from the same
instance. PushID(go.GetHashCode()) scopes each node's ID by object
identity rather than name, since nothing stops two sibling GameObjects
sharing a Name and ImGui's default label-based IDs would otherwise merge
their open/selected state.

Also gives samples/WindowDemo/scene.json a child GameObject (offset,
half-scale, parented under Quad) — the existing scene only had one root,
nothing to show a tree with. Verified by screenshot: both quads render at
their correct composed WorldMatrix (the child visibly smaller and offset,
confirming parent/child composition is still correct through this
change), and Hierarchy lists "Quad" as a collapsible node.

Full suite still green: 65 tests.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N1qPfzq8TDCUMFMV3UwV5N
2026-09-02 16:19:36 +03:00
EmilandClaude Sonnet 5 4c67c2c905 M3: editor shell boots — ImGui overlay drawn over the live scene
Introduces engine.editor, a new plugin that renders an ImGui panel on top
of whatever the scene is drawing, using Silk.NET.OpenGL.Extensions.ImGui's
ImGuiController against the same GL context and window engine.render
already owns.

Getting the overlay to actually show up in the same frame (not delayed by
one, which is what happens if UI draws after SwapBuffers) required
splitting engine.render's Draw system: SwapBuffers moves out into its own
Present system on a new Stage.Present, run by Engine.Host after every
Stage.Render system — this plugin's Draw and, now, engine.editor's ImGui
pass — has drawn into the same back buffer. Stage.Present is the second
addition to the frame stage set (after FixedUpdate was scoped out for M4);
docs/kernel-contract.md already committed to the set being fixed and
kernel-defined, not plugin-extensible, and to only adding a stage when
there's something real to run in it — SwapBuffers already needed
somewhere to live once a second Render-stage system existed to race it.

Also extends IEngineInput with a Native IInputContext property, the same
escape hatch IEngineWindow.Native already is — ImGuiController's
constructor needs the raw Silk.NET input context directly.

Verified with a real windowed run: --screenshot after 5 frames shows the
"Lingua" ImGui panel (FPS/frame counters) correctly composited over the
still-correct 3D checkerboard quad from the M3 camera pipeline, in the
same frame. Full suite still green: 65 tests.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N1qPfzq8TDCUMFMV3UwV5N
2026-09-02 16:17:51 +03:00