Native bullet ray request

I want to ask if it is possible to add the rayCast function bullet offers to the wrapper, it is really usefull for larger worlds, as it does a broadphase check before doing aabb checks, and is for some usecases quite faster than the jme one (Especiall if you use high poly grafical models, but a simple physic representation is accurate enough (player vs capsule)).



If this is not possible (or no time is aviable) i would be glad to get some tips about how the current binding was created, and then try to implement that myself.



@normen

Right, the rayTest and sweepTest are not implemented yet… You can simply edit the C++ and java code in engine/src/bullet and then try and compile the natives using “ant build-bullet-natives”, you might have to configure the properties in engine/src/bullet to compile properly, see the readme.txt file. There is a project set up (the engine/src/bullet folder itself is the project in this case) that lets you edit the C++ and java code more comfortably in NetBeans (given you downloaded the version that has C++ support or install the plugin), you will have to add the java include folder and the bullet source folder to the global NetBeans C++ code completion settings to get full code checking and completion for the C++ part.

1 Like

Well lets see if I get at least the rays to work, if I do I will post svn patch for it.

1 Like

Well Netbeans does ignore the includes if I specify them in the tools-option-c+±codeassistance. In fact it shows nothing included at all and the project as freeform. Why is this so?



(It builds the project without problems however, wtf netbeans, seriously)

Lol, self-fulfilling prophecy ^^

Java is C, not C++, so you have to register the java classes under C. Also the project isn’t built using netbeans but using ant, its not a normal C++ project. Also the java code completion for the bullet subproject will fail because it includes the “normal” bullet classes. This all is due to how I set up the project to easily build using only ant, especially for those that refuse to use other IDE’s :stuck_out_tongue:

Do you have any C++ compiler installed btw? If you don’t have includes you probably don’t have any headers.

g++.exe is in path and works from console,yes. Before I started to modify things I first compiled it without changes with mingw and cmake

the compiling worked at all the time without problems, only netbeans was … netbeans.



I’m using notepad++ for the .cpp now and eclipse for ant.

First success, was able to throw a not implemented exception from the rays in cpp up to java.



I’m kinda confident I will get this to work.

Lol, you see thats what makes me do these videos, no other IDE user group than the Eclipse one has so many issues with NetBeans that they have to mention it in every single post or even before running the application ^^ Never hear anything like this from IntelliJ or BlueJ users or NetBeans users when using Eclipse xD Theres just gotta be some kind of subliminal messages in Eclipse that work on some of its users. I wonder how much time you would spend trying to get such stuff to work in Eclipse. :roll: Ah right, it doesn’t support C++ :stuck_out_tongue:

It does and it needed me about 5 minutes…

Eclipse CDT | The Eclipse Foundation



skip the following if you dont want to read flaming, you have been warned.

But this time I gave netbeans a real try, I tried for over one hour to get stuff to work, that according to documentation should already be working. (im 100% positive that the includes where not set wrong but ignored, I even watched a video tutorial for this, just to be sure) In fact it did not include anything at all, however the codecompletition was set up right. None of the paths there where shown when strg + hover over the #include.



