ソースを参照

Imgui update, debugging

Thomas Buck 9年前
コミット
d6eab5d760

+ 5
- 6
CMakeLists.txt ファイルの表示

@@ -37,17 +37,16 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
37 37
     set (WARNINGS "${WARNINGS} -Wno-padded -Wno-packed")
38 38
     set (WARNINGS "${WARNINGS} -Wno-global-constructors -Wno-exit-time-destructors")
39 39
     set (WARNINGS "${WARNINGS} -Wno-documentation-unknown-command -Wno-c++98-compat-pedantic")
40
+    set (WARNINGS "${WARNINGS} -Wno-date-time -Wno-unused-variable")
40 41
     set (WARNINGS "${WARNINGS} -Wno-shorten-64-to-32 -Wno-sign-compare -Wno-sign-conversion")
41 42
     set (OpenRaider_CXX_FLAGS "${OpenRaider_CXX_FLAGS} -std=c++11")
42
-    set (OpenRaider_CXX_FLAGS_DEBUG "${OpenRaider_CXX_FLAGS_DEBUG} -g -O0 -ftrapv")
43
-    set (OpenRaider_CXX_FLAGS_RELEASE "${OpenRaider_CXX_FLAGS_RELEASE} -O2 -fomit-frame-pointer")
44
-    set (OpenRaider_CXX_FLAGS_RELEASE "${OpenRaider_CXX_FLAGS_RELEASE} -ffast-math -funroll-loops")
43
+    set (OpenRaider_CXX_FLAGS_DEBUG "${OpenRaider_CXX_FLAGS_DEBUG} -g -O0")
44
+    set (OpenRaider_CXX_FLAGS_RELEASE "${OpenRaider_CXX_FLAGS_RELEASE} -O2")
45 45
 elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
46 46
     set (WARNINGS "${WARNINGS} -Wall -Wextra -Wpedantic")
47 47
     set (OpenRaider_CXX_FLAGS "${OpenRaider_CXX_FLAGS} -std=c++11")
48
-    set (OpenRaider_CXX_FLAGS_DEBUG "${OpenRaider_CXX_FLAGS_DEBUG} -g -O0 -ftrapv")
49
-    set (OpenRaider_CXX_FLAGS_RELEASE "${OpenRaider_CXX_FLAGS_RELEASE} -O2 -fomit-frame-pointer")
50
-    set (OpenRaider_CXX_FLAGS_RELEASE "${OpenRaider_CXX_FLAGS_RELEASE} -ffast-math -funroll-loops")
48
+    set (OpenRaider_CXX_FLAGS_DEBUG "${OpenRaider_CXX_FLAGS_DEBUG} -g -O0")
49
+    set (OpenRaider_CXX_FLAGS_RELEASE "${OpenRaider_CXX_FLAGS_RELEASE} -O2")
51 50
 elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
52 51
     # TODO Visual C++ compiler flags?
53 52
 endif()

+ 21
- 7
src/Render.cpp ファイルの表示

@@ -130,14 +130,19 @@ void Render::buildRoomList(glm::mat4 VP, int room, glm::vec2 min, glm::vec2 max)
130 130
         // Check all portals leading from this room to somewhere else
131 131
         for (int i = 0; i < World::getRoom(room).sizePortals(); i++) {
132 132
             auto& portal = World::getRoom(room).getPortal(i);
133
-            auto& room = World::getRoom(portal.getAdjoiningRoom());
133
+            auto& r = World::getRoom(portal.getAdjoiningRoom());
134 134
 
135 135
             // Calculate the 2D screen-space bounding box of this portal
136 136
             glm::vec3 newMin, newMax;
137 137
             for (int c = 0; c < 4; c++) {
138
-                glm::vec3 vert = portal.getVertex(c);
139
-                glm::vec4 result = VP * glm::vec4(vert, 1.0f);
140
-                vert = glm::vec3(result) / result.w;
138
+                glm::vec3 port = portal.getVertex(c);
139
+                glm::vec4 result = VP * glm::vec4(port, 1.0f);
140
+                glm::vec3 vert = glm::vec3(result) / result.w;
141
+
142
+                ImGui::Text("%.2f %.2f %.2f", port.x, port.y, port.z);
143
+                ImGui::Text("%.2f %.2f %.2f %.2f", result.x, result.y, result.z, result.w);
144
+                ImGui::Text("%.2f %.2f %.2f", vert.x, vert.y, vert.z);
145
+                ImGui::Text("----");
141 146
 
142 147
                 if (c == 0) {
143 148
                     newMin = vert;
@@ -158,11 +163,20 @@ void Render::buildRoomList(glm::mat4 VP, int room, glm::vec2 min, glm::vec2 max)
158 163
                 }
159 164
             }
160 165
 
166
+            //ImGui::Text("%.2f %.2f %.2f", newMin.x, newMin.y, newMin.z);
167
+            //ImGui::Text("%.2f %.2f %.2f", newMax.x, newMax.y, newMax.z);
168
+            //ImGui::Text("----");
169
+
161 170
             //! \fixme Currently also checking behind player, because Z is always 1.0f?!
162 171
             //if ((newMin.z > 0.0f) || (newMin.z < -1.0f) || (newMax.z > 0.0f) || (newMax.z < -1.0f)) {
163 172
             //    continue;
164 173
             //}
165 174
 
175
+            //! \fixme Need to check portal normal, only render if it points in our direction
176
+            //if (!normalFacingUs) {
177
+            //    continue;
178
+            //}
179
+
166 180
             // Check if the portal intersects the portal leading into this room
167 181
             if (!((min.x < newMax.x) && (max.x > newMin.x)
168 182
                 && (min.y < newMax.y) && (max.y > newMin.y))) {
@@ -170,14 +184,14 @@ void Render::buildRoomList(glm::mat4 VP, int room, glm::vec2 min, glm::vec2 max)
170 184
             }
171 185
 
172 186
             // Check if the connected room is in our view frustum (could be visible)
173
-            if (!Camera::boxInFrustum(room.getBoundingBox())) {
174
-                continue;
187
+            if (!Camera::boxInFrustum(r.getBoundingBox())) {
188
+                //continue;
175 189
             }
176 190
 
177 191
             // Check if this room is already in the list...
178 192
             bool found = false;
179 193
             for (int n = 0; n < roomList.size(); n++) {
180
-                if (roomList.at(n).room == &room) {
194
+                if (roomList.at(n).room == &r) {
181 195
                     found = true;
182 196
                     break;
183 197
                 }

+ 6
- 5
src/UI.cpp ファイルの表示

@@ -151,7 +151,7 @@ void UI::eventsFinished() {
151 151
     io.DisplaySize = ImVec2(Window::getSize().x, Window::getSize().y);
152 152
 
153 153
     static unsigned long lastTime = 0;
154
-    io.DeltaTime = ((float)(systemTimerGet() - lastTime)) / 1000.0f;
154
+    io.DeltaTime = (systemTimerGet() - lastTime) / 1000.0f;
155 155
     lastTime = systemTimerGet();
156 156
     if (io.DeltaTime <= 0.0f)
157 157
         io.DeltaTime = 1.0f / 60.0f;
@@ -172,8 +172,9 @@ void UI::eventsFinished() {
172 172
 
173 173
         if (!(visible || Console::isVisible() || Menu::isVisible())) {
174 174
             for (int n = forwardAction; n < ActionEventCount; n++) {
175
-                if (RunTime::getKeyBinding((ActionEvents)n) == std::get<0>(i))
176
-                    Game::handleAction((ActionEvents)n, !std::get<1>(i));
175
+                auto ae = static_cast<ActionEvents>(n);
176
+                if (RunTime::getKeyBinding(ae) == std::get<0>(i))
177
+                    Game::handleAction(ae, !std::get<1>(i));
177 178
             }
178 179
         }
179 180
 
@@ -402,7 +403,7 @@ void UI::handleText(char* text, bool notFinished) {
402 403
 
403 404
 void UI::handleMouseClick(unsigned int x, unsigned int y, KeyboardButton button, bool released) {
404 405
     ImGuiIO& io = ImGui::GetIO();
405
-    io.MousePos = ImVec2((float)x, (float)y);
406
+    io.MousePos = ImVec2(x, y);
406 407
     if (button == leftmouseKey) {
407 408
         io.MouseDown[0] = !released;
408 409
     } else if (button == rightmouseKey) {
@@ -420,7 +421,7 @@ void UI::handleMouseClick(unsigned int x, unsigned int y, KeyboardButton button,
420 421
 
421 422
 void UI::handleMouseMotion(int xrel, int yrel, int xabs, int yabs) {
422 423
     ImGuiIO& io = ImGui::GetIO();
423
-    io.MousePos = ImVec2((float)xabs, (float)yabs);
424
+    io.MousePos = ImVec2(xabs, yabs);
424 425
 
425 426
     motionEvents.push_back(std::make_tuple(xrel, yrel, xabs, yabs));
426 427
 }

+ 1
- 1
src/commands/CommandBind.cpp ファイルの表示

@@ -97,7 +97,7 @@ KeyboardButton CommandBind::stringToKeyboardButton(std::string key) {
97 97
         char c = key[1];
98 98
         if (((c >= '0') && (c <= '9'))
99 99
             || ((c >= 'a') && (c <= 'z')))
100
-            return (KeyboardButton)c;
100
+            return static_cast<KeyboardButton>(c);
101 101
     } else if ((key.length() >= 3) && (key[0] == '\"') && (key[key.length() - 1] == '\"')) {
102 102
         // Special characters like tilde, esc, quote...
103 103
         key.erase(key.length() - 1); // Delete " at end

+ 8
- 5
src/deps/imgui/imconfig.h ファイルの表示

@@ -19,6 +19,12 @@
19 19
 //#define IMGUI_API __declspec( dllexport )
20 20
 //#define IMGUI_API __declspec( dllimport )
21 21
 
22
+//---- Include imgui_user.inl at the end of imgui.cpp so you can include code that extends ImGui using its private data/functions.
23
+#define IMGUI_INCLUDE_IMGUI_USER_INL
24
+
25
+//---- Include imgui_user.h at the end of imgui.h
26
+#define IMGUI_INCLUDE_IMGUI_USER_H
27
+
22 28
 //---- Don't implement default handlers for Windows (so as not to link with OpenClipboard() and others Win32 functions)
23 29
 //#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCS
24 30
 //#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCS
@@ -26,11 +32,8 @@
26 32
 //---- Don't implement help and test window functionality (ShowUserGuide()/ShowStyleEditor()/ShowTestWindow() methods will be empty)
27 33
 //#define IMGUI_DISABLE_TEST_WINDOWS
28 34
 
29
-//---- Include imgui_user.inl at the end of imgui.cpp so you can include code that extends ImGui using its private data/functions.
30
-#define IMGUI_INCLUDE_IMGUI_USER_INL
31
-
32
-//---- Include imgui_user.h at the end of imgui.h
33
-#define IMGUI_INCLUDE_IMGUI_USER_H
35
+//---- Implement STB libraries in a namespace to avoid conflicts
36
+//#define IMGUI_STB_NAMESPACE     ImStb
34 37
 
35 38
 //---- Define constructor and implicit cast operators to convert back<>forth from your math types and ImVec2/ImVec4.
36 39
 #define IM_VEC2_CLASS_EXTRA                                                \

+ 198
- 44
src/deps/imgui/imgui.cpp ファイルの表示

@@ -1,4 +1,4 @@
1
-// ImGui library v1.38 WIP
1
+// ImGui library v1.39 WIP
2 2
 // See ImGui::ShowTestWindow() for sample code.
3 3
 // Read 'Programmer guide' below for notes on how to setup ImGui in your codebase.
4 4
 // Get latest version at https://github.com/ocornut/imgui
@@ -13,6 +13,7 @@
13 13
  - API BREAKING CHANGES (read me when you update!)
14 14
  - FREQUENTLY ASKED QUESTIONS (FAQ), TIPS
15 15
    - Can I have multiple widgets with the same label? (Yes)
16
+   - How do I update to a newer version of ImGui?
16 17
    - Why is my text output blurry?
17 18
    - How can I load a different font than the default? 
18 19
    - How can I load multiple fonts?
@@ -268,6 +269,15 @@
268 269
       e.g. when displaying a single object that may change over time (1-1 relationship), using a static string as ID will preserve your node open/closed state when the targeted object change.
269 270
       e.g. when displaying a list of objects, using indices or pointers as ID will preserve the node open/closed state differently. experiment and see what makes more sense!
270 271
 
272
+ Q: How do I update to a newer version of ImGui?
273
+ A: Overwrite the following files:
274
+     imgui.cpp
275
+     imgui.h
276
+     stb_rect_pack.h
277
+     stb_textedit.h
278
+     stb_truetype.h
279
+    Check the "API BREAKING CHANGES" sections for a list of occasional API breaking changes.
280
+
271 281
  Q: Why is my text output blurry?
272 282
  A: In your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f)
273 283
 
@@ -492,7 +502,7 @@ static bool         ItemAdd(const ImRect& bb, const ImGuiID* id);
492 502
 static void         ItemSize(ImVec2 size, float text_offset_y = 0.0f);
493 503
 static void         ItemSize(const ImRect& bb, float text_offset_y = 0.0f);
494 504
 static void         PushColumnClipRect(int column_index = -1);
495
-static bool         IsClippedEx(const ImRect& bb, bool clip_even_when_logged);
505
+static bool         IsClippedEx(const ImRect& bb, const ImGuiID* id, bool clip_even_when_logged);
496 506
 
497 507
 static bool         IsMouseHoveringRect(const ImRect& bb);
498 508
 static bool         IsKeyPressedMap(ImGuiKey key, bool repeat = true);
@@ -1146,6 +1156,7 @@ struct ImGuiState
1146 1156
     ImGuiID                 ScalarAsInputTextId;                // Temporary text input when CTRL+clicking on a slider, etc.
1147 1157
     ImGuiStorage            ColorEditModeStorage;               // for user selection
1148 1158
     ImGuiID                 ActiveComboID;
1159
+    ImVec2                  ActiveClickDeltaToCenter;
1149 1160
     float                   DragCurrentValue;                   // current dragged value, always float, not rounded by end-user precision settings
1150 1161
     ImVec2                  DragLastMouseDelta;
1151 1162
     float                   DragSpeedDefaultRatio;              // if speed == 0.0f, uses (max-min) * DragSpeedDefaultRatio
@@ -1204,6 +1215,7 @@ struct ImGuiState
1204 1215
 
1205 1216
         ScalarAsInputTextId = 0;
1206 1217
         ActiveComboID = 0;
1218
+        ActiveClickDeltaToCenter = ImVec2(0.0f, 0.0f);
1207 1219
         DragCurrentValue = 0.0f;
1208 1220
         DragLastMouseDelta = ImVec2(0.0f, 0.0f);
1209 1221
         DragSpeedDefaultRatio = 0.01f;
@@ -1403,6 +1415,14 @@ float* ImGuiStorage::GetFloatRef(ImGuiID key, float default_val)
1403 1415
     return &it->val_f;
1404 1416
 }
1405 1417
 
1418
+void** ImGuiStorage::GetVoidPtrRef(ImGuiID key, void* default_val)
1419
+{
1420
+    ImVector<Pair>::iterator it = LowerBound(Data, key);
1421
+    if (it == Data.end() || it->key != key)
1422
+        it = Data.insert(it, Pair(key, default_val));
1423
+    return &it->val_p;
1424
+}
1425
+
1406 1426
 // FIXME-OPT: Wasting CPU because all SetInt() are preceeded by GetInt() calls so we should have the result from lower_bound already in place.
1407 1427
 // However we only use SetInt() on explicit user action (so that's maximum once a frame) so the optimisation isn't much needed.
1408 1428
 void ImGuiStorage::SetInt(ImU32 key, int val)
@@ -4255,7 +4275,7 @@ void ImGui::TextUnformatted(const char* text, const char* text_end)
4255 4275
                 while (line < text_end)
4256 4276
                 {
4257 4277
                     const char* line_end = strchr(line, '\n');
4258
-                    if (IsClippedEx(line_rect, false))
4278
+                    if (IsClippedEx(line_rect, NULL, false))
4259 4279
                         break;
4260 4280
 
4261 4281
                     const ImVec2 line_size = CalcTextSize(line, line_end, false);
@@ -5126,7 +5146,7 @@ static inline float RoundScalar(float value, int decimal_precision)
5126 5146
     return value;
5127 5147
 }
5128 5148
 
5129
-static bool SliderBehavior(const ImRect& frame_bb, const ImRect& slider_bb, ImGuiID id, float* v, float v_min, float v_max, float power, int decimal_precision, bool horizontal)
5149
+static bool SliderScalarBehavior(const ImRect& frame_bb, ImGuiID id, float* v, float v_min, float v_max, float power, int decimal_precision, bool horizontal)
5130 5150
 {
5131 5151
     ImGuiState& g = *GImGui;
5132 5152
     ImGuiWindow* window = GetCurrentWindow();
@@ -5137,15 +5157,16 @@ static bool SliderBehavior(const ImRect& frame_bb, const ImRect& slider_bb, ImGu
5137 5157
 
5138 5158
     const bool is_non_linear = fabsf(power - 1.0f) > 0.0001f;
5139 5159
 
5140
-    const float slider_sz = horizontal ? slider_bb.GetWidth() : slider_bb.GetHeight();
5160
+    const float padding = horizontal ? style.FramePadding.x : style.FramePadding.y;
5161
+    const float slider_sz = horizontal ? (frame_bb.GetWidth() - padding * 2.0f) : (frame_bb.GetHeight() - padding * 2.0f);
5141 5162
     float grab_sz;
5142 5163
     if (decimal_precision > 0)
5143 5164
         grab_sz = ImMin(style.GrabMinSize, slider_sz);
5144 5165
     else
5145 5166
         grab_sz = ImMin(ImMax(1.0f * (slider_sz / (v_max-v_min+1.0f)), style.GrabMinSize), slider_sz);  // Integer sliders, if possible have the grab size represent 1 unit
5146 5167
     const float slider_usable_sz = slider_sz - grab_sz;
5147
-    const float slider_usable_pos_min = (horizontal ? slider_bb.Min.x : slider_bb.Min.y) + grab_sz*0.5f;
5148
-    const float slider_usable_pos_max = (horizontal ? slider_bb.Max.x : slider_bb.Max.y) - grab_sz*0.5f;
5168
+    const float slider_usable_pos_min = (horizontal ? frame_bb.Min.x : frame_bb.Min.y) + padding + grab_sz*0.5f;
5169
+    const float slider_usable_pos_max = (horizontal ? frame_bb.Max.x : frame_bb.Max.y) - padding - grab_sz*0.5f;
5149 5170
 
5150 5171
     bool value_changed = false;
5151 5172
 
@@ -5183,7 +5204,7 @@ static bool SliderBehavior(const ImRect& frame_bb, const ImRect& slider_bb, ImGu
5183 5204
                     // Negative: rescale to the negative range before powering
5184 5205
                     float a = 1.0f - (normalized_pos / linear_zero_pos);
5185 5206
                     a = powf(a, power);
5186
-                    new_value = ImLerp(ImMin(v_max,0.f), v_min, a);
5207
+                    new_value = ImLerp(ImMin(v_max,0.0f), v_min, a);
5187 5208
                 }
5188 5209
                 else
5189 5210
                 {
@@ -5272,7 +5293,6 @@ bool ImGui::SliderFloat(const char* label, float* v, float v_min, float v_max, c
5272 5293
 
5273 5294
     const ImVec2 label_size = CalcTextSize(label, NULL, true);
5274 5295
     const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w, label_size.y) + style.FramePadding*2.0f);
5275
-    const ImRect inner_bb(frame_bb.Min + style.FramePadding, frame_bb.Max - style.FramePadding);
5276 5296
     const ImRect total_bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0.0f));
5277 5297
 
5278 5298
     // NB- we don't call ItemSize() yet because we may turn into a text edit box below
@@ -5312,16 +5332,16 @@ bool ImGui::SliderFloat(const char* label, float* v, float v_min, float v_max, c
5312 5332
     ItemSize(total_bb, style.FramePadding.y);
5313 5333
 
5314 5334
     // Actual slider behavior + render grab
5315
-    const bool value_changed = SliderBehavior(frame_bb, inner_bb, id, v, v_min, v_max, power, decimal_precision, true);
5335
+    const bool value_changed = SliderScalarBehavior(frame_bb, id, v, v_min, v_max, power, decimal_precision, true);
5316 5336
 
5317 5337
     // Display value using user-provided display format so user can add prefix/suffix/decorations to the value.
5318 5338
     char value_buf[64];
5319 5339
     const char* value_buf_end = value_buf + ImFormatString(value_buf, IM_ARRAYSIZE(value_buf), display_format, *v);
5320 5340
     const ImVec2 value_text_size = CalcTextSize(value_buf, value_buf_end, true);
5321
-    RenderTextClipped(ImVec2(ImMax(frame_bb.Min.x + style.FramePadding.x, inner_bb.GetCenter().x - value_text_size.x*0.5f), frame_bb.Min.y + style.FramePadding.y), value_buf, value_buf_end, &value_text_size, frame_bb.Max);
5341
+    RenderTextClipped(ImVec2(ImMax(frame_bb.Min.x + style.FramePadding.x, frame_bb.GetCenter().x - value_text_size.x*0.5f), frame_bb.Min.y + style.FramePadding.y), value_buf, value_buf_end, &value_text_size, frame_bb.Max);
5322 5342
 
5323 5343
     if (label_size.x > 0.0f)
5324
-        RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, inner_bb.Min.y), label);
5344
+        RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label);
5325 5345
 
5326 5346
     return value_changed;
5327 5347
 }
@@ -5338,7 +5358,6 @@ bool ImGui::VSliderFloat(const char* label, const ImVec2& size, float* v, float
5338 5358
 
5339 5359
     const ImVec2 label_size = CalcTextSize(label, NULL, true);
5340 5360
     const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + size);
5341
-    const ImRect slider_bb(frame_bb.Min + style.FramePadding, frame_bb.Max - style.FramePadding);
5342 5361
     const ImRect bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0.0f));
5343 5362
 
5344 5363
     ItemSize(bb, style.FramePadding.y);
@@ -5361,17 +5380,17 @@ bool ImGui::VSliderFloat(const char* label, const ImVec2& size, float* v, float
5361 5380
     }
5362 5381
 
5363 5382
     // Actual slider behavior + render grab
5364
-    bool value_changed = SliderBehavior(frame_bb, slider_bb, id, v, v_min, v_max, power, decimal_precision, false);
5383
+    bool value_changed = SliderScalarBehavior(frame_bb, id, v, v_min, v_max, power, decimal_precision, false);
5365 5384
 
5366 5385
     // Display value using user-provided display format so user can add prefix/suffix/decorations to the value.
5367 5386
     // For the vertical slider we allow centered text to overlap the frame padding
5368 5387
     char value_buf[64];
5369 5388
     char* value_buf_end = value_buf + ImFormatString(value_buf, IM_ARRAYSIZE(value_buf), display_format, *v);
5370 5389
     const ImVec2 value_text_size = CalcTextSize(value_buf, value_buf_end, true);
5371
-    RenderTextClipped(ImVec2(ImMax(frame_bb.Min.x, slider_bb.GetCenter().x - value_text_size.x*0.5f), frame_bb.Min.y + style.FramePadding.y), value_buf, value_buf_end, &value_text_size, frame_bb.Max);
5390
+    RenderTextClipped(ImVec2(ImMax(frame_bb.Min.x, frame_bb.GetCenter().x - value_text_size.x*0.5f), frame_bb.Min.y + style.FramePadding.y), value_buf, value_buf_end, &value_text_size, frame_bb.Max);
5372 5391
 
5373 5392
     if (label_size.x > 0.0f)
5374
-        RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, slider_bb.Min.y), label);
5393
+        RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label);
5375 5394
 
5376 5395
     return value_changed;
5377 5396
 }
@@ -5405,7 +5424,7 @@ bool ImGui::VSliderInt(const char* label, const ImVec2& size, int* v, int v_min,
5405 5424
 }
5406 5425
 
5407 5426
 // Add multiple sliders on 1 line for compact edition of multiple components
5408
-static bool SliderFloatN(const char* label, float v[3], int components, float v_min, float v_max, const char* display_format, float power)
5427
+static bool SliderFloatN(const char* label, float* v, int components, float v_min, float v_max, const char* display_format, float power)
5409 5428
 {
5410 5429
     ImGuiState& g = *GImGui;
5411 5430
     ImGuiWindow* window = GetCurrentWindow();
@@ -5457,7 +5476,7 @@ bool ImGui::SliderFloat4(const char* label, float v[4], float v_min, float v_max
5457 5476
     return SliderFloatN(label, v, 4, v_min, v_max, display_format, power);
5458 5477
 }
5459 5478
 
5460
-static bool SliderIntN(const char* label, int v[3], int components, int v_min, int v_max, const char* display_format)
5479
+static bool SliderIntN(const char* label, int* v, int components, int v_min, int v_max, const char* display_format)
5461 5480
 {
5462 5481
     ImGuiState& g = *GImGui;
5463 5482
     ImGuiWindow* window = GetCurrentWindow();
@@ -5522,7 +5541,7 @@ static bool DragScalarBehavior(const ImRect& frame_bb, ImGuiID id, float* v, flo
5522 5541
 
5523 5542
     bool value_changed = false;
5524 5543
 
5525
-    // Process clicking on the slider
5544
+    // Process clicking on the drag
5526 5545
     if (g.ActiveId == id)
5527 5546
     {
5528 5547
         if (g.IO.MouseDown[0])
@@ -5652,6 +5671,58 @@ bool ImGui::DragFloat(const char* label, float *v, float v_speed, float v_min, f
5652 5671
     return value_changed;
5653 5672
 }
5654 5673
 
5674
+static bool DragFloatN(const char* label, float* v, int components, float v_speed, float v_min, float v_max, const char* display_format, float power)
5675
+{
5676
+    ImGuiState& g = *GImGui;
5677
+    ImGuiWindow* window = GetCurrentWindow();
5678
+    if (window->SkipItems)
5679
+        return false;
5680
+
5681
+    const ImGuiStyle& style = g.Style;
5682
+    const float w_full = ImGui::CalcItemWidth();
5683
+    const float w_item_one  = ImMax(1.0f, (float)(int)((w_full - (style.FramePadding.x*2.0f + style.ItemInnerSpacing.x)*(components-1)) / (float)components));
5684
+    const float w_item_last = ImMax(1.0f, (float)(int)(w_full - (w_item_one + style.FramePadding.x*2.0f + style.ItemInnerSpacing.x)*(components-1)));
5685
+
5686
+    bool value_changed = false;
5687
+    ImGui::BeginGroup();
5688
+    ImGui::PushID(label);
5689
+    ImGui::PushItemWidth(w_item_one);
5690
+    for (int i = 0; i < components; i++)
5691
+    {
5692
+        ImGui::PushID(i);
5693
+        if (i + 1 == components)
5694
+        {
5695
+            ImGui::PopItemWidth();
5696
+            ImGui::PushItemWidth(w_item_last);
5697
+        }
5698
+        value_changed |= ImGui::DragFloat("##v", &v[i], v_speed, v_min, v_max, display_format, power);
5699
+        ImGui::SameLine(0, (int)style.ItemInnerSpacing.x);
5700
+        ImGui::PopID();
5701
+    }
5702
+    ImGui::PopItemWidth();
5703
+    ImGui::PopID();
5704
+
5705
+    ImGui::TextUnformatted(label, FindTextDisplayEnd(label));
5706
+    ImGui::EndGroup();
5707
+
5708
+    return value_changed;
5709
+}
5710
+
5711
+bool ImGui::DragFloat2(const char* label, float v[2], float v_speed, float v_min, float v_max, const char* display_format, float power)
5712
+{
5713
+    return DragFloatN(label, v, 2, v_speed, v_min, v_max, display_format, power);
5714
+}
5715
+
5716
+bool ImGui::DragFloat3(const char* label, float v[2], float v_speed, float v_min, float v_max, const char* display_format, float power)
5717
+{
5718
+    return DragFloatN(label, v, 3, v_speed, v_min, v_max, display_format, power);
5719
+}
5720
+
5721
+bool ImGui::DragFloat4(const char* label, float v[2], float v_speed, float v_min, float v_max, const char* display_format, float power)
5722
+{
5723
+    return DragFloatN(label, v, 4, v_speed, v_min, v_max, display_format, power);
5724
+}
5725
+
5655 5726
 // NB: v_speed is float to allow adjusting the drag speed with more precision
5656 5727
 bool ImGui::DragInt(const char* label, int* v, float v_speed, int v_min, int v_max, const char* display_format)
5657 5728
 {
@@ -5663,6 +5734,58 @@ bool ImGui::DragInt(const char* label, int* v, float v_speed, int v_min, int v_m
5663 5734
     return value_changed;
5664 5735
 }
5665 5736
 
5737
+static bool DragIntN(const char* label, int* v, int components, float v_speed, int v_min, int v_max, const char* display_format)
5738
+{
5739
+    ImGuiState& g = *GImGui;
5740
+    ImGuiWindow* window = GetCurrentWindow();
5741
+    if (window->SkipItems)
5742
+        return false;
5743
+
5744
+    const ImGuiStyle& style = g.Style;
5745
+    const float w_full = ImGui::CalcItemWidth();
5746
+    const float w_item_one  = ImMax(1.0f, (float)(int)((w_full - (style.FramePadding.x*2.0f + style.ItemInnerSpacing.x)*(components-1)) / (float)components));
5747
+    const float w_item_last = ImMax(1.0f, (float)(int)(w_full - (w_item_one + style.FramePadding.x*2.0f + style.ItemInnerSpacing.x)*(components-1)));
5748
+
5749
+    bool value_changed = false;
5750
+    ImGui::BeginGroup();
5751
+    ImGui::PushID(label);
5752
+    ImGui::PushItemWidth(w_item_one);
5753
+    for (int i = 0; i < components; i++)
5754
+    {
5755
+        ImGui::PushID(i);
5756
+        if (i + 1 == components)
5757
+        {
5758
+            ImGui::PopItemWidth();
5759
+            ImGui::PushItemWidth(w_item_last);
5760
+        }
5761
+        value_changed |= ImGui::DragInt("##v", &v[i], v_speed, v_min, v_max, display_format);
5762
+        ImGui::SameLine(0, (int)style.ItemInnerSpacing.x);
5763
+        ImGui::PopID();
5764
+    }
5765
+    ImGui::PopItemWidth();
5766
+    ImGui::PopID();
5767
+
5768
+    ImGui::TextUnformatted(label, FindTextDisplayEnd(label));
5769
+    ImGui::EndGroup();
5770
+
5771
+    return value_changed;
5772
+}
5773
+
5774
+bool ImGui::DragInt2(const char* label, int v[2], float v_speed, int v_min, int v_max, const char* display_format)
5775
+{
5776
+    return DragIntN(label, v, 2, v_speed, v_min, v_max, display_format);
5777
+}
5778
+
5779
+bool ImGui::DragInt3(const char* label, int v[3], float v_speed, int v_min, int v_max, const char* display_format)
5780
+{
5781
+    return DragIntN(label, v, 3, v_speed, v_min, v_max, display_format);
5782
+}
5783
+
5784
+bool ImGui::DragInt4(const char* label, int v[4], float v_speed, int v_min, int v_max, const char* display_format)
5785
+{
5786
+    return DragIntN(label, v, 4, v_speed, v_min, v_max, display_format);
5787
+}
5788
+
5666 5789
 enum ImGuiPlotType
5667 5790
 {
5668 5791
     ImGuiPlotType_Lines,
@@ -6865,7 +6988,8 @@ bool ImGui::Selectable(const char* label, bool selected, const ImVec2& size_arg)
6865 6988
     const ImVec2 size(size_arg.x != 0.0f ? size_arg.x : w, size_arg.y != 0.0f ? size_arg.y : label_size.y);
6866 6989
     ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size);
6867 6990
     ItemSize(bb);
6868
-    bb.Max.x += style.AutoFitPadding.x;
6991
+    if (size_arg.x == 0.0f)
6992
+        bb.Max.x += style.AutoFitPadding.x;
6869 6993
 
6870 6994
     // Selectables are meant to be tightly packed together. So for both rendering and collision we extend to compensate for spacing.
6871 6995
     ImRect bb_with_spacing = bb;
@@ -7256,15 +7380,16 @@ static inline void ItemSize(const ImRect& bb, float text_offset_y)
7256 7380
     ItemSize(bb.GetSize(), text_offset_y); 
7257 7381
 }
7258 7382
 
7259
-static bool IsClippedEx(const ImRect& bb, bool clip_even_when_logged)
7383
+static bool IsClippedEx(const ImRect& bb, const ImGuiID* id, bool clip_even_when_logged)
7260 7384
 {
7261 7385
     ImGuiState& g = *GImGui;
7262 7386
     ImGuiWindow* window = GetCurrentWindow();
7263 7387
 
7264 7388
     if (!bb.Overlaps(ImRect(window->ClipRectStack.back())))
7265 7389
     {
7266
-        if (clip_even_when_logged || !g.LogEnabled)
7267
-            return true;
7390
+        if (!id || *id != GImGui->ActiveId)
7391
+            if (clip_even_when_logged || !g.LogEnabled)
7392
+                return true;
7268 7393
     }
7269 7394
     return false;
7270 7395
 }
@@ -7272,7 +7397,7 @@ static bool IsClippedEx(const ImRect& bb, bool clip_even_when_logged)
7272 7397
 bool ImGui::IsRectClipped(const ImVec2& size)
7273 7398
 {
7274 7399
     ImGuiWindow* window = GetCurrentWindow();
7275
-    return IsClippedEx(ImRect(window->DC.CursorPos, window->DC.CursorPos + size), true);
7400
+    return IsClippedEx(ImRect(window->DC.CursorPos, window->DC.CursorPos + size), NULL, true);
7276 7401
 }
7277 7402
 
7278 7403
 static bool ItemAdd(const ImRect& bb, const ImGuiID* id)
@@ -7280,13 +7405,10 @@ static bool ItemAdd(const ImRect& bb, const ImGuiID* id)
7280 7405
     ImGuiWindow* window = GetCurrentWindow();
7281 7406
     window->DC.LastItemID = id ? *id : 0;
7282 7407
     window->DC.LastItemRect = bb;
7283
-    if (IsClippedEx(bb, false))
7408
+    if (IsClippedEx(bb, id, false))
7284 7409
     {
7285
-        if (!id || *id != GImGui->ActiveId)
7286
-        {
7287
-            window->DC.LastItemHoveredAndUsable = window->DC.LastItemHoveredRect = false;
7288
-            return false;
7289
-        }
7410
+        window->DC.LastItemHoveredAndUsable = window->DC.LastItemHoveredRect = false;
7411
+        return false;
7290 7412
     }
7291 7413
 
7292 7414
     // This is a sensible default, but widgets are free to override it after calling ItemAdd()
@@ -7416,7 +7538,7 @@ void ImGui::NextColumn()
7416 7538
         window->DC.CurrentLineTextBaseOffset = 0.0f;
7417 7539
 
7418 7540
         PushColumnClipRect();
7419
-        ImGui::PushItemWidth(ImGui::GetColumnWidth() * 0.65f);
7541
+        ImGui::PushItemWidth(ImGui::GetColumnWidth() * 0.65f);  // FIXME
7420 7542
     }
7421 7543
 }
7422 7544
 
@@ -7432,6 +7554,21 @@ int ImGui::GetColumnsCount()
7432 7554
     return window->DC.ColumnsCount;
7433 7555
 }
7434 7556
 
7557
+static float GetDraggedColumnOffset(int column_index)
7558
+{
7559
+    // Active (dragged) column always follow mouse. The reason we need this is that dragging a column to the right edge of an auto-resizing
7560
+    // window creates a feedback loop because we store normalized positions/ So while dragging we enforce absolute positioning
7561
+    ImGuiState& g = *GImGui;
7562
+    ImGuiWindow* window = GetCurrentWindow();
7563
+    IM_ASSERT(g.ActiveId == window->DC.ColumnsSetID + ImGuiID(column_index));
7564
+
7565
+    float x = g.IO.MousePos.x + g.ActiveClickDeltaToCenter.x;
7566
+    x -= window->Pos.x;
7567
+    x = ImClamp(x, ImGui::GetColumnOffset(column_index-1)+g.Style.ColumnsMinSpacing, ImGui::GetColumnOffset(column_index+1)-g.Style.ColumnsMinSpacing);
7568
+
7569
+    return x;
7570
+}
7571
+
7435 7572
 float ImGui::GetColumnOffset(int column_index)
7436 7573
 {
7437 7574
     ImGuiState& g = *GImGui;
@@ -7439,6 +7576,13 @@ float ImGui::GetColumnOffset(int column_index)
7439 7576
     if (column_index < 0)
7440 7577
         column_index = window->DC.ColumnsCurrent;
7441 7578
 
7579
+    if (g.ActiveId)
7580
+    {
7581
+        const ImGuiID column_id = window->DC.ColumnsSetID + ImGuiID(column_index);
7582
+        if (g.ActiveId == column_id)
7583
+            return GetDraggedColumnOffset(column_index);
7584
+    }
7585
+
7442 7586
     // Read from cache
7443 7587
     IM_ASSERT(column_index < (int)window->DC.ColumnsOffsetsT.size());
7444 7588
     const float t = window->DC.ColumnsOffsetsT[column_index];
@@ -7515,7 +7659,7 @@ void ImGui::Columns(int columns_count, const char* id, bool border)
7515 7659
             const ImGuiID column_id = window->DC.ColumnsSetID + ImGuiID(i);
7516 7660
             const ImRect column_rect(ImVec2(x-4,y1),ImVec2(x+4,y2));
7517 7661
 
7518
-            if (IsClippedEx(column_rect, false))
7662
+            if (IsClippedEx(column_rect, &column_id, false))
7519 7663
                 continue;
7520 7664
 
7521 7665
             bool hovered, held;
@@ -7530,10 +7674,11 @@ void ImGui::Columns(int columns_count, const char* id, bool border)
7530 7674
 
7531 7675
             if (held)
7532 7676
             {
7533
-                x -= window->Pos.x;
7534
-                x = ImClamp(x + g.IO.MouseDelta.x, ImGui::GetColumnOffset(i-1)+g.Style.ColumnsMinSpacing, ImGui::GetColumnOffset(i+1)-g.Style.ColumnsMinSpacing);
7677
+                if (g.ActiveIdIsJustActivated)
7678
+                    g.ActiveClickDeltaToCenter.x = x - g.IO.MousePos.x;
7679
+
7680
+                x = GetDraggedColumnOffset(i);
7535 7681
                 SetColumnOffset(i, x);
7536
-                x += window->Pos.x;
7537 7682
             }
7538 7683
         }
7539 7684
     }
@@ -9868,29 +10013,32 @@ void ImGui::ShowTestWindow(bool* opened)
9868 10013
             ImGui::InputFloat3("input float3", vec4a);
9869 10014
         }
9870 10015
 
9871
-        /*
9872 10016
         {
9873 10017
             static int i1=50;
9874 10018
             static int i2=42;
9875 10019
             ImGui::DragInt("drag int", &i1, 1);
9876
-            ImGui::DragInt("drag int 0..100", &i2, 1, 0, 100);
10020
+            ImGui::SameLine();
10021
+            ImGui::TextColored(ImColor(170,170,170,255), "(?)");
10022
+            if (ImGui::IsItemHovered())
10023
+                ImGui::SetTooltip("Click and drag to edit value.\nHold SHIFT/ALT for faster/slower edit.\nDouble-click or CTRL+click to input text");
10024
+
10025
+            ImGui::DragInt("drag int 0..100", &i2, 1, 0, 100, "%.0f%%");
9877 10026
 
9878 10027
             static float f1=1.00f;
9879 10028
             static float f2=0.0067f;
9880 10029
             ImGui::DragFloat("drag float", &f1, 1.0f);
9881
-            ImGui::DragFloat("drag small float", &f2, 0.0001f, 0.0f, 0.0f, "%.06f");
10030
+            ImGui::DragFloat("drag small float", &f2, 0.0001f, 0.0f, 0.0f, "%.06f ns");
9882 10031
         }
9883
-        */
9884 10032
 
9885 10033
         {
9886 10034
             static int i1=0;
9887
-            static int i2=42;
10035
+            //static int i2=42;
9888 10036
             ImGui::SliderInt("slider int 0..3", &i1, 0, 3);
9889
-            ImGui::SliderInt("slider int -100..100", &i2, -100, 100);
10037
+            //ImGui::SliderInt("slider int -100..100", &i2, -100, 100);
9890 10038
 
9891
-            static float f1=1.123f;
9892
-            static float f2=0;
9893
-            ImGui::SliderFloat("slider float", &f1, 0.0f, 2.0f);
10039
+            static float f1=0.123f;
10040
+            static float f2=0.0f;
10041
+            ImGui::SliderFloat("slider float", &f1, 0.0f, 1.0f, "ratio = %.3f");
9894 10042
             ImGui::SliderFloat("slider log float", &f2, -10.0f, 10.0f, "%.4f", 3.0f);
9895 10043
             static float angle = 0.0f;
9896 10044
             ImGui::SliderAngle("slider angle", &angle);
@@ -9918,18 +10066,24 @@ void ImGui::ShowTestWindow(bool* opened)
9918 10066
             static int vec4i[4] = { 1, 5, 100, 255 };
9919 10067
 
9920 10068
             ImGui::InputFloat2("input float2", vec4f);
10069
+            ImGui::DragFloat2("drag float2", vec4f, 0.01f, 0.0f, 1.0f);
9921 10070
             ImGui::SliderFloat2("slider float2", vec4f, 0.0f, 1.0f);
10071
+            ImGui::DragInt2("drag int2", vec4i, 1, 0, 255);
9922 10072
             ImGui::InputInt2("input int2", vec4i);
9923 10073
             ImGui::SliderInt2("slider int2", vec4i, 0, 255);
9924 10074
 
9925 10075
             ImGui::InputFloat3("input float3", vec4f);
10076
+            ImGui::DragFloat3("drag float3", vec4f, 0.01f, 0.0f, 1.0f);
9926 10077
             ImGui::SliderFloat3("slider float3", vec4f, 0.0f, 1.0f);
10078
+            ImGui::DragInt3("drag int3", vec4i, 1, 0, 255);
9927 10079
             ImGui::InputInt3("input int3", vec4i);
9928 10080
             ImGui::SliderInt3("slider int3", vec4i, 0, 255);
9929 10081
 
9930 10082
             ImGui::InputFloat4("input float4", vec4f);
10083
+            ImGui::DragFloat4("drag float4", vec4f, 0.01f, 0.0f, 1.0f);
9931 10084
             ImGui::SliderFloat4("slider float4", vec4f, 0.0f, 1.0f);
9932 10085
             ImGui::InputInt4("input int4", vec4i);
10086
+            ImGui::DragInt4("drag int4", vec4i, 1, 0, 255);
9933 10087
             ImGui::SliderInt4("slider int4", vec4i, 0, 255);
9934 10088
 
9935 10089
             ImGui::Indent();

+ 11
- 5
src/deps/imgui/imgui.h ファイルの表示

@@ -1,4 +1,4 @@
1
-// ImGui library v1.38 WIP
1
+// ImGui library v1.39 WIP
2 2
 // See .cpp file for documentation.
3 3
 // See ImGui::ShowTestWindow() for sample code.
4 4
 // Read 'Programmer guide' in .cpp for notes on how to setup ImGui in your codebase.
@@ -13,7 +13,7 @@
13 13
 #include <stdlib.h>         // NULL, malloc, free, qsort, atoi
14 14
 #include <string.h>         // memset, memmove, memcpy, strlen, strchr, strcpy, strcmp
15 15
 
16
-#define IMGUI_VERSION       "1.38 WIP"
16
+#define IMGUI_VERSION       "1.39 WIP"
17 17
 
18 18
 // Define assertion handler.
19 19
 #ifndef IM_ASSERT
@@ -317,9 +317,14 @@ namespace ImGui
317 317
     IMGUI_API bool          VSliderInt(const char* label, const ImVec2& size, int* v, int v_min, int v_max, const char* display_format = "%.0f");
318 318
 
319 319
     // Widgets: Drags (tip: ctrl+click on a drag box to input text)
320
-    // ImGui 1.38+ work-in-progress, may change name or API.
321
-    IMGUI_API bool          DragFloat(const char* label, float* v, float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* display_format = "%.3f", float power = 1.0f);  // If v_max >= v_max we have no bound
322
-    IMGUI_API bool          DragInt(const char* label, int* v, float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* display_format = "%.0f");                                    // If v_max >= v_max we have no bound
320
+    IMGUI_API bool          DragFloat(const char* label, float* v, float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* display_format = "%.3f", float power = 1.0f);     // If v_max >= v_max we have no bound
321
+    IMGUI_API bool          DragFloat2(const char* label, float v[2], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* display_format = "%.3f", float power = 1.0f);
322
+    IMGUI_API bool          DragFloat3(const char* label, float v[3], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* display_format = "%.3f", float power = 1.0f);
323
+    IMGUI_API bool          DragFloat4(const char* label, float v[4], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* display_format = "%.3f", float power = 1.0f);
324
+    IMGUI_API bool          DragInt(const char* label, int* v, float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* display_format = "%.0f");                                       // If v_max >= v_max we have no bound
325
+    IMGUI_API bool          DragInt2(const char* label, int v[2], float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* display_format = "%.0f");
326
+    IMGUI_API bool          DragInt3(const char* label, int v[3], float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* display_format = "%.0f");
327
+    IMGUI_API bool          DragInt4(const char* label, int v[4], float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* display_format = "%.0f");
323 328
 
324 329
     // Widgets: Input
325 330
     IMGUI_API bool          InputText(const char* label, char* buf, size_t buf_size, ImGuiInputTextFlags flags = 0, ImGuiTextEditCallback callback = NULL, void* user_data = NULL);
@@ -799,6 +804,7 @@ struct ImGuiStorage
799 804
     // - You can also use this to quickly create temporary editable values during a session of using Edit&Continue, without restarting your application.
800 805
     IMGUI_API int*    GetIntRef(ImGuiID key, int default_val = 0);
801 806
     IMGUI_API float*  GetFloatRef(ImGuiID key, float default_val = 0);
807
+    IMGUI_API void**  GetVoidPtrRef(ImGuiID key, void* default_val = NULL);
802 808
 
803 809
     // Use on your own storage if you know only integer are being stored (open/close all tree nodes)
804 810
     IMGUI_API void    SetAllInt(int val);

+ 5
- 2
src/loader/Loader.cpp ファイルの表示

@@ -51,9 +51,12 @@ std::unique_ptr<Loader> Loader::createLoader(std::string f) {
51 51
 
52 52
         case TR_3:
53 53
             return std::unique_ptr<Loader>(new LoaderTR3());
54
-    }
55 54
 
56
-    return nullptr;
55
+        case TR_UNKNOWN:
56
+        case TR_4:
57
+        case TR_5:
58
+            return nullptr;
59
+    }
57 60
 }
58 61
 
59 62
 Loader::~Loader() { }

+ 3
- 3
src/loader/LoaderTR1.cpp ファイルの表示

@@ -307,7 +307,7 @@ void LoaderTR1::loadAngleSet(BoneFrame* bf, BinaryReader& frame, uint16_t numMes
307 307
             tmp += (i - 1) * 16; // TODO ?
308 308
             BinaryMemory tree(tmp, (numMeshTrees * 4) - meshTree - ((i - 1) * 16));
309 309
 
310
-            flag = (char)tree.readU32();
310
+            flag = static_cast<char>(tree.readU32());
311 311
             offset.x = tree.read32();
312 312
             offset.y = tree.read32();
313 313
             offset.z = tree.read32();
@@ -317,8 +317,8 @@ void LoaderTR1::loadAngleSet(BoneFrame* bf, BinaryReader& frame, uint16_t numMes
317 317
             rotation[0] = (a & 0x3FF0) >> 4;
318 318
             rotation[1] = ((a & 0x000F) << 6) | ((b & 0xFC00) >> 10);
319 319
             rotation[2] = b & 0x03FF;
320
-            for (int i = 0; i < 3; i++)
321
-                rotation[i] = rotation[i] * 360.0f / 1024.0f;
320
+            for (int n = 0; n < 3; n++)
321
+                rotation[n] = rotation[n] * 360.0f / 1024.0f;
322 322
         }
323 323
 
324 324
         glm::vec3 rot(rotation[0], rotation[1], rotation[2]);

+ 12
- 12
src/loader/LoaderTR2.cpp ファイルの表示

@@ -189,8 +189,8 @@ void LoaderTR2::loadAnimatedTextures() {
189 189
 // ---- Rooms ----
190 190
 
191 191
 void LoaderTR2::loadRoomLights() {
192
-    int16_t intensity1 = file.read16();
193
-    int16_t intensity2 = file.read16();
192
+    int16_t roomIntensity1 = file.read16();
193
+    int16_t roomIntensity2 = file.read16();
194 194
     int16_t lightMode = file.read16();
195 195
 
196 196
     uint16_t numLights = file.readU16();
@@ -314,10 +314,10 @@ void LoaderTR2::loadRooms() {
314 314
 
315 315
             // Fill bounding box
316 316
             if (v == 0) {
317
-                for (int i = 0; i < 2; i++) {
318
-                    bbox[i].x = vert.x;
319
-                    bbox[i].y = vert.y;
320
-                    bbox[i].z = vert.z;
317
+                for (int n = 0; n < 2; n++) {
318
+                    bbox[n].x = vert.x;
319
+                    bbox[n].y = vert.y;
320
+                    bbox[n].z = vert.z;
321 321
                 }
322 322
             } else {
323 323
                 if (vert.x < bbox[0].x)
@@ -413,7 +413,7 @@ void LoaderTR2::loadRooms() {
413 413
             // There is a special value of the 'real' index, 2047 or 0x7FF.
414 414
 
415 415
             bool wall = false;
416
-            if ((((uint8_t)floor) == 0x81) || (((uint8_t)ceiling) == 0x81)) {
416
+            if (((floor & 0xFF) == 0x81) || ((ceiling & 0xFF) == 0x81)) {
417 417
                 wall = true;
418 418
             }
419 419
 
@@ -728,7 +728,7 @@ void LoaderTR2::loadAngleSet(BoneFrame* bf, BinaryReader& frame, uint16_t numMes
728 728
             char* tmp = reinterpret_cast<char*>(&meshTrees[0]) + meshTree; // TODO (meshTree * 4)?
729 729
             tmp += (i - 1) * 16; // TODO ?
730 730
             BinaryMemory tree(tmp, (numMeshTrees * 4) - meshTree - ((i - 1) * 16));
731
-            flag = (char)tree.readU32();
731
+            flag = static_cast<char>(tree.readU32());
732 732
             offset.x = tree.read32();
733 733
             offset.y = tree.read32();
734 734
             offset.z = tree.read32();
@@ -741,15 +741,15 @@ void LoaderTR2::loadAngleSet(BoneFrame* bf, BinaryReader& frame, uint16_t numMes
741 741
                     index = 2;
742 742
                 else if (a & 0x4000)
743 743
                     index = 1;
744
-                rotation[index] = ((float)(a & 0x03FF)) * 360.0f / 1024.0f;
744
+                rotation[index] = (static_cast<float>(a & 0x03FF)) * 360.0f / 1024.0f;
745 745
             } else {
746 746
                 // Three angles
747 747
                 uint16_t b = frame.readU16();
748 748
                 rotation[0] = (a & 0x3FF0) >> 4;
749 749
                 rotation[1] = ((a & 0x000F) << 6) | ((b & 0xFC00) >> 10);
750 750
                 rotation[2] = b & 0x03FF;
751
-                for (int i = 0; i < 3; i++)
752
-                    rotation[i] = rotation[i] * 360.0f / 1024.0f;
751
+                for (int n = 0; n < 3; n++)
752
+                    rotation[n] = rotation[n] * 360.0f / 1024.0f;
753 753
             }
754 754
         }
755 755
 
@@ -1122,7 +1122,7 @@ void LoaderTR2::loadSoundDetails() {
1122 1122
         // Bits 0-1: channel number?
1123 1123
         uint16_t unknown2 = file.readU16();
1124 1124
 
1125
-        SoundManager::addSoundDetail(sample, ((float)volume) / 32767.0f);
1125
+        SoundManager::addSoundDetail(sample, volume / 32767.0f);
1126 1126
     }
1127 1127
 
1128 1128
     if (numSoundDetails > 0)

+ 2
- 2
src/loader/LoaderTR3.cpp ファイルの表示

@@ -53,8 +53,8 @@ int LoaderTR3::load(std::string f) {
53 53
 }
54 54
 
55 55
 void LoaderTR3::loadRoomLights() {
56
-    int16_t intensity1 = file.read16();
57
-    int16_t intensity2 = file.read16();
56
+    int16_t roomIntensity1 = file.read16();
57
+    int16_t roomIntensity2 = file.read16();
58 58
 
59 59
     uint16_t numLights = file.readU16();
60 60
     for (unsigned int l = 0; l < numLights; l++) {

+ 2
- 0
src/main.cpp ファイルの表示

@@ -184,7 +184,9 @@ int main(int argc, char* argv[]) {
184 184
 #ifdef DEBUG
185 185
     std::cout << std::endl;
186 186
     std::cout << "Thanks for testing " << VERSION << std::endl;
187
+#if defined(__DATE__) && defined(__TIME__)
187 188
     std::cout << "Build date: " << __DATE__ << " @ " << __TIME__ << std::endl;
189
+#endif
188 190
     std::cout << "Build host: " << BUILD_HOST << std::endl;
189 191
     std::cout << "Web site  : http://github.com/xythobuz/OpenRaider" << std::endl;
190 192
     std::cout << "Contact   : xythobuz@xythobuz.de" << std::endl;

+ 1
- 2
src/system/WindowSDL.cpp ファイルの表示

@@ -203,8 +203,7 @@ void WindowSDL::eventHandling() {
203 203
 
204 204
             case SDL_TEXTINPUT:
205 205
             case SDL_TEXTEDITING:
206
-                if (event.text.text != nullptr)
207
-                    UI::handleText(event.text.text, (event.type == SDL_TEXTEDITING));
206
+                UI::handleText(event.text.text, (event.type == SDL_TEXTEDITING));
208 207
                 break;
209 208
 
210 209
             case SDL_KEYDOWN:

+ 1
- 1
src/utils/Folder.cpp ファイルの表示

@@ -112,7 +112,7 @@ void Folder::executeRemoveFiles(std::function<bool (File& f)> func) {
112 112
     createFolderItems();
113 113
     for (unsigned long i = 0; i < fileCount(); i++) {
114 114
         if (func(getFile(i))) {
115
-            files.erase(files.begin() + (long)i--);
115
+            files.erase(files.begin() + i--);
116 116
         }
117 117
     }
118 118
 }

+ 4
- 4
src/utils/pcx.cpp ファイルの表示

@@ -24,7 +24,7 @@ int pcxCheck(const char* filename) {
24 24
     unsigned char* header = new unsigned char[128];
25 25
 
26 26
     // Basic validation
27
-    if (!file.read((char*)(&header[0]), 128)) {
27
+    if (!file.read(reinterpret_cast<char*>(&header[0]), 128)) {
28 28
         Log::get(LOG_ERROR) << "File not big enough for valid PCX header!" << Log::endl;
29 29
         delete [] header;
30 30
         return -1;
@@ -83,7 +83,7 @@ int pcxLoad(const char* filename, unsigned char** image,
83 83
     unsigned char* header = new unsigned char[128];
84 84
 
85 85
     // Basic validation
86
-    if (!file.read((char*)(&header[0]), 128)) {
86
+    if (!file.read(reinterpret_cast<char*>(&header[0]), 128)) {
87 87
         Log::get(LOG_ERROR) << "File not big enough for valid PCX header!" << Log::endl;
88 88
         delete [] header;
89 89
         return -1;
@@ -174,7 +174,7 @@ int pcxLoad(const char* filename, unsigned char** image,
174 174
         }
175 175
 
176 176
         for (unsigned int j = 0; j < n; j++)
177
-            buffer[b++] = (unsigned char)c;
177
+            buffer[b++] = static_cast<unsigned char>(c);
178 178
 
179 179
         i += n;
180 180
     }
@@ -186,7 +186,7 @@ int pcxLoad(const char* filename, unsigned char** image,
186 186
         if ((c == 12) && file) {
187 187
             palette = new unsigned char[768];
188 188
             for (unsigned int i = 0; i < 768; i++) {
189
-                palette[i] = (unsigned char)file.get();
189
+                palette[i] = static_cast<unsigned char>(file.get());
190 190
                 if (!file) {
191 191
                     Log::get(LOG_ERROR) << "Could not read 256 color palette (" << i << ")" << Log::endl;
192 192
                     delete [] buffer;

+ 14
- 14
src/utils/pixel.cpp ファイルの表示

@@ -16,11 +16,11 @@ unsigned char* generateColorTexture(glm::vec4 rgba, unsigned int width,
16 16
 
17 17
     unsigned char* image = new unsigned char[height * width * (bpp / 8)];
18 18
     for (unsigned int i = 0; i < (width * height); i++) {
19
-        image[i * (bpp / 8)] = (unsigned char)(rgba.r * 255);
20
-        image[(i * (bpp / 8)) + 1] = (unsigned char)(rgba.g * 255);
21
-        image[(i * (bpp / 8)) + 2] = (unsigned char)(rgba.b * 255);
19
+        image[i * (bpp / 8)] = static_cast<unsigned char>(rgba.r * 255);
20
+        image[(i * (bpp / 8)) + 1] = static_cast<unsigned char>(rgba.g * 255);
21
+        image[(i * (bpp / 8)) + 2] = static_cast<unsigned char>(rgba.b * 255);
22 22
         if (bpp == 32) {
23
-            image[(i * (bpp / 8)) + 3] = (unsigned char)(rgba.a * 255);
23
+            image[(i * (bpp / 8)) + 3] = static_cast<unsigned char>(rgba.a * 255);
24 24
         }
25 25
     }
26 26
     return image;
@@ -113,27 +113,27 @@ unsigned char* scaleBuffer(unsigned char* image, unsigned int* w, unsigned int*
113 113
 
114 114
     // Copy user data to float format.
115 115
     for (unsigned int i = 0; i < original_height * original_width * components; ++i) {
116
-        tempin[i] = (float)image[i];
116
+        tempin[i] = image[i];
117 117
     }
118 118
 
119 119
     // Determine which filter to use by checking ratios.
120 120
     float sx;
121 121
     if (width > 1) {
122
-        sx = (float)(original_width - 1) / (float)(width - 1);
122
+        sx = (original_width - 1.0f) / (width - 1.0f);
123 123
     } else {
124
-        sx = (float)(original_width - 1);
124
+        sx = original_width - 1.0f;
125 125
     }
126 126
 
127 127
     float sy;
128 128
     if (height > 1) {
129
-        sy = (float)(original_height - 1) / (float)(height - 1);
129
+        sy = (original_height - 1.0f) / (height - 1.0f);
130 130
     } else {
131
-        sy = (float)(original_height - 1);
131
+        sy = original_height - 1.0f;
132 132
     }
133 133
 
134 134
     if (sx < 1.0 && sy < 1.0) { // Magnify both width and height: use weighted sample of 4 pixels
135 135
         for (unsigned int i = 0; i < height; ++i) {
136
-            unsigned int i0 = (unsigned int)(i * sy);
136
+            unsigned int i0 = static_cast<unsigned int>(i * sy);
137 137
             unsigned int i1 = i0 + 1;
138 138
 
139 139
             if (i1 >= original_height) {
@@ -143,7 +143,7 @@ unsigned char* scaleBuffer(unsigned char* image, unsigned int* w, unsigned int*
143 143
             float alpha = i * sy - i0;
144 144
 
145 145
             for (unsigned int j = 0; j < width; ++j) {
146
-                unsigned int j0 = (unsigned int)(j * sx);
146
+                unsigned int j0 = static_cast<unsigned int>(j * sx);
147 147
                 unsigned int j1 = j0 + 1;
148 148
 
149 149
                 if (j1 >= original_width) {
@@ -169,7 +169,7 @@ unsigned char* scaleBuffer(unsigned char* image, unsigned int* w, unsigned int*
169 169
         }
170 170
     } else { // Shrink width and/or height: use an unweighted box filter
171 171
         for (unsigned int i = 0; i < height; ++i) {
172
-            unsigned int i0 = (unsigned int)(i * sy);
172
+            unsigned int i0 = static_cast<unsigned int>(i * sy);
173 173
             unsigned int i1 = i0 + 1;
174 174
 
175 175
             if (i1 >= original_height) {
@@ -177,7 +177,7 @@ unsigned char* scaleBuffer(unsigned char* image, unsigned int* w, unsigned int*
177 177
             }
178 178
 
179 179
             for (unsigned int j = 0; j < width; ++j) {
180
-                unsigned int j0 = (unsigned int)(j * sx);
180
+                unsigned int j0 = static_cast<unsigned int>(j * sx);
181 181
                 unsigned int j1 = j0 + 1;
182 182
 
183 183
                 if (j1 >= original_width) {
@@ -206,7 +206,7 @@ unsigned char* scaleBuffer(unsigned char* image, unsigned int* w, unsigned int*
206 206
 
207 207
     // Copy to our results.
208 208
     for (unsigned int i = 0; i < height * width * components; ++i) {
209
-        timage[i] = (unsigned char)tempout[i];
209
+        timage[i] = static_cast<unsigned char>(tempout[i]);
210 210
     }
211 211
 
212 212
     // Delete our temp buffers.

読み込み中…
キャンセル
保存