Since I don't use visual c++ or the Microsoft compiler anymore I am using gcc to compile and for windows it's mingw. I'll see if I can patch it up and come up with a test case.
How to create a fixed joint - Solved with code
General DiscussionHello,
I managed to reproduce your problem. The problem happens because the length of the fixed joint is quite long in your example, and in this case the b2FixedJoint::SolvePositionConstraints apparently starts adding energy to the system which causes it to behave erratically (I had to make an approximation in that function so I have a pretty good idea where the problem comes from). If you change the contents of the function with 'return true' then you'll see that the system is stable (but the boxes will slowly drift apart when you start throwing them around).
If you use the constraint for breakable objects (which basically means the bodies touch eachother) the problem will be much less noticable.
I'll see if I can get this problem sorted, but I think it will be a while before I have time to dig into this.
I managed to reproduce your problem. The problem happens because the length of the fixed joint is quite long in your example, and in this case the b2FixedJoint::SolvePositionConstraints apparently starts adding energy to the system which causes it to behave erratically (I had to make an approximation in that function so I have a pretty good idea where the problem comes from). If you change the contents of the function with 'return true' then you'll see that the system is stable (but the boxes will slowly drift apart when you start throwing them around).
If you use the constraint for breakable objects (which basically means the bodies touch eachother) the problem will be much less noticable.
I'll see if I can get this problem sorted, but I think it will be a while before I have time to dig into this.
Going forward, I will be putting user contributions like this into the contributions folder, rather than in the main code. This should be sorted out for the next release.
I recommend against using fixed joints. They give people the idea that they should use fixed joints for breakable bodies. However, the iterative solver will not be able to keep all the pieces together rigidly.
I recommend against using fixed joints. They give people the idea that they should use fixed joints for breakable bodies. However, the iterative solver will not be able to keep all the pieces together rigidly.
Yeah, it definitely looks to be the case that unless you need the forces/torques, you are much much better off figuring out a system where you combine bodies by (temporarily) putting their shapes into one body.
dc443 wrote:
Yeah, it definitely looks to be the case that unless you need the forces/torques, you are much much better off figuring out a system where you combine bodies by (temporarily) putting their shapes into one body.
Can you elaborate on this please? Does Box2D support adding shapes to bodies on the fly?Isn't there a testbed demo that lets you dynamically change the shapes on a body?
I don't even tihnk you need to do a refilter, you just have to be sure you do a SetMassFromShapes().
I don't even tihnk you need to do a refilter, you just have to be sure you do a SetMassFromShapes().
Hello,
I've fixed the long joint issue. I've updated the document and code at http://jrouwe.nl/fixedjoint/ and I've attached the code for SVN revision 222. I hope this was the last issue.
Jorrit.
I've fixed the long joint issue. I've updated the document and code at http://jrouwe.nl/fixedjoint/ and I've attached the code for SVN revision 222. I hope this was the last issue.
Jorrit.
I appreciate this work, Jorrit. I just tested it a bit and it looks great. Can't thank you enough.
Hello Erin, BorisTheBrave,
It has been a couple of months now and I see that the broken b2FixedJoint code is still in the repository. Can you please either delete the b2FixedJoint from the repostitory or check in the fixed version that I attached to my last post. Alternatively you can give me sourceforge access (account jrouwe) to box2d and I'll update it for you. I don't like leaving broken code hanging around...
Thanks,
Jorrit.
It has been a couple of months now and I see that the broken b2FixedJoint code is still in the repository. Can you please either delete the b2FixedJoint from the repostitory or check in the fixed version that I attached to my last post. Alternatively you can give me sourceforge access (account jrouwe) to box2d and I'll update it for you. I don't like leaving broken code hanging around...
Thanks,
Jorrit.
I don't have any source access either, Jorrit, Erin's keeping a tight ship on things. You've probably missed it, but r28 adds a core "Weld" joint, which is functionally the fixed joint with a few frills. The wider issue is that user contributed joints are somehow meant to go Contributions/, but there's no way to properly add joint types without modifying core files.
Original thread: https://box2d.org/forum/viewtopic.php?t=3340