FarseerDuality
The features that intersect to form the contact point
This must be 4 bytes or less.
Feature index on ShapeA
Feature index on ShapeB
The feature type on ShapeA
The feature type on ShapeB
Contact ids to facilitate warm starting.
The features that intersect to form the contact point
Used to quickly compare contact ids.
A manifold point is a contact point belonging to a contact
manifold. It holds details related to the geometry and dynamics
of the contact points.
The local point usage depends on the manifold type:
-ShapeType.Circles: the local center of circleB
-SeparationFunction.FaceA: the local center of cirlceB or the clip point of polygonB
-SeparationFunction.FaceB: the clip point of polygonA
This structure is stored across time steps, so we keep it small.
Note: the impulses are used for internal caching and may not
provide reliable contact forces, especially for high speed collisions.
Uniquely identifies a contact point between two Shapes
A manifold for two touching convex Shapes.
Box2D supports multiple types of contact:
- clip point versus plane with radius
- point versus point with radius (circles)
The local point usage depends on the manifold type:
-ShapeType.Circles: the local center of circleA
-SeparationFunction.FaceA: the center of faceA
-SeparationFunction.FaceB: the center of faceB
Similarly the local normal usage:
-ShapeType.Circles: not used
-SeparationFunction.FaceA: the normal on polygonA
-SeparationFunction.FaceB: the normal on polygonB
We store contacts in this way so that position correction can
account for movement, which is critical for continuous physics.
All contact scenarios must be expressed in one of these types.
This structure is stored across time steps, so we keep it small.
Not use for Type.SeparationFunction.Points
Usage depends on manifold type
The number of manifold points
The points of contact
This is used for determining the state of contact points.
Point does not exist
Point was added in the update
Point persisted across the update
Point was removed in the update
Used for computing contact manifolds.
Ray-cast input data. The ray extends from p1 to p1 + maxFraction * (p2 - p1).
Ray-cast output data. The ray hits at p1 + fraction * (p2 - p1), where p1 and p2
come from RayCastInput.
An axis aligned bounding box.
The lower vertex
The upper vertex
Verify that the bounds are sorted.
true if this instance is valid; otherwise, false.
Combine an AABB into this one.
The aabb.
Combine two AABBs into this one.
The aabb1.
The aabb2.
Does this aabb contain the provided AABB.
The aabb.
true if it contains the specified aabb; otherwise, false.
Determines whether the AAABB contains the specified point.
The point.
true if it contains the specified point; otherwise, false.
Get the center of the AABB.
Get the extents of the AABB (half-widths).
Get the perimeter length
Gets the vertices of the AABB.
The corners of the AABB
first quadrant
Edge shape plus more stuff.
This lets us treate and edge shape and a polygon in the same
way in the SAT collider.
Evaluate the manifold with supplied transforms. This assumes
modest motion from the original state. This does not change the
point count, impulses, etc. The radii must come from the Shapes
that generated the manifold.
The manifold.
The transform for A.
The radius for A.
The transform for B.
The radius for B.
World vector pointing from A to B
Torld contact point (point of intersection).
Compute the collision manifold between two circles.
Compute the collision manifold between a polygon and a circle.
The manifold.
The polygon A.
The transform of A.
The circle B.
The transform of B.
Compute the collision manifold between two polygons.
The manifold.
The poly A.
The transform A.
The poly B.
The transform B.
Compute contact points for edge versus circle.
This accounts for edge connectivity.
The manifold.
The edge A.
The transform A.
The circle B.
The transform B.
Collides and edge and a polygon, taking into account edge adjacency.
The manifold.
The edge A.
The xf A.
The polygon B.
The xf B.
Clipping for contact manifolds.
The v out.
The v in.
The normal.
The offset.
The vertex index A.
Find the separation between poly1 and poly2 for a give edge normal on poly1.
The poly1.
The XF1.
The edge1.
The poly2.
The XF2.
Find the max separation between poly1 and poly2 using edge normals from poly1.
Index of the edge.
The poly1.
The XF1.
The poly2.
The XF2.
A distance proxy is used by the GJK algorithm.
It encapsulates any shape.
Initialize the proxy using the given shape. The shape
must remain in scope while the proxy is in use.
The shape.
The index.
Get the supporting vertex index in the given direction.
The direction.
Get the supporting vertex in the given direction.
The direction.
Used to warm start ComputeDistance.
Set count to zero on first call.
Length or area
Vertices on shape A
Vertices on shape B
Input for ComputeDistance.
You have to option to use the shape radii
in the computation.
Output for ComputeDistance.
Number of GJK iterations used
Closest point on shapeA
Closest point on shapeB
Barycentric coordinate for closest point
wA index
wB index
wB - wA
Support point in proxyA
Support point in proxyB
A node in the dynamic tree. The client does not interact with this directly.
This is the fattened AABB.
A dynamic tree arranges data in a binary tree to accelerate
queries such as volume queries and ray casts. Leafs are proxies
with an AABB. In the tree we expand the proxy AABB by Settings.b2_fatAABBFactor
so that the proxy AABB is bigger than the client object. This allows the client
object to move by small amounts without triggering a tree update.
Nodes are pooled and relocatable, so we use node indices rather than pointers.
This is used incrementally traverse the tree for re-balancing.
Constructing the tree initializes the node pool.
Create a proxy in the tree as a leaf node. We return the index
of the node instead of a pointer so that we can grow
the node pool.
///
The aabb.
The user data.
Index of the created proxy
Destroy a proxy. This asserts if the id is invalid.
The proxy id.
Move a proxy with a swepted AABB. If the proxy has moved outside of its fattened AABB,
then the proxy is removed from the tree and re-inserted. Otherwise
the function returns immediately.
The proxy id.
The aabb.
The displacement.
true if the proxy was re-inserted.
Perform some iterations to re-balance the tree.
The iterations.
Get proxy user data.
The proxy id.
the proxy user data or 0 if the id is invalid.
Get the fat AABB for a proxy.
The proxy id.
The fat AABB.
Compute the height of the binary tree in O(N) time. Should not be
called often.
Query an AABB for overlapping proxies. The callback class
is called for each proxy that overlaps the supplied AABB.
The callback.
The aabb.
Ray-cast against the proxies in the tree. This relies on the callback
to perform a exact ray-cast in the case were the proxy contains a Shape.
The callback also performs the any collision filtering. This has performance
roughly equal to k * log(n), where k is the number of collisions and n is the
number of proxies in the tree.
A callback class that is called for each proxy that is hit by the ray.
The ray-cast input data. The ray extends from p1 to p1 + maxFraction * (p2 - p1).
The broad-phase is used for computing pairs and performing volume queries and ray casts.
This broad-phase does not persist pairs. Instead, this reports potentially new pairs.
It is up to the client to consume the new pairs and to track subsequent overlap.
Create a proxy with an initial AABB. Pairs are not reported until
UpdatePairs is called.
The user data.
Destroy a proxy. It is up to the client to remove any pairs.
The proxy id.
Get the AABB for a proxy.
The proxy id.
The aabb.
Get user data from a proxy. Returns null if the id is invalid.
The proxy id.
Test overlap of fat AABBs.
The proxy id A.
The proxy id B.
Update the pairs. This results in pair callbacks. This can only add pairs.
The callback.
Query an AABB for overlapping proxies. The callback class
is called for each proxy that overlaps the supplied AABB.
The callback.
The aabb.
Ray-cast against the proxies in the tree. This relies on the callback
to perform a exact ray-cast in the case were the proxy contains a shape.
The callback also performs the any collision filtering. This has performance
roughly equal to k * log(n), where k is the number of collisions and n is the
number of proxies in the tree.
A callback class that is called for each proxy that is hit by the ray.
The ray-cast input data. The ray extends from p1 to p1 + maxFraction * (p2 - p1).
Compute the height of the embedded tree.
Get the number of proxies.
The proxy count.
returns the quadrant of span that entirely contains test. if none, return 0.
tests if ray intersects AABB
Creates a new quad tree broadphase with the specified span.
the maximum span of the tree (world size)
Test overlap of fat AABBs.
The proxy id A.
The proxy id B.
The number of proxies
A shape is used for collision detection. You can create a shape however you like.
Shapes used for simulation in World are created automatically when a Fixture
is created. Shapes may encapsulate a one or more child shapes.
Clone the concrete shape
A clone of the shape
Test a point for containment in this shape. This only works for convex shapes.
The shape world transform.
a point in world coordinates.
True if the point is inside the shape
Cast a ray against a child shape.
The ray-cast results.
The ray-cast input parameters.
The transform to be applied to the shape.
The child shape index.
True if the ray-cast hits the shape
Given a transform, compute the associated axis aligned bounding box for a child shape.
The aabb results.
The world transform of the shape.
The child shape index.
Compute the mass properties of this shape using its dimensions and density.
The inertia tensor is computed about the local origin, not the centroid.
Get the type of this shape.
The type of the shape.
Get the number of child primitives.
Gets or sets the density.
The density.
Radius of the Shape
Test a point for containment in this shape. This only works for convex shapes.
The shape world transform.
a point in world coordinates.
True if the point is inside the shape
Cast a ray against a child shape.
The ray-cast results.
The ray-cast input parameters.
The transform to be applied to the shape.
The child shape index.
True if the ray-cast hits the shape
Given a transform, compute the associated axis aligned bounding box for a child shape.
The aabb results.
The world transform of the shape.
The child shape index.
Compute the mass properties of this shape using its dimensions and density.
The inertia tensor is computed about the local origin, not the centroid.
A line segment (edge) Shape. These can be connected in chains or loops
to other edge Shapes. The connectivity information is used to ensure
correct contact normals.
Optional adjacent vertices. These are used for smooth collision.
Optional adjacent vertices. These are used for smooth collision.
Edge start vertex
Edge end vertex
Set this as an isolated edge.
The start.
The end.
Test a point for containment in this shape. This only works for convex shapes.
The shape world transform.
a point in world coordinates.
True if the point is inside the shape
Cast a ray against a child shape.
The ray-cast results.
The ray-cast input parameters.
The transform to be applied to the shape.
The child shape index.
True if the ray-cast hits the shape
Given a transform, compute the associated axis aligned bounding box for a child shape.
The aabb results.
The world transform of the shape.
The child shape index.
Compute the mass properties of this shape using its dimensions and density.
The inertia tensor is computed about the local origin, not the centroid.
These are the edge vertices
These are the edge vertices
A chain shape is a free form sequence of line segments.
The chain may cross upon itself, but this is not recommended for smooth collision.
The chain has double sided collision, so you can use inside and outside collision.
Therefore, you may use any winding order.
The vertices. These are not owned/freed by the loop Shape.
Create a new chainshape from the vertices.
The vertices to use. Must contain 2 or more vertices.
Set to true to create a closed loop. It connects the first vertice to the last, and automatically adjusts connectivity to create smooth collisions along the chain.
Adjusts the shapes previous and next vertex settings in order
to form a loop shape. This requires the first vertex to equal
the last one. If this is not the case, a new vertex will be
added to close the loop.
Adjusts the shapes previous and next vertex settings in order
to form a chain shape. This requires the first vertex to not
equal the last one. If this is the case, the last vertex will be
removed to break the loop.
Test a point for containment in this shape. This only works for convex shapes.
The shape world transform.
a point in world coordinates.
True if the point is inside the shape
Cast a ray against a child shape.
The ray-cast results.
The ray-cast input parameters.
The transform to be applied to the shape.
The child shape index.
True if the ray-cast hits the shape
Given a transform, compute the associated axis aligned bounding box for a child shape.
The aabb results.
The world transform of the shape.
The child shape index.
Chains have zero mass.
Represents a simple non-selfintersecting convex polygon.
If you want to have concave polygons, you will have to use the or the
to decompose the concave polygon into 2 or more convex polygons.
Initializes a new instance of the class.
The vertices.
The density.
Copy vertices. This assumes the vertices define a convex polygon.
It is assumed that the exterior is the the right of each edge.
The vertices.
Compute the mass properties of this shape using its dimensions and density.
The inertia tensor is computed about the local origin, not the centroid.
Build vertices to represent an axis-aligned box.
The half-width.
The half-height.
Build vertices to represent an oriented box.
The half-width..
The half-height.
The center of the box in local coordinates.
The rotation of the box in local coordinates.
Test a point for containment in this shape. This only works for convex shapes.
The shape world transform.
a point in world coordinates.
True if the point is inside the shape
Cast a ray against a child shape.
The ray-cast results.
The ray-cast input parameters.
The transform to be applied to the shape.
The child shape index.
True if the ray-cast hits the shape
Given a transform, compute the associated axis aligned bounding box for a child shape.
The aabb results.
The world transform of the shape.
The child shape index.
This holds the mass data computed for a shape.
The area of the shape
The position of the shape's centroid relative to the shape's origin.
The rotational inertia of the shape about the local origin.
The mass of the shape, usually in kilograms.
Input parameters for CalculateTimeOfImpact
Compute the upper bound on time before two shapes penetrate. Time is represented as
a fraction between [0,tMax]. This uses a swept separating axis and may miss some intermediate,
non-tunneling collision. If you change the time interval, you should call this function
again.
Note: use Distance() to compute the contact point and normal at the time of impact.
The output.
The input.
Gets the convex hull.
http://www.softsurfer.com/Archive/algorithm_0109/algorithm_0109.htm
Find the convex hull of a point cloud using "Gift-wrap" algorithm - start
with an extremal point, and walk around the outside edge by testing
angles.
Runs in O(N*S) time where S is number of sides of resulting polygon.
Worst case: point cloud is all vertices of convex polygon: O(N^2).
There may be faster algorithms to do this, should you need one -
this is just the simplest. You can get O(N log N) expected time if you
try, I think, and O(N) if you restrict inputs to simple polygons.
Returns null if number of vertices passed is less than 3.
Results should be passed through convex decomposition afterwards
to ensure that each shape has few enough points to be used in Box2d.
Warning: May be buggy with colinear points on hull.
The vertices.
Creates a convex hull.
Note:
1. Vertices must be of a simple polygon, i.e. edges do not overlap.
2. Melkman does not work on point clouds
Implemented using Melkman's Convex Hull Algorithm - O(n) time complexity.
Reference: http://www.ams.sunysb.edu/~jsbm/courses/345/melkman.pdf
A convex hull in counterclockwise winding order.
Convex decomposition algorithm created by Mark Bayazit (http://mnbayazit.com/)
Properties:
- Tries to decompose using polygons instead of triangles.
- Tends to produce optimal results with low processing time.
- Running time is O(nr), n = number of vertices, r = reflex vertices.
- Does not support holes.
For more information about this algorithm, see http://mnbayazit.com/406/bayazit
Decompose the polygon into several smaller non-concave polygon.
If the polygon is already convex, it will return the original polygon, unless it is over Settings.MaxPolygonVertices.
2D constrained Delaunay triangulation algorithm.
Based on the paper "Sweep-line algorithm for constrained Delaunay triangulation" by V. Domiter and and B. Zalik
Properties:
- Creates triangles with a large interior angle.
- Supports holes
- Generate a lot of garbage due to incapsulation of the Poly2Tri library.
- Running time is O(n^2), n = number of vertices.
- Does not care about winding order.
Source: http://code.google.com/p/poly2tri/
Decompose the polygon into several smaller non-concave polygon.
Update neighbor pointers
Point 1 of the shared edge
Point 2 of the shared edge
This triangle's new neighbor
Exhaustive search to update neighbor pointers
Clears all references to all other triangles and points
Opposite triangle
The point in t that isn't shared between the triangles
Legalize triangle by rotating clockwise around oPoint
The origin point to rotate around
???
Finalize edge marking
Mark edge as constrained
Get the index of the neighbor that shares this edge (or -1 if it isn't shared)
index of the shared edge or -1 if edge isn't shared
@author Thomas Ã…hlen (thahlen@gmail.com)
MM: This seems to be used by LocateNode to guess a position in the implicit linked list of AdvancingFrontNodes near x
Removed an overload that depended on this being exact
We use a balancing tree to locate a node smaller or equal to given key value
This implementation will use simple node traversal algorithm to find a point on the front
Triangulate simple polygon with holes
Start sweeping the Y-sorted point set from bottom to top
If this is a Delaunay Triangulation of a pointset we need to fill so the triangle mesh gets a ConvexHull
We will traverse the entire advancing front and fill it to form a convex hull.
Find closes node to the left of the new point and
create a new triangle. If needed new holes and basins
will be filled to.
Creates a new front triangle and legalize it
When we need to traverse from one triangle to the next we need
the point in current triangle that is the opposite point to the next
triangle.
After a flip we have two triangles and know that only one will still be
intersecting the edge. So decide which to contiune with and legalize the other
should be the result of an TriangulationUtil.orient2d( eq, op, ep )
triangle 1
triangle 2
a point shared by both triangles
another point shared by both triangles
returns the triangle still intersecting the edge
Scan part of the FlipScan algorithm
When a triangle pair isn't flippable we will scan for the next
point that is inside the flip triangle scan area. When found
we generate a new flipEdgeEvent
last point on the edge we are traversing
first point on the edge we are traversing
the current triangle sharing the point eq with edge
Fills holes in the Advancing Front
Fills a basin that has formed on the Advancing Front to the right
of given node.
First we decide a left,bottom and right node that forms the
boundaries of the basin. Then we do a reqursive fill.
starting node, this or next node will be left node
Recursive algorithm to fill a Basin with triangles
???
middle node
the angle between 3 front nodes
The basin angle is decided against the horizontal line [1,0]
Adds a triangle to the advancing front to fill a hole.
middle node, that is the bottom of the hole
Returns true if triangle was legalized
Rotates a triangle pair one vertex CW
n2 n2
P +-----+ P +-----+
| t /| |\ t |
| / | | \ |
n1| / |n3 n1| \ |n3
| / | after CW | \ |
|/ oT | | oT \|
+-----+ oP +-----+
n4 n4
Give two points in any order. Will always be ordered so
that q.y > p.y and q.x > p.x if same y value
@author Thomas Åhlén, thahlen@gmail.com
Try to map a node to all sides of this triangle that don't have
a neighbor.
Create a polygon from a list of at least 3 points with no duplicates.
A list of unique points
Create a polygon from a list of at least 3 points with no duplicates.
A list of unique points.
Creates constraints and populates the context with points
The context
Add a hole to the polygon.
A subtraction polygon fully contained inside this polygon.
Inserts newPoint after point.
The point to insert after in the polygon
The point to insert into the polygon
Inserts list (after last point in polygon?)
Adds a point after the last in the polygon.
The point to add
Removes a point from the polygon.
@param points - A list of all points in PointSet
@param constraints - Pairs of two points defining a constraint, all points must be part of given PointSet!
@author Thomas Åhlén, thahlen@gmail.com
Requirements:
1. a,b and c form a triangle.
2. a and d is know to be on opposite side of bc
a
+
/ \
/ \
b/ \c
+-------+
/ B \
/ \
Facts:
d has to be in area B to have a chance to be inside the circle formed by a,b and c
d is outside B if orient2d(a,b,d) or orient2d(c,a,d) is CW
This preknowledge gives us a way to optimize the incircle test
triangle point, opposite d
triangle point
triangle point
point opposite a
true if d is inside circle, false if on circle edge
Forumla to calculate signed area
Positive if CCW
Negative if CW
0 if collinear
A[P1,P2,P3] = (x1*y2 - y1*x2) + (x2*y3 - y2*x3) + (x3*y1 - y3*x1)
= (x1-x3)*(y2-y3) - (y1-y3)*(x2-x3)
Convex decomposition algorithm using ear clipping
Properties:
- Only works on simple polygons.
- Does not support holes.
- Running time is O(n^2), n = number of vertices.
Source: http://www.ewjordan.com/earClip/
Decompose the polygon into several smaller non-concave polygon.
Each resulting polygon will have no more than Settings.MaxPolygonVertices vertices.
The vertices.
The tolerance.
Triangulates a polygon using simple ear-clipping algorithm. Returns
size of Triangle array unless the polygon can't be triangulated.
This should only happen if the polygon self-intersects,
though it will not _always_ return null for a bad polygon - it is the
caller's responsibility to check for self-intersection, and if it
doesn't, it should at least check that the return value is non-null
before using. You're warned!
Triangles may be degenerate, especially if you have identical points
in the input to the algorithm. Check this before you use them.
This is totally unoptimized, so for large polygons it should not be part
of the simulation loop.
Only works on simple polygons.
Finds and fixes "pinch points," points where two polygon
vertices are at the same point.
If a pinch point is found, pin is broken up into poutA and poutB
and true is returned; otherwise, returns false.
Mostly for internal use.
O(N^2) time, which sucks...
The pin.
The pout A.
The pout B.
Fix for obnoxious behavior for the % operator for negative numbers...
The x.
The modulus.
Checks if vertex i is the tip of an ear in polygon defined by xv[] and yv[].
The i.
The xv.
The yv.
Length of the xv.
Assumes clockwise orientation of polygon.
true if the specified i is ear; otherwise, false.
Nexts the index.
The index.
Gets the previous index.
The index.
Gets the signed area.
Gets the area.
Gets the centroid.
Gets the radius based on area.
Returns an AABB for vertex.
Translates the vertices with the specified vector.
The vector.
Scales the vertices with the specified vector.
The Value.
Rotate the vertices with the defined value in radians.
The amount to rotate by in radians.
Assuming the polygon is simple; determines whether the polygon is convex.
NOTE: It will also return false if the input contains colinear edges.
true if it is convex; otherwise, false.
Forces counter clock wise order.
Check for edge crossings
Checks if the polygon is valid for use in the engine.
Performs a full check, for simplicity, convexity,
orientation, minimum angle, and volume.
From Eric Jordan's convex decomposition library
PolygonError.NoError if there were no error.
Trace the edge of a non-simple polygon and return a simple polygon.
Method:
Start at vertex with minimum y (pick maximum x one if there are two).
We aim our "lastDir" vector at (1.0, 0)
We look at the two rays going off from our start vertex, and follow whichever
has the smallest angle (in -Pi . Pi) wrt lastDir ("rightest" turn)
Loop until we hit starting vertex:
We add our current vertex to the list.
We check the seg from current vertex to next vertex for intersections
- if no intersections, follow to next vertex and continue
- if intersections, pick one with minimum distance
- if more than one, pick one with "rightest" next point (two possibilities for each)
The vertices.
Projects to axis.
The axis.
The min.
The max.
Winding number test for a point in a polygon.
See more info about the algorithm here: http://softsurfer.com/Archive/algorithm_0103/algorithm_0103.htm
The point to be tested.
-1 if the winding number is zero and the point is outside
the polygon, 1 if the point is inside the polygon, and 0 if the point
is on the polygons edge.
Compute the sum of the angles made between the test point and each pair of points making up the polygon.
If this sum is 2pi then the point is an interior point, if 0 then the point is an exterior point.
ref: http://ozviz.wasp.uwa.edu.au/~pbourke/geometry/insidepoly/ - Solution 2
Convex decomposition algorithm created by unknown
Properties:
- No support for holes
- Very fast
- Only works on simple polygons
- Only works on counter clockwise polygons
More information: http://www.flipcode.com/archives/Efficient_Polygon_Triangulation.shtml
Decompose the polygon into triangles.
Properties:
- Only works on counter clockwise polygons
The list of points describing the polygon
Check if the point P is inside the triangle defined by
the points A, B, C
The A point.
The B point.
The C point.
The point to be tested.
True if the point is inside the triangle
Cut a the contour and add a triangle into V to describe the
location of the cut
The list of points defining the polygon
The index of the first point
The index of the second point
The index of the third point
The number of elements in the array.
The array to populate with indicies of triangles.
True if a triangle was found
Convex decomposition algorithm created by Raimund Seidel
Properties:
- Decompose the polygon into trapezoids, then triangulate.
- To use the trapezoid data, use ConvexPartitionTrapezoid()
- Generate a lot of garbage due to incapsulation of the Poly2Tri library.
- Running time is O(n log n), n = number of vertices.
- Running time is almost linear for most simple polygons.
- Does not care about winding order.
For more information, see Raimund Seidel's paper "A simple and fast incremental randomized
algorithm for computing trapezoidal decompositions and for triangulating polygons"
See also: "Computational Geometry", 3rd edition, by Mark de Berg et al, Chapter 6.2
"Computational Geometry in C", 2nd edition, by Joseph O'Rourke
Original code from the Poly2Tri project by Mason Green.
http://code.google.com/p/poly2tri/source/browse?repo=archive#hg/scala/src/org/poly2tri/seidel
This implementation is from Dec 14, 2010
Decompose the polygon into several smaller non-concave polygons.
The polygon to decompose.
The sheer to use if you get bad results, try using a higher value.
A list of triangles
Decompose the polygon into several smaller non-concave polygons.
The polygon to decompose.
The sheer to use if you get bad results, try using a higher value.
A list of trapezoids
Convex decomposition algorithm using ear clipping
Properties:
- Only works on simple polygons.
- Does not support holes.
- Running time is O(n^2), n = number of vertices.
Convex decomposition algorithm created by Mark Bayazit (http://mnbayazit.com/)
Properties:
- Tries to decompose using polygons instead of triangles.
- Tends to produce optimal results with low processing time.
- Running time is O(nr), n = number of vertices, r = reflex vertices.
- Does not support holes.
Convex decomposition algorithm created by unknown
Properties:
- No support for holes
- Very fast
- Only works on simple polygons
- Only works on counter clockwise polygons
Convex decomposition algorithm created by Raimund Seidel
Properties:
- Decompose the polygon into trapezoids, then triangulate.
- To use the trapezoid data, use ConvexPartitionTrapezoid()
- Generate a lot of garbage due to incapsulation of the Poly2Tri library.
- Running time is O(n log n), n = number of vertices.
- Running time is almost linear for most simple polygons.
- Does not care about winding order.
2D constrained Delaunay triangulation algorithm.
Based on the paper "Sweep-line algorithm for constrained Delaunay triangulation" by V. Domiter and and B. Zalik
Properties:
- Creates triangles with a large interior angle.
- Supports holes
- Generate a lot of garbage due to incapsulation of the Poly2Tri library.
- Running time is O(n^2), n = number of vertices.
- Does not care about winding order.
Collection of helper methods for misc collisions.
Does float tolerance and line collisions with lines and AABBs.
Check if the lines a0->a1 and b0->b1 cross.
If they do, intersectionPoint will be filled
with the point of crossing.
Grazing lines should not return true.
This method detects if two line segments (or lines) intersect,
and, if so, the point of intersection. Use the and
parameters to set whether the intersection point
must be on the first and second line segments. Setting these
both to true means you are doing a line-segment to line-segment
intersection. Setting one of them to true means you are doing a
line to line-segment intersection test, and so on.
Note: If two line segments are coincident, then
no intersection is detected (there are actually
infinite intersection points).
Author: Jeremy Bell
The first point of the first line segment.
The second point of the first line segment.
The first point of the second line segment.
The second point of the second line segment.
This is set to the intersection
point if an intersection is detected.
Set this to true to require that the
intersection point be on the first line segment.
Set this to true to require that the
intersection point be on the second line segment.
True if an intersection is detected, false otherwise.
This method detects if two line segments (or lines) intersect,
and, if so, the point of intersection. Use the and
parameters to set whether the intersection point
must be on the first and second line segments. Setting these
both to true means you are doing a line-segment to line-segment
intersection. Setting one of them to true means you are doing a
line to line-segment intersection test, and so on.
Note: If two line segments are coincident, then
no intersection is detected (there are actually
infinite intersection points).
Author: Jeremy Bell
The first point of the first line segment.
The second point of the first line segment.
The first point of the second line segment.
The second point of the second line segment.
This is set to the intersection
point if an intersection is detected.
Set this to true to require that the
intersection point be on the first line segment.
Set this to true to require that the
intersection point be on the second line segment.
True if an intersection is detected, false otherwise.
This method detects if two line segments intersect,
and, if so, the point of intersection.
Note: If two line segments are coincident, then
no intersection is detected (there are actually
infinite intersection points).
The first point of the first line segment.
The second point of the first line segment.
The first point of the second line segment.
The second point of the second line segment.
This is set to the intersection
point if an intersection is detected.
True if an intersection is detected, false otherwise.
This method detects if two line segments intersect,
and, if so, the point of intersection.
Note: If two line segments are coincident, then
no intersection is detected (there are actually
infinite intersection points).
The first point of the first line segment.
The second point of the first line segment.
The first point of the second line segment.
The second point of the second line segment.
This is set to the intersection
point if an intersection is detected.
True if an intersection is detected, false otherwise.
Get all intersections between a line segment and a list of vertices
representing a polygon. The vertices reuse adjacent points, so for example
edges one and two are between the first and second vertices and between the
second and third vertices. The last edge is between vertex vertices.Count - 1
and verts0. (ie, vertices from a Geometry or AABB)
The first point of the line segment to test
The second point of the line segment to test.
The vertices, as described above
An list of intersection points. Any intersection points
found will be added to this list.
Get all intersections between a line segment and an AABB.
The first point of the line segment to test
The second point of the line segment to test.
The AABB that is used for testing intersection.
An list of intersection points. Any intersection points found will be added to this list.
This function is used to ensure that a floating point number is
not a NaN or infinity.
The x.
true if the specified x is valid; otherwise, false.
This is a approximate yet fast inverse square-root.
The x.
Return the angle between two vectors on a plane
The angle is from vector 1 to vector 2, positive anticlockwise
The result is between -pi -> pi
Returns a positive number if c is to the left of the line going from a to b.
Positive number if point is left, negative if point is right,
and 0 if points are collinear.
Returns a positive number if c is to the left of the line going from a to b.
Positive number if point is left, negative if point is right,
and 0 if points are collinear.
Determines if three vertices are collinear (ie. on a straight line)
First vertex
Second vertex
Third vertex
Checks if a floating point Value is equal to another,
within a certain tolerance.
The first floating point Value.
The second floating point Value.
The floating point tolerance.
True if the values are "equal", false otherwise.
Checks if a floating point Value is within a specified
range of values (inclusive).
The Value to check.
The minimum Value.
The maximum Value.
True if the Value is within the range specified,
false otherwise.
A 2-by-2 matrix. Stored in column-major order.
Construct this matrix using columns.
The c1.
The c2.
Construct this matrix using scalars.
The a11.
The a12.
The a21.
The a22.
Construct this matrix using an angle. This matrix becomes
an orthonormal rotation matrix.
The angle.
Initialize this matrix using columns.
The c1.
The c2.
Initialize this matrix using an angle. This matrix becomes
an orthonormal rotation matrix.
The angle.
Set this to the identity matrix.
Set this matrix to all zeros.
Solve A * x = b, where b is a column vector. This is more efficient
than computing the inverse in one-shot cases.
The b.
Extract the angle from this matrix (assumed to be
a rotation matrix).
A 3-by-3 matrix. Stored in column-major order.
Construct this matrix using columns.
The c1.
The c2.
The c3.
Set this matrix to all zeros.
Solve A * x = b, where b is a column vector. This is more efficient
than computing the inverse in one-shot cases.
The b.
Solve A * x = b, where b is a column vector. This is more efficient
than computing the inverse in one-shot cases. Solve only the upper
2-by-2 matrix equation.
The b.
A transform contains translation and rotation. It is used to represent
the position and orientation of rigid frames.
Initialize using a position vector and a rotation matrix.
The position.
The r.
Set this to the identity transform.
Set this based on the position and angle.
The position.
The angle.
Calculate the angle that the rotation matrix represents.
This describes the motion of a body/shape for TOI computation.
Shapes are defined with respect to the body origin, which may
no coincide with the center of mass. However, to support dynamics
we must interpolate the center of mass position.
World angles
Fraction of the current time step in the range [0,1]
c0 and a0 are the positions at alpha0.
Center world positions
Local center of mass position
Get the interpolated transform at a specific time.
The transform.
beta is a factor in [0,1], where 0 indicates alpha0.
Advance the sweep forward, yielding a new initial state.
new initial time..
Normalize the angles.
Path:
Very similar to Vertices, but this
class contains vectors describing
control points on a Catmull-Rom
curve.
All the points that makes up the curve
Initializes a new instance of the class.
Initializes a new instance of the class.
The vertices to created the path from.
Initializes a new instance of the class.
The vertices to created the path from.
Gets the next index of a controlpoint
The index.
Gets the previous index of a controlpoint
The index.
Translates the control points by the specified vector.
The vector.
Scales the control points by the specified vector.
The Value.
Rotate the control points by the defined value in radians.
The amount to rotate by in radians.
Returns a set of points defining the
curve with the specifed number of divisions
between each control point.
Number of divisions between each control point.
Gets the normal for the given time.
The time
The normal.
True if the curve is closed.
true if closed; otherwise, false.
An easy to use manager for creating paths.
Convert a path into a set of edges and attaches them to the specified body.
Note: use only for static edges.
The path.
The body.
The subdivisions.
Convert a closed path into a polygon.
Convex decomposition is automatically performed.
The path.
The body.
The density.
The subdivisions.
Duplicates the given Body along the given path for approximatly the given copies.
The world.
The path.
The shapes.
The type.
The copies.
Duplicates the given Body along the given path for approximatly the given copies.
The world.
The path.
The shape.
The type.
The copies.
The user data.
Moves the body on the path.
The path.
The body.
The time.
The strength.
The time step.
Attaches the bodies with revolute joints.
The world.
The bodies.
The local anchor A.
The local anchor B.
if set to true [connect first and last].
if set to true [collide connected].
Attaches the bodies with revolute joints.
The world.
The bodies.
The local anchor A.
The local anchor B.
if set to true [connect first and last].
if set to true [collide connected].
Minimum length of the slider joint.
Maximum length of the slider joint.
Split a fixture into 2 vertice collections using the given entry and exit-point.
The Fixture to split
The entry point - The start point
The exit point - The end point
The size of the split. Think of this as the laser-width
The first collection of vertexes
The second collection of vertexes
This is a high-level function to cuts fixtures inside the given world, using the start and end points.
Note: We don't support cutting when the start or end is inside a shape.
The world.
The startpoint.
The endpoint.
The thickness of the cut
Removes all collinear points on the polygon.
The polygon that needs simplification.
The collinearity tolerance.
A simplified polygon.
Removes all collinear points on the polygon.
Has a default bias of 0
The polygon that needs simplification.
A simplified polygon.
Ramer-Douglas-Peucker polygon simplification algorithm. This is the general recursive version that does not use the
speed-up technique by using the Melkman convex hull.
If you pass in 0, it will remove all collinear points
The simplified polygon
Merges all parallel edges in the list of vertices
The vertices.
The tolerance.
Merges the identical points in the polygon.
The vertices.
Reduces the polygon by distance.
The vertices.
The distance between points. Points closer than this will be 'joined'.
Reduces the polygon by removing the Nth vertex in the vertices list.
The vertices.
The Nth point to remove. Example: 5.
Implements "A new algorithm for Boolean operations on general polygons"
available here: http://liama.ia.ac.cn/wiki/_media/user:dong:dong_cg_05.pdf
Merges two polygons, a subject and a clip with the specified operation. Polygons may not be
self-intersecting.
Warning: May yield incorrect results or even crash if polygons contain collinear points.
The subject polygon.
The clip polygon, which is added,
substracted or intersected with the subject
The operation to be performed. Either
Union, Difference or Intersection.
The error generated (if any)
A list of closed polygons, which make up the result of the clipping operation.
Outer contours are ordered counter clockwise, holes are ordered clockwise.
Calculates all intersections between two polygons.
The first polygon.
The second polygon.
Returns the first polygon with added intersection points.
Returns the second polygon with added intersection points.
Calculates the simplical chain corresponding to the input polygon.
Used by method Execute().
Calculates the characteristics function for all edges of
the given simplical chains and builds the result chain.
Used by method Execute().
Calculates the polygon(s) from the result simplical chain.
Used by method Execute().
Needed to calculate the characteristics function of a simplex.
Used by method CalculateEdgeCharacter().
Needed for sorting multiple intersections points on the same edge.
Used by method CalculateIntersections().
Returns the coefficient of a simplex.
Used by method CalculateSimplicalChain().
Winding number test for a point in a simplex.
The point to be tested.
The edge that the point is tested against.
False if the winding number is even and the point is outside
the simplex and True otherwise.
Tests if a point lies on a line segment.
Used by method CalculateBeta().
Specifies an Edge. Edges are used to represent simplicies in simplical chains
Build vertices to represent an axis-aligned box.
the half-width.
the half-height.
Build vertices to represent an oriented box.
the half-width.
the half-height.
the center of the box in local coordinates.
the rotation of the box in local coordinates.
Creates a rounded rectangle with the specified width and height.
The width.
The height.
The rounding X radius.
The rounding Y radius.
The number of segments to subdivide the edges.
Set this as a single edge.
The first point.
The second point.
Creates a circle with the specified radius and number of edges.
The radius.
The number of edges. The more edges, the more it resembles a circle
Creates a ellipse with the specified width, height and number of edges.
Width of the ellipse.
Height of the ellipse.
The number of edges. The more edges, the more it resembles an ellipse
Creates an capsule with the specified height, radius and number of edges.
A capsule has the same form as a pill capsule.
Height (inner height + 2 * radius) of the capsule.
Radius of the capsule ends.
The number of edges of the capsule ends. The more edges, the more it resembles an capsule
Creates an capsule with the specified height, radius and number of edges.
A capsule has the same form as a pill capsule.
Height (inner height + radii) of the capsule.
Radius of the top.
The number of edges of the top. The more edges, the more it resembles an capsule
Radius of bottom.
The number of edges of the bottom. The more edges, the more it resembles an capsule
Creates a gear shape with the specified radius and number of teeth.
The radius.
The number of teeth.
The tip percentage.
Height of the tooth.
Detects the vertices by analyzing the texture data.
The texture data.
The texture width.
Detects the vertices by analyzing the texture data.
The texture data.
The texture width.
if set to true it will perform hole detection.
Detects the vertices by analyzing the texture data.
The texture data.
The texture width.
The hull tolerance.
The alpha tolerance.
if set to true it will perform multi part detection.
if set to true it will perform hole detection.
Marching squares over the given domain using the mesh defined via the dimensions
(wid,hei) to build a set of polygons such that f(x,y) less than 0, using the given number
'bin' for recursive linear inteprolation along cell boundaries.
if 'comb' is true, then the polygons will also be composited into larger possible concave
polygons.
Linearly interpolate between (x0 to x1) given a value at these coordinates (v0 and v1)
such as to approximate value(return) = 0
*
Recursive linear interpolation for use in marching squares *
Recursive linear interpolation for use in marching squares *
Square value for use in marching squares *
Used in polygon composition to composit polygons into scan lines
Combining polya and polyb into one super-polygon stored in polya.
*
Designed as a complete port of CxFastList from CxStd.
Iterator to start of list (O(1))
Iterator to end of list (O(1))
Returns first element of list (O(1))
add object to list (O(1))
remove object from list, returns true if an element was removed (O(n))
pop element from head of list (O(1)) Note: this does not return the object popped!
There is good reason to this, and it regards the Alloc list variants which guarantee
objects are released to the object pool. You do not want to retrieve an element
through pop or else that object may suddenly be used by another piece of code which
retrieves it from the object pool.
insert object after 'node' returning an iterator to the inserted object.
removes the element pointed to by 'node' with 'prev' being the previous iterator,
returning an iterator to the element following that of 'node' (O(1))
whether the list is empty (O(1))
computes size of list (O(n))
empty the list (O(1) if CxMixList, O(n) otherwise)
returns true if 'value' is an element of the list (O(n))
Associated polygon at coordinate *
Key of original sub-polygon *
Return true if the specified color is inside the terrain.
Simple class to maintain a terrain.
World to manage terrain in.
Center of terrain in world units.
Width of terrain in world units.
Height of terrain in world units.
Points per each world unit used to define the terrain in the point cloud.
Points per cell.
Points per sub cell.
Number of iterations to perform in the Marching Squares algorithm.
Note: More then 3 has almost no effect on quality.
Decomposer to use when regenerating terrain. Can be changed on the fly without consequence.
Note: Some decomposerers are unstable.
Point cloud defining the terrain.
Generated bodies.
Initialize the terrain for use.
Apply a texture to the terrain using the specified TerrainTester.
Texture to apply.
Top left position of the texture relative to the terrain.
Delegate method used to determine what colors should be included in the terrain.
Apply a texture to the terrain using the specified TerrainTester.
Top left position of the texture relative to the terrain.
Convert a texture to an sbtye array compatible with ApplyData().
Texture to convert.
Modify a single point in the terrain.
World location to modify. Automatically clipped.
-1 = inside terrain, 1 = outside terrain
Regenerate the terrain.
The detection type affects the resulting polygon data.
Holes are integrated into the main polygon.
The data of the main polygon and hole polygons is returned separately.
Detected vertices of a single polygon.
This array is ment to be readonly.
It's not because it is accessed very frequently.
Detects the vertices of the supplied texture data. (PolygonDetectionType.Integrated)
The texture data.
The texture width.
Detects the vertices of the supplied texture data.
The texture data.
The texture width.
if set to true it will perform hole detection.
Detects the vertices of the supplied texture data.
The texture data.
The texture width.
if set to true it will perform hole detection.
The hull tolerance.
The alpha tolerance.
if set to true it will perform multi part detection.
Function to search for an entrance point of a hole in a polygon. It searches the polygon from top to bottom between the polygon edges.
The polygon to search in.
The last entrance point.
The next holes entrance point. Null if ther are no holes.
Searches the polygon for the x coordinates of the edges that cross the specified y coordinate.
Polygon to search in.
Y coordinate to check for edges.
Descending sorted list of x coordinates of edges that cross the specified y coordinate.
Searches for the next shape.
Already detected polygons.
Search start coordinate.
Returns the found entrance coordinate. Null if no other shapes found.
True if a new shape was found.
Get or set the polygon detection type.
Will detect texture 'holes' if set to true. Slows down the detection. Default is false.
Will detect texture multiple 'solid' isles if set to true. Slows down the detection. Default is false.
Will optimize the vertex positions along the interpolated normal between two edges about a half pixel (post processing). Default is false.
Can be used for scaling.
Alpha (coverage) tolerance. Default is 20: Every pixel with a coverage value equal or greater to 20 will be counts as solid.
Default is 1.5f.
There were no errors in the polygon
Polygon must have between 3 and Settings.MaxPolygonVertices vertices.
Polygon must be simple. This means no overlapping edges.
Polygon must have a counter clockwise winding.
The polygon is concave, it needs to be convex.
Polygon area is too small.
The polygon has a side that is too short.
The body type.
Zero velocity, may be manually moved. Note: even static bodies have mass.
Zero mass, non-zero velocity set by user, moved by solver
Positive mass, non-zero velocity determined by forces, moved by solver
Resets the dynamics of this body.
Sets torque, force and linear/angular velocity to 0
Creates a fixture and attach it to this body.
If the density is non-zero, this function automatically updates the mass of the body.
Contacts are not created until the next time step.
Warning: This function is locked during callbacks.
The shape.
Creates a fixture and attach it to this body.
If the density is non-zero, this function automatically updates the mass of the body.
Contacts are not created until the next time step.
Warning: This function is locked during callbacks.
The shape.
Application specific data
Destroy a fixture. This removes the fixture from the broad-phase and
destroys all contacts associated with this fixture. This will
automatically adjust the mass of the body if the body is dynamic and the
fixture has positive density.
All fixtures attached to a body are implicitly destroyed when the body is destroyed.
Warning: This function is locked during callbacks.
The fixture to be removed.
Set the position of the body's origin and rotation.
This breaks any contacts and wakes the other bodies.
Manipulating a body's transform may cause non-physical behavior.
The world position of the body's local origin.
The world rotation in radians.
Set the position of the body's origin and rotation.
This breaks any contacts and wakes the other bodies.
Manipulating a body's transform may cause non-physical behavior.
The world position of the body's local origin.
The world rotation in radians.
For teleporting a body without considering new contacts immediately.
The position.
The angle.
Get the body transform for the body's origin.
The transform of the body's origin.
Apply a force at a world point. If the force is not
applied at the center of mass, it will generate a torque and
affect the angular velocity. This wakes up the body.
The world force vector, usually in Newtons (N).
The world position of the point of application.
Applies a force at the center of mass.
The force.
Applies a force at the center of mass.
The force.
Apply a force at a world point. If the force is not
applied at the center of mass, it will generate a torque and
affect the angular velocity. This wakes up the body.
The world force vector, usually in Newtons (N).
The world position of the point of application.
Apply a torque. This affects the angular velocity
without affecting the linear velocity of the center of mass.
This wakes up the body.
The torque about the z-axis (out of the screen), usually in N-m.
Apply an impulse at a point. This immediately modifies the velocity.
This wakes up the body.
The world impulse vector, usually in N-seconds or kg-m/s.
Apply an impulse at a point. This immediately modifies the velocity.
It also modifies the angular velocity if the point of application
is not at the center of mass.
This wakes up the body.
The world impulse vector, usually in N-seconds or kg-m/s.
The world position of the point of application.
Apply an impulse at a point. This immediately modifies the velocity.
This wakes up the body.
The world impulse vector, usually in N-seconds or kg-m/s.
Apply an impulse at a point. This immediately modifies the velocity.
It also modifies the angular velocity if the point of application
is not at the center of mass.
This wakes up the body.
The world impulse vector, usually in N-seconds or kg-m/s.
The world position of the point of application.
Apply an angular impulse.
The angular impulse in units of kg*m*m/s.
This resets the mass properties to the sum of the mass properties of the fixtures.
This normally does not need to be called unless you called SetMassData to override
the mass and you later want to reset the mass.
Get the world coordinates of a point given the local coordinates.
A point on the body measured relative the the body's origin.
The same point expressed in world coordinates.
Get the world coordinates of a point given the local coordinates.
A point on the body measured relative the the body's origin.
The same point expressed in world coordinates.
Get the world coordinates of a vector given the local coordinates.
Note that the vector only takes the rotation into account, not the position.
A vector fixed in the body.
The same vector expressed in world coordinates.
Get the world coordinates of a vector given the local coordinates.
A vector fixed in the body.
The same vector expressed in world coordinates.
Gets a local point relative to the body's origin given a world point.
Note that the vector only takes the rotation into account, not the position.
A point in world coordinates.
The corresponding local point relative to the body's origin.
Gets a local point relative to the body's origin given a world point.
A point in world coordinates.
The corresponding local point relative to the body's origin.
Gets a local vector given a world vector.
Note that the vector only takes the rotation into account, not the position.
A vector in world coordinates.
The corresponding local vector.
Gets a local vector given a world vector.
Note that the vector only takes the rotation into account, not the position.
A vector in world coordinates.
The corresponding local vector.
Get the world linear velocity of a world point attached to this body.
A point in world coordinates.
The world velocity of a point.
Get the world linear velocity of a world point attached to this body.
A point in world coordinates.
The world velocity of a point.
Get the world velocity of a local point.
A point in local coordinates.
The world velocity of a point.
Get the world velocity of a local point.
A point in local coordinates.
The world velocity of a point.
This is used to prevent connected bodies from colliding.
It may lie, depending on the collideConnected flag.
The other body.
Gets the total number revolutions the body has made.
The revolutions.
Gets or sets the body type.
The type of body.
Get or sets the linear velocity of the center of mass.
The linear velocity.
Gets or sets the angular velocity. Radians/second.
The angular velocity.
Gets or sets the linear damping.
The linear damping.
Gets or sets the angular damping.
The angular damping.
Gets or sets a value indicating whether this body should be included in the CCD solver.
true if this instance is included in CCD; otherwise, false.
You can disable sleeping on this body. If you disable sleeping, the
body will be woken.
true if sleeping is allowed; otherwise, false.
Set the sleep state of the body. A sleeping body has very
low CPU cost.
true if awake; otherwise, false.
Set the active state of the body. An inactive body is not
simulated and cannot be collided with or woken up.
If you pass a flag of true, all fixtures will be added to the
broad-phase.
If you pass a flag of false, all fixtures will be removed from
the broad-phase and all contacts will be destroyed.
Fixtures and joints are otherwise unaffected. You may continue
to create/destroy fixtures and joints on inactive bodies.
Fixtures on an inactive body are implicitly inactive and will
not participate in collisions, ray-casts, or queries.
Joints connected to an inactive body are implicitly inactive.
An inactive body is still owned by a b2World object and remains
in the body list.
true if active; otherwise, false.
Set this body to have fixed rotation. This causes the mass
to be reset.
true if it has fixed rotation; otherwise, false.
Gets all the fixtures attached to this body.
The fixture list.
Get the list of all joints attached to this body.
The joint list.
Get the list of all contacts attached to this body.
Warning: this list changes during the time step and you may
miss some collisions if you don't use ContactListener.
The contact list.
Set the user data. Use this to store your application specific data.
The user data.
Get the world body origin position.
Return the world position of the body's origin.
Get the angle in radians.
Return the current world rotation angle in radians.
Gets or sets a value indicating whether this body is static.
true if this instance is static; otherwise, false.
Gets or sets a value indicating whether this body ignores gravity.
true if it ignores gravity; otherwise, false.
Get the world position of the center of mass.
The world position.
Get the local position of the center of mass.
The local position.
Gets or sets the mass. Usually in kilograms (kg).
The mass.
Get or set the rotational inertia of the body about the local origin. usually in kg-m^2.
The inertia.
Fires when a contact is created
The filter used by the contact manager.
Fires when a contact is deleted
Fires when the broadphase detects that two Fixtures are close to each other.
Fires after the solver has run
Fires before the solver runs
A contact edge is used to connect bodies and contacts together
in a contact graph where each body is a node and each contact
is an edge. A contact edge belongs to a doubly linked list
maintained in each attached body. Each contact has two contact
nodes, one for each attached body.
The contact
The next contact edge in the body's contact list
Provides quick access to the other body attached.
The previous contact edge in the body's contact list
Used when crawling contact graph when forming islands.
Set when the shapes are touching.
This contact can be disabled (by user)
This contact needs filtering because a fixture filter was changed.
This bullet contact had a TOI event
This contact has a valid TOI i the field TOI
The class manages contact between two shapes. A contact exists for each overlapping
AABB in the broad-phase (except if filtered). Therefore a contact object may exist
that has no contact points.
Get the contact manifold. Do not modify the manifold unless you understand the
internals of Box2D.
The manifold.
Gets the world manifold.
Determines whether this contact is touching.
true if this instance is touching; otherwise, false.
Flag this contact for filtering. Filtering will occur the next time step.
Update the contact manifold and touching status.
Note: do not assume the fixture AABBs are overlapping or are valid.
The contact manager.
Evaluate this contact with your own manifold and transforms.
The manifold.
The first transform.
The second transform.
Enable/disable this contact. This can be used inside the pre-solve
contact listener. The contact is only disabled for the current
time step (or sub-step in continuous collisions).
Get the child primitive index for fixture A.
The child index A.
Get the child primitive index for fixture B.
The child index B.
This proxy is used internally to connect fixtures to the broad-phase.
A fixture is used to attach a Shape to a body for collision detection. A fixture
inherits its transform from its parent. Fixtures hold additional non-geometric data
such as friction, collision filters, etc.
Fixtures are created via Body.CreateFixture.
Warning: You cannot reuse fixtures.
Restores collisions between this fixture and the provided fixture.
The fixture.
Ignores collisions between this fixture and the provided fixture.
The fixture.
Determines whether collisions are ignored between this fixture and the provided fixture.
The fixture.
true if the fixture is ignored; otherwise, false.
Contacts are persistant and will keep being persistant unless they are
flagged for filtering.
This methods flags all contacts associated with the body for filtering.
Test a point for containment in this fixture.
A point in world coordinates.
Cast a ray against this Shape.
The ray-cast results.
The ray-cast input parameters.
Index of the child.
Get the fixture's AABB. This AABB may be enlarge and/or stale.
If you need a more accurate AABB, compute it using the Shape and
the body transform.
The aabb.
Index of the child.
Defaults to 0
If Settings.UseFPECollisionCategories is set to false:
Collision groups allow a certain group of objects to never collide (negative)
or always collide (positive). Zero means no collision group. Non-zero group
filtering always wins against the mask bits.
If Settings.UseFPECollisionCategories is set to true:
If 2 fixtures are in the same collision group, they will not collide.
Defaults to Category.All
The collision mask bits. This states the categories that this
fixture would accept for collision.
Use Settings.UseFPECollisionCategories to change the behavior.
The collision categories this fixture is a part of.
If Settings.UseFPECollisionCategories is set to false:
Defaults to Category.Cat1
If Settings.UseFPECollisionCategories is set to true:
Defaults to Category.All
Get the type of the child Shape. You can use this to down cast to the concrete Shape.
The type of the shape.
Get the child Shape. You can modify the child Shape, however you should not change the
number of vertices because this will crash some collision caching mechanisms.
The shape.
Gets or sets a value indicating whether this fixture is a sensor.
true if this instance is a sensor; otherwise, false.
Get the parent body of this fixture. This is null if the fixture is not attached.
The body.
Set the user data. Use this to store your application specific data.
The user data.
Get or set the coefficient of friction.
The friction.
Get or set the coefficient of restitution.
The restitution.
Gets a unique ID for this fixture.
The fixture id.
This is an internal class.
Maintains a fixed angle between two bodies
The Breakpoint simply indicates the maximum Value the JointError can be before it breaks.
The default value is float.MaxValue
Constructor for fixed joint
Get the reaction force on body2 at the joint anchor in Newtons.
The inv_dt.
Get the reaction torque on body2 in N*m.
The inv_dt.
Solves the position constraints.
returns true if the position errors are within tolerance.
Gets or sets the type of the joint.
The type of the joint.
Get the first body attached to this joint.
Get the second body attached to this joint.
Get the anchor point on body1 in world coordinates.
Get the anchor point on body2 in world coordinates.
Set the user data pointer.
The data.
Short-cut function to determine if either body is inactive.
true if active; otherwise, false.
Set this flag to true if the attached bodies should collide.
Fires when the joint is broken.
A distance joint rains two points on two bodies
to remain at a fixed distance from each other. You can view
this as a massless, rigid rod.
The local anchor point relative to bodyA's origin.
The local anchor point relative to bodyB's origin.
This requires defining an
anchor point on both bodies and the non-zero length of the
distance joint. If you don't supply a length, the local anchor points
is used so that the initial configuration can violate the constraint
slightly. This helps when saving and loading a game.
@warning Do not use a zero or short length.
The first body
The second body
The first body anchor
The second body anchor
The natural length between the anchor points.
Manipulating the length can lead to non-physical behavior when the frequency is zero.
The mass-spring-damper frequency in Hertz.
The damping ratio. 0 = no damping, 1 = critical damping.
Friction joint. This is used for top-down friction.
It provides 2D translational friction and angular friction.
The maximum friction force in N.
The maximum friction torque in N-m.
A gear joint is used to connect two joints together. Either joint
can be a revolute or prismatic joint. You specify a gear ratio
to bind the motions together:
coordinate1 + ratio * coordinate2 = ant
The ratio can be negative or positive. If one joint is a revolute joint
and the other joint is a prismatic joint, then the ratio will have units
of length or units of 1/length.
@warning The revolute and prismatic joints must be attached to
fixed bodies (which must be body1 on those joints).
Requires two existing revolute or prismatic joints (any combination will work).
The provided joints must attach a dynamic body to a static body.
The first joint.
The second joint.
The ratio.
The gear ratio.
The first revolute/prismatic joint attached to the gear joint.
The second revolute/prismatic joint attached to the gear joint.
A joint edge is used to connect bodies and joints together
in a joint graph where each body is a node and each joint
is an edge. A joint edge belongs to a doubly linked list
maintained in each attached body. Each joint has two joint
nodes, one for each attached body.
The joint.
The next joint edge in the body's joint list.
Provides quick access to the other body attached.
The previous joint edge in the body's joint list.
A prismatic joint. This joint provides one degree of freedom: translation
along an axis fixed in body1. Relative rotation is prevented. You can
use a joint limit to restrict the range of motion and a joint motor to
drive the motion or to model joint friction.
This requires defining a line of
motion using an axis and an anchor point. The definition uses local
anchor points and a local axis so that the initial configuration
can violate the constraint slightly. The joint translation is zero
when the local anchor points coincide in world space. Using local
anchors and a local axis helps when saving and loading a game.
The first body.
The second body.
The first body anchor.
The second body anchor.
The axis.
Get the current joint translation, usually in meters.
Get the current joint translation speed, usually in meters per second.
Is the joint limit enabled?
true if [limit enabled]; otherwise, false.
Get the lower joint limit, usually in meters.
Get the upper joint limit, usually in meters.
Is the joint motor enabled?
true if [motor enabled]; otherwise, false.
Set the motor speed, usually in meters per second.
The speed.
Set the maximum motor force, usually in N.
The force.
Get the current motor force, usually in N.
The pulley joint is connected to two bodies and two fixed ground points.
The pulley supports a ratio such that:
length1 + ratio * length2 = ant
Yes, the force transmitted is scaled by the ratio.
The pulley also enforces a maximum length limit on both sides. This is
useful to prevent one side of the pulley hitting the top.
Get the first ground anchor.
Get the second ground anchor.
Initialize the bodies, anchors, lengths, max lengths, and ratio using the world anchors.
This requires two ground anchors,
two dynamic body anchor points, max lengths for each side,
and a pulley ratio.
The first body.
The second body.
The ground anchor for the first body.
The ground anchor for the second body.
The first body anchor.
The second body anchor.
The ratio.
Get the current length of the segment attached to body1.
Get the current length of the segment attached to body2.
Get the pulley ratio.
A revolute joint rains to bodies to share a common point while they
are free to rotate about the point. The relative rotation about the shared
point is the joint angle. You can limit the relative rotation with
a joint limit that specifies a lower and upper angle. You can use a motor
to drive the relative rotation about the shared point. A maximum motor torque
is provided so that infinite forces are not generated.
Initialize the bodies and local anchor.
This requires defining an
anchor point where the bodies are joined. The definition
uses local anchor points so that the initial configuration
can violate the constraint slightly. You also need to
specify the initial relative angle for joint limits. This
helps when saving and loading a game.
The local anchor points are measured from the body's origin
rather than the center of mass because:
1. you might not know where the center of mass will be.
2. if you add/remove shapes from a body and recompute the mass,
the joints will be broken.
The first body.
The second body.
The first body anchor.
The second anchor.
Get the current joint angle in radians.
Get the current joint angle speed in radians per second.
Is the joint limit enabled?
true if [limit enabled]; otherwise, false.
Get the lower joint limit in radians.
Get the upper joint limit in radians.
Is the joint motor enabled?
true if [motor enabled]; otherwise, false.
Set the motor speed in radians per second.
The speed.
Set the maximum motor torque, usually in N-m.
The torque.
Get the current motor torque, usually in N-m.
A rope joint enforces a maximum distance between two points
on two bodies. It has no other effect.
Warning: if you attempt to change the maximum length during
the simulation you will get some non-physical behavior.
A model that would allow you to dynamically modify the length
would have some sponginess, so I chose not to implement it
that way. See b2DistanceJoint if you want to dynamically
control length.
Get the maximum length of the rope.
A distance joint contrains two points on two bodies
to remain at a fixed distance from each other. You can view
this as a massless, rigid rod.
Initializes a new instance of the class.
Warning: Do not use a zero or short length.
The first body.
The second body.
The first body anchor.
The second body anchor.
The minimum length between anchorpoints
The maximum length between anchorpoints.
The maximum length between the anchor points.
The length.
The minimal length between the anchor points.
The length.
The mass-spring-damper frequency in Hertz.
The frequency.
The damping ratio. 0 = no damping, 1 = critical damping.
The damping ratio.
A weld joint essentially glues two bodies together. A weld joint may
distort somewhat because the island constraint solver is approximate.
The body2 angle minus body1 angle in the reference state (radians).
You need to specify a local anchor point
where they are attached and the relative body angle. The position
of the anchor point is important for computing the reaction torque.
You can change the anchor points relative to bodyA or bodyB by changing LocalAnchorA
and/or LocalAnchorB.
The first body
The second body
The first body anchor.
The second body anchor.
This is an internal structure.
Time step (Delta time)
dt * inv_dt0
Inverse time step (0 if dt == 0).
Contains filter data that can determine whether an object should be processed or not.
Adds the category.
The category.
Removes the category.
The category.
Determines whether this body ignores the the specified controller.
The category.
true if the object has the specified category; otherwise, false.
Adds the category.
The category.
Removes the category.
The category.
Determines whether this body ignores the the specified controller.
The category.
true if the object has the specified category; otherwise, false.
Flag that indicates a new fixture has been added to the world.
Flag that clear the forces after each time step.
The world class manages all physics entities, dynamic simulation,
and asynchronous queries.
Fires whenever a body has been added
Fires whenever a body has been removed
Fires whenever a fixture has been added
Fires whenever a fixture has been removed
Fires whenever a joint has been added
Fires whenever a joint has been removed
If false, the whole simulation stops. It still processes added and removed geometries.
Initializes a new instance of the class.
Initializes a new instance of the class.
The gravity.
Change the global gravity vector.
The gravity.
Add a rigid body.
Destroy a rigid body.
Warning: This automatically deletes all associated shapes and joints.
The body.
Create a joint to constrain bodies together. This may cause the connected bodies to cease colliding.
The joint.
Destroy a joint. This may cause the connected bodies to begin colliding.
The joint.
All adds and removes are cached by the World duing a World step.
To process the changes before the world updates again, call this method.
Take a time step. This performs collision detection, integration,
and consraint solution.
The amount of time to simulate, this should not vary.
Call this after you are done with time steps to clear the forces. You normally
call this after each call to Step, unless you are performing sub-steps. By default,
forces will be automatically cleared, so you don't need to call this function.
Query the world for all fixtures that potentially overlap the
provided AABB.
Inside the callback:
Return true: Continues the query
Return false: Terminate the query
A user implemented callback class.
The aabb query box.
Ray-cast the world for all fixtures in the path of the ray. Your callback
controls whether you get the closest point, any point, or n-points.
The ray-cast ignores shapes that contain the starting point.
Inside the callback:
return -1: ignore this fixture and continue
return 0: terminate the ray cast
return fraction: clip the ray to this point
return 1: don't clip the ray and continue
A user implemented callback class.
The ray starting point.
The ray ending point.
Find TOI contacts and solve them.
The step.
Returns a list of fixtures that are at the specified point.
The point.
Get the number of broad-phase proxies.
The proxy count.
Set flag to control automatic clearing of forces after each time step.
true if it should auto clear forces; otherwise, false.
Get the contact manager for testing.
The contact manager.
Get the world body list.
Thehead of the world body list.
Get the world joint list.
The joint list.
Get the world contact list. With the returned contact, use Contact.GetNext to get
the next contact in the world list. A null contact indicates the end of the list.
The head of the world contact list.
Enable/disable single stepped continuous physics. For testing.
Called for each fixture found in the query. You control how the ray cast
proceeds by returning a float:
-1 to filter, 0 to terminate, fraction to clip the ray for closest hit, 1 to continue
This delegate is called when a contact is deleted
This delegate is called when a contact is created
Creates a capsule.
Note: Automatically decomposes the capsule if it contains too many vertices (controlled by Settings.MaxPolygonVertices)
The world.
The height.
The top radius.
The top edges.
The bottom radius.
The bottom edges.
The density.
The position.
Creates a rounded rectangle.
Note: Automatically decomposes the capsule if it contains too many vertices (controlled by Settings.MaxPolygonVertices)
The world.
The width.
The height.
The x radius.
The y radius.
The segments.
The density.
The position.
An easy to use factory for creating bodies
An easy to use factory for using joints.
Creates a revolute joint.
The anchor of bodyB in local coordinates
Creates a revolute joint and adds it to the world
Creates a weld joint
Creates a weld joint and adds it to the world
Creates a prsimatic joint
Creates a prismatic joint and adds it to the world
Creates a line joint
Creates a line joint and adds it to the world
Creates an angle joint.
The world.
The first body.
The second body.
Creates a chain.
The world.
The start.
The end.
The width.
The height.
The number of links.
The link density.
Enabling diagnistics causes the engine to gather timing information.
You can see how much time it took to solve the contacts, solve CCD
and update the controllers.
The number of velocity iterations used in the solver.
The number of position iterations used in the solver.
Enable/Disable Continuous Collision Detection (CCD)
The number of velocity iterations in the TOI solver
The number of position iterations in the TOI solver
Maximum number of sub-steps per contact in continuous physics simulation.
Enable/Disable warmstarting
Enable/Disable sleeping
The maximum number of vertices on a convex polygon.
Conserve memory makes sure that objects are used by reference instead of cloned.
When you give a vertices collection to a PolygonShape, it will by default copy the vertices
instead of using the original reference. This is to ensure that objects modified outside the engine
does not affect the engine itself, however, this uses extra memory. This behavior
can be turned off by setting ConserveMemory to true.
The maximum number of contact points between two convex shapes.
This is used to fatten AABBs in the dynamic tree. This allows proxies
to move by a small amount without triggering a tree adjustment.
This is in meters.
This is used to fatten AABBs in the dynamic tree. This is used to predict
the future position based on the current displacement.
This is a dimensionless multiplier.
A small length used as a collision and constraint tolerance. Usually it is
chosen to be numerically significant, but visually insignificant.
A small angle used as a collision and constraint tolerance. Usually it is
chosen to be numerically significant, but visually insignificant.
The radius of the polygon/edge shape skin. This should not be modified. Making
this smaller means polygons will have an insufficient buffer for continuous collision.
Making it larger may create artifacts for vertex collision.
Maximum number of contacts to be handled to solve a TOI impact.
The maximum linear position correction used when solving constraints. This helps to
prevent overshoot.
The maximum angular position correction used when solving constraints. This helps to
prevent overshoot.
This scale factor controls how fast overlap is resolved. Ideally this would be 1 so
that overlap is removed in one time step. However using values close to 1 often lead
to overshoot.
The time that a body must be still before it will go to sleep.
A body cannot sleep if its linear velocity is above this tolerance.
A body cannot sleep if its angular velocity is above this tolerance.
The maximum linear velocity of a body. This limit is very large and is used
to prevent numerical problems. You shouldn't need to adjust this.
The maximum angular velocity of a body. This limit is very large and is used
to prevent numerical problems. You shouldn't need to adjust this.
Farseer Physics Engine has a different way of filtering fixtures than Box2d.
We have both FPE and Box2D filtering in the engine. If you are upgrading
from earlier versions of FPE, set this to true.
A velocity threshold for elastic collisions. Any collision with a relative linear
velocity below this threshold will be treated as inelastic.
Friction mixing law. Feel free to customize this.
The friction1.
The friction2.
Restitution mixing law. Feel free to customize this.
The restitution1.
The restitution2.