|
ASW Lib
A.D.S. Games SDL Wrapper Library. A library targeted at Allegro4 users who want to switch to SDL3 and use modern c++.
|
Functions | |
| template<typename T > | |
| Vec2< T >::Real | signed_area (const Polygon< T > &polygon) |
| Get the signed area of a polygon. | |
| template<typename T > | |
| Quad< T > | bounds (const Polygon< T > &polygon) |
| Get the smallest rectangle that holds every corner of a polygon. | |
| template<typename T > | |
| bool | point_in_triangle (const Vec2< T > &point, const Vec2< T > &a, const Vec2< T > &b, const Vec2< T > &c) |
| Check if a point is inside a triangle. Points on an edge are inside. | |
| std::optional< float > | ray_hit (const Vec2f &origin, const Vec2f &direction, const Vec2f &a, const Vec2f &b) |
| Find where a ray hits a line segment. | |
| Polygonf | visibility (const Vec2f &from, float radius, const std::vector< Polygonf > &occluders, float direction=0.0F, float cone=0.0F) |
| Find the area that can be seen from a point. | |
| void | visibility (Polygonf &result, const Vec2f &from, float radius, const std::vector< Polygonf > &occluders, float direction=0.0F, float cone=0.0F) |
| Find the area that can be seen from a point, into a polygon you keep between calls so it does not allocate each time. | |
| void | visibility (Polygonf &result, const Vec2f &from, float radius, const std::vector< Polygonf > &occluders, const std::vector< Quadf > &occluder_bounds, float direction=0.0F, float cone=0.0F) |
| Find the area that can be seen from a point, with the bounds of the occluders already worked out, e.g. once per frame for many lights. | |
Get the smallest rectangle that holds every corner of a polygon.
| polygon | The polygon. |
Definition at line 766 of file geometry.h.
| bool asw::geometry::point_in_triangle | ( | const Vec2< T > & | point, |
| const Vec2< T > & | a, | ||
| const Vec2< T > & | b, | ||
| const Vec2< T > & | c ) |
Check if a point is inside a triangle. Points on an edge are inside.
| point | The point to check. |
| a | The first corner. |
| b | The second corner. |
| c | The third corner. |
Definition at line 790 of file geometry.h.
| std::optional< float > asw::geometry::ray_hit | ( | const Vec2f & | origin, |
| const Vec2f & | direction, | ||
| const Vec2f & | a, | ||
| const Vec2f & | b ) |
Find where a ray hits a line segment.
| origin | Where the ray starts. |
| direction | Which way the ray goes. It does not need to be normalized. |
| a | One end of the segment. |
| b | The other end of the segment. |
direction, or nothing when the ray misses or runs along the segment. Definition at line 86 of file geometry.cpp.
Get the signed area of a polygon.
| polygon | The polygon. |
Definition at line 751 of file geometry.h.
| asw::Polygonf asw::geometry::visibility | ( | const Vec2f & | from, |
| float | radius, | ||
| const std::vector< Polygonf > & | occluders, | ||
| float | direction = 0.0F, | ||
| float | cone = 0.0F ) |
Find the area that can be seen from a point.
Useful for field of view and for light. Rays stop at the first polygon edge, and at a square of half size radius around from.
| from | The point to look from. |
| radius | How far to look. |
| occluders | Polygons that block the view. |
| direction | Direction to look, in radians, when cone is set. |
| cone | Width of the view in radians. 0 looks all round. |
from. Definition at line 104 of file geometry.cpp.
| void asw::geometry::visibility | ( | Polygonf & | result, |
| const Vec2f & | from, | ||
| float | radius, | ||
| const std::vector< Polygonf > & | occluders, | ||
| const std::vector< Quadf > & | occluder_bounds, | ||
| float | direction = 0.0F, | ||
| float | cone = 0.0F ) |
Find the area that can be seen from a point, with the bounds of the occluders already worked out, e.g. once per frame for many lights.
| occluder_bounds | The bounds() of each occluder, in the same order. Must be the same size as occluders. |
Definition at line 123 of file geometry.cpp.
| void asw::geometry::visibility | ( | Polygonf & | result, |
| const Vec2f & | from, | ||
| float | radius, | ||
| const std::vector< Polygonf > & | occluders, | ||
| float | direction = 0.0F, | ||
| float | cone = 0.0F ) |
Find the area that can be seen from a point, into a polygon you keep between calls so it does not allocate each time.
| result | Replaced with the edge of the visible area. |
Definition at line 112 of file geometry.cpp.