Collision bug in seg2poly

Discuss any Chipmunk bugs here.

Collision bug in seg2poly

Postby josephg » Sat Jan 26, 2013 12:49 pm

I've created a couple shapes which should collide with each other, but don't seem to. I may well be doing something wrong - but I've tried poking my code in a few different ways and it seems to always mess up the same.

Two shapes:
* A segment from -50,-100 to 50,100
* A box which is 300 wide, 100 tall centered around the origin

Somehow, they don't collide with each other. I've tried putting them on bodies in an updating space and so on, and I get the same behaviour. If the box is 200 wide instead, they collide correctly. (??)

Code: Select all
  cpShape *seg = cpSegmentShapeNew(NULL, cpv(-50, -100), cpv(50, 100), 10);
  cpShapeUpdate(seg, cpvzero, cpvforangle(0));
  cpShape *poly = cpBoxShapeNew(NULL, 300, 100);
  cpShapeUpdate(poly, cpvzero, cpvforangle(0));

  cpContact c[100];
  int num = cpCollideShapes(seg, poly, c);
  printf("%d\n", num); // prints 0
Posts: 29
Joined: Sat Dec 24, 2011 4:54 am

Re: Collision bug in seg2poly

Postby slembcke » Mon Jan 28, 2013 6:15 pm

So without getting into it too much, it's definitely a bug. I've known that highly overlapping polygons and segments, it can report weird contact points. I didn't know there were bugs where it would report no collisions though. The collision detection code is the oldest in Chipmunk. (Actually older than Chipmunk itself).

The good news is that I have a branch where I've been rewriting the collision detection to fix the issues that I know about and add a few features that I've been wanting (beveled polygons, smoothed terrain collisions). The bad news is that I've been working on it for quite a while now. It works fine if I disable the GJK caching, but then it's prohibitively slow. When caching is enabled, it misses maybe 1/10,000 collisions depending on the previous position, but the performance is comparable to the SAT based version. I'm not quite sure when I'm going to get the caching to work right. :-\
Can't sleep... Chipmunks will eat me...
Check out our latest projects! ->
User avatar
Site Admin
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Return to Bugs

Who is online

Users browsing this forum: No registered users and 1 guest