Toast Engine
Loading...
Searching...
No Matches
raycast.hpp
Go to the documentation of this file.
1
9
10#pragma once
11
12#include "body.hpp"
13#include "shape.hpp"
14#include "toast/world/box.hpp"
15
16#include <glm/glm.hpp>
17#include <optional>
18#include <vector>
19
20namespace physics {
21
22struct RayHit {
24 glm::vec3 position;
25 glm::vec3 normal;
26 float distance;
27 BodyID body;
28 ShapeID shape;
29};
30
36TOAST_API auto raycast(
37 glm::vec3 origin, glm::vec3 direction, float max_distance = -1.0f, BodyID ignored = {}, const std::vector<int>& layers = {}
38) -> std::optional<RayHit>;
39
45TOAST_API auto raymulticast(
46 glm::vec3 origin, glm::vec3 direction, float max_distance = -1.0f, int max_hits = -1, BodyID ignored = {},
47 const std::vector<int>& layers = {}
48) -> std::vector<RayHit>;
49
53TOAST_API auto linecast(glm::vec3 from, glm::vec3 to, int max_hits = -1, BodyID ignored = {}, const std::vector<int>& layers = {})
54 -> std::vector<RayHit>;
55
56struct SphereHit {
58 glm::vec3 position;
59 glm::vec3 normal;
60 float penetration;
61};
62
63TOAST_API auto sphereOverlap(glm::vec3 position, float radius) -> std::optional<SphereHit>;
64
66TOAST_API auto overlapAABB(glm::vec3 min, glm::vec3 max) -> bool;
67
68}
Body identifiers, creation data, and copied runtime state.
pseudo shared pointer for Nodes
Intrusive reference-counted handle to a Node.
Definition box.hpp:35
Shape identifiers, geometry, and runtime records.
Definition body.hpp:20
Definition raycast.hpp:22
Definition shape.hpp:29
Definition raycast.hpp:56