java.lang.Object
java.lang.Record
technology.sola.engine.physics.CollisionManifold
- Record Components:
entityA- the firstEntityin the collisionentityB- the secondEntityin 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 aCollisionManifoldrecord class. -
Method Summary
Modifier and TypeMethodDescriptionvoidconditionallyResolveCollision(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.EntityentityA()Returns the value of theentityArecord component.technology.sola.ecs.EntityentityB()Returns the value of theentityBrecord component.booleanChecks if this instance is equal to another object.inthashCode()Returns a hash code value for this object.normal()Returns the value of thenormalrecord component.floatReturns the value of thepenetrationrecord component.final StringtoString()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 firstEntityin the collisionentityB- the secondEntityin the collisionminimumTranslationVector- theMinimumTranslationVectorfor the collision
-
CollisionManifold
public CollisionManifold(technology.sola.ecs.Entity entityA, technology.sola.ecs.Entity entityB, Vector2D normal, float penetration) Creates an instance of aCollisionManifoldrecord class.- Parameters:
entityA- the value for theentityArecord componententityB- the value for theentityBrecord componentnormal- the value for thenormalrecord componentpenetration- the value for thepenetrationrecord 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 twoEntityat 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 theentityArecord component.- Returns:
- the value of the
entityArecord component
-
entityB
public technology.sola.ecs.Entity entityB()Returns the value of theentityBrecord component.- Returns:
- the value of the
entityBrecord component
-
normal
Returns the value of thenormalrecord component.- Returns:
- the value of the
normalrecord component
-
penetration
public float penetration()Returns the value of thepenetrationrecord component.- Returns:
- the value of the
penetrationrecord component
-