[committed] JBullet code changes

So, at erlend_sh's request, I'm posting changes to the JBullet implementation, and if I get no objections, will find a place to commit it.  (or have somebody do it for me.)



At this point, it looks like I have joints, and basic dynamics & collisions figured out.  JBullet is REALLY, REALLY twitchy with default material settings, and at this point the only material setting I'm using is density, so it'll take AT LEAST another release before I'm happy with things.  It also means none of the material-specific tests work, but here's a start at least.



Fixes include:


  • proper handling of center of mass (at least, as far as I can tell)
  • Joint construction is now done correctly including

       1 axis translational (slider)

       1 axis rotational (hinge)

       3 axis rotational (6DOF)
  • code is available for 2axis rotational, but is still odd.  I would welcome input, but continue to debug.



    Library change includes:


  • upgraded jbullet.jar to 2.70-beta version. - cannot attach . . . check here for latest jar.



    Code changes include:



    com.jmex.physics.impl.jbullet.JBulletPhysicsSpace:

    line 102 - changed implementation version to 2.70b

    line 349 - changed to ‘dynamicsWorld.stepSimulation(time,600);’ from previous code to make timing variable instead of fixed. (up to a maximum 10 second time delta);



    com.jmex.physics.impl.jbullet.JBulletRigidBody
  • removed the com.bulletphysics.BulletGlobals import
  • removed methods getGravity(), getCenterOfMassPosition(), and setCenterOfMassPosition()



    com.jmex.physics.impl.jbullet.geometry.JBulletGeometry
  • added com.jmex.physics.material.Material to imports
  • added 'public Material getMaterial()' and 'public void setMaterial(Material)' methods to the interface.  Implementation was already present.



    com.jmex.physics.impl.jbullet.joints.JBulletJoint
  • many modifications.  See attached file.



    com.jmex.physics.impl.jbullet.JBulletDynamicPhysicsNode
  • many modifications.  See attached file.



    That should cover it.  It's not perfect yet, but it's less FUBAR than the last attempt.  I welcome feedback and comments.



    Remember, as this is a largely inactive and currently non-functional part of the code anyway, I'm not striving for perfection . . . just forward progress.  I'm sure there's some refactoring to be done (especially in the joint creation code) and optimizations to be made, but I think getting working code out for people to debug is more important at this point.



    Comments?  Criticism?  I'm open to both.



    -Falken224



    <editied due to cut & paste wrong code>
Comments?  Criticism?  I'm open to both.

A comment could be a Critism, too, couldn't it? :wink:

But mine is a positive one ;)

Go one with your work, I'm sure it will help people.
And though i'm not familiar with jBullet, nor familiar with jMEPhysics (well I use it  :D, but not develop it ;))
I'm thinking that this will improve things without side-effects.  :)

Hizah! People are working on JMEPhysics and the JBullet implementation again!  :smiley:

Great that you work on the jBullet-integration, cause ODE is not usable for anything serious.

Keep up the good work! :slight_smile:

Just bumping this topic, as I got a bunch more done over the week since I posted this.  More problems fixed, new bugs I introduced with the last posted changes fixed, collision event triggering wired, some material properties wired, joint axes wired up to correctly read / change joint properties on the fly.



In short . . . lots of changes . . . too much to post here.  If anyboy's interested, feel free to msg me privately, and I can send you a .zip with the code for inspection.



-Falken

So, I created a new branch on the jmephysics project specifically for this jbullet integration.  I just committed my latest changes which should include the following:


  • All joints wired up (except 2x rotational which is still eluding me)
  • Correct collisions (FINALLY) including proper center of mass compensation.
  • Geometry-accurate collision detection, and events. (BTW . . . capability exists to do triangle accurate, if anybody's interested.)
  • Contact Callbacks are being executed properly.  (Though PhysicsCallbacks are not)
  • auto-rest threshold can be set.
  • SOME joint axis properties are wired up, though many are still not.
  • SOME material properties are wired up, though many are still not.



    From a code standpoint:
  • created the ShapeProxy interface and subclasses to allow geometry-accurate collision detection.
  • Added subclasses of the JBullet-specific joints to make them more easy to encapsulate joint-specific logic.  (not there yet, but laying the groundwork.)



    And that's it for the moment.  This should be a pretty big leap forward from the last release, though not perfect by any means.  I'll keep working, but it's gonna be a lot of niggly details from here on.



    Next up . . . Rays, PhysicsPicker, and Physics Callbacks.  The rest is details.



    This branch is at:



    http://jmephysics.googlecode.com/svn/branches/jbullet-integration



    Please give feedback as you have it.



    -Falken224

Awesome work Falken! I will keep reiterating the importance of this project for as long as it takes until we get to see an additional physics guru or two sign up for the fun.



So, is this technically your first commit? Just saying, from now on it would be best if you keep separate commits to separate commit posts, as it makes them a whole lot easier to refer back to, something you should get used to doing back-to-back between googlecode and the forum.

yeah, first commit, technically.  Kind of a milestone, I guess.  :slight_smile:



And I'm still kinda getting used to the process here, so feel free to kick me in the shins if I'm doing things a little wacky.  I know there's a ton in there, but I haven't wanted to stop working just 'cause I didn't have access.  From now on it'll prolly be a bit more bite-sized.



And by separate commit posts . . . you mean new topics?  If so, I'll make sure to do that in the future.



In the meantime, I hope this is a step in the right direction.



:slight_smile:

Falken224 said:
And by separate commit posts . . . you mean new topics?  If so, I'll make sure to do that in the future.
That's what I mean, yeah. But basically we are talking about substantial changes in code here. Basically when you want the other users to review something. You don't necessarily have to post all/parts of your code in the thread (though I think a lot of people prefer and appreciate you doing that) but make sure to start a new thread and make some proper pointers when there's code to be reviewed.

I looked at the JBullet-jMEphysics code branch, it seems to be mostly complete right? You're using some classes which now have more efficient replacements, in the last version of JBullet you have AxisSweep3 where in your code you mention it's not available.

Actually, yes, I'm working on swapping that out right now.  Earlier it was unavailable.



In fact the 2x rotational joints are going to stay broken for the time being due to the lack of the Hinge2Constraint, which I need in order to get it all working.  I've got a few other parts of that I'm working to put together, but part of fixing up the code is putting the pieces of JBullet in place that have been added.



Funny you should mention the AxisSweep3 since I JUST ran across that about 10 minutes ago.  Was working on forcing collision checks (i.e. PhysicsSpace.collide()) and had to dig into the broadphase handlers, and discovered the new AxisSweep3 stuff.  (And the AxisSweep3_32, for those that REEEEAAAAALLLY need a ton of objects!)



Happy accidents abound.  :) 



Although that discovery prompted me to go digging through the JBullet changelogs, and the actual Bullet Physics project documentation.  There's a fair bit of porting work left to be done in JBullet, and he doesn't seem to be going about it terribly quickly.  I'll keep my eyes out for changes, but I wouldn't expect this library to be production-ready any time soon.  It kinda reinforces my thoughts that this is a good START, but that to get a real physics engine we're going to have to go native at some point.  :expressionless:



But in the meantime, 'til I get this as polished as I can, I'll keep plugging away.  I'm hoping by the end of the week to be able to commit another chunk for further evaluation.  'til then, keep the comments rolling in.

Are the commited changes in the google code svn, or did you commit them to a different branch or something?  :?

I committed them to a branch.  I'm not quite ready to start screwing around with trunk at the moment.  :slight_smile:



http://jmephysics.googlecode.com/svn/branches/jbullet-integration



That should do it for you.