diff --git a/tests/Ymir.Box3D.Soa.Tests/Box3DSoaCouplingTests.cs b/tests/Ymir.Box3D.Soa.Tests/Box3DSoaCouplingTests.cs
index 0438bcf..62e805f 100644
--- a/tests/Ymir.Box3D.Soa.Tests/Box3DSoaCouplingTests.cs
+++ b/tests/Ymir.Box3D.Soa.Tests/Box3DSoaCouplingTests.cs
@@ -394,10 +394,11 @@ public sealed class Box3DSoaCouplingTests
}
/// The 16 x 16 sheet cost scene with one body, plus fluid particles (r 1.25 cm) of XSPH viscosity poured on the sheet; ms per tick at 4 substeps.
- private static double PourCost(int fluid, float viscosity = 0f)
+ private static double PourCost(int fluid, float viscosity = 0f, int sensors = 0)
{
- using var world = new Box3DSoaWorld(64, gravityY: -G, particles: new Box3DSoaParticleCapacities(16 * 48 + 256 + fluid, 16 * 47 + 480, 16 * 46 + 448, 16, 600, 2, fluid));
+ using var world = new Box3DSoaWorld(64, gravityY: -G, particles: new Box3DSoaParticleCapacities(16 * 48 + 256 + fluid, 16 * 47 + 480, 16 * 46 + 448, 16, 600, 2, fluid, 0, sensors));
world.AddStaticBox(1, (0f, -0.5f, 0f), (20f, 0.5f, 20f));
+ for (var s = 0; s < sensors; s++) world.CreateSensors([(0, (0.35f + 0.1f * s, 1.8f, 0.15f), 0.15f)]); // body-frame y 1.8 is world 1.3: over the block
world.SetMaterial(0, 0f, 0, viscosity);
for (var c = 0; c < 16; c++)
Graph.Rope(world, Line((0f, 0.5f + 0.03f * c, 0.02f * (c % 4)), (Spacing, 0f, 0f), 48), ParticleMass, ParticleRadius, Box3DSoaPhase.Of((uint)(c + 1), true, true));
@@ -460,5 +461,24 @@ public sealed class Box3DSoaCouplingTests
Reading(line);
Assert.True(withs[pairs / 2] > 0);
}
+ // Four liquid sensors over the pour, paired the same way against the same scene without them (same binary, the order alternating): the sensors' increment.
+ {
+ var increments = new double[pairs];
+ var withs = new double[pairs];
+ var withouts = new double[pairs];
+ for (var k = 0; k < pairs; k++)
+ {
+ if (k % 2 == 0) { withouts[k] = PourCost(fluid); withs[k] = PourCost(fluid, 0f, 4); }
+ else { withs[k] = PourCost(fluid, 0f, 4); withouts[k] = PourCost(fluid); }
+ increments[k] = withs[k] - withouts[k];
+ }
+ Array.Sort(increments);
+ Array.Sort(withs);
+ Array.Sort(withouts);
+ var line = $"PARTICLE_COST {fluid} fluid particles, 4 liquid sensors r 15 cm over the pour, 4 substeps, {pairs} interleaved pairs: median {withs[pairs / 2]:F3} ms per tick with, {withouts[pairs / 2]:F3} without; sensor increment median {increments[pairs / 2]:F3} ms per tick (min {increments[0]:F3}, max {increments[pairs - 1]:F3})";
+ Console.Error.WriteLine(line);
+ Reading(line);
+ Assert.True(withs[pairs / 2] > 0);
+ }
}
}
diff --git a/tests/Ymir.Box3D.Soa.Tests/Box3DSoaSensorTests.cs b/tests/Ymir.Box3D.Soa.Tests/Box3DSoaSensorTests.cs
index e52b4b0..abcedfa 100644
--- a/tests/Ymir.Box3D.Soa.Tests/Box3DSoaSensorTests.cs
+++ b/tests/Ymir.Box3D.Soa.Tests/Box3DSoaSensorTests.cs
@@ -100,12 +100,13 @@ public sealed partial class Box3DSoaFluidTests
public void Sensor_follows_its_body_frame_and_the_pose_the_step_ends_in()
{
// Zero gravity, drops 0.5 m apart so none moves. The anchor is turned a quarter about z, so its body-frame point (0.3, 0, 0) lies at world (x, y + 0.3, z) over it,
- // and it runs 0.5 m a tick along x: at the end of tick s it is over the drop at x 0.5 s. Decoys sit where an unrotated frame (or the pose a substep earlier) would look.
+ // and it runs 0.5 m a tick along x: at the end of tick s it is over x 0.5 s. A drop waits there for even s only, so a sensor that reads the wrong place or pose
+ // differs on the odd ticks, where a decoy lies at (x + 0.3, 0, 0) (an unrotated frame's centre) 0.42 m from the true centre (inside a radius compared unsquared).
using var world = FluidWorld(32, 4, gravityY: 0f, sensors: 2);
var descs = new List();
- for (var k = 0; k < 8; k++)
+ for (var k = 0; k < 10; k++)
{
- descs.Add(Fluid((0.5f * k, 0.3f, 0f), FluidMass, R));
+ if (k % 2 == 0) descs.Add(Fluid((0.5f * k, 0.3f, 0f), FluidMass, R));
descs.Add(Fluid((0.5f * k + 0.3f, 0f, 0f), FluidMass, R));
}
world.CreateParticles(descs.ToArray());
@@ -120,9 +121,7 @@ public sealed partial class Box3DSoaFluidTests
world.Step(Dt, Sub);
reads[s] = world.View.SensorLiquidVolume[handle[0]];
}
- for (var s = 1; s <= 7; s++) Assert.Equal(DropVolume, reads[s]);
- Assert.Equal(0f, reads[8]);
- Assert.Equal(0f, reads[9]);
+ for (var s = 1; s <= 9; s++) Assert.Equal(s % 2 == 0 ? DropVolume : 0f, reads[s]);
}
[Fact]