Removed redundant dtSqrt function and replaced calls to it with dtMathSqrtf
This commit is contained in:
parent
2f788530f5
commit
45b36f4d75
@ -19,6 +19,8 @@
|
||||
#ifndef DETOURCOMMON_H
|
||||
#define DETOURCOMMON_H
|
||||
|
||||
#include "DetourMath.h"
|
||||
|
||||
/**
|
||||
@defgroup detour Detour
|
||||
|
||||
@ -71,11 +73,6 @@ template<class T> inline T dtSqr(T a) { return a*a; }
|
||||
/// @return The value, clamped to the specified range.
|
||||
template<class T> inline T dtClamp(T v, T mn, T mx) { return v < mn ? mn : (v > mx ? mx : v); }
|
||||
|
||||
/// Returns the square root of the value.
|
||||
/// @param[in] x The value.
|
||||
/// @return The square root of the vlaue.
|
||||
float dtSqrt(float x);
|
||||
|
||||
/// @}
|
||||
/// @name Vector helper functions.
|
||||
/// @{
|
||||
@ -202,7 +199,7 @@ inline void dtVcopy(float* dest, const float* a)
|
||||
/// @return The scalar length of the vector.
|
||||
inline float dtVlen(const float* v)
|
||||
{
|
||||
return dtSqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]);
|
||||
return dtMathSqrtf(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
|
||||
}
|
||||
|
||||
/// Derives the square of the scalar length of the vector. (len * len)
|
||||
@ -222,7 +219,7 @@ inline float dtVdist(const float* v1, const float* v2)
|
||||
const float dx = v2[0] - v1[0];
|
||||
const float dy = v2[1] - v1[1];
|
||||
const float dz = v2[2] - v1[2];
|
||||
return dtSqrt(dx*dx + dy*dy + dz*dz);
|
||||
return dtMathSqrtf(dx*dx + dy*dy + dz*dz);
|
||||
}
|
||||
|
||||
/// Returns the square of the distance between two points.
|
||||
@ -247,7 +244,7 @@ inline float dtVdist2D(const float* v1, const float* v2)
|
||||
{
|
||||
const float dx = v2[0] - v1[0];
|
||||
const float dz = v2[2] - v1[2];
|
||||
return dtSqrt(dx*dx + dz*dz);
|
||||
return dtMathSqrtf(dx*dx + dz*dz);
|
||||
}
|
||||
|
||||
/// Derives the square of the distance between the specified points on the xz-plane.
|
||||
@ -265,7 +262,7 @@ inline float dtVdist2DSqr(const float* v1, const float* v2)
|
||||
/// @param[in,out] v The vector to normalize. [(x, y, z)]
|
||||
inline void dtVnormalize(float* v)
|
||||
{
|
||||
float d = 1.0f / dtSqrt(dtSqr(v[0]) + dtSqr(v[1]) + dtSqr(v[2]));
|
||||
float d = 1.0f / dtMathSqrtf(dtSqr(v[0]) + dtSqr(v[1]) + dtSqr(v[2]));
|
||||
v[0] *= d;
|
||||
v[1] *= d;
|
||||
v[2] *= d;
|
||||
|
@ -21,11 +21,6 @@
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
float dtSqrt(float x)
|
||||
{
|
||||
return dtMathSqrtf(x);
|
||||
}
|
||||
|
||||
void dtClosestPtPointTriangle(float* closest, const float* p,
|
||||
const float* a, const float* b, const float* c)
|
||||
{
|
||||
@ -360,7 +355,7 @@ void dtRandomPointInConvexPoly(const float* pts, const int npts, float* areas,
|
||||
acc += dacc;
|
||||
}
|
||||
|
||||
float v = dtSqrt(t);
|
||||
float v = dtMathSqrtf(t);
|
||||
|
||||
const float a = 1 - v;
|
||||
const float b = (1 - u) * v;
|
||||
|
@ -44,7 +44,7 @@ static int sweepCircleCircle(const float* c0, const float r0, const float* v,
|
||||
float d = b*b - a*c;
|
||||
if (d < 0.0f) return 0; // no intersection.
|
||||
a = 1.0f / a;
|
||||
const float rd = dtSqrt(d);
|
||||
const float rd = dtMathSqrtf(d);
|
||||
tmin = (b - rd) * a;
|
||||
tmax = (b + rd) * a;
|
||||
return 1;
|
||||
@ -482,7 +482,7 @@ int dtObstacleAvoidanceQuery::sampleVelocityGrid(const float* pos, const float r
|
||||
// vector normalization that ignores the y-component.
|
||||
inline void dtNormalize2D(float* v)
|
||||
{
|
||||
float d = dtSqrt(v[0]*v[0]+v[2]*v[2]);
|
||||
float d = dtMathSqrtf(v[0] * v[0] + v[2] * v[2]);
|
||||
if (d==0)
|
||||
return;
|
||||
d = 1.0f / d;
|
||||
|
@ -745,7 +745,7 @@ void NavMeshTesterTool::recalc()
|
||||
// Find movement delta.
|
||||
float delta[3], len;
|
||||
dtVsub(delta, steerPos, iterPos);
|
||||
len = dtSqrt(dtVdot(delta,delta));
|
||||
len = dtMathSqrtf(dtVdot(delta, delta));
|
||||
// If the steer target is end of path or off-mesh link, do not move past the location.
|
||||
if ((endOfPath || offMeshConnection) && len < STEP_SIZE)
|
||||
len = 1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user