Match Jimmy controller arithmetic and facing to original probes
This commit is contained in:
1 parent
42ea2b8cd5
commit
0e2f426d42
60 files changed
+6027
-48
No files matched your search
@@ -0,0 +1,25 @@
|
||||
using System.Numerics;
|
||||
namespace GamePort.Game;
|
||||
|
||||
/// <summary>43A420 active Jimmy facing, followed by334→458F90→472480.
|
||||
/// Targets are retained caller state; all three axes take the shortest arc.
|
||||
/// Source4.5/3.7 constants are doubles and delta parameters publish as floats.</summary>
|
||||
public static class JimmyOrientation
|
||||
{
|
||||
public static Vector3 Step(Vector3 current,Vector3 target,float seconds,bool enabled=true,bool dirty=true)
|
||||
{
|
||||
if(!float.IsFinite(current.X)||!float.IsFinite(current.Y)||!float.IsFinite(current.Z)
|
||||
||!float.IsFinite(target.X)||!float.IsFinite(target.Y)||!float.IsFinite(target.Z)
|
||||
||!float.IsFinite(seconds)||seconds<0||seconds>=1)
|
||||
throw new ArgumentOutOfRangeException(nameof(seconds));
|
||||
if(!enabled||!dirty)return current;
|
||||
static float Arc(float value)=>value>180?value-360:value< -180?value+360:value;
|
||||
static double WideArc(double value)=>value>180?value-360:value< -180?value+360:value;
|
||||
var x=Arc(target.X-current.X);var y=Arc(target.Y-current.Y);
|
||||
//X/Y differences have explicit float stack stores. The Z difference
|
||||
//remains on x87 until its final float argument publication.
|
||||
var z=WideArc((double)target.Z-current.Z);
|
||||
var delta=new Vector3((float)((double)x*seconds*4.5),(float)((double)y*seconds*3.7),(float)(z*seconds*4.5));
|
||||
return RocketOrientation.Add(current,delta);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user