semicongine/contrib/algorithms/collision

Types

Collider = object
  transform*: Mat4 = (data: [1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0,
                             1.0, 0.0, 0.0, 0.0, 0.0, 1.0])
  case theType*: ColliderType
  of Box:
    nil
  of Sphere:
    radius*: float32
  of Points:
    points*: seq[Vec3f]
ColliderType = enum
  Box, Sphere, Points

Procs

func calculateCollider(points: openArray[Vec3f]; theType: ColliderType): Collider {.
    ...raises: [], tags: [], forbids: [].}
func collision(a, b: Collider; as2D = false): tuple[hasCollision: bool,
    normal: Vec3f, penetrationDepth: float32] {....raises: [Exception], tags: [],
    forbids: [].}
func contains(collider: Collider; x: Vec3f): bool {....raises: [Exception],
    tags: [], forbids: [].}
func intersects(a, b: Collider; as2D = false): bool {....raises: [Exception],
    tags: [], forbids: [].}
proc rayIntersectAABB(origin, dir, boxA, boxB: Vec3f): Option[(Vec3f, float32)] {.
    ...raises: [], tags: [], forbids: [].}