[botlib] Use floating point absolute value rather than truncate to integer

This commit is contained in:
Thomas Köppe committed 2016-07-25 18:36:31 +01:00
1 parent 9a5add2b60
commit 18d6c8fda2
5 files changed
+9 -8

No files matched your search

+2 -2
View File
@@ -390,9 +390,9 @@ int AAS_NearestEntity(vec3_t origin, int modelindex)
ent = &aasworld.entities[i];
if (ent->i.modelindex != modelindex) continue;
VectorSubtract(ent->i.origin, origin, dir);
if (abs(dir[0]) < 40)
if (fabsf(dir[0]) < 40)
{
if (abs(dir[1]) < 40)
if (fabsf(dir[1]) < 40)
{
dist = VectorLength(dir);
if (dist < bestdist)
+1 -1
View File
@@ -168,7 +168,7 @@ int AAS_AgainstLadder(vec3_t origin)
//get the plane the face is in
plane = &aasworld.planes[face->planenum ^ side];
//if the origin is pretty close to the plane
if (abs(DotProduct(plane->normal, origin) - plane->dist) < 3)
if (fabsf(DotProduct(plane->normal, origin) - plane->dist) < 3)
{
if (AAS_PointInsideFace(abs(facenum), origin, 0.1f)) return qtrue;
} //end if
+4 -4
View File
@@ -2465,8 +2465,8 @@ int AAS_Reachability_Ladder(int area1num, int area2num)
VectorMA(area1point, -32, dir, area1point);
VectorMA(area2point, 32, dir, area2point);
//
ladderface1vertical = abs(DotProduct(plane1->normal, up)) < 0.1;
ladderface2vertical = abs(DotProduct(plane2->normal, up)) < 0.1;
ladderface1vertical = fabsf(DotProduct(plane1->normal, up)) < 0.1;
ladderface2vertical = fabsf(DotProduct(plane2->normal, up)) < 0.1;
//there's only reachability between vertical ladder faces
if (!ladderface1vertical && !ladderface2vertical) return qfalse;
//if both vertical ladder faces
@@ -2474,7 +2474,7 @@ int AAS_Reachability_Ladder(int area1num, int area2num)
//and the ladder faces do not make a sharp corner
&& DotProduct(plane1->normal, plane2->normal) > 0.7
//and the shared edge is not too vertical
&& abs(DotProduct(sharededgevec, up)) < 0.7)
&& fabsf(DotProduct(sharededgevec, up)) < 0.7)
{
//create a new reachability link
lreach = AAS_AllocReachability();
@@ -2599,7 +2599,7 @@ int AAS_Reachability_Ladder(int area1num, int area2num)
if (face2->faceflags & FACE_LADDER)
{
plane2 = &aasworld.planes[face2->planenum];
if (abs(DotProduct(plane2->normal, up)) < 0.1) break;
if (fabsf(DotProduct(plane2->normal, up)) < 0.1) break;
} //end if
} //end for
//if from another area without vertical ladder faces
+1 -1
View File
@@ -2054,7 +2054,7 @@ bot_moveresult_t BotTravel_Elevator(bot_movestate_t *ms, aas_reachability_t *rea
botimport.Print(PRT_MESSAGE, "bot on elevator\n");
#endif //DEBUG_ELEVATOR
//if vertically not too far from the end point
if (abs(ms->origin[2] - reach->end[2]) < sv_maxbarrier->value)
if (fabsf(ms->origin[2] - reach->end[2]) < sv_maxbarrier->value)
{
#ifdef DEBUG_ELEVATOR
botimport.Print(PRT_MESSAGE, "bot moving to end\n");