public abstract class Box2DUtils
extends java.lang.Object
Bodies, Fixtures and Shapes| Modifier and Type | Class and Description |
|---|---|
static class |
Box2DUtils.ShapeCache
cached method results
|
| Modifier and Type | Field and Description |
|---|---|
static boolean |
autoCache
if shapes should automatically be cached when they are inspected for the first time
|
static com.badlogic.gdx.utils.ObjectMap<com.badlogic.gdx.physics.box2d.Shape,Box2DUtils.ShapeCache> |
cache
Cached
Shapes and their Box2DUtils.ShapeCache. |
static boolean |
checkPreconditions
if Box2D preconditions should be checked to avoid crashes
|
static byte |
maxPolygonVertices
the max amount of vertices of a
PolygonShape (limitation by Box2D) |
static float |
minExclusivePolygonArea
the area that is too small for a
PolygonShape to contain it (limitation by Box2D) |
private static com.badlogic.gdx.math.Vector2 |
vec2_0
for internal, temporary usage
|
private static com.badlogic.gdx.math.Vector2 |
vec2_1
for internal, temporary usage
|
| Constructor and Description |
|---|
Box2DUtils() |
| Modifier and Type | Method and Description |
|---|---|
static Box2DUtils.ShapeCache |
cache(com.badlogic.gdx.physics.box2d.Shape shape) |
static com.badlogic.gdx.physics.box2d.Body |
clone(com.badlogic.gdx.physics.box2d.Body body)
clones a
Body (without deep copying the Shapes of its Fixtures) |
static com.badlogic.gdx.physics.box2d.Body |
clone(com.badlogic.gdx.physics.box2d.Body body,
boolean shapes)
clones a
Body |
static com.badlogic.gdx.physics.box2d.Fixture |
clone(com.badlogic.gdx.physics.box2d.Fixture fixture,
com.badlogic.gdx.physics.box2d.Body body)
clones a
Fixture (without deep copying its Shape) |
static com.badlogic.gdx.physics.box2d.Fixture |
clone(com.badlogic.gdx.physics.box2d.Fixture fixture,
com.badlogic.gdx.physics.box2d.Body body,
boolean shape)
clones a
Fixture |
static <T extends com.badlogic.gdx.physics.box2d.Shape> |
clone(T shape)
creates a deep copy of a
ShapeNote: The previous and next vertex of a ChainShape will not be copied since this is not possible due to the API. |
static com.badlogic.gdx.physics.box2d.BodyDef |
createDef(com.badlogic.gdx.physics.box2d.Body body) |
static com.badlogic.gdx.physics.box2d.FixtureDef |
createDef(com.badlogic.gdx.physics.box2d.Fixture fixture) |
static void |
destroyFixtures(com.badlogic.gdx.physics.box2d.Body body)
destroys all fixtures of the given body |
static void |
destroyFixtures(com.badlogic.gdx.physics.box2d.Body body,
com.badlogic.gdx.utils.Array<com.badlogic.gdx.physics.box2d.Fixture> exclude)
destroys all fixtures of the given body except the given ones |
static void |
destroyFixtures(com.badlogic.gdx.physics.box2d.Body body,
com.badlogic.gdx.physics.box2d.Fixture... exclude) |
static void |
destroyFixtures(com.badlogic.gdx.physics.box2d.Body body,
com.badlogic.gdx.physics.box2d.Fixture exclude) |
static com.badlogic.gdx.math.Vector2[][] |
fixtureVertices(com.badlogic.gdx.physics.box2d.Body body) |
static float |
height(com.badlogic.gdx.physics.box2d.Body body) |
static float |
height(com.badlogic.gdx.physics.box2d.Fixture fixture) |
static float |
height(com.badlogic.gdx.physics.box2d.Shape shape) |
private static float |
height0(com.badlogic.gdx.physics.box2d.Shape shape) |
static float |
maxX(com.badlogic.gdx.physics.box2d.Body body) |
static float |
maxX(com.badlogic.gdx.physics.box2d.Fixture fixture) |
static float |
maxX(com.badlogic.gdx.physics.box2d.Shape shape) |
private static float |
maxX0(com.badlogic.gdx.physics.box2d.Shape shape) |
static float |
maxY(com.badlogic.gdx.physics.box2d.Body body) |
static float |
maxY(com.badlogic.gdx.physics.box2d.Fixture fixture) |
static float |
maxY(com.badlogic.gdx.physics.box2d.Shape shape) |
private static float |
maxY0(com.badlogic.gdx.physics.box2d.Shape shape) |
static float |
minX(com.badlogic.gdx.physics.box2d.Body body) |
static float |
minX(com.badlogic.gdx.physics.box2d.Fixture fixture) |
static float |
minX(com.badlogic.gdx.physics.box2d.Shape shape) |
private static float |
minX0(com.badlogic.gdx.physics.box2d.Shape shape) |
static float |
minY(com.badlogic.gdx.physics.box2d.Body body) |
static float |
minY(com.badlogic.gdx.physics.box2d.Fixture fixture) |
static float |
minY(com.badlogic.gdx.physics.box2d.Shape shape) |
private static float |
minY0(com.badlogic.gdx.physics.box2d.Shape shape) |
static com.badlogic.gdx.math.Vector2 |
position(com.badlogic.gdx.physics.box2d.Fixture fixture) |
static com.badlogic.gdx.math.Vector2 |
position(com.badlogic.gdx.physics.box2d.Shape shape,
com.badlogic.gdx.physics.box2d.Body body) |
static com.badlogic.gdx.math.Vector2 |
positionRelative(com.badlogic.gdx.physics.box2d.CircleShape shape) |
static com.badlogic.gdx.math.Vector2 |
positionRelative(com.badlogic.gdx.physics.box2d.Fixture fixture) |
static com.badlogic.gdx.math.Vector2 |
positionRelative(com.badlogic.gdx.physics.box2d.Shape shape,
float rotation) |
static void |
setSensor(com.badlogic.gdx.physics.box2d.Body body,
boolean sensor)
sets the
sensor flag of all of the given Body's Fixtures |
static com.badlogic.gdx.math.Vector2 |
size(com.badlogic.gdx.physics.box2d.Body body) |
static com.badlogic.gdx.math.Vector2 |
size(com.badlogic.gdx.physics.box2d.Fixture fixture) |
static com.badlogic.gdx.math.Vector2 |
size(com.badlogic.gdx.physics.box2d.Shape shape) |
private static com.badlogic.gdx.math.Vector2 |
size0(com.badlogic.gdx.physics.box2d.Shape shape) |
static boolean |
split(com.badlogic.gdx.physics.box2d.Body body,
com.badlogic.gdx.math.Vector2 a,
com.badlogic.gdx.math.Vector2 b,
net.dermetfan.utils.Pair<com.badlogic.gdx.physics.box2d.Body,com.badlogic.gdx.physics.box2d.Body> store) |
static boolean |
split(com.badlogic.gdx.physics.box2d.Fixture fixture,
com.badlogic.gdx.math.Vector2 a,
com.badlogic.gdx.math.Vector2 b,
com.badlogic.gdx.physics.box2d.Body aBody,
com.badlogic.gdx.physics.box2d.Body bBody,
net.dermetfan.utils.Pair<com.badlogic.gdx.physics.box2d.Fixture,com.badlogic.gdx.physics.box2d.Fixture> store) |
static boolean |
split(com.badlogic.gdx.physics.box2d.Fixture fixture,
com.badlogic.gdx.math.Vector2 a,
com.badlogic.gdx.math.Vector2 b,
net.dermetfan.utils.Pair<com.badlogic.gdx.physics.box2d.FixtureDef,com.badlogic.gdx.physics.box2d.FixtureDef> store) |
static <T extends com.badlogic.gdx.physics.box2d.Shape> |
split(T shape,
com.badlogic.gdx.math.Vector2 a,
com.badlogic.gdx.math.Vector2 b,
net.dermetfan.utils.Pair<T,T> store)
splits the given Shape using the segment described by the two given Vector2s
|
static com.badlogic.gdx.math.Vector2[] |
vertices(com.badlogic.gdx.physics.box2d.Body body) |
static com.badlogic.gdx.math.Vector2[] |
vertices(com.badlogic.gdx.physics.box2d.Fixture fixture) |
static com.badlogic.gdx.math.Vector2[] |
vertices(com.badlogic.gdx.physics.box2d.Shape shape) |
private static com.badlogic.gdx.math.Vector2[] |
vertices0(com.badlogic.gdx.physics.box2d.Shape shape) |
static float |
width(com.badlogic.gdx.physics.box2d.Body body) |
static float |
width(com.badlogic.gdx.physics.box2d.Fixture fixture) |
static float |
width(com.badlogic.gdx.physics.box2d.Shape shape) |
private static float |
width0(com.badlogic.gdx.physics.box2d.Shape shape) |
public static final com.badlogic.gdx.utils.ObjectMap<com.badlogic.gdx.physics.box2d.Shape,Box2DUtils.ShapeCache> cache
Shapes and their Box2DUtils.ShapeCache. You should clear this when you don't use the shapes anymore.public static boolean autoCache
public static final float minExclusivePolygonArea
PolygonShape to contain it (limitation by Box2D)public static final byte maxPolygonVertices
PolygonShape (limitation by Box2D)public static boolean checkPreconditions
private static final com.badlogic.gdx.math.Vector2 vec2_0
private static final com.badlogic.gdx.math.Vector2 vec2_1
public static Box2DUtils.ShapeCache cache(com.badlogic.gdx.physics.box2d.Shape shape)
shape - the Shape to create a new Box2DUtils.ShapeCache for that will be added to cacheprivate static com.badlogic.gdx.math.Vector2[] vertices0(com.badlogic.gdx.physics.box2d.Shape shape)
shape - the Shape which vertices to get (for circles, the bounding box vertices will be returned)private static float minX0(com.badlogic.gdx.physics.box2d.Shape shape)
private static float minY0(com.badlogic.gdx.physics.box2d.Shape shape)
private static float maxX0(com.badlogic.gdx.physics.box2d.Shape shape)
private static float maxY0(com.badlogic.gdx.physics.box2d.Shape shape)
private static float width0(com.badlogic.gdx.physics.box2d.Shape shape)
private static float height0(com.badlogic.gdx.physics.box2d.Shape shape)
private static com.badlogic.gdx.math.Vector2 size0(com.badlogic.gdx.physics.box2d.Shape shape)
public static com.badlogic.gdx.math.Vector2[] vertices(com.badlogic.gdx.physics.box2d.Shape shape)
public static float minX(com.badlogic.gdx.physics.box2d.Shape shape)
public static float minY(com.badlogic.gdx.physics.box2d.Shape shape)
public static float maxX(com.badlogic.gdx.physics.box2d.Shape shape)
public static float maxY(com.badlogic.gdx.physics.box2d.Shape shape)
public static float width(com.badlogic.gdx.physics.box2d.Shape shape)
public static float height(com.badlogic.gdx.physics.box2d.Shape shape)
public static com.badlogic.gdx.math.Vector2 size(com.badlogic.gdx.physics.box2d.Shape shape)
Vector2 representing the size of the given Shapepublic static com.badlogic.gdx.math.Vector2[] vertices(com.badlogic.gdx.physics.box2d.Fixture fixture)
vertices(Shape)public static float minX(com.badlogic.gdx.physics.box2d.Fixture fixture)
minX(Shape)public static float minY(com.badlogic.gdx.physics.box2d.Fixture fixture)
minY(Shape)public static float maxX(com.badlogic.gdx.physics.box2d.Fixture fixture)
maxX(Shape)public static float maxY(com.badlogic.gdx.physics.box2d.Fixture fixture)
maxY(Shape)public static float width(com.badlogic.gdx.physics.box2d.Fixture fixture)
width(Shape)public static float height(com.badlogic.gdx.physics.box2d.Fixture fixture)
height(Shape)public static com.badlogic.gdx.math.Vector2 size(com.badlogic.gdx.physics.box2d.Fixture fixture)
size(Shape)public static com.badlogic.gdx.math.Vector2[][] fixtureVertices(com.badlogic.gdx.physics.box2d.Body body)
public static com.badlogic.gdx.math.Vector2[] vertices(com.badlogic.gdx.physics.box2d.Body body)
public static float minX(com.badlogic.gdx.physics.box2d.Body body)
public static float minY(com.badlogic.gdx.physics.box2d.Body body)
public static float maxX(com.badlogic.gdx.physics.box2d.Body body)
public static float maxY(com.badlogic.gdx.physics.box2d.Body body)
public static float width(com.badlogic.gdx.physics.box2d.Body body)
public static float height(com.badlogic.gdx.physics.box2d.Body body)
public static com.badlogic.gdx.math.Vector2 size(com.badlogic.gdx.physics.box2d.Body body)
public static com.badlogic.gdx.math.Vector2 positionRelative(com.badlogic.gdx.physics.box2d.CircleShape shape)
positionRelative(Shape, float),
CircleShape.getPosition()public static com.badlogic.gdx.math.Vector2 positionRelative(com.badlogic.gdx.physics.box2d.Shape shape,
float rotation)
public static com.badlogic.gdx.math.Vector2 position(com.badlogic.gdx.physics.box2d.Shape shape,
com.badlogic.gdx.physics.box2d.Body body)
shape - the Shape which position to getbody - the Body the given Shape is attached topublic static com.badlogic.gdx.math.Vector2 positionRelative(com.badlogic.gdx.physics.box2d.Fixture fixture)
positionRelative(Shape, float)public static com.badlogic.gdx.math.Vector2 position(com.badlogic.gdx.physics.box2d.Fixture fixture)
position(Shape, Body)public static com.badlogic.gdx.physics.box2d.Body clone(com.badlogic.gdx.physics.box2d.Body body)
Body (without deep copying the Shapes of its Fixtures)copy(body, false)clone(Body, boolean)public static com.badlogic.gdx.physics.box2d.Body clone(com.badlogic.gdx.physics.box2d.Body body,
boolean shapes)
Bodybody - the Body to copyshapes - if the Shapes of the Fixures of the given body should be copied as wellbodypublic static com.badlogic.gdx.physics.box2d.Fixture clone(com.badlogic.gdx.physics.box2d.Fixture fixture,
com.badlogic.gdx.physics.box2d.Body body)
Fixture (without deep copying its Shape)copy(fixture, body, false)clone(Fixture, Body, boolean)public static com.badlogic.gdx.physics.box2d.Fixture clone(com.badlogic.gdx.physics.box2d.Fixture fixture,
com.badlogic.gdx.physics.box2d.Body body,
boolean shape)
Fixturefixture - the Fixture to copybody - the Body to create a copy of the given fixture onshape - if the shape of the given fixture should be deep copied as wellFixturepublic static <T extends com.badlogic.gdx.physics.box2d.Shape> T clone(T shape)
Shapeprevious and next vertex of a ChainShape will not be copied since this is not possible due to the API.shape - the Shape to copyShape exactly like the one passed inpublic static com.badlogic.gdx.physics.box2d.BodyDef createDef(com.badlogic.gdx.physics.box2d.Body body)
body - the body for which to setup a new BodyDefBodyDef instance that can be used to clone the given bodypublic static com.badlogic.gdx.physics.box2d.FixtureDef createDef(com.badlogic.gdx.physics.box2d.Fixture fixture)
fixture - the fixture for which to setup a new FixtureDefFixtureDef instance that can be used to clone the given fixturepublic static boolean split(com.badlogic.gdx.physics.box2d.Body body,
com.badlogic.gdx.math.Vector2 a,
com.badlogic.gdx.math.Vector2 b,
net.dermetfan.utils.Pair<com.badlogic.gdx.physics.box2d.Body,com.badlogic.gdx.physics.box2d.Body> store)
body - the Body to splita - the first point of the segmentb - the second point of the segmentstore - The Pair to store the resulting bodies in. May be null.public static boolean split(com.badlogic.gdx.physics.box2d.Fixture fixture,
com.badlogic.gdx.math.Vector2 a,
com.badlogic.gdx.math.Vector2 b,
com.badlogic.gdx.physics.box2d.Body aBody,
com.badlogic.gdx.physics.box2d.Body bBody,
net.dermetfan.utils.Pair<com.badlogic.gdx.physics.box2d.Fixture,com.badlogic.gdx.physics.box2d.Fixture> store)
fixture - the fixture to splita - the first point of the segmentb - the second point of the segmentaBody - the body the first resulting fixture will be created onbBody - the body the second resulting fixture will be created onstore - The Pair to store the resulting fixtures in. May be null.split(Shape, Vector2, Vector2, Pair)public static boolean split(com.badlogic.gdx.physics.box2d.Fixture fixture,
com.badlogic.gdx.math.Vector2 a,
com.badlogic.gdx.math.Vector2 b,
net.dermetfan.utils.Pair<com.badlogic.gdx.physics.box2d.FixtureDef,com.badlogic.gdx.physics.box2d.FixtureDef> store)
fixture - the fixture to splita - the first point of the segmentb - the second point of the segmentstore - the Pair to store the resulting FixtureDefs insplit(Shape, Vector2, Vector2, Pair)public static <T extends com.badlogic.gdx.physics.box2d.Shape> boolean split(T shape,
com.badlogic.gdx.math.Vector2 a,
com.badlogic.gdx.math.Vector2 b,
net.dermetfan.utils.Pair<T,T> store)
shape - the Shape to splita - the first point of the segmentb - the second point of the segmentstore - the Pair to store the split Shapes inpublic static void setSensor(com.badlogic.gdx.physics.box2d.Body body,
boolean sensor)
sensor flag of all of the given Body's Fixturesbody - the Body which Fixtures' sensor flag to setsensor - the parameter to pass to Fixture.setSensor(boolean)Fixture.setSensor(boolean)public static void destroyFixtures(com.badlogic.gdx.physics.box2d.Body body)
destroys all fixtures of the given bodybody - the body which fixtures to destroypublic static void destroyFixtures(com.badlogic.gdx.physics.box2d.Body body,
com.badlogic.gdx.utils.Array<com.badlogic.gdx.physics.box2d.Fixture> exclude)
destroys all fixtures of the given body except the given onesexclude - the fixtures not to destroybody - the body which fixtures to destroypublic static void destroyFixtures(com.badlogic.gdx.physics.box2d.Body body,
com.badlogic.gdx.physics.box2d.Fixture... exclude)
destroyFixtures(Body, Array)public static void destroyFixtures(com.badlogic.gdx.physics.box2d.Body body,
com.badlogic.gdx.physics.box2d.Fixture exclude)
destroyFixtures(Body, Array)