Merge branch 'Testing' of https://gitea.grillkol.net/grillkol/FluidSim into Testing

This commit is contained in:
max
2026-06-09 17:50:16 +02:00
4 changed files with 177 additions and 145 deletions

View File

@@ -100,24 +100,39 @@ namespace FluidSim.Components
{
float deg = thetaDeg % 720f;
if (deg < 0f) deg += 720f;
float duration = closes - opens;
float duration;
float effectiveOpen = opens;
float effectiveClose = closes;
if (closes < opens)
{
// Wraparound case (e.g., exhaust: opens near 480°, closes near 30°)
effectiveClose += 720f;
}
duration = effectiveClose - effectiveOpen;
if (duration <= 0f) return 0f;
// Map the angle into the [opens, opens+duration] window
float mapped = deg;
if (mapped < opens) mapped += 720f;
if (mapped < opens || mapped > effectiveClose) return 0f;
float rampDur = duration * 0.25f;
float holdDur = duration - 2f * rampDur;
if (deg >= opens && deg < opens + rampDur)
if (mapped >= opens && mapped < opens + rampDur)
{
float t = (deg - opens) / rampDur;
float t = (mapped - opens) / rampDur;
return peakLift * t * t * (3f - 2f * t);
}
else if (deg >= opens + rampDur && deg < opens + rampDur + holdDur)
else if (mapped >= opens + rampDur && mapped < opens + rampDur + holdDur)
{
return peakLift;
}
else if (deg >= opens + rampDur + holdDur && deg <= closes)
else if (mapped >= opens + rampDur + holdDur && mapped <= effectiveClose)
{
float t = (deg - (opens + rampDur + holdDur)) / rampDur;
float t = (mapped - (opens + rampDur + holdDur)) / rampDur;
return peakLift * (1f - t) * (1f - t) * (1f + 2f * t);
}
return 0f;
@@ -194,6 +209,7 @@ namespace FluidSim.Components
float totalMass = _airMass + _exhaustMass;
_airMass = 0f; _exhaustMass = totalMass;
}
fuelInjected = false;
float dFraction = newFraction - burnFraction;
if (dFraction > 0f)