Disk-shaped geometry.
More...
#include <objects_geometry.h>
|
| | DiskGeometry (float _radius) |
| | Construct an ObjectGeometry.
|
| virtual void | create_box2d_shape (b2BodyId body_id, b2ShapeDef &shape_def) override |
| | Create Box2D shape based on this geometry.
|
| float | get_radius () const |
| | Return radius of the disk.
|
| 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 *renderer, b2WorldId world_id, float x, float y, float theta, uint8_t r, uint8_t g, uint8_t b, uint8_t alpha=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 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 float | get_distance_to (b2Vec2 orig, b2Vec2 point) const |
| | Compute the distance from a given point to the geometry.
|
◆ DiskGeometry()
| DiskGeometry::DiskGeometry |
( |
float | _radius | ) |
|
|
inline |
◆ compute_bounding_box()
| BoundingBox DiskGeometry::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 DiskGeometry::create_box2d_shape |
( |
b2BodyId | body_id, |
|
|
b2ShapeDef & | shape_def ) |
|
overridevirtual |
◆ export_geometry_grid()
| std::vector< std::vector< bool > > DiskGeometry::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_x | Number of bins along the X-axis. |
| num_bins_y | Number of bins along the Y-axis. |
| bin_width | Width (size) of each bin. |
| bin_height | Height (size) of each bin. |
| obj_x | The x-coordinate of the object (geometry center). |
| obj_y | The 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()
| arena_polygons_t DiskGeometry::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_radius()
| float DiskGeometry::get_radius |
( |
| ) |
const |
|
inline |
Return radius of the disk.
◆ render()
| void DiskGeometry::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 |
|
overridevirtual |
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.
◆ radius
| float DiskGeometry::radius |
|
protected |
The documentation for this class was generated from the following files: