Fix camera occlusion and stabilize WMO/M2 collision behavior

This commit is contained in:
Kelsi 2026-02-03 16:04:21 -08:00
parent d03ff5ee4c
commit a3f351f395
6 changed files with 247 additions and 127 deletions

View file

@ -41,8 +41,8 @@ private:
float pitch = 0.0f;
float fov = 45.0f;
float aspectRatio = 16.0f / 9.0f;
float nearPlane = 0.1f;
float farPlane = 200000.0f; // Large draw distance for terrain visibility
float nearPlane = 0.05f;
float farPlane = 30000.0f; // Improves depth precision vs extremely large far clip
glm::mat4 viewMatrix = glm::mat4(1.0f);
glm::mat4 projectionMatrix = glm::mat4(1.0f);

View file

@ -92,8 +92,8 @@ private:
static constexpr float ZOOM_SMOOTH_SPEED = 15.0f; // How fast zoom eases
static constexpr float CAM_SMOOTH_SPEED = 20.0f; // How fast camera position smooths
static constexpr float PIVOT_HEIGHT = 1.8f; // Pivot at head height
static constexpr float CAM_SPHERE_RADIUS = 0.2f; // Collision sphere radius
static constexpr float CAM_EPSILON = 0.05f; // Offset from walls
static constexpr float CAM_SPHERE_RADIUS = 0.32f; // Keep camera farther from geometry to avoid clipping-through surfaces
static constexpr float CAM_EPSILON = 0.22f; // Extra wall offset to avoid near-plane clipping artifacts
static constexpr float MIN_PITCH = -88.0f; // Look almost straight down
static constexpr float MAX_PITCH = 35.0f; // Limited upward look
glm::vec3* followTarget = nullptr;

View file

@ -57,6 +57,7 @@ struct M2Instance {
glm::vec3 rotation; // Euler angles in degrees
float scale;
glm::mat4 modelMatrix;
glm::mat4 invModelMatrix;
// Animation state
float animTime = 0.0f; // Current animation time