group2 0.1.0
CSE 125 Group 2
Loading...
Searching...
No Matches
SweptCollision.hpp
Go to the documentation of this file.
1
3
4#pragma once
5
7#include "SurfaceType.hpp"
8
9#include <cmath>
10#include <cstdint>
11#include <functional>
12#include <glm/geometric.hpp>
13#include <glm/vec3.hpp>
14#include <span>
15#include <vector>
16
26namespace physics
27{
28
36
39{
40 glm::vec3 min;
41 glm::vec3 max;
43};
44
64
76
84
86struct BVHNode
87{
88 glm::vec3 boundsMin;
89 glm::vec3 boundsMax;
91 int count;
92};
93
108{
109 std::vector<glm::vec3> vertices;
110 std::vector<uint32_t> indices;
111 std::vector<BVHNode> bvhNodes;
112 std::vector<uint32_t> triIndices;
113 glm::vec3 boundsMin{0.0f};
114 glm::vec3 boundsMax{0.0f};
115
116 // Welding data (one entry per canonical triangle index in `indices`).
117 std::vector<glm::vec3> faceNormals;
118 std::vector<uint8_t> edgeActive;
119 std::vector<uint8_t> vertActive;
120
134 std::vector<uint32_t> edgeNeighbor;
135
136 // Phase 3 material data. If `triangleMaterials` is empty, every triangle
137 // falls back to `defaultSurface`. Authored by `MapLoader` from Blender
138 // per-face materials.
139 std::vector<uint8_t> triangleMaterials;
141};
142
149{
150 std::vector<BVHNode> nodes;
151 std::vector<uint32_t> meshIndices;
152 std::vector<WorldAABB> meshBounds;
153};
154
156void buildStaticWorldBroadphase(StaticWorldBroadphase& broadphase, std::span<const WorldTriMesh> triMeshes);
157
162 const WorldAABB& query,
163 const std::function<bool(uint32_t meshIndex)>& visit);
164
165[[nodiscard]] inline bool broadphaseAabbOverlap(const WorldAABB& a, const WorldAABB& b) noexcept
166{
167 return a.max.x >= b.min.x && a.min.x <= b.max.x && a.max.y >= b.min.y && a.min.y <= b.max.y && a.max.z >= b.min.z &&
168 a.min.z <= b.max.z;
169}
170
171template <class Visit>
172inline void
174{
176 if (broadphase.nodes.empty())
177 return;
178
179 constexpr int kStackCapacity = 128;
180 int stack[kStackCapacity];
181 std::vector<int> overflowStack;
182 int stackPtr = 0;
183 stack[0] = 0;
184
185 auto pushNode = [&](int nodeIndex) {
186 if (stackPtr + 1 < kStackCapacity) {
187 stack[++stackPtr] = nodeIndex;
188 } else {
189 overflowStack.push_back(nodeIndex);
190 }
191 };
192
193 while (stackPtr >= 0 || !overflowStack.empty()) {
194 int nodeIdx = 0;
195 if (stackPtr >= 0) {
196 nodeIdx = stack[stackPtr--];
197 } else {
198 nodeIdx = overflowStack.back();
199 overflowStack.pop_back();
200 }
201 const BVHNode& node = broadphase.nodes[static_cast<std::size_t>(nodeIdx)];
202 const WorldAABB nodeBounds{.min = node.boundsMin, .max = node.boundsMax};
203 if (!broadphaseAabbOverlap(nodeBounds, query))
204 continue;
205
206 if (node.count > 0) {
207 for (int i = node.leftFirst; i < node.leftFirst + node.count; ++i) {
208 const uint32_t meshIndex = broadphase.meshIndices[static_cast<std::size_t>(i)];
209 if (meshIndex >= broadphase.meshBounds.size() ||
210 !broadphaseAabbOverlap(broadphase.meshBounds[meshIndex], query))
211 continue;
213 if (!visit(meshIndex))
214 return;
215 }
216 } else {
217 pushNode(node.leftFirst);
218 pushNode(node.leftFirst + 1);
219 }
220 }
221}
222
225{
226 std::span<const Plane> planes;
227 std::span<const WorldAABB> boxes;
228 std::span<const WorldBrush> brushes;
229 std::span<const WorldCylinder> cylinders;
230 std::span<const WorldSphere> spheres;
231 std::span<const WorldTriMesh> triMeshes;
233};
234
247{
248 float radius{16.0f};
249 float halfHeight{20.0f};
250 glm::vec3 up{0.0f, 1.0f, 0.0f};
251
253 [[nodiscard]] glm::vec3 segA(glm::vec3 center) const noexcept { return center + up * halfHeight; }
254
256 [[nodiscard]] glm::vec3 segB(glm::vec3 center) const noexcept { return center - up * halfHeight; }
257
262 [[nodiscard]] glm::vec3 enclosingHalfExtents() const noexcept
263 {
264 return {std::abs(up.x) * halfHeight + radius,
265 std::abs(up.y) * halfHeight + radius,
266 std::abs(up.z) * halfHeight + radius};
267 }
268
275 [[nodiscard]] float minkowskiExtent(glm::vec3 n) const noexcept
276 {
277 return radius + halfHeight * std::abs(glm::dot(up, n));
278 }
279
285 [[nodiscard]] float effectiveStepHeight(float requestedStepHeight) const noexcept
286 {
287 const float maxAllowed = std::max(halfHeight - 0.5f, 0.0f);
288 const float clamped = std::min(std::max(requestedStepHeight, 0.0f), maxAllowed);
289 return clamped;
290 }
291
299 [[nodiscard]] CapsuleShape walkShape(float requestedStepHeight) const noexcept
300 {
301 const float effStep = effectiveStepHeight(requestedStepHeight);
302 return CapsuleShape{.radius = radius, .halfHeight = halfHeight - effStep * 0.5f, .up = up};
303 }
304
308 [[nodiscard]] glm::vec3 walkCenterOffset(float requestedStepHeight) const noexcept
309 {
310 return up * (effectiveStepHeight(requestedStepHeight) * 0.5f);
311 }
312};
313
316{
317 bool hit{false};
318 float tFirst{1.0f};
319 glm::vec3 normal{0.0f, 1.0f, 0.0f};
321};
322
335HitResult sweepAABB(glm::vec3 halfExtents, glm::vec3 start, glm::vec3 end, std::span<const Plane> planes);
336
342HitResult sweepAABBvsBox(glm::vec3 halfExtents, glm::vec3 start, glm::vec3 end, const WorldAABB& box);
343
348HitResult sweepAABBvsBrush(glm::vec3 halfExtents, glm::vec3 start, glm::vec3 end, const WorldBrush& brush);
349
355HitResult sweepAABBvsCylinder(glm::vec3 halfExtents, glm::vec3 start, glm::vec3 end, const WorldCylinder& cyl);
356
362HitResult sweepAABBvsSphere(glm::vec3 halfExtents, glm::vec3 start, glm::vec3 end, const WorldSphere& sph);
363
365HitResult sweepAll(glm::vec3 halfExtents, glm::vec3 start, glm::vec3 end, const WorldGeometry& world);
366
367// Capsule swept-collision against convex primitives. Planes and brushes use
368// per-plane capsule extents; box, cylinder, and sphere keep conservative
369// dev-arena approximations. Production map geometry is expected to use the
370// trimesh capsule path in TriMeshCollision.hpp.
371
373HitResult sweepCapsuleVsPlanes(CapsuleShape capsule, glm::vec3 start, glm::vec3 end, std::span<const Plane> planes);
374
376HitResult sweepCapsuleVsBox(CapsuleShape capsule, glm::vec3 start, glm::vec3 end, const WorldAABB& box);
377
379HitResult sweepCapsuleVsBrush(CapsuleShape capsule, glm::vec3 start, glm::vec3 end, const WorldBrush& brush);
380
382HitResult sweepCapsuleVsCylinder(CapsuleShape capsule, glm::vec3 start, glm::vec3 end, const WorldCylinder& cyl);
383
385HitResult sweepCapsuleVsSphere(CapsuleShape capsule, glm::vec3 start, glm::vec3 end, const WorldSphere& sph);
386
388HitResult sweepAll(CapsuleShape capsule, glm::vec3 start, glm::vec3 end, const WorldGeometry& world);
389
407{
408 bool contact{false};
409 float distance{1e30f};
410 glm::vec3 pointOnGeometry{0.0f};
411 glm::vec3 normal{0.0f, 1.0f, 0.0f};
413};
414
415// Capsule-vs-primitive closest-point queries (Phase C clearance CA).
416//
417// Each query returns the directed distance from the capsule's surface to
418// the nearest point on the primitive (positive = outside, zero = touching,
419// negative = penetrating) and the contact normal pointing into free space.
420//
421// EXACT for planes, brushes, and spheres. For boxes, cylinders, and
422// trimeshes the query uses the underlying segment-vs-primitive geometry
423// where exact (capsule axis as the moving feature), falling back to
424// capsule's enclosing AABB where exact would require disproportionate
425// per-feature math (boxes — exact would need full SAT-vs-segment).
426//
427// All results are conservative: the reported `distance` is always
428// ≤ the true distance, so an advance of `distance / velIntoSurface`
429// along the velocity direction never penetrates.
430
431ClearanceResult clearanceCapsuleVsPlanes(CapsuleShape capsule, glm::vec3 pos, std::span<const Plane> planes);
432ClearanceResult clearanceCapsuleVsBox(CapsuleShape capsule, glm::vec3 pos, const WorldAABB& box);
433ClearanceResult clearanceCapsuleVsBrush(CapsuleShape capsule, glm::vec3 pos, const WorldBrush& brush);
434ClearanceResult clearanceCapsuleVsCylinder(CapsuleShape capsule, glm::vec3 pos, const WorldCylinder& cyl);
435ClearanceResult clearanceCapsuleVsSphere(CapsuleShape capsule, glm::vec3 pos, const WorldSphere& sph);
436
440ClearanceResult clearanceCapsuleVsWorld(CapsuleShape capsule,
441 glm::vec3 pos,
442 const WorldGeometry& world,
443 float maxMeshSearchRadius = 1024.0f);
444
445// Character-controller utilities (modern KCC pattern)
446
455{
456 bool hit{false};
457 bool walkable{false};
458 float distance{1e30f};
459 glm::vec3 point{0.0f};
460 glm::vec3 normal{0.0f, 1.0f, 0.0f};
462};
463
480GroundProbeResult probeGround(CapsuleShape capsule, glm::vec3 pos, float maxDistance, const WorldGeometry& world);
481
492{
493 bool valid{false};
494 float depth{0.0f};
495 glm::vec3 normal{0.0f, 1.0f, 0.0f};
497};
498
500{
501 float maxPushDistance{1e30f};
503};
504
506{
507 float pushDistance{0.0f};
508 int passes{0};
509 bool emergencyUnstuck{false};
510 bool exceededMaxPush{false};
511 bool unresolvedOverlap{false};
512};
513
517DepenContact deepestCapsuleContact(CapsuleShape capsule, glm::vec3 pos, glm::vec3 vel, const WorldGeometry& world);
518
536void depenetrateCapsuleVsWorld(glm::vec3& pos, glm::vec3& vel, CapsuleShape capsule, const WorldGeometry& world);
537
538DepenetrationResult depenetrateCapsuleVsWorldDetailed(glm::vec3& pos,
539 glm::vec3& vel,
540 CapsuleShape capsule,
541 const WorldGeometry& world,
542 DepenetrationOptions options = {});
543
554bool emergencyUnstick(glm::vec3& pos, glm::vec3& vel, CapsuleShape capsule, const WorldGeometry& world);
555
556// Sphere cast
557
560{
561 bool hit{false};
562 float t{1.0f};
563 glm::vec3 normal{0.0f, 1.0f, 0.0f};
564 glm::vec3 point{0.0f};
566};
567
578SphereHitResult sphereCast(float radius, glm::vec3 start, glm::vec3 end, const WorldGeometry& world);
579
580} // namespace physics
Optional per-frame physics/KCC counters for client performance captures.
Surface-material classification shared across collision, raycasts, VFX, SFX, and damage falloff.
SurfaceType
Surface material hit by a projectile / hitscan / contact.
Definition SurfaceType.hpp:28
@ Concrete
Definition SurfaceType.hpp:30
Definition BroadphaseTree.cpp:11
void add(std::uint32_t FrameStats::*field, std::uint32_t amount=1) noexcept
Definition PhysicsPerfStats.hpp:107
Pure physics math — no ECS types, no registry.
Definition BroadphaseTree.cpp:11
bool emergencyUnstick(glm::vec3 &pos, glm::vec3 &vel, CapsuleShape capsule, const WorldGeometry &world)
Last-resort recovery for a capsule embedded in geometry with no clear depen direction.
Definition SweptCollision.cpp:1432
ClearanceResult clearanceCapsuleVsWorld(CapsuleShape capsule, glm::vec3 pos, const WorldGeometry &world, float maxMeshSearchRadius)
Scene-wide minimum clearance.
Definition SweptCollision.cpp:1096
HitResult sweepAll(glm::vec3 halfExtents, glm::vec3 start, glm::vec3 end, const WorldGeometry &world)
Sweep an AABB against all world geometry, returning the earliest hit.
Definition SweptCollision.cpp:856
bool broadphaseAabbOverlap(const WorldAABB &a, const WorldAABB &b) noexcept
Definition SweptCollision.hpp:165
HitResult sweepCapsuleVsCylinder(CapsuleShape capsule, glm::vec3 start, glm::vec3 end, const WorldCylinder &cyl)
Sweep a capsule against a vertical cylinder. Conservative.
Definition SweptCollision.cpp:714
HitResult sweepAABBvsBox(glm::vec3 halfExtents, glm::vec3 start, glm::vec3 end, const WorldAABB &box)
Sweep an AABB against a static axis-aligned box.
Definition SweptCollision.cpp:270
ClearanceResult clearanceCapsuleVsSphere(CapsuleShape capsule, glm::vec3 pos, const WorldSphere &sph)
Definition SweptCollision.cpp:1071
SphereHitResult sphereCast(float radius, glm::vec3 start, glm::vec3 end, const WorldGeometry &world)
Cast a sphere along the path [start, end] against all world geometry.
Definition SweptCollision.cpp:1477
void buildStaticWorldBroadphase(StaticWorldBroadphase &broadphase, std::span< const WorldTriMesh > triMeshes)
Rebuild the immutable broadphase over all static triangle meshes.
Definition SweptCollision.cpp:189
HitResult sweepCapsuleVsPlanes(CapsuleShape capsule, glm::vec3 start, glm::vec3 end, std::span< const Plane > planes)
Sweep a capsule along [start, end] against a list of infinite planes.
Definition SweptCollision.cpp:577
HitResult sweepAABBvsSphere(glm::vec3 halfExtents, glm::vec3 start, glm::vec3 end, const WorldSphere &sph)
Sweep an AABB against a sphere.
Definition SweptCollision.cpp:519
HitResult sweepAABBvsCylinder(glm::vec3 halfExtents, glm::vec3 start, glm::vec3 end, const WorldCylinder &cyl)
Sweep an AABB against a vertical cylinder.
Definition SweptCollision.cpp:411
HitResult sweepCapsuleVsBox(CapsuleShape capsule, glm::vec3 start, glm::vec3 end, const WorldAABB &box)
Sweep a capsule against a static axis-aligned box. Conservative.
Definition SweptCollision.cpp:603
HitResult sweepCapsuleVsBrush(CapsuleShape capsule, glm::vec3 start, glm::vec3 end, const WorldBrush &brush)
Sweep a capsule against a convex brush. Exact (per-plane Minkowski extent).
Definition SweptCollision.cpp:665
HitResult sweepAABB(glm::vec3 halfExtents, glm::vec3 start, glm::vec3 end, std::span< const Plane > planes)
Sweep an AABB along the path [start, end] against a list of infinite planes.
Definition SweptCollision.cpp:224
DepenetrationResult depenetrateCapsuleVsWorldDetailed(glm::vec3 &pos, glm::vec3 &vel, CapsuleShape capsule, const WorldGeometry &world, DepenetrationOptions options)
Definition SweptCollision.cpp:1357
ClearanceResult clearanceCapsuleVsCylinder(CapsuleShape capsule, glm::vec3 pos, const WorldCylinder &cyl)
Definition SweptCollision.cpp:1058
ClearanceResult clearanceCapsuleVsPlanes(CapsuleShape capsule, glm::vec3 pos, std::span< const Plane > planes)
Definition SweptCollision.cpp:936
HitResult sweepAABBvsBrush(glm::vec3 halfExtents, glm::vec3 start, glm::vec3 end, const WorldBrush &brush)
Sweep an AABB against a convex brush (set of bounding planes).
Definition SweptCollision.cpp:346
DepenContact deepestCapsuleContact(CapsuleShape capsule, glm::vec3 pos, glm::vec3 vel, const WorldGeometry &world)
Scene-wide deepest single contact (per-primitive, per-feature).
Definition SweptCollision.cpp:1332
void depenetrateCapsuleVsWorld(glm::vec3 &pos, glm::vec3 &vel, CapsuleShape capsule, const WorldGeometry &world)
Per-pass-deepest-first capsule depenetration against the whole world.
Definition SweptCollision.cpp:1427
ClearanceResult clearanceCapsuleVsBrush(CapsuleShape capsule, glm::vec3 pos, const WorldBrush &brush)
Definition SweptCollision.cpp:1015
void queryStaticWorldBroadphase(const StaticWorldBroadphase &broadphase, const WorldAABB &query, const std::function< bool(uint32_t meshIndex)> &visit)
Visit triangle-mesh indices whose mesh bounds overlap query.
Definition SweptCollision.cpp:217
HitResult sweepCapsuleVsSphere(CapsuleShape capsule, glm::vec3 start, glm::vec3 end, const WorldSphere &sph)
Sweep a capsule against a sphere. Conservative.
Definition SweptCollision.cpp:810
ClearanceResult clearanceCapsuleVsBox(CapsuleShape capsule, glm::vec3 pos, const WorldAABB &box)
Definition SweptCollision.cpp:954
GroundProbeResult probeGround(CapsuleShape capsule, glm::vec3 pos, float maxDistance, const WorldGeometry &world)
Downward sweep that classifies the ground under a capsule.
Definition SweptCollision.cpp:1133
void queryStaticWorldBroadphaseFast(const StaticWorldBroadphase &broadphase, const WorldAABB &query, Visit &&visit)
Definition SweptCollision.hpp:173
A single BVH node for spatial acceleration of triangle meshes.
Definition SweptCollision.hpp:87
int leftFirst
If leaf: index into triIndices[]. If interior: left child index.
Definition SweptCollision.hpp:90
glm::vec3 boundsMax
AABB maximum corner.
Definition SweptCollision.hpp:89
int count
>0 → leaf with count triangles. 0 → interior node.
Definition SweptCollision.hpp:91
glm::vec3 boundsMin
AABB minimum corner.
Definition SweptCollision.hpp:88
Capsule shape input for swept-collision queries.
Definition SweptCollision.hpp:247
glm::vec3 enclosingHalfExtents() const noexcept
Tight half-extents of the AABB that encloses the capsule at center.
Definition SweptCollision.hpp:262
float halfHeight
Half the segment length (excludes spherical caps).
Definition SweptCollision.hpp:249
glm::vec3 up
Unit-length axis direction.
Definition SweptCollision.hpp:250
CapsuleShape walkShape(float requestedStepHeight) const noexcept
"Walk" capsule — a shorter capsule whose foot is lifted by stepHeight (using effectiveStepHeight) and...
Definition SweptCollision.hpp:299
float radius
Cylinder cross-section radius.
Definition SweptCollision.hpp:248
float effectiveStepHeight(float requestedStepHeight) const noexcept
Clamp a requested step height to a value the capsule can safely support — never larger than the segme...
Definition SweptCollision.hpp:285
glm::vec3 segA(glm::vec3 center) const noexcept
Top endpoint of the inner segment at center.
Definition SweptCollision.hpp:253
glm::vec3 segB(glm::vec3 center) const noexcept
Bottom endpoint of the inner segment at center.
Definition SweptCollision.hpp:256
float minkowskiExtent(glm::vec3 n) const noexcept
Minkowski half-extent of the capsule along a unit direction n.
Definition SweptCollision.hpp:275
glm::vec3 walkCenterOffset(float requestedStepHeight) const noexcept
Centre-position offset that takes a full-capsule centre to the matching walk-capsule centre (head ali...
Definition SweptCollision.hpp:308
Result of a shape-vs-geometry closest-point clearance query.
Definition SweptCollision.hpp:407
float distance
Signed distance shape-surface → geometry-surface.
Definition SweptCollision.hpp:409
glm::vec3 normal
Unit-length, points from geometry into free space.
Definition SweptCollision.hpp:411
bool contact
True when distance <= contactEpsilon.
Definition SweptCollision.hpp:408
glm::vec3 pointOnGeometry
World-space closest point on the geometry side.
Definition SweptCollision.hpp:410
SurfaceType surfaceType
Material tag at the closest feature.
Definition SweptCollision.hpp:412
Single deepest contact from a capsule against a primitive or the world.
Definition SweptCollision.hpp:492
glm::vec3 normal
Definition SweptCollision.hpp:495
SurfaceType surfaceType
Definition SweptCollision.hpp:496
float depth
Definition SweptCollision.hpp:494
bool valid
Definition SweptCollision.hpp:493
Definition SweptCollision.hpp:500
bool allowEmergencyUnstick
Definition SweptCollision.hpp:502
float maxPushDistance
Definition SweptCollision.hpp:501
Definition SweptCollision.hpp:506
bool unresolvedOverlap
Definition SweptCollision.hpp:511
int passes
Definition SweptCollision.hpp:508
bool emergencyUnstuck
Definition SweptCollision.hpp:509
float pushDistance
Definition SweptCollision.hpp:507
bool exceededMaxPush
Definition SweptCollision.hpp:510
Result of a downward ground probe — what's directly under a character's feet, classified for walkabil...
Definition SweptCollision.hpp:455
glm::vec3 point
World-space contact point on the surface.
Definition SweptCollision.hpp:459
float distance
Foot-to-surface signed distance along the probe axis.
Definition SweptCollision.hpp:458
bool walkable
True if the surface normal makes it standable per k_floorAngleCos.
Definition SweptCollision.hpp:457
SurfaceType surfaceType
Material at the hit surface.
Definition SweptCollision.hpp:461
glm::vec3 normal
Outward-pointing surface normal (toward free space).
Definition SweptCollision.hpp:460
bool hit
True if any surface was found within the probe range.
Definition SweptCollision.hpp:456
Result of a swept AABB collision query.
Definition SweptCollision.hpp:316
SurfaceType surfaceType
Material at the hit surface (Phase 3).
Definition SweptCollision.hpp:320
glm::vec3 normal
Surface normal at the contact point.
Definition SweptCollision.hpp:319
float tFirst
Fraction along the movement path [0..1] where the first hit occurs.
Definition SweptCollision.hpp:318
bool hit
True if the sweep intersected a plane.
Definition SweptCollision.hpp:317
An infinite plane dividing free space from solid geometry.
Definition SweptCollision.hpp:31
SurfaceType surfaceType
Material tag for impact VFX / SFX (Phase 3).
Definition SweptCollision.hpp:34
glm::vec3 normal
Unit vector pointing into free (non-solid) space.
Definition SweptCollision.hpp:32
float distance
Signed offset: dot(normal, p) == distance for points on the plane.
Definition SweptCollision.hpp:33
Result of a sphere-cast query (includes world-space hit point).
Definition SweptCollision.hpp:560
glm::vec3 point
World-space contact point on the surface.
Definition SweptCollision.hpp:564
bool hit
Definition SweptCollision.hpp:561
float t
Fraction along path [0..1].
Definition SweptCollision.hpp:562
glm::vec3 normal
Surface normal at contact.
Definition SweptCollision.hpp:563
SurfaceType surfaceType
Material at the hit surface (Phase 3).
Definition SweptCollision.hpp:565
Immutable world-level BVH over WorldTriMesh bounds.
Definition SweptCollision.hpp:149
std::vector< uint32_t > meshIndices
Definition SweptCollision.hpp:151
std::vector< WorldAABB > meshBounds
Definition SweptCollision.hpp:152
std::vector< BVHNode > nodes
Definition SweptCollision.hpp:150
An axis-aligned box in world space, used as static collision geometry.
Definition SweptCollision.hpp:39
SurfaceType surfaceType
Material tag (Phase 3).
Definition SweptCollision.hpp:42
glm::vec3 max
Maximum corner (highest x, y, z).
Definition SweptCollision.hpp:41
glm::vec3 min
Minimum corner (lowest x, y, z).
Definition SweptCollision.hpp:40
A convex volume defined by bounding planes (for ramps, angled walls, etc.).
Definition SweptCollision.hpp:58
Plane planes[k_maxPlanes]
Definition SweptCollision.hpp:60
static constexpr int k_maxPlanes
Definition SweptCollision.hpp:59
SurfaceType surfaceType
Material tag (Phase 3).
Definition SweptCollision.hpp:62
int planeCount
Definition SweptCollision.hpp:61
A vertical (Y-axis) cylinder in world space.
Definition SweptCollision.hpp:70
float radius
Horizontal radius.
Definition SweptCollision.hpp:72
float height
Extent along +Y from base.
Definition SweptCollision.hpp:73
glm::vec3 base
Centre of the bottom cap.
Definition SweptCollision.hpp:71
SurfaceType surfaceType
Material tag (Phase 3).
Definition SweptCollision.hpp:74
All world collision geometry for one tick.
Definition SweptCollision.hpp:225
std::span< const WorldCylinder > cylinders
Definition SweptCollision.hpp:229
std::span< const WorldTriMesh > triMeshes
Definition SweptCollision.hpp:231
const StaticWorldBroadphase * staticBroadphase
Definition SweptCollision.hpp:232
std::span< const Plane > planes
Definition SweptCollision.hpp:226
std::span< const WorldAABB > boxes
Definition SweptCollision.hpp:227
std::span< const WorldBrush > brushes
Definition SweptCollision.hpp:228
std::span< const WorldSphere > spheres
Definition SweptCollision.hpp:230
A sphere in world space.
Definition SweptCollision.hpp:79
SurfaceType surfaceType
Material tag (Phase 3).
Definition SweptCollision.hpp:82
glm::vec3 center
Centre point.
Definition SweptCollision.hpp:80
float radius
Radius.
Definition SweptCollision.hpp:81
A triangle mesh with BVH acceleration for collision queries.
Definition SweptCollision.hpp:108
std::vector< uint8_t > vertActive
Bit i set ⇔ vertex i of this triangle is touched by an active edge.
Definition SweptCollision.hpp:119
std::vector< uint32_t > indices
Triangle indices (3 per triangle).
Definition SweptCollision.hpp:110
std::vector< uint8_t > triangleMaterials
One SurfaceType index per triangle (empty = use default).
Definition SweptCollision.hpp:139
std::vector< BVHNode > bvhNodes
Flat BVH node array.
Definition SweptCollision.hpp:111
std::vector< glm::vec3 > faceNormals
CCW face normal (unit length) per triangle.
Definition SweptCollision.hpp:117
std::vector< uint8_t > edgeActive
Bit i set ⇔ edge i of this triangle is an active (boundary or convex) edge.
Definition SweptCollision.hpp:118
SurfaceType defaultSurface
Fallback for triangles without per-face material data.
Definition SweptCollision.hpp:140
std::vector< glm::vec3 > vertices
All vertex positions (world space, scaled).
Definition SweptCollision.hpp:109
std::vector< uint32_t > edgeNeighbor
Phase B — edge → neighbour triangle adjacency.
Definition SweptCollision.hpp:134
glm::vec3 boundsMin
Whole-mesh AABB min.
Definition SweptCollision.hpp:113
glm::vec3 boundsMax
Whole-mesh AABB max.
Definition SweptCollision.hpp:114
std::vector< uint32_t > triIndices
Permutation: BVH leaf ranges → triangle indices.
Definition SweptCollision.hpp:112
std::uint32_t staticBroadphaseQueries
Definition PhysicsPerfStats.hpp:34
std::uint32_t staticBroadphaseMeshes
Definition PhysicsPerfStats.hpp:35