Toast Engine
Loading...
Searching...
No Matches
raycast.hpp File Reference

Raycast Implmentation mostly from https://iquilezles.org/articles/intersectors/ and https://www.realtimerendering.com/intersections.html. More...

#include "body.hpp"
#include "shape.hpp"
#include "toast/world/box.hpp"
#include <glm/glm.hpp>
#include <optional>
#include <vector>
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::RayHit
struct  physics::SphereHit

Functions

auto physics::raycast (glm::vec3 origin, glm::vec3 direction, float max_distance, BodyID ignored, const std::vector< int > &layers) -> std::optional< RayHit >
auto physics::raymulticast (glm::vec3 origin, glm::vec3 direction, float max_distance, int max_hits, BodyID ignored, const std::vector< int > &layers) -> std::vector< RayHit >
auto physics::linecast (glm::vec3 from, glm::vec3 to, int max_hits, BodyID ignored, const std::vector< int > &layers) -> std::vector< RayHit >
auto physics::sphereOverlap (glm::vec3 position, float radius) -> std::optional< SphereHit >
auto physics::overlapAABB (glm::vec3 min, glm::vec3 max) -> bool
 Tests a world-space axis-aligned box against enabled physics shapes.

Detailed Description

Raycast Implmentation mostly from https://iquilezles.org/articles/intersectors/ and https://www.realtimerendering.com/intersections.html.

Author
Dante Harper
Date
25 Sep 26

Function Documentation

◆ linecast()

TOAST_API auto physics::linecast ( glm::vec3 from,
glm::vec3 to,
int max_hits = -1,
BodyID ignored = {},
const std::vector< int > & layers = {} ) -> std::vector< RayHit >

Like raymulticast from from until to

◆ raycast()

TOAST_API auto physics::raycast ( glm::vec3 origin,
glm::vec3 direction,
float max_distance = -1.0f,
BodyID ignored = {},
const std::vector< int > & layers = {} ) -> std::optional< RayHit >

The nearest thing a ray hits

Parameters
ignoredShapes of this body are not hit
layersIndices of the layers a body must include one of to be hit, every layer when empty

◆ raymulticast()

TOAST_API auto physics::raymulticast ( glm::vec3 origin,
glm::vec3 direction,
float max_distance = -1.0f,
int max_hits = -1,
BodyID ignored = {},
const std::vector< int > & layers = {} ) -> std::vector< RayHit >

Up to max_hits things a ray hits

Adds a hit per time a ray enters a body