Skip to content

Instantly share code, notes, and snippets.

@fowlmouth
Created March 14, 2014 18:46
Show Gist options
  • Save fowlmouth/9554171 to your computer and use it in GitHub Desktop.
Save fowlmouth/9554171 to your computer and use it in GitHub Desktop.
type
parbiter = object
swappedcoll: bool
a,b: pshape
pshape = ptr object
#/ Return the colliding shapes involved for this arbiter.
#/ The order of their cpSpace.collision_type values will match
#/ the order set when the collision handler was registered.
proc getShapes*(arb: PArbiter, a, b: var PShape) {.inline.} =
if arb.swappedColl.bool:
a = arb.b
b = arb.a
else:
a = arb.a
b = arb.b
#/ A macro shortcut for defining and retrieving the shapes from an arbiter.
#define CP_ARBITER_GET_SHAPES(arb, a, b) cpShape *a, *b; cpArbiterGetShapes(arb, &a, &b);
template getShapes*(arb: PArbiter, name1, name2: expr): stmt {.immediate.} =
var name1, name2: PShape
getShapes(arb, name1, name2)
var
arb: PArbiter
a,b: PShape
getshapes(arb,a,b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment