Native bullet bug fix

I succeeded in working demos with native bullet:

TestWalkingChar

TestBoneRagdoll

TestCollisionListener

TestBrickWall (enable BombControl)



YouTube

http://www.youtube.com/watch?v=-K5Weo3nyfY



download(Windows, Solaris binary):
http://sourceforge.jp/projects/mikumikustudio/downloads/53514/native-bullet.7z/
for other platforms: please compile yourself.

changelog:
add SixDofSpringJoint support
add physics collision event support
add PhysicsGhostObject#GetOverlapping support
many bug fixes.
3 Likes

Nice work! Can the fixes that doesn’t introduce new futures compared to jbullet (e.g. SixDofSpringJoint is new) be added to nightly?

@makeshift

I posted SixDofSpringJoint source code 5 months ago.

http://hub.jmonkeyengine.org/groups/free-announcements/forum/topic/mikumikudance-viewer/

However, it is still ignored.

1 Like

I know, @normen want’s to wait with introducing new features until native works properly, but your other fixes should be added :slight_smile:

Hmm… it’s disappointing because MikuMikuDance uses SixDofSpringJoint.

1 Like

full source is here.

hg clone mikumikustudio/MikuMikuStudio: log



patch from r8366

[patch]

diff -r 7a78f7ca8432 -r 19650db1402b engine/src/bullet/com/jme3/bullet/PhysicsSpace.java

— a/engine/src/bullet/com/jme3/bullet/PhysicsSpace.java Mon Oct 10 16:11:17 2011 +0900

+++ b/engine/src/bullet/com/jme3/bullet/PhysicsSpace.java Sat Oct 15 08:11:40 2011 +0900

@@ -329,6 +329,10 @@

// }

// });

// }

  • public void addCollisionEvent(PhysicsCollisionObject node, PhysicsCollisionObject node1, long manifoldPointObjectId) {

    +// System.out.println("addCollisionEvent:"+node.getObjectId()+" "+ node1.getObjectId());
  •    collisionEvents.add(eventFactory.getEvent(PhysicsCollisionEvent.TYPE_PROCESSED, node, node1, manifoldPointObjectId));<br />
    
  • }

    /**
  • updates the physics space
  • @param time the current time value

    diff -r 7a78f7ca8432 -r 19650db1402b engine/src/bullet/com/jme3/bullet/collision/PhysicsCollisionEvent.java

    — a/engine/src/bullet/com/jme3/bullet/collision/PhysicsCollisionEvent.java Mon Oct 10 16:11:17 2011 +0900

    +++ b/engine/src/bullet/com/jme3/bullet/collision/PhysicsCollisionEvent.java Sat Oct 15 08:11:40 2011 +0900

    @@ -49,56 +49,14 @@

    private int type;

    private PhysicsCollisionObject nodeA;

    private PhysicsCollisionObject nodeB;
  • public final Vector3f localPointA;
  • public final Vector3f localPointB;
  • public final Vector3f positionWorldOnB;
  • public final Vector3f positionWorldOnA;
  • public final Vector3f normalWorldOnB;
  • public float distance1;
  • public float combinedFriction;
  • public float combinedRestitution;
  • public int partId0;
  • public int partId1;
  • public int index0;
  • public int index1;
  • public Object userPersistentData;
  • public float appliedImpulse;
  • public boolean lateralFrictionInitialized;
  • public float appliedImpulseLateral1;
  • public float appliedImpulseLateral2;
  • public int lifeTime;
  • public final Vector3f lateralFrictionDir1;
  • public final Vector3f lateralFrictionDir2;
  • private long manifoldPointObjectId = 0;


  • public PhysicsCollisionEvent(int type, PhysicsCollisionObject nodeA, PhysicsCollisionObject nodeB) {
  •    this(type, nodeA, nodeB, new Vector3f(), new Vector3f(), new Vector3f(), new Vector3f(), new Vector3f(), 0, 0, 0, 0, 0, 0, 0, null, 0, false, 0, 0, 0, new Vector3f(), new Vector3f());<br />
    
  • }

    -
  • public PhysicsCollisionEvent(int type, PhysicsCollisionObject nodeA, PhysicsCollisionObject nodeB, Vector3f localPointA, Vector3f localPointB, Vector3f positionWorldOnB, Vector3f positionWorldOnA, Vector3f normalWorldOnB, float distance1, float combinedFriction, float combinedRestitution, int partId0, int partId1, int index0, int index1, Object userPersistentData, float appliedImpulse, boolean lateralFrictionInitialized, float appliedImpulseLateral1, float appliedImpulseLateral2, int lifeTime, Vector3f lateralFrictionDir1, Vector3f lateralFrictionDir2) {
  • public PhysicsCollisionEvent(int type, PhysicsCollisionObject nodeA, PhysicsCollisionObject nodeB, long manifoldPointObjectId) {

    super(nodeA);

    this.type = type;

    this.nodeA = nodeA;

    this.nodeB = nodeB;
  •    this.localPointA = localPointA;<br />
    
  •    this.localPointB = localPointB;<br />
    
  •    this.positionWorldOnB = positionWorldOnB;<br />
    
  •    this.positionWorldOnA = positionWorldOnA;<br />
    
  •    this.normalWorldOnB = normalWorldOnB;<br />
    
  •    this.distance1 = distance1;<br />
    
  •    this.combinedFriction = combinedFriction;<br />
    
  •    this.combinedRestitution = combinedRestitution;<br />
    
  •    this.partId0 = partId0;<br />
    
  •    this.partId1 = partId1;<br />
    
  •    this.index0 = index0;<br />
    
  •    this.index1 = index1;<br />
    
  •    this.userPersistentData = userPersistentData;<br />
    
  •    this.appliedImpulse = appliedImpulse;<br />
    
  •    this.lateralFrictionInitialized = lateralFrictionInitialized;<br />
    
  •    this.appliedImpulseLateral1 = appliedImpulseLateral1;<br />
    
  •    this.appliedImpulseLateral2 = appliedImpulseLateral2;<br />
    
  •    this.lifeTime = lifeTime;<br />
    
  •    this.lateralFrictionDir1 = lateralFrictionDir1;<br />
    
  •    this.lateralFrictionDir2 = lateralFrictionDir2;<br />
    
  •    this.manifoldPointObjectId = manifoldPointObjectId;<br />
    

}



/**

@@ -109,6 +67,7 @@

this.type = 0;

this.nodeA = null;

this.nodeB = null;

  •    this.manifoldPointObjectId = 0;<br />
    

// this.localPointA = null;

// this.localPointB = null;

// this.positionWorldOnB = null;

@@ -121,7 +80,7 @@

// this.partId1 = null;

// this.index0 = null;

// this.index1 = null;

  •    this.userPersistentData = null;<br />
    

+// this.userPersistentData = null;

// this.appliedImpulse = null;

// this.lateralFrictionInitialized = null;

// this.appliedImpulseLateral1 = null;

@@ -134,31 +93,32 @@

/**

  • used by event factory, called when event reused

    */
  • public void refactor(int type, PhysicsCollisionObject source, PhysicsCollisionObject nodeB, Vector3f localPointA, Vector3f localPointB, Vector3f positionWorldOnB, Vector3f positionWorldOnA, Vector3f normalWorldOnB, float distance1, float combinedFriction, float combinedRestitution, int partId0, int partId1, int index0, int index1, Object userPersistentData, float appliedImpulse, boolean lateralFrictionInitialized, float appliedImpulseLateral1, float appliedImpulseLateral2, int lifeTime, Vector3f lateralFrictionDir1, Vector3f lateralFrictionDir2) {
  • public void refactor(int type, PhysicsCollisionObject source, PhysicsCollisionObject nodeB, long manifoldPointObjectId) {

    this.source = source;

    this.type = type;

    this.nodeA = source;

    this.nodeB = nodeB;
  •    this.localPointA.set(localPointA);<br />
    
  •    this.localPointB.set(localPointB);<br />
    
  •    this.positionWorldOnB.set(positionWorldOnB);<br />
    
  •    this.positionWorldOnA.set(positionWorldOnA);<br />
    
  •    this.normalWorldOnB.set(normalWorldOnB);<br />
    
  •    this.distance1 = distance1;<br />
    
  •    this.combinedFriction = combinedFriction;<br />
    
  •    this.combinedRestitution = combinedRestitution;<br />
    
  •    this.partId0 = partId0;<br />
    
  •    this.partId1 = partId1;<br />
    
  •    this.index0 = index0;<br />
    
  •    this.index1 = index1;<br />
    
  •    this.userPersistentData = userPersistentData;<br />
    
  •    this.appliedImpulse = appliedImpulse;<br />
    
  •    this.lateralFrictionInitialized = lateralFrictionInitialized;<br />
    
  •    this.appliedImpulseLateral1 = appliedImpulseLateral1;<br />
    
  •    this.appliedImpulseLateral2 = appliedImpulseLateral2;<br />
    
  •    this.lifeTime = lifeTime;<br />
    
  •    this.lateralFrictionDir1.set(lateralFrictionDir1);<br />
    
  •    this.lateralFrictionDir2.set(lateralFrictionDir2);<br />
    
  •    this.manifoldPointObjectId = manifoldPointObjectId;<br />
    

+// this.localPointA.set(localPointA);

+// this.localPointB.set(localPointB);

+// this.positionWorldOnB.set(positionWorldOnB);

+// this.positionWorldOnA.set(positionWorldOnA);

+// this.normalWorldOnB.set(normalWorldOnB);

+// this.distance1 = distance1;

+// this.combinedFriction = combinedFriction;

+// this.combinedRestitution = combinedRestitution;

+// this.partId0 = partId0;

+// this.partId1 = partId1;

+// this.index0 = index0;

+// this.index1 = index1;

+// this.userPersistentData = userPersistentData;

+// this.appliedImpulse = appliedImpulse;

+// this.lateralFrictionInitialized = lateralFrictionInitialized;

+// this.appliedImpulseLateral1 = appliedImpulseLateral1;

+// this.appliedImpulseLateral2 = appliedImpulseLateral2;

+// this.lifeTime = lifeTime;

+// this.lateralFrictionDir1.set(lateralFrictionDir1);

+// this.lateralFrictionDir2.set(lateralFrictionDir2);

}



public int getType() {

@@ -194,82 +154,109 @@

}



public float getAppliedImpulse() {

  •    return appliedImpulse;<br />
    
  •    return getAppliedImpulse(manifoldPointObjectId);<br />
    

}

  • private native float getAppliedImpulse(long manifoldPointObjectId);



    public float getAppliedImpulseLateral1() {
  •    return appliedImpulseLateral1;<br />
    
  •    return getAppliedImpulseLateral1(manifoldPointObjectId);<br />
    

}

  • private native float getAppliedImpulseLateral1(long manifoldPointObjectId);



    public float getAppliedImpulseLateral2() {
  •    return appliedImpulseLateral2;<br />
    
  •    return getAppliedImpulseLateral2(manifoldPointObjectId);<br />
    

}

  • private native float getAppliedImpulseLateral2(long manifoldPointObjectId);

    +
  • public float getCombinedFriction() {
  •    return getCombinedFriction(manifoldPointObjectId);<br />
    
  • }
  • private native float getCombinedFriction(long manifoldPointObjectId);

    +
  • public float getCombinedRestitution() {
  •    return getCombinedRestitution(manifoldPointObjectId);<br />
    
  • }
  • private native float getCombinedRestitution(long manifoldPointObjectId);

    +
  • public float getDistance1() {
  •    return getDistance1(manifoldPointObjectId);<br />
    
  • }
  • private native float getDistance1(long manifoldPointObjectId);

    +
  • public int getIndex0() {
  •    return getIndex0(manifoldPointObjectId);<br />
    
  • }
  • private native int getIndex0(long manifoldPointObjectId);

    +
  • public int getIndex1() {
  •    return getIndex1(manifoldPointObjectId);<br />
    
  • }
  • private native int getIndex1(long manifoldPointObjectId);


  • public float getCombinedFriction() {
  •    return combinedFriction;<br />
    
  • }

    -
  • public float getCombinedRestitution() {
  •    return combinedRestitution;<br />
    
  • }

    -
  • public float getDistance1() {
  •    return distance1;<br />
    
  • }

    -
  • public int getIndex0() {
  •    return index0;<br />
    
  • }

    -
  • public int getIndex1() {
  •    return index1;<br />
    
  • }

    -
  • public Vector3f getLateralFrictionDir1() {
  • public Vector3f getLateralFrictionDir1(Vector3f lateralFrictionDir1) {
  •    getLateralFrictionDir1(manifoldPointObjectId, lateralFrictionDir1);<br />
    

return lateralFrictionDir1;

}

  • private native void getLateralFrictionDir1(long manifoldPointObjectId, Vector3f lateralFrictionDir1);


  • public Vector3f getLateralFrictionDir2() {
  • public Vector3f getLateralFrictionDir2(Vector3f lateralFrictionDir2) {
  •    getLateralFrictionDir2(manifoldPointObjectId, lateralFrictionDir2);<br />
    

return lateralFrictionDir2;

}

  • private native void getLateralFrictionDir2(long manifoldPointObjectId, Vector3f lateralFrictionDir2);



    public boolean isLateralFrictionInitialized() {
  •    return lateralFrictionInitialized;<br />
    
  •    return isLateralFrictionInitialized(manifoldPointObjectId);<br />
    

}

  • private native boolean isLateralFrictionInitialized(long manifoldPointObjectId);



    public int getLifeTime() {
  •    return lifeTime;<br />
    
  •    return getLifeTime(manifoldPointObjectId);<br />
    

}

  • private native int getLifeTime(long manifoldPointObjectId);


  • public Vector3f getLocalPointA() {
  • public Vector3f getLocalPointA(Vector3f localPointA) {
  •    getLocalPointA(manifoldPointObjectId, localPointA);<br />
    

return localPointA;

}

  • private native void getLocalPointA(long manifoldPointObjectId, Vector3f localPointA);


  • public Vector3f getLocalPointB() {
  • public Vector3f getLocalPointB(Vector3f localPointB) {
  •    getLocalPointB(manifoldPointObjectId, localPointB);<br />
    

return localPointB;

}

  • private native void getLocalPointB(long manifoldPointObjectId, Vector3f localPointB);


  • public Vector3f getNormalWorldOnB() {
  • public Vector3f getNormalWorldOnB(Vector3f normalWorldOnB) {
  •    getNormalWorldOnB(manifoldPointObjectId, normalWorldOnB);<br />
    

return normalWorldOnB;

}

  • private native void getNormalWorldOnB(long manifoldPointObjectId, Vector3f normalWorldOnB);



    public int getPartId0() {
  •    return partId0;<br />
    
  •    return getPartId0(manifoldPointObjectId);<br />
    

}

  • private native int getPartId0(long manifoldPointObjectId);

    +
  • public int getPartId1() {
  •    return getPartId1(manifoldPointObjectId);<br />
    
  • }

    +
  • private native int getPartId1(long manifoldPointObjectId);


  • public int getPartId1() {
  •    return partId1;<br />
    
  • }

    -
  • public Vector3f getPositionWorldOnA() {
  • public Vector3f getPositionWorldOnA(Vector3f positionWorldOnA) {
  •    getPositionWorldOnA(positionWorldOnA);<br />
    

return positionWorldOnA;

}

  • private native void getPositionWorldOnA(long manifoldPointObjectId, Vector3f positionWorldOnA);


  • public Vector3f getPositionWorldOnB() {
  • public Vector3f getPositionWorldOnB(Vector3f positionWorldOnB) {
  •    getPositionWorldOnB(manifoldPointObjectId, positionWorldOnB);<br />
    

return positionWorldOnB;

}

  • private native void getPositionWorldOnB(long manifoldPointObjectId, Vector3f positionWorldOnB);


  • public Object getUserPersistentData() {
  •    return userPersistentData;<br />
    
  • }

    +// public Object getUserPersistentData() {

    +// return userPersistentData;

    +// }

    }

    diff -r 7a78f7ca8432 -r 19650db1402b engine/src/bullet/com/jme3/bullet/collision/PhysicsCollisionEventFactory.java

    — a/engine/src/bullet/com/jme3/bullet/collision/PhysicsCollisionEventFactory.java Mon Oct 10 16:11:17 2011 +0900

    +++ b/engine/src/bullet/com/jme3/bullet/collision/PhysicsCollisionEventFactory.java Sat Oct 15 08:11:40 2011 +0900

    @@ -41,12 +41,12 @@



    private ConcurrentLinkedQueue<PhysicsCollisionEvent> eventBuffer = new ConcurrentLinkedQueue<PhysicsCollisionEvent>();


  • public PhysicsCollisionEvent getEvent(int type, PhysicsCollisionObject source, PhysicsCollisionObject nodeB) {
  • public PhysicsCollisionEvent getEvent(int type, PhysicsCollisionObject source, PhysicsCollisionObject nodeB, long manifoldPointObjectId) {

    PhysicsCollisionEvent event = eventBuffer.poll();

    if (event == null) {
  •        event = new PhysicsCollisionEvent(type, source, nodeB);<br />
    
  •        event = new PhysicsCollisionEvent(type, source, nodeB, manifoldPointObjectId);<br />
    

}else{

-// event.refactor(type, source, nodeB);

  •        event.refactor(type, source, nodeB, manifoldPointObjectId);<br />
    

}

return event;

}

diff -r 7a78f7ca8432 -r 19650db1402b engine/src/bullet/com/jme3/bullet/collision/PhysicsCollisionObject.java

— a/engine/src/bullet/com/jme3/bullet/collision/PhysicsCollisionObject.java Mon Oct 10 16:11:17 2011 +0900

+++ b/engine/src/bullet/com/jme3/bullet/collision/PhysicsCollisionObject.java Sat Oct 15 08:11:40 2011 +0900

@@ -125,6 +125,9 @@

*/

public void setCollisionGroup(int collisionGroup) {

this.collisionGroup = collisionGroup;

  •    if (objectId != 0) {<br />
    
  •        setCollisionGroup(objectId, collisionGroup);<br />
    
  •    }<br />
    

}



/**

@@ -135,6 +138,9 @@

*/

public void addCollideWithGroup(int collisionGroup) {

this.collisionGroupsMask = this.collisionGroupsMask | collisionGroup;

  •    if (objectId != 0) {<br />
    
  •        setCollideWithGroups(objectId, this.collisionGroupsMask);<br />
    
  •    }<br />
    

}



/**

@@ -143,6 +149,9 @@

*/

public void removeCollideWithGroup(int collisionGroup) {

this.collisionGroupsMask = this.collisionGroupsMask & ~collisionGroup;

  •    if (objectId != 0) {<br />
    
  •        setCollideWithGroups(this.collisionGroupsMask);<br />
    
  •    }<br />
    

}



/**

@@ -151,6 +160,9 @@

*/

public void setCollideWithGroups(int collisionGroups) {

this.collisionGroupsMask = collisionGroups;

  •    if (objectId != 0) {<br />
    
  •        setCollideWithGroups(objectId, this.collisionGroupsMask);<br />
    
  •    }<br />
    

}



/**

@@ -160,7 +172,12 @@

public int getCollideWithGroups() {

return collisionGroupsMask;

}

-

+

  • protected void initUserPointer() {
  •    Logger.getLogger(this.getClass().getName()).log(Level.INFO, &quot;initUserPointer() objectId = {0}&quot;, Long.toHexString(objectId));<br />
    
  •    initUserPointer(objectId, collisionGroup, collisionGroupsMask);<br />
    
  • }
  • native void initUserPointer(long objectId, int group, int groups);

    /**
  • Creates a visual debug shape of the current collision shape of this physics object<br/>
  • <b>Does not work with detached physics, please switch to PARALLEL or SEQUENTIAL for debugging</b>

    @@ -278,6 +295,8 @@

    }



    protected native void attachCollisionShape(long objectId, long collisionShapeId);
  • native void setCollisionGroup(long objectId, int collisionGroup);
  • native void setCollideWithGroups(long objectId, int collisionGroups);



    @Override

    public void write(JmeExporter e) throws IOException {

    diff -r 7a78f7ca8432 -r 19650db1402b engine/src/bullet/com/jme3/bullet/joints/SixDofJoint.java

    — a/engine/src/bullet/com/jme3/bullet/joints/SixDofJoint.java Mon Oct 10 16:11:17 2011 +0900

    +++ b/engine/src/bullet/com/jme3/bullet/joints/SixDofJoint.java Sat Oct 15 08:11:40 2011 +0900

    @@ -59,14 +59,14 @@

    */

    public class SixDofJoint extends PhysicsJoint {


  • private Matrix3f rotA, rotB;
  • private boolean useLinearReferenceFrameA;
  • private LinkedList<RotationalLimitMotor> rotationalMotors = new LinkedList<RotationalLimitMotor>();
  • private TranslationalLimitMotor translationalMotor;
  • private Vector3f angularUpperLimit = new Vector3f(Vector3f.POSITIVE_INFINITY);
  • private Vector3f angularLowerLimit = new Vector3f(Vector3f.NEGATIVE_INFINITY);
  • private Vector3f linearUpperLimit = new Vector3f(Vector3f.POSITIVE_INFINITY);
  • private Vector3f linearLowerLimit = new Vector3f(Vector3f.NEGATIVE_INFINITY);
  • Matrix3f rotA, rotB;
  • boolean useLinearReferenceFrameA;
  • LinkedList<RotationalLimitMotor> rotationalMotors = new LinkedList<RotationalLimitMotor>();
  • TranslationalLimitMotor translationalMotor;
  • Vector3f angularUpperLimit = new Vector3f(Vector3f.POSITIVE_INFINITY);
  • Vector3f angularLowerLimit = new Vector3f(Vector3f.NEGATIVE_INFINITY);
  • Vector3f linearUpperLimit = new Vector3f(Vector3f.POSITIVE_INFINITY);
  • Vector3f linearLowerLimit = new Vector3f(Vector3f.NEGATIVE_INFINITY);



    public SixDofJoint() {

    }

    @@ -160,7 +160,7 @@



    private native void setAngularLowerLimit(long objctId, Vector3f vector);


  • private native long createJoint(long objectIdA, long objectIdB, Vector3f pivotA, Matrix3f rotA, Vector3f pivotB, Matrix3f rotB, boolean useLinearReferenceFrameA);
  • native long createJoint(long objectIdA, long objectIdB, Vector3f pivotA, Matrix3f rotA, Vector3f pivotB, Matrix3f rotB, boolean useLinearReferenceFrameA);



    @Override

    public void read(JmeImporter im) throws IOException {

    diff -r 7a78f7ca8432 -r 19650db1402b engine/src/bullet/com/jme3/bullet/joints/SixDofSpringJoint.java

    — /dev/null Thu Jan 01 00:00:00 1970 +0000

    +++ b/engine/src/bullet/com/jme3/bullet/joints/SixDofSpringJoint.java Sat Oct 15 08:11:40 2011 +0900

    @@ -0,0 +1,103 @@

    +/*
    • Copyright © 2009-2010 jMonkeyEngine
    • All rights reserved.
  • *
    • Redistribution and use in source and binary forms, with or without
    • modification, are permitted provided that the following conditions are
    • met:
  • *
      • Redistributions of source code must retain the above copyright
    • notice, this list of conditions and the following disclaimer.
  • *
      • Redistributions in binary form must reproduce the above copyright
    • notice, this list of conditions and the following disclaimer in the
    • documentation and/or other materials provided with the distribution.
  • *
      • Neither the name of ‘jMonkeyEngine’ nor the names of its contributors
    • may be used to endorse or promote products derived from this software
    • without specific prior written permission.
  • *
    • THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    • "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
    • TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    • PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
    • CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    • EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    • PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
    • PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
    • LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
    • NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    • SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  • */

    +package com.jme3.bullet.joints;

    +

    +import com.jme3.export.JmeExporter;

    +import com.jme3.export.JmeImporter;

    +import com.jme3.math.Matrix3f;

    +import com.jme3.math.Vector3f;

    +import com.jme3.bullet.joints.motors.RotationalLimitMotor;

    +import com.jme3.bullet.joints.motors.TranslationalLimitMotor;

    +import com.jme3.bullet.objects.PhysicsRigidBody;

    +import com.jme3.export.InputCapsule;

    +import com.jme3.export.OutputCapsule;

    +import java.io.IOException;

    +import java.util.Iterator;

    +import java.util.LinkedList;

    +import java.util.logging.Level;

    +import java.util.logging.Logger;

    +

    +/**
    • <i>From bullet manual:</i><br>
    • This generic constraint can emulate a variety of standard constraints,
    • by configuring each of the 6 degrees of freedom (dof).
    • The first 3 dof axis are linear axis, which represent translation of rigidbodies,
    • and the latter 3 dof axis represent the angular motion. Each axis can be either locked,
    • free or limited. On construction of a new btGeneric6DofConstraint, all axis are locked.
    • Afterwards the axis can be reconfigured. Note that several combinations that
    • include free and/or limited angular degrees of freedom are undefined.
    • @author normenhansen
  • */

    +public class SixDofSpringJoint extends SixDofJoint {

    +
  • final boolean springEnabled[] = new boolean[6];
  • final float equilibriumPoint[] = new float[6];
  • final float springStiffness[] = new float[6];
  • final float springDamping[] = new float[6]; // between 0 and 1 (1 == no damping)

    +
  • public SixDofSpringJoint() {
  • }

    +
  • /**
  • * @param pivotA local translation of the joint connection point in node A<br />
    
  • * @param pivotB local translation of the joint connection point in node B<br />
    
  • */<br />
    
  • public SixDofSpringJoint(PhysicsRigidBody nodeA, PhysicsRigidBody nodeB, Vector3f pivotA, Vector3f pivotB, Matrix3f rotA, Matrix3f rotB, boolean useLinearReferenceFrameA) {
  •    super(nodeA, nodeB, pivotA, pivotB, rotA, rotB, useLinearReferenceFrameA);<br />
    
  • }
  • public void enableSpring(int index, boolean onOff) {
  •    enableSpring(objectId, index, onOff);<br />
    
  • }
  • native void enableSpring(long objctId, int index, boolean onOff);

    +
  • public void setStiffness(int index, float stiffness) {
  •    setStiffness(objectId, index, stiffness);<br />
    
  • }
  • native void setStiffness(long objctId, int index, float stiffness);

    +
  • public void setDamping(int index, float damping) {
  •    setDamping(objectId, index, damping);<br />
    

+

  • }
  • native void setDamping(long objctId, int index, float damping);
  • public void setEquilibriumPoint() { // set the current constraint position/orientation as an equilibrium point for all DOF
  •    setEquilibriumPoint(objectId);<br />
    
  • }
  • native void setEquilibriumPoint(long objctId);
  • public void setEquilibriumPoint(int index){ // set the current constraint position/orientation as an equilibrium point for given DOF
  •    setEquilibriumPoint(objectId, index);<br />
    
  • }
  • native void setEquilibriumPoint(long objctId, int index);
  • @Override
  • native long createJoint(long objectIdA, long objectIdB, Vector3f pivotA, Matrix3f rotA, Vector3f pivotB, Matrix3f rotB, boolean useLinearReferenceFrameA);

    +

    +}

    diff -r 7a78f7ca8432 -r 19650db1402b engine/src/bullet/com/jme3/bullet/objects/PhysicsCharacter.java

    — a/engine/src/bullet/com/jme3/bullet/objects/PhysicsCharacter.java Mon Oct 10 16:11:17 2011 +0900

    +++ b/engine/src/bullet/com/jme3/bullet/objects/PhysicsCharacter.java Sat Oct 15 08:11:40 2011 +0900

    @@ -79,6 +79,7 @@

    if (objectId == 0) {

    objectId = createGhostObject();

    Logger.getLogger(this.getClass().getName()).log(Level.INFO, "Creating GhostObject {0}", Long.toHexString(objectId));
  •        initUserPointer();<br />
    

}

setCharacterFlags(objectId);

attachCollisionShape(objectId, collisionShape.getObjectId());

diff -r 7a78f7ca8432 -r 19650db1402b engine/src/bullet/com/jme3/bullet/objects/PhysicsGhostObject.java

— a/engine/src/bullet/com/jme3/bullet/objects/PhysicsGhostObject.java Mon Oct 10 16:11:17 2011 +0900

+++ b/engine/src/bullet/com/jme3/bullet/objects/PhysicsGhostObject.java Sat Oct 15 08:11:40 2011 +0900

@@ -80,6 +80,7 @@

objectId = createGhostObject();

Logger.getLogger(this.getClass().getName()).log(Level.INFO, "Created Ghost Object {0}", Long.toHexString(objectId));

setGhostFlags(objectId);

  •        initUserPointer();<br />
    

}

// if (gObject == null) {

// gObject = new PairCachingGhostObject();

@@ -215,12 +216,17 @@

  • @return All CollisionObjects overlapping with this GhostNode.

    */

    public List<PhysicsCollisionObject> getOverlappingObjects() {

    -// overlappingObjects.clear();
  •    overlappingObjects.clear();<br />
    
  •    getOverlappingObjects(objectId);<br />
    

// for (com.bulletphysics.collision.dispatch.CollisionObject collObj : gObject.getOverlappingPairs()) {

// overlappingObjects.add((PhysicsCollisionObject) collObj.getUserPointer());

// }

return overlappingObjects;

}

  • protected native void getOverlappingObjects(long objectId);
  • protected void addOverlappingObject(PhysicsCollisionObject co) {
  •    overlappingObjects.add(co);<br />
    
  • }



    /**

    *

    diff -r 7a78f7ca8432 -r 19650db1402b engine/src/bullet/com/jme3/bullet/objects/PhysicsRigidBody.java

    — a/engine/src/bullet/com/jme3/bullet/objects/PhysicsRigidBody.java Mon Oct 10 16:11:17 2011 +0900

    +++ b/engine/src/bullet/com/jme3/bullet/objects/PhysicsRigidBody.java Sat Oct 15 08:11:40 2011 +0900

    @@ -121,6 +121,7 @@

    } else {

    setStatic(objectId, false);

    }
  •    initUserPointer();<br />
    

}



/**

@@ -420,7 +421,7 @@

  • @param restitution

    */

    public void setRestitution(float restitution) {
  •    setRestitution(objectId, mass);<br />
    
  •    setRestitution(objectId, restitution);<br />
    

}



private native void setRestitution(long objectId, float factor);

diff -r 7a78f7ca8432 -r 19650db1402b engine/src/bullet/com/jme3/bullet/objects/PhysicsVehicle.java

— a/engine/src/bullet/com/jme3/bullet/objects/PhysicsVehicle.java Mon Oct 10 16:11:17 2011 +0900

+++ b/engine/src/bullet/com/jme3/bullet/objects/PhysicsVehicle.java Sat Oct 15 08:11:40 2011 +0900

@@ -149,6 +149,12 @@

setCoordinateSystem(vehicleId, 0, 1, 2);

for (VehicleWheel wheel : wheels) {

wheel.setWheelId(addWheel(vehicleId, wheel.getLocation(), wheel.getDirection(), wheel.getAxle(), wheel.getRestLength(), wheel.getRadius(), tuning, wheel.isFrontWheel()));

  •        wheel.setFrictionSlip(tuning.frictionSlip);<br />
    
  •        wheel.setMaxSuspensionTravelCm(tuning.maxSuspensionTravelCm);<br />
    
  •        wheel.setSuspensionStiffness(tuning.suspensionStiffness);<br />
    
  •        wheel.setWheelsDampingCompression(tuning.suspensionCompression);<br />
    
  •        wheel.setWheelsDampingRelaxation(tuning.suspensionDamping);<br />
    
  •        wheel.setMaxSuspensionForce(tuning.maxSuspensionForce);<br />
    

}

}

[/patch]

1 Like

[patch]

diff -r 7a78f7ca8432 -r 19650db1402b engine/src/bullet/native/build.xml

— a/engine/src/bullet/native/build.xml Mon Oct 10 16:11:17 2011 +0900

+++ b/engine/src/bullet/native/build.xml Sat Oct 15 08:11:40 2011 +0900

@@ -5,6 +5,9 @@

<!-- load properties -->

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

<!-- condition for mac platform check -->

  • <condition property="isSolaris">
  •   &lt;os name=&quot;SunOS&quot;/&gt;<br />
    
  • </condition>

    <condition property="isMac">

    <and>

    <os family="mac" />

    @@ -22,6 +25,9 @@

    <not>

    <os family="mac"/>

    </not>
  •   &lt;not&gt;<br />
    
  •     &lt;os name=&quot;SunOS&quot;/&gt;<br />
    
  •   &lt;/not&gt;<br />
    

</and>

</condition>

<!-- condition for x86_64 check -->

@@ -41,7 +47,7 @@

<fileset refid="lib.jme.jars"/>

</pathconvert>


  • <target name="build-bullet-natives" description="builds the native bullet library for the platform being run on" depends="-create-folders, create-native-headers, -nativelib-osx, -nativelib-windows, -nativelib-linux">
  • <target name="build-bullet-natives" description="builds the native bullet library for the platform being run on" depends="-create-folders, create-native-headers, -nativelib-osx, -nativelib-windows, -nativelib-linux, -nativelib-solaris">

    <echo message="Updating native jME3-bullet-natives.jar"/>

    <zip basedir="${bullet.output.base}/jarcontent" file="${bullet.output.base}/jME3-bullet-natives.jar" compress="true"/>

    <copy file="${bullet.output.base}/jME3-bullet-natives.jar" todir="dist/lib"/>

    @@ -51,6 +57,7 @@

    <javah destdir="${bullet.source.dir}" classpath="${bullet.build.dir}${path.separator}${lib.importpath}" force="yes">

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


  •        &lt;class name=&quot;com.jme3.bullet.collision.PhysicsCollisionEvent&quot;/&gt;<br />
    

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

<class name="com.jme3.bullet.objects.PhysicsCharacter"/>

<class name="com.jme3.bullet.objects.PhysicsGhostObject"/>

@@ -78,6 +85,7 @@

<class name="com.jme3.bullet.joints.HingeJoint"/>

<class name="com.jme3.bullet.joints.Point2PointJoint"/>

<class name="com.jme3.bullet.joints.SixDofJoint"/>

  •        &lt;class name=&quot;com.jme3.bullet.joints.SixDofSpringJoint&quot;/&gt;<br />
    

<class name="com.jme3.bullet.joints.SliderJoint"/>

<class name="com.jme3.bullet.joints.motors.RotationalLimitMotor"/>

<class name="com.jme3.bullet.joints.motors.TranslationalLimitMotor"/>

@@ -172,7 +180,10 @@

<includepath path="${bullet.java.include}/linux"/>

<includepath path="${bullet.bullet.include}"/>

<!–compilerarg value="-m32"/–>

  • <compilerarg value="-m32"/>
  • <compilerarg value="-static-libgcc"/>

    <linker name="${bullet.linux.compiler}">
  • <!-- linkerarg value="-static-libgcc"/ -->

    <libset dir="${bullet.folder}/src/BulletMultiThreaded" libs="BulletMultiThreaded"/>

    <libset dir="${bullet.folder}/src/BulletDynamics" libs="BulletDynamics"/>

    <libset dir="${bullet.folder}/src/BulletCollision" libs="BulletCollision"/>

    @@ -181,6 +192,36 @@

    </cc>

    <delete file="${bullet.output.dir}/linux/history.xml"/>

    </target>
  • <target name="-nativelib-solaris" if="isSolaris">
  •    &lt;echo message=&quot;Building Solaris version of native bullet&quot;/&gt;<br />
    
  •    &lt;mkdir dir=&quot;${bullet.output.dir}/linux&quot;/&gt;<br />
    
  •    &lt;cc name=&quot;${bullet.solaris.compiler}&quot; warnings=&quot;severe&quot; debug=&quot;${bullet.compile.debug}&quot; link=&quot;shared&quot; outfile=&quot;${bullet.output.dir}/solaris/${bullet.library.name}&quot; objdir=&quot;${bullet.build.dir}&quot;&gt;<br />
    
  •        &lt;fileset dir=&quot;${bullet.source.dir}&quot;&gt;<br />
    
  •            &lt;include name=&quot;*.cpp&quot;&gt;<br />
    
  •            &lt;/include&gt;<br />
    
  •        &lt;/fileset&gt;<br />
    
  •        &lt;includepath path=&quot;${bullet.java.include}&quot;/&gt;<br />
    
  •        &lt;includepath path=&quot;${bullet.java.include}/solaris&quot;/&gt;<br />
    
  •        &lt;includepath path=&quot;${bullet.bullet.include}&quot;/&gt;<br />
    
  •        &lt;!--compilerarg value=&quot;-m32&quot;/--&gt;<br />
    
  • <compilerarg value="-m32"/>
  • <compilerarg value="-fno-strict-aliasing"/>
  • <compilerarg value="-pthread"/>
  • <compilerarg value="-fPIC"/>
  • <compilerarg value="-D_REENTRANT"/>
  • <compilerarg value="-static-libstdc++"/>
  • <compilerarg value="-static-libgcc"/>
  • <compilerarg value="-D_REENTRANT"/>
  •        &lt;linker name=&quot;${bullet.solaris.compiler}&quot;&gt;<br />
    
  • <linkerarg value="-R/usr/sfw/lib"/>
  •            &lt;libset dir=&quot;${bullet.folder}/src/BulletMultiThreaded&quot; libs=&quot;BulletMultiThreaded&quot;/&gt;<br />
    
  •            &lt;libset dir=&quot;${bullet.folder}/src/BulletDynamics&quot; libs=&quot;BulletDynamics&quot;/&gt;<br />
    
  •            &lt;libset dir=&quot;${bullet.folder}/src/BulletCollision&quot; libs=&quot;BulletCollision&quot;/&gt;<br />
    
  •            &lt;libset dir=&quot;${bullet.folder}/src/LinearMath&quot; libs=&quot;LinearMath&quot;/&gt;<br />
    
  •        &lt;/linker&gt;<br />
    
  •    &lt;/cc&gt;<br />
    
  •    &lt;delete file=&quot;${bullet.output.dir}/solaris/history.xml&quot;/&gt;<br />
    
  • </target>



    <target name="-nativelib-windows" if="isWindows">

    <echo message="Building Windows version of native bullet"/>

    @@ -194,10 +235,11 @@

    <includepath path="${bullet.java.include}/win32"/>

    <includepath path="${bullet.bullet.include}"/>

    <!–compilerarg value="-m32"/–>
  • <!-- compilerarg value="-static-libgcc -static-libstdc++"/ -->

    <linker name="${bullet.windows.compiler}" debug="${bullet.compile.debug}" >

    <linkerarg value="-o${bullet.library.name}.dll" />

    <linkerarg value="–kill-at" />
  •            &lt;linkerarg value=&quot;-static&quot;/&gt;<br />
    
  • <linkerarg value="-static"/>

    <libset dir="${bullet.folder}/lib" libs="BulletMultiThreaded,BulletDynamics,BulletCollision,LinearMath"/>

    </linker>

    </cc>

    diff -r 7a78f7ca8432 -r 19650db1402b engine/src/bullet/native/bullet.properties

    — a/engine/src/bullet/native/bullet.properties Mon Oct 10 16:11:17 2011 +0900

    +++ b/engine/src/bullet/native/bullet.properties Sat Oct 15 08:11:40 2011 +0900

    @@ -1,12 +1,15 @@

    -#####################################################

    +####################################################

these are the ant build properties for bullet-jme #

#####################################################

bullet.library.name=bulletjme

bullet.library.version=0.9


change if bullet folder has different location

-bullet.folder=…/bullet-trunk

-

+# bullet.folder=…/bullet-trunk

+# bullet.folder=…/bullet-trunk.win32

+# bullet.folder=…/bullet-trunk.linux

+# bullet.folder=…/bullet-trunk.mac

+bullet.folder=…/bullet-trunk.solaris

compile options

bullet.compile.debug=false



@@ -16,9 +19,11 @@

change this to msvc for MS Visual Studio compiler

bullet.windows.compiler=g++

bullet.linux.compiler=g++

-

+bullet.solaris.compiler=g++

native header include directories

-bullet.java.include=${java.home}/…/include

+# bullet.java.include=${java.home}/…/include:${java.home}/…/include/win32

+bullet.java.include=${java.home}/…/include:${java.home}/…/include/solaris

+# bullet.java.include=${java.home}/…/include:${java.home}/…/include/linux

OSX has no JRE, only JDK

bullet.osx.java.include=${java.home}/include



diff -r 7a78f7ca8432 -r 19650db1402b engine/src/bullet/native/com_jme3_bullet_PhysicsSpace.cpp

— a/engine/src/bullet/native/com_jme3_bullet_PhysicsSpace.cpp Mon Oct 10 16:11:17 2011 +0900

+++ b/engine/src/bullet/native/com_jme3_bullet_PhysicsSpace.cpp Sat Oct 15 08:11:40 2011 +0900

@@ -32,7 +32,7 @@

#include "com_jme3_bullet_PhysicsSpace.h"

#include "jmePhysicsSpace.h"

#include "jmeBulletUtil.h"

-

+#include "jmeUserPointer.h"

/**

  • Author: Normen Hansen

    */

    @@ -93,6 +93,9 @@

    env->ThrowNew(newExc, "The collision object does not exist.");

    return;

    }
  •    jmeUserPointer *userPointer = (jmeUserPointer*)collisionObject-&gt;getUserPointer();<br />
    
  •    userPointer -&gt; space = space;<br />
    

+

space->getDynamicsWorld()->addCollisionObject(collisionObject);

}



@@ -116,6 +119,8 @@

return;

}

space->getDynamicsWorld()->removeCollisionObject(collisionObject);

  •    jmeUserPointer *userPointer = (jmeUserPointer*)collisionObject-&gt;getUserPointer();<br />
    
  •    userPointer -&gt; space = NULL;<br />
    

}



/*

@@ -137,6 +142,8 @@

env->ThrowNew(newExc, "The collision object does not exist.");

return;

}

  •    jmeUserPointer *userPointer = (jmeUserPointer*)collisionObject-&gt;getUserPointer();<br />
    
  •    userPointer -&gt; space = space;<br />
    

space->getDynamicsWorld()->addRigidBody(collisionObject);

}



@@ -159,6 +166,8 @@

env->ThrowNew(newExc, "The collision object does not exist.");

return;

}

  •    jmeUserPointer *userPointer = (jmeUserPointer*)collisionObject-&gt;getUserPointer();<br />
    
  •    userPointer -&gt; space = NULL;<br />
    

space->getDynamicsWorld()->removeRigidBody(collisionObject);

}



@@ -181,7 +190,12 @@

env->ThrowNew(newExc, "The collision object does not exist.");

return;

}

  •    space-&gt;getDynamicsWorld()-&gt;addCollisionObject(collisionObject, btBroadphaseProxy::CharacterFilter, btBroadphaseProxy::StaticFilter | btBroadphaseProxy::DefaultFilter);<br />
    
  •    jmeUserPointer *userPointer = (jmeUserPointer*)collisionObject-&gt;getUserPointer();<br />
    
  •    userPointer -&gt; space = space;<br />
    
  •    space-&gt;getDynamicsWorld()-&gt;addCollisionObject(collisionObject,<br />
    
  •            btBroadphaseProxy::CharacterFilter,<br />
    
  •            btBroadphaseProxy::StaticFilter | btBroadphaseProxy::DefaultFilter<br />
    
  •    );<br />
    

}



/*

@@ -203,6 +217,8 @@

env->ThrowNew(newExc, "The collision object does not exist.");

return;

}

  •    jmeUserPointer *userPointer = (jmeUserPointer*)collisionObject-&gt;getUserPointer();<br />
    
  •    userPointer -&gt; space = NULL;<br />
    

space->getDynamicsWorld()->removeCollisionObject(collisionObject);

}



diff -r 7a78f7ca8432 -r 19650db1402b engine/src/bullet/native/com_jme3_bullet_collision_PhysicsCollisionObject.cpp

— a/engine/src/bullet/native/com_jme3_bullet_collision_PhysicsCollisionObject.cpp Mon Oct 10 16:11:17 2011 +0900

+++ b/engine/src/bullet/native/com_jme3_bullet_collision_PhysicsCollisionObject.cpp Sat Oct 15 08:11:40 2011 +0900

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

*/

#include "com_jme3_bullet_collision_PhysicsCollisionObject.h"

#include "jmeBulletUtil.h"

+#include "jmePhysicsSpace.h"

+#include "jmeUserPointer.h"



#ifdef __cplusplus

extern "C" {

@@ -75,8 +77,73 @@

env->ThrowNew(newExc, "The native object does not exist.");

return;

}

  •    if (collisionObject -&gt; getUserPointer() != NULL){<br />
    
  •        jmeUserPointer *userPointer = (jmeUserPointer*)collisionObject-&gt;getUserPointer();<br />
    
  •        delete(userPointer);<br />
    
  •    }<br />
    

delete(collisionObject);

}

  • /*
  • * Class:     com_jme3_bullet_collision_PhysicsCollisionObject<br />
    
  • * Method:    initUserPointer<br />
    
  • * Signature: (JII)V<br />
    
  • */<br />
    
  • JNIEXPORT void JNICALL Java_com_jme3_bullet_collision_PhysicsCollisionObject_initUserPointer
  •  (JNIEnv *env, jobject object, jlong objectId, jint group, jint groups) {<br />
    
  •    btCollisionObject* collisionObject = (btCollisionObject*) objectId;<br />
    
  •    if (collisionObject == NULL) {<br />
    
  •        jclass newExc = env-&gt;FindClass(&quot;java/lang/NullPointerException&quot;);<br />
    
  •        env-&gt;ThrowNew(newExc, &quot;The native object does not exist.&quot;);<br />
    
  •        return;<br />
    
  •    }<br />
    
  •    jmeUserPointer *userPointer = (jmeUserPointer*)collisionObject-&gt;getUserPointer();<br />
    
  •    if (userPointer != NULL) {<br />
    

+// delete(userPointer);

  •    }<br />
    
  •    userPointer = new jmeUserPointer();<br />
    
  •    userPointer -&gt; javaCollisionObject = env-&gt;NewWeakGlobalRef(object);<br />
    
  •    userPointer -&gt; group = group;<br />
    
  •    userPointer -&gt; groups = groups;<br />
    
  •    userPointer -&gt; space = NULL;<br />
    
  •    collisionObject -&gt; setUserPointer(userPointer);<br />
    
  • }
  • /*
  • * Class:     com_jme3_bullet_collision_PhysicsCollisionObject<br />
    
  • * Method:    setCollisionGroup<br />
    
  • * Signature: (JI)V<br />
    
  • */<br />
    
  • JNIEXPORT void JNICALL Java_com_jme3_bullet_collision_PhysicsCollisionObject_setCollisionGroup
  •  (JNIEnv *env, jobject object, jlong objectId, jint group) {<br />
    
  •    btCollisionObject* collisionObject = (btCollisionObject*) objectId;<br />
    
  •    if (collisionObject == NULL) {<br />
    
  •        jclass newExc = env-&gt;FindClass(&quot;java/lang/NullPointerException&quot;);<br />
    
  •        env-&gt;ThrowNew(newExc, &quot;The native object does not exist.&quot;);<br />
    
  •        return;<br />
    
  •    }<br />
    
  •    jmeUserPointer *userPointer = (jmeUserPointer*)collisionObject-&gt;getUserPointer();<br />
    
  •    if (userPointer != NULL){<br />
    
  •        userPointer -&gt; group = group;<br />
    
  •    }<br />
    
  • }
  • /*
  • * Class:     com_jme3_bullet_collision_PhysicsCollisionObject<br />
    
  • * Method:    setCollideWithGroups<br />
    
  • * Signature: (JI)V<br />
    
  • */<br />
    
  • JNIEXPORT void JNICALL Java_com_jme3_bullet_collision_PhysicsCollisionObject_setCollideWithGroups
  •  (JNIEnv *env, jobject object, jlong objectId, jint groups) {<br />
    
  •    btCollisionObject* collisionObject = (btCollisionObject*) objectId;<br />
    
  •    if (collisionObject == NULL) {<br />
    
  •        jclass newExc = env-&gt;FindClass(&quot;java/lang/NullPointerException&quot;);<br />
    
  •        env-&gt;ThrowNew(newExc, &quot;The native object does not exist.&quot;);<br />
    
  •        return;<br />
    
  •    }<br />
    
  •    jmeUserPointer *userPointer = (jmeUserPointer*)collisionObject-&gt;getUserPointer();<br />
    
  •    if (userPointer != NULL){<br />
    
  •        userPointer -&gt; groups = groups;<br />
    
  •    }<br />
    
  • }

    +

    #ifdef __cplusplus

    }

    #endif

    diff -r 7a78f7ca8432 -r 19650db1402b engine/src/bullet/native/com_jme3_bullet_collision_PhysicsCollisionObject.h

    — a/engine/src/bullet/native/com_jme3_bullet_collision_PhysicsCollisionObject.h Mon Oct 10 16:11:17 2011 +0900

    +++ b/engine/src/bullet/native/com_jme3_bullet_collision_PhysicsCollisionObject.h Sat Oct 15 08:11:40 2011 +0900

    @@ -43,6 +43,14 @@

    #define com_jme3_bullet_collision_PhysicsCollisionObject_COLLISION_GROUP_16 32768L

    /*
  • Class: com_jme3_bullet_collision_PhysicsCollisionObject
    • Method: initUserPointer
    • Signature: (JII)V
  • */

    +JNIEXPORT void JNICALL Java_com_jme3_bullet_collision_PhysicsCollisionObject_initUserPointer
  • (JNIEnv , jobject, jlong, jint, jint);

    +

    +/

    • Class: com_jme3_bullet_collision_PhysicsCollisionObject
  • Method: attachCollisionShape
  • Signature: (JJ)V

    /

    @@ -51,6 +59,22 @@



    /

  • Class: com_jme3_bullet_collision_PhysicsCollisionObject
    • Method: setCollisionGroup
    • Signature: (JI)V
  • */

    +JNIEXPORT void JNICALL Java_com_jme3_bullet_collision_PhysicsCollisionObject_setCollisionGroup
  • (JNIEnv , jobject, jlong, jint);

    +

    +/

    • Class: com_jme3_bullet_collision_PhysicsCollisionObject
    • Method: setCollideWithGroups
    • Signature: (JI)V
  • */

    +JNIEXPORT void JNICALL Java_com_jme3_bullet_collision_PhysicsCollisionObject_setCollideWithGroups
  • (JNIEnv , jobject, jlong, jint);

    +

    +/

    • Class: com_jme3_bullet_collision_PhysicsCollisionObject
  • Method: finalizeNative
  • Signature: (J)V

    */

    diff -r 7a78f7ca8432 -r 19650db1402b engine/src/bullet/native/com_jme3_bullet_joints_SixDofSpringJoint.cpp

    — /dev/null Thu Jan 01 00:00:00 1970 +0000

    +++ b/engine/src/bullet/native/com_jme3_bullet_joints_SixDofSpringJoint.cpp Sat Oct 15 08:11:40 2011 +0900

    @@ -0,0 +1,103 @@

    +

    +/**
    • Author: Normen Hansen
  • /

    +#include "com_jme3_bullet_joints_SixDofSpringJoint.h"

    +#include "jmeBulletUtil.h"

    +

    +#ifdef __cplusplus

    +extern "C" {

    +#endif

    +

    +/

    • Class: com_jme3_bullet_joints_SixDofSpringJoint
    • Method: enableString
    • Signature: (JIZ)V
  • */

    +JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SixDofSpringJoint_enableSpring
  • (JNIEnv *env, jobject object, jlong jointId, jint index, jboolean onOff) {
  • btGeneric6DofSpringConstraint* joint = (btGeneric6DofSpringConstraint*) jointId;
  • joint -> enableSpring(index, onOff);

    +}

    +

    +

    +/*
    • Class: com_jme3_bullet_joints_SixDofSpringJoint
    • Method: setStiffness
    • Signature: (JIF)V
  • */

    +JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SixDofSpringJoint_setStiffness
  • (JNIEnv *env, jobject object, jlong jointId, jint index, jfloat stiffness) {
  • btGeneric6DofSpringConstraint* joint = (btGeneric6DofSpringConstraint*) jointId;
  • joint -> setStiffness(index, stiffness);

    +}

    +

    +/*
    • Class: com_jme3_bullet_joints_SixDofSpringJoint
    • Method: setDamping
    • Signature: (JIF)V
  • */

    +JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SixDofSpringJoint_setDamping
  • (JNIEnv *env, jobject object, jlong jointId, jint index, jfloat damping) {
  • btGeneric6DofSpringConstraint* joint = (btGeneric6DofSpringConstraint*) jointId;
  • joint -> setDamping(index, damping);

    +}

    +

    +/*
    • Class: com_jme3_bullet_joints_SixDofSpringJoint
    • Method: setEquilibriumPoint
    • Signature: (JIF)V
  • */

    +JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SixDofSpringJoint_setEquilibriumPoint__J
  • (JNIEnv *env, jobject object, jlong jointId) {
  • btGeneric6DofSpringConstraint* joint = (btGeneric6DofSpringConstraint*) jointId;
  • joint -> setEquilibriumPoint();

    +}

    +

    +/*
    • Class: com_jme3_bullet_joints_SixDofSpringJoint
    • Method: setEquilibriumPoint
    • Signature: (JI)V
  • */

    +JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SixDofSpringJoint_setEquilibriumPoint__JI
  • (JNIEnv *env, jobject object, jlong jointId, jint index) {
  • btGeneric6DofSpringConstraint* joint = (btGeneric6DofSpringConstraint*) jointId;
  • joint -> setEquilibriumPoint(index);

    +}

    +

    +

    +

    +

    +/*
    • Class: com_jme3_bullet_joints_SixDofSpringJoint
    • Method: createJoint
    • Signature: (JJLcom/jme3/math/Vector3f;Lcom/jme3/math/Matrix3f;Lcom/jme3/math/Vector3f;Lcom/jme3/math/Matrix3f;Z)J
  • */

    +JNIEXPORT jlong JNICALL Java_com_jme3_bullet_joints_SixDofSpringJoint_createJoint
  • (JNIEnv * env, jobject object, jlong bodyIdA, jlong bodyIdB, jobject pivotA, jobject rotA, jobject pivotB, jobject rotB, jboolean useLinearReferenceFrameA) {
  •    jmeClasses::initJavaClasses(env);<br />
    
  •    btRigidBody* bodyA = (btRigidBody*) bodyIdA;<br />
    
  •    btRigidBody* bodyB = (btRigidBody*) bodyIdB;<br />
    
  •    btMatrix3x3* mtx1 = &amp;btMatrix3x3();<br />
    
  •    btMatrix3x3* mtx2 = &amp;btMatrix3x3();<br />
    

+/* btTransform* transA = &btTransform(*mtx1);

  •    jmeBulletUtil::convert(env, pivotA, &amp;transA-&gt;getOrigin());<br />
    
  •    jmeBulletUtil::convert(env, rotA, &amp;transA-&gt;getBasis());<br />
    
  •    btTransform* transB = &amp;btTransform(*mtx2);<br />
    
  •    jmeBulletUtil::convert(env, pivotB, &amp;transB-&gt;getOrigin());<br />
    
  •    jmeBulletUtil::convert(env, rotB, &amp;transB-&gt;getBasis());<br />
    

+*/

  •    btTransform transA;<br />
    
  •    jmeBulletUtil::convert(env, pivotA, &amp;transA.getOrigin());<br />
    
  •    jmeBulletUtil::convert(env, rotA, &amp;transA.getBasis());<br />
    
  •    btTransform transB;<br />
    
  •    jmeBulletUtil::convert(env, pivotB, &amp;transB.getOrigin());<br />
    
  •    jmeBulletUtil::convert(env, rotB, &amp;transB.getBasis());<br />
    

+

  •    btGeneric6DofSpringConstraint* joint = new btGeneric6DofSpringConstraint(*bodyA, *bodyB, transA, transB, useLinearReferenceFrameA);<br />
    
  •    return (long)joint;<br />
    
  • }

    +

    +#ifdef __cplusplus

    +}

    +#endif

    diff -r 7a78f7ca8432 -r 19650db1402b engine/src/bullet/native/com_jme3_bullet_joints_SixDofSpringJoint.h

    — /dev/null Thu Jan 01 00:00:00 1970 +0000

    +++ b/engine/src/bullet/native/com_jme3_bullet_joints_SixDofSpringJoint.h Sat Oct 15 08:11:40 2011 +0900

    @@ -0,0 +1,61 @@

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

    +#include <jni.h>

    +/
    Header for class com_jme3_bullet_joints_SixDofSpringJoint /

    +

    +#ifndef _Included_com_jme3_bullet_joints_SixDofSpringJoint

    +#define _Included_com_jme3_bullet_joints_SixDofSpringJoint

    +#ifdef __cplusplus

    +extern "C" {

    +#endif

    +/

    • Class: com_jme3_bullet_joints_SixDofSpringJoint
    • Method: enableSpring
    • Signature: (JIZ)V
  • */

    +JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SixDofSpringJoint_enableSpring
  • (JNIEnv , jobject, jlong, jint, jboolean);

    +

    +/

    • Class: com_jme3_bullet_joints_SixDofSpringJoint
    • Method: setStiffness
    • Signature: (JIF)V
  • */

    +JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SixDofSpringJoint_setStiffness
  • (JNIEnv , jobject, jlong, jint, jfloat);

    +

    +/

    • Class: com_jme3_bullet_joints_SixDofSpringJoint
    • Method: setDamping
    • Signature: (JIF)V
  • */

    +JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SixDofSpringJoint_setDamping
  • (JNIEnv , jobject, jlong, jint, jfloat);

    +

    +/

    • Class: com_jme3_bullet_joints_SixDofSpringJoint
    • Method: setEquilibriumPoint
    • Signature: (J)V
  • */

    +JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SixDofSpringJoint_setEquilibriumPoint__J
  • (JNIEnv , jobject, jlong);

    +

    +/

    • Class: com_jme3_bullet_joints_SixDofSpringJoint
    • Method: setEquilibriumPoint
    • Signature: (JI)V
  • */

    +JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SixDofSpringJoint_setEquilibriumPoint__JI
  • (JNIEnv , jobject, jlong, jint);

    +

    +/

    • Class: com_jme3_bullet_joints_SixDofSpringJoint
    • Method: createJoint
    • Signature: (JJLcom/jme3/math/Vector3f;Lcom/jme3/math/Matrix3f;Lcom/jme3/math/Vector3f;Lcom/jme3/math/Matrix3f;Z)J
  • */

    +JNIEXPORT jlong JNICALL Java_com_jme3_bullet_joints_SixDofSpringJoint_createJoint
  • (JNIEnv *, jobject, jlong, jlong, jobject, jobject, jobject, jobject, jboolean);

    +

    +#ifdef __cplusplus

    +}

    +#endif

    +#endif

    diff -r 7a78f7ca8432 -r 19650db1402b engine/src/bullet/native/com_jme3_bullet_objects_PhysicsCharacter.cpp

    — a/engine/src/bullet/native/com_jme3_bullet_objects_PhysicsCharacter.cpp Mon Oct 10 16:11:17 2011 +0900

    +++ b/engine/src/bullet/native/com_jme3_bullet_objects_PhysicsCharacter.cpp Sat Oct 15 08:11:40 2011 +0900

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

    env->ThrowNew(newExc, "The native object does not exist.");

    return;

    }
  •    ghost-&gt;setCollisionFlags(ghost-&gt;getCollisionFlags() | btCollisionObject::CF_CHARACTER_OBJECT);<br />
    
  •    ghost-&gt;setCollisionFlags(/*ghost-&gt;getCollisionFlags() |*/ btCollisionObject::CF_CHARACTER_OBJECT);<br />
    

ghost->setCollisionFlags(ghost->getCollisionFlags() & ~btCollisionObject::CF_NO_CONTACT_RESPONSE);

}



diff -r 7a78f7ca8432 -r 19650db1402b engine/src/bullet/native/com_jme3_bullet_objects_PhysicsGhostObject.cpp

— a/engine/src/bullet/native/com_jme3_bullet_objects_PhysicsGhostObject.cpp Mon Oct 10 16:11:17 2011 +0900

+++ b/engine/src/bullet/native/com_jme3_bullet_objects_PhysicsGhostObject.cpp Sat Oct 15 08:11:40 2011 +0900

@@ -37,8 +37,10 @@

#include <BulletCollision/CollisionDispatch/btGhostObject.h>



#include "com_jme3_bullet_objects_PhysicsGhostObject.h"

+#include "BulletCollision/BroadphaseCollision/btOverlappingPairCache.h"

#include "jmeBulletUtil.h"

-

+#include "jmePhysicsSpace.h"

+#include "jmeUserPointer.h"

#ifdef __cplusplus

extern "C" {

#endif

@@ -166,9 +168,51 @@

}

jmeBulletUtil::convert(env, &ghost->getWorldTransform().getBasis(), value);

}

+

  • class jmeGhostOverlapCallback : public btOverlapCallback {
  •    JNIEnv* m_env;<br />
    
  •    jobject m_object;<br />
    
  • public:
  •    jmeGhostOverlapCallback(JNIEnv *env, jobject object)<br />
    
  •            :m_env(env),<br />
    
  •             m_object(object)<br />
    
  •    {<br />
    
  •    }<br />
    
  •    virtual ~jmeGhostOverlapCallback() {}<br />
    
  •    virtual bool    processOverlap(btBroadphasePair&amp; pair)<br />
    
  •    {<br />
    
  •        btCollisionObject *co1 = (btCollisionObject *)pair.m_pProxy0-&gt;m_clientObject;<br />
    
  •        jmeUserPointer *up1 = (jmeUserPointer*)co1 -&gt; getUserPointer();<br />
    

+

  •        m_env-&gt;CallVoidMethod(m_object, jmeClasses::PhysicsGhostObject_addOverlappingObject, up1-&gt;javaCollisionObject);<br />
    
  •        if (m_env-&gt;ExceptionCheck()) {<br />
    
  •            m_env-&gt;Throw(m_env-&gt;ExceptionOccurred());<br />
    
  •            return false;<br />
    
  •        }<br />
    

+

  •        return false;<br />
    
  •    }<br />
    
  • };



    /*
  • Class: com_jme3_bullet_objects_PhysicsGhostObject
  • * Method:    getOverlappingObjects<br />
    
  • * Signature: (J)V<br />
    
  • */<br />
    
  • JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsGhostObject_getOverlappingObjects
  •  (JNIEnv *env, jobject object, jlong objectId) {<br />
    
  •    btPairCachingGhostObject* ghost = (btPairCachingGhostObject*) objectId;<br />
    
  •    if (ghost == NULL) {<br />
    
  •        jclass newExc = env-&gt;FindClass(&quot;java/lang/NullPointerException&quot;);<br />
    
  •        env-&gt;ThrowNew(newExc, &quot;The native object does not exist.&quot;);<br />
    
  •        return;<br />
    
  •    }<br />
    
  •    btHashedOverlappingPairCache * pc = ghost-&gt;getOverlappingPairCache();<br />
    
  •    jmeGhostOverlapCallback cb(env, object);<br />
    
  •    pc -&gt; processAllOverlappingPairs(&amp;cb, NULL);<br />
    
  • }
  • /*
  • * Class:     com_jme3_bullet_objects_PhysicsGhostObject<br />
    
  • Method: getOverlappingCount
  • Signature: (J)I

    /

    diff -r 7a78f7ca8432 -r 19650db1402b engine/src/bullet/native/com_jme3_bullet_objects_PhysicsGhostObject.h

    — a/engine/src/bullet/native/com_jme3_bullet_objects_PhysicsGhostObject.h Mon Oct 10 16:11:17 2011 +0900

    +++ b/engine/src/bullet/native/com_jme3_bullet_objects_PhysicsGhostObject.h Sat Oct 15 08:11:40 2011 +0900

    @@ -107,6 +107,14 @@



    /

  • Class: com_jme3_bullet_objects_PhysicsGhostObject
    • Method: getOverlappingObjects
    • Signature: (J)V
  • */

    +JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsGhostObject_getOverlappingObjects
  • (JNIEnv , jobject, jlong);

    +

    +/

    • Class: com_jme3_bullet_objects_PhysicsGhostObject
  • Method: getOverlappingCount
  • Signature: (J)I

    /

    diff -r 7a78f7ca8432 -r 19650db1402b engine/src/bullet/native/com_jme3_bullet_objects_PhysicsRigidBody.cpp

    — a/engine/src/bullet/native/com_jme3_bullet_objects_PhysicsRigidBody.cpp Mon Oct 10 16:11:17 2011 +0900

    +++ b/engine/src/bullet/native/com_jme3_bullet_objects_PhysicsRigidBody.cpp Sat Oct 15 08:11:40 2011 +0900

    @@ -54,6 +54,7 @@

    btVector3 localInertia = btVector3();

    shape->calculateLocalInertia(mass, localInertia);

    btRigidBody
    body = new btRigidBody(mass, motionState, shape, localInertia);
  •    body-&gt;setUserPointer(NULL);<br />
    

