net.java.dev.joode.collision.collider
Class RectangleRectangleCollider

java.lang.Object
  extended by net.java.dev.joode.collision.collider.RectangleRectangleCollider
All Implemented Interfaces:
Collider

public class RectangleRectangleCollider
extends java.lang.Object
implements Collider

Ported from Phys2D The implementation of box to box collision. The create() method is used as a factory to produce the collider instance.

Currently the collider is stateless so a single instance is returned each time. TODO Quite alot of garbage production by this class

Author:
Kevin Glass, ported by Tom Larkworthy

Nested Class Summary
static class RectangleRectangleCollider.FeaturePair
          ported from Phys2D, this class was not an inner class, but as only the RectangleCollider seems to use it extensively I have placed it here, though this may need to be moved when more funcionality is ported
 
Field Summary
static int EDGE1
          The identifier indicating the first edge collides
static int EDGE2
          The identifier indicating the second edge collides
static int EDGE3
          The identifier indicating the third edge collides
static int EDGE4
          The identifier indicating the forth edge collides
static int FACE_A_X
          The identifier for the x coordinate of the first face
static int FACE_A_Y
          The identifier for the y coordinate of the first face
static int FACE_B_X
          The identifier for the x coordinate of the second face
static int FACE_B_Y
          The identifier for the y coordinate of the second face
static Collider INSTANCE
           
static int NO_EDGE
          The identifier indicating no edges collided
 
Method Summary
 int collide(ContactGeom[] contacts, int contactIndex, Rectangle a, Rectangle b)
           
 int collide(Geom o1, Geom o2, int flags, ContactGeom[] contact, int contactIndex, int skip)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FACE_A_X

public static final int FACE_A_X
The identifier for the x coordinate of the first face

See Also:
Constant Field Values

FACE_A_Y

public static final int FACE_A_Y
The identifier for the y coordinate of the first face

See Also:
Constant Field Values

FACE_B_X

public static final int FACE_B_X
The identifier for the x coordinate of the second face

See Also:
Constant Field Values

FACE_B_Y

public static final int FACE_B_Y
The identifier for the y coordinate of the second face

See Also:
Constant Field Values

NO_EDGE

public static final int NO_EDGE
The identifier indicating no edges collided

See Also:
Constant Field Values

EDGE1

public static final int EDGE1
The identifier indicating the first edge collides

See Also:
Constant Field Values

EDGE2

public static final int EDGE2
The identifier indicating the second edge collides

See Also:
Constant Field Values

EDGE3

public static final int EDGE3
The identifier indicating the third edge collides

See Also:
Constant Field Values

EDGE4

public static final int EDGE4
The identifier indicating the forth edge collides

See Also:
Constant Field Values

INSTANCE

public static final Collider INSTANCE
Method Detail

collide

public int collide(Geom o1,
                   Geom o2,
                   int flags,
                   ContactGeom[] contact,
                   int contactIndex,
                   int skip)
Specified by:
collide in interface Collider

collide

public int collide(ContactGeom[] contacts,
                   int contactIndex,
                   Rectangle a,
                   Rectangle b)