瀏覽代碼

Fixed formatting [skip ci]

Thomas Buck 9 年之前
父節點
當前提交
267ad50cbb
共有 5 個檔案被更改,包括 36 行新增19 行删除
  1. 2
    1
      include/BoundingSphere.h
  2. 13
    7
      src/BoundingSphere.cpp
  3. 2
    1
      src/RoomData.cpp
  4. 14
    7
      src/Selector.cpp
  5. 5
    3
      src/UI.cpp

+ 2
- 1
include/BoundingSphere.h 查看文件

@@ -12,7 +12,8 @@
12 12
 
13 13
 class BoundingSphere {
14 14
   public:
15
-    BoundingSphere(glm::vec3 p = glm::vec3(0.0f, 0.0f, 0.0f), float r = 100.0f, int res = 42) : pos(p), radius(r), resolution(res) { }
15
+    BoundingSphere(glm::vec3 p = glm::vec3(0.0f, 0.0f, 0.0f), float r = 100.0f, int res = 42) : pos(p),
16
+        radius(r), resolution(res) { }
16 17
 
17 18
     void setPosition(glm::vec3 p) { pos = p; }
18 19
     glm::vec3 getPosition() { return pos; }

+ 13
- 7
src/BoundingSphere.cpp 查看文件

@@ -18,7 +18,7 @@ std::vector<glm::vec3> BoundingSphere::colors;
18 18
 
19 19
 void BoundingSphere::display(glm::mat4 VP, glm::vec3 color) {
20 20
     for (int w = 0; w < resolution; w++) {
21
-        for (int h = (-resolution / 2); h < (resolution / 2); h++){
21
+        for (int h = (-resolution / 2); h < (resolution / 2); h++) {
22 22
             float inc1 = (w / float(resolution)) * 2.0f * glm::pi<float>();
23 23
             float inc2 = ((w + 1) / float(resolution)) * 2.0f * glm::pi<float>();
24 24
             float inc3 = (h / float(resolution)) * glm::pi<float>();
@@ -35,13 +35,19 @@ void BoundingSphere::display(glm::mat4 VP, glm::vec3 color) {
35 35
             float z1 = radius * glm::sin(inc3);
36 36
             float z2 = radius * glm::sin(inc4);
37 37
 
38
-            vertices.emplace_back(VP * (glm::vec4(radius1 * x1, z1, radius1 * y1, 1.0f) + glm::vec4(pos, 0.0f)));
39
-            vertices.emplace_back(VP * (glm::vec4(radius1 * x2, z1, radius1 * y2, 1.0f) + glm::vec4(pos, 0.0f)));
40
-            vertices.emplace_back(VP * (glm::vec4(radius2 * x2, z2, radius2 * y2, 1.0f) + glm::vec4(pos, 0.0f)));
38
+            vertices.emplace_back(VP * (glm::vec4(radius1 * x1, z1, radius1 * y1, 1.0f) + glm::vec4(pos,
39
+                                        0.0f)));
40
+            vertices.emplace_back(VP * (glm::vec4(radius1 * x2, z1, radius1 * y2, 1.0f) + glm::vec4(pos,
41
+                                        0.0f)));
42
+            vertices.emplace_back(VP * (glm::vec4(radius2 * x2, z2, radius2 * y2, 1.0f) + glm::vec4(pos,
43
+                                        0.0f)));
41 44
 
42
-            vertices.emplace_back(VP * (glm::vec4(radius1 * x1, z1, radius1 * y1, 1.0f) + glm::vec4(pos, 0.0f)));
43
-            vertices.emplace_back(VP * (glm::vec4(radius2 * x2, z2, radius2 * y2, 1.0f) + glm::vec4(pos, 0.0f)));
44
-            vertices.emplace_back(VP * (glm::vec4(radius2 * x1, z2, radius2 * y1, 1.0f) + glm::vec4(pos, 0.0f)));
45
+            vertices.emplace_back(VP * (glm::vec4(radius1 * x1, z1, radius1 * y1, 1.0f) + glm::vec4(pos,
46
+                                        0.0f)));
47
+            vertices.emplace_back(VP * (glm::vec4(radius2 * x2, z2, radius2 * y2, 1.0f) + glm::vec4(pos,
48
+                                        0.0f)));
49
+            vertices.emplace_back(VP * (glm::vec4(radius2 * x1, z2, radius2 * y1, 1.0f) + glm::vec4(pos,
50
+                                        0.0f)));
45 51
 
46 52
             for (int i = 0; i < 6; i++) {
47 53
                 colors.emplace_back(color);

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

@@ -71,7 +71,8 @@ float RoomSprite::getRadius() {
71 71
 }
72 72
 
73 73
 void RoomSprite::displayBoundingSphere(glm::mat4 VP, glm::vec3 color) {
74
-    World::getSprite(sprite).getBoundingSphere().display(VP * glm::translate(glm::mat4(1.0f), pos), color);
74
+    World::getSprite(sprite).getBoundingSphere().display(VP * glm::translate(glm::mat4(1.0f), pos),
75
+            color);
75 76
 }
76 77
 
77 78
 void RoomSprite::display(glm::mat4 VP) {

+ 14
- 7
src/Selector.cpp 查看文件

@@ -28,7 +28,8 @@ glm::i32vec2 Selector::rayScreen(-1, -1);
28 28
 glm::vec3 Selector::rayWorld, Selector::lastIntersectPos, Selector::lastIntersectNorm;
29 29
 unsigned long Selector::lastIndexA, Selector::lastIndexB;
30 30
 
31
-void Selector::handleMouseClick(unsigned int x, unsigned int y, KeyboardButton button, bool released) {
31
+void Selector::handleMouseClick(unsigned int x, unsigned int y, KeyboardButton button,
32
+                                bool released) {
32 33
     if ((button == leftmouseKey) && (!released)) {
33 34
         // Calculate click ray
34 35
         rayScreen = glm::vec2(x, y);
@@ -71,7 +72,8 @@ void Selector::handleMouseClick(unsigned int x, unsigned int y, KeyboardButton b
71 72
                 if (clickOnObject[roomSpriteObject]) {
72 73
                     for (unsigned long j = 0; j < r.sizeSprites(); j++) {
73 74
                         RoomSprite& rs = r.getSprite(j);
74
-                        if (glm::intersectRaySphere(Camera::getPosition(), rayWorld, rs.getCenter(), rs.getRadius(), pos, norm)) {
75
+                        if (glm::intersectRaySphere(Camera::getPosition(), rayWorld, rs.getCenter(), rs.getRadius(), pos,
76
+                                                    norm)) {
75 77
                             float newDepth = glm::abs(glm::distance(rs.getCenter(), Camera::getPosition()));
76 78
                             if ((newDepth < depth) || (depth < 0.0f)) {
77 79
                                 depth = newDepth;
@@ -96,9 +98,11 @@ void Selector::handleMouseClick(unsigned int x, unsigned int y, KeyboardButton b
96 98
 
97 99
 void Selector::displaySelection() {
98 100
     if (lastClickedObject == roomModelObject) {
99
-        World::getRoom(lastIndexA).getModel(lastIndexB).displayBoundingSphere(Camera::getProjectionMatrix() * Camera::getViewMatrix(), glm::vec3(1.0f, 0.0f, 0.0f));
101
+        World::getRoom(lastIndexA).getModel(lastIndexB).displayBoundingSphere(
102
+            Camera::getProjectionMatrix() * Camera::getViewMatrix(), glm::vec3(1.0f, 0.0f, 0.0f));
100 103
     } else if (lastClickedObject == roomSpriteObject) {
101
-        World::getRoom(lastIndexA).getSprite(lastIndexB).displayBoundingSphere(Camera::getProjectionMatrix() * Camera::getViewMatrix(), glm::vec3(1.0f, 0.0f, 0.0f));
104
+        World::getRoom(lastIndexA).getSprite(lastIndexB).displayBoundingSphere(
105
+            Camera::getProjectionMatrix() * Camera::getViewMatrix(), glm::vec3(1.0f, 0.0f, 0.0f));
102 106
     } else {
103 107
         lastClickedObject = WorldObjectCount;
104 108
     }
@@ -122,15 +126,18 @@ void Selector::display() {
122 126
     }
123 127
     ImGui::Separator();
124 128
 
125
-    ImGui::Text("Camera: (%.2f %.2f %.2f)", Camera::getPosition().x, Camera::getPosition().y, Camera::getPosition().z);
129
+    ImGui::Text("Camera: (%.2f %.2f %.2f)", Camera::getPosition().x, Camera::getPosition().y,
130
+                Camera::getPosition().z);
126 131
     ImGui::Text("Last click: (%d %d)", rayScreen.x, rayScreen.y);
127 132
     if ((rayScreen.x >= 0) && (rayScreen.y >= 0)) {
128 133
         ImGui::Text("Normalized Ray: (%.3f %.3f %.3f)", rayWorld.x, rayWorld.y, rayWorld.z);
129 134
     }
130 135
 
131 136
     if (lastClickedObject != WorldObjectCount) {
132
-        ImGui::Text("Intersect Pos: (%.2f %.2f %.2f)", lastIntersectPos.x, lastIntersectPos.y, lastIntersectPos.z);
133
-        ImGui::Text("Intersect Norm: (%.2f %.2f %.2f)", lastIntersectNorm.x, lastIntersectNorm.y, lastIntersectNorm.z);
137
+        ImGui::Text("Intersect Pos: (%.2f %.2f %.2f)", lastIntersectPos.x, lastIntersectPos.y,
138
+                    lastIntersectPos.z);
139
+        ImGui::Text("Intersect Norm: (%.2f %.2f %.2f)", lastIntersectNorm.x, lastIntersectNorm.y,
140
+                    lastIntersectNorm.z);
134 141
     }
135 142
 
136 143
     if (lastClickedObject == roomModelObject) {

+ 5
- 3
src/UI.cpp 查看文件

@@ -186,7 +186,7 @@ void UI::eventsFinished() {
186 186
     while (!keyboardEvents.empty()) {
187 187
         auto i = keyboardEvents.front();
188 188
 
189
-        if (!(visible || Console::isVisible() || Menu::isVisible() /* || Selector::isVisible() */ )) {
189
+        if (!(visible || Console::isVisible() || Menu::isVisible() /* || Selector::isVisible() */)) {
190 190
             for (int n = forwardAction; n < ActionEventCount; n++) {
191 191
                 auto ae = static_cast<ActionEvents>(n);
192 192
                 if (RunTime::getKeyBinding(ae) == std::get<0>(i))
@@ -195,7 +195,8 @@ void UI::eventsFinished() {
195 195
         }
196 196
 
197 197
         if (std::get<1>(i)) {
198
-            if ((!io.WantCaptureKeyboard) || (!(visible || Console::isVisible() || Menu::isVisible() || Selector::isVisible()))) {
198
+            if ((!io.WantCaptureKeyboard) || (!(visible || Console::isVisible() || Menu::isVisible()
199
+                                                || Selector::isVisible()))) {
199 200
                 if (!metaKeyIsActive) {
200 201
                     if (RunTime::getKeyBinding(debugAction) == std::get<0>(i)) {
201 202
                         visible = !visible;
@@ -236,7 +237,8 @@ void UI::eventsFinished() {
236 237
         Console::setVisible(false);
237 238
     }
238 239
 
239
-    if (Window::getTextInput() != (visible || Console::isVisible() || Menu::isVisible() || Selector::isVisible()))
240
+    if (Window::getTextInput() != (visible || Console::isVisible() || Menu::isVisible()
241
+                                   || Selector::isVisible()))
240 242
         Window::setTextInput(visible || Console::isVisible() || Menu::isVisible() || Selector::isVisible());
241 243
 
242 244
     bool input = !(visible || Console::isVisible() || Menu::isVisible() || Selector::isVisible());

Loading…
取消
儲存