Pogosim
Loading...
Searching...
No Matches
ArenaGeometry Class Referencefinal

Geometry representing the entire arena (collection of wall polygons). More...

#include <objects_geometry.h>

Inheritance diagram for ArenaGeometry:
ObjectGeometry

Public Member Functions

 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.
Public Member Functions inherited from ObjectGeometry
 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.

Additional Inherited Members

Protected Attributes inherited from ObjectGeometry
bool shape_created = false
b2ShapeId shape_id
 Box2D shape identifier.

Detailed Description

Geometry representing the entire arena (collection of wall polygons).

Each element of arena_polygons describes one closed wall loop.

Constructor & Destructor Documentation

◆ ArenaGeometry()

ArenaGeometry::ArenaGeometry ( arena_polygons_t const & arena_polygons)
inlineexplicitnoexcept

Ctor – keeps a ref to the polygon container that lives elsewhere.

Member Function Documentation

◆ 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()

BoundingDisk ArenaGeometry::compute_bounding_disk ( ) const
overridevirtual

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

Create Box2D shape based on this geometry.

Implements ObjectGeometry.

◆ 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_contourDesired 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()

arena_polygons_t const & ArenaGeometry::get_arena_polygons ( )
inline

◆ 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
rendererPointer to the SDL_Renderer.
world_idThe Box2D world identifier (unused in rendering).
xX coordinate
yY coordinate
rRed color component
gGreen color component
bBlue color component
alphaAlpha color component

Implements ObjectGeometry.


The documentation for this class was generated from the following files: