Box2D Forums

It is currently Sun May 19, 2013 4:57 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 14 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Sat Jan 28, 2012 7:12 am 
Offline

Joined: Sat Jan 28, 2012 6:56 am
Posts: 15
In the API for b2DistanceJointDef, there is a warning
Quote:
Warning: Do not use a zero or short length.
Why shouldn't I create a soft distance joint with zero length? For example connect a body to the ground body at the same world point.

I couldn't find the reason for this anywhere (box2d manual, google..).
Any clarification is greatly appreciated. Thanks!


Top
 Profile  
 
PostPosted: Sat Jan 28, 2012 5:07 pm 
Offline

Joined: Sun Oct 25, 2009 3:28 am
Posts: 242
You can try it. Even if it does work, I can imagine b2DistanceJoint would be less effective than b2RevoluteJoint (since setting the two points at the same point would be the same thing).

But I have no idea why it says do not use a zero or short length for distance joints.


Top
 Profile  
 
PostPosted: Sat Jan 28, 2012 5:16 pm 
Offline

Joined: Sat Jan 28, 2012 6:56 am
Posts: 15
It isn't the same thing because you can use a soft distance joint to make the body bounce when it's hit.
I'm currently using distance joints with zero length, and it works good.

That's exactly why I'm asking, because maybe it affects performance and I don't realize it..?!


Top
 Profile  
 
PostPosted: Sun Jan 29, 2012 1:53 am 
Offline

Joined: Tue Jun 24, 2008 8:25 pm
Posts: 1515
Location: Tokyo
Could be something to do with how the deep black magic part of the engine works, maybe matrices go awry somehow...
Have you tried the weld joint... recently it was given some upgrades so that now you can give it a frequency and damping ratio. I have not tried it myself but it sounds like exactly what you need. That change was only a few months ago though, so you'll need an up to date version of Box2D.


Top
 Profile  
 
PostPosted: Sun Jan 29, 2012 1:40 pm 
Offline

Joined: Sat Jan 28, 2012 6:56 am
Posts: 15
@irresistible force Thanks.
However for a weld joint the frequency is for rotation only, as it says in the API. That's not what I need.

Basically what I want is a platform that is connected with 2 soft distance joints at each end to the ground. If something drops on the platform (from any angle) it will stretch (bounce), as shown in the image below.

Image


Top
 Profile  
 
PostPosted: Sun Jan 29, 2012 2:49 pm 
Offline

Joined: Tue Jun 24, 2008 8:25 pm
Posts: 1515
Location: Tokyo
I should have mentioned the mouse joint too, that could be a good match.


Top
 Profile  
 
PostPosted: Sun Jan 29, 2012 4:07 pm 
Offline

Joined: Sat Jan 28, 2012 6:56 am
Posts: 15
@irresistible force Thanks again! Indeed that looked promising.

I did some tests with 88 rectangle bodies joined together with revolute joints and each one having 2 mouse joints at each end and another test, same configuration but with zero length distance joints with the ground body instead of mouse joints.

The results are unexpected. The bodies using distance joints have far better performance than the ones using mouse joints.
So distance joints are still the best bet here.. even though it seamed that mouse joints are the way to go...


Top
 Profile  
 
PostPosted: Wed Feb 01, 2012 1:00 pm 
Offline
Site Admin

Joined: Thu Sep 06, 2007 12:34 am
Posts: 2931
What you really want is a soft revolute joint. Distance joints constrain motion along on one axis. When the points overlap the axis is undefined, so the distance joint can't do anything.

You could try altering a soft weld joint. Remove the rotational part.


Top
 Profile  
 
PostPosted: Wed Feb 01, 2012 2:50 pm 
Offline

Joined: Sat Jan 28, 2012 6:56 am
Posts: 15
Thanks Erin, I appreciate you made time to answer. I'll try to alter a weld joint then and remove the rotational part.


Top
 Profile  
 
PostPosted: Thu Feb 02, 2012 6:58 am 
Offline

Joined: Sat Jan 28, 2012 6:56 am
Posts: 15
Erin Catto wrote:
You could try altering a soft weld joint. Remove the rotational part.
Erin, I checked the weld joint code and I'm not quite sure I understand how to remove the rotational part as you said. Can you give me a little hint on how to do this please? Thanks!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 14 posts ]  Go to page 1, 2  Next

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: Google [Bot] and 3 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:
cron
Powered by phpBB® Forum Software © phpBB Group