Hello,
I am using box2d in openframeworks and i'm having a weird problem. I am trying to set the size of the box to query overlap but it only works at a single point instead of the bounds of the box i set.
For reference, here is some code from the ofxBox2d class to set mouse grabbing. I try to set d as a much bigger size but it only works at the precise mouse vector.
Am I missing something here or is this a bug? Any help is much appreciated!
I am using box2d in openframeworks and i'm having a weird problem. I am trying to set the size of the box to query overlap but it only works at a single point instead of the bounds of the box i set.
For reference, here is some code from the ofxBox2d class to set mouse grabbing. I try to set d as a much bigger size but it only works at the precise mouse vector.
Am I missing something here or is this a bug? Any help is much appreciated!
Code:
// Make a small box.
b2AABB aabb;
b2Vec2 d;
d.Set(0.001f, 0.001f);
aabb.lowerBound = p - d;
aabb.upperBound = p + d;
// Query the world for overlapping shapes.
QueryCallback callback(p);
world->QueryAABB(&callback, aabb);
if (callback.m_fixture) {
b2Body* body = callback.m_fixture->GetBody();
b2MouseJointDef md;
md.bodyA = mouseBody;
md.bodyB = body;
md.target = p;
md.maxForce = 1000.0f * body->GetMass();
mouseJoint = (b2MouseJoint*)world->CreateJoint(&md);
body->SetAwake(true);
}
b2AABB aabb;
b2Vec2 d;
d.Set(0.001f, 0.001f);
aabb.lowerBound = p - d;
aabb.upperBound = p + d;
// Query the world for overlapping shapes.
QueryCallback callback(p);
world->QueryAABB(&callback, aabb);
if (callback.m_fixture) {
b2Body* body = callback.m_fixture->GetBody();
b2MouseJointDef md;
md.bodyA = mouseBody;
md.bodyB = body;
md.target = p;
md.maxForce = 1000.0f * body->GetMass();
mouseJoint = (b2MouseJoint*)world->CreateJoint(&md);
body->SetAwake(true);
}