diff --git a/src/actor.h b/src/actor.h index a9bd60f75..ed38d0020 100644 --- a/src/actor.h +++ b/src/actor.h @@ -591,31 +591,11 @@ enum struct fixedvec3 { fixed_t x, y, z; - - operator FVector3() - { - return FVector3(FIXED2FLOAT(x), FIXED2FLOAT(y), FIXED2FLOAT(z)); - } - - operator TVector3() - { - return TVector3(FIXED2DBL(x), FIXED2DBL(y), FIXED2DBL(z)); - } }; struct fixedvec2 { fixed_t x, y; - - operator FVector2() - { - return FVector2(FIXED2FLOAT(x), FIXED2FLOAT(y)); - } - - operator TVector2() - { - return TVector2(FIXED2DBL(x), FIXED2DBL(y)); - } }; struct FDropItem diff --git a/src/b_func.cpp b/src/b_func.cpp index eb86beba8..3edc560b0 100644 --- a/src/b_func.cpp +++ b/src/b_func.cpp @@ -465,7 +465,8 @@ fixed_t FCajunMaster::FakeFire (AActor *source, AActor *dest, ticcmd_t *cmd) float speed = (float)th->Speed; - TVector3 velocity = source->Vec3To(dest); + fixedvec3 fixvel = source->Vec3To(dest); + TVector3 velocity(fixvel.x, fixvel.y, fixvel.z); velocity.MakeUnit(); th->velx = FLOAT2FIXED(velocity[0] * speed); th->vely = FLOAT2FIXED(velocity[1] * speed); diff --git a/src/g_shared/a_camera.cpp b/src/g_shared/a_camera.cpp index 61a155ea7..37457e7f0 100644 --- a/src/g_shared/a_camera.cpp +++ b/src/g_shared/a_camera.cpp @@ -176,8 +176,9 @@ void AAimingCamera::Tick () } if (MaxPitchChange) { // Aim camera's pitch; use floats for precision - TVector2 vect = tracer->Vec2To(this); - double dz = FIXED2DBL(Z() - tracer->Z() - tracer->height/2); + fixedvec2 fv3 = tracer->Vec2To(this); + TVector2 vect(fv3.x, fv3.y); + double dz = Z() - tracer->Z() - tracer->height/2; double dist = vect.Length(); double ang = dist != 0.f ? atan2 (dz, dist) : 0; int desiredpitch = (angle_t)(ang * 2147483648.f / PI); diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index 90a7a5f5c..0fd23f73e 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -2777,7 +2777,8 @@ void A_Face (AActor *self, AActor *other, angle_t max_turn, angle_t max_pitch, a // disabled and is so by default. if (max_pitch <= ANGLE_180) { - TVector2 dist = self->Vec2To(other); + fixedvec2 pos = self->Vec2To(other); + TVector2 dist(pos.x, pos.y); // Positioning ala missile spawning, 32 units above foot level fixed_t source_z = self->Z() + 32*FRACUNIT + self->GetBobOffset(); @@ -2801,7 +2802,7 @@ void A_Face (AActor *self, AActor *other, angle_t max_turn, angle_t max_pitch, a if (!(flags & FAF_NODISTFACTOR)) target_z += pitch_offset; - double dist_z = FIXED2DBL(target_z - source_z); + double dist_z = target_z - source_z; double ddist = sqrt(dist.X*dist.X + dist.Y*dist.Y + dist_z*dist_z); int other_pitch = (int)rad2bam(asin(dist_z / ddist)); @@ -2915,8 +2916,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_MonsterRail) if (linetarget == NULL) { // We probably won't hit the target, but aim at it anyway so we don't look stupid. - TVector2 xydiff = self->Vec2To(self->target); - double zdiff = FIXED2DBL((self->target->Z() + (self->target->height>>1)) - (self->Z() + (self->height>>1) - self->floorclip)); + fixedvec2 pos = self->Vec2To(self->target); + TVector2 xydiff(pos.x, pos.y); + double zdiff = (self->target->Z() + (self->target->height>>1)) - (self->Z() + (self->height>>1) - self->floorclip); self->pitch = int(atan2(zdiff, xydiff.Length()) * ANGLE_180 / -M_PI); } diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 9f8fbe2ea..32a20e321 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -2037,7 +2037,7 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) //dest->x - source->x fixedvec3 vect = mo->Vec3To(origin); vect.z += origin->height / 2; - FVector3 velocity(vect); + TVector3 velocity(vect.x, vect.y, vect.z); velocity.Resize(speed); mo->velx = (fixed_t)(velocity.X); mo->vely = (fixed_t)(velocity.Y); @@ -5733,7 +5733,8 @@ AActor *P_SpawnMissileXYZ (fixed_t x, fixed_t y, fixed_t z, // missile? // Answer: No, because this way, you can set up sets of parallel missiles. - FVector3 velocity = source->Vec3To(dest); + fixedvec3 fixvel = source->Vec3To(dest); + FVector3 velocity(fixvel.x, fixvel.y, fixvel.z); // Floor and ceiling huggers should never have a vertical component to their velocity if (th->flags3 & (MF3_FLOORHUGGER|MF3_CEILINGHUGGER)) { @@ -5742,7 +5743,7 @@ AActor *P_SpawnMissileXYZ (fixed_t x, fixed_t y, fixed_t z, // [RH] Adjust the trajectory if the missile will go over the target's head. else if (z - source->Z() >= dest->height) { - velocity.Z += dest->height - z + source->Z(); + velocity.Z += (dest->height - z + source->Z()); } velocity.Resize (speed); th->velx = (fixed_t)(velocity.X); diff --git a/src/p_things.cpp b/src/p_things.cpp index 85d7961af..be28ed98d 100644 --- a/src/p_things.cpp +++ b/src/p_things.cpp @@ -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 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 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 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 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 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);