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"
8
9#include <cmath>
10#include <cstdint>
11#include <glm/vec3.hpp>
12
17namespace physics
18{
19
22{
23 // Side walls (wallrunning)
24 bool wallLeft{false};
25 bool wallRight{false};
26 glm::vec3 leftNormal{0.0f};
27 glm::vec3 rightNormal{0.0f};
28 glm::vec3 leftPoint{0.0f};
29 glm::vec3 rightPoint{0.0f};
30 uint32_t leftMeshIndex{UINT32_MAX};
31 uint32_t rightMeshIndex{UINT32_MAX};
32 uint32_t leftTriId{UINT32_MAX};
33 uint32_t rightTriId{UINT32_MAX};
36
37 // Front wall diagnostics.
38 bool wallFront{false};
39 glm::vec3 frontNormal{0.0f};
40 glm::vec3 frontPoint{0.0f};
41 uint32_t frontMeshIndex{UINT32_MAX};
42 uint32_t frontTriId{UINT32_MAX};
44
45 // Ground distance
46 float groundDistance{1e10f};
47};
48
51{
52 bool found{false};
53 glm::vec3 anchor{0.0f};
54 glm::vec3 normal{0.0f};
55 uint32_t meshIndex{UINT32_MAX};
56 uint32_t triId{UINT32_MAX};
58};
59
76WallDetectionResult detectWalls(glm::vec3 pos,
77 float yaw,
78 glm::vec3 halfExtents,
79 const WorldGeometry& world,
80 float checkDist,
81 float sphereRadius,
82 glm::vec3 prevWallNormal = glm::vec3(0.0f),
83 bool gravityFlipped = false,
84 bool includeGroundDistance = true);
85
88 glm::vec3 pos, glm::vec3 halfExtents, const WorldGeometry& world, float sphereRadius, bool gravityFlipped = false);
89
96WallAttachmentResult findWallRunAttachment(CapsuleShape capsule,
97 glm::vec3 pos,
98 const WorldGeometry& world,
99 glm::vec3 continuityNormal,
100 glm::vec3 travelDir = glm::vec3{0.0f},
101 float lookaheadDist = 0.0f,
102 float checkDist = 24.0f,
103 uint32_t previousMeshIndex = UINT32_MAX,
104 uint32_t previousTriId = UINT32_MAX,
105 TriRegion previousRegion = TriRegion::Face);
106
110inline bool isWallNormal(glm::vec3 normal)
111{
112 return std::abs(normal.y) < 0.3f;
113}
114
115} // namespace physics
Swept AABB and sphere collision queries against world geometry.
Triangle-mesh collision with BVH acceleration and seam welding.
Pure physics math — no ECS types, no registry.
Definition BroadphaseTree.cpp:11
bool isWallNormal(glm::vec3 normal)
Check if a surface normal represents a wall (not floor/ceiling).
Definition WallDetection.hpp:110
WallDetectionResult detectWalls(glm::vec3 pos, float yaw, glm::vec3 halfExtents, const WorldGeometry &world, float checkDist, float sphereRadius, glm::vec3 prevWallNormal, bool gravityFlipped, bool includeGroundDistance)
Detect walls to the left, right, and front of the player.
Definition WallDetection.cpp:308
TriRegion
Voronoi region of a triangle.
Definition TriMeshCollision.hpp:27
@ Face
Definition TriMeshCollision.hpp:28
WallAttachmentResult findWallRunAttachment(CapsuleShape capsule, glm::vec3 pos, const WorldGeometry &world, glm::vec3 continuityNormal, glm::vec3 travelDir, float lookaheadDist, float checkDist, uint32_t previousMeshIndex, uint32_t previousTriId, TriRegion previousRegion)
Find the best triangle-mesh wallrun attachment, with optional lookahead along the current travel dire...
Definition WallDetection.cpp:132
float probeWallrunGroundDistance(glm::vec3 pos, glm::vec3 halfExtents, const WorldGeometry &world, float sphereRadius, bool gravityFlipped)
Probe only the downward ground distance used by wallrun entry gates.
Definition WallDetection.cpp:492
Stable wallrun attachment target on authored triangle meshes.
Definition WallDetection.hpp:51
TriRegion region
Definition WallDetection.hpp:57
glm::vec3 normal
Definition WallDetection.hpp:54
uint32_t meshIndex
Definition WallDetection.hpp:55
uint32_t triId
Definition WallDetection.hpp:56
glm::vec3 anchor
Definition WallDetection.hpp:53
bool found
Definition WallDetection.hpp:52
Results of wall detection probes.
Definition WallDetection.hpp:22
glm::vec3 frontNormal
Surface normal of the front wall.
Definition WallDetection.hpp:39
uint32_t rightTriId
Triangle id for stable wallrun attachment, if applicable.
Definition WallDetection.hpp:33
uint32_t rightMeshIndex
Static trimesh index for stable wallrun attachment, if applicable.
Definition WallDetection.hpp:31
glm::vec3 frontPoint
World-space contact point on the front wall.
Definition WallDetection.hpp:40
TriRegion rightRegion
Closest triangle feature for wallrun seam traversal.
Definition WallDetection.hpp:35
glm::vec3 rightNormal
Surface normal of the right wall.
Definition WallDetection.hpp:27
glm::vec3 leftPoint
World-space contact point on the left wall.
Definition WallDetection.hpp:28
bool wallRight
True if a wall was detected to the right.
Definition WallDetection.hpp:25
glm::vec3 rightPoint
World-space contact point on the right wall.
Definition WallDetection.hpp:29
uint32_t leftMeshIndex
Static trimesh index for stable wallrun attachment, if applicable.
Definition WallDetection.hpp:30
bool wallFront
True if a wall was detected in front.
Definition WallDetection.hpp:38
bool wallLeft
True if a wall was detected to the left.
Definition WallDetection.hpp:24
uint32_t frontMeshIndex
Static trimesh index for the front-wall diagnostic, if applicable.
Definition WallDetection.hpp:41
uint32_t leftTriId
Triangle id for stable wallrun attachment, if applicable.
Definition WallDetection.hpp:32
uint32_t frontTriId
Triangle id for the front-wall diagnostic, if applicable.
Definition WallDetection.hpp:42
glm::vec3 leftNormal
Surface normal of the left wall.
Definition WallDetection.hpp:26
TriRegion frontRegion
Closest triangle feature for the front-wall diagnostic.
Definition WallDetection.hpp:43
float groundDistance
Distance to ground below the player (u).
Definition WallDetection.hpp:46
TriRegion leftRegion
Closest triangle feature for wallrun seam traversal.
Definition WallDetection.hpp:34