java.lang.Object
java.lang.Record
technology.sola.engine.physics.CollisionManifold
- Record Components:
entityA
- the firstEntity
in the collisionentityB
- the secondEntity
in the collisionnormal
- the collision normalpenetration
- the penetration of the collision
@NullMarked
public record CollisionManifold(technology.sola.ecs.Entity entityA, technology.sola.ecs.Entity entityB, Vector2D normal, float penetration)
extends Record
Creates a CollisionManifoldEventMessage for two entities.
-
Constructor Summary
ConstructorsConstructorDescriptionCollisionManifold
(technology.sola.ecs.Entity entityA, technology.sola.ecs.Entity entityB, MinimumTranslationVector minimumTranslationVector) Creates a CollisionManifoldEventMessage for two entities.CollisionManifold
(technology.sola.ecs.Entity entityA, technology.sola.ecs.Entity entityB, Vector2D normal, float penetration) Creates an instance of aCollisionManifold
record class. -
Method Summary
Modifier and TypeMethodDescriptionvoid
conditionallyResolveCollision
(Function<technology.sola.ecs.Entity, Boolean> entityOneCollisionCondition, Function<technology.sola.ecs.Entity, Boolean> entityTwoCollisionCondition, BiConsumer<technology.sola.ecs.Entity, technology.sola.ecs.Entity> collisionResolver) Calls the collision resolve callback if both entity collision condition checks return true.technology.sola.ecs.Entity
entityA()
Returns the value of theentityA
record component.technology.sola.ecs.Entity
entityB()
Returns the value of theentityB
record component.boolean
Checks if this instance is equal to another object.int
hashCode()
Returns a hash code value for this object.normal()
Returns the value of thenormal
record component.float
Returns the value of thepenetration
record component.final String
toString()
Returns a string representation of this record class.
-
Constructor Details
-
CollisionManifold
public CollisionManifold(technology.sola.ecs.Entity entityA, technology.sola.ecs.Entity entityB, MinimumTranslationVector minimumTranslationVector) Creates a CollisionManifoldEventMessage for two entities.- Parameters:
entityA
- the firstEntity
in the collisionentityB
- the secondEntity
in the collisionminimumTranslationVector
- theMinimumTranslationVector
for the collision
-
CollisionManifold
public CollisionManifold(technology.sola.ecs.Entity entityA, technology.sola.ecs.Entity entityB, Vector2D normal, float penetration) Creates an instance of aCollisionManifold
record class.- Parameters:
entityA
- the value for theentityA
record componententityB
- the value for theentityB
record componentnormal
- the value for thenormal
record componentpenetration
- the value for thepenetration
record component
-
-
Method Details
-
conditionallyResolveCollision
public void conditionallyResolveCollision(Function<technology.sola.ecs.Entity, Boolean> entityOneCollisionCondition, Function<technology.sola.ecs.Entity, Boolean> entityTwoCollisionCondition, BiConsumer<technology.sola.ecs.Entity, technology.sola.ecs.Entity> collisionResolver) Calls the collision resolve callback if both entity collision condition checks return true.- Parameters:
entityOneCollisionCondition
- the first entity collision conditionentityTwoCollisionCondition
- the second entity collision conditioncollisionResolver
- the resolver for the collision
-
equals
Checks if this instance is equal to another object. It will return true regardless of the order of entityA and entityB. This assumes that there can only be one collision between any twoEntity
at the same time.Example: If this manifold has entityA with id 1 and entityB with id 2 and another manifold has entityA with id 2 and entityB with id 1 it will return true.
-
hashCode
public int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
entityA
public technology.sola.ecs.Entity entityA()Returns the value of theentityA
record component.- Returns:
- the value of the
entityA
record component
-
entityB
public technology.sola.ecs.Entity entityB()Returns the value of theentityB
record component.- Returns:
- the value of the
entityB
record component
-
normal
Returns the value of thenormal
record component.- Returns:
- the value of the
normal
record component
-
penetration
public float penetration()Returns the value of thepenetration
record component.- Returns:
- the value of the
penetration
record component
-