diff --git a/Assets/Scripts/ServerShared/DrawAhead.cs b/Assets/Scripts/ServerShared/DrawAhead.cs index 3f2c870bc..159e51c44 100644 --- a/Assets/Scripts/ServerShared/DrawAhead.cs +++ b/Assets/Scripts/ServerShared/DrawAhead.cs @@ -30,8 +30,9 @@ public static class DrawAhead public static float FloaterHeight(Zone zone, GameplaySettings settings, float2 planar, float lead) => Height(zone, planar, lead) + settings.FloaterLayerHeight; // A belt rock's drawn position (ruling asteroids-on-floater-layer): its planar pose at the drawn time, on the floater layer over the field. - // Open question asteroid-clearance: the rock centre sits at the layer. ChunkHeight is the one line that changes if its top should (pose.w is the radius). - public static float ChunkHeight(Zone zone, GameplaySettings settings, float4 pose, float lead) => FloaterHeight(zone, settings, pose.xy, lead); + // Ruling asteroid-tops-at-layer: the rock's top sits at the layer, so its centre is a drawn radius below it. pose.w is that radius: + // the renderer scales the unit rock mesh by it. + public static float ChunkHeight(Zone zone, GameplaySettings settings, float4 pose, float lead) => FloaterHeight(zone, settings, pose.xy, lead) - pose.w; public static float3 Chunk(Zone zone, GameplaySettings settings, ChunkId chunk, float lead) { diff --git a/tests/Aetheria.Shared.Tests/DrawnPoseTests.cs b/tests/Aetheria.Shared.Tests/DrawnPoseTests.cs index 8ed638905..33b37f44e 100644 --- a/tests/Aetheria.Shared.Tests/DrawnPoseTests.cs +++ b/tests/Aetheria.Shared.Tests/DrawnPoseTests.cs @@ -349,9 +349,10 @@ public sealed class DrawnPoseTests : IDisposable } // The reticle (DrawAhead.Chunk) and the renderer's per-rock instance (DrawAhead.ChunkHeight on EvaluateBelt's drawn pose) - // are one height: the field at the rock's planar position at the drawn time, plus the floater layer. Ruling asteroids-on-floater-layer. + // are one height: the field at the rock's planar position at the drawn time, plus the floater layer, less its drawn radius, so its top + // is at the layer. Rulings asteroids-on-floater-layer, asteroid-tops-at-layer. [Fact] - public void AChunkIsDrawnOnTheFloaterLayerOverTheField() + public void AChunkIsDrawnWithItsTopOnTheFloaterLayerOverTheField() { var w = Build(); Step(w, 1f / 60f, 301); @@ -367,7 +368,11 @@ public sealed class DrawnPoseTests : IDisposable var reticle = DrawAhead.Chunk(w.Zone, settings, new ChunkId(w.Belt, i), lead); var field = FieldAt(w, drawn[i].xy, time); AssertNear(drawn[i].xy, reticle.xz, 1e-3f, $"chunk {i} reticle xz"); - Assert.Equal(field + FloaterLayerHeight, reticle.y, 3); + var radius = w.Zone.ChunkRadius(new ChunkId(w.Belt, i)); + Assert.True(radius > 2f, $"chunk {i} has a radius that any scaling of it would move"); + Assert.Equal(radius, drawn[i].w, 4); + Assert.Equal(field + FloaterLayerHeight - radius, reticle.y, 3); + Assert.Equal(field + FloaterLayerHeight, reticle.y + radius, 3); Assert.Equal(reticle.y, DrawAhead.ChunkHeight(w.Zone, settings, drawn[i], lead), 4); if (abs(field) > 1f) deep++; }