return (long) body;

}



@@ -433,7 +434,7 @@

env->ThrowNew(newExc, "The native object does not exist.");

return;

}

  •    body-&gt;setDamping(body-&gt;getLinearDamping(), value);<br />
    
  •    body-&gt;setDamping(body-&gt;getAngularDamping(), value);<br />
    

}



/*

@@ -756,7 +757,7 @@

env->ThrowNew(newExc, "The native object does not exist.");

return;

}

  •    body-&gt;setSleepingThresholds(value, body-&gt;getAngularSleepingThreshold());<br />
    
  •    body-&gt;setSleepingThresholds(value, body-&gt;getLinearSleepingThreshold());<br />
    

}



/*

@@ -772,7 +773,7 @@

env->ThrowNew(newExc, "The native object does not exist.");

return;

}

  •    body-&gt;setSleepingThresholds(body-&gt;getLinearSleepingThreshold(), value);<br />
    
  •    body-&gt;setSleepingThresholds(body-&gt;getAngularSleepingThreshold(), value);<br />
    

}



/

diff -r 7a78f7ca8432 -r 19650db1402b engine/src/bullet/native/com_jme3_bullet_objects_PhysicsVehicle.cpp

— a/engine/src/bullet/native/com_jme3_bullet_objects_PhysicsVehicle.cpp Mon Oct 10 16:11:17 2011 +0900

+++ b/engine/src/bullet/native/com_jme3_bullet_objects_PhysicsVehicle.cpp Sat Oct 15 08:11:40 2011 +0900

@@ -36,6 +36,7 @@



#include "com_jme3_bullet_objects_PhysicsVehicle.h"

#include "jmeBulletUtil.h"

+#include "jmePhysicsSpace.h"

#include "BulletDynamics/Vehicle/btRaycastVehicle.h"



#ifdef __cplusplus

@@ -66,13 +67,13 @@

JNIEXPORT jlong JNICALL Java_com_jme3_bullet_objects_PhysicsVehicle_createVehicleRaycaster

(JNIEnv env, jobject object, jlong bodyId, jlong spaceId) {

//btRigidBody
body = (btRigidBody
) bodyId;

  •    btDiscreteDynamicsWorld* spsace = (btDiscreteDynamicsWorld*) spaceId;<br />
    
  •    if (spsace == NULL) {<br />
    
  •    jmePhysicsSpace *space = (jmePhysicsSpace *)spaceId;<br />
    
  •    if (space == NULL) {<br />
    

jclass newExc = env->FindClass("java/lang/NullPointerException");

env->ThrowNew(newExc, "The native object does not exist.");

return 0;

}

  •    btDefaultVehicleRaycaster* caster = new btDefaultVehicleRaycaster(spsace);<br />
    
  •    btDefaultVehicleRaycaster* caster = new btDefaultVehicleRaycaster(space-&gt;getDynamicsWorld());<br />
    

return (long) caster;

}



diff -r 7a78f7ca8432 -r 19650db1402b engine/src/bullet/native/com_jme3_bullet_util_DebugShapeFactory.cpp

— a/engine/src/bullet/native/com_jme3_bullet_util_DebugShapeFactory.cpp Mon Oct 10 16:11:17 2011 +0900

+++ b/engine/src/bullet/native/com_jme3_bullet_util_DebugShapeFactory.cpp Sat Oct 15 08:11:40 2011 +0900

@@ -105,7 +105,7 @@

// Check there is a hull shape to render

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

// create a hull approximation

  •            btShapeHull* hull = &amp;btShapeHull(convexShape);<br />
    
  •            btShapeHull* hull = new btShapeHull(convexShape);<br />
    

float margin = convexShape->getMargin();

hull->buildHull(margin);

convexShape->setUserPointer(hull);

@@ -146,7 +146,7 @@

return;

}

}

-

  •        delete hull;<br />
    

convexShape->setUserPointer(NULL);

}

}

diff -r 7a78f7ca8432 -r 19650db1402b engine/src/bullet/native/com_jme3_bullet_util_DebugShapeFactory.h

— a/engine/src/bullet/native/com_jme3_bullet_util_DebugShapeFactory.h Mon Oct 10 16:11:17 2011 +0900

+++ b/engine/src/bullet/native/com_jme3_bullet_util_DebugShapeFactory.h Sat Oct 15 08:11:40 2011 +0900

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

#ifdef __cplusplus

extern "C" {

#endif

-/* Inaccessible static: _00024assertionsDisabled /

/

  • Class: com_jme3_bullet_util_DebugShapeFactory
  • Method: getVertices

    diff -r 7a78f7ca8432 -r 19650db1402b engine/src/bullet/native/jmeBulletUtil.h

    — a/engine/src/bullet/native/jmeBulletUtil.h Mon Oct 10 16:11:17 2011 +0900

    +++ b/engine/src/bullet/native/jmeBulletUtil.h Sat Oct 15 08:11:40 2011 +0900

    @@ -49,4 +49,4 @@

    jmeBulletUtil(){};

    ~jmeBulletUtil(){};



    -};

    No newline at end of file

    +};

    diff -r 7a78f7ca8432 -r 19650db1402b engine/src/bullet/native/jmeClasses.cpp

    — a/engine/src/bullet/native/jmeClasses.cpp Mon Oct 10 16:11:17 2011 +0900

    +++ b/engine/src/bullet/native/jmeClasses.cpp Sat Oct 15 08:11:40 2011 +0900

    @@ -38,6 +38,10 @@

    jclass jmeClasses::PhysicsSpace;

    jmethodID jmeClasses::PhysicsSpace_preTick;

    jmethodID jmeClasses::PhysicsSpace_postTick;

    +jmethodID jmeClasses::PhysicsSpace_addCollisionEvent;

    +

    +jclass jmeClasses::PhysicsGhostObject;

    +jmethodID jmeClasses::PhysicsGhostObject_addOverlappingObject;



    jclass jmeClasses::Vector3f;

    jmethodID jmeClasses::Vector3f_set;

    @@ -106,6 +110,18 @@



    PhysicsSpace_preTick = env->GetMethodID(PhysicsSpace, "preTick_native", "(F)V");

    PhysicsSpace_postTick = env->GetMethodID(PhysicsSpace, "postTick_native", "(F)V");
  • PhysicsSpace_addCollisionEvent = env->GetMethodID(PhysicsSpace, "addCollisionEvent","(Lcom/jme3/bullet/collision/PhysicsCollisionObject;Lcom/jme3/bullet/collision/PhysicsCollisionObject;J)V");
  • if (env->ExceptionCheck()) {
  •    env-&gt;Throw(env-&gt;ExceptionOccurred());<br />
    
  •    return;<br />
    
  • }

    +
  • PhysicsGhostObject = env->FindClass("com/jme3/bullet/objects/PhysicsGhostObject");
  • if (env->ExceptionCheck()) {
  •    env-&gt;Throw(env-&gt;ExceptionOccurred());<br />
    
  •    return;<br />
    
  • }
  • PhysicsGhostObject_addOverlappingObject = env->GetMethodID(PhysicsGhostObject, "addOverlappingObject","(Lcom/jme3/bullet/collision/PhysicsCollisionObject;)V");

    if (env->ExceptionCheck()) {

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

    return;

    diff -r 7a78f7ca8432 -r 19650db1402b engine/src/bullet/native/jmeClasses.h

    — a/engine/src/bullet/native/jmeClasses.h Mon Oct 10 16:11:17 2011 +0900

    +++ b/engine/src/bullet/native/jmeClasses.h Sat Oct 15 08:11:40 2011 +0900

    @@ -43,6 +43,9 @@

    static jclass PhysicsSpace;

    static jmethodID PhysicsSpace_preTick;

    static jmethodID PhysicsSpace_postTick;
  • static jmethodID PhysicsSpace_addCollisionEvent;
  • static jclass PhysicsGhostObject;
  • static jmethodID PhysicsGhostObject_addOverlappingObject;



    static jclass Vector3f;

    static jmethodID Vector3f_set;

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

    private:

    jmeClasses(){};

    ~jmeClasses(){};

    -};

    No newline at end of file

    +};

    diff -r 7a78f7ca8432 -r 19650db1402b engine/src/bullet/native/jmeMotionState.cpp

    — a/engine/src/bullet/native/jmeMotionState.cpp Mon Oct 10 16:11:17 2011 +0900

    +++ b/engine/src/bullet/native/jmeMotionState.cpp Sat Oct 15 08:11:40 2011 +0900

    @@ -38,6 +38,7 @@



    jmeMotionState::jmeMotionState() {

    trans = new btTransform();
  • trans -> setIdentity();

    worldTransform = *trans;

    dirty = true;

    }

    diff -r 7a78f7ca8432 -r 19650db1402b engine/src/bullet/native/jmePhysicsSpace.cpp

    — a/engine/src/bullet/native/jmePhysicsSpace.cpp Mon Oct 10 16:11:17 2011 +0900

    +++ b/engine/src/bullet/native/jmePhysicsSpace.cpp Sat Oct 15 08:11:40 2011 +0900

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

    */

    #include "jmePhysicsSpace.h"

    #include "jmeBulletUtil.h"

    -

    +#include "jmeUserPointer.h"

    +#include <stdio.h>

    /**
  • Author: Normen Hansen

    /

    @@ -170,16 +171,33 @@

    // return true when pairs need collision



    virtual bool needBroadphaseCollision(btBroadphaseProxy
    proxy0, btBroadphaseProxy * proxy1) const {

    +// bool collides = (proxy0->m_collisionFilterGroup & proxy1->m_collisionFilterMask) != 0;

    +// collides = collides && (proxy1->m_collisionFilterGroup & proxy0->m_collisionFilterMask);

    bool collides = (proxy0->m_collisionFilterGroup & proxy1->m_collisionFilterMask) != 0;

    collides = collides && (proxy1->m_collisionFilterGroup & proxy0->m_collisionFilterMask);
  •        if (collides) {<br />
    
  •            btCollisionObject* co0 = (btCollisionObject*)proxy0-&gt;m_clientObject;<br />
    
  •            btCollisionObject* co1 = (btCollisionObject*)proxy1-&gt;m_clientObject;<br />
    
  •            jmeUserPointer *up0 = (jmeUserPointer*)co0 -&gt; getUserPointer();<br />
    
  •            jmeUserPointer *up1 = (jmeUserPointer*)co1 -&gt; getUserPointer();<br />
    
  •            if (up0 != NULL &amp;&amp; up1 != NULL) {<br />
    
  •                collides = (up0-&gt;group &amp; up1-&gt;groups) != 0;<br />
    
  •                collides = collides &amp;&amp; (up1-&gt;group &amp; up0-&gt;groups);<br />
    

- //add some additional logic here that modified 'collides'
+ //add some additional logic here that modified 'collides'
+ return collides;
+ }
+ return false;
+ }
return collides;
}
};
dynamicsWorld->getPairCache()->setOverlapFilterCallback(new jmeFilterCallback());
dynamicsWorld->setInternalTickCallback(&jmePhysicsSpace::preTickCallback, static_cast<void *> (this), true);
dynamicsWorld->setInternalTickCallback(&jmePhysicsSpace::postTickCallback, static_cast<void *> (this));
+ if (gContactProcessedCallback == NULL) {
+ gContactProcessedCallback = &jmePhysicsSpace::contactProcessedCallback;
+ }
}

void jmePhysicsSpace::preTickCallback(btDynamicsWorld *world, btScalar timeStep) {
@@ -201,7 +219,25 @@
return;
}
}
-
+bool jmePhysicsSpace::contactProcessedCallback(btManifoldPoint &cp, void *body0, void *body1) {
+// printf("contactProcessedCallback %d %dn", body0, body1);
+ btCollisionObject* co0 = (btCollisionObject*)body0;
+ jmeUserPointer *up0 = (jmeUserPointer*)co0 -> getUserPointer();
+ btCollisionObject* co1 = (btCollisionObject*)body1;
+ jmeUserPointer *up1 = (jmeUserPointer*)co1 -> getUserPointer();
+ if (up0 != NULL) {
+ jmePhysicsSpace *dynamicsWorld = up0->space;
+ if (dynamicsWorld != NULL) {
+ JNIEnv* env = dynamicsWorld->getEnv();
+ env->CallVoidMethod(dynamicsWorld->getJavaPhysicsSpace(), jmeClasses::PhysicsSpace_addCollisionEvent, up0->javaCollisionObject, up1->javaCollisionObject, (jlong)&cp);
+ if (env->ExceptionCheck()) {
+ env->Throw(env->ExceptionOccurred());
+ return true;
+ }
+ }
+ }
+ return true;
+}
btDynamicsWorld* jmePhysicsSpace::getDynamicsWorld() {
return dynamicsWorld;
}
diff -r 7a78f7ca8432 -r 19650db1402b engine/src/bullet/native/jmePhysicsSpace.h
--- a/engine/src/bullet/native/jmePhysicsSpace.h Mon Oct 10 16:11:17 2011 +0900
+++ b/engine/src/bullet/native/jmePhysicsSpace.h Sat Oct 15 08:11:40 2011 +0900
@@ -46,6 +46,8 @@
#include "BulletMultiThreaded/SpuCollisionTaskProcess.h"
#include "BulletMultiThreaded/SequentialThreadSupport.h"
#include "BulletCollision/CollisionDispatch/btSimulationIslandManager.h"
+#include "BulletCollision/NarrowPhaseCollision/btManifoldPoint.h"
+#include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h"

/**
* Author: Normen Hansen
@@ -70,4 +72,5 @@
JNIEnv* getEnv();
static void preTickCallback(btDynamicsWorld*, btScalar);
static void postTickCallback(btDynamicsWorld*, btScalar);
-};
No newline at end of file
+ static bool contactProcessedCallback(btManifoldPoint &, void *, void *);
+};
[/patch]
1 Like

Thanks very much! Theres a few bugs in those patches still so it gonna take a bit of time and yeah, I won’t add the SixDofSpringJoint yet.

Your “jmeuserpointer.h” class is missing, but I am not sure if its needed, you reference objects with it, you can do that with a normal long…

Sorry, I forgot to commit it.

jmeUserPointer.h

[java]

#ifndef _Included_jmeUserPointer

#define _Included_jmeUserPointer

#include <jni.h>

class jmeUserPointer {

public:

jobject javaCollisionObject;

jint group;

jint groups;

jmePhysicsSpace *space;

};

#endif

[/java]

1 Like

Sorry, I forgot to commit these files too:

PhysicsCollisionEvent.cpp

PhysicsCollisionEvent.h



Please get from mercurial repository.

1 Like
chototsu said:
Please get from mercurial repository.

Funny guy, its all in japanese oO

My mercurial repository is here.

mikumikustudio/MikuMikuStudio: log

You can get without Japanese.



command:

hg clone mikumikustudio/MikuMikuStudio: log

1 Like

Right, well I got it.

I added this to svn, gotta check the compile on windows etc. still. Then we could use some people compiling e.g. android and windows64 binaries (still… :/) Best if people not create some esoteric homebrew compile setup but really try and integrate it in the ant build script, even if its harder at first it makes it much easier compiling the binaries later when fixes and changes are made…

Edit: This doesn’t go to you btw, you even added and fixed the solaris part, good job :slight_smile:

Edit2: As a thank you, I even added the sixdofspringjoint, but only if you promise you won’t recommend that to people on the forum before native bullet is officially made the physics implementation of choice, ok? :wink:

2 Likes

Thanks.

As a thank you , I even added the sixdofspringjoint , but only if you promise you will not recommend that to people on the forum before native bullet is officially made the physics implementation of choice , ok ?



OK.

I don’t talk about that in the forum.

1 Like

@phate666 I fixed that.



Thanks.



[patch]

diff -r 72176547181a -r a5ac8981f5a9 engine/src/bullet/native/com_jme3_bullet_joints_SixDofSpringJoint.cpp

— a/engine/src/bullet/native/com_jme3_bullet_joints_SixDofSpringJoint.cpp Sat Oct 15 22:30:22 2011 +0900

+++ b/engine/src/bullet/native/com_jme3_bullet_joints_SixDofSpringJoint.cpp Sun Oct 16 00:59:33 2011 +0900

@@ -78,8 +78,8 @@

jmeClasses::initJavaClasses(env);

btRigidBody* bodyA = (btRigidBody*) bodyIdA;

btRigidBody* bodyB = (btRigidBody*) bodyIdB;

  •    btMatrix3x3* mtx1 = &amp;btMatrix3x3();<br />
    
  •    btMatrix3x3* mtx2 = &amp;btMatrix3x3();<br />
    

+// btMatrix3x3 mtx1 = btMatrix3x3();

+// btMatrix3x3 mtx2 = btMatrix3x3();

/* btTransform* transA = &btTransform(*mtx1);

jmeBulletUtil::convert(env, pivotA, &transA->getOrigin());

jmeBulletUtil::convert(env, rotA, &transA->getBasis());

diff -r 72176547181a -r a5ac8981f5a9 engine/src/bullet/native/com_jme3_bullet_objects_PhysicsVehicle.cpp

— a/engine/src/bullet/native/com_jme3_bullet_objects_PhysicsVehicle.cpp Sat Oct 15 22:30:22 2011 +0900

+++ b/engine/src/bullet/native/com_jme3_bullet_objects_PhysicsVehicle.cpp Sun Oct 16 00:59:33 2011 +0900

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

env->ThrowNew(newExc, "The native object does not exist.");

return;

}

  •    jmeBulletUtil::convert(env, &amp;vehicle-&gt;getForwardVector(), out);<br />
    
  •    btVector3 forwardVector = vehicle-&gt;getForwardVector();<br />
    
  •    jmeBulletUtil::convert(env, &amp;forwardVector, out);<br />
    

}



/*

[/patch]

1 Like

Added the binaries for Windows (32bit) and MacOSX (32+64bit Intel) to svn, the nightly build server will add the binaries for Linux (64bit) in some hours. Also updated the bullet version to bullet-2.79.

2 Likes

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

Thanks to you all for making native bullit for jME3 better and better. :slight_smile: