Browse Source

Fixed formatting [skip ci]

Thomas Buck 9 years ago
parent
commit
267ad50cbb
5 changed files with 36 additions and 19 deletions
  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 View File

12
 
12
 
13
 class BoundingSphere {
13
 class BoundingSphere {
14
   public:
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
     void setPosition(glm::vec3 p) { pos = p; }
18
     void setPosition(glm::vec3 p) { pos = p; }
18
     glm::vec3 getPosition() { return pos; }
19
     glm::vec3 getPosition() { return pos; }

+ 13
- 7
src/BoundingSphere.cpp View File

18
 
18
 
19
 void BoundingSphere::display(glm::mat4 VP, glm::vec3 color) {
19
 void BoundingSphere::display(glm::mat4 VP, glm::vec3 color) {
20
     for (int w = 0; w < resolution; w++) {
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
             float inc1 = (w / float(resolution)) * 2.0f * glm::pi<float>();
22
             float inc1 = (w / float(resolution)) * 2.0f * glm::pi<float>();
23
             float inc2 = ((w + 1) / float(resolution)) * 2.0f * glm::pi<float>();
23
             float inc2 = ((w + 1) / float(resolution)) * 2.0f * glm::pi<float>();
24
             float inc3 = (h / float(resolution)) * glm::pi<float>();
24
             float inc3 = (h / float(resolution)) * glm::pi<float>();
35
             float z1 = radius * glm::sin(inc3);
35
             float z1 = radius * glm::sin(inc3);
36
             float z2 = radius * glm::sin(inc4);
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
             for (int i = 0; i < 6; i++) {
52
             for (int i = 0; i < 6; i++) {
47
                 colors.emplace_back(color);
53
                 colors.emplace_back(color);

+ 2
- 1
src/RoomData.cpp View File

71
 }
71
 }
72
 
72
 
73
 void RoomSprite::displayBoundingSphere(glm::mat4 VP, glm::vec3 color) {
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
 void RoomSprite::display(glm::mat4 VP) {
78
 void RoomSprite::display(glm::mat4 VP) {

+ 14
- 7
src/Selector.cpp View File

28
 glm::vec3 Selector::rayWorld, Selector::lastIntersectPos, Selector::lastIntersectNorm;
28
 glm::vec3 Selector::rayWorld, Selector::lastIntersectPos, Selector::lastIntersectNorm;
29
 unsigned long Selector::lastIndexA, Selector::lastIndexB;
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
     if ((button == leftmouseKey) && (!released)) {
33
     if ((button == leftmouseKey) && (!released)) {
33
         // Calculate click ray
34
         // Calculate click ray
34
         rayScreen = glm::vec2(x, y);
35
         rayScreen = glm::vec2(x, y);
71
                 if (clickOnObject[roomSpriteObject]) {
72
                 if (clickOnObject[roomSpriteObject]) {
72
                     for (unsigned long j = 0; j < r.sizeSprites(); j++) {
73
                     for (unsigned long j = 0; j < r.sizeSprites(); j++) {
73
                         RoomSprite& rs = r.getSprite(j);
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
                             float newDepth = glm::abs(glm::distance(rs.getCenter(), Camera::getPosition()));
77
                             float newDepth = glm::abs(glm::distance(rs.getCenter(), Camera::getPosition()));
76
                             if ((newDepth < depth) || (depth < 0.0f)) {
78
                             if ((newDepth < depth) || (depth < 0.0f)) {
77
                                 depth = newDepth;
79
                                 depth = newDepth;
96
 
98
 
97
 void Selector::displaySelection() {
99
 void Selector::displaySelection() {
98
     if (lastClickedObject == roomModelObject) {
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
     } else if (lastClickedObject == roomSpriteObject) {
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
     } else {
106
     } else {
103
         lastClickedObject = WorldObjectCount;
107
         lastClickedObject = WorldObjectCount;
104
     }
108
     }
122
     }
126
     }
123
     ImGui::Separator();
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
     ImGui::Text("Last click: (%d %d)", rayScreen.x, rayScreen.y);
131
     ImGui::Text("Last click: (%d %d)", rayScreen.x, rayScreen.y);
127
     if ((rayScreen.x >= 0) && (rayScreen.y >= 0)) {
132
     if ((rayScreen.x >= 0) && (rayScreen.y >= 0)) {
128
         ImGui::Text("Normalized Ray: (%.3f %.3f %.3f)", rayWorld.x, rayWorld.y, rayWorld.z);
133
         ImGui::Text("Normalized Ray: (%.3f %.3f %.3f)", rayWorld.x, rayWorld.y, rayWorld.z);
129
     }
134
     }
130
 
135
 
131
     if (lastClickedObject != WorldObjectCount) {
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
     if (lastClickedObject == roomModelObject) {
143
     if (lastClickedObject == roomModelObject) {

+ 5
- 3
src/UI.cpp View File

186
     while (!keyboardEvents.empty()) {
186
     while (!keyboardEvents.empty()) {
187
         auto i = keyboardEvents.front();
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
             for (int n = forwardAction; n < ActionEventCount; n++) {
190
             for (int n = forwardAction; n < ActionEventCount; n++) {
191
                 auto ae = static_cast<ActionEvents>(n);
191
                 auto ae = static_cast<ActionEvents>(n);
192
                 if (RunTime::getKeyBinding(ae) == std::get<0>(i))
192
                 if (RunTime::getKeyBinding(ae) == std::get<0>(i))
195
         }
195
         }
196
 
196
 
197
         if (std::get<1>(i)) {
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
                 if (!metaKeyIsActive) {
200
                 if (!metaKeyIsActive) {
200
                     if (RunTime::getKeyBinding(debugAction) == std::get<0>(i)) {
201
                     if (RunTime::getKeyBinding(debugAction) == std::get<0>(i)) {
201
                         visible = !visible;
202
                         visible = !visible;
236
         Console::setVisible(false);
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
         Window::setTextInput(visible || Console::isVisible() || Menu::isVisible() || Selector::isVisible());
242
         Window::setTextInput(visible || Console::isVisible() || Menu::isVisible() || Selector::isVisible());
241
 
243
 
242
     bool input = !(visible || Console::isVisible() || Menu::isVisible() || Selector::isVisible());
244
     bool input = !(visible || Console::isVisible() || Menu::isVisible() || Selector::isVisible());

Loading…
Cancel
Save