GDevelop Core
Core library for developing platforms and tools compatible with GDevelop.
Public Member Functions | Public Attributes | List of all members
Polygon2d Class Reference

Represents a polygon. Usually used for collisions masks. More...

#include <Polygon2d.h>

Public Member Functions

std::vector< gd::Vector2f > & GetVertices ()
 Get the vertices composing the polygon.
 
const std::vector< gd::Vector2f > & GetVertices () const
 Get the vertices composing the polygon.
 
void Move (double x, double y)
 Moves each vertices from the given amount. More...
 
void Rotate (double angle)
 Rotate the polygon. More...
 
void ComputeEdges () const
 Automatically fill edges vector using vertices.
 
bool IsConvex () const
 Check if the polygon is convex. More...
 
gd::Vector2f ComputeCenter () const
 Return the position of the center of the polygon.
 

Static Public Member Functions

Tools

Tool functions

static Polygon2d CreateRectangle (double width, double height)
 Create a rectangle.
 

Public Attributes

std::vector< gd::Vector2fvertices
 The vertices composing the polygon.
 
std::vector< gd::Vector2fedges
 Edges. Can be computed from vertices using ComputeEdges()
 

Detailed Description

Represents a polygon. Usually used for collisions masks.

This class stores the vertices of the polygon. It can also compute and store the edges ( needed by some collisions algorithms ) if ComputeEdges is called.

Member Function Documentation

◆ IsConvex()

bool Polygon2d::IsConvex ( ) const

Check if the polygon is convex.

Returns
true if the polygon is convex

◆ Move()

void Polygon2d::Move ( double  x,
double  y 
)

Moves each vertices from the given amount.

Note
Edges are updated, there is no need to call ComputeEdges after calling Move.

◆ Rotate()

void Polygon2d::Rotate ( double  angle)

Rotate the polygon.

Parameters
angleAngle in radians
Warning
Rotation is made clockwise
edges vector is not updated, you have to call ComputeEdges if needed.

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