Static
Readonly
DISABLE_disables all edge/edge contacts and collisions.
Static
Readonly
DISABLE_true means don't generate contacts from midpoint Vertexes.
Static
Readonly
HIGHLIGHT_highlight edges and Vertexes being tested for collisions or contacts
Static
edgenumber of times that an edge-edge collision test occurred
Static
specialNumber of times that special normal was requested when it was already calculated.
Static
specialNumber of times that special normal was requested when it was not yet calculated.
Static
specialNumber of times the specialNormal
was rotated to world coords.
Static
vertexnumber of times that testCollisionVertex
was called.
Static
addAdds the given collision only if it there is not already a deeper collision between the same bodies and same edges very close by. This helps prevent having duplicate collisions (or contacts), which helps the process of solving for contact forces or collision impulses with ComputeForces.
When a vertex collides into an edge, we need to see if there is a more accurate edge/edge collision to be used instead of the vertex/edge collision. For endpoint Vertexes, this involves testing both edges on either side of the vertex.
One way to look at this addCollision function is that you are defining an equality test between collisions, along with an ordering. A pair of collisions have to be approximately equal, and then we take the better of the two. If this were transitive, then you needn't worry about the case of 3 nearly equal collisions. Because you add collisions one at a time, you would always have only one of the 3 in the list at any time.
But collisions aren't really transitive because of the nearness criteria. Suppose there are 3 collisions, A, B, and C. A is near B, and B is near C. But A is not be 'near' C. As an example, suppose there are two 'decorated' midpoint Vertexes, A and C, on a curved edge. Suppose the distance between A and C is 0.11 and the nearness criteria is 0.1. So they are considered not near and both are added to the list. Now we add B, the edge/edge collision between A and C. It is near both A and C. To ensure that both A and C are removed, we need to go thru the entire list, allowing B to kick out every collision it is near to.
Even if the collision we are adding is rejected, we should still go thru the
entire list. In the above example, again suppose that A and C are on the list but not
near each other. But this time, A is the deepest collision, followed by B, with C
being the shallowest. So A > B > C
(where > means 'deeper'). We try to add B, but
because A > B
, we reject B. If we stop there, then C will still be on the list. If we
continue, we find that B > C
and also reject C. If we don't go thru the entire list
this way, then the ordering of the list determines the final result: in one ordering
of the list, C survives in another ordering it is rejected.
Therefore, we always go thru the entire list, even when the collision we are considering has been shown to be shallower than a nearby collision. (Although this is probably very rare, and not devastating if it slipped through).
Joints are a special case, they should always be added, never removed.
the list of collisions, to search and possibly add to
the RigidBodyCollision to possibly add to the list
true if the collision was added
Static
checkChecks for collision of each vertex of body2 with edges of body1.
the list of collisions to add to
the RigidBody whose edges are checked
the RigidBody whose Vertexes are checked
current simulation time
Static
intersectionPerforms a rough proximity test: are the bodies close enough that their proximity
circles overlap? Returns false
when there can be no intersection between the two
RigidBody bounding rectangles. Returns true
when an intersection between the
two bodies is possible.
Further checks are needed besides this rough check to determine if there really is
intersection of the two bodies. The bounding rectangle can be increased in size by the
swellage
amount.
false if there can be no intersection between the two bodies.
Static
intersectionStatic
Private
makethe list of collisions to add to
current simulation time
Static
printStatic
subsetReturns a subset of collisions such that all the collisions in the set are are connected. Two collisions are connected when they have a common moveable (finite mass) body. The subset will be such that you can go from one collision to any other collision via neighboring connected collisions.
the set of collisions to examine
a subset of collisions such that all the collisions in the set are connected by moveable bodies
Static
subsetGiven a set of collisions and a starting collision in that set, returns the subset of collisions that are connected by joints to the moveable bodies in the starting collision. The subset will be such that you can go from one collision to any other collision via neighboring connected collisions.
the set of collisions to examine
the starting collision in the superset
include collisions involving either body in startC
array of velocity of each collision
for hybrid collision handling, only include collisions that have more negative velocity than this minimum.
a subset of collisions such that all the collisions in the set are connected via joints to the moveable bodies of the starting collision.
Static
Private
testTests for collision or contact of a RigidBody with a Vertex. If a collision or contact is found, adds a new RigidBodyCollision to the list of collisions.
TO DO there may be opportunities to save computing time by calculating distance squared instead of distance, and selecting the proper distance from among those that got calculated (instead of recalculating the distance yet again when making the collision record).
the list of collisions to add to
the RigidBody whose edges we are checking for collisions
the Vertex of body2
the current position of vertex2 in body coords of body1
the position of vertex2 at the last time step in body coords of body1, see Polygon.saveOldCoords
the distance between v_body and v_body_old
current simulation time
Generated using TypeDoc
Static class that provides utility methods for calculating collision information.