MCPcopy Create free account
hub / github.com/RobLoach/raylib-cpp / Ray

Class Ray

include/Ray.hpp:12–85  ·  view source on GitHub ↗

* Ray type (useful for raycast) */

Source from the content-addressed store, hash-verified

10 * Ray type (useful for raycast)
11 */
12class Ray : public ::Ray {
13public:
14 Ray(const ::Ray& ray) { set(ray); }
15
16 constexpr Ray(::Vector3 position = {0.0f, 0.0f, 0.0f}, ::Vector3 direction = {0.0f, 0.0f, 0.0f})
17 : ::Ray{position, direction} {
18 // Nothing.
19 }
20
21 Ray(::Vector2 mousePosition, const ::Camera& camera) { set(::GetMouseRay(mousePosition, camera)); }
22
23 Ray& operator=(const ::Ray& ray) {
24 set(ray);
25 return *this;
26 }
27
28 GETTERSETTER(::Vector3, Position, position)
29 GETTERSETTER(::Vector3, Direction, direction)
30
31 /**
32 * Draw a ray line
33 */
34 void Draw(::Color color) const { DrawRay(*this, color); }
35
36 /**
37 * Get collision information between ray and sphere
38 */
39 RayCollision GetCollision(::Vector3 center, float radius) const {
40 return ::GetRayCollisionSphere(*this, center, radius);
41 }
42
43 /**
44 * Detect collision between ray and box
45 */
46 RayCollision GetCollision(const ::BoundingBox& box) const { return ::GetRayCollisionBox(*this, box); }
47
48 /**
49 * Get collision information between ray and mesh
50 */
51 RayCollision GetCollision(const ::Mesh& mesh, const ::Matrix& transform) const {
52 return ::GetRayCollisionMesh(*this, mesh, transform);
53 }
54
55 /**
56 * Get collision info between ray and triangle
57 */
58 RayCollision GetCollision(::Vector3 p1, ::Vector3 p2, ::Vector3 p3) const {
59 return ::GetRayCollisionTriangle(*this, p1, p2, p3);
60 }
61
62 /**
63 * Get collision info between ray and quad
64 */
65 RayCollision GetCollision(::Vector3 p1, ::Vector3 p2, ::Vector3 p3, ::Vector3 p4) const {
66 return ::GetRayCollisionQuad(*this, p1, p2, p3, p4);
67 }
68
69 /**

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected