Not wanting collision callbacks

Official forum for the Chipmunk2D Physics Library.

Not wanting collision callbacks

Postby iisystems2 » Thu Oct 01, 2009 12:07 pm

Hi,

I'm pretty sure at some point I had seen the ability in Chipmunk to define shape classes (cpShapeClass?) or possibly collision classes for the purpose of NOT receiving collision callbacks for shapes within the same shape/collision class. At the time, I didn't see the need for this, but now see I am constantly getting callbacks from overlapping static shapes in my game which I am routing to a one-line (return 0) callback, but nonetheless am incurring the overhead of the calls. Now that I'm looking for the information again, I can't find it either in the forums or in the documentaion.

Could someone please point me to info on how to define shapes into a common class so I will not receive callbacks on their collisions?

Thanks very much!

Scott
iisystems2
 
Posts: 2
Joined: Thu Oct 01, 2009 11:46 am

Re: Not wanting collision callbacks

Postby maximile » Thu Oct 01, 2009 1:20 pm

I thought that static shapes didn't collide with each other. Are you adding them as static shapes?

Anyway, you can filter collisions by layer or group. Sounds like either of them would suit your needs. I can't find the info in the new docs, but here's the relevant bits from the old docs:
Code: Select all
typedef struct cpShape{
    cpBB bb;

    unsigned long collision_type;
    unsigned long group;
    unsigned long layers;

    void *data;

    cpBody *body;
    cpFloat e, u;
    cpVect surface_v;
} cpShape;


group: Shapes in the same non-zero group do not generate collisions. Useful when creating an object out of many shapes that you don’t want to self collide. Defaults to 0;
layers: Shapes only collide if they are in the same bit-planes. i.e. (a->layers & b->layers) != 0 By default, a shape occupies all 32 bit-planes.
maximile
 
Posts: 157
Joined: Mon Aug 20, 2007 12:53 pm
Location: London, UK

Re: Not wanting collision callbacks

Postby slembcke » Thu Oct 01, 2009 2:01 pm

maximile wrote:I thought that static shapes didn't collide with each other. Are you adding them as static shapes?


Correct, static shapes are never queried against each other.

The new docs have the layers and groups explanation underneath the struct just like in the old ones. http://code.google.com/p/chipmunk-physics/wiki/cpShape
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: Not wanting collision callbacks

Postby iisystems2 » Thu Oct 01, 2009 7:03 pm

Thank you both maximile and slembcke! I knew I was getting callbacks I didn't want when nothing was moving, and sure enough, yes-- one of these shapes was not static (because I had the intent to make it move later) and I didn't look close enough. Nonetheless, cpShape.group was what I was looking for in general and I'm now making use of it.
iisystems2
 
Posts: 2
Joined: Thu Oct 01, 2009 11:46 am


Return to Chipmunk2D Physics

Who is online

Users browsing this forum: No registered users and 1 guest

cron