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

Shared hitscan raycasting against world geometry and player hitboxes. More...

#include "ecs/components/CollisionShape.hpp"
#include "ecs/components/Hitbox.hpp"
#include "ecs/components/Player.hpp"
#include "ecs/components/Position.hpp"
#include "ecs/components/Projectile.hpp"
#include "ecs/physics/SweptCollision.hpp"
#include "ecs/physics/TriMeshCollision.hpp"
#include "ecs/physics/WorldData.hpp"
#include "ecs/registry/Registry.hpp"
#include <algorithm>
#include <cmath>
#include <glm/geometric.hpp>
Include dependency graph for Raycast.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  physics::HitscanHit
 Result of a hitscan raycast. More...
struct  physics::HitboxHit
 Skeleton-driven hitbox raycast (capsule-based). More...

Namespaces

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

Functions

bool physics::raycastAABB (glm::vec3 origin, glm::vec3 direction, const WorldAABB &box, float maxDistance, float &outDistance, glm::vec3 &outNormal)
 Ray vs axis-aligned box intersection (slab method).
bool physics::raycastCylinder (glm::vec3 origin, glm::vec3 direction, const WorldCylinder &cyl, float maxDistance, float &outDistance, glm::vec3 &outNormal)
 Ray vs vertical cylinder intersection.
bool physics::raycastSphere (glm::vec3 origin, glm::vec3 direction, const WorldSphere &sph, float maxDistance, float &outDistance, glm::vec3 &outNormal)
 Ray vs sphere intersection.
bool physics::raycastTriMesh (glm::vec3 origin, glm::vec3 direction, const WorldTriMesh &mesh, float maxDistance, float &outDistance, glm::vec3 &outNormal)
 Raycast against a triangle mesh using BVH-accelerated Möller-Trumbore.
bool physics::raycastBrush (glm::vec3 origin, glm::vec3 direction, const WorldBrush &brush, float maxDistance, float &outDistance, glm::vec3 &outNormal)
 Ray vs convex brush intersection (generalised slab method).
HitscanHit physics::raycastWorld (glm::vec3 origin, glm::vec3 direction, const WorldGeometry &world)
 Raycast against all static world geometry (planes + boxes + cylinders + spheres).
HitscanHit physics::raycastPlayers (Registry &registry, entt::entity shooter, glm::vec3 origin, glm::vec3 direction, float maxDistance)
 Raycast against all player hitboxes (axis-aligned capsule approximation).
HitscanHit physics::resolveHitscan (Registry &registry, entt::entity shooter, glm::vec3 origin, glm::vec3 direction)
 Full hitscan resolution: world geometry first, then players (closest wins).
bool physics::raycastCapsule (glm::vec3 origin, glm::vec3 dir, glm::vec3 A, glm::vec3 B, float r, float maxDist, float &outDist, glm::vec3 &outNormal)
 Ray vs capsule intersection.
HitboxHit physics::raycastPlayerHitboxes (Registry &registry, entt::entity shooter, glm::vec3 origin, glm::vec3 direction, float maxDistance)
 Raycast against all player hitbox capsules (skeleton-driven).
HitboxHit physics::resolveHitscanHitbox (Registry &registry, entt::entity shooter, glm::vec3 origin, glm::vec3 direction)
 Full hitscan with skeleton-driven hitboxes.

Variables

constexpr float physics::k_hitscanRange = 5000.0f
 Maximum hitscan distance in world units.
constexpr float physics::k_parallelEpsilon = 1e-6f
 Epsilon for parallel-ray checks.

Detailed Description

Shared hitscan raycasting against world geometry and player hitboxes.

Used by both the server (WeaponSystem) and the client (local fire VFX). Functions are inline so this remains a header-only utility.