Funny tho, that I have much less problems working with the powershell and notepad++ than with netbeans (actually I also have no problems working with jbuilder, and vi ( and seriously bluej is not a real ide the users coming from there would probably be happy with notepad, as it surly is a improvement).

If no C/C++ compiler is found, code assistance won’t work. You dont really want to explain to me that it doesn’t work at all eh? Of course it does, you just didn’t manage to set it up. Also, you only tried maximum half an hour the first time, look at your post times. I agree that the project structure is a bit complicated and it would probably be easier to set up a normal C++ project with normal includes, but the global includes work fine for java/include and bullet/src. I have no interest in flaming, this whole thread more serves to my amusement, don’t worry.

P.S. What should “Strg-Hover” do you say? It does nothing over C++ includes… If you have no red underlines its actually working ^^

It is found, every path it says in the c++ stuff is absolutly correctly. It just does not care for them. I would make a screenvideo showing you it, but then I would need to install netbeans again. Next time I try something with netbeasn i make a video and comment on every little thing that annyos me while using it.

No I believe it didn’t work for you, the force is strong in you young jedi :wink:

Beware the temptation of the dark side (netbeans + macs)^^

Yay, I will get this to work, first positive results :slight_smile: Think 2-4 days then I have everything in I want, and cleanup done. (For example the current system the header files are set up does not support cyclic includes (due to missing #ifndef + class definitions in headers (the manual generated ones, the autogenerated need no change of course)), fixing that)



(Ray test against the brick tower example)

Doing ray

RayResult (-0.18252689, -0.80405563, -0.56584316)

RayResult 0.0

RayResult brick (Geometry)

RayResult (-0.21050228, -0.79781574, -0.56495917)

RayResult 0.0

RayResult brick (Geometry)

RayResult (0.0, -1.0, 0.0)

RayResult 0.0

RayResult floor (Geometry)

RayResult (-2.1127876E-4, -0.99999994, 1.6196255E-4)

RayResult 0.0

RayResult brick (Geometry)

1 Like

Awesome, good job. You plan to add the sweepTest too?

Depends on how much more work it will be, if its quite similar i might do so.

1 Like

It should be, yeah.

Hey, I have some kind of strange problem (probably I just forget something)



[patch]Index: src/test/jme3test/bullet/TestBrickTower.java

===================================================================

— src/test/jme3test/bullet/TestBrickTower.java (revision 8533)

+++ src/test/jme3test/bullet/TestBrickTower.java (working copy)

@@ -68,7 +68,7 @@

public class TestBrickTower extends SimpleApplication {



int bricksPerLayer = 8;

  • int brickLayers = 30;
  • int brickLayers = 100;



    static float brickWidth = .75f, brickHeight = .25f, brickDepth = .25f;

    float radius = 3f;

    @@ -94,6 +94,7 @@

    public void simpleInitApp() {

    bulletAppState = new BulletAppState();

    bulletAppState.setThreadingType(BulletAppState.ThreadingType.PARALLEL);

    +

    // bulletAppState.setEnabled(false);

    stateManager.attach(bulletAppState);

    bullet = new Sphere(32, 32, 0.4f, true, false);

    @@ -113,13 +114,9 @@

    inputManager.addMapping("shoot", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));

    inputManager.addListener(actionListener, "shoot");

    rootNode.setShadowMode(ShadowMode.Off);
  •    bsr = new PssmShadowRenderer(assetManager, 1024, 2);<br />
    
  •    bsr.setDirection(new Vector3f(-1, -1, -1).normalizeLocal());<br />
    
  •    bsr.setLambda(0.55f);<br />
    
  •    bsr.setShadowIntensity(0.6f);<br />
    
  •    bsr.setCompareMode(CompareMode.Hardware);<br />
    
  •    bsr.setFilterMode(FilterMode.PCF4);<br />
    
  •    viewPort.addProcessor(bsr);<br />
    

+

+

+

}



private PhysicsSpace getPhysicsSpace() {

@@ -139,6 +136,8 @@

bulletg.addControl(bulletNode);

rootNode.attachChild(bulletg);

getPhysicsSpace().add(bulletNode);

+

  •            bulletAppState.getPhysicsSpace().rayTest(new Vector3f(0,1000,0),new Vector3f(0,-1000,0));<br />
    

}

}

};

Index: src/bullet/native/com_jme3_bullet_PhysicsSpace.cpp

===================================================================

— src/bullet/native/com_jme3_bullet_PhysicsSpace.cpp (revision 8533)

+++ src/bullet/native/com_jme3_bullet_PhysicsSpace.cpp (working copy)

@@ -396,6 +396,59 @@

delete(space);

}



+

+

+

  • JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_rayTest_1native
  • (JNIEnv * env,jobject object, jobject to,jobject from,jlong spaceId,jobject resultlist) {

    +
  •   jmePhysicsSpace* space = reinterpret_cast&lt;jmePhysicsSpace*&gt;(spaceId);<br />
    
  •   if(space == NULL){<br />
    
  •    	jclass newExc = env-&gt;FindClass(&quot;java/lang/NullPointerException&quot;);<br />
    
  •        env-&gt;ThrowNew(newExc, &quot;Physicspace null native geht&quot;);<br />
    
  •        return;<br />
    
  •   }<br />
    

+

  •   struct	AllRayResultCallback : public btCollisionWorld::RayResultCallback<br />
    
  •   {<br />
    
  •   	AllRayResultCallback(const btVector3&amp;	rayFromWorld,const btVector3&amp;	rayToWorld):m_rayFromWorld(rayFromWorld),m_rayToWorld(rayToWorld){<br />
    
  •   	}<br />
    
  •   	jobject resultlist;<br />
    
  •   	JNIEnv* env;<br />
    
  •   	btVector3	m_rayFromWorld;//used to calculate hitPointWorld from hitFraction<br />
    
  •   	btVector3	m_rayToWorld;<br />
    

+

  •   	btVector3	m_hitNormalWorld;<br />
    
  •   	btVector3	m_hitPointWorld;<br />
    

+

  •   	virtual	btScalar	addSingleResult(btCollisionWorld::LocalRayResult&amp; rayResult,bool normalInWorldSpace)<br />
    
  •   	{<br />
    
  •   		if (normalInWorldSpace){<br />
    
  •   			m_hitNormalWorld = rayResult.m_hitNormalLocal;<br />
    
  •   		} else	{<br />
    
  •   			m_hitNormalWorld = m_collisionObject-&gt;getWorldTransform().getBasis()*rayResult.m_hitNormalLocal;<br />
    
  •   		}<br />
    
  •   		m_hitPointWorld.setInterpolate3(m_rayFromWorld,m_rayToWorld,rayResult.m_hitFraction);<br />
    

+

  •   	    jmeBulletUtil::addResult(env, resultlist,m_hitNormalWorld,m_hitPointWorld,rayResult.m_hitFraction,rayResult.m_collisionObject);<br />
    

+

  •   		return 1.f;<br />
    
  •   	}<br />
    
  •   };<br />
    

+

  •    btVector3 native_to = btVector3();<br />
    
  •    jmeBulletUtil::convert(env, to, &amp;native_to);<br />
    

+

  •    btVector3 native_from = btVector3();<br />
    
  •    jmeBulletUtil::convert(env, from, &amp;native_from);<br />
    

+

  •   AllRayResultCallback resultCallback(native_from,native_to);<br />
    
  •   resultCallback.env = env;<br />
    
  •   resultCallback.resultlist = resultlist;<br />
    
  •   space-&gt;getDynamicsWorld()-&gt;rayTest (native_from,native_to, resultCallback);<br />
    
  •    return;<br />
    
  • }

    +

    #ifdef __cplusplus

    }

    #endif

    Index: src/bullet/native/jmeUserPointer.h

    ===================================================================

    — src/bullet/native/jmeUserPointer.h (revision 8533)

    +++ src/bullet/native/jmeUserPointer.h (working copy)

    @@ -1,6 +1,7 @@

    #ifndef _Included_jmeUserPointer

    #define _Included_jmeUserPointer

    #include <jni.h>

    +#include "jmePhysicsSpace.h"

    class jmeUserPointer {

    public:

    jobject javaCollisionObject;

    @@ -8,4 +9,4 @@

    jint groups;

    jmePhysicsSpace *space;

    };

    -#endif

    No newline at end of file

    +#endif

    Index: src/bullet/native/jmeMotionState.h

    ===================================================================

    — src/bullet/native/jmeMotionState.h (revision 8533)

    +++ src/bullet/native/jmeMotionState.h (working copy)

    @@ -29,6 +29,9 @@
  • NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  • SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

    */

    +

    +#ifndef _Included_jmeMotionState

    +#define _Included_jmeMotionState

    #include <jni.h>



    /**

    @@ -36,6 +39,8 @@

    */



    #include "btBulletDynamicsCommon.h"

    +#include "jmePhysicsSpace.h"

    +#endif

    //#include "btBulletCollisionCommon.h"



    class jmeMotionState : public btMotionState {

    Index: src/bullet/native/bullet.properties

    ===================================================================

    — src/bullet/native/bullet.properties (revision 8533)

    +++ src/bullet/native/bullet.properties (working copy)

    @@ -5,7 +5,7 @@

    bullet.library.version=0.9


change if bullet folder has different location

-bullet.folder=…/bullet-2.79

+bullet.folder=…/nativebullet


compile options

bullet.compile.debug=false

Index: src/bullet/native/jmeClasses.h

===================================================================

— src/bullet/native/jmeClasses.h (revision 8533)

+++ src/bullet/native/jmeClasses.h (working copy)

@@ -88,4 +88,4 @@

private:

jmeClasses(){};

~jmeClasses(){};

-};

No newline at end of file

+};

Index: src/bullet/native/jmeClasses.cpp

===================================================================

— src/bullet/native/jmeClasses.cpp (revision 8533)

+++ src/bullet/native/jmeClasses.cpp (working copy)

@@ -179,7 +179,7 @@

env->Throw(env->ExceptionOccurred());

return;

}

-

+

DebugMeshCallback_addVector = env->GetMethodID(DebugMeshCallback, "addVector", "(FFFII)V");

if (env->ExceptionCheck()) {

env->Throw(env->ExceptionOccurred());

Index: src/bullet/native/com_jme3_bullet_collision_PhysicsCollisionEvent.h

===================================================================

— src/bullet/native/com_jme3_bullet_collision_PhysicsCollisionEvent.h (revision 8533)

+++ src/bullet/native/com_jme3_bullet_collision_PhysicsCollisionEvent.h (working copy)

@@ -8,7 +8,7 @@

extern "C" {

#endif

#undef com_jme3_bullet_collision_PhysicsCollisionEvent_serialVersionUID

-#define com_jme3_bullet_collision_PhysicsCollisionEvent_serialVersionUID 5516075349620653480LL

+#define com_jme3_bullet_collision_PhysicsCollisionEvent_serialVersionUID 5516075349620653480i64

#undef com_jme3_bullet_collision_PhysicsCollisionEvent_TYPE_ADDED

#define com_jme3_bullet_collision_PhysicsCollisionEvent_TYPE_ADDED 0L

#undef com_jme3_bullet_collision_PhysicsCollisionEvent_TYPE_PROCESSED

Index: src/bullet/native/jmeBulletUtil.h

===================================================================

— src/bullet/native/jmeBulletUtil.h (revision 8533)

+++ src/bullet/native/jmeBulletUtil.h (working copy)

@@ -29,11 +29,15 @@

  • NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  • SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

    */

    +

    +#ifndef _Included_jmeBulletUtil

    +#define _Included_jmeBulletUtil

    #include "jmeClasses.h"

    #include "btBulletDynamicsCommon.h"

    #include "btBulletCollisionCommon.h"

    #include "LinearMath/btVector3.h"

    -

    +#include "jmeUserPointer.h"

    +#endif

    /**
  • Author: Normen Hansen

    /

    @@ -45,8 +49,9 @@

    static void convert(JNIEnv
    env, const btMatrix3x3* in, jobject out);

    static void convertQuat(JNIEnv* env, jobject in, btMatrix3x3* out);

    static void convertQuat(JNIEnv* env, const btMatrix3x3* in, jobject out);
  • static void addResult(JNIEnv* env, jobject resultlist, const btVector3 hitnormal,const btVector3 m_hitPointWorld,const btScalar m_hitFraction,btCollisionObject* hitobject);

    private:

    jmeBulletUtil(){};

    ~jmeBulletUtil(){};



    -};

    No newline at end of file

    +};

    Index: src/bullet/native/build.xml

    ===================================================================

    — src/bullet/native/build.xml (revision 8533)

    +++ src/bullet/native/build.xml (working copy)

    @@ -1,6 +1,7 @@

    <?xml version="1.0" encoding="UTF-8"?>

    -<project name="build bullet natives" default="all" basedir="…/…/…/">
  • <!-- load cpp compiler ant task -->

    +<project name="build bullet natives" basedir="…/…/…/">
  • <import file="${basedir}/build.xml"/>
  • <!-- load cpp compiler ant task -->

    <taskdef resource="cpptasks.tasks" classpath="lib/antlibs/cpptasks.jar"/>

    <!-- load properties -->

    <property file="src/bullet/native/bullet.properties"/>

    @@ -54,7 +55,11 @@

    </target>



    <target name="create-native-headers" description="creates the native headers">
  •    &lt;javah destdir=&quot;${bullet.source.dir}&quot; classpath=&quot;${bullet.build.dir}${path.separator}${lib.importpath}&quot; force=&quot;yes&quot;&gt;<br />
    
  •   &lt;echo message=&quot;${basedir}/build.xml&quot;&gt;&lt;/echo&gt;<br />
    

+

  •   &lt;antcall  target=&quot;default&quot;&gt;&lt;/antcall&gt;<br />
    

+

  •   &lt;javah destdir=&quot;${bullet.source.dir}&quot; classpath=&quot;${bullet.build.dir}${path.separator}${lib.importpath}&quot; force=&quot;yes&quot; verbose=&quot;yes&quot;&gt;<br />
    

<class name="com.jme3.bullet.PhysicsSpace"/>



<class name="com.jme3.bullet.collision.PhysicsCollisionEvent"/>

Index: src/bullet/native/jmeBulletUtil.cpp

===================================================================

— src/bullet/native/jmeBulletUtil.cpp (revision 8533)

+++ src/bullet/native/jmeBulletUtil.cpp (working copy)

@@ -306,3 +306,88 @@

return;

}

}

+

+void jmeBulletUtil::addResult(JNIEnv* env, jobject resultlist, btVector3 hitnormal,btVector3 m_hitPointWorld,btScalar m_hitFraction,btCollisionObject* hitobject) {

+

+

  • jclass clazz = env->FindClass("com/jme3/bullet/collision/PhysicsRayTestResult");
  • if (env->ExceptionCheck()) {
  •    env-&gt;Throw(env-&gt;ExceptionOccurred());<br />
    
  •    return;<br />
    
  • }
  • jobject singleresult = env->AllocObject(clazz);
  • if (env->ExceptionCheck()) {
  •    env-&gt;Throw(env-&gt;ExceptionOccurred());<br />
    
  •    return;<br />
    
  • }

    +

    +

    +
  • jclass Vector3f = env->FindClass("com/jme3/math/Vector3f");
  • if (env->ExceptionCheck()) {
  •    env-&gt;Throw(env-&gt;ExceptionOccurred());<br />
    
  •    return;<br />
    
  • }

    +
  • jobject hitnormalvec = env->AllocObject(Vector3f);
  • if (env->ExceptionCheck()) {
  •    env-&gt;Throw(env-&gt;ExceptionOccurred());<br />
    
  •    return;<br />
    
  • }

    +
  • jfieldID normalInWorldSpace = env->GetFieldID(clazz,"hitNormalLocal","Lcom/jme3/math/Vector3f;");
  • if (env->ExceptionCheck()) {
  •    env-&gt;Throw(env-&gt;ExceptionOccurred());<br />
    
  •    return;<br />
    
  • }
  • convert(env,const_cast<btVector3*>(&hitnormal),hitnormalvec);
  • env->SetObjectField(singleresult,normalInWorldSpace,hitnormalvec);
  • if (env->ExceptionCheck()) {
  •    env-&gt;Throw(env-&gt;ExceptionOccurred());<br />
    
  •    return;<br />
    
  • }

    +
  • jfieldID hitfraction = env->GetFieldID(clazz,"hitFraction","F");
  • if (env->ExceptionCheck()) {
  •    env-&gt;Throw(env-&gt;ExceptionOccurred());<br />
    
  •    return;<br />
    
  • }
  • env->SetFloatField(singleresult,hitfraction,m_hitFraction);
  • if (env->ExceptionCheck()) {
  •    env-&gt;Throw(env-&gt;ExceptionOccurred());<br />
    
  •    return;<br />
    
  • }

    +
  • jfieldID collisionObject = env->GetFieldID(clazz,"collisionObject","Lcom/jme3/bullet/collision/PhysicsCollisionObject;");
  • if (env->ExceptionCheck()) {
  •    env-&gt;Throw(env-&gt;ExceptionOccurred());<br />
    
  •    return;<br />
    
  • }

    +
  • jmeUserPointer up1 = (jmeUserPointer)hitobject -> getUserPointer();
  • env->SetObjectField(singleresult,collisionObject,up1->javaCollisionObject);
  • if (env->ExceptionCheck()) {
  •    env-&gt;Throw(env-&gt;ExceptionOccurred());<br />
    
  •    return;<br />
    
  • }

    +

    +
  • jclass listresult = env->FindClass("java/util/List");
  • if (env->ExceptionCheck()) {
  •    env-&gt;Throw(env-&gt;ExceptionOccurred());<br />
    
  •    return;<br />
    
  • }
  • jmethodID addmethod = env->GetMethodID(listresult,"add","(Ljava/lang/Object;)Z");
  • if (env->ExceptionCheck()) {
  •    env-&gt;Throw(env-&gt;ExceptionOccurred());<br />
    
  •    return;<br />
    
  • }
  • env->CallVoidMethod(resultlist,addmethod,singleresult);
  • if (env->ExceptionCheck()) {
  •    env-&gt;Throw(env-&gt;ExceptionOccurred());<br />
    
  •    return;<br />
    
  • }

    +

    +

    +

    +}

    Index: src/bullet/native/jmePhysicsSpace.h

    ===================================================================

    — src/bullet/native/jmePhysicsSpace.h (revision 8533)

    +++ src/bullet/native/jmePhysicsSpace.h (working copy)

    @@ -29,6 +29,8 @@
  • NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  • SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

    /

    +#ifndef _Included_jmePhysicsSpace

    +#define _Included_jmePhysicsSpace

    #include <jni.h>

    #include "btBulletDynamicsCommon.h"

    #include "btBulletCollisionCommon.h"

    @@ -73,4 +75,5 @@

    static void preTickCallback(btDynamicsWorld
    , btScalar);

    static void postTickCallback(btDynamicsWorld*, btScalar);

    static bool contactProcessedCallback(btManifoldPoint &, void *, void );

    -};

    No newline at end of file

    +};

    +#endif

    Index: src/bullet/native/com_jme3_bullet_PhysicsSpace.h

    ===================================================================

    — src/bullet/native/com_jme3_bullet_PhysicsSpace.h (revision 8533)

    +++ src/bullet/native/com_jme3_bullet_PhysicsSpace.h (working copy)

    @@ -1,157 +0,0 @@

    -/
    DO NOT EDIT THIS FILE - it is machine generated /

    -#include <jni.h>

    -/
    Header for class com_jme3_bullet_PhysicsSpace /

    -

    -#ifndef _Included_com_jme3_bullet_PhysicsSpace

    -#define _Included_com_jme3_bullet_PhysicsSpace

    -#ifdef __cplusplus

    -extern "C" {

    -#endif

    -#undef com_jme3_bullet_PhysicsSpace_AXIS_X

    -#define com_jme3_bullet_PhysicsSpace_AXIS_X 0L

    -#undef com_jme3_bullet_PhysicsSpace_AXIS_Y

    -#define com_jme3_bullet_PhysicsSpace_AXIS_Y 1L

    -#undef com_jme3_bullet_PhysicsSpace_AXIS_Z

    -#define com_jme3_bullet_PhysicsSpace_AXIS_Z 2L

    -/
    Inaccessible static: pQueueTL /

    -/
    Inaccessible static: physicsSpaceTL /

    -/

    • Class: com_jme3_bullet_PhysicsSpace
    • Method: createPhysicsSpace
    • Signature: (FFFFFFIZ)J
  • */

    -JNIEXPORT jlong JNICALL Java_com_jme3_bullet_PhysicsSpace_createPhysicsSpace
  • (JNIEnv , jobject, jfloat, jfloat, jfloat, jfloat, jfloat, jfloat, jint, jboolean);

    -

    -/

    • Class: com_jme3_bullet_PhysicsSpace
    • Method: stepSimulation
    • Signature: (JFIF)V
  • */

    -JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_stepSimulation
  • (JNIEnv , jobject, jlong, jfloat, jint, jfloat);

    -

    -/

    • Class: com_jme3_bullet_PhysicsSpace
    • Method: addCollisionObject
    • Signature: (JJ)V
  • */

    -JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_addCollisionObject
  • (JNIEnv , jobject, jlong, jlong);

    -

    -/

    • Class: com_jme3_bullet_PhysicsSpace
    • Method: removeCollisionObject
    • Signature: (JJ)V
  • */

    -JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_removeCollisionObject
  • (JNIEnv , jobject, jlong, jlong);

    -

    -/

    • Class: com_jme3_bullet_PhysicsSpace
    • Method: addRigidBody
    • Signature: (JJ)V
  • */

    -JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_addRigidBody
  • (JNIEnv , jobject, jlong, jlong);

    -

    -/

    • Class: com_jme3_bullet_PhysicsSpace
    • Method: removeRigidBody
    • Signature: (JJ)V
  • */

    -JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_removeRigidBody
  • (JNIEnv , jobject, jlong, jlong);

    -

    -/

    • Class: com_jme3_bullet_PhysicsSpace
    • Method: addCharacterObject
    • Signature: (JJ)V
  • */

    -JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_addCharacterObject
  • (JNIEnv , jobject, jlong, jlong);

    -

    -/

    • Class: com_jme3_bullet_PhysicsSpace
    • Method: removeCharacterObject
    • Signature: (JJ)V
  • */

    -JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_removeCharacterObject
  • (JNIEnv , jobject, jlong, jlong);

    -

    -/

    • Class: com_jme3_bullet_PhysicsSpace
    • Method: addAction
    • Signature: (JJ)V
  • */

    -JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_addAction
  • (JNIEnv , jobject, jlong, jlong);

    -

    -/

    • Class: com_jme3_bullet_PhysicsSpace
    • Method: removeAction
    • Signature: (JJ)V
  • */

    -JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_removeAction
  • (JNIEnv , jobject, jlong, jlong);

    -

    -/

    • Class: com_jme3_bullet_PhysicsSpace
    • Method: addVehicle
    • Signature: (JJ)V
  • */

    -JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_addVehicle
  • (JNIEnv , jobject, jlong, jlong);

    -

    -/

    • Class: com_jme3_bullet_PhysicsSpace
    • Method: removeVehicle
    • Signature: (JJ)V
  • */

    -JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_removeVehicle
  • (JNIEnv , jobject, jlong, jlong);

    -

    -/

    • Class: com_jme3_bullet_PhysicsSpace
    • Method: addConstraint
    • Signature: (JJ)V
  • */

    -JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_addConstraint
  • (JNIEnv , jobject, jlong, jlong);

    -

    -/

    • Class: com_jme3_bullet_PhysicsSpace
    • Method: removeConstraint
    • Signature: (JJ)V
  • */

    -JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_removeConstraint
  • (JNIEnv , jobject, jlong, jlong);

    -

    -/

    • Class: com_jme3_bullet_PhysicsSpace
    • Method: setGravity
    • Signature: (JLcom/jme3/math/Vector3f;)V
  • */

    -JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_setGravity
  • (JNIEnv , jobject, jlong, jobject);

    -

    -/

    • Class: com_jme3_bullet_PhysicsSpace
    • Method: initNativePhysics
    • Signature: ()V
  • */

    -JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_initNativePhysics
  • (JNIEnv , jclass);

    -

    -/

    • Class: com_jme3_bullet_PhysicsSpace
    • Method: finalizeNative
    • Signature: (J)V
  • */

    -JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_finalizeNative
  • (JNIEnv *, jobject, jlong);

    -

    -#ifdef __cplusplus

    -}

    -#endif

    -#endif

    Index: src/bullet/com/jme3/bullet/joints/SliderJoint.java

    ===================================================================

    — src/bullet/com/jme3/bullet/joints/SliderJoint.java (revision 8533)

    +++ src/bullet/com/jme3/bullet/joints/SliderJoint.java (working copy)

    @@ -35,7 +35,6 @@

    import com.jme3.math.Matrix3f;

    import com.jme3.math.Vector3f;

    import com.jme3.bullet.objects.PhysicsRigidBody;

    -import com.jme3.bullet.util.Converter;

    import com.jme3.export.InputCapsule;

    import com.jme3.export.JmeImporter;

    import com.jme3.export.OutputCapsule;

    Index: src/bullet/com/jme3/bullet/collision/PhysicsRayTestResult.java

    ===================================================================

    — src/bullet/com/jme3/bullet/collision/PhysicsRayTestResult.java (revision 8533)

    +++ src/bullet/com/jme3/bullet/collision/PhysicsRayTestResult.java (working copy)

    @@ -35,6 +35,8 @@



    /**
  • Contains the results of a PhysicsSpace rayTest
    • bulletAppState.getPhysicsSpace().rayTest(new Vector3f(0,1000,0),new Vector3f(0,-1000,0));
  • javap -s java.util.List
  • @author normenhansen

    */

    public class PhysicsRayTestResult {

    @@ -42,16 +44,12 @@

    private PhysicsCollisionObject collisionObject;

    private Vector3f hitNormalLocal;

    private float hitFraction;
  • private boolean normalInWorldSpace;

    -
  • public PhysicsRayTestResult() {
  • }
  • private boolean normalInWorldSpace = true;


  • public PhysicsRayTestResult(PhysicsCollisionObject collisionObject, Vector3f hitNormalLocal, float hitFraction, boolean normalInWorldSpace) {
  •    this.collisionObject = collisionObject;<br />
    
  •    this.hitNormalLocal = hitNormalLocal;<br />
    
  •    this.hitFraction = hitFraction;<br />
    
  •    this.normalInWorldSpace = normalInWorldSpace;<br />
    
  • /**
  • * allocated by native code only<br />
    
  • */<br />
    
  • private PhysicsRayTestResult() {

    }



    /

    Index: src/bullet/com/jme3/bullet/PhysicsSpace.java

    ===================================================================

    — src/bullet/com/jme3/bullet/PhysicsSpace.java (revision 8533)

    +++ src/bullet/com/jme3/bullet/PhysicsSpace.java (working copy)

    @@ -715,17 +715,31 @@

    /

  • Performs a ray collision test and returns the results as a list of PhysicsRayTestResults

    */
  • public List<PhysicsRayTestResult> rayTest(Vector3f from, Vector3f to) {
  •    List&lt;PhysicsRayTestResult&gt; results = new LinkedList&lt;PhysicsRayTestResult&gt;();<br />
    

-// dynamicsWorld.rayTest(Converter.convert(from, rayVec1), Converter.convert(to, rayVec2), new InternalRayListener(results));

  • public List rayTest(Vector3f from, Vector3f to) {
  •   System.out.println(&quot;Doing ray&quot;);<br />
    
  •   List results = new LinkedList();<br />
    
  •    rayTest(from,to,results);<br />
    

+

  •    List&lt;PhysicsRayTestResult&gt; resulttscastet = results;<br />
    
  •    for(PhysicsRayTestResult res:resulttscastet){<br />
    
  •    	System.out.println(&quot;RayResult &quot; + res.getHitNormalLocal());<br />
    
  •    	System.out.println(&quot;RayResult &quot; + res.getHitFraction());<br />
    
  •    	if(res.getCollisionObject() != null){<br />
    
  •    		if(res.getCollisionObject().getUserObject() != null){<br />
    
  •    			System.out.println(&quot;RayResult &quot; + res.getCollisionObject().getUserObject().toString());<br />
    
  •        	}<br />
    
  •    	}<br />
    
  •    }<br />
    

return results;

}



+

/**

  • Performs a ray collision test and returns the results as a list of PhysicsRayTestResults

    */

    public List<PhysicsRayTestResult> rayTest(Vector3f from, Vector3f to, List<PhysicsRayTestResult> results) {

    results.clear();
  •    rayTest_native(from,to,physicsSpaceId,results);<br />
    

// dynamicsWorld.rayTest(Converter.convert(from, rayVec1), Converter.convert(to, rayVec2), new InternalRayListener(results));

return results;

}

@@ -884,6 +898,9 @@

public void disableDebug() {

debugManager = null;

}

+

  • public native void rayTest_native(Vector3f from,Vector3f to,long physicsSpaceId, List<PhysicsRayTestResult> results);

    +



    public AssetManager getDebugManager() {

    return debugManager;

    [/patch]



    This here works fine



    However as soon as I try to relocate the jmethodid and class tuff to the jmeClasses I get access exceptions (following an intant crash).

    Can you maybe test if you are able to put one of those into the jmeClasses and post that back, maybee I see the error then.

Mostly the issues with “access exception” etc. is when you make a pointer out of a pointer or similar using & and *. I’ll see when I have the time to look into this, thanks.

So is it working now?