|
Candle v1.0
2D lighting for SFML
|
This file contains the Line struct and main raycast algorithm. More...
#include <limits>#include <SFML/System/Vector2.hpp>#include <SFML/Graphics/Rect.hpp>#include "Candle/geometry/Vector2.hpp"#include "Candle/Constants.hpp"Classes | |
| struct | sfu::Line |
| 2D Line defined by an origin point and a direction vector. More... | |
Functions | |
| template<typename Iterator > | |
| sf::Vector2f | sfu::castRay (const Iterator &begin, const Iterator &end, Line ray, float maxRange=std::numeric_limits< float >::infinity()) |
| Cast a ray against a set of segments. More... | |
This file contains the Line struct and main raycast algorithm.
| sf::Vector2f sfu::castRay | ( | const Iterator & | begin, |
| const Iterator & | end, | ||
| Line | ray, | ||
| float | maxRange = std::numeric_limits<float>::infinity() |
||
| ) |
Cast a ray against a set of segments.
Use a line as a ray, casted from its origin in its direction. It is intersected with * a set of segments, represented as [Lines](sfu::Line) too, and the one closest to the cast point is returned.
Segments are interpreted to be delimited by the ray.m_origin and ray.point(1).
| begin | Iterator to the first ray. |
| end | Iterator to the last ray. |
| ray | |
| maxRange | Optional argument to indicate the max distance allowed for a ray to hit a segment. |