Implement Baseball aiming, pooled projectiles and VR07 targets
This commit is contained in:
1 parent
50fcb87d90
commit
d6ca417e9e
50 files changed
+3149
-32
No files matched your search
@@ -13,6 +13,8 @@ public readonly record struct OrdinaryBodyStep(OrdinaryBodyState Body, Vector3 P
|
||||
Vector3 SupportAnchor, SupportHit? SupportHit, BodyLandingObservation? Landing,
|
||||
CameraRayPolygon? Contact, int CollisionPasses, int TriangleTests);
|
||||
|
||||
public enum BodyResponseProfile { Jimmy, Baseball }
|
||||
|
||||
/// <summary>
|
||||
/// Bounded479D20 composition: enabled integration/support/pairs/static flags,
|
||||
/// prevent-lowering true, ordinary Jimmy370/374/37C and no dynamic body pass.
|
||||
@@ -26,10 +28,10 @@ public sealed class OriginalBodyPhysics
|
||||
{
|
||||
private readonly OriginalStaticCollision collision;
|
||||
|
||||
public OriginalBodyPhysics(OriginalStaticCollision collision)
|
||||
public OriginalBodyPhysics(OriginalStaticCollision collision, bool allowSpecialMaterials = false)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(collision);
|
||||
if (collision.HasSpecialPlayerContacts)
|
||||
if (collision.HasSpecialPlayerContacts && !allowSpecialMaterials)
|
||||
throw new NotSupportedException("Ordinary body composition requires recovered special-contact policies for this scene");
|
||||
this.collision = collision;
|
||||
}
|
||||
@@ -38,7 +40,8 @@ public sealed class OriginalBodyPhysics
|
||||
|
||||
public OrdinaryBodyStep Step(OrdinaryBodyState body, float seconds,
|
||||
float radius = OriginalBodySupport.JimmyRadius, float factor = OriginalBodySupport.JimmyFactor,
|
||||
float friction = .8f, float suppressionScale = .5f, bool geometryEnabled = true)
|
||||
float friction = .8f, float suppressionScale = .5f, bool geometryEnabled = true,
|
||||
BodyResponseProfile profile = BodyResponseProfile.Jimmy)
|
||||
{
|
||||
Finite(body.Position); Finite(body.Velocity); Finite(body.Acceleration); Finite(body.Impulse);
|
||||
Finite(body.AngularVelocity); Finite(body.Rotation);
|
||||
@@ -77,6 +80,21 @@ public sealed class OriginalBodyPhysics
|
||||
if (velocity.Y > 0) velocity.Y = 0;
|
||||
if (acceleration.Y > 0) acceleration.Y = 0;
|
||||
}
|
||||
else if (profile == BodyResponseProfile.Baseball && move.CallbackPolygon is { } wall)
|
||||
{
|
||||
//40FEE0 ->458890 ->472750: reflect horizontal direction, keep Y,
|
||||
//then damp horizontal components by1-.46. Its angular tail does not
|
||||
//change position/velocity; sprite/Euler side effects remain separate.
|
||||
var horizontal = velocity with {Y=0};
|
||||
var magnitude = OriginalBodySupport.QuickMagnitude(horizontal);
|
||||
if (magnitude > 0)
|
||||
{
|
||||
var direction = horizontal / magnitude;
|
||||
var reflected = direction - 2 * Vector3.Dot(direction, wall.StoredNormal) * wall.StoredNormal;
|
||||
velocity = new(reflected.X * magnitude * (1-.46f), velocity.Y,
|
||||
reflected.Z * magnitude * (1-.46f));
|
||||
}
|
||||
}
|
||||
var position = move.Position;
|
||||
if (horizontalFirst) position.Y += delta.Y;
|
||||
position.Y = MathF.Max(position.Y, -25000);
|
||||
@@ -86,13 +104,21 @@ public sealed class OriginalBodyPhysics
|
||||
BodyLandingObservation? landing = null;
|
||||
if (geometryEnabled)
|
||||
{
|
||||
var support = OriginalBodySupport.Resolve(new(position, previous, velocity, acceleration, radius, factor),
|
||||
var support = OriginalBodySupport.Resolve(new(position, previous, velocity, acceleration, radius, factor,
|
||||
PreventLowering: profile == BodyResponseProfile.Jimmy),
|
||||
wasSupported, (start, end, sides) => collision.TraceSupport(start, end, sides));
|
||||
if (support.Supported)
|
||||
{
|
||||
//37C observes new root/zero acceleration but old velocity/support.
|
||||
//Jimmy's inherited37C is a no-op; the observation is diagnostic.
|
||||
if (support.Landed) landing = new(support.Body.Position, velocity, support.Body.Acceleration, false);
|
||||
if (support.Landed)
|
||||
{
|
||||
landing = new(support.Body.Position, velocity, support.Body.Acceleration, false);
|
||||
//40FF80 receives old live velocity after root/acceleration
|
||||
//publication and writes impulse288, before support zeros Y.
|
||||
if (profile == BodyResponseProfile.Baseball)
|
||||
body = body with {Impulse = new(velocity.X, velocity.Y * -.65f, velocity.Z)};
|
||||
}
|
||||
body = body with { Position = support.Body.Position, Velocity = support.Body.Velocity,
|
||||
Acceleration = support.Body.Acceleration, Supported = true };
|
||||
anchor = support.SupportAnchor;
|
||||
|
||||
Reference in new issue
Block a user