|
@@ -10,6 +10,7 @@
|
10
|
10
|
#include <sstream>
|
11
|
11
|
|
12
|
12
|
#include "global.h"
|
|
13
|
+#include "BoundingBox.h"
|
13
|
14
|
#include "Camera.h"
|
14
|
15
|
#include "Log.h"
|
15
|
16
|
#include "Menu.h"
|
|
@@ -26,7 +27,7 @@
|
26
|
27
|
#include "stb/stb_image_write.h"
|
27
|
28
|
|
28
|
29
|
RenderMode Render::mode = RenderMode::LoadScreen;
|
29
|
|
-std::vector<Room*> Render::roomList;
|
|
30
|
+std::vector<RoomRenderList> Render::roomList;
|
30
|
31
|
bool Render::displayViewFrustum = false;
|
31
|
32
|
bool Render::displayVisibilityCheck = false;
|
32
|
33
|
|
|
@@ -63,25 +64,44 @@ void Render::display() {
|
63
|
64
|
}
|
64
|
65
|
|
65
|
66
|
for (int r = roomList.size() - 1; r >= 0; r--) {
|
66
|
|
- roomList.at(r)->display(VP);
|
|
67
|
+ auto& rl = roomList.at(r);
|
|
68
|
+
|
|
69
|
+ //! \fixme TODO scissor to portal in screenspace to fix 4D rendering
|
|
70
|
+
|
|
71
|
+ //gl::glEnable(gl::GL_SCISSOR_TEST);
|
|
72
|
+ //gl::glScissor(rl.portalPos.x, rl.portalPos.y, rl.portalSize.x, rl.portalSize.y);
|
|
73
|
+
|
|
74
|
+ //ImGui::Text("%.2f %.2f", rl.portalPos.x, rl.portalPos.y);
|
|
75
|
+ //ImGui::Text("%.2f %.2f", rl.portalSize.x, rl.portalSize.y);
|
|
76
|
+ //ImGui::Text("--");
|
|
77
|
+
|
|
78
|
+ rl.room->display(VP);
|
67
|
79
|
|
68
|
80
|
for (int i = 0; i < World::sizeEntity(); i++) {
|
69
|
81
|
auto& e = World::getEntity(i);
|
70
|
|
- if (roomList.at(r)->getIndex() == e.getRoom()) {
|
|
82
|
+ if (rl.room->getIndex() == e.getRoom()) {
|
71
|
83
|
e.display(VP);
|
72
|
84
|
}
|
73
|
85
|
}
|
|
86
|
+
|
|
87
|
+ //gl::glDisable(gl::GL_SCISSOR_TEST);
|
74
|
88
|
}
|
75
|
89
|
|
76
|
90
|
if (displayViewFrustum)
|
77
|
91
|
Camera::displayFrustum(VP);
|
78
|
92
|
|
|
93
|
+ BoundingBox::display();
|
|
94
|
+
|
79
|
95
|
if (mode == RenderMode::Wireframe) {
|
80
|
96
|
gl::glPolygonMode(gl::GL_FRONT_AND_BACK, gl::GL_FILL);
|
81
|
97
|
}
|
82
|
98
|
}
|
83
|
99
|
|
84
|
100
|
void Render::buildRoomList(glm::mat4 VP, int room, glm::vec2 min, glm::vec2 max) {
|
|
101
|
+ glm::vec2 halfSize = glm::vec2(Window::getSize()) / 2.0f;
|
|
102
|
+ glm::vec2 pos = (min * halfSize) + halfSize;
|
|
103
|
+ glm::vec2 size = (max * halfSize) + halfSize - pos;
|
|
104
|
+
|
85
|
105
|
if (room < -1) {
|
86
|
106
|
// Check if the camera currently is in a room...
|
87
|
107
|
for (int i = 0; i < World::sizeRoom(); i++) {
|
|
@@ -95,11 +115,11 @@ void Render::buildRoomList(glm::mat4 VP, int room, glm::vec2 min, glm::vec2 max)
|
95
|
115
|
// Check visibility for all rooms!
|
96
|
116
|
for (int i = 0; i < World::sizeRoom(); i++) {
|
97
|
117
|
if (Camera::boxInFrustum(World::getRoom(i).getBoundingBox())) {
|
98
|
|
- roomList.push_back(&World::getRoom(i));
|
|
118
|
+ roomList.emplace_back(&World::getRoom(i), pos, size);
|
99
|
119
|
}
|
100
|
120
|
}
|
101
|
121
|
} else {
|
102
|
|
- roomList.push_back(&World::getRoom(room));
|
|
122
|
+ roomList.emplace_back(&World::getRoom(room), pos, size);
|
103
|
123
|
|
104
|
124
|
if (displayVisibilityCheck) {
|
105
|
125
|
// Display the visibility test for the portal to this room
|
|
@@ -157,7 +177,7 @@ void Render::buildRoomList(glm::mat4 VP, int room, glm::vec2 min, glm::vec2 max)
|
157
|
177
|
// Check if this room is already in the list...
|
158
|
178
|
bool found = false;
|
159
|
179
|
for (int n = 0; n < roomList.size(); n++) {
|
160
|
|
- if (roomList.at(n) == &room) {
|
|
180
|
+ if (roomList.at(n).room == &room) {
|
161
|
181
|
found = true;
|
162
|
182
|
break;
|
163
|
183
|
}
|