Working with Sensors

Official forum for the Chipmunk2D Physics Library.
Post Reply
barrington
Posts: 1
Joined: Mon Mar 12, 2012 3:36 pm
Contact:

Working with Sensors

Post by barrington »

Hi!

Having an issue with a sensor shape that I have attached to a sprite.

I have two AABB's around my sprite:
  • - a smaller one that fits around his texture that triggers all of the normal collisions (sensor = false), and
    - a larger one for detecting objects in his vicinity (sensor = true).
When I drop him out of the sky onto a vanilla AABB platform, the sensor shape generates a single begin collision callback with 3 arbiters. All of the arbiters have a normal of (0, -1).

If I walk him off an edge or make him fly, then the sensor shape generates a single separate collision callback with 0 arbiters.

The smaller collider (sensor = false) seems to do everything as expected:
  • 1. After landing, one being collision callback is called containing a single arbiter.
    2. After lifting off the ground or falling off an edge, one separate collision callback is called with another single arbiter.
Should I expect the sensor shape to behave like this?

Thanks in advance,
B
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Working with Sensors

Post by slembcke »

You mean the arbiter for a begin callback has three contact points with normals of (0, -1)?

It's undefined behavior, but separate callbacks shouldn't have any contact points. The shapes aren't colliding any more, so there shouldn't be any information other than which shapes separated. If it is returning collision points, then they are cached from the previous frame and should be ignored. I know I have code that explicitly clears the contact count somewhere, but it might not happen in all cases. I'll check that out and mark it as a bug.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Post Reply

Who is online

Users browsing this forum: No registered users and 14 guests