blaze.collision.shapes.polygon
- class
PolyDef
: blaze.collision.shapes.shape.ShapeDef;
- Convex polygon. The vertices must be in CCW order for a right-handed
coordinate system with the z-axis coming out of the screen.
Implements:
ShapeDef
- bVec2 []
vertices
;
- The polygon
vertices
in local coordinates.
- this(float density, bVec2 [] vertices);
- Params:
float density |
the density of the polygon |
verticies |
the verticies that make up the polygon |
- void
setAsBox
(float hx, float hy);
- Build vertices to represent an axis-aligned box.
Params:
float hx |
the half-width. |
float hy |
the half-height. |
- void
setAsBox
(float hx, float hy, bVec2 center, float angle);
- Build vertices to represent an oriented box.
Params:
float hx |
the half-width.
hy the = half-height. |
bVec2 center |
the center of the box in local coordinates. |
float angle |
the rotation of the box in local coordinates. |
- class
Polygon
: blaze.collision.shapes.shape.Shape;
- A polygon
Implements:
Shape
- this(ShapeDef def);
- Constructs a polygon from a ShapeDef
BUGS:
www.dsource.org/forums/viewtopic.php?t=4354&sid=ced13ecab0525aa79a60a826e7290805
This example code demonstrates the failure
auto sdef = new blaze.PolyDef;
sdef.vertices ~= Vec2(-.07, -.11);
sdef.vertices ~= Vec2(.07, -.11);
sdef.vertices ~= Vec2(.07, .1);
sdef.vertices ~= Vec2(-.07, .1);
- bVec2
firstVertex
(bXForm xf);
- Returns:
the first vertex and apply the supplied transform.
- AABB
aabb
();
- Returns:
the axis aligned bounding box associated with the shape, in
reference to the parent body's transform
- void
updateAABB
();
- Update the AABB
- OBB
obb
();
- Returns:
the oriented bounding box relative to the parent body.
- bVec2
centroid
();
- Returns:
the local
centroid
relative to the parent body.
- bVec2
centroid
(bXForm xf);
- Returns:
the
centroid
and apply the supplied transform.
- int
vertexCount
();
- Returns:
the vertex count
- bVec2 []
vertices
();
- Returns:
the
vertices
in local coordinates.
- bVec2 []
worldVertices
();
- Returns:
the vertices in world coordinates
- bVec2
worldCenter
();
- Returns:
The polygon's centroid in world coordinates
- bVec2 []
coreVertices
();
- Returns:
The core vertices in local coordinates. These vertices
represent a smaller polygon that is used for time of impact
computations.
- bVec2 []
normals
();
- Returns:
The edge normal vectors. There is one for each vertex.
- void
updateSweepRadius
(bVec2 center);
- Update the sweep radius (maximum radius) as measured from
a local center point.
Params:
bVec2 center |
the center point to measure from |
- bool
testPoint
(bXForm xf, bVec2 p);
- Test a point for containment in this shape. This only works for convex
shapes.
Params:
bXForm xf |
the shape world transform. |
bVec2 p |
a point in world coordinates. |
Returns:
true if the point lies within the shape, false otherwise.
Implements:
blaze.collision.shapes.shape.Shape.
testPoint
- SegmentCollide
testSegment
(bXForm xf, ref float lambda, ref bVec2 normal, Segment segment, float maxLambda);
- Perform a ray cast against this shape.
Params:
bXForm xf |
the shape world transform. |
float lambda |
returns the hit fraction. You can use this to compute the
contact point p = (1 - lambda) * segment.p1 + lambda * segment.p2 |
bVec2 normal |
returns the normal at the contact point. If there is no
intersection, the normal is not set. |
Segment segment |
defines the begin and end point of the ray cast. |
float maxLambda |
a number typically in the range [0,1]. |
Returns:
a SegmentCollide representing the collision between this shape
and the segment
Implements:
blaze.collision.shapes.shape.Shape.
testSegment
- void
computeAABB
(ref AABB aabb, bXForm xf);
- Given a transform, compute the associated axis aligned bounding box for
this shape.
This does not modify the shape's AABB
Params:
AABB aabb |
returns the axis aligned box. |
bXForm xf |
the world transform of the shape. |
Implements:
blaze.collision.shapes.shape.Shape.
computeAABB
- void
computeSweptAABB
(bXForm xf1, bXForm xf2);
- Given two transforms, compute the associated swept axis aligned bounding
box for this shape. This DOES modify the shape's AABB (see bugs)
Params:
bXForm xf1 |
the world transform of the shape. |
bXForm xf2 |
the velocity of the shape |
Implements:
blaze.collision.shapes.shape.Shape.
computeSweptAABB
BUGS:
Why is this different from the way Box2d does it? And why does it
behave differently from computeAABB?
- void
computeMass
(ref MassData massData);
- Compute the mass properties of this shape using its dimensions and density.
The inertia tensor is computed about the local origin, not the centroid.
Params:
MassData massData |
returns the mass data for this shape. |
Implements:
blaze.collision.shapes.shape.Shape.
computeMass
- bVec2
support
(bXForm xf, bVec2 d);
- Returns:
The shape's
support
point (for MPR & GJK)
- void
triangulate
();
- Triangulate the shape in world coordinates.
Currently this is only used by the buoyancy solver.
- bVec2
computeCentroid
(bVec2 [] vs);
- Determines the centroid of a polygon
Params:
bVec2 [] vs |
the verticies that define the polygon |
Returns:
the location of the centroid (probably in local coordinates)
- void
computeOBB
(ref OBB obb, bVec2 [] vs);
- Computes the object bounding box for a polygon
Params:
OBB obb |
the bounding box that the result is stored in |
bVec2 [] vs |
the verticies that define the polygon |
See Also:
www.geometrictools.com/Documentation/minNumimumAreaRectangle.pdf
|