Allow full camera zoom on outdoor WMO structures without ceilings

Removed blanket 3.5-unit zoom limit when inside any WMO. Now only
constrains zoom when ceiling raycast detects actual structure above.
Increased ceiling detect range from 15 to 20 units. Allows full zoom
on bridges, platforms, ramparts, and other outdoor WMO areas while
still preventing camera clipping through enclosed building ceilings.
This commit is contained in:
Kelsi 2026-02-08 20:21:49 -08:00
parent b48802855b
commit b51543fdd2

View file

@ -606,9 +606,8 @@ void CameraController::update(float deltaTime) {
float zoomLerp = 1.0f - std::exp(-ZOOM_SMOOTH_SPEED * deltaTime);
currentDistance += (userTargetDistance - currentDistance) * zoomLerp;
// Limit max zoom when inside a WMO (building interior)
// Limit max zoom when inside a WMO with a ceiling (building interior)
// Throttle: only recheck every 10 frames or when position changes >2 units.
static constexpr float WMO_MAX_DISTANCE = 3.5f;
if (wmoRenderer) {
float distFromLastCheck = glm::length(targetPos - lastInsideWMOCheckPos);
if (++insideWMOCheckCounter >= 10 || distFromLastCheck > 2.0f) {
@ -617,16 +616,13 @@ void CameraController::update(float deltaTime) {
insideWMOCheckCounter = 0;
lastInsideWMOCheckPos = targetPos;
}
if (cachedInsideWMO && currentDistance > WMO_MAX_DISTANCE) {
currentDistance = WMO_MAX_DISTANCE;
}
// Constrain zoom if there's a ceiling/upper floor above player
// Raycast upward from player to find ceiling, limit camera distance
glm::vec3 upRayOrigin = targetPos;
glm::vec3 upRayDir(0.0f, 0.0f, 1.0f);
float ceilingDist = wmoRenderer->raycastBoundingBoxes(upRayOrigin, upRayDir, 15.0f);
if (ceilingDist < 15.0f) {
float ceilingDist = wmoRenderer->raycastBoundingBoxes(upRayOrigin, upRayDir, 20.0f);
if (ceilingDist < 20.0f) {
// Found ceiling above — limit zoom to prevent camera from going through it
// Camera is behind player by currentDistance, at an angle
// Approximate: if ceiling is N units above, limit zoom to ~N units