Geometry representing the entire arena (collection of wall polygons).
More...
#include <objects_geometry.h>
|
| | ArenaGeometry (arena_polygons_t const &arena_polygons) noexcept |
| | Ctor – keeps a ref to the polygon container that lives elsewhere.
|
| void | create_box2d_shape (b2BodyId body_id, b2ShapeDef &shape_def) override |
| | Create Box2D shape based on this geometry.
|
| std::vector< std::vector< bool > > | export_geometry_grid (std::size_t num_bins_x, std::size_t num_bins_y, float bin_width, float bin_height, float obj_x, float obj_y) const override |
| void | render (SDL_Renderer *, b2WorldId, float, float, float, uint8_t, uint8_t, uint8_t, uint8_t=255) const override |
| | Renders the object on the given SDL renderer.
|
| BoundingDisk | compute_bounding_disk () const override |
| | Computes the bounding disk that completely encloses the geometry.
|
| BoundingBox | compute_bounding_box () const override |
| | Computes the axis-aligned bounding box that completely encloses the geometry.
|
| float | get_distance_to (b2Vec2, b2Vec2 point) const override |
| | Return the shortest Euclidean distance between point and all arena walls.
|
| arena_polygons_t const & | get_arena_polygons () |
| virtual arena_polygons_t | generate_contours (std::size_t points_per_contour=0, b2Vec2 position={0.0f, 0.0f}) const override |
| | Return one or more polygonal contours that approximate / represent this geometry.
|
| | ObjectGeometry () |
| | Construct an ObjectGeometry.
|
| virtual | ~ObjectGeometry () |
| | Destructor.
|
| b2ShapeId | get_shape_id () const |
| | Return Box2D shape_id.
|
| virtual std::vector< std::vector< bool > > | export_geometry_grid (size_t num_bins_x, size_t num_bins_y, float bin_width, float bin_height, float obj_x, float obj_y) const =0 |
| | Exports a boolean 2D grid showing which bins are covered by the geometry.
|
Geometry representing the entire arena (collection of wall polygons).
Each element of arena_polygons describes one closed wall loop.
◆ ArenaGeometry()
Ctor – keeps a ref to the polygon container that lives elsewhere.
◆ compute_bounding_box()
| BoundingBox ArenaGeometry::compute_bounding_box |
( |
| ) |
const |
|
overridevirtual |
Computes the axis-aligned bounding box that completely encloses the geometry.
- Returns
- A BoundingBox with top-left corner (x,y) and width and height.
Implements ObjectGeometry.
◆ compute_bounding_disk()
Computes the bounding disk that completely encloses the geometry.
- Returns
- A BoundingDisk with center (x,y) and radius.
Implements ObjectGeometry.
◆ create_box2d_shape()
| void ArenaGeometry::create_box2d_shape |
( |
b2BodyId | body_id, |
|
|
b2ShapeDef & | shape_def ) |
|
inlineoverridevirtual |
◆ export_geometry_grid()
| std::vector< std::vector< bool > > ArenaGeometry::export_geometry_grid |
( |
std::size_t | num_bins_x, |
|
|
std::size_t | num_bins_y, |
|
|
float | bin_width, |
|
|
float | bin_height, |
|
|
float | obj_x, |
|
|
float | obj_y ) const |
|
override |
◆ generate_contours()
| arena_polygons_t ArenaGeometry::generate_contours |
( |
std::size_t | points_per_contour = 0, |
|
|
b2Vec2 | position = {0.0f, 0.0f} ) const |
|
overridevirtual |
Return one or more polygonal contours that approximate / represent this geometry.
- Parameters
-
| points_per_contour | Desired number of vertices for each contour (a rectangle has one contour, a disk has one, an arena may have many – one per wall). |
- Returns
- arena_polygons_t A vector of closed polygons (counter‑clockwise, last vertex different from the first – the caller may close the loop if needed).
Implements ObjectGeometry.
◆ get_arena_polygons()
◆ get_distance_to()
| float ArenaGeometry::get_distance_to |
( |
b2Vec2 | orig, |
|
|
b2Vec2 | point ) const |
|
overridevirtual |
Return the shortest Euclidean distance between point and all arena walls.
The orig parameter is ignored (it is only useful for geometries that need a reference point such as Catmull‑Rom splines).
Reimplemented from ObjectGeometry.
◆ render()
| void ArenaGeometry::render |
( |
SDL_Renderer * | renderer, |
|
|
b2WorldId | world_id, |
|
|
float | x, |
|
|
float | y, |
|
|
float | theta, |
|
|
uint8_t | r, |
|
|
uint8_t | g, |
|
|
uint8_t | b, |
|
|
uint8_t | alpha = 255 ) const |
|
inlineoverridevirtual |
Renders the object on the given SDL renderer.
- Parameters
-
| renderer | Pointer to the SDL_Renderer. |
| world_id | The Box2D world identifier (unused in rendering). |
| x | X coordinate |
| y | Y coordinate |
| r | Red color component |
| g | Green color component |
| b | Blue color component |
| alpha | Alpha color component |
Implements ObjectGeometry.
The documentation for this class was generated from the following files: