1
0
mirror of https://github.com/XProger/OpenLara.git synced 2025-08-15 01:24:35 +02:00

#23 select optimal water reflection plane

This commit is contained in:
XProger
2018-03-11 08:33:46 +03:00
parent a278858f4e
commit b62d06a5f7

View File

@@ -805,16 +805,23 @@ struct WaterCache {
if (roomsCount) {
// select optimal water plane
float waterLevel = -INF;
float waterDist = 10000000.0f;
int waterItem = 0;
for (int i = 0; i < count; i++) {
Item &item = items[i];
if (!item.visible) continue;
if (item.pos.y > waterLevel)
waterLevel = item.pos.y;
float d = fabsf(item.pos.y - camera->eye.pos.y);
if (d < waterDist) {
waterDist = d;
waterItem = i;
}
}
float waterLevel = items[waterItem].pos.y;
reflectPlane = vec4(0, 1, 0, -waterLevel);
camera->reflectPlane = &reflectPlane;
camera->setup(true);