|
@@ -110,26 +110,20 @@ void Render::buildRoomList(glm::mat4 VP, int room, glm::vec2 min, glm::vec2 max)
|
110
|
110
|
// Display the visibility test for the portal to this room
|
111
|
111
|
BoundingBox debugBox(glm::vec3(min, 0.0f), glm::vec3(max, 0.0f));
|
112
|
112
|
debugBox.display(glm::mat4(1.0f), glm::vec3(1.0f, 1.0f, 1.0f), glm::vec3(0.0f, 1.0f, 0.0f));
|
113
|
|
-
|
114
|
|
- ImGui::Text(" Min: %.3f %.3f", min.x, min.y);
|
115
|
|
- ImGui::Text(" Max: %.3f %.3f", max.x, max.y);
|
116
|
113
|
}
|
117
|
114
|
|
118
|
115
|
// Check all portals leading from this room to somewhere else
|
119
|
116
|
for (int i = 0; i < World::getRoom(room).sizePortals(); i++) {
|
120
|
117
|
auto& portal = World::getRoom(room).getPortal(i);
|
|
118
|
+ auto& room = World::getRoom(portal.getAdjoiningRoom());
|
121
|
119
|
|
122
|
|
- // Calculate the 2D window of this portal
|
|
120
|
+ // Calculate the 2D screen-space bounding box of this portal
|
123
|
121
|
glm::vec3 newMin, newMax;
|
124
|
122
|
for (int c = 0; c < 4; c++) {
|
125
|
123
|
glm::vec3 vert = portal.getVertex(c);
|
126
|
124
|
glm::vec4 result = VP * glm::vec4(vert, 1.0f);
|
127
|
125
|
vert = glm::vec3(result) / result.w;
|
128
|
126
|
|
129
|
|
- if (displayVisibilityCheck) {
|
130
|
|
- ImGui::Text("Test %d: %.3f %.3f %.3f", c, vert.x, vert.y, vert.z);
|
131
|
|
- }
|
132
|
|
-
|
133
|
127
|
if (c == 0) {
|
134
|
128
|
newMin = vert;
|
135
|
129
|
newMax = vert;
|
|
@@ -149,11 +143,6 @@ void Render::buildRoomList(glm::mat4 VP, int room, glm::vec2 min, glm::vec2 max)
|
149
|
143
|
}
|
150
|
144
|
}
|
151
|
145
|
|
152
|
|
- if (displayVisibilityCheck) {
|
153
|
|
- ImGui::Text("NewMin: %.3f %.3f %.3f", newMin.x, newMin.y, newMin.z);
|
154
|
|
- ImGui::Text("NewMax: %.3f %.3f %.3f", newMax.x, newMax.y, newMax.z);
|
155
|
|
- }
|
156
|
|
-
|
157
|
146
|
//! \fixme Currently also checking behind player, because Z is always 1.0f?!
|
158
|
147
|
//if ((newMin.z > 0.0f) || (newMin.z < -1.0f) || (newMax.z > 0.0f) || (newMax.z < -1.0f)) {
|
159
|
148
|
// continue;
|
|
@@ -165,10 +154,15 @@ void Render::buildRoomList(glm::mat4 VP, int room, glm::vec2 min, glm::vec2 max)
|
165
|
154
|
continue;
|
166
|
155
|
}
|
167
|
156
|
|
|
157
|
+ // Check if the connected room is in our view frustum (could be visible)
|
|
158
|
+ if (!Camera::boxInFrustum(room.getBoundingBox())) {
|
|
159
|
+ continue;
|
|
160
|
+ }
|
|
161
|
+
|
168
|
162
|
// Check if this room is already in the list...
|
169
|
163
|
bool found = false;
|
170
|
164
|
for (int n = 0; n < roomList.size(); n++) {
|
171
|
|
- if (roomList.at(n) == &World::getRoom(portal.getAdjoiningRoom())) {
|
|
165
|
+ if (roomList.at(n) == &room) {
|
172
|
166
|
found = true;
|
173
|
167
|
break;
|
174
|
168
|
}
|