Procházet zdrojové kódy

Removed vec_t typedefs

Thomas Buck před 10 roky
rodič
revize
b1fb7c9965

+ 4
- 0
ChangeLog.md Zobrazit soubor

@@ -2,6 +2,10 @@
2 2
 
3 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 9
     [ 20140703 ]
6 10
     * Removed SDL_GL_LoadLibrary() call and corresponding
7 11
       config file entry

+ 14
- 15
include/Camera.h Zobrazit soubor

@@ -9,7 +9,6 @@
9 9
 #ifndef _CAMERA_H_
10 10
 #define _CAMERA_H_
11 11
 
12
-#include "math/math.h"
13 12
 #include "math/Quaternion.h"
14 13
 
15 14
 /*!
@@ -36,29 +35,29 @@ public:
36 35
      * \brief Get the target currently looked at
37 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 41
      * \brief Get angle/yaw of camera
43 42
      * \returns theta angle/yaw of camera
44 43
      */
45
-    vec_t getRadianYaw();
44
+    float getRadianYaw();
46 45
 
47 46
     /*!
48 47
      * \brief Get angle/pitch of camera
49 48
      * \returns phi angle/pitch of camera
50 49
      */
51
-    vec_t getRadianPitch();
50
+    float getRadianPitch();
52 51
 
53 52
     /*!
54 53
      * \brief Set current position
55 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 63
      * \brief Updates view target
@@ -73,16 +72,16 @@ public:
73 72
 
74 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 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 87
 Camera &getCamera();

+ 0
- 1
include/Console.h Zobrazit soubor

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

+ 5
- 6
include/Entity.h Zobrazit soubor

@@ -8,7 +8,6 @@
8 8
 #ifndef _ENTITY_H_
9 9
 #define _ENTITY_H_
10 10
 
11
-#include "math/math.h"
12 11
 #include "SkeletalModel.h"
13 12
 #include "TombRaider.h"
14 13
 
@@ -34,9 +33,9 @@ public:
34 33
     MoveType getMoveType();
35 34
     void setMoveType(MoveType m);
36 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 39
     int getRoom();
41 40
 
42 41
     // Animation State
@@ -48,8 +47,8 @@ public:
48 47
     void setIdleAnimation(unsigned int index);
49 48
 
50 49
 private:
51
-    vec3_t pos;
52
-    vec3_t angles;
50
+    float pos[3];
51
+    float angles[3];
53 52
     int room;
54 53
 
55 54
     unsigned int skeletalModel;

+ 0
- 1
include/FontTRLE.h Zobrazit soubor

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

+ 0
- 3
include/Game.h Zobrazit soubor

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

+ 18
- 20
include/Mesh.h Zobrazit soubor

@@ -10,8 +10,6 @@
10 10
 #ifndef _MESH_H_
11 11
 #define _MESH_H_
12 12
 
13
-#include "math/math.h"
14
-
15 13
 /*!
16 14
  * \brief OpenGL Mesh
17 15
  */
@@ -39,10 +37,10 @@ public:
39 37
         unsigned int cnum_alpha_triangles;
40 38
 
41 39
         unsigned int num_texcoors;
42
-        vec2_t *texcoors;
40
+        float **texcoors; // 2D
43 41
 
44 42
         unsigned int num_texcoors2;
45
-        vec2_t *texcoors2;
43
+        float **texcoors2; // 2D
46 44
 
47 45
         //! Arrays of triangle indices sorted by texture
48 46
         unsigned int num_triangles;
@@ -64,10 +62,10 @@ public:
64 62
         unsigned int cnum_alpha_quads;
65 63
 
66 64
         unsigned int num_texcoors;
67
-        vec2_t *texcoors;
65
+        float **texcoors; // 2D
68 66
 
69 67
         unsigned int num_texcoors2;
70
-        vec2_t *texcoors2;
68
+        float **texcoors2; // 2D
71 69
 
72 70
         //! Arrays of rectangle indices sorted by texture
73 71
         unsigned int num_quads;
@@ -103,15 +101,15 @@ public:
103 101
 
