group2 0.1.0
CSE 125 Group 2
Loading...
Searching...
No Matches
WallDetection.hpp
Go to the documentation of this file.
1
3
4#pragma once
5
6#include "SweptCollision.hpp"
7
8#include <cmath>
9#include <glm/vec3.hpp>
10
15namespace physics
16{
17
20{
21 // Side walls (wallrunning)
22 bool wallLeft{false};
23 bool wallRight{false};
24 glm::vec3 leftNormal{0.0f};
25 glm::vec3 rightNormal{0.0f};
26 glm::vec3 leftPoint{0.0f};
27 glm::vec3 rightPoint{0.0f};
28
29 // Front wall (climbing)
30 bool wallFront{false};
31 glm::vec3 frontNormal{0.0f};
32 glm::vec3 frontPoint{0.0f};
33
34 // Ledge (top of front wall)
35 bool ledgeDetected{false};
36 glm::vec3 ledgePoint{0.0f};
37 glm::vec3 ledgeNormal{0.0f};
38
39 // Ground distance
40 float groundDistance{1e10f};
41};
42
58WallDetectionResult detectWalls(glm::vec3 pos,
59 float yaw,
60 glm::vec3 halfExtents,
61 const WorldGeometry& world,
62 float checkDist,
63 float sphereRadius,
64 glm::vec3 prevWallNormal = glm::vec3(0.0f));
65
69inline bool isWallNormal(glm::vec3 normal)
70{
71 return std::abs(normal.y) < 0.3f;
72}
73
74} // namespace physics
Swept AABB and sphere collision queries against world geometry.
Pure physics math — no ECS types, no registry.
Definition MapLoader.cpp:51
bool isWallNormal(glm::vec3 normal)
Check if a surface normal represents a wall (not floor/ceiling).
Definition WallDetection.hpp:69
WallDetectionResult detectWalls(glm::vec3 pos, float yaw, glm::vec3 halfExtents, const WorldGeometry &world, float checkDist, float sphereRadius, glm::vec3 prevWallNormal)
Detect walls to the left, right, and front of the player via sphere casts.
Definition WallDetection.cpp:13
Results of wall detection sphere casts.
Definition WallDetection.hpp:20
glm::vec3 frontNormal
Surface normal of the front wall.
Definition WallDetection.hpp:31
glm::vec3 frontPoint
World-space contact point on the front wall.
Definition WallDetection.hpp:32
glm::vec3 rightNormal
Surface normal of the right wall.
Definition WallDetection.hpp:25
glm::vec3 leftPoint
World-space contact point on the left wall.
Definition WallDetection.hpp:26
bool wallRight
True if a wall was detected to the right.
Definition WallDetection.hpp:23
glm::vec3 rightPoint
World-space contact point on the right wall.
Definition WallDetection.hpp:27
bool wallFront
True if a wall was detected in front.
Definition WallDetection.hpp:30
bool wallLeft
True if a wall was detected to the left.
Definition WallDetection.hpp:22
glm::vec3 ledgePoint
World-space point on the ledge surface.
Definition WallDetection.hpp:36
glm::vec3 leftNormal
Surface normal of the left wall.
Definition WallDetection.hpp:24
float groundDistance
Distance to ground below the player (u).
Definition WallDetection.hpp:40
bool ledgeDetected
True if a ledge was detected above the front wall.
Definition WallDetection.hpp:35
glm::vec3 ledgeNormal
Wall normal at the ledge.
Definition WallDetection.hpp:37