Body collision to bodies that are placed higher

Hello,
I'm actually working on a platformer game, but I conclused that making my own physics system is pointless, so after quick brainstorm I choosed Box2D. After implementing it I met following problem:
Image
I want to make platforms, that are positioned lower than player to collide with him, but those, which are higher should be transparent (and when he'll jump on them, they will become solid). On this image:
1 shouldn't collide with player,
2 should collide with player (because it's lower than player's highest part - head)
3 should collide with player (because it's underneath him)
I know of filtering, but it provides only 16 groups (so I wouldn't be able to make map higher than 16 cells (one cell = 64px, and so are platforms). I can reassign platforms to two groups (upper and lower) every each frame or player movement, but I think it will be helluva slow, and what if there will be for example 10 players on map? 20 groups won't fit. How can I achieve this with Box2D, or any other engine?
kijanek6,

If I am understanding the problem correctly, I think you are just talking about one-way platforms. Take a look at the Box2d Testbed code as there is an example of a one-way platform.

Regards,
Q
Yeah, this is what I was looking for. Thanks! Anyway, I've got now next problem. I'm writing player controlling using SetLinearVelocity. However, the player sometimes freezes and is unable to move (though he's within world boundaries). Every tile has it's own body (each of 0.64 x 0.64 units), placed continually. Friction and restitution are set to 0 for every body, tiles are static and player is dynamic.
Image
On upper screen character is moving (sliding on ground) right with force of 5. On the lower screen he suddenly stops facing next tile (his right side X is equal to the actual tile his standing X). It looks like the tiles are placed on different Y values (if next tile is higher than first, he should stop), but they're placed on equal Y. Player isn't frozen (IsFrozen()) nor asleep (IsSleeping()).
Player creation:
Code:
   hShapeDef = new b2PolygonDef;
   hShapeDef->density = 1;
   hShapeDef->friction = 0;
   hShapeDef->restitution = 0;
   hShapeDef->SetAsBox(0.265, 0.58); //size of player body is 53x116 pixels (0.53 x 1.16 in meters)
   hBodyDef = new b2BodyDef;
   hBodyDef->position.Set(0, 0);
   hBodyDef->fixedRotation = 1;
   hBody = GLOBVAR->level->hWorld->CreateBody(hBodyDef);
   hBody->CreateShape(hShapeDef);
   hBody->SetMassFromShapes();
   b2MassData massData;
   massData.mass = hBody->GetMass();
   massData.center = b2Vec2(0.265f, 0.58f);
   massData.I = 0.0f;
   hBody->SetMass(&massData);

Tile creation (for every tile):
Code:
     hShapeDef = new b2PolygonDef;
    hShapeDef->density = 0;
    hShapeDef->friction = 0;
    hShapeDef->restitution = 0;
    hShapeDef->SetAsBox(0.32, 0.32);
    hBodyDef = new b2BodyDef;
    hBodyDef->position.Set(iX*0.64+0.32, iY*0.64+0.32); //because constructor has given coords in cell x cell format, I need to convert them from cells to world coords (each cell is 0.64 wide and 0.64 high, plus half of dimension to center it
    hBody = GLOBVAR->level->hWorld->CreateBody(hBodyDef);
    hBody->CreateShape(hShapeDef);

And controlling:
Code:
    if( KSE->Input_Key(KSEK_RIGHT) ) //if right key (arrow) is pressed
     hBody->ApplyImpulse(b2Vec2(5.0f, 0.0f), b2Vec2(0,0));
    else if( KSE->Input_Key(KSEK_LEFT) ) //if left key is pressed
     hBody->ApplyImpulse(b2Vec2(-5.0f, 0.0f), b2Vec2(0,0));
   

If player's speed is high it sometimes go on, but sometimes stop. And on most of tiles everything is OK. I can provide source & binaries if you need them to solve the problem. I hope I'll find a solution for this problem because I'm two days late in relation to the plan.
Sounds like you might be running into the same issue discussed here and here.
Yeah, but I don't see any good solution. Making one big polygon is not a way, because there could be many 1x1 tiles that are moving (elevators), and when they'll be in a row character will still be stuck, and this idea don't work well with dynamic levels (because when I delete one tile, I have to rebuild everything). Character dont has to be sliding (when the key is up, I set the velocity to 0), so I can use SetXForm, but it stucks character to tiles that are on the same Y than him...
Erin Catto wrote:
It is not a bug

...it's a feature? Lmao. Actually, it IS a bug, because one body is sliding on others, which are placed in a row. In normal world you won't stuck. Is there any way to fix this? If it's impossible with Box2D, am I forced to make my own physics library? -.-
The real world is not a bunch of boxes and people are not rigid boxes. When I push a table across my tile floor, sometimes a leg gets snagged on an edge. Since shapes in Box2D have a small amount of overlap (of their skins), you can get some snagging.

I may look at implementing adjacency information for edges. However, posts like this don't inspire me.
haha who never hurted his feet on one of those $@§z!?! tile floors! 😉

@kijanek6 I would recommand you to have a look at the EdgeShape, EdgeChain, etc. in the latest version. If you consider only one segment per tile (the upper one) you will solve this issue (maybe you will need more segments depending on your needs, but that's easy to solve this issue with segments instead of shapes).

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