104 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 108
     void bufferTriangles(unsigned int count,
111
-                            unsigned int *indices, vec_t *texCoords,
109
+                            unsigned int *indices, float *texCoords,
112 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 114
     void setColor(unsigned int index, float r, float g, float b, float a);
117 115
 
@@ -125,13 +123,13 @@ public:
125 123
     void sortFacesByTexture();
126 124
 
127 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 128
     void addTexTiledFace(int textureIndex, int textureIndexB,
131 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 134
     void duplicateArraysForTexTiledTexcoords();
137 135
 #endif
@@ -141,13 +139,13 @@ public:
141 139
     MeshMode mMode;
142 140
 
143 141
     unsigned int mNumVertices;
144
-    vec3_t *mVertices; //!< XYZ
142
+    float **mVertices; //!< XYZ
145 143
 
146 144
     unsigned int mNumNormals;
147
-    vec3_t *mNormals; //!< IJK
145
+    float **mNormals; //!< IJK
148 146
 
149 147
     unsigned int mNumColors;
150
-    vec4_t *mColors; //!< RGBA
148
+    float **mColors; //!< RGBA
151 149
 
152 150
     unsigned int mNumTris;
153 151
     tris_t *mTris;
@@ -159,11 +157,11 @@ public:
159 157
     int *mTriangleTextures;
160 158
     unsigned int *mTriangleIndices;
161 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 167
 #endif

+ 1
- 8
include/OpenRaider.h Zobrazit soubor

@@ -8,15 +8,8 @@
8 8
 #ifndef _OPENRAIDER_H_
9 9
 #define _OPENRAIDER_H_
10 10
 
11
-#include <sstream>
11
+#include <istream>
12 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 15
  * \brief Main Game Singleton

+ 3
- 4
include/Room.h Zobrazit soubor

@@ -9,7 +9,6 @@
9 9
 #define _ROOM_H_
10 10
 
11 11
 #include <vector>
12
-#include "math/math.h"
13 12
 #include "Mesh.h"
14 13
 #include "Sprite.h"
15 14
 #include "TombRaider.h"
@@ -37,7 +36,7 @@ public:
37 36
 
38 37
     unsigned int getNumXSectors();
39 38
     unsigned int getNumZSectors();
40
-    void getPos(vec3_t p);
39
+    void getPos(float p[3]);
41 40
 
42 41
     void setFlags(unsigned int f);
43 42
     unsigned int getFlags();
@@ -69,7 +68,7 @@ private:
69 68
     unsigned int flags;
70 69
     unsigned int numXSectors;
71 70
     unsigned int numZSectors;
72
-    vec3_t pos;
71
+    float pos[3];
73 72
 
74 73
     BoundingBox bbox;
75 74
     Mesh mesh;
@@ -83,7 +82,7 @@ private:
83 82
     std::vector<Light *> lights;
84 83
 
85 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 88
 #endif

+ 26
- 30
include/RoomData.h Zobrazit soubor

@@ -10,21 +10,20 @@
10 10
 
11 11
 #include <vector>
12 12
 #include <memory>
13
-#include "math/math.h"
14 13
 #include "math/Matrix.h"
15 14
 #include "TombRaider.h"
16 15
 
17 16
 class BoundingBox {
18 17
 public:
19 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 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 25
 private:
27
-    vec3_t a, b;
26
+    float a[3], b[3];
28 27
 };
29 28
 
30 29
 class Light {
@@ -40,19 +39,19 @@ public:
40 39
 
41 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 47
     LightType getType();
49 48
 
50 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 55
     LightType type; //! Type of light
57 56
 };
58 57
 
@@ -66,23 +65,23 @@ public:
66 65
 
67 66
 private:
68 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 75
 class Portal {
77 76
 public:
78 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 80
     int getAdjoiningRoom();
82 81
 
83 82
 private:
84
-    vec3_t vertices[4];
85
-    vec3_t normal;
83
+    float vertices[4][3];
84
+    float normal[3];
86 85
     int adjoiningRoom;
87 86
 };
88 87
 
@@ -91,22 +90,19 @@ public:
91 90
     Box(TombRaider &tr, unsigned int room, unsigned int index);
92 91
 
93 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 96
 class Sector {
101 97
 public:
102 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 101
     bool isWall();
106 102
 
107 103
 private:
108
-    vec_t floor;
109
-    vec_t ceiling;
104
+    float floor;
105
+    float ceiling;
110 106
     bool wall;
111 107
 };
112 108
 

+ 11
- 12
include/SkeletalModel.h Zobrazit soubor

@@ -11,7 +11,6 @@
11 11
 
12 12
 #include <vector>
13 13
 
14
-#include "math/math.h"
15 14
 #include "TombRaider.h"
16 15
 
17 16
 class BoneTag {
@@ -19,14 +18,14 @@ public:
19 18
     BoneTag(TombRaider &tr, unsigned int index, unsigned int j, unsigned int *l, unsigned int frame_offset);
20 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 23
     char getFlag();
25 24
 
26 25
 private:
27 26
     int mesh;
28
-    vec3_t off;
29
-    vec3_t rot;
27
+    float off[3];
28
+    float rot[3];
30 29
     char flag;
31 30
 };
32 31
 
@@ -35,13 +34,13 @@ public:
35 34
     BoneFrame(TombRaider &tr, unsigned int index, unsigned int frame_offset);
36 35
     ~BoneFrame();
37 36
 
38
-    void getPosition(vec3_t p);
37
+    void getPosition(float p[3]);
39 38
 
40 39
     unsigned int size();
41 40
     BoneTag &get(unsigned int i);
42 41
 
43 42
 private:
44
-    vec3_t pos;
43
+    float pos[3];
45 44
     std::vector<BoneTag *> tag;
46 45
 };
47 46
 
@@ -66,7 +65,7 @@ public:
66 65
 
67 66
     int getId();
68 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 70
     unsigned int size();
72 71
     AnimationFrame &get(unsigned int i);
@@ -76,12 +75,12 @@ private:
76 75
     bool tr4Overlay;
77 76
     bool pigtails;
78 77
     int ponytailId;
79
-    vec3_t ponytail;
78
+    float ponytail[3];
80 79
     int ponytailMeshId;
81 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 84
     std::vector<AnimationFrame *> animation;
86 85
 };
87 86
 

+ 4
- 5
include/Sprite.h Zobrazit soubor

@@ -8,7 +8,6 @@
8 8
 #ifndef _SPRITE_H_
9 9
 #define _SPRITE_H_
10 10
 
11
-#include "math/math.h"
12 11
 #include "TombRaider.h"
13 12
 
14 13
 class Sprite {
@@ -18,10 +17,10 @@ public:
18 17
     void display();
19 18
 
20 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 24
     int texture;
26 25
 };
27 26
 

+ 9
- 10
include/StaticMesh.h Zobrazit soubor

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

+ 11
- 12
include/ViewVolume.h Zobrazit soubor

@@ -9,7 +9,6 @@
9 9
 #define _VIEWVOLUME_H_
10 10
 
11 11
 #include "math/Matrix.h"
12
-#include "RoomData.h"
13 12
 
14 13
 /*!
15 14
  * \brief Viewing Volume for culling use
@@ -51,7 +50,7 @@ public:
51 50
      * \param z Z coordinate of point
52 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 56
      * \brief Check if bounding sphere is in view volume
@@ -61,7 +60,7 @@ public:
61 60
      * \param radius radius of a valid abstract sphere
62 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 66
      * \brief Check if bounding box is in view volume
@@ -69,7 +68,7 @@ public:
69 68
      * \param max maximum point of valid abstract bounding box
70 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 74
      * \brief Distance to Bounding sphere
@@ -79,7 +78,7 @@ public:
79 78
      * \param radius radius of a valid abstract sphere
80 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 84
      * \brief Distance to Bounding box
@@ -87,27 +86,27 @@ public:
87 86
      * \param max maximum point of a valid abstract bounding box
88 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 92
      * \brief Get a copy of the view volume
94 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 98
      * \brief Get a copy of a given plane in view volume
100 99
      * \param p side
101 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 105
      * \brief Updates view volume for this frame.
107 106
      * \param proj new projection matrix
108 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 112
      * \brief Updates view volume for this frame.
@@ -120,13 +119,13 @@ public:
120 119
      * \brief Set this class' model matrix
121 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 125
      * \brief Set this class' projection matrix
127 126
      * \param proj new projection matrix
128 127
      */
129
-    void setProjection(matrix_t proj);
128
+    void setProjection(float proj[16]);
130 129
 
131 130
 private:
132 131
 
@@ -147,7 +146,7 @@ private:
147 146
     Matrix mProjection;   //!< Projection matrix
148 147
     Matrix mModel;        //!< Model matrix
149 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 152
 #endif

+ 2
- 7
include/Window.h Zobrazit soubor

@@ -8,18 +8,13 @@
8 8
 #ifndef _WINDOW_H_
9 9
 #define _WINDOW_H_
10 10
 
11
-#include <ctime>
12
-
13 11
 /*!
14 12
  * \brief Windowing interface
15 13
  */
16 14
 class Window {
17 15
 public:
18 16
 
19
-    /*!
20
-     * \brief Deconstructs an object of Window
21
-     */
22
-    virtual ~Window();
17
+    virtual ~Window() {}
23 18
 
24 19
     virtual void setSize(unsigned int width, unsigned int height) = 0;
25 20
 
@@ -33,7 +28,7 @@ public:
33 28
 
34 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 33
     virtual void swapBuffersGL() = 0;
39 34
 

+ 1
- 1
include/WindowSDL.h Zobrazit soubor

@@ -40,7 +40,7 @@ public:
40 40
 
41 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 45
     virtual void swapBuffersGL();
46 46
 

+ 0
- 1
include/World.h Zobrazit soubor

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

+ 16
- 16
include/math/Matrix.h Zobrazit soubor

@@ -46,7 +46,7 @@ public:
46 46
      * \brief Constructs an object of Matrix
47 47
      * \param mat Matrix as data source
48 48
      */
49
-    Matrix(matrix_t mat);
49
+    Matrix(float mat[16]);
50 50
 
51 51
     /*!
52 52
      * \brief Constructs an object of Matrix
@@ -58,19 +58,19 @@ public:
58 58
      * \brief Returns this matrix copy
59 59
      * \param mat target
60 60
      */
61
-    void getMatrix(matrix_t mat);
61
+    void getMatrix(float mat[16]);
62 62
 
63 63
     /*!
64 64
      * \brief Returns this matrix transposed
65 65
      * \param mat target
66 66
      */
67
-    void getTransposeMatrix(matrix_t mat);
67
+    void getTransposeMatrix(float mat[16]);
68 68
 
69 69
     /*!
70 70
      * \brief Returns this matrix inverted
71 71
      * \param mat target
72 72
      */
73
-    bool getInvert(matrix_t mat);
73
+    bool getInvert(float mat[16]);
74 74
 
75 75
     /*!
76 76
      * \brief Multiplies two matrices
@@ -85,14 +85,14 @@ public:
85 85
      * \param v vector
86 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 91
      * \brief Multiplies v vector and this matrix
92 92
      * \param v vector
93 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 98
      * \brief Prints matrix values to stdout
@@ -129,7 +129,7 @@ public:
129 129
      * \fixme dangerous, scary, boo!
130 130
      * \param mat new matrix
131 131
      */
132
-    void setMatrix(matrix_t mat);
132
+    void setMatrix(float mat[16]);
133 133
 
134 134
     /*!
135 135
      * \brief Rotate object in 3D space
@@ -137,13 +137,13 @@ public:
137 137
      * \param y y rotation in radians
138 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 143
      * \brief Rotate object in 3D space
144 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 149
      * \brief Scale object in 3D space
@@ -151,13 +151,13 @@ public:
151 151
      * \param y y scaling
152 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 157
      * \brief Scale object in 3D space
158 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 163
      * \brief Translate (move) object in 3D space
@@ -165,20 +165,20 @@ public:
165 165
      * \param y y translation
166 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 171
      * \brief Translate (move) object in 3D space
172 172
      * \param xyz translations
173 173
      */
174
-    void translate(const vec_t *xyz);
174
+    void translate(const float *xyz);
175 175
 
176 176
     /*!
177 177
      * \brief Transpose this matrix
178 178
      */
179 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 183
 private:
184 184
 
@@ -187,7 +187,7 @@ private:
187 187
      * \param source source
188 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 193
      * \brief Multiplies matrices a and b. Neither a or b is also the result.
@@ -195,7 +195,7 @@ private:
195 195
      * \param b second matrix
196 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 201
 #endif

+ 13
- 13
include/math/Quaternion.h Zobrazit soubor

@@ -28,19 +28,19 @@ public:
28 28
      * \param y Y part of new Quaternion
29 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 34
      * \brief Constructs an object of Quaternion
35 35
      * \param v contents of new Quaternion
36 36
      */
37
-    Quaternion(vec4_t v);
37
+    Quaternion(float v[4]);
38 38
 
39 39
     /*!
40 40
      * \brief Get column order matrix equivalent of this quaternion
41 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 46
      * \brief Multiplies this quaternion.
@@ -92,7 +92,7 @@ public:
92 92
      * \param s scaling factor
93 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 98
      * \brief Inverse this quaternion
@@ -106,13 +106,13 @@ public:
106 106
      * \param b second argument to dot product
107 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 112
      * \brief Magnitude of this quaternion
113 113
      * \returns Magnitude of this quaternion
114 114
      */
115
-    vec_t magnitude();
115
+    float magnitude();
116 116
 
117 117
     /*!
118 118
      * \brief Interpolates between a and b rotations.
@@ -125,7 +125,7 @@ public:
125 125
      * \param time time argument for slerp
126 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 131
      * \brief Sets this quaternion to identity
@@ -139,7 +139,7 @@ public:
139 139
      * \param y new Y coordinate
140 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 145
      * \brief Normalize this quaternion
@@ -156,7 +156,7 @@ public:
156 156
      * \brief Sets matrix equivalent of this quaternion
157 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 161
 private:
162 162
 
@@ -192,10 +192,10 @@ private:
192 192
      */
193 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 201
 #endif

+ 9
- 9
include/math/Vector3d.h Zobrazit soubor

@@ -25,7 +25,7 @@ public:
25 25
      * \brief Constructs an object of Vector3d
26 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 31
      * \brief Constructs an object of Vector3d
@@ -33,7 +33,7 @@ public:
33 33
      * \param y Y part of new Vector3d
34 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 39
      * \brief Constructs an object of Vector3d
@@ -47,7 +47,7 @@ public:
47 47
      * \param v second argument
48 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 53
      * \brief Calculate cross product
@@ -61,7 +61,7 @@ public:
61 61
      * \brief Get Magnitude
62 62
      * \returns magnitude of this vector
63 63
      */
64
-    vec_t magnitude();
64
+    float magnitude();
65 65
 
66 66
     /*!
67 67
      * \brief Normalize
@@ -100,21 +100,21 @@ public:
100 100
      * \param s scaling factor
101 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 106
      * \brief Scale this vactor
107 107
      * \param s inverse scaling factor
108 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 113
      * \brief Dot product this vector
114 114
      * \param v second vector for dot product
115 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 120
      * \brief Normalizes this vector
@@ -152,9 +152,9 @@ public:
152 152
      * \param s scaling factor
153 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 160
 #endif

+ 10
- 22
include/math/math.h Zobrazit soubor

@@ -7,29 +7,17 @@
7 7
  * \author xythobuz
8 8
  */
9 9
 
10
-#include <cmath>
11
-
12 10
 #ifndef _MATH_MATH_H
13 11
 #define _MATH_MATH_H
14 12
 
15 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 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 23
  * \brief Compare two floats with an Epsilon.
@@ -37,7 +25,7 @@ typedef vec_t matrix_t[16]; //!< Used as _Column_major_ in every class now!
37 25
  * \param b second float
38 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 31
  * \brief Calculate Intersection of a line and a polygon
@@ -47,7 +35,7 @@ bool equalEpsilon(vec_t a, vec_t b);
47 35
  * \param polygon polygon vertex array (0 to 2 are used)
48 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 41
  * \brief Calculate the length of a line segment / the distance between two points
@@ -55,7 +43,7 @@ int intersectionLinePolygon(vec3_t intersect, vec3_t p1, vec3_t p2, vec3_t *poly
55 43
  * \param b Second point
56 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 49
  * \brief Calculates the midpoint between two points / of a line segment
@@ -63,7 +51,7 @@ vec_t distance(const vec3_t a, const vec3_t b);
63 51
  * \param b Second point
64 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 57
  * \brief Calculates a pseudo-random number
@@ -71,7 +59,7 @@ void midpoint(const vec3_t a, const vec3_t b, vec3_t mid);
71 59
  * \param to Upper bound
72 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 64
 #endif
77 65
 

+ 0
- 1
include/utils/strings.h Zobrazit soubor

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

+ 7
- 6
src/Camera.cpp Zobrazit soubor

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

+ 5
- 2
src/Command.cpp Zobrazit soubor

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

+ 7
- 5
src/Entity.cpp Zobrazit soubor

@@ -5,6 +5,8 @@
5 5
  * \author xythobuz
6 6
  */
7 7
 
8
+#include <cmath>
9
+
8 10
 #include "global.h"
9 11
 #include "Console.h"
10 12
 #include "Entity.h"
@@ -34,8 +36,8 @@ Entity::Entity(TombRaider &tr, unsigned int index, unsigned int i, unsigned int
34 36
 }
35 37
 
36 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 41
     return (distA < distB);
40 42
 }
41 43
 
@@ -236,16 +238,16 @@ int Entity::getObjectId() {
236 238
     return objectId;
237 239
 }
238 240
 
239
-void Entity::setAngles(vec3_t a) {
241
+void Entity::setAngles(float a[3]) {
240 242
     for (unsigned int i = 0; i < 3; i++)
241 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 247
     return pos[i];
246 248
 }
247 249
 
248
-vec_t Entity::getAngle(unsigned int i) {
250
+float Entity::getAngle(unsigned int i) {
249 251
     return angles[i];
250 252
 }
251 253
 

+ 10
- 10
src/FontTRLE.cpp Zobrazit soubor

@@ -95,9 +95,9 @@ void FontTRLE::loadLPS(const char *f) {
95 95
 #define SCALING 2.0f
96 96
 
97 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 102
     // screen coordinates
103 103
     int xMin = xDraw;
@@ -106,10 +106,10 @@ void FontTRLE::writeChar(unsigned int index, unsigned int xDraw, FontString &s)
106 106
     int yMax = yMin + height;
107 107
 
108 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 114
     // draw
115 115
     glBindTexture(GL_TEXTURE_2D, mFontTexture);
@@ -144,10 +144,10 @@ void FontTRLE::writeString(FontString &s) {
144 144
             continue; // skip unprintable chars
145 145
 
146 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 153
     s.w = x - s.x;

+ 4
- 1
src/Game.cpp Zobrazit soubor

@@ -10,12 +10,15 @@
10 10
 #include <cstdlib>
11 11
 
12 12
 #include "global.h"
13
+#include "Camera.h"
13 14
 #include "Console.h"
14 15
 #include "Game.h"
15 16
 #include "OpenRaider.h"
17
+#include "Render.h"
16 18
 #include "Sound.h"
17 19
 #include "StaticMesh.h"
18 20
 #include "TextureManager.h"
21
+#include "World.h"
19 22
 #include "utils/strings.h"
20 23
 
21 24
 #include "games/TombRaider1.h"
@@ -164,7 +167,7 @@ void Game::handleMouseMotion(int xrel, int yrel) {
164 167
                 getCamera().command(CAMERA_ROTATE_DOWN);
165 168
 
166 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 171
         getLara().setAngles(angles);
169 172
     }
170 173
 }

+ 1
- 0
src/Menu.cpp Zobrazit soubor

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

+ 37
- 13
src/Mesh.cpp Zobrazit soubor

@@ -49,12 +49,18 @@ Mesh::Mesh()
49 49
 
50 50
 Mesh::~Mesh()
51 51
 {
52
+    for (unsigned int i = 0; i < mNumVertices; i++)
53
+        delete [] mVertices[i];
52 54
     delete [] mVertices;
53 55
     mVertices = NULL;
54 56
 
57
+    for (unsigned int i = 0; i < mNumNormals; i++)
58
+        delete [] mNormals[i];
55 59
     delete [] mNormals;
56 60
     mNormals = NULL;
57 61
 
62
+    for (unsigned int i = 0; i < mNumColors; i++)
63
+        delete [] mColors[i];
58 64
     delete [] mColors;
59 65
     mColors = NULL;
60 66
 
@@ -374,8 +380,10 @@ void Mesh::allocateColors(unsigned int n)
374 380
 {
375 381
     if (mColors)
376 382
     {
377
-        mNumColors = 0;
383
+        for (unsigned int i = 0; i < mNumColors; i++)
384
+            delete [] mColors[i];
378 385
         delete [] mColors;
386
+        mNumColors = 0;
379 387
     }
380 388
 
381 389
     if (!n)
@@ -384,7 +392,9 @@ void Mesh::allocateColors(unsigned int n)
384 392
     }
385 393
 
386 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,8 +402,10 @@ void Mesh::allocateNormals(unsigned int n)
392 402
 {
393 403
     if (mNormals)
394 404
     {
395
-        mNumNormals = 0;
405
+        for (unsigned int i = 0; i < mNumNormals; i++)
406
+            delete [] mNormals[i];
396 407
         delete [] mNormals;
408
+        mNumNormals = 0;
397 409
     }
398 410
 
399 411
     if (!n)
@@ -402,7 +414,9 @@ void Mesh::allocateNormals(unsigned int n)
402 414
     }
403 415
 
404 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,8 +460,10 @@ void Mesh::allocateVertices(unsigned int n)
446 460
 {
447 461
     if (mVertices)
448 462
     {
449
-        mNumVertices = 0;
463
+        for (unsigned int i = 0; i < mNumVertices; i++)
464
+            delete [] mVertices[i];
450 465
         delete [] mVertices;
466
+        mNumVertices = 0;
451 467
     }
452 468
 
453 469
     if (!n)
@@ -456,16 +472,20 @@ void Mesh::allocateVertices(unsigned int n)
456 472
     }
457 473
 
458 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 483
     if (mColors)
466 484
     {
467
-        mNumColors = 0;
485
+        for (unsigned int i = 0; i < mNumColors; i++)
486
+            delete [] mColors[i];
468 487
         delete [] mColors;
488
+        mNumColors = 0;
469 489
     }
470 490
 
471 491
     if (!colorCount)
@@ -478,12 +498,14 @@ void Mesh::bufferColorArray(unsigned int colorCount, vec_t *colors)
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 503
     if (mNormals)
484 504
     {
485
-        mNumNormals = 0;
505
+        for (unsigned int i = 0; i < mNumNormals; i++)
506
+            delete [] mNormals[i];
486 507
         delete [] mNormals;
508
+        mNumNormals = 0;
487 509
     }
488 510
 
489 511
     if (!normalCount)
@@ -497,7 +519,7 @@ void Mesh::bufferNormalArray(unsigned int normalCount, vec_t *normals)
497 519
 
498 520
 
499 521
 void Mesh::bufferTriangles(unsigned int count,
500
-        unsigned int *indices, vec_t *texCoords,
522
+        unsigned int *indices, float *texCoords,
501 523
         int *textures, unsigned int *flags)
502 524
 {
503 525
 
@@ -511,12 +533,14 @@ void Mesh::bufferTriangles(unsigned int count,
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 538
     if (mVertices)
517 539
     {
518
-        mNumVertices = 0;
540
+        for (unsigned int i = 0; i < mNumVertices; i++)
541
+            delete [] mVertices[i];
519 542
         delete [] mVertices;
543
+        mNumVertices = 0;
520 544
     }
521 545
 
522 546
     if (!vertexCount)

+ 1
- 1
src/OpenRaider.cpp Zobrazit soubor

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

+ 8
- 10
src/Render.cpp Zobrazit soubor

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

+ 20
- 12
src/Room.cpp Zobrazit soubor

@@ -20,7 +20,7 @@ extern std::map<int, int> gMapTex2Bump;
20 20
 #endif
21 21
 
22 22
 Room::Room(TombRaider &tr, unsigned int index) {
23
-    vec3_t box[2];
23
+    float box[2][3];
24 24
     Matrix transform;
25 25
 
26 26
     if (!tr.isRoomValid(index)) {
@@ -90,9 +90,9 @@ Room::Room(TombRaider &tr, unsigned int index) {
90 90
 //#define EXPERIMENTAL_UNIFIED_ROOM_GEOMETERY
91 91
 #ifdef EXPERIMENTAL_UNIFIED_ROOM_GEOMETERY
92 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 96
     unsigned int *indices, *fflags;
97 97
     float *texCoords;
98 98
     int *textures;
@@ -255,7 +255,9 @@ Room::Room(TombRaider &tr, unsigned int index) {
255 255
                 mesh.mTris[j].num_triangles = t;
256 256
                 mesh.mTris[j].triangles = new unsigned int[t*3];
257 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 263
             t = triangle_counter_alpha[i];
@@ -265,7 +267,9 @@ Room::Room(TombRaider &tr, unsigned int index) {
265 267
                 mesh.mTris[j].num_alpha_triangles = t;
266 268
                 mesh.mTris[j].alpha_triangles = new unsigned int[t*3];
267 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,7 +299,9 @@ Room::Room(TombRaider &tr, unsigned int index) {
295 299
                 mesh.mQuads[j].num_quads = r;
296 300
                 mesh.mQuads[j].quads = new unsigned int[r*4];
297 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 307
             r = rectangle_counter_alpha[i];
@@ -305,7 +311,9 @@ Room::Room(TombRaider &tr, unsigned int index) {
305 311
                 mesh.mQuads[j].num_alpha_quads = r;
306 312
                 mesh.mQuads[j].alpha_quads = new unsigned int[r*4];
307 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,7 +474,7 @@ void Room::display(bool alpha) {
466 474
 
467 475
         for (unsigned int i = 0; i < sizePortals(); i++) {
468 476
             Portal &portal = getPortal(i);
469
-            vec3_t vertices[4];
477
+            float vertices[4][3];
470 478
             portal.getVertices(vertices);
471 479
 
472 480
             glBegin(GL_LINE_LOOP);
@@ -561,8 +569,8 @@ void Room::getHeightAtPosition(float x, float *y, float z) {
561 569
 
562 570
 int Room::getAdjoiningRoom(float x, float y, float z,
563 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 575
     p1[0] = x;  p1[1] = y;  p1[2] = z;
568 576
     p2[0] = x2; p2[1] = y2; p2[2] = z2;
@@ -589,7 +597,7 @@ unsigned int Room::getNumZSectors() {
589 597
     return numZSectors;
590 598
 }
591 599
 
592
-void Room::getPos(vec3_t p) {
600
+void Room::getPos(float p[3]) {
593 601
     for (unsigned int i = 0; i < 3; i++)
594 602
         p[i] = pos[i];
595 603
 }

+ 13
- 13
src/RoomData.cpp Zobrazit soubor

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

+ 13
- 12
src/SkeletalModel.cpp Zobrazit soubor

@@ -17,13 +17,13 @@ BoneTag::BoneTag(TombRaider &tr, unsigned int index, unsigned int i, unsigned in
17 17
     tr2_meshtree_t *meshtree = tr.MeshTree();
18 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 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 27
     mesh = moveable[index].starting_mesh + i;
28 28
 
29 29
     // Setup offsets to produce skeleton
@@ -52,13 +52,13 @@ void BoneTag::display() {
52 52
     getWorld().getStaticMesh(mesh).display();
53 53
 }
54 54
 
55
-void BoneTag::getOffset(vec3_t o) {
55
+void BoneTag::getOffset(float o[3]) {
56 56
     o[0] = off[0];
57 57
     o[1] = off[1];
58 58
     o[2] = off[2];
59 59
 }
60 60
 
61
-void BoneTag::getRotation(vec3_t r) {
61
+void BoneTag::getRotation(float r[3]) {
62 62
     r[0] = rot[0];
63 63
     r[1] = rot[1];
64 64
     r[2] = rot[2];
@@ -96,7 +96,7 @@ BoneTag &BoneFrame::get(unsigned int i) {
96 96
     return *tag.at(i);
97 97
 }
98 98
 
99
-void BoneFrame::getPosition(vec3_t p) {
99
+void BoneFrame::getPosition(float p[3]) {
100 100
     p[0] = pos[0];
101 101
     p[1] = pos[1];
102 102
     p[2] = pos[2];
@@ -273,13 +273,14 @@ void SkeletalModel::display(unsigned int aframe, unsigned int bframe) {
273 273
     AnimationFrame &anim = get(aframe);
274 274
     BoneFrame &boneframe = anim.get(bframe);
275 275
 
276
-    vec3_t pos;
276
+    float pos[3];
277 277
     boneframe.getPosition(pos);
278 278
     glTranslatef(pos[0], pos[1], pos[2]);
279 279
 
280 280
     for (unsigned int a = 0; a < boneframe.size(); a++) {
281 281
         BoneTag &tag = boneframe.get(a);
282
-        vec3_t rot, off;
282
+        float rot[3], off[3];
283
+
283 284
         tag.getRotation(rot);
284 285
         tag.getOffset(off);
285 286
 
@@ -374,7 +375,7 @@ void SkeletalModel::setPigTail(bool b) {
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 379
     ponytail[0] = x;
379 380
     ponytail[1] = y;
380 381
     ponytail[2] = z;

+ 8
- 8
src/Sprite.cpp Zobrazit soubor

@@ -66,17 +66,17 @@ Sprite::Sprite(TombRaider &tr, unsigned int item, unsigned int sequence, unsigne
66 66
     vertex[2][2] = 0;
67 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 81
     texture = sprite->tile + getGame().getTextureStart();
82 82
     radius = width2 / 2.0f;

+ 3
- 3
src/StaticMesh.cpp Zobrazit soubor

@@ -12,7 +12,7 @@
12 12
 #include "utils/pixel.h"
13 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 16
     index[0] = i[0];
17 17
     index[1] = i[1];
18 18
     index[2] = i[2];
@@ -26,7 +26,7 @@ TexturedTriangle::TexturedTriangle(int i[3], vec_t s[6], int tex, unsigned short
26 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 30
     assert(vertices != NULL);
31 31
 
32 32
     if ((getRender().getMode() != Render::modeWireframe)
@@ -253,7 +253,7 @@ void StaticMesh::display() {
253 253
     }
254 254
 }
255 255
 
256
-vec_t StaticMesh::getRadius() {
256
+float StaticMesh::getRadius() {
257 257
     return radius;
258 258
 }
259 259
 

+ 1
- 0
src/TextureManager.cpp Zobrazit soubor

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

+ 16
- 16
src/ViewVolume.cpp Zobrazit soubor

@@ -21,7 +21,7 @@ ViewVolume::ViewVolume() {
21 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 25
     for (unsigned int p = 0; p < 6; ++p) {
26 26
         if (mFrustum[p][0] * x + mFrustum[p][1] * y + mFrustum[p][2] * z +
27 27
                 mFrustum[p][3] <= 0) {
@@ -31,16 +31,16 @@ bool ViewVolume::isPointInFrustum(vec_t x, vec_t y, vec_t z) {
31 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 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 37
         if (d <= -radius)
38 38
             return false;
39 39
     }
40 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 44
     for (unsigned int p = 0; p < 6; ++p) {
45 45
         if (mFrustum[p][0] * min[0] +
46 46
                 mFrustum[p][1] * min[1] +
@@ -87,8 +87,8 @@ bool ViewVolume::isBboxInFrustum(vec3_t min, vec3_t max) {
87 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 92
     for (unsigned int p = 0; p < 6; ++p) {
93 93
         d = mFrustum[p][0] * x + mFrustum[p][1] * y + mFrustum[p][2] * z + mFrustum[p][3];
94 94
         if (d <= -radius)
@@ -97,9 +97,9 @@ vec_t ViewVolume::getDistToSphereFromNear(vec_t x, vec_t y, vec_t z, vec_t radiu
97 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 104
     midpoint(min, max, center);
105 105
 
@@ -117,7 +117,7 @@ vec_t ViewVolume::getDistToBboxFromNear(const vec3_t min, const vec3_t max) {
117 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 121
     for (unsigned int p = 0; p < 6; ++p) {
122 122
         for (unsigned int i = 0; i < 4; ++i) {
123 123
             frustum[p][i] = mFrustum[p][i];
@@ -125,13 +125,13 @@ void ViewVolume::getFrustum(vec_t frustum[6][4]) {
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 129
     for (unsigned int i = 0; i < 4; ++i) {
130 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 135
     setModel(mdl);
136 136
     setProjection(proj);
137 137
     updateClip();
@@ -143,11 +143,11 @@ void ViewVolume::updateFrame() {
143 143
     updateFrustum();
144 144
 }
145 145
 
146
-void ViewVolume::setModel(matrix_t mdl) {
146
+void ViewVolume::setModel(float mdl[16]) {
147 147
     mModel.setMatrix(mdl);
148 148
 }
149 149
 
150
-void ViewVolume::setProjection(matrix_t proj) {
150
+void ViewVolume::setProjection(float proj[16]) {
151 151
     mProjection.setMatrix(proj);
152 152
 }
153 153
 
@@ -156,8 +156,8 @@ void ViewVolume::updateClip() {
156 156
 }
157 157
 
158 158
 void ViewVolume::updateFrustum() {
159
-    matrix_t clip;
160
-    vec_t t;
159
+    float clip[16];
160
+    float t;
161 161
 
162 162
     mClip.getMatrix(clip);
163 163
 

+ 1
- 3
src/Window.cpp Zobrazit soubor

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

+ 2
- 1
src/WindowSDL.cpp Zobrazit soubor

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

+ 24
- 24
src/math/Matrix.cpp Zobrazit soubor

@@ -15,18 +15,18 @@ Matrix::Matrix() {
15 15
     setIdentity();
16 16
 }
17 17
 
18
-Matrix::Matrix(matrix_t m) {
18
+Matrix::Matrix(float m[16]) {
19 19
     setMatrix(m);
20 20
 }
21 21
 
22 22
 Matrix::Matrix(Quaternion &q) {
23
-    matrix_t m;
23
+    float m[16];
24 24
     q.getMatrix(m);
25 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 31
 #ifdef COLUMN_ORDER
32 32
     getMatrix(m);
@@ -152,11 +152,11 @@ bool Matrix::getInvert(matrix_t out) {
152 152
 #undef SWAP_ROWS
153 153
 }
154 154
 
155
-void Matrix::getMatrix(matrix_t mat) {
155
+void Matrix::getMatrix(float mat[16]) {
156 156
     copy(mMatrix, mat);
157 157
 }
158 158
 
159
-void Matrix::getTransposeMatrix(matrix_t m) {
159
+void Matrix::getTransposeMatrix(float m[16]) {
160 160
     m[ 0]= mMatrix[0]; m[ 1]= mMatrix[4]; m[ 2]= mMatrix[ 8]; m[ 3]=mMatrix[12];
161 161
     m[ 4]= mMatrix[1]; m[ 5]= mMatrix[5]; m[ 6]= mMatrix[ 9]; m[ 7]=mMatrix[13];
162 162
     m[ 8]= mMatrix[2]; m[ 9]= mMatrix[6]; m[10]= mMatrix[10]; m[11]=mMatrix[14];
@@ -174,7 +174,7 @@ Matrix Matrix::operator *(const Matrix &a) {
174 174
 }
175 175
 
176 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 179
 #ifdef COLUMN_ORDER
180 180
     return Vector3d(mMatrix[0]*x + mMatrix[4]*y + mMatrix[ 8]*z + mMatrix[12],
@@ -187,16 +187,16 @@ Vector3d Matrix::operator *(Vector3d v) {
187 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 193
     result[0] = mMatrix[0]*x + mMatrix[1]*y + mMatrix[ 2]*z + mMatrix[ 3];
194 194
     result[1] = mMatrix[4]*x + mMatrix[5]*y + mMatrix[ 6]*z + mMatrix[ 7];
195 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 201
     result[0] = mMatrix[ 0]*x + mMatrix[ 1]*y + mMatrix[ 2]*z + mMatrix[ 3]*w;
202 202
     result[1] = mMatrix[ 4]*x + mMatrix[ 5]*y + mMatrix[ 6]*z + mMatrix[ 7]*w;
@@ -241,7 +241,7 @@ bool Matrix::isIdentity() {
241 241
     return false;
242 242
 }
243 243
 
244
-void Matrix::setMatrix(matrix_t mat) {
244
+void Matrix::setMatrix(float mat[16]) {
245 245
     copy(mat, mMatrix);
246 246
 }
247 247
 
@@ -252,13 +252,13 @@ void Matrix::setIdentity() {
252 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 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 263
     smatrix[ 0] = sx; smatrix[ 1] = 0;  smatrix[ 2] = 0;  smatrix[ 3] = 0;
264 264
     smatrix[ 4] = 0;  smatrix[ 5] = sy; smatrix[ 6] = 0;  smatrix[ 7] = 0;
@@ -269,12 +269,12 @@ void Matrix::scale(vec_t sx, vec_t sy, vec_t sz) {
269 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 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 279
     xmat[ 0]=1;         xmat[ 1]=0;         xmat[ 2]=0;         xmat[ 3]=0;
280 280
     xmat[ 4]=0;         xmat[ 5]=cosf(ax);  xmat[ 6]=sinf(ax);  xmat[ 7]=0;
@@ -296,12 +296,12 @@ void Matrix::rotate(vec_t ax, vec_t ay, vec_t az) {
296 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 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 306
     tmat[ 0]=1;  tmat[ 1]=0;  tmat[ 2]=0;  tmat[ 3]=0;
307 307
     tmat[ 4]=0;  tmat[ 5]=1;  tmat[ 6]=0;  tmat[ 7]=0;
@@ -312,12 +312,12 @@ void Matrix::translate(vec_t tx, vec_t ty, vec_t tz) {
312 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 316
     for (int i = 0; i < 16; i++)
317 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 321
     /* Generated code for matrix mult
322 322
      * Code used:
323 323
 

+ 14
- 14
src/math/Quaternion.cpp Zobrazit soubor

@@ -17,21 +17,21 @@ Quaternion::Quaternion() {
17 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 21
     mW = w;
22 22
     mX = x;
23 23
     mY = y;
24 24
     mZ = z;
25 25
 }
26 26
 
27
-Quaternion::Quaternion(vec4_t v) {
27
+Quaternion::Quaternion(float v[4]) {
28 28
     mW = v[0];
29 29
     mX = v[1];
30 30
     mY = v[2];
31 31
     mZ = v[3];
32 32
 }
33 33
 
34
-void Quaternion::getMatrix(matrix_t m) {
34
+void Quaternion::getMatrix(float m[16]) {
35 35
     m[ 0] = 1.0f - 2.0f * (mY*mY + mZ*mZ);
36 36
     m[ 1] = 2.0f * (mX*mY - mW*mZ);
37 37
     m[ 2] = 2.0f * (mX*mZ + mW*mY);
@@ -79,7 +79,7 @@ Quaternion Quaternion::conjugate() {
79 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 83
     return Quaternion(mW * s, mX * s, mY * s, mZ * s);
84 84
 }
85 85
 
@@ -87,11 +87,11 @@ Quaternion Quaternion::inverse() {
87 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 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 95
     return sqrtf(dot(*this, *this));
96 96
 }
97 97
 
@@ -102,8 +102,8 @@ void Quaternion::setIdentity() {
102 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 108
     // Normalize
109 109
     temp = x*x + y*y + z*z;
@@ -122,7 +122,7 @@ void Quaternion::set(vec_t angle, vec_t x, vec_t y, vec_t z) {
122 122
 }
123 123
 
124 124
 void Quaternion::normalize() {
125
-    vec_t dist, square;
125
+    float dist, square;
126 126
 
127 127
     square = mX * mX + mY * mY + mZ * mZ + mW * mW;
128 128
 
@@ -145,7 +145,7 @@ void Quaternion::copy(Quaternion q) {
145 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 150
      * Spherical Linear Interpolation algorthim
151 151
      *-----------------------------------------------------------------
@@ -161,7 +161,7 @@ Quaternion Quaternion::slerp(Quaternion a, Quaternion b, vec_t time) {
161 161
      *
162 162
      *******************************************************************/
163 163
 
164
-    vec_t result, scaleA, scaleB;
164
+    float result, scaleA, scaleB;
165 165
     Quaternion i;
166 166
 
167 167
 
@@ -197,8 +197,8 @@ Quaternion Quaternion::slerp(Quaternion a, Quaternion b, vec_t time) {
197 197
     if (1 - result > 0.1f) {
198 198
         // Get the angle between the 2 quaternions, and then
199 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 203
         // Calculate the scale for qA and qB, according to
204 204
         // the angle and it's sine value
@@ -211,7 +211,7 @@ Quaternion Quaternion::slerp(Quaternion a, Quaternion b, vec_t time) {
211 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 215
     float diagonal = matrix[0] + matrix[5] + matrix[10] + 1.0f;
216 216
     float scale = 0.0f;
217 217
     float w = 0.0f, x = 0.0f, y = 0.0f, z = 0.0f;

+ 10
- 10
src/math/Vector3d.cpp Zobrazit soubor

@@ -14,13 +14,13 @@ Vector3d::Vector3d() {
14 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 18
     mVec[0] = v[0];
19 19
     mVec[1] = v[1];
20 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 24
     mVec[0] = x;
25 25
     mVec[1] = y;
26 26
     mVec[2] = z;
@@ -32,7 +32,7 @@ Vector3d::Vector3d(const Vector3d &v) {
32 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 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,12 +42,12 @@ Vector3d Vector3d::cross(const Vector3d &u, const Vector3d &v) {
42 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 46
     return sqrtf(mVec[0]*mVec[0] + mVec[1]*mVec[1] + mVec[2]*mVec[2]);
47 47
 }
48 48
 
49 49
 Vector3d Vector3d::unit() {
50
-    vec_t norm = magnitude();
50
+    float norm = magnitude();
51 51
 
52 52
     return Vector3d(mVec[0] / norm,
53 53
             mVec[1] / norm,
@@ -76,24 +76,24 @@ Vector3d Vector3d::operator -() {
76 76
             -mVec[2]);
77 77
 }
78 78
 
79
-Vector3d Vector3d::operator *(vec_t s) {
79
+Vector3d Vector3d::operator *(float s) {
80 80
     return Vector3d(s * mVec[0],
81 81
             s * mVec[1],
82 82
             s * mVec[2]);
83 83
 }
84 84
 
85
-Vector3d Vector3d::operator /(vec_t s) {
85
+Vector3d Vector3d::operator /(float s) {
86 86
     return Vector3d(mVec[0] / s,
87 87
             mVec[1] / s,
88 88
             mVec[2] / s);
89 89
 }
90 90
 
91
-vec_t Vector3d::operator *(const Vector3d &v) {
91
+float Vector3d::operator *(const Vector3d &v) {
92 92
     return dot(*this, v);
93 93
 }
94 94
 
95 95
 void Vector3d::normalize() {
96
-    vec_t norm = magnitude();
96
+    float norm = magnitude();
97 97
 
98 98
     mVec[0] /= norm;
99 99
     mVec[1] /= norm;
@@ -127,7 +127,7 @@ Vector3d &Vector3d::operator -=(const Vector3d &v) {
127 127
     return *this;
128 128
 }
129 129
 
130
-Vector3d &Vector3d::operator *=(vec_t s) {
130
+Vector3d &Vector3d::operator *=(float s) {
131 131
     mVec[0] *= s;
132 132
     mVec[1] *= s;
133 133
     mVec[2] *= s;

+ 11
- 11
src/math/math.cpp Zobrazit soubor

@@ -7,8 +7,8 @@
7 7
  * \author xythobuz
8 8
  */
9 9
 
10
-#include <stdlib.h>
11
-#include <math.h>
10
+#include <cstdlib>
11
+#include <cmath>
12 12
 #include <float.h>
13 13
 #include <algorithm>
14 14
 
@@ -17,20 +17,20 @@
17 17
 #include "math/Matrix.h"
18 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 22
     if (fabs(a - b) <= (std::max(fabs(a), fabs(b)) * epsilon))
23 23
         return true;
24 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 29
     assert(polygon != NULL);
30 30
 
31
-    // vec3_t normal, a, b;
31
+    // float normal[3], a[3], b[3];
32 32
     Vector3d a, b, normal, pA, pB;
33
-    vec_t d, denominator, mu;
33
+    float d, denominator, mu;
34 34
 
35 35
 
36 36
     pA = Vector3d(p1);
@@ -76,19 +76,19 @@ int intersectionLinePolygon(vec3_t intersect,
76 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 80
     return sqrtf(((b[0] - a[0]) * (b[0] - a[0])) +
81 81
                  ((b[1] - a[1]) * (b[1] - a[1])) +
82 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 86
     mid[0] = (a[0] + b[0]) / 2.0f;
87 87
     mid[1] = (a[1] + b[1]) / 2.0f;
88 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 92
     return from + ((to - from) * rand() / (RAND_MAX + 1.0f));
93 93
 }
94 94
 

Loading…
Zrušit
Uložit