From 7dd8a0fce947d0a8b9cb8fd23f5a0165b3562830 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 7 Nov 2010 14:39:09 +0000 Subject: [PATCH] - replaced all calls to sqrtf with sqrt. Also changed P_RadiusAttack to use doubles for all floating point calculations. SVN r2989 (trunk) --- src/am_map.cpp | 2 +- src/g_heretic/a_hereticweaps.cpp | 4 ++-- src/g_shared/a_decals.cpp | 2 +- src/p_map.cpp | 36 ++++++++++++++++---------------- src/p_setup.cpp | 6 +++--- 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/am_map.cpp b/src/am_map.cpp index 2de0a5bc3..cf8876157 100644 --- a/src/am_map.cpp +++ b/src/am_map.cpp @@ -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; diff --git a/src/g_heretic/a_hereticweaps.cpp b/src/g_heretic/a_hereticweaps.cpp index ad0115089..0a44cdbec 100644 --- a/src/g_heretic/a_hereticweaps.cpp +++ b/src/g_heretic/a_hereticweaps.cpp @@ -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); diff --git a/src/g_shared/a_decals.cpp b/src/g_shared/a_decals.cpp index d992bec9e..1c15bd914 100644 --- a/src/g_shared/a_decals.cpp +++ b/src/g_shared/a_decals.cpp @@ -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) diff --git a/src/p_map.cpp b/src/p_map.cpp index 3c791fea6..082db59fa 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -4305,8 +4305,8 @@ void P_RadiusAttack (AActor *bombspot, AActor *bombsource, int bombdamage, int b return; fulldamagedistance = clamp(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(len - (float)fulldamagedistance, 0, len); + len = clamp(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(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) diff --git a/src/p_setup.cpp b/src/p_setup.cpp index b26d44ee5..f91542916 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -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) {