group2 0.1.0
CSE 125 Group 2
Loading...
Searching...
No Matches
DebugCollisionDraw.hpp File Reference

Debug accumulator for physics contact points and normals. More...

#include <cstdint>
#include <glm/vec3.hpp>
#include <span>
Include dependency graph for DebugCollisionDraw.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  physics::debug::Contact
 A single recorded contact event. More...

Namespaces

namespace  physics
 Pure physics math — no ECS types, no registry.
namespace  physics::debug

Enumerations

enum class  physics::debug::ContactSource : uint8_t {
  physics::debug::PlaneSweep = 0 , physics::debug::BoxSweep = 1 , physics::debug::BrushSweep = 2 , physics::debug::CylinderSweep = 3 ,
  physics::debug::SphereSweep = 4 , physics::debug::TriMeshSweep = 5 , physics::debug::PlaneDepen = 6 , physics::debug::BoxDepen = 7 ,
  physics::debug::BrushDepen = 8 , physics::debug::CylinderDepen = 9 , physics::debug::SphereDepen = 10 , physics::debug::TriMeshDepen = 11 ,
  physics::debug::Count = 12
}
 Source of a recorded contact, for filter / colour in the overlay. More...

Functions

void physics::debug::pushContact (const Contact &c) noexcept
 Push a contact event.
void physics::debug::pushSweepContact (glm::vec3 point, glm::vec3 normal, ContactSource source, uint32_t primitiveIndex=0) noexcept
 Convenience overload for non-depenetration (sweep) contacts.
void physics::debug::pushDepenContact (glm::vec3 point, glm::vec3 normal, float depth, ContactSource source, uint32_t primitiveIndex=0) noexcept
 Convenience overload for depenetration contacts (with depth).
void physics::debug::setEnabled (bool on) noexcept
 Enable / disable recording.
bool physics::debug::isEnabled () noexcept
 Query the recording flag. Internal fast-path predicate.
void physics::debug::beginFrame () noexcept
 Drain all thread-local buffers into the front buffer and clear them.
std::span< const Contactphysics::debug::contacts () noexcept
 Snapshot of all contacts pushed since the last beginFrame().

Detailed Description

Debug accumulator for physics contact points and normals.

Physics code (CollisionSystem, SweptCollision, TriMeshCollision) pushes contacts here at every hit event. When recording is disabled (the default) every push is wait-free and amounts to a single relaxed atomic load + branch — safe to leave wired in the release path.

All writes go through a thread-local buffer so the multithreaded physics kernels (e.g. CollisionSystem's parallelFor over players) never contend. Reads are made consistent by calling beginFrame() exactly once per rendered frame from the main thread, BEFORE the next physics step starts.

Determinism note. The buffer is purely diagnostic — no entry ever feeds back into the simulation. The enable/disable atomic is relaxed because out-of-order observation between threads cannot affect sim outcomes.