GDevelop Core
Core library for developing platforms and tools compatible with GDevelop.
Polygon2d.h
1 /*
2  * GDevelop Core
3  * Copyright 2008-2016 Florian Rival ([email protected]). All rights
4  * reserved. This project is released under the MIT License.
5  */
6 #ifndef GDCORE_POLYGON_H
7 #define GDCORE_POLYGON_H
8 #include <vector>
9 
10 #include "GDCore/Vector2.h"
11 
21 class GD_CORE_API Polygon2d {
22  public:
23  Polygon2d(){};
24  virtual ~Polygon2d(){};
25 
26  std::vector<gd::Vector2f> vertices;
27  mutable std::vector<gd::Vector2f>
29 
33  std::vector<gd::Vector2f>& GetVertices() { return vertices; }
34 
38  const std::vector<gd::Vector2f>& GetVertices() const { return vertices; }
39 
46  void Move(double x, double y);
47 
56  void Rotate(double angle);
57 
61  void ComputeEdges() const;
62 
67  bool IsConvex() const;
68 
72  gd::Vector2f ComputeCenter() const;
73 
78 
81  static Polygon2d CreateRectangle(double width, double height);
83 };
84 
85 #endif // GDCORE_POLYGON_H
Represents a polygon. Usually used for collisions masks.
Definition: Polygon2d.h:21
std::vector< gd::Vector2f > & GetVertices()
Get the vertices composing the polygon.
Definition: Polygon2d.h:33
const std::vector< gd::Vector2f > & GetVertices() const
Get the vertices composing the polygon.
Definition: Polygon2d.h:38
std::vector< gd::Vector2f > edges
Edges. Can be computed from vertices using ComputeEdges()
Definition: Polygon2d.h:28
std::vector< gd::Vector2f > vertices
The vertices composing the polygon.
Definition: Polygon2d.h:24
Utility template class for manipulating 2-dimensional vectors.
Definition: Vector2.h:40