Browse Source

Removed vec_t typedefs

Thomas Buck 10 years ago
parent
commit
b1fb7c9965

+ 4
- 0
ChangeLog.md View File

2
 
2
 
3
 ## OpenRaider (0.1.3) xythobuz <xythobuz@xythobuz.de>
3
 ## OpenRaider (0.1.3) xythobuz <xythobuz@xythobuz.de>
4
 
4
 
5
+    [ 20140704 ]
6
+    * Removed unnecessary #include dependencies
7
+    * Removed vecX_t typedefs
8
+
5
     [ 20140703 ]
9
     [ 20140703 ]
6
     * Removed SDL_GL_LoadLibrary() call and corresponding
10
     * Removed SDL_GL_LoadLibrary() call and corresponding
7
       config file entry
11
       config file entry

+ 14
- 15
include/Camera.h View File

9
 #ifndef _CAMERA_H_
9
 #ifndef _CAMERA_H_
10
 #define _CAMERA_H_
10
 #define _CAMERA_H_
11
 
11
 
12
-#include "math/math.h"
13
 #include "math/Quaternion.h"
12
 #include "math/Quaternion.h"
14
 
13
 
15
 /*!
14
 /*!
36
      * \brief Get the target currently looked at
35
      * \brief Get the target currently looked at
37
      * \param target where the target will be stored
36
      * \param target where the target will be stored
38
      */
37
      */
39
-    void getTarget(vec3_t target);
38
+    void getTarget(float target[3]);
40
 
39
 
41
     /*!
40
     /*!
42
      * \brief Get angle/yaw of camera
41
      * \brief Get angle/yaw of camera
43
      * \returns theta angle/yaw of camera
42
      * \returns theta angle/yaw of camera
44
      */
43
      */
45
-    vec_t getRadianYaw();
44
+    float getRadianYaw();
46
 
45
 
47
     /*!
46
     /*!
48
      * \brief Get angle/pitch of camera
47
      * \brief Get angle/pitch of camera
49
      * \returns phi angle/pitch of camera
48
      * \returns phi angle/pitch of camera
50
      */
49
      */
51
-    vec_t getRadianPitch();
50
+    float getRadianPitch();
52
 
51
 
53
     /*!
52
     /*!
54
      * \brief Set current position
53
      * \brief Set current position
55
      * \param pos new position
54
      * \param pos new position
56
      */
55
      */
57
-    void setPosition(vec3_t pos);
56
+    void setPosition(float pos[3]);
58
 
57
 
59
-    void setSensitivityX(vec_t sens);
58
+    void setSensitivityX(float sens);
60
 
59
 
61
-    void setSensitivityY(vec_t sens);
60
+    void setSensitivityY(float sens);
62
 
61
 
63
     /*!
62
     /*!
64
      * \brief Updates view target
63
      * \brief Updates view target
73
 
72
 
74
 private:
73
 private:
75
 
74
 
76
-    void rotate(vec_t angle, vec_t x, vec_t y, vec_t z);
75
+    void rotate(float angle, float x, float y, float z);
77
 
76
 
78
     Quaternion mQ;         //!< Quaternion for rotation
77
     Quaternion mQ;         //!< Quaternion for rotation
79
-    vec4_t mPos;           //!< Location in 3 space (aka eye)
80
-    vec4_t mTarget;        //!< Postition we're looking at
81
-    vec_t mViewDistance;   //!< Distance from target
82
-    vec_t mTheta;          //!< View angle Y
83
-    vec_t mTheta2;         //!< View angle Z
84
-    vec_t mRotationDeltaX; //!< Horizontal mouse sensitivity
85
-    vec_t mRotationDeltaY; //!< Vertical mouse sensitivity
78
+    float mPos[4];         //!< Location in 3 space (aka eye)
79
+    float mTarget[4];      //!< Postition we're looking at
80
+    float mViewDistance;   //!< Distance from target
81
+    float mTheta;          //!< View angle Y
82
+    float mTheta2;         //!< View angle Z
83
+    float mRotationDeltaX; //!< Horizontal mouse sensitivity
84
+    float mRotationDeltaY; //!< Vertical mouse sensitivity
86
 };
85
 };
87
 
86
 
88
 Camera &getCamera();
87
 Camera &getCamera();

+ 0
- 1
include/Console.h View File

8
 #ifndef _CONSOLE_H_
8
 #ifndef _CONSOLE_H_
9
 #define _CONSOLE_H_
9
 #define _CONSOLE_H_
10
 
10
 
11
-#include <cstring>
12
 #include <vector>
11
 #include <vector>
13
 
12
 
14
 /*!
13
 /*!

+ 5
- 6
include/Entity.h View File

8
 #ifndef _ENTITY_H_
8
 #ifndef _ENTITY_H_
9
 #define _ENTITY_H_
9
 #define _ENTITY_H_
10
 
10
 
11
-#include "math/math.h"
12
 #include "SkeletalModel.h"
11
 #include "SkeletalModel.h"
13
 #include "TombRaider.h"
12
 #include "TombRaider.h"
14
 
13
 
34
     MoveType getMoveType();
33
     MoveType getMoveType();
35
     void setMoveType(MoveType m);
34
     void setMoveType(MoveType m);
36
     int getObjectId();
35
     int getObjectId();
37
-    void setAngles(vec3_t a);
38
-    vec_t getPos(unsigned int i);
39
-    vec_t getAngle(unsigned int i);
36
+    void setAngles(float a[3]);
37
+    float getPos(unsigned int i);
38
+    float getAngle(unsigned int i);
40
     int getRoom();
39
     int getRoom();
41
 
40
 
42
     // Animation State
41
     // Animation State
48
     void setIdleAnimation(unsigned int index);
47
     void setIdleAnimation(unsigned int index);
49
 
48
 
50
 private:
49
 private:
51
-    vec3_t pos;
52
-    vec3_t angles;
50
+    float pos[3];
51
+    float angles[3];
53
     int room;
52
     int room;
54
 
53
 
55
     unsigned int skeletalModel;
54
     unsigned int skeletalModel;

+ 0
- 1
include/FontTRLE.h View File

8
 #ifndef _FONT_TRLE_H_
8
 #ifndef _FONT_TRLE_H_
9
 #define _FONT_TRLE_H_
9
 #define _FONT_TRLE_H_
10
 
10
 
11
-#include "math/math.h"
12
 #include "Font.h"
11
 #include "Font.h"
13
 
12
 
14
 /*!
13
 /*!

+ 0
- 3
include/Game.h View File

10
 
10
 
11
 #include <vector>
11
 #include <vector>
12
 
12
 
13
-#include "Camera.h"
14
 #include "Entity.h"
13
 #include "Entity.h"
15
-#include "Render.h"
16
 #include "TombRaider.h"
14
 #include "TombRaider.h"
17
-#include "World.h"
18
 
15
 
19
 /*!
16
 /*!
20
  * \brief Game abstraction
17
  * \brief Game abstraction

+ 18
- 20
include/Mesh.h View File

10
 #ifndef _MESH_H_
10
 #ifndef _MESH_H_
11
 #define _MESH_H_
11
 #define _MESH_H_
12
 
12
 
13
-#include "math/math.h"
14
-
15
 /*!
13
 /*!
16
  * \brief OpenGL Mesh
14
  * \brief OpenGL Mesh
17
  */
15
  */
39
         unsigned int cnum_alpha_triangles;
37
         unsigned int cnum_alpha_triangles;
40
 
38
 
41
         unsigned int num_texcoors;
39
         unsigned int num_texcoors;
42
-        vec2_t *texcoors;
40
+        float **texcoors; // 2D
43
 
41
 
44
         unsigned int num_texcoors2;
42
         unsigned int num_texcoors2;
45
-        vec2_t *texcoors2;
43
+        float **texcoors2; // 2D
46
 
44
 
47
         //! Arrays of triangle indices sorted by texture
45
         //! Arrays of triangle indices sorted by texture
48
         unsigned int num_triangles;
46
         unsigned int num_triangles;
64
         unsigned int cnum_alpha_quads;
62
         unsigned int cnum_alpha_quads;
65
 
63
 
66
         unsigned int num_texcoors;
64
         unsigned int num_texcoors;
67
-        vec2_t *texcoors;
65
+        float **texcoors; // 2D
68
 
66
 
69
         unsigned int num_texcoors2;
67
         unsigned int num_texcoors2;
70
-        vec2_t *texcoors2;
68
+        float **texcoors2; // 2D
71
 
69
 
72
         //! Arrays of rectangle indices sorted by texture
70
         //! Arrays of rectangle indices sorted by texture
73
         unsigned int num_quads;
71
         unsigned int num_quads;
103
 
101
 
104
     void allocateVertices(unsigned int n);
102
     void allocateVertices(unsigned int n);
105
 
103
 
106
-    void bufferColorArray(unsigned int colorCount, vec_t *colors);
104
+    void bufferColorArray(unsigned int colorCount, float *colors);
107
 
105
 
108
-    void bufferNormalArray(unsigned int normalCount, vec_t *normals);
106
+    void bufferNormalArray(unsigned int normalCount, float *normals);
109
 
107
 
110
     void bufferTriangles(unsigned int count,
108
     void bufferTriangles(unsigned int count,
111
-                            unsigned int *indices, vec_t *texCoords,
109
+                            unsigned int *indices, float *texCoords,
112
                             int *textures, unsigned int *flags);
110
                             int *textures, unsigned int *flags);
113
 
111
 
114
-    void bufferVertexArray(unsigned int vertexCount, vec_t *vertices);
112
+    void bufferVertexArray(unsigned int vertexCount, float *vertices);
115
 
113
 
116
     void setColor(unsigned int index, float r, float g, float b, float a);
114
     void setColor(unsigned int index, float r, float g, float b, float a);
117
 
115
 
125
     void sortFacesByTexture();
123
     void sortFacesByTexture();
126
 
124
 
127
     void addFace(int textureIndex, int textureIndexB, unsigned int flags,
125
     void addFace(int textureIndex, int textureIndexB, unsigned int flags,
128
-                    unsigned int vertexIndexCount, vec_t *vertexIndices);
126
+                    unsigned int vertexIndexCount, float *vertexIndices);
129
 
127
 
130
     void addTexTiledFace(int textureIndex, int textureIndexB,
128
     void addTexTiledFace(int textureIndex, int textureIndexB,
131
                             unsigned int flags, unsigned int indexCount,
129
                             unsigned int flags, unsigned int indexCount,
132
-                            vec_t *vertexIndices, vec_t *texcoords);
130
+                            float *vertexIndices, float *texcoords);
133
 
131
 
134
-    void bufferTexcoords(unsigned int texcoordCount, vec_t *texcoords);
132
+    void bufferTexcoords(unsigned int texcoordCount, float *texcoords);
135
 
133
 
136
     void duplicateArraysForTexTiledTexcoords();
134
     void duplicateArraysForTexTiledTexcoords();
137
 #endif
135
 #endif
141
     MeshMode mMode;
139
     MeshMode mMode;
142
 
140
 
143
     unsigned int mNumVertices;
141
     unsigned int mNumVertices;
144
-    vec3_t *mVertices; //!< XYZ
142
+    float **mVertices; //!< XYZ
145
 
143
 
146
     unsigned int mNumNormals;
144
     unsigned int mNumNormals;
147
-    vec3_t *mNormals; //!< IJK
145
+    float **mNormals; //!< IJK
148
 
146
 
149
     unsigned int mNumColors;
147
     unsigned int mNumColors;
150
-    vec4_t *mColors; //!< RGBA
148
+    float **mColors; //!< RGBA
151
 
149
 
152
     unsigned int mNumTris;
150
     unsigned int mNumTris;
153
     tris_t *mTris;
151
     tris_t *mTris;
159
     int *mTriangleTextures;
157
     int *mTriangleTextures;
160
     unsigned int *mTriangleIndices;
158
     unsigned int *mTriangleIndices;
161
     unsigned int *mTriangleFlags;
159
     unsigned int *mTriangleFlags;
162
-    vec_t *mTriangleTexCoordArray;
160
+    float *mTriangleTexCoordArray;
163
 
161
 
164
-    vec_t *mVertexArray;
165
-    vec_t *mNormalArray;
166
-    vec_t *mColorArray;
162
+    float *mVertexArray;
163
+    float *mNormalArray;
164
+    float *mColorArray;
167
 };
165
 };
168
 
166
 
169
 #endif
167
 #endif

+ 1
- 8
include/OpenRaider.h View File

8
 #ifndef _OPENRAIDER_H_
8
 #ifndef _OPENRAIDER_H_
9
 #define _OPENRAIDER_H_
9
 #define _OPENRAIDER_H_
10
 
10
 
11
-#include <sstream>
11
+#include <istream>
12
 #include <string>
12
 #include <string>
13
-#include <vector>
14
-
15
-#include "Console.h"
16
-#include "Font.h"
17
-#include "Game.h"
18
-#include "Menu.h"
19
-#include "Sound.h"
20
 
13
 
21
 /*!
14
 /*!
22
  * \brief Main Game Singleton
15
  * \brief Main Game Singleton

+ 3
- 4
include/Room.h View File

9
 #define _ROOM_H_
9
 #define _ROOM_H_
10
 
10
 
11
 #include <vector>
11
 #include <vector>
12
-#include "math/math.h"
13
 #include "Mesh.h"
12
 #include "Mesh.h"
14
 #include "Sprite.h"
13
 #include "Sprite.h"
15
 #include "TombRaider.h"
14
 #include "TombRaider.h"
37
 
36
 
38
     unsigned int getNumXSectors();
37
     unsigned int getNumXSectors();
39
     unsigned int getNumZSectors();
38
     unsigned int getNumZSectors();
40
-    void getPos(vec3_t p);
39
+    void getPos(float p[3]);
41
 
40
 
42
     void setFlags(unsigned int f);
41
     void setFlags(unsigned int f);
43
     unsigned int getFlags();
42
     unsigned int getFlags();
69
     unsigned int flags;
68
     unsigned int flags;
70
     unsigned int numXSectors;
69
     unsigned int numXSectors;
71
     unsigned int numZSectors;
70
     unsigned int numZSectors;
72
-    vec3_t pos;
71
+    float pos[3];
73
 
72
 
74
     BoundingBox bbox;
73
     BoundingBox bbox;
75
     Mesh mesh;
74
     Mesh mesh;
83
     std::vector<Light *> lights;
82
     std::vector<Light *> lights;
84
 
83
 
85
     // Was used for "depth sorting" render list, but never assigned...?!
84
     // Was used for "depth sorting" render list, but never assigned...?!
86
-    //vec_t dist; // Distance to near plane, move to room?
85
+    //float dist; // Distance to near plane, move to room?
87
 };
86
 };
88
 
87
 
89
 #endif
88
 #endif

+ 26
- 30
include/RoomData.h View File

10
 
10
 
11
 #include <vector>
11
 #include <vector>
12
 #include <memory>
12
 #include <memory>
13
-#include "math/math.h"
14
 #include "math/Matrix.h"
13
 #include "math/Matrix.h"
15
 #include "TombRaider.h"
14
 #include "TombRaider.h"
16
 
15
 
17
 class BoundingBox {
16
 class BoundingBox {
18
 public:
17
 public:
19
     BoundingBox();
18
     BoundingBox();
20
-    void getBoundingBox(vec3_t box[2]);
21
-    void setBoundingBox(vec3_t min, vec3_t max);
19
+    void getBoundingBox(float box[2][3]);
20
+    void setBoundingBox(float min[3], float max[3]);
22
     void display(bool points, const unsigned char c1[4], const unsigned char c2[4]);
21
     void display(bool points, const unsigned char c1[4], const unsigned char c2[4]);
23
-    bool inBox(vec_t x, vec_t y, vec_t z);
24
-    bool inBoxPlane(vec_t x, vec_t z);
22
+    bool inBox(float x, float y, float z);
23
+    bool inBoxPlane(float x, float z);
25
 
24
 
26
 private:
25
 private:
27
-    vec3_t a, b;
26
+    float a[3], b[3];
28
 };
27
 };
29
 
28
 
30
 class Light {
29
 class Light {
40
 
39
 
41
     Light(TombRaider &tr, unsigned int room, unsigned int index);
40
     Light(TombRaider &tr, unsigned int room, unsigned int index);
42
 
41
 
43
-    void getPos(vec4_t p);
44
-    void getDir(vec3_t d);
45
-    vec_t getAtt();
46
-    void getColor(vec4_t c);
47
-    vec_t getCutoff();
42
+    void getPos(float p[4]);
43
+    void getDir(float d[3]);
44
+    float getAtt();
45
+    void getColor(float c[4]);
46
+    float getCutoff();
48
     LightType getType();
47
     LightType getType();
49
 
48
 
50
 private:
49
 private:
51
-    vec4_t pos; //! Light position in 3 space
52
-    vec3_t dir; //! Light direction
53
-    vec_t att;
54
-    vec4_t color; //! Color of light
55
-    vec_t cutoff; //! Fade out distance
50
+    float pos[4]; //! Light position in 3 space
51
+    float dir[3]; //! Light direction
52
+    float att;
53
+    float color[4]; //! Color of light
54
+    float cutoff; //! Fade out distance
56
     LightType type; //! Type of light
55
     LightType type; //! Type of light
57
 };
56
 };
58
 
57
 
66
 
65
 
67
 private:
66
 private:
68
     int index;
67
     int index;
69
-    vec_t yaw;
70
-    vec3_t pos;
68
+    float yaw;
69
+    float pos[3];
71
 
70
 
72
     // ?
71
     // ?
73
-    //vec3_t bbox[2];
72
+    //float bbox[2][3];
74
 };
73
 };
75
 
74
 
76
 class Portal {
75
 class Portal {
77
 public:
76
 public:
78
     Portal(TombRaider &tr, unsigned int room, unsigned int index, Matrix &transform);
77
     Portal(TombRaider &tr, unsigned int room, unsigned int index, Matrix &transform);
79
 
78
 
80
-    void getVertices(vec3_t vert[4]);
79
+    void getVertices(float vert[4][3]);
81
     int getAdjoiningRoom();
80
     int getAdjoiningRoom();
82
 
81
 
83
 private:
82
 private:
84
-    vec3_t vertices[4];
85
-    vec3_t normal;
83
+    float vertices[4][3];
84
+    float normal[3];
86
     int adjoiningRoom;
85
     int adjoiningRoom;
87
 };
86
 };
88
 
87
 
91
     Box(TombRaider &tr, unsigned int room, unsigned int index);
90
     Box(TombRaider &tr, unsigned int room, unsigned int index);
92
 
91
 
93
 private:
92
 private:
94
-    vec3_t a;
95
-    vec3_t b;
96
-    vec3_t c;
97
-    vec3_t d;
93
+    float a[3], b[3], c[3], d[3];
98
 };
94
 };
99
 
95
 
100
 class Sector {
96
 class Sector {
101
 public:
97
 public:
102
     Sector(TombRaider &tr, unsigned int room, unsigned int index);
98
     Sector(TombRaider &tr, unsigned int room, unsigned int index);
103
-    vec_t getFloor();
104
-    vec_t getCeiling();
99
+    float getFloor();
100
+    float getCeiling();
105
     bool isWall();
101
     bool isWall();
106
 
102
 
107
 private:
103
 private:
108
-    vec_t floor;
109
-    vec_t ceiling;
104
+    float floor;
105
+    float ceiling;
110
     bool wall;
106
     bool wall;
111
 };
107
 };
112
 
108
 

+ 11
- 12
include/SkeletalModel.h View File

11
 
11
 
12
 #include <vector>
12
 #include <vector>
13
 
13
 
14
-#include "math/math.h"
15
 #include "TombRaider.h"
14
 #include "TombRaider.h"
16
 
15
 
17
 class BoneTag {
16
 class BoneTag {
19
     BoneTag(TombRaider &tr, unsigned int index, unsigned int j, unsigned int *l, unsigned int frame_offset);
18
     BoneTag(TombRaider &tr, unsigned int index, unsigned int j, unsigned int *l, unsigned int frame_offset);
20
     void display();
19
     void display();
21
 
20
 
22
-    void getOffset(vec3_t o);
23
-    void getRotation(vec3_t r);
21
+    void getOffset(float o[3]);
22
+    void getRotation(float r[3]);
24
     char getFlag();
23
     char getFlag();
25
 
24
 
26
 private:
25
 private:
27
     int mesh;
26
     int mesh;
28
-    vec3_t off;
29
-    vec3_t rot;
27
+    float off[3];
28
+    float rot[3];
30
     char flag;
29
     char flag;
31
 };
30
 };
32
 
31
 
35
     BoneFrame(TombRaider &tr, unsigned int index, unsigned int frame_offset);
34
     BoneFrame(TombRaider &tr, unsigned int index, unsigned int frame_offset);
36
     ~BoneFrame();
35
     ~BoneFrame();
37
 
36
 
38
-    void getPosition(vec3_t p);
37
+    void getPosition(float p[3]);
39
 
38
 
40
     unsigned int size();
39
     unsigned int size();
41
     BoneTag &get(unsigned int i);
40
     BoneTag &get(unsigned int i);
42
 
41
 
43
 private:
42
 private:
44
-    vec3_t pos;
43
+    float pos[3];
45
     std::vector<BoneTag *> tag;
44
     std::vector<BoneTag *> tag;
46
 };
45
 };
47
 
46
 
66
 
65
 
67
     int getId();
66
     int getId();
68
     void setPigTail(bool b);
67
     void setPigTail(bool b);
69
-    void setPonyPos(vec_t x, vec_t y, vec_t z, vec_t angle);
68
+    void setPonyPos(float x, float y, float z, float angle);
70
 
69
 
71
     unsigned int size();
70
     unsigned int size();
72
     AnimationFrame &get(unsigned int i);
71
     AnimationFrame &get(unsigned int i);
76
     bool tr4Overlay;
75
     bool tr4Overlay;
77
     bool pigtails;
76
     bool pigtails;
78
     int ponytailId;
77
     int ponytailId;
79
-    vec3_t ponytail;
78
+    float ponytail[3];
80
     int ponytailMeshId;
79
     int ponytailMeshId;
81
     unsigned int ponytailNumMeshes;
80
     unsigned int ponytailNumMeshes;
82
-    vec_t ponytailAngle;
83
-    vec_t ponyOff;
84
-    vec_t ponyOff2;
81
+    float ponytailAngle;
82
+    float ponyOff;
83
+    float ponyOff2;
85
     std::vector<AnimationFrame *> animation;
84
     std::vector<AnimationFrame *> animation;
86
 };
85
 };
87
 
86
 

+ 4
- 5
include/Sprite.h View File

8
 #ifndef _SPRITE_H_
8
 #ifndef _SPRITE_H_
9
 #define _SPRITE_H_
9
 #define _SPRITE_H_
10
 
10
 
11
-#include "math/math.h"
12
 #include "TombRaider.h"
11
 #include "TombRaider.h"
13
 
12
 
14
 class Sprite {
13
 class Sprite {
18
     void display();
17
     void display();
19
 
18
 
20
 private:
19
 private:
21
-    vec3_t vertex[4];
22
-    vec2_t texel[4];
23
-    vec3_t pos;
24
-    vec_t radius;     //!< \fixme yeah, I know (I don't? --xythobuz)
20
+    float vertex[4][3];
21
+    float texel[4][2];
22
+    float pos[3];
23
+    float radius; //!< \fixme yeah, I know (I don't? --xythobuz)
25
     int texture;
24
     int texture;
26
 };
25
 };
27
 
26
 

+ 9
- 10
include/StaticMesh.h View File

9
 #define _STATIC_MODEL_H_
9
 #define _STATIC_MODEL_H_
10
 
10
 
11
 #include <vector>
11
 #include <vector>
12
-#include "math/math.h"
13
 #include "TombRaider.h"
12
 #include "TombRaider.h"
14
 
13
 
15
 class TexturedTriangle {
14
 class TexturedTriangle {
16
 public:
15
 public:
17
-    TexturedTriangle(int i[3], vec_t s[6], int tex, unsigned short trans);
18
-    void display(vec_t *vertices, vec_t *colors, vec_t *normals);
16
+    TexturedTriangle(int i[3], float s[6], int tex, unsigned short trans);
17
+    void display(float *vertices, float *colors, float *normals);
19
 
18
 
20
 private:
19
 private:
21
     int index[3];
20
     int index[3];
22
-    vec_t st[6];
21
+    float st[6];
23
     int texture;
22
     int texture;
24
     unsigned short transparency;
23
     unsigned short transparency;
25
 };
24
 };
29
     StaticMesh(TombRaider &tr, unsigned int index);
28
     StaticMesh(TombRaider &tr, unsigned int index);
30
     ~StaticMesh();
29
     ~StaticMesh();
31
     void display();
30
     void display();
32
-    vec_t getRadius();
31
+    float getRadius();
33
 
32
 
34
 private:
33
 private:
35
     bool dontshow;
34
     bool dontshow;
36
-    vec3_t center;
37
-    vec_t radius;
35
+    float center[3];
36
+    float radius;
38
 
37
 
39
     unsigned int vertexCount;
38
     unsigned int vertexCount;
40
     unsigned int colorCount;
39
     unsigned int colorCount;
41
     unsigned int normalCount;
40
     unsigned int normalCount;
42
 
41
 
43
-    vec_t *vertices;
44
-    vec_t *colors;
45
-    vec_t *normals;
42
+    float *vertices;
43
+    float *colors;
44
+    float *normals;
46
 
45
 
47
     std::vector<TexturedTriangle *> triangles;
46
     std::vector<TexturedTriangle *> triangles;
48
 };
47
 };

+ 11
- 12
include/ViewVolume.h View File

9
 #define _VIEWVOLUME_H_
9
 #define _VIEWVOLUME_H_
10
 
10
 
11
 #include "math/Matrix.h"
11
 #include "math/Matrix.h"
12
-#include "RoomData.h"
13
 
12
 
14
 /*!
13
 /*!
15
  * \brief Viewing Volume for culling use
14
  * \brief Viewing Volume for culling use
51
      * \param z Z coordinate of point
50
      * \param z Z coordinate of point
52
      * \returns true if point in view volume
51
      * \returns true if point in view volume
53
      */
52
      */
54
-    bool isPointInFrustum(vec_t x, vec_t y, vec_t z);
53
+    bool isPointInFrustum(float x, float y, float z);
55
 
54
 
56
     /*!
55
     /*!
57
      * \brief Check if bounding sphere is in view volume
56
      * \brief Check if bounding sphere is in view volume
61
      * \param radius radius of a valid abstract sphere
60
      * \param radius radius of a valid abstract sphere
62
      * \returns true if abstract sphere in view volume
61
      * \returns true if abstract sphere in view volume
63
      */
62
      */
64
-    bool isSphereInFrustum(vec_t x, vec_t y, vec_t z, vec_t radius);
63
+    bool isSphereInFrustum(float x, float y, float z, float radius);
65
 
64
 
66
     /*!
65
     /*!
67
      * \brief Check if bounding box is in view volume
66
      * \brief Check if bounding box is in view volume
69
      * \param max maximum point of valid abstract bounding box
68
      * \param max maximum point of valid abstract bounding box
70
      * \returns true if abstract bounding box in view volume
69
      * \returns true if abstract bounding box in view volume
71
      */
70
      */
72
-    bool isBboxInFrustum(vec3_t min, vec3_t max);
71
+    bool isBboxInFrustum(float min[3], float max[3]);
73
 
72
 
74
     /*!
73
     /*!
75
      * \brief Distance to Bounding sphere
74
      * \brief Distance to Bounding sphere
79
      * \param radius radius of a valid abstract sphere
78
      * \param radius radius of a valid abstract sphere
80
      * \returns distance to abstract sphere bounding volume
79
      * \returns distance to abstract sphere bounding volume
81
      */
80
      */
82
-    vec_t getDistToSphereFromNear(vec_t x, vec_t y, vec_t z, vec_t radius);
81
+    float getDistToSphereFromNear(float x, float y, float z, float radius);
83
 
82
 
84
     /*!
83
     /*!
85
      * \brief Distance to Bounding box
84
      * \brief Distance to Bounding box
87
      * \param max maximum point of a valid abstract bounding box
86
      * \param max maximum point of a valid abstract bounding box
88
      * \returns distance to abstract box bounding volume
87
      * \returns distance to abstract box bounding volume
89
      */
88
      */
90
-    vec_t getDistToBboxFromNear(const vec3_t min, const vec3_t max);
89
+    float getDistToBboxFromNear(const float min[3], const float max[3]);
91
 
90
 
92
     /*!
91
     /*!
93
      * \brief Get a copy of the view volume
92
      * \brief Get a copy of the view volume
94
      * \param frustum where frustum will be stored
93
      * \param frustum where frustum will be stored
95
      */
94
      */
96
-    void getFrustum(vec_t frustum[6][4]);
95
+    void getFrustum(float frustum[6][4]);
97
 
96
 
98
     /*!
97
     /*!
99
      * \brief Get a copy of a given plane in view volume
98
      * \brief Get a copy of a given plane in view volume
100
      * \param p side
99
      * \param p side
101
      * \param plane wher plane will be stored
100
      * \param plane wher plane will be stored
102
      */
101
      */
103
-    void getPlane(ViewVolumeSide p, vec4_t plane);
102
+    void getPlane(ViewVolumeSide p, float plane[4]);
104
 
103
 
105
     /*!
104
     /*!
106
      * \brief Updates view volume for this frame.
105
      * \brief Updates view volume for this frame.
107
      * \param proj new projection matrix
106
      * \param proj new projection matrix
108
      * \param mdl new model matrix
107
      * \param mdl new model matrix
109
      */
108
      */
110
-    void updateFrame(matrix_t proj, matrix_t mdl);
109
+    void updateFrame(float proj[16], float mdl[16]);
111
 
110
 
112
     /*!
111
     /*!
113
      * \brief Updates view volume for this frame.
112
      * \brief Updates view volume for this frame.
120
      * \brief Set this class' model matrix
119
      * \brief Set this class' model matrix
121
      * \param mdl new model matrix
120
      * \param mdl new model matrix
122
      */
121
      */
123
-    void setModel(matrix_t mdl);
122
+    void setModel(float mdl[16]);
124
 
123
 
125
     /*!
124
     /*!
126
      * \brief Set this class' projection matrix
125
      * \brief Set this class' projection matrix
127
      * \param proj new projection matrix
126
      * \param proj new projection matrix
128
      */
127
      */
129
-    void setProjection(matrix_t proj);
128
+    void setProjection(float proj[16]);
130
 
129
 
131
 private:
130
 private:
132
 
131
 
147
     Matrix mProjection;   //!< Projection matrix
146
     Matrix mProjection;   //!< Projection matrix
