Native bullet bug fix

Momoko_Fan said:
Do we need some kind of special GCC version to compile for android? Perhaps we can add it to the build script

Yes, as said, would be awesome if somebody got it to work with the script. Same for all other missing platforms.

Hi.

I forgot to say an important thing.

The profiler of bullet physics is not thread safe on some platforms(Solaris, Linux etc.).

Please disable profiler.



LinearMath/btQuickprof.h

[java]

#ifndef QUICK_PROF_H

#define QUICK_PROF_H



//To disable built-in profiling, please comment out next line

#define BT_NO_PROFILE 1 // <


remove comment
#ifndef BT_NO_PROFILE
[/java]
1 Like

Android patch

[patch]

diff -r 05978cf01219 -r c7f8ca96d04c engine/src/bullet/native/com_jme3_bullet_objects_PhysicsGhostObject.cpp

ā€” a/engine/src/bullet/native/com_jme3_bullet_objects_PhysicsGhostObject.cpp Sun Oct 16 01:12:02 2011 +0900

+++ b/engine/src/bullet/native/com_jme3_bullet_objects_PhysicsGhostObject.cpp Mon Oct 17 23:58:18 2011 +0900

@@ -183,8 +183,9 @@

{

btCollisionObject *co1 = (btCollisionObject *)pair.m_pProxy0->m_clientObject;

jmeUserPointer up1 = (jmeUserPointer)co1 -> getUserPointer();

-

  •        m_env-&gt;CallVoidMethod(m_object, jmeClasses::PhysicsGhostObject_addOverlappingObject, up1-&gt;javaCollisionObject);<br />
    
  •        jobject javaCollisionObject1 = m_env-&gt;NewLocalRef(up1-&gt;javaCollisionObject);<br />
    
  •        m_env-&gt;CallVoidMethod(m_object, jmeClasses::PhysicsGhostObject_addOverlappingObject, javaCollisionObject1);<br />
    
  •        m_env-&gt;DeleteLocalRef(javaCollisionObject1);<br />
    

if (m_env->ExceptionCheck()) {

m_env->Throw(m_env->ExceptionOccurred());

return false;

diff -r 05978cf01219 -r c7f8ca96d04c engine/src/bullet/native/com_jme3_bullet_util_DebugShapeFactory.cpp

ā€” a/engine/src/bullet/native/com_jme3_bullet_util_DebugShapeFactory.cpp Sun Oct 16 01:12:02 2011 +0900

+++ b/engine/src/bullet/native/com_jme3_bullet_util_DebugShapeFactory.cpp Mon Oct 17 23:58:18 2011 +0900

@@ -90,8 +90,8 @@

(JNIEnv env, jclass clazz, jlong shapeId, jobject callback) {

btCollisionShape
shape = (btCollisionShape*) shapeId;

if (shape->isConcave()) {

  •        fprintf(stdout,&quot;Concave shape&quot;);<br />
    
  •        fflush(stdout);<br />
    

+// fprintf(stdout,"Concave shape");

+// fflush(stdout);

btConcaveShape* concave = (btConcaveShape*) shape;

DebugCallback* clb = new DebugCallback(env, callback);

btVector3 min = btVector3(-1e30, -1e30, -1e30);

@@ -99,8 +99,8 @@

concave->processAllTriangles(clb, min, max);

delete(clb);

} else if (shape->isConvex()) {

  •        fprintf(stdout,&quot;Convex shape&quot;);<br />
    
  •        fflush(stdout);<br />
    

+// fprintf(stdout,"Convex shape");

+// fflush(stdout);

btConvexShape* convexShape = (btConvexShape*) shape;

// Check there is a hull shape to render

if (convexShape->getUserPointer() == NULL) {

diff -r 05978cf01219 -r c7f8ca96d04c engine/src/bullet/native/jmeClasses.cpp

ā€” a/engine/src/bullet/native/jmeClasses.cpp Sun Oct 16 01:12:02 2011 +0900

+++ b/engine/src/bullet/native/jmeClasses.cpp Mon Oct 17 23:58:18 2011 +0900

@@ -30,6 +30,7 @@

  • SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

    */

    #include "jmeClasses.h"

    +#include <stdio.h>



    /**
  • Author: Normen Hansen

    diff -r 05978cf01219 -r c7f8ca96d04c engine/src/bullet/native/jmePhysicsSpace.cpp

    ā€” a/engine/src/bullet/native/jmePhysicsSpace.cpp Sun Oct 16 01:12:02 2011 +0900

    +++ b/engine/src/bullet/native/jmePhysicsSpace.cpp Mon Oct 17 23:58:18 2011 +0900

    @@ -48,7 +48,11 @@

    }



    void jmePhysicsSpace::attachThread() {
  • vm->AttachCurrentThread((void **) &env, NULL);

    +#ifdef ANDROID
  • vm->AttachCurrentThread(&env, NULL);

    +#else
  • vm->AttachCurrentThread((void )&env, NULL);

    +#endif

    }



    JNIEnv
    jmePhysicsSpace::getEnv() {

    @@ -203,20 +207,28 @@

    void jmePhysicsSpace::preTickCallback(btDynamicsWorld world, btScalar timeStep) {

    jmePhysicsSpace
    dynamicsWorld = (jmePhysicsSpace
    ) world->getWorldUserInfo();

    JNIEnv* env = dynamicsWorld->getEnv();
  • env->CallVoidMethod(dynamicsWorld->getJavaPhysicsSpace(), jmeClasses::PhysicsSpace_preTick, timeStep);
  • if (env->ExceptionCheck()) {
  •    env-&gt;Throw(env-&gt;ExceptionOccurred());<br />
    
  •    return;<br />
    
  • jobject javaPhysicsSpace = env->NewLocalRef(dynamicsWorld->getJavaPhysicsSpace());
  • if (javaPhysicsSpace != NULL) {
  •    env-&gt;CallVoidMethod(javaPhysicsSpace, jmeClasses::PhysicsSpace_preTick, timeStep);<br />
    
  •    env-&gt;DeleteLocalRef(javaPhysicsSpace);<br />
    
  •    if (env-&gt;ExceptionCheck()) {<br />
    
  •        env-&gt;Throw(env-&gt;ExceptionOccurred());<br />
    
  •        return;<br />
    
  •    }<br />
    

}

}



void jmePhysicsSpace::postTickCallback(btDynamicsWorld world, btScalar timeStep) {

jmePhysicsSpace
dynamicsWorld = (jmePhysicsSpace*) world->getWorldUserInfo();

JNIEnv* env = dynamicsWorld->getEnv();

  • env->CallVoidMethod(dynamicsWorld->getJavaPhysicsSpace(), jmeClasses::PhysicsSpace_postTick, timeStep);
  • if (env->ExceptionCheck()) {
  •    env-&gt;Throw(env-&gt;ExceptionOccurred());<br />
    
  •    return;<br />
    
  • jobject javaPhysicsSpace = env->NewLocalRef(dynamicsWorld->getJavaPhysicsSpace());
  • if (javaPhysicsSpace != NULL) {
  •    env-&gt;CallVoidMethod(javaPhysicsSpace, jmeClasses::PhysicsSpace_postTick, timeStep);<br />
    
  •    env-&gt;DeleteLocalRef(javaPhysicsSpace);<br />
    
  •    if (env-&gt;ExceptionCheck()) {<br />
    
  •        env-&gt;Throw(env-&gt;ExceptionOccurred());<br />
    
  •        return;<br />
    
  •    }<br />
    

}

}

bool jmePhysicsSpace::contactProcessedCallback(btManifoldPoint &cp, void *body0, void *body1) {

@@ -229,10 +241,18 @@

jmePhysicsSpace dynamicsWorld = up0->space;

if (dynamicsWorld != NULL) {

JNIEnv
env = dynamicsWorld->getEnv();

  •        env-&gt;CallVoidMethod(dynamicsWorld-&gt;getJavaPhysicsSpace(), jmeClasses::PhysicsSpace_addCollisionEvent, up0-&gt;javaCollisionObject, up1-&gt;javaCollisionObject, (jlong)&amp;cp);<br />
    
  •        if (env-&gt;ExceptionCheck()) {<br />
    
  •            env-&gt;Throw(env-&gt;ExceptionOccurred());<br />
    
  •            return true;<br />
    
  •        jobject javaPhysicsSpace = env-&gt;NewLocalRef(dynamicsWorld-&gt;getJavaPhysicsSpace());<br />
    
  •        if (javaPhysicsSpace != NULL) {<br />
    
  •            jobject javaCollisionObject0 = env-&gt;NewLocalRef(up0-&gt;javaCollisionObject);<br />
    
  •            jobject javaCollisionObject1 = env-&gt;NewLocalRef(up1-&gt;javaCollisionObject);<br />
    
  •            env-&gt;CallVoidMethod(javaPhysicsSpace, jmeClasses::PhysicsSpace_addCollisionEvent, javaCollisionObject0, javaCollisionObject1, (jlong)&amp;cp);<br />
    
  •            env-&gt;DeleteLocalRef(javaPhysicsSpace);<br />
    
  •            env-&gt;DeleteLocalRef(javaCollisionObject0);<br />
    
  •            env-&gt;DeleteLocalRef(javaCollisionObject1);<br />
    
  •            if (env-&gt;ExceptionCheck()) {<br />
    
  •                env-&gt;Throw(env-&gt;ExceptionOccurred());<br />
    
  •                return true;<br />
    
  •            }<br />
    

}

}

}

[/patch]



TestBoneRagdoll

ASUS Transformer TF101

http://i.imgur.com/OQAzb.png

2 Likes

Can you please make the patch towards the current jme3 version and not your own?

Nvm, added the changes anyway. Still Iā€™d recommend doing the changes against the official version, this branching makes it much harder to track the changes, why did you branch it anyway :/.

Good morning.


why did you branch it anyway



Because Iā€™m not a committer of jME.

I contributed many patches.

However, my patches were not received for a half year.

I cannot stop development of my projects so for a long time.

I couldnā€™t but make my branch of jME.



However, I donā€™t want to maintain my branch of jME.

Itā€™s means and is not a purpose.

I stop development of my branch if official release of jME becomes perfect.

Having local changes in some code is normal, opening a public branch is something else. Anyway it was mainly about having the patches against the actual version I have to apply them to :wink:

I fixed PhysicsVehicle bugs.



YouTube

http://www.youtube.com/watch?v=7HbidlYv-VI

1 Like

Cool, what was it?

Pointer bug

Initialize sequence bug



I updated my repository on sourceforge.

Please see source.

can you post a patch against the official jme3 version?

Why rate down?

I was offended very much.

I think because a line like ā€œplease see sourceā€ when you actually use the code of the person you address might seem a little careless given that you know how to use diff/patch and versioning systems.

I donā€™t post the patch because I posted android patch 3 days ago but you didnā€™t welcome it.



I thought that you welcomed my work. However, it was not so.

I donā€™t contribute to jME anymore if my work is not welcomed.

Uhm, @chototsu, all your patches have been applied by me to the jme3 svn, after tedious work because they were done against another version of the jme3 native bullet libraryā€¦ I compiled a windows, linux and mac version of the new libraries with all changes and I mentioned you in every commit. In this thread I asked you to make the patches against the svn version of jme3 and the next answer from you was ā€œcheck my svn for the changesā€.

We all (and I think I speak for the whole community here) appreciate very much what you do for the engine but you have to see that this is work for us too and the fact that you have the ability to make applying these fixes to the engine easier for us would help us more if it you executed it :slight_smile:

OK I looked into the repo and after playing around a bit I see whats the issue now, your fixes are not done correctly though, so you donā€™t need to post a patch (no offense). I will fix this today in the jme3 svn.

all your patches have been applied by me to the jme3 svn

I know, it is big progress.

My repository and yours will be unified.

However, I was still working to fix other bugs on my repository.

It was difficult to merge it during work.

I succeeded in finally compile it on win64 some time ago.

I updated my repository.



P.S.

There is the patch more than 8,500 lines.

I donā€™t paste the patch because itā€™s too big.



P.S.2

When I contribute and receive criticism, I am hurt very much.

You were receiving criticism for not contributing :wink: The change in casting you committed lately should not be necessary though, you should be able to solve that with some compiler flagā€¦

Vehicle is now fixed in the jme3 svn as well. The change involves using the wheel index now for addressing the right wheel instead of a pointer to the wheelInfo object.

you should be able to solve that with some compiler flagā€¦

Really!?

How can you do it?