Hamdullah shah
Hamdullah shah

Reputation: 804

Box2D mouse Joint issue while dragging. TestPoint function return false

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.

enter image description here

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.

enter image description here

Edit2: using R.U.B.E same result here too.

enter image description here

Upvotes: 0

Views: 449

Answers (1)

iforce2d
iforce2d

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

Related Questions