Property | Type | Description | |
---|---|---|---|
_edgeNormals | Vector2[] | ||
isUnrotated | bool | ||
points | Vector2[] |
Property | Type | Description | |
---|---|---|---|
_originalPoints | Vector2[] |
Method | Description | |
---|---|---|
Polygon ( Vector2 points ) : System |
constructs a Polygon from points. points should be specified in clockwise fashion without duplicating the first/last point and they should be centered around 0,0.
|
|
Polygon ( int vertCount, float radius ) : System |
creates a symmetrical polygon based on the radius and vertCount passed in
|
|
buildEdgeNormals ( ) : void |
builds the Polygon edge normals. These are lazily created and updated only by the edgeNormals getter
|
|
buildSymmetricalPolygon ( int vertCount, float radius ) : Vector2[] |
builds a symmetrical polygon (hexagon, octogon, n-gon) and returns the points
|
|
collidesWithLine ( Vector2 start, Vector2 end, RaycastHit &hit ) : bool | ||
collidesWithShape ( |
||
containsPoint ( Vector2 point ) : bool |
essentially what the algorithm is doing is shooting a ray from point out. If it intersects an odd number of polygon sides we know it is inside the polygon.
|
|
findPolygonCenter ( Vector2 points ) : Vector2 |
finds the center of the Polygon. Note that this will be accurate for regular polygons. Irregular polygons have no center.
|
|
getClosestPointOnPolygonToPoint ( Vector2 points, Vector2 point, float &distanceSquared, Vector2 &edgeNormal ) : Vector2 |
iterates all the edges of the polygon and gets the closest point on any edge to point. Returns via out the squared distance to the closest point and the normal of the edge it is on. point should be in the space of the Polygon (point - poly.position)
|
|
getFarthestPointInDirection ( Vector2 points, Vector2 direction ) : Vector2 | ||
overlaps ( |
||
pointCollidesWithShape ( Vector2 point, CollisionResult &result ) : bool | ||
recalculateCenterAndEdgeNormals ( ) : void |
recalculates the Polygon centers. This must be called if the points are changed!
|
|
recenterPolygonVerts ( Vector2 points ) : void |
recenters the points of the polygon
|
Method | Description | |
---|---|---|
Polygon ( Vector2 points, bool isBox ) : System | ||
recalculateBounds ( Collider collider ) : void |
public Polygon ( Vector2 points ) : System | ||
points | Vector2 | Points. |
return | System |
public Polygon ( int vertCount, float radius ) : System | ||
vertCount | int | Vert count. |
radius | float | Radius. |
return | System |
public static buildSymmetricalPolygon ( int vertCount, float radius ) : Vector2[] | ||
vertCount | int | Vert count. |
radius | float | Radius. |
return | Vector2[] |
public collidesWithLine ( Vector2 start, Vector2 end, RaycastHit &hit ) : bool | ||
start | Vector2 | |
end | Vector2 | |
hit | RaycastHit | |
return | bool |
public collidesWithShape ( |
||
other | ||
result | CollisionResult | |
return | bool |
public containsPoint ( Vector2 point ) : bool | ||
point | Vector2 | Point. |
return | bool |
public static findPolygonCenter ( Vector2 points ) : Vector2 | ||
points | Vector2 | Points. |
return | Vector2 |
public static getClosestPointOnPolygonToPoint ( Vector2 points, Vector2 point, float &distanceSquared, Vector2 &edgeNormal ) : Vector2 | ||
points | Vector2 | |
point | Vector2 | Point. |
distanceSquared | float | Distance squared. |
edgeNormal | Vector2 | Edge normal. |
return | Vector2 |
public static getFarthestPointInDirection ( Vector2 points, Vector2 direction ) : Vector2 | ||
points | Vector2 | |
direction | Vector2 | |
return | Vector2 |
public pointCollidesWithShape ( Vector2 point, CollisionResult &result ) : bool | ||
point | Vector2 | |
result | CollisionResult | |
return | bool |
public recalculateCenterAndEdgeNormals ( ) : void | ||
return | void |
public static recenterPolygonVerts ( Vector2 points ) : void | ||
points | Vector2 | Points. |
return | void |