mirror of
https://github.com/XProger/OpenLara.git
synced 2025-08-15 17:44:25 +02:00
#23 select optimal water reflection plane
This commit is contained in:
13
src/cache.h
13
src/cache.h
@@ -805,16 +805,23 @@ struct WaterCache {
|
|||||||
|
|
||||||
if (roomsCount) {
|
if (roomsCount) {
|
||||||
// select optimal water plane
|
// select optimal water plane
|
||||||
float waterLevel = -INF;
|
float waterDist = 10000000.0f;
|
||||||
|
int waterItem = 0;
|
||||||
|
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
Item &item = items[i];
|
Item &item = items[i];
|
||||||
if (!item.visible) continue;
|
if (!item.visible) continue;
|
||||||
|
|
||||||
if (item.pos.y > waterLevel)
|
float d = fabsf(item.pos.y - camera->eye.pos.y);
|
||||||
waterLevel = item.pos.y;
|
|
||||||
|
if (d < waterDist) {
|
||||||
|
waterDist = d;
|
||||||
|
waterItem = i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float waterLevel = items[waterItem].pos.y;
|
||||||
|
|
||||||
reflectPlane = vec4(0, 1, 0, -waterLevel);
|
reflectPlane = vec4(0, 1, 0, -waterLevel);
|
||||||
camera->reflectPlane = &reflectPlane;
|
camera->reflectPlane = &reflectPlane;
|
||||||
camera->setup(true);
|
camera->setup(true);
|
||||||
|
Reference in New Issue
Block a user