瀏覽代碼

Fixed StaticMesh Y offset

Thomas Buck 9 年之前
父節點
當前提交
4e9ef0cb43
共有 9 個檔案被更改,包括 27 行新增104 行删除
  1. 1
    0
      ChangeLog.md
  2. 1
    1
      include/RunTime.h
  3. 1
    1
      src/Camera.cpp
  4. 5
    5
      src/Render.cpp
  5. 1
    1
      src/RoomData.cpp
  6. 3
    8
      src/main.cpp
  7. 12
    4
      src/system/Window.cpp
  8. 3
    13
      test/CMakeLists.txt
  9. 0
    71
      test/Loader.cpp

+ 1
- 0
ChangeLog.md 查看文件

@@ -8,6 +8,7 @@
8 8
     * Now using stb_image for all image loading (except pcx format)
9 9
     * Now storing screenshots in PNG format
10 10
     * Updated imgui
11
+    * Fixed StaticMesh Y-offset (position Y needed to be flipped)
11 12
 
12 13
     [ 20141228 ]
13 14
     * Room Bounding Boxes are now visualized in Wireframe mode (again).

+ 1
- 1
include/RunTime.h 查看文件

@@ -36,7 +36,7 @@ class RunTime {
36 36
     static void setRunning(bool run) { gameIsRunning = run; }
37 37
 
38 38
     static bool getShowFPS() { return showFPS; }
39
-    static void setShowFPS(bool fps) { showFPS = fps; }
39
+    static void setShowFPS(bool f) { showFPS = f; }
40 40
 
41 41
     static unsigned long getFPS() { return fps; }
42 42
     static const std::vector<float>& getHistoryFPS() { return history; }

+ 1
- 1
src/Camera.cpp 查看文件

@@ -94,8 +94,8 @@ void Camera::handleMouseMotion(int x, int y) {
94 94
         dirty = true;
95 95
     }
96 96
 
97
-    static int lastDir = 0;
98 97
     if (y != 0) {
98
+        static int lastDir = 0;
99 99
         float a = glm::dot(upUnit, quaternion * upUnit);
100 100
         if (((lastDir >= 0) && (y < 0)) || ((lastDir <= 0) && (y > 0)) || (a > 0.5f)) {
101 101
             quaternion = glm::quat(quaternion * -rightUnit * (rotationDeltaY * y)) * quaternion;

+ 5
- 5
src/Render.cpp 查看文件

@@ -196,12 +196,12 @@ void Render::drawTexture(float x, float y, float w, float h, glm::vec4 color,
196 196
     Window::drawTextGL(vertices, uvs, color, texture);
197 197
 }
198 198
 
199
-void Render::displayUI() {
200
-    static const int modeStringCount = 5;
201
-    static const char* modeStrings[modeStringCount] = {
202
-        "Disable", "Splash", "Texture", "Wireframe", "Solid"
203
-    };
199
+static const int modeStringCount = 5;
200
+static const char* modeStrings[modeStringCount] = {
201
+    "Disable", "Splash", "Texture", "Wireframe", "Solid"
202
+};
204 203
 
204
+void Render::displayUI() {
205 205
     if (ImGui::CollapsingHeader("Render Settings")) {
206 206
         int item = 0;
207 207
         if (mode == RenderMode::LoadScreen)

+ 1
- 1
src/RoomData.cpp 查看文件

@@ -65,7 +65,7 @@ void StaticModel::display(glm::mat4 view, glm::mat4 projection) {
65 65
         assert(cache >= 0);
66 66
     }
67 67
 
68
-    glm::mat4 translate = glm::translate(glm::mat4(1.0f), pos);
68
+    glm::mat4 translate = glm::translate(glm::mat4(1.0f), glm::vec3(pos.x, -pos.y, pos.z));
69 69
     glm::mat4 rotate = glm::rotate(glm::mat4(1.0f), angle, glm::vec3(0.0f, 1.0f, 0.0f));
70 70
     glm::mat4 model = translate * rotate;
71 71
     getWorld().getStaticMesh(cache).display(model, view, projection);

+ 3
- 8
src/main.cpp 查看文件

@@ -10,12 +10,6 @@
10 10
 
11 11
 #include "global.h"
12 12
 #include "Exception.h"
13
-#include "commander/commander.h"
14
-#include "commands/Command.h"
15
-#include "utils/time.h"
16
-
17
-#ifndef UNIT_TEST
18
-
19 13
 #include "Game.h"
20 14
 #include "Log.h"
21 15
 #include "MenuFolder.h"
@@ -24,9 +18,12 @@
24 18
 #include "TextureManager.h"
25 19
 #include "UI.h"
26 20
 #include "World.h"
21
+#include "commander/commander.h"
22
+#include "commands/Command.h"
27 23
 #include "system/Font.h"
28 24
 #include "system/Sound.h"
29 25
 #include "system/Window.h"
26
+#include "utils/time.h"
30 27
 
31 28
 static std::string configFileToUse;
32 29
 
@@ -176,8 +173,6 @@ void renderFrame() {
176 173
     RunTime::updateFPS();
177 174
 }
178 175
 
179
-#endif // UNIT_TEST
180
-
181 176
 #if defined(HAVE_EXECINFO_H) && defined(HAVE_BACKTRACE) && defined(HAVE_BACKTRACE_SYMBOLS)
182 177
 #ifndef NDEBUG
183 178
 

+ 12
- 4
src/system/Window.cpp 查看文件

@@ -19,11 +19,13 @@
19 19
 #endif
20 20
 
21 21
 int Window::initialize() {
22
-    int res = -1;
22
+    int res;
23 23
 #ifdef USING_SDL
24 24
     res = WindowSDL::initialize();
25 25
 #elif defined(USING_GLFW)
26 26
     res = WindowGLFW::initialize();
27
+#else
28
+    res = -1;
27 29
 #endif
28 30
 
29 31
     initializeGL();
@@ -84,11 +86,13 @@ void Window::setFullscreen(bool f) {
84 86
 }
85 87
 
86 88
 bool Window::getFullscreen() {
87
-    bool ret = false;
89
+    bool ret;
88 90
 #ifdef USING_SDL
89 91
     ret = WindowSDL::getFullscreen();
90 92
 #elif defined(USING_GLFW)
91 93
     ret = WindowGLFW::getFullscreen();
94
+#else
95
+    ret = false;
92 96
 #endif
93 97
 
94 98
     return ret;
@@ -103,11 +107,13 @@ void Window::setMousegrab(bool g) {
103 107
 }
104 108
 
105 109
 bool Window::getMousegrab() {
106
-    bool ret = false;
110
+    bool ret;
107 111
 #ifdef USING_SDL
108 112
     ret = WindowSDL::getMousegrab();
109 113
 #elif defined(USING_GLFW)
110 114
     ret = WindowGLFW::getMousegrab();
115
+#else
116
+    ret = false;
111 117
 #endif
112 118
 
113 119
     return ret;
@@ -122,11 +128,13 @@ void Window::setTextInput(bool t) {
122 128
 }
123 129
 
124 130
 bool Window::getTextInput() {
125
-    bool ret = false;
131
+    bool ret;
126 132
 #ifdef USING_SDL
127 133
     ret = WindowSDL::getTextInput();
128 134
 #elif defined(USING_GLFW)
129 135
     ret = WindowGLFW::getTextInput();
136
+#else
137
+    ret = false;
130 138
 #endif
131 139
 
132 140
     return ret;

+ 3
- 13
test/CMakeLists.txt 查看文件

@@ -8,27 +8,17 @@ add_custom_target (check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure)
8 8
 
9 9
 add_executable (tester_binary EXCLUDE_FROM_ALL
10 10
     "binary.cpp" "../src/utils/binary.cpp"
11
-    "../src/Exception.cpp" "../src/main.cpp"
11
+    "../src/Exception.cpp"
12 12
 )
13 13
 add_dependencies (check tester_binary)
14 14
 add_test (NAME test_binary COMMAND tester_binary)
15 15
 
16 16
 #################################################################
17 17
 
18
-add_executable (tester_loader EXCLUDE_FROM_ALL
19
-    "Loader.cpp" "../src/utils/binary.cpp"
20
-    "../src/loader/Loader.cpp" "../src/loader/LoaderTR1.cpp"
21
-    "../src/loader/LoaderTR2.cpp" "../src/loader/LoaderTR3.cpp"
22
-)
23
-#add_dependencies (check tester_loader)
24
-#add_test (NAME test_loader COMMAND tester_loader)
25
-
26
-#################################################################
27
-
28 18
 add_executable (tester_script EXCLUDE_FROM_ALL
29 19
     "Script.cpp" "ScriptPayload.h" "ScriptTest.h"
30
-    "../src/Script.cpp" "../src/main.cpp"
31
-    "../src/utils/binary.cpp" "../src/Exception.cpp"
20
+    "../src/Script.cpp" "../src/Exception.cpp"
21
+    "../src/utils/binary.cpp"
32 22
 )
33 23
 
34 24
 find_package (ZLIB REQUIRED)

+ 0
- 71
test/Loader.cpp 查看文件

@@ -1,71 +0,0 @@
1
-/*!
2
- * \file test/Loader.cpp
3
- * \brief Level Loader Unit Test
4
- *
5
- * \author xythobuz
6
- */
7
-
8
-#include "global.h"
9
-#include "loader/Loader.h"
10
-
11
-int main(int argc, char* argv[]) {
12
-    if (argc != 2) {
13
-        std::cout << "Usage:" << std::endl;
14
-        std::cout << "\t" << argv[0] << " /path/to/level.tr2" << std::endl;
15
-        return 0; // Don't fail when just running this test...
16
-    }
17
-
18
-    // Print file engine version
19
-    std::cout << "Loading \"" << argv[1] << "\"" << std::endl;
20
-    std::cout << "Trying to detect engine version... ";
21
-    Loader::LoaderVersion v = Loader::checkFile(argv[1]);
22
-    switch (v) {
23
-        case Loader::TR_1:
24
-            std::cout << "TR 1";
25
-            break;
26
-
27
-        case Loader::TR_2:
28
-            std::cout << "TR 2";
29
-            break;
30
-
31
-        case Loader::TR_3:
32
-            std::cout << "TR 3";
33
-            break;
34
-
35
-        case Loader::TR_4:
36
-            std::cout << "TR 4";
37
-            break;
38
-
39
-        case Loader::TR_5:
40
-            std::cout << "TR 5";
41
-            break;
42
-
43
-        case Loader::TR_UNKNOWN:
44
-            std::cout << "Unknown version!" << std::endl;
45
-            return 2;
46
-    }
47
-    std::cout << " detected!" << std::endl;
48
-
49
-    // Create matching loader
50
-    std::cout << std::endl << "Creating level loader... ";
51
-    std::unique_ptr<Loader> loader = Loader::createLoader(argv[1]);
52
-    if (!loader) {
53
-        std::cout << "Failed!" << std::endl;
54
-        return 3;
55
-    } else {
56
-        std::cout << "Success!" << std::endl;
57
-    }
58
-
59
-    // Try to load the level
60
-    std::cout << "Trying to load level... ";
61
-    int error = loader->load(argv[1]);
62
-    if (error != 0) {
63
-        std::cout << "Failure!" << std::endl;
64
-        std::cout << "Error code: " << error << std::endl;
65
-    } else {
66
-        std::cout << "Success!" << std::endl;
67
-    }
68
-
69
-    return error;
70
-}
71
-

Loading…
取消
儲存