Fix DivideByZero crashes in Railgun projectile
This commit is contained in:
@@ -153,6 +153,7 @@ namespace OpenRA.Mods.Common.Projectiles
|
|||||||
|
|
||||||
// An easy vector to find which is perpendicular vector to forwardStep, with 0 Z component
|
// An easy vector to find which is perpendicular vector to forwardStep, with 0 Z component
|
||||||
LeftVector = new WVec(ForwardStep.Y, -ForwardStep.X, 0);
|
LeftVector = new WVec(ForwardStep.Y, -ForwardStep.X, 0);
|
||||||
|
if (LeftVector.LengthSquared != 0)
|
||||||
LeftVector = 1024 * LeftVector / LeftVector.Length;
|
LeftVector = 1024 * LeftVector / LeftVector.Length;
|
||||||
|
|
||||||
// Vector that is pointing upwards from the ground
|
// Vector that is pointing upwards from the ground
|
||||||
@@ -160,6 +161,8 @@ namespace OpenRA.Mods.Common.Projectiles
|
|||||||
-ForwardStep.X * ForwardStep.Z,
|
-ForwardStep.X * ForwardStep.Z,
|
||||||
-ForwardStep.Z * ForwardStep.Y,
|
-ForwardStep.Z * ForwardStep.Y,
|
||||||
ForwardStep.X * ForwardStep.X + ForwardStep.Y * ForwardStep.Y);
|
ForwardStep.X * ForwardStep.X + ForwardStep.Y * ForwardStep.Y);
|
||||||
|
|
||||||
|
if (UpVector.LengthSquared != 0)
|
||||||
UpVector = 1024 * UpVector / UpVector.Length;
|
UpVector = 1024 * UpVector / UpVector.Length;
|
||||||
|
|
||||||
//// LeftVector and UpVector are unit vectors of size 1024.
|
//// LeftVector and UpVector are unit vectors of size 1024.
|
||||||
|
|||||||
Reference in New Issue
Block a user