]> git.jsancho.org Git - lugaru.git/blobdiff - Source/Quaternions.h
some more unused variables cleanup
[lugaru.git] / Source / Quaternions.h
index 872500c9ddd8371d4f413515fc7a1eb685c7f2f9..39037b5f2638ca9fc9392f4bcf67eb162ca32ae7 100644 (file)
@@ -1,3 +1,24 @@
+/*
+Copyright (C) 2003, 2010 - Wolfire Games
+
+This file is part of Lugaru.
+
+Lugaru is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
+
+See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+*/
+
 
 #ifndef _QUATERNIONS_H_
 #define _QUATERNIONS_H_
@@ -8,8 +29,8 @@
 
 //#include "Carbon.h"
 #include "math.h"
-#include "Physicsmath.h"
-#include "gl.h"
+#include "PhysicsMath.h"
+#include "gamegl.h"
 
 /**> Quaternion Structures <**/
 #define PI      3.14159265355555897932384626
@@ -37,6 +58,7 @@ public:
        float x;
        float y;
        float z;
+    XYZ() : x(0.0f), y(0.0f), z(0.0f) {}
        inline XYZ operator+(XYZ add);
        inline XYZ operator-(XYZ add);
        inline XYZ operator*(float add);
@@ -76,7 +98,8 @@ float LineFacetd(XYZ *p1,XYZ *p2,XYZ *pa,XYZ *pb,XYZ *pc,XYZ *n, XYZ *p);
 float LineFacetd(XYZ *p1,XYZ *p2,XYZ *pa,XYZ *pb,XYZ *pc, XYZ *p);
 bool PointInTriangle(Vector *p, Vector normal, float p11, float p12, float p13, float p21, float p22, float p23, float p31, float p32, float p33);
 bool LineFacet(Vector p1,Vector p2,Vector pa,Vector pb,Vector pc,Vector *p);
-inline void ReflectVector(XYZ *vel, XYZ *n);
+inline void ReflectVector(XYZ *vel, const XYZ *n);
+inline void ReflectVector(XYZ *vel, const XYZ &n);
 inline XYZ DoRotation(XYZ thePoint, float xang, float yang, float zang);
 inline XYZ DoRotationRadian(XYZ thePoint, float xang, float yang, float zang);
 inline float findDistance(XYZ *point1, XYZ *point2);
@@ -85,7 +108,7 @@ inline float findLengthfast(XYZ *point1);
 inline float findDistancefast(XYZ *point1, XYZ *point2);
 inline float findDistancefast(XYZ point1, XYZ point2);
 inline float findDistancefastflat(XYZ *point1, XYZ *point2);
-inline float dotproduct(XYZ *point1, XYZ *point2);
+inline float dotproduct(const XYZ *point1, const XYZ *point2);
 bool sphere_line_intersection (
                                                           float x1, float y1 , float z1,
                                                           float x2, float y2 , float z2,
@@ -207,9 +230,7 @@ inline void CrossProduct(XYZ P, XYZ Q, XYZ *V){
 
 inline float fast_sqrt (register float arg)
 {      
-#ifdef WIN32
-       return sqrtf( arg);
-#else
+#if PLATFORM_MACOSX
        // Can replace with slower return std::sqrt(arg);
        register float result;
 
@@ -224,6 +245,8 @@ inline float fast_sqrt (register float arg)
        result = result + 0.5 * result * (1.0 - arg * result * result);
 
        return result * arg;
+#else
+       return sqrtf( arg);
 #endif
 }
 
@@ -235,16 +258,21 @@ inline float normaldotproduct(XYZ point1, XYZ point2){
        return returnvalue;
 }
 
-inline void ReflectVector(XYZ *vel, XYZ *n)
+inline void ReflectVector(XYZ *vel, const XYZ *n)
+{
+    ReflectVector(vel, *n);
+}
+
+inline void ReflectVector(XYZ *vel, const XYZ &n)
 {
        static XYZ vn;
        static XYZ vt;
        static float dotprod;
 
-       dotprod=dotproduct(n,vel);
-       vn.x=n->x*dotprod;
-       vn.y=n->y*dotprod;
-       vn.z=n->z*dotprod;
+       dotprod=dotproduct(&n,vel);
+       vn.x=n.x*dotprod;
+       vn.y=n.y*dotprod;
+       vn.z=n.z*dotprod;
 
        vt.x=vel->x-vn.x;
        vt.y=vel->y-vn.y;
@@ -255,7 +283,7 @@ inline void ReflectVector(XYZ *vel, XYZ *n)
        vel->z = vt.z - vn.z;
 }
 
-inline float dotproduct(XYZ *point1, XYZ *point2){
+inline float dotproduct(const XYZ *point1, const XYZ *point2){
        static GLfloat returnvalue;
        returnvalue=(point1->x*point2->x+point1->y*point2->y+point1->z*point2->z);
        return returnvalue;
@@ -342,8 +370,8 @@ inline bool sphere_line_intersection (
        // This function returns a pointer array which first index indicates
        // the number of intersection point, followed by coordinate pairs.
 
-       static float x , y , z;
-       static float a, b, c, mu, i ;
+       //~ static float x , y , z;
+       static float a, b, c, /*mu,*/ i ;
 
        if(x1>x3+r&&x2>x3+r)return(0);
        if(x1<x3-r&&x2<x3-r)return(0);
@@ -381,8 +409,8 @@ inline bool sphere_line_intersection (
        // This function returns a pointer array which first index indicates
        // the number of intersection point, followed by coordinate pairs.
 
-       static float x , y , z;
-       static float a, b, c, mu, i ;
+       //~ static float x , y , z;
+       static float a, b, c, /*mu,*/ i ;
 
        if(p1->x>p3->x+*r&&p2->x>p3->x+*r)return(0);
        if(p1->x<p3->x-*r&&p2->x<p3->x-*r)return(0);
@@ -463,4 +491,4 @@ inline bool DistancePointLine( XYZ *Point, XYZ *LineStart, XYZ *LineEnd, float *
        return 1;
 }
 
-#endif
\ No newline at end of file
+#endif