Record Class CollisionManifold

java.lang.Object
java.lang.Record
technology.sola.engine.physics.CollisionManifold
Record Components:
entityA - the first Entity in the collision
entityB - the second Entity in the collision
normal - the collision normal
penetration - 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

    Constructors
    Constructor
    Description
    CollisionManifold(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 a CollisionManifold record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    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.
    technology.sola.ecs.Entity
    Returns the value of the entityA record component.
    technology.sola.ecs.Entity
    Returns the value of the entityB record component.
    boolean
    Checks if this instance is equal to another object.
    int
    Returns a hash code value for this object.
    Returns the value of the normal record component.
    float
    Returns the value of the penetration record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • 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 first Entity in the collision
      entityB - the second Entity in the collision
      minimumTranslationVector - the MinimumTranslationVector for the collision
    • CollisionManifold

      public CollisionManifold(technology.sola.ecs.Entity entityA, technology.sola.ecs.Entity entityB, Vector2D normal, float penetration)
      Creates an instance of a CollisionManifold record class.
      Parameters:
      entityA - the value for the entityA record component
      entityB - the value for the entityB record component
      normal - the value for the normal record component
      penetration - the value for the penetration 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 condition
      entityTwoCollisionCondition - the second entity collision condition
      collisionResolver - the resolver for the collision
    • equals

      public boolean equals(Object o)
      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 two Entity 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.

      Specified by:
      equals in class Record
      Parameters:
      o - Object to check equality with
      Returns:
      true if equal
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • entityA

      public technology.sola.ecs.Entity entityA()
      Returns the value of the entityA record component.
      Returns:
      the value of the entityA record component
    • entityB

      public technology.sola.ecs.Entity entityB()
      Returns the value of the entityB record component.
      Returns:
      the value of the entityB record component
    • normal

      public Vector2D normal()
      Returns the value of the normal record component.
      Returns:
      the value of the normal record component
    • penetration

      public float penetration()
      Returns the value of the penetration record component.
      Returns:
      the value of the penetration record component