contact filtering for lots of characters

hello,

I'm working with the c++ version of box2d

I want to implement custom contact filtering so that a character only collides with ground objects from above, never from below,
like in the adventures of tinger:
http://www.huesforalice.com/resource/86

but where tinger only needs to filter for the player, I would like it to work for the large number of 'enemies' as well.

I'm trying to work out the most efficient way to achieve this without needing to store a record with a value for every platform x every character.

anyone got any ideas?

cheers

mathew
cheers

mathew
use edge shapes!
they're unidirectional
i thought that edge shapes couldn't tell the difference between a collision from underneath, and a deep collision from above, and will move a object from below to the top,

I also don't want large characters to get skewered on an edge shape, I only what bodies that are coming completely from above to collide, I assumed that that is more than edge shapes can do.

no?
ahh you are correct, sorry.

i guess subclass the b2ContactFilter and if they do collide then run another test to see if one shape is ground and the other is a player/enemy (could use userdata to store this), if so only collide if the player/enemy is above the ground shape.
thanks sleepless

working out exactly when to switch off collisions is one of the area where i'd like a bit of help,

its a bit theoretical at the moment - I'm waiting for my computer to complete the long process of re-install and system updates before i can get xcode running again - so i can't just test it myself yet but:

I'm assuming that when you have a collision there will be some penetration so the test i probably need to do involves a mix of:

is the penetration below some small threshold,
is the centre of the body above the edge

I noticed that in tinger, the conditional platforms are pretty much horizontal, which seems to be a limitation of this strategy.

As an alternative I have been imagining creating a trigger area under and to the sides of the platform, and if the character has very recently collided with the trigger area, that collisions with the platform will be switched off for that character. then i could make the conditional platforms any shape i wanted:

Image

in the example above, the red object is colliding with the trigger area, so the collision with the green platform will be filtered.

the blue object is not contacting the trigger area, so it will collide with the green platform

the other thing that seems i might want to take into account is that the red object is in contact with the ground too

ever done anything like that?

cheers
thanks for the help
mat
Read this thread: viewtopic.php?f=8&t=1748

In short: you can fairly easily accomplish unidirectional platforms by utilizing b2CollisionPoint normal angles, but you'll need to apply a hack that is about to become official to get at the b2Contact objects.

Original thread: https://box2d.org/forum/viewtopic.php?t=1952