The configuration of this polygon.
A mapping of vertices which define potential collision points
The set of edges which define potential boundaries of the polygon
A collection of rays which are fired at vertices
The rectangular bounds of this polygon
The origin point of the source polygon.
Customize the provided configuration object for this polygon type.
The provided polygon origin
The provided configuration object
Perform the implementation-specific computation
Compute the polygon using the origin and configuration options.
The computed polygon
Apply a constraining boundary shape to an existing PointSourcePolygon. Return a new instance of the polygon with the constraint applied. The new instance is only a "shallow clone", as it shares references to component properties with the original.
The constraining boundary shape
A new constrained polygon
Convert a PIXI.Polygon into an array of clipper points [{X,Y}, ...]. Note that clipper points must be rounded to integers. In order to preserve some amount of floating point precision, an optional scaling factor may be provided.
Options which affect how clipper points are generated
} An array of points to be used by clipper
Intersect this PIXI.Polygon with another PIXI.Polygon using the clipper library.
Another PIXI.Polygon
Options which configure how the intersection is computed
The intersected polygon or null if no solution was present
Intersect this PIXI.Polygon with a PIXI.Circle. For now, convert the circle to a Polygon approximation and use intersectPolygon. In the future we may replace this with more specialized logic which uses the line-circle intersection formula.
A PIXI.Circle
The intersected polygon
Intersect this PIXI.Polygon with a PIXI.Rectangle. For now, convert the rectangle to a Polygon and use intersectPolygon. In the future we may replace this with more specialized logic which uses the line-line intersection formula.
A PIXI.Rectangle
The intersected polygon
Get the super-set of walls which could potentially apply to this polygon. Define a custom collision test used by the Quadtree to obtain candidate Walls.
Compute the aggregate bounding box which is the intersection of all boundary shapes. Round and pad the resulting rectangle by 1 pixel to ensure it always contains the origin.
Configure a limited angle and rotation into a triangular polygon boundary shape.
Configure a provided limited radius as a circular polygon boundary shape.
Translate walls and other obstacles into edges which limit visibility
Consolidate all vertices from identified edges and register them as part of the vertex mapping.
Add additional vertices for intersections between edges.
A mapping of wall IDs to PolygonEdge instances
Truncate an edge which intersects with a boundary by replacing one of its vertices with the intersection point.
The edge which intersects with the boundary
The vertex of the intersection point
Execute the sweep over wall vertices
Include collinear vertices until they have all been added. Do not include the original vertex in the set.
The current vertex
Update active edges at a given vertex Must delete first, in case the edge is in both sets.
The current vertex
A set of currently active edges
Determine the initial set of active edges as those which intersect with the initial ray
A set of initially active edges
Sort vertices clockwise from the initial ray (due west).
The array of sorted vertices
Test whether a target vertex is behind some closer active edge. If the vertex is to the left of the edge, is must be behind the edge relative to origin. If the vertex is collinear with the edge, it should be considered "behind" and ignored. We know edge.A is ccw to edge.B because of the logic in _identifyVertices.
The target vertex
The set of active edges
Is the target vertex behind some closer edge?
Determine the result for the sweep at a given vertex
The target vertex
The set of active edges
Are there collinear vertices behind the target vertex?
Switch to a new active edge. Moving from the origin, a collision that first blocks a side must be stored as a polygon point. Subsequent collisions blocking that side are ignored. Once both sides are blocked, we are done.
Collisions that limit a side will block if that side was previously limited.
If neither side is blocked and the ray internally collides with a non-limited edge, n skip without adding polygon endpoints. Sight is unaffected before this edge, and the internal collision can be ignored.
The pending collision result
The set of currently active edges
Constrain polygon points by applying boundary shapes.
Visualize the polygon, displaying its computed area, rays, and collision points
Benchmark the performance of polygon computation for this source
The number of test iterations to perform
The origin point to benchmark
The polygon configuration to benchmark
Compute the polygon given a point origin and radius
The origin source point
The computed polygon instance
Test whether a Ray between the origin and destination points would collide with a boundary of this Polygon. A valid wall restriction type is compulsory and must be passed into the config options.
An origin point
A destination point
The configuration that defines a certain Polygon type
The collision result depends on the mode of the test: * any: returns a boolean for whether any collision occurred * all: returns a sorted array of PolygonVertex instances * closest: returns a PolygonVertex instance or null
Construct a PIXI.Polygon instance from an array of clipper points [{X,Y}, ...].
Options which affect how canvas points are generated
The resulting PIXI.Polygon
An indicator for whether this polygon is constrained by some boundary shape?
A PointSourcePolygon implementation that uses CCW (counter-clockwise) geometry orientation. Sweep around the origin, accumulating collision points based on the set of active walls. This algorithm was created with valuable contributions from https://github.com/caewok