diff --git a/src/BadDay.Ymir/Blood.cs b/src/BadDay.Ymir/Blood.cs
new file mode 100644
index 0000000..b9a777d
--- /dev/null
+++ b/src/BadDay.Ymir/Blood.cs
@@ -0,0 +1,41 @@
+using System;
+using Lodur;
+using Lodur.Body.Ymir;
+using Ymir.Box3D;
+
+namespace BadDay.Ymir;
+
+///
+/// Content for the blood of a seated body: every number is a balance knob (ruling economy-numbers-are-sim-tuned-knobs).
+/// is how many times the real volume is drawn and spilled (ruling bds-blood-gain-simulated); the
+/// drops are fluid particles of one size, each.
+///
+public sealed record BloodParameters
+{
+ /// Visible volume per real volume bled; the physiology's own blood volume is never scaled.
+ public double Gain { get; init; } = 10.0;
+ /// Drop radius in m; a drop's volume is (2 r)^3, as Ymir's Settle reads it (0.0125 m: 15.625 mL).
+ public float DropRadius { get; init; } = 0.0125f;
+ /// kg/m^3; a drop's mass is this times .
+ public double Density { get; init; } = 1060.0;
+ /// m/s along the wound's normal, over the part's own velocity.
+ public float ExitSpeed { get; init; } = 0.5f;
+ /// m/s: a supported drop slower than this is calm.
+ public float SettleSpeed { get; init; } = 0.05f;
+ /// Consecutive calm ticks before a drop settles into a wet patch.
+ public int SettleTicks { get; init; } = 30;
+ /// Fluid particle lanes: the most drops that are live at once (ruling ymir-fluid-live-cap-512).
+ public int LiveCap { get; init; } = 512;
+ /// Drops emitted over all wounds in one tick; the rest of the volume waits as backlog.
+ public int MaxDropsPerTick { get; init; } = 8;
+ /// Wet patch lanes.
+ public int WetLanes { get; init; } = 256;
+ /// The blood material's table index and its friction, viscosity and wet friction.
+ public int Material { get; init; } = 1;
+ public float Friction { get; init; } = 0.3f;
+ public float Viscosity { get; init; } = 0.01f;
+ public float WetFriction { get; init; } = 0.1f;
+
+ /// One drop's volume in m^3.
+ public double DropVolume => Math.Pow(2.0 * DropRadius, 3.0);
+}
diff --git a/src/BadDay.Ymir/SeatedBody.cs b/src/BadDay.Ymir/SeatedBody.cs
index b3b87be..b9dcc68 100644
--- a/src/BadDay.Ymir/SeatedBody.cs
+++ b/src/BadDay.Ymir/SeatedBody.cs
@@ -27,12 +27,16 @@ public sealed class SeatedBody : IDisposable
private readonly Queue _events = new();
private bool _disposed;
- public SeatedBody()
+ public SeatedBody(BloodParameters? blood = null)
{
+ blood ??= new BloodParameters();
var needs = SeatedPuppet.Needs;
- _world = new Box3DSoaWorld(capacity: needs.Bodies, jointCapacity: needs.Joints);
+ _world = new Box3DSoaWorld(capacity: needs.Bodies, jointCapacity: needs.Joints,
+ particles: new Box3DSoaParticleCapacities(Particles: blood.LiveCap, 0, 0, 0, 0, Materials: blood.Material + 1,
+ Fluid: blood.LiveCap, Wets: blood.WetLanes, Sensors: needs.Sensors));
try
{
+ _world.SetMaterial(blood.Material, blood.Friction, viscosity: blood.Viscosity, wetFriction: blood.WetFriction);
_ragdoll = SeatedPuppet.Build(_world);
var plan = _ragdoll.Plan;
_x = new float[plan.SensePoints.Count];
diff --git a/src/BadDay.Ymir/SeatedPuppet.cs b/src/BadDay.Ymir/SeatedPuppet.cs
index 2fdd035..60bbacc 100644
--- a/src/BadDay.Ymir/SeatedPuppet.cs
+++ b/src/BadDay.Ymir/SeatedPuppet.cs
@@ -14,18 +14,21 @@ public static class SeatedPuppet
/// Physics substeps per 1/120 s step. The ragdoll gains were tuned against 4; the behaviour tests, not this number, are the rule.
public const int Substeps = 4;
- /// Bodies and joints a world needs for : the ragdoll, the ground and the stool, and the weld.
- public static (int Bodies, int Joints) Needs => (Ragdoll.Needs(Plan).Bodies + 2, Ragdoll.Needs(Plan).Joints + 1);
+ /// The stable id of the first of Fella's parts: a part's stable id is this plus its ordinal. The ground is 1 and the stool 2.
+ public const ulong FirstStableId = 100;
+
+ /// Bodies, joints and sensors a world needs for : the ragdoll, the ground and the stool, the weld, and the airway sensors (the world must also have a particle system for them).
+ public static (int Bodies, int Joints, int Sensors) Needs => (Ragdoll.Needs(Plan).Bodies + 2, Ragdoll.Needs(Plan).Joints + 1, Ragdoll.Needs(Plan).Sensors);
/// The humanoid plan every BDS body is built from; classes resolve their labels against it once.
public static BodyPlan Plan { get; } = BodyPlans.Humanoid();
- /// Adds the ground, the stool, the ragdoll (stable ids from 100) and the pelvis weld to , which must be sized by .
+ /// Adds the ground, the stool, the ragdoll (stable ids from ) and the pelvis weld to , which must be sized by .
public static Ragdoll Build(Box3DSoaWorld world)
{
world.AddStaticBox(1, (0f, -0.5f, 0f), (20f, 0.5f, 20f), friction: 0.8f);
var stool = world.AddStaticBox(2, (0f, 1.11f, -0.115f), (0.05f, 0.05f, 0.025f), friction: 0.8f);
- var ragdoll = Ragdoll.Build(world, Plan, (0f, 0f), firstStableId: 100);
+ var ragdoll = Ragdoll.Build(world, Plan, (0f, 0f), firstStableId: FirstStableId);
world.AddJoint(Box3DSoaJointKind.Weld, stool, ragdoll.BodyLane(Plan.PartIndex("Pelvis")), (0f, 1.11f, -0.09f), (0f, 1f, 0f));
return ragdoll;
}