Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constructors. #14

Open
schteppe opened this issue Oct 14, 2011 · 6 comments
Open

Constructors. #14

schteppe opened this issue Oct 14, 2011 · 6 comments

Comments

@schteppe
Copy link

I was just wondering, is it possible to use other constructors of Bullet classes than the first?

For example, the btHingeConstraint. It's got four constructors:

new Ammo.btHingeConstraint (rbA, rbB, pivotInA, pivotInB, axisInA, axisInB, useReferenceFrameA)
new Ammo.btHingeConstraint (rbA, pivotInA, axisInA, useReferenceFrameA)
new Ammo.btHingeConstraint (rbA, rbB, rbAFrame, rbBFrame, useReferenceFrameA)
new Ammo.btHingeConstraint (rbA, rbAFrame, useReferenceFrameA)

(See http://www.bulletphysics.com/Bullet/BulletFull/classbtHingeConstraint.html for full doc.)

The first constructor seems to work (see the ragdoll demo), but nothing happens when I try any other constructor. Did I miss something obvious here?

@kripken
Copy link
Owner

kripken commented Oct 14, 2011

It should be possible to use different overloaded constructors, assuming they are differentiated by the number of parameters.

For btHingeConstraint, looking in the generated code (bullet/build/bindings.js or builds/ammo.new.js - they only exist if you build locally though), there is

function btHingeConstraint(arg0, arg1, arg2, arg3, arg4, arg5, arg6) {
  if (arg3 === undefined)
    this.ptr = _emscripten_bind_btHingeConstraint__btHingeConstraint_p3(arg0.ptr, arg1.ptr, arg2.ptr);
  else   if (arg4 === undefined)
    this.ptr = _emscripten_bind_btHingeConstraint__btHingeConstraint_p4(arg0.ptr, arg1.ptr, arg2.ptr, arg3);
  else   if (arg6 === undefined)
    this.ptr = _emscripten_bind_btHingeConstraint__btHingeConstraint_p6(arg0.ptr, arg1.ptr, arg2.ptr, arg3.ptr, arg4.ptr, arg5.ptr);
  else 
    this.ptr = _emscripten_bind_btHingeConstraint__btHingeConstraint_p7(arg0.ptr, arg1.ptr, arg2.ptr, arg3.ptr, arg4.ptr, arg5.ptr, arg6);
  btHingeConstraint.prototype.__cache__[this.ptr] = this;
  this.__class__ = btHingeConstraint;
}

which looks like it handles the 4 cases. Or at least tries to - I haven't tested it myself ;)

Can you provide a testcase that shows the problem you are seeing?

@schteppe
Copy link
Author

After working some more with this, I realized there is nothing wrong with the constructors. I can use the two first constructors without problem, see my double pendulum at: http://granular.cs.umu.se/ammo/Demos/PendulumDemo/

I cannot seem to be able to use the 3rd or 4th constructor though (which uses local frames). No matter how I use them, the constraint seem to be unsolveable and blow up.

I have tried to port the Ragdolldemo from the original Bullet Physics trunk and also this simple demo: http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?f=9&t=3191, without success.

I'm fine with using pivots and axes, but I find it annoying to not be able to use frames. I'll do some more testing and come back.

Did anyone else try to use the frame-based hinge constraints?

@RodrigoHamuy
Copy link

Hi @schteppe , did you found the issue with this?
I was trying to port the FokLiftDemo from Bullet and it uses the frame-based btHingeConstraint. Whenever I apply this hinge my objects will get NaN positions.

@schteppe
Copy link
Author

@RodrigoHamuy it was a loooong time ago... Don't really remember. If I solved it back then, you can probably find the solution here: https://github.com/schteppe/ammo.js-demos

@RodrigoHamuy
Copy link

Thanks @schteppe ! The frame based constructor is there now. The issue for me was that it didn't work if you set the hinge limit to 0,0. Instead, I use 0.0001 now and it works.
Anyway, yeah, this is a super old issue, thanks for answering!

@bberak
Copy link

bberak commented Apr 30, 2020

Hey @RodrigoHamuy can you give some more details about your fix? I've set my limits to 0.0001 but I'm still getting NaN values for my body transformations..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants