Reputation: 804
i'm using box2D mouse joint to drag the objects but i'm stuck in a strange issue that bodies are not responding to the moved function because
if (currentFixture->TestPoint(worldPoint)) {
always return false for some specific bodies.
From above image "Yellow" body is draggable but from some position like centre or bottom of body but not from top.
Note: Bodies are created using "PhysicEditor" so the bodies are "b2PolygonShape".
Edit: Bodies without Textures... i think the problem is that vertex lines are intersecting each other.
Edit2: using R.U.B.E same result here too.
Upvotes: 0
Views: 449
Reputation: 8262
When bodies have multiple fixtures, you need to check every fixture:
bool touchingBody( b2Body* b, b2Vec2 worldPoint )
{
bool bodyIsTouched = false;
for (b2Fixture* f = b->GetFixtureList(); f; f = f->GetNext()) {
if ( bodyIsTouched = f->TestPoint(worldPoint) )
break;
}
return bodyIsTouched;
}
Upvotes: 1