- Object
-
- ContactConstraint<T>
-
- Type Parameters:
T
- ThePhysicsBody
type
- All Implemented Interfaces:
Shiftable
public final class ContactConstraint<T extends PhysicsBody> extends Object implements Shiftable
Represents aSolvableContact
constraint for eachPhysicsBody
pair.- Since:
- 1.0.0
- Version:
- 4.0.0
- Author:
- William Bittle
-
-
Constructor Summary
Constructors Constructor Description ContactConstraint(CollisionPair<T,BodyFixture> pair)
Full constructor.ContactConstraint(CollisionPair<T,BodyFixture> pair, Manifold manifold, double friction, double restitution)
Deprecated.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description T
getBody(CollisionBody<?> body)
Returns the body that matches the given body.T
getBody1()
Returns the firstPhysicsBody
.T
getBody2()
Returns the secondPhysicsBody
.CollisionPair<T,BodyFixture>
getCollisionPair()
Returns theCollisionPair
.List<? extends SolvedContact>
getContacts()
Returns the list ofSolvableContact
s.BodyFixture
getFixture(CollisionBody<?> body)
Returns the fixture for the body that matches the given body.BodyFixture
getFixture1()
Returns the firstPhysicsBody
'sBodyFixture
.BodyFixture
getFixture2()
Returns the secondPhysicsBody
'sBodyFixture
.double
getFriction()
Returns the coefficient of friction for this contact constraint.ContactConstraintId
getId()
Deprecated.Deprecated in 4.0.0.Vector2
getNormal()
Returns the collision normal.T
getOtherBody(CollisionBody<?> body)
Returns the body that does not match the given body.BodyFixture
getOtherFixture(CollisionBody<?> body)
Returns the fixture for the body that does not match the given body.double
getRestitution()
Returns the coefficient of restitution for this contact constraint.Vector2
getTangent()
Returns the collision tangent.double
getTangentSpeed()
Returns the surface speed of the contact constraint.boolean
isEnabled()
Returns true if this contact constraint is enabled for processing by the collision resolution step.boolean
isOnIsland()
Deprecated.Deprecated in 4.0.0.boolean
isSensor()
Returns true if thisContactConstraint
is a sensor.void
setEnabled(boolean flag)
Sets the enabled flag.void
setFriction(double friction)
Sets the coefficient of friction for this contact constraint.void
setOnIsland(boolean flag)
Deprecated.Deprecated in 4.0.0.void
setRestitution(double restitution)
Sets the coefficient of restitution for this contact constraint.void
setSensor(boolean flag)
Sets this contact constraint to a sensor if flag is true.void
setTangentSpeed(double speed)
Sets the target surface speed of the contact constraint.void
shift(Vector2 shift)
Translates the object to match the given coordinate shift.String
toString()
void
update(Manifold manifold, Settings settings, ContactUpdateHandler handler)
Updates thisContactConstraint
with the newManifold
information and reports begin, persist, and end events to the handler.
-
-
-
Constructor Detail
-
ContactConstraint
@Deprecated public ContactConstraint(CollisionPair<T,BodyFixture> pair, Manifold manifold, double friction, double restitution)
Deprecated.Full constructor.- Parameters:
pair
- the pairmanifold
- the contactManifold
friction
- the friction for the contact constraintrestitution
- the restitution for the contact constraint
-
ContactConstraint
public ContactConstraint(CollisionPair<T,BodyFixture> pair)
Full constructor.- Parameters:
pair
- the pair
-
-
Method Detail
-
update
public void update(Manifold manifold, Settings settings, ContactUpdateHandler handler)
Updates thisContactConstraint
with the newManifold
information and reports begin, persist, and end events to the handler.- Parameters:
manifold
- the new manifoldsettings
- the settingshandler
- the handler
-
shift
public void shift(Vector2 shift)
Description copied from interface:Shiftable
Translates the object to match the given coordinate shift.
-
getId
@Deprecated public ContactConstraintId getId()
Deprecated.Deprecated in 4.0.0. No replacement.Returns the contact constraint id.- Returns:
ContactConstraintId
-
getNormal
public Vector2 getNormal()
Returns the collision normal.- Returns:
Vector2
the collision normal
-
getTangent
public Vector2 getTangent()
Returns the collision tangent.- Returns:
Vector2
the collision tangent
-
getContacts
public List<? extends SolvedContact> getContacts()
Returns the list ofSolvableContact
s.Modification of the list is permitted.
- Returns:
- List<
SolvableContact
> the list ofSolvableContact
s
-
getCollisionPair
public CollisionPair<T,BodyFixture> getCollisionPair()
Returns theCollisionPair
.- Returns:
CollisionPair
- Since:
- 4.0.0
-
getBody1
public T getBody1()
Returns the firstPhysicsBody
.- Returns:
PhysicsBody
-
getBody2
public T getBody2()
Returns the secondPhysicsBody
.- Returns:
PhysicsBody
-
getFixture1
public BodyFixture getFixture1()
Returns the firstPhysicsBody
'sBodyFixture
.- Returns:
BodyFixture
the firstPhysicsBody
'sBodyFixture
-
getFixture2
public BodyFixture getFixture2()
Returns the secondPhysicsBody
'sBodyFixture
.- Returns:
BodyFixture
the secondPhysicsBody
'sBodyFixture
-
getBody
public T getBody(CollisionBody<?> body)
Returns the body that matches the given body.If the given body is neither body1 or body2, null is returned.
- Parameters:
body
- the body- Returns:
- T
-
getFixture
public BodyFixture getFixture(CollisionBody<?> body)
Returns the fixture for the body that matches the given body.If the given body is neither body1 or body2, null is returned.
- Parameters:
body
- the body- Returns:
- E
-
getOtherBody
public T getOtherBody(CollisionBody<?> body)
Returns the body that does not match the given body.If the given body is neither body1 or body2, null is returned.
- Parameters:
body
- the body- Returns:
- T
-
getOtherFixture
public BodyFixture getOtherFixture(CollisionBody<?> body)
Returns the fixture for the body that does not match the given body.If the given body is neither body1 or body2, null is returned.
- Parameters:
body
- the body- Returns:
- E
-
getFriction
public double getFriction()
Returns the coefficient of friction for this contact constraint.- Returns:
- double
-
setFriction
public void setFriction(double friction)
Sets the coefficient of friction for this contact constraint.- Parameters:
friction
- the friction; must be 0 or greater- Since:
- 3.0.2
-
getRestitution
public double getRestitution()
Returns the coefficient of restitution for this contact constraint.- Returns:
- double
-
setRestitution
public void setRestitution(double restitution)
Sets the coefficient of restitution for this contact constraint.- Parameters:
restitution
- the restitution; must be zero or greater- Since:
- 3.0.2
-
isSensor
public boolean isSensor()
Returns true if thisContactConstraint
is a sensor.By default a contact constraint is a sensor if either of the two
BodyFixture
s are sensor fixtures. This can be overridden using thesetSensor(boolean)
method.- Returns:
- boolean
- Since:
- 1.0.1
-
setSensor
public void setSensor(boolean flag)
Sets this contact constraint to a sensor if flag is true.A sensor constraint is not solved.
- Parameters:
flag
- true if this contact constraint should be a sensor- Since:
- 3.0.2
-
getTangentSpeed
public double getTangentSpeed()
Returns the surface speed of the contact constraint.This will always be zero unless specified manually. This can be used to set the target velocity at the contact to simulate a conveyor belt type effect.
- Returns:
- double
- Since:
- 3.0.2
-
setTangentSpeed
public void setTangentSpeed(double speed)
Sets the target surface speed of the contact constraint.The surface speed, in meters / second, is used to simulate a conveyor belt.
A value of zero deactivates this feature.
- Parameters:
speed
- the speed in Meters / Second- Since:
- 3.0.2
-
setEnabled
public void setEnabled(boolean flag)
Sets the enabled flag.A value of true would enable the contact to be processed by the collision resolution step. A value of false would disable the processing of this constraint for this step only.
True by default.
- Parameters:
flag
- true if the contact should be enabled- Since:
- 3.3.0
-
isEnabled
public boolean isEnabled()
Returns true if this contact constraint is enabled for processing by the collision resolution step.- Returns:
- boolean
- Since:
- 3.3.0
-
isOnIsland
@Deprecated public boolean isOnIsland()
Deprecated.Deprecated in 4.0.0. No replacement needed.Returns true if this contact constraint is on an island.- Returns:
- boolean
-
setOnIsland
@Deprecated public void setOnIsland(boolean flag)
Deprecated.Deprecated in 4.0.0. No replacement needed.Flags this contact constraint as being on an island.- Parameters:
flag
- true if this contact constraint is on an island
-
-