sims.collision

class GridDetector

[source: sims/collision/GridDetector.scala]

class GridDetector(val override world : World)
extends Detector
A conrete implementation of Detector. GridDetector divides the world into a grid for faster collision detection.
Value Summary
val collisionMethods : scala.collection.mutable.ArrayBuffer[scala.PartialFunction[(Shape, Shape), Collision]]
Array of methods returning collisions. It is assumed that both shapes are colliding.
val detectionMethods : scala.collection.mutable.ArrayBuffer[scala.PartialFunction[(Shape, Shape), Boolean]]
Array of collision detection methods. These methods return true if two shapes are colliding.
var gridSide : Double
Width and height of a grid cell.
Method Summary
def colliding (p : Pair) : Boolean
Checks the pair of shapes p for collision.
def collidingPairs : scala.Seq[Pair]
Returns all colliding pairs.
def collision (p : Pair) : Collision
Returns the collision between both shapes of the pair p.
def collisions : scala.Seq[Collision]
Returns all collisions.
def getPairs : scala.Seq[Pair]
Returns potential colliding pairs of shapes of the world world.
def pairs : scala.Seq[Pair]
All potential colliding pairs of the world.
Methods inherited from AnyRef
getClass, hashCode, equals, clone, toString, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized
Methods inherited from Any
==, !=, isInstanceOf, asInstanceOf
Value Details
val detectionMethods : scala.collection.mutable.ArrayBuffer[scala.PartialFunction[(Shape, Shape), Boolean]]
Array of collision detection methods. These methods return true if two shapes are colliding.

val collisionMethods : scala.collection.mutable.ArrayBuffer[scala.PartialFunction[(Shape, Shape), Collision]]
Array of methods returning collisions. It is assumed that both shapes are colliding.

var gridSide : Double
Width and height of a grid cell.

Method Details
def colliding(p : Pair) : Boolean
Checks the pair of shapes p for collision.
Parameters
p - Pair of shapes.

def collision(p : Pair) : Collision
Returns the collision between both shapes of the pair p.
Parameters
p - Pair of shapes.

def getPairs : scala.Seq[Pair]
Returns potential colliding pairs of shapes of the world world.

A potential colliding pair is a pair of two shapes that comply with the following criteria:

  • The shapes are situated in the same grid cell.
  • Their AABBs overlap.
  • The shapes do not belong to the same body.
  • At least one shape is not fixed.
  • Both shapes are {@link dynamics.Shape#collidable}.

def pairs : scala.Seq[Pair]
All potential colliding pairs of the world.
See Also
getPairs

def collidingPairs : scala.Seq[Pair]
Returns all colliding pairs.

def collisions : scala.Seq[Collision]
Returns all collisions.
Overrides
Detector.collisions