diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Maths.cpp | 24 | ||||
-rw-r--r-- | src/Maths.h | 11 | ||||
-rw-r--r-- | src/Models.cpp | 4 | ||||
-rw-r--r-- | src/Person.cpp | 2 | ||||
-rw-r--r-- | src/PhysicsMath.h | 6 | ||||
-rw-r--r-- | src/Quaternions.cpp | 32 | ||||
-rw-r--r-- | src/Quaternions.h | 2 | ||||
-rw-r--r-- | src/Sprites.cpp | 4 |
8 files changed, 13 insertions, 72 deletions
diff --git a/src/Maths.cpp b/src/Maths.cpp deleted file mode 100644 index 58e769a..0000000 --- a/src/Maths.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/**> HEADER FILES <**/ -#include "Maths.h" - -double fast_sqrt (register double arg) -{ -#ifdef OS9 - // Can replace with slower return std::sqrt(arg); - register double result; - - if (arg == 0.0) return 0.0; - - asm { - frsqrte result,arg // Calculate Square root - } - - // Newton Rhapson iterations. - result = result + 0.5 * result * (1.0 - arg * result * result); - result = result + 0.5 * result * (1.0 - arg * result * result); - - return result * arg; -#else - return sqrt(arg); -#endif -} diff --git a/src/Maths.h b/src/Maths.h deleted file mode 100644 index d9a8f61..0000000 --- a/src/Maths.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef _MATHS_H_ -#define _MATHS_H_ - - -/**> HEADER FILES <**/ -#include <cmath> - -double fast_sqrt (register double arg); - -#endif - diff --git a/src/Models.cpp b/src/Models.cpp index 8caefd8..b4fbb82 100644 --- a/src/Models.cpp +++ b/src/Models.cpp @@ -59,7 +59,7 @@ void Model::UpdateVertexArray(){ for(int i=0;i<vertexNum;i++){ if(findDistancefast(average,vertex[i])>boundingsphereradius)boundingsphereradius=findDistancefast(average,vertex[i]); } - boundingsphereradius=fast_sqrt(boundingsphereradius); + boundingsphereradius=sqrt(boundingsphereradius); } bool Model::load(Str255 Name) @@ -99,7 +99,7 @@ bool Model::load(Str255 Name) for(int i=0;i<vertexNum;i++){ if(findDistancefast(average,vertex[i])>boundingsphereradius)boundingsphereradius=findDistancefast(average,vertex[i]); } - boundingsphereradius=fast_sqrt(boundingsphereradius); + boundingsphereradius=sqrt(boundingsphereradius); return 1; } diff --git a/src/Person.cpp b/src/Person.cpp index 6490658..bc77ad9 100644 --- a/src/Person.cpp +++ b/src/Person.cpp @@ -49,7 +49,7 @@ HitStruct Person::BulletCollideWithPlayer(int who, XYZ start, XYZ end){ distancemax=findDistancefast(average,skeleton.joints[j].position); } } - distancemax=fast_sqrt(distancemax); + distancemax=sqrt(distancemax); //Collide with player if(skeleton.free<1){ start=start-playercoords; diff --git a/src/PhysicsMath.h b/src/PhysicsMath.h index c975941..99ef76f 100644 --- a/src/PhysicsMath.h +++ b/src/PhysicsMath.h @@ -162,7 +162,7 @@ inline float Vector::Magnitude(void) { - return (float) fast_sqrt(x*x + y*y + z*z); + return (float) sqrt(x*x + y*y + z*z); } @@ -172,7 +172,7 @@ inline void Vector::Normalize(void) { - float m = (float) fast_sqrt(x*x + y*y + z*z); + float m = (float) sqrt(x*x + y*y + z*z); if(m <= tol) m = 1; @@ -998,7 +998,7 @@ inline float Quaternion::Magnitude(void) { - return (float) fast_sqrt(n*n + v.x*v.x + v.y*v.y + v.z*v.z); + return (float) sqrt(n*n + v.x*v.x + v.y*v.y + v.z*v.z); } diff --git a/src/Quaternions.cpp b/src/Quaternions.cpp index 6edbd3a..9ce344f 100644 --- a/src/Quaternions.cpp +++ b/src/Quaternions.cpp @@ -120,7 +120,7 @@ quaternion To_Quat(Matrix_t m) int i,j,k; if (Tr >= 1.0) { - fourD = 2.0*fast_sqrt(Tr); + fourD = 2.0 * sqrt(Tr); q[3] = fourD/4.0; q[0] = (m[2][1] - m[1][2]) / fourD; q[1] = (m[0][2] - m[2][0]) / fourD; @@ -142,7 +142,7 @@ quaternion To_Quat(Matrix_t m) } j = (i+1)%3; k = (j+1)%3; - fourD = 2.0*fast_sqrt(m[i][i] - m[j][j] - m[k][k] + 1.0); + fourD = 2.0 * sqrt(m[i][i] - m[j][j] - m[k][k] + 1.0); q[i] = fourD / 4.0; q[j] = (m[j][i] + m[i][j]) / fourD; q[k] = (m[k][i] + m[i][k]) / fourD; @@ -276,35 +276,13 @@ void CrossProduct(XYZ P, XYZ Q, XYZ *V){ } void Normalise(XYZ *vectory) { - float d = fast_sqrt(vectory->x*vectory->x+vectory->y*vectory->y+vectory->z*vectory->z); + float d = sqrt(vectory->x*vectory->x+vectory->y*vectory->y+vectory->z*vectory->z); if(d==0){return;} vectory->x /= d; vectory->y /= d; vectory->z /= d; } -float fast_sqrt (register float arg) -{ -#ifdef OS9 - // Can replace with slower return std::sqrt(arg); - register float result; - - if (arg == 0.0) return 0.0; - - asm { - frsqrte result,arg // Calculate Square root - } - - // Newton Rhapson iterations. - result = result + 0.5 * result * (1.0 - arg * result * result); - result = result + 0.5 * result * (1.0 - arg * result * result); - - return result * arg; -#else - return sqrt(arg); -#endif -} - float normaldotproduct(XYZ point1, XYZ point2){ GLfloat returnvalue; Normalise(&point1); @@ -612,11 +590,11 @@ float dotproduct(XYZ point1, XYZ point2){ } float findDistance(XYZ point1, XYZ point2){ - return(fast_sqrt((point1.x-point2.x)*(point1.x-point2.x)+(point1.y-point2.y)*(point1.y-point2.y)+(point1.z-point2.z)*(point1.z-point2.z))); + return sqrt((point1.x-point2.x)*(point1.x-point2.x)+(point1.y-point2.y)*(point1.y-point2.y)+(point1.z-point2.z)*(point1.z-point2.z)); } float findLength(XYZ point1){ - return(fast_sqrt((point1.x)*(point1.x)+(point1.y)*(point1.y)+(point1.z)*(point1.z))); + return sqrt((point1.x)*(point1.x)+(point1.y)*(point1.y)+(point1.z)*(point1.z)); } diff --git a/src/Quaternions.h b/src/Quaternions.h index 0a0ca4f..1678b79 100644 --- a/src/Quaternions.h +++ b/src/Quaternions.h @@ -6,7 +6,6 @@ #pragma mark - #endif -#include "Maths.h" #ifdef OS9 #include <gl.h> #else @@ -69,7 +68,6 @@ XYZ Quat2Vector(quaternion Quat); void CrossProduct(XYZ P, XYZ Q, XYZ *V); void Normalise(XYZ *vectory); float normaldotproduct(XYZ point1, XYZ point2); -float fast_sqrt (register float arg); bool PointInTriangle(XYZ *p, XYZ normal, XYZ *p1, XYZ *p2, XYZ *p3); bool LineFacet(XYZ p1,XYZ p2,XYZ pa,XYZ pb,XYZ pc,XYZ *p); float LineFacetd(XYZ p1,XYZ p2,XYZ pa,XYZ pb,XYZ pc,XYZ *p); diff --git a/src/Sprites.cpp b/src/Sprites.cpp index 9c7bd44..9bf307d 100644 --- a/src/Sprites.cpp +++ b/src/Sprites.cpp @@ -127,7 +127,7 @@ void Sprites::DoStuff() if(type[i]==flashsprite)brightness[i]-=multiplier*10; if(type[i]==smokesprite||type[i]==smokespritenoup||type[i]==bloodspritedown||type[i]==particlesspritedown)brightness[i]-=multiplier*.5; if(type[i]==bloodspritenoup)brightness[i]-=multiplier*.9; - if(type[i]==smokesprite)size[i]=initialsize[i]*abs(fast_sqrt(fast_sqrt((float)abs(initialbrightness[i]-brightness[i]))));//velocity[i].y+=multiplier*20; + if(type[i]==smokesprite)size[i]=initialsize[i]*abs(sqrt(sqrt((float)abs(initialbrightness[i]-brightness[i]))));//velocity[i].y+=multiplier*20; if(type[i]==bloodspritenoup||type[i]==particlesspritedown)size[i]=initialsize[i]*(initialbrightness[i]-brightness[i]+.4)*(initialbrightness[i]-brightness[i]+.4);//velocity[i].y+=multiplier*20; if(type[i]==bloodspritenoup||type[i]==particlesspritedown)velocity[i]=initialvelocity[i]*brightness[i];//velocity[i].y+=multiplier*20; if(type[i]==bullet)brightness[i]-=multiplier; @@ -299,7 +299,7 @@ void Sprites::draw() dx = endProj.x - begProj.x; dy = endProj.y - begProj.y; - oolen= 1/fast_sqrt(dx*dx+dy*dy)*0.5; + oolen= 1/sqrt(dx*dx+dy*dy)*0.5; persp=0; persp.x=-dy*oolen; persp.y=dx*oolen; |