From 58ec7693a151e4f1a2d654c8e66521d6f35957b6 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Sun, 8 Feb 2026 20:26:24 -0800 Subject: [PATCH] Relax walkable slope threshold and floor cache for steep stairs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changed walkable slope threshold from 0.45 (63°) to 0.40 (66°) in both WMO and M2 collision to allow climbing steeper stairs (like 60° steps). Increased WMO floor cache above-tolerance from 0.35 to 0.50 units to prevent falling through floors in places like Booty Bay where cached floor is slightly above query point. --- src/rendering/m2_renderer.cpp | 4 ++-- src/rendering/wmo_renderer.cpp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/rendering/m2_renderer.cpp b/src/rendering/m2_renderer.cpp index f91d6b56..9d99cffe 100644 --- a/src/rendering/m2_renderer.cpp +++ b/src/rendering/m2_renderer.cpp @@ -718,7 +718,7 @@ void M2ModelGPU::CollisionMesh::build() { glm::vec3 normal = glm::cross(v1 - v0, v2 - v0); float normalLen = glm::length(normal); float absNz = (normalLen > 0.001f) ? std::abs(normal.z / normalLen) : 0.0f; - bool isFloor = (absNz >= 0.45f); + bool isFloor = (absNz >= 0.40f); // ~66° max slope (relaxed for steep stairs) bool isWall = (absNz < 0.65f); float triMinX = std::min({v0.x, v1.x, v2.x}); @@ -2573,7 +2573,7 @@ std::optional M2Renderer::getFloorHeight(float glX, float glY, float glZ) if (localN.z < 0.0f) localN = -localN; glm::vec3 worldN = glm::normalize( glm::vec3(instance.modelMatrix * glm::vec4(localN, 0.0f))); - if (std::abs(worldN.z) < 0.45f) continue; // too steep + if (std::abs(worldN.z) < 0.40f) continue; // too steep (~66° max slope) } if (hitZ <= localPos.z + 3.0f && hitZ > bestHitZ) { diff --git a/src/rendering/wmo_renderer.cpp b/src/rendering/wmo_renderer.cpp index aabd084b..35355d9e 100644 --- a/src/rendering/wmo_renderer.cpp +++ b/src/rendering/wmo_renderer.cpp @@ -1607,7 +1607,7 @@ void WMORenderer::GroupResources::buildCollisionGrid() { glm::vec3 normal = glm::cross(edge1, edge2); float normalLen = glm::length(normal); float absNz = (normalLen > 0.001f) ? std::abs(normal.z / normalLen) : 0.0f; - bool isFloor = (absNz >= 0.45f); + bool isFloor = (absNz >= 0.40f); // ~66° max slope (relaxed for steep stairs) bool isWall = (absNz < 0.65f); // Matches walkable slope threshold int cellMinX = std::max(0, static_cast((triMinX - gridOrigin.x) * invCellW)); @@ -1750,7 +1750,7 @@ std::optional WMORenderer::getFloorHeight(float glX, float glY, float glZ float cachedHeight = gridIt->second; // Only trust cache if it's basically at foot level. // Prevent ledges/shoulder ramps from being treated as "floor". - constexpr float CACHE_ABOVE = 0.35f; // tune: 0.25–0.60 + constexpr float CACHE_ABOVE = 0.50f; // tune: 0.25–0.60 (increased to catch borderline floors) constexpr float CACHE_BELOW = 4.0f; // keep generous below if (cachedHeight <= glZ + CACHE_ABOVE && cachedHeight >= glZ - CACHE_BELOW) { // Persistent cache doesn't store normal — report as flat @@ -2066,7 +2066,7 @@ bool WMORenderer::checkWallCollision(const glm::vec3& from, const glm::vec3& to, if (horizDist <= PLAYER_RADIUS) { // Skip floor-like surfaces — grounding handles them, not wall collision float absNz = std::abs(normal.z); - if (absNz >= 0.45f) continue; + if (absNz >= 0.40f) continue; const float SKIN = 0.005f; // small separation so we don't re-collide immediately // Stronger push when inside WMO for more responsive indoor collision