Fix floor cache for multi-story buildings

Skip cached floor height if it's too far below query point (>4 units),
forcing a full raycast. This handles cases where the cache has a
different floor's height (e.g., ground floor cached while on upper floor).
This commit is contained in:
Kelsi 2026-02-05 17:41:46 -08:00
parent d1e9bbeb1f
commit e768f5048c

View file

@ -1392,8 +1392,10 @@ std::optional<float> WMORenderer::getFloorHeight(float glX, float glY, float glZ
auto gridIt = precomputedFloorGrid.find(gridKey); auto gridIt = precomputedFloorGrid.find(gridKey);
if (gridIt != precomputedFloorGrid.end()) { if (gridIt != precomputedFloorGrid.end()) {
float cachedHeight = gridIt->second; float cachedHeight = gridIt->second;
// Only use if cached height is below query point (not a ceiling) // Only use cache if floor is close to query point (within ~4 units below).
if (cachedHeight <= glZ + 2.0f) { // For multi-story buildings, the cache has the top floor - if we're on a
// lower floor, skip cache and do full raycast to find actual floor.
if (cachedHeight <= glZ + 2.0f && cachedHeight >= glZ - 4.0f) {
return cachedHeight; return cachedHeight;
} }
} }