Fix engine-wide code review findings
CI / build-test (push) Failing after 1m7s

Collisions: init bucket heads to -1 (QueryAabb hung before the first
rebuild), reset query stamps on truncated QueryAabb (later queries
silently dropped entities), inside-origin raycasts hit at fraction 0 for
circles too, exactly-touching boxes now pair like touching circles.

Graphics: render into the letterbox viewport so the picture matches
ScreenToWorld/WorldToScreen instead of stretching; Y-sort by the
transform pivot rather than the quad center; lock-free snapshot
LayerRegistry (parallel submit read it unsynchronized); validate
InitialCapacity; warn when UseRenderer2D drops options of a later scene.

Core: scenes are explicitly single-use (re-loading threw silently
duplicated systems/entities before — now it throws), Scene.RegisterUnload
for per-scene resources, a switch requested during the reveal phase
covers again instead of hard-swapping, borderless fullscreen
(HardwareModeSwitch off), InputCapture service for input-suppressing
overlays, host disposes the transition renderer and IDisposable services
on shutdown.

Input: game input reads as released while InputCapture is held; mouse
position and wheel freeze so deltas stay zero.

DevConsole: holds InputCapture while open (typing no longer drives the
camera), Revision increments only under the lock, quoted command
arguments, history capped at 256.

UI: scene Desktop skips Myra input processing while the console is open
(clicks no longer fall through), is disposed on scene unload, and Myra
init no longer depends on a process-static flag.

Audio: validate channel count/sample rate before stopping the previous
track, empty looped oggs no longer hang FillBuffers, the instance stops
when a non-looping track drains (IsPlaying was stuck true).

Atlases: metadata v2 stores per-source size+mtime snapshots, so
timestamp-preserving copies and renames invalidate correctly; loader
checks the version and disposes pages on partial load failure; shared
pages never exceed a non-POT MaxPageSize; oversized items pack first
onto exact-size pages instead of splitting an open shared page; the CLI
validates numeric options.

Assets.Generator: file names are escaped in XML docs and string
literals, members no longer collide with the enclosing class (CS0542),
and the Assets root is resolved against build_property.projectdir so
nested "Assets" directories do not shift region paths.

Pathfinding: queries throw when the grid was resized after construction;
generation stamps survive int overflow.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Leonid Pershin
2026-06-11 21:18:08 +03:00
co-authored by Claude Fable 5
parent 56f2a85478
commit 501d81e19f
35 changed files with 926 additions and 98 deletions
+17 -7
View File
@@ -54,9 +54,14 @@ public sealed class CollisionWorld
}
_cellSize = cellSize;
Array.Fill(_bucketHeads, -1); // пустой хэш до первого ребилда: обход бакета сразу завершается
}
/// <summary>Pairs found by the last rebuild.</summary>
/// <summary>
/// Pairs found by the last rebuild. Order is deterministic for identical registration
/// history; it may differ between sessions whose peak collider count differed
/// (the hash table only grows and its size affects bucket iteration order).
/// </summary>
public ReadOnlySpan<CollisionPair> Pairs => _pairs.AsSpan(0, _pairCount);
/// <summary>Colliders registered in the last rebuild.</summary>
@@ -134,6 +139,7 @@ public sealed class CollisionWorld
{
if (found == results.Length)
{
ResetQueryStamps(); // иначе следующий запрос пропустит помеченные записи
return found;
}
@@ -150,6 +156,8 @@ public sealed class CollisionWorld
/// <summary>
/// Casts a segment and returns the closest hit among colliders whose
/// <see cref="Collider.Layer"/> intersects <paramref name="mask"/>.
/// A ray starting inside a collider hits it at fraction 0. Linear scan over all
/// registered colliders — fine for occasional rays, not for thousands per tick.
/// </summary>
public bool Raycast(Vector2 from, Vector2 to, out RaycastHit hit, uint mask = uint.MaxValue)
{
@@ -280,7 +288,9 @@ public sealed class CollisionWorld
if (a.Shape == ColliderShape.Box && b.Shape == ColliderShape.Box)
{
return a.Aabb.Intersects(b.Aabb);
// Включительно (касание = пара) — единообразно с кругами; RectF.Intersects строгий.
return a.Aabb.Left <= b.Aabb.Right && b.Aabb.Left <= a.Aabb.Right &&
a.Aabb.Top <= b.Aabb.Bottom && b.Aabb.Top <= a.Aabb.Bottom;
}
// circle vs box
@@ -305,6 +315,11 @@ public sealed class CollisionWorld
var b = 2f * Vector2.Dot(f, d);
var c = Vector2.Dot(f, f) - radius * radius;
if (c <= 0f)
{
return true; // старт внутри круга — попадание в точке старта (как и у AABB)
}
var discriminant = b * b - 4f * a * c;
if (discriminant < 0f)
{
@@ -313,11 +328,6 @@ public sealed class CollisionWorld
var sqrt = MathF.Sqrt(discriminant);
var t = (-b - sqrt) / (2f * a);
if (t < 0f)
{
t = (-b + sqrt) / (2f * a); // старт внутри круга
}
if (t < 0f || t > 1f)
{
return false;