mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-22 23:30:14 +00:00
Improve floor detection for multi-story buildings
- Increase footprint sampling radius from 0.28 to 0.4 units - Only update floor cache if found floor is close to query height - Prevents caching wrong floor from different stories
This commit is contained in:
parent
e768f5048c
commit
bf6a5ba596
2 changed files with 7 additions and 5 deletions
|
|
@ -518,9 +518,9 @@ void CameraController::update(float deltaTime) {
|
|||
return base;
|
||||
};
|
||||
|
||||
// Sample center + small footprint to avoid slipping through narrow floor pieces.
|
||||
// Sample center + footprint to avoid slipping through narrow floor pieces.
|
||||
std::optional<float> groundH;
|
||||
constexpr float FOOTPRINT = 0.28f;
|
||||
constexpr float FOOTPRINT = 0.4f; // Larger footprint for better floor detection
|
||||
const glm::vec2 offsets[] = {
|
||||
{0.0f, 0.0f},
|
||||
{FOOTPRINT, 0.0f}, {-FOOTPRINT, 0.0f},
|
||||
|
|
@ -824,7 +824,7 @@ void CameraController::update(float deltaTime) {
|
|||
};
|
||||
|
||||
std::optional<float> groundH;
|
||||
constexpr float FOOTPRINT = 0.28f;
|
||||
constexpr float FOOTPRINT = 0.4f; // Larger footprint for better floor detection
|
||||
const glm::vec2 offsets[] = {
|
||||
{0.0f, 0.0f}, {FOOTPRINT, 0.0f}, {-FOOTPRINT, 0.0f}, {0.0f, FOOTPRINT}, {0.0f, -FOOTPRINT}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1495,8 +1495,10 @@ std::optional<float> WMORenderer::getFloorHeight(float glX, float glY, float glZ
|
|||
}
|
||||
}
|
||||
|
||||
// Cache the result in persistent grid (never expires)
|
||||
if (bestFloor) {
|
||||
// Cache the result in persistent grid.
|
||||
// Only update cache if we found a floor that's close to query height,
|
||||
// to avoid caching wrong floors when player is on different stories.
|
||||
if (bestFloor && *bestFloor >= glZ - 6.0f) {
|
||||
precomputedFloorGrid[gridKey] = *bestFloor;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue