Cut 5d-2: ParticlePool + OmniLight3D[4], CameraJuiceState, Hud hit-markers & vignette, unified SimEvent drain
This commit is contained in:
parent
7f811c3011
commit
323c02cf8d
12 changed files with 2294 additions and 320 deletions
|
|
@ -1227,36 +1227,157 @@ public partial class Smoke : Node
|
|||
$"Expected zero StandardMaterial3D duplicates, got {VehicleVisualInstance.PerfMaterialDupCount}");
|
||||
}
|
||||
|
||||
// 12. Finding 2: Monotonic TracerEvent.Id spawns muzzle flash + recoilless smoke puffs ONCE regardless of TTL or FPS
|
||||
// 12. Cut 5d-2: Unified SimEvent -> ParticlePool idempotency + OmniLight3D[4] cap + CameraJuice zero-idle-jitter + Hud X-flash & vignette
|
||||
{
|
||||
var tracers = _main.Session.ViewState.Tracers;
|
||||
tracers.Clear();
|
||||
_main.Arena.Sync(_main.Session, 1.69f, 0f);
|
||||
int vfxBefore = _main.Arena.TransientVfxCount;
|
||||
var particles = _main.Arena.Particles;
|
||||
particles.ClearAll();
|
||||
int beforeCount = particles.ActiveParticleCount;
|
||||
|
||||
int tracerId = _main.Session.ViewState.AllocateTracerId();
|
||||
var localC = _main.Session.LocalContender;
|
||||
Vector3 pPos = new(localC.X, localC.Y, localC.Z);
|
||||
tracers.Add(new TracerEvent(
|
||||
pPos.X, pPos.Y + 1f, pPos.Z,
|
||||
pPos.X + 20f, pPos.Y + 1f, pPos.Z,
|
||||
0xFFEEDDAAu,
|
||||
0.03f, // Low TTL (< old 0.085f threshold) simulating <=30 FPS decay
|
||||
WeaponVisualClass.Explosive,
|
||||
"recoilless",
|
||||
tracerId));
|
||||
var shotEvent = new ShotFiredEvent
|
||||
{
|
||||
TracerId = tracerId,
|
||||
IsSpectatorShooter = false,
|
||||
ShooterId = _main.Session.LocalContenderId,
|
||||
StartX = pPos.X,
|
||||
StartY = pPos.Y + 1f,
|
||||
StartZ = pPos.Z,
|
||||
EndX = pPos.X + 20f,
|
||||
EndY = pPos.Y + 1f,
|
||||
EndZ = pPos.Z,
|
||||
ColorRgba = 0xFFEEDDAAu,
|
||||
Ttl = 0.03f,
|
||||
WeaponClass = (byte)WeaponVisualClass.Explosive,
|
||||
WeaponId = "recoilless"
|
||||
};
|
||||
|
||||
_main.Arena.Sync(_main.Session, 1.70f, 0f);
|
||||
int vfxAfterFirst = _main.Arena.TransientVfxCount;
|
||||
Check(vfxAfterFirst == vfxBefore + 5 && _main.Arena.LastSpawnedTracerId == tracerId,
|
||||
$"Expected recoilless tracer #{tracerId} with Ttl=0.03 to spawn 1 muzzle + 4 smoke puffs (+5 VFX), got +{vfxAfterFirst - vfxBefore} (lastId={_main.Arena.LastSpawnedTracerId})");
|
||||
var simBatch = new List<ISimEvent> { shotEvent };
|
||||
var emptyFootsteps = new List<FootstepPulse>();
|
||||
_main.Arena.ConsumeEvents(_main.Session, simBatch, emptyFootsteps, 0f, _main.SampleCurrentMapGroundTint);
|
||||
int afterFirst = particles.ActiveParticleCount;
|
||||
Check(afterFirst == beforeCount + 5,
|
||||
$"Expected recoilless ShotFiredEvent #{tracerId} to spawn 1 muzzle starburst + 4 smoke puffs (+5 particles), got +{afterFirst - beforeCount}");
|
||||
|
||||
// Re-sync with dt=0 (simulating >=60/120 FPS seeing the same TracerEvent again): must NOT re-emit
|
||||
_main.Arena.Sync(_main.Session, 1.71f, 0f);
|
||||
_main.Arena.Sync(_main.Session, 1.72f, 0f);
|
||||
Check(_main.Arena.TransientVfxCount == vfxAfterFirst,
|
||||
$"Expected same TracerEvent #{tracerId} across repeated render frames to spawn VFX once, got {vfxAfterFirst} -> {_main.Arena.TransientVfxCount}");
|
||||
tracers.Clear();
|
||||
// Re-consume with dt=0: idempotent TracerId dedupe must NOT double-emit
|
||||
_main.Arena.ConsumeEvents(_main.Session, simBatch, emptyFootsteps, 0f, _main.SampleCurrentMapGroundTint);
|
||||
_main.Arena.ConsumeEvents(_main.Session, simBatch, emptyFootsteps, 0f, _main.SampleCurrentMapGroundTint);
|
||||
Check(particles.ActiveParticleCount == afterFirst,
|
||||
$"Expected duplicate ShotFiredEvent #{tracerId} across dt=0 frames to spawn once, got {afterFirst} -> {particles.ActiveParticleCount}");
|
||||
|
||||
// OmniLight3D[4] pool strictly capped at <= 4 active lights even under 12 simultaneous flashes
|
||||
particles.ClearAll();
|
||||
for (int f = 0; f < 12; f++)
|
||||
{
|
||||
particles.TriggerFlashLightForTest(
|
||||
pPos + new Vector3(f * 2f, 1.5f, 0f),
|
||||
new Color(1f, 0.7f, 0.3f),
|
||||
3.0f,
|
||||
12f,
|
||||
0.15f,
|
||||
priority: f);
|
||||
}
|
||||
particles.AdvanceAndCommit(0f);
|
||||
Check(particles.FlashLightPoolSize == 4 && particles.ActiveFlashLightCount <= 4 && particles.PeakFlashLightCount <= 4,
|
||||
$"Expected OmniLight3D pool capped at <= 4, got active={particles.ActiveFlashLightCount} peak={particles.PeakFlashLightCount}");
|
||||
|
||||
// Far walker footstep pulse (>70m static LOD, <=110m) still emits terrain-tinted dust in ParticlePool
|
||||
particles.ClearAll();
|
||||
var farStep = new FootstepPulse(
|
||||
IsContender: true,
|
||||
EntityId: 99,
|
||||
LegIndex: 0,
|
||||
ChassisId: "bastion",
|
||||
MassKg: 4600f,
|
||||
LoadG: 1.25f,
|
||||
WorldPos: new System.Numerics.Vector3(pPos.X + 85f, pPos.Y, pPos.Z));
|
||||
_main.Arena.ConsumeEvents(_main.Session, Array.Empty<ISimEvent>(), new[] { farStep }, 0f, _main.SampleCurrentMapGroundTint);
|
||||
Check(particles.ActiveParticleCount >= 3,
|
||||
$"Expected far walker (85m > 70m static LOD) footstep to emit dust puffs, got {particles.ActiveParticleCount}");
|
||||
particles.ClearAll();
|
||||
|
||||
// CameraJuiceState zero-idle-jitter & ComputeCenterScreenAim invariance under trauma
|
||||
var juice = _main.CameraJuice;
|
||||
juice.Reset();
|
||||
Check(juice.IsIdle, "Expected CameraJuiceState idle after Reset");
|
||||
var (aimIdleX, aimIdleY, aimIdleZ) = _main.ProbeCenterScreenAim();
|
||||
juice.ConsumeEvents(simBatch, _main.Session.LocalContenderId, new System.Numerics.Vector3(pPos.X, pPos.Y, pPos.Z));
|
||||
juice.Update(0.016f, 0f, false);
|
||||
Check(!juice.IsIdle && juice.RecoilPitchRad > 0f, "Expected CameraJuiceState recoil after local recoilless shot");
|
||||
var (aimJuiceX, aimJuiceY, aimJuiceZ) = _main.ProbeCenterScreenAim();
|
||||
Check(MathF.Abs(aimIdleX - aimJuiceX) < 1e-4f && MathF.Abs(aimIdleY - aimJuiceY) < 1e-4f && MathF.Abs(aimIdleZ - aimJuiceZ) < 1e-4f,
|
||||
"Expected ComputeCenterScreenAim to remain strictly invariant during camera recoil/trauma");
|
||||
juice.Reset();
|
||||
|
||||
// Hud reticle hit-marker X-flash + hud_vignette.gdshader falsification
|
||||
_main.Hud.ResetFeedback();
|
||||
Check(!_main.Hud.HasActiveHitMarker && !_main.Hud.IsVignetteVisible,
|
||||
"Expected HUD hit-marker & vignette inactive when cool and unhit");
|
||||
|
||||
// Non-local shooter must produce ZERO reticle hit-marker flash
|
||||
var aiHit = new HitImpactEvent
|
||||
{
|
||||
EventId = 8801,
|
||||
ShooterId = _main.Session.LocalContenderId + 1,
|
||||
IsContenderShooter = true,
|
||||
TargetKind = (byte)HitTargetKind.Contender,
|
||||
TargetId = _main.Session.LocalContenderId + 2,
|
||||
ArmorDamage = 18f,
|
||||
CoreDamage = 0f,
|
||||
Killed = false
|
||||
};
|
||||
_main.Hud.ConsumeEvents(new ISimEvent[] { aiHit }, _main.Session.LocalContenderId, 1.0f, 0.2f);
|
||||
Check(!_main.Hud.HasActiveHitMarker, "Expected AI/other shooter hit NOT to trigger local reticle hit-marker");
|
||||
|
||||
// Local armor hit -> Armor X-flash
|
||||
var localArmorHit = new HitImpactEvent
|
||||
{
|
||||
EventId = 8802,
|
||||
ShooterId = _main.Session.LocalContenderId,
|
||||
IsContenderShooter = true,
|
||||
TargetKind = (byte)HitTargetKind.Contender,
|
||||
TargetId = _main.Session.LocalContenderId + 1,
|
||||
ArmorDamage = 22f,
|
||||
CoreDamage = 0f,
|
||||
Killed = false
|
||||
};
|
||||
_main.Hud.ConsumeEvents(new ISimEvent[] { localArmorHit }, _main.Session.LocalContenderId, 1.0f, 0.2f);
|
||||
Check(_main.Hud.HasActiveHitMarker && _main.Hud.ActiveHitMarkerKind == HitMarkerKind.Armor,
|
||||
$"Expected Armor hit-marker, got {_main.Hud.ActiveHitMarkerKind}");
|
||||
|
||||
// Local core hit -> Core X-flash
|
||||
var localCoreHit = new HitImpactEvent
|
||||
{
|
||||
EventId = 8803,
|
||||
ShooterId = _main.Session.LocalContenderId,
|
||||
IsContenderShooter = true,
|
||||
TargetKind = (byte)HitTargetKind.Contender,
|
||||
TargetId = _main.Session.LocalContenderId + 1,
|
||||
ArmorDamage = 10f,
|
||||
CoreDamage = 14f,
|
||||
Killed = false
|
||||
};
|
||||
_main.Hud.ConsumeEvents(new ISimEvent[] { localCoreHit }, _main.Session.LocalContenderId, 1.0f, 0.2f);
|
||||
Check(_main.Hud.HasActiveHitMarker && _main.Hud.ActiveHitMarkerKind == HitMarkerKind.Core,
|
||||
$"Expected Core hit-marker, got {_main.Hud.ActiveHitMarkerKind}");
|
||||
|
||||
// Local kill + overheat -> Kill double-X + vignette active
|
||||
var localKillHit = new HitImpactEvent
|
||||
{
|
||||
EventId = 8804,
|
||||
ShooterId = _main.Session.LocalContenderId,
|
||||
IsContenderShooter = true,
|
||||
TargetKind = (byte)HitTargetKind.Contender,
|
||||
TargetId = _main.Session.LocalContenderId + 1,
|
||||
ArmorDamage = 0f,
|
||||
CoreDamage = 35f,
|
||||
Killed = true
|
||||
};
|
||||
_main.Hud.ConsumeEvents(new ISimEvent[] { localKillHit }, _main.Session.LocalContenderId, 1.0f, 0.92f);
|
||||
Check(_main.Hud.HasActiveHitMarker && _main.Hud.ActiveHitMarkerKind == HitMarkerKind.Kill && _main.Hud.IsVignetteVisible,
|
||||
$"Expected Kill hit-marker & overheat vignette active, got kind={_main.Hud.ActiveHitMarkerKind} vig={_main.Hud.IsVignetteVisible}");
|
||||
_main.Hud.ResetFeedback();
|
||||
}
|
||||
|
||||
// 13. Loopback IClientArenaSession check: ServerMatchHost + RemoteArenaSession join + snapshot sync
|
||||
|
|
@ -1655,7 +1776,15 @@ public partial class Smoke : Node
|
|||
|
||||
float disp = MathF.Sqrt((player.X - startX) * (player.X - startX) + (player.Z - startZ) * (player.Z - startZ));
|
||||
Check(disp > 1.5f, $"Expected player displacement > 1.5m on Sion after 30 frames, got {disp:F2}m");
|
||||
GD.Print($"SMOKE INFO: Sion verified (chunks={_main.SionMap.TerrainChunkCount}, tiles={_main.SionMap.BuildingTileCount}, lod1={_main.SionMap.ActiveLod1TileCount}, lod2={_main.SionMap.ActiveLod2TileCount}, disp={disp:F2}m)");
|
||||
|
||||
Color inBoundsTint = _main.SionMap.SampleGroundTint(player.X, player.Z);
|
||||
Color outBoundsTint = _main.SionMap.SampleGroundTint(9999f, 9999f);
|
||||
Check(float.IsFinite(inBoundsTint.R) && float.IsFinite(inBoundsTint.G) && float.IsFinite(inBoundsTint.B) && inBoundsTint.R > 0.1f,
|
||||
$"Expected valid Sion SampleGroundTint at player pos, got {inBoundsTint}");
|
||||
Check(MathF.Abs(outBoundsTint.R - 0.56f) < 0.01f && MathF.Abs(outBoundsTint.G - 0.53f) < 0.01f,
|
||||
$"Expected neutral alpine fallback tint outside Sion bounds, got {outBoundsTint}");
|
||||
|
||||
GD.Print($"SMOKE INFO: Sion verified (chunks={_main.SionMap.TerrainChunkCount}, tiles={_main.SionMap.BuildingTileCount}, lod1={_main.SionMap.ActiveLod1TileCount}, lod2={_main.SionMap.ActiveLod2TileCount}, disp={disp:F2}m, tint=({inBoundsTint.R:F2},{inBoundsTint.G:F2},{inBoundsTint.B:F2}))");
|
||||
}
|
||||
|
||||
private static int CountPremulViolations(Image img, float tolerance)
|
||||
|
|
|
|||
Loading…
Reference in a new issue