diff --git a/src/rendering/camera_controller.cpp b/src/rendering/camera_controller.cpp index e97b9708..230e9757 100644 --- a/src/rendering/camera_controller.cpp +++ b/src/rendering/camera_controller.cpp @@ -396,9 +396,9 @@ void CameraController::update(float deltaTime) { glm::vec3 desiredPos = targetPos; float moveDist = glm::length(desiredPos - startPos); // Adaptive CCD: keep per-step movement short to avoid clipping through walls. - int sweepSteps = std::max(1, std::min(8, static_cast(std::ceil(moveDist / 0.3f)))); + int sweepSteps = std::max(1, std::min(12, static_cast(std::ceil(moveDist / 0.20f)))); if (deltaTime > 0.04f) { - sweepSteps = std::min(12, std::max(sweepSteps, static_cast(std::ceil(deltaTime / 0.016f)))); + sweepSteps = std::min(16, std::max(sweepSteps, static_cast(std::ceil(deltaTime / 0.016f)))); } glm::vec3 stepPos = startPos; glm::vec3 stepDelta = (desiredPos - startPos) / static_cast(sweepSteps); @@ -614,6 +614,14 @@ 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) + static constexpr float WMO_MAX_DISTANCE = 15.0f; + if (wmoRenderer && wmoRenderer->isInsideWMO(targetPos.x, targetPos.y, targetPos.z + 1.0f, nullptr)) { + if (currentDistance > WMO_MAX_DISTANCE) { + currentDistance = WMO_MAX_DISTANCE; + } + } + // ===== Camera collision (sphere sweep approximation) ===== // Find max safe distance using raycast + sphere radius collisionDistance = currentDistance; @@ -822,9 +830,9 @@ void CameraController::update(float deltaTime) { glm::vec3 desiredFeet = newPos - glm::vec3(0, 0, eyeHeight); float moveDist = glm::length(desiredFeet - startFeet); // Adaptive CCD: keep per-step movement short to avoid clipping through walls. - int sweepSteps = std::max(1, std::min(8, static_cast(std::ceil(moveDist / 0.3f)))); + int sweepSteps = std::max(1, std::min(12, static_cast(std::ceil(moveDist / 0.20f)))); if (deltaTime > 0.04f) { - sweepSteps = std::min(12, std::max(sweepSteps, static_cast(std::ceil(deltaTime / 0.016f)))); + sweepSteps = std::min(16, std::max(sweepSteps, static_cast(std::ceil(deltaTime / 0.016f)))); } glm::vec3 stepPos = startFeet; glm::vec3 stepDelta = (desiredFeet - startFeet) / static_cast(sweepSteps); diff --git a/src/rendering/wmo_renderer.cpp b/src/rendering/wmo_renderer.cpp index fa16b289..bdac6a89 100644 --- a/src/rendering/wmo_renderer.cpp +++ b/src/rendering/wmo_renderer.cpp @@ -1515,9 +1515,9 @@ bool WMORenderer::checkWallCollision(const glm::vec3& from, const glm::vec3& to, if (moveDistXY < 0.001f) return false; // Player collision parameters - const float PLAYER_RADIUS = 0.55f; // Slightly wider for better wall collision + const float PLAYER_RADIUS = 0.70f; // Wider radius for better wall collision const float PLAYER_HEIGHT = 2.0f; // Player height for wall checks - const float MAX_STEP_HEIGHT = 0.85f; // Balanced step-up without wall pass-through + const float MAX_STEP_HEIGHT = 0.70f; // Lower step height to catch more walls // Debug logging static int wallDebugCounter = 0; @@ -1636,7 +1636,7 @@ bool WMORenderer::checkWallCollision(const glm::vec3& from, const glm::vec3& to, float horizDist = glm::length(glm::vec2(delta.x, delta.y)); if (horizDist <= PLAYER_RADIUS) { wallsHit++; - float pushDist = PLAYER_RADIUS - horizDist + 0.02f; + float pushDist = PLAYER_RADIUS - horizDist + 0.08f; // More aggressive pushback glm::vec2 pushDir2; if (horizDist > 1e-4f) { pushDir2 = glm::normalize(glm::vec2(delta.x, delta.y));