Ray¶
C++ type: Ray
Description¶
A ray defined by an origin point and a direction/length vector. Used for raycasting — detecting which objects lie along the ray. Doriax supports raycasts against geometric volumes (AABB, OBB, Sphere, Plane) and against the physics simulation (Body2D / Body3D).
The direction vector doubles as the length of the ray — objects beyond origin + direction are not reported as hits.
Properties¶
| Type | Name | Langs |
|---|---|---|
| Vector3 | origin | C++ | Lua |
| Vector3 | direction | C++ | Lua |
Methods¶
| Type | Name | Langs |
|---|---|---|
| Vector3 | getPoint | C++ | Lua |
| RayReturn | intersects | C++ | Lua |
Property details¶
origin / direction¶
- Setter: void setOrigin(Vector3 point) / void setDirection(Vector3 direction)
- Getter: Vector3 getOrigin() const / Vector3 getDirection() const
origin is the start of the ray. direction is both the normalised direction and the maximum reach (its magnitude = ray length). Use Camera::screenToRay() to generate a ray from a screen pixel.
Method details¶
getPoint¶
- Vector3 getPoint(float distance) const
Returns the world-space point at distance units along the ray: origin + direction.normalized() * distance.
intersects¶
Multiple overloads for different collision targets:
- RayReturn intersects(const Plane& plane) const
- RayReturn intersects(const AABB& box) const
- RayReturn intersects(const OBB& obb) const
- RayReturn intersects(const Sphere& sphere) const
- RayReturn intersects(const Body2D& body) const
- RayReturn intersects(const Body3D& body) const
- RayReturn intersects(Scene* scene, RayFilter raytest) const
- RayReturn intersects(Scene* scene, RayFilter raytest, bool onlyStatic) const
- RayReturn intersects(Scene* scene, RayFilter raytest, uint16_t categoryBits, uint16_t maskBits) const
Returns a RayReturn struct. Test the result with if (result) or result.hit.