Package net.dermetfan.gdx.physics.box2d
Class Box2DUtils
java.lang.Object
net.dermetfan.gdx.physics.box2d.Box2DUtils
public class Box2DUtils
extends java.lang.Object
provides methods for operations with Box2D
Bodies
, Fixtures
and Shapes
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Box2DUtils.PreconditionCheck
checks if Box2D's preconditions are met to avoid native crashesstatic class
Box2DUtils.Settings
b2Settings.hstatic class
Box2DUtils.ShapeCache
cached method results -
Field Summary
Fields Modifier and Type Field Description static boolean
autoCache
if shapes should automatically be cached when they are inspected for the first timestatic com.badlogic.gdx.utils.ObjectMap<com.badlogic.gdx.physics.box2d.Shape,Box2DUtils.ShapeCache>
cache
CachedShapes
and theirBox2DUtils.ShapeCache
.static Box2DUtils.PreconditionCheck
check
the PreconditionCheck to use -
Constructor Summary
Constructors Constructor Description Box2DUtils()
-
Method Summary
Modifier and Type Method Description static com.badlogic.gdx.math.Rectangle
aabb(com.badlogic.gdx.physics.box2d.Body body)
static com.badlogic.gdx.math.Rectangle
aabb(com.badlogic.gdx.physics.box2d.Body body, com.badlogic.gdx.math.Rectangle aabb)
static com.badlogic.gdx.math.Rectangle
aabb(com.badlogic.gdx.physics.box2d.Fixture fixture)
static com.badlogic.gdx.math.Rectangle
aabb(com.badlogic.gdx.physics.box2d.Fixture fixture, com.badlogic.gdx.math.Rectangle aabb)
static com.badlogic.gdx.math.Rectangle
aabb(com.badlogic.gdx.physics.box2d.Shape shape, float rotation)
static com.badlogic.gdx.math.Rectangle
aabb(com.badlogic.gdx.physics.box2d.Shape shape, float rotation, com.badlogic.gdx.math.Rectangle aabb)
static com.badlogic.gdx.math.Polyline
as(com.badlogic.gdx.physics.box2d.ChainShape shape, com.badlogic.gdx.math.Polyline polyline)
static com.badlogic.gdx.math.Circle
as(com.badlogic.gdx.physics.box2d.CircleShape shape, com.badlogic.gdx.math.Circle circle)
static com.badlogic.gdx.math.Polyline
as(com.badlogic.gdx.physics.box2d.EdgeShape shape, com.badlogic.gdx.math.Polyline polyline)
static com.badlogic.gdx.math.Circle
as(com.badlogic.gdx.physics.box2d.Fixture fixture, com.badlogic.gdx.math.Circle circle)
sets the given Circle to the Fixture's CircleShape, in world coordinatesstatic com.badlogic.gdx.math.Polygon
as(com.badlogic.gdx.physics.box2d.Fixture fixture, com.badlogic.gdx.math.Polygon polygon)
sets the given Polygon to the Fixture's PolygonShape, in world coordinatesstatic com.badlogic.gdx.math.Polyline
as(com.badlogic.gdx.physics.box2d.Fixture fixture, com.badlogic.gdx.math.Polyline polyline)
sets the given Polyline to the given Fixture's EdgeShape or ChainShape, in world coordinatesstatic com.badlogic.gdx.math.Polygon
as(com.badlogic.gdx.physics.box2d.PolygonShape shape, com.badlogic.gdx.math.Polygon polygon)
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 Bodystatic 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 Fixturestatic <T extends com.badlogic.gdx.physics.box2d.Shape>
Tclone(T shape)
creates a deep copy of a Shapestatic 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 com.badlogic.gdx.physics.box2d.JointDef
createDef(com.badlogic.gdx.physics.box2d.Joint joint)
static com.badlogic.gdx.physics.box2d.joints.DistanceJointDef
createDef(com.badlogic.gdx.physics.box2d.joints.DistanceJoint joint)
static com.badlogic.gdx.physics.box2d.joints.FrictionJointDef
createDef(com.badlogic.gdx.physics.box2d.joints.FrictionJoint joint)
static com.badlogic.gdx.physics.box2d.joints.GearJointDef
createDef(com.badlogic.gdx.physics.box2d.joints.GearJoint joint)
static com.badlogic.gdx.physics.box2d.joints.MotorJointDef
createDef(com.badlogic.gdx.physics.box2d.joints.MotorJoint joint)
static com.badlogic.gdx.physics.box2d.joints.MouseJointDef
createDef(com.badlogic.gdx.physics.box2d.joints.MouseJoint joint)
static com.badlogic.gdx.physics.box2d.joints.PrismaticJointDef
createDef(com.badlogic.gdx.physics.box2d.joints.PrismaticJoint joint)
static com.badlogic.gdx.physics.box2d.joints.PulleyJointDef
createDef(com.badlogic.gdx.physics.box2d.joints.PulleyJoint joint)
static com.badlogic.gdx.physics.box2d.joints.RevoluteJointDef
createDef(com.badlogic.gdx.physics.box2d.joints.RevoluteJoint joint)
static com.badlogic.gdx.physics.box2d.joints.RopeJointDef
createDef(com.badlogic.gdx.physics.box2d.joints.RopeJoint joint)
static com.badlogic.gdx.physics.box2d.joints.WeldJointDef
createDef(com.badlogic.gdx.physics.box2d.joints.WeldJoint joint)
static com.badlogic.gdx.physics.box2d.joints.WheelJointDef
createDef(com.badlogic.gdx.physics.box2d.joints.WheelJoint joint)
static void
destroyFixtures(com.badlogic.gdx.physics.box2d.Body body)
destroys
all fixtures of the given bodystatic 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 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 onesstatic boolean
equals(com.badlogic.gdx.physics.box2d.Filter a, com.badlogic.gdx.physics.box2d.Filter b)
static boolean
equals(com.badlogic.gdx.physics.box2d.MassData a, com.badlogic.gdx.physics.box2d.MassData b)
static boolean
equals(com.badlogic.gdx.physics.box2d.Transform a, com.badlogic.gdx.physics.box2d.Transform b)
static float[][]
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)
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)
static float
maxXWorld(com.badlogic.gdx.physics.box2d.Body body)
static float
maxXWorld(com.badlogic.gdx.physics.box2d.Fixture fixture)
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)
static float
maxYWorld(com.badlogic.gdx.physics.box2d.Body body)
static float
maxYWorld(com.badlogic.gdx.physics.box2d.Fixture fixture)
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)
static float
minXWorld(com.badlogic.gdx.physics.box2d.Body body)
static float
minXWorld(com.badlogic.gdx.physics.box2d.Fixture fixture)
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)
static float
minYWorld(com.badlogic.gdx.physics.box2d.Body body)
static float
minYWorld(com.badlogic.gdx.physics.box2d.Fixture fixture)
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 com.badlogic.gdx.physics.box2d.BodyDef
reset(com.badlogic.gdx.physics.box2d.BodyDef bodyDef)
static com.badlogic.gdx.physics.box2d.FixtureDef
reset(com.badlogic.gdx.physics.box2d.FixtureDef fixtureDef)
static com.badlogic.gdx.physics.box2d.BodyDef
set(com.badlogic.gdx.physics.box2d.BodyDef bodyDef, com.badlogic.gdx.physics.box2d.Body body)
static com.badlogic.gdx.physics.box2d.FixtureDef
set(com.badlogic.gdx.physics.box2d.FixtureDef fixtureDef, com.badlogic.gdx.physics.box2d.Fixture fixture)
static com.badlogic.gdx.physics.box2d.JointDef
set(com.badlogic.gdx.physics.box2d.JointDef jointDef, com.badlogic.gdx.physics.box2d.Joint joint)
static com.badlogic.gdx.physics.box2d.joints.DistanceJointDef
set(com.badlogic.gdx.physics.box2d.joints.DistanceJointDef jointDef, com.badlogic.gdx.physics.box2d.joints.DistanceJoint joint)
static com.badlogic.gdx.physics.box2d.joints.FrictionJointDef
set(com.badlogic.gdx.physics.box2d.joints.FrictionJointDef jointDef, com.badlogic.gdx.physics.box2d.joints.FrictionJoint joint)
static com.badlogic.gdx.physics.box2d.joints.GearJointDef
set(com.badlogic.gdx.physics.box2d.joints.GearJointDef jointDef, com.badlogic.gdx.physics.box2d.joints.GearJoint joint)
static com.badlogic.gdx.physics.box2d.joints.MotorJointDef
set(com.badlogic.gdx.physics.box2d.joints.MotorJointDef jointDef, com.badlogic.gdx.physics.box2d.joints.MotorJoint joint)
static com.badlogic.gdx.physics.box2d.joints.MouseJointDef
set(com.badlogic.gdx.physics.box2d.joints.MouseJointDef jointDef, com.badlogic.gdx.physics.box2d.joints.MouseJoint joint)
static com.badlogic.gdx.physics.box2d.joints.PrismaticJointDef
set(com.badlogic.gdx.physics.box2d.joints.PrismaticJointDef jointDef, com.badlogic.gdx.physics.box2d.joints.PrismaticJoint joint)
static com.badlogic.gdx.physics.box2d.joints.PulleyJointDef
set(com.badlogic.gdx.physics.box2d.joints.PulleyJointDef jointDef, com.badlogic.gdx.physics.box2d.joints.PulleyJoint joint)
static com.badlogic.gdx.physics.box2d.joints.RevoluteJointDef
set(com.badlogic.gdx.physics.box2d.joints.RevoluteJointDef jointDef, com.badlogic.gdx.physics.box2d.joints.RevoluteJoint joint)
static com.badlogic.gdx.physics.box2d.joints.RopeJointDef
set(com.badlogic.gdx.physics.box2d.joints.RopeJointDef jointDef, com.badlogic.gdx.physics.box2d.joints.RopeJoint joint)
static com.badlogic.gdx.physics.box2d.joints.WeldJointDef
set(com.badlogic.gdx.physics.box2d.joints.WeldJointDef jointDef, com.badlogic.gdx.physics.box2d.joints.WeldJoint joint)
Note: The reference angle cannot be set due to the Box2D API not providing it.static com.badlogic.gdx.physics.box2d.joints.WheelJointDef
set(com.badlogic.gdx.physics.box2d.joints.WheelJointDef jointDef, com.badlogic.gdx.physics.box2d.joints.WheelJoint joint)
static void
setSensor(com.badlogic.gdx.physics.box2d.Body body, boolean sensor)
sets thesensor flags
of all of the given Body's Fixturesstatic 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)
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>
booleansplit(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 Vector2sstatic float[]
toLocalVertices(float[] vertices, int offset, int length, com.badlogic.gdx.physics.box2d.Body body)
static float[]
toLocalVertices(float[] vertices, com.badlogic.gdx.physics.box2d.Body body)
static float[]
toWorldVertices(float[] vertices, int offset, int length, com.badlogic.gdx.physics.box2d.Body body)
static float[]
toWorldVertices(float[] vertices, com.badlogic.gdx.physics.box2d.Body body)
static float[]
vertices(com.badlogic.gdx.physics.box2d.Fixture fixture)
static float[]
vertices(com.badlogic.gdx.physics.box2d.Shape shape)
static int
weld(float[] vertices)
static int
weld(float[] vertices, int offset, int length)
welds the given vertices together the wayPolygonShape.set(float[])
doesstatic int
weld(com.badlogic.gdx.utils.FloatArray vertices)
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)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
cache
public static final com.badlogic.gdx.utils.ObjectMap<com.badlogic.gdx.physics.box2d.Shape,Box2DUtils.ShapeCache> cacheCachedShapes
and theirBox2DUtils.ShapeCache
. You shouldclear
this when you don't use the shapes anymore. -
autoCache
public static boolean autoCacheif shapes should automatically be cached when they are inspected for the first time -
check
the PreconditionCheck to use
-
-
Constructor Details
-
Box2DUtils
public Box2DUtils()
-
-
Method Details
-
cache
- Parameters:
shape
- the Shape to create a newBox2DUtils.ShapeCache
for that will be added tocache
-
vertices
public static float[] vertices(com.badlogic.gdx.physics.box2d.Shape shape)- Returns:
- the vertices of the given Shape
-
minX
public static float minX(com.badlogic.gdx.physics.box2d.Shape shape)- Returns:
- the minimal x value of the vertices of the given Shape
-
minY
public static float minY(com.badlogic.gdx.physics.box2d.Shape shape)- Returns:
- the minimal y value of the vertices of the given Shape
-
maxX
public static float maxX(com.badlogic.gdx.physics.box2d.Shape shape)- Returns:
- the maximal x value of the vertices of the given Shape
-
maxY
public static float maxY(com.badlogic.gdx.physics.box2d.Shape shape)- Returns:
- the maximal y value of the vertices of the given Shape
-
width
public static float width(com.badlogic.gdx.physics.box2d.Shape shape)- Returns:
- the width of the given Shape
-
height
public static float height(com.badlogic.gdx.physics.box2d.Shape shape)- Returns:
- the height of the given Shape
-
size
public static com.badlogic.gdx.math.Vector2 size(com.badlogic.gdx.physics.box2d.Shape shape)- Returns:
- a
Vector2
representing the size of the given Shape
-
vertices
public static float[] vertices(com.badlogic.gdx.physics.box2d.Fixture fixture)- See Also:
vertices(Shape)
-
minX
public static float minX(com.badlogic.gdx.physics.box2d.Fixture fixture)- See Also:
minX(Shape)
-
minY
public static float minY(com.badlogic.gdx.physics.box2d.Fixture fixture)- See Also:
minY(Shape)
-
maxX
public static float maxX(com.badlogic.gdx.physics.box2d.Fixture fixture)- See Also:
maxX(Shape)
-
maxY
public static float maxY(com.badlogic.gdx.physics.box2d.Fixture fixture)- See Also:
maxY(Shape)
-
minXWorld
public static float minXWorld(com.badlogic.gdx.physics.box2d.Fixture fixture)- Returns:
- the minimal x coordinate of the vertices of the given Fixture in world coordinates
-
minYWorld
public static float minYWorld(com.badlogic.gdx.physics.box2d.Fixture fixture)- Returns:
- the minimal y coordinate of the vertices of the given Fixture in world coordinates
-
maxXWorld
public static float maxXWorld(com.badlogic.gdx.physics.box2d.Fixture fixture)- Returns:
- the maximal x coordinate of the vertices of the given Fixture in world coordinates
-
maxYWorld
public static float maxYWorld(com.badlogic.gdx.physics.box2d.Fixture fixture)- Returns:
- the maximal y coordinate of the vertices of the given Fixture in world coordinates
-
width
public static float width(com.badlogic.gdx.physics.box2d.Fixture fixture)- See Also:
width(Shape)
-
height
public static float height(com.badlogic.gdx.physics.box2d.Fixture fixture)- See Also:
height(Shape)
-
size
public static com.badlogic.gdx.math.Vector2 size(com.badlogic.gdx.physics.box2d.Fixture fixture)- See Also:
size(Shape)
-
fixtureVertices
public static float[][] fixtureVertices(com.badlogic.gdx.physics.box2d.Body body)- Returns:
- the vertices of all fixtures of a body
-
minX
public static float minX(com.badlogic.gdx.physics.box2d.Body body)- Returns:
- the minimal x value of the vertices of all fixtures of the the given Body
-
minY
public static float minY(com.badlogic.gdx.physics.box2d.Body body)- Returns:
- the minimal y value of the vertices of all fixtures of the the given Body
-
maxX
public static float maxX(com.badlogic.gdx.physics.box2d.Body body)- Returns:
- the maximal x value of the vertices of all fixtures of the the given Body
-
maxY
public static float maxY(com.badlogic.gdx.physics.box2d.Body body)- Returns:
- the maximal y value of the vertices of all fixtures of the the given Body
-
minXWorld
public static float minXWorld(com.badlogic.gdx.physics.box2d.Body body)- Returns:
- the minimal x coordinate of the vertices of all fixtures of the given Body in world coordinates
-
minYWorld
public static float minYWorld(com.badlogic.gdx.physics.box2d.Body body)- Returns:
- the minimal y coordinate of the vertices of all fixtures of the given Body in world coordinates
-
maxXWorld
public static float maxXWorld(com.badlogic.gdx.physics.box2d.Body body)- Returns:
- the maximal x coordinate of the vertices of all fixtures of the given Body in world coordinates
-
maxYWorld
public static float maxYWorld(com.badlogic.gdx.physics.box2d.Body body)- Returns:
- the maximal y coordinate of the vertices of all fixtures of the given Body in world coordinates
-
width
public static float width(com.badlogic.gdx.physics.box2d.Body body)- Returns:
- the width of the given Body
-
height
public static float height(com.badlogic.gdx.physics.box2d.Body body)- Returns:
- the height of the given Body
-
size
public static com.badlogic.gdx.math.Vector2 size(com.badlogic.gdx.physics.box2d.Body body) -
positionRelative
public static com.badlogic.gdx.math.Vector2 positionRelative(com.badlogic.gdx.physics.box2d.CircleShape shape)- See Also:
positionRelative(Shape, float)
,CircleShape.getPosition()
-
positionRelative
public static com.badlogic.gdx.math.Vector2 positionRelative(com.badlogic.gdx.physics.box2d.Shape shape, float rotation)- Returns:
- the position of the given shape relative to its Body
-
position
public static com.badlogic.gdx.math.Vector2 position(com.badlogic.gdx.physics.box2d.Shape shape, com.badlogic.gdx.physics.box2d.Body body)- Parameters:
shape
- the Shape which position to getbody
- the Body the given Shape is attached to- Returns:
- the position of the given Shape in world coordinates
-
positionRelative
public static com.badlogic.gdx.math.Vector2 positionRelative(com.badlogic.gdx.physics.box2d.Fixture fixture)- See Also:
positionRelative(Shape, float)
-
position
public static com.badlogic.gdx.math.Vector2 position(com.badlogic.gdx.physics.box2d.Fixture fixture)- See Also:
position(Shape, Body)
-
aabb
public static com.badlogic.gdx.math.Rectangle aabb(com.badlogic.gdx.physics.box2d.Shape shape, float rotation, com.badlogic.gdx.math.Rectangle aabb)- Parameters:
shape
- the Shape which AABB to getaabb
- the Rectangle to set to the given Shape's AABB- Returns:
- the given Rectangle set as axis aligned bounding box of the given Shape
- Since:
- 0.9.1
-
aabb
public static com.badlogic.gdx.math.Rectangle aabb(com.badlogic.gdx.physics.box2d.Shape shape, float rotation)- See Also:
aabb(Shape, float, Rectangle)
-
aabb
public static com.badlogic.gdx.math.Rectangle aabb(com.badlogic.gdx.physics.box2d.Fixture fixture, com.badlogic.gdx.math.Rectangle aabb)- Returns:
- the given Rectangle set as axis aligned bounding box of the given Fixture, in world coordinates
- See Also:
aabb(Shape, float, Rectangle)
-
aabb
public static com.badlogic.gdx.math.Rectangle aabb(com.badlogic.gdx.physics.box2d.Fixture fixture)- See Also:
aabb(Fixture, Rectangle)
-
aabb
public static com.badlogic.gdx.math.Rectangle aabb(com.badlogic.gdx.physics.box2d.Body body, com.badlogic.gdx.math.Rectangle aabb)- Returns:
- the given Rectangle set as axis aligned bounding box of all fixtures of the given Body, in world coordinates
- Since:
- 0.9.1
-
aabb
public static com.badlogic.gdx.math.Rectangle aabb(com.badlogic.gdx.physics.box2d.Body body)- See Also:
aabb(Body, Rectangle)
-
clone
public 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)- Returns:
copy(body, false)
- See Also:
clone(Body, boolean)
-
clone
public static com.badlogic.gdx.physics.box2d.Body clone(com.badlogic.gdx.physics.box2d.Body body, boolean shapes)clones a Body- Parameters:
body
- the Body to copyshapes
- if the Shapes of the Fixtures of the given Body should becopied
as well- Returns:
- a deep copy of the given Body
-
clone
public 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)- Returns:
copy(fixture, body, false)
- See Also:
clone(Fixture, Body, boolean)
-
clone
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)clones a Fixture- Parameters:
fixture
- the Fixture to copybody
- the Body to create a copy of the givenfixture
onshape
- if theshape
of the given Fixture should be deepcopied
as well- Returns:
- the copied Fixture
-
clone
public static <T extends com.badlogic.gdx.physics.box2d.Shape> T clone(T shape)creates a deep copy of a Shape- Parameters:
shape
- the Shape to clone- Returns:
- a Shape exactly like the one passed in
-
clone
public static <T extends com.badlogic.gdx.physics.box2d.Joint> T clone(T joint)- Parameters:
joint
- the joint to clone- Since:
- 0.7.1
-
set
public static com.badlogic.gdx.physics.box2d.BodyDef set(com.badlogic.gdx.physics.box2d.BodyDef bodyDef, com.badlogic.gdx.physics.box2d.Body body)- Parameters:
bodyDef
- the BodyDef to set according to the given Bodybody
- the Body to set the given BodyDef accordingly to- Returns:
- the given BodyDef for chaining
- Since:
- 0.7.1
-
set
public static com.badlogic.gdx.physics.box2d.FixtureDef set(com.badlogic.gdx.physics.box2d.FixtureDef fixtureDef, com.badlogic.gdx.physics.box2d.Fixture fixture)- Parameters:
fixtureDef
- the FixtureDef to set according to the given Fixturefixture
- the Fixture to set the given FixtureDef accordingly to- Returns:
- the given FixtureDef for chaining
- Since:
- 0.7.1
-
set
public static com.badlogic.gdx.physics.box2d.JointDef set(com.badlogic.gdx.physics.box2d.JointDef jointDef, com.badlogic.gdx.physics.box2d.Joint joint)- Parameters:
jointDef
- the JointDef to set according to the given Jointjoint
- the Joint to set the given JointDef accordingly to- Returns:
- the given JointDef for chaining
- Since:
- 0.7.1
-
set
public static com.badlogic.gdx.physics.box2d.joints.DistanceJointDef set(com.badlogic.gdx.physics.box2d.joints.DistanceJointDef jointDef, com.badlogic.gdx.physics.box2d.joints.DistanceJoint joint)- See Also:
set(JointDef, Joint)
-
set
public static com.badlogic.gdx.physics.box2d.joints.FrictionJointDef set(com.badlogic.gdx.physics.box2d.joints.FrictionJointDef jointDef, com.badlogic.gdx.physics.box2d.joints.FrictionJoint joint)- See Also:
set(JointDef, Joint)
-
set
public static com.badlogic.gdx.physics.box2d.joints.GearJointDef set(com.badlogic.gdx.physics.box2d.joints.GearJointDef jointDef, com.badlogic.gdx.physics.box2d.joints.GearJoint joint)- See Also:
set(JointDef, Joint)
-
set
public static com.badlogic.gdx.physics.box2d.joints.MotorJointDef set(com.badlogic.gdx.physics.box2d.joints.MotorJointDef jointDef, com.badlogic.gdx.physics.box2d.joints.MotorJoint joint)- See Also:
set(JointDef, Joint)
-
set
public static com.badlogic.gdx.physics.box2d.joints.MouseJointDef set(com.badlogic.gdx.physics.box2d.joints.MouseJointDef jointDef, com.badlogic.gdx.physics.box2d.joints.MouseJoint joint)- See Also:
set(JointDef, Joint)
-
set
public static com.badlogic.gdx.physics.box2d.joints.RevoluteJointDef set(com.badlogic.gdx.physics.box2d.joints.RevoluteJointDef jointDef, com.badlogic.gdx.physics.box2d.joints.RevoluteJoint joint)- See Also:
set(JointDef, Joint)
-
set
public static com.badlogic.gdx.physics.box2d.joints.PrismaticJointDef set(com.badlogic.gdx.physics.box2d.joints.PrismaticJointDef jointDef, com.badlogic.gdx.physics.box2d.joints.PrismaticJoint joint)- See Also:
set(JointDef, Joint)
-
set
public static com.badlogic.gdx.physics.box2d.joints.PulleyJointDef set(com.badlogic.gdx.physics.box2d.joints.PulleyJointDef jointDef, com.badlogic.gdx.physics.box2d.joints.PulleyJoint joint)- See Also:
set(JointDef, Joint)
-
set
public static com.badlogic.gdx.physics.box2d.joints.WheelJointDef set(com.badlogic.gdx.physics.box2d.joints.WheelJointDef jointDef, com.badlogic.gdx.physics.box2d.joints.WheelJoint joint)- See Also:
set(JointDef, Joint)
-
set
public static com.badlogic.gdx.physics.box2d.joints.WeldJointDef set(com.badlogic.gdx.physics.box2d.joints.WeldJointDef jointDef, com.badlogic.gdx.physics.box2d.joints.WeldJoint joint)Note: The reference angle cannot be set due to the Box2D API not providing it.- See Also:
set(JointDef, Joint)
-
set
public static com.badlogic.gdx.physics.box2d.joints.RopeJointDef set(com.badlogic.gdx.physics.box2d.joints.RopeJointDef jointDef, com.badlogic.gdx.physics.box2d.joints.RopeJoint joint)- See Also:
set(JointDef, Joint)
-
createDef
public static com.badlogic.gdx.physics.box2d.BodyDef createDef(com.badlogic.gdx.physics.box2d.Body body)- Parameters:
body
- the body for which to setup a newBodyDef
- Returns:
- a new
BodyDef
instance that can be used to clone the given body
-
createDef
public static com.badlogic.gdx.physics.box2d.FixtureDef createDef(com.badlogic.gdx.physics.box2d.Fixture fixture)- Parameters:
fixture
- the fixture for which to setup a newFixtureDef
- Returns:
- a new
FixtureDef
instance that can be used to clone the given fixture
-
createDef
public static com.badlogic.gdx.physics.box2d.JointDef createDef(com.badlogic.gdx.physics.box2d.Joint joint)- Parameters:
joint
- the joint for which to create a new JointDef- Returns:
- a new JointDef instance that can be used to clone the given joint
- Since:
- 0.7.1
-
createDef
public static com.badlogic.gdx.physics.box2d.joints.DistanceJointDef createDef(com.badlogic.gdx.physics.box2d.joints.DistanceJoint joint)- See Also:
createDef(Joint)
-
createDef
public static com.badlogic.gdx.physics.box2d.joints.FrictionJointDef createDef(com.badlogic.gdx.physics.box2d.joints.FrictionJoint joint)- See Also:
createDef(Joint)
-
createDef
public static com.badlogic.gdx.physics.box2d.joints.GearJointDef createDef(com.badlogic.gdx.physics.box2d.joints.GearJoint joint)- See Also:
createDef(Joint)
-
createDef
public static com.badlogic.gdx.physics.box2d.joints.MotorJointDef createDef(com.badlogic.gdx.physics.box2d.joints.MotorJoint joint)- See Also:
createDef(Joint)
-
createDef
public static com.badlogic.gdx.physics.box2d.joints.MouseJointDef createDef(com.badlogic.gdx.physics.box2d.joints.MouseJoint joint)- See Also:
createDef(Joint)
-
createDef
public static com.badlogic.gdx.physics.box2d.joints.RevoluteJointDef createDef(com.badlogic.gdx.physics.box2d.joints.RevoluteJoint joint)- See Also:
createDef(Joint)
-
createDef
public static com.badlogic.gdx.physics.box2d.joints.PrismaticJointDef createDef(com.badlogic.gdx.physics.box2d.joints.PrismaticJoint joint)- See Also:
createDef(Joint)
-
createDef
public static com.badlogic.gdx.physics.box2d.joints.PulleyJointDef createDef(com.badlogic.gdx.physics.box2d.joints.PulleyJoint joint)- See Also:
createDef(Joint)
-
createDef
public static com.badlogic.gdx.physics.box2d.joints.WheelJointDef createDef(com.badlogic.gdx.physics.box2d.joints.WheelJoint joint)- See Also:
createDef(Joint)
-
createDef
public static com.badlogic.gdx.physics.box2d.joints.WeldJointDef createDef(com.badlogic.gdx.physics.box2d.joints.WeldJoint joint)- See Also:
createDef(Joint)
-
createDef
public static com.badlogic.gdx.physics.box2d.joints.RopeJointDef createDef(com.badlogic.gdx.physics.box2d.joints.RopeJoint joint)- See Also:
createDef(Joint)
-
split
public 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)- Parameters:
body
- the Body to splita
- the first point of the segmentb
- the second point of the segmentstore
- ThePair
to store the resulting bodies in. May be null.- Returns:
- If the body was successfully split, which means that all fixtures intersecting with the given segment were split. If false, only some fixtures may have been created!
-
split
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)- Parameters:
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 on. No fixture will be created if this is null.bBody
- The body the second resulting fixture will be created on. No fixture will be created if this is null.store
- ThePair
to store the resulting fixtures in. May be null.- Returns:
- if the fixture was split
- See Also:
split(Shape, Vector2, Vector2, Pair)
-
split
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)- Parameters:
fixture
- the fixture to splita
- the first point of the segmentb
- the second point of the segmentstore
- thePair
to store the resultingFixtureDefs
in- Returns:
- if the fixture was split
- See Also:
split(Shape, Vector2, Vector2, Pair)
-
split
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)splits the given Shape using the segment described by the two given Vector2s- Parameters:
shape
- the Shape to splita
- The first point of the segment. Will be set to the first intersection with the given shape.b
- The second point of the segment. Will be set to the second intersection with the given shape.store
- thePair
to store the split Shapes in- Returns:
- if the given shape was split
-
weld
public static int weld(com.badlogic.gdx.utils.FloatArray vertices)- See Also:
weld(float[], int, int)
-
weld
public static int weld(float[] vertices)- See Also:
weld(float[], int, int)
-
weld
public static int weld(float[] vertices, int offset, int length)welds the given vertices together the wayPolygonShape.set(float[])
does- Returns:
- the new number of vertices (starting at offset)
-
as
public static com.badlogic.gdx.math.Circle as(com.badlogic.gdx.physics.box2d.CircleShape shape, com.badlogic.gdx.math.Circle circle)- Parameters:
circle
- the Circle to set according to the given shape- Returns:
- the given Circle for chaining
- Since:
- 0.11.1
-
as
public static com.badlogic.gdx.math.Polygon as(com.badlogic.gdx.physics.box2d.PolygonShape shape, com.badlogic.gdx.math.Polygon polygon)- Parameters:
polygon
- the Polygon which vertices to set according to the given shape- Returns:
- the given Polygon for chaining
- Since:
- 0.11.1
-
as
public static com.badlogic.gdx.math.Polyline as(com.badlogic.gdx.physics.box2d.EdgeShape shape, com.badlogic.gdx.math.Polyline polyline)- Parameters:
polyline
- the Polyline which vertices to set according to the given shape- Returns:
- the given Polyline for chaining
- Since:
- 0.11.1
-
as
public static com.badlogic.gdx.math.Polyline as(com.badlogic.gdx.physics.box2d.ChainShape shape, com.badlogic.gdx.math.Polyline polyline)- Parameters:
polyline
- the Polyline which vertices to set according to the given shape- Returns:
- the given Polyline for chaining
- Since:
- 0.11.1
-
as
public static com.badlogic.gdx.math.Circle as(com.badlogic.gdx.physics.box2d.Fixture fixture, com.badlogic.gdx.math.Circle circle)sets the given Circle to the Fixture's CircleShape, in world coordinates- Throws:
java.lang.IllegalArgumentException
- if the Fixture's Shape is not ofShape.Type.Circle
- Since:
- 0.11.1
- See Also:
as(CircleShape, Circle)
-
as
public static com.badlogic.gdx.math.Polygon as(com.badlogic.gdx.physics.box2d.Fixture fixture, com.badlogic.gdx.math.Polygon polygon)sets the given Polygon to the Fixture's PolygonShape, in world coordinates- Throws:
java.lang.IllegalArgumentException
- if the Fixture's Shape is not ofShape.Type.Polygon
- Since:
- 0.11.1
- See Also:
as(PolygonShape, Polygon)
-
as
public static com.badlogic.gdx.math.Polyline as(com.badlogic.gdx.physics.box2d.Fixture fixture, com.badlogic.gdx.math.Polyline polyline)sets the given Polyline to the given Fixture's EdgeShape or ChainShape, in world coordinates- Throws:
java.lang.IllegalArgumentException
- if the Fixture's Shape is neither ofShape.Type.Edge
norShape.Type.Chain
- Since:
- 0.11.1
- See Also:
as(EdgeShape, Polyline)
,as(ChainShape, Polyline)
-
toWorldVertices
public static float[] toWorldVertices(float[] vertices, int offset, int length, com.badlogic.gdx.physics.box2d.Body body)- Parameters:
vertices
- the local vertices to convert to world verticesbody
- the Body relative to which the given vertices are local- Returns:
- the given vertices for chaining, converted to world vertices
-
toWorldVertices
public static float[] toWorldVertices(float[] vertices, com.badlogic.gdx.physics.box2d.Body body)- See Also:
toWorldVertices(float[], int, int, Body)
-
toLocalVertices
public static float[] toLocalVertices(float[] vertices, int offset, int length, com.badlogic.gdx.physics.box2d.Body body)- Parameters:
vertices
- the world vertices to convert to local verticesbody
- the Body in which local coordinate system to convert the vertices- Returns:
- the given vertices for chaining, converted to local vertices
-
toLocalVertices
public static float[] toLocalVertices(float[] vertices, com.badlogic.gdx.physics.box2d.Body body)- See Also:
toLocalVertices(float[], int, int, Body)
-
equals
public static boolean equals(com.badlogic.gdx.physics.box2d.Transform a, com.badlogic.gdx.physics.box2d.Transform b)- Returns:
- whether the two given Transforms
values
equal - Since:
- 0.7.1
-
equals
public static boolean equals(com.badlogic.gdx.physics.box2d.MassData a, com.badlogic.gdx.physics.box2d.MassData b)- Returns:
- whether the two MassDatas values equal
- Since:
- 0.7.1
-
equals
public static boolean equals(com.badlogic.gdx.physics.box2d.Filter a, com.badlogic.gdx.physics.box2d.Filter b)- Returns:
- whether the two Filters values equal
- Since:
- 0.7.1
-
setSensor
public static void setSensor(com.badlogic.gdx.physics.box2d.Body body, boolean sensor)sets thesensor flags
of all of the given Body's Fixtures- Parameters:
body
- theBody
whichFixtures'
sensor flags to setsensor
- the parameter to pass toFixture.setSensor(boolean)
- See Also:
Fixture.setSensor(boolean)
-
destroyFixtures
public static void destroyFixtures(com.badlogic.gdx.physics.box2d.Body body)destroys
all fixtures of the given body- Parameters:
body
- the body which fixtures to destroy
-
destroyFixtures
public 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- Parameters:
exclude
- the fixtures not to destroybody
- the body which fixtures to destroy
-
destroyFixtures
public static void destroyFixtures(com.badlogic.gdx.physics.box2d.Body body, com.badlogic.gdx.physics.box2d.Fixture... exclude)- See Also:
destroyFixtures(Body, Array)
-
destroyFixtures
public static void destroyFixtures(com.badlogic.gdx.physics.box2d.Body body, com.badlogic.gdx.physics.box2d.Fixture exclude)- See Also:
destroyFixtures(Body, Array)
-
reset
public static com.badlogic.gdx.physics.box2d.BodyDef reset(com.badlogic.gdx.physics.box2d.BodyDef bodyDef)- Parameters:
bodyDef
- the BodyDef to reset to default values- Returns:
- the given BodyDef for chaining
- Since:
- 0.9.1
-
reset
public static com.badlogic.gdx.physics.box2d.FixtureDef reset(com.badlogic.gdx.physics.box2d.FixtureDef fixtureDef)- Parameters:
fixtureDef
- the FixtureDef to reset to default values- Returns:
- the given FixtureDef for chaining
- Since:
- 0.9.1
-