|
Toast Engine
|
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>

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. | |
Raycast Implmentation mostly from https://iquilezles.org/articles/intersectors/ and https://www.realtimerendering.com/intersections.html.
| 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
| 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
| ignored | Shapes of this body are not hit |
| layers | Indices of the layers a body must include one of to be hit, every layer when empty |