- 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
// 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;
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->vely = FixedMul(7*FRACUNIT, finesine[angle]);
#else
double velscale = sqrtf ((float)self->velx * (float)self->velx +
(float)self->vely * (float)self->vely);
double velscale = sqrt ((double)self->velx * (double)self->velx +
(double)self->vely * (double)self->vely);
velscale = 458752 / velscale;
self->velx = (int)(self->velx * 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)
{
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)

View File

@ -4305,8 +4305,8 @@ void P_RadiusAttack (AActor *bombspot, AActor *bombsource, int bombdamage, int b
return;
fulldamagedistance = clamp<int>(fulldamagedistance, 0, bombdistance-1);
float bombdistancefloat = 1.f / (float)(bombdistance - fulldamagedistance);
float bombdamagefloat = (float)bombdamage;
double bombdistancefloat = 1.f / (double)(bombdistance - fulldamagedistance);
double bombdamagefloat = (double)bombdamage;
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
// height of the thing and not the height of the map.
float points;
float len;
double points;
double len;
fixed_t dx, dy;
float boxradius;
double boxradius;
dx = abs (thing->x - bombspot->x);
dy = abs (thing->y - bombspot->y);
boxradius = float (thing->radius);
boxradius = double (thing->radius);
// 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)
{
float dz;
double dz;
if (bombspot->z > thing->z)
{
dz = float (bombspot->z - thing->z - thing->height);
dz = double (bombspot->z - thing->z - thing->height);
}
else
{
dz = float (thing->z - bombspot->z);
dz = double (thing->z - bombspot->z);
}
if (len <= boxradius)
{
@ -4380,7 +4380,7 @@ void P_RadiusAttack (AActor *bombspot, AActor *bombsource, int bombdamage, int b
else
{
len -= boxradius;
len = sqrtf (len*len + dz*dz);
len = sqrt (len*len + dz*dz);
}
}
else
@ -4390,18 +4390,18 @@ void P_RadiusAttack (AActor *bombspot, AActor *bombsource, int bombdamage, int b
len = 0.f;
}
len /= FRACUNIT;
len = clamp<float>(len - (float)fulldamagedistance, 0, len);
len = clamp<double>(len - (double)fulldamagedistance, 0, len);
points = bombdamagefloat * (1.f - len * bombdistancefloat);
if (thing == bombsource)
{
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))
{ // OK to damage; target is in direct path
float velz;
float thrust;
double velz;
double thrust;
int damage = (int)points;
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))
{
thrust = points * 0.5f / (float)thing->Mass;
thrust = points * 0.5f / (double)thing->Mass;
if (bombsource == thing)
{
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)
{
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
dist = clamp<int>(dist - fulldamagedistance, 0, dist);
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);
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->backsector = ld->sidedef[1] != NULL ? ld->sidedef[1]->sector : NULL;
float dx = FIXED2FLOAT(ld->v2->x - ld->v1->x);
float dy = FIXED2FLOAT(ld->v2->y - ld->v1->y);
double dx = FIXED2DBL(ld->v2->x - ld->v1->x);
double dy = FIXED2DBL(ld->v2->y - ld->v1->y);
int linenum = int(ld-lines);
if (ld->frontsector == NULL)
@ -1842,7 +1842,7 @@ void P_FinishLoadingLineDef(line_t *ld, int alpha)
}
// [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)
{