mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-23 15:50:20 +00:00
Disable WMO floor cache and add camera collision with WMO/M2
Disabled persistent WMO floor grid cache - it stored one height per 2-unit cell causing fall-through at stairs where floor height changes within a cell. Per-frame dedup cache is sufficient for performance. Added camera raycast collision against WMO walls (when inside) and M2 objects to zoom in when camera would clip through geometry instead of phasing through walls.
This commit is contained in:
parent
dbadfb043b
commit
7765b41611
2 changed files with 26 additions and 18 deletions
|
|
@ -641,8 +641,30 @@ void CameraController::update(float deltaTime) {
|
|||
// Find max safe distance using raycast + sphere radius
|
||||
collisionDistance = currentDistance;
|
||||
|
||||
// Camera collision: terrain-only floor clamping (skip expensive WMO raycasts).
|
||||
// The camera may clip through WMO walls but won't go underground.
|
||||
// WMO raycast collision: zoom in when camera would clip through walls
|
||||
if (wmoRenderer && cachedInsideWMO && currentDistance > MIN_DISTANCE) {
|
||||
glm::vec3 camRayOrigin = pivot;
|
||||
glm::vec3 camRayDir = camDir;
|
||||
float wmoHitDist = wmoRenderer->raycastBoundingBoxes(camRayOrigin, camRayDir, currentDistance);
|
||||
if (wmoHitDist < currentDistance) {
|
||||
// Hit WMO geometry — pull camera in to avoid clipping
|
||||
constexpr float CAM_RADIUS = 0.3f;
|
||||
collisionDistance = std::max(MIN_DISTANCE, wmoHitDist - CAM_RADIUS);
|
||||
}
|
||||
}
|
||||
|
||||
// M2 raycast collision: zoom in when camera would clip through doodads
|
||||
if (m2Renderer && currentDistance > MIN_DISTANCE) {
|
||||
glm::vec3 camRayOrigin = pivot;
|
||||
glm::vec3 camRayDir = camDir;
|
||||
float m2HitDist = m2Renderer->raycastBoundingBoxes(camRayOrigin, camRayDir, currentDistance);
|
||||
if (m2HitDist < collisionDistance) {
|
||||
constexpr float CAM_RADIUS = 0.3f;
|
||||
collisionDistance = std::max(MIN_DISTANCE, m2HitDist - CAM_RADIUS);
|
||||
}
|
||||
}
|
||||
|
||||
// Camera collision: terrain-only floor clamping
|
||||
auto getTerrainFloorAt = [&](float x, float y) -> std::optional<float> {
|
||||
if (terrainManager) {
|
||||
return terrainManager->getHeightAt(x, y);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue