- removed the implicit fixedvec -> TVector conversions because they caused too many problems. Also reviewed all uses of these and made the necessary adjustments. Problems were present in P_SpawnMissileXYZ and P_Thing_Projectile.

- replaced some single precision float math with doubles.
This commit is contained in:
Christoph Oelckers 2016-01-23 20:44:33 +01:00
commit c4377b7039
6 changed files with 20 additions and 35 deletions

View file

@ -256,7 +256,7 @@ bool P_Thing_Projectile (int tid, AActor *source, int type, const char *type_nam
{
fixedvec3 vect = mobj->Vec3To(targ);
vect.z += targ->height / 2;
FVector3 aim = vect;
TVector3<double> aim(vect.x, vect.y, vect.z);
if (leadTarget && speed > 0 && (targ->velx | targ->vely | targ->velz))
{
@ -267,7 +267,7 @@ bool P_Thing_Projectile (int tid, AActor *source, int type, const char *type_nam
// with the math. I don't think I would have thought of using
// trig alone had I been left to solve it by myself.
FVector3 tvel(targ->velx, targ->vely, targ->velz);
TVector3<double> tvel(targ->velx, targ->vely, targ->velz);
if (!(targ->flags & MF_NOGRAVITY) && targ->waterlevel < 3)
{ // If the target is subject to gravity and not underwater,
// assume that it isn't moving vertically. Thanks to gravity,
@ -288,14 +288,14 @@ bool P_Thing_Projectile (int tid, AActor *source, int type, const char *type_nam
// Use the cross product of two of the triangle's sides to get a
// rotation vector.
FVector3 rv(tvel ^ aim);
TVector3<double> rv(tvel ^ aim);
// The vector must be normalized.
rv.MakeUnit();
// Now combine the rotation vector with angle b to get a rotation matrix.
FMatrix3x3 rm(rv, cos(asin(sinb)), sinb);
TMatrix3x3<double> rm(rv, cos(asin(sinb)), sinb);
// And multiply the original aim vector with the matrix to get a
// new aim vector that leads the target.
FVector3 aimvec = rm * aim;
TVector3<double> aimvec = rm * aim;
// And make the projectile follow that vector at the desired speed.
double aimscale = fspeed / dist;
mobj->velx = fixed_t (aimvec[0] * aimscale);