Problem with normal vector

Hello everyone,

I'm new to all of this, so bare with me if I'm asking something truly idiotic here.

I'm working on an iphone game with box2d and basically updating the contacts on my hero entity periodically (on each frame, basically). I created the world by parsing a svg file which I constructed a couple of times trying out different things (edges vs. rects vs. polys). In addition, I'm using the contact manifold and it's normal vector to determine what my hero _can_ or _can't_ do (ie. jumping, slide on walls, etc).

This has been pretty reliable, except for the following edge-case, which I can't seem to find a good solution for:

Image

When the body stands directly on top of a poly _corner_ then the normal points directly down... which makes no sense. I'm not sure why that is exactly, maybe it's a limitation of the simulation, not sure. Do you guys have any ideas on how to work around that?

I tried the following to no avail:
- Tried using concave polygons all over the map instead of edge bodies.
- Tried to see if more than one contact was generated (a "good" one besides the "bad" one) No go.
- Tried flattening the edge so it wouldn't be so sharp. Seems to work so long as I keep it above 90 degs (as opposed to a sharp angle like the one in the picture above), but this makes map-making a tad more difficult. I could live with it, but just wondering if there's a better solution.

Any ideas?

Thanks so much, in advance!
If I understand it correctly, the normal lies along the quickest direction to move the shapes apart so that they are no longer overlapping, so it does make sense.
How about having a sensor attached to the bottom of your player, and you check that to see if it is touching something, then you can jump. This way you can also shape the sensor in a different way to your players shape for a bit more customizability. I'm doing this and it works great.
About the normal though... Maybe from an algorithm standpoint the normal is defined as what you said, but in reality the normal should definitely be pointing somewhere upwards (probably to the right as well) as a reaction force to the contact on the ground.

In any case, your idea sounds like a great solution. I'll try that.

Thanks!
The normal always points from shape A to shape B. I think this is stated in the manual somewhere. There is no guarantee about with shape is picked to be A or B. But you can check your shapes using the shape user data and flip the normal if you like.
Ahhh, that makes sense. I'll look into that.

Thanks!

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