New types for cell and pixel coordinate position/vectors.

This commit is contained in:
James Dunne
2012-06-20 23:22:27 -05:00
parent 0b98a8ce5e
commit 9c49143534
162 changed files with 1291 additions and 865 deletions

View File

@@ -20,7 +20,7 @@ namespace OpenRA.Mods.RA.Air
bool isCalculated;
Actor dest;
int2 w1, w2, w3; /* tangent points to turn circles */
PPos w1, w2, w3; /* tangent points to turn circles */
public static Actor ChooseAirfield(Actor self)
{
@@ -52,19 +52,18 @@ namespace OpenRA.Mods.RA.Air
var speed = .2f * aircraft.MovementSpeed;
var approachStart = landPos - new float2(aircraft.Altitude * speed, 0);
var approachStart = landPos.ToFloat2() - new float2(aircraft.Altitude * speed, 0);
var turnRadius = (128f / self.Info.Traits.Get<AircraftInfo>().ROT) * speed / (float)Math.PI;
/* work out the center points */
var fwd = -float2.FromAngle(aircraft.Facing / 128f * (float)Math.PI);
var side = new float2(-fwd.Y, fwd.X); /* rotate */
var sideTowardBase = new[] { side, -side }
.OrderBy(a => float2.Dot(a, self.CenterLocation - approachStart))
.OrderBy(a => float2.Dot(a, self.CenterLocation.ToFloat2() - approachStart))
.First();
var c1 = self.CenterLocation + turnRadius * sideTowardBase;
var c2 = approachStart + new float2(0,
turnRadius * Math.Sign(self.CenterLocation.Y - approachStart.Y)); // above or below start point
var c1 = self.CenterLocation.ToFloat2() + turnRadius * sideTowardBase;
var c2 = approachStart + new float2(0, turnRadius * Math.Sign(self.CenterLocation.Y - approachStart.Y)); // above or below start point
/* work out tangent points */
var d = c2 - c1;
@@ -75,10 +74,10 @@ namespace OpenRA.Mods.RA.Air
if (f.X > 0) f = -f;
w1 = (c1 + f).ToInt2();
w2 = (c2 + f).ToInt2();
w3 = (approachStart).ToInt2();
plane.RTBPathHash = w1 + w2 + w3;
w1 = (PPos)(c1 + f).ToInt2();
w2 = (PPos)(c2 + f).ToInt2();
w3 = (PPos)(approachStart).ToInt2();
plane.RTBPathHash = (PVecInt)w1 + (PVecInt)w2 + (PVecInt)w3;
isCalculated = true;
}