148
     Matrix mModel;        //!< Model matrix
147
     Matrix mModel;        //!< Model matrix
149
     Matrix mClip;         //!< Clipping matrix
148
     Matrix mClip;         //!< Clipping matrix
150
-    vec_t mFrustum[6][4]; //!< View volume
149
+    float mFrustum[6][4]; //!< View volume
151
 };
150
 };
152
 
151
 
153
 #endif
152
 #endif

+ 2
- 7
include/Window.h View File

8
 #ifndef _WINDOW_H_
8
 #ifndef _WINDOW_H_
9
 #define _WINDOW_H_
9
 #define _WINDOW_H_
10
 
10
 
11
-#include <ctime>
12
-
13
 /*!
11
 /*!
14
  * \brief Windowing interface
12
  * \brief Windowing interface
15
  */
13
  */
16
 class Window {
14
 class Window {
17
 public:
15
 public:
18
 
16
 
19
-    /*!
20
-     * \brief Deconstructs an object of Window
21
-     */
22
-    virtual ~Window();
17
+    virtual ~Window() {}
23
 
18
 
24
     virtual void setSize(unsigned int width, unsigned int height) = 0;
19
     virtual void setSize(unsigned int width, unsigned int height) = 0;
25
 
20
 
33
 
28
 
34
     virtual void setTextInput(bool on) = 0;
29
     virtual void setTextInput(bool on) = 0;
35
 
30
 
36
-    virtual void delay(clock_t ms) = 0;
31
+    virtual void delay(unsigned int ms) = 0;
37
 
32
 
38
     virtual void swapBuffersGL() = 0;
33
     virtual void swapBuffersGL() = 0;
39
 
34
 

+ 1
- 1
include/WindowSDL.h View File

40
 
40
 
41
     virtual void setTextInput(bool on);
41
     virtual void setTextInput(bool on);
42
 
42
 
43
-    virtual void delay(clock_t ms);
43
+    virtual void delay(unsigned int ms);
44
 
44
 
45
     virtual void swapBuffersGL();
45
     virtual void swapBuffersGL();
46
 
46
 

+ 0
- 1
include/World.h View File

9
 #ifndef _WORLD_H_
9
 #ifndef _WORLD_H_
10
 #define _WORLD_H_
10
 #define _WORLD_H_
11
 
11
 
12
-#include <list>
13
 #include <vector>
12
 #include <vector>
14
 
13
 
15
 #include "Entity.h"
14
 #include "Entity.h"

+ 16
- 16
include/math/Matrix.h View File

46
      * \brief Constructs an object of Matrix
46
      * \brief Constructs an object of Matrix
47
      * \param mat Matrix as data source
47
      * \param mat Matrix as data source
48
      */
48
      */
49
-    Matrix(matrix_t mat);
49
+    Matrix(float mat[16]);
50
 
50
 
51
     /*!
51
     /*!
52
      * \brief Constructs an object of Matrix
52
      * \brief Constructs an object of Matrix
58
      * \brief Returns this matrix copy
58
      * \brief Returns this matrix copy
59
      * \param mat target
59
      * \param mat target
60
      */
60
      */
61
-    void getMatrix(matrix_t mat);
61
+    void getMatrix(float mat[16]);
62
 
62
 
63
     /*!
63
     /*!
64
      * \brief Returns this matrix transposed
64
      * \brief Returns this matrix transposed
65
      * \param mat target
65
      * \param mat target
66
      */
66
      */
67
-    void getTransposeMatrix(matrix_t mat);
67
+    void getTransposeMatrix(float mat[16]);
68
 
68
 
69
     /*!
69
     /*!
70
      * \brief Returns this matrix inverted
70
      * \brief Returns this matrix inverted
71
      * \param mat target
71
      * \param mat target
72
      */
72
      */
73
-    bool getInvert(matrix_t mat);
73
+    bool getInvert(float mat[16]);
74
 
74
 
75
     /*!
75
     /*!
76
      * \brief Multiplies two matrices
76
      * \brief Multiplies two matrices
85
      * \param v vector
85
      * \param v vector
86
      * \param result where the result will be stored, may be same as v
86
      * \param result where the result will be stored, may be same as v
87
      */
87
      */
88
-    void multiply4v(vec4_t v, vec4_t result);
88
+    void multiply4v(float v[4], float result[4]);
89
 
89
 
90
     /*!
90
     /*!
91
      * \brief Multiplies v vector and this matrix
91
      * \brief Multiplies v vector and this matrix
92
      * \param v vector
92
      * \param v vector
93
      * \param result where the result will be stored, may be same as v
93
      * \param result where the result will be stored, may be same as v
94
      */
94
      */
95
-    void multiply3v(vec3_t v, vec3_t result);
95
+    void multiply3v(float v[3], float result[3]);
96
 
96
 
97
     /*!
97
     /*!
98
      * \brief Prints matrix values to stdout
98
      * \brief Prints matrix values to stdout
129
      * \fixme dangerous, scary, boo!
129
      * \fixme dangerous, scary, boo!
130
      * \param mat new matrix
130
      * \param mat new matrix
131
      */
131
      */
132
-    void setMatrix(matrix_t mat);
132
+    void setMatrix(float mat[16]);
133
 
133
 
134
     /*!
134
     /*!
135
      * \brief Rotate object in 3D space
135
      * \brief Rotate object in 3D space
137
      * \param y y rotation in radians
137
      * \param y y rotation in radians
138
      * \param z z rotation in radians
138
      * \param z z rotation in radians
139
      */
139
      */
140
-    void rotate(vec_t x, vec_t y, vec_t z);
140
+    void rotate(float x, float y, float z);
141
 
141
 
142
     /*!
142
     /*!
143
      * \brief Rotate object in 3D space
143
      * \brief Rotate object in 3D space
144
      * \param xyz rotation in radians
144
      * \param xyz rotation in radians
145
      */
145
      */
146
-    void rotate(const vec_t *xyz);
146
+    void rotate(const float *xyz);
147
 
147
 
148
     /*!
148
     /*!
149
      * \brief Scale object in 3D space
149
      * \brief Scale object in 3D space
151
      * \param y y scaling
151
      * \param y y scaling
152
      * \param z z scaling
152
      * \param z z scaling
153
      */
153
      */
154
-    void scale(vec_t x, vec_t y, vec_t z);
154
+    void scale(float x, float y, float z);
155
 
155
 
156
     /*!
156
     /*!
157
      * \brief Scale object in 3D space
157
      * \brief Scale object in 3D space
158
      * \param xyz scaling factors
158
      * \param xyz scaling factors
159
      */
159
      */
160
-    void scale(const vec_t *xyz);
160
+    void scale(const float *xyz);
161
 
161
 
162
     /*!
162
     /*!
163
      * \brief Translate (move) object in 3D space
163
      * \brief Translate (move) object in 3D space
165
      * \param y y translation
165
      * \param y y translation
166
      * \param z z translation
166
      * \param z z translation
167
      */
167
      */
168
-    void translate(vec_t x, vec_t y, vec_t z);
168
+    void translate(float x, float y, float z);
169
 
169
 
170
     /*!
170
     /*!
171
      * \brief Translate (move) object in 3D space
171
      * \brief Translate (move) object in 3D space
172
      * \param xyz translations
172
      * \param xyz translations
173
      */
173
      */
174
-    void translate(const vec_t *xyz);
174
+    void translate(const float *xyz);
175
 
175
 
176
     /*!
176
     /*!
177
      * \brief Transpose this matrix
177
      * \brief Transpose this matrix
178
      */
178
      */
179
     void transpose();
179
     void transpose();
180
 
180
 
181
-    matrix_t mMatrix; //!< Data model, moved public for faster external renderer feedback use
181
+    float mMatrix[16]; //!< Data model, moved public for faster external renderer feedback use
182
 
182
 
183
 private:
183
 private:
184
 
184
 
187
      * \param source source
187
      * \param source source
188
      * \param dest destination
188
      * \param dest destination
189
      */
189
      */
190
-    static void copy(matrix_t source, matrix_t dest);
190
+    static void copy(float source[16], float dest[16]);
191
 
191
 
192
     /*!
192
     /*!
193
      * \brief Multiplies matrices a and b. Neither a or b is also the result.
193
      * \brief Multiplies matrices a and b. Neither a or b is also the result.
195
      * \param b second matrix
195
      * \param b second matrix
196
      * \param result wil be set to resultant matrix value
196
      * \param result wil be set to resultant matrix value
197
      */
197
      */
198
-    static void multiply(const matrix_t a, const matrix_t b, matrix_t result);
198
+    static void multiply(const float a[16], const float b[16], float result[16]);
199
 };
199
 };
200
 
200
 
201
 #endif
201
 #endif

+ 13
- 13
include/math/Quaternion.h View File

28
      * \param y Y part of new Quaternion
28
      * \param y Y part of new Quaternion
29
      * \param z Z part of new Quaternion
29
      * \param z Z part of new Quaternion
30
      */
30
      */
31
-    Quaternion(vec_t w, vec_t x, vec_t y, vec_t z);
31
+    Quaternion(float w, float x, float y, float z);
32
 
32
 
33
     /*!
33
     /*!
34
      * \brief Constructs an object of Quaternion
34
      * \brief Constructs an object of Quaternion
35
      * \param v contents of new Quaternion
35
      * \param v contents of new Quaternion
36
      */
36
      */
37
-    Quaternion(vec4_t v);
37
+    Quaternion(float v[4]);
38
 
38
 
39
     /*!
39
     /*!
40
      * \brief Get column order matrix equivalent of this quaternion
40
      * \brief Get column order matrix equivalent of this quaternion
41
      * \param m where matrix will be stored
41
      * \param m where matrix will be stored
42
      */
42
      */
43
-    void getMatrix(matrix_t m);
43
+    void getMatrix(float m[16]);
44
 
44
 
45
     /*!
45
     /*!
46
      * \brief Multiplies this quaternion.
46
      * \brief Multiplies this quaternion.
92
      * \param s scaling factor
92
      * \param s scaling factor
93
      * \returns Scaled result of this quaternion
93
      * \returns Scaled result of this quaternion
94
      */
94
      */
95
-    Quaternion scale(vec_t s);
95
+    Quaternion scale(float s);
96
 
96
 
97
     /*!
97
     /*!
98
      * \brief Inverse this quaternion
98
      * \brief Inverse this quaternion
106
      * \param b second argument to dot product
106
      * \param b second argument to dot product
107
      * \returns dot product between a and b quaternions
107
      * \returns dot product between a and b quaternions
108
      */
108
      */
109
-    static vec_t dot(Quaternion a, Quaternion b);
109
+    static float dot(Quaternion a, Quaternion b);
110
 
110
 
111
     /*!
111
     /*!
112
      * \brief Magnitude of this quaternion
112
      * \brief Magnitude of this quaternion
113
      * \returns Magnitude of this quaternion
113
      * \returns Magnitude of this quaternion
114
      */
114
      */
115
-    vec_t magnitude();
115
+    float magnitude();
116
 
116
 
117
     /*!
117
     /*!
118
      * \brief Interpolates between a and b rotations.
118
      * \brief Interpolates between a and b rotations.
125
      * \param time time argument for slerp
125
      * \param time time argument for slerp
126
      * \returns resultant quaternion
126
      * \returns resultant quaternion
127
      */
127
      */
128
-    static Quaternion slerp(Quaternion a, Quaternion b, vec_t time);
128
+    static Quaternion slerp(Quaternion a, Quaternion b, float time);
129
 
129
 
130
     /*!
130
     /*!
131
      * \brief Sets this quaternion to identity
131
      * \brief Sets this quaternion to identity
139
      * \param y new Y coordinate
139
      * \param y new Y coordinate
140
      * \param z new Z coordinate
140
      * \param z new Z coordinate
141
      */
141
      */
142
-    void set(vec_t angle, vec_t x, vec_t y, vec_t z);
142
+    void set(float angle, float x, float y, float z);
143
 
143
 
144
     /*!
144
     /*!
145
      * \brief Normalize this quaternion
145
      * \brief Normalize this quaternion
156
      * \brief Sets matrix equivalent of this quaternion
156
      * \brief Sets matrix equivalent of this quaternion
157
      * \param m matrix in valid column order
157
      * \param m matrix in valid column order
158
      */
158
      */
159
-    void setByMatrix(matrix_t m);
159
+    void setByMatrix(float m[16]);
160
 
160
 
161
 private:
161
 private:
162
 
162
 
192
      */
192
      */
193
     static Quaternion subtract(Quaternion a, Quaternion b);
193
     static Quaternion subtract(Quaternion a, Quaternion b);
194
 
194
 
195
-    vec_t mW; //!< Quaternion, W part
196
-    vec_t mX; //!< Quaternion, X part
197
-    vec_t mY; //!< Quaternion, Y part
198
-    vec_t mZ; //!< Quaternion, Z part
195
+    float mW; //!< Quaternion, W part
196
+    float mX; //!< Quaternion, X part
197
+    float mY; //!< Quaternion, Y part
198
+    float mZ; //!< Quaternion, Z part
199
 };
199
 };
200
 
200
 
201
 #endif
201
 #endif

+ 9
- 9
include/math/Vector3d.h View File

25
      * \brief Constructs an object of Vector3d
25
      * \brief Constructs an object of Vector3d
26
      * \param v data to load into new Vector3d
26
      * \param v data to load into new Vector3d
27
      */
27
      */
28
-    Vector3d(vec3_t v);
28
+    Vector3d(float v[3]);
29
 
29
 
30
     /*!
30
     /*!
31
      * \brief Constructs an object of Vector3d
31
      * \brief Constructs an object of Vector3d
33
      * \param y Y part of new Vector3d
33
      * \param y Y part of new Vector3d
34
      * \param z Z part of new Vector3d
34
      * \param z Z part of new Vector3d
35
      */
35
      */
36
-    Vector3d(vec_t x, vec_t y, vec_t z);
36
+    Vector3d(float x, float y, float z);
37
 
37
 
38
     /*!
38
     /*!
39
      * \brief Constructs an object of Vector3d
39
      * \brief Constructs an object of Vector3d
47
      * \param v second argument
47
      * \param v second argument
48
      * \returns dot product of u and v vectors
48
      * \returns dot product of u and v vectors
49
      */
49
      */
50
-    static vec_t dot(const Vector3d &u, const Vector3d &v);
50
+    static float dot(const Vector3d &u, const Vector3d &v);
51
 
51
 
52
     /*!
52
     /*!
53
      * \brief Calculate cross product
53
      * \brief Calculate cross product
61
      * \brief Get Magnitude
61
      * \brief Get Magnitude
62
      * \returns magnitude of this vector
62
      * \returns magnitude of this vector
63
      */
63
      */
64
-    vec_t magnitude();
64
+    float magnitude();
65
 
65
 
66
     /*!
66
     /*!
67
      * \brief Normalize
67
      * \brief Normalize
100
      * \param s scaling factor
100
      * \param s scaling factor
101
      * \returns this vector multiplied with s
101
      * \returns this vector multiplied with s
102
      */
102
      */
103
-    Vector3d operator *(vec_t s);
103
+    Vector3d operator *(float s);
104
 
104
 
105
     /*!
105
     /*!
106
      * \brief Scale this vactor
106
      * \brief Scale this vactor
107
      * \param s inverse scaling factor
107
      * \param s inverse scaling factor
108
      * \returns this vector divided by s
108
      * \returns this vector divided by s
109
      */
109
      */
