JBullet source code

Hi,



I need to build the JBullet stuff from source to put some debug stuff in. I have the official JBullet download but this is missing some functions that I assume you have added in your own branch? If so is this branch available for checkout?



Thanks,



Matt

I was searching for jbullet source code for debug purposes the other day

I found most of the things here but i dont know if its the latest version

1 Like

I found that too and it looked right but there is no setPreTickCallback method on the DiscreteDynamicsWorld class. Hmmmm

mattm said:
I found that too and it looked right but there is no setPreTickCallback method on the DiscreteDynamicsWorld class. Hmmmm

No, its only in my local build because I haven't implemented it like in the native bullet atm (I guess, didnt look at how its done natively), I only want to commit changes that are a direct copy of the native versions change. Apart from that this is the version of jbullet that jME3 uses, it has some improvements to characters, wheels and heightmap collision compared to the main jbullet branch.

Edit: But mostly you wont have to debug in the jbullet source, when its native that wont be possible anymore anyway.. Common problems with jbullet can easily be solved by enabling assertions, jbullet has a lot of assertion checks. Most of the time I thought bullet had a bug it was me adding a physics object multiple times to the physics space.
1 Like

I am trying to find out why, after about 3000 ticks, I get a different result between my client for exactly the same input data and walk direction. To do this I really need to put some debug script into the physics at each step to find out why it is different; unfortunately the asserts are not present where I need this information.



Matt

Would it be possible to prehaps have a copy of just the DiscreteDynamicsWorld java file so I can give this a go without having to hack my own pre-tick listener code into the main bullet branch? I have no intention of copying it etc, I am just interested in where the inaccuracy occurs. The difference is tiny, and wont make a difference to my game, but I cant for the life of me see where anything other than the fixed step is used for the KinematicCharacter controller and so cannot see what could be different given the same input!



Thanks,



Matt

Sure thing, heres a patch:

[patch]# This patch file was generated by NetBeans IDE

Following Index: paths are relative to: /Users/normenhansen/Documents/Code/jbullet/src/com/bulletphysics/dynamics

This patch can be applied using context Tools: Patch action on respective folder.

It uses platform neutral UTF-8 encoding and n newlines.

Above lines and this line are ignored by the patching process.

Index: DiscreteDynamicsWorld.java

— DiscreteDynamicsWorld.java Remotely Modified (Based On HEAD)

+++ DiscreteDynamicsWorld.java Locally Modified (Based On LOCAL)

@@ -86,6 +86,8 @@



protected int profileTimings = 0;


  •    protected InternalTickCallback preTickCallback;<br />
    

+

public DiscreteDynamicsWorld(Dispatcher dispatcher, BroadphaseInterface pairCache, ConstraintSolver constraintSolver, CollisionConfiguration collisionConfiguration) {

super(dispatcher, pairCache, collisionConfiguration);

this.constraintSolver = constraintSolver;

@@ -359,6 +361,10 @@

protected void internalSingleStepSimulation(float timeStep) {

BulletStats.pushProfile("internalSingleStepSimulation");

try {

  •                    if (preTickCallback != null) {<br />
    
  •   		preTickCallback.internalTick(this, timeStep);<br />
    
  •   	}<br />
    

+

// apply gravity, predict motion

predictUnconstraintMotion(timeStep);



@@ -1060,6 +1066,10 @@

public void setNumTasks(int numTasks) {

}


  •    public void setPreTickCallback(InternalTickCallback callback){<br />
    
  •            preTickCallback = callback;<br />
    
  •    }<br />
    

+

////////////////////////////////////////////////////////////////////////////



private static final Comparator<TypedConstraint> sortConstraintOnIslandPredicate = new Comparator<TypedConstraint>() {

[/patch]



Edit: btw, you should be able to get clickable stack traces for bullet by simply adding a link to the sources (don’t have to be exactly the same) to the jme3 libraries (Tools->Libraries)

Fantastic, thank you very much. I got the sources linked but they seem quite different and I also have the problem that the issue only occurs very rarely, and I only know after the physics steps that it has done so!

I can explain, in most physic engine ( i think newton is a expection here) are mathematically unstable calculations. Normally you won’t notice but it is not guranteed to behave exactly identicall.

Err, no. Bullet is deterministic. As long as the fps does not go lower than accuracy/stepSize all should be 100% predictable

Thanks for that code. I think (99% positive_ that it happens when I remove and then add an object to physics space. Although it is added at the same position etc I think that there is some penetration variable that is slightly different to how it was if it remained in the scene. Not an issue, and nice to get to the bottom of.



Matt

1 Like

Thanks for the detailed report.

Err, no. Bullet is deterministic. As long as the fps does not go lower than accuracy/stepSize all should be 100% predictable


Actually, in the way I am using it, even when the fps drops right down I should get the same behaviour on the client and the server and I do, but only by adding a sneaky method into the KinematicController that effectively switches it off without taking it out the physics space! (I know this will not work in future, but it allowed me to prove a point. The reason that the framerate does not matter to me is that I only peform a tick for given entity on the server when I have a message telling me a move occurred. The Server side ticker does not tick itself, it is purely event driven. As long as I feed all the events from the client then it stays the same!

I can move onto the interesting stuff now. Haven't fired up Blender since before it was open sourced (yes, that long ago!) so look forward to using it again.

Matt

Hello,



I need to build the JBullet stuff from source and I have this message



GRAVE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]

java.lang.Error: not instrumented1

at cz.advel.stack.Stack.alloc(Stack.java:118)

at com.bulletphysics.collision.shapes.StridingMeshInterface.internalProcessAllTriangles(StridingMeshInterface.java:48)

at com.bulletphysics.collision.shapes.StridingMeshInterface.calculateAabbBruteForce(StridingMeshInterface.java:87)

at com.bulletphysics.collision.shapes.BvhTriangleMeshShape.(BvhTriangleMeshShape.java:83)

at com.bulletphysics.collision.shapes.BvhTriangleMeshShape.(BvhTriangleMeshShape.java:69)

at com.jme3.bullet.collision.shapes.MeshCollisionShape.createShape(MeshCollisionShape.java:122)

at com.jme3.bullet.collision.shapes.MeshCollisionShape.createCollisionMesh(MeshCollisionShape.java:77)

at com.jme3.bullet.collision.shapes.MeshCollisionShape.(MeshCollisionShape.java:65)

at com.jme3.bullet.util.CollisionShapeFactory.createSingleMeshShape(CollisionShapeFactory.java:174)

at com.jme3.bullet.util.CollisionShapeFactory.createCompoundShape(CollisionShapeFactory.java:67)

at com.jme3.bullet.util.CollisionShapeFactory.createCompoundShape(CollisionShapeFactory.java:62)

at com.jme3.bullet.util.CollisionShapeFactory.createCompoundShape(CollisionShapeFactory.java:62)

at com.jme3.bullet.util.CollisionShapeFactory.createCompoundShape(CollisionShapeFactory.java:62)

at com.jme3.bullet.util.CollisionShapeFactory.createCompoundShape(CollisionShapeFactory.java:85)

at com.jme3.bullet.util.CollisionShapeFactory.createMeshCompoundShape(CollisionShapeFactory.java:94)

at com.jme3.bullet.util.CollisionShapeFactory.createMeshShape(CollisionShapeFactory.java:134)

at Test.TestAppStates.initialize(TestAppStates.java:385)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:136)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:193)

at java.lang.Thread.run(Thread.java:662)



Thank you

So you’re doing it wrong. Use the ant build script.

I would like to merge some change in jbullet (like Spring, may be using jme’sVector and TempVar vs vecmath + stack-alloc). But the regular jbullet doesn’t work with jme3-jbullet. So where can I found the current (2014) source (github, svn) ?

@david.bernard.31 said: I would like to merge some change in jbullet (like Spring, may be using jme'sVector and TempVar vs vecmath + stack-alloc). But the regular jbullet doesn't work with jme3-jbullet. So where can I found the current (2014) source (github, svn) ?

I don’t know if jbullet is worth this work as we move to native bullet anyway, but the source of the jbullet version we use is still here:
http://code.google.com/p/jbullet-jme/source/browse/#svn%2Fbranches%2Fjbullet%2Fsrc%2Fcom%2Fbulletphysics

Thanks. As I wrote in other Thread, jvm crash with native bullet in my case.

@normen said: I don't know if jbullet is worth this work as we move to native bullet anyway, but the source of the jbullet version we use is still here: http://code.google.com/p/jbullet-jme/source/browse/#svn%2Fbranches%2Fjbullet%2Fsrc%2Fcom%2Fbulletphysics

As a fallback for unsupported unknown client plaforms it’s always nice to have. (Eg the macbook of my prof, where for unknown reasons the native crashes, but only his one, others do work ^^)

@david.bernard.31 said: Thanks. As I wrote in other Thread, jvm crash with native bullet in my case.

Native bullet is still in alpha but it will replace jbullet at some point as said.