- replaced all calls to sqrtf with sqrt. Also changed P_RadiusAttack to use doubles for all floating point calculations.

SVN r2989 (trunk)
This commit is contained in:
Christoph Oelckers 2010-11-07 14:39:09 +00:00
parent dff4553663
commit 7dd8a0fce9
5 changed files with 25 additions and 25 deletions

View file

@ -1533,7 +1533,7 @@ void AM_drawGrid (const AMColor &color)
// [RH] Calculate a minimum for how long the grid lines should be so that // [RH] Calculate a minimum for how long the grid lines should be so that
// they cover the screen at any rotation. // they cover the screen at any rotation.
minlen = (fixed_t)sqrtf ((float)m_w*(float)m_w + (float)m_h*(float)m_h); minlen = (fixed_t)sqrt ((double)m_w*(double)m_w + (double)m_h*(double)m_h);
extx = (minlen - m_w) / 2; extx = (minlen - m_w) / 2;
exty = (minlen - m_h) / 2; exty = (minlen - m_h) / 2;

View file

@ -462,8 +462,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_MacePL1Check)
self->velx = FixedMul(7*FRACUNIT, finecosine[angle]); self->velx = FixedMul(7*FRACUNIT, finecosine[angle]);
self->vely = FixedMul(7*FRACUNIT, finesine[angle]); self->vely = FixedMul(7*FRACUNIT, finesine[angle]);
#else #else
double velscale = sqrtf ((float)self->velx * (float)self->velx + double velscale = sqrt ((double)self->velx * (double)self->velx +
(float)self->vely * (float)self->vely); (double)self->vely * (double)self->vely);
velscale = 458752 / velscale; velscale = 458752 / velscale;
self->velx = (int)(self->velx * velscale); self->velx = (int)(self->velx * velscale);
self->vely = (int)(self->vely * velscale); self->vely = (int)(self->vely * velscale);

View file

@ -414,7 +414,7 @@ static void GetWallStuff (side_t *wall, vertex_t *&v1, fixed_t &ldx, fixed_t &ld
static fixed_t Length (fixed_t dx, fixed_t dy) static fixed_t Length (fixed_t dx, fixed_t dy)
{ {
return (fixed_t)sqrtf ((float)dx*(float)dx+(float)dy*(float)dy); return (fixed_t)sqrt ((double)dx*(double)dx+(double)dy*(double)dy);
} }
static side_t *NextWall (const side_t *wall) static side_t *NextWall (const side_t *wall)

View file

@ -4305,8 +4305,8 @@ void P_RadiusAttack (AActor *bombspot, AActor *bombsource, int bombdamage, int b
return; return;
fulldamagedistance = clamp<int>(fulldamagedistance, 0, bombdistance-1); fulldamagedistance = clamp<int>(fulldamagedistance, 0, bombdistance-1);
float bombdistancefloat = 1.f / (float)(bombdistance - fulldamagedistance); double bombdistancefloat = 1.f / (double)(bombdistance - fulldamagedistance);
float bombdamagefloat = (float)bombdamage; double bombdamagefloat = (double)bombdamage;
FVector3 bombvec(FIXED2FLOAT(bombspot->x), FIXED2FLOAT(bombspot->y), FIXED2FLOAT(bombspot->z)); FVector3 bombvec(FIXED2FLOAT(bombspot->x), FIXED2FLOAT(bombspot->y), FIXED2FLOAT(bombspot->z));
@ -4349,29 +4349,29 @@ void P_RadiusAttack (AActor *bombspot, AActor *bombsource, int bombdamage, int b
{ {
// [RH] New code. The bounding box only covers the // [RH] New code. The bounding box only covers the
// height of the thing and not the height of the map. // height of the thing and not the height of the map.
float points; double points;
float len; double len;
fixed_t dx, dy; fixed_t dx, dy;
float boxradius; double boxradius;
dx = abs (thing->x - bombspot->x); dx = abs (thing->x - bombspot->x);
dy = abs (thing->y - bombspot->y); dy = abs (thing->y - bombspot->y);
boxradius = float (thing->radius); boxradius = double (thing->radius);
// The damage pattern is square, not circular. // The damage pattern is square, not circular.
len = float (dx > dy ? dx : dy); len = double (dx > dy ? dx : dy);
if (bombspot->z < thing->z || bombspot->z >= thing->z + thing->height) if (bombspot->z < thing->z || bombspot->z >= thing->z + thing->height)
{ {
float dz; double dz;
if (bombspot->z > thing->z) if (bombspot->z > thing->z)
{ {
dz = float (bombspot->z - thing->z - thing->height); dz = double (bombspot->z - thing->z - thing->height);
} }
else else
{ {
dz = float (thing->z - bombspot->z); dz = double (thing->z - bombspot->z);
} }
if (len <= boxradius) if (len <= boxradius)
{ {
@ -4380,7 +4380,7 @@ void P_RadiusAttack (AActor *bombspot, AActor *bombsource, int bombdamage, int b
else else
{ {
len -= boxradius; len -= boxradius;
len = sqrtf (len*len + dz*dz); len = sqrt (len*len + dz*dz);
} }
} }
else else
@ -4390,18 +4390,18 @@ void P_RadiusAttack (AActor *bombspot, AActor *bombsource, int bombdamage, int b
len = 0.f; len = 0.f;
} }
len /= FRACUNIT; len /= FRACUNIT;
len = clamp<float>(len - (float)fulldamagedistance, 0, len); len = clamp<double>(len - (double)fulldamagedistance, 0, len);
points = bombdamagefloat * (1.f - len * bombdistancefloat); points = bombdamagefloat * (1.f - len * bombdistancefloat);
if (thing == bombsource) if (thing == bombsource)
{ {
points = points * splashfactor; points = points * splashfactor;
} }
points *= thing->GetClass()->Meta.GetMetaFixed(AMETA_RDFactor, FRACUNIT)/(float)FRACUNIT; points *= thing->GetClass()->Meta.GetMetaFixed(AMETA_RDFactor, FRACUNIT)/(double)FRACUNIT;
if (points > 0.f && P_CheckSight (thing, bombspot, SF_IGNOREVISIBILITY|SF_IGNOREWATERBOUNDARY)) if (points > 0.f && P_CheckSight (thing, bombspot, SF_IGNOREVISIBILITY|SF_IGNOREWATERBOUNDARY))
{ // OK to damage; target is in direct path { // OK to damage; target is in direct path
float velz; double velz;
float thrust; double thrust;
int damage = (int)points; int damage = (int)points;
if (bombdodamage) P_DamageMobj (thing, bombspot, bombsource, damage, bombmod); if (bombdodamage) P_DamageMobj (thing, bombspot, bombsource, damage, bombmod);
@ -4415,12 +4415,12 @@ void P_RadiusAttack (AActor *bombspot, AActor *bombsource, int bombdamage, int b
{ {
if (bombsource == NULL || !(bombsource->flags2 & MF2_NODMGTHRUST)) if (bombsource == NULL || !(bombsource->flags2 & MF2_NODMGTHRUST))
{ {
thrust = points * 0.5f / (float)thing->Mass; thrust = points * 0.5f / (double)thing->Mass;
if (bombsource == thing) if (bombsource == thing)
{ {
thrust *= selfthrustscale; thrust *= selfthrustscale;
} }
velz = (float)(thing->z + (thing->height>>1) - bombspot->z) * thrust; velz = (double)(thing->z + (thing->height>>1) - bombspot->z) * thrust;
if (bombsource != thing) if (bombsource != thing)
{ {
velz *= 0.5f; velz *= 0.5f;
@ -4460,7 +4460,7 @@ void P_RadiusAttack (AActor *bombspot, AActor *bombsource, int bombdamage, int b
{ // OK to damage; target is in direct path { // OK to damage; target is in direct path
dist = clamp<int>(dist - fulldamagedistance, 0, dist); dist = clamp<int>(dist - fulldamagedistance, 0, dist);
int damage = Scale (bombdamage, bombdistance-dist, bombdistance); int damage = Scale (bombdamage, bombdistance-dist, bombdistance);
damage = (int)((float)damage * splashfactor); damage = (int)((double)damage * splashfactor);
damage = Scale(damage, thing->GetClass()->Meta.GetMetaFixed(AMETA_RDFactor, FRACUNIT), FRACUNIT); damage = Scale(damage, thing->GetClass()->Meta.GetMetaFixed(AMETA_RDFactor, FRACUNIT), FRACUNIT);
if (damage > 0) if (damage > 0)

View file

@ -1832,8 +1832,8 @@ void P_FinishLoadingLineDef(line_t *ld, int alpha)
ld->frontsector = ld->sidedef[0] != NULL ? ld->sidedef[0]->sector : NULL; ld->frontsector = ld->sidedef[0] != NULL ? ld->sidedef[0]->sector : NULL;
ld->backsector = ld->sidedef[1] != NULL ? ld->sidedef[1]->sector : NULL; ld->backsector = ld->sidedef[1] != NULL ? ld->sidedef[1]->sector : NULL;
float dx = FIXED2FLOAT(ld->v2->x - ld->v1->x); double dx = FIXED2DBL(ld->v2->x - ld->v1->x);
float dy = FIXED2FLOAT(ld->v2->y - ld->v1->y); double dy = FIXED2DBL(ld->v2->y - ld->v1->y);
int linenum = int(ld-lines); int linenum = int(ld-lines);
if (ld->frontsector == NULL) if (ld->frontsector == NULL)
@ -1842,7 +1842,7 @@ void P_FinishLoadingLineDef(line_t *ld, int alpha)
} }
// [RH] Set some new sidedef properties // [RH] Set some new sidedef properties
int len = (int)(sqrtf (dx*dx + dy*dy) + 0.5f); int len = (int)(sqrt (dx*dx + dy*dy) + 0.5f);
if (ld->sidedef[0] != NULL) if (ld->sidedef[0] != NULL)
{ {