#include <region.h>
Public Types | |
enum | REGION_TYPE { RT_REGION, RT_WALKREGION } |
Public Member Functions | |
virtual bool | init (const Polygon &contour, const Common::Array< Polygon > *pHoles=NULL) |
bool | isValid () const |
const Vertex & | getPosition () const |
int | getPosX () const |
int | getPosY () const |
bool | isPointInRegion (const Vertex &vertex) const |
bool | isPointInRegion (int x, int y) const |
const Polygon & | getContour () const |
int | getHoleCount () const |
const Polygon & | getHole (uint i) const |
Vertex | findClosestRegionPoint (const Vertex &point) const |
Vertex | getCentroid () const |
bool | isLineOfSight (const Vertex &a, const Vertex &b) const |
virtual void | setPos (int x, int y) |
void | setPosX (int x) |
void | setPosY (int y) |
bool | persist (OutputPersistenceBlock &writer) override |
bool | unpersist (InputPersistenceBlock &reader) override |
Static Public Member Functions | |
static uint | create (REGION_TYPE type) |
static uint | create (InputPersistenceBlock &reader, uint handle=0) |
Protected Member Functions | |
Region () | |
Region (InputPersistenceBlock &reader, uint handle) | |
void | updateBoundingBox () |
Vertex | findClosestPointOnLine (const Vertex &lineStart, const Vertex &lineEnd, const Vertex point) const |
Protected Attributes | |
REGION_TYPE | _type |
This specifies the type of object. | |
bool | _valid |
This variable indicates whether the current object state is valid. | |
Vertex | _position |
This vertex is the position of the region. | |
Common::Array< Polygon > | _polygons |
This array contains all the polygons that define the region. The first element of. | |
Common::Rect | _boundingBox |
The bounding box for the region. | |
This class is the base class of all regions.
The IsValid() method can be queried to see whether the object is in a valid state. If this is not the case, the method Init() is the only method that may be invoked. This class guarantees that the Vertecies outline of the hole, and the polygons are arranged in a clockwise direction, so that the polygon working algorithms will work properly.
|
protected |
Creates a new BS_Region object
After creation the object is invaild (IsValid() return false), but a call can be made later on to Init() to set up the region into a valid state.
|
virtual |
Initializes a BS_Region object
Contour | A polygon indicating the outline of the region |
pHoles | A pointer to an array of polygons representing the hole state in the region. If the region has no holes, it must be passed as NULL. The default value is NULL. |
Reimplemented in Sword25::WalkRegion.
|
inline |
Specifies whether the object is in a valid state
|
inline |
Returns the position of the region
|
inline |
Returns the X position of the region
|
inline |
Returns the Y position of the region
bool Sword25::Region::isPointInRegion | ( | const Vertex & | vertex | ) | const |
Indicates whether a point is inside the region
Vertex | A verex with the co-ordinates of the test point |
bool Sword25::Region::isPointInRegion | ( | int | x, |
int | y | ||
) | const |
Indicates whether a point is inside the region
X | The X position |
Y | The Y position |
|
inline |
Returns the countour of the region
|
inline |
Returns the number of polygons in the hole region
|
inline |
Returns a specific hole polygon in the region
i | The number of the hole to return. The index must be between 0 and GetHoleCount() - 1. |
For a point outside the region, finds the closest point inside the region
Point | The point that is outside the region |
Vertex Sword25::Region::getCentroid | ( | ) | const |
Returns the centroid for the region
|
virtual |
Sets the position of the region
X | The new X psoition of the region |
Y | The new Y psoition of the region |
Reimplemented in Sword25::WalkRegion.
void Sword25::Region::setPosX | ( | int | x | ) |
Sets the X position of the region
X | The new X position of the region |
void Sword25::Region::setPosY | ( | int | y | ) |
Sets the Y position of the region
Y | The new Y position of the region |
|
protected |
Updates the bounding box of the region.
|
protected |
Find the point on a line which is closest to another point
LineStart | The start of the line |
LineEnd | The end of the line |
Point | The point to be compared against |