110
-    Vector3d operator /(vec_t s);
110
+    Vector3d operator /(float s);
111
 
111
 
112
     /*!
112
     /*!
113
      * \brief Dot product this vector
113
      * \brief Dot product this vector
114
      * \param v second vector for dot product
114
      * \param v second vector for dot product
115
      * \returns dot product of V by this vector
115
      * \returns dot product of V by this vector
116
      */
116
      */
117
-    vec_t operator *(const Vector3d &v);
117
+    float operator *(const Vector3d &v);
118
 
118
 
119
     /*!
119
     /*!
120
      * \brief Normalizes this vector
120
      * \brief Normalizes this vector
152
      * \param s scaling factor
152
      * \param s scaling factor
153
      * \returns this vactor multiplied by s
153
      * \returns this vactor multiplied by s
154
      */
154
      */
155
-    Vector3d &operator *=(vec_t s);
155
+    Vector3d &operator *=(float s);
156
 
156
 
157
-    vec3_t mVec; //!< Vector data
157
+    float mVec[3]; //!< Vector data
158
 };
158
 };
159
 
159
 
160
 #endif
160
 #endif

+ 10
- 22
include/math/math.h View File

7
  * \author xythobuz
7
  * \author xythobuz
8
  */
8
  */
9
 
9
 
10
-#include <cmath>
11
-
12
 #ifndef _MATH_MATH_H
10
 #ifndef _MATH_MATH_H
13
 #define _MATH_MATH_H
11
 #define _MATH_MATH_H
14
 
12
 
15
 #ifndef M_PI
13
 #ifndef M_PI
16
-#define M_PI 3.14159265358979323846
14
+#define OR_PI (3.14159265358979323846f) //!< pi
15
+#else
16
+#define OR_PI ((float)M_PI) //!< pi
17
 #endif
17
 #endif
18
 
18
 
19
-#define OR_PI           ((float)M_PI) //!< pi
20
-#define OR_2_PI         (OR_PI * 2.0f) //!< pi*2
21
-#define OR_PI_OVER_4    (OR_PI / 4.0f) //!< pi/4
22
-#define OR_PI_OVER_180  (OR_PI / 180.0f) //!< pi/180
23
-#define OR_180_OVER_PI  (180.0f / OR_PI) //!< 180/pi
24
-
25
-#define OR_RAD_TO_DEG(x) ((x) * OR_180_OVER_PI) //!< Convert radians to degrees
26
-#define OR_DEG_TO_RAD(x) ((x) * OR_PI_OVER_180) //!< Convert degrees to radians
27
-
28
-typedef float vec_t;        //!< 1D Vector, aka float
29
-typedef float vec2_t[2];    //!< 2D Vector
30
-typedef float vec3_t[3];    //!< 3D Vector
31
-typedef float vec4_t[4];    //!< 4D Vector
32
-typedef vec_t matrix_t[16]; //!< Used as _Column_major_ in every class now!
19
+#define OR_RAD_TO_DEG(x) ((x) * (180.0f / OR_PI)) //!< Convert radians to degrees
20
+#define OR_DEG_TO_RAD(x) ((x) * (OR_PI / 180.0f)) //!< Convert degrees to radians
33
 
21
 
34
 /*!
22
 /*!
35
  * \brief Compare two floats with an Epsilon.
23
  * \brief Compare two floats with an Epsilon.
37
  * \param b second float
25
  * \param b second float
38
  * \returns true if a and b are probably the same.
26
  * \returns true if a and b are probably the same.
39
  */
27
  */
40
-bool equalEpsilon(vec_t a, vec_t b);
28
+bool equalEpsilon(float a, float b);
41
 
29
 
42
 /*!
30
 /*!
43
  * \brief Calculate Intersection of a line and a polygon
31
  * \brief Calculate Intersection of a line and a polygon
47
  * \param polygon polygon vertex array (0 to 2 are used)
35
  * \param polygon polygon vertex array (0 to 2 are used)
48
  * \returns 0 if there is no intersection
36
  * \returns 0 if there is no intersection
49
  */
37
  */
50
-int intersectionLinePolygon(vec3_t intersect, vec3_t p1, vec3_t p2, vec3_t *polygon);
38
+int intersectionLinePolygon(float intersect[3], float p1[3], float p2[3], float polygon[3][3]);
51
 
39
 
52
 /*!
40
 /*!
53
  * \brief Calculate the length of a line segment / the distance between two points
41
  * \brief Calculate the length of a line segment / the distance between two points
55
  * \param b Second point
43
  * \param b Second point
56
  * \returns distance/length
44
  * \returns distance/length
57
  */
45
  */
58
-vec_t distance(const vec3_t a, const vec3_t b);
46
+float distance(const float a[3], const float b[3]);
59
 
47
 
60
 /*!
48
 /*!
61
  * \brief Calculates the midpoint between two points / of a line segment
49
  * \brief Calculates the midpoint between two points / of a line segment
63
  * \param b Second point
51
  * \param b Second point
64
  * \param mid Midpoint will be stored here
52
  * \param mid Midpoint will be stored here
65
  */
53
  */
66
-void midpoint(const vec3_t a, const vec3_t b, vec3_t mid);
54
+void midpoint(const float a[3], const float b[3], float mid[3]);
67
 
55
 
68
 /*!
56
 /*!
69
  * \brief Calculates a pseudo-random number
57
  * \brief Calculates a pseudo-random number
71
  * \param to Upper bound
59
  * \param to Upper bound
72
  * \returns random number
60
  * \returns random number
73
  */
61
  */
74
-vec_t randomNum(vec_t from, vec_t to);
62
+float randomNum(float from, float to);
75
 
63
 
76
 #endif
64
 #endif
77
 
65
 

+ 0
- 1
include/utils/strings.h View File

10
 #define _UTILS_STRINGS_H_
10
 #define _UTILS_STRINGS_H_
11
 
11
 
12
 #include <cstdarg>
12
 #include <cstdarg>
13
-#include <vector>
14
 
13
 
15
 char *stringRemoveQuotes(const char *s);
14
 char *stringRemoveQuotes(const char *s);
16
 
15
 

+ 7
- 6
src/Camera.cpp View File

7
  */
7
  */
8
 
8
 
9
 #include "global.h"
9
 #include "global.h"
10
+#include <cmath>
10
 #include "math/Matrix.h"
11
 #include "math/Matrix.h"
11
 #include "Camera.h"
12
 #include "Camera.h"
12
 
13
 
28
     mQ.setIdentity();
29
     mQ.setIdentity();
29
 }
30
 }
30
 
31
 
31
-void Camera::getTarget(vec3_t target) {
32
+void Camera::getTarget(float target[3]) {
32
     target[0] = mTarget[0];
33
     target[0] = mTarget[0];
33
     target[1] = mTarget[1];
34
     target[1] = mTarget[1];
34
     target[2] = mTarget[2];
35
     target[2] = mTarget[2];
35
 }
36
 }
36
 
37
 
37
-vec_t Camera::getRadianYaw() {
38
+float Camera::getRadianYaw() {
38
     return mTheta;
39
     return mTheta;
39
 }
40
 }
40
 
41
 
41
-vec_t Camera::getRadianPitch() {
42
+float Camera::getRadianPitch() {
42
     return mTheta2;
43
     return mTheta2;
43
 }
44
 }
44
 
45
 
45
-void Camera::setPosition(vec3_t pos) {
46
+void Camera::setPosition(float pos[3]) {
46
     mPos[0] = pos[0];
47
     mPos[0] = pos[0];
47
     mPos[1] = pos[1];
48
     mPos[1] = pos[1];
48
     mPos[2] = pos[2];
49
     mPos[2] = pos[2];
49
 }
50
 }
50
 
51
 
51
-void Camera::setSensitivityX(vec_t sens) {
52
+void Camera::setSensitivityX(float sens) {
52
     mRotationDeltaX = sens;
53
     mRotationDeltaX = sens;
53
 }
54
 }
54
 
55
 
55
-void Camera::setSensitivityY(vec_t sens) {
56
+void Camera::setSensitivityY(float sens) {
56
     mRotationDeltaY = sens;
57
     mRotationDeltaY = sens;
57
 }
58
 }
58
 
59
 

+ 5
- 2
src/Command.cpp View File

6
  */
6
  */
7
 
7
 
8
 #include <fstream>
8
 #include <fstream>
9
-
10
-#include "WindowSDL.h"
9
+#include <sstream>
11
 
10
 
12
 #include "global.h"
11
 #include "global.h"
12
+#include "Camera.h"
13
 #include "Console.h"
13
 #include "Console.h"
14
 #include "Entity.h"
14
 #include "Entity.h"
15
 #include "Font.h"
15
 #include "Font.h"
16
 #include "Game.h"
16
 #include "Game.h"
17
 #include "math/math.h"
17
 #include "math/math.h"
18
 #include "Menu.h"
18
 #include "Menu.h"
19
+#include "Render.h"
19
 #include "Sound.h"
20
 #include "Sound.h"
20
 #include "TombRaider.h"
21
 #include "TombRaider.h"
22
+#include "Window.h"
23
+#include "World.h"
21
 #include "utils/strings.h"
24
 #include "utils/strings.h"
22
 #include "utils/time.h"
25
 #include "utils/time.h"
23
 #include "OpenRaider.h"
26
 #include "OpenRaider.h"

+ 7
- 5
src/Entity.cpp View File

5
  * \author xythobuz
5
  * \author xythobuz
6
  */
6
  */
7
 
7
 
8
+#include <cmath>
9
+
8
 #include "global.h"
10
 #include "global.h"
9
 #include "Console.h"
11
 #include "Console.h"
10
 #include "Entity.h"
12
 #include "Entity.h"
34
 }
36
 }
35
 
37
 
36
 bool Entity::operator<(Entity &o) {
38
 bool Entity::operator<(Entity &o) {
37
-    vec_t distA = getRender().mViewVolume.getDistToSphereFromNear(pos[0], pos[1], pos[2], 1.0f);
38
-    vec_t distB = getRender().mViewVolume.getDistToSphereFromNear(o.pos[0], o.pos[1], o.pos[2], 1.0f);
39
+    float distA = getRender().mViewVolume.getDistToSphereFromNear(pos[0], pos[1], pos[2], 1.0f);
40
+    float distB = getRender().mViewVolume.getDistToSphereFromNear(o.pos[0], o.pos[1], o.pos[2], 1.0f);
39
     return (distA < distB);
41
     return (distA < distB);
40
 }
42
 }
41
 
43
 
236
     return objectId;
238
     return objectId;
237
 }
239
 }
238
 
240
 
239
-void Entity::setAngles(vec3_t a) {
241
+void Entity::setAngles(float a[3]) {
240
     for (unsigned int i = 0; i < 3; i++)
242
     for (unsigned int i = 0; i < 3; i++)
241
         angles[i] = a[i];
243
         angles[i] = a[i];
242
 }
244
 }
243
 
245
 
244
-vec_t Entity::getPos(unsigned int i) {
246
+float Entity::getPos(unsigned int i) {
245
     return pos[i];
247
     return pos[i];
246
 }
248
 }
247
 
249
 
248
-vec_t Entity::getAngle(unsigned int i) {
250
+float Entity::getAngle(unsigned int i) {
249
     return angles[i];
251
     return angles[i];
250
 }
252
 }
251
 
253
 

+ 10
- 10
src/FontTRLE.cpp View File

95
 #define SCALING 2.0f
95
 #define SCALING 2.0f
96
 
96
 
97
 void FontTRLE::writeChar(unsigned int index, unsigned int xDraw, FontString &s) {
97
 void FontTRLE::writeChar(unsigned int index, unsigned int xDraw, FontString &s) {
98
-    int width = (int)(((vec_t)offsets[index][2]) * s.scale * SCALING);
99
-    int height = (int)(((vec_t)offsets[index][3]) * s.scale * SCALING);
100
-    int offset = (int)(((vec_t)offsets[index][4]) * s.scale * SCALING);
98
+    int width = (int)(((float)offsets[index][2]) * s.scale * SCALING);
99
+    int height = (int)(((float)offsets[index][3]) * s.scale * SCALING);
100
+    int offset = (int)(((float)offsets[index][4]) * s.scale * SCALING);
101
 
101
 
102
     // screen coordinates
102
     // screen coordinates
103
     int xMin = xDraw;
103
     int xMin = xDraw;
106
     int yMax = yMin + height;
106
     int yMax = yMin + height;
107
 
107
 
108
     // texture part
108
     // texture part
109
-    vec_t txMin = ((vec_t)offsets[index][0]) / 256.0f;
110
-    vec_t txMax = ((vec_t)(offsets[index][0] + offsets[index][2])) / 256.0f;
111
-    vec_t tyMin = ((vec_t)offsets[index][1]) / 256.0f;
112
-    vec_t tyMax = ((vec_t)(offsets[index][1] + offsets[index][3])) / 256.0f;
109
+    float txMin = ((float)offsets[index][0]) / 256.0f;
110
+    float txMax = ((float)(offsets[index][0] + offsets[index][2])) / 256.0f;
111
+    float tyMin = ((float)offsets[index][1]) / 256.0f;
112
+    float tyMax = ((float)(offsets[index][1] + offsets[index][3])) / 256.0f;
113
 
113
 
114
     // draw
114
     // draw
115
     glBindTexture(GL_TEXTURE_2D, mFontTexture);
115
     glBindTexture(GL_TEXTURE_2D, mFontTexture);
144
             continue; // skip unprintable chars
144
             continue; // skip unprintable chars
145
 
145
 
146
         writeChar((unsigned int)index, x, s);
146
         writeChar((unsigned int)index, x, s);
147
-        x += (int)((vec_t)(offsets[index][2] + 1) * s.scale * SCALING); // width
147
+        x += (int)((float)(offsets[index][2] + 1) * s.scale * SCALING); // width
148
 
148
 
149
-        if (y < (unsigned int)(((vec_t)offsets[index][3]) * s.scale * SCALING))
150
-            y = (unsigned int)(((vec_t)offsets[index][3]) * s.scale * SCALING);
149
+        if (y < (unsigned int)(((float)offsets[index][3]) * s.scale * SCALING))
150
+            y = (unsigned int)(((float)offsets[index][3]) * s.scale * SCALING);
151
     }
151
     }
152
 
152
 
153
     s.w = x - s.x;
153
     s.w = x - s.x;

+ 4
- 1
src/Game.cpp View File

10
 #include <cstdlib>
10
 #include <cstdlib>
11
 
11
 
12
 #include "global.h"
12
 #include "global.h"
13
+#include "Camera.h"
13
 #include "Console.h"
14
 #include "Console.h"
14
 #include "Game.h"
15
 #include "Game.h"
15
 #include "OpenRaider.h"
16
 #include "OpenRaider.h"
17
+#include "Render.h"
16
 #include "Sound.h"
18
 #include "Sound.h"
17
 #include "StaticMesh.h"
19
 #include "StaticMesh.h"
18
 #include "TextureManager.h"
20
 #include "TextureManager.h"
21
+#include "World.h"
19
 #include "utils/strings.h"
22
 #include "utils/strings.h"
20
 
23
 
21
 #include "games/TombRaider1.h"
24
 #include "games/TombRaider1.h"
164
                 getCamera().command(CAMERA_ROTATE_DOWN);
167
                 getCamera().command(CAMERA_ROTATE_DOWN);
165
 
168
 
166
         // Fix Laras rotation
169
         // Fix Laras rotation
167
-        vec3_t angles = { 0.0f, getCamera().getRadianYaw(), getCamera().getRadianPitch() };
170
+        float angles[3] = { 0.0f, getCamera().getRadianYaw(), getCamera().getRadianPitch() };
168
         getLara().setAngles(angles);
171
         getLara().setAngles(angles);
169
     }
172
     }
170
 }
173
 }

+ 1
- 0
src/Menu.cpp View File

11
 #include "Console.h"
11
 #include "Console.h"
12
 #include "OpenRaider.h"
12
 #include "OpenRaider.h"
13
 #include "utils/strings.h"
13
 #include "utils/strings.h"
14
+#include "TombRaider.h"
14
 #include "Window.h"
15
 #include "Window.h"
15
 #include "Menu.h"
16
 #include "Menu.h"
16
 
17
 

+ 37
- 13
src/Mesh.cpp View File

49
 
49
 
50
 Mesh::~Mesh()
50
 Mesh::~Mesh()
51
 {
51
 {
52
+    for (unsigned int i = 0; i < mNumVertices; i++)
53
+        delete [] mVertices[i];
52
     delete [] mVertices;
54
     delete [] mVertices;
53
     mVertices = NULL;
55
     mVertices = NULL;
54
 
56
 
57
+    for (unsigned int i = 0; i < mNumNormals; i++)
58
+        delete [] mNormals[i];
55
     delete [] mNormals;
59
     delete [] mNormals;
56
     mNormals = NULL;
60
     mNormals = NULL;
57
 
61
 
62
+    for (unsigned int i = 0; i < mNumColors; i++)
63
+        delete [] mColors[i];
58
     delete [] mColors;
64
     delete [] mColors;
59
     mColors = NULL;
65
     mColors = NULL;
60
 
66
 
374
 {
380
 {
375
     if (mColors)
381
     if (mColors)
376
     {
382
     {
377
-        mNumColors = 0;
383
+        for (unsigned int i = 0; i < mNumColors; i++)
384
+            delete [] mColors[i];
378
         delete [] mColors;
385
         delete [] mColors;
386
+        mNumColors = 0;
379
     }
387
     }
380
 
388
 
381
     if (!n)
389
     if (!n)
384
     }
392
     }
385
 
393
 
386
     mNumColors = n;
394
     mNumColors = n;
387
-    mColors = new vec4_t[mNumColors];
395
+    mColors = new float *[mNumColors];
396
+    for (unsigned int i = 0; i < mNumColors; i++)
397
+        mColors[i] = new float[4];
388
 }
398
 }
389
 
399
 
390
 
400
 
392
 {
402
 {
393
     if (mNormals)
403
     if (mNormals)
394
     {
404
     {
395
-        mNumNormals = 0;
405
+        for (unsigned int i = 0; i < mNumNormals; i++)
406
+            delete [] mNormals[i];
396
         delete [] mNormals;
407
         delete [] mNormals;
408
+        mNumNormals = 0;
397
     }
409
     }
398
 
410
 
399
     if (!n)
411
     if (!n)
402
     }
414
     }
403
 
415
 
404
     mNumNormals = n;
416
     mNumNormals = n;
405
-    mNormals = new vec3_t[mNumNormals];
417
+    mNormals = new float *[mNumNormals];
418
+    for (unsigned int i = 0; i < mNumNormals; i++)
419
+        mNormals[i] = new float[3];
406
 }
420
 }
407
 
421
 
408
 
422
 
446
 {
460
 {
447
     if (mVertices)
461
     if (mVertices)
448
     {
462
     {
449
-        mNumVertices = 0;
463
+        for (unsigned int i = 0; i < mNumVertices; i++)
464
+            delete [] mVertices[i];
450
         delete [] mVertices;
465
         delete [] mVertices;
466
+        mNumVertices = 0;
451
     }
467
     }
452
 
468
 
453
     if (!n)
469
     if (!n)
456
     }
472
     }
457
 
473
 
458
     mNumVertices = n;
474
     mNumVertices = n;
459
-    mVertices = new vec3_t[mNumVertices];
475
+    mVertices = new float *[mNumVertices];
476
+    for (unsigned int i = 0; i < mNumVertices; i++)
477
+        mVertices[i] = new float[3];
460
 }
478
 }
461
 
479
 
462
 
480
 
463
-void Mesh::bufferColorArray(unsigned int colorCount, vec_t *colors)
481
+void Mesh::bufferColorArray(unsigned int colorCount, float *colors)
464
 {
482
 {
465
     if (mColors)
483
     if (mColors)
466
     {
484
     {
467
-        mNumColors = 0;
485
+        for (unsigned int i = 0; i < mNumColors; i++)
486
+            delete [] mColors[i];
468
         delete [] mColors;
487
         delete [] mColors;
488
+        mNumColors = 0;
469
     }
489
     }
470
 
490
 
471
     if (!colorCount)
491
     if (!colorCount)
478
 }
498
 }
479
 
499
 
480
 
500
 
481
-void Mesh::bufferNormalArray(unsigned int normalCount, vec_t *normals)
501
+void Mesh::bufferNormalArray(unsigned int normalCount, float *normals)
482
 {
502
 {
483
     if (mNormals)
503
     if (mNormals)
484
     {
504
     {
485
-        mNumNormals = 0;
505
+        for (unsigned int i = 0; i < mNumNormals; i++)
506
+            delete [] mNormals[i];
486
         delete [] mNormals;
507
         delete [] mNormals;
508
+        mNumNormals = 0;
487
     }
509
     }
488
 
510
 
489
     if (!normalCount)
511
     if (!normalCount)
497
 
519
 
498
 
520
 
499
 void Mesh::bufferTriangles(unsigned int count,
521
 void Mesh::bufferTriangles(unsigned int count,
500
-        unsigned int *indices, vec_t *texCoords,
522
+        unsigned int *indices, float *texCoords,
501
         int *textures, unsigned int *flags)
523
         int *textures, unsigned int *flags)
502
 {
524
 {
503
 
525
 
511
 }
533
 }
512
 
534
 
513
 
535
 
514
-void Mesh::bufferVertexArray(unsigned int vertexCount, vec_t *vertices)
536
+void Mesh::bufferVertexArray(unsigned int vertexCount, float *vertices)
515
 {
537
 {
516
     if (mVertices)
538
     if (mVertices)
517
     {
539
     {
518
-        mNumVertices = 0;
540
+        for (unsigned int i = 0; i < mNumVertices; i++)
541
+            delete [] mVertices[i];
519
         delete [] mVertices;
542
         delete [] mVertices;
543
+        mNumVertices = 0;
520
     }
544
     }
521
 
545
 
522
     if (!vertexCount)
546
     if (!vertexCount)

+ 1
- 1
src/OpenRaider.cpp View File

11
 #include "global.h"
11
 #include "global.h"
12
 #include "Console.h"
12
 #include "Console.h"
13
 #include "Game.h"
13
 #include "Game.h"
14
-#include "math/math.h"
15
 #include "Menu.h"
14
 #include "Menu.h"
15
+#include "Render.h"
16
 #include "Sound.h"
16
 #include "Sound.h"
17
 #include "TextureManager.h"
17
 #include "TextureManager.h"
18
 #include "TombRaider.h"
18
 #include "TombRaider.h"

+ 8
- 10
src/Render.cpp View File

13
 #include <string.h>
13
 #include <string.h>
14
 
14
 
15
 #include "global.h"
15
 #include "global.h"
16
+#include "Camera.h"
16
 #include "Game.h"
17
 #include "Game.h"
17
 #include "OpenRaider.h"
18
 #include "OpenRaider.h"
18
 #include "Render.h"
19
 #include "Render.h"
20
 #include "utils/strings.h"
21
 #include "utils/strings.h"
21
 #include "utils/tga.h"
22
 #include "utils/tga.h"
22
 #include "Window.h"
23
 #include "Window.h"
24
+#include "World.h"
23
 
25
 
24
 Render::Render() {
26
 Render::Render() {
25
     mSkyMesh = -1;
27
     mSkyMesh = -1;
109
     for (unsigned int i = 0; i < room.sizeLights(); ++i)
111
     for (unsigned int i = 0; i < room.sizeLights(); ++i)
110
     {
112
     {
111
         Light &light = room.getLight(i);
113
         Light &light = room.getLight(i);
112
-        vec4_t pos, color;
113
-        vec3_t dir;
114
+        float pos[4], color[4];
115
+        float dir[3];
114
         light.getPos(pos);
116
         light.getPos(pos);
115
         light.getColor(color);
117
         light.getColor(color);
116
         light.getDir(dir);
118
         light.getDir(dir);
298
             break;
300
             break;
299
     }
301
     }
300
 
302
 
301
-    vec3_t curPos;
302
-    vec3_t camPos;
303
-    vec3_t atPos;
303
+    float curPos[3], camPos[3], atPos[3];
304
 
304
 
305
     curPos[0] = getGame().getLara().getPos(0);
305
     curPos[0] = getGame().getLara().getPos(0);
306
     curPos[1] = getGame().getLara().getPos(1);
306
     curPos[1] = getGame().getLara().getPos(1);
307
     curPos[2] = getGame().getLara().getPos(2);
307
     curPos[2] = getGame().getLara().getPos(2);
308
-    vec_t yaw = getGame().getLara().getAngle(1);
308
+    float yaw = getGame().getLara().getAngle(1);
309
 
309
 
310
     // Mongoose 2002.08.24, New 3rd person camera hack
310
     // Mongoose 2002.08.24, New 3rd person camera hack
311
     camPos[0] = curPos[0] - (1024.0f * sinf(yaw));
311
     camPos[0] = curPos[0] - (1024.0f * sinf(yaw));
550
 
550
 
551
 void Render::updateViewVolume()
551
 void Render::updateViewVolume()
552
 {
552
 {
553
-    matrix_t proj;
554
-    matrix_t mdl;
555
-
553
+    float proj[16], mdl[16];
556
 
554
 
557
     glGetFloatv(GL_PROJECTION_MATRIX, proj);
555
     glGetFloatv(GL_PROJECTION_MATRIX, proj);
558
     glGetFloatv(GL_MODELVIEW_MATRIX, mdl);
556
     glGetFloatv(GL_MODELVIEW_MATRIX, mdl);
560
 }
558
 }
561
 
559
 
562
 bool Render::isVisible(BoundingBox &box) {
560
 bool Render::isVisible(BoundingBox &box) {
563
-    vec3_t bbox[2];
561
+    float bbox[2][3];
564
     box.getBoundingBox(bbox);
562
     box.getBoundingBox(bbox);
565
 
563
 
566
     // For debugging purposes
564
     // For debugging purposes

+ 20
- 12
src/Room.cpp View File

20
 #endif
20
 #endif
21
 
21
 
22
 Room::Room(TombRaider &tr, unsigned int index) {
22
 Room::Room(TombRaider &tr, unsigned int index) {
23
-    vec3_t box[2];
23
+    float box[2][3];
24
     Matrix transform;
24
     Matrix transform;
25
 
25
 
26
     if (!tr.isRoomValid(index)) {
26
     if (!tr.isRoomValid(index)) {
90
 //#define EXPERIMENTAL_UNIFIED_ROOM_GEOMETERY
90
 //#define EXPERIMENTAL_UNIFIED_ROOM_GEOMETERY
91
 #ifdef EXPERIMENTAL_UNIFIED_ROOM_GEOMETERY
91
 #ifdef EXPERIMENTAL_UNIFIED_ROOM_GEOMETERY
92
     unsigned int vertexCount, normalCount, colorCount, triCount;
92
     unsigned int vertexCount, normalCount, colorCount, triCount;
93
-    vec_t *vertexArray;
94
-    vec_t *normalArray;
95
-    vec_t *colorArray;
93
+    float *vertexArray;
94
+    float *normalArray;
95
+    float *colorArray;
96
     unsigned int *indices, *fflags;
96
     unsigned int *indices, *fflags;
97
     float *texCoords;
97
     float *texCoords;
98
     int *textures;
98
     int *textures;
255
                 mesh.mTris[j].num_triangles = t;
255
                 mesh.mTris[j].num_triangles = t;
256
                 mesh.mTris[j].triangles = new unsigned int[t*3];
256
                 mesh.mTris[j].triangles = new unsigned int[t*3];
257
                 mesh.mTris[j].num_texcoors = t * 3;
257
                 mesh.mTris[j].num_texcoors = t * 3;
258
-                mesh.mTris[j].texcoors = new vec2_t[t * 3];
258
+                mesh.mTris[j].texcoors = new float *[t * 3];
259
+                for (unsigned int tmp = 0; tmp < (t * 3); tmp++)
260
+                    mesh.mTris[j].texcoors[tmp] = new float[2];
259
             }
261
             }
260
 
262
 
261
             t = triangle_counter_alpha[i];
263
             t = triangle_counter_alpha[i];
265
                 mesh.mTris[j].num_alpha_triangles = t;
267
                 mesh.mTris[j].num_alpha_triangles = t;
266
                 mesh.mTris[j].alpha_triangles = new unsigned int[t*3];
268
                 mesh.mTris[j].alpha_triangles = new unsigned int[t*3];
267
                 mesh.mTris[j].num_texcoors2 = t * 3;
269
                 mesh.mTris[j].num_texcoors2 = t * 3;
268
-                mesh.mTris[j].texcoors2 = new vec2_t[t * 3];
270
+                mesh.mTris[j].texcoors2 = new float *[t * 3];
271
+                for (unsigned int tmp = 0; tmp < (t * 3); tmp++)
272
+                    mesh.mTris[j].texcoors2[tmp] = new float[2];
269
             }
273
             }
270
         }
274
         }
271
 
275
 
295
                 mesh.mQuads[j].num_quads = r;
299
                 mesh.mQuads[j].num_quads = r;
296
                 mesh.mQuads[j].quads = new unsigned int[r*4];
300
                 mesh.mQuads[j].quads = new unsigned int[r*4];
297
                 mesh.mQuads[j].num_texcoors = r * 4;
301
                 mesh.mQuads[j].num_texcoors = r * 4;
298
-                mesh.mQuads[j].texcoors = new vec2_t[r * 4];
302
+                mesh.mQuads[j].texcoors = new float *[r * 4];
303
+                for (unsigned int tmp = 0; tmp < (r * 4); tmp++)
304
+                    mesh.mQuads[j].texcoors[tmp] = new float[2];
299
             }
305
             }
300
 
306
 
301
             r = rectangle_counter_alpha[i];
307
             r = rectangle_counter_alpha[i];
305
                 mesh.mQuads[j].num_alpha_quads = r;
311
                 mesh.mQuads[j].num_alpha_quads = r;
306
                 mesh.mQuads[j].alpha_quads = new unsigned int[r*4];
312
                 mesh.mQuads[j].alpha_quads = new unsigned int[r*4];
307
                 mesh.mQuads[j].num_texcoors2 = r * 4;
313
                 mesh.mQuads[j].num_texcoors2 = r * 4;
308
-                mesh.mQuads[j].texcoors2 = new vec2_t[r * 4];
314
+                mesh.mQuads[j].texcoors2 = new float *[r * 4];
315
+                for (unsigned int tmp = 0; tmp < (r * 4); tmp++)
316
+                    mesh.mQuads[j].texcoors2[tmp] = new float[2];
309
             }
317
             }
310
         }
318
         }
311
     }
319
     }
466
 
474
 
467
         for (unsigned int i = 0; i < sizePortals(); i++) {
475
         for (unsigned int i = 0; i < sizePortals(); i++) {
468
             Portal &portal = getPortal(i);
476
             Portal &portal = getPortal(i);
469
-            vec3_t vertices[4];
477
+            float vertices[4][3];
470
             portal.getVertices(vertices);
478
             portal.getVertices(vertices);
471
 
479
 
472
             glBegin(GL_LINE_LOOP);
480
             glBegin(GL_LINE_LOOP);
561
 
569
 
562
 int Room::getAdjoiningRoom(float x, float y, float z,
570
 int Room::getAdjoiningRoom(float x, float y, float z,
563
         float x2, float y2, float z2) {
571
         float x2, float y2, float z2) {
564
-    vec3_t intersect, p1, p2;
565
-    vec3_t vertices[4];
572
+    float intersect[3], p1[3], p2[3];
573
+    float vertices[4][3];
566
 
574
 
567
     p1[0] = x;  p1[1] = y;  p1[2] = z;
575
     p1[0] = x;  p1[1] = y;  p1[2] = z;
568
     p2[0] = x2; p2[1] = y2; p2[2] = z2;
576
     p2[0] = x2; p2[1] = y2; p2[2] = z2;
589
     return numZSectors;
597
     return numZSectors;
590
 }
598
 }
591
 
599
 
592
-void Room::getPos(vec3_t p) {
600
+void Room::getPos(float p[3]) {
593
     for (unsigned int i = 0; i < 3; i++)
601
     for (unsigned int i = 0; i < 3; i++)
594
         p[i] = pos[i];
602
         p[i] = pos[i];
595
 }
603
 }

+ 13
- 13
src/RoomData.cpp View File

16
     b[0] = b[1] = b[2] = 0;
16
     b[0] = b[1] = b[2] = 0;
17
 }
17
 }
18
 
18
 
19
-void BoundingBox::getBoundingBox(vec3_t box[2]) {
19
+void BoundingBox::getBoundingBox(float box[2][3]) {
20
     box[0][0] = a[0];
20
     box[0][0] = a[0];
21
     box[1][0] = b[0];
21
     box[1][0] = b[0];
22
     box[0][1] = a[1];
22
     box[0][1] = a[1];
25
     box[1][2] = b[2];
25
     box[1][2] = b[2];
26
 }
26
 }
27
 
27
 
28
-void BoundingBox::setBoundingBox(vec3_t min, vec3_t max) {
28
+void BoundingBox::setBoundingBox(float min[3], float max[3]) {
29
     a[0] = min[0];
29
     a[0] = min[0];
30
     b[0] = max[0];
30
     b[0] = max[0];
31
     a[1] = min[1];
31
     a[1] = min[1];
34
     b[2] = max[2];
34
     b[2] = max[2];
35
 }
35
 }
36
 
36
 
37
-bool BoundingBox::inBox(vec_t x, vec_t y, vec_t z) {
37
+bool BoundingBox::inBox(float x, float y, float z) {
38
     return ((y > a[1]) && (y < b[1]) && inBoxPlane(x, z));
38
     return ((y > a[1]) && (y < b[1]) && inBoxPlane(x, z));
39
 }
39
 }
40
 
40
 
41
-bool BoundingBox::inBoxPlane(vec_t x, vec_t z) {
41
+bool BoundingBox::inBoxPlane(float x, float z) {
42
     return ((x > a[0]) && (x < b[0])
42
     return ((x > a[0]) && (x < b[0])
43
             && (z > a[2]) && (z < b[2]));
43
             && (z > a[2]) && (z < b[2]));
44
 }
44
 }
140
     //! \todo Light flags?
140
     //! \todo Light flags?
141
 }
141
 }
142
 
142
 
143
-void Light::getPos(vec4_t p) {
143
+void Light::getPos(float p[4]) {
144
     p[0] = pos[0];
144
     p[0] = pos[0];
145
     p[1] = pos[1];
145
     p[1] = pos[1];
146
     p[2] = pos[2];
146
     p[2] = pos[2];
147
     p[3] = pos[3];
147
     p[3] = pos[3];
148
 }
148
 }
149
 
149
 
150
-void Light::getDir(vec3_t d) {
150
+void Light::getDir(float d[3]) {
151
     d[0] = dir[0];
151
     d[0] = dir[0];
152
     d[1] = dir[1];
152
     d[1] = dir[1];
153
     d[2] = dir[2];
153
     d[2] = dir[2];
154
 }
154
 }
155
 
155
 
156
-vec_t Light::getAtt() {
156
+float Light::getAtt() {
157
     return att;
157
     return att;
158
 }
158
 }
159
 
159
 
160
-void Light::getColor(vec4_t c) {
160
+void Light::getColor(float c[4]) {
161
     c[0] = color[0];
161
     c[0] = color[0];
162
     c[1] = color[1];
162
     c[1] = color[1];
163
     c[2] = color[2];
163
     c[2] = color[2];
164
     c[3] = color[3];
164
     c[3] = color[3];
165
 }
165
 }
166
 
166
 
167
-vec_t Light::getCutoff() {
167
+float Light::getCutoff() {
168
     return cutoff;
168
     return cutoff;
169
 }
169
 }
170
 
170
 
192
 }
192
 }
193
 
193
 
194
 bool StaticModel::operator<(const StaticModel &other) {
194
 bool StaticModel::operator<(const StaticModel &other) {
195
-    vec_t distA, distB;
195
+    float distA, distB;
196
     distA = getRender().mViewVolume.getDistToSphereFromNear(pos[0],
196
     distA = getRender().mViewVolume.getDistToSphereFromNear(pos[0],
197
             pos[1], pos[2], 128.0f);
197
             pos[1], pos[2], 128.0f);
198
     distB = getRender().mViewVolume.getDistToSphereFromNear(other.pos[0],
198
     distB = getRender().mViewVolume.getDistToSphereFromNear(other.pos[0],
215
     }
215
     }
216
 }
216
 }
217
 
217
 
218
-void Portal::getVertices(vec3_t vert[4]) {
218
+void Portal::getVertices(float vert[4][3]) {
219
     for (unsigned int i = 0; i < 4; i++) {
219
     for (unsigned int i = 0; i < 4; i++) {
220
         for (unsigned int j = 0; j < 3; j++) {
220
         for (unsigned int j = 0; j < 3; j++) {
221
             vert[i][j] = vertices[i][j];
221
             vert[i][j] = vertices[i][j];
246
     wall = (sectorFlags & tombraiderSector_wall);
246
     wall = (sectorFlags & tombraiderSector_wall);
247
 }
247
 }
248
 
248
 
249
-vec_t Sector::getFloor() {
249
+float Sector::getFloor() {
250
     return floor;
250
     return floor;
251
 }
251
 }
252
 
252
 
253
-vec_t Sector::getCeiling() {
253
+float Sector::getCeiling() {
254
     return ceiling;
254
     return ceiling;
255
 }
255
 }
256
 
256
 

+ 13
- 12
src/SkeletalModel.cpp View File

17
     tr2_meshtree_t *meshtree = tr.MeshTree();
17
     tr2_meshtree_t *meshtree = tr.MeshTree();
18
     unsigned short *frame = tr.Frame();
18
     unsigned short *frame = tr.Frame();
19
 
19
 
20
-    off[0] = 0.0;
21
-    off[1] = 0.0;
22
-    off[2] = 0.0;
20
+    off[0] = 0.0f;
21
+    off[1] = 0.0f;
22
+    off[2] = 0.0f;
23
     flag = 0x00;
23
     flag = 0x00;
24
-    rot[0] = 0.0;
25
-    rot[1] = 0.0;
26
-    rot[2] = 0.0;
24
+    rot[0] = 0.0f;
25
+    rot[1] = 0.0f;
26
+    rot[2] = 0.0f;
27
     mesh = moveable[index].starting_mesh + i;
27
     mesh = moveable[index].starting_mesh + i;
28
 
28
 
29
     // Setup offsets to produce skeleton
29
     // Setup offsets to produce skeleton
52
     getWorld().getStaticMesh(mesh).display();
52
     getWorld().getStaticMesh(mesh).display();
53
 }
53
 }
54
 
54
 
55
-void BoneTag::getOffset(vec3_t o) {
55
+void BoneTag::getOffset(float o[3]) {
56
     o[0] = off[0];
56
     o[0] = off[0];
57
     o[1] = off[1];
57
     o[1] = off[1];
58
     o[2] = off[2];
58
     o[2] = off[2];
59
 }
59
 }
60
 
60
 
61
-void BoneTag::getRotation(vec3_t r) {
61
+void BoneTag::getRotation(float r[3]) {
62
     r[0] = rot[0];
62
     r[0] = rot[0];
63
     r[1] = rot[1];
63
     r[1] = rot[1];
64
     r[2] = rot[2];
64
     r[2] = rot[2];
96
     return *tag.at(i);
96
     return *tag.at(i);
97
 }
97
 }
98
 
98
 
99
-void BoneFrame::getPosition(vec3_t p) {
99
+void BoneFrame::getPosition(float p[3]) {
100
     p[0] = pos[0];
100
     p[0] = pos[0];
101
     p[1] = pos[1];
101
     p[1] = pos[1];
102
     p[2] = pos[2];
102
     p[2] = pos[2];
273
     AnimationFrame &anim = get(aframe);
273
     AnimationFrame &anim = get(aframe);
274
     BoneFrame &boneframe = anim.get(bframe);
274
     BoneFrame &boneframe = anim.get(bframe);
275
 
275
 
276
-    vec3_t pos;
276
+    float pos[3];
277
     boneframe.getPosition(pos);
277
     boneframe.getPosition(pos);
278
     glTranslatef(pos[0], pos[1], pos[2]);
278
     glTranslatef(pos[0], pos[1], pos[2]);
279
 
279
 
280
     for (unsigned int a = 0; a < boneframe.size(); a++) {
280
     for (unsigned int a = 0; a < boneframe.size(); a++) {
281
         BoneTag &tag = boneframe.get(a);
281
         BoneTag &tag = boneframe.get(a);
282
-        vec3_t rot, off;
282
+        float rot[3], off[3];
283
+
283
         tag.getRotation(rot);
284
         tag.getRotation(rot);
284
         tag.getOffset(off);
285
         tag.getOffset(off);
285
 
286
 
374
     }
375
     }
375
 }
376
 }
376
 
377
 
377
-void SkeletalModel::setPonyPos(vec_t x, vec_t y, vec_t z, vec_t angle) {
378
+void SkeletalModel::setPonyPos(float x, float y, float z, float angle) {
378
     ponytail[0] = x;
379
     ponytail[0] = x;
379
     ponytail[1] = y;
380
     ponytail[1] = y;
380
     ponytail[2] = z;
381
     ponytail[2] = z;

+ 8
- 8
src/Sprite.cpp View File

66
     vertex[2][2] = 0;
66
     vertex[2][2] = 0;
67
     vertex[3][2] = 0;
67
     vertex[3][2] = 0;
68
 
68
 
69
-    texel[3][0] = (vec_t)(x+width)/texelScale;
70
-    texel[3][1] = (vec_t)(y+height)/texelScale;
69
+    texel[3][0] = (float)(x+width)/texelScale;
70
+    texel[3][1] = (float)(y+height)/texelScale;
71
 
71
 
72
-    texel[2][0] = (vec_t)(x+width)/texelScale;
73
-    texel[2][1] = (vec_t)(y)/texelScale;
72
+    texel[2][0] = (float)(x+width)/texelScale;
73
+    texel[2][1] = (float)(y)/texelScale;
74
 
74
 
75
-    texel[1][0] = (vec_t)(x) /texelScale;
76
-    texel[1][1] = (vec_t)(y) /texelScale;
75
+    texel[1][0] = (float)(x) /texelScale;
76
+    texel[1][1] = (float)(y) /texelScale;
77
 
77
 
78
-    texel[0][0] = (vec_t)(x) / texelScale;
79
-    texel[0][1] = (vec_t)(y+height)/texelScale;
78
+    texel[0][0] = (float)(x) / texelScale;
79
+    texel[0][1] = (float)(y+height)/texelScale;
80
 
80
 
81
     texture = sprite->tile + getGame().getTextureStart();
81
     texture = sprite->tile + getGame().getTextureStart();
82
     radius = width2 / 2.0f;
82
     radius = width2 / 2.0f;

+ 3
- 3
src/StaticMesh.cpp View File

12
 #include "utils/pixel.h"
12
 #include "utils/pixel.h"
13
 #include "StaticMesh.h"
13
 #include "StaticMesh.h"
14
 
14
 
15
-TexturedTriangle::TexturedTriangle(int i[3], vec_t s[6], int tex, unsigned short trans) {
15
+TexturedTriangle::TexturedTriangle(int i[3], float s[6], int tex, unsigned short trans) {
16
     index[0] = i[0];
16
     index[0] = i[0];
17
     index[1] = i[1];
17
     index[1] = i[1];
18
     index[2] = i[2];
18
     index[2] = i[2];
26
     transparency = trans;
26
     transparency = trans;
27
 }
27
 }
28
 
28
 
29
-void TexturedTriangle::display(vec_t *vertices, vec_t *colors, vec_t *normals) {
29
+void TexturedTriangle::display(float *vertices, float *colors, float *normals) {
30
     assert(vertices != NULL);
30
     assert(vertices != NULL);
31
 
31
 
32
     if ((getRender().getMode() != Render::modeWireframe)
32
     if ((getRender().getMode() != Render::modeWireframe)
253
     }
253
     }
254
 }
254
 }
255
 
255
 
256
-vec_t StaticMesh::getRadius() {
256
+float StaticMesh::getRadius() {
257
     return radius;
257
     return radius;
258
 }
258
 }
259
 
259
 

+ 1
- 0
src/TextureManager.cpp View File

12
 #include <stdarg.h>
12
 #include <stdarg.h>
13
 
13
 
14
 #include "global.h"
14
 #include "global.h"
15
+#include "Console.h"
15
 #include "OpenRaider.h"
16
 #include "OpenRaider.h"
16
 #include "utils/pcx.h"
17
 #include "utils/pcx.h"
17
 #include "utils/pixel.h"
18
 #include "utils/pixel.h"

+ 16
- 16
src/ViewVolume.cpp View File

21
     mFrustum[5][0] = mFrustum[5][1] = mFrustum[5][2] = mFrustum[5][3] = 0.0f;
21
     mFrustum[5][0] = mFrustum[5][1] = mFrustum[5][2] = mFrustum[5][3] = 0.0f;
22
 }
22
 }
23
 
23
 
24
-bool ViewVolume::isPointInFrustum(vec_t x, vec_t y, vec_t z) {
24
+bool ViewVolume::isPointInFrustum(float x, float y, float z) {
25
     for (unsigned int p = 0; p < 6; ++p) {
25
     for (unsigned int p = 0; p < 6; ++p) {
26
         if (mFrustum[p][0] * x + mFrustum[p][1] * y + mFrustum[p][2] * z +
26
         if (mFrustum[p][0] * x + mFrustum[p][1] * y + mFrustum[p][2] * z +
27
                 mFrustum[p][3] <= 0) {
27
                 mFrustum[p][3] <= 0) {
31
     return true;
31
     return true;
32
 }
32
 }
33
 
33
 
34
-bool ViewVolume::isSphereInFrustum(vec_t x, vec_t y, vec_t z, vec_t radius) {
34
+bool ViewVolume::isSphereInFrustum(float x, float y, float z, float radius) {
35
     for (unsigned int p = 0; p < 6; ++p) {
35
     for (unsigned int p = 0; p < 6; ++p) {
36
-        vec_t d = mFrustum[p][0] * x + mFrustum[p][1] * y + mFrustum[p][2] * z + mFrustum[p][3];
36
+        float d = mFrustum[p][0] * x + mFrustum[p][1] * y + mFrustum[p][2] * z + mFrustum[p][3];
37
         if (d <= -radius)
37
         if (d <= -radius)
38
             return false;
38
             return false;
39
     }
39
     }
40
     return true;
40
     return true;
41
 }
41
 }
42
 
42
 
43
-bool ViewVolume::isBboxInFrustum(vec3_t min, vec3_t max) {
43
+bool ViewVolume::isBboxInFrustum(float min[3], float max[3]) {
44
     for (unsigned int p = 0; p < 6; ++p) {
44
     for (unsigned int p = 0; p < 6; ++p) {
45
         if (mFrustum[p][0] * min[0] +
45
         if (mFrustum[p][0] * min[0] +
46
                 mFrustum[p][1] * min[1] +
46
                 mFrustum[p][1] * min[1] +
87
     return true;
87
     return true;
88
 }
88
 }
89
 
89
 
90
-vec_t ViewVolume::getDistToSphereFromNear(vec_t x, vec_t y, vec_t z, vec_t radius) {
91
-    vec_t d = 0.0;
90
+float ViewVolume::getDistToSphereFromNear(float x, float y, float z, float radius) {
91
+    float d = 0.0;
92
     for (unsigned int p = 0; p < 6; ++p) {
92
     for (unsigned int p = 0; p < 6; ++p) {
93
         d = mFrustum[p][0] * x + mFrustum[p][1] * y + mFrustum[p][2] * z + mFrustum[p][3];
93
         d = mFrustum[p][0] * x + mFrustum[p][1] * y + mFrustum[p][2] * z + mFrustum[p][3];
94
         if (d <= -radius)
94
         if (d <= -radius)
97
     return d + radius;
97
     return d + radius;
98
 }
98
 }
99
 
99
 
100
-vec_t ViewVolume::getDistToBboxFromNear(const vec3_t min, const vec3_t max) {
101
-    vec3_t center;
102
-    vec_t d, radius;
100
+float ViewVolume::getDistToBboxFromNear(const float min[3], const float max[3]) {
101
+    float center[3];
102
+    float d, radius;
103
 
103
 
104
     midpoint(min, max, center);
104
     midpoint(min, max, center);
105
 
105
 
117
     return d + radius;
117
     return d + radius;
118
 }
118
 }
119
 
119
 
120
-void ViewVolume::getFrustum(vec_t frustum[6][4]) {
120
+void ViewVolume::getFrustum(float frustum[6][4]) {
121
     for (unsigned int p = 0; p < 6; ++p) {
121
     for (unsigned int p = 0; p < 6; ++p) {
122
         for (unsigned int i = 0; i < 4; ++i) {
122
         for (unsigned int i = 0; i < 4; ++i) {
123
             frustum[p][i] = mFrustum[p][i];
123
             frustum[p][i] = mFrustum[p][i];
125
     }
125
     }
126
 }
126
 }
127
 
127
 
128
-void ViewVolume::getPlane(ViewVolumeSide p, vec4_t plane) {
128
+void ViewVolume::getPlane(ViewVolumeSide p, float plane[4]) {
129
     for (unsigned int i = 0; i < 4; ++i) {
129
     for (unsigned int i = 0; i < 4; ++i) {
130
         plane[i] =  mFrustum[p][i];
130
         plane[i] =  mFrustum[p][i];
131
     }
131
     }
132
 }
132
 }
133
 
133
 
134
-void ViewVolume::updateFrame(matrix_t proj, matrix_t mdl) {
134
+void ViewVolume::updateFrame(float proj[16], float mdl[16]) {
135
     setModel(mdl);
135
     setModel(mdl);
136
     setProjection(proj);
136
     setProjection(proj);
137
     updateClip();
137
     updateClip();
143
     updateFrustum();
143
     updateFrustum();
144
 }
144
 }
145
 
145
 
146
-void ViewVolume::setModel(matrix_t mdl) {
146
+void ViewVolume::setModel(float mdl[16]) {
147
     mModel.setMatrix(mdl);
147
     mModel.setMatrix(mdl);
148
 }
148
 }
149
 
149
 
150
-void ViewVolume::setProjection(matrix_t proj) {
150
+void ViewVolume::setProjection(float proj[16]) {
151
     mProjection.setMatrix(proj);
151
     mProjection.setMatrix(proj);
152
 }
152
 }
153
 
153
 
156
 }
156
 }
157
 
157
 
158
 void ViewVolume::updateFrustum() {
158
 void ViewVolume::updateFrustum() {
159
-    matrix_t clip;
160
-    vec_t t;
159
+    float clip[16];
160
+    float t;
161
 
161
 
162
     mClip.getMatrix(clip);
162
     mClip.getMatrix(clip);
163
 
163
 

+ 1
- 3
src/Window.cpp View File

8
 #include <cstdio>
8
 #include <cstdio>
9
 #include <cstring>
9
 #include <cstring>
10
 #include <cstdarg>
10
 #include <cstdarg>
11
+#include <cmath>
11
 
12
 
12
 #include "global.h"
13
 #include "global.h"
13
 #include "math/math.h"
14
 #include "math/math.h"
14
 #include "utils/strings.h"
15
 #include "utils/strings.h"
15
 #include "Window.h"
16
 #include "Window.h"
16
 
17
 
17
-Window::~Window() {
18
-}
19
-
20
 unsigned int Window::getWidth() {
18
 unsigned int Window::getWidth() {
21
     return mWidth;
19
     return mWidth;
22
 }
20
 }

+ 2
- 1
src/WindowSDL.cpp View File

6
  */
6
  */
7
 
7
 
8
 #include <cstdio>
8
 #include <cstdio>
9
+#include <ctime>
9
 
10
 
10
 #include "global.h"
11
 #include "global.h"
11
 #include "OpenRaider.h"
12
 #include "OpenRaider.h"
452
         SDL_StopTextInput();
453
         SDL_StopTextInput();
453
 }
454
 }
454
 
455
 
455
-void WindowSDL::delay(clock_t ms) {
456
+void WindowSDL::delay(unsigned int ms) {
456
     assert(mInit == true);
457
     assert(mInit == true);
457
 
458
 
458
     SDL_Delay(ms);
459
     SDL_Delay(ms);

+ 24
- 24
src/math/Matrix.cpp View File

15
     setIdentity();
15
     setIdentity();
16
 }
16
 }
17
 
17
 
18
-Matrix::Matrix(matrix_t m) {
18
+Matrix::Matrix(float m[16]) {
19
     setMatrix(m);
19
     setMatrix(m);
20
 }
20
 }
21
 
21
 
22
 Matrix::Matrix(Quaternion &q) {
22
 Matrix::Matrix(Quaternion &q) {
23
-    matrix_t m;
23
+    float m[16];
24
     q.getMatrix(m);
24
     q.getMatrix(m);
25
     setMatrix(m);
25
     setMatrix(m);
26
 }
26
 }
27
 
27
 
28
-bool Matrix::getInvert(matrix_t out) {
29
-    matrix_t m;
28
+bool Matrix::getInvert(float out[16]) {
29
+    float m[16];
30
 
30
 
31
 #ifdef COLUMN_ORDER
31
 #ifdef COLUMN_ORDER
32
     getMatrix(m);
32
     getMatrix(m);
152
 #undef SWAP_ROWS
152
 #undef SWAP_ROWS
153
 }
153
 }
154
 
154
 
155
-void Matrix::getMatrix(matrix_t mat) {
155
+void Matrix::getMatrix(float mat[16]) {
156
     copy(mMatrix, mat);
156
     copy(mMatrix, mat);
157
 }
157
 }
158
 
158
 
159
-void Matrix::getTransposeMatrix(matrix_t m) {
159
+void Matrix::getTransposeMatrix(float m[16]) {
160
     m[ 0]= mMatrix[0]; m[ 1]= mMatrix[4]; m[ 2]= mMatrix[ 8]; m[ 3]=mMatrix[12];
160
     m[ 0]= mMatrix[0]; m[ 1]= mMatrix[4]; m[ 2]= mMatrix[ 8]; m[ 3]=mMatrix[12];
161
     m[ 4]= mMatrix[1]; m[ 5]= mMatrix[5]; m[ 6]= mMatrix[ 9]; m[ 7]=mMatrix[13];
161
     m[ 4]= mMatrix[1]; m[ 5]= mMatrix[5]; m[ 6]= mMatrix[ 9]; m[ 7]=mMatrix[13];
162
     m[ 8]= mMatrix[2]; m[ 9]= mMatrix[6]; m[10]= mMatrix[10]; m[11]=mMatrix[14];
162
     m[ 8]= mMatrix[2]; m[ 9]= mMatrix[6]; m[10]= mMatrix[10]; m[11]=mMatrix[14];
174
 }
174
 }
175
 
175
 
176
 Vector3d Matrix::operator *(Vector3d v) {
176
 Vector3d Matrix::operator *(Vector3d v) {
177
-    vec_t x = v.mVec[0], y = v.mVec[1], z = v.mVec[2];
177
+    float x = v.mVec[0], y = v.mVec[1], z = v.mVec[2];
178
 
178
 
179
 #ifdef COLUMN_ORDER
179
 #ifdef COLUMN_ORDER
180
     return Vector3d(mMatrix[0]*x + mMatrix[4]*y + mMatrix[ 8]*z + mMatrix[12],
180
     return Vector3d(mMatrix[0]*x + mMatrix[4]*y + mMatrix[ 8]*z + mMatrix[12],
187
 #endif
187
 #endif
188
 }
188
 }
189
 
189
 
190
-void Matrix::multiply3v(vec3_t v, vec3_t result) {
191
-    vec_t x = v[0], y = v[1], z = v[2];
190
+void Matrix::multiply3v(float v[3], float result[3]) {
191
+    float x = v[0], y = v[1], z = v[2];
192
 
192
 
193
     result[0] = mMatrix[0]*x + mMatrix[1]*y + mMatrix[ 2]*z + mMatrix[ 3];
193
     result[0] = mMatrix[0]*x + mMatrix[1]*y + mMatrix[ 2]*z + mMatrix[ 3];
194
     result[1] = mMatrix[4]*x + mMatrix[5]*y + mMatrix[ 6]*z + mMatrix[ 7];
194
     result[1] = mMatrix[4]*x + mMatrix[5]*y + mMatrix[ 6]*z + mMatrix[ 7];
195
     result[2] = mMatrix[8]*x + mMatrix[9]*y + mMatrix[10]*z + mMatrix[11];
195
     result[2] = mMatrix[8]*x + mMatrix[9]*y + mMatrix[10]*z + mMatrix[11];
196
 }
196
 }
197
 
197
 
198
-void Matrix::multiply4v(vec4_t v, vec4_t result) {
199
-    vec_t x = v[0], y = v[1], z = v[2], w = v[3];
198
+void Matrix::multiply4v(float v[4], float result[4]) {
199
+    float x = v[0], y = v[1], z = v[2], w = v[3];
200
 
200
 
201
     result[0] = mMatrix[ 0]*x + mMatrix[ 1]*y + mMatrix[ 2]*z + mMatrix[ 3]*w;
201
     result[0] = mMatrix[ 0]*x + mMatrix[ 1]*y + mMatrix[ 2]*z + mMatrix[ 3]*w;
202
     result[1] = mMatrix[ 4]*x + mMatrix[ 5]*y + mMatrix[ 6]*z + mMatrix[ 7]*w;
202
     result[1] = mMatrix[ 4]*x + mMatrix[ 5]*y + mMatrix[ 6]*z + mMatrix[ 7]*w;
241
     return false;
241
     return false;
242
 }
242
 }
243
 
243
 
244
-void Matrix::setMatrix(matrix_t mat) {
244
+void Matrix::setMatrix(float mat[16]) {
245
     copy(mat, mMatrix);
245
     copy(mat, mMatrix);
246
 }
246
 }
247
 
247
 
252
     mMatrix[12] = 0; mMatrix[13] = 0; mMatrix[14] = 0; mMatrix[15] = 1;
252
     mMatrix[12] = 0; mMatrix[13] = 0; mMatrix[14] = 0; mMatrix[15] = 1;
253
 }
253
 }
254
 
254
 
255
-void Matrix::scale(const vec_t *xyz) {
255
+void Matrix::scale(const float *xyz) {
256
     scale(xyz[0], xyz[1], xyz[2]);
256
     scale(xyz[0], xyz[1], xyz[2]);
257
 }
257
 }
258
 
258
 
259
-void Matrix::scale(vec_t sx, vec_t sy, vec_t sz) {
260
-    matrix_t smatrix;
261
-    matrix_t tmp;
259
+void Matrix::scale(float sx, float sy, float sz) {
260
+    float smatrix[16];
261
+    float tmp[16];
262
 
262
 
263
     smatrix[ 0] = sx; smatrix[ 1] = 0;  smatrix[ 2] = 0;  smatrix[ 3] = 0;
263
     smatrix[ 0] = sx; smatrix[ 1] = 0;  smatrix[ 2] = 0;  smatrix[ 3] = 0;
264
     smatrix[ 4] = 0;  smatrix[ 5] = sy; smatrix[ 6] = 0;  smatrix[ 7] = 0;
264
     smatrix[ 4] = 0;  smatrix[ 5] = sy; smatrix[ 6] = 0;  smatrix[ 7] = 0;
269
     multiply(tmp, smatrix, mMatrix);
269
     multiply(tmp, smatrix, mMatrix);
270
 }
270
 }
271
 
271
 
272
-void Matrix::rotate(const vec_t *xyz) {
272
+void Matrix::rotate(const float *xyz) {
273
     rotate(xyz[0], xyz[1], xyz[2]);
273
     rotate(xyz[0], xyz[1], xyz[2]);
274
 }
274
 }
275
 
275
 
276
-void Matrix::rotate(vec_t ax, vec_t ay, vec_t az) {
277
-    matrix_t xmat, ymat, zmat, tmp, tmp2;
276
+void Matrix::rotate(float ax, float ay, float az) {
277
+    float xmat[16], ymat[16], zmat[16], tmp[16], tmp2[16];
278
 
278
 
279
     xmat[ 0]=1;         xmat[ 1]=0;         xmat[ 2]=0;         xmat[ 3]=0;
279
     xmat[ 0]=1;         xmat[ 1]=0;         xmat[ 2]=0;         xmat[ 3]=0;
280
     xmat[ 4]=0;         xmat[ 5]=cosf(ax);  xmat[ 6]=sinf(ax);  xmat[ 7]=0;
280
     xmat[ 4]=0;         xmat[ 5]=cosf(ax);  xmat[ 6]=sinf(ax);  xmat[ 7]=0;
296
     multiply(tmp2, zmat, mMatrix);
296
     multiply(tmp2, zmat, mMatrix);
297
 }
297
 }
298
 
298
 
299
-void Matrix::translate(const vec_t *xyz) {
299
+void Matrix::translate(const float *xyz) {
300
     translate(xyz[0], xyz[1], xyz[2]);
300
     translate(xyz[0], xyz[1], xyz[2]);
301
 }
301
 }
302
 
302
 
303
-void Matrix::translate(vec_t tx, vec_t ty, vec_t tz) {
304
-    matrix_t tmat, tmp;
303
+void Matrix::translate(float tx, float ty, float tz) {
304
+    float tmat[16], tmp[16];
305
 
305
 
306
     tmat[ 0]=1;  tmat[ 1]=0;  tmat[ 2]=0;  tmat[ 3]=0;
306
     tmat[ 0]=1;  tmat[ 1]=0;  tmat[ 2]=0;  tmat[ 3]=0;
307
     tmat[ 4]=0;  tmat[ 5]=1;  tmat[ 6]=0;  tmat[ 7]=0;
307
     tmat[ 4]=0;  tmat[ 5]=1;  tmat[ 6]=0;  tmat[ 7]=0;
312
     multiply(tmp, tmat, mMatrix);
312
     multiply(tmp, tmat, mMatrix);
313
 }
313
 }
314
 
314
 
315
-void Matrix::copy(matrix_t source, matrix_t dest) {
315
+void Matrix::copy(float source[16], float dest[16]) {
316
     for (int i = 0; i < 16; i++)
316
     for (int i = 0; i < 16; i++)
317
         dest[i] = source[i];
317
         dest[i] = source[i];
318
 }
318
 }
319
 
319
 
320
-void Matrix::multiply(const matrix_t a, const matrix_t b, matrix_t result) {
320
+void Matrix::multiply(const float a[16], const float b[16], float result[16]) {
321
     /* Generated code for matrix mult
321
     /* Generated code for matrix mult
322
      * Code used:
322
      * Code used:
323
 
323
 

+ 14
- 14
src/math/Quaternion.cpp View File

17
     mZ = 0;
17
     mZ = 0;
18
 }
18
 }
19
 
19
 
20
-Quaternion::Quaternion(vec_t w, vec_t x, vec_t y, vec_t z) {
20
+Quaternion::Quaternion(float w, float x, float y, float z) {
21
     mW = w;
21
     mW = w;
22
     mX = x;
22
     mX = x;
23
     mY = y;
23
     mY = y;
24
     mZ = z;
24
     mZ = z;
25
 }
25
 }
26
 
26
 
27
-Quaternion::Quaternion(vec4_t v) {
27
+Quaternion::Quaternion(float v[4]) {
28
     mW = v[0];
28
     mW = v[0];
29
     mX = v[1];
29
     mX = v[1];
30
     mY = v[2];
30
     mY = v[2];
31
     mZ = v[3];
31
     mZ = v[3];
32
 }
32
 }
33
 
33
 
34
-void Quaternion::getMatrix(matrix_t m) {
34
+void Quaternion::getMatrix(float m[16]) {
35
     m[ 0] = 1.0f - 2.0f * (mY*mY + mZ*mZ);
35
     m[ 0] = 1.0f - 2.0f * (mY*mY + mZ*mZ);
36
     m[ 1] = 2.0f * (mX*mY - mW*mZ);
36
     m[ 1] = 2.0f * (mX*mY - mW*mZ);
37
     m[ 2] = 2.0f * (mX*mZ + mW*mY);
37
     m[ 2] = 2.0f * (mX*mZ + mW*mY);
79
     return Quaternion(mW, -mX, -mY, -mZ);
79
     return Quaternion(mW, -mX, -mY, -mZ);
80
 }
80
 }
81
 
81
 
82
-Quaternion Quaternion::scale(vec_t s) {
82
+Quaternion Quaternion::scale(float s) {
83
     return Quaternion(mW * s, mX * s, mY * s, mZ * s);
83
     return Quaternion(mW * s, mX * s, mY * s, mZ * s);
84
 }
84
 }
85
 
85
 
87
     return conjugate().scale(1/magnitude());
87
     return conjugate().scale(1/magnitude());
88
 }
88
 }
89
 
89
 
90
-vec_t Quaternion::dot(Quaternion a, Quaternion b) {
90
+float Quaternion::dot(Quaternion a, Quaternion b) {
91
     return ((a.mW * b.mW) + (a.mX * b.mX) + (a.mY * b.mY) + (a.mZ * b.mZ));
91
     return ((a.mW * b.mW) + (a.mX * b.mX) + (a.mY * b.mY) + (a.mZ * b.mZ));
92
 }
92
 }
93
 
93
 
94
-vec_t Quaternion::magnitude() {
94
+float Quaternion::magnitude() {
95
     return sqrtf(dot(*this, *this));
95
     return sqrtf(dot(*this, *this));
96
 }
96
 }
97
 
97
 
102
     mZ = 0.0;
102
     mZ = 0.0;
103
 }
103
 }
104
 
104
 
105
-void Quaternion::set(vec_t angle, vec_t x, vec_t y, vec_t z) {
106
-    vec_t temp, dist;
105
+void Quaternion::set(float angle, float x, float y, float z) {
106
+    float temp, dist;
107
 
107
 
108
     // Normalize
108
     // Normalize
109
     temp = x*x + y*y + z*z;
109
     temp = x*x + y*y + z*z;
122
 }
122
 }
123
 
123
 
124
 void Quaternion::normalize() {
124
 void Quaternion::normalize() {
125
-    vec_t dist, square;
125
+    float dist, square;
126
 
126
 
127
     square = mX * mX + mY * mY + mZ * mZ + mW * mW;
127
     square = mX * mX + mY * mY + mZ * mZ + mW * mW;
128
 
128
 
145
     mZ = q.mZ;
145
     mZ = q.mZ;
146
 }
146
 }
147
 
147
 
148
-Quaternion Quaternion::slerp(Quaternion a, Quaternion b, vec_t time) {
148
+Quaternion Quaternion::slerp(Quaternion a, Quaternion b, float time) {
149
     /*******************************************************************
149
     /*******************************************************************
150
      * Spherical Linear Interpolation algorthim
150
      * Spherical Linear Interpolation algorthim
151
      *-----------------------------------------------------------------
151
      *-----------------------------------------------------------------
161
      *
161
      *
162
      *******************************************************************/
162
      *******************************************************************/
163
 
163
 
164
-    vec_t result, scaleA, scaleB;
164
+    float result, scaleA, scaleB;
165
     Quaternion i;
165
     Quaternion i;
166
 
166
 
167
 
167
 
197
     if (1 - result > 0.1f) {
197
     if (1 - result > 0.1f) {
198
         // Get the angle between the 2 quaternions, and then
198
         // Get the angle between the 2 quaternions, and then
199
         // store the sin() of that angle
199
         // store the sin() of that angle
200
-        vec_t theta = (float)acos(result);
201
-        vec_t sinTheta = (float)sin(theta);
200
+        float theta = (float)acos(result);
201
+        float sinTheta = (float)sin(theta);
202
 
202
 
203
         // Calculate the scale for qA and qB, according to
203
         // Calculate the scale for qA and qB, according to
204
         // the angle and it's sine value
204
         // the angle and it's sine value
211
     return (a.scale(scaleA) + b.scale(scaleB));
211
     return (a.scale(scaleA) + b.scale(scaleB));
212
 }
212
 }
213
 
213
 
214
-void Quaternion::setByMatrix(matrix_t matrix) {
214
+void Quaternion::setByMatrix(float matrix[16]) {
215
     float diagonal = matrix[0] + matrix[5] + matrix[10] + 1.0f;
215
     float diagonal = matrix[0] + matrix[5] + matrix[10] + 1.0f;
216
     float scale = 0.0f;
216
     float scale = 0.0f;
217
     float w = 0.0f, x = 0.0f, y = 0.0f, z = 0.0f;
217
     float w = 0.0f, x = 0.0f, y = 0.0f, z = 0.0f;

+ 10
- 10
src/math/Vector3d.cpp View File

14
     mVec[0] = mVec[1] = mVec[2] = 0.0f;
14
     mVec[0] = mVec[1] = mVec[2] = 0.0f;
15
 }
15
 }
16
 
16
 
17
-Vector3d::Vector3d(vec3_t v) {
17
+Vector3d::Vector3d(float v[3]) {
18
     mVec[0] = v[0];
18
     mVec[0] = v[0];
19
     mVec[1] = v[1];
19
     mVec[1] = v[1];
20
     mVec[2] = v[2];
20
     mVec[2] = v[2];
21
 }
21
 }
22
 
22
 
23
-Vector3d::Vector3d(vec_t x, vec_t y, vec_t z) {
23
+Vector3d::Vector3d(float x, float y, float z) {
24
     mVec[0] = x;
24
     mVec[0] = x;
25
     mVec[1] = y;
25
     mVec[1] = y;
26
     mVec[2] = z;
26
     mVec[2] = z;
32
     mVec[2] = v.mVec[2];
32
     mVec[2] = v.mVec[2];
33
 }
33
 }
34
 
34
 
35
-vec_t Vector3d::dot(const Vector3d &u, const Vector3d &v) {
35
+float Vector3d::dot(const Vector3d &u, const Vector3d &v) {
36
     return (u.mVec[0]*v.mVec[0] + u.mVec[1]*v.mVec[1] + u.mVec[2]*v.mVec[2]);
36
     return (u.mVec[0]*v.mVec[0] + u.mVec[1]*v.mVec[1] + u.mVec[2]*v.mVec[2]);
37
 }
37
 }
38
 
38
 
42
             u.mVec[0] * v.mVec[1] - u.mVec[1] * v.mVec[0]);
42
             u.mVec[0] * v.mVec[1] - u.mVec[1] * v.mVec[0]);
43
 }
43
 }
44
 
44
 
45
-vec_t Vector3d::magnitude() {
45
+float Vector3d::magnitude() {
46
     return sqrtf(mVec[0]*mVec[0] + mVec[1]*mVec[1] + mVec[2]*mVec[2]);
46
     return sqrtf(mVec[0]*mVec[0] + mVec[1]*mVec[1] + mVec[2]*mVec[2]);
47
 }
47
 }
48
 
48
 
49
 Vector3d Vector3d::unit() {
49
 Vector3d Vector3d::unit() {
50
-    vec_t norm = magnitude();
50
+    float norm = magnitude();
51
 
51
 
52
     return Vector3d(mVec[0] / norm,
52
     return Vector3d(mVec[0] / norm,
53
             mVec[1] / norm,
53
             mVec[1] / norm,
76
             -mVec[2]);
76
             -mVec[2]);
77
 }
77
 }
78
 
78
 
79
-Vector3d Vector3d::operator *(vec_t s) {
79
+Vector3d Vector3d::operator *(float s) {
80
     return Vector3d(s * mVec[0],
80
     return Vector3d(s * mVec[0],
81
             s * mVec[1],
81
             s * mVec[1],
82
             s * mVec[2]);
82
             s * mVec[2]);
83
 }
83
 }
84
 
84
 
85
-Vector3d Vector3d::operator /(vec_t s) {
85
+Vector3d Vector3d::operator /(float s) {
86
     return Vector3d(mVec[0] / s,
86
     return Vector3d(mVec[0] / s,
87
             mVec[1] / s,
87
             mVec[1] / s,
88
             mVec[2] / s);
88
             mVec[2] / s);
89
 }
89
 }
90
 
90
 
91
-vec_t Vector3d::operator *(const Vector3d &v) {
91
+float Vector3d::operator *(const Vector3d &v) {
92
     return dot(*this, v);
92
     return dot(*this, v);
93
 }
93
 }
94
 
94
 
95
 void Vector3d::normalize() {
95
 void Vector3d::normalize() {
96
-    vec_t norm = magnitude();
96
+    float norm = magnitude();
97
 
97
 
98
     mVec[0] /= norm;
98
     mVec[0] /= norm;
99
     mVec[1] /= norm;
99
     mVec[1] /= norm;
127
     return *this;
127
     return *this;
128
 }
128
 }
129
 
129
 
130
-Vector3d &Vector3d::operator *=(vec_t s) {
130
+Vector3d &Vector3d::operator *=(float s) {
131
     mVec[0] *= s;
131
     mVec[0] *= s;
132
     mVec[1] *= s;
132
     mVec[1] *= s;
133
     mVec[2] *= s;
133
     mVec[2] *= s;

+ 11
- 11
src/math/math.cpp View File

7
  * \author xythobuz
7
  * \author xythobuz
8
  */
8
  */
9
 
9
 
10
-#include <stdlib.h>
11
-#include <math.h>
10
+#include <cstdlib>
11
+#include <cmath>
12
 #include <float.h>
12
 #include <float.h>
13
 #include <algorithm>
13
 #include <algorithm>
14
 
14
 
17
 #include "math/Matrix.h"
17
 #include "math/Matrix.h"
18
 #include "math/math.h"
18
 #include "math/math.h"
19
 
19
 
20
-bool equalEpsilon(vec_t a, vec_t b) {
21
-    vec_t epsilon = FLT_EPSILON;
20
+bool equalEpsilon(float a, float b) {
21
+    float epsilon = FLT_EPSILON;
22
     if (fabs(a - b) <= (std::max(fabs(a), fabs(b)) * epsilon))
22
     if (fabs(a - b) <= (std::max(fabs(a), fabs(b)) * epsilon))
23
         return true;
23
         return true;
24
     return false;
24
     return false;
25
 }
25
 }
26
 
26
 
27
-int intersectionLinePolygon(vec3_t intersect,
28
-        vec3_t p1, vec3_t p2, vec3_t *polygon) {
27
+int intersectionLinePolygon(float intersect[3],
28
+        float p1[3], float p2[3], float polygon[3][3]) {
29
     assert(polygon != NULL);
29
     assert(polygon != NULL);
30
 
30
 
31
-    // vec3_t normal, a, b;
31
+    // float normal[3], a[3], b[3];
32
     Vector3d a, b, normal, pA, pB;
32
     Vector3d a, b, normal, pA, pB;
33
-    vec_t d, denominator, mu;
33
+    float d, denominator, mu;
34
 
34
 
35
 
35
 
36
     pA = Vector3d(p1);
36
     pA = Vector3d(p1);
76
     return 1;
76
     return 1;
77
 }
77
 }
78
 
78
 
79
-vec_t distance(const vec3_t a, const vec3_t b) {
79
+float distance(const float a[3], const float b[3]) {
80
     return sqrtf(((b[0] - a[0]) * (b[0] - a[0])) +
80
     return sqrtf(((b[0] - a[0]) * (b[0] - a[0])) +
81
                  ((b[1] - a[1]) * (b[1] - a[1])) +
81
                  ((b[1] - a[1]) * (b[1] - a[1])) +
82
                  ((b[2] - a[2]) * (b[2] - a[2])));
82
                  ((b[2] - a[2]) * (b[2] - a[2])));
83
 }
83
 }
84
 
84
 
85
-void midpoint(const vec3_t a, const vec3_t b, vec3_t mid) {
85
+void midpoint(const float a[3], const float b[3], float mid[3]) {
86
     mid[0] = (a[0] + b[0]) / 2.0f;
86
     mid[0] = (a[0] + b[0]) / 2.0f;
87
     mid[1] = (a[1] + b[1]) / 2.0f;
87
     mid[1] = (a[1] + b[1]) / 2.0f;
88
     mid[2] = (a[2] + b[2]) / 2.0f;
88
     mid[2] = (a[2] + b[2]) / 2.0f;
89
 }
89
 }
90
 
90
 
91
-vec_t randomNum(vec_t from, vec_t to) {
91
+float randomNum(float from, float to) {
92
     return from + ((to - from) * rand() / (RAND_MAX + 1.0f));
92
     return from + ((to - from) * rand() / (RAND_MAX + 1.0f));
93
 }
93
 }
94
 
94
 

Loading…
Cancel
Save