polyandcircle contact problems

hello!
i get contactRemoved events when there only should come persisted events with circle inside polygon.
this doesn't happen on circle on circle collisions.

what i do: i have a big static poly-sensor and a dynamic circlebody.
i am setting the color of the poly to alpha = 1, when i get a contactPersisted event.
on contactRemoved, i set the alpha of the poly to 0.5.
but although the circle is still moving inside the poly, i get a removed event.
if i use a big static circle-sensor, the events are generated as they should.

is this a bug? did anyone experience the same problem?

greets

btw i use the iphone port of handcircus, but i replaced "b2PolyAndCircleContact.cpp" with the newest box2d versions file..same problem
ok i tried it with Box2D_v2.0.1.zip, but problem is the same.
it also happens with poly on poly contacts.
the funny thing is, when i move 2 circles inside the poly, i get the wrong added/removed contacts only when i move the circle that entered the poly at first.
i think its definetly a bug and there is something wrong with the polycontacts.

any help or tips would be very cool because this is really annoying.

greets
Contacts are a mystery. They come and go, however the number should remain constant (still have at least one active contact while the shapes are colliding. If that is not the case then it may be a bug.

FYI - A new contact system is being implemented which should improve things.
does anybody know if it has been fixed in the newest (svn)version?
*bump*

I'm having the same problem with all contacts between a polygon sensor and a circle being removed while the two are still in contact (using 2.0.2).

My polygon (a diamond, 96px wide and 64px high) is created with:
Code:
polygonDef->vertexCount = 4;
polygonDef->vertices[0].Set(SCREEN_TO_WORLD(16.0f - 64.0f), SCREEN_TO_WORLD(64.0f - 64.0f));
polygonDef->vertices[1].Set(SCREEN_TO_WORLD(64.0f - 64.0f), SCREEN_TO_WORLD(32.0f - 64.0f));
polygonDef->vertices[2].Set(SCREEN_TO_WORLD(112.0f - 64.0f), SCREEN_TO_WORLD(64.0f - 64.0f));
polygonDef->vertices[3].Set(SCREEN_TO_WORLD(64.0f - 64.0f), SCREEN_TO_WORLD(96.0f - 64.0f));


My circle (with radius 11px) is created with:
circleDef->radius = SCREEN_TO_WORLD(11.0f);

I'm counting the polygon's contacts as they are added and removed. Then after the world step, I check to see how many contacts the polygon has. Two or three times as the circle moves across the polygon, the contact count after the world step is zero (this should only happen once, after the circle leaves the polygon).

EDIT: Updating to the latest revision in trunk (220) with the new fixtures stuff seems to solve the problem.
There's nothing wrong with the old system, but given the new exists, I cannot be bothered to explain how to use it.
BorisTheBrave wrote:
There's nothing wrong with the old system, but given the new exists, I cannot be bothered to explain how to use it.


Sorry to be a pain, but could you explain what I was doing wrong? I'd love to know what it was so I can avoid it in the future 🙂
There's multiple add and removes per shape-pair. You need to keep a running count of adds-removes in order to determine overlap.
BorisTheBrave wrote:
There's multiple add and removes per shape-pair. You need to keep a running count of adds-removes in order to determine overlap.


That's what (I think) I'm doing. Each of my game actors keeps an array of contacts. For each contact point, I add/remove one entry from each actor's contact array. So, if there are two contact points between Actor A and Actor B, there are two items in each actor's contact array.

Code:
void ContactListener::Add(const b2ContactPoint *point) {
   id<Actor> actor1 = (id<Actor>)point->shape1->GetBody()->GetUserData();
   id<Actor> actor2 = (id<Actor>)point->shape2->GetBody()->GetUserData();
   [actor1 addContact:actor2];
   [actor2 addContact:actor1];
}

void ContactListener::Remove(bconst b2ContactPoint *point) {
   id<Actor> actor1 = (id<Actor>)point->shape1->GetBody()->GetUserData();
   id<Actor> actor2 = (id<Actor>)point->shape2->GetBody()->GetUserData();
   [actor1 removeContact:actor2];
   [actor2 removeContact:actor1];
}


After the world step, I'm checking the length of each actor's contacts array and performing game logic. This works beautifully for everything except polygon sensors, which only work intermittently.
BorisTheBrave wrote:
There's nothing wrong with the old system, but given the new exists, I cannot be bothered to explain how to use it.


i don't get it.
if there is nothing wrong with the old system, is there a bug in my brain ? 😕
i expected contacts to be added/removed when a shape enters/leaves another shape, both just once.
meanwhile i expected to get just contactPersisted events.

in my game loop, once per frame, i step the world, then iterate through the contactpoints and send adds/removes/persists to both
bodies (userdata) classes. there should definitely happen just persisted contacts while inside a poly.

please give me a hint

greetz

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