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

Geometry representing the entire simulation. More...

#include <objects_geometry.h>

Inheritance diagram for GlobalGeometry:
ObjectGeometry

Public Member Functions

 GlobalGeometry ()
 Construct an ObjectGeometry.
virtual void create_box2d_shape (b2BodyId, b2ShapeDef &) override
 Create Box2D shape based on this geometry.
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 override
 Exports a boolean 2D grid showing which bins are covered by the geometry.
virtual 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.
virtual BoundingDisk compute_bounding_disk () const override
 Computes the bounding disk that completely encloses the geometry.
virtual BoundingBox compute_bounding_box () const override
 Computes the axis-aligned bounding box that completely encloses the geometry.
virtual float get_distance_to (b2Vec2 orig, b2Vec2 point) const override
 Compute the distance from a given point to the geometry.
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.

Additional Inherited Members

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

Detailed Description

Geometry representing the entire simulation.

Constructor & Destructor Documentation

◆ GlobalGeometry()

GlobalGeometry::GlobalGeometry ( )
inline

Construct an ObjectGeometry.

Member Function Documentation

◆ compute_bounding_box()

BoundingBox GlobalGeometry::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 GlobalGeometry::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()

virtual void GlobalGeometry::create_box2d_shape ( b2BodyId ,
b2ShapeDef &  )
inlineoverridevirtual

Create Box2D shape based on this geometry.

Implements ObjectGeometry.

◆ export_geometry_grid()

std::vector< std::vector< bool > > GlobalGeometry::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
overridevirtual

Exports a boolean 2D grid showing which bins are covered by the geometry.

Parameters
num_bins_xNumber of bins along the X-axis.
num_bins_yNumber of bins along the Y-axis.
bin_widthWidth (size) of each bin.
bin_heightHeight (size) of each bin.
obj_xThe x-coordinate of the object (geometry center).
obj_yThe y-coordinate of the object (geometry center).
Returns
A 2D vector of booleans. True in a given cell indicates that the geometry covers that bin.

Implements ObjectGeometry.

◆ generate_contours()

virtual arena_polygons_t GlobalGeometry::generate_contours ( std::size_t points_per_contour = 0,
b2Vec2 position = {0.0f, 0.0f} ) const
inlineoverridevirtual

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

virtual float GlobalGeometry::get_distance_to ( b2Vec2 orig,
b2Vec2 point ) const
inlineoverridevirtual

Compute the distance from a given point to the geometry.

Reimplemented from ObjectGeometry.

◆ render()

virtual void GlobalGeometry::render ( SDL_Renderer * ,
b2WorldId ,
float ,
float ,
float ,
uint8_t ,
uint8_t ,
uint8_t ,
uint8_t = 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: