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 classBox2DUtils.PreconditionCheckchecks if Box2D's preconditions are met to avoid native crashesstatic classBox2DUtils.Settingsb2Settings.hstatic classBox2DUtils.ShapeCachecached method results -
Field Summary
Fields Modifier and Type Field Description static booleanautoCacheif 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>cacheCachedShapesand theirBox2DUtils.ShapeCache.static Box2DUtils.PreconditionCheckcheckthe PreconditionCheck to use -
Constructor Summary
Constructors Constructor Description Box2DUtils() -
Method Summary
Modifier and Type Method Description static com.badlogic.gdx.math.Rectangleaabb(com.badlogic.gdx.physics.box2d.Body body)static com.badlogic.gdx.math.Rectangleaabb(com.badlogic.gdx.physics.box2d.Body body, com.badlogic.gdx.math.Rectangle aabb)static com.badlogic.gdx.math.Rectangleaabb(com.badlogic.gdx.physics.box2d.Fixture fixture)static com.badlogic.gdx.math.Rectangleaabb(com.badlogic.gdx.physics.box2d.Fixture fixture, com.badlogic.gdx.math.Rectangle aabb)static com.badlogic.gdx.math.Rectangleaabb(com.badlogic.gdx.physics.box2d.Shape shape, float rotation)static com.badlogic.gdx.math.Rectangleaabb(com.badlogic.gdx.physics.box2d.Shape shape, float rotation, com.badlogic.gdx.math.Rectangle aabb)static com.badlogic.gdx.math.Polylineas(com.badlogic.gdx.physics.box2d.ChainShape shape, com.badlogic.gdx.math.Polyline polyline)static com.badlogic.gdx.math.Circleas(com.badlogic.gdx.physics.box2d.CircleShape shape, com.badlogic.gdx.math.Circle circle)static com.badlogic.gdx.math.Polylineas(com.badlogic.gdx.physics.box2d.EdgeShape shape, com.badlogic.gdx.math.Polyline polyline)static com.badlogic.gdx.math.Circleas(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.Polygonas(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.Polylineas(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.Polygonas(com.badlogic.gdx.physics.box2d.PolygonShape shape, com.badlogic.gdx.math.Polygon polygon)static Box2DUtils.ShapeCachecache(com.badlogic.gdx.physics.box2d.Shape shape)static com.badlogic.gdx.physics.box2d.Bodyclone(com.badlogic.gdx.physics.box2d.Body body)clones a Body (without deep copying the Shapes of its Fixtures)static com.badlogic.gdx.physics.box2d.Bodyclone(com.badlogic.gdx.physics.box2d.Body body, boolean shapes)clones a Bodystatic com.badlogic.gdx.physics.box2d.Fixtureclone(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.Fixtureclone(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.BodyDefcreateDef(com.badlogic.gdx.physics.box2d.Body body)static com.badlogic.gdx.physics.box2d.FixtureDefcreateDef(com.badlogic.gdx.physics.box2d.Fixture fixture)static com.badlogic.gdx.physics.box2d.JointDefcreateDef(com.badlogic.gdx.physics.box2d.Joint joint)static com.badlogic.gdx.physics.box2d.joints.DistanceJointDefcreateDef(com.badlogic.gdx.physics.box2d.joints.DistanceJoint joint)static com.badlogic.gdx.physics.box2d.joints.FrictionJointDefcreateDef(com.badlogic.gdx.physics.box2d.joints.FrictionJoint joint)static com.badlogic.gdx.physics.box2d.joints.GearJointDefcreateDef(com.badlogic.gdx.physics.box2d.joints.GearJoint joint)static com.badlogic.gdx.physics.box2d.joints.MotorJointDefcreateDef(com.badlogic.gdx.physics.box2d.joints.MotorJoint joint)static com.badlogic.gdx.physics.box2d.joints.MouseJointDefcreateDef(com.badlogic.gdx.physics.box2d.joints.MouseJoint joint)static com.badlogic.gdx.physics.box2d.joints.PrismaticJointDefcreateDef(com.badlogic.gdx.physics.box2d.joints.PrismaticJoint joint)static com.badlogic.gdx.physics.box2d.joints.PulleyJointDefcreateDef(com.badlogic.gdx.physics.box2d.joints.PulleyJoint joint)static com.badlogic.gdx.physics.box2d.joints.RevoluteJointDefcreateDef(com.badlogic.gdx.physics.box2d.joints.RevoluteJoint joint)static com.badlogic.gdx.physics.box2d.joints.RopeJointDefcreateDef(com.badlogic.gdx.physics.box2d.joints.RopeJoint joint)static com.badlogic.gdx.physics.box2d.joints.WeldJointDefcreateDef(com.badlogic.gdx.physics.box2d.joints.WeldJoint joint)static com.badlogic.gdx.physics.box2d.joints.WheelJointDefcreateDef(com.badlogic.gdx.physics.box2d.joints.WheelJoint joint)static voiddestroyFixtures(com.badlogic.gdx.physics.box2d.Body body)destroysall fixtures of the given bodystatic voiddestroyFixtures(com.badlogic.gdx.physics.box2d.Body body, com.badlogic.gdx.physics.box2d.Fixture exclude)static voiddestroyFixtures(com.badlogic.gdx.physics.box2d.Body body, com.badlogic.gdx.physics.box2d.Fixture... exclude)static voiddestroyFixtures(com.badlogic.gdx.physics.box2d.Body body, com.badlogic.gdx.utils.Array<com.badlogic.gdx.physics.box2d.Fixture> exclude)destroysall fixtures of the given body except the given onesstatic booleanequals(com.badlogic.gdx.physics.box2d.Filter a, com.badlogic.gdx.physics.box2d.Filter b)static booleanequals(com.badlogic.gdx.physics.box2d.MassData a, com.badlogic.gdx.physics.box2d.MassData b)static booleanequals(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 floatheight(com.badlogic.gdx.physics.box2d.Body body)static floatheight(com.badlogic.gdx.physics.box2d.Fixture fixture)static floatheight(com.badlogic.gdx.physics.box2d.Shape shape)static floatmaxX(com.badlogic.gdx.physics.box2d.Body body)static floatmaxX(com.badlogic.gdx.physics.box2d.Fixture fixture)static floatmaxX(com.badlogic.gdx.physics.box2d.Shape shape)static floatmaxXWorld(com.badlogic.gdx.physics.box2d.Body body)static floatmaxXWorld(com.badlogic.gdx.physics.box2d.Fixture fixture)static floatmaxY(com.badlogic.gdx.physics.box2d.Body body)static floatmaxY(com.badlogic.gdx.physics.box2d.Fixture fixture)static floatmaxY(com.badlogic.gdx.physics.box2d.Shape shape)static floatmaxYWorld(com.badlogic.gdx.physics.box2d.Body body)static floatmaxYWorld(com.badlogic.gdx.physics.box2d.Fixture fixture)static floatminX(com.badlogic.gdx.physics.box2d.Body body)static floatminX(com.badlogic.gdx.physics.box2d.Fixture fixture)static floatminX(com.badlogic.gdx.physics.box2d.Shape shape)static floatminXWorld(com.badlogic.gdx.physics.box2d.Body body)static floatminXWorld(com.badlogic.gdx.physics.box2d.Fixture fixture)static floatminY(com.badlogic.gdx.physics.box2d.Body body)static floatminY(com.badlogic.gdx.physics.box2d.Fixture fixture)static floatminY(com.badlogic.gdx.physics.box2d.Shape shape)static floatminYWorld(com.badlogic.gdx.physics.box2d.Body body)static floatminYWorld(com.badlogic.gdx.physics.box2d.Fixture fixture)static com.badlogic.gdx.math.Vector2position(com.badlogic.gdx.physics.box2d.Fixture fixture)static com.badlogic.gdx.math.Vector2position(com.badlogic.gdx.physics.box2d.Shape shape, com.badlogic.gdx.physics.box2d.Body body)static com.badlogic.gdx.math.Vector2positionRelative(com.badlogic.gdx.physics.box2d.CircleShape shape)static com.badlogic.gdx.math.Vector2positionRelative(com.badlogic.gdx.physics.box2d.Fixture fixture)static com.badlogic.gdx.math.Vector2positionRelative(com.badlogic.gdx.physics.box2d.Shape shape, float rotation)static com.badlogic.gdx.physics.box2d.BodyDefreset(com.badlogic.gdx.physics.box2d.BodyDef bodyDef)static com.badlogic.gdx.physics.box2d.FixtureDefreset(com.badlogic.gdx.physics.box2d.FixtureDef fixtureDef)static com.badlogic.gdx.physics.box2d.BodyDefset(com.badlogic.gdx.physics.box2d.BodyDef bodyDef, com.badlogic.gdx.physics.box2d.Body body)static com.badlogic.gdx.physics.box2d.FixtureDefset(com.badlogic.gdx.physics.box2d.FixtureDef fixtureDef, com.badlogic.gdx.physics.box2d.Fixture fixture)static com.badlogic.gdx.physics.box2d.JointDefset(com.badlogic.gdx.physics.box2d.JointDef jointDef, com.badlogic.gdx.physics.box2d.Joint joint)static com.badlogic.gdx.physics.box2d.joints.DistanceJointDefset(com.badlogic.gdx.physics.box2d.joints.DistanceJointDef jointDef, com.badlogic.gdx.physics.box2d.joints.DistanceJoint joint)static com.badlogic.gdx.physics.box2d.joints.FrictionJointDefset(com.badlogic.gdx.physics.box2d.joints.FrictionJointDef jointDef, com.badlogic.gdx.physics.box2d.joints.FrictionJoint joint)static com.badlogic.gdx.physics.box2d.joints.GearJointDefset(com.badlogic.gdx.physics.box2d.joints.GearJointDef jointDef, com.badlogic.gdx.physics.box2d.joints.GearJoint joint)static com.badlogic.gdx.physics.box2d.joints.MotorJointDefset(com.badlogic.gdx.physics.box2d.joints.MotorJointDef jointDef, com.badlogic.gdx.physics.box2d.joints.MotorJoint joint)static com.badlogic.gdx.physics.box2d.joints.MouseJointDefset(com.badlogic.gdx.physics.box2d.joints.MouseJointDef jointDef, com.badlogic.gdx.physics.box2d.joints.MouseJoint joint)static com.badlogic.gdx.physics.box2d.joints.PrismaticJointDefset(com.badlogic.gdx.physics.box2d.joints.PrismaticJointDef jointDef, com.badlogic.gdx.physics.box2d.joints.PrismaticJoint joint)static com.badlogic.gdx.physics.box2d.joints.PulleyJointDefset(com.badlogic.gdx.physics.box2d.joints.PulleyJointDef jointDef, com.badlogic.gdx.physics.box2d.joints.PulleyJoint joint)static com.badlogic.gdx.physics.box2d.joints.RevoluteJointDefset(com.badlogic.gdx.physics.box2d.joints.RevoluteJointDef jointDef, com.badlogic.gdx.physics.box2d.joints.RevoluteJoint joint)static com.badlogic.gdx.physics.box2d.joints.RopeJointDefset(com.badlogic.gdx.physics.box2d.joints.RopeJointDef jointDef, com.badlogic.gdx.physics.box2d.joints.RopeJoint joint)static com.badlogic.gdx.physics.box2d.joints.WeldJointDefset(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.WheelJointDefset(com.badlogic.gdx.physics.box2d.joints.WheelJointDef jointDef, com.badlogic.gdx.physics.box2d.joints.WheelJoint joint)static voidsetSensor(com.badlogic.gdx.physics.box2d.Body body, boolean sensor)sets thesensor flagsof all of the given Body's Fixturesstatic com.badlogic.gdx.math.Vector2size(com.badlogic.gdx.physics.box2d.Body body)static com.badlogic.gdx.math.Vector2size(com.badlogic.gdx.physics.box2d.Fixture fixture)static com.badlogic.gdx.math.Vector2size(com.badlogic.gdx.physics.box2d.Shape shape)static booleansplit(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 booleansplit(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 booleansplit(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 intweld(float[] vertices)static intweld(float[] vertices, int offset, int length)welds the given vertices together the wayPolygonShape.set(float[])doesstatic intweld(com.badlogic.gdx.utils.FloatArray vertices)static floatwidth(com.badlogic.gdx.physics.box2d.Body body)static floatwidth(com.badlogic.gdx.physics.box2d.Fixture fixture)static floatwidth(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> cacheCachedShapesand theirBox2DUtils.ShapeCache. You shouldclearthis 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.ShapeCachefor 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
Vector2representing 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 becopiedas 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 givenfixtureonshape- if theshapeof the given Fixture should be deepcopiedas 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
BodyDefinstance 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
FixtureDefinstance 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- ThePairto 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- ThePairto 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- thePairto store the resultingFixtureDefsin- 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- thePairto 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.EdgenorShape.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
valuesequal - 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 flagsof all of the given Body's Fixtures- Parameters:
body- theBodywhichFixtures'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)destroysall 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)destroysall 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
-