Interface Collider

All Known Implementing Classes:
PolygonCollider

public interface Collider
Describes an object that can collide with others.
Since:
21.06.2021
Author:
Juyas
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Determines whether a collider could potentially intersect with another collider ONLY by their collision layers.
    Determines whether a collider intersects with another collider IGNORING the collision layers.
    The shape of the collider.
    boolean
    hasMask(int layer)
    Determines whether a collision mask for a specified layer is enabled.
    boolean
    isOnLayer(int layer)
    Determines whether the collider exists in a specified layer.
    short
    A short containing all enabled layers encoded as bit mask.
    short
    A short containing all enabled masks encoded as bit mask.
    boolean
    Defines the behaviour of this collider.
    void
    setLayer(int layer, boolean active)
    Change the colliders presence in a specified layer.
    void
    setMask(int layer, boolean active)
    Changes the collision mask entry for a specified layer.
  • Method Details

    • getShape

      PrimitiveShape getShape()
      The shape of the collider.
      Returns:
      the shape of the collider
    • detectCollision

      CollisionInformation detectCollision(Collider collider)
      Determines whether a collider intersects with another collider IGNORING the collision layers.
      Parameters:
      collider - the other collider
      Returns:
      an object containing the result of collision detection
    • canCollideWith

      boolean canCollideWith(Collider collider)
      Determines whether a collider could potentially intersect with another collider ONLY by their collision layers. This method can be considered part of the broad phase of collision detection.
      Parameters:
      collider - the other collider
      Returns:
      true if and only if both objects could potentially collide
    • layers

      short layers()
      A short containing all enabled layers encoded as bit mask. Should be usable to compare different masks with each other to check for intersection.
      Returns:
      a short with all layer encoded
    • mask

      short mask()
      A short containing all enabled masks encoded as bit mask. Should be usable to compare different masks with each other to check for intersection.
      Returns:
      a short with all masks encoded
    • hasMask

      boolean hasMask(int layer)
      Determines whether a collision mask for a specified layer is enabled.
      Parameters:
      layer - the layer from 0 to TOTAL_LAYER-1, the behaviour for layers outside the range is undefined
      Returns:
      true if and only if the mask for the specified layer is enabled
    • isOnLayer

      boolean isOnLayer(int layer)
      Determines whether the collider exists in a specified layer.
      Parameters:
      layer - the layer from 0 to TOTAL_LAYER-1, the behaviour for layers outside the range is undefined
      Returns:
      true if and only if the collider exists in the specified layer
    • setLayer

      void setLayer(int layer, boolean active)
      Change the colliders presence in a specified layer. Making a collider present in a specified layer will it enable to collide with all collider including the specified layer in their collision mask.
      Parameters:
      layer - the layer from 0 to TOTAL_LAYER-1, the behaviour for layers outside the range is undefined
      active - whether the collider should be present (true) or not (false)
    • setMask

      void setMask(int layer, boolean active)
      Changes the collision mask entry for a specified layer. Enabling the mask for layer n will allow this collider to collide with any other collider set in the target layer n vise versa.
      Parameters:
      layer - the layer from 0 to TOTAL_LAYER-1, the behaviour for layers outside the range is undefined
      active - whether the mask should enabled (true) or disabled (false)
    • passive

      boolean passive()
      Defines the behaviour of this collider. A passive collider will never get checked against others colliders, however any collider might get checked against it.
      Returns:
      whether this collider is passive