public final class PolygonShape extends Shape
| Modifier and Type | Field and Description |
|---|---|
Vec2 |
m_centroid
Local position of the shape centroid in parent body frame.
|
Vec2[] |
m_normals
The normals of the shape.
|
Vec2[] |
m_vertices
The vertices of the shape.
|
| Constructor and Description |
|---|
PolygonShape() |
| Modifier and Type | Method and Description |
|---|---|
Vec2 |
centroid(Transform xf)
Get the centroid and apply the supplied transform.
|
Vec2 |
centroidToOut(Transform xf,
Vec2 out)
Get the centroid and apply the supplied transform.
|
Shape |
clone() |
void |
computeAABB(AABB aabb,
Transform xf,
int childIndex)
Given a transform, compute the associated axis aligned bounding box for a child shape.
|
void |
computeCentroidToOut(Vec2[] vs,
int count,
Vec2 out) |
float |
computeDistanceToOut(Transform xf,
Vec2 p,
int childIndex,
Vec2 normalOut)
Compute the distance from the current shape to the specified point.
|
void |
computeMass(MassData massData,
float density)
Compute the mass properties of this shape using its dimensions and density.
|
int |
getChildCount() |
Vec2[] |
getNormals()
Get the edge normal vectors.
|
Vec2 |
getVertex(int index)
Get a vertex by index.
|
int |
getVertexCount() |
Vec2[] |
getVertices()
Get the vertices in local coordinates.
|
boolean |
raycast(RayCastOutput output,
RayCastInput input,
Transform xf,
int childIndex)
Cast a ray against a child shape.
|
void |
set(Vec2[] vertices,
int count)
Create a convex hull from the given array of points.
|
void |
setAsBox(float hx,
float hy)
Build vertices to represent an axis-aligned box.
|
void |
setAsBox(float hx,
float hy,
Vec2 center,
float angle)
Build vertices to represent an oriented box.
|
boolean |
testPoint(Transform xf,
Vec2 p)
Test a point for containment in this shape.
|
boolean |
validate()
Validate convexity.
|
public final Vec2 m_centroid
public final Vec2[] m_vertices
public final Vec2[] m_normals
public int getChildCount()
getChildCount in class Shapepublic boolean testPoint(Transform xf, Vec2 p)
Shapepublic void computeAABB(AABB aabb, Transform xf, int childIndex)
ShapecomputeAABB in class Shapeaabb - returns the axis aligned boxxf - the world transform of the shapechildIndex - the child shape indexpublic float computeDistanceToOut(Transform xf, Vec2 p, int childIndex, Vec2 normalOut)
ShapecomputeDistanceToOut in class Shapexf - the shape world transform.p - a point in world coordinates.normalOut - returns the direction in which the distance increases.public boolean raycast(RayCastOutput output, RayCastInput input, Transform xf, int childIndex)
Shapepublic void computeMass(MassData massData, float density)
ShapecomputeMass in class ShapemassData - returns the mass data for this shape.density - the density in kilograms per meter squared.public void set(Vec2[] vertices, int count)
public void setAsBox(float hx,
float hy)
hx - the half-width.hy - the half-height.public void setAsBox(float hx,
float hy,
Vec2 center,
float angle)
hx - the half-width.hy - the half-height.center - the center of the box in local coordinates.angle - the rotation of the box in local coordinates.public int getVertexCount()
public Vec2 getVertex(int index)
index - public boolean validate()
public Vec2[] getVertices()
public Vec2[] getNormals()
Copyright © 2018. All rights reserved.