Browse Source

Auto code indentation [skip ci]

Thomas Buck 9 years ago
parent
commit
e83305bc8e
100 changed files with 2215 additions and 2783 deletions
  1. 11
    0
      CMakeLists.txt
  2. 3
    0
      ChangeLog.md
  3. 3
    3
      include/Camera.h
  4. 2
    2
      include/Console.h
  5. 6
    6
      include/Entity.h
  6. 4
    4
      include/Exception.h
  7. 5
    5
      include/Font.h
  8. 3
    3
      include/FontImGui.h
  9. 5
    5
      include/FontSDL.h
  10. 5
    5
      include/FontTRLE.h
  11. 5
    5
      include/Game.h
  12. 3
    3
      include/Log.h
  13. 6
    6
      include/Menu.h
  14. 5
    5
      include/MenuFolder.h
  15. 31
    31
      include/Mesh.h
  16. 8
    8
      include/Render.h
  17. 20
    20
      include/Room.h
  18. 19
    19
      include/RoomData.h
  19. 3
    3
      include/RunTime.h
  20. 5
    5
      include/Script.h
  21. 20
    18
      include/SkeletalModel.h
  22. 5
    4
      include/Sound.h
  23. 5
    4
      include/SoundAL.h
  24. 5
    4
      include/SoundNull.h
  25. 9
    9
      include/Sprite.h
  26. 10
    10
      include/StaticMesh.h
  27. 14
    14
      include/TextureManager.h
  28. 127
    126
      include/TombRaider.h
  29. 115
    114
      include/TombRaiderData.h
  30. 3
    3
      include/UI.h
  31. 2
    2
      include/ViewVolume.h
  32. 5
    5
      include/Window.h
  33. 2
    2
      include/WindowGLUT.h
  34. 3
    3
      include/WindowSDL.h
  35. 13
    13
      include/World.h
  36. 2
    2
      include/commands/Command.h
  37. 1
    1
      include/commands/CommandAnimate.h
  38. 2
    2
      include/commands/CommandBind.h
  39. 3
    3
      include/commands/CommandEngine.h
  40. 4
    4
      include/commands/CommandGame.h
  41. 1
    1
      include/commands/CommandMove.h
  42. 3
    3
      include/commands/CommandRender.h
  43. 1
    1
      include/commands/CommandSet.h
  44. 1
    1
      include/commands/CommandSound.h
  45. 1
    1
      include/games/TombRaider1.h
  46. 8
    6
      include/global.h
  47. 2
    2
      include/loader/Loader.h
  48. 2
    2
      include/loader/LoaderTR1.h
  49. 2
    2
      include/loader/LoaderTR2.h
  50. 2
    2
      include/loader/LoaderTR3.h
  51. 8
    8
      include/math/Matrix.h
  52. 7
    7
      include/math/Quaternion.h
  53. 11
    11
      include/math/Vector3d.h
  54. 4
    4
      include/utils/File.h
  55. 10
    10
      include/utils/Folder.h
  56. 3
    3
      include/utils/binary.h
  57. 3
    3
      include/utils/pcx.h
  58. 7
    6
      include/utils/pixel.h
  59. 5
    5
      include/utils/png.h
  60. 5
    5
      include/utils/tga.h
  61. 1
    1
      src/Console.cpp
  62. 15
    15
      src/Entity.cpp
  63. 2
    2
      src/Exception.cpp
  64. 3
    3
      src/Font.cpp
  65. 6
    4
      src/FontImGui.cpp
  66. 9
    7
      src/FontSDL.cpp
  67. 5
    5
      src/FontTRLE.cpp
  68. 22
    29
      src/Game.cpp
  69. 7
    7
      src/Menu.cpp
  70. 12
    11
      src/MenuFolder.cpp
  71. 82
    142
      src/Mesh.cpp
  72. 50
    85
      src/Render.cpp
  73. 87
    128
      src/Room.cpp
  74. 15
    16
      src/RoomData.cpp
  75. 9
    8
      src/Script.cpp
  76. 30
    28
      src/SkeletalModel.cpp
  77. 7
    6
      src/SoundAL.cpp
  78. 3
    2
      src/SoundNull.cpp
  79. 17
    17
      src/Sprite.cpp
  80. 30
    29
      src/StaticMesh.cpp
  81. 20
    20
      src/TextureManager.cpp
  82. 916
    1384
      src/TombRaider.cpp
  83. 14
    14
      src/UI.cpp
  84. 32
    32
      src/ViewVolume.cpp
  85. 9
    9
      src/Window.cpp
  86. 2
    2
      src/WindowGLUT.cpp
  87. 2
    2
      src/WindowSDL.cpp
  88. 12
    13
      src/World.cpp
  89. 3
    3
      src/commands/Command.cpp
  90. 6
    7
      src/commands/CommandAnimate.cpp
  91. 2
    2
      src/commands/CommandSet.cpp
  92. 3
    3
      src/loader/LoaderTR2.cpp
  93. 13
    13
      src/main.cpp
  94. 109
    100
      src/math/Matrix.cpp
  95. 28
    28
      src/math/Quaternion.cpp
  96. 26
    26
      src/math/Vector3d.cpp
  97. 1
    1
      src/math/math.cpp
  98. 2
    2
      src/utils/File.cpp
  99. 15
    13
      src/utils/Folder.cpp
  100. 0
    0
      src/utils/FolderRecursive.cpp

+ 11
- 0
CMakeLists.txt View File

160
         # Clean doc files
160
         # Clean doc files
161
         set_directory_properties (PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "doc")
161
         set_directory_properties (PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "doc")
162
     endif (DOXYGEN_FOUND)
162
     endif (DOXYGEN_FOUND)
163
+
164
+    #################################################################
165
+
166
+    # Auto-format code
167
+    add_custom_target (format
168
+        COMMAND astyle -A14s4pHUk1OocxC100z2SKNLm1Qxynr "include/*.h"
169
+        COMMAND astyle -A14s4pHUk1OocxC100z2SKNLm1Qxynr "src/*.cpp" --exclude=src/deps
170
+        COMMAND astyle -A14s4pHUk1OocxC100z2SKNLm1Qxynr "test/*.cpp" "test/*.h"
171
+        WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
172
+        COMMENT "Auto-Formatting code..." VERBATIM
173
+    )
163
 endif (${CMAKE_GENERATOR} STREQUAL "Unix Makefiles")
174
 endif (${CMAKE_GENERATOR} STREQUAL "Unix Makefiles")
164
 
175
 

+ 3
- 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
+    [ 20141018 ]
6
+    * Added target to auto-indent code using astyle and used it.
7
+
5
     [ 20141016 ]
8
     [ 20141016 ]
6
     * ImGuis Font can now be used if no other is available
9
     * ImGuis Font can now be used if no other is available
7
     * Added [Binspector](https://github.com/binspector/binspector) binary file format template
10
     * Added [Binspector](https://github.com/binspector/binspector) binary file format template

+ 3
- 3
include/Camera.h View File

25
  * \brief Camera class
25
  * \brief Camera class
26
  */
26
  */
27
 class Camera {
27
 class Camera {
28
-public:
28
+  public:
29
     /*!
29
     /*!
30
      * \brief Constructs an object of Camera
30
      * \brief Constructs an object of Camera
31
      */
31
      */
70
      */
70
      */
71
     void command(enum camera_command cmd);
71
     void command(enum camera_command cmd);
72
 
72
 
73
-private:
73
+  private:
74
 
74
 
75
     void rotate(float angle, float x, float y, float z);
75
     void rotate(float angle, float x, float y, float z);
76
 
76
 
84
     float mRotationDeltaY; //!< Vertical mouse sensitivity
84
     float mRotationDeltaY; //!< Vertical mouse sensitivity
85
 };
85
 };
86
 
86
 
87
-Camera &getCamera();
87
+Camera& getCamera();
88
 
88
 
89
 #endif
89
 #endif

+ 2
- 2
include/Console.h View File

12
 #include <vector>
12
 #include <vector>
13
 
13
 
14
 class Console {
14
 class Console {
15
-public:
15
+  public:
16
     static void display();
16
     static void display();
17
 
17
 
18
-private:
18
+  private:
19
     const static int bufferLength = 256;
19
     const static int bufferLength = 256;
20
     static char buffer[bufferLength + 1];
20
     static char buffer[bufferLength + 1];
21
     static bool scrollToBottom;
21
     static bool scrollToBottom;

+ 6
- 6
include/Entity.h View File

12
 #include "TombRaider.h"
12
 #include "TombRaider.h"
13
 
13
 
14
 class Entity {
14
 class Entity {
15
-public:
15
+  public:
16
     typedef enum {
16
     typedef enum {
17
         MoveTypeWalkNoSwim = -1,
17
         MoveTypeWalkNoSwim = -1,
18
         MoveTypeWalk       = 0,
18
         MoveTypeWalk       = 0,
21
         MoveTypeSwim       = 3
21
         MoveTypeSwim       = 3
22
     } MoveType;
22
     } MoveType;
23
 
23
 
24
-    Entity(TombRaider &tr, unsigned int index, unsigned int i, unsigned int model);
24
+    Entity(TombRaider& tr, unsigned int index, unsigned int i, unsigned int model);
25
 
25
 
26
-    bool operator<(Entity &o);
27
-    static bool compare(Entity *a, Entity *b);
26
+    bool operator<(Entity& o);
27
+    static bool compare(Entity* a, Entity* b);
28
     void display();
28
     void display();
29
     void move(char movement);
29
     void move(char movement);
30
     void print();
30
     void print();
31
 
31
 
32
-    SkeletalModel &getModel();
32
+    SkeletalModel& getModel();
33
     void setSkeletalModel(unsigned int model);
33
     void setSkeletalModel(unsigned int model);
34
     MoveType getMoveType();
34
     MoveType getMoveType();
35
     void setMoveType(MoveType m);
35
     void setMoveType(MoveType m);
47
     unsigned long getIdleAnimation();
47
     unsigned long getIdleAnimation();
48
     void setIdleAnimation(unsigned long index);
48
     void setIdleAnimation(unsigned long index);
49
 
49
 
50
-private:
50
+  private:
51
     float pos[3];
51
     float pos[3];
52
     float angles[3];
52
     float angles[3];
53
     long room;
53
     long room;

+ 4
- 4
include/Exception.h View File

13
 #include <string>
13
 #include <string>
14
 
14
 
15
 class Exception : std::runtime_error {
15
 class Exception : std::runtime_error {
16
-public:
17
-    Exception(const char *what);
18
-    Exception(const std::string &what);
16
+  public:
17
+    Exception(const char* what);
18
+    Exception(const std::string& what);
19
 
19
 
20
     static std::string getLastException();
20
     static std::string getLastException();
21
 
21
 
22
-private:
22
+  private:
23
     static std::string lastException;
23
     static std::string lastException;
24
 
24
 
25
     virtual void foo(); //!< We don't want to emit a vtable in every translation unit
25
     virtual void foo(); //!< We don't want to emit a vtable in every translation unit

+ 5
- 5
include/Font.h View File

14
  * \brief Font interface
14
  * \brief Font interface
15
  */
15
  */
16
 class Font {
16
 class Font {
17
-public:
17
+  public:
18
     static void shutdown();
18
     static void shutdown();
19
 
19
 
20
     static int initialize(std::string font = "");
20
     static int initialize(std::string font = "");
24
     static unsigned int heightText(float scale, unsigned int maxWidth, std::string s);
24
     static unsigned int heightText(float scale, unsigned int maxWidth, std::string s);
25
 
25
 
26
     static void drawText(unsigned int x, unsigned int y, float scale,
26
     static void drawText(unsigned int x, unsigned int y, float scale,
27
-            const unsigned char color[4], std::string s);
27
+                         const unsigned char color[4], std::string s);
28
 
28
 
29
     static void drawTextWrapped(unsigned int x, unsigned int y, float scale,
29
     static void drawTextWrapped(unsigned int x, unsigned int y, float scale,
30
-            const unsigned char color[4], unsigned int maxWidth, std::string s);
30
+                                const unsigned char color[4], unsigned int maxWidth, std::string s);
31
 
31
 
32
     static void drawTextCentered(unsigned int x, unsigned int y, float scale,
32
     static void drawTextCentered(unsigned int x, unsigned int y, float scale,
33
-            const unsigned char color[4], unsigned int width, std::string s);
33
+                                 const unsigned char color[4], unsigned int width, std::string s);
34
 
34
 
35
-private:
35
+  private:
36
     static bool isInit;
36
     static bool isInit;
37
     static std::string fontName;
37
     static std::string fontName;
38
 };
38
 };

+ 3
- 3
include/FontImGui.h View File

12
  * \brief Default Font implementation
12
  * \brief Default Font implementation
13
  */
13
  */
14
 class FontImGui {
14
 class FontImGui {
15
-public:
15
+  public:
16
     static unsigned int widthText(float scale, std::string s);
16
     static unsigned int widthText(float scale, std::string s);
17
 
17
 
18
     static unsigned int heightText(float scale, unsigned int maxWidth, std::string s);
18
     static unsigned int heightText(float scale, unsigned int maxWidth, std::string s);
19
 
19
 
20
     static void drawText(unsigned int x, unsigned int y, float scale,
20
     static void drawText(unsigned int x, unsigned int y, float scale,
21
-            const unsigned char color[4], std::string s);
21
+                         const unsigned char color[4], std::string s);
22
 
22
 
23
     static void drawTextWrapped(unsigned int x, unsigned int y, float scale,
23
     static void drawTextWrapped(unsigned int x, unsigned int y, float scale,
24
-            const unsigned char color[4], unsigned int maxWidth, std::string s);
24
+                                const unsigned char color[4], unsigned int maxWidth, std::string s);
25
 };
25
 };
26
 
26
 
27
 #endif
27
 #endif

+ 5
- 5
include/FontSDL.h View File

14
  * \brief SDL Font implementation
14
  * \brief SDL Font implementation
15
  */
15
  */
16
 class FontSDL {
16
 class FontSDL {
17
-public:
17
+  public:
18
     static void shutdown();
18
     static void shutdown();
19
 
19
 
20
     static int initialize(std::string font);
20
     static int initialize(std::string font);
24
     static unsigned int heightText(float scale, unsigned int maxWidth, std::string s);
24
     static unsigned int heightText(float scale, unsigned int maxWidth, std::string s);
25
 
25
 
26
     static void drawText(unsigned int x, unsigned int y, float scale,
26
     static void drawText(unsigned int x, unsigned int y, float scale,
27
-            const unsigned char color[4], std::string s);
27
+                         const unsigned char color[4], std::string s);
28
 
28
 
29
     static void drawTextWrapped(unsigned int x, unsigned int y, float scale,
29
     static void drawTextWrapped(unsigned int x, unsigned int y, float scale,
30
-            const unsigned char color[4], unsigned int maxWidth, std::string s);
30
+                                const unsigned char color[4], unsigned int maxWidth, std::string s);
31
 
31
 
32
-private:
32
+  private:
33
     static bool mFontInit;
33
     static bool mFontInit;
34
-    static TTF_Font *mFont;
34
+    static TTF_Font* mFont;
35
     static unsigned int mFontTexture;
35
     static unsigned int mFontTexture;
36
 };
36
 };
37
 
37
 

+ 5
- 5
include/FontTRLE.h View File

12
  * \brief Tomb Raider Level Editor Font loader
12
  * \brief Tomb Raider Level Editor Font loader
13
  */
13
  */
14
 class FontTRLE {
14
 class FontTRLE {
15
-public:
15
+  public:
16
     static void shutdown();
16
     static void shutdown();
17
 
17
 
18
     static int initialize(std::string font);
18
     static int initialize(std::string font);
22
     static unsigned int heightText(float scale, unsigned int maxWidth, std::string s);
22
     static unsigned int heightText(float scale, unsigned int maxWidth, std::string s);
23
 
23
 
24
     static void drawText(unsigned int x, unsigned int y, float scale,
24
     static void drawText(unsigned int x, unsigned int y, float scale,
25
-            const unsigned char color[4], std::string s);
25
+                         const unsigned char color[4], std::string s);
26
 
26
 
27
     static void drawTextWrapped(unsigned int x, unsigned int y, float scale,
27
     static void drawTextWrapped(unsigned int x, unsigned int y, float scale,
28
-            const unsigned char color[4], unsigned int maxWidth, std::string s);
28
+                                const unsigned char color[4], unsigned int maxWidth, std::string s);
29
 
29
 
30
-private:
30
+  private:
31
     static void setDefaultOffsets();
31
     static void setDefaultOffsets();
32
     static void loadLPS(std::string f);
32
     static void loadLPS(std::string f);
33
     static void writeChar(unsigned int index, unsigned int xDraw, unsigned int yDraw,
33
     static void writeChar(unsigned int index, unsigned int xDraw, unsigned int yDraw,
34
-            float scale, const unsigned char color[4]);
34
+                          float scale, const unsigned char color[4]);
35
 
35
 
36
     static bool mFontInit;
36
     static bool mFontInit;
37
     static unsigned int mFontTexture;
37
     static unsigned int mFontTexture;

+ 5
- 5
include/Game.h View File

15
 #include "TombRaider.h"
15
 #include "TombRaider.h"
16
 
16
 
17
 class Game {
17
 class Game {
18
-public:
18
+  public:
19
 
19
 
20
     Game();
20
     Game();
21
     ~Game();
21
     ~Game();
24
 
24
 
25
     bool isLoaded();
25
     bool isLoaded();
26
 
26
 
27
-    int loadLevel(const char *level);
27
+    int loadLevel(const char* level);
28
 
28
 
29
     void destroy();
29
     void destroy();
30
 
30
 
35
     unsigned int getTextureStart();
35
     unsigned int getTextureStart();
36
     unsigned int getTextureOffset();
36
     unsigned int getTextureOffset();
37
 
37
 
38
-    Entity &getLara();
38
+    Entity& getLara();
39
 
39
 
40
-private:
40
+  private:
41
 
41
 
42
     void processPakSounds();
42
     void processPakSounds();
43
     void processTextures();
43
     void processTextures();
58
     long mLara;
58
     long mLara;
59
 };
59
 };
60
 
60
 
61
-Game &getGame();
61
+Game& getGame();
62
 
62
 
63
 #endif
63
 #endif

+ 3
- 3
include/Log.h View File

13
 #include <vector>
13
 #include <vector>
14
 
14
 
15
 class Log {
15
 class Log {
16
-public:
16
+  public:
17
 
17
 
18
     const static char endl = '\n';
18
     const static char endl = '\n';
19
 
19
 
35
         return (*this);
35
         return (*this);
36
     }
36
     }
37
 
37
 
38
-private:
38
+  private:
39
     std::vector<std::string> mHistory;
39
     std::vector<std::string> mHistory;
40
     std::ostringstream printBuffer;
40
     std::ostringstream printBuffer;
41
 };
41
 };
42
 
42
 
43
-Log &getLog();
43
+Log& getLog();
44
 
44
 
45
 #endif
45
 #endif
46
 
46
 

+ 6
- 6
include/Menu.h View File

11
 #include <functional>
11
 #include <functional>
12
 
12
 
13
 class Menu {
13
 class Menu {
14
-public:
14
+  public:
15
 
15
 
16
     virtual ~Menu() { }
16
     virtual ~Menu() { }
17
 
17
 
22
     virtual void handleKeyboard(KeyboardButton key, bool pressed) = 0;
22
     virtual void handleKeyboard(KeyboardButton key, bool pressed) = 0;
23
 
23
 
24
     virtual void handleMouseClick(unsigned int x, unsigned int y,
24
     virtual void handleMouseClick(unsigned int x, unsigned int y,
25
-            KeyboardButton button, bool released) = 0;
25
+                                  KeyboardButton button, bool released) = 0;
26
 
26
 
27
     virtual void handleMouseScroll(int xrel, int yrel) = 0;
27
     virtual void handleMouseScroll(int xrel, int yrel) = 0;
28
 
28
 
30
 
30
 
31
     void setVisible(bool v) { visible = v; }
31
     void setVisible(bool v) { visible = v; }
32
 
32
 
33
-protected:
33
+  protected:
34
 
34
 
35
     virtual void showDialog(std::string msg, std::string btn1, std::string btn2,
35
     virtual void showDialog(std::string msg, std::string btn1, std::string btn2,
36
-            std::function<int (bool state)> callback = std::function<int (bool)>());
36
+                            std::function<int (bool state)> callback = std::function<int (bool)>());
37
 
37
 
38
     virtual void ackDialog();
38
     virtual void ackDialog();
39
 
39
 
40
     virtual bool handleKeyboardDialog(KeyboardButton key, bool pressed);
40
     virtual bool handleKeyboardDialog(KeyboardButton key, bool pressed);
41
 
41
 
42
     virtual bool handleMouseClickDialog(unsigned int x, unsigned int y,
42
     virtual bool handleMouseClickDialog(unsigned int x, unsigned int y,
43
-            KeyboardButton button, bool released);
43
+                                        KeyboardButton button, bool released);
44
 
44
 
45
     virtual bool handleMouseScrollDialog(int xrel, int yrel);
45
     virtual bool handleMouseScrollDialog(int xrel, int yrel);
46
 
46
 
55
     bool visible;
55
     bool visible;
56
 };
56
 };
57
 
57
 
58
-Menu &getMenu();
58
+Menu& getMenu();
59
 
59
 
60
 #endif
60
 #endif
61
 
61
 

+ 5
- 5
include/MenuFolder.h View File

15
  * \brief Menu 'overlay'
15
  * \brief Menu 'overlay'
16
  */
16
  */
17
 class MenuFolder : public Menu {
17
 class MenuFolder : public Menu {
18
-public:
18
+  public:
19
 
19
 
20
     /*!
20
     /*!
21
      * \brief Constructs an object of MenuFolder
21
      * \brief Constructs an object of MenuFolder
32
     virtual void display();
32
     virtual void display();
33
     virtual void handleKeyboard(KeyboardButton key, bool pressed);
33
     virtual void handleKeyboard(KeyboardButton key, bool pressed);
34
     virtual void handleMouseClick(unsigned int x, unsigned int y,
34
     virtual void handleMouseClick(unsigned int x, unsigned int y,
35
-            KeyboardButton button, bool released);
35
+                                  KeyboardButton button, bool released);
36
     virtual void handleMouseScroll(int xrel, int yrel);
36
     virtual void handleMouseScroll(int xrel, int yrel);
37
 
37
 
38
-private:
38
+  private:
39
 
39
 
40
     int init(std::string s);
40
     int init(std::string s);
41
-    int init(Folder *folder, bool filter = true);
41
+    int init(Folder* folder, bool filter = true);
42
     virtual void loadOrOpen();
42
     virtual void loadOrOpen();
43
 
43
 
44
     long mCursor;
44
     long mCursor;
45
     long mMin;
45
     long mMin;
46
 
46
 
47
-    Folder *mapFolder;
47
+    Folder* mapFolder;
48
     bool hiddenState;
48
     bool hiddenState;
49
 };
49
 };
50
 
50
 

+ 31
- 31
include/Mesh.h View File

14
  * \brief OpenGL Mesh
14
  * \brief OpenGL Mesh
15
  */
15
  */
16
 class Mesh {
16
 class Mesh {
17
-public:
17
+  public:
18
 
18
 
19
     typedef enum {
19
     typedef enum {
20
         MeshModeSolid,
20
         MeshModeSolid,
37
         unsigned int cnum_alpha_triangles;
37
         unsigned int cnum_alpha_triangles;
38
 
38
 
39
         unsigned int num_texcoors;
39
         unsigned int num_texcoors;
40
-        float **texcoors; // 2D
40
+        float** texcoors; // 2D
41
 
41
 
42
         unsigned int num_texcoors2;
42
         unsigned int num_texcoors2;
43
-        float **texcoors2; // 2D
43
+        float** texcoors2; // 2D
44
 
44
 
45
         //! Arrays of triangle indices sorted by texture
45
         //! Arrays of triangle indices sorted by texture
46
         unsigned int num_triangles;
46
         unsigned int num_triangles;
47
-        unsigned int *triangles; //!< ABCABCABC...
47
+        unsigned int* triangles; //!< ABCABCABC...
48
 
48
 
49
         //! Arrays of alpha triangle indices sorted by texture
49
         //! Arrays of alpha triangle indices sorted by texture
50
         unsigned int num_alpha_triangles;
50
         unsigned int num_alpha_triangles;
51
-        unsigned int *alpha_triangles; //!< ABCABCABC...
51
+        unsigned int* alpha_triangles; //!< ABCABCABC...
52
     } tris_t;
52
     } tris_t;
53
 
53
 
54
     typedef struct {
54
     typedef struct {
62
         unsigned int cnum_alpha_quads;
62
         unsigned int cnum_alpha_quads;
63
 
63
 
64
         unsigned int num_texcoors;
64
         unsigned int num_texcoors;
65
-        float **texcoors; // 2D
65
+        float** texcoors; // 2D
66
 
66
 
67
         unsigned int num_texcoors2;
67
         unsigned int num_texcoors2;
68
-        float **texcoors2; // 2D
68
+        float** texcoors2; // 2D
69
 
69
 
70
         //! Arrays of rectangle indices sorted by texture
70
         //! Arrays of rectangle indices sorted by texture
71
         unsigned int num_quads;
71
         unsigned int num_quads;
72
-        unsigned int *quads; //!< ABCDABCDABCD...
72
+        unsigned int* quads; //!< ABCDABCDABCD...
73
 
73
 
74
         //! Arrays of alpha rectangle indices sorted by texture
74
         //! Arrays of alpha rectangle indices sorted by texture
75
         unsigned int num_alpha_quads;
75
         unsigned int num_alpha_quads;
76
-        unsigned int *alpha_quads; //!< ABCDABCDABCD...
76
+        unsigned int* alpha_quads; //!< ABCDABCDABCD...
77
 
77
 
78
     } rect_t;
78
     } rect_t;
79
 
79
 
101
 
101
 
102
     void allocateVertices(unsigned int n);
102
     void allocateVertices(unsigned int n);
103
 
103
 
104
-    void bufferColorArray(unsigned int colorCount, float *colors);
104
+    void bufferColorArray(unsigned int colorCount, float* colors);
105
 
105
 
106
-    void bufferNormalArray(unsigned int normalCount, float *normals);
106
+    void bufferNormalArray(unsigned int normalCount, float* normals);
107
 
107
 
108
     void bufferTriangles(unsigned int count,
108
     void bufferTriangles(unsigned int count,
109
-                            unsigned int *indices, float *texCoords,
110
-                            int *textures, unsigned int *flags);
109
+                         unsigned int* indices, float* texCoords,
110
+                         int* textures, unsigned int* flags);
111
 
111
 
112
-    void bufferVertexArray(unsigned int vertexCount, float *vertices);
112
+    void bufferVertexArray(unsigned int vertexCount, float* vertices);
113
 
113
 
114
     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);
115
 
115
 
123
     void sortFacesByTexture();
123
     void sortFacesByTexture();
124
 
124
 
125
     void addFace(int textureIndex, int textureIndexB, unsigned int flags,
125
     void addFace(int textureIndex, int textureIndexB, unsigned int flags,
126
-                    unsigned int vertexIndexCount, float *vertexIndices);
126
+                 unsigned int vertexIndexCount, float* vertexIndices);
127
 
127
 
128
     void addTexTiledFace(int textureIndex, int textureIndexB,
128
     void addTexTiledFace(int textureIndex, int textureIndexB,
129
-                            unsigned int flags, unsigned int indexCount,
130
-                            float *vertexIndices, float *texcoords);
129
+                         unsigned int flags, unsigned int indexCount,
130
+                         float* vertexIndices, float* texcoords);
131
 
131
 
132
-    void bufferTexcoords(unsigned int texcoordCount, float *texcoords);
132
+    void bufferTexcoords(unsigned int texcoordCount, float* texcoords);
133
 
133
 
134
     void duplicateArraysForTexTiledTexcoords();
134
     void duplicateArraysForTexTiledTexcoords();
135
 #endif
135
 #endif
139
     MeshMode mMode;
139
     MeshMode mMode;
140
 
140
 
141
     unsigned int mNumVertices;
141
     unsigned int mNumVertices;
142
-    float **mVertices; //!< XYZ
142
+    float** mVertices; //!< XYZ
143
 
143
 
144
     unsigned int mNumNormals;
144
     unsigned int mNumNormals;
145
-    float **mNormals; //!< IJK
145
+    float** mNormals; //!< IJK
146
 
146
 
147
     unsigned int mNumColors;
147
     unsigned int mNumColors;
148
-    float **mColors; //!< RGBA
148
+    float** mColors; //!< RGBA
149
 
149
 
150
     unsigned int mNumTris;
150
     unsigned int mNumTris;
151
-    tris_t *mTris;
151
+    tris_t* mTris;
152
 
152
 
153
     unsigned int mNumQuads;
153
     unsigned int mNumQuads;
154
-    rect_t *mQuads;
154
+    rect_t* mQuads;
155
 
155
 
156
     unsigned int mTriangleCount;
156
     unsigned int mTriangleCount;
157
-    int *mTriangleTextures;
158
-    unsigned int *mTriangleIndices;
159
-    unsigned int *mTriangleFlags;
160
-    float *mTriangleTexCoordArray;
161
-
162
-    float *mVertexArray;
163
-    float *mNormalArray;
164
-    float *mColorArray;
157
+    int* mTriangleTextures;
158
+    unsigned int* mTriangleIndices;
159
+    unsigned int* mTriangleFlags;
160
+    float* mTriangleTexCoordArray;
161
+
162
+    float* mVertexArray;
163
+    float* mNormalArray;
164
+    float* mColorArray;
165
 };
165
 };
166
 
166
 
167
 #endif
167
 #endif

+ 8
- 8
include/Render.h View File

18
  * \brief OpenRaider Renderer class
18
  * \brief OpenRaider Renderer class
19
  */
19
  */
20
 class Render {
20
 class Render {
21
-public:
21
+  public:
22
 
22
 
23
     typedef enum {
23
     typedef enum {
24
         modeDisabled,
24
         modeDisabled,
53
      * \brief Makes a screenshot, writes to disk
53
      * \brief Makes a screenshot, writes to disk
54
      * \param filenameBase basename of file to be written
54
      * \param filenameBase basename of file to be written
55
      */
55
      */
56
-    void screenShot(const char *filenameBase);
56
+    void screenShot(const char* filenameBase);
57
 
57
 
58
     /*!
58
     /*!
59
      * \brief Gets current rendering mode
59
      * \brief Gets current rendering mode
111
      */
111
      */
112
     bool isVisible(float x, float y, float z, float radius);
112
     bool isVisible(float x, float y, float z, float radius);
113
 
113
 
114
-    bool isVisible(BoundingBox &box);
114
+    bool isVisible(BoundingBox& box);
115
 
115
 
116
     //! \fixme should be private
116
     //! \fixme should be private
117
     ViewVolume mViewVolume; //!< View Volume for frustum culling
117
     ViewVolume mViewVolume; //!< View Volume for frustum culling
118
 
118
 
119
-private:
119
+  private:
120
 
120
 
121
-    static void lightRoom(Room &room);
121
+    static void lightRoom(Room& room);
122
 
122
 
123
     void drawLoadScreen();
123
     void drawLoadScreen();
124
 
124
 
133
      * only considers its linked rooms and their linked rooms.
133
      * only considers its linked rooms and their linked rooms.
134
      * \param room First room in list
134
      * \param room First room in list
135
      */
135
      */
136
-    void buildRoomRenderList(Room &room);
136
+    void buildRoomRenderList(Room& room);
137
 
137
 
138
     /*!
138
     /*!
139
      * \brief Renders Sky domes/boxes/etc by scaling factor.
139
      * \brief Renders Sky domes/boxes/etc by scaling factor.
148
      */
148
      */
149
     void updateViewVolume();
149
     void updateViewVolume();
150
 
150
 
151
-    std::vector<Room *> mRoomRenderList;
151
+    std::vector<Room*> mRoomRenderList;
152
 
152
 
153
     unsigned int mFlags;                  //!< Rendering flags
153
     unsigned int mFlags;                  //!< Rendering flags
154
     unsigned int mMode;                   //!< Rendering mode
154
     unsigned int mMode;                   //!< Rendering mode
157
     bool mSkyMeshRotation;                //!< Should Skymesh be rotated?
157
     bool mSkyMeshRotation;                //!< Should Skymesh be rotated?
158
 };
158
 };
159
 
159
 
160
-Render &getRender();
160
+Render& getRender();
161
 
161
 
162
 #endif
162
 #endif

+ 20
- 20
include/Room.h View File

19
 } RoomFlags;
19
 } RoomFlags;
20
 
20
 
21
 class Room {
21
 class Room {
22
-public:
23
-    Room(TombRaider &tr, unsigned int index);
22
+  public:
23
+    Room(TombRaider& tr, unsigned int index);
24
     ~Room();
24
     ~Room();
25
 
25
 
26
-    BoundingBox &getBoundingBox();
27
-    Mesh &getMesh();
26
+    BoundingBox& getBoundingBox();
27
+    Mesh& getMesh();
28
     void display(bool alpha);
28
     void display(bool alpha);
29
 
29
 
30
     bool isWall(unsigned long sector);
30
     bool isWall(unsigned long sector);
31
-    long getSector(float x, float z, float *floor, float *ceiling);
31
+    long getSector(float x, float z, float* floor, float* ceiling);
32
     long getSector(float x, float z);
32
     long getSector(float x, float z);
33
-    void getHeightAtPosition(float x, float *y, float z);
33
+    void getHeightAtPosition(float x, float* y, float z);
34
     int getAdjoiningRoom(float x, float y, float z,
34
     int getAdjoiningRoom(float x, float y, float z,
35
-        float x2, float y2, float z2);
35
+                         float x2, float y2, float z2);
36
 
36
 
37
     unsigned int getNumXSectors();
37
     unsigned int getNumXSectors();
38
     unsigned int getNumZSectors();
38
     unsigned int getNumZSectors();
45
     long getAdjacentRoom(unsigned long index);
45
     long getAdjacentRoom(unsigned long index);
46
 
46
 
47
     unsigned long sizePortals();
47
     unsigned long sizePortals();
48
-    Portal &getPortal(unsigned long index);
48
+    Portal& getPortal(unsigned long index);
49
 
49
 
50
     unsigned long sizeSectors();
50
     unsigned long sizeSectors();
51
-    Sector &getSector(unsigned long index);
51
+    Sector& getSector(unsigned long index);
52
 
52
 
53
     unsigned long sizeBox();
53
     unsigned long sizeBox();
54
-    Box &getBox(unsigned long index);
54
+    Box& getBox(unsigned long index);
55
 
55
 
56
     unsigned long sizeModels();
56
     unsigned long sizeModels();
57
-    StaticModel &getModel(unsigned long index);
57
+    StaticModel& getModel(unsigned long index);
58
 
58
 
59
     unsigned long sizeLights();
59
     unsigned long sizeLights();
60
-    Light &getLight(unsigned long index);
60
+    Light& getLight(unsigned long index);
61
 
61
 
62
     unsigned long sizeSprites();
62
     unsigned long sizeSprites();
63
-    Sprite &getSprite(unsigned long index);
63
+    Sprite& getSprite(unsigned long index);
64
 
64
 
65
-private:
65
+  private:
66
     void sortModels();
66
     void sortModels();
67
 
67
 
68
     unsigned int flags;
68
     unsigned int flags;
74
     Mesh mesh;
74
     Mesh mesh;
75
 
75
 
76
     std::vector<long> adjacentRooms;
76
     std::vector<long> adjacentRooms;
77
-    std::vector<Sprite *> sprites;
78
-    std::vector<StaticModel *> models;
79
-    std::vector<Portal *> portals;
80
-    std::vector<Box *> boxes;
81
-    std::vector<Sector *> sectors;
82
-    std::vector<Light *> lights;
77
+    std::vector<Sprite*> sprites;
78
+    std::vector<StaticModel*> models;
79
+    std::vector<Portal*> portals;
80
+    std::vector<Box*> boxes;
81
+    std::vector<Sector*> sectors;
82
+    std::vector<Light*> lights;
83
 
83
 
84
     // Was used for "depth sorting" render list, but never assigned...?!
84
     // Was used for "depth sorting" render list, but never assigned...?!
85
     //float dist; // Distance to near plane, move to room?
85
     //float dist; // Distance to near plane, move to room?

+ 19
- 19
include/RoomData.h View File

14
 #include "TombRaider.h"
14
 #include "TombRaider.h"
15
 
15
 
16
 class BoundingBox {
16
 class BoundingBox {
17
-public:
17
+  public:
18
     BoundingBox();
18
     BoundingBox();
19
     void getBoundingBox(float box[2][3]);
19
     void getBoundingBox(float box[2][3]);
20
     void setBoundingBox(float min[3], float max[3]);
20
     void setBoundingBox(float min[3], float max[3]);
22
     bool inBox(float x, float y, float z);
22
     bool inBox(float x, float y, float z);
23
     bool inBoxPlane(float x, float z);
23
     bool inBoxPlane(float x, float z);
24
 
24
 
25
-private:
25
+  private:
26
     float a[3], b[3];
26
     float a[3], b[3];
27
 };
27
 };
28
 
28
 
29
 class Light {
29
 class Light {
30
-public:
30
+  public:
31
     /*!
31
     /*!
32
      * \brief Type a light can be of
32
      * \brief Type a light can be of
33
      */
33
      */
37
         typeDirectional = 3  //!< Directional light
37
         typeDirectional = 3  //!< Directional light
38
     } LightType;
38
     } LightType;
39
 
39
 
40
-    Light(TombRaider &tr, unsigned int room, unsigned int index);
40
+    Light(TombRaider& tr, unsigned int room, unsigned int index);
41
 
41
 
42
     void getPos(float p[4]);
42
     void getPos(float p[4]);
43
     void getDir(float d[3]);
43
     void getDir(float d[3]);
46
     float getCutoff();
46
     float getCutoff();
47
     LightType getType();
47
     LightType getType();
48
 
48
 
49
-private:
49
+  private:
50
     float pos[4]; //! Light position in 3 space
50
     float pos[4]; //! Light position in 3 space
51
     float dir[3]; //! Light direction
51
     float dir[3]; //! Light direction
52
     float att;
52
     float att;
56
 };
56
 };
57
 
57
 
58
 class StaticModel {
58
 class StaticModel {
59
-public:
60
-    StaticModel(TombRaider &tr, unsigned int room, unsigned int i);
59
+  public:
60
+    StaticModel(TombRaider& tr, unsigned int room, unsigned int i);
61
     void display();
61
     void display();
62
 
62
 
63
     // Compares distance to ViewVolume for depth sorting
63
     // Compares distance to ViewVolume for depth sorting
64
-    bool operator<(const StaticModel &other);
65
-    static bool compare(StaticModel *a, StaticModel *b);
64
+    bool operator<(const StaticModel& other);
65
+    static bool compare(StaticModel* a, StaticModel* b);
66
 
66
 
67
-private:
67
+  private:
68
     int index;
68
     int index;
69
     float yaw;
69
     float yaw;
70
     float pos[3];
70
     float pos[3];
74
 };
74
 };
75
 
75
 
76
 class Portal {
76
 class Portal {
77
-public:
78
-    Portal(TombRaider &tr, unsigned int room, unsigned int index, Matrix &transform);
77
+  public:
78
+    Portal(TombRaider& tr, unsigned int room, unsigned int index, Matrix& transform);
79
 
79
 
80
     void getVertices(float vert[4][3]);
80
     void getVertices(float vert[4][3]);
81
     int getAdjoiningRoom();
81
     int getAdjoiningRoom();
82
 
82
 
83
-private:
83
+  private:
84
     float vertices[4][3];
84
     float vertices[4][3];
85
     float normal[3];
85
     float normal[3];
86
     int adjoiningRoom;
86
     int adjoiningRoom;
87
 };
87
 };
88
 
88
 
89
 class Box {
89
 class Box {
90
-public:
91
-    Box(TombRaider &tr, unsigned int room, unsigned int index);
90
+  public:
91
+    Box(TombRaider& tr, unsigned int room, unsigned int index);
92
 
92
 
93
-private:
93
+  private:
94
     float a[3], b[3], c[3], d[3];
94
     float a[3], b[3], c[3], d[3];
95
 };
95
 };
96
 
96
 
97
 class Sector {
97
 class Sector {
98
-public:
99
-    Sector(TombRaider &tr, unsigned int room, unsigned int index);
98
+  public:
99
+    Sector(TombRaider& tr, unsigned int room, unsigned int index);
100
     float getFloor();
100
     float getFloor();
101
     float getCeiling();
101
     float getCeiling();
102
     bool isWall();
102
     bool isWall();
103
 
103
 
104
-private:
104
+  private:
105
     float floor;
105
     float floor;
106
     float ceiling;
106
     float ceiling;
107
     bool wall;
107
     bool wall;

+ 3
- 3
include/RunTime.h View File

14
  * \brief Main Game Singleton
14
  * \brief Main Game Singleton
15
  */
15
  */
16
 class RunTime {
16
 class RunTime {
17
-public:
17
+  public:
18
 
18
 
19
     RunTime();
19
     RunTime();
20
 
20
 
36
     bool getFPS();
36
     bool getFPS();
37
     void setFPS(bool fps);
37
     void setFPS(bool fps);
38
 
38
 
39
-private:
39
+  private:
40
     std::string baseDir;
40
     std::string baseDir;
41
     std::string pakDir;
41
     std::string pakDir;
42
     std::string audioDir;
42
     std::string audioDir;
47
     bool showFPS;
47
     bool showFPS;
48
 };
48
 };
49
 
49
 
50
-RunTime &getRunTime();
50
+RunTime& getRunTime();
51
 
51
 
52
 #endif
52
 #endif
53
 
53
 

+ 5
- 5
include/Script.h View File

19
  * \brief Game script loader
19
  * \brief Game script loader
20
  */
20
  */
21
 class Script {
21
 class Script {
22
-public:
22
+  public:
23
 
23
 
24
     typedef enum {
24
     typedef enum {
25
         S_English  = 0,
25
         S_English  = 0,
93
     Script();
93
     Script();
94
     ~Script();
94
     ~Script();
95
 
95
 
96
-    int load(const char *file);
96
+    int load(const char* file);
97
 
97
 
98
     unsigned int levelCount();
98
     unsigned int levelCount();
99
     std::string getLevelName(unsigned int i);
99
     std::string getLevelName(unsigned int i);
124
     void registerScriptHandler(ScriptOpCode op, std::function<int (bool, uint16_t)> func);
124
     void registerScriptHandler(ScriptOpCode op, std::function<int (bool, uint16_t)> func);
125
     int runScript(unsigned int level);
125
     int runScript(unsigned int level);
126
 
126
 
127
-private:
127
+  private:
128
 
128
 
129
     typedef enum {
129
     typedef enum {
130
         S_DemoVersion            = (1 << 0),  //!< Don't load a MAIN.SFX
130
         S_DemoVersion            = (1 << 0),  //!< Don't load a MAIN.SFX
141
         S_EnableCheatCode        = (1 << 11)  //!< No known effect
141
         S_EnableCheatCode        = (1 << 11)  //!< No known effect
142
     } ScriptFlag;
142
     } ScriptFlag;
143
 
143
 
144
-    void readStringPackage(BinaryFile &f, std::vector<std::string> &v, unsigned int n);
145
-    void readScriptPackage(BinaryFile &f, std::vector<std::vector<uint16_t>> &v, unsigned int n);
144
+    void readStringPackage(BinaryFile& f, std::vector<std::string>& v, unsigned int n);
145
+    void readScriptPackage(BinaryFile& f, std::vector<std::vector<uint16_t>>& v, unsigned int n);
146
 
146
 
147
     const bool opcodeHasOperand[OP_UNKNOWN] {
147
     const bool opcodeHasOperand[OP_UNKNOWN] {
148
         true, true, true, true, true, true,
148
         true, true, true, true, true, true,

+ 20
- 18
include/SkeletalModel.h View File

14
 #include "TombRaider.h"
14
 #include "TombRaider.h"
15
 
15
 
16
 class BoneTag {
16
 class BoneTag {
17
-public:
18
-    BoneTag(TombRaider &tr, unsigned int index, unsigned int j, unsigned int *l, unsigned int frame_offset);
17
+  public:
18
+    BoneTag(TombRaider& tr, unsigned int index, unsigned int j, unsigned int* l,
19
+            unsigned int frame_offset);
19
     void display();
20
     void display();
20
 
21
 
21
     void getOffset(float o[3]);
22
     void getOffset(float o[3]);
22
     void getRotation(float r[3]);
23
     void getRotation(float r[3]);
23
     char getFlag();
24
     char getFlag();
24
 
25
 
25
-private:
26
+  private:
26
     int mesh;
27
     int mesh;
27
     float off[3];
28
     float off[3];
28
     float rot[3];
29
     float rot[3];
30
 };
31
 };
31
 
32
 
32
 class BoneFrame {
33
 class BoneFrame {
33
-public:
34
-    BoneFrame(TombRaider &tr, unsigned int index, unsigned int frame_offset);
34
+  public:
35
+    BoneFrame(TombRaider& tr, unsigned int index, unsigned int frame_offset);
35
     ~BoneFrame();
36
     ~BoneFrame();
36
 
37
 
37
     void getPosition(float p[3]);
38
     void getPosition(float p[3]);
38
 
39
 
39
     unsigned long size();
40
     unsigned long size();
40
-    BoneTag &get(unsigned long i);
41
+    BoneTag& get(unsigned long i);
41
 
42
 
42
-private:
43
+  private:
43
     float pos[3];
44
     float pos[3];
44
-    std::vector<BoneTag *> tag;
45
+    std::vector<BoneTag*> tag;
45
 };
46
 };
46
 
47
 
47
 class AnimationFrame {
48
 class AnimationFrame {
48
-public:
49
-    AnimationFrame(TombRaider &tr, unsigned int index, int a, unsigned int *frame_offset, int frame_step);
49
+  public:
50
+    AnimationFrame(TombRaider& tr, unsigned int index, int a, unsigned int* frame_offset,
51
+                   int frame_step);
50
     ~AnimationFrame();
52
     ~AnimationFrame();
51
 
53
 
52
     unsigned long size();
54
     unsigned long size();
53
-    BoneFrame &get(unsigned long i);
55
+    BoneFrame& get(unsigned long i);
54
 
56
 
55
-private:
57
+  private:
56
     char rate;
58
     char rate;
57
-    std::vector<BoneFrame *> frame;
59
+    std::vector<BoneFrame*> frame;
58
 };
60
 };
59
 
61
 
60
 class SkeletalModel {
62
 class SkeletalModel {
61
-public:
62
-    SkeletalModel(TombRaider &tr, unsigned int index, int objectId);
63
+  public:
64
+    SkeletalModel(TombRaider& tr, unsigned int index, int objectId);
63
     ~SkeletalModel();
65
     ~SkeletalModel();
64
     void display(unsigned long aframe, unsigned long bframe);
66
     void display(unsigned long aframe, unsigned long bframe);
65
 
67
 
68
     void setPonyPos(float x, float y, float z, float angle);
70
     void setPonyPos(float x, float y, float z, float angle);
69
 
71
 
70
     unsigned long size();
72
     unsigned long size();
71
-    AnimationFrame &get(unsigned long i);
73
+    AnimationFrame& get(unsigned long i);
72
 
74
 
73
-private:
75
+  private:
74
     int id;
76
     int id;
75
     bool tr4Overlay;
77
     bool tr4Overlay;
76
     bool pigtails;
78
     bool pigtails;
81
     float ponytailAngle;
83
     float ponytailAngle;
82
     float ponyOff;
84
     float ponyOff;
83
     float ponyOff2;
85
     float ponyOff2;
84
-    std::vector<AnimationFrame *> animation;
86
+    std::vector<AnimationFrame*> animation;
85
 };
87
 };
86
 
88
 
87
 #endif
89
 #endif

+ 5
- 4
include/Sound.h View File

13
  * \brief This is the audio manager for OpenRaider
13
  * \brief This is the audio manager for OpenRaider
14
  */
14
  */
15
 class Sound {
15
 class Sound {
16
-public:
16
+  public:
17
 
17
 
18
     typedef enum {
18
     typedef enum {
19
         SoundFlagsNone = 0,       //!< No effect
19
         SoundFlagsNone = 0,       //!< No effect
71
      * \param flags set options. Use SoundFlags enum bitwise OR-ed
71
      * \param flags set options. Use SoundFlags enum bitwise OR-ed
72
      * \returns 0 for no error or < 0 error flag
72
      * \returns 0 for no error or < 0 error flag
73
      */
73
      */
74
-    virtual int addFile(const char *filename, unsigned long *source, unsigned int flags) = 0;
74
+    virtual int addFile(const char* filename, unsigned long* source, unsigned int flags) = 0;
75
 
75
 
76
     /*!
76
     /*!
77
      * \brief Load wav file from buffer
77
      * \brief Load wav file from buffer
81
      * \param flags set options. Use SoundFlags enum bitwise OR-ed
81
      * \param flags set options. Use SoundFlags enum bitwise OR-ed
82
      * \returns 0 for no error or < 0 error flag
82
      * \returns 0 for no error or < 0 error flag
83
      */
83
      */
84
-    virtual int addWave(unsigned char *wav, unsigned int length, unsigned long *source, unsigned int flags) = 0;
84
+    virtual int addWave(unsigned char* wav, unsigned int length, unsigned long* source,
85
+                        unsigned int flags) = 0;
85
 
86
 
86
     /*!
87
     /*!
87
      * \brief Play sound source
88
      * \brief Play sound source
96
     virtual void stop(unsigned long source) = 0;
97
     virtual void stop(unsigned long source) = 0;
97
 };
98
 };
98
 
99
 
99
-Sound &getSound();
100
+Sound& getSound();
100
 
101
 
101
 #endif
102
 #endif
102
 
103
 

+ 5
- 4
include/SoundAL.h View File

17
  * \brief This is the OpenAL audio manager
17
  * \brief This is the OpenAL audio manager
18
  */
18
  */
19
 class SoundAL : public Sound {
19
 class SoundAL : public Sound {
20
-public:
20
+  public:
21
 
21
 
22
     /*!
22
     /*!
23
      * \brief Constructs an object of SoundAL
23
      * \brief Constructs an object of SoundAL
75
      * \param flags set options. Use SoundFlags enum bitwise OR-ed
75
      * \param flags set options. Use SoundFlags enum bitwise OR-ed
76
      * \returns 0 for no error or < 0 error flag
76
      * \returns 0 for no error or < 0 error flag
77
      */
77
      */
78
-    virtual int addFile(const char *filename, unsigned long *source, unsigned int flags);
78
+    virtual int addFile(const char* filename, unsigned long* source, unsigned int flags);
79
 
79
 
80
     /*!
80
     /*!
81
      * \brief Load wav file from buffer
81
      * \brief Load wav file from buffer
85
      * \param flags set options. Use SoundFlags enum bitwise OR-ed
85
      * \param flags set options. Use SoundFlags enum bitwise OR-ed
86
      * \returns 0 for no error or < 0 error flag
86
      * \returns 0 for no error or < 0 error flag
87
      */
87
      */
88
-    virtual int addWave(unsigned char *wav, unsigned int length, unsigned long *source, unsigned int flags);
88
+    virtual int addWave(unsigned char* wav, unsigned int length, unsigned long* source,
89
+                        unsigned int flags);
89
 
90
 
90
     /*!
91
     /*!
91
      * \brief Play sound source
92
      * \brief Play sound source
99
      */
100
      */
100
     virtual void stop(unsigned long source);
101
     virtual void stop(unsigned long source);
101
 
102
 
102
-private:
103
+  private:
103
 
104
 
104
     bool mEnabled;
105
     bool mEnabled;
105
     bool mInit;                         //!< Guard to ensure ausio system is active
106
     bool mInit;                         //!< Guard to ensure ausio system is active

+ 5
- 4
include/SoundNull.h View File

14
  * \brief This is the null audio manager
14
  * \brief This is the null audio manager
15
  */
15
  */
16
 class SoundNull : public Sound {
16
 class SoundNull : public Sound {
17
-public:
17
+  public:
18
 
18
 
19
     /*!
19
     /*!
20
      * \brief Constructs an object of SoundNull
20
      * \brief Constructs an object of SoundNull
72
      * \param flags set options. Use SoundFlags enum bitwise OR-ed
72
      * \param flags set options. Use SoundFlags enum bitwise OR-ed
73
      * \returns 0 for no error or < 0 error flag
73
      * \returns 0 for no error or < 0 error flag
74
      */
74
      */
75
-    virtual int addFile(const char *filename, unsigned long *source, unsigned int flags);
75
+    virtual int addFile(const char* filename, unsigned long* source, unsigned int flags);
76
 
76
 
77
     /*!
77
     /*!
78
      * \brief Load wav file from buffer
78
      * \brief Load wav file from buffer
82
      * \param flags set options. Use SoundFlags enum bitwise OR-ed
82
      * \param flags set options. Use SoundFlags enum bitwise OR-ed
83
      * \returns 0 for no error or < 0 error flag
83
      * \returns 0 for no error or < 0 error flag
84
      */
84
      */
85
-    virtual int addWave(unsigned char *wav, unsigned int length, unsigned long *source, unsigned int flags);
85
+    virtual int addWave(unsigned char* wav, unsigned int length, unsigned long* source,
86
+                        unsigned int flags);
86
 
87
 
87
     /*!
88
     /*!
88
      * \brief Play sound source
89
      * \brief Play sound source
96
      */
97
      */
97
     virtual void stop(unsigned long source);
98
     virtual void stop(unsigned long source);
98
 
99
 
99
-private:
100
+  private:
100
     unsigned long sources;
101
     unsigned long sources;
101
 };
102
 };
102
 
103
 

+ 9
- 9
include/Sprite.h View File

11
 #include "TombRaider.h"
11
 #include "TombRaider.h"
12
 
12
 
13
 class Sprite {
13
 class Sprite {
14
-public:
15
-    Sprite(TombRaider &tr, unsigned int room, unsigned int index);
16
-    Sprite(TombRaider &tr, unsigned int item, unsigned int sequence, unsigned int index);
14
+  public:
15
+    Sprite(TombRaider& tr, unsigned int room, unsigned int index);
16
+    Sprite(TombRaider& tr, unsigned int item, unsigned int sequence, unsigned int index);
17
     void display();
17
     void display();
18
 
18
 
19
-private:
19
+  private:
20
     float vertex[4][3];
20
     float vertex[4][3];
21
     float texel[4][2];
21
     float texel[4][2];
22
     float pos[3];
22
     float pos[3];
25
 };
25
 };
26
 
26
 
27
 class SpriteSequence {
27
 class SpriteSequence {
28
-public:
29
-    SpriteSequence(TombRaider &tr, unsigned int item, unsigned int sequence);
28
+  public:
29
+    SpriteSequence(TombRaider& tr, unsigned int item, unsigned int sequence);
30
     ~SpriteSequence();
30
     ~SpriteSequence();
31
 
31
 
32
     unsigned long size();
32
     unsigned long size();
33
-    Sprite &get(unsigned long index);
33
+    Sprite& get(unsigned long index);
34
 
34
 
35
-private:
36
-    std::vector<Sprite *> sprites;
35
+  private:
36
+    std::vector<Sprite*> sprites;
37
 };
37
 };
38
 
38
 
39
 #endif
39
 #endif

+ 10
- 10
include/StaticMesh.h View File

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

+ 14
- 14
include/TextureManager.h View File

15
  * \brief Texture registry
15
  * \brief Texture registry
16
  */
16
  */
17
 class TextureManager {
17
 class TextureManager {
18
-public:
18
+  public:
19
 
19
 
20
     enum TextureFlag {
20
     enum TextureFlag {
21
         fUseMultiTexture = (1 << 0),
21
         fUseMultiTexture = (1 << 0),
26
     */
26
     */
27
     TextureManager();
27
     TextureManager();
28
 
28
 
29
-   /*!
30
-    * \brief Deconstructs an object of Texture
31
-    */
29
+    /*!
30
+     * \brief Deconstructs an object of Texture
31
+     */
32
     ~TextureManager();
32
     ~TextureManager();
33
 
33
 
34
     /*!
34
     /*!
76
      * \param filter if the texture should be mipmap filtered
76
      * \param filter if the texture should be mipmap filtered
77
      * \returns texture ID or < 0 on error
77
      * \returns texture ID or < 0 on error
78
      */
78
      */
79
-    int loadBufferSlot(unsigned char *image,
80
-                        unsigned int width, unsigned int height,
81
-                        ColorMode mode, unsigned int bpp,
82
-                        unsigned int slot, bool filter = true);
79
+    int loadBufferSlot(unsigned char* image,
80
+                       unsigned int width, unsigned int height,
81
+                       ColorMode mode, unsigned int bpp,
82
+                       unsigned int slot, bool filter = true);
83
 
83
 
84
-    int loadImage(const char *filename);
84
+    int loadImage(const char* filename);
85
 
85
 
86
     /*!
86
     /*!
87
      * \brief Sets an option flag
87
      * \brief Sets an option flag
91
 
91
 
92
     void useMultiTexture(float aU, float aV, float bU, float bV);
92
     void useMultiTexture(float aU, float aV, float bU, float bV);
93
 
93
 
94
-private:
95
-    int loadTGA(const char *filename);
96
-    int loadPCX(const char *filename);
97
-    int loadPNG(const char *filename);
94
+  private:
95
+    int loadTGA(const char* filename);
96
+    int loadPCX(const char* filename);
97
+    int loadPNG(const char* filename);
98
 
98
 
99
     std::vector<unsigned int> mTextureIds;
99
     std::vector<unsigned int> mTextureIds;
100
     unsigned int mFlags;
100
     unsigned int mFlags;
101
 };
101
 };
102
 
102
 
103
-TextureManager &getTextureManager();
103
+TextureManager& getTextureManager();
104
 
104
 
105
 #endif
105
 #endif
106
 
106
 

+ 127
- 126
include/TombRaider.h View File

18
  * \brief Loads maps, meshes, textures...
18
  * \brief Loads maps, meshes, textures...
19
  */
19
  */
20
 class TombRaider {
20
 class TombRaider {
21
-public:
21
+  public:
22
 
22
 
23
     /*!
23
     /*!
24
      * \brief Constructs an object of TombRaider
24
      * \brief Constructs an object of TombRaider
60
 
60
 
61
     tr2_version_type Engine();
61
     tr2_version_type Engine();
62
 
62
 
63
-    unsigned short *Frame();
63
+    unsigned short* Frame();
64
 
64
 
65
-    tr2_animation_t *Animation();
65
+    tr2_animation_t* Animation();
66
 
66
 
67
-    tr2_item_t *Item();
67
+    tr2_item_t* Item();
68
 
68
 
69
-    tr2_object_texture_t *ObjectTextures();
69
+    tr2_object_texture_t* ObjectTextures();
70
 
70
 
71
     /*!
71
     /*!
72
      * \brief Get number of boxes
72
      * \brief Get number of boxes
74
      */
74
      */
75
     unsigned int getNumBoxes();
75
     unsigned int getNumBoxes();
76
 
76
 
77
-    tr2_box_t *Box();
77
+    tr2_box_t* Box();
78
 
78
 
79
-    tr2_mesh_t *Mesh();
79
+    tr2_mesh_t* Mesh();
80
 
80
 
81
     /*!
81
     /*!
82
      * \brief Get number of animations for a moveable
82
      * \brief Get number of animations for a moveable
85
      */
85
      */
86
     int getNumAnimsForMoveable(int moveable_index);
86
     int getNumAnimsForMoveable(int moveable_index);
87
 
87
 
88
-    tr2_staticmesh_t *StaticMesh();
88
+    tr2_staticmesh_t* StaticMesh();
89
 
89
 
90
-    tr2_moveable_t *Moveable();
90
+    tr2_moveable_t* Moveable();
91
 
91
 
92
-    tr2_meshtree_t *MeshTree();
92
+    tr2_meshtree_t* MeshTree();
93
 
93
 
94
     /*!
94
     /*!
95
      * \brief Get the sprites
95
      * \brief Get the sprites
96
      * \returns the sprite array
96
      * \returns the sprite array
97
      */
97
      */
98
-    tr2_sprite_texture_t *Sprite();
98
+    tr2_sprite_texture_t* Sprite();
99
 
99
 
100
-    tr2_sprite_sequence_t *SpriteSequence();
100
+    tr2_sprite_sequence_t* SpriteSequence();
101
 
101
 
102
     /*!
102
     /*!
103
      * \brief Makes a 32bit RGBA image from a stexture/bmap
103
      * \brief Makes a 32bit RGBA image from a stexture/bmap
104
      * \param texture valid index into tex_special list
104
      * \param texture valid index into tex_special list
105
      * \returns 32bit RGBA image or NULL on error
105
      * \returns 32bit RGBA image or NULL on error
106
      */
106
      */
107
-    unsigned char *SpecialTexTile(int texture);
107
+    unsigned char* SpecialTexTile(int texture);
108
 
108
 
109
     /*!
109
     /*!
110
      * \brief Get copies of texture and it's bumpmap
110
      * \brief Get copies of texture and it's bumpmap
112
      * \param image will be set to texture if found, or NULL
112
      * \param image will be set to texture if found, or NULL
113
      * \param bumpmap will be set to bumpmap if found, or NULL
113
      * \param bumpmap will be set to bumpmap if found, or NULL
114
      */
114
      */
115
-    void Texture(int texture, unsigned char **image, unsigned char **bumpmap);
115
+    void Texture(int texture, unsigned char** image, unsigned char** bumpmap);
116
 
116
 
117
-    unsigned int *Palette16();
117
+    unsigned int* Palette16();
118
 
118
 
119
-    unsigned char *Palette8();
119
+    unsigned char* Palette8();
120
 
120
 
121
-    tr2_room_t *Room();
121
+    tr2_room_t* Room();
122
 
122
 
123
     /*!
123
     /*!
124
      * \brief Check if a file is a TombRaider pak
124
      * \brief Check if a file is a TombRaider pak
125
      * \param filename file to check
125
      * \param filename file to check
126
      * \returns 0 if it is a TombRaider pak
126
      * \returns 0 if it is a TombRaider pak
127
      */
127
      */
128
-    static int checkMime(const char *filename);
128
+    static int checkMime(const char* filename);
129
 
129
 
130
     /*!
130
     /*!
131
      * \brief Loads TombRaider 1-5 pak into memory
131
      * \brief Loads TombRaider 1-5 pak into memory
134
      * \returns 0 on success, < 0 on error
134
      * \returns 0 on success, < 0 on error
135
      * \sa TombRaider::loadTR5()
135
      * \sa TombRaider::loadTR5()
136
      */
136
      */
137
-    int Load(const char *filename);
137
+    int Load(const char* filename);
138
 
138
 
139
     /*!
139
     /*!
140
      * \brief Makes a clamped 0.0 to 1.0 texel from coord pair
140
      * \brief Makes a clamped 0.0 to 1.0 texel from coord pair
153
      * \param y will be set to computed angle
153
      * \param y will be set to computed angle
154
      * \param z will be set to computed angle
154
      * \param z will be set to computed angle
155
      */
155
      */
156
-    void computeRotationAngles(unsigned short **frame,
157
-                                unsigned int *frame_offset,
158
-                                unsigned int *angle_offset,
159
-                                float *x, float *y, float *z);
156
+    void computeRotationAngles(unsigned short** frame,
157
+                               unsigned int* frame_offset,
158
+                               unsigned int* angle_offset,
159
+                               float* x, float* y, float* z);
160
 
160
 
161
     /*!
161
     /*!
162
      * \brief Returns computed UV in u and v
162
      * \brief Returns computed UV in u and v
164
      * \param u will contain calculated x value
164
      * \param u will contain calculated x value
165
      * \param v will contain calculated y value
165
      * \param v will contain calculated y value
166
      */
166
      */
167
-    void computeUV(tr2_object_texture_vert_t *st, float *u, float *v);
167
+    void computeUV(tr2_object_texture_vert_t* st, float* u, float* v);
168
 
168
 
169
     /*!
169
     /*!
170
      * \brief Get number of bump maps in loaded pak
170
      * \brief Get number of bump maps in loaded pak
183
      * \param radius will be filled with radius, not NULL
183
      * \param radius will be filled with radius, not NULL
184
      */
184
      */
185
     void getMeshCollisionInfo(unsigned int meshIndex,
185
     void getMeshCollisionInfo(unsigned int meshIndex,
186
-                                float center[3], float *radius);
186
+                              float center[3], float* radius);
187
 
187
 
188
     /*!
188
     /*!
189
      * \brief Get SIGNED mesh count (TR encoded < 0 errors)
189
      * \brief Get SIGNED mesh count (TR encoded < 0 errors)
204
      * \fixme This method interface may change later
204
      * \fixme This method interface may change later
205
      */
205
      */
206
     void getMeshColoredRectangle(unsigned int meshIndex,
206
     void getMeshColoredRectangle(unsigned int meshIndex,
207
-                                    unsigned int faceIndex,
208
-                                    int index[6], float color[4]);
207
+                                 unsigned int faceIndex,
208
+                                 int index[6], float color[4]);
209
 
209
 
210
     /*!
210
     /*!
211
      * \brief This method is made to let you fill arrays or
211
      * \brief This method is made to let you fill arrays or
236
      * \fixme This method interface may change later
236
      * \fixme This method interface may change later
237
      */
237
      */
238
     void getMeshTexturedRectangle(unsigned int meshIndex,
238
     void getMeshTexturedRectangle(unsigned int meshIndex,
239
-                                    unsigned int faceIndex,
240
-                                    int index[6], float st[12], int *texture,
241
-                                    unsigned short *transparency);
239
+                                  unsigned int faceIndex,
240
+                                  int index[6], float st[12], int* texture,
241
+                                  unsigned short* transparency);
242
 
242
 
243
     /*!
243
     /*!
244
      * \brief This method is made to let you fill arrays or
244
      * \brief This method is made to let you fill arrays or
253
      * \fixme This method interface may change later
253
      * \fixme This method interface may change later
254
      */
254
      */
255
     void getMeshTexturedTriangle(unsigned int meshIndex,
255
     void getMeshTexturedTriangle(unsigned int meshIndex,
256
-                                    unsigned int faceIndex,
257
-                                    int index[3], float st[6], int *texture,
258
-                                    unsigned short *transparency);
256
+                                 unsigned int faceIndex,
257
+                                 int index[3], float st[6], int* texture,
258
+                                 unsigned short* transparency);
259
 
259
 
260
     /*!
260
     /*!
261
      * \brief Get face counts for a given mesh.
261
      * \brief Get face counts for a given mesh.
297
      * \param colors will be set to allocated color array (I)
297
      * \param colors will be set to allocated color array (I)
298
      */
298
      */
299
     void getMeshVertexArrays(unsigned int meshIndex,
299
     void getMeshVertexArrays(unsigned int meshIndex,
300
-                                unsigned int *vertexCount, float **verts,
301
-                                unsigned int *normalCount, float **norms,
302
-                                unsigned int *colorCount, float **colors);
300
+                             unsigned int* vertexCount, float** verts,
301
+                             unsigned int* normalCount, float** norms,
302
+                             unsigned int* colorCount, float** colors);
303
 
303
 
304
     /*!
304
     /*!
305
      * \brief Get a single collision box from room (unified)
305
      * \brief Get a single collision box from room (unified)
312
      * \returns 0 on success, < 0 on error
312
      * \returns 0 on success, < 0 on error
313
      */
313
      */
314
     int getRoomBox(unsigned int roomIndex, unsigned int index,
314
     int getRoomBox(unsigned int roomIndex, unsigned int index,
315
-                    float *xyzA, float *xyzB, float *xyzC, float *xyzD);
315
+                   float* xyzA, float* xyzB, float* xyzC, float* xyzD);
316
 
316
 
317
     /*!
317
     /*!
318
      * \brief Get number of collision boxes in room (unified)
318
      * \brief Get number of collision boxes in room (unified)
322
     unsigned int getRoomBoxCount(unsigned int roomIndex);
322
     unsigned int getRoomBoxCount(unsigned int roomIndex);
323
 
323
 
324
     void getRoomInfo(unsigned int index,
324
     void getRoomInfo(unsigned int index,
325
-                        unsigned int *flags, float pos[3],
326
-                        float bboxMin[3], float bboxMax[3]);
325
+                     unsigned int* flags, float pos[3],
326
+                     float bboxMin[3], float bboxMax[3]);
327
 
327
 
328
     /*!
328
     /*!
329
      * \brief Get a single light from a room (unified)
329
      * \brief Get a single light from a room (unified)
339
      * \returns 0 on success, < 0 on error
339
      * \returns 0 on success, < 0 on error
340
      */
340
      */
341
     int getRoomLight(unsigned int roomIndex, unsigned int index,
341
     int getRoomLight(unsigned int roomIndex, unsigned int index,
342
-                        float pos[4], float color[4], float dir[3],
343
-                        float *attenuation, float *cutoffAngle,
344
-                        unsigned int *type, unsigned int *flags);
342
+                     float pos[4], float color[4], float dir[3],
343
+                     float* attenuation, float* cutoffAngle,
344
+                     unsigned int* type, unsigned int* flags);
345
 
345
 
346
     /*!
346
     /*!
347
      * \brief Get number of lights in room (unified)
347
      * \brief Get number of lights in room (unified)
360
      * \returns 0 on success, < 0 on error
360
      * \returns 0 on success, < 0 on error
361
      */
361
      */
362
     int getRoomModel(unsigned int roomIndex, unsigned int index,
362
     int getRoomModel(unsigned int roomIndex, unsigned int index,
363
-                        int *modelIndex, float pos[3], float *yaw);
363
+                     int* modelIndex, float pos[3], float* yaw);
364
 
364
 
365
     /*!
365
     /*!
366
      * \brief Get number of room models in room (unified)
366
      * \brief Get number of room models in room (unified)
379
      * \returns 0 on success, < 0 on error
379
      * \returns 0 on success, < 0 on error
380
      */
380
      */
381
     int getRoomPortal(unsigned int roomIndex, unsigned int index,
381
     int getRoomPortal(unsigned int roomIndex, unsigned int index,
382
-                        int *adjoiningRoom, float normal[3], float vertices[12]);
382
+                      int* adjoiningRoom, float normal[3], float vertices[12]);
383
 
383
 
384
     /*!
384
     /*!
385
      * \brief Get number of portals from room (unified)
385
      * \brief Get number of portals from room (unified)
399
      * \param flags will contain flags
399
      * \param flags will contain flags
400
      */
400
      */
401
     void getRoomRectangle(unsigned int roomIndex, unsigned int rectangleIndex,
401
     void getRoomRectangle(unsigned int roomIndex, unsigned int rectangleIndex,
402
-                            unsigned int *indices, float *texCoords, int *texture,
403
-                            unsigned int *flags);
402
+                          unsigned int* indices, float* texCoords, int* texture,
403
+                          unsigned int* flags);
404
 
404
 
405
     /*!
405
     /*!
406
      * \brief Get number of rectangles from room (unified)
406
      * \brief Get number of rectangles from room (unified)
423
      * \return 0 on success, < 0 on error
423
      * \return 0 on success, < 0 on error
424
      */
424
      */
425
     int getRoomSector(unsigned int roomIndex, unsigned int index,
425
     int getRoomSector(unsigned int roomIndex, unsigned int index,
426
-                        unsigned int *flags, float *ceiling, float *floor,
427
-                        int *floorDataIndex, int *boxIndex,
428
-                        int *roomBelow, int *roomAbove);
426
+                      unsigned int* flags, float* ceiling, float* floor,
427
+                      int* floorDataIndex, int* boxIndex,
428
+                      int* roomBelow, int* roomAbove);
429
 
429
 
430
     /*!
430
     /*!
431
      * \brief Get number of sectors in room (unified)
431
      * \brief Get number of sectors in room (unified)
435
      * \returns number of sectors in room
435
      * \returns number of sectors in room
436
      */
436
      */
437
     unsigned int getRoomSectorCount(unsigned int roomIndex,
437
     unsigned int getRoomSectorCount(unsigned int roomIndex,
438
-                                    unsigned int *zSectorsCount,
439
-                                    unsigned int *xSectorsCount);
438
+                                    unsigned int* zSectorsCount,
439
+                                    unsigned int* xSectorsCount);
440
 
440
 
441
     void getRoomSprite(unsigned int roomIndex, unsigned int index,
441
     void getRoomSprite(unsigned int roomIndex, unsigned int index,
442
-                        float scale, int *texture,
443
-                        float *pos, float *vertices, float *texcoords);
442
+                       float scale, int* texture,
443
+                       float* pos, float* vertices, float* texcoords);
444
 
444
 
445
     /*!
445
     /*!
446
      * \brief Get number of sprites in room (unified)
446
      * \brief Get number of sprites in room (unified)
460
      * \param flags will contain flags
460
      * \param flags will contain flags
461
      */
461
      */
462
     void getRoomTriangle(unsigned int roomIndex, unsigned int triangleIndex,
462
     void getRoomTriangle(unsigned int roomIndex, unsigned int triangleIndex,
463
-                            unsigned int *indices, float *texCoords, int *texture,
464
-                            unsigned int *flags);
463
+                         unsigned int* indices, float* texCoords, int* texture,
464
+                         unsigned int* flags);
465
 
465
 
466
     /*!
466
     /*!
467
      * \brief Gets triangle data with texCoords for non-matching
467
      * \brief Gets triangle data with texCoords for non-matching
479
      * \param flags will contain flags
479
      * \param flags will contain flags
480
      */
480
      */
481
     void getRoomTriangles(unsigned int index, int textureOffset,
481
     void getRoomTriangles(unsigned int index, int textureOffset,
482
-                            unsigned int *count, unsigned int **indices,
483
-                            float **texCoords, int **textures,
484
-                            unsigned int **flags);
482
+                          unsigned int* count, unsigned int** indices,
483
+                          float** texCoords, int** textures,
484
+                          unsigned int** flags);
485
 
485
 
486
     /*!
486
     /*!
487
      * \brief Gets triangle data with duplicated vertex/color/normal
487
      * \brief Gets triangle data with duplicated vertex/color/normal
500
      * \param flags will contain flags
500
      * \param flags will contain flags
501
      */
501
      */
502
     void getRoomTriangles(unsigned int roomIndex, int textureOffset,
502
     void getRoomTriangles(unsigned int roomIndex, int textureOffset,
503
-                            unsigned int *count,
504
-                            unsigned int **indices, float **vertices,
505
-                            float **texCoords, float **colors,
506
-                            int **textures, unsigned int **flags);
503
+                          unsigned int* count,
504
+                          unsigned int** indices, float** vertices,
505
+                          float** texCoords, float** colors,
506
+                          int** textures, unsigned int** flags);
507
 
507
 
508
     /*!
508
     /*!
509
      * \brief Get number of triangles from room (unified)
509
      * \brief Get number of triangles from room (unified)
520
      * \param rgba will contain vertex color, has to be allocated
520
      * \param rgba will contain vertex color, has to be allocated
521
      */
521
      */
522
     void getRoomVertex(unsigned int roomIndex, unsigned int vertexIndex,
522
     void getRoomVertex(unsigned int roomIndex, unsigned int vertexIndex,
523
-                        float *xyz, float *rgba);
523
+                       float* xyz, float* rgba);
524
 
524
 
525
     /*!
525
     /*!
526
      * \brief Get allocated vertex and color arrays and their element counts (unified)
526
      * \brief Get allocated vertex and color arrays and their element counts (unified)
533
      * \param colors will contain color array
533
      * \param colors will contain color array
534
      */
534
      */
535
     void getRoomVertexArrays(unsigned int roomIndex,
535
     void getRoomVertexArrays(unsigned int roomIndex,
536
-                                unsigned int *vertexCount, float **vertices,
537
-                                unsigned int *normalCount, float **normals,
538
-                                unsigned int *colorCount, float **colors);
536
+                             unsigned int* vertexCount, float** vertices,
537
+                             unsigned int* normalCount, float** normals,
538
+                             unsigned int* colorCount, float** colors);
539
 
539
 
540
     /*!
540
     /*!
541
      * \brief Get number of lights in room (unified)
541
      * \brief Get number of lights in room (unified)
559
      * \param data will contain sound sample
559
      * \param data will contain sound sample
560
      */
560
      */
561
     void getSoundSample(unsigned int index,
561
     void getSoundSample(unsigned int index,
562
-                        unsigned int *bytes, unsigned char **data);
562
+                        unsigned int* bytes, unsigned char** data);
563
 
563
 
564
     /*!
564
     /*!
565
      * \brief Get number of loaded sound samples
565
      * \brief Get number of loaded sound samples
586
      * \param filename pak to load
586
      * \param filename pak to load
587
      * \returns < 0 on error
587
      * \returns < 0 on error
588
      */
588
      */
589
-    int loadSFX(const char *filename);
589
+    int loadSFX(const char* filename);
590
 
590
 
591
     void reset();
591
     void reset();
592
 
592
 
604
      */
604
      */
605
     void setTexelScalingFactor(float f);
605
     void setTexelScalingFactor(float f);
606
 
606
 
607
-private:
607
+  private:
608
 
608
 
609
-    void extractMeshes(unsigned char *mesh_data,
610
-                        unsigned int num_mesh_pointers,
611
-                        unsigned int *mesh_pointers);
609
+    void extractMeshes(unsigned char* mesh_data,
610
+                       unsigned int num_mesh_pointers,
611
+                       unsigned int* mesh_pointers);
612
 
612
 
613
-    int Fread(void *buffer, size_t size, size_t count, FILE *f);
613
+    int Fread(void* buffer, size_t size, size_t count, FILE* f);
614
 
614
 
615
     /*!
615
     /*!
616
      * \brief Get a copy of the sound samples
616
      * \brief Get a copy of the sound samples
617
      * \param bytes will contain size of sound samples
617
      * \param bytes will contain size of sound samples
618
      * \param data will contain sound samples themselves
618
      * \param data will contain sound samples themselves
619
      */
619
      */
620
-    void getRiffData(unsigned int *bytes, unsigned char **data);
620
+    void getRiffData(unsigned int* bytes, unsigned char** data);
621
 
621
 
622
     /*!
622
     /*!
623
      * \brief Get a copy of a TR4 sound sample
623
      * \brief Get a copy of a TR4 sound sample
626
      * \param data will contain sound sample itself
626
      * \param data will contain sound sample itself
627
      */
627
      */
628
     void getRiffDataTR4(unsigned int index,
628
     void getRiffDataTR4(unsigned int index,
629
-                        unsigned int *bytes, unsigned char **data);
629
+                        unsigned int* bytes, unsigned char** data);
630
 
630
 
631
     /*!
631
     /*!
632
      * \brief Get an array of offsets for a contiguous RIFF data stream in chunks.
632
      * \brief Get an array of offsets for a contiguous RIFF data stream in chunks.
640
      * \param numOffsets known number
640
      * \param numOffsets known number
641
      * \returns number of RIFFs found
641
      * \returns number of RIFFs found
642
      */
642
      */
643
-    int getRiffOffsets(unsigned char *riffData, unsigned int riffDataBytes,
644
-                        unsigned int **offsets, unsigned int numOffsets);
643
+    int getRiffOffsets(unsigned char* riffData, unsigned int riffDataBytes,
644
+                       unsigned int** offsets, unsigned int numOffsets);
645
 
645
 
646
     /*!
646
     /*!
647
      * \brief Makes a 32bit RGBA image from a textile.
647
      * \brief Makes a 32bit RGBA image from a textile.
651
      * \param texture valid index into textile list
651
      * \param texture valid index into textile list
652
      * \returns 32bit RGBA image or NULL on error
652
      * \returns 32bit RGBA image or NULL on error
653
      */
653
      */
654
-    unsigned char *getTexTile(int texture);
654
+    unsigned char* getTexTile(int texture);
655
 
655
 
656
     /*!
656
     /*!
657
      * \brief Loads a TR5 pak into memory.
657
      * \brief Loads a TR5 pak into memory.
658
      * \param f valid FILE
658
      * \param f valid FILE
659
      * \returns 0 on success, < 0 on error
659
      * \returns 0 on success, < 0 on error
660
      */
660
      */
661
-    int loadTR5(FILE *f);
661
+    int loadTR5(FILE* f);
662
 
662
 
663
-    static void print(const char *methodName, const char *s, ...) __attribute__((format(printf, 2, 3)));
663
+    static void print(const char* methodName, const char* s, ...) __attribute__((format(printf, 2, 3)));
664
 
664
 
665
-    void printDebug(const char *methodName, const char *s, ...) __attribute__((format(printf, 3, 4)));
665
+    void printDebug(const char* methodName, const char* s, ...) __attribute__((format(printf, 3, 4)));
666
 
666
 
667
     bool mDebug;                           //!< Debug output toggle
667
     bool mDebug;                           //!< Debug output toggle
668
     unsigned int mPakVersion;              //!< TombRaider pak file header version
668
     unsigned int mPakVersion;              //!< TombRaider pak file header version
673
     unsigned short  _num_room_textures;    //!< Num textures only for room use?
673
     unsigned short  _num_room_textures;    //!< Num textures only for room use?
674
     unsigned short _num_misc_textures;     //!< Num of textures for misc use?
674
     unsigned short _num_misc_textures;     //!< Num of textures for misc use?
675
     unsigned short _num_bump_map_textures; //!< Num of textures that are bump map, texture pairs
675
     unsigned short _num_bump_map_textures; //!< Num of textures that are bump map, texture pairs
676
-    tr2_textile8_t *_textile8;             //!< 8-bit (palettised) textiles
677
-    tr2_textile16_t *_textile16;           //!< 16-bit (ARGB) textiles
678
-    tr2_textile32_t *_textile32;           //!< 32-bit (BGRA) textiles
676
+    tr2_textile8_t* _textile8;             //!< 8-bit (palettised) textiles
677
+    tr2_textile16_t* _textile16;           //!< 16-bit (ARGB) textiles
678
+    tr2_textile32_t* _textile32;           //!< 32-bit (BGRA) textiles
679
     unsigned int _num_tex_special;         //!< Special textures and bump maps count
679
     unsigned int _num_tex_special;         //!< Special textures and bump maps count
680
-    unsigned char *_tex_special;           //!< Special textures and bump maps
680
+    unsigned char* _tex_special;           //!< Special textures and bump maps
681
     unsigned int _unknown_t;               //!< 32-bit unknown (always 0 in real TR2 levels)
681
     unsigned int _unknown_t;               //!< 32-bit unknown (always 0 in real TR2 levels)
682
     unsigned short _num_rooms;             //!< Number of rooms in this level
682
     unsigned short _num_rooms;             //!< Number of rooms in this level
683
-    tr2_room_t *_rooms;                    //!< List of rooms (TR1,TR2,TR3,TR4)
684
-    tr5_room_t *mRoomsTR5;                 //!< Rooms ( TR5 / TRC ) Only
683
+    tr2_room_t* _rooms;                    //!< List of rooms (TR1,TR2,TR3,TR4)
684
+    tr5_room_t* mRoomsTR5;                 //!< Rooms ( TR5 / TRC ) Only
685
     unsigned int _num_floor_data;          //!< Num of words of floor data this level
685
     unsigned int _num_floor_data;          //!< Num of words of floor data this level
686
-    unsigned short *_floor_data;           //!< Floor data
686
+    unsigned short* _floor_data;           //!< Floor data
687
     int mMeshCount;                        //!< Number of meshes this level
687
     int mMeshCount;                        //!< Number of meshes this level
688
-    tr2_mesh_t *mMeshes;                   //!< list of meshes
688
+    tr2_mesh_t* mMeshes;                   //!< list of meshes
689
     unsigned int _num_animations;          //!< number of animations this level
689
     unsigned int _num_animations;          //!< number of animations this level
690
-    tr2_animation_t *_animations;          //!< list of animations
690
+    tr2_animation_t* _animations;          //!< list of animations
691
     unsigned int _num_state_changes;       //!< number of structures(?) this level
691
     unsigned int _num_state_changes;       //!< number of structures(?) this level
692
-    tr2_state_change_t *_state_changes;    //!< list of structures
692
+    tr2_state_change_t* _state_changes;    //!< list of structures
693
     unsigned int _num_anim_dispatches;     //!< number of ranges(?) this level
693
     unsigned int _num_anim_dispatches;     //!< number of ranges(?) this level
694
-    tr2_anim_dispatch_t *_anim_dispatches; //!< list of ranges
694
+    tr2_anim_dispatch_t* _anim_dispatches; //!< list of ranges
695
     unsigned int _num_anim_commands;       //!< number of Bone1s this level
695
     unsigned int _num_anim_commands;       //!< number of Bone1s this level
696
-    tr2_anim_command_t *_anim_commands;    //!< list of Bone1s
696
+    tr2_anim_command_t* _anim_commands;    //!< list of Bone1s
697
     unsigned int _num_mesh_trees;          //!< number of Bone2s this level
697
     unsigned int _num_mesh_trees;          //!< number of Bone2s this level
698
-    tr2_meshtree_t *_mesh_trees;           //!< list of Bone2s
698
+    tr2_meshtree_t* _mesh_trees;           //!< list of Bone2s
699
     unsigned int _num_frames;              //!< num of words of frame data this level
699
     unsigned int _num_frames;              //!< num of words of frame data this level
700
-    unsigned short *_frames;               //!< frame data
700
+    unsigned short* _frames;               //!< frame data
701
     unsigned int _num_moveables;           //!< number of moveables this level
701
     unsigned int _num_moveables;           //!< number of moveables this level
702
-    tr2_moveable_t *_moveables;            //!< list of moveables
702
+    tr2_moveable_t* _moveables;            //!< list of moveables
703
 
703
 
704
     uint32_t numMoveablesTR5;
704
     uint32_t numMoveablesTR5;
705
-    tr5_moveable_t *moveablesTR5;
705
+    tr5_moveable_t* moveablesTR5;
706
 
706
 
707
     uint32_t numAnimationsTR5;
707
     uint32_t numAnimationsTR5;
708
-    tr5_animation_t *animationsTR5;
708
+    tr5_animation_t* animationsTR5;
709
 
709
 
710
     uint32_t numObjectTexturesTR5;
710
     uint32_t numObjectTexturesTR5;
711
-    tr5_object_texture_t *objectTexturesTR5;
711
+    tr5_object_texture_t* objectTexturesTR5;
712
 
712
 
713
     uint32_t numCinematicFramesTR5;
713
     uint32_t numCinematicFramesTR5;
714
-    tr5_cinematic_frame_t *cinematicFramesTR5;
714
+    tr5_cinematic_frame_t* cinematicFramesTR5;
715
 
715
 
716
     uint32_t numFlyByCamerasTR5;
716
     uint32_t numFlyByCamerasTR5;
717
-    tr5_flyby_camera_t *flyByCamerasTR5;
717
+    tr5_flyby_camera_t* flyByCamerasTR5;
718
 
718
 
719
     unsigned int _num_static_meshes;        //!< number of static meshes this level
719
     unsigned int _num_static_meshes;        //!< number of static meshes this level
720
-    tr2_staticmesh_t *_static_meshes;       //!< static meshes
720
+    tr2_staticmesh_t* _static_meshes;       //!< static meshes
721
     unsigned int _num_object_textures;      //!< number of object textures this level
721
     unsigned int _num_object_textures;      //!< number of object textures this level
722
-    tr2_object_texture_t *_object_textures; //!< list of object textures
722
+    tr2_object_texture_t* _object_textures; //!< list of object textures
723
 
723
 
724
     unsigned int _num_sprite_textures;        //!< num of sprite textures this level
724
     unsigned int _num_sprite_textures;        //!< num of sprite textures this level
725
-    tr2_sprite_texture_t *_sprite_textures;   //!< list of sprite textures
725
+    tr2_sprite_texture_t* _sprite_textures;   //!< list of sprite textures
726
     unsigned int _num_sprite_sequences;       //!< num of sprite sequences this level
726
     unsigned int _num_sprite_sequences;       //!< num of sprite sequences this level
727
-    tr2_sprite_sequence_t *_sprite_sequences; //!< sprite sequence data
727
+    tr2_sprite_sequence_t* _sprite_sequences; //!< sprite sequence data
728
     int  _num_cameras;                        //!< Number of Cameras
728
     int  _num_cameras;                        //!< Number of Cameras
729
-    tr2_camera_t  *_cameras;                  //!< cameras
729
+    tr2_camera_t*  _cameras;                  //!< cameras
730
     int  _num_sound_sources;                  //!< Number of Sounds
730
     int  _num_sound_sources;                  //!< Number of Sounds
731
-    tr2_sound_source_t *_sound_sources;       //!< sounds
731
+    tr2_sound_source_t* _sound_sources;       //!< sounds
732
     int  _num_boxes;                          //!< Number of Boxes
732
     int  _num_boxes;                          //!< Number of Boxes
733
-    tr2_box_t *_boxes;                        /*!< boxes - looks like
733
+    tr2_box_t* _boxes;                        /*!< boxes - looks like
734
                                                * struct { unsigned short value[4]; }
734
                                                * struct { unsigned short value[4]; }
735
                                                * - value[0..2] might be a vector;
735
                                                * - value[0..2] might be a vector;
736
                                                * value[3] seems to be index into
736
                                                * value[3] seems to be index into
737
                                                * Overlaps[] */
737
                                                * Overlaps[] */
738
     int  _num_overlaps;                       //!< Number of Overlaps
738
     int  _num_overlaps;                       //!< Number of Overlaps
739
-    short  *_overlaps;                        /*!< Overlaps -
739
+    short*  _overlaps;                        /*!< Overlaps -
740
                                                * looks like ushort; 0x8000 is flag
740
                                                * looks like ushort; 0x8000 is flag
741
                                                * of some sort appears to be an
741
                                                * of some sort appears to be an
742
                                                * offset into Boxes[] and/or
742
                                                * offset into Boxes[] and/or
743
                                                * Boxes2[] */
743
                                                * Boxes2[] */
744
-    short  *_zones;                           //!< Boxes2
744
+    short*  _zones;                           //!< Boxes2
745
     int  _num_animated_textures;              //!< Number of AnimTextures
745
     int  _num_animated_textures;              //!< Number of AnimTextures
746
-    short  *_animated_textures;               //!< Animtextures
746
+    short*  _animated_textures;               //!< Animtextures
747
     int  _num_items;                          //!< Number of Items
747
     int  _num_items;                          //!< Number of Items
748
-    tr2_item_t *_items;                       //!< Items
749
-    unsigned char  *_light_map;               //!< Colour-light maps
748
+    tr2_item_t* _items;                       //!< Items
749
+    unsigned char*  _light_map;               //!< Colour-light maps
750
     unsigned int _num_cinematic_frames;       //!< Number of cut-scene frames
750
     unsigned int _num_cinematic_frames;       //!< Number of cut-scene frames
751
-    tr2_cinematic_frame_t *_cinematic_frames; //!< Cut-scene frames
751
+    tr2_cinematic_frame_t* _cinematic_frames; //!< Cut-scene frames
752
     short  _num_demo_data;                    //!< Number of Demo Data
752
     short  _num_demo_data;                    //!< Number of Demo Data
753
-    unsigned char  *_demo_data;               //!< Demo data
753
+    unsigned char*  _demo_data;               //!< Demo data
754
     float mRoomVertexLightingFactor;
754
     float mRoomVertexLightingFactor;
755
     float mTexelScale;
755
     float mTexelScale;
756
 
756
 
757
     // Sound data
757
     // Sound data
758
-    short  *mSoundMap;                   //!< Sound map
758
+    short*  mSoundMap;                   //!< Sound map
759
     int  mNumSoundDetails;               //!< Number of SampleModifiers
759
     int  mNumSoundDetails;               //!< Number of SampleModifiers
760
-    tr2_sound_details_t *mSoundDetails;  //!< Sample modifiers
760
+    tr2_sound_details_t* mSoundDetails;  //!< Sample modifiers
761
     int  mNumSampleIndices;              //!< Number of Sample Indices
761
     int  mNumSampleIndices;              //!< Number of Sample Indices
762
-    int  *mSampleIndices;                //!< Sample indices
763
-    unsigned int *mSampleIndicesTR5;
762
+    int*  mSampleIndices;                //!< Sample indices
763
+    unsigned int* mSampleIndicesTR5;
764
     bool mRiffAlternateLoaded;           //!< Is a TR2,TR3 SFX loaded?
764
     bool mRiffAlternateLoaded;           //!< Is a TR2,TR3 SFX loaded?
765
-    unsigned int *mRiffAlternateOffsets; //!< After parsing this will
766
-                                         //!< hold byte offsets for TR2,TR3
767
-                                         //!< RIFFs in the buffered SFX
765
+    unsigned int* mRiffAlternateOffsets; //!< After parsing this will
766
+    //!< hold byte offsets for TR2,TR3
767
+    //!< RIFFs in the buffered SFX
768
     int mRiffDataSz;                     //!< Byte size of a loaded SFX
768
     int mRiffDataSz;                     //!< Byte size of a loaded SFX
769
-    unsigned char *mRiffData;            //!< SFX RIFF data in chunks
769
+    unsigned char* mRiffData;            //!< SFX RIFF data in chunks
770
     unsigned int mNumTR4Samples;
770
     unsigned int mNumTR4Samples;
771
-    unsigned char **mTR4Samples;
772
-    unsigned int *mTR4SamplesSz;
771
+    unsigned char** mTR4Samples;
772
+    unsigned int* mTR4SamplesSz;
773
 
773
 
774
     // For packed Fread emu/wrapper
774
     // For packed Fread emu/wrapper
775
-    unsigned char *mCompressedLevelData;     //!< Buffer used to emulate fread with uncompressed libz data
775
+    unsigned char*
776
+    mCompressedLevelData;     //!< Buffer used to emulate fread with uncompressed libz data
776
     unsigned int mCompressedLevelDataOffset; //!< Offset into buffer
777
     unsigned int mCompressedLevelDataOffset; //!< Offset into buffer
777
     unsigned int mCompressedLevelSize;       //!< Size of buffer
778
     unsigned int mCompressedLevelSize;       //!< Size of buffer
778
     tr_fread_mode_t mFreadMode;              //!< Fread mode file|buffer
779
     tr_fread_mode_t mFreadMode;              //!< Fread mode file|buffer

+ 115
- 114
include/TombRaiderData.h View File

102
     unsigned char r; //!< Red part
102
     unsigned char r; //!< Red part
103
     unsigned char g; //!< Green part
103
     unsigned char g; //!< Green part
104
     unsigned char b; //!< Blue part
104
     unsigned char b; //!< Blue part
105
-} __attribute__ ((packed)) tr2_colour_t;
105
+} __attribute__((packed)) tr2_colour_t;
106
 
106
 
107
 /*!
107
 /*!
108
  * \brief Basic vertex structure.
108
  * \brief Basic vertex structure.
115
     short x;
115
     short x;
116
     short y;
116
     short y;
117
     short z;
117
     short z;
118
-} __attribute__ ((packed)) tr2_vertex_t;
118
+} __attribute__((packed)) tr2_vertex_t;
119
 
119
 
120
 /*!
120
 /*!
121
  * \brief A rectangular (quad) face definition.
121
  * \brief A rectangular (quad) face definition.
131
 typedef struct {
131
 typedef struct {
132
     unsigned short vertices[4];
132
     unsigned short vertices[4];
133
     unsigned short texture;
133
     unsigned short texture;
134
-} __attribute__ ((packed)) tr2_quad_t; // was tr2_face4
134
+} __attribute__((packed)) tr2_quad_t;  // was tr2_face4
135
 
135
 
136
 typedef struct {
136
 typedef struct {
137
     unsigned short vertices[4]; //!< The 4 vertices of a quad
137
     unsigned short vertices[4]; //!< The 4 vertices of a quad
146
      * the strength of this effect:
146
      * the strength of this effect:
147
      * the more bigger the value is, the more visible is the effect.
147
      * the more bigger the value is, the more visible is the effect.
148
      */
148
      */
149
-} __attribute__ ((packed)) tr4_quad_t;
149
+} __attribute__((packed)) tr4_quad_t;
150
 
150
 
151
 /*!
151
 /*!
152
  * \brief A triangular face definition.
152
  * \brief A triangular face definition.
162
 typedef struct {
162
 typedef struct {
163
     unsigned short vertices[3];
163
     unsigned short vertices[3];
164
     unsigned short texture;
164
     unsigned short texture;
165
-} __attribute__ ((packed)) tr2_tri_t; // was tr2_face3
165
+} __attribute__((packed)) tr2_tri_t;  // was tr2_face3
166
 
166
 
167
 typedef struct {
167
 typedef struct {
168
     unsigned short vertices[3]; //!< The 3 vertices of a tri
168
     unsigned short vertices[3]; //!< The 3 vertices of a tri
169
     unsigned short texture;     //!< Object-texture index
169
     unsigned short texture;     //!< Object-texture index
170
     unsigned short lighting;    //!< Transparency flag & strength of the highlight
170
     unsigned short lighting;    //!< Transparency flag & strength of the highlight
171
-} __attribute__ ((packed)) tr4_tri_t;
171
+} __attribute__((packed)) tr4_tri_t;
172
 
172
 
173
 /*!
173
 /*!
174
  * \brief An 8-bit texture tile (65536 bytes).
174
  * \brief An 8-bit texture tile (65536 bytes).
178
  */
178
  */
179
 typedef struct {
179
 typedef struct {
180
     unsigned char tile[256 * 256];
180
     unsigned char tile[256 * 256];
181
-} __attribute__ ((packed)) tr2_textile8_t;
181
+} __attribute__((packed)) tr2_textile8_t;
182
 
182
 
183
 /*!
183
 /*!
184
  * \brief A 16-bit texture tile (131072 bytes).
184
  * \brief A 16-bit texture tile (131072 bytes).
193
  */
193
  */
194
 typedef struct {
194
 typedef struct {
195
     unsigned short tile[256 * 256];
195
     unsigned short tile[256 * 256];
196
-} __attribute__ ((packed)) tr2_textile16_t;
196
+} __attribute__((packed)) tr2_textile16_t;
197
 
197
 
198
 /*!
198
 /*!
199
  * \brief A 32-bit texture tile (262144 bytes).
199
  * \brief A 32-bit texture tile (262144 bytes).
202
  */
202
  */
203
 typedef struct {
203
 typedef struct {
204
     unsigned int tile[256 * 256];
204
     unsigned int tile[256 * 256];
205
-} __attribute__ ((packed)) tr2_textile32_t;
205
+} __attribute__((packed)) tr2_textile32_t;
206
 
206
 
207
 /*!
207
 /*!
208
  * \brief The "header" of a room.
208
  * \brief The "header" of a room.
221
     int z;        //!< Z-offset of room (world coordinates)
221
     int z;        //!< Z-offset of room (world coordinates)
222
     int y_bottom; //!< Y-offset of lowest point in room (world coordinates, actually highest value)
222
     int y_bottom; //!< Y-offset of lowest point in room (world coordinates, actually highest value)
223
     int y_top;    //!< Y-offset of highest point in room (world coordinates, actually lowest value)
223
     int y_top;    //!< Y-offset of highest point in room (world coordinates, actually lowest value)
224
-} __attribute__ ((packed)) tr2_room_info_t;
224
+} __attribute__((packed)) tr2_room_info_t;
225
 
225
 
226
 /*!
226
 /*!
227
  * \brief Portal structure.
227
  * \brief Portal structure.
237
     unsigned short adjoining_room; //!< Which room this "door" leads to
237
     unsigned short adjoining_room; //!< Which room this "door" leads to
238
     tr2_vertex_t normal;           //!< Which way the "door" faces
238
     tr2_vertex_t normal;           //!< Which way the "door" faces
239
     tr2_vertex_t vertices[4];      //!< The corners of the "door"
239
     tr2_vertex_t vertices[4];      //!< The corners of the "door"
240
-} __attribute__ ((packed)) tr2_room_portal_t;
240
+} __attribute__((packed)) tr2_room_portal_t;
241
 
241
 
242
 /*!
242
 /*!
243
  * \brief Room sector structure.
243
  * \brief Room sector structure.
277
     char floor;                //!< Absolute height of floor (Multiply by 256 for world coordinates)
277
     char floor;                //!< Absolute height of floor (Multiply by 256 for world coordinates)
278
     unsigned char  room_above; //!< The number of the room above this one (-1 or 255 if none)
278
     unsigned char  room_above; //!< The number of the room above this one (-1 or 255 if none)
279
     char ceiling;              //!< Absolute height of ceiling (multiply by 256 for world coordinates)
279
     char ceiling;              //!< Absolute height of ceiling (multiply by 256 for world coordinates)
280
-} __attribute__ ((packed)) tr2_room_sector_t;
280
+} __attribute__((packed)) tr2_room_sector_t;
281
 
281
 
282
 /*!
282
 /*!
283
  * \brief Room lighting structure.
283
  * \brief Room lighting structure.
294
     unsigned short intensity2;
294
     unsigned short intensity2;
295
     unsigned int fade1;
295
     unsigned int fade1;
296
     unsigned int fade2;
296
     unsigned int fade2;
297
-} __attribute__ ((packed)) tr2_room_light_t;
297
+} __attribute__((packed)) tr2_room_light_t;
298
 
298
 
299
 typedef struct {
299
 typedef struct {
300
     int xPosition;           //!< World coords
300
     int xPosition;           //!< World coords
309
     float length;
309
     float length;
310
     float cutoff;
310
     float cutoff;
311
     float xDir, yDir, zDir;  //!< Direction?
311
     float xDir, yDir, zDir;  //!< Direction?
312
-} __attribute__ ((packed)) tr4_room_light_t;
312
+} __attribute__((packed)) tr4_room_light_t;
313
 
313
 
314
 /*!
314
 /*!
315
  * \brief Room vertex structure.
315
  * \brief Room vertex structure.
319
 typedef struct {
319
 typedef struct {
320
     tr2_vertex_t vertex;
320
     tr2_vertex_t vertex;
321
     short lighting1;           //!< Values range from 0 to 32767 in TR3, 0=dark.
321
     short lighting1;           //!< Values range from 0 to 32767 in TR3, 0=dark.
322
-                               /*!< I think the values ranged from 0 to 8192
323
-                                * in TR1/2, 0=bright.  */
322
+    /*!< I think the values ranged from 0 to 8192
323
+     * in TR1/2, 0=bright.  */
324
     unsigned short attributes; /*!<
324
     unsigned short attributes; /*!<
325
                                 * * 0x8000 Something to do with water surface
325
                                 * * 0x8000 Something to do with water surface
326
                                 * * 0x4000 Under water lighting modulation
326
                                 * * 0x4000 Under water lighting modulation
332
                                 */
332
                                 */
333
 
333
 
334
     short lighting2;           //!< Seems to be the same as lighting1
334
     short lighting2;           //!< Seems to be the same as lighting1
335
-} __attribute__ ((packed)) tr2_vertex_room_t;
335
+} __attribute__((packed)) tr2_vertex_room_t;
336
 
336
 
337
 /*!
337
 /*!
338
  * \brief Sprite structure
338
  * \brief Sprite structure
340
 typedef struct {
340
 typedef struct {
341
     short vertex;  //!< Offset into vertex list
341
     short vertex;  //!< Offset into vertex list
342
     short texture; //!< Offset into texture list
342
     short texture; //!< Offset into texture list
343
-} __attribute__ ((packed)) tr2_room_sprite_t;
343
+} __attribute__((packed)) tr2_room_sprite_t;
344
 
344
 
345
 /*!
345
 /*!
346
  * \brief Room mesh structure.
346
  * \brief Room mesh structure.
352
  */
352
  */
353
 typedef struct tr2_room_data_s {
353
 typedef struct tr2_room_data_s {
354
     short num_vertices;          //!< Number of vertices in the following list
354
     short num_vertices;          //!< Number of vertices in the following list
355
-    tr2_vertex_room_t *vertices; //!< List of vertices (relative coordinates)
355
+    tr2_vertex_room_t* vertices; //!< List of vertices (relative coordinates)
356
     short num_rectangles;        //!< Number of textured rectangles
356
     short num_rectangles;        //!< Number of textured rectangles
357
-    tr2_quad_t *rectangles;      //!< List of textured rectangles
357
+    tr2_quad_t* rectangles;      //!< List of textured rectangles
358
     short num_triangles;         //!< Number of textured triangles
358
     short num_triangles;         //!< Number of textured triangles
359
-    tr2_tri_t *triangles;        //!< List of textured triangles
359
+    tr2_tri_t* triangles;        //!< List of textured triangles
360
     short num_sprites;           //!< Number of sprites
360
     short num_sprites;           //!< Number of sprites
361
-    tr2_room_sprite_t *sprites;  //!< List of sprites
362
-} __attribute__ ((packed)) tr2_room_data_t;
361
+    tr2_room_sprite_t* sprites;  //!< List of sprites
362
+} __attribute__((packed)) tr2_room_data_t;
363
 
363
 
364
 /*!
364
 /*!
365
  * \brief Room static mesh data.
365
  * \brief Room static mesh data.
375
     unsigned short intensity1;
375
     unsigned short intensity1;
376
     unsigned short intensity2;
376
     unsigned short intensity2;
377
     unsigned short object_id;  //!< Which StaticMesh item to draw
377
     unsigned short object_id;  //!< Which StaticMesh item to draw
378
-} __attribute__ ((packed)) tr2_room_staticmesh_t;
378
+} __attribute__((packed)) tr2_room_staticmesh_t;
379
 
379
 
380
 
380
 
381
 /*!
381
 /*!
386
 typedef struct {
386
 typedef struct {
387
     tr2_room_info_t info;                 //!< where the room exists, in world coordinates
387
     tr2_room_info_t info;                 //!< where the room exists, in world coordinates
388
     unsigned int num_data_words;          //!< number of data words (bitu16)
388
     unsigned int num_data_words;          //!< number of data words (bitu16)
389
-    unsigned char *data;                  //!< the raw data from which the rest of this is derived
389
+    unsigned char* data;                  //!< the raw data from which the rest of this is derived
390
     tr2_room_data_t room_data;            //!< the room mesh
390
     tr2_room_data_t room_data;            //!< the room mesh
391
     unsigned short num_portals;           //!< number of visibility portals that leave this room
391
     unsigned short num_portals;           //!< number of visibility portals that leave this room
392
-    tr2_room_portal_t *portals;           //!< list of visibility portals
392
+    tr2_room_portal_t* portals;           //!< list of visibility portals
393
     unsigned short num_zsectors;          //!< width of sector list
393
     unsigned short num_zsectors;          //!< width of sector list
394
     unsigned short num_xsectors;          //!< height of sector list
394
     unsigned short num_xsectors;          //!< height of sector list
395
-    tr2_room_sector_t *sector_list;       //!< list of sectors in this room
395
+    tr2_room_sector_t* sector_list;       //!< list of sectors in this room
396
     short intensity1;
396
     short intensity1;
397
     short intensity2;
397
     short intensity2;
398
     short light_mode;
398
     short light_mode;
399
     unsigned short num_lights;            //!< number of lights in this room
399
     unsigned short num_lights;            //!< number of lights in this room
400
-    tr2_room_light_t *lights;             //!< list of lights
400
+    tr2_room_light_t* lights;             //!< list of lights
401
     unsigned short num_static_meshes;     //!< number of static meshes
401
     unsigned short num_static_meshes;     //!< number of static meshes
402
-    tr2_room_staticmesh_t *static_meshes; //!< static meshes
402
+    tr2_room_staticmesh_t* static_meshes; //!< static meshes
403
     short  alternate_room;
403
     short  alternate_room;
404
     short  flags;                         /*!< * 0x0001 - room is filled with water
404
     short  flags;                         /*!< * 0x0001 - room is filled with water
405
                                            *   * 0x0020 - Lara's ponytail gets blown by the wind */
405
                                            *   * 0x0020 - Lara's ponytail gets blown by the wind */
406
     tr2_colour_t room_light_colour;       //!< TR3 ONLY!
406
     tr2_colour_t room_light_colour;       //!< TR3 ONLY!
407
-    tr4_room_light_t *tr4Lights;          //!< TR4 ONLY!
408
-} __attribute__ ((packed)) tr2_room_t;
407
+    tr4_room_light_t* tr4Lights;          //!< TR4 ONLY!
408
+} __attribute__((packed)) tr2_room_t;
409
 
409
 
410
 /*!
410
 /*!
411
  * \brief Animation structure up to TR3.
411
  * \brief Animation structure up to TR3.
420
     short unknown3;
420
     short unknown3;
421
     short unknown4;
421
     short unknown4;
422
     unsigned short frame_start;         //!< first frame in this animation
422
     unsigned short frame_start;         //!< first frame in this animation
423
-    unsigned short frame_end;           //!< last frame in this animation (numframes = (End - Start) + 1)
423
+    unsigned short
424
+    frame_end;           //!< last frame in this animation (numframes = (End - Start) + 1)
424
     unsigned short next_animation;
425
     unsigned short next_animation;
425
     unsigned short next_frame;
426
     unsigned short next_frame;
426
     unsigned short num_state_changes;
427
     unsigned short num_state_changes;
427
     unsigned short state_change_offset; //!< offset into StateChanges[]
428
     unsigned short state_change_offset; //!< offset into StateChanges[]
428
     unsigned short num_anim_commands;
429
     unsigned short num_anim_commands;
429
     unsigned short anim_command;        //!< offset into AnimCommands[]
430
     unsigned short anim_command;        //!< offset into AnimCommands[]
430
-} __attribute__ ((packed)) tr2_animation_t;
431
+} __attribute__((packed)) tr2_animation_t;
431
 
432
 
432
 /*!
433
 /*!
433
  * \brief Data for an animation structure (40 bytes in TR4 vice 32 in TR1/2/3)
434
  * \brief Data for an animation structure (40 bytes in TR4 vice 32 in TR1/2/3)
450
     unsigned short state_change_offset; //!< same meaning as in TR3
451
     unsigned short state_change_offset; //!< same meaning as in TR3
451
     unsigned short num_anim_commands;   //!< same meaning as in TR3
452
     unsigned short num_anim_commands;   //!< same meaning as in TR3
452
     unsigned short anim_command;        //!< same meaning as in TR3
453
     unsigned short anim_command;        //!< same meaning as in TR3
453
-} __attribute__ ((packed)) tr4_animation_t;
454
+} __attribute__((packed)) tr4_animation_t;
454
 
455
 
455
 /*!
456
 /*!
456
  * \brief State Change structure
457
  * \brief State Change structure
459
     unsigned short state_id;
460
     unsigned short state_id;
460
     unsigned short num_anim_dispatches; //!< Number of dispatches (seems to always be 1..5)
461
     unsigned short num_anim_dispatches; //!< Number of dispatches (seems to always be 1..5)
461
     unsigned short anim_dispatch;       //!< Offset into AnimDispatches[]
462
     unsigned short anim_dispatch;       //!< Offset into AnimDispatches[]
462
-} __attribute__ ((packed)) tr2_state_change_t;
463
+} __attribute__((packed)) tr2_state_change_t;
463
 
464
 
464
 /*!
465
 /*!
465
  * \brief Animation Dispatch structure
466
  * \brief Animation Dispatch structure
469
     short high;
470
     short high;
470
     short next_animation;
471
     short next_animation;
471
     short next_frame;
472
     short next_frame;
472
-} __attribute__ ((packed)) tr2_anim_dispatch_t;
473
+} __attribute__((packed)) tr2_anim_dispatch_t;
473
 
474
 
474
 /*!
475
 /*!
475
  * \brief AnimCommand structure
476
  * \brief AnimCommand structure
476
  */
477
  */
477
 typedef struct {
478
 typedef struct {
478
     short value;
479
     short value;
479
-} __attribute__ ((packed)) tr2_anim_command_t;
480
+} __attribute__((packed)) tr2_anim_command_t;
480
 
481
 
481
 /*!
482
 /*!
482
  * \brief MeshTree structure.
483
  * \brief MeshTree structure.
492
     int x;
493
     int x;
493
     int y;
494
     int y;
494
     int z;
495
     int z;
495
-} __attribute__ ((packed)) tr2_meshtree_t;
496
+} __attribute__((packed)) tr2_meshtree_t;
496
 
497
 
497
 /*!
498
 /*!
498
  * \brief Moveable structure.
499
  * \brief Moveable structure.
513
     unsigned int mesh_tree;       //!< offset into MeshTree[]
514
     unsigned int mesh_tree;       //!< offset into MeshTree[]
514
     unsigned int frame_offset;    //!< byte offset into Frames[] (divide by 2 for Frames[i])
515
     unsigned int frame_offset;    //!< byte offset into Frames[] (divide by 2 for Frames[i])
515
     unsigned short animation;     //!< offset into Animations[]
516
     unsigned short animation;     //!< offset into Animations[]
516
-} __attribute__ ((packed)) tr2_moveable_t;
517
+} __attribute__((packed)) tr2_moveable_t;
517
 
518
 
518
 /*!
519
 /*!
519
  * \brief StaticMesh structure.
520
  * \brief StaticMesh structure.
526
     unsigned short starting_mesh;    //!< first mesh
527
     unsigned short starting_mesh;    //!< first mesh
527
     tr2_vertex_t bounding_box[2][2];
528
     tr2_vertex_t bounding_box[2][2];
528
     unsigned short flags;
529
     unsigned short flags;
529
-} __attribute__ ((packed)) tr2_staticmesh_t;
530
+} __attribute__((packed)) tr2_staticmesh_t;
530
 
531
 
531
 /*!
532
 /*!
532
  * \brief Object texture vertex structure.
533
  * \brief Object texture vertex structure.
538
     unsigned char xpixel;
539
     unsigned char xpixel;
539
     unsigned char ycoordinate;
540
     unsigned char ycoordinate;
540
     unsigned char ypixel;
541
     unsigned char ypixel;
541
-} __attribute__ ((packed)) tr2_object_texture_vert_t;
542
+} __attribute__((packed)) tr2_object_texture_vert_t;
542
 
543
 
543
 /*!
544
 /*!
544
  * \brief Object texture structure.
545
  * \brief Object texture structure.
551
                                             */
552
                                             */
552
     unsigned short tile;                   //!< index into textile list
553
     unsigned short tile;                   //!< index into textile list
553
     tr2_object_texture_vert_t vertices[4]; //!< the four corners of the texture
554
     tr2_object_texture_vert_t vertices[4]; //!< the four corners of the texture
554
-} __attribute__ ((packed)) tr2_object_texture_t;
555
+} __attribute__((packed)) tr2_object_texture_t;
555
 
556
 
556
 /*!
557
 /*!
557
  * \brief Sprite texture structure.
558
  * \brief Sprite texture structure.
566
     short top_side;
567
     short top_side;
567
     short right_side;
568
     short right_side;
568
     short bottom_side;
569
     short bottom_side;
569
-} __attribute__ ((packed)) tr2_sprite_texture_t;
570
+} __attribute__((packed)) tr2_sprite_texture_t;
570
 
571
 
571
 /*!
572
 /*!
572
  * \brief Sprite Sequence structure
573
  * \brief Sprite Sequence structure
575
     int object_id;         //!< Item identifier (same numbering as in tr2_moveable)
576
     int object_id;         //!< Item identifier (same numbering as in tr2_moveable)
576
     short negative_length; //!< Negative of "how many sprites are in this sequence"
577
     short negative_length; //!< Negative of "how many sprites are in this sequence"
577
     short offset;          //!< Where (in sprite texture list) this sequence starts
578
     short offset;          //!< Where (in sprite texture list) this sequence starts
578
-} __attribute__ ((packed)) tr2_sprite_sequence_t;
579
+} __attribute__((packed)) tr2_sprite_sequence_t;
579
 
580
 
580
 /*!
581
 /*!
581
  * \brief Mesh structure.
582
  * \brief Mesh structure.
595
                                       * (relative coordinates, just like the vertices) */
596
                                       * (relative coordinates, just like the vertices) */
596
     int collision_size;              //!< radius of collisional sphere
597
     int collision_size;              //!< radius of collisional sphere
597
     short num_vertices;              //!< number of vertices in this mesh
598
     short num_vertices;              //!< number of vertices in this mesh
598
-    tr2_vertex_t *vertices;          //!< list of vertices (relative coordinates)
599
+    tr2_vertex_t* vertices;          //!< list of vertices (relative coordinates)
599
     short num_normals;               //!< number of normals in this mesh (should always equal NumVertices)
600
     short num_normals;               //!< number of normals in this mesh (should always equal NumVertices)
600
-    tr2_vertex_t *normals;           //!< list of normals (NULL if NumNormals < 0)
601
-    short *mesh_lights;              //!< if NumNormals < 0
601
+    tr2_vertex_t* normals;           //!< list of normals (NULL if NumNormals < 0)
602
+    short* mesh_lights;              //!< if NumNormals < 0
602
     short num_textured_rectangles;   //!< number of textured rectangles
603
     short num_textured_rectangles;   //!< number of textured rectangles
603
-    tr2_quad_t *textured_rectangles; //!< list of textured rectangles
604
+    tr2_quad_t* textured_rectangles; //!< list of textured rectangles
604
     short num_textured_triangles;    //!< number of textured triangles in this mesh
605
     short num_textured_triangles;    //!< number of textured triangles in this mesh
605
-    tr2_tri_t *textured_triangles;   //!< list of textured triangles
606
+    tr2_tri_t* textured_triangles;   //!< list of textured triangles
606
     short num_coloured_rectangles;   //!< number of coloured rectangles
607
     short num_coloured_rectangles;   //!< number of coloured rectangles
607
-    tr2_quad_t *coloured_rectangles; //!< list of coloured rectangles
608
+    tr2_quad_t* coloured_rectangles; //!< list of coloured rectangles
608
     short num_coloured_triangles;    //!< number of coloured triangles in this mesh
609
     short num_coloured_triangles;    //!< number of coloured triangles in this mesh
609
-    tr2_tri_t *coloured_triangles;   //!< list of coloured triangles
610
-} __attribute__ ((packed)) tr2_mesh_t;
610
+    tr2_tri_t* coloured_triangles;   //!< list of coloured triangles
611
+} __attribute__((packed)) tr2_mesh_t;
611
 
612
 
612
 /*!
613
 /*!
613
  * \brief Frame structure.
614
  * \brief Frame structure.
649
 typedef struct {
650
 typedef struct {
650
     tr2_vertex_t vector[3];
651
     tr2_vertex_t vector[3];
651
     int num_words;
652
     int num_words;
652
-    unsigned short *words;
653
-} __attribute__ ((packed)) tr2_frame_t;
653
+    unsigned short* words;
654
+} __attribute__((packed)) tr2_frame_t;
654
 
655
 
655
 /*!
656
 /*!
656
  * \brief Item structure
657
  * \brief Item structure
665
     short intensity1;
666
     short intensity1;
666
     short intensity2;
667
     short intensity2;
667
     short flags;      //!< 0x0100 indicates "inactive" or "invisible"
668
     short flags;      //!< 0x0100 indicates "inactive" or "invisible"
668
-} __attribute__ ((packed)) tr2_item_t;
669
+} __attribute__((packed)) tr2_item_t;
669
 
670
 
670
 /*!
671
 /*!
671
  * \brief SoundSource structure
672
  * \brief SoundSource structure
676
     int z;
677
     int z;
677
     unsigned short sound_id; //!< internal sound index
678
     unsigned short sound_id; //!< internal sound index
678
     unsigned short flags;    //!< 0x40, 0x80, or 0xc0
679
     unsigned short flags;    //!< 0x40, 0x80, or 0xc0
679
-} __attribute__ ((packed)) tr2_sound_source_t;
680
+} __attribute__((packed)) tr2_sound_source_t;
680
 
681
 
681
 /*!
682
 /*!
682
  * \brief Boxes structure
683
  * \brief Boxes structure
688
     unsigned char xmax;
689
     unsigned char xmax;
689
     short true_floor;    //!< Y value (no scaling)
690
     short true_floor;    //!< Y value (no scaling)
690
     short overlap_index; //!< index into Overlaps[]
691
     short overlap_index; //!< index into Overlaps[]
691
-} __attribute__ ((packed)) tr2_box_t;
692
+} __attribute__((packed)) tr2_box_t;
692
 
693
 
693
 /*!
694
 /*!
694
  * \brief AnimatedTexture structure.
695
  * \brief AnimatedTexture structure.
697
  */
698
  */
698
 typedef struct {
699
 typedef struct {
699
     short num_texture_ids; //!< Number of Texture IDs - 1
700
     short num_texture_ids; //!< Number of Texture IDs - 1
700
-    short *texture_list;   //!< list of textures to cycle through
701
-} __attribute__ ((packed)) tr2_animated_texture_t;
701
+    short* texture_list;   //!< list of textures to cycle through
702
+} __attribute__((packed)) tr2_animated_texture_t;
702
 
703
 
703
 /*!
704
 /*!
704
  * \brief Camera structure
705
  * \brief Camera structure
709
     int z;
710
     int z;
710
     short room;
711
     short room;
711
     unsigned short unknown1; //!< correlates to Boxes[]?
712
     unsigned short unknown1; //!< correlates to Boxes[]?
712
-} __attribute__ ((packed)) tr2_camera_t;
713
+} __attribute__((packed)) tr2_camera_t;
713
 
714
 
714
 /*
715
 /*
715
  * \brief Data for a flyby camera (40 bytes)
716
  * \brief Data for a flyby camera (40 bytes)
719
     unsigned char index[2];    //!< A pair of indices
720
     unsigned char index[2];    //!< A pair of indices
720
     unsigned short unknown[5]; //!< ??
721
     unsigned short unknown[5]; //!< ??
721
     int id;                    //!< Index of something
722
     int id;                    //!< Index of something
722
-} __attribute__ ((packed)) tr4_extra_camera_t;
723
+} __attribute__((packed)) tr4_extra_camera_t;
723
 
724
 
724
 /*!
725
 /*!
725
  * \brief Sound sample structure
726
  * \brief Sound sample structure
730
     short sound_range;
731
     short sound_range;
731
     short flags;       /*!< \ brief bits 8-15: priority?, 2-7: number of sound samples
732
     short flags;       /*!< \ brief bits 8-15: priority?, 2-7: number of sound samples
732
                         * in this group, bits 0-1: channel number */
733
                         * in this group, bits 0-1: channel number */
733
-} __attribute__ ((packed)) tr2_sound_details_t;
734
+} __attribute__((packed)) tr2_sound_details_t;
734
 
735
 
735
 /*!
736
 /*!
736
  * \brief Cutscene Camera structure
737
  * \brief Cutscene Camera structure
744
     short posx;     //!< X position of camera, relative to something
745
     short posx;     //!< X position of camera, relative to something
745
     short unknown1;
746
     short unknown1;
746
     short rotx;     //!< Rotation about X axis, +/-32767 ::= +/- 180 degrees
747
     short rotx;     //!< Rotation about X axis, +/-32767 ::= +/- 180 degrees
747
-} __attribute__ ((packed)) tr2_cinematic_frame_t;
748
+} __attribute__((packed)) tr2_cinematic_frame_t;
748
 
749
 
749
 /*!
750
 /*!
750
  * \brief Data for a AI object (24 bytes).
751
  * \brief Data for a AI object (24 bytes).
755
  */
756
  */
756
 typedef struct {
757
 typedef struct {
757
     unsigned short int object_id; //!< the objectID from the AI object
758
     unsigned short int object_id; //!< the objectID from the AI object
758
-                                  //!< (AI_FOLLOW is 402)
759
+    //!< (AI_FOLLOW is 402)
759
     unsigned short int room;
760
     unsigned short int room;
760
     int x, y, a;
761
     int x, y, a;
761
     unsigned short int ocb;
762
     unsigned short int ocb;
762
     unsigned short int flags;     //!< The trigger flags
763
     unsigned short int flags;     //!< The trigger flags
763
-                                  //!< (button 1-5, first button has value 2)
764
+    //!< (button 1-5, first button has value 2)
764
     int angle;                    //!< rotation
765
     int angle;                    //!< rotation
765
-} __attribute__ ((packed)) tr4_ai_object_t;
766
+} __attribute__((packed)) tr4_ai_object_t;
766
 
767
 
767
 /*!
768
 /*!
768
  * \brief Used to read packed TR4 texels
769
  * \brief Used to read packed TR4 texels
774
     tr2_object_texture_vert_t vertices[4]; //!< same meaning as in TR3
775
     tr2_object_texture_vert_t vertices[4]; //!< same meaning as in TR3
775
     unsigned int unknown1, unknown2;       //!< new in TR4: x & y offset in something
776
     unsigned int unknown1, unknown2;       //!< new in TR4: x & y offset in something
776
     unsigned int xsize, ysize;             //!< new in TR4: width-1 & height-1 of the object texture
777
     unsigned int xsize, ysize;             //!< new in TR4: width-1 & height-1 of the object texture
777
-} __attribute__ ((packed)) tr4_object_texture_t;
778
+} __attribute__((packed)) tr4_object_texture_t;
778
 
779
 
779
 /*!
780
 /*!
780
  * \brief TR5 Room Layer (56 bytes)
781
  * \brief TR5 Room Layer (56 bytes)
785
     uint16_t numLayerRectangles; //!< number of rectangles in this layer (2 bytes)
786
     uint16_t numLayerRectangles; //!< number of rectangles in this layer (2 bytes)
786
     uint16_t numLayerTriangles;  //!< number of triangles in this layer (2 bytes)
787
     uint16_t numLayerTriangles;  //!< number of triangles in this layer (2 bytes)
787
     uint16_t unknownL2;          //!< appears to be the number of 2 sided textures
788
     uint16_t unknownL2;          //!< appears to be the number of 2 sided textures
788
-                                  //!< in this layer, however is sometimes 1 off (2 bytes)
789
+    //!< in this layer, however is sometimes 1 off (2 bytes)
789
     uint16_t filler;             //!< always 0 (2 bytes)
790
     uint16_t filler;             //!< always 0 (2 bytes)
790
     uint16_t filler2;            //!< always 0 (2 bytes)
791
     uint16_t filler2;            //!< always 0 (2 bytes)
791
 
792
 
806
  */
807
  */
807
 typedef struct {
808
 typedef struct {
808
     uint16_t vertices[4]; //!< the values are the indices into the
809
     uint16_t vertices[4]; //!< the values are the indices into the
809
-                           //!< appropriate layer vertice list. (2 bytes each)
810
+    //!< appropriate layer vertice list. (2 bytes each)
810
     uint16_t texture;     //!< the texture number for this face. Needs to be masked
811
     uint16_t texture;     //!< the texture number for this face. Needs to be masked
811
-                           //!< with 0xFFF as the high 4 bits are flags (2 bytes)
812
+    //!< with 0xFFF as the high 4 bits are flags (2 bytes)
812
     uint16_t unknownF4;   //!< unknown (2 bytes)
813
     uint16_t unknownF4;   //!< unknown (2 bytes)
813
 } tr5_face4_t;
814
 } tr5_face4_t;
814
 
815
 
817
  */
818
  */
818
 typedef struct {
819
 typedef struct {
819
     uint16_t vertices[3]; //!< the values are the indices into the
820
     uint16_t vertices[3]; //!< the values are the indices into the
820
-                           //!< appropriate layer vertice list (2 bytes each)
821
+    //!< appropriate layer vertice list (2 bytes each)
821
     uint16_t texture;     //!< the texture number for this face. Needs to be masked
822
     uint16_t texture;     //!< the texture number for this face. Needs to be masked
822
-                           //!< with 0xFFF as the high 4 bits are flags (2 bytes)
823
+    //!< with 0xFFF as the high 4 bits are flags (2 bytes)
823
     uint16_t unknownF3;   //!< unknown (2 bytes)
824
     uint16_t unknownF3;   //!< unknown (2 bytes)
824
 } tr5_face3_t;
825
 } tr5_face3_t;
825
 
826
 
840
  * \brief This is to help store and manage TR5 layer based polgons for rooms
841
  * \brief This is to help store and manage TR5 layer based polgons for rooms
841
  */
842
  */
842
 typedef struct {
843
 typedef struct {
843
-    tr5_face4_t *quads;
844
-    tr5_face3_t *tris;
845
-    tr5_vertex_t *verts;
844
+    tr5_face4_t* quads;
845
+    tr5_face3_t* tris;
846
+    tr5_vertex_t* verts;
846
 } tr5_room_geometry_t;
847
 } tr5_room_geometry_t;
847
 
848
 
848
 /*!
849
 /*!
964
     uint32_t seperator8;          //!< 0xCDCDCDCD (4 bytes)
965
     uint32_t seperator8;          //!< 0xCDCDCDCD (4 bytes)
965
     uint32_t unknownR6;           //!< unknown (4 bytes)
966
     uint32_t unknownR6;           //!< unknown (4 bytes)
966
     float roomX;                   //!< X position of room in world coordinates
967
     float roomX;                   //!< X position of room in world coordinates
967
-                                   //!< If  null room then this data will be 0xCDCDCDCD (4 bytes)
968
+    //!< If  null room then this data will be 0xCDCDCDCD (4 bytes)
968
     uint32_t seperator9;          //!< 0x00000000 or 0xCDCDCDCD if null room. (4 bytes)
969
     uint32_t seperator9;          //!< 0x00000000 or 0xCDCDCDCD if null room. (4 bytes)
969
     float roomZ;                   //!< Z position of room in world coordinates
970
     float roomZ;                   //!< Z position of room in world coordinates
970
-                                   //!< If null room then will be bitu32 0xCDCDCDCD (4 bytes)
971
+    //!< If null room then will be bitu32 0xCDCDCDCD (4 bytes)
971
     uint32_t seperator10;         //!< 0xCDCDCDCD (4 bytes)
972
     uint32_t seperator10;         //!< 0xCDCDCDCD (4 bytes)
972
     uint32_t seperator11;         //!< 0xCDCDCDCD (4 bytes)
973
     uint32_t seperator11;         //!< 0xCDCDCDCD (4 bytes)
973
     uint32_t seperator12;         //!< 0xCDCDCDCD (4 bytes)
974
     uint32_t seperator12;         //!< 0xCDCDCDCD (4 bytes)
981
     uint32_t numTotalRoomLights;  //!< total number of lights this room (4 bytes)
982
     uint32_t numTotalRoomLights;  //!< total number of lights this room (4 bytes)
982
     uint32_t unknownR7;           //!< unknown, usually equals 0, 1, 2, or 3 (4 bytes)
983
     uint32_t unknownR7;           //!< unknown, usually equals 0, 1, 2, or 3 (4 bytes)
983
     int32_t unknownR8;             //!< usually equals room yTop. Sometimes a few blocks off.
984
     int32_t unknownR8;             //!< usually equals room yTop. Sometimes a few blocks off.
984
-                                   //!< If null room then 0xCDCDCDCD
985
+    //!< If null room then 0xCDCDCDCD
985
     int32_t lyBottom;              //!< equals room yBottom. If null room then 0xCDCDCDCD (4 bytes)
986
     int32_t lyBottom;              //!< equals room yBottom. If null room then 0xCDCDCDCD (4 bytes)
986
     uint32_t numLayers;           //!< number of layers (pieces) this room (4 bytes)
987
     uint32_t numLayers;           //!< number of layers (pieces) this room (4 bytes)
987
     uint32_t layerOffset;         //!< this number + 216 will give you an offset from the start
988
     uint32_t layerOffset;         //!< this number + 216 will give you an offset from the start
988
-                                   //!< of the room data to the start of the layer data (4 bytes)
989
+    //!< of the room data to the start of the layer data (4 bytes)
989
     uint32_t verticesOffset;      //!< this number + 216 will give you an offset from the start
990
     uint32_t verticesOffset;      //!< this number + 216 will give you an offset from the start
990
-                                   //!< of the room data to the start of the verex data (4 bytes)
991
+    //!< of the room data to the start of the verex data (4 bytes)
991
     uint32_t polyOffset;          //!< this number + 216 will give you an offset from the start
992
     uint32_t polyOffset;          //!< this number + 216 will give you an offset from the start
992
-                                   //!< of the room data to the start of the rectangle/triangle data (4 bytes)
993
+    //!< of the room data to the start of the rectangle/triangle data (4 bytes)
993
     uint32_t polyOffset2;         //!< same as above ? (4 bytes)
994
     uint32_t polyOffset2;         //!< same as above ? (4 bytes)
994
     uint32_t verticesSize;        //!< size of vertices data block (4 bytes)
995
     uint32_t verticesSize;        //!< size of vertices data block (4 bytes)
995
     uint32_t seperator17;         //!< 0xCDCDCDCD (4 bytes)
996
     uint32_t seperator17;         //!< 0xCDCDCDCD (4 bytes)
996
     uint32_t seperator18;         //!< 0xCDCDCDCD (4 bytes)
997
     uint32_t seperator18;         //!< 0xCDCDCDCD (4 bytes)
997
     uint32_t seperator19;         //!< 0xCDCDCDCD (4 bytes)
998
     uint32_t seperator19;         //!< 0xCDCDCDCD (4 bytes)
998
     uint32_t seperator20;         //!< 0xCDCDCDCD (4 bytes)
999
     uint32_t seperator20;         //!< 0xCDCDCDCD (4 bytes)
999
-    tr5_light_t *lights;           //!< [LightSize];
1000
-                                   //!< data for the lights (88 bytes * NumRoomLights)
1001
-    tr2_room_sector_t *sectors;    //!< Data[(NumXSectors * NumZSectors) * 8];
1002
-                                   //!< normal sector data structure
1000
+    tr5_light_t* lights;           //!< [LightSize];
1001
+    //!< data for the lights (88 bytes * NumRoomLights)
1002
+    tr2_room_sector_t* sectors;    //!< Data[(NumXSectors * NumZSectors) * 8];
1003
+    //!< normal sector data structure
1003
     uint16_t numDoors;            //!< number of portals (2 bytes)
1004
     uint16_t numDoors;            //!< number of portals (2 bytes)
1004
-    tr2_room_portal_t *doors;      //!< [NumDoors];
1005
-                                   //!< normal portal structure (32 bytes * NumDoors)
1005
+    tr2_room_portal_t* doors;      //!< [NumDoors];
1006
+    //!< normal portal structure (32 bytes * NumDoors)
1006
     uint16_t seperator21;         //!< 0xCDCD (2 bytes)
1007
     uint16_t seperator21;         //!< 0xCDCD (2 bytes)
1007
-    tr2_room_staticmesh_t *meshes; //!< [NumStaticMeshes];
1008
-                                   //!< normal room static mesh structure (20 bytes * NumRoomStaticMeshes)
1009
-    tr5_room_layer_t *layers;      //!< [NumLayers];
1010
-                                   //!< data for the room layers (pieces) (56 bytes * NumLayers)
1011
-    tr5_room_geometry_t *faces;    //!< [NumRoomRectangles + NumRoomTriangles];
1012
-                                   /* Data for the room polys (face4 and face3).
1013
-                                    * Structured as first layers rectangles
1014
-                                    * then triangles, followed by the
1015
-                                    * next layers rectangles and triangles, etc.,
1016
-                                    * until all layers are done.
1017
-                                    * (12 bytes each rectangle. 10 bytes each triangle)
1018
-                                    */
1019
-    tr5_vertex_t *vertices;        //!< [VerticesSize];
1020
-                                   /*!< Data for the room vertices.
1021
-                                    * Structured as vertices for the first layer,
1022
-                                    * then vertices for the second layer, etc.,
1023
-                                    * until all layers are done.
1024
-                                    * (28 bytes each vertex.
1025
-                                    */
1008
+    tr2_room_staticmesh_t* meshes; //!< [NumStaticMeshes];
1009
+    //!< normal room static mesh structure (20 bytes * NumRoomStaticMeshes)
1010
+    tr5_room_layer_t* layers;      //!< [NumLayers];
1011
+    //!< data for the room layers (pieces) (56 bytes * NumLayers)
1012
+    tr5_room_geometry_t* faces;    //!< [NumRoomRectangles + NumRoomTriangles];
1013
+    /* Data for the room polys (face4 and face3).
1014
+     * Structured as first layers rectangles
1015
+     * then triangles, followed by the
1016
+     * next layers rectangles and triangles, etc.,
1017
+     * until all layers are done.
1018
+     * (12 bytes each rectangle. 10 bytes each triangle)
1019
+     */
1020
+    tr5_vertex_t* vertices;        //!< [VerticesSize];
1021
+    /*!< Data for the room vertices.
1022
+     * Structured as vertices for the first layer,
1023
+     * then vertices for the second layer, etc.,
1024
+     * until all layers are done.
1025
+     * (28 bytes each vertex.
1026
+     */
1026
 } tr5_room_t;
1027
 } tr5_room_t;
1027
 
1028
 
1028
 /*!
1029
 /*!
1030
  */
1031
  */
1031
 typedef struct {
1032
 typedef struct {
1032
     uint8_t xCoordinate; //!< 0 if Xpixel is the low value,
1033
     uint8_t xCoordinate; //!< 0 if Xpixel is the low value,
1033
-                          //!< 255 if Xpixel is the high value in the object texture (1 byte)
1034
+    //!< 255 if Xpixel is the high value in the object texture (1 byte)
1034
     uint8_t xPixel;      //!< (1 byte)
1035
     uint8_t xPixel;      //!< (1 byte)
1035
     uint8_t yCoordinate; //!< 0 if Ypixel is the low value,
1036
     uint8_t yCoordinate; //!< 0 if Ypixel is the low value,
1036
-                          //!< 255 if Ypixel is the high value in the object texture (1 byte)
1037
+    //!< 255 if Ypixel is the high value in the object texture (1 byte)
1037
     uint8_t yPixel;      //!< (1 byte)
1038
     uint8_t yPixel;      //!< (1 byte)
1038
 } tr5_object_texture_vertex_t;
1039
 } tr5_object_texture_vertex_t;
1039
 
1040
 
1043
 typedef struct {
1044
 typedef struct {
1044
     uint16_t attribute;                     //!< 0, 1, or 2 (2 means 2 sided) (2 bytes)
1045
     uint16_t attribute;                     //!< 0, 1, or 2 (2 means 2 sided) (2 bytes)
1045
     uint32_t tile;                          //!< need to mask with 0xFF as other bits are flags.
1046
     uint32_t tile;                          //!< need to mask with 0xFF as other bits are flags.
1046
-                                             //!< ie int15_t seems to indicate triangle (4 bytes)
1047
+    //!< ie int15_t seems to indicate triangle (4 bytes)
1047
     tr5_object_texture_vertex_t vertices[4]; //!< Vertices[4] (16 bytes)
1048
     tr5_object_texture_vertex_t vertices[4]; //!< Vertices[4] (16 bytes)
1048
     uint32_t uv1;                           //!< unknown how used (4 bytes)
1049
     uint32_t uv1;                           //!< unknown how used (4 bytes)
1049
     uint32_t uv2;                           //!< unknown how used (4 bytes)
1050
     uint32_t uv2;                           //!< unknown how used (4 bytes)
1091
     tr2_vertex_t center;             //!< relative coordinates of mesh centre (6 bytes)
1092
     tr2_vertex_t center;             //!< relative coordinates of mesh centre (6 bytes)
1092
     uint8_t unknown1[4];            //!< unknown (4 bytes)
1093
     uint8_t unknown1[4];            //!< unknown (4 bytes)
1093
     int16_t numVertices;             //!< number of vertices to follow (2 bytes)
1094
     int16_t numVertices;             //!< number of vertices to follow (2 bytes)
1094
-    tr2_vertex_t *vertices;          //!< list of vertices (NumVertices * 6 bytes)
1095
+    tr2_vertex_t* vertices;          //!< list of vertices (NumVertices * 6 bytes)
1095
     int16_t numNormals;              //!< number of normals to follow (2 bytes)
1096
     int16_t numNormals;              //!< number of normals to follow (2 bytes)
1096
-    tr2_vertex_t *normals;           //!< list of normals (NumNormals * 6 bytes)
1097
-                                     //!< (becomes Lights if NumNormals < 0; 2 bytes)
1097
+    tr2_vertex_t* normals;           //!< list of normals (NumNormals * 6 bytes)
1098
+    //!< (becomes Lights if NumNormals < 0; 2 bytes)
1098
     int16_t numTexturedRectangles;   //!< number of textured rectangles to follow (2 bytes)
1099
     int16_t numTexturedRectangles;   //!< number of textured rectangles to follow (2 bytes)
1099
-    tr5_face4_t *texturedRectangles; //!< list of textured rectangles (NumTexturedRectangles * 12 bytes)
1100
+    tr5_face4_t* texturedRectangles; //!< list of textured rectangles (NumTexturedRectangles * 12 bytes)
1100
     int16_t numTexturedTriangles;    //!< number of textured triangles to follow (2 bytes)
1101
     int16_t numTexturedTriangles;    //!< number of textured triangles to follow (2 bytes)
1101
-    tr5_face3_t *texturedTriangles;  //!< list of textured triangles (NumTexturedTriangles * 10 bytes)
1102
+    tr5_face3_t* texturedTriangles;  //!< list of textured triangles (NumTexturedTriangles * 10 bytes)
1102
 } tr5_mesh_t;
1103
 } tr5_mesh_t;
1103
 
1104
 
1104
 /*!
1105
 /*!

+ 3
- 3
include/UI.h View File

16
 #include "imgui/imgui.h"
16
 #include "imgui/imgui.h"
17
 
17
 
18
 class UI {
18
 class UI {
19
-public:
19
+  public:
20
     static int initialize();
20
     static int initialize();
21
     static void eventsFinished();
21
     static void eventsFinished();
22
     static void display();
22
     static void display();
26
     static bool isVisible();
26
     static bool isVisible();
27
 
27
 
28
     static void handleKeyboard(KeyboardButton key, bool pressed);
28
     static void handleKeyboard(KeyboardButton key, bool pressed);
29
-    static void handleText(char *text, bool notFinished);
29
+    static void handleText(char* text, bool notFinished);
30
     static void handleMouseClick(unsigned int x, unsigned int y, KeyboardButton button, bool released);
30
     static void handleMouseClick(unsigned int x, unsigned int y, KeyboardButton button, bool released);
31
     static void handleMouseMotion(int xrel, int yrel, int xabs, int yabs);
31
     static void handleMouseMotion(int xrel, int yrel, int xabs, int yabs);
32
     static void handleMouseScroll(int xrel, int yrel);
32
     static void handleMouseScroll(int xrel, int yrel);
33
 
33
 
34
     static void renderImGui(ImDrawList** const draw_lists, int count);
34
     static void renderImGui(ImDrawList** const draw_lists, int count);
35
 
35
 
36
-private:
36
+  private:
37
     static bool visible;
37
     static bool visible;
38
     static unsigned int fontTex;
38
     static unsigned int fontTex;
39
     static std::string iniFilename;
39
     static std::string iniFilename;

+ 2
- 2
include/ViewVolume.h View File

14
  * \brief Viewing Volume for culling use
14
  * \brief Viewing Volume for culling use
15
  */
15
  */
16
 class ViewVolume {
16
 class ViewVolume {
17
-public:
17
+  public:
18
 
18
 
19
     /*!
19
     /*!
20
      * \brief Sides of the view volume
20
      * \brief Sides of the view volume
127
      */
127
      */
128
     void setProjection(float proj[16]);
128
     void setProjection(float proj[16]);
129
 
129
 
130
-private:
130
+  private:
131
 
131
 
132
     /*!
132
     /*!
133
      * \brief Computes clipping matrix.
133
      * \brief Computes clipping matrix.

+ 5
- 5
include/Window.h View File

12
  * \brief Windowing interface
12
  * \brief Windowing interface
13
  */
13
  */
14
 class Window {
14
 class Window {
15
-public:
15
+  public:
16
 
16
 
17
     virtual ~Window() {}
17
     virtual ~Window() {}
18
 
18
 
47
     virtual void glExit2D();
47
     virtual void glExit2D();
48
 
48
 
49
     static void lookAt(float eyeX, float eyeY, float eyeZ,
49
     static void lookAt(float eyeX, float eyeY, float eyeZ,
50
-                        float lookAtX, float lookAtY, float lookAtZ,
51
-                        float upX, float upY, float upZ);
50
+                       float lookAtX, float lookAtY, float lookAtZ,
51
+                       float upX, float upY, float upZ);
52
 
52
 
53
-protected:
53
+  protected:
54
     bool mInit;
54
     bool mInit;
55
     bool mFullscreen;
55
     bool mFullscreen;
56
     bool mMousegrab;
56
     bool mMousegrab;
59
     unsigned int mHeight;
59
     unsigned int mHeight;
60
 };
60
 };
61
 
61
 
62
-Window &getWindow();
62
+Window& getWindow();
63
 
63
 
64
 #endif
64
 #endif
65
 
65
 

+ 2
- 2
include/WindowGLUT.h View File

14
  * \brief GLUT windowing implementation
14
  * \brief GLUT windowing implementation
15
  */
15
  */
16
 class WindowGLUT : public Window {
16
 class WindowGLUT : public Window {
17
-public:
17
+  public:
18
 
18
 
19
     WindowGLUT();
19
     WindowGLUT();
20
 
20
 
32
 
32
 
33
     virtual void swapBuffersGL();
33
     virtual void swapBuffersGL();
34
 
34
 
35
-private:
35
+  private:
36
     static void reshapeCallback(int width, int height);
36
     static void reshapeCallback(int width, int height);
37
     static void keyboardCallback(unsigned char key, int x, int y);
37
     static void keyboardCallback(unsigned char key, int x, int y);
38
     static void keyboardUpCallback(unsigned char key, int x, int y);
38
     static void keyboardUpCallback(unsigned char key, int x, int y);

+ 3
- 3
include/WindowSDL.h View File

16
  * \brief SDL windowing implementation
16
  * \brief SDL windowing implementation
17
  */
17
  */
18
 class WindowSDL : public Window {
18
 class WindowSDL : public Window {
19
-public:
19
+  public:
20
 
20
 
21
     /*!
21
     /*!
22
      * \brief Constructs an object of WindowSDL
22
      * \brief Constructs an object of WindowSDL
42
 
42
 
43
     virtual void swapBuffersGL();
43
     virtual void swapBuffersGL();
44
 
44
 
45
-private:
46
-    SDL_Window *mWindow;      //!< This is the pointer to the SDL surface
45
+  private:
46
+    SDL_Window* mWindow;      //!< This is the pointer to the SDL surface
47
     SDL_GLContext mGLContext; //!< The OpenGL Context
47
     SDL_GLContext mGLContext; //!< The OpenGL Context
48
 };
48
 };
49
 
49
 

+ 13
- 13
include/World.h View File

22
  * \brief The game world (model)
22
  * \brief The game world (model)
23
  */
23
  */
24
 class World {
24
 class World {
25
-public:
25
+  public:
26
 
26
 
27
     /*!
27
     /*!
28
      * \brief Deconstructs an object of World
28
      * \brief Deconstructs an object of World
34
      */
34
      */
35
     void destroy();
35
     void destroy();
36
 
36
 
37
-    void addRoom(Room &room);
37
+    void addRoom(Room& room);
38
     unsigned long sizeRoom();
38
     unsigned long sizeRoom();
39
-    Room &getRoom(unsigned long index);
39
+    Room& getRoom(unsigned long index);
40
 
40
 
41
-    void addSprite(SpriteSequence &sprite);
41
+    void addSprite(SpriteSequence& sprite);
42
     unsigned long sizeSprite();
42
     unsigned long sizeSprite();
43
-    SpriteSequence &getSprite(unsigned long index);
43
+    SpriteSequence& getSprite(unsigned long index);
44
 
44
 
45
-    void addEntity(Entity &entity);
45
+    void addEntity(Entity& entity);
46
     unsigned long sizeEntity();
46
     unsigned long sizeEntity();
47
-    Entity &getEntity(unsigned long index);
47
+    Entity& getEntity(unsigned long index);
48
 
48
 
49
-    void addSkeletalModel(SkeletalModel &model);
49
+    void addSkeletalModel(SkeletalModel& model);
50
     unsigned long sizeSkeletalModel();
50
     unsigned long sizeSkeletalModel();
51
-    SkeletalModel &getSkeletalModel(unsigned long index);
51
+    SkeletalModel& getSkeletalModel(unsigned long index);
52
 
52
 
53
-    void addStaticMesh(StaticMesh &model);
53
+    void addStaticMesh(StaticMesh& model);
54
     unsigned long sizeStaticMesh();
54
     unsigned long sizeStaticMesh();
55
-    StaticMesh &getStaticMesh(unsigned long index);
55
+    StaticMesh& getStaticMesh(unsigned long index);
56
 
56
 
57
     /*!
57
     /*!
58
      * \brief Find room a location is in.
58
      * \brief Find room a location is in.
77
      */
77
      */
78
     long getRoomByLocation(float x, float y, float z);
78
     long getRoomByLocation(float x, float y, float z);
79
 
79
 
80
-private:
80
+  private:
81
     std::vector<std::unique_ptr<Room>> mRooms;
81
     std::vector<std::unique_ptr<Room>> mRooms;
82
     std::vector<std::unique_ptr<SpriteSequence>> mSprites;
82
     std::vector<std::unique_ptr<SpriteSequence>> mSprites;
83
     std::vector<std::unique_ptr<Entity>> mEntities;
83
     std::vector<std::unique_ptr<Entity>> mEntities;
85
     std::vector<std::unique_ptr<StaticMesh>> mMeshes;
85
     std::vector<std::unique_ptr<StaticMesh>> mMeshes;
86
 };
86
 };
87
 
87
 
88
-World &getWorld();
88
+World& getWorld();
89
 
89
 
90
 #endif
90
 #endif

+ 2
- 2
include/commands/Command.h View File

14
 #include <vector>
14
 #include <vector>
15
 
15
 
16
 class Command {
16
 class Command {
17
-public:
17
+  public:
18
     virtual ~Command();
18
     virtual ~Command();
19
     virtual std::string name() = 0;
19
     virtual std::string name() = 0;
20
     virtual std::string brief() = 0;
20
     virtual std::string brief() = 0;
25
     static int command(std::string c);
25
     static int command(std::string c);
26
     static int executeFile(std::string file);
26
     static int executeFile(std::string file);
27
 
27
 
28
-private:
28
+  private:
29
     static std::vector<std::shared_ptr<Command>> commands;
29
     static std::vector<std::shared_ptr<Command>> commands;
30
 };
30
 };
31
 
31
 

+ 1
- 1
include/commands/CommandAnimate.h View File

11
 #include "commands/Command.h"
11
 #include "commands/Command.h"
12
 
12
 
13
 class CommandAnimate : public Command {
13
 class CommandAnimate : public Command {
14
-public:
14
+  public:
15
     virtual std::string name();
15
     virtual std::string name();
16
     virtual std::string brief();
16
     virtual std::string brief();
17
     virtual void printHelp();
17
     virtual void printHelp();

+ 2
- 2
include/commands/CommandBind.h View File

11
 #include "commands/Command.h"
11
 #include "commands/Command.h"
12
 
12
 
13
 class CommandBind : public Command {
13
 class CommandBind : public Command {
14
-public:
14
+  public:
15
     virtual std::string name();
15
     virtual std::string name();
16
     virtual std::string brief();
16
     virtual std::string brief();
17
     virtual void printHelp();
17
     virtual void printHelp();
18
     virtual int execute(std::istream& args);
18
     virtual int execute(std::istream& args);
19
 
19
 
20
-private:
20
+  private:
21
     ActionEvents stringToActionEvent(std::string action);
21
     ActionEvents stringToActionEvent(std::string action);
22
     KeyboardButton stringToKeyboardButton(std::string key);
22
     KeyboardButton stringToKeyboardButton(std::string key);
23
 };
23
 };

+ 3
- 3
include/commands/CommandEngine.h View File

11
 #include "commands/Command.h"
11
 #include "commands/Command.h"
12
 
12
 
13
 class CommandLoad : public Command {
13
 class CommandLoad : public Command {
14
-public:
14
+  public:
15
     virtual std::string name();
15
     virtual std::string name();
16
     virtual std::string brief();
16
     virtual std::string brief();
17
     virtual void printHelp();
17
     virtual void printHelp();
19
 };
19
 };
20
 
20
 
21
 class CommandScreenshot : public Command {
21
 class CommandScreenshot : public Command {
22
-public:
22
+  public:
23
     virtual std::string name();
23
     virtual std::string name();
24
     virtual std::string brief();
24
     virtual std::string brief();
25
     virtual void printHelp();
25
     virtual void printHelp();
27
 };
27
 };
28
 
28
 
29
 class CommandQuit : public Command {
29
 class CommandQuit : public Command {
30
-public:
30
+  public:
31
     virtual std::string name();
31
     virtual std::string name();
32
     virtual std::string brief();
32
     virtual std::string brief();
33
     virtual int execute(std::istream& args);
33
     virtual int execute(std::istream& args);

+ 4
- 4
include/commands/CommandGame.h View File

11
 #include "commands/Command.h"
11
 #include "commands/Command.h"
12
 
12
 
13
 class CommandPos : public Command {
13
 class CommandPos : public Command {
14
-public:
14
+  public:
15
     virtual std::string name();
15
     virtual std::string name();
16
     virtual std::string brief();
16
     virtual std::string brief();
17
     virtual int execute(std::istream& args);
17
     virtual int execute(std::istream& args);
18
 };
18
 };
19
 
19
 
20
 class CommandViewmodel : public Command {
20
 class CommandViewmodel : public Command {
21
-public:
21
+  public:
22
     virtual std::string name();
22
     virtual std::string name();
23
     virtual std::string brief();
23
     virtual std::string brief();
24
     virtual int execute(std::istream& args);
24
     virtual int execute(std::istream& args);
25
 };
25
 };
26
 
26
 
27
 class CommandPigtail : public Command {
27
 class CommandPigtail : public Command {
28
-public:
28
+  public:
29
     virtual std::string name();
29
     virtual std::string name();
30
     virtual std::string brief();
30
     virtual std::string brief();
31
     virtual int execute(std::istream& args);
31
     virtual int execute(std::istream& args);
32
 };
32
 };
33
 
33
 
34
 class CommandPonypos : public Command {
34
 class CommandPonypos : public Command {
35
-public:
35
+  public:
36
     virtual std::string name();
36
     virtual std::string name();
37
     virtual std::string brief();
37
     virtual std::string brief();
38
     virtual int execute(std::istream& args);
38
     virtual int execute(std::istream& args);

+ 1
- 1
include/commands/CommandMove.h View File

11
 #include "commands/Command.h"
11
 #include "commands/Command.h"
12
 
12
 
13
 class CommandMove : public Command {
13
 class CommandMove : public Command {
14
-public:
14
+  public:
15
     virtual std::string name();
15
     virtual std::string name();
16
     virtual std::string brief();
16
     virtual std::string brief();
17
     virtual void printHelp();
17
     virtual void printHelp();

+ 3
- 3
include/commands/CommandRender.h View File

11
 #include "commands/Command.h"
11
 #include "commands/Command.h"
12
 
12
 
13
 class CommandMode : public Command {
13
 class CommandMode : public Command {
14
-public:
14
+  public:
15
     virtual std::string name();
15
     virtual std::string name();
16
     virtual std::string brief();
16
     virtual std::string brief();
17
     virtual void printHelp();
17
     virtual void printHelp();
19
 };
19
 };
20
 
20
 
21
 class CommandRenderflag : public Command {
21
 class CommandRenderflag : public Command {
22
-public:
22
+  public:
23
     virtual std::string name();
23
     virtual std::string name();
24
     virtual std::string brief();
24
     virtual std::string brief();
25
     virtual void printHelp();
25
     virtual void printHelp();
26
     virtual int execute(std::istream& args);
26
     virtual int execute(std::istream& args);
27
 
27
 
28
-private:
28
+  private:
29
     int stringToFlag(std::string flag);
29
     int stringToFlag(std::string flag);
30
 };
30
 };
31
 
31
 

+ 1
- 1
include/commands/CommandSet.h View File

11
 #include "commands/Command.h"
11
 #include "commands/Command.h"
12
 
12
 
13
 class CommandSet : public Command {
13
 class CommandSet : public Command {
14
-public:
14
+  public:
15
     virtual std::string name();
15
     virtual std::string name();
16
     virtual std::string brief();
16
     virtual std::string brief();
17
     virtual void printHelp();
17
     virtual void printHelp();

+ 1
- 1
include/commands/CommandSound.h View File

11
 #include "commands/Command.h"
11
 #include "commands/Command.h"
12
 
12
 
13
 class CommandSound : public Command {
13
 class CommandSound : public Command {
14
-public:
14
+  public:
15
     virtual std::string name();
15
     virtual std::string name();
16
     virtual std::string brief();
16
     virtual std::string brief();
17
     virtual void printHelp();
17
     virtual void printHelp();

+ 1
- 1
include/games/TombRaider1.h View File

14
  * \brief Tomb Raider 1 items and states
14
  * \brief Tomb Raider 1 items and states
15
  */
15
  */
16
 class TombRaider1 {
16
 class TombRaider1 {
17
-public:
17
+  public:
18
 
18
 
19
     /*!
19
     /*!
20
      * \brief States of a Wolf (Item 7)
20
      * \brief States of a Wolf (Item 7)

+ 8
- 6
include/global.h View File

107
 #include <execinfo.h>
107
 #include <execinfo.h>
108
 
108
 
109
 template<typename T, typename U>
109
 template<typename T, typename U>
110
-[[noreturn]] void assertEqualImplementation(const char *exp, T a, U b, const char *file, int line, bool print) {
110
+[[noreturn]] void assertEqualImplementation(const char* exp, T a, U b, const char* file, int line,
111
+        bool print) {
111
     const unsigned int maxSize = 128;
112
     const unsigned int maxSize = 128;
112
-    void *callstack[maxSize];
113
+    void* callstack[maxSize];
113
     int frames = backtrace(callstack, maxSize);
114
     int frames = backtrace(callstack, maxSize);
114
-    char **strs = backtrace_symbols(callstack, frames);
115
+    char** strs = backtrace_symbols(callstack, frames);
115
 
116
 
116
     std::cout << std::endl << "assertion failed:" << std::endl;
117
     std::cout << std::endl << "assertion failed:" << std::endl;
117
     std::cout << "\t" << exp << std::endl;
118
     std::cout << "\t" << exp << std::endl;
127
 }
128
 }
128
 
129
 
129
 template<typename T, typename U>
130
 template<typename T, typename U>
130
-[[noreturn]] void assertNotEqualImplementation(const char *exp, T a, U b, const char *file, int line, bool print) {
131
+[[noreturn]] void assertNotEqualImplementation(const char* exp, T a, U b, const char* file,
132
+        int line, bool print) {
131
     const unsigned int maxSize = 128;
133
     const unsigned int maxSize = 128;
132
-    void *callstack[maxSize];
134
+    void* callstack[maxSize];
133
     int frames = backtrace(callstack, maxSize);
135
     int frames = backtrace(callstack, maxSize);
134
-    char **strs = backtrace_symbols(callstack, frames);
136
+    char** strs = backtrace_symbols(callstack, frames);
135
 
137
 
136
     std::cout << std::endl << "assertion failed:" << std::endl;
138
     std::cout << std::endl << "assertion failed:" << std::endl;
137
     std::cout << "\t" << exp << std::endl;
139
     std::cout << "\t" << exp << std::endl;

+ 2
- 2
include/loader/Loader.h View File

14
 #include "utils/binary.h"
14
 #include "utils/binary.h"
15
 
15
 
16
 class Loader {
16
 class Loader {
17
-public:
17
+  public:
18
 
18
 
19
     typedef enum {
19
     typedef enum {
20
         TR_UNKNOWN = 0,
20
         TR_UNKNOWN = 0,
33
 
33
 
34
     virtual int load(std::string f) = 0;
34
     virtual int load(std::string f) = 0;
35
 
35
 
36
-protected:
36
+  protected:
37
     BinaryFile file;
37
     BinaryFile file;
38
 };
38
 };
39
 
39
 

+ 2
- 2
include/loader/LoaderTR1.h View File

11
 #include "loader/Loader.h"
11
 #include "loader/Loader.h"
12
 
12
 
13
 class LoaderTR1 : public Loader {
13
 class LoaderTR1 : public Loader {
14
-public:
14
+  public:
15
     LoaderTR1();
15
     LoaderTR1();
16
     virtual ~LoaderTR1();
16
     virtual ~LoaderTR1();
17
 
17
 
18
     virtual int load(std::string f);
18
     virtual int load(std::string f);
19
 
19
 
20
-private:
20
+  private:
21
 
21
 
22
 };
22
 };
23
 
23
 

+ 2
- 2
include/loader/LoaderTR2.h View File

11
 #include "loader/Loader.h"
11
 #include "loader/Loader.h"
12
 
12
 
13
 class LoaderTR2 : public Loader {
13
 class LoaderTR2 : public Loader {
14
-public:
14
+  public:
15
     LoaderTR2();
15
     LoaderTR2();
16
     virtual ~LoaderTR2();
16
     virtual ~LoaderTR2();
17
 
17
 
18
     virtual int load(std::string f);
18
     virtual int load(std::string f);
19
 
19
 
20
-private:
20
+  private:
21
     void loadPaletteTextiles();
21
     void loadPaletteTextiles();
22
     void loadRooms();
22
     void loadRooms();
23
     void loadFloorData();
23
     void loadFloorData();

+ 2
- 2
include/loader/LoaderTR3.h View File

11
 #include "loader/Loader.h"
11
 #include "loader/Loader.h"
12
 
12
 
13
 class LoaderTR3 : public Loader {
13
 class LoaderTR3 : public Loader {
14
-public:
14
+  public:
15
     LoaderTR3();
15
     LoaderTR3();
16
     virtual ~LoaderTR3();
16
     virtual ~LoaderTR3();
17
 
17
 
18
     virtual int load(std::string f);
18
     virtual int load(std::string f);
19
 
19
 
20
-private:
20
+  private:
21
 
21
 
22
 };
22
 };
23
 
23
 

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

35
  *     ///////////////////////////////////////////////
35
  *     ///////////////////////////////////////////////
36
  */
36
  */
37
 class Matrix {
37
 class Matrix {
38
-public:
38
+  public:
39
 
39
 
40
     /*!
40
     /*!
41
      * \brief Constructs an object of Matrix
41
      * \brief Constructs an object of Matrix
52
      * \brief Constructs an object of Matrix
52
      * \brief Constructs an object of Matrix
53
      * \param q Converts and assigns the Quaternion to the Matrix
53
      * \param q Converts and assigns the Quaternion to the Matrix
54
      */
54
      */
55
-    Matrix(Quaternion &q);
55
+    Matrix(Quaternion& q);
56
 
56
 
57
     /*!
57
     /*!
58
      * \brief Returns this matrix copy
58
      * \brief Returns this matrix copy
78
      * \param b second matrix
78
      * \param b second matrix
79
      * \returns resultant matrix
79
      * \returns resultant matrix
80
      */
80
      */
81
-    static Matrix multiply(const Matrix &a, const Matrix &b);
81
+    static Matrix multiply(const Matrix& a, const Matrix& b);
82
 
82
 
83
     /*!
83
     /*!
84
      * \brief Multiplies v vector and this matrix
84
      * \brief Multiplies v vector and this matrix
110
      * \param a matrix to multiply with
110
      * \param a matrix to multiply with
111
      * \returns resultant matrix
111
      * \returns resultant matrix
112
      */
112
      */
113
-    Matrix operator *(const Matrix &a);
113
+    Matrix operator *(const Matrix& a);
114
 
114
 
115
     /*!
115
     /*!
116
      * \brief Multiply vector by this matrix
116
      * \brief Multiply vector by this matrix
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 float *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
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 float *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
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 float *xyz);
174
+    void translate(const float* xyz);
175
 
175
 
176
     /*!
176
     /*!
177
      * \brief Transpose this matrix
177
      * \brief Transpose this matrix
180
 
180
 
181
     float mMatrix[16]; //!< 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
 
185
     /*!
185
     /*!
186
      * \brief Copys value from source to dest
186
      * \brief Copys value from source to dest

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

14
  * \brief Quaternion
14
  * \brief Quaternion
15
  */
15
  */
16
 class Quaternion {
16
 class Quaternion {
17
-public:
17
+  public:
18
 
18
 
19
     /*!
19
     /*!
20
      * \brief Constructs an object of Quaternion
20
      * \brief Constructs an object of Quaternion
51
      * \returns resultant quaternion
51
      * \returns resultant quaternion
52
      * \sa Quaternion::normalize()
52
      * \sa Quaternion::normalize()
53
      */
53
      */
54
-    Quaternion operator *(const Quaternion &q);
54
+    Quaternion operator *(const Quaternion& q);
55
 
55
 
56
     /*!
56
     /*!
57
      * \brief Divide from this quaternion
57
      * \brief Divide from this quaternion
58
      * \param q what to divide from this quaternion
58
      * \param q what to divide from this quaternion
59
      * \returns resultant quaternion
59
      * \returns resultant quaternion
60
      */
60
      */
61
-    Quaternion operator /(const Quaternion &q);
61
+    Quaternion operator /(const Quaternion& q);
62
 
62
 
63
     /*!
63
     /*!
64
      * \brief Add to this quaternion
64
      * \brief Add to this quaternion
65
      * \param q what to add to this quaternion
65
      * \param q what to add to this quaternion
66
      * \returns resultant quaternion
66
      * \returns resultant quaternion
67
      */
67
      */
68
-    Quaternion operator +(const Quaternion &q);
68
+    Quaternion operator +(const Quaternion& q);
69
 
69
 
70
     /*!
70
     /*!
71
      * \brief Subtract from this quaternion
71
      * \brief Subtract from this quaternion
72
      * \param q what to subtract from this quaternion
72
      * \param q what to subtract from this quaternion
73
      * \returns resultant quaternion
73
      * \returns resultant quaternion
74
      */
74
      */
75
-    Quaternion operator -(const Quaternion &q);
75
+    Quaternion operator -(const Quaternion& q);
76
 
76
 
77
     /*!
77
     /*!
78
      * \brief Compares q to this quaternion
78
      * \brief Compares q to this quaternion
79
      * \param q what to compare this quaternion to
79
      * \param q what to compare this quaternion to
80
      * \returns true if equal, false otherwise
80
      * \returns true if equal, false otherwise
81
      */
81
      */
82
-    bool operator ==(const Quaternion &q);
82
+    bool operator ==(const Quaternion& q);
83
 
83
 
84
     /*!
84
     /*!
85
      * \brief Conjugate this quaternion
85
      * \brief Conjugate this quaternion
158
      */
158
      */
159
     void setByMatrix(float m[16]);
159
     void setByMatrix(float m[16]);
160
 
160
 
161
-private:
161
+  private:
162
 
162
 
163
     /*!
163
     /*!
164
      * \brief Multiplies two quaternions
164
      * \brief Multiplies two quaternions

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

14
  * \brief 3D Math Vector
14
  * \brief 3D Math Vector
15
  */
15
  */
16
 class Vector3d {
16
 class Vector3d {
17
-public:
17
+  public:
18
 
18
 
19
     /*!
19
     /*!
20
      * \brief Constructs an object of Vector3d
20
      * \brief Constructs an object of Vector3d
39
      * \brief Constructs an object of Vector3d
39
      * \brief Constructs an object of Vector3d
40
      * \param v contents of new Vector3d
40
      * \param v contents of new Vector3d
41
      */
41
      */
42
-    Vector3d(const Vector3d &v);
42
+    Vector3d(const Vector3d& v);
43
 
43
 
44
     /*!
44
     /*!
45
      * \brief Calculate dot product
45
      * \brief Calculate dot product
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 float 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
55
      * \param v second argument
55
      * \param v second argument
56
      * \returns cross product of u and v vectors
56
      * \returns cross product of u and v vectors
57
      */
57
      */
58
-    static Vector3d cross(const Vector3d &u, const Vector3d &v);
58
+    static Vector3d cross(const Vector3d& u, const Vector3d& v);
59
 
59
 
60
     /*!
60
     /*!
61
      * \brief Get Magnitude
61
      * \brief Get Magnitude
80
      * \param v addend
80
      * \param v addend
81
      * \returns a vector = this vector + v
81
      * \returns a vector = this vector + v
82
      */
82
      */
83
-    Vector3d operator +(const Vector3d &v);
83
+    Vector3d operator +(const Vector3d& v);
84
 
84
 
85
     /*!
85
     /*!
86
      * \brief Subtract from this vector
86
      * \brief Subtract from this vector
87
      * \param v subtrahend
87
      * \param v subtrahend
88
      * \returns a vector = this vector - v
88
      * \returns a vector = this vector - v
89
      */
89
      */
90
-    Vector3d operator -(const Vector3d &v);
90
+    Vector3d operator -(const Vector3d& v);
91
 
91
 
92
     /*!
92
     /*!
93
      * \brief Negate this vector
93
      * \brief Negate 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
-    float operator *(const Vector3d &v);
117
+    float operator *(const Vector3d& v);
118
 
118
 
119
     /*!
119
     /*!
120
      * \brief Normalizes this vector
120
      * \brief Normalizes this vector
131
      * \param v what this vector will be set to
131
      * \param v what this vector will be set to
132
      * \returns this vector, now equal to v
132
      * \returns this vector, now equal to v
133
      */
133
      */
134
-    Vector3d &operator =(const Vector3d &v);
134
+    Vector3d& operator =(const Vector3d& v);
135
 
135
 
136
     /*!
136
     /*!
137
      * \brief Add to this vector, in place
137
      * \brief Add to this vector, in place
138
      * \param v what will be added to this vector
138
      * \param v what will be added to this vector
139
      * \returns this vector, with v added
139
      * \returns this vector, with v added
140
      */
140
      */
141
-    Vector3d &operator +=(const Vector3d &v);
141
+    Vector3d& operator +=(const Vector3d& v);
142
 
142
 
143
     /*!
143
     /*!
144
      * \brief Subtract from this vector, in place
144
      * \brief Subtract from this vector, in place
145
      * \param v what will be subtracted from this vector
145
      * \param v what will be subtracted from this vector
146
      * \returns this vector, with v subtracted
146
      * \returns this vector, with v subtracted
147
      */
147
      */
148
-    Vector3d &operator -=(const Vector3d &v);
148
+    Vector3d& operator -=(const Vector3d& v);
149
 
149
 
150
     /*!
150
     /*!
151
      * \brief Scale this vector, in place
151
      * \brief Scale this vector, in place
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 *=(float s);
155
+    Vector3d& operator *=(float s);
156
 
156
 
157
     float mVec[3]; //!< Vector data
157
     float mVec[3]; //!< Vector data
158
 };
158
 };

+ 4
- 4
include/utils/File.h View File

13
 class Folder;
13
 class Folder;
14
 
14
 
15
 class File {
15
 class File {
16
-public:
16
+  public:
17
     File(std::string file);
17
     File(std::string file);
18
 
18
 
19
-    std::string &getName();
20
-    std::string &getPath();
19
+    std::string& getName();
20
+    std::string& getPath();
21
 
21
 
22
-private:
22
+  private:
23
     std::string name;
23
     std::string name;
24
     std::string path;
24
     std::string path;
25
 };
25
 };

+ 10
- 10
include/utils/Folder.h View File

17
 #include <vector>
17
 #include <vector>
18
 
18
 
19
 class Folder {
19
 class Folder {
20
-public:
20
+  public:
21
     Folder(std::string folder, bool listDotFiles = false);
21
     Folder(std::string folder, bool listDotFiles = false);
22
 
22
 
23
-    std::string &getName();
24
-    std::string &getPath();
23
+    std::string& getName();
24
+    std::string& getPath();
25
 
25
 
26
     unsigned long fileCount();
26
     unsigned long fileCount();
27
-    File &getFile(unsigned long i);
27
+    File& getFile(unsigned long i);
28
 
28
 
29
     unsigned long folderCount();
29
     unsigned long folderCount();
30
-    Folder &getFolder(unsigned long i);
30
+    Folder& getFolder(unsigned long i);
31
 
31
 
32
     Folder getParent();
32
     Folder getParent();
33
 
33
 
34
-    void executeRemoveFiles(std::function<bool (File &f)> func);
34
+    void executeRemoveFiles(std::function<bool (File& f)> func);
35
 
35
 
36
     // Accessing a folder recursively
36
     // Accessing a folder recursively
37
     // This treats all files in all subfolders as if they were in this folder
37
     // This treats all files in all subfolders as if they were in this folder
38
     unsigned long countRecursiveFiles();
38
     unsigned long countRecursiveFiles();
39
-    void executeRemoveRecursiveFiles(std::function<bool (File &f)> func);
39
+    void executeRemoveRecursiveFiles(std::function<bool (File& f)> func);
40
     std::string getRecursiveFileName(unsigned long i);
40
     std::string getRecursiveFileName(unsigned long i);
41
-    File &getRecursiveFile(unsigned long i);
41
+    File& getRecursiveFile(unsigned long i);
42
 
42
 
43
-private:
43
+  private:
44
 
44
 
45
     void createFolderItems();
45
     void createFolderItems();
46
-    int readFolderItems(std::vector<std::string> &foundFiles, std::vector<std::string> &foundFolders);
46
+    int readFolderItems(std::vector<std::string>& foundFiles, std::vector<std::string>& foundFolders);
47
 
47
 
48
     std::string name; //!< Only last part of path
48
     std::string name; //!< Only last part of path
49
     std::string path; //!< Full path, with name and '/' at end
49
     std::string path; //!< Full path, with name and '/' at end

+ 3
- 3
include/utils/binary.h View File

11
 #include <fstream>
11
 #include <fstream>
12
 
12
 
13
 class BinaryFile {
13
 class BinaryFile {
14
-public:
14
+  public:
15
 
15
 
16
     ~BinaryFile();
16
     ~BinaryFile();
17
 
17
 
18
-    int open(const char *f);
18
+    int open(const char* f);
19
 
19
 
20
     long long tell();
20
     long long tell();
21
     void seek(long long pos);
21
     void seek(long long pos);
34
 
34
 
35
     float readFloat();
35
     float readFloat();
36
 
36
 
37
-private:
37
+  private:
38
     std::ifstream file;
38
     std::ifstream file;
39
 };
39
 };
40
 
40
 

+ 3
- 3
include/utils/pcx.h View File

16
  * \param filename path of file to read
16
  * \param filename path of file to read
17
  * \returns 0 on success
17
  * \returns 0 on success
18
  */
18
  */
19
-int pcxCheck(const char *filename);
19
+int pcxCheck(const char* filename);
20
 
20
 
21
 /*!
21
 /*!
22
  * \brief Load a PCX image file into a buffer
22
  * \brief Load a PCX image file into a buffer
28
  * \param bpp place where pixel width will be stored (8, 24, 32)
28
  * \param bpp place where pixel width will be stored (8, 24, 32)
29
  * \returns 0 on success
29
  * \returns 0 on success
30
  */
30
  */
31
-int pcxLoad(const char *filename, unsigned char **image,
32
-        unsigned int *width, unsigned int *height, ColorMode *mode, unsigned int *bpp);
31
+int pcxLoad(const char* filename, unsigned char** image,
32
+            unsigned int* width, unsigned int* height, ColorMode* mode, unsigned int* bpp);
33
 
33
 
34
 #endif
34
 #endif
35
 
35
 

+ 7
- 6
include/utils/pixel.h View File

8
 #ifndef _UTILS_PIXEL_H_
8
 #ifndef _UTILS_PIXEL_H_
9
 #define _UTILS_PIXEL_H_
9
 #define _UTILS_PIXEL_H_
10
 
10
 
11
-unsigned char *generateColorTexture(const unsigned char *rgba, unsigned int width,
12
-        unsigned int height, unsigned int bpp);
11
+unsigned char* generateColorTexture(const unsigned char* rgba, unsigned int width,
12
+                                    unsigned int height, unsigned int bpp);
13
 
13
 
14
-void bgr2rgb24(unsigned char *image, unsigned int w, unsigned int h);
15
-void bgra2rgba32(unsigned char *image, unsigned int w, unsigned int h);
16
-void argb2rgba32(unsigned char *image, unsigned int w, unsigned int h);
14
+void bgr2rgb24(unsigned char* image, unsigned int w, unsigned int h);
15
+void bgra2rgba32(unsigned char* image, unsigned int w, unsigned int h);
16
+void argb2rgba32(unsigned char* image, unsigned int w, unsigned int h);
17
 
17
 
18
-unsigned char *scaleBuffer(unsigned char *image, unsigned int *w, unsigned int *h, unsigned int bpp);
18
+unsigned char* scaleBuffer(unsigned char* image, unsigned int* w, unsigned int* h,
19
+                           unsigned int bpp);
19
 
20
 
20
 #endif
21
 #endif
21
 
22
 

+ 5
- 5
include/utils/png.h View File

13
  * \param filename path of file to read
13
  * \param filename path of file to read
14
  * \returns 0 on success
14
  * \returns 0 on success
15
  */
15
  */
16
-int pngCheck(const char *filename);
16
+int pngCheck(const char* filename);
17
 
17
 
18
 /*!
18
 /*!
19
  * \brief Load a PNG image file into an RGBA buffer
19
  * \brief Load a PNG image file into an RGBA buffer
25
  * \param bpp place where pixel width will be stored (8, 24, 32)
25
  * \param bpp place where pixel width will be stored (8, 24, 32)
26
  * \returns 0 on success
26
  * \returns 0 on success
27
  */
27
  */
28
-int pngLoad(const char *filename, unsigned char **image,
29
-        unsigned int *width, unsigned int *height, ColorMode *mode, unsigned int *bpp);
28
+int pngLoad(const char* filename, unsigned char** image,
29
+            unsigned int* width, unsigned int* height, ColorMode* mode, unsigned int* bpp);
30
 
30
 
31
 /*!
31
 /*!
32
  * \brief Create a PNG image file from an RGBA buffer
32
  * \brief Create a PNG image file from an RGBA buffer
38
  * \param bpp bits per pixel (8, 24, 32)
38
  * \param bpp bits per pixel (8, 24, 32)
39
  * \returns 0 on success
39
  * \returns 0 on success
40
  */
40
  */
41
-int pngSave(const char *filename, unsigned char *image,
42
-        unsigned int width, unsigned int height, ColorMode mode, unsigned int bpp);
41
+int pngSave(const char* filename, unsigned char* image,
42
+            unsigned int width, unsigned int height, ColorMode mode, unsigned int bpp);
43
 
43
 
44
 #endif
44
 #endif
45
 
45
 

+ 5
- 5
include/utils/tga.h View File

13
  * \param filename path to file
13
  * \param filename path to file
14
  * \returns 0 if valid, else error condition
14
  * \returns 0 if valid, else error condition
15
  */
15
  */
16
-int tgaCheck(const char *filename);
16
+int tgaCheck(const char* filename);
17
 
17
 
18
 /*!
18
 /*!
19
  * \brief Load a TGA image from file
19
  * \brief Load a TGA image from file
24
  * \param type where the type will be stored (tga_type_t)
24
  * \param type where the type will be stored (tga_type_t)
25
  * \returns 0 on success, else error condition
25
  * \returns 0 on success, else error condition
26
  */
26
  */
27
-int tgaLoad(const char *filename, unsigned char **image,
28
-                unsigned int *width, unsigned int *height, char *type);
27
+int tgaLoad(const char* filename, unsigned char** image,
28
+            unsigned int* width, unsigned int* height, char* type);
29
 
29
 
30
 /*!
30
 /*!
31
  * \brief Save a pixel buffer into a file on disk
31
  * \brief Save a pixel buffer into a file on disk
36
  * \param type tga type to use
36
  * \param type tga type to use
37
  * \returns 0 on success, else error condition
37
  * \returns 0 on success, else error condition
38
  */
38
  */
39
-int tgaSave(const char *filename, unsigned char *image,
40
-                unsigned int width, unsigned int height, char type);
39
+int tgaSave(const char* filename, unsigned char* image,
40
+            unsigned int width, unsigned int height, char type);
41
 
41
 
42
 #endif
42
 #endif
43
 
43
 

+ 1
- 1
src/Console.cpp View File

78
         }
78
         }
79
 
79
 
80
         if (ImGui::InputText("Command", buffer, bufferLength,
80
         if (ImGui::InputText("Command", buffer, bufferLength,
81
-                    ImGuiInputTextFlags_AutoSelectAll | ImGuiInputTextFlags_EnterReturnsTrue)) {
81
+                             ImGuiInputTextFlags_AutoSelectAll | ImGuiInputTextFlags_EnterReturnsTrue)) {
82
             getLog() << "> " << buffer << Log::endl;
82
             getLog() << "> " << buffer << Log::endl;
83
             int error = Command::command(buffer);
83
             int error = Command::command(buffer);
84
             if (error != 0) {
84
             if (error != 0) {

+ 15
- 15
src/Entity.cpp View File

15
 
15
 
16
 #include "games/TombRaider1.h"
16
 #include "games/TombRaider1.h"
17
 
17
 
18
-Entity::Entity(TombRaider &tr, unsigned int index, unsigned int i, unsigned int model) {
19
-    tr2_moveable_t *moveable = tr.Moveable();
20
-    tr2_item_t *item = tr.Item();
18
+Entity::Entity(TombRaider& tr, unsigned int index, unsigned int i, unsigned int model) {
19
+    tr2_moveable_t* moveable = tr.Moveable();
20
+    tr2_item_t* item = tr.Item();
21
 
21
 
22
     pos[0] = item[i].x;
22
     pos[0] = item[i].x;
23
     pos[1] = item[i].y;
23
     pos[1] = item[i].y;
35
     state = 0;
35
     state = 0;
36
 }
36
 }
37
 
37
 
38
-bool Entity::operator<(Entity &o) {
38
+bool Entity::operator<(Entity& o) {
39
     float distA = getRender().mViewVolume.getDistToSphereFromNear(pos[0], pos[1], 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);
40
     float distB = getRender().mViewVolume.getDistToSphereFromNear(o.pos[0], o.pos[1], o.pos[2], 1.0f);
41
     return (distA < distB);
41
     return (distA < distB);
42
 }
42
 }
43
 
43
 
44
-bool Entity::compare(Entity *a, Entity *b) {
44
+bool Entity::compare(Entity* a, Entity* b) {
45
     return (*b) < (*a);
45
     return (*b) < (*a);
46
 }
46
 }
47
 
47
 
114
 
114
 
115
     if (roomNew == -1) { // Will we hit a portal?
115
     if (roomNew == -1) { // Will we hit a portal?
116
         roomNew = getWorld().getRoom(room).getAdjoiningRoom(pos[0], pos[1], pos[2],
116
         roomNew = getWorld().getRoom(room).getAdjoiningRoom(pos[0], pos[1], pos[2],
117
-                x, y, z);
117
+                  x, y, z);
118
 
118
 
119
         if (roomNew > -1)
119
         if (roomNew > -1)
120
             getLog() << "Crossing from room " << room << " to " << roomNew << Log::endl;
120
             getLog() << "Crossing from room " << room << " to " << roomNew << Log::endl;
139
     // Mongoose 2002.09.02, Add check for room -> room transition
139
     // Mongoose 2002.09.02, Add check for room -> room transition
140
     // (Only allow by movement between rooms by using portals)
140
     // (Only allow by movement between rooms by using portals)
141
     if (((moveType == MoveTypeNoClipping) ||
141
     if (((moveType == MoveTypeNoClipping) ||
142
-                (moveType == MoveTypeFly) ||
143
-                (moveType == MoveTypeSwim)) ||
144
-            ((roomNew > -1) && (!wall))) {
142
+         (moveType == MoveTypeFly) ||
143
+         (moveType == MoveTypeSwim)) ||
144
+        ((roomNew > -1) && (!wall))) {
145
         room = roomNew;
145
         room = roomNew;
146
 
146
 
147
         switch (movement) {
147
         switch (movement) {
214
 
214
 
215
 void Entity::print() {
215
 void Entity::print() {
216
     getLog() << "Entity " << objectId << ":" << Log::endl
216
     getLog() << "Entity " << objectId << ":" << Log::endl
217
-        << "  Room " << room << " (" << getWorld().getRoom(room).getFlags()
218
-        << ")" << Log::endl
219
-        << "  " << pos[0] << "x " << pos[1] << "y " << pos[2] << "z"
220
-        << Log::endl
221
-        << "  " << OR_RAD_TO_DEG(angles[1]) << " Yaw" << Log::endl;
217
+             << "  Room " << room << " (" << getWorld().getRoom(room).getFlags()
218
+             << ")" << Log::endl
219
+             << "  " << pos[0] << "x " << pos[1] << "y " << pos[2] << "z"
220
+             << Log::endl
221
+             << "  " << OR_RAD_TO_DEG(angles[1]) << " Yaw" << Log::endl;
222
 }
222
 }
223
 
223
 
224
-SkeletalModel &Entity::getModel() {
224
+SkeletalModel& Entity::getModel() {
225
     return getWorld().getSkeletalModel(skeletalModel);
225
     return getWorld().getSkeletalModel(skeletalModel);
226
 }
226
 }
227
 
227
 

+ 2
- 2
src/Exception.cpp View File

10
 
10
 
11
 std::string Exception::lastException("No custom exception since start!");
11
 std::string Exception::lastException("No custom exception since start!");
12
 
12
 
13
-Exception::Exception(const char *what) : runtime_error(what) {
13
+Exception::Exception(const char* what) : runtime_error(what) {
14
     lastException = what;
14
     lastException = what;
15
 }
15
 }
16
 
16
 
17
-Exception::Exception(const std::string &what) : runtime_error(what) {
17
+Exception::Exception(const std::string& what) : runtime_error(what) {
18
     lastException = what;
18
     lastException = what;
19
 }
19
 }
20
 
20
 

+ 3
- 3
src/Font.cpp View File

70
 }
70
 }
71
 
71
 
72
 void Font::drawText(unsigned int x, unsigned int y, float scale,
72
 void Font::drawText(unsigned int x, unsigned int y, float scale,
73
-        const unsigned char color[4], std::string s) {
73
+                    const unsigned char color[4], std::string s) {
74
     if (stringEndsWith(fontName, ".pc")) {
74
     if (stringEndsWith(fontName, ".pc")) {
75
         FontTRLE::drawText(x, y, scale, color, s);
75
         FontTRLE::drawText(x, y, scale, color, s);
76
 #ifdef USING_SDL_FONT
76
 #ifdef USING_SDL_FONT
83
 }
83
 }
84
 
84
 
85
 void Font::drawTextWrapped(unsigned int x, unsigned int y, float scale,
85
 void Font::drawTextWrapped(unsigned int x, unsigned int y, float scale,
86
-        const unsigned char color[4], unsigned int maxWidth, std::string s) {
86
+                           const unsigned char color[4], unsigned int maxWidth, std::string s) {
87
     if (stringEndsWith(fontName, ".pc")) {
87
     if (stringEndsWith(fontName, ".pc")) {
88
         FontTRLE::drawTextWrapped(x, y, scale, color, maxWidth, s);
88
         FontTRLE::drawTextWrapped(x, y, scale, color, maxWidth, s);
89
 #ifdef USING_SDL_FONT
89
 #ifdef USING_SDL_FONT
96
 }
96
 }
97
 
97
 
98
 void Font::drawTextCentered(unsigned int x, unsigned int y, float scale,
98
 void Font::drawTextCentered(unsigned int x, unsigned int y, float scale,
99
-        const unsigned char color[4], unsigned int width, std::string s) {
99
+                            const unsigned char color[4], unsigned int width, std::string s) {
100
     drawText(x + ((width / 2) - (widthText(scale, s) / 2)), y, scale, color, s);
100
     drawText(x + ((width / 2) - (widthText(scale, s) / 2)), y, scale, color, s);
101
 }
101
 }
102
 
102
 

+ 6
- 4
src/FontImGui.cpp View File

14
 
14
 
15
 unsigned int FontImGui::widthText(float scale, std::string s) {
15
 unsigned int FontImGui::widthText(float scale, std::string s) {
16
     ImGuiIO& io = ImGui::GetIO();
16
     ImGuiIO& io = ImGui::GetIO();
17
-    ImVec2 size = io.Font->CalcTextSizeA(scale * SCALE_CALC, io.DisplaySize.y, s.c_str(), s.c_str() + s.length());
17
+    ImVec2 size = io.Font->CalcTextSizeA(scale * SCALE_CALC, io.DisplaySize.y, s.c_str(),
18
+                                         s.c_str() + s.length());
18
     return size.y;
19
     return size.y;
19
 }
20
 }
20
 
21
 
21
 void FontImGui::drawText(unsigned int x, unsigned int y, float scale,
22
 void FontImGui::drawText(unsigned int x, unsigned int y, float scale,
22
-        const unsigned char color[4], std::string s) {
23
+                         const unsigned char color[4], std::string s) {
23
     ImGuiIO& io = ImGui::GetIO();
24
     ImGuiIO& io = ImGui::GetIO();
24
     ImVec2 pos = ImVec2(x, y);
25
     ImVec2 pos = ImVec2(x, y);
25
     ImU32 col = color[0] | (color[1] << 8) | (color[2] << 16) | (color[3] << 24);
26
     ImU32 col = color[0] | (color[1] << 8) | (color[2] << 16) | (color[3] << 24);
34
 
35
 
35
 unsigned int FontImGui::heightText(float scale, unsigned int maxWidth, std::string s) {
36
 unsigned int FontImGui::heightText(float scale, unsigned int maxWidth, std::string s) {
36
     ImGuiIO& io = ImGui::GetIO();
37
     ImGuiIO& io = ImGui::GetIO();
37
-    ImVec2 size = io.Font->CalcTextSizeA(scale * SCALE_CALC, maxWidth, s.c_str(), s.c_str() + s.length());
38
+    ImVec2 size = io.Font->CalcTextSizeA(scale * SCALE_CALC, maxWidth, s.c_str(),
39
+                                         s.c_str() + s.length());
38
     return size.x;
40
     return size.x;
39
 }
41
 }
40
 
42
 
41
 void FontImGui::drawTextWrapped(unsigned int x, unsigned int y, float scale,
43
 void FontImGui::drawTextWrapped(unsigned int x, unsigned int y, float scale,
42
-        const unsigned char color[4], unsigned int maxWidth, std::string s) {
44
+                                const unsigned char color[4], unsigned int maxWidth, std::string s) {
43
     drawText(x, y, scale, color, s);
45
     drawText(x, y, scale, color, s);
44
 }
46
 }
45
 
47
 

+ 9
- 7
src/FontSDL.cpp View File

62
 }
62
 }
63
 
63
 
64
 void FontSDL::drawText(unsigned int x, unsigned int y, float scale,
64
 void FontSDL::drawText(unsigned int x, unsigned int y, float scale,
65
-        const unsigned char color[4], std::string s) {
65
+                       const unsigned char color[4], std::string s) {
66
     assert(mFontInit == true);
66
     assert(mFontInit == true);
67
     assert(mFont != nullptr);
67
     assert(mFont != nullptr);
68
     assert(s.length() > 0);
68
     assert(s.length() > 0);
73
     col.b = color[2];
73
     col.b = color[2];
74
     col.a = color[3];
74
     col.a = color[3];
75
 
75
 
76
-    SDL_Surface *surface = TTF_RenderUTF8_Blended(mFont, s.c_str(), col);
76
+    SDL_Surface* surface = TTF_RenderUTF8_Blended(mFont, s.c_str(), col);
77
     if (surface == nullptr) {
77
     if (surface == nullptr) {
78
         std::cout << "TTF_RenderUTF8_Blended Error: " << TTF_GetError() << std::endl;
78
         std::cout << "TTF_RenderUTF8_Blended Error: " << TTF_GetError() << std::endl;
79
         return;
79
         return;
98
     glBindTexture(GL_TEXTURE_2D, mFontTexture);
98
     glBindTexture(GL_TEXTURE_2D, mFontTexture);
99
     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
99
     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
100
     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
100
     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
101
-    glTexImage2D(GL_TEXTURE_2D, 0, surface->format->BytesPerPixel, surface->w, surface->h, 0, textureFormat, GL_UNSIGNED_BYTE, surface->pixels);
101
+    glTexImage2D(GL_TEXTURE_2D, 0, surface->format->BytesPerPixel, surface->w, surface->h, 0,
102
+                 textureFormat, GL_UNSIGNED_BYTE, surface->pixels);
102
     SDL_FreeSurface(surface);
103
     SDL_FreeSurface(surface);
103
 
104
 
104
     GLuint xMin = x;
105
     GLuint xMin = x;
130
     assert(maxWidth > 0);
131
     assert(maxWidth > 0);
131
 
132
 
132
     SDL_Color col;
133
     SDL_Color col;
133
-    SDL_Surface *surface = TTF_RenderUTF8_Blended_Wrapped(mFont, s.c_str(), col, maxWidth);
134
+    SDL_Surface* surface = TTF_RenderUTF8_Blended_Wrapped(mFont, s.c_str(), col, maxWidth);
134
     if (surface == nullptr) {
135
     if (surface == nullptr) {
135
         std::cout << "TTF_RenderUTF8_Blended_Wrapped Error: " << TTF_GetError() << std::endl;
136
         std::cout << "TTF_RenderUTF8_Blended_Wrapped Error: " << TTF_GetError() << std::endl;
136
         return 0;
137
         return 0;
141
 }
142
 }
142
 
143
 
143
 void FontSDL::drawTextWrapped(unsigned int x, unsigned int y, float scale,
144
 void FontSDL::drawTextWrapped(unsigned int x, unsigned int y, float scale,
144
-        const unsigned char color[4], unsigned int maxWidth, std::string s) {
145
+                              const unsigned char color[4], unsigned int maxWidth, std::string s) {
145
     assert(mFontInit == true);
146
     assert(mFontInit == true);
146
     assert(mFont != nullptr);
147
     assert(mFont != nullptr);
147
     assert(s.length() > 0);
148
     assert(s.length() > 0);
153
     col.b = color[2];
154
     col.b = color[2];
154
     col.a = color[3];
155
     col.a = color[3];
155
 
156
 
156
-    SDL_Surface *surface = TTF_RenderUTF8_Blended_Wrapped(mFont, s.c_str(), col, maxWidth);
157
+    SDL_Surface* surface = TTF_RenderUTF8_Blended_Wrapped(mFont, s.c_str(), col, maxWidth);
157
     if (surface == nullptr) {
158
     if (surface == nullptr) {
158
         std::cout << "TTF_RenderUTF8_Blended_Wrapped Error: " << TTF_GetError() << std::endl;
159
         std::cout << "TTF_RenderUTF8_Blended_Wrapped Error: " << TTF_GetError() << std::endl;
159
         return;
160
         return;
178
     glBindTexture(GL_TEXTURE_2D, mFontTexture);
179
     glBindTexture(GL_TEXTURE_2D, mFontTexture);
179
     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
180
     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
180
     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
181
     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
181
-    glTexImage2D(GL_TEXTURE_2D, 0, surface->format->BytesPerPixel, surface->w, surface->h, 0, textureFormat, GL_UNSIGNED_BYTE, surface->pixels);
182
+    glTexImage2D(GL_TEXTURE_2D, 0, surface->format->BytesPerPixel, surface->w, surface->h, 0,
183
+                 textureFormat, GL_UNSIGNED_BYTE, surface->pixels);
182
     SDL_FreeSurface(surface);
184
     SDL_FreeSurface(surface);
183
 
185
 
184
     GLuint xMin = x;
186
     GLuint xMin = x;

+ 5
- 5
src/FontTRLE.cpp View File

32
 
32
 
33
     // Load .pc file...
33
     // Load .pc file...
34
     std::ifstream file(font, std::ios::in | std::ios::binary);
34
     std::ifstream file(font, std::ios::in | std::ios::binary);
35
-    unsigned char *pixels = new unsigned char[256 * 256 * 4];
36
-    if (!file.read((char *)pixels, 256 * 256 * 4)) {
35
+    unsigned char* pixels = new unsigned char[256 * 256 * 4];
36
+    if (!file.read((char*)pixels, 256 * 256 * 4)) {
37
         delete [] pixels;
37
         delete [] pixels;
38
         return -1;
38
         return -1;
39
     }
39
     }
94
 }
94
 }
95
 
95
 
96
 void FontTRLE::writeChar(unsigned int index, unsigned int xDraw, unsigned int yDraw,
96
 void FontTRLE::writeChar(unsigned int index, unsigned int xDraw, unsigned int yDraw,
97
-        float scale, const unsigned char color[4]) {
97
+                         float scale, const unsigned char color[4]) {
98
     assert(mFontInit == true);
98
     assert(mFontInit == true);
99
 
99
 
100
     int width = (int)(((float)offsets[index][2]) * scale * SCALING);
100
     int width = (int)(((float)offsets[index][2]) * scale * SCALING);
150
 }
150
 }
151
 
151
 
152
 void FontTRLE::drawText(unsigned int x, unsigned int y, float scale,
152
 void FontTRLE::drawText(unsigned int x, unsigned int y, float scale,
153
-        const unsigned char color[4], std::string s) {
153
+                        const unsigned char color[4], std::string s) {
154
     assert(mFontInit == true);
154
     assert(mFontInit == true);
155
     assert(s.length() > 0);
155
     assert(s.length() > 0);
156
 
156
 
203
 }
203
 }
204
 
204
 
205
 void FontTRLE::drawTextWrapped(unsigned int x, unsigned int y, float scale,
205
 void FontTRLE::drawTextWrapped(unsigned int x, unsigned int y, float scale,
206
-        const unsigned char color[4], unsigned int maxWidth, std::string s) {
206
+                               const unsigned char color[4], unsigned int maxWidth, std::string s) {
207
     assert(mFontInit == true);
207
     assert(mFontInit == true);
208
     assert(s.length() > 0);
208
     assert(s.length() > 0);
209
 
209
 

+ 22
- 29
src/Game.cpp View File

73
     return mLoaded;
73
     return mLoaded;
74
 }
74
 }
75
 
75
 
76
-int Game::loadLevel(const char *level) {
76
+int Game::loadLevel(const char* level) {
77
     if (mLoaded)
77
     if (mLoaded)
78
         destroy();
78
         destroy();
79
 
79
 
183
     }
183
     }
184
 }
184
 }
185
 
185
 
186
-Entity &Game::getLara() {
186
+Entity& Game::getLara() {
187
     assert(mLara >= 0);
187
     assert(mLara >= 0);
188
     assert(mLara < (int)getWorld().sizeEntity());
188
     assert(mLara < (int)getWorld().sizeEntity());
189
     return getWorld().getEntity(mLara);
189
     return getWorld().getEntity(mLara);
217
     getLog() << "Found " << mTombRaider.getMeshCount() << " meshes." << Log::endl;
217
     getLog() << "Found " << mTombRaider.getMeshCount() << " meshes." << Log::endl;
218
 }
218
 }
219
 
219
 
220
-void Game::processPakSounds()
221
-{
222
-    unsigned char *riff;
220
+void Game::processPakSounds() {
221
+    unsigned char* riff;
223
     unsigned int riffSz;
222
     unsigned int riffSz;
224
     //tr2_sound_source_t *sound;
223
     //tr2_sound_source_t *sound;
225
     //tr2_sound_details_t *detail;
224
     //tr2_sound_details_t *detail;
235
     // in this group, bits 0-1: channel number
234
     // in this group, bits 0-1: channel number
236
     */
235
     */
237
 
236
 
238
-    for (i = 0; i < mTombRaider.getSoundSamplesCount(); ++i)
239
-    {
237
+    for (i = 0; i < mTombRaider.getSoundSamplesCount(); ++i) {
240
         mTombRaider.getSoundSample(i, &riffSz, &riff);
238
         mTombRaider.getSoundSample(i, &riffSz, &riff);
241
 
239
 
242
         getSound().addWave(riff, riffSz, &id, Sound::SoundFlagsNone);
240
         getSound().addWave(riff, riffSz, &id, Sound::SoundFlagsNone);
243
 
241
 
244
         //if (((i + 1) == TR_SOUND_F_PISTOL) && (id > 0))
242
         //if (((i + 1) == TR_SOUND_F_PISTOL) && (id > 0))
245
         //{
243
         //{
246
-            //m_testSFX = id;
244
+        //m_testSFX = id;
247
         //}
245
         //}
248
 
246
 
249
         delete [] riff;
247
         delete [] riff;
259
     getLog() << "Found " << mTombRaider.getSoundSamplesCount() << " sound samples." << Log::endl;
257
     getLog() << "Found " << mTombRaider.getSoundSamplesCount() << " sound samples." << Log::endl;
260
 }
258
 }
261
 
259
 
262
-void Game::processTextures()
263
-{
264
-    unsigned char *image;
265
-    unsigned char *bumpmap;
260
+void Game::processTextures() {
261
+    unsigned char* image;
262
+    unsigned char* bumpmap;
266
     int i;
263
     int i;
267
 
264
 
268
     //if ( mTombRaider.getNumBumpMaps())
265
     //if ( mTombRaider.getNumBumpMaps())
269
     //  gBumpMapStart = mTombRaider.NumTextures();
266
     //  gBumpMapStart = mTombRaider.NumTextures();
270
 
267
 
271
-    for (i = 0; i < mTombRaider.NumTextures(); ++i)
272
-    {
268
+    for (i = 0; i < mTombRaider.NumTextures(); ++i) {
273
         mTombRaider.Texture(i, &image, &bumpmap);
269
         mTombRaider.Texture(i, &image, &bumpmap);
274
 
270
 
275
         // Overwrite any previous level textures on load
271
         // Overwrite any previous level textures on load
276
         getTextureManager().loadBufferSlot(image, 256, 256,
272
         getTextureManager().loadBufferSlot(image, 256, 256,
277
-                RGBA, 32, (mTextureStart - 1) + i);
273
+                                           RGBA, 32, (mTextureStart - 1) + i);
278
 
274
 
279
 #ifdef MULTITEXTURE
275
 #ifdef MULTITEXTURE
280
         gMapTex2Bump[(mTextureStart - 1) + i] = -1;
276
         gMapTex2Bump[(mTextureStart - 1) + i] = -1;
281
 #endif
277
 #endif
282
 
278
 
283
-        if (bumpmap)
284
-        {
279
+        if (bumpmap) {
285
 #ifdef MULTITEXTURE
280
 #ifdef MULTITEXTURE
286
             gMapTex2Bump[(mTextureStart - 1) + i] = (mTextureStart - 1) + i +
281
             gMapTex2Bump[(mTextureStart - 1) + i] = (mTextureStart - 1) + i +
287
-                    mTombRaider.NumTextures();
282
+                                                    mTombRaider.NumTextures();
288
 #endif
283
 #endif
289
             getTextureManager().loadBufferSlot(bumpmap, 256, 256,
284
             getTextureManager().loadBufferSlot(bumpmap, 256, 256,
290
-                    RGBA, 32,
291
-                    (mTextureStart - 1) + i + mTombRaider.NumTextures());
285
+                                               RGBA, 32,
286
+                                               (mTextureStart - 1) + i + mTombRaider.NumTextures());
292
         }
287
         }
293
 
288
 
294
         if (image)
289
         if (image)
303
     getLog() << "Found " << mTombRaider.NumTextures() << " textures." << Log::endl;
298
     getLog() << "Found " << mTombRaider.NumTextures() << " textures." << Log::endl;
304
 }
299
 }
305
 
300
 
306
-void Game::processMoveables()
307
-{
301
+void Game::processMoveables() {
308
     unsigned int statCount = 0;
302
     unsigned int statCount = 0;
309
 
303
 
310
-    tr2_moveable_t *moveable = mTombRaider.Moveable();
311
-    tr2_item_t *item = mTombRaider.Item();
312
-    tr2_sprite_sequence_t *sprite_sequence = mTombRaider.SpriteSequence();
304
+    tr2_moveable_t* moveable = mTombRaider.Moveable();
305
+    tr2_item_t* item = mTombRaider.Item();
306
+    tr2_sprite_sequence_t* sprite_sequence = mTombRaider.SpriteSequence();
313
 
307
 
314
-    for (int i = 0; i < mTombRaider.NumItems(); ++i)
315
-    {
308
+    for (int i = 0; i < mTombRaider.NumItems(); ++i) {
316
         int j;
309
         int j;
317
         int object_id = item[i].object_id;
310
         int object_id = item[i].object_id;
318
 
311
 
406
         getWorld().addSkeletalModel(*new SkeletalModel(mTombRaider, index, object_id));
399
         getWorld().addSkeletalModel(*new SkeletalModel(mTombRaider, index, object_id));
407
 
400
 
408
     // Create a new Entity, using the cached or the new SkeletalModel
401
     // Create a new Entity, using the cached or the new SkeletalModel
409
-    Entity &entity = *new Entity(mTombRaider, index, i, model);
402
+    Entity& entity = *new Entity(mTombRaider, index, i, model);
410
     getWorld().addEntity(entity);
403
     getWorld().addEntity(entity);
411
 
404
 
412
     // Store reference to Lara
405
     // Store reference to Lara
416
     // Store reference to the SkyMesh
409
     // Store reference to the SkyMesh
417
     if (i == mTombRaider.getSkyModelId())
410
     if (i == mTombRaider.getSkyModelId())
418
         getRender().setSkyMesh(i, //moveable[i].starting_mesh,
411
         getRender().setSkyMesh(i, //moveable[i].starting_mesh,
419
-                (mTombRaider.Engine() == TR_VERSION_2));
412
+                               (mTombRaider.Engine() == TR_VERSION_2));
420
 }
413
 }
421
 
414
 

+ 7
- 7
src/Menu.cpp View File

13
 #include "MenuFolder.h"
13
 #include "MenuFolder.h"
14
 
14
 
15
 void Menu::showDialog(std::string msg, std::string btn1, std::string btn2,
15
 void Menu::showDialog(std::string msg, std::string btn1, std::string btn2,
16
-        std::function<int (bool state)> callback) {
16
+                      std::function<int (bool state)> callback) {
17
     // Only show one dialog at a time
17
     // Only show one dialog at a time
18
     assert(dialogText.length() == 0);
18
     assert(dialogText.length() == 0);
19
     assert(dialogButton1.length() == 0);
19
     assert(dialogButton1.length() == 0);
75
 }
75
 }
76
 
76
 
77
 bool Menu::handleMouseClickDialog(unsigned int x, unsigned int y,
77
 bool Menu::handleMouseClickDialog(unsigned int x, unsigned int y,
78
-            KeyboardButton button, bool released) {
78
+                                  KeyboardButton button, bool released) {
79
     //! \todo Allow mouse usage of Menu dialogs!
79
     //! \todo Allow mouse usage of Menu dialogs!
80
     return (dialogText.length() > 0);
80
     return (dialogText.length() > 0);
81
 }
81
 }
151
         if (dialogButton2.length() > 0) {
151
         if (dialogButton2.length() > 0) {
152
             if ((w1 + w2) <= wMax) {
152
             if ((w1 + w2) <= wMax) {
153
                 Font::drawTextWrapped(xOverlay + 10, yOverlay + 10 + h0, 1.0f,
153
                 Font::drawTextWrapped(xOverlay + 10, yOverlay + 10 + h0, 1.0f,
154
-                    dialogState ? BLUE : RED, w1, dialogButton1);
154
+                                      dialogState ? BLUE : RED, w1, dialogButton1);
155
                 Font::drawTextWrapped(xOverlay + 10 + w1, yOverlay + 10 + h0,
155
                 Font::drawTextWrapped(xOverlay + 10 + w1, yOverlay + 10 + h0,
156
-                    1.0f, dialogState ? RED : BLUE, w2, dialogButton2);
156
+                                      1.0f, dialogState ? RED : BLUE, w2, dialogButton2);
157
             } else {
157
             } else {
158
                 Font::drawTextWrapped((::getWindow().getWidth() - w1) / 2,
158
                 Font::drawTextWrapped((::getWindow().getWidth() - w1) / 2,
159
-                    yOverlay + 10 + h0, 1.0f, dialogState ? BLUE : RED, w1, dialogButton1);
159
+                                      yOverlay + 10 + h0, 1.0f, dialogState ? BLUE : RED, w1, dialogButton1);
160
                 Font::drawTextWrapped((::getWindow().getWidth() - w2) / 2,
160
                 Font::drawTextWrapped((::getWindow().getWidth() - w2) / 2,
161
-                    yOverlay + 10 + h0 + h1, 1.0f, dialogState ? RED : BLUE, w2, dialogButton2);
161
+                                      yOverlay + 10 + h0 + h1, 1.0f, dialogState ? RED : BLUE, w2, dialogButton2);
162
             }
162
             }
163
         } else {
163
         } else {
164
             Font::drawTextWrapped((::getWindow().getWidth() - w1) / 2,
164
             Font::drawTextWrapped((::getWindow().getWidth() - w1) / 2,
165
-                    yOverlay + 10 + h0, 1.0f, RED, w1, dialogButton1);
165
+                                  yOverlay + 10 + h0, 1.0f, RED, w1, dialogButton1);
166
         }
166
         }
167
     }
167
     }
168
 }
168
 }

+ 12
- 11
src/MenuFolder.cpp View File

36
     return init(new Folder(s));
36
     return init(new Folder(s));
37
 }
37
 }
38
 
38
 
39
-int MenuFolder::init(Folder *folder, bool filter) {
39
+int MenuFolder::init(Folder* folder, bool filter) {
40
     if (mapFolder != nullptr)
40
     if (mapFolder != nullptr)
41
         delete mapFolder;
41
         delete mapFolder;
42
 
42
 
44
     mMin = mCursor = 0;
44
     mMin = mCursor = 0;
45
 
45
 
46
     if (filter) {
46
     if (filter) {
47
-        mapFolder->executeRemoveFiles([](File &f) {
47
+        mapFolder->executeRemoveFiles([](File & f) {
48
             // Filter files based on file name
48
             // Filter files based on file name
49
             if ((f.getName().length() > 4)
49
             if ((f.getName().length() > 4)
50
                 && (f.getName().compare(f.getName().length() - 4, 4, ".phd") != 0)
50
                 && (f.getName().compare(f.getName().length() - 4, 4, ".phd") != 0)
58
             Loader::LoaderVersion version = Loader::checkFile(f.getPath());
58
             Loader::LoaderVersion version = Loader::checkFile(f.getPath());
59
             if (version == Loader::TR_UNKNOWN) {
59
             if (version == Loader::TR_UNKNOWN) {
60
                 getLog() << "Error: pak file '" << f.getName().c_str()
60
                 getLog() << "Error: pak file '" << f.getName().c_str()
61
-                    << "' invalid" << Log::endl;
61
+                         << "' invalid" << Log::endl;
62
                 return true; // delete file from list
62
                 return true; // delete file from list
63
             }
63
             }
64
 
64
 
92
 
92
 
93
     // Print list of "..", folders, files
93
     // Print list of "..", folders, files
94
     for (long i = mMin; (i < (mMin + items))
94
     for (long i = mMin; (i < (mMin + items))
95
-                && (i < (mapFolder->folderCount() + mapFolder->fileCount() + 1)); i++) {
95
+         && (i < (mapFolder->folderCount() + mapFolder->fileCount() + 1)); i++) {
96
         if (i == 0) {
96
         if (i == 0) {
97
             Font::drawText(25, 50, 0.75f, (mCursor == i) ? RED : BLUE, "..");
97
             Font::drawText(25, 50, 0.75f, (mCursor == i) ? RED : BLUE, "..");
98
         } else {
98
         } else {
99
             Font::drawText(25, (unsigned int)(50 + (25 * (i - mMin))), 0.75f,
99
             Font::drawText(25, (unsigned int)(50 + (25 * (i - mMin))), 0.75f,
100
-                (mCursor == i) ? RED : BLUE,
101
-                ((i - 1) < mapFolder->folderCount()) ?
102
-                    (mapFolder->getFolder(i - 1).getName() + "/")
103
-                    : mapFolder->getFile(i - 1 - mapFolder->folderCount()).getName());
100
+                           (mCursor == i) ? RED : BLUE,
101
+                           ((i - 1) < mapFolder->folderCount()) ?
102
+                           (mapFolder->getFolder(i - 1).getName() + "/")
103
+                           : mapFolder->getFile(i - 1 - mapFolder->folderCount()).getName());
104
         }
104
         }
105
     }
105
     }
106
 
106
 
120
         }
120
         }
121
     } else {
121
     } else {
122
         int error = getGame().loadLevel(mapFolder->getFile((unsigned long)mCursor
122
         int error = getGame().loadLevel(mapFolder->getFile((unsigned long)mCursor
123
-                    - 1 - mapFolder->folderCount()).getPath().c_str());
123
+                                        - 1 - mapFolder->folderCount()).getPath().c_str());
124
         if (error == 0) {
124
         if (error == 0) {
125
             visible = false;
125
             visible = false;
126
         } else {
126
         } else {
165
     }
165
     }
166
 }
166
 }
167
 
167
 
168
-void MenuFolder::handleMouseClick(unsigned int x, unsigned int y, KeyboardButton button, bool released) {
168
+void MenuFolder::handleMouseClick(unsigned int x, unsigned int y, KeyboardButton button,
169
+                                  bool released) {
169
     if (handleMouseClickDialog(x, y, button, released))
170
     if (handleMouseClickDialog(x, y, button, released))
170
         return;
171
         return;
171
 
172
 
175
         return;
176
         return;
176
 
177
 
177
     if ((y >= 50) && (y <= (unsigned int)(50 + (25 * items)))
178
     if ((y >= 50) && (y <= (unsigned int)(50 + (25 * items)))
178
-            && ((mMin + (y / 25)) <= (mapFolder->folderCount() + mapFolder->fileCount() + 2))) {
179
+        && ((mMin + (y / 25)) <= (mapFolder->folderCount() + mapFolder->fileCount() + 2))) {
179
         y -= 50;
180
         y -= 50;
180
         if (mCursor == (mMin + (y / 25)))
181
         if (mCursor == (mMin + (y / 25)))
181
             loadOrOpen();
182
             loadOrOpen();

+ 82
- 142
src/Mesh.cpp View File

15
 // Constructors
15
 // Constructors
16
 ////////////////////////////////////////////////////////////
16
 ////////////////////////////////////////////////////////////
17
 
17
 
18
-Mesh::Mesh()
19
-{
18
+Mesh::Mesh() {
20
     mNumVertices = 0;
19
     mNumVertices = 0;
21
     mVertices = 0x0;
20
     mVertices = 0x0;
22
 
21
 
47
 }
46
 }
48
 
47
 
49
 
48
 
50
-Mesh::~Mesh()
51
-{
49
+Mesh::~Mesh() {
52
     for (unsigned int i = 0; i < mNumVertices; i++)
50
     for (unsigned int i = 0; i < mNumVertices; i++)
53
         delete [] mVertices[i];
51
         delete [] mVertices[i];
54
     delete [] mVertices;
52
     delete [] mVertices;
64
     delete [] mColors;
62
     delete [] mColors;
65
     mColors = NULL;
63
     mColors = NULL;
66
 
64
 
67
-    if (mTris)
68
-    {
69
-        for (unsigned int i = 0; i < mNumTris; ++i)
70
-        {
65
+    if (mTris) {
66
+        for (unsigned int i = 0; i < mNumTris; ++i) {
71
             delete [] mTris[i].triangles;
67
             delete [] mTris[i].triangles;
72
             delete [] mTris[i].alpha_triangles;
68
             delete [] mTris[i].alpha_triangles;
73
             delete [] mTris[i].texcoors;
69
             delete [] mTris[i].texcoors;
78
         mTris = NULL;
74
         mTris = NULL;
79
     }
75
     }
80
 
76
 
81
-    if (mQuads)
82
-    {
83
-        for (unsigned int i = 0; i < mNumQuads; ++i)
84
-        {
77
+    if (mQuads) {
78
+        for (unsigned int i = 0; i < mNumQuads; ++i) {
85
             delete [] mQuads[i].quads;
79
             delete [] mQuads[i].quads;
86
             delete [] mQuads[i].alpha_quads;
80
             delete [] mQuads[i].alpha_quads;
87
             delete [] mQuads[i].texcoors;
81
             delete [] mQuads[i].texcoors;
119
 // Public Accessors
113
 // Public Accessors
120
 ////////////////////////////////////////////////////////////
114
 ////////////////////////////////////////////////////////////
121
 
115
 
122
-void Mesh::drawAlpha()
123
-{
116
+void Mesh::drawAlpha() {
124
     unsigned int i, j, k, index;
117
     unsigned int i, j, k, index;
125
 
118
 
126
 
119
 
127
     // Render quadralaterals
120
     // Render quadralaterals
128
-    for (mQuads ? i = 0 : i = mNumQuads; i < mNumQuads; ++i)
129
-    {
130
-        switch (mMode)
131
-        {
121
+    for (mQuads ? i = 0 : i = mNumQuads; i < mNumQuads; ++i) {
122
+        switch (mMode) {
132
             case MeshModeWireframe:
123
             case MeshModeWireframe:
133
                 glColor3f(0.0, 0.0, 1.0);
124
                 glColor3f(0.0, 0.0, 1.0);
134
                 glBindTexture(GL_TEXTURE_2D, 0);
125
                 glBindTexture(GL_TEXTURE_2D, 0);
140
             case MeshModeTexture:
131
             case MeshModeTexture:
141
             case MeshModeMultiTexture:
132
             case MeshModeMultiTexture:
142
                 // Bind texture id for textures
133
                 // Bind texture id for textures
143
-                glBindTexture(GL_TEXTURE_2D, mQuads[i].texture+1);
134
+                glBindTexture(GL_TEXTURE_2D, mQuads[i].texture + 1);
144
                 break;
135
                 break;
145
         }
136
         }
146
 
137
 
147
         glBegin(GL_QUADS);
138
         glBegin(GL_QUADS);
148
 
139
 
149
-        for (j = 0; j < mQuads[i].num_alpha_quads; ++j)
150
-        {
151
-            for (k = 0; k < 4; ++k)
152
-            {
153
-                index = mQuads[i].alpha_quads[j*4+k];
140
+        for (j = 0; j < mQuads[i].num_alpha_quads; ++j) {
141
+            for (k = 0; k < 4; ++k) {
142
+                index = mQuads[i].alpha_quads[j * 4 + k];
154
 
143
 
155
-                glTexCoord2fv(mQuads[i].texcoors2[j*4+k]);
144
+                glTexCoord2fv(mQuads[i].texcoors2[j * 4 + k]);
156
                 glColor4fv(mColors[index]);
145
                 glColor4fv(mColors[index]);
157
                 glVertex3fv(mVertices[index]);
146
                 glVertex3fv(mVertices[index]);
158
             }
147
             }
162
     }
151
     }
163
 
152
 
164
     // Render triangles
153
     // Render triangles
165
-    for (mTris ? i = 0 : i = mNumTris; i < mNumTris; ++i)
166
-    {
167
-        switch (mMode)
168
-        {
154
+    for (mTris ? i = 0 : i = mNumTris; i < mNumTris; ++i) {
155
+        switch (mMode) {
169
             case MeshModeWireframe:
156
             case MeshModeWireframe:
170
                 glColor3f(0.0, 1.0, 0.0);
157
                 glColor3f(0.0, 1.0, 0.0);
171
                 glBindTexture(GL_TEXTURE_2D, 0);
158
                 glBindTexture(GL_TEXTURE_2D, 0);
177
             case MeshModeTexture:
164
             case MeshModeTexture:
178
             case MeshModeMultiTexture:
165
             case MeshModeMultiTexture:
179
                 // Bind texture id for textures
166
                 // Bind texture id for textures
180
-                glBindTexture(GL_TEXTURE_2D, mTris[i].texture+1);
167
+                glBindTexture(GL_TEXTURE_2D, mTris[i].texture + 1);
181
                 break;
168
                 break;
182
         }
169
         }
183
 
170
 
184
         glBegin(GL_TRIANGLES);
171
         glBegin(GL_TRIANGLES);
185
 
172
 
186
-        for (j = 0; j < mTris[i].num_alpha_triangles; ++j)
187
-        {
188
-            for (k = 0; k < 3; ++k)
189
-            {
190
-                index = mTris[i].alpha_triangles[j*3+k];
173
+        for (j = 0; j < mTris[i].num_alpha_triangles; ++j) {
174
+            for (k = 0; k < 3; ++k) {
175
+                index = mTris[i].alpha_triangles[j * 3 + k];
191
 
176
 
192
-                glTexCoord2fv(mTris[i].texcoors2[j*3+k]);
177
+                glTexCoord2fv(mTris[i].texcoors2[j * 3 + k]);
193
                 glColor4fv(mColors[index]);
178
                 glColor4fv(mColors[index]);
194
                 glVertex3fv(mVertices[index]);
179
                 glVertex3fv(mVertices[index]);
195
             }
180
             }
200
 }
185
 }
201
 
186
 
202
 
187
 
203
-void Mesh::drawSolid()
204
-{
188
+void Mesh::drawSolid() {
205
     unsigned int i, j, k, index;
189
     unsigned int i, j, k, index;
206
 
190
 
207
 
191
 
208
-    if (mFlags & fMesh_UseVertexArray)
209
-    {
192
+    if (mFlags & fMesh_UseVertexArray) {
210
         //glEnableClientState(GL_VERTEX_ARRAY);
193
         //glEnableClientState(GL_VERTEX_ARRAY);
211
         //glVertexPointer(3, GL_FLOAT, 0, mVertexArray);
194
         //glVertexPointer(3, GL_FLOAT, 0, mVertexArray);
212
 
195
 
214
         glColor3f(1.0f, 1.0f, 1.0f);
197
         glColor3f(1.0f, 1.0f, 1.0f);
215
         glBegin(GL_TRIANGLES);
198
         glBegin(GL_TRIANGLES);
216
 
199
 
217
-        for (i = 0; i < mTriangleCount*3; ++i)
218
-        {
200
+        for (i = 0; i < mTriangleCount * 3; ++i) {
219
             //glArrayElement(mTriangleIndices[i]);
201
             //glArrayElement(mTriangleIndices[i]);
220
-            glVertex3fv(mVertexArray+mTriangleIndices[i]);
202
+            glVertex3fv(mVertexArray + mTriangleIndices[i]);
221
         }
203
         }
222
 
204
 
223
         glEnd();
205
         glEnd();
242
     }
224
     }
243
 
225
 
244
     // Render quadralaterals
226
     // Render quadralaterals
245
-    for (mQuads ? i = 0 : i = mNumQuads; i < mNumQuads; ++i)
246
-    {
247
-        switch (mMode)
248
-        {
227
+    for (mQuads ? i = 0 : i = mNumQuads; i < mNumQuads; ++i) {
228
+        switch (mMode) {
249
             case MeshModeSolid:
229
             case MeshModeSolid:
250
                 glColor3f(0.0, 0.0, 0.0);
230
                 glColor3f(0.0, 0.0, 0.0);
251
                 break;
231
                 break;
257
             case MeshModeMultiTexture:
237
             case MeshModeMultiTexture:
258
                 glActiveTextureARB(GL_TEXTURE0_ARB);
238
                 glActiveTextureARB(GL_TEXTURE0_ARB);
259
                 glEnable(GL_TEXTURE_2D);
239
                 glEnable(GL_TEXTURE_2D);
260
-                glBindTexture(GL_TEXTURE_2D, mQuads[i].texture+1);
240
+                glBindTexture(GL_TEXTURE_2D, mQuads[i].texture + 1);
261
 
241
 
262
                 glActiveTextureARB(GL_TEXTURE1_ARB);
242
                 glActiveTextureARB(GL_TEXTURE1_ARB);
263
                 glEnable(GL_TEXTURE_2D);
243
                 glEnable(GL_TEXTURE_2D);
264
-                glBindTexture(GL_TEXTURE_2D, mQuads[i].bumpmap+1);
244
+                glBindTexture(GL_TEXTURE_2D, mQuads[i].bumpmap + 1);
265
                 break;
245
                 break;
266
 #else
246
 #else
267
             case MeshModeMultiTexture:
247
             case MeshModeMultiTexture:
269
             case MeshModeTexture:
249
             case MeshModeTexture:
270
                 // Bind texture id for textures
250
                 // Bind texture id for textures
271
                 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
251
                 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
272
-                glBindTexture(GL_TEXTURE_2D, mQuads[i].texture+1);
252
+                glBindTexture(GL_TEXTURE_2D, mQuads[i].texture + 1);
273
                 break;
253
                 break;
274
         }
254
         }
275
 
255
 
276
         glBegin(GL_QUADS);
256
         glBegin(GL_QUADS);
277
 
257
 
278
-        for (j = 0; j < mQuads[i].num_quads; ++j)
279
-        {
280
-            for (k = 0; k < 4; ++k)
281
-            {
282
-                index = mQuads[i].quads[j*4+k];
258
+        for (j = 0; j < mQuads[i].num_quads; ++j) {
259
+            for (k = 0; k < 4; ++k) {
260
+                index = mQuads[i].quads[j * 4 + k];
283
 
261
 
284
                 glColor4fv(mColors[index]);
262
                 glColor4fv(mColors[index]);
285
 
263
 
286
 #ifdef MULTITEXTURE
264
 #ifdef MULTITEXTURE
287
-                if (mMode == MeshModeMultiTexture)
288
-                {
265
+                if (mMode == MeshModeMultiTexture) {
289
                     glMultiTexCoord2fvARB(GL_TEXTURE0_ARB,
266
                     glMultiTexCoord2fvARB(GL_TEXTURE0_ARB,
290
-                            mQuads[i].texcoors[j*4+k]);
267
+                                          mQuads[i].texcoors[j * 4 + k]);
291
                     glMultiTexCoord2fvARB(GL_TEXTURE1_ARB,
268
                     glMultiTexCoord2fvARB(GL_TEXTURE1_ARB,
292
-                            mQuads[i].texcoors[j*4+k]);
293
-                }
294
-                else
269
+                                          mQuads[i].texcoors[j * 4 + k]);
270
+                } else
295
 #endif
271
 #endif
296
-                    glTexCoord2fv(mQuads[i].texcoors[j*4+k]);
272
+                    glTexCoord2fv(mQuads[i].texcoors[j * 4 + k]);
297
 
273
 
298
                 glVertex3fv(mVertices[index]);
274
                 glVertex3fv(mVertices[index]);
299
             }
275
             }
303
     }
279
     }
304
 
280
 
305
     // Render triangles
281
     // Render triangles
306
-    for (mTris ? i = 0 : i = mNumTris; i < mNumTris; ++i)
307
-    {
308
-        switch (mMode)
309
-        {
282
+    for (mTris ? i = 0 : i = mNumTris; i < mNumTris; ++i) {
283
+        switch (mMode) {
310
             case MeshModeSolid:
284
             case MeshModeSolid:
311
                 glColor3f(1.0, 0.0, 0.0);
285
                 glColor3f(1.0, 0.0, 0.0);
312
                 break;
286
                 break;
318
             case MeshModeMultiTexture:
292
             case MeshModeMultiTexture:
319
                 glActiveTextureARB(GL_TEXTURE0_ARB);
293
                 glActiveTextureARB(GL_TEXTURE0_ARB);
320
                 glEnable(GL_TEXTURE_2D);
294
                 glEnable(GL_TEXTURE_2D);
321
-                glBindTexture(GL_TEXTURE_2D, mTris[i].texture+1);
295
+                glBindTexture(GL_TEXTURE_2D, mTris[i].texture + 1);
322
 
296
 
323
                 glActiveTextureARB(GL_TEXTURE1_ARB);
297
                 glActiveTextureARB(GL_TEXTURE1_ARB);
324
                 glEnable(GL_TEXTURE_2D);
298
                 glEnable(GL_TEXTURE_2D);
325
-                glBindTexture(GL_TEXTURE_2D, mTris[i].bumpmap+1);
299
+                glBindTexture(GL_TEXTURE_2D, mTris[i].bumpmap + 1);
326
                 break;
300
                 break;
327
 #else
301
 #else
328
             case MeshModeMultiTexture:
302
             case MeshModeMultiTexture:
330
             case MeshModeTexture:
304
             case MeshModeTexture:
331
                 // Bind texture id for textures
305
                 // Bind texture id for textures
332
                 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
306
                 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
333
-                glBindTexture(GL_TEXTURE_2D, mTris[i].texture+1);
307
+                glBindTexture(GL_TEXTURE_2D, mTris[i].texture + 1);
334
                 break;
308
                 break;
335
         }
309
         }
336
 
310
 
337
         glBegin(GL_TRIANGLES);
311
         glBegin(GL_TRIANGLES);
338
 
312
 
339
-        for (j = 0; j < mTris[i].num_triangles; ++j)
340
-        {
341
-            for (k = 0; k < 3; ++k)
342
-            {
343
-                index = mTris[i].triangles[j*3+k];
313
+        for (j = 0; j < mTris[i].num_triangles; ++j) {
314
+            for (k = 0; k < 3; ++k) {
315
+                index = mTris[i].triangles[j * 3 + k];
344
 
316
 
345
 #ifdef MULTITEXTURE
317
 #ifdef MULTITEXTURE
346
-                if (mMode == MeshModeMultiTexture)
347
-                {
318
+                if (mMode == MeshModeMultiTexture) {
348
                     glMultiTexCoord2fvARB(GL_TEXTURE0_ARB,
319
                     glMultiTexCoord2fvARB(GL_TEXTURE0_ARB,
349
-                            mTris[i].texcoors[j*3+k]);
320
+                                          mTris[i].texcoors[j * 3 + k]);
350
                     glMultiTexCoord2fvARB(GL_TEXTURE1_ARB,
321
                     glMultiTexCoord2fvARB(GL_TEXTURE1_ARB,
351
-                            mTris[i].texcoors[j*3+k]);
352
-                }
353
-                else
322
+                                          mTris[i].texcoors[j * 3 + k]);
323
+                } else
354
 #endif
324
 #endif
355
-                    glTexCoord2fv(mTris[i].texcoors[j*3+k]);
325
+                    glTexCoord2fv(mTris[i].texcoors[j * 3 + k]);
356
 
326
 
357
                 glColor4fv(mColors[index]);
327
                 glColor4fv(mColors[index]);
358
                 glVertex3fv(mVertices[index]);
328
                 glVertex3fv(mVertices[index]);
363
     }
333
     }
364
 
334
 
365
 #ifdef MULTITEXTURE
335
 #ifdef MULTITEXTURE
366
-    if (mMode == MeshModeMultiTexture)
367
-    {
336
+    if (mMode == MeshModeMultiTexture) {
368
         glDisable(GL_TEXTURE_2D);
337
         glDisable(GL_TEXTURE_2D);
369
         glActiveTextureARB(GL_TEXTURE0_ARB);
338
         glActiveTextureARB(GL_TEXTURE0_ARB);
370
     }
339
     }
376
 // Public Mutators
345
 // Public Mutators
377
 ////////////////////////////////////////////////////////////
346
 ////////////////////////////////////////////////////////////
378
 
347
 
379
-void Mesh::allocateColors(unsigned int n)
380
-{
381
-    if (mColors)
382
-    {
348
+void Mesh::allocateColors(unsigned int n) {
349
+    if (mColors) {
383
         for (unsigned int i = 0; i < mNumColors; i++)
350
         for (unsigned int i = 0; i < mNumColors; i++)
384
             delete [] mColors[i];
351
             delete [] mColors[i];
385
         delete [] mColors;
352
         delete [] mColors;
386
         mNumColors = 0;
353
         mNumColors = 0;
387
     }
354
     }
388
 
355
 
389
-    if (!n)
390
-    {
356
+    if (!n) {
391
         return;
357
         return;
392
     }
358
     }
393
 
359
 
398
 }
364
 }
399
 
365
 
400
 
366
 
401
-void Mesh::allocateNormals(unsigned int n)
402
-{
403
-    if (mNormals)
404
-    {
367
+void Mesh::allocateNormals(unsigned int n) {
368
+    if (mNormals) {
405
         for (unsigned int i = 0; i < mNumNormals; i++)
369
         for (unsigned int i = 0; i < mNumNormals; i++)
406
             delete [] mNormals[i];
370
             delete [] mNormals[i];
407
         delete [] mNormals;
371
         delete [] mNormals;
408
         mNumNormals = 0;
372
         mNumNormals = 0;
409
     }
373
     }
410
 
374
 
411
-    if (!n)
412
-    {
375
+    if (!n) {
413
         return;
376
         return;
414
     }
377
     }
415
 
378
 
420
 }
383
 }
421
 
384
 
422
 
385
 
423
-void Mesh::allocateRectangles(unsigned int n)
424
-{
425
-    if (mQuads)
426
-    {
386
+void Mesh::allocateRectangles(unsigned int n) {
387
+    if (mQuads) {
427
         mNumQuads = 0;
388
         mNumQuads = 0;
428
         delete [] mQuads;
389
         delete [] mQuads;
429
     }
390
     }
430
 
391
 
431
-    if (!n)
432
-    {
392
+    if (!n) {
433
         return;
393
         return;
434
     }
394
     }
435
 
395
 
438
 }
398
 }
439
 
399
 
440
 
400
 
441
-void Mesh::allocateTriangles(unsigned int n)
442
-{
443
-    if (mTris)
444
-    {
401
+void Mesh::allocateTriangles(unsigned int n) {
402
+    if (mTris) {
445
         mNumTris = 0;
403
         mNumTris = 0;
446
         delete [] mTris;
404
         delete [] mTris;
447
     }
405
     }
448
 
406
 
449
-    if (!n)
450
-    {
407
+    if (!n) {
451
         return;
408
         return;
452
     }
409
     }
453
 
410
 
456
 }
413
 }
457
 
414
 
458
 
415
 
459
-void Mesh::allocateVertices(unsigned int n)
460
-{
461
-    if (mVertices)
462
-    {
416
+void Mesh::allocateVertices(unsigned int n) {
417
+    if (mVertices) {
463
         for (unsigned int i = 0; i < mNumVertices; i++)
418
         for (unsigned int i = 0; i < mNumVertices; i++)
464
             delete [] mVertices[i];
419
             delete [] mVertices[i];
465
         delete [] mVertices;
420
         delete [] mVertices;
466
         mNumVertices = 0;
421
         mNumVertices = 0;
467
     }
422
     }
468
 
423
 
469
-    if (!n)
470
-    {
424
+    if (!n) {
471
         return;
425
         return;
472
     }
426
     }
473
 
427
 
478
 }
432
 }
479
 
433
 
480
 
434
 
481
-void Mesh::bufferColorArray(unsigned int colorCount, float *colors)
482
-{
483
-    if (mColors)
484
-    {
435
+void Mesh::bufferColorArray(unsigned int colorCount, float* colors) {
436
+    if (mColors) {
485
         for (unsigned int i = 0; i < mNumColors; i++)
437
         for (unsigned int i = 0; i < mNumColors; i++)
486
             delete [] mColors[i];
438
             delete [] mColors[i];
487
         delete [] mColors;
439
         delete [] mColors;
488
         mNumColors = 0;
440
         mNumColors = 0;
489
     }
441
     }
490
 
442
 
491
-    if (!colorCount)
492
-    {
443
+    if (!colorCount) {
493
         return;
444
         return;
494
     }
445
     }
495
 
446
 
498
 }
449
 }
499
 
450
 
500
 
451
 
501
-void Mesh::bufferNormalArray(unsigned int normalCount, float *normals)
502
-{
503
-    if (mNormals)
504
-    {
452
+void Mesh::bufferNormalArray(unsigned int normalCount, float* normals) {
453
+    if (mNormals) {
505
         for (unsigned int i = 0; i < mNumNormals; i++)
454
         for (unsigned int i = 0; i < mNumNormals; i++)
506
             delete [] mNormals[i];
455
             delete [] mNormals[i];
507
         delete [] mNormals;
456
         delete [] mNormals;
508
         mNumNormals = 0;
457
         mNumNormals = 0;
509
     }
458
     }
510
 
459
 
511
-    if (!normalCount)
512
-    {
460
+    if (!normalCount) {
513
         return;
461
         return;
514
     }
462
     }
515
 
463
 
519
 
467
 
520
 
468
 
521
 void Mesh::bufferTriangles(unsigned int count,
469
 void Mesh::bufferTriangles(unsigned int count,
522
-        unsigned int *indices, float *texCoords,
523
-        int *textures, unsigned int *flags)
524
-{
470
+                           unsigned int* indices, float* texCoords,
471
+                           int* textures, unsigned int* flags) {
525
 
472
 
526
     mTriangleCount = count;
473
     mTriangleCount = count;
527
     mTriangleTextures = textures;
474
     mTriangleTextures = textures;
533
 }
480
 }
534
 
481
 
535
 
482
 
536
-void Mesh::bufferVertexArray(unsigned int vertexCount, float *vertices)
537
-{
538
-    if (mVertices)
539
-    {
483
+void Mesh::bufferVertexArray(unsigned int vertexCount, float* vertices) {
484
+    if (mVertices) {
540
         for (unsigned int i = 0; i < mNumVertices; i++)
485
         for (unsigned int i = 0; i < mNumVertices; i++)
541
             delete [] mVertices[i];
486
             delete [] mVertices[i];
542
         delete [] mVertices;
487
         delete [] mVertices;
543
         mNumVertices = 0;
488
         mNumVertices = 0;
544
     }
489
     }
545
 
490
 
546
-    if (!vertexCount)
547
-    {
491
+    if (!vertexCount) {
548
         return;
492
         return;
549
     }
493
     }
550
 
494
 
555
 
499
 
556
 
500
 
557
 void Mesh::setColor(unsigned int index,
501
 void Mesh::setColor(unsigned int index,
558
-        float r, float g, float b, float a)
559
-{
502
+                    float r, float g, float b, float a) {
560
     assert(index < mNumColors);
503
     assert(index < mNumColors);
561
 
504
 
562
     mColors[index][0] = r;
505
     mColors[index][0] = r;
566
 }
509
 }
567
 
510
 
568
 
511
 
569
-void Mesh::setColor(unsigned int index, float rgba[4])
570
-{
512
+void Mesh::setColor(unsigned int index, float rgba[4]) {
571
     assert(index < mNumColors);
513
     assert(index < mNumColors);
572
 
514
 
573
     mColors[index][0] = rgba[0];
515
     mColors[index][0] = rgba[0];
577
 }
519
 }
578
 
520
 
579
 
521
 
580
-void Mesh::setNormal(unsigned int index, float i, float j, float k)
581
-{
522
+void Mesh::setNormal(unsigned int index, float i, float j, float k) {
582
     assert(index < mNumNormals);
523
     assert(index < mNumNormals);
583
 
524
 
584
     mNormals[index][0] = i;
525
     mNormals[index][0] = i;
587
 }
528
 }
588
 
529
 
589
 
530
 
590
-void Mesh::setVertex(unsigned int index, float x, float y, float z)
591
-{
531
+void Mesh::setVertex(unsigned int index, float x, float y, float z) {
592
     assert(index < mNumVertices);
532
     assert(index < mNumVertices);
593
 
533
 
594
     mVertices[index][0] = x;
534
     mVertices[index][0] = x;

+ 50
- 85
src/Render.cpp View File

39
     mRoomRenderList.clear();
39
     mRoomRenderList.clear();
40
 }
40
 }
41
 
41
 
42
-void Render::screenShot(const char *filenameBase)
43
-{
42
+void Render::screenShot(const char* filenameBase) {
44
     int sz = getWindow().getWidth() * getWindow().getHeight();
43
     int sz = getWindow().getWidth() * getWindow().getHeight();
45
-    unsigned char *image = new unsigned char[sz * 3];
44
+    unsigned char* image = new unsigned char[sz * 3];
46
     static int count = 0;
45
     static int count = 0;
47
     bool done = false;
46
     bool done = false;
48
 
47
 
53
     while (!done) {
52
     while (!done) {
54
         filename << filenameBase << "-" << count++ << ".tga";
53
         filename << filenameBase << "-" << count++ << ".tga";
55
 
54
 
56
-        FILE *f = fopen(filename.str().c_str(), "rb");
55
+        FILE* f = fopen(filename.str().c_str(), "rb");
57
         if (f) {
56
         if (f) {
58
             fclose(f);
57
             fclose(f);
59
         } else {
58
         } else {
61
         }
60
         }
62
     }
61
     }
63
 
62
 
64
-    glReadPixels(0, 0, getWindow().getWidth(), getWindow().getHeight(), GL_BGR_EXT, GL_UNSIGNED_BYTE, image);
63
+    glReadPixels(0, 0, getWindow().getWidth(), getWindow().getHeight(), GL_BGR_EXT, GL_UNSIGNED_BYTE,
64
+                 image);
65
     tgaSave(filename.str().c_str(), image, getWindow().getWidth(), getWindow().getHeight(), 0);
65
     tgaSave(filename.str().c_str(), image, getWindow().getWidth(), getWindow().getHeight(), 0);
66
     delete [] image;
66
     delete [] image;
67
 }
67
 }
70
     return mFlags;
70
     return mFlags;
71
 }
71
 }
72
 
72
 
73
-void Render::lightRoom(Room &room)
74
-{
75
-    for (unsigned int i = 0; i < room.sizeLights(); ++i)
76
-    {
77
-        Light &light = room.getLight(i);
73
+void Render::lightRoom(Room& room) {
74
+    for (unsigned int i = 0; i < room.sizeLights(); ++i) {
75
+        Light& light = room.getLight(i);
78
         float pos[4], color[4];
76
         float pos[4], color[4];
79
         float dir[3];
77
         float dir[3];
80
         light.getPos(pos);
78
         light.getPos(pos);
83
 
81
 
84
         glEnable(GL_LIGHT0 + i);
82
         glEnable(GL_LIGHT0 + i);
85
 
83
 
86
-        switch (light.getType())
87
-        {
84
+        switch (light.getType()) {
88
             case Light::typeSpot:
85
             case Light::typeSpot:
89
                 glLightf(GL_LIGHT0 + i,  GL_SPOT_CUTOFF,    light.getCutoff());
86
                 glLightf(GL_LIGHT0 + i,  GL_SPOT_CUTOFF,    light.getCutoff());
90
                 glLightfv(GL_LIGHT0 + i, GL_POSITION,       pos);
87
                 glLightfv(GL_LIGHT0 + i, GL_POSITION,       pos);
106
     }
103
     }
107
 }
104
 }
108
 
105
 
109
-void Render::clearFlags(unsigned int flags)
110
-{
106
+void Render::clearFlags(unsigned int flags) {
111
     mFlags &= ~flags;
107
     mFlags &= ~flags;
112
 
108
 
113
-    if (flags & Render::fFog)
114
-    {
115
-        if (glIsEnabled(GL_FOG))
116
-        {
109
+    if (flags & Render::fFog) {
110
+        if (glIsEnabled(GL_FOG)) {
117
             glDisable(GL_FOG);
111
             glDisable(GL_FOG);
118
         }
112
         }
119
     }
113
     }
120
 
114
 
121
-    if (flags & Render::fGL_Lights)
122
-    {
115
+    if (flags & Render::fGL_Lights) {
123
         glDisable(GL_LIGHTING);
116
         glDisable(GL_LIGHTING);
124
     }
117
     }
125
 }
118
 }
126
 
119
 
127
-void Render::setFlags(unsigned int flags)
128
-{
120
+void Render::setFlags(unsigned int flags) {
129
     mFlags |= flags;
121
     mFlags |= flags;
130
 
122
 
131
-    if (flags & Render::fFog)
132
-    {
123
+    if (flags & Render::fFog) {
133
         glEnable(GL_FOG);
124
         glEnable(GL_FOG);
134
         glFogf(GL_FOG_MODE, GL_EXP2);
125
         glFogf(GL_FOG_MODE, GL_EXP2);
135
         glFogf(GL_FOG_DENSITY, 0.00008f);
126
         glFogf(GL_FOG_DENSITY, 0.00008f);
144
         glFogfv(GL_FOG_COLOR, color);
135
         glFogfv(GL_FOG_COLOR, color);
145
     }
136
     }
146
 
137
 
147
-    if (flags & Render::fGL_Lights)
148
-    {
138
+    if (flags & Render::fGL_Lights) {
149
         float color[4];
139
         float color[4];
150
         color[0] = WHITE[0] * 256.0f;
140
         color[0] = WHITE[0] * 256.0f;
151
         color[1] = WHITE[1] * 256.0f;
141
         color[1] = WHITE[1] * 256.0f;
165
     }
155
     }
166
 }
156
 }
167
 
157
 
168
-int Render::getMode()
169
-{
158
+int Render::getMode() {
170
     return mMode;
159
     return mMode;
171
 }
160
 }
172
 
161
 
173
-void Render::setMode(int n)
174
-{
162
+void Render::setMode(int n) {
175
     mMode = n;
163
     mMode = n;
176
 
164
 
177
-    switch (mMode)
178
-    {
165
+    switch (mMode) {
179
         case Render::modeDisabled:
166
         case Render::modeDisabled:
180
             break;
167
             break;
181
         case Render::modeSolid:
168
         case Render::modeSolid:
182
         case Render::modeWireframe:
169
         case Render::modeWireframe:
183
             glClearColor(PURPLE[0] * 256.0f, PURPLE[1] * 256.0f,
170
             glClearColor(PURPLE[0] * 256.0f, PURPLE[1] * 256.0f,
184
-                    PURPLE[2] * 256.0f, PURPLE[3] * 256.0f);
171
+                         PURPLE[2] * 256.0f, PURPLE[3] * 256.0f);
185
             glDisable(GL_TEXTURE_2D);
172
             glDisable(GL_TEXTURE_2D);
186
             break;
173
             break;
187
         default:
174
         default:
188
-            if (mMode == Render::modeLoadScreen)
189
-            {
175
+            if (mMode == Render::modeLoadScreen) {
190
                 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
176
                 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
191
-            }
192
-            else
193
-            {
177
+            } else {
194
                 glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
178
                 glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
195
             }
179
             }
196
 
180
 
200
     }
184
     }
201
 }
185
 }
202
 
186
 
203
-void Render::display()
204
-{
205
-    switch (mMode)
206
-    {
187
+void Render::display() {
188
+    switch (mMode) {
207
         case Render::modeDisabled:
189
         case Render::modeDisabled:
208
             return;
190
             return;
209
         case Render::modeLoadScreen:
191
         case Render::modeLoadScreen:
221
 
203
 
222
     float camOffsetH = 0.0f;
204
     float camOffsetH = 0.0f;
223
 
205
 
224
-    switch (getGame().getLara().getMoveType())
225
-    {
206
+    switch (getGame().getLara().getMoveType()) {
226
         case Entity::MoveTypeFly:
207
         case Entity::MoveTypeFly:
227
         case Entity::MoveTypeNoClipping:
208
         case Entity::MoveTypeNoClipping:
228
         case Entity::MoveTypeSwim:
209
         case Entity::MoveTypeSwim:
252
 
233
 
253
     // Handle camera out of world
234
     // Handle camera out of world
254
     if ((sector < 0) ||
235
     if ((sector < 0) ||
255
-            ((unsigned int)sector >= getWorld().getRoom(index).sizeSectors()) ||
256
-            getWorld().getRoom(index).isWall(sector)) {
236
+        ((unsigned int)sector >= getWorld().getRoom(index).sizeSectors()) ||
237
+        getWorld().getRoom(index).isWall(sector)) {
257
         camPos[0] = curPos[0] + (64.0f * sinf(yaw));
238
         camPos[0] = curPos[0] + (64.0f * sinf(yaw));
258
         camPos[1] -= 64.0f;
239
         camPos[1] -= 64.0f;
259
         camPos[2] = curPos[2] + (64.0f * cosf(yaw));
240
         camPos[2] = curPos[2] + (64.0f * cosf(yaw));
281
 
262
 
282
     // Room solid pass, need to do depth sorting to avoid 2 pass render
263
     // Room solid pass, need to do depth sorting to avoid 2 pass render
283
     for (unsigned int i = 0; i < mRoomRenderList.size(); i++) {
264
     for (unsigned int i = 0; i < mRoomRenderList.size(); i++) {
284
-        Room &room = *mRoomRenderList[i];
265
+        Room& room = *mRoomRenderList[i];
285
 
266
 
286
         if (mFlags & Render::fGL_Lights)
267
         if (mFlags & Render::fGL_Lights)
287
             lightRoom(room);
268
             lightRoom(room);
291
 
272
 
292
     // Draw all visible enities
273
     // Draw all visible enities
293
     if (mFlags & Render::fEntityModels) {
274
     if (mFlags & Render::fEntityModels) {
294
-        std::vector<Entity *> entityRenderList;
275
+        std::vector<Entity*> entityRenderList;
295
 
276
 
296
         for (unsigned int i = 0; i < getWorld().sizeEntity(); i++) {
277
         for (unsigned int i = 0; i < getWorld().sizeEntity(); i++) {
297
-            Entity &e = getWorld().getEntity(i);
278
+            Entity& e = getWorld().getEntity(i);
298
 
279
 
299
             // Don't show Lara to the player
280
             // Don't show Lara to the player
300
             if (&e == &getGame().getLara())
281
             if (&e == &getGame().getLara())
303
             // Mongoose 2002.08.15, Nothing to draw, skip
284
             // Mongoose 2002.08.15, Nothing to draw, skip
304
             // Mongoose 2002.12.24, Some entities have no animation =p
285
             // Mongoose 2002.12.24, Some entities have no animation =p
305
             if (e.getModel().size() == 0)
286
             if (e.getModel().size() == 0)
306
-                    continue;
287
+                continue;
307
 
288
 
308
             // Is it in view volume? ( Hack to use sphere )
289
             // Is it in view volume? ( Hack to use sphere )
309
             if (!isVisible(e.getPos(0), e.getPos(1), e.getPos(2), 512.0f))
290
             if (!isVisible(e.getPos(0), e.getPos(1), e.getPos(2), 512.0f))
326
 
307
 
327
         // Draw sprites after player to handle alpha
308
         // Draw sprites after player to handle alpha
328
         for (unsigned int i = 0; i < getWorld().sizeSprite(); i++) {
309
         for (unsigned int i = 0; i < getWorld().sizeSprite(); i++) {
329
-            SpriteSequence &sprite = getWorld().getSprite(i);
310
+            SpriteSequence& sprite = getWorld().getSprite(i);
330
             for (unsigned int j = 0; j < sprite.size(); j++)
311
             for (unsigned int j = 0; j < sprite.size(); j++)
331
                 sprite.get(j).display();
312
                 sprite.get(j).display();
332
         }
313
         }
353
     glFlush();
334
     glFlush();
354
 }
335
 }
355
 
336
 
356
-void Render::drawLoadScreen()
357
-{
337
+void Render::drawLoadScreen() {
358
     float x = 0.0f, y = 0.0f, z = 0.0f;
338
     float x = 0.0f, y = 0.0f, z = 0.0f;
359
     float w = getWindow().getWidth(), h = getWindow().getHeight();
339
     float w = getWindow().getWidth(), h = getWindow().getHeight();
360
 
340
 
397
     glFlush();
377
     glFlush();
398
 }
378
 }
399
 
379
 
400
-void Render::newRoomRenderList(int index)
401
-{
380
+void Render::newRoomRenderList(int index) {
402
     static int currentRoomId = -1;
381
     static int currentRoomId = -1;
403
 
382
 
404
-    if (index == -1) // -1 is error, so draw room 0, for the hell of it
405
-    {
383
+    if (index == -1) { // -1 is error, so draw room 0, for the hell of it
406
         mRoomRenderList.clear();
384
         mRoomRenderList.clear();
407
         mRoomRenderList.push_back(&getWorld().getRoom(0));
385
         mRoomRenderList.push_back(&getWorld().getRoom(0));
408
-    }
409
-    else
410
-    {
386
+    } else {
411
         // Update room render list if needed
387
         // Update room render list if needed
412
-        if (currentRoomId != index)
413
-        {
388
+        if (currentRoomId != index) {
414
             buildRoomRenderList(getWorld().getRoom(index));
389
             buildRoomRenderList(getWorld().getRoom(index));
415
         }
390
         }
416
     }
391
     }
418
     currentRoomId = index;
393
     currentRoomId = index;
419
 }
394
 }
420
 
395
 
421
-void Render::buildRoomRenderList(Room &room)
422
-{
396
+void Render::buildRoomRenderList(Room& room) {
423
 
397
 
424
     // Must be visible
398
     // Must be visible
425
     //! \fixme Add depth sorting here - remove multipass
399
     //! \fixme Add depth sorting here - remove multipass
427
         return;
401
         return;
428
 
402
 
429
     // Must not already be cached
403
     // Must not already be cached
430
-    for (unsigned int i = 0; i < mRoomRenderList.size(); i++)
431
-    {
432
-        Room *room2 = mRoomRenderList[i];
404
+    for (unsigned int i = 0; i < mRoomRenderList.size(); i++) {
405
+        Room* room2 = mRoomRenderList[i];
433
 
406
 
434
         if (room2 == &room)
407
         if (room2 == &room)
435
             return;
408
             return;
439
     mRoomRenderList.push_back(&room);
412
     mRoomRenderList.push_back(&room);
440
 
413
 
441
     // Try to add adj rooms and their adj rooms, skip this room
414
     // Try to add adj rooms and their adj rooms, skip this room
442
-    for (unsigned int i = 1; i < room.sizeAdjacentRooms(); i++)
443
-    {
415
+    for (unsigned int i = 1; i < room.sizeAdjacentRooms(); i++) {
444
         if (room.getAdjacentRoom(i) < 0)
416
         if (room.getAdjacentRoom(i) < 0)
445
             continue;
417
             continue;
446
 
418
 
447
-        Room &room2 = getWorld().getRoom(room.getAdjacentRoom(i));
419
+        Room& room2 = getWorld().getRoom(room.getAdjacentRoom(i));
448
 
420
 
449
         //! \fixme Add portal visibility check here
421
         //! \fixme Add portal visibility check here
450
 
422
 
453
     }
425
     }
454
 }
426
 }
455
 
427
 
456
-void Render::drawSkyMesh(float scale)
457
-{
428
+void Render::drawSkyMesh(float scale) {
458
     //skeletal_model_t *model = getWorld().getModel(mSkyMesh);
429
     //skeletal_model_t *model = getWorld().getModel(mSkyMesh);
459
     //if (!model)
430
     //if (!model)
460
     //    return;
431
     //    return;
473
     glEnable(GL_DEPTH_TEST);
444
     glEnable(GL_DEPTH_TEST);
474
 }
445
 }
475
 
446
 
476
-void Render::setSkyMesh(int index, bool rot)
477
-{
447
+void Render::setSkyMesh(int index, bool rot) {
478
     mSkyMesh = index;
448
     mSkyMesh = index;
479
     mSkyMeshRotation = rot;
449
     mSkyMeshRotation = rot;
480
 }
450
 }
481
 
451
 
482
-void Render::updateViewVolume()
483
-{
452
+void Render::updateViewVolume() {
484
     float proj[16], mdl[16];
453
     float proj[16], mdl[16];
485
 
454
 
486
     glGetFloatv(GL_PROJECTION_MATRIX, proj);
455
     glGetFloatv(GL_PROJECTION_MATRIX, proj);
488
     mViewVolume.updateFrame(proj, mdl);
457
     mViewVolume.updateFrame(proj, mdl);
489
 }
458
 }
490
 
459
 
491
-bool Render::isVisible(BoundingBox &box) {
460
+bool Render::isVisible(BoundingBox& box) {
492
     float bbox[2][3];
461
     float bbox[2][3];
493
     box.getBoundingBox(bbox);
462
     box.getBoundingBox(bbox);
494
 
463
 
499
     return mViewVolume.isBboxInFrustum(bbox[0], bbox[1]);
468
     return mViewVolume.isBboxInFrustum(bbox[0], bbox[1]);
500
 }
469
 }
501
 
470
 
502
-bool Render::isVisible(float x, float y, float z)
503
-{
471
+bool Render::isVisible(float x, float y, float z) {
504
     // For debugging purposes
472
     // For debugging purposes
505
-    if (mMode == Render::modeWireframe)
506
-    {
473
+    if (mMode == Render::modeWireframe) {
507
         glPointSize(5.0);
474
         glPointSize(5.0);
508
         glColor3ubv(PINK);
475
         glColor3ubv(PINK);
509
         glBegin(GL_POINTS);
476
         glBegin(GL_POINTS);
514
     return (mViewVolume.isPointInFrustum(x, y, z));
481
     return (mViewVolume.isPointInFrustum(x, y, z));
515
 }
482
 }
516
 
483
 
517
-bool Render::isVisible(float x, float y, float z, float radius)
518
-{
484
+bool Render::isVisible(float x, float y, float z, float radius) {
519
     // For debugging purposes
485
     // For debugging purposes
520
-    if (mMode == Render::modeWireframe)
521
-    {
486
+    if (mMode == Render::modeWireframe) {
522
         glPointSize(5.0);
487
         glPointSize(5.0);
523
         glColor3ubv(PINK);
488
         glColor3ubv(PINK);
524
         glBegin(GL_POINTS);
489
         glBegin(GL_POINTS);

+ 87
- 128
src/Room.cpp View File

19
 extern std::map<int, int> gMapTex2Bump;
19
 extern std::map<int, int> gMapTex2Bump;
20
 #endif
20
 #endif
21
 
21
 
22
-Room::Room(TombRaider &tr, unsigned int index) {
22
+Room::Room(TombRaider& tr, unsigned int index) {
23
     float box[2][3];
23
     float box[2][3];
24
     Matrix transform;
24
     Matrix transform;
25
 
25
 
88
 //#define EXPERIMENTAL_UNIFIED_ROOM_GEOMETERY
88
 //#define EXPERIMENTAL_UNIFIED_ROOM_GEOMETERY
89
 #ifdef EXPERIMENTAL_UNIFIED_ROOM_GEOMETERY
89
 #ifdef EXPERIMENTAL_UNIFIED_ROOM_GEOMETERY
90
     unsigned int vertexCount, normalCount, colorCount, triCount;
90
     unsigned int vertexCount, normalCount, colorCount, triCount;
91
-    float *vertexArray;
92
-    float *normalArray;
93
-    float *colorArray;
94
-    unsigned int *indices, *fflags;
95
-    float *texCoords;
96
-    int *textures;
91
+    float* vertexArray;
92
+    float* normalArray;
93
+    float* colorArray;
94
+    unsigned int* indices, *fflags;
95
+    float* texCoords;
96
+    int* textures;
97
 
97
 
98
     tr.getRoomVertexArrays(index,
98
     tr.getRoomVertexArrays(index,
99
-            &vertexCount, &vertexArray,
100
-            &normalCount, &normalArray,
101
-            &colorCount, &colorArray);
99
+                           &vertexCount, &vertexArray,
100
+                           &normalCount, &normalArray,
101
+                           &colorCount, &colorArray);
102
 
102
 
103
     mesh.bufferVertexArray(vertexCount, vertexArray);
103
     mesh.bufferVertexArray(vertexCount, vertexArray);
104
     mesh.bufferNormalArray(normalCount, normalArray);
104
     mesh.bufferNormalArray(normalCount, normalArray);
105
     mesh.bufferColorArray(vertexCount, colorArray);
105
     mesh.bufferColorArray(vertexCount, colorArray);
106
 
106
 
107
     tr.getRoomTriangles(index, getGame().getTextureStart(),
107
     tr.getRoomTriangles(index, getGame().getTextureStart(),
108
-            &triCount, &indices, &texCoords, &textures,
109
-            &fflags);
108
+                        &triCount, &indices, &texCoords, &textures,
109
+                        &fflags);
110
 
110
 
111
     mesh.bufferTriangles(triCount, indices, texCoords, textures, fflags);
111
     mesh.bufferTriangles(triCount, indices, texCoords, textures, fflags);
112
 #else
112
 #else
119
     mesh.allocateNormals(0); // count
119
     mesh.allocateNormals(0); // count
120
     mesh.allocateColors(count);
120
     mesh.allocateColors(count);
121
 
121
 
122
-    for (unsigned int i = 0; i < count; ++i)
123
-    {
122
+    for (unsigned int i = 0; i < count; ++i) {
124
         tr.getRoomVertex(index, i, xyz, rgba);
123
         tr.getRoomVertex(index, i, xyz, rgba);
125
 
124
 
126
         mesh.setVertex(i, xyz[0], xyz[1], xyz[2]);
125
         mesh.setVertex(i, xyz[0], xyz[1], xyz[2]);
137
     int tris_mesh_map[TextureLimit];
136
     int tris_mesh_map[TextureLimit];
138
     int rect_mesh_map[TextureLimit];
137
     int rect_mesh_map[TextureLimit];
139
 
138
 
140
-    for (unsigned int i = 0; i < TextureLimit; ++i)
141
-    {
139
+    for (unsigned int i = 0; i < TextureLimit; ++i) {
142
         triangle_counter[i]        = 0;
140
         triangle_counter[i]        = 0;
143
         triangle_counter_alpha[i]  = 0;
141
         triangle_counter_alpha[i]  = 0;
144
         rectangle_counter[i]       = 0;
142
         rectangle_counter[i]       = 0;
159
     count = tr.getRoomTriangleCount(index);
157
     count = tr.getRoomTriangleCount(index);
160
 
158
 
161
     // Mongoose 2002.08.15, Presort by alpha and texture and setup mapping
159
     // Mongoose 2002.08.15, Presort by alpha and texture and setup mapping
162
-    for (t = 0; t < count; ++t)
163
-    {
160
+    for (t = 0; t < count; ++t) {
164
         tr.getRoomTriangle(index, t,
161
         tr.getRoomTriangle(index, t,
165
-                indices, texCoords, &texture, &flags);
162
+                           indices, texCoords, &texture, &flags);
166
 
163
 
167
         texture += getGame().getTextureStart();
164
         texture += getGame().getTextureStart();
168
 
165
 
169
-        if (texture > (int)TextureLimit)
170
-        {
166
+        if (texture > (int)TextureLimit) {
171
             getLog() << "Handling bad room[" << index << "].tris["
167
             getLog() << "Handling bad room[" << index << "].tris["
172
-                << t << "].texture = " << texture << Log::endl;
168
+                     << t << "].texture = " << texture << Log::endl;
173
             texture = TextureLimit - 1;
169
             texture = TextureLimit - 1;
174
         }
170
         }
175
 
171
 
176
         // Counters set up polygon allocation
172
         // Counters set up polygon allocation
177
         if (flags & tombraiderFace_Alpha ||
173
         if (flags & tombraiderFace_Alpha ||
178
-                flags & tombraiderFace_PartialAlpha)
179
-        {
174
+            flags & tombraiderFace_PartialAlpha) {
180
             triangle_counter_alpha[texture] += 1;
175
             triangle_counter_alpha[texture] += 1;
181
-        }
182
-        else
183
-        {
176
+        } else {
184
             triangle_counter[texture] += 1;
177
             triangle_counter[texture] += 1;
185
         }
178
         }
186
 
179
 
187
         // Counter sets up texture id to mesh id mapping
180
         // Counter sets up texture id to mesh id mapping
188
-        if (tris_mesh_map[texture] == -1)
189
-        {
181
+        if (tris_mesh_map[texture] == -1) {
190
             tris_mesh_map[texture] = ++numTris;
182
             tris_mesh_map[texture] = ++numTris;
191
         }
183
         }
192
     }
184
     }
193
 
185
 
194
     count = tr.getRoomRectangleCount(index);
186
     count = tr.getRoomRectangleCount(index);
195
 
187
 
196
-    for (r = 0; r < count; ++r)
197
-    {
188
+    for (r = 0; r < count; ++r) {
198
         tr.getRoomRectangle(index, r,
189
         tr.getRoomRectangle(index, r,
199
-                indices, texCoords, &texture, &flags);
190
+                            indices, texCoords, &texture, &flags);
200
 
191
 
201
         texture += getGame().getTextureStart();
192
         texture += getGame().getTextureStart();
202
 
193
 
203
-        if (texture > (int)TextureLimit)
204
-        {
194
+        if (texture > (int)TextureLimit) {
205
             getLog() << "Handling bad room[" << index << "].quad["
195
             getLog() << "Handling bad room[" << index << "].quad["
206
-                << r << "].texture = " << texture << Log::endl;
196
+                     << r << "].texture = " << texture << Log::endl;
207
             texture = TextureLimit - 1;
197
             texture = TextureLimit - 1;
208
         }
198
         }
209
 
199
 
210
         if (flags & tombraiderFace_Alpha ||
200
         if (flags & tombraiderFace_Alpha ||
211
-                flags & tombraiderFace_PartialAlpha)
212
-        {
201
+            flags & tombraiderFace_PartialAlpha) {
213
             rectangle_counter_alpha[texture] += 1;
202
             rectangle_counter_alpha[texture] += 1;
214
-        }
215
-        else
216
-        {
203
+        } else {
217
             rectangle_counter[texture] += 1;
204
             rectangle_counter[texture] += 1;
218
         }
205
         }
219
 
206
 
220
-        if (rect_mesh_map[texture] == -1)
221
-        {
207
+        if (rect_mesh_map[texture] == -1) {
222
             rect_mesh_map[texture] = ++numQuads;
208
             rect_mesh_map[texture] = ++numQuads;
223
         }
209
         }
224
     }
210
     }
227
     mesh.allocateTriangles(numTris);
213
     mesh.allocateTriangles(numTris);
228
     mesh.allocateRectangles(numQuads);
214
     mesh.allocateRectangles(numQuads);
229
 
215
 
230
-    for (unsigned int i = 0, j = 0; i < TextureLimit; ++i)
231
-    {
232
-        if (tris_mesh_map[i] > 0)
233
-        {
216
+    for (unsigned int i = 0, j = 0; i < TextureLimit; ++i) {
217
+        if (tris_mesh_map[i] > 0) {
234
             j = tris_mesh_map[i] - 1;
218
             j = tris_mesh_map[i] - 1;
235
 
219
 
236
             t = triangle_counter[i];
220
             t = triangle_counter[i];
248
             mesh.mTris[j].texcoors = 0x0;
232
             mesh.mTris[j].texcoors = 0x0;
249
             mesh.mTris[j].texcoors2 = 0x0;
233
             mesh.mTris[j].texcoors2 = 0x0;
250
 
234
 
251
-            if (t > 0)
252
-            {
235
+            if (t > 0) {
253
                 mesh.mTris[j].num_triangles = t;
236
                 mesh.mTris[j].num_triangles = t;
254
-                mesh.mTris[j].triangles = new unsigned int[t*3];
237
+                mesh.mTris[j].triangles = new unsigned int[t * 3];
255
                 mesh.mTris[j].num_texcoors = t * 3;
238
                 mesh.mTris[j].num_texcoors = t * 3;
256
                 mesh.mTris[j].texcoors = new float *[t * 3];
239
                 mesh.mTris[j].texcoors = new float *[t * 3];
257
                 for (unsigned int tmp = 0; tmp < (t * 3); tmp++)
240
                 for (unsigned int tmp = 0; tmp < (t * 3); tmp++)
260
 
243
 
261
             t = triangle_counter_alpha[i];
244
             t = triangle_counter_alpha[i];
262
 
245
 
263
-            if (t > 0)
264
-            {
246
+            if (t > 0) {
265
                 mesh.mTris[j].num_alpha_triangles = t;
247
                 mesh.mTris[j].num_alpha_triangles = t;
266
-                mesh.mTris[j].alpha_triangles = new unsigned int[t*3];
248
+                mesh.mTris[j].alpha_triangles = new unsigned int[t * 3];
267
                 mesh.mTris[j].num_texcoors2 = t * 3;
249
                 mesh.mTris[j].num_texcoors2 = t * 3;
268
                 mesh.mTris[j].texcoors2 = new float *[t * 3];
250
                 mesh.mTris[j].texcoors2 = new float *[t * 3];
269
                 for (unsigned int tmp = 0; tmp < (t * 3); tmp++)
251
                 for (unsigned int tmp = 0; tmp < (t * 3); tmp++)
273
 
255
 
274
         ///////////////////////////////////////////
256
         ///////////////////////////////////////////
275
 
257
 
276
-        if (rect_mesh_map[i] > 0)
277
-        {
258
+        if (rect_mesh_map[i] > 0) {
278
             j = rect_mesh_map[i] - 1;
259
             j = rect_mesh_map[i] - 1;
279
 
260
 
280
             r = rectangle_counter[i];
261
             r = rectangle_counter[i];
292
             mesh.mQuads[j].texcoors = 0x0;
273
             mesh.mQuads[j].texcoors = 0x0;
293
             mesh.mQuads[j].texcoors2 = 0x0;
274
             mesh.mQuads[j].texcoors2 = 0x0;
294
 
275
 
295
-            if (r > 0)
296
-            {
276
+            if (r > 0) {
297
                 mesh.mQuads[j].num_quads = r;
277
                 mesh.mQuads[j].num_quads = r;
298
-                mesh.mQuads[j].quads = new unsigned int[r*4];
278
+                mesh.mQuads[j].quads = new unsigned int[r * 4];
299
                 mesh.mQuads[j].num_texcoors = r * 4;
279
                 mesh.mQuads[j].num_texcoors = r * 4;
300
                 mesh.mQuads[j].texcoors = new float *[r * 4];
280
                 mesh.mQuads[j].texcoors = new float *[r * 4];
301
                 for (unsigned int tmp = 0; tmp < (r * 4); tmp++)
281
                 for (unsigned int tmp = 0; tmp < (r * 4); tmp++)
304
 
284
 
305
             r = rectangle_counter_alpha[i];
285
             r = rectangle_counter_alpha[i];
306
 
286
 
307
-            if (r > 0)
308
-            {
287
+            if (r > 0) {
309
                 mesh.mQuads[j].num_alpha_quads = r;
288
                 mesh.mQuads[j].num_alpha_quads = r;
310
-                mesh.mQuads[j].alpha_quads = new unsigned int[r*4];
289
+                mesh.mQuads[j].alpha_quads = new unsigned int[r * 4];
311
                 mesh.mQuads[j].num_texcoors2 = r * 4;
290
                 mesh.mQuads[j].num_texcoors2 = r * 4;
312
                 mesh.mQuads[j].texcoors2 = new float *[r * 4];
291
                 mesh.mQuads[j].texcoors2 = new float *[r * 4];
313
                 for (unsigned int tmp = 0; tmp < (r * 4); tmp++)
292
                 for (unsigned int tmp = 0; tmp < (r * 4); tmp++)
319
     // Generate textured triangles
298
     // Generate textured triangles
320
     count = tr.getRoomTriangleCount(index);
299
     count = tr.getRoomTriangleCount(index);
321
 
300
 
322
-    for (t = 0; t < count; ++t)
323
-    {
301
+    for (t = 0; t < count; ++t) {
324
         tr.getRoomTriangle(index, t,
302
         tr.getRoomTriangle(index, t,
325
-                indices, texCoords, &texture, &flags);
303
+                           indices, texCoords, &texture, &flags);
326
 
304
 
327
         // Adjust texture id using getGame().getTextureStart() to map into
305
         // Adjust texture id using getGame().getTextureStart() to map into
328
         // correct textures
306
         // correct textures
331
         unsigned int j = tris_mesh_map[texture] - 1;
309
         unsigned int j = tris_mesh_map[texture] - 1;
332
 
310
 
333
         // Setup per vertex
311
         // Setup per vertex
334
-        for (unsigned int i = 0; i < 3; ++i)
335
-        {
312
+        for (unsigned int i = 0; i < 3; ++i) {
336
             // Get vertex index {(0, a), (1, b), (2, c)}
313
             // Get vertex index {(0, a), (1, b), (2, c)}
337
             v = indices[i];
314
             v = indices[i];
338
 
315
 
339
             if ((flags & tombraiderFace_Alpha ||
316
             if ((flags & tombraiderFace_Alpha ||
340
-                        flags & tombraiderFace_PartialAlpha) &&
341
-                    mesh.mTris[j].num_alpha_triangles > 0)
342
-            {
343
-                q = mesh.mTris[j].cnum_alpha_triangles*3+i;
317
+                 flags & tombraiderFace_PartialAlpha) &&
318
+                mesh.mTris[j].num_alpha_triangles > 0) {
319
+                q = mesh.mTris[j].cnum_alpha_triangles * 3 + i;
344
 
320
 
345
                 mesh.mTris[j].alpha_triangles[q] = v;
321
                 mesh.mTris[j].alpha_triangles[q] = v;
346
 
322
 
347
-                mesh.mTris[j].texcoors2[q][0] = texCoords[i*2];
348
-                mesh.mTris[j].texcoors2[q][1] = texCoords[i*2+1];
349
-            }
350
-            else if (mesh.mTris[j].num_triangles > 0)
351
-            {
352
-                q = mesh.mTris[j].cnum_triangles*3+i;
323
+                mesh.mTris[j].texcoors2[q][0] = texCoords[i * 2];
324
+                mesh.mTris[j].texcoors2[q][1] = texCoords[i * 2 + 1];
325
+            } else if (mesh.mTris[j].num_triangles > 0) {
326
+                q = mesh.mTris[j].cnum_triangles * 3 + i;
353
 
327
 
354
                 mesh.mTris[j].triangles[q] = v;
328
                 mesh.mTris[j].triangles[q] = v;
355
 
329
 
356
-                mesh.mTris[j].texcoors[q][0] = texCoords[i*2];
357
-                mesh.mTris[j].texcoors[q][1] = texCoords[i*2+1];
330
+                mesh.mTris[j].texcoors[q][0] = texCoords[i * 2];
331
+                mesh.mTris[j].texcoors[q][1] = texCoords[i * 2 + 1];
358
             }
332
             }
359
 
333
 
360
             // Partial alpha hack
334
             // Partial alpha hack
361
-            if (flags & tombraiderFace_PartialAlpha)
362
-            {
335
+            if (flags & tombraiderFace_PartialAlpha) {
363
                 //mesh.colors[v].rgba[3] = 0.45;
336
                 //mesh.colors[v].rgba[3] = 0.45;
364
             }
337
             }
365
         }
338
         }
366
 
339
 
367
         if (flags & tombraiderFace_Alpha ||
340
         if (flags & tombraiderFace_Alpha ||
368
-                flags & tombraiderFace_PartialAlpha)
369
-        {
341
+            flags & tombraiderFace_PartialAlpha) {
370
             mesh.mTris[j].cnum_alpha_triangles++;
342
             mesh.mTris[j].cnum_alpha_triangles++;
371
-        }
372
-        else
373
-        {
343
+        } else {
374
             mesh.mTris[j].cnum_triangles++;
344
             mesh.mTris[j].cnum_triangles++;
375
         }
345
         }
376
     }
346
     }
378
     // Generate textured quads
348
     // Generate textured quads
379
     count = tr.getRoomRectangleCount(index);
349
     count = tr.getRoomRectangleCount(index);
380
 
350
 
381
-    for (r = 0; r < count; ++r)
382
-    {
351
+    for (r = 0; r < count; ++r) {
383
         tr.getRoomRectangle(index, r,
352
         tr.getRoomRectangle(index, r,
384
-                indices, texCoords, &texture, &flags);
353
+                            indices, texCoords, &texture, &flags);
385
 
354
 
386
         // Adjust texture id using getGame().getTextureStart() to map into
355
         // Adjust texture id using getGame().getTextureStart() to map into
387
         // correct textures
356
         // correct textures
388
         texture += getGame().getTextureStart();
357
         texture += getGame().getTextureStart();
389
 
358
 
390
-        if (texture > (int)TextureLimit)
391
-        {
359
+        if (texture > (int)TextureLimit) {
392
             texture = TextureLimit - 1;
360
             texture = TextureLimit - 1;
393
         }
361
         }
394
 
362
 
395
         unsigned int j = rect_mesh_map[texture] - 1;
363
         unsigned int j = rect_mesh_map[texture] - 1;
396
 
364
 
397
         if (mesh.mQuads[j].num_quads <= 0 &&
365
         if (mesh.mQuads[j].num_quads <= 0 &&
398
-                mesh.mQuads[j].num_alpha_quads <= 0)
366
+            mesh.mQuads[j].num_alpha_quads <= 0)
399
             continue;
367
             continue;
400
 
368
 
401
         // Setup per vertex
369
         // Setup per vertex
402
-        for (unsigned int i = 0; i < 4; ++i)
403
-        {
370
+        for (unsigned int i = 0; i < 4; ++i) {
404
             // Get vertex index {(0, a), (1, b), (2, c), (3, d)}
371
             // Get vertex index {(0, a), (1, b), (2, c), (3, d)}
405
             v = indices[i];
372
             v = indices[i];
406
 
373
 
407
             if ((flags & tombraiderFace_Alpha ||
374
             if ((flags & tombraiderFace_Alpha ||
408
-                        flags & tombraiderFace_PartialAlpha) &&
409
-                    mesh.mQuads[j].num_alpha_quads > 0)
410
-            {
411
-                q = mesh.mQuads[j].cnum_alpha_quads*4+i;
375
+                 flags & tombraiderFace_PartialAlpha) &&
376
+                mesh.mQuads[j].num_alpha_quads > 0) {
377
+                q = mesh.mQuads[j].cnum_alpha_quads * 4 + i;
412
 
378
 
413
                 mesh.mQuads[j].alpha_quads[q] = v;
379
                 mesh.mQuads[j].alpha_quads[q] = v;
414
 
380
 
415
-                mesh.mQuads[j].texcoors2[q][0] = texCoords[i*2];
416
-                mesh.mQuads[j].texcoors2[q][1] = texCoords[i*2+1];
417
-            }
418
-            else if (mesh.mQuads[j].num_quads > 0)
419
-            {
420
-                q = mesh.mQuads[j].cnum_quads*4+i;
381
+                mesh.mQuads[j].texcoors2[q][0] = texCoords[i * 2];
382
+                mesh.mQuads[j].texcoors2[q][1] = texCoords[i * 2 + 1];
383
+            } else if (mesh.mQuads[j].num_quads > 0) {
384
+                q = mesh.mQuads[j].cnum_quads * 4 + i;
421
 
385
 
422
                 mesh.mQuads[j].quads[q] = v;
386
                 mesh.mQuads[j].quads[q] = v;
423
 
387
 
424
-                mesh.mQuads[j].texcoors[q][0] = texCoords[i*2];
425
-                mesh.mQuads[j].texcoors[q][1] = texCoords[i*2+1];
388
+                mesh.mQuads[j].texcoors[q][0] = texCoords[i * 2];
389
+                mesh.mQuads[j].texcoors[q][1] = texCoords[i * 2 + 1];
426
             }
390
             }
427
 
391
 
428
             // Partial alpha hack
392
             // Partial alpha hack
429
-            if (flags & tombraiderFace_PartialAlpha)
430
-            {
393
+            if (flags & tombraiderFace_PartialAlpha) {
431
                 //rRoom->mesh.colors[v].rgba[3] = 0.45;
394
                 //rRoom->mesh.colors[v].rgba[3] = 0.45;
432
             }
395
             }
433
         }
396
         }
434
 
397
 
435
         if (flags & tombraiderFace_Alpha ||
398
         if (flags & tombraiderFace_Alpha ||
436
-                flags & tombraiderFace_PartialAlpha)
437
-        {
399
+            flags & tombraiderFace_PartialAlpha) {
438
             mesh.mQuads[j].cnum_alpha_quads++;
400
             mesh.mQuads[j].cnum_alpha_quads++;
439
-        }
440
-        else
441
-        {
401
+        } else {
442
             mesh.mQuads[j].cnum_quads++;
402
             mesh.mQuads[j].cnum_quads++;
443
         }
403
         }
444
     }
404
     }
471
         glColor3ubv(RED);
431
         glColor3ubv(RED);
472
 
432
 
473
         for (unsigned int i = 0; i < sizePortals(); i++) {
433
         for (unsigned int i = 0; i < sizePortals(); i++) {
474
-            Portal &portal = getPortal(i);
434
+            Portal& portal = getPortal(i);
475
             float vertices[4][3];
435
             float vertices[4][3];
476
             portal.getVertices(vertices);
436
             portal.getVertices(vertices);
477
 
437
 
495
     // Reset since GL_MODULATE used, reset to WHITE
455
     // Reset since GL_MODULATE used, reset to WHITE
496
     glColor3ubv(WHITE);
456
     glColor3ubv(WHITE);
497
 
457
 
498
-    switch (getRender().getMode())
499
-    {
458
+    switch (getRender().getMode()) {
500
         case Render::modeWireframe:
459
         case Render::modeWireframe:
501
             getMesh().mMode = Mesh::MeshModeWireframe;
460
             getMesh().mMode = Mesh::MeshModeWireframe;
502
             break;
461
             break;
517
 
476
 
518
     // Draw other room meshes and sprites
477
     // Draw other room meshes and sprites
519
     if (alpha || (getRender().getMode() == Render::modeWireframe)
478
     if (alpha || (getRender().getMode() == Render::modeWireframe)
520
-            || (getRender().getMode() == Render::modeSolid)) {
479
+        || (getRender().getMode() == Render::modeSolid)) {
521
         sortModels();
480
         sortModels();
522
         for (unsigned int i = 0; i < sizeModels(); i++)
481
         for (unsigned int i = 0; i < sizeModels(); i++)
523
             getModel(i).display();
482
             getModel(i).display();
534
     return ((sector > 0) && sectors.at(sector)->isWall());
493
     return ((sector > 0) && sectors.at(sector)->isWall());
535
 }
494
 }
536
 
495
 
537
-long Room::getSector(float x, float z, float *floor, float *ceiling) {
496
+long Room::getSector(float x, float z, float* floor, float* ceiling) {
538
     assert(floor != NULL);
497
     assert(floor != NULL);
539
     assert(ceiling != NULL);
498
     assert(ceiling != NULL);
540
 
499
 
550
 
509
 
551
 long Room::getSector(float x, float z) {
510
 long Room::getSector(float x, float z) {
552
     long sector = (((((int)x - (int)pos[0]) / 1024) *
511
     long sector = (((((int)x - (int)pos[0]) / 1024) *
553
-        numZSectors) + (((int)z - (int)pos[2]) / 1024));
512
+                    numZSectors) + (((int)z - (int)pos[2]) / 1024));
554
 
513
 
555
     if (sector < 0)
514
     if (sector < 0)
556
         return -1;
515
         return -1;
558
     return sector;
517
     return sector;
559
 }
518
 }
560
 
519
 
561
-void Room::getHeightAtPosition(float x, float *y, float z) {
520
+void Room::getHeightAtPosition(float x, float* y, float z) {
562
     long sector = getSector(x, z);
521
     long sector = getSector(x, z);
563
     if ((sector >= 0) && (sector < (long)sectors.size()))
522
     if ((sector >= 0) && (sector < (long)sectors.size()))
564
         *y = sectors.at(sector)->getFloor();
523
         *y = sectors.at(sector)->getFloor();
565
 }
524
 }
566
 
525
 
567
 int Room::getAdjoiningRoom(float x, float y, float z,
526
 int Room::getAdjoiningRoom(float x, float y, float z,
568
-        float x2, float y2, float z2) {
527
+                           float x2, float y2, float z2) {
569
     float intersect[3], p1[3], p2[3];
528
     float intersect[3], p1[3], p2[3];
570
     float vertices[4][3];
529
     float vertices[4][3];
571
 
530
 
575
     for (unsigned long i = 0; i < portals.size(); i++) {
534
     for (unsigned long i = 0; i < portals.size(); i++) {
576
         portals.at(i)->getVertices(vertices);
535
         portals.at(i)->getVertices(vertices);
577
         if (intersectionLinePolygon(intersect, p1, p2, //4,
536
         if (intersectionLinePolygon(intersect, p1, p2, //4,
578
-                    vertices))
537
+                                    vertices))
579
             return portals.at(i)->getAdjoiningRoom();
538
             return portals.at(i)->getAdjoiningRoom();
580
     }
539
     }
581
 
540
 
612
     return portals.size();
571
     return portals.size();
613
 }
572
 }
614
 
573
 
615
-Portal &Room::getPortal(unsigned long index) {
574
+Portal& Room::getPortal(unsigned long index) {
616
     assert(index < portals.size());
575
     assert(index < portals.size());
617
     return *portals.at(index);
576
     return *portals.at(index);
618
 }
577
 }
621
     return sectors.size();
580
     return sectors.size();
622
 }
581
 }
623
 
582
 
624
-Sector &Room::getSector(unsigned long index) {
583
+Sector& Room::getSector(unsigned long index) {
625
     assert(index < sectors.size());
584
     assert(index < sectors.size());
626
     return *sectors.at(index);
585
     return *sectors.at(index);
627
 }
586
 }
630
     return boxes.size();
589
     return boxes.size();
631
 }
590
 }
632
 
591
 
633
-Box &Room::getBox(unsigned long index) {
592
+Box& Room::getBox(unsigned long index) {
634
     assert(index < boxes.size());
593
     assert(index < boxes.size());
635
     return *boxes.at(index);
594
     return *boxes.at(index);
636
 }
595
 }
639
     return models.size();
598
     return models.size();
640
 }
599
 }
641
 
600
 
642
-StaticModel &Room::getModel(unsigned long index) {
601
+StaticModel& Room::getModel(unsigned long index) {
643
     assert(index < models.size());
602
     assert(index < models.size());
644
     return *models.at(index);
603
     return *models.at(index);
645
 }
604
 }
652
     return lights.size();
611
     return lights.size();
653
 }
612
 }
654
 
613
 
655
-Light &Room::getLight(unsigned long index) {
614
+Light& Room::getLight(unsigned long index) {
656
     assert(index < lights.size());
615
     assert(index < lights.size());
657
     return *lights.at(index);
616
     return *lights.at(index);
658
 }
617
 }
661
     return sprites.size();
620
     return sprites.size();
662
 }
621
 }
663
 
622
 
664
-Sprite &Room::getSprite(unsigned long index) {
623
+Sprite& Room::getSprite(unsigned long index) {
665
     assert(index < sprites.size());
624
     assert(index < sprites.size());
666
     return *sprites.at(index);
625
     return *sprites.at(index);
667
 }
626
 }
668
 
627
 
669
-BoundingBox &Room::getBoundingBox() {
628
+BoundingBox& Room::getBoundingBox() {
670
     return bbox;
629
     return bbox;
671
 }
630
 }
672
 
631
 
673
-Mesh &Room::getMesh() {
632
+Mesh& Room::getMesh() {
674
     return mesh;
633
     return mesh;
675
 }
634
 }
676
 
635
 

+ 15
- 16
src/RoomData.cpp View File

56
     glVertex3f(b[0], b[1], b[2]);
56
     glVertex3f(b[0], b[1], b[2]);
57
     glVertex3f(a[0], a[1], a[2]);
57
     glVertex3f(a[0], a[1], a[2]);
58
 
58
 
59
-    if (points)
60
-    {
59
+    if (points) {
61
         glVertex3f(b[0], a[1], b[2]);
60
         glVertex3f(b[0], a[1], b[2]);
62
         glVertex3f(a[0], b[1], b[2]);
61
         glVertex3f(a[0], b[1], b[2]);
63
         glVertex3f(b[0], b[1], a[2]);
62
         glVertex3f(b[0], b[1], a[2]);
119
 
118
 
120
 // ----------------------------------------------------------------------------
119
 // ----------------------------------------------------------------------------
121
 
120
 
122
-Light::Light(TombRaider &tr, unsigned int room, unsigned int index) {
121
+Light::Light(TombRaider& tr, unsigned int room, unsigned int index) {
123
     unsigned int lightFlags, lightType;
122
     unsigned int lightFlags, lightType;
124
 
123
 
125
     tr.getRoomLight(room, index, pos, color,
124
     tr.getRoomLight(room, index, pos, color,
126
-            dir, &att, &cutoff, &lightType, &lightFlags);
125
+                    dir, &att, &cutoff, &lightType, &lightFlags);
127
 
126
 
128
     switch (lightType) {
127
     switch (lightType) {
129
         case tombraiderLight_typeDirectional:
128
         case tombraiderLight_typeDirectional:
174
 
173
 
175
 // ----------------------------------------------------------------------------
174
 // ----------------------------------------------------------------------------
176
 
175
 
177
-StaticModel::StaticModel(TombRaider &tr, unsigned int room, unsigned int i) {
176
+StaticModel::StaticModel(TombRaider& tr, unsigned int room, unsigned int i) {
178
     tr.getRoomModel(room, i, &index, pos, &yaw);
177
     tr.getRoomModel(room, i, &index, pos, &yaw);
179
 }
178
 }
180
 
179
 
181
 void StaticModel::display() {
180
 void StaticModel::display() {
182
-    StaticMesh &mesh = getWorld().getStaticMesh(index);
181
+    StaticMesh& mesh = getWorld().getStaticMesh(index);
183
 
182
 
184
     if (!getRender().isVisible(pos[0], pos[1], pos[2], mesh.getRadius()))
183
     if (!getRender().isVisible(pos[0], pos[1], pos[2], mesh.getRadius()))
185
         return;
184
         return;
191
     glPopMatrix();
190
     glPopMatrix();
192
 }
191
 }
193
 
192
 
194
-bool StaticModel::operator<(const StaticModel &other) {
193
+bool StaticModel::operator<(const StaticModel& other) {
195
     float distA, distB;
194
     float distA, distB;
196
     distA = getRender().mViewVolume.getDistToSphereFromNear(pos[0],
195
     distA = getRender().mViewVolume.getDistToSphereFromNear(pos[0],
197
             pos[1], pos[2], 128.0f);
196
             pos[1], pos[2], 128.0f);
200
     return (distA < distB);
199
     return (distA < distB);
201
 }
200
 }
202
 
201
 
203
-bool StaticModel::compare(StaticModel *a, StaticModel *b) {
202
+bool StaticModel::compare(StaticModel* a, StaticModel* b) {
204
     return (*b) < (*a);
203
     return (*b) < (*a);
205
 }
204
 }
206
 
205
 
207
 // ----------------------------------------------------------------------------
206
 // ----------------------------------------------------------------------------
208
 
207
 
209
-Portal::Portal(TombRaider &tr, unsigned int room, unsigned int index, Matrix &transform) {
208
+Portal::Portal(TombRaider& tr, unsigned int room, unsigned int index, Matrix& transform) {
210
     float portalVertices[12];
209
     float portalVertices[12];
211
     tr.getRoomPortal(room, index, &adjoiningRoom, normal, portalVertices);
210
     tr.getRoomPortal(room, index, &adjoiningRoom, normal, portalVertices);
212
     for (unsigned int j = 0; j < 4; ++j) {
211
     for (unsigned int j = 0; j < 4; ++j) {
213
-        vertices[j][0] = portalVertices[j*3];
214
-        vertices[j][1] = portalVertices[j*3+1];
215
-        vertices[j][2] = portalVertices[j*3+2];
212
+        vertices[j][0] = portalVertices[j * 3];
213
+        vertices[j][1] = portalVertices[j * 3 + 1];
214
+        vertices[j][2] = portalVertices[j * 3 + 2];
216
 
215
 
217
         // Relative coors in vis portals
216
         // Relative coors in vis portals
218
         transform.multiply3v(vertices[j], vertices[j]);
217
         transform.multiply3v(vertices[j], vertices[j]);
233
 
232
 
234
 // ----------------------------------------------------------------------------
233
 // ----------------------------------------------------------------------------
235
 
234
 
236
-Box::Box(TombRaider &tr, unsigned int room, unsigned int index) {
235
+Box::Box(TombRaider& tr, unsigned int room, unsigned int index) {
237
     tr.getRoomBox(room, index, a, b, c, d);
236
     tr.getRoomBox(room, index, a, b, c, d);
238
 }
237
 }
239
 
238
 
240
 // ----------------------------------------------------------------------------
239
 // ----------------------------------------------------------------------------
241
 
240
 
242
-Sector::Sector(TombRaider &tr, unsigned int room, unsigned int index) {
241
+Sector::Sector(TombRaider& tr, unsigned int room, unsigned int index) {
243
     unsigned int sectorFlags;
242
     unsigned int sectorFlags;
244
     int floorDataIndex, boxIndex, roomBelow, roomAbove;
243
     int floorDataIndex, boxIndex, roomBelow, roomAbove;
245
 
244
 
246
     tr.getRoomSector(room, index, &sectorFlags,
245
     tr.getRoomSector(room, index, &sectorFlags,
247
-            &ceiling, &floor, &floorDataIndex, &boxIndex,
248
-            &roomBelow, &roomAbove);
246
+                     &ceiling, &floor, &floorDataIndex, &boxIndex,
247
+                     &roomBelow, &roomAbove);
249
 
248
 
250
     wall = (sectorFlags & tombraiderSector_wall);
249
     wall = (sectorFlags & tombraiderSector_wall);
251
 }
250
 }

+ 9
- 8
src/Script.cpp View File

15
 
15
 
16
 }
16
 }
17
 
17
 
18
-int Script::load(const char *file) {
18
+int Script::load(const char* file) {
19
     BinaryFile f;
19
     BinaryFile f;
20
 
20
 
21
     if (f.open(file) != 0)
21
     if (f.open(file) != 0)
96
     return 0;
96
     return 0;
97
 }
97
 }
98
 
98
 
99
-void Script::readStringPackage(BinaryFile &f, std::vector<std::string> &v, unsigned int n) {
100
-    uint16_t *offset = new uint16_t[n];
99
+void Script::readStringPackage(BinaryFile& f, std::vector<std::string>& v, unsigned int n) {
100
+    uint16_t* offset = new uint16_t[n];
101
     for (unsigned int i = 0; i < n; i++)
101
     for (unsigned int i = 0; i < n; i++)
102
         offset[i] = f.readU16();
102
         offset[i] = f.readU16();
103
 
103
 
104
     uint16_t numBytes = f.readU16();
104
     uint16_t numBytes = f.readU16();
105
 
105
 
106
-    char *list = new char[numBytes];
106
+    char* list = new char[numBytes];
107
     for (uint16_t i = 0; i < numBytes; i++) {
107
     for (uint16_t i = 0; i < numBytes; i++) {
108
         list[i] = f.read8();
108
         list[i] = f.read8();
109
         if (flags & S_UseSecurityTag) {
109
         if (flags & S_UseSecurityTag) {
120
     delete [] offset;
120
     delete [] offset;
121
 }
121
 }
122
 
122
 
123
-void Script::readScriptPackage(BinaryFile &f, std::vector<std::vector<uint16_t>> &v, unsigned int n) {
124
-    uint16_t *offset = new uint16_t[n];
123
+void Script::readScriptPackage(BinaryFile& f, std::vector<std::vector<uint16_t>>& v,
124
+                               unsigned int n) {
125
+    uint16_t* offset = new uint16_t[n];
125
     for (unsigned int i = 0; i < n; i++) {
126
     for (unsigned int i = 0; i < n; i++) {
126
         offset[i] = f.readU16();
127
         offset[i] = f.readU16();
127
         assertEqual(offset[i] % 2, 0);
128
         assertEqual(offset[i] % 2, 0);
130
     uint16_t numBytes = f.readU16();
131
     uint16_t numBytes = f.readU16();
131
     assertEqual(numBytes % 2, 0); // 16 bit opcodes and operands
132
     assertEqual(numBytes % 2, 0); // 16 bit opcodes and operands
132
 
133
 
133
-    uint16_t *list = new uint16_t[(numBytes + 6) / 2];
134
+    uint16_t* list = new uint16_t[(numBytes + 6) / 2];
134
     for (uint16_t i = 0; i < (numBytes / 2); i++) {
135
     for (uint16_t i = 0; i < (numBytes / 2); i++) {
135
         list[i] = f.readU16();
136
         list[i] = f.readU16();
136
     }
137
     }
143
     hack[1] = f.readU16();
144
     hack[1] = f.readU16();
144
     hack[2] = f.readU16();
145
     hack[2] = f.readU16();
145
     if (((hack[0] == 19) && (hack[1] == 20) && (hack[2] == 21))
146
     if (((hack[0] == 19) && (hack[1] == 20) && (hack[2] == 21))
146
-            || ((hack[0] == 21) && (hack[1] == 22) && (hack[2] == 23))) {
147
+        || ((hack[0] == 21) && (hack[1] == 22) && (hack[2] == 23))) {
147
         list[numBytes / 2] = hack[0];
148
         list[numBytes / 2] = hack[0];
148
         list[(numBytes / 2) + 1] = hack[1];
149
         list[(numBytes / 2) + 1] = hack[1];
149
         list[(numBytes / 2) + 2] = hack[2];
150
         list[(numBytes / 2) + 2] = hack[2];

+ 30
- 28
src/SkeletalModel.cpp View File

12
 #include "SkeletalModel.h"
12
 #include "SkeletalModel.h"
13
 #include "World.h"
13
 #include "World.h"
14
 
14
 
15
-BoneTag::BoneTag(TombRaider &tr, unsigned int index, unsigned int i, unsigned int *l, unsigned int frame_offset) {
16
-    tr2_moveable_t *moveable = tr.Moveable();
17
-    tr2_meshtree_t *meshtree = tr.MeshTree();
18
-    unsigned short *frame = tr.Frame();
15
+BoneTag::BoneTag(TombRaider& tr, unsigned int index, unsigned int i, unsigned int* l,
16
+                 unsigned int frame_offset) {
17
+    tr2_moveable_t* moveable = tr.Moveable();
18
+    tr2_meshtree_t* meshtree = tr.MeshTree();
19
+    unsigned short* frame = tr.Frame();
19
 
20
 
20
     off[0] = 0.0f;
21
     off[0] = 0.0f;
21
     off[1] = 0.0f;
22
     off[1] = 0.0f;
34
 
35
 
35
         // Hack: moveable[index].mesh_tree is a byte offset
36
         // Hack: moveable[index].mesh_tree is a byte offset
36
         //       into mesh_tree[], so we have to convert to index
37
         //       into mesh_tree[], so we have to convert to index
37
-        int *tree = (int *)(void *)meshtree;
38
-        tr2_meshtree_t *mesh_tree = (tr2_meshtree_t *)(tree
39
-                + moveable[index].mesh_tree + ((i - 1) * 4));
38
+        int* tree = (int*)(void*)meshtree;
39
+        tr2_meshtree_t* mesh_tree = (tr2_meshtree_t*)(tree
40
+                                    + moveable[index].mesh_tree + ((i - 1) * 4));
40
 
41
 
41
         off[0] = mesh_tree->x;
42
         off[0] = mesh_tree->x;
42
         off[1] = mesh_tree->y;
43
         off[1] = mesh_tree->y;
68
     return flag;
69
     return flag;
69
 }
70
 }
70
 
71
 
71
-BoneFrame::BoneFrame(TombRaider &tr, unsigned int index, unsigned int frame_offset) {
72
-    tr2_moveable_t *moveable = tr.Moveable();
73
-    unsigned short *frame = tr.Frame();
72
+BoneFrame::BoneFrame(TombRaider& tr, unsigned int index, unsigned int frame_offset) {
73
+    tr2_moveable_t* moveable = tr.Moveable();
74
+    unsigned short* frame = tr.Frame();
74
 
75
 
75
     pos[0] = (short)frame[frame_offset + 6];
76
     pos[0] = (short)frame[frame_offset + 6];
76
     pos[1] = (short)frame[frame_offset + 7];
77
     pos[1] = (short)frame[frame_offset + 7];
91
     return tag.size();
92
     return tag.size();
92
 }
93
 }
93
 
94
 
94
-BoneTag &BoneFrame::get(unsigned long i) {
95
+BoneTag& BoneFrame::get(unsigned long i) {
95
     assert(i < tag.size());
96
     assert(i < tag.size());
96
     return *tag.at(i);
97
     return *tag.at(i);
97
 }
98
 }
102
     p[2] = pos[2];
103
     p[2] = pos[2];
103
 }
104
 }
104
 
105
 
105
-AnimationFrame::AnimationFrame(TombRaider &tr, unsigned int index, int a, unsigned int *frame_offset, int frame_step) {
106
-    tr2_moveable_t *moveable = tr.Moveable();
107
-    tr2_animation_t *animation = tr.Animation();
106
+AnimationFrame::AnimationFrame(TombRaider& tr, unsigned int index, int a,
107
+                               unsigned int* frame_offset, int frame_step) {
108
+    tr2_moveable_t* moveable = tr.Moveable();
109
+    tr2_animation_t* animation = tr.Animation();
108
 
110
 
109
     unsigned int frame_count = (animation[a].frame_end - animation[a].frame_start) + 1;
111
     unsigned int frame_count = (animation[a].frame_end - animation[a].frame_start) + 1;
110
     rate = animation[a].frame_rate;
112
     rate = animation[a].frame_rate;
138
 
140
 
139
         if (*frame_offset > tr.NumFrames()) {
141
         if (*frame_offset > tr.NumFrames()) {
140
             getLog() << "WARNING: Bad animation frame " << *frame_offset
142
             getLog() << "WARNING: Bad animation frame " << *frame_offset
141
-                << " > " << tr.NumFrames() << " (" << index << "." << a << ")"
142
-                << Log::endl;
143
+                     << " > " << tr.NumFrames() << " (" << index << "." << a << ")"
144
+                     << Log::endl;
143
             return;
145
             return;
144
         }
146
         }
145
 
147
 
156
     return frame.size();
158
     return frame.size();
157
 }
159
 }
158
 
160
 
159
-BoneFrame &AnimationFrame::get(unsigned long i) {
161
+BoneFrame& AnimationFrame::get(unsigned long i) {
160
     assert(i < frame.size());
162
     assert(i < frame.size());
161
     return *frame.at(i);
163
     return *frame.at(i);
162
 }
164
 }
163
 
165
 
164
-SkeletalModel::SkeletalModel(TombRaider &tr, unsigned int index, int objectId) {
165
-    tr2_moveable_t *moveable = tr.Moveable();
166
-    tr2_animation_t *anim = tr.Animation();
167
-    tr2_mesh_t *mesh = tr.Mesh();
166
+SkeletalModel::SkeletalModel(TombRaider& tr, unsigned int index, int objectId) {
167
+    tr2_moveable_t* moveable = tr.Moveable();
168
+    tr2_animation_t* anim = tr.Animation();
169
+    tr2_mesh_t* mesh = tr.Mesh();
168
 
170
 
169
     id = objectId;
171
     id = objectId;
170
 
172
 
184
                 ponytailId = getWorld().sizeSkeletalModel(); //! \fixme Why is this even needed?
186
                 ponytailId = getWorld().sizeSkeletalModel(); //! \fixme Why is this even needed?
185
                 ponytailMeshId = moveable[index].starting_mesh;
187
                 ponytailMeshId = moveable[index].starting_mesh;
186
                 ponytailNumMeshes = ((moveable[index].num_meshes > 0) ?
188
                 ponytailNumMeshes = ((moveable[index].num_meshes > 0) ?
187
-                        moveable[index].num_meshes : 0);
189
+                                     moveable[index].num_meshes : 0);
188
                 ponytailAngle = -90.0f;
190
                 ponytailAngle = -90.0f;
189
                 ponytail[0] = -3;
191
                 ponytail[0] = -3;
190
                 ponytail[1] = -22;
192
                 ponytail[1] = -22;
214
                 ponytailId = getWorld().sizeSkeletalModel(); //! \fixme Why is this even needed?
216
                 ponytailId = getWorld().sizeSkeletalModel(); //! \fixme Why is this even needed?
215
                 ponytailMeshId = moveable[index].starting_mesh;
217
                 ponytailMeshId = moveable[index].starting_mesh;
216
                 ponytailNumMeshes = ((moveable[index].num_meshes > 0) ?
218
                 ponytailNumMeshes = ((moveable[index].num_meshes > 0) ?
217
-                        moveable[index].num_meshes : 0);
219
+                                     moveable[index].num_meshes : 0);
218
                 ponytailAngle = -90.0f;
220
                 ponytailAngle = -90.0f;
219
                 ponytail[0] = 0;
221
                 ponytail[0] = 0;
220
                 ponytail[1] = -20;
222
                 ponytail[1] = -20;
271
     assert(aframe < size());
273
     assert(aframe < size());
272
     assert(bframe < get(aframe).size());
274
     assert(bframe < get(aframe).size());
273
 
275
 
274
-    AnimationFrame &anim = get(aframe);
275
-    BoneFrame &boneframe = anim.get(bframe);
276
+    AnimationFrame& anim = get(aframe);
277
+    BoneFrame& boneframe = anim.get(bframe);
276
 
278
 
277
     float pos[3];
279
     float pos[3];
278
     boneframe.getPosition(pos);
280
     boneframe.getPosition(pos);
279
     glTranslatef(pos[0], pos[1], pos[2]);
281
     glTranslatef(pos[0], pos[1], pos[2]);
280
 
282
 
281
     for (unsigned int a = 0; a < boneframe.size(); a++) {
283
     for (unsigned int a = 0; a < boneframe.size(); a++) {
282
-        BoneTag &tag = boneframe.get(a);
284
+        BoneTag& tag = boneframe.get(a);
283
         float rot[3], off[3];
285
         float rot[3], off[3];
284
 
286
 
285
         tag.getRotation(rot);
287
         tag.getRotation(rot);
304
 
306
 
305
         // Draw layered lara in TR4 (2 meshes per tag)
307
         // Draw layered lara in TR4 (2 meshes per tag)
306
         if (tr4Overlay) {
308
         if (tr4Overlay) {
307
-            BoneFrame &boneframe2 = get(0).get(0); //! \fixme Woot?
309
+            BoneFrame& boneframe2 = get(0).get(0); //! \fixme Woot?
308
             if (a < boneframe2.size())
310
             if (a < boneframe2.size())
309
                 boneframe2.get(a).display();
311
                 boneframe2.get(a).display();
310
         }
312
         }
387
     return animation.size();
389
     return animation.size();
388
 }
390
 }
389
 
391
 
390
-AnimationFrame &SkeletalModel::get(unsigned long i) {
392
+AnimationFrame& SkeletalModel::get(unsigned long i) {
391
     assert(i < animation.size());
393
     assert(i < animation.size());
392
     return *animation.at(i);
394
     return *animation.at(i);
393
 }
395
 }

+ 7
- 6
src/SoundAL.cpp View File

40
     if (!mEnabled)
40
     if (!mEnabled)
41
         return 0;
41
         return 0;
42
 
42
 
43
-    ALCdevice *Device = alcOpenDevice(NULL);
44
-    ALCcontext *Context = alcCreateContext(Device, NULL);
43
+    ALCdevice* Device = alcOpenDevice(NULL);
44
+    ALCcontext* Context = alcCreateContext(Device, NULL);
45
     alcMakeContextCurrent(Context);
45
     alcMakeContextCurrent(Context);
46
 
46
 
47
     if (alutInitWithoutContext(NULL, NULL) == AL_FALSE) {
47
     if (alutInitWithoutContext(NULL, NULL) == AL_FALSE) {
120
 }
120
 }
121
 
121
 
122
 //! \fixme Seperate sourcing and buffering, Mongoose 2002.01.04
122
 //! \fixme Seperate sourcing and buffering, Mongoose 2002.01.04
123
-int SoundAL::addFile(const char *filename, unsigned long *source, unsigned int flags) {
123
+int SoundAL::addFile(const char* filename, unsigned long* source, unsigned int flags) {
124
     ALsizei size;
124
     ALsizei size;
125
     ALfloat freq;
125
     ALfloat freq;
126
     ALenum format;
126
     ALenum format;
127
-    ALvoid *data;
127
+    ALvoid* data;
128
     unsigned long id;
128
     unsigned long id;
129
 
129
 
130
     assert(mSource.size() == mBuffer.size());
130
     assert(mSource.size() == mBuffer.size());
176
     return 0;
176
     return 0;
177
 }
177
 }
178
 
178
 
179
-int SoundAL::addWave(unsigned char *wav, unsigned int length, unsigned long *source, unsigned int flags) {
179
+int SoundAL::addWave(unsigned char* wav, unsigned int length, unsigned long* source,
180
+                     unsigned int flags) {
180
     ALsizei size;
181
     ALsizei size;
181
     ALfloat freq;
182
     ALfloat freq;
182
     ALenum format;
183
     ALenum format;
183
-    ALvoid *data;
184
+    ALvoid* data;
184
     int error = 0;
185
     int error = 0;
185
     unsigned long id;
186
     unsigned long id;
186
 
187
 

+ 3
- 2
src/SoundNull.cpp View File

40
     assert(source < sources);
40
     assert(source < sources);
41
 }
41
 }
42
 
42
 
43
-int SoundNull::addFile(const char *filename, unsigned long *source, unsigned int flags) {
43
+int SoundNull::addFile(const char* filename, unsigned long* source, unsigned int flags) {
44
     *source = sources;
44
     *source = sources;
45
     sources++;
45
     sources++;
46
     return 0;
46
     return 0;
47
 }
47
 }
48
 
48
 
49
-int SoundNull::addWave(unsigned char *wav, unsigned int length, unsigned long *source, unsigned int flags) {
49
+int SoundNull::addWave(unsigned char* wav, unsigned int length, unsigned long* source,
50
+                       unsigned int flags) {
50
     *source = sources;
51
     *source = sources;
51
     sources++;
52
     sources++;
52
     return 0;
53
     return 0;

+ 17
- 17
src/Sprite.cpp View File

11
 #include "Render.h"
11
 #include "Render.h"
12
 #include "Sprite.h"
12
 #include "Sprite.h"
13
 
13
 
14
-SpriteSequence::SpriteSequence(TombRaider &tr, unsigned int item, unsigned int sequence) {
14
+SpriteSequence::SpriteSequence(TombRaider& tr, unsigned int item, unsigned int sequence) {
15
     for (int i = 0; i < (-tr.SpriteSequence()[sequence].negative_length); i++)
15
     for (int i = 0; i < (-tr.SpriteSequence()[sequence].negative_length); i++)
16
         sprites.push_back(new Sprite(tr, item, sequence, i));
16
         sprites.push_back(new Sprite(tr, item, sequence, i));
17
 }
17
 }
25
     return sprites.size();
25
     return sprites.size();
26
 }
26
 }
27
 
27
 
28
-Sprite &SpriteSequence::get(unsigned long index) {
28
+Sprite& SpriteSequence::get(unsigned long index) {
29
     assert(index < sprites.size());
29
     assert(index < sprites.size());
30
     return *sprites.at(index);
30
     return *sprites.at(index);
31
 }
31
 }
32
 
32
 
33
-Sprite::Sprite(TombRaider &tr, unsigned int item, unsigned int sequence, unsigned int index) {
34
-    tr2_item_t *i = tr.Item();
35
-    tr2_sprite_texture_t *spriteTextures = tr.Sprite();
36
-    tr2_sprite_sequence_t *spriteSequence = tr.SpriteSequence();
33
+Sprite::Sprite(TombRaider& tr, unsigned int item, unsigned int sequence, unsigned int index) {
34
+    tr2_item_t* i = tr.Item();
35
+    tr2_sprite_texture_t* spriteTextures = tr.Sprite();
36
+    tr2_sprite_sequence_t* spriteSequence = tr.SpriteSequence();
37
 
37
 
38
     //! \fixme index was unused?!
38
     //! \fixme index was unused?!
39
-    tr2_sprite_texture_t *sprite = &spriteTextures[spriteSequence[sequence].offset + index];
39
+    tr2_sprite_texture_t* sprite = &spriteTextures[spriteSequence[sequence].offset + index];
40
 
40
 
41
     int width = sprite->width >> 8;
41
     int width = sprite->width >> 8;
42
     int height = sprite->height >> 8;
42
     int height = sprite->height >> 8;
67
     vertex[2][2] = 0;
67
     vertex[2][2] = 0;
68
     vertex[3][2] = 0;
68
     vertex[3][2] = 0;
69
 
69
 
70
-    texel[3][0] = (float)(x+width)/texelScale;
71
-    texel[3][1] = (float)(y+height)/texelScale;
70
+    texel[3][0] = (float)(x + width) / texelScale;
71
+    texel[3][1] = (float)(y + height) / texelScale;
72
 
72
 
73
-    texel[2][0] = (float)(x+width)/texelScale;
74
-    texel[2][1] = (float)(y)/texelScale;
73
+    texel[2][0] = (float)(x + width) / texelScale;
74
+    texel[2][1] = (float)(y) / texelScale;
75
 
75
 
76
-    texel[1][0] = (float)(x) /texelScale;
77
-    texel[1][1] = (float)(y) /texelScale;
76
+    texel[1][0] = (float)(x) / texelScale;
77
+    texel[1][1] = (float)(y) / texelScale;
78
 
78
 
79
     texel[0][0] = (float)(x) / texelScale;
79
     texel[0][0] = (float)(x) / texelScale;
80
-    texel[0][1] = (float)(y+height)/texelScale;
80
+    texel[0][1] = (float)(y + height) / texelScale;
81
 
81
 
82
     texture = sprite->tile + getGame().getTextureStart();
82
     texture = sprite->tile + getGame().getTextureStart();
83
     radius = width2 / 2.0f;
83
     radius = width2 / 2.0f;
84
 }
84
 }
85
 
85
 
86
-Sprite::Sprite(TombRaider &tr, unsigned int room, unsigned int index) {
86
+Sprite::Sprite(TombRaider& tr, unsigned int room, unsigned int index) {
87
     float spriteVertices[12];
87
     float spriteVertices[12];
88
     float spriteTexCoords[8];
88
     float spriteTexCoords[8];
89
 
89
 
90
     tr.getRoomSprite(room, index,
90
     tr.getRoomSprite(room, index,
91
-            10.0f, &texture, pos, spriteVertices, spriteTexCoords);
91
+                     10.0f, &texture, pos, spriteVertices, spriteTexCoords);
92
 
92
 
93
     texture += getGame().getTextureStart(); // OpenRaider preloads some textures
93
     texture += getGame().getTextureStart(); // OpenRaider preloads some textures
94
 
94
 
140
             glColor3ubv(WHITE);
140
             glColor3ubv(WHITE);
141
             break;
141
             break;
142
         default:
142
         default:
143
-            glBindTexture(GL_TEXTURE_2D, texture+1);
143
+            glBindTexture(GL_TEXTURE_2D, texture + 1);
144
 
144
 
145
             glBegin(GL_TRIANGLE_STRIP);
145
             glBegin(GL_TRIANGLE_STRIP);
146
             glTexCoord2fv(texel[0]);
146
             glTexCoord2fv(texel[0]);

+ 30
- 29
src/StaticMesh.cpp View File

26
     transparency = trans;
26
     transparency = trans;
27
 }
27
 }
28
 
28
 
29
-void TexturedTriangle::display(float *vertices, float *colors, float *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)
33
-            && (getRender().getMode() != Render::modeSolid)) {
33
+        && (getRender().getMode() != Render::modeSolid)) {
34
         glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
34
         glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
35
         glBindTexture(GL_TEXTURE_2D, texture + 1);
35
         glBindTexture(GL_TEXTURE_2D, texture + 1);
36
     }
36
     }
97
 #include <map>
97
 #include <map>
98
 std::map<unsigned int, unsigned int> gColorTextureHACK;
98
 std::map<unsigned int, unsigned int> gColorTextureHACK;
99
 
99
 
100
-int setupTextureColor(float *colorf) {
100
+int setupTextureColor(float* colorf) {
101
     unsigned char color[4];
101
     unsigned char color[4];
102
     unsigned int colorI;
102
     unsigned int colorI;
103
     unsigned int texture;
103
     unsigned int texture;
104
 
104
 
105
-    color[0] = (unsigned char)(colorf[0]*255.0f);
106
-    color[1] = (unsigned char)(colorf[1]*255.0f);
107
-    color[2] = (unsigned char)(colorf[2]*255.0f);
108
-    color[3] = (unsigned char)(colorf[3]*255.0f);
105
+    color[0] = (unsigned char)(colorf[0] * 255.0f);
106
+    color[1] = (unsigned char)(colorf[1] * 255.0f);
107
+    color[2] = (unsigned char)(colorf[2] * 255.0f);
108
+    color[3] = (unsigned char)(colorf[3] * 255.0f);
109
 
109
 
110
-    ((unsigned char *)(&colorI))[3] = color[0];
111
-    ((unsigned char *)(&colorI))[2] = color[1];
112
-    ((unsigned char *)(&colorI))[1] = color[2];
113
-    ((unsigned char *)(&colorI))[0] = color[3];
110
+    ((unsigned char*)(&colorI))[3] = color[0];
111
+    ((unsigned char*)(&colorI))[2] = color[1];
112
+    ((unsigned char*)(&colorI))[1] = color[2];
113
+    ((unsigned char*)(&colorI))[0] = color[3];
114
 
114
 
115
     try {
115
     try {
116
         texture = gColorTextureHACK.at(colorI);
116
         texture = gColorTextureHACK.at(colorI);
117
     } catch (...) {
117
     } catch (...) {
118
-        unsigned char *image = generateColorTexture(color, 32, 32, 32);
118
+        unsigned char* image = generateColorTexture(color, 32, 32, 32);
119
         texture = getTextureManager().loadBufferSlot(image, 32, 32,
119
         texture = getTextureManager().loadBufferSlot(image, 32, 32,
120
-                RGBA, 32, getTextureManager().getTextureCount());
120
+                  RGBA, 32, getTextureManager().getTextureCount());
121
         delete [] image;
121
         delete [] image;
122
     }
122
     }
123
 
123
 
126
 
126
 
127
 #endif
127
 #endif
128
 
128
 
129
-StaticMesh::StaticMesh(TombRaider &tr, unsigned int index) {
129
+StaticMesh::StaticMesh(TombRaider& tr, unsigned int index) {
130
     int count, texture;
130
     int count, texture;
131
     int vertexIndices[6];
131
     int vertexIndices[6];
132
     float st[12];
132
     float st[12];
146
     //! \fixme Arrays don't work either  =)
146
     //! \fixme Arrays don't work either  =)
147
     // Mesh geometery, colors, etc
147
     // Mesh geometery, colors, etc
148
     tr.getMeshVertexArrays(index,
148
     tr.getMeshVertexArrays(index,
149
-            &vertexCount, &vertices,
150
-            &normalCount, &normals,
151
-            &colorCount,  &colors);
149
+                           &vertexCount, &vertices,
150
+                           &normalCount, &normals,
151
+                           &colorCount,  &colors);
152
 
152
 
153
     // Textured Triangles
153
     // Textured Triangles
154
     count = tr.getMeshTexturedTriangleCount(index);
154
     count = tr.getMeshTexturedTriangleCount(index);
155
     for (int i = 0; i < count; i++) {
155
     for (int i = 0; i < count; i++) {
156
         tr.getMeshTexturedTriangle(index, i,
156
         tr.getMeshTexturedTriangle(index, i,
157
-                vertexIndices, st,
158
-                &texture, &transparency);
157
+                                   vertexIndices, st,
158
+                                   &texture, &transparency);
159
         triangles.push_back(
159
         triangles.push_back(
160
-                new TexturedTriangle(vertexIndices, st, texture + getGame().getTextureStart(), transparency));
160
+            new TexturedTriangle(vertexIndices, st, texture + getGame().getTextureStart(), transparency));
161
     }
161
     }
162
 
162
 
163
     // Coloured Triangles
163
     // Coloured Triangles
164
     count = tr.getMeshColoredTriangleCount(index);
164
     count = tr.getMeshColoredTriangleCount(index);
165
     for (int i = 0; i < count; i++) {
165
     for (int i = 0; i < count; i++) {
166
         tr.getMeshColoredTriangle(index, i,
166
         tr.getMeshColoredTriangle(index, i,
167
-                vertexIndices, color);
167
+                                  vertexIndices, color);
168
         st[0] = color[0];
168
         st[0] = color[0];
169
         st[1] = color[1];
169
         st[1] = color[1];
170
         st[2] = color[2];
170
         st[2] = color[2];
180
         transparency = 0;
180
         transparency = 0;
181
 
181
 
182
         triangles.push_back(
182
         triangles.push_back(
183
-                new TexturedTriangle(vertexIndices, st, texture + getGame().getTextureStart(), transparency));
183
+            new TexturedTriangle(vertexIndices, st, texture + getGame().getTextureStart(), transparency));
184
     }
184
     }
185
 
185
 
186
     // Textured Rectangles
186
     // Textured Rectangles
187
     count = tr.getMeshTexturedRectangleCount(index);
187
     count = tr.getMeshTexturedRectangleCount(index);
188
     for (int i = 0; i < count; i++) {
188
     for (int i = 0; i < count; i++) {
189
         tr.getMeshTexturedRectangle(index, i,
189
         tr.getMeshTexturedRectangle(index, i,
190
-                vertexIndices, st,
191
-                &texture, &transparency);
190
+                                    vertexIndices, st,
191
+                                    &texture, &transparency);
192
         triangles.push_back(
192
         triangles.push_back(
193
-                new TexturedTriangle(vertexIndices, st, texture + getGame().getTextureStart(), transparency));
193
+            new TexturedTriangle(vertexIndices, st, texture + getGame().getTextureStart(), transparency));
194
         triangles.push_back(
194
         triangles.push_back(
195
-                new TexturedTriangle(vertexIndices + 3, st + 6, texture + getGame().getTextureStart(), transparency));
195
+            new TexturedTriangle(vertexIndices + 3, st + 6, texture + getGame().getTextureStart(),
196
+                                 transparency));
196
     }
197
     }
197
 
198
 
198
     // Coloured Rectangles
199
     // Coloured Rectangles
199
     count = tr.getMeshColoredRectangleCount(index);
200
     count = tr.getMeshColoredRectangleCount(index);
200
     for (int i = 0; i < count; i++) {
201
     for (int i = 0; i < count; i++) {
201
         tr.getMeshColoredRectangle(index, i,
202
         tr.getMeshColoredRectangle(index, i,
202
-                vertexIndices, color);
203
+                                   vertexIndices, color);
203
 
204
 
204
         st[0] = color[0];
205
         st[0] = color[0];
205
         st[1] = color[1];
206
         st[1] = color[1];
216
         transparency = 0;
217
         transparency = 0;
217
 
218
 
218
         triangles.push_back(
219
         triangles.push_back(
219
-                new TexturedTriangle(vertexIndices, st, texture + getGame().getTextureStart(), transparency));
220
+            new TexturedTriangle(vertexIndices, st, texture + getGame().getTextureStart(), transparency));
220
         triangles.push_back(
221
         triangles.push_back(
221
-                new TexturedTriangle(vertexIndices + 3, st, texture + getGame().getTextureStart(), transparency));
222
+            new TexturedTriangle(vertexIndices + 3, st, texture + getGame().getTextureStart(), transparency));
222
     }
223
     }
223
 }
224
 }
224
 
225
 

+ 20
- 20
src/TextureManager.cpp View File

41
 }
41
 }
42
 
42
 
43
 int TextureManager::initialize() {
43
 int TextureManager::initialize() {
44
-    unsigned char *image = generateColorTexture(WHITE, 32, 32, 32);
44
+    unsigned char* image = generateColorTexture(WHITE, 32, 32, 32);
45
     loadBufferSlot(image, 32, 32, RGBA, 32, mTextureIds.size());
45
     loadBufferSlot(image, 32, 32, RGBA, 32, mTextureIds.size());
46
     delete [] image;
46
     delete [] image;
47
 
47
 
108
 #endif
108
 #endif
109
 }
109
 }
110
 
110
 
111
-int TextureManager::loadBufferSlot(unsigned char *image,
112
-        unsigned int width, unsigned int height,
113
-        ColorMode mode, unsigned int bpp,
114
-        unsigned int slot, bool filter) {
111
+int TextureManager::loadBufferSlot(unsigned char* image,
112
+                                   unsigned int width, unsigned int height,
113
+                                   ColorMode mode, unsigned int bpp,
114
+                                   unsigned int slot, bool filter) {
115
     assert(image != NULL);
115
     assert(image != NULL);
116
     assert(width > 0);
116
     assert(width > 0);
117
     assert(height > 0);
117
     assert(height > 0);
118
     assert((mode == GREYSCALE) || (mode == RGB)
118
     assert((mode == GREYSCALE) || (mode == RGB)
119
-            || (mode == BGR) || (mode == ARGB)
120
-            || (mode == RGBA) || (mode ==  BGRA));
119
+           || (mode == BGR) || (mode == ARGB)
120
+           || (mode == RGBA) || (mode ==  BGRA));
121
     assert((bpp == 8) || (bpp == 24) || (bpp == 32));
121
     assert((bpp == 8) || (bpp == 24) || (bpp == 32));
122
 
122
 
123
     while (mTextureIds.size() <= slot) {
123
     while (mTextureIds.size() <= slot) {
192
     glBindTexture(GL_TEXTURE_2D, mTextureIds.at(n));
192
     glBindTexture(GL_TEXTURE_2D, mTextureIds.at(n));
193
 }
193
 }
194
 
194
 
195
-int TextureManager::loadImage(const char *filename) {
195
+int TextureManager::loadImage(const char* filename) {
196
     if (stringEndsWith(filename, ".pcx") || stringEndsWith(filename, ".PCX")) {
196
     if (stringEndsWith(filename, ".pcx") || stringEndsWith(filename, ".PCX")) {
197
         return loadPCX(filename);
197
         return loadPCX(filename);
198
     } else if (stringEndsWith(filename, ".png") || stringEndsWith(filename, ".PNG")) {
198
     } else if (stringEndsWith(filename, ".png") || stringEndsWith(filename, ".PNG")) {
206
     return -1;
206
     return -1;
207
 }
207
 }
208
 
208
 
209
-int TextureManager::loadPCX(const char *filename) {
209
+int TextureManager::loadPCX(const char* filename) {
210
     assert(filename != NULL);
210
     assert(filename != NULL);
211
     assert(filename[0] != '\0');
211
     assert(filename[0] != '\0');
212
 
212
 
213
-    unsigned char *image;
213
+    unsigned char* image;
214
     unsigned int w, h, bpp;
214
     unsigned int w, h, bpp;
215
     ColorMode c;
215
     ColorMode c;
216
     int id = -1;
216
     int id = -1;
217
     int error = pcxLoad(filename, &image, &w, &h, &c, &bpp);
217
     int error = pcxLoad(filename, &image, &w, &h, &c, &bpp);
218
 
218
 
219
     if (error == 0) {
219
     if (error == 0) {
220
-        unsigned char *image2 = scaleBuffer(image, &w, &h, bpp);
220
+        unsigned char* image2 = scaleBuffer(image, &w, &h, bpp);
221
         if (image2) {
221
         if (image2) {
222
             delete [] image;
222
             delete [] image;
223
             image = image2;
223
             image = image2;
229
     return id;
229
     return id;
230
 }
230
 }
231
 
231
 
232
-int TextureManager::loadPNG(const char *filename) {
232
+int TextureManager::loadPNG(const char* filename) {
233
 #ifdef USING_PNG
233
 #ifdef USING_PNG
234
     assert(filename != NULL);
234
     assert(filename != NULL);
235
     assert(filename[0] != '\0');
235
     assert(filename[0] != '\0');
238
         return -1;
238
         return -1;
239
     }
239
     }
240
 
240
 
241
-    unsigned char *image;
241
+    unsigned char* image;
242
     unsigned int w, h, bpp;
242
     unsigned int w, h, bpp;
243
     ColorMode c;
243
     ColorMode c;
244
     int id = -1;
244
     int id = -1;
245
     int error = pngLoad(filename, &image, &w, &h, &c, &bpp);
245
     int error = pngLoad(filename, &image, &w, &h, &c, &bpp);
246
 
246
 
247
     if (error == 0) {
247
     if (error == 0) {
248
-        unsigned char *image2 = scaleBuffer(image, &w, &h, bpp);
248
+        unsigned char* image2 = scaleBuffer(image, &w, &h, bpp);
249
         if (image2) {
249
         if (image2) {
250
             delete [] image;
250
             delete [] image;
251
             image = image2;
251
             image = image2;
261
 #endif
261
 #endif
262
 }
262
 }
263
 
263
 
264
-int TextureManager::loadTGA(const char *filename) {
264
+int TextureManager::loadTGA(const char* filename) {
265
     assert(filename != NULL);
265
     assert(filename != NULL);
266
     assert(filename[0] != '\0');
266
     assert(filename[0] != '\0');
267
 
267
 
268
-    unsigned char *image;
268
+    unsigned char* image;
269
     unsigned int w, h;
269
     unsigned int w, h;
270
     char type;
270
     char type;
271
     int id = -1;
271
     int id = -1;
273
     if (!tgaCheck(filename)) {
273
     if (!tgaCheck(filename)) {
274
         tgaLoad(filename, &image, &w, &h, &type);
274
         tgaLoad(filename, &image, &w, &h, &type);
275
 
275
 
276
-        unsigned char *image2 = scaleBuffer(image, &w, &h, (type == 2) ? 32 : 24);
276
+        unsigned char* image2 = scaleBuffer(image, &w, &h, (type == 2) ? 32 : 24);
277
         if (image2) {
277
         if (image2) {
278
             delete [] image;
278
             delete [] image;
279
             image = image2;
279
             image = image2;
280
         }
280
         }
281
         if (image) {
281
         if (image) {
282
             id = loadBufferSlot(image, w, h,
282
             id = loadBufferSlot(image, w, h,
283
-                    (type == 2) ? RGBA : RGB,
284
-                    (type == 2) ? 32 : 24,
285
-                    mTextureIds.size());
283
+                                (type == 2) ? RGBA : RGB,
284
+                                (type == 2) ? 32 : 24,
285
+                                mTextureIds.size());
286
             delete [] image;
286
             delete [] image;
287
         }
287
         }
288
     }
288
     }

+ 916
- 1384
src/TombRaider.cpp
File diff suppressed because it is too large
View File


+ 14
- 14
src/UI.cpp View File

71
     ImGui::GetDefaultFontData(NULL, NULL, &png_data, &png_size);
71
     ImGui::GetDefaultFontData(NULL, NULL, &png_data, &png_size);
72
     int tex_x, tex_y, tex_comp;
72
     int tex_x, tex_y, tex_comp;
73
     void* tex_data = stbi_load_from_memory((const unsigned char*)png_data,
73
     void* tex_data = stbi_load_from_memory((const unsigned char*)png_data,
74
-            (int)png_size, &tex_x, &tex_y, &tex_comp, 0);
74
+                                           (int)png_size, &tex_x, &tex_y, &tex_comp, 0);
75
 
75
 
76
-     //! \fixme TODO use proper texture slot
77
-    fontTex = getTextureManager().loadBufferSlot((unsigned char *)tex_data,
78
-            tex_x, tex_y, RGBA, 32, 0, false);
76
+    //! \fixme TODO use proper texture slot
77
+    fontTex = getTextureManager().loadBufferSlot((unsigned char*)tex_data,
78
+              tex_x, tex_y, RGBA, 32, 0, false);
79
 
79
 
80
     stbi_image_free(tex_data);
80
     stbi_image_free(tex_data);
81
 
81
 
99
             auto i = clickEvents.front();
99
             auto i = clickEvents.front();
100
             if (getMenu().isVisible()) {
100
             if (getMenu().isVisible()) {
101
                 getMenu().handleMouseClick(std::get<0>(i), std::get<1>(i),
101
                 getMenu().handleMouseClick(std::get<0>(i), std::get<1>(i),
102
-                        std::get<2>(i), std::get<3>(i));
102
+                                           std::get<2>(i), std::get<3>(i));
103
             }
103
             }
104
             clickEvents.pop_front();
104
             clickEvents.pop_front();
105
         }
105
         }
108
             auto i = motionEvents.front();
108
             auto i = motionEvents.front();
109
             if (!getMenu().isVisible()) {
109
             if (!getMenu().isVisible()) {
110
                 getGame().handleMouseMotion(std::get<0>(i), std::get<1>(i),
110
                 getGame().handleMouseMotion(std::get<0>(i), std::get<1>(i),
111
-                        std::get<2>(i), std::get<3>(i));
111
+                                            std::get<2>(i), std::get<3>(i));
112
             }
112
             }
113
             motionEvents.pop_front();
113
             motionEvents.pop_front();
114
         }
114
         }
163
     }
163
     }
164
 
164
 
165
     if (visible && (
165
     if (visible && (
166
-                ((!io.WantCaptureKeyboard) && io.KeysDown[escapeKey])
167
-                || ((!io.WantCaptureMouse) && clicked)
168
-            )) {
166
+            ((!io.WantCaptureKeyboard) && io.KeysDown[escapeKey])
167
+            || ((!io.WantCaptureMouse) && clicked)
168
+        )) {
169
         visible = false;
169
         visible = false;
170
     }
170
     }
171
 
171
 
217
         metaKeyIsActive = pressed;
217
         metaKeyIsActive = pressed;
218
 }
218
 }
219
 
219
 
220
-void UI::handleText(char *text, bool notFinished) {
220
+void UI::handleText(char* text, bool notFinished) {
221
     if (notFinished)
221
     if (notFinished)
222
         return;
222
         return;
223
 
223
 
289
         const ImDrawList* cmd_list = cmd_lists[n];
289
         const ImDrawList* cmd_list = cmd_lists[n];
290
         const unsigned char* vtx_buffer = (const unsigned char*)cmd_list->vtx_buffer.begin();
290
         const unsigned char* vtx_buffer = (const unsigned char*)cmd_list->vtx_buffer.begin();
291
         glVertexPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)(vtx_buffer));
291
         glVertexPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)(vtx_buffer));
292
-        glTexCoordPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)(vtx_buffer+8));
293
-        glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(ImDrawVert), (void*)(vtx_buffer+16));
292
+        glTexCoordPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)(vtx_buffer + 8));
293
+        glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(ImDrawVert), (void*)(vtx_buffer + 16));
294
 
294
 
295
         int vtx_offset = 0;
295
         int vtx_offset = 0;
296
         const ImDrawCmd* pcmd_end = cmd_list->commands.end();
296
         const ImDrawCmd* pcmd_end = cmd_list->commands.end();
297
         for (const ImDrawCmd* pcmd = cmd_list->commands.begin(); pcmd != pcmd_end; pcmd++) {
297
         for (const ImDrawCmd* pcmd = cmd_list->commands.begin(); pcmd != pcmd_end; pcmd++) {
298
             glScissor((int)pcmd->clip_rect.x, (int)(ImGui::GetIO().DisplaySize.y - pcmd->clip_rect.w),
298
             glScissor((int)pcmd->clip_rect.x, (int)(ImGui::GetIO().DisplaySize.y - pcmd->clip_rect.w),
299
-                    (int)(pcmd->clip_rect.z - pcmd->clip_rect.x),
300
-                    (int)(pcmd->clip_rect.w - pcmd->clip_rect.y));
299
+                      (int)(pcmd->clip_rect.z - pcmd->clip_rect.x),
300
+                      (int)(pcmd->clip_rect.w - pcmd->clip_rect.y));
301
             glDrawArrays(GL_TRIANGLES, vtx_offset, pcmd->vtx_count);
301
             glDrawArrays(GL_TRIANGLES, vtx_offset, pcmd->vtx_count);
302
             vtx_offset += pcmd->vtx_count;
302
             vtx_offset += pcmd->vtx_count;
303
         }
303
         }

+ 32
- 32
src/ViewVolume.cpp View File

24
 bool ViewVolume::isPointInFrustum(float x, float y, float 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) {
28
             return false;
28
             return false;
29
         }
29
         }
30
     }
30
     }
43
 bool ViewVolume::isBboxInFrustum(float min[3], float max[3]) {
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] +
47
-                mFrustum[p][2] * min[2] + mFrustum[p][3] > 0)
46
+            mFrustum[p][1] * min[1] +
47
+            mFrustum[p][2] * min[2] + mFrustum[p][3] > 0)
48
             continue;
48
             continue;
49
 
49
 
50
         if (mFrustum[p][0] * max[0] +
50
         if (mFrustum[p][0] * max[0] +
51
-                mFrustum[p][1] * max[1] +
52
-                mFrustum[p][2] * max[2] + mFrustum[p][3] > 0)
51
+            mFrustum[p][1] * max[1] +
52
+            mFrustum[p][2] * max[2] + mFrustum[p][3] > 0)
53
             continue;
53
             continue;
54
 
54
 
55
         if (mFrustum[p][0] * min[0] +
55
         if (mFrustum[p][0] * min[0] +
56
-                mFrustum[p][1] * max[1] +
57
-                mFrustum[p][2] * max[2] + mFrustum[p][3] > 0)
56
+            mFrustum[p][1] * max[1] +
57
+            mFrustum[p][2] * max[2] + mFrustum[p][3] > 0)
58
             continue;
58
             continue;
59
 
59
 
60
         if (mFrustum[p][0] * min[0] +
60
         if (mFrustum[p][0] * min[0] +
61
-                mFrustum[p][1] * min[1] +
62
-                mFrustum[p][2] * max[2] + mFrustum[p][3] > 0)
61
+            mFrustum[p][1] * min[1] +
62
+            mFrustum[p][2] * max[2] + mFrustum[p][3] > 0)
63
             continue;
63
             continue;
64
 
64
 
65
         if (mFrustum[p][0] * min[0] +
65
         if (mFrustum[p][0] * min[0] +
66
-                mFrustum[p][1] * max[1] +
67
-                mFrustum[p][2] * min[2] + mFrustum[p][3] > 0)
66
+            mFrustum[p][1] * max[1] +
67
+            mFrustum[p][2] * min[2] + mFrustum[p][3] > 0)
68
             continue;
68
             continue;
69
 
69
 
70
         if (mFrustum[p][0] * max[0] +
70
         if (mFrustum[p][0] * max[0] +
71
-                mFrustum[p][1] * min[1] +
72
-                mFrustum[p][2] * min[2] + mFrustum[p][3] > 0)
71
+            mFrustum[p][1] * min[1] +
72
+            mFrustum[p][2] * min[2] + mFrustum[p][3] > 0)
73
             continue;
73
             continue;
74
 
74
 
75
         if (mFrustum[p][0] * max[0] +
75
         if (mFrustum[p][0] * max[0] +
76
-                mFrustum[p][1] * max[1] +
77
-                mFrustum[p][2] * min[2] + mFrustum[p][3] > 0)
76
+            mFrustum[p][1] * max[1] +
77
+            mFrustum[p][2] * min[2] + mFrustum[p][3] > 0)
78
             continue;
78
             continue;
79
 
79
 
80
         if (mFrustum[p][0] * max[0] +
80
         if (mFrustum[p][0] * max[0] +
81
-                mFrustum[p][1] * min[1] +
82
-                mFrustum[p][2] * max[2] + mFrustum[p][3] > 0)
81
+            mFrustum[p][1] * min[1] +
82
+            mFrustum[p][2] * max[2] + mFrustum[p][3] > 0)
83
             continue;
83
             continue;
84
 
84
 
85
         return false;
85
         return false;
105
 
105
 
106
     // 5 should be near plane
106
     // 5 should be near plane
107
     d = (mFrustum[5][0] * center[0] +
107
     d = (mFrustum[5][0] * center[0] +
108
-            mFrustum[5][1] * center[1] +
109
-            mFrustum[5][2] * center[2] +
110
-            mFrustum[5][3]);
108
+         mFrustum[5][1] * center[1] +
109
+         mFrustum[5][2] * center[2] +
110
+         mFrustum[5][3]);
111
 
111
 
112
     radius = distance(max, center);
112
     radius = distance(max, center);
113
 
113
 
169
 
169
 
170
     /* Normalize the result */
170
     /* Normalize the result */
171
     t = sqrtf(mFrustum[0][0] * mFrustum[0][0] +
171
     t = sqrtf(mFrustum[0][0] * mFrustum[0][0] +
172
-            mFrustum[0][1] * mFrustum[0][1] +
173
-            mFrustum[0][2] * mFrustum[0][2]);
172
+              mFrustum[0][1] * mFrustum[0][1] +
173
+              mFrustum[0][2] * mFrustum[0][2]);
174
     mFrustum[0][0] /= t;
174
     mFrustum[0][0] /= t;
175
     mFrustum[0][1] /= t;
175
     mFrustum[0][1] /= t;
176
     mFrustum[0][2] /= t;
176
     mFrustum[0][2] /= t;
184
 
184
 
185
     /* Normalize the result */
185
     /* Normalize the result */
186
     t = sqrtf(mFrustum[1][0] * mFrustum[1][0] +
186
     t = sqrtf(mFrustum[1][0] * mFrustum[1][0] +
187
-            mFrustum[1][1] * mFrustum[1][1] +
188
-            mFrustum[1][2] * mFrustum[1][2]);
187
+              mFrustum[1][1] * mFrustum[1][1] +
188
+              mFrustum[1][2] * mFrustum[1][2]);
189
     mFrustum[1][0] /= t;
189
     mFrustum[1][0] /= t;
190
     mFrustum[1][1] /= t;
190
     mFrustum[1][1] /= t;
191
     mFrustum[1][2] /= t;
191
     mFrustum[1][2] /= t;
199
 
199
 
200
     /* Normalize the result */
200
     /* Normalize the result */
201
     t = sqrtf(mFrustum[2][0] * mFrustum[2][0] +
201
     t = sqrtf(mFrustum[2][0] * mFrustum[2][0] +
202
-            mFrustum[2][1] * mFrustum[2][1] +
203
-            mFrustum[2][2] * mFrustum[2][2]);
202
+              mFrustum[2][1] * mFrustum[2][1] +
203
+              mFrustum[2][2] * mFrustum[2][2]);
204
     mFrustum[2][0] /= t;
204
     mFrustum[2][0] /= t;
205
     mFrustum[2][1] /= t;
205
     mFrustum[2][1] /= t;
206
     mFrustum[2][2] /= t;
206
     mFrustum[2][2] /= t;
214
 
214
 
215
     /* Normalize the result */
215
     /* Normalize the result */
216
     t = sqrtf(mFrustum[3][0] * mFrustum[3][0] +
216
     t = sqrtf(mFrustum[3][0] * mFrustum[3][0] +
217
-            mFrustum[3][1] * mFrustum[3][1] +
218
-            mFrustum[3][2] * mFrustum[3][2]);
217
+              mFrustum[3][1] * mFrustum[3][1] +
218
+              mFrustum[3][2] * mFrustum[3][2]);
219
     mFrustum[3][0] /= t;
219
     mFrustum[3][0] /= t;
220
     mFrustum[3][1] /= t;
220
     mFrustum[3][1] /= t;
221
     mFrustum[3][2] /= t;
221
     mFrustum[3][2] /= t;
229
 
229
 
230
     /* Normalize the result */
230
     /* Normalize the result */
231
     t = sqrtf(mFrustum[4][0] * mFrustum[4][0] +
231
     t = sqrtf(mFrustum[4][0] * mFrustum[4][0] +
232
-            mFrustum[4][1] * mFrustum[4][1] +
233
-            mFrustum[4][2] * mFrustum[4][2]);
232
+              mFrustum[4][1] * mFrustum[4][1] +
233
+              mFrustum[4][2] * mFrustum[4][2]);
234
     mFrustum[4][0] /= t;
234
     mFrustum[4][0] /= t;
235
     mFrustum[4][1] /= t;
235
     mFrustum[4][1] /= t;
236
     mFrustum[4][2] /= t;
236
     mFrustum[4][2] /= t;
244
 
244
 
245
     /* Normalize the result */
245
     /* Normalize the result */
246
     t = sqrtf(mFrustum[5][0] * mFrustum[5][0] +
246
     t = sqrtf(mFrustum[5][0] * mFrustum[5][0] +
247
-            mFrustum[5][1] * mFrustum[5][1] +
248
-            mFrustum[5][2] * mFrustum[5][2]);
247
+              mFrustum[5][1] * mFrustum[5][1] +
248
+              mFrustum[5][2] * mFrustum[5][2]);
249
     mFrustum[5][0] /= t;
249
     mFrustum[5][0] /= t;
250
     mFrustum[5][1] /= t;
250
     mFrustum[5][1] /= t;
251
     mFrustum[5][2] /= t;
251
     mFrustum[5][2] /= t;

+ 9
- 9
src/Window.cpp View File

24
     // Testing for goodies
24
     // Testing for goodies
25
     //const char *s = (const char *)glGetString(GL_EXTENSIONS);
25
     //const char *s = (const char *)glGetString(GL_EXTENSIONS);
26
     //if ((s != NULL) && (s[0] != '\0')) {
26
     //if ((s != NULL) && (s[0] != '\0')) {
27
-        //! \todo MultiTexture flag
28
-        //if (strstr(s, "GL_ARB_multitexture"))
29
-            //mFlags |= Render::fMultiTexture;
27
+    //! \todo MultiTexture flag
28
+    //if (strstr(s, "GL_ARB_multitexture"))
29
+    //mFlags |= Render::fMultiTexture;
30
     //}
30
     //}
31
 
31
 
32
     // Set up Z buffer
32
     // Set up Z buffer
146
 // Replaced the deprecated gluLookAt with slightly modified code from here:
146
 // Replaced the deprecated gluLookAt with slightly modified code from here:
147
 // http://www.khronos.org/message_boards/showthread.php/4991
147
 // http://www.khronos.org/message_boards/showthread.php/4991
148
 void Window::lookAt(float eyeX, float eyeY, float eyeZ,
148
 void Window::lookAt(float eyeX, float eyeY, float eyeZ,
149
-        float lookAtX, float lookAtY, float lookAtZ,
150
-        float upX, float upY, float upZ) {
149
+                    float lookAtX, float lookAtY, float lookAtZ,
150
+                    float upX, float upY, float upZ) {
151
     // calculating the viewing vector
151
     // calculating the viewing vector
152
     float f[3] = {
152
     float f[3] = {
153
         lookAtX - eyeX,
153
         lookAtX - eyeX,
162
     f[2] /= fMag;
162
     f[2] /= fMag;
163
 
163
 
164
     float s[3] = {
164
     float s[3] = {
165
-        (f[1] * upZ) - (upY * f[2]),
166
-        (upX * f[2]) - (f[0] * upZ),
167
-        (f[0] * upY) - (upX * f[1])
165
+        (f[1] * upZ) - (upY* f[2]),
166
+        (upX* f[2]) - (f[0] * upZ),
167
+        (f[0] * upY) - (upX* f[1])
168
     };
168
     };
169
 
169
 
170
     float u[3] = {
170
     float u[3] = {
177
         s[0], u[0], -f[0], 0,
177
         s[0], u[0], -f[0], 0,
178
         s[1], u[1], -f[1], 0,
178
         s[1], u[1], -f[1], 0,
179
         s[2], u[2], -f[2], 0,
179
         s[2], u[2], -f[2], 0,
180
-           0,    0,     0, 1
180
+        0,    0,     0, 1
181
     };
181
     };
182
     glMultMatrixf(m);
182
     glMultMatrixf(m);
183
     glTranslatef(-eyeX, -eyeY, -eyeZ);
183
     glTranslatef(-eyeX, -eyeY, -eyeZ);

+ 2
- 2
src/WindowGLUT.cpp View File

67
     assert(mInit == false);
67
     assert(mInit == false);
68
 
68
 
69
     int argc = 1;
69
     int argc = 1;
70
-    char *argv[] = { new char[11], nullptr };
70
+    char* argv[] = { new char[11], nullptr };
71
     strcpy(argv[0], "OpenRaider");
71
     strcpy(argv[0], "OpenRaider");
72
     glutInit(&argc, argv);
72
     glutInit(&argc, argv);
73
     glutInitWindowSize(mWidth, mHeight);
73
     glutInitWindowSize(mWidth, mHeight);
197
 
197
 
198
     // Alphanumerics can be returned as is
198
     // Alphanumerics can be returned as is
199
     if (((key >= '0') && (key <= '9'))
199
     if (((key >= '0') && (key <= '9'))
200
-            || ((key >= 'a') && (key <= 'z'))) {
200
+        || ((key >= 'a') && (key <= 'z'))) {
201
         return static_cast<KeyboardButton>(key);
201
         return static_cast<KeyboardButton>(key);
202
     }
202
     }
203
 
203
 

+ 2
- 2
src/WindowSDL.cpp View File

92
     }
92
     }
93
 
93
 
94
     mWindow = SDL_CreateWindow(VERSION, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
94
     mWindow = SDL_CreateWindow(VERSION, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
95
-                mWidth, mHeight, flags);
95
+                               mWidth, mHeight, flags);
96
     if (mWindow == NULL) {
96
     if (mWindow == NULL) {
97
         std::cout << "SDL_CreateWindow Error: " << SDL_GetError() << std::endl;
97
         std::cout << "SDL_CreateWindow Error: " << SDL_GetError() << std::endl;
98
         return -3;
98
         return -3;
116
 
116
 
117
     assert(mInit == true);
117
     assert(mInit == true);
118
 
118
 
119
-    while(SDL_PollEvent(&event)) {
119
+    while (SDL_PollEvent(&event)) {
120
         switch (event.type) {
120
         switch (event.type) {
121
             case SDL_MOUSEMOTION:
121
             case SDL_MOUSEMOTION:
122
                 UI::handleMouseMotion(event.motion.xrel, event.motion.yrel, event.motion.x, event.motion.y);
122
                 UI::handleMouseMotion(event.motion.xrel, event.motion.yrel, event.motion.x, event.motion.y);

+ 12
- 13
src/World.cpp View File

15
     destroy();
15
     destroy();
16
 }
16
 }
17
 
17
 
18
-void World::addRoom(Room &room) {
18
+void World::addRoom(Room& room) {
19
     mRooms.push_back(std::unique_ptr<Room>(&room));
19
     mRooms.push_back(std::unique_ptr<Room>(&room));
20
 }
20
 }
21
 
21
 
23
     return mRooms.size();
23
     return mRooms.size();
24
 }
24
 }
25
 
25
 
26
-Room &World::getRoom(unsigned long index) {
26
+Room& World::getRoom(unsigned long index) {
27
     assert(index < mRooms.size());
27
     assert(index < mRooms.size());
28
     return *mRooms.at(index);
28
     return *mRooms.at(index);
29
 }
29
 }
30
 
30
 
31
-void World::addSprite(SpriteSequence &sprite) {
31
+void World::addSprite(SpriteSequence& sprite) {
32
     mSprites.push_back(std::unique_ptr<SpriteSequence>(&sprite));
32
     mSprites.push_back(std::unique_ptr<SpriteSequence>(&sprite));
33
 }
33
 }
34
 
34
 
36
     return mSprites.size();
36
     return mSprites.size();
37
 }
37
 }
38
 
38
 
39
-SpriteSequence &World::getSprite(unsigned long index) {
39
+SpriteSequence& World::getSprite(unsigned long index) {
40
     assert(index < mSprites.size());
40
     assert(index < mSprites.size());
41
     return *mSprites.at(index);
41
     return *mSprites.at(index);
42
 }
42
 }
43
 
43
 
44
-void World::addEntity(Entity &entity) {
44
+void World::addEntity(Entity& entity) {
45
     mEntities.push_back(std::unique_ptr<Entity>(&entity));
45
     mEntities.push_back(std::unique_ptr<Entity>(&entity));
46
 }
46
 }
47
 
47
 
49
     return mEntities.size();
49
     return mEntities.size();
50
 }
50
 }
51
 
51
 
52
-Entity &World::getEntity(unsigned long index) {
52
+Entity& World::getEntity(unsigned long index) {
53
     assert(index < mEntities.size());
53
     assert(index < mEntities.size());
54
     return *mEntities.at(index);
54
     return *mEntities.at(index);
55
 }
55
 }
56
 
56
 
57
-void World::addSkeletalModel(SkeletalModel &model) {
57
+void World::addSkeletalModel(SkeletalModel& model) {
58
     mModels.push_back(std::unique_ptr<SkeletalModel>(&model));
58
     mModels.push_back(std::unique_ptr<SkeletalModel>(&model));
59
 }
59
 }
60
 
60
 
62
     return mModels.size();
62
     return mModels.size();
63
 }
63
 }
64
 
64
 
65
-SkeletalModel &World::getSkeletalModel(unsigned long index) {
65
+SkeletalModel& World::getSkeletalModel(unsigned long index) {
66
     assert(index < mModels.size());
66
     assert(index < mModels.size());
67
     return *mModels.at(index);
67
     return *mModels.at(index);
68
 }
68
 }
69
 
69
 
70
-void World::addStaticMesh(StaticMesh &model) {
70
+void World::addStaticMesh(StaticMesh& model) {
71
     mMeshes.push_back(std::unique_ptr<StaticMesh>(&model));
71
     mMeshes.push_back(std::unique_ptr<StaticMesh>(&model));
72
 }
72
 }
73
 
73
 
75
     return mMeshes.size();
75
     return mMeshes.size();
76
 }
76
 }
77
 
77
 
78
-StaticMesh &World::getStaticMesh(unsigned long index) {
78
+StaticMesh& World::getStaticMesh(unsigned long index) {
79
     assert(index < mMeshes.size());
79
     assert(index < mMeshes.size());
80
     return *mMeshes.at(index);
80
     return *mMeshes.at(index);
81
 }
81
 }
82
 
82
 
83
 
83
 
84
-long World::getRoomByLocation(long index, float x, float y, float z)
85
-{
84
+long World::getRoomByLocation(long index, float x, float y, float z) {
86
     assert(index >= 0);
85
     assert(index >= 0);
87
     assert(index < (long)mRooms.size());
86
     assert(index < (long)mRooms.size());
88
-    Room &room = *mRooms.at(index);
87
+    Room& room = *mRooms.at(index);
89
 
88
 
90
     if (room.getBoundingBox().inBox(x, y, z))
89
     if (room.getBoundingBox().inBox(x, y, z))
91
         return index;
90
         return index;

+ 3
- 3
src/commands/Command.cpp View File

74
             getLog() << "Available commands:" << Log::endl;
74
             getLog() << "Available commands:" << Log::endl;
75
             getLog() << std::right << std::setw(11);
75
             getLog() << std::right << std::setw(11);
76
             getLog() << "help" << " - print command help" << Log::endl;
76
             getLog() << "help" << " - print command help" << Log::endl;
77
-            for (auto &x : commands) {
77
+            for (auto& x : commands) {
78
                 if (x) {
78
                 if (x) {
79
                     getLog() << std::right << std::setw(11);
79
                     getLog() << std::right << std::setw(11);
80
                     getLog() << x->name() << " - " << x->brief() << Log::endl;
80
                     getLog() << x->name() << " - " << x->brief() << Log::endl;
85
             return 0;
85
             return 0;
86
         } else {
86
         } else {
87
             // Show help for a specific command
87
             // Show help for a specific command
88
-            for (auto &x : commands) {
88
+            for (auto& x : commands) {
89
                 if (x) {
89
                 if (x) {
90
                     if (x->name().compare(arg) == 0) {
90
                     if (x->name().compare(arg) == 0) {
91
                         x->printHelp();
91
                         x->printHelp();
99
     }
99
     }
100
 
100
 
101
     // Execute command
101
     // Execute command
102
-    for (auto &x : commands) {
102
+    for (auto& x : commands) {
103
         if (x) {
103
         if (x) {
104
             if (x->name().compare(cmd) == 0) {
104
             if (x->name().compare(cmd) == 0) {
105
                 return x->execute(command);
105
                 return x->execute(command);

+ 6
- 7
src/commands/CommandAnimate.cpp View File

39
         // Step all skeletal models to their next animation
39
         // Step all skeletal models to their next animation
40
         if (getRender().getFlags() & Render::fAnimateAllModels) {
40
         if (getRender().getFlags() & Render::fAnimateAllModels) {
41
             for (unsigned int i = 0; i < getWorld().sizeEntity(); i++) {
41
             for (unsigned int i = 0; i < getWorld().sizeEntity(); i++) {
42
-                Entity &e = getWorld().getEntity(i);
43
-                SkeletalModel &m = e.getModel();
42
+                Entity& e = getWorld().getEntity(i);
43
+                SkeletalModel& m = e.getModel();
44
                 if (e.getAnimation() < (m.size() - 1))
44
                 if (e.getAnimation() < (m.size() - 1))
45
                     e.setAnimation(e.getAnimation() + 1);
45
                     e.setAnimation(e.getAnimation() + 1);
46
                 else
46
                 else
53
         // Step all skeletal models to their previous animation
53
         // Step all skeletal models to their previous animation
54
         if (getRender().getFlags() & Render::fAnimateAllModels) {
54
         if (getRender().getFlags() & Render::fAnimateAllModels) {
55
             for (unsigned int i = 0; i < getWorld().sizeEntity(); i++) {
55
             for (unsigned int i = 0; i < getWorld().sizeEntity(); i++) {
56
-                Entity &e = getWorld().getEntity(i);
57
-                SkeletalModel &m = e.getModel();
56
+                Entity& e = getWorld().getEntity(i);
57
+                SkeletalModel& m = e.getModel();
58
                 if (e.getAnimation() > 0)
58
                 if (e.getAnimation() > 0)
59
                     e.setAnimation(e.getAnimation() - 1);
59
                     e.setAnimation(e.getAnimation() - 1);
60
-                else
61
-                    if (m.size() > 0)
62
-                        e.setAnimation(m.size() - 1);
60
+                else if (m.size() > 0)
61
+                    e.setAnimation(m.size() - 1);
63
             }
62
             }
64
         } else {
63
         } else {
65
             getLog() << "Animations need to be enabled!" << Log::endl;
64
             getLog() << "Animations need to be enabled!" << Log::endl;

+ 2
- 2
src/commands/CommandSet.cpp View File

46
     std::string expandNames(std::string s) {
46
     std::string expandNames(std::string s) {
47
         // Remove quotes
47
         // Remove quotes
48
         if ((s.length() >= 3) &&
48
         if ((s.length() >= 3) &&
49
-                (((s[0] == '"') && (s[s.length() - 1] == '"'))
50
-                || ((s[0] == '\'') && (s[s.length() - 1] == '\'')))) {
49
+            (((s[0] == '"') && (s[s.length() - 1] == '"'))
50
+             || ((s[0] == '\'') && (s[s.length() - 1] == '\'')))) {
51
             s.erase(0, 1);
51
             s.erase(0, 1);
52
             s.erase(s.length() - 1, 1);
52
             s.erase(s.length() - 1, 1);
53
         }
53
         }

+ 3
- 3
src/loader/LoaderTR2.cpp View File

61
 
61
 
62
     // Read the 16bit palette, 256 * 4 bytes, RGBA, A unused
62
     // Read the 16bit palette, 256 * 4 bytes, RGBA, A unused
63
     std::array<uint32_t, 256> palette; //!< RGBA, A unused
63
     std::array<uint32_t, 256> palette; //!< RGBA, A unused
64
-    for (auto &x : palette)
64
+    for (auto& x : palette)
65
         x = file.readU32();
65
         x = file.readU32();
66
 
66
 
67
     uint32_t numTextiles = file.readU32();
67
     uint32_t numTextiles = file.readU32();
72
     std::vector<std::array<uint16_t, 256 * 256>> textiles;
72
     std::vector<std::array<uint16_t, 256 * 256>> textiles;
73
     for (unsigned int i = 0; i < numTextiles; i++) {
73
     for (unsigned int i = 0; i < numTextiles; i++) {
74
         std::array<uint16_t, 256 * 256> arr;
74
         std::array<uint16_t, 256 * 256> arr;
75
-        for (auto &x : arr) {
75
+        for (auto& x : arr) {
76
             x = file.readU16();
76
             x = file.readU16();
77
         }
77
         }
78
         textiles.push_back(arr);
78
         textiles.push_back(arr);
605
 
605
 
606
 void LoaderTR2::loadSoundMap() {
606
 void LoaderTR2::loadSoundMap() {
607
     std::array<int16_t, 370> soundMap;
607
     std::array<int16_t, 370> soundMap;
608
-    for (auto &x : soundMap) {
608
+    for (auto& x : soundMap) {
609
         x = file.read16();
609
         x = file.read16();
610
     }
610
     }
611
 
611
 

+ 13
- 13
src/main.cpp View File

56
 static std::shared_ptr<Window> gWindow;
56
 static std::shared_ptr<Window> gWindow;
57
 static std::shared_ptr<World> gWorld;
57
 static std::shared_ptr<World> gWorld;
58
 
58
 
59
-Camera &getCamera() {
59
+Camera& getCamera() {
60
     return *gCamera;
60
     return *gCamera;
61
 }
61
 }
62
 
62
 
63
-Game &getGame() {
63
+Game& getGame() {
64
     return *gGame;
64
     return *gGame;
65
 }
65
 }
66
 
66
 
67
-Log &getLog() {
67
+Log& getLog() {
68
     return *gLog;
68
     return *gLog;
69
 }
69
 }
70
 
70
 
71
-Menu &getMenu() {
71
+Menu& getMenu() {
72
     return *gMenu;
72
     return *gMenu;
73
 }
73
 }
74
 
74
 
75
-Render &getRender() {
75
+Render& getRender() {
76
     return *gRender;
76
     return *gRender;
77
 }
77
 }
78
 
78
 
79
-RunTime &getRunTime() {
79
+RunTime& getRunTime() {
80
     return *gRunTime;
80
     return *gRunTime;
81
 }
81
 }
82
 
82
 
83
-Sound &getSound() {
83
+Sound& getSound() {
84
     return *gSound;
84
     return *gSound;
85
 }
85
 }
86
 
86
 
87
-TextureManager &getTextureManager() {
87
+TextureManager& getTextureManager() {
88
     return *gTextureManager;
88
     return *gTextureManager;
89
 }
89
 }
90
 
90
 
91
-Window &getWindow() {
91
+Window& getWindow() {
92
     return *gWindow;
92
     return *gWindow;
93
 }
93
 }
94
 
94
 
95
-World &getWorld() {
95
+World& getWorld() {
96
     return *gWorld;
96
     return *gWorld;
97
 }
97
 }
98
 
98
 
100
     command_t cmd;
100
     command_t cmd;
101
     command_init(&cmd, argv[0], VERSION);
101
     command_init(&cmd, argv[0], VERSION);
102
     command_option(&cmd, "-c", "--config <file>", "select config file to use",
102
     command_option(&cmd, "-c", "--config <file>", "select config file to use",
103
-            [](command_t *self) {
103
+    [](command_t* self) {
104
         configFileToUse = self->arg;
104
         configFileToUse = self->arg;
105
     });
105
     });
106
     command_parse(&cmd, argc, argv);
106
     command_parse(&cmd, argc, argv);
271
 
271
 
272
     [[noreturn]] void terminateHandler() {
272
     [[noreturn]] void terminateHandler() {
273
         const unsigned int maxSize = 128;
273
         const unsigned int maxSize = 128;
274
-        void *callstack[maxSize];
274
+        void* callstack[maxSize];
275
         int frames = backtrace(callstack, maxSize);
275
         int frames = backtrace(callstack, maxSize);
276
-        char **strs = backtrace_symbols(callstack, frames);
276
+        char** strs = backtrace_symbols(callstack, frames);
277
 
277
 
278
         std::cout << std::endl;
278
         std::cout << std::endl;
279
         for (int i = 0; i < frames; i++)
279
         for (int i = 0; i < frames; i++)

+ 109
- 100
src/math/Matrix.cpp View File

19
     setMatrix(m);
19
     setMatrix(m);
20
 }
20
 }
21
 
21
 
22
-Matrix::Matrix(Quaternion &q) {
22
+Matrix::Matrix(Quaternion& q) {
23
     float m[16];
23
     float m[16];
24
     q.getMatrix(m);
24
     q.getMatrix(m);
25
     setMatrix(m);
25
     setMatrix(m);
43
 
43
 
44
     float wtmp[4][8];
44
     float wtmp[4][8];
45
     float m0, m1, m2, m3, s;
45
     float m0, m1, m2, m3, s;
46
-    float *r0, *r1, *r2, *r3;
46
+    float* r0, *r1, *r2, *r3;
47
 
47
 
48
     r0 = wtmp[0], r1 = wtmp[1], r2 = wtmp[2], r3 = wtmp[3];
48
     r0 = wtmp[0], r1 = wtmp[1], r2 = wtmp[2], r3 = wtmp[3];
49
 
49
 
50
-    r0[0] = MAT(m,0,0), r0[1] = MAT(m,0,1),
51
-    r0[2] = MAT(m,0,2), r0[3] = MAT(m,0,3),
52
-    r0[4] = 1.0f, r0[5] = r0[6] = r0[7] = 0.0f,
50
+    r0[0] = MAT(m, 0, 0), r0[1] = MAT(m, 0, 1),
51
+                                  r0[2] = MAT(m, 0, 2), r0[3] = MAT(m, 0, 3),
52
+                                          r0[4] = 1.0f, r0[5] = r0[6] = r0[7] = 0.0f,
53
 
53
 
54
-    r1[0] = MAT(m,1,0), r1[1] = MAT(m,1,1),
55
-    r1[2] = MAT(m,1,2), r1[3] = MAT(m,1,3),
56
-    r1[5] = 1.0f, r1[4] = r1[6] = r1[7] = 0.0f,
54
+                                                  r1[0] = MAT(m, 1, 0), r1[1] = MAT(m, 1, 1),
55
+                                                          r1[2] = MAT(m, 1, 2), r1[3] = MAT(m, 1, 3),
56
+                                                                  r1[5] = 1.0f, r1[4] = r1[6] = r1[7] = 0.0f,
57
 
57
 
58
-    r2[0] = MAT(m,2,0), r2[1] = MAT(m,2,1),
59
-    r2[2] = MAT(m,2,2), r2[3] = MAT(m,2,3),
60
-    r2[6] = 1.0f, r2[4] = r2[5] = r2[7] = 0.0f,
58
+                                                                          r2[0] = MAT(m, 2, 0), r2[1] = MAT(m, 2, 1),
59
+                                                                                  r2[2] = MAT(m, 2, 2), r2[3] = MAT(m, 2, 3),
60
+                                                                                          r2[6] = 1.0f, r2[4] = r2[5] = r2[7] = 0.0f,
61
 
61
 
62
-    r3[0] = MAT(m,3,0), r3[1] = MAT(m,3,1),
63
-    r3[2] = MAT(m,3,2), r3[3] = MAT(m,3,3),
64
-    r3[7] = 1.0f, r3[4] = r3[5] = r3[6] = 0.0f;
62
+                                                                                                  r3[0] = MAT(m, 3, 0), r3[1] = MAT(m, 3, 1),
63
+                                                                                                          r3[2] = MAT(m, 3, 2), r3[3] = MAT(m, 3, 3),
64
+                                                                                                                  r3[7] = 1.0f, r3[4] = r3[5] = r3[6] = 0.0f;
65
 
65
 
66
     /* choose pivot - or die */
66
     /* choose pivot - or die */
67
-    if (fabs(r3[0])>fabs(r2[0])) SWAP_ROWS(r3, r2);
68
-    if (fabs(r2[0])>fabs(r1[0])) SWAP_ROWS(r2, r1);
69
-    if (fabs(r1[0])>fabs(r0[0])) SWAP_ROWS(r1, r0);
67
+    if (fabs(r3[0]) > fabs(r2[0])) SWAP_ROWS(r3, r2);
68
+    if (fabs(r2[0]) > fabs(r1[0])) SWAP_ROWS(r2, r1);
69
+    if (fabs(r1[0]) > fabs(r0[0])) SWAP_ROWS(r1, r0);
70
     if (0.0f == r0[0])  return false;
70
     if (0.0f == r0[0])  return false;
71
 
71
 
72
     /* eliminate first variable     */
72
     /* eliminate first variable     */
73
-    m1 = r1[0]/r0[0]; m2 = r2[0]/r0[0]; m3 = r3[0]/r0[0];
73
+    m1 = r1[0] / r0[0]; m2 = r2[0] / r0[0]; m3 = r3[0] / r0[0];
74
     s = r0[1]; r1[1] -= m1 * s; r2[1] -= m2 * s; r3[1] -= m3 * s;
74
     s = r0[1]; r1[1] -= m1 * s; r2[1] -= m2 * s; r3[1] -= m3 * s;
75
     s = r0[2]; r1[2] -= m1 * s; r2[2] -= m2 * s; r3[2] -= m3 * s;
75
     s = r0[2]; r1[2] -= m1 * s; r2[2] -= m2 * s; r3[2] -= m3 * s;
76
     s = r0[3]; r1[3] -= m1 * s; r2[3] -= m2 * s; r3[3] -= m3 * s;
76
     s = r0[3]; r1[3] -= m1 * s; r2[3] -= m2 * s; r3[3] -= m3 * s;
84
     if (s != 0.0f) { r1[7] -= m1 * s; r2[7] -= m2 * s; r3[7] -= m3 * s; }
84
     if (s != 0.0f) { r1[7] -= m1 * s; r2[7] -= m2 * s; r3[7] -= m3 * s; }
85
 
85
 
86
     /* choose pivot - or die */
86
     /* choose pivot - or die */
87
-    if (fabs(r3[1])>fabs(r2[1])) SWAP_ROWS(r3, r2);
88
-    if (fabs(r2[1])>fabs(r1[1])) SWAP_ROWS(r2, r1);
87
+    if (fabs(r3[1]) > fabs(r2[1])) SWAP_ROWS(r3, r2);
88
+    if (fabs(r2[1]) > fabs(r1[1])) SWAP_ROWS(r2, r1);
89
     if (0.0f == r1[1])  return false;
89
     if (0.0f == r1[1])  return false;
90
 
90
 
91
     /* eliminate second variable */
91
     /* eliminate second variable */
92
-    m2 = r2[1]/r1[1]; m3 = r3[1]/r1[1];
92
+    m2 = r2[1] / r1[1]; m3 = r3[1] / r1[1];
93
     r2[2] -= m2 * r1[2]; r3[2] -= m3 * r1[2];
93
     r2[2] -= m2 * r1[2]; r3[2] -= m3 * r1[2];
94
     r2[3] -= m2 * r1[3]; r3[3] -= m3 * r1[3];
94
     r2[3] -= m2 * r1[3]; r3[3] -= m3 * r1[3];
95
-    s = r1[4]; if (0.0f != s) { r2[4] -= m2 * s; r3[4] -= m3 * s; }
96
-    s = r1[5]; if (0.0f != s) { r2[5] -= m2 * s; r3[5] -= m3 * s; }
97
-    s = r1[6]; if (0.0f != s) { r2[6] -= m2 * s; r3[6] -= m3 * s; }
98
-    s = r1[7]; if (0.0f != s) { r2[7] -= m2 * s; r3[7] -= m3 * s; }
95
+    s = r1[4];
96
+    if (0.0f != s) { r2[4] -= m2 * s; r3[4] -= m3 * s; }
97
+    s = r1[5];
98
+    if (0.0f != s) { r2[5] -= m2 * s; r3[5] -= m3 * s; }
99
+    s = r1[6];
100
+    if (0.0f != s) { r2[6] -= m2 * s; r3[6] -= m3 * s; }
101
+    s = r1[7];
102
+    if (0.0f != s) { r2[7] -= m2 * s; r3[7] -= m3 * s; }
99
 
103
 
100
     /* choose pivot - or die */
104
     /* choose pivot - or die */
101
-    if (fabs(r3[2])>fabs(r2[2])) SWAP_ROWS(r3, r2);
105
+    if (fabs(r3[2]) > fabs(r2[2])) SWAP_ROWS(r3, r2);
102
     if (0.0f == r2[2])  return false;
106
     if (0.0f == r2[2])  return false;
103
 
107
 
104
     /* eliminate third variable */
108
     /* eliminate third variable */
105
-    m3 = r3[2]/r2[2];
109
+    m3 = r3[2] / r2[2];
106
     r3[3] -= m3 * r2[3], r3[4] -= m3 * r2[4],
110
     r3[3] -= m3 * r2[3], r3[4] -= m3 * r2[4],
107
-    r3[5] -= m3 * r2[5], r3[6] -= m3 * r2[6],
108
-    r3[7] -= m3 * r2[7];
111
+                                  r3[5] -= m3 * r2[5], r3[6] -= m3 * r2[6],
112
+                                           r3[7] -= m3 * r2[7];
109
 
113
 
110
     /* last check */
114
     /* last check */
111
     if (0.0f == r3[3]) return false;
115
     if (0.0f == r3[3]) return false;
112
 
116
 
113
-    s = 1.0f/r3[3];              /* now back substitute row 3 */
117
+    s = 1.0f / r3[3];            /* now back substitute row 3 */
114
     r3[4] *= s; r3[5] *= s; r3[6] *= s; r3[7] *= s;
118
     r3[4] *= s; r3[5] *= s; r3[6] *= s; r3[7] *= s;
115
 
119
 
116
     m2 = r2[3];                 /* now back substitute row 2 */
120
     m2 = r2[3];                 /* now back substitute row 2 */
117
-    s  = 1.0f/r2[2];
121
+    s  = 1.0f / r2[2];
118
     r2[4] = s * (r2[4] - r3[4] * m2), r2[5] = s * (r2[5] - r3[5] * m2),
122
     r2[4] = s * (r2[4] - r3[4] * m2), r2[5] = s * (r2[5] - r3[5] * m2),
119
-    r2[6] = s * (r2[6] - r3[6] * m2), r2[7] = s * (r2[7] - r3[7] * m2);
123
+            r2[6] = s * (r2[6] - r3[6] * m2), r2[7] = s * (r2[7] - r3[7] * m2);
120
     m1 = r1[3];
124
     m1 = r1[3];
121
     r1[4] -= r3[4] * m1, r1[5] -= r3[5] * m1,
125
     r1[4] -= r3[4] * m1, r1[5] -= r3[5] * m1,
122
-    r1[6] -= r3[6] * m1, r1[7] -= r3[7] * m1;
126
+                                  r1[6] -= r3[6] * m1, r1[7] -= r3[7] * m1;
123
     m0 = r0[3];
127
     m0 = r0[3];
124
     r0[4] -= r3[4] * m0, r0[5] -= r3[5] * m0,
128
     r0[4] -= r3[4] * m0, r0[5] -= r3[5] * m0,
125
-    r0[6] -= r3[6] * m0, r0[7] -= r3[7] * m0;
129
+                                  r0[6] -= r3[6] * m0, r0[7] -= r3[7] * m0;
126
 
130
 
127
     m1 = r1[2];                 /* now back substitute row 1 */
131
     m1 = r1[2];                 /* now back substitute row 1 */
128
-    s  = 1.0f/r1[1];
132
+    s  = 1.0f / r1[1];
129
     r1[4] = s * (r1[4] - r2[4] * m1), r1[5] = s * (r1[5] - r2[5] * m1),
133
     r1[4] = s * (r1[4] - r2[4] * m1), r1[5] = s * (r1[5] - r2[5] * m1),
130
-    r1[6] = s * (r1[6] - r2[6] * m1), r1[7] = s * (r1[7] - r2[7] * m1);
134
+            r1[6] = s * (r1[6] - r2[6] * m1), r1[7] = s * (r1[7] - r2[7] * m1);
131
     m0 = r0[2];
135
     m0 = r0[2];
132
     r0[4] -= r2[4] * m0, r0[5] -= r2[5] * m0,
136
     r0[4] -= r2[4] * m0, r0[5] -= r2[5] * m0,
133
-    r0[6] -= r2[6] * m0, r0[7] -= r2[7] * m0;
137
+                                  r0[6] -= r2[6] * m0, r0[7] -= r2[7] * m0;
134
 
138
 
135
     m0 = r0[1];                 /* now back substitute row 0 */
139
     m0 = r0[1];                 /* now back substitute row 0 */
136
-    s  = 1.0f/r0[0];
140
+    s  = 1.0f / r0[0];
137
     r0[4] = s * (r0[4] - r1[4] * m0), r0[5] = s * (r0[5] - r1[5] * m0),
141
     r0[4] = s * (r0[4] - r1[4] * m0), r0[5] = s * (r0[5] - r1[5] * m0),
138
-    r0[6] = s * (r0[6] - r1[6] * m0), r0[7] = s * (r0[7] - r1[7] * m0);
139
-
140
-    MAT(out,0,0) = r0[4];
141
-    MAT(out,0,1) = r0[5], MAT(out,0,2) = r0[6];
142
-    MAT(out,0,3) = r0[7], MAT(out,1,0) = r1[4];
143
-    MAT(out,1,1) = r1[5], MAT(out,1,2) = r1[6];
144
-    MAT(out,1,3) = r1[7], MAT(out,2,0) = r2[4];
145
-    MAT(out,2,1) = r2[5], MAT(out,2,2) = r2[6];
146
-    MAT(out,2,3) = r2[7], MAT(out,3,0) = r3[4];
147
-    MAT(out,3,1) = r3[5], MAT(out,3,2) = r3[6];
148
-    MAT(out,3,3) = r3[7];
142
+            r0[6] = s * (r0[6] - r1[6] * m0), r0[7] = s * (r0[7] - r1[7] * m0);
143
+
144
+    MAT(out, 0, 0) = r0[4];
145
+    MAT(out, 0, 1) = r0[5], MAT(out, 0, 2) = r0[6];
146
+    MAT(out, 0, 3) = r0[7], MAT(out, 1, 0) = r1[4];
147
+    MAT(out, 1, 1) = r1[5], MAT(out, 1, 2) = r1[6];
148
+    MAT(out, 1, 3) = r1[7], MAT(out, 2, 0) = r2[4];
149
+    MAT(out, 2, 1) = r2[5], MAT(out, 2, 2) = r2[6];
150
+    MAT(out, 2, 3) = r2[7], MAT(out, 3, 0) = r3[4];
151
+    MAT(out, 3, 1) = r3[5], MAT(out, 3, 2) = r3[6];
152
+    MAT(out, 3, 3) = r3[7];
149
 
153
 
150
     return true;
154
     return true;
151
 #undef MAT
155
 #undef MAT
157
 }
161
 }
158
 
162
 
159
 void Matrix::getTransposeMatrix(float m[16]) {
163
 void Matrix::getTransposeMatrix(float m[16]) {
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];
162
-    m[ 8]= mMatrix[2]; m[ 9]= mMatrix[6]; m[10]= mMatrix[10]; m[11]=mMatrix[14];
163
-    m[12]= mMatrix[3]; m[13]= mMatrix[7]; m[14]= mMatrix[11]; m[15]=mMatrix[15];
164
+    m[ 0] = mMatrix[0]; m[ 1] = mMatrix[4]; m[ 2] = mMatrix[ 8]; m[ 3] = mMatrix[12];
165
+    m[ 4] = mMatrix[1]; m[ 5] = mMatrix[5]; m[ 6] = mMatrix[ 9]; m[ 7] = mMatrix[13];
166
+    m[ 8] = mMatrix[2]; m[ 9] = mMatrix[6]; m[10] = mMatrix[10]; m[11] = mMatrix[14];
167
+    m[12] = mMatrix[3]; m[13] = mMatrix[7]; m[14] = mMatrix[11]; m[15] = mMatrix[15];
164
 }
168
 }
165
 
169
 
166
-Matrix Matrix::multiply(const Matrix &a, const Matrix &b) {
170
+Matrix Matrix::multiply(const Matrix& a, const Matrix& b) {
167
     Matrix c;
171
     Matrix c;
168
     multiply(a.mMatrix, b.mMatrix, c.mMatrix);
172
     multiply(a.mMatrix, b.mMatrix, c.mMatrix);
169
     return c;
173
     return c;
170
 }
174
 }
171
 
175
 
172
-Matrix Matrix::operator *(const Matrix &a) {
176
+Matrix Matrix::operator *(const Matrix& a) {
173
     return multiply(a, *this);
177
     return multiply(a, *this);
174
 }
178
 }
175
 
179
 
177
     float x = v.mVec[0], y = v.mVec[1], z = v.mVec[2];
181
     float x = v.mVec[0], y = v.mVec[1], z = v.mVec[2];
178
 
182
 
179
 #ifdef COLUMN_ORDER
183
 #ifdef COLUMN_ORDER
180
-    return Vector3d(mMatrix[0]*x + mMatrix[4]*y + mMatrix[ 8]*z + mMatrix[12],
181
-            mMatrix[1]*x + mMatrix[5]*y + mMatrix[ 9]*z + mMatrix[13],
182
-            mMatrix[2]*x + mMatrix[6]*y + mMatrix[10]*z + mMatrix[14]);
184
+    return Vector3d(mMatrix[0] * x + mMatrix[4] * y + mMatrix[ 8] * z + mMatrix[12],
185
+                    mMatrix[1] * x + mMatrix[5] * y + mMatrix[ 9] * z + mMatrix[13],
186
+                    mMatrix[2] * x + mMatrix[6] * y + mMatrix[10] * z + mMatrix[14]);
183
 #else
187
 #else
184
-    return Vector3d(mMatrix[0]*x + mMatrix[1]*y + mMatrix[ 2]*z + mMatrix[ 3],
185
-            mMatrix[4]*x + mMatrix[5]*y + mMatrix[ 6]*z + mMatrix[ 7],
186
-            mMatrix[8]*x + mMatrix[9]*y + mMatrix[10]*z + mMatrix[11]);
188
+    return Vector3d(mMatrix[0] * x + mMatrix[1] * y + mMatrix[ 2] * z + mMatrix[ 3],
189
+                    mMatrix[4] * x + mMatrix[5] * y + mMatrix[ 6] * z + mMatrix[ 7],
190
+                    mMatrix[8] * x + mMatrix[9] * y + mMatrix[10] * z + mMatrix[11]);
187
 #endif
191
 #endif
188
 }
192
 }
189
 
193
 
190
 void Matrix::multiply3v(float v[3], float result[3]) {
194
 void Matrix::multiply3v(float v[3], float result[3]) {
191
     float x = v[0], y = v[1], z = v[2];
195
     float x = v[0], y = v[1], z = v[2];
192
 
196
 
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];
195
-    result[2] = mMatrix[8]*x + mMatrix[9]*y + mMatrix[10]*z + mMatrix[11];
197
+    result[0] = mMatrix[0] * x + mMatrix[1] * y + mMatrix[ 2] * z + mMatrix[ 3];
198
+    result[1] = mMatrix[4] * x + mMatrix[5] * y + mMatrix[ 6] * z + mMatrix[ 7];
199
+    result[2] = mMatrix[8] * x + mMatrix[9] * y + mMatrix[10] * z + mMatrix[11];
196
 }
200
 }
197
 
201
 
198
 void Matrix::multiply4v(float v[4], float result[4]) {
202
 void Matrix::multiply4v(float v[4], float result[4]) {
199
     float x = v[0], y = v[1], z = v[2], w = v[3];
203
     float x = v[0], y = v[1], z = v[2], w = v[3];
200
 
204
 
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;
203
-    result[2] = mMatrix[ 8]*x + mMatrix[ 9]*y + mMatrix[10]*z + mMatrix[11]*w;
204
-    result[3] = mMatrix[12]*x + mMatrix[13]*y + mMatrix[14]*z + mMatrix[15]*w;
205
+    result[0] = mMatrix[ 0] * x + mMatrix[ 1] * y + mMatrix[ 2] * z + mMatrix[ 3] * w;
206
+    result[1] = mMatrix[ 4] * x + mMatrix[ 5] * y + mMatrix[ 6] * z + mMatrix[ 7] * w;
207
+    result[2] = mMatrix[ 8] * x + mMatrix[ 9] * y + mMatrix[10] * z + mMatrix[11] * w;
208
+    result[3] = mMatrix[12] * x + mMatrix[13] * y + mMatrix[14] * z + mMatrix[15] * w;
205
 }
209
 }
206
 
210
 
207
 void Matrix::print() {
211
 void Matrix::print() {
208
     printf("{\n%f %f %f %f\n%f %f %f %f\n%f %f %f %f\n%f %f %f %f\n}\n",
212
     printf("{\n%f %f %f %f\n%f %f %f %f\n%f %f %f %f\n%f %f %f %f\n}\n",
209
 #ifdef COLUMN_ORDER
213
 #ifdef COLUMN_ORDER
210
-            mMatrix[0], mMatrix[4], mMatrix[ 8], mMatrix[12],
211
-            mMatrix[1], mMatrix[5], mMatrix[ 9], mMatrix[13],
212
-            mMatrix[2], mMatrix[6], mMatrix[10], mMatrix[14],
213
-            mMatrix[3], mMatrix[7], mMatrix[11], mMatrix[15]);
214
+           mMatrix[0], mMatrix[4], mMatrix[ 8], mMatrix[12],
215
+           mMatrix[1], mMatrix[5], mMatrix[ 9], mMatrix[13],
216
+           mMatrix[2], mMatrix[6], mMatrix[10], mMatrix[14],
217
+           mMatrix[3], mMatrix[7], mMatrix[11], mMatrix[15]);
214
 #else
218
 #else
215
-            mMatrix[ 0], mMatrix[ 1], mMatrix[ 2], mMatrix[ 3],
216
-            mMatrix[ 4], mMatrix[ 5], mMatrix[ 6], mMatrix[ 7],
217
-            mMatrix[ 8], mMatrix[ 9], mMatrix[10], mMatrix[11],
218
-            mMatrix[12], mMatrix[13], mMatrix[14], mMatrix[15]);
219
+           mMatrix[ 0], mMatrix[ 1], mMatrix[ 2], mMatrix[ 3],
220
+           mMatrix[ 4], mMatrix[ 5], mMatrix[ 6], mMatrix[ 7],
221
+           mMatrix[ 8], mMatrix[ 9], mMatrix[10], mMatrix[11],
222
+           mMatrix[12], mMatrix[13], mMatrix[14], mMatrix[15]);
219
 #endif
223
 #endif
220
 }
224
 }
221
 
225
 
230
             mMatrix[15] == 1)
234
             mMatrix[15] == 1)
231
         return true;
235
         return true;
232
     */
236
     */
233
-    if (equalEpsilon(mMatrix[ 0], 1.0) && equalEpsilon(mMatrix[ 1], 0.0) && equalEpsilon(mMatrix[ 2], 0.0) &&
234
-        equalEpsilon(mMatrix[ 3], 0.0) && equalEpsilon(mMatrix[ 4], 0.0) && equalEpsilon(mMatrix[ 5], 1.0) &&
235
-        equalEpsilon(mMatrix[ 6], 0.0) && equalEpsilon(mMatrix[ 7], 0.0) && equalEpsilon(mMatrix[ 8], 0.0) &&
236
-        equalEpsilon(mMatrix[ 9], 0.0) && equalEpsilon(mMatrix[10], 1.0) && equalEpsilon(mMatrix[11], 0.0) &&
237
-        equalEpsilon(mMatrix[12], 0.0) && equalEpsilon(mMatrix[13], 0.0) && equalEpsilon(mMatrix[14], 0.0) &&
237
+    if (equalEpsilon(mMatrix[ 0], 1.0) && equalEpsilon(mMatrix[ 1], 0.0)
238
+        && equalEpsilon(mMatrix[ 2], 0.0) &&
239
+        equalEpsilon(mMatrix[ 3], 0.0) && equalEpsilon(mMatrix[ 4], 0.0) && equalEpsilon(mMatrix[ 5], 1.0)
240
+        &&
241
+        equalEpsilon(mMatrix[ 6], 0.0) && equalEpsilon(mMatrix[ 7], 0.0) && equalEpsilon(mMatrix[ 8], 0.0)
242
+        &&
243
+        equalEpsilon(mMatrix[ 9], 0.0) && equalEpsilon(mMatrix[10], 1.0) && equalEpsilon(mMatrix[11], 0.0)
244
+        &&
245
+        equalEpsilon(mMatrix[12], 0.0) && equalEpsilon(mMatrix[13], 0.0) && equalEpsilon(mMatrix[14], 0.0)
246
+        &&
238
         equalEpsilon(mMatrix[15], 1.0))
247
         equalEpsilon(mMatrix[15], 1.0))
239
         return true;
248
         return true;
240
 
249
 
252
     mMatrix[12] = 0; mMatrix[13] = 0; mMatrix[14] = 0; mMatrix[15] = 1;
261
     mMatrix[12] = 0; mMatrix[13] = 0; mMatrix[14] = 0; mMatrix[15] = 1;
253
 }
262
 }
254
 
263
 
255
-void Matrix::scale(const float *xyz) {
264
+void Matrix::scale(const float* xyz) {
256
     scale(xyz[0], xyz[1], xyz[2]);
265
     scale(xyz[0], xyz[1], xyz[2]);
257
 }
266
 }
258
 
267
 
269
     multiply(tmp, smatrix, mMatrix);
278
     multiply(tmp, smatrix, mMatrix);
270
 }
279
 }
271
 
280
 
272
-void Matrix::rotate(const float *xyz) {
281
+void Matrix::rotate(const float* xyz) {
273
     rotate(xyz[0], xyz[1], xyz[2]);
282
     rotate(xyz[0], xyz[1], xyz[2]);
274
 }
283
 }
275
 
284
 
276
 void Matrix::rotate(float ax, float ay, float az) {
285
 void Matrix::rotate(float ax, float ay, float az) {
277
     float xmat[16], ymat[16], zmat[16], tmp[16], tmp2[16];
286
     float xmat[16], ymat[16], zmat[16], tmp[16], tmp2[16];
278
 
287
 
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;
281
-    xmat[ 8]=0;         xmat[ 9]=-sinf(ax); xmat[10]=cosf(ax);  xmat[11]=0;
282
-    xmat[12]=0;         xmat[13]=0;         xmat[14]=0;         xmat[15]=1;
288
+    xmat[ 0] = 1;         xmat[ 1] = 0;         xmat[ 2] = 0;         xmat[ 3] = 0;
289
+    xmat[ 4] = 0;         xmat[ 5] = cosf(ax);  xmat[ 6] = sinf(ax);  xmat[ 7] = 0;
290
+    xmat[ 8] = 0;         xmat[ 9] = -sinf(ax); xmat[10] = cosf(ax);  xmat[11] = 0;
291
+    xmat[12] = 0;         xmat[13] = 0;         xmat[14] = 0;         xmat[15] = 1;
283
 
292
 
284
-    ymat[ 0]=cosf(ay);  ymat[ 1]=0;         ymat[ 2]=-sinf(ay); ymat[ 3]=0;
285
-    ymat[ 4]=0;         ymat[ 5]=1;         ymat[ 6]=0;         ymat[ 7]=0;
286
-    ymat[ 8]=sinf(ay);  ymat[ 9]=0;         ymat[10]=cosf(ay);  ymat[11]=0;
287
-    ymat[12]=0;         ymat[13]=0;         ymat[14]=0;         ymat[15]=1;
293
+    ymat[ 0] = cosf(ay);  ymat[ 1] = 0;         ymat[ 2] = -sinf(ay); ymat[ 3] = 0;
294
+    ymat[ 4] = 0;         ymat[ 5] = 1;         ymat[ 6] = 0;         ymat[ 7] = 0;
295
+    ymat[ 8] = sinf(ay);  ymat[ 9] = 0;         ymat[10] = cosf(ay);  ymat[11] = 0;
296
+    ymat[12] = 0;         ymat[13] = 0;         ymat[14] = 0;         ymat[15] = 1;
288
 
297
 
289
-    zmat[ 0]=cosf(az);  zmat[ 1]=sinf(az);  zmat[ 2]=0;         zmat[ 3]=0;
290
-    zmat[ 4]=-sinf(az); zmat[ 5]=cosf(az);  zmat[ 6]=0;         zmat[ 7]=0;
291
-    zmat[ 8]=0;         zmat[ 9]=0;         zmat[10]=1;         zmat[11]=0;
292
-    zmat[12]=0;         zmat[13]=0;         zmat[14]=0;         zmat[15]=1;
298
+    zmat[ 0] = cosf(az);  zmat[ 1] = sinf(az);  zmat[ 2] = 0;         zmat[ 3] = 0;
299
+    zmat[ 4] = -sinf(az); zmat[ 5] = cosf(az);  zmat[ 6] = 0;         zmat[ 7] = 0;
300
+    zmat[ 8] = 0;         zmat[ 9] = 0;         zmat[10] = 1;         zmat[11] = 0;
301
+    zmat[12] = 0;         zmat[13] = 0;         zmat[14] = 0;         zmat[15] = 1;
293
 
302
 
294
     multiply(mMatrix, ymat, tmp);
303
     multiply(mMatrix, ymat, tmp);
295
     multiply(tmp, xmat, tmp2);
304
     multiply(tmp, xmat, tmp2);
296
     multiply(tmp2, zmat, mMatrix);
305
     multiply(tmp2, zmat, mMatrix);
297
 }
306
 }
298
 
307
 
299
-void Matrix::translate(const float *xyz) {
308
+void Matrix::translate(const float* xyz) {
300
     translate(xyz[0], xyz[1], xyz[2]);
309
     translate(xyz[0], xyz[1], xyz[2]);
301
 }
310
 }
302
 
311
 
303
 void Matrix::translate(float tx, float ty, float tz) {
312
 void Matrix::translate(float tx, float ty, float tz) {
304
     float tmat[16], tmp[16];
313
     float tmat[16], tmp[16];
305
 
314
 
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;
308
-    tmat[ 8]=0;  tmat[ 9]=0;  tmat[10]=1;  tmat[11]=0;
309
-    tmat[12]=tx; tmat[13]=ty; tmat[14]=tz; tmat[15]=1;
315
+    tmat[ 0] = 1;  tmat[ 1] = 0;  tmat[ 2] = 0;  tmat[ 3] = 0;
316
+    tmat[ 4] = 0;  tmat[ 5] = 1;  tmat[ 6] = 0;  tmat[ 7] = 0;
317
+    tmat[ 8] = 0;  tmat[ 9] = 0;  tmat[10] = 1;  tmat[11] = 0;
318
+    tmat[12] = tx; tmat[13] = ty; tmat[14] = tz; tmat[15] = 1;
310
 
319
 
311
     copy(mMatrix, tmp);
320
     copy(mMatrix, tmp);
312
     multiply(tmp, tmat, mMatrix);
321
     multiply(tmp, tmat, mMatrix);

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

32
 }
32
 }
33
 
33
 
34
 void Quaternion::getMatrix(float m[16]) {
34
 void Quaternion::getMatrix(float m[16]) {
35
-    m[ 0] = 1.0f - 2.0f * (mY*mY + mZ*mZ);
36
-    m[ 1] = 2.0f * (mX*mY - mW*mZ);
37
-    m[ 2] = 2.0f * (mX*mZ + mW*mY);
35
+    m[ 0] = 1.0f - 2.0f * (mY * mY + mZ * mZ);
36
+    m[ 1] = 2.0f * (mX * mY - mW * mZ);
37
+    m[ 2] = 2.0f * (mX * mZ + mW * mY);
38
     m[ 3] = 0.0f;
38
     m[ 3] = 0.0f;
39
 
39
 
40
-    m[ 4] = 2.0f * (mX*mY + mW*mZ);
41
-    m[ 5] = 1.0f - 2.0f * (mX*mX + mZ*mZ);
42
-    m[ 6] = 2.0f * (mY*mZ - mW*mX);
40
+    m[ 4] = 2.0f * (mX * mY + mW * mZ);
41
+    m[ 5] = 1.0f - 2.0f * (mX * mX + mZ * mZ);
42
+    m[ 6] = 2.0f * (mY * mZ - mW * mX);
43
     m[ 7] = 0.0f;
43
     m[ 7] = 0.0f;
44
 
44
 
45
-    m[ 8] = 2.0f * (mX*mZ - mW*mY);
46
-    m[ 9] = 2.0f * (mY*mZ + mW*mX);
47
-    m[10] = 1.0f - 2.0f * (mX*mX + mY*mY);
45
+    m[ 8] = 2.0f * (mX * mZ - mW * mY);
46
+    m[ 9] = 2.0f * (mY * mZ + mW * mX);
47
+    m[10] = 1.0f - 2.0f * (mX * mX + mY * mY);
48
     m[11] = 0.0f;
48
     m[11] = 0.0f;
49
 
49
 
50
     m[12] = 0.0f;
50
     m[12] = 0.0f;
53
     m[15] = 1.0f;
53
     m[15] = 1.0f;
54
 }
54
 }
55
 
55
 
56
-Quaternion Quaternion::operator *(const Quaternion &q) {
56
+Quaternion Quaternion::operator *(const Quaternion& q) {
57
     return multiply(*this, q);
57
     return multiply(*this, q);
58
 }
58
 }
59
 
59
 
60
-Quaternion Quaternion::operator /(const Quaternion &q) {
60
+Quaternion Quaternion::operator /(const Quaternion& q) {
61
     return divide(*this, q);
61
     return divide(*this, q);
62
 }
62
 }
63
 
63
 
64
-Quaternion Quaternion::operator +(const Quaternion &q) {
64
+Quaternion Quaternion::operator +(const Quaternion& q) {
65
     return add(*this, q);
65
     return add(*this, q);
66
 }
66
 }
67
 
67
 
68
-Quaternion Quaternion::operator -(const Quaternion &q) {
68
+Quaternion Quaternion::operator -(const Quaternion& q) {
69
     return subtract(*this, q);
69
     return subtract(*this, q);
70
 }
70
 }
71
 
71
 
72
-bool Quaternion::operator ==(const Quaternion &q) {
72
+bool Quaternion::operator ==(const Quaternion& q) {
73
     //return (mX == q.mX && mY == q.mY && mZ == q.mZ && mW == q.mW);
73
     //return (mX == q.mX && mY == q.mY && mZ == q.mZ && mW == q.mW);
74
     return (equalEpsilon(mX, q.mX) && equalEpsilon(mY, q.mY) &&
74
     return (equalEpsilon(mX, q.mX) && equalEpsilon(mY, q.mY) &&
75
             equalEpsilon(mZ, q.mZ) && equalEpsilon(mW, q.mW));
75
             equalEpsilon(mZ, q.mZ) && equalEpsilon(mW, q.mW));
84
 }
84
 }
85
 
85
 
86
 Quaternion Quaternion::inverse() {
86
 Quaternion Quaternion::inverse() {
87
-    return conjugate().scale(1/magnitude());
87
+    return conjugate().scale(1 / magnitude());
88
 }
88
 }
89
 
89
 
90
 float Quaternion::dot(Quaternion a, Quaternion b) {
90
 float Quaternion::dot(Quaternion a, Quaternion b) {
106
     float temp, dist;
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;
110
 
110
 
111
     dist = 1.0f / sqrtf(temp);
111
     dist = 1.0f / sqrtf(temp);
112
 
112
 
228
         // If the first element of the diagonal is the greatest value
228
         // If the first element of the diagonal is the greatest value
229
         if (matrix[0] > matrix[5] && matrix[0] > matrix[10]) {
229
         if (matrix[0] > matrix[5] && matrix[0] > matrix[10]) {
230
             // Find the scale according to the first element, and double it
230
             // Find the scale according to the first element, and double it
231
-            scale = (float)sqrt(1.0f + matrix[0] - matrix[5] - matrix[10])*2.0f;
231
+            scale = (float)sqrt(1.0f + matrix[0] - matrix[5] - matrix[10]) * 2.0f;
232
 
232
 
233
             // Calculate the quaternion
233
             // Calculate the quaternion
234
             w = (matrix[9] - matrix[6]) / scale;
234
             w = (matrix[9] - matrix[6]) / scale;
238
         } else if (matrix[5] > matrix[10]) {
238
         } else if (matrix[5] > matrix[10]) {
239
             // The second element of the diagonal is the greatest value
239
             // The second element of the diagonal is the greatest value
240
             // Find the scale according to the second element, and double it
240
             // Find the scale according to the second element, and double it
241
-            scale = (float)sqrt(1.0f + matrix[5] - matrix[0] - matrix[10])*2.0f;
241
+            scale = (float)sqrt(1.0f + matrix[5] - matrix[0] - matrix[10]) * 2.0f;
242
 
242
 
243
             // Calculate the quaternion
243
             // Calculate the quaternion
244
             w = (matrix[2] - matrix[8]) / scale;
244
             w = (matrix[2] - matrix[8]) / scale;
247
             z = (matrix[9] + matrix[6]) / scale;
247
             z = (matrix[9] + matrix[6]) / scale;
248
         } else { // The third element of the diagonal is the greatest value
248
         } else { // The third element of the diagonal is the greatest value
249
             // Find the scale according to the third element, and double it
249
             // Find the scale according to the third element, and double it
250
-            scale = (float)sqrt(1.0f + matrix[10] - matrix[0] - matrix[5])*2.0f;
250
+            scale = (float)sqrt(1.0f + matrix[10] - matrix[0] - matrix[5]) * 2.0f;
251
 
251
 
252
             // Calculate the quaternion
252
             // Calculate the quaternion
253
             w = (matrix[4] - matrix[1]) / scale;
253
             w = (matrix[4] - matrix[1]) / scale;
265
 
265
 
266
 Quaternion Quaternion::multiply(Quaternion a, Quaternion b) {
266
 Quaternion Quaternion::multiply(Quaternion a, Quaternion b) {
267
     return Quaternion(a.mW * b.mW - a.mX * b.mX - a.mY * b.mY - a.mZ * b.mZ,
267
     return Quaternion(a.mW * b.mW - a.mX * b.mX - a.mY * b.mY - a.mZ * b.mZ,
268
-            a.mW * b.mX + a.mX * b.mW + a.mY * b.mZ - a.mZ * b.mY,
269
-            a.mW * b.mY + a.mY * b.mW + a.mZ * b.mX - a.mX * b.mZ,
270
-            a.mW * b.mZ + a.mZ * b.mW + a.mX * b.mY - a.mY * b.mX);
268
+                      a.mW * b.mX + a.mX * b.mW + a.mY * b.mZ - a.mZ * b.mY,
269
+                      a.mW * b.mY + a.mY * b.mW + a.mZ * b.mX - a.mX * b.mZ,
270
+                      a.mW * b.mZ + a.mZ * b.mW + a.mX * b.mY - a.mY * b.mX);
271
 }
271
 }
272
 
272
 
273
 Quaternion Quaternion::divide(Quaternion a, Quaternion b) {
273
 Quaternion Quaternion::divide(Quaternion a, Quaternion b) {
276
 
276
 
277
 Quaternion Quaternion::add(Quaternion a, Quaternion b) {
277
 Quaternion Quaternion::add(Quaternion a, Quaternion b) {
278
     return Quaternion(a.mW + b.mW,
278
     return Quaternion(a.mW + b.mW,
279
-            a.mX + b.mX,
280
-            a.mY + b.mY,
281
-            a.mZ + b.mZ);
279
+                      a.mX + b.mX,
280
+                      a.mY + b.mY,
281
+                      a.mZ + b.mZ);
282
 }
282
 }
283
 
283
 
284
 Quaternion Quaternion::subtract(Quaternion a, Quaternion b) {
284
 Quaternion Quaternion::subtract(Quaternion a, Quaternion b) {
285
     return Quaternion(a.mW - b.mW,
285
     return Quaternion(a.mW - b.mW,
286
-            a.mX - b.mX,
287
-            a.mY - b.mY,
288
-            a.mZ - b.mZ);
286
+                      a.mX - b.mX,
287
+                      a.mY - b.mY,
288
+                      a.mZ - b.mZ);
289
 }
289
 }
290
 
290
 

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

26
     mVec[2] = z;
26
     mVec[2] = z;
27
 }
27
 }
28
 
28
 
29
-Vector3d::Vector3d(const Vector3d &v) {
29
+Vector3d::Vector3d(const Vector3d& v) {
30
     mVec[0] = v.mVec[0];
30
     mVec[0] = v.mVec[0];
31
     mVec[1] = v.mVec[1];
31
     mVec[1] = v.mVec[1];
32
     mVec[2] = v.mVec[2];
32
     mVec[2] = v.mVec[2];
33
 }
33
 }
34
 
34
 
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]);
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]);
37
 }
37
 }
38
 
38
 
39
-Vector3d Vector3d::cross(const Vector3d &u, const Vector3d &v) {
39
+Vector3d Vector3d::cross(const Vector3d& u, const Vector3d& v) {
40
     return Vector3d(u.mVec[1] * v.mVec[2] - u.mVec[2] * v.mVec[1],
40
     return Vector3d(u.mVec[1] * v.mVec[2] - u.mVec[2] * v.mVec[1],
41
-            u.mVec[2] * v.mVec[0] - u.mVec[0] * v.mVec[2],
42
-            u.mVec[0] * v.mVec[1] - u.mVec[1] * v.mVec[0]);
41
+                    u.mVec[2] * v.mVec[0] - u.mVec[0] * v.mVec[2],
42
+                    u.mVec[0] * v.mVec[1] - u.mVec[1] * v.mVec[0]);
43
 }
43
 }
44
 
44
 
45
 float 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
     float norm = magnitude();
50
     float norm = magnitude();
51
 
51
 
52
     return Vector3d(mVec[0] / norm,
52
     return Vector3d(mVec[0] / norm,
53
-            mVec[1] / norm,
54
-            mVec[2] / norm);
53
+                    mVec[1] / norm,
54
+                    mVec[2] / norm);
55
 }
55
 }
56
 
56
 
57
 Vector3d Vector3d::zeroVector() {
57
 Vector3d Vector3d::zeroVector() {
58
     return Vector3d(0, 0, 0);
58
     return Vector3d(0, 0, 0);
59
 }
59
 }
60
 
60
 
61
-Vector3d Vector3d::operator +(const Vector3d &v) {
61
+Vector3d Vector3d::operator +(const Vector3d& v) {
62
     return Vector3d(mVec[0] + v.mVec[0],
62
     return Vector3d(mVec[0] + v.mVec[0],
63
-            mVec[1] + v.mVec[1],
64
-            mVec[2] + v.mVec[2]);
63
+                    mVec[1] + v.mVec[1],
64
+                    mVec[2] + v.mVec[2]);
65
 }
65
 }
66
 
66
 
67
-Vector3d Vector3d::operator -(const Vector3d &v) {
67
+Vector3d Vector3d::operator -(const Vector3d& v) {
68
     return Vector3d(mVec[0] - v.mVec[0],
68
     return Vector3d(mVec[0] - v.mVec[0],
69
-            mVec[1] - v.mVec[1],
70
-            mVec[2] - v.mVec[2]);
69
+                    mVec[1] - v.mVec[1],
70
+                    mVec[2] - v.mVec[2]);
71
 }
71
 }
72
 
72
 
73
 Vector3d Vector3d::operator -() {
73
 Vector3d Vector3d::operator -() {
74
     return Vector3d(-mVec[0],
74
     return Vector3d(-mVec[0],
75
-            -mVec[1],
76
-            -mVec[2]);
75
+                    -mVec[1],
76
+                    -mVec[2]);
77
 }
77
 }
78
 
78
 
79
 Vector3d Vector3d::operator *(float s) {
79
 Vector3d Vector3d::operator *(float s) {
80
     return Vector3d(s * mVec[0],
80
     return Vector3d(s * mVec[0],
81
-            s * mVec[1],
82
-            s * mVec[2]);
81
+                    s * mVec[1],
82
+                    s * mVec[2]);
83
 }
83
 }
84
 
84
 
85
 Vector3d Vector3d::operator /(float s) {
85
 Vector3d Vector3d::operator /(float s) {
86
     return Vector3d(mVec[0] / s,
86
     return Vector3d(mVec[0] / s,
87
-            mVec[1] / s,
88
-            mVec[2] / s);
87
+                    mVec[1] / s,
88
+                    mVec[2] / s);
89
 }
89
 }
90
 
90
 
91
-float 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
 
106
     mVec[2] = 0;
106
     mVec[2] = 0;
107
 }
107
 }
108
 
108
 
109
-Vector3d &Vector3d::operator =(const Vector3d &v) {
109
+Vector3d& Vector3d::operator =(const Vector3d& v) {
110
     mVec[0] = v.mVec[0];
110
     mVec[0] = v.mVec[0];
111
     mVec[1] = v.mVec[1];
111
     mVec[1] = v.mVec[1];
112
     mVec[2] = v.mVec[2];
112
     mVec[2] = v.mVec[2];
113
     return *this;
113
     return *this;
114
 }
114
 }
115
 
115
 
116
-Vector3d &Vector3d::operator +=(const Vector3d &v) {
116
+Vector3d& Vector3d::operator +=(const Vector3d& v) {
117
     mVec[0] += v.mVec[0];
117
     mVec[0] += v.mVec[0];
118
     mVec[1] += v.mVec[1];
118
     mVec[1] += v.mVec[1];
119
     mVec[2] += v.mVec[2];
119
     mVec[2] += v.mVec[2];
120
     return *this;
120
     return *this;
121
 }
121
 }
122
 
122
 
123
-Vector3d &Vector3d::operator -=(const Vector3d &v) {
123
+Vector3d& Vector3d::operator -=(const Vector3d& v) {
124
     mVec[0] -= v.mVec[0];
124
     mVec[0] -= v.mVec[0];
125
     mVec[1] -= v.mVec[1];
125
     mVec[1] -= v.mVec[1];
126
     mVec[2] -= v.mVec[2];
126
     mVec[2] -= v.mVec[2];
127
     return *this;
127
     return *this;
128
 }
128
 }
129
 
129
 
130
-Vector3d &Vector3d::operator *=(float 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;

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

25
 }
25
 }
26
 
26
 
27
 int intersectionLinePolygon(float intersect[3],
27
 int intersectionLinePolygon(float intersect[3],
28
-        float p1[3], float p2[3], float polygon[3][3]) {
28
+                            float p1[3], float p2[3], float polygon[3][3]) {
29
     assert(polygon != NULL);
29
     assert(polygon != NULL);
30
 
30
 
31
     // float normal[3], a[3], b[3];
31
     // float normal[3], a[3], b[3];

+ 2
- 2
src/utils/File.cpp View File

17
     std::transform(name.begin(), name.end(), name.begin(), ::tolower);
17
     std::transform(name.begin(), name.end(), name.begin(), ::tolower);
18
 }
18
 }
19
 
19
 
20
-std::string &File::getName() {
20
+std::string& File::getName() {
21
     return name;
21
     return name;
22
 }
22
 }
23
 
23
 
24
-std::string &File::getPath() {
24
+std::string& File::getPath() {
25
     return path;
25
     return path;
26
 }
26
 }
27
 
27
 

+ 15
- 13
src/utils/Folder.cpp View File

28
 Folder::Folder(std::string folder, bool listDotFiles) {
28
 Folder::Folder(std::string folder, bool listDotFiles) {
29
     if (((folder.length() == 0) || (folder.compare(".") == 0))
29
     if (((folder.length() == 0) || (folder.compare(".") == 0))
30
 #ifdef _WIN32
30
 #ifdef _WIN32
31
-            || ((folder.compare(1, 2, std::string(":\\")) != 0) && (folder.at(0) != '~'))
31
+        || ((folder.compare(1, 2, std::string(":\\")) != 0) && (folder.at(0) != '~'))
32
 #else
32
 #else
33
-            || ((folder.at(0) != '/') && (folder.at(0) != '~'))
33
+        || ((folder.at(0) != '/') && (folder.at(0) != '~'))
34
 #endif
34
 #endif
35
-            ) {
35
+       ) {
36
         // Prepend current working directory
36
         // Prepend current working directory
37
         path = getCurrentWorkingDirectory();
37
         path = getCurrentWorkingDirectory();
38
         if (folder.length() > 1)
38
         if (folder.length() > 1)
70
     listDot = listDotFiles;
70
     listDot = listDotFiles;
71
 }
71
 }
72
 
72
 
73
-std::string &Folder::getName() {
73
+std::string& Folder::getName() {
74
     return name;
74
     return name;
75
 }
75
 }
76
 
76
 
77
-std::string &Folder::getPath() {
77
+std::string& Folder::getPath() {
78
     return path;
78
     return path;
79
 }
79
 }
80
 
80
 
83
     return files.size();
83
     return files.size();
84
 }
84
 }
85
 
85
 
86
-File &Folder::getFile(unsigned long i) {
86
+File& Folder::getFile(unsigned long i) {
87
     createFolderItems();
87
     createFolderItems();
88
     assert(i < files.size());
88
     assert(i < files.size());
89
     return files.at(i);
89
     return files.at(i);
94
     return folders.size();
94
     return folders.size();
95
 }
95
 }
96
 
96
 
97
-Folder &Folder::getFolder(unsigned long i) {
97
+Folder& Folder::getFolder(unsigned long i) {
98
     createFolderItems();
98
     createFolderItems();
99
     assert(i < folders.size());
99
     assert(i < folders.size());
100
     return folders.at(i);
100
     return folders.at(i);
108
     return Folder(parent, listDot);
108
     return Folder(parent, listDot);
109
 }
109
 }
110
 
110
 
111
-void Folder::executeRemoveFiles(std::function<bool (File &f)> func) {
111
+void Folder::executeRemoveFiles(std::function<bool (File& f)> func) {
112
     createFolderItems();
112
     createFolderItems();
113
     for (unsigned long i = 0; i < fileCount(); i++) {
113
     for (unsigned long i = 0; i < fileCount(); i++) {
114
         if (func(getFile(i))) {
114
         if (func(getFile(i))) {
159
 
159
 
160
 #ifdef USE_DIRENT
160
 #ifdef USE_DIRENT
161
 
161
 
162
-int Folder::readFolderItems(std::vector<std::string> &foundFiles, std::vector<std::string> &foundFolders) {
162
+int Folder::readFolderItems(std::vector<std::string>& foundFiles,
163
+                            std::vector<std::string>& foundFolders) {
163
     struct dirent entry;
164
     struct dirent entry;
164
-    struct dirent *ep = nullptr;
165
-    DIR *pakDir;
165
+    struct dirent* ep = nullptr;
166
+    DIR* pakDir;
166
 
167
 
167
     pakDir = opendir(path.c_str());
168
     pakDir = opendir(path.c_str());
168
     if (pakDir != nullptr) {
169
     if (pakDir != nullptr) {
169
         readdir_r(pakDir, &entry, &ep);
170
         readdir_r(pakDir, &entry, &ep);
170
         while (ep != nullptr) {
171
         while (ep != nullptr) {
171
             if ((strcmp(".", ep->d_name) != 0)
172
             if ((strcmp(".", ep->d_name) != 0)
172
-                     && (strcmp("..", ep->d_name) != 0)) {
173
+                && (strcmp("..", ep->d_name) != 0)) {
173
                 std::string tmp(path);
174
                 std::string tmp(path);
174
                 if (tmp.back() != '/')
175
                 if (tmp.back() != '/')
175
                     tmp += '/';
176
                     tmp += '/';
194
 
195
 
195
 #elif defined(USE_FINDFILE)
196
 #elif defined(USE_FINDFILE)
196
 
197
 
197
-int Folder::readFolderItems(std::vector<std::string> &foundFiles, std::vector<std::string> &foundFolders) {
198
+int Folder::readFolderItems(std::vector<std::string>& foundFiles,
199
+                            std::vector<std::string>& foundFolders) {
198
     std::string tmp(path);
200
     std::string tmp(path);
199
     tmp += "/*";
201
     tmp += "/*";
200
 
202
 

+ 0
- 0
src/utils/FolderRecursive.cpp View File


Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save