Box2D Forums

It is currently Fri May 24, 2013 1:29 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: b2MouseJoint Issue
PostPosted: Tue Jan 17, 2012 2:25 pm 
Offline

Joined: Wed Sep 07, 2011 12:38 pm
Posts: 8
Hello,

I'm not sure what I'm doing wrong here, but every time I create a mouse joint like so:
Code:
                b2MouseJointDef mouseJointDef;
                mouseJointDef.maxForce = 100;
                mouseJointDef.bodyA = body;
                mouseJointDef.bodyB = m_groundBody;
                mouseJointDef.target = b2Vec2(10, 10);

                m_mouseJoint = (b2MouseJoint *)m_world->CreateJoint(&mouseJointDef);


I get this at the next call to Step()

Code:
/build/src/Box2D_v2.2.1/Box2D/Dynamics/Joints/b2MouseJoint.cpp:125: virtual void b2MouseJoint::InitVelocityConstraints(const b2SolverData&): Assertion `d + h * k > 1.19209289550781250000e-7F' failed.
Aborted


d + h * k is extremely vague, and I was hoping you guys could keep me from pulling my hair out. Can anyone decode this for me? I'm clueless as to what's wrong.


Top
 Profile  
 
 Post subject: Re: b2MouseJoint Issue
PostPosted: Tue Jan 17, 2012 9:04 pm 
Offline

Joined: Tue Jun 24, 2008 8:25 pm
Posts: 1517
Location: Tokyo
Try making body A the ground.


Top
 Profile  
 
 Post subject: Re: b2MouseJoint Issue
PostPosted: Tue Jan 17, 2012 11:09 pm 
Offline

Joined: Wed Sep 07, 2011 12:38 pm
Posts: 8
Interesting... That seemed to have worked. What is the proper way to initialize a ground body? Now that the mouse joint is applied properly the body flies around the page.

EDIT: My problem was that I wasn't using the target property on the b2MouseJointDef class. Problem solved. Thanks!


Last edited by roadkillguy on Wed Jan 18, 2012 12:19 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: b2MouseJoint Issue
PostPosted: Tue Jan 17, 2012 11:53 pm 
Offline

Joined: Tue Jun 24, 2008 8:25 pm
Posts: 1517
Location: Tokyo
The default values for b2BodyDef are set as a static body positioned at 0,0 so it could be as simple as:
Code:
b2Body* groundBody = world->CreateBody( &b2BodyDef() );
... although some compilers will not like that :) Typically you would do:
Code:
b2BodyDef bodyDef;
b2Body* groundBody = world->CreateBody( &bodyDef );

Are you moving the anchor point somehow? If not, it should settle down pretty quickly even when the initial movement is large.


Top
 Profile  
 
 Post subject: Re: b2MouseJoint Issue
PostPosted: Wed Jan 18, 2012 12:21 am 
Offline

Joined: Wed Sep 07, 2011 12:38 pm
Posts: 8
Whoops, didn't see your post.

I wasn't using the target property of b2MouseJointDef, and for whatever reason that caused the body to fly to the bottom right whenever I called SetTarget().

Thanks for the help


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group