Convert to using jBulletFork

This commit is contained in:
austin 2021-07-24 15:22:13 -04:00
parent afe51eb966
commit b5a0987ea1
10 changed files with 69 additions and 69 deletions

View File

@ -123,9 +123,9 @@
source: https://github.com/jbullet-maven/jbullet/tree/master/src/main/java/com/bulletphysics source: https://github.com/jbullet-maven/jbullet/tree/master/src/main/java/com/bulletphysics
--> -->
<dependency> <dependency>
<groupId>cz.advel.jbullet</groupId> <groupId>electrosphere</groupId>
<artifactId>jbullet</artifactId> <artifactId>jBulletFork</artifactId>
<version>20101010-1</version> <version>0.1</version>
</dependency> </dependency>
<!-- <!--

View File

@ -1,6 +1,6 @@
package electrosphere.engine; package electrosphere.engine;
import com.bulletphysics.collision.dispatch.CollisionObject; import electrosphere.collision.dispatch.CollisionObject;
import electrosphere.controls.ControlHandler; import electrosphere.controls.ControlHandler;
import electrosphere.entity.CameraEntityUtils; import electrosphere.entity.CameraEntityUtils;
import electrosphere.entity.Entity; import electrosphere.entity.Entity;

View File

@ -1,6 +1,6 @@
package electrosphere.entity.state; package electrosphere.entity.state;
import com.bulletphysics.collision.dispatch.CollisionObject; import electrosphere.collision.dispatch.CollisionObject;
import electrosphere.entity.Entity; import electrosphere.entity.Entity;
import electrosphere.entity.EntityUtils; import electrosphere.entity.EntityUtils;
import electrosphere.entity.state.movement.Impulse; import electrosphere.entity.state.movement.Impulse;
@ -121,7 +121,7 @@ public class GravityTree {
} }
// System.out.println(hitFraction); // System.out.println(hitFraction);
bodyTransformMatrix = new javax.vecmath.Matrix4f(PhysicsUtils.jomlToVecmathQuaternionf(rotation),PhysicsUtils.jomlToVecmathVector3f(position),1.0f); bodyTransformMatrix = new javax.vecmath.Matrix4f(PhysicsUtils.jomlToVecmathQuaternionf(rotation),PhysicsUtils.jomlToVecmathVector3f(position),1.0f);
body.setWorldTransform(new com.bulletphysics.linearmath.Transform(bodyTransformMatrix)); body.setWorldTransform(new electrosphere.linearmath.Transform(bodyTransformMatrix));
} }
break; break;
case NOT_ACTIVE: case NOT_ACTIVE:

View File

@ -1,7 +1,7 @@
package electrosphere.entity.state.movement; package electrosphere.entity.state.movement;
import com.bulletphysics.collision.dispatch.CollisionObject; import electrosphere.collision.dispatch.CollisionObject;
import com.bulletphysics.dynamics.RigidBody; import electrosphere.dynamics.RigidBody;
import electrosphere.entity.types.creature.CreatureUtils; import electrosphere.entity.types.creature.CreatureUtils;
import electrosphere.entity.Entity; import electrosphere.entity.Entity;
import electrosphere.entity.EntityDataStrings; import electrosphere.entity.EntityDataStrings;
@ -151,7 +151,7 @@ public class MovementTree {
position.add(impulseForce); position.add(impulseForce);
} }
bodyTransformMatrix = new javax.vecmath.Matrix4f(PhysicsUtils.jomlToVecmathQuaternionf(rotation),PhysicsUtils.jomlToVecmathVector3f(position),1.0f); bodyTransformMatrix = new javax.vecmath.Matrix4f(PhysicsUtils.jomlToVecmathQuaternionf(rotation),PhysicsUtils.jomlToVecmathVector3f(position),1.0f);
body.setWorldTransform(new com.bulletphysics.linearmath.Transform(bodyTransformMatrix)); body.setWorldTransform(new electrosphere.linearmath.Transform(bodyTransformMatrix));
//state machine //state machine
switch(state){ switch(state){
@ -183,7 +183,7 @@ public class MovementTree {
rotation.rotationTo(new Vector3f(0,0,1), movementVector); rotation.rotationTo(new Vector3f(0,0,1), movementVector);
bodyTransformMatrix = new javax.vecmath.Matrix4f(PhysicsUtils.jomlToVecmathQuaternionf(rotation),PhysicsUtils.jomlToVecmathVector3f(newPosition),1.0f); bodyTransformMatrix = new javax.vecmath.Matrix4f(PhysicsUtils.jomlToVecmathQuaternionf(rotation),PhysicsUtils.jomlToVecmathVector3f(newPosition),1.0f);
body.setWorldTransform(new com.bulletphysics.linearmath.Transform(bodyTransformMatrix)); body.setWorldTransform(new electrosphere.linearmath.Transform(bodyTransformMatrix));
activateGravityTree(); activateGravityTree();
@ -241,7 +241,7 @@ public class MovementTree {
rotation.rotationTo(new Vector3f(0,0,1), movementVector); rotation.rotationTo(new Vector3f(0,0,1), movementVector);
bodyTransformMatrix = new javax.vecmath.Matrix4f(PhysicsUtils.jomlToVecmathQuaternionf(rotation),PhysicsUtils.jomlToVecmathVector3f(newPosition),1.0f); bodyTransformMatrix = new javax.vecmath.Matrix4f(PhysicsUtils.jomlToVecmathQuaternionf(rotation),PhysicsUtils.jomlToVecmathVector3f(newPosition),1.0f);
body.setWorldTransform(new com.bulletphysics.linearmath.Transform(bodyTransformMatrix)); body.setWorldTransform(new electrosphere.linearmath.Transform(bodyTransformMatrix));
activateGravityTree(); activateGravityTree();
@ -303,7 +303,7 @@ public class MovementTree {
rotation.rotationTo(new Vector3f(0,0,1), movementVector); rotation.rotationTo(new Vector3f(0,0,1), movementVector);
bodyTransformMatrix = new javax.vecmath.Matrix4f(PhysicsUtils.jomlToVecmathQuaternionf(rotation),PhysicsUtils.jomlToVecmathVector3f(newPosition),1.0f); bodyTransformMatrix = new javax.vecmath.Matrix4f(PhysicsUtils.jomlToVecmathQuaternionf(rotation),PhysicsUtils.jomlToVecmathVector3f(newPosition),1.0f);
body.setWorldTransform(new com.bulletphysics.linearmath.Transform(bodyTransformMatrix)); body.setWorldTransform(new electrosphere.linearmath.Transform(bodyTransformMatrix));
activateGravityTree(); activateGravityTree();

View File

@ -1,7 +1,7 @@
package electrosphere.entity.types.collision; package electrosphere.entity.types.collision;
import com.bulletphysics.collision.dispatch.CollisionObject; import electrosphere.collision.dispatch.CollisionObject;
import com.bulletphysics.collision.shapes.CylinderShape; import electrosphere.collision.shapes.CylinderShape;
import electrosphere.entity.Entity; import electrosphere.entity.Entity;
import electrosphere.entity.EntityDataStrings; import electrosphere.entity.EntityDataStrings;
import electrosphere.game.collision.PhysicsUtils; import electrosphere.game.collision.PhysicsUtils;
@ -24,7 +24,7 @@ public class CollisionObjUtils {
PhysicsUtils.jomlToVecmathQuaternionf(rotation), PhysicsUtils.jomlToVecmathQuaternionf(rotation),
PhysicsUtils.jomlToVecmathVector3f(position), PhysicsUtils.jomlToVecmathVector3f(position),
1.0f); 1.0f);
planeObject.setWorldTransform(new com.bulletphysics.linearmath.Transform(planeTransform)); planeObject.setWorldTransform(new electrosphere.linearmath.Transform(planeTransform));
Collidable collidable = new Collidable(rVal, Collidable.TYPE_STRUCTURE); Collidable collidable = new Collidable(rVal, Collidable.TYPE_STRUCTURE);
Globals.collisionEngine.registerCollisionObject(planeObject, collidable); Globals.collisionEngine.registerCollisionObject(planeObject, collidable);
Globals.collisionEngine.registerStructurePhysicsEntity(rVal); Globals.collisionEngine.registerStructurePhysicsEntity(rVal);
@ -49,7 +49,7 @@ public class CollisionObjUtils {
PhysicsUtils.jomlToVecmathQuaternionf(rotation), PhysicsUtils.jomlToVecmathQuaternionf(rotation),
PhysicsUtils.jomlToVecmathVector3f(position), PhysicsUtils.jomlToVecmathVector3f(position),
1.0f); 1.0f);
cubeObject.setWorldTransform(new com.bulletphysics.linearmath.Transform(planeTransform)); cubeObject.setWorldTransform(new electrosphere.linearmath.Transform(planeTransform));
Collidable collidable = new Collidable(rVal, Collidable.TYPE_STRUCTURE); Collidable collidable = new Collidable(rVal, Collidable.TYPE_STRUCTURE);
Globals.collisionEngine.registerCollisionObject(cubeObject, collidable); Globals.collisionEngine.registerCollisionObject(cubeObject, collidable);
Globals.collisionEngine.registerStructurePhysicsEntity(rVal); Globals.collisionEngine.registerStructurePhysicsEntity(rVal);

View File

@ -1,7 +1,7 @@
package electrosphere.entity.types.creature; package electrosphere.entity.types.creature;
import com.bulletphysics.collision.dispatch.CollisionObject; import electrosphere.collision.dispatch.CollisionObject;
import com.bulletphysics.dynamics.RigidBody; import electrosphere.dynamics.RigidBody;
import electrosphere.entity.Entity; import electrosphere.entity.Entity;
import electrosphere.entity.EntityDataStrings; import electrosphere.entity.EntityDataStrings;
import electrosphere.entity.EntityUtils; import electrosphere.entity.EntityUtils;

View File

@ -1,7 +1,7 @@
package electrosphere.game.client.drawcell; package electrosphere.game.client.drawcell;
import com.bulletphysics.collision.dispatch.CollisionObject; import electrosphere.collision.dispatch.CollisionObject;
import com.bulletphysics.dynamics.RigidBody; import electrosphere.dynamics.RigidBody;
import electrosphere.entity.Entity; import electrosphere.entity.Entity;
import electrosphere.entity.EntityUtils; import electrosphere.entity.EntityUtils;
import electrosphere.game.collision.PhysicsUtils; import electrosphere.game.collision.PhysicsUtils;

View File

@ -1,31 +1,31 @@
package electrosphere.game.collision; package electrosphere.game.collision;
import com.bulletphysics.collision.broadphase.BroadphaseInterface; import electrosphere.collision.broadphase.BroadphaseInterface;
import com.bulletphysics.collision.broadphase.BroadphasePair; import electrosphere.collision.broadphase.BroadphasePair;
import com.bulletphysics.collision.broadphase.BroadphaseProxy; import electrosphere.collision.broadphase.BroadphaseProxy;
import com.bulletphysics.collision.broadphase.DbvtBroadphase; import electrosphere.collision.broadphase.DbvtBroadphase;
import com.bulletphysics.collision.broadphase.Dispatcher; import electrosphere.collision.broadphase.Dispatcher;
import com.bulletphysics.collision.broadphase.OverlappingPairCache; import electrosphere.collision.broadphase.OverlappingPairCache;
import com.bulletphysics.collision.dispatch.CollisionDispatcher; import electrosphere.collision.dispatch.CollisionDispatcher;
import com.bulletphysics.collision.dispatch.CollisionObject; import electrosphere.collision.dispatch.CollisionObject;
import com.bulletphysics.collision.dispatch.CollisionWorld.ClosestConvexResultCallback; import electrosphere.collision.dispatch.CollisionWorld.ClosestConvexResultCallback;
import com.bulletphysics.collision.dispatch.CollisionWorld.ConvexResultCallback; import electrosphere.collision.dispatch.CollisionWorld.ConvexResultCallback;
import com.bulletphysics.collision.dispatch.CollisionWorld.LocalConvexResult; import electrosphere.collision.dispatch.CollisionWorld.LocalConvexResult;
import com.bulletphysics.collision.dispatch.DefaultCollisionConfiguration; import electrosphere.collision.dispatch.DefaultCollisionConfiguration;
import com.bulletphysics.collision.narrowphase.ManifoldPoint; import electrosphere.collision.narrowphase.ManifoldPoint;
import com.bulletphysics.collision.narrowphase.PersistentManifold; import electrosphere.collision.narrowphase.PersistentManifold;
import com.bulletphysics.collision.shapes.BoxShape; import electrosphere.collision.shapes.BoxShape;
import com.bulletphysics.collision.shapes.CollisionShape; import electrosphere.collision.shapes.CollisionShape;
import com.bulletphysics.collision.shapes.SphereShape; import electrosphere.collision.shapes.SphereShape;
import com.bulletphysics.dynamics.DiscreteDynamicsWorld; import electrosphere.dynamics.DiscreteDynamicsWorld;
import com.bulletphysics.dynamics.DynamicsWorld; import electrosphere.dynamics.DynamicsWorld;
import com.bulletphysics.dynamics.InternalTickCallback; import electrosphere.dynamics.InternalTickCallback;
import com.bulletphysics.dynamics.RigidBody; import electrosphere.dynamics.RigidBody;
import com.bulletphysics.dynamics.RigidBodyConstructionInfo; import electrosphere.dynamics.RigidBodyConstructionInfo;
import com.bulletphysics.dynamics.constraintsolver.SequentialImpulseConstraintSolver; import electrosphere.dynamics.constraintsolver.SequentialImpulseConstraintSolver;
import com.bulletphysics.linearmath.DefaultMotionState; import electrosphere.linearmath.DefaultMotionState;
import com.bulletphysics.linearmath.Transform; import electrosphere.linearmath.Transform;
import com.bulletphysics.util.ObjectArrayList; import electrosphere.util.ObjectArrayList;
import electrosphere.entity.Entity; import electrosphere.entity.Entity;
import electrosphere.entity.EntityDataStrings; import electrosphere.entity.EntityDataStrings;
import electrosphere.entity.EntityUtils; import electrosphere.entity.EntityUtils;

View File

@ -1,15 +1,15 @@
package electrosphere.game.collision; package electrosphere.game.collision;
import com.bulletphysics.collision.dispatch.CollisionObject; import electrosphere.collision.dispatch.CollisionObject;
import com.bulletphysics.collision.shapes.BoxShape; import electrosphere.collision.shapes.BoxShape;
import com.bulletphysics.collision.shapes.BvhTriangleMeshShape; import electrosphere.collision.shapes.BvhTriangleMeshShape;
import com.bulletphysics.collision.shapes.CylinderShape; import electrosphere.collision.shapes.CylinderShape;
import com.bulletphysics.collision.shapes.IndexedMesh; import electrosphere.collision.shapes.IndexedMesh;
import com.bulletphysics.collision.shapes.TriangleIndexVertexArray; import electrosphere.collision.shapes.TriangleIndexVertexArray;
import com.bulletphysics.dynamics.RigidBody; import electrosphere.dynamics.RigidBody;
import com.bulletphysics.dynamics.RigidBodyConstructionInfo; import electrosphere.dynamics.RigidBodyConstructionInfo;
import com.bulletphysics.linearmath.DefaultMotionState; import electrosphere.linearmath.DefaultMotionState;
import com.bulletphysics.linearmath.Transform; import electrosphere.linearmath.Transform;
import electrosphere.entity.Entity; import electrosphere.entity.Entity;
import electrosphere.entity.EntityDataStrings; import electrosphere.entity.EntityDataStrings;
import electrosphere.entity.EntityUtils; import electrosphere.entity.EntityUtils;
@ -37,7 +37,7 @@ public class PhysicsUtils {
* @param halfDimensions * @param halfDimensions
*/ */
public static void attachCylinderRigidBody(Entity entity, Vector3f halfDimensions){ public static void attachCylinderRigidBody(Entity entity, Vector3f halfDimensions){
new com.bulletphysics.collision.shapes.CylinderShape(new javax.vecmath.Vector3f(halfDimensions.x,halfDimensions.y,halfDimensions.z)); new electrosphere.collision.shapes.CylinderShape(new javax.vecmath.Vector3f(halfDimensions.x,halfDimensions.y,halfDimensions.z));
} }
@ -110,7 +110,7 @@ public class PhysicsUtils {
//http://jbullet.advel.cz/javadoc/com/bulletphysics/collision/shapes/IndexedMesh.html //http://jbullet.advel.cz/javadoc/com/bulletphysics/collision/shapes/IndexedMesh.html
com.bulletphysics.collision.shapes.IndexedMesh indexedMesh = new com.bulletphysics.collision.shapes.IndexedMesh(); electrosphere.collision.shapes.IndexedMesh indexedMesh = new electrosphere.collision.shapes.IndexedMesh();
indexedMesh.numTriangles = indices.length / 3; indexedMesh.numTriangles = indices.length / 3;
indexedMesh.triangleIndexBase = ByteBuffer.allocateDirect(indices.length*Float.BYTES).order(ByteOrder.nativeOrder()); indexedMesh.triangleIndexBase = ByteBuffer.allocateDirect(indices.length*Float.BYTES).order(ByteOrder.nativeOrder());
@ -128,14 +128,14 @@ public class PhysicsUtils {
//http://jbullet.advel.cz/javadoc/com/bulletphysics/collision/shpaes/TriangleIndexVertexArray.html //http://jbullet.advel.cz/javadoc/com/bulletphysics/collision/shpaes/TriangleIndexVertexArray.html
com.bulletphysics.collision.shapes.TriangleIndexVertexArray triangleIndexArray = new com.bulletphysics.collision.shapes.TriangleIndexVertexArray(); electrosphere.collision.shapes.TriangleIndexVertexArray triangleIndexArray = new electrosphere.collision.shapes.TriangleIndexVertexArray();
triangleIndexArray.addIndexedMesh(indexedMesh); //this assumes the scalar type is integer (assumes bytebuffer is actually integer triangleIndexArray.addIndexedMesh(indexedMesh); //this assumes the scalar type is integer (assumes bytebuffer is actually integer
// triangleIndexArray.calculateAabbBruteForce(aabbMin, aabbMax); // triangleIndexArray.calculateAabbBruteForce(aabbMin, aabbMax);
//http://jbullet.advel.cz/javadoc/com/bulletphysics/collision/shapes/BvhTriangleMeshShape.html //http://jbullet.advel.cz/javadoc/com/bulletphysics/collision/shapes/BvhTriangleMeshShape.html
com.bulletphysics.collision.shapes.BvhTriangleMeshShape terrainShape = new com.bulletphysics.collision.shapes.BvhTriangleMeshShape( electrosphere.collision.shapes.BvhTriangleMeshShape terrainShape = new electrosphere.collision.shapes.BvhTriangleMeshShape(
triangleIndexArray, triangleIndexArray,
true // "useQuantizedAabbCompression" -- apparently means better memory usage ( http://jbullet.advel.cz/javadoc/com/bulletphysics/collision/shapes/BvhTriangleMeshShape.html ) true // "useQuantizedAabbCompression" -- apparently means better memory usage ( http://jbullet.advel.cz/javadoc/com/bulletphysics/collision/shapes/BvhTriangleMeshShape.html )
); );
@ -207,7 +207,7 @@ public class PhysicsUtils {
//http://jbullet.advel.cz/javadoc/com/bulletphysics/collision/shpaes/TriangleIndexVertexArray.html //http://jbullet.advel.cz/javadoc/com/bulletphysics/collision/shpaes/TriangleIndexVertexArray.html
com.bulletphysics.collision.shapes.TriangleIndexVertexArray triangleIndexArray = new com.bulletphysics.collision.shapes.TriangleIndexVertexArray( electrosphere.collision.shapes.TriangleIndexVertexArray triangleIndexArray = new electrosphere.collision.shapes.TriangleIndexVertexArray(
// numberTriangles, // numberTriangles,
// triangleData, // triangleData,
// triangleStride, // triangleStride,
@ -221,7 +221,7 @@ public class PhysicsUtils {
//http://jbullet.advel.cz/javadoc/com/bulletphysics/collision/shapes/BvhTriangleMeshShape.html //http://jbullet.advel.cz/javadoc/com/bulletphysics/collision/shapes/BvhTriangleMeshShape.html
com.bulletphysics.collision.shapes.BvhTriangleMeshShape terrainShape = new com.bulletphysics.collision.shapes.BvhTriangleMeshShape( electrosphere.collision.shapes.BvhTriangleMeshShape terrainShape = new electrosphere.collision.shapes.BvhTriangleMeshShape(
triangleIndexArray, triangleIndexArray,
true // "useQuantizedAabbCompression" -- apparently means better memory usage ( http://jbullet.advel.cz/javadoc/com/bulletphysics/collision/shapes/BvhTriangleMeshShape.html ) true // "useQuantizedAabbCompression" -- apparently means better memory usage ( http://jbullet.advel.cz/javadoc/com/bulletphysics/collision/shapes/BvhTriangleMeshShape.html )
); );
@ -241,13 +241,13 @@ public class PhysicsUtils {
public static Vector3f getRigidBodyPosition(CollisionObject body){ public static Vector3f getRigidBodyPosition(CollisionObject body){
javax.vecmath.Vector3f transform = new javax.vecmath.Vector3f(0,0,0); javax.vecmath.Vector3f transform = new javax.vecmath.Vector3f(0,0,0);
body.getWorldTransform(new com.bulletphysics.linearmath.Transform()).transform(transform); body.getWorldTransform(new electrosphere.linearmath.Transform()).transform(transform);
// body.getMotionState().getWorldTransform(new com.bulletphysics.linearmath.Transform()).transform(transform); // body.getMotionState().getWorldTransform(new com.bulletphysics.linearmath.Transform()).transform(transform);
return vecmathToJomlVector3f(transform); return vecmathToJomlVector3f(transform);
} }
public static Quaternionf getRigidBodyRotation(RigidBody body){ public static Quaternionf getRigidBodyRotation(RigidBody body){
return vecmathtoJomlQuaternionf(body.getMotionState().getWorldTransform(new com.bulletphysics.linearmath.Transform()).getRotation(new javax.vecmath.Quat4f())); return vecmathtoJomlQuaternionf(body.getMotionState().getWorldTransform(new electrosphere.linearmath.Transform()).getRotation(new javax.vecmath.Quat4f()));
} }
public static Vector3f vecmathToJomlVector3f(javax.vecmath.Vector3f vector){ public static Vector3f vecmathToJomlVector3f(javax.vecmath.Vector3f vector){
@ -266,8 +266,8 @@ public class PhysicsUtils {
return new javax.vecmath.Quat4f(quaternion.x, quaternion.y, quaternion.z, quaternion.w); return new javax.vecmath.Quat4f(quaternion.x, quaternion.y, quaternion.z, quaternion.w);
} }
public static com.bulletphysics.linearmath.Transform jomlVecToTransform(Vector3f vector){ public static electrosphere.linearmath.Transform jomlVecToTransform(Vector3f vector){
com.bulletphysics.linearmath.Transform transform = new com.bulletphysics.linearmath.Transform(); electrosphere.linearmath.Transform transform = new electrosphere.linearmath.Transform();
javax.vecmath.Matrix4f transformMatrix = new javax.vecmath.Matrix4f(); javax.vecmath.Matrix4f transformMatrix = new javax.vecmath.Matrix4f();
transformMatrix.setIdentity(); transformMatrix.setIdentity();
@ -279,7 +279,7 @@ public class PhysicsUtils {
} }
public static void setRigidBodyTransform(Vector3f position, Quaternionf rotation, CollisionObject body){ public static void setRigidBodyTransform(Vector3f position, Quaternionf rotation, CollisionObject body){
com.bulletphysics.linearmath.Transform transform = new com.bulletphysics.linearmath.Transform(); electrosphere.linearmath.Transform transform = new electrosphere.linearmath.Transform();
javax.vecmath.Matrix4f transformMatrix = new javax.vecmath.Matrix4f(); javax.vecmath.Matrix4f transformMatrix = new javax.vecmath.Matrix4f();
transformMatrix.setIdentity(); transformMatrix.setIdentity();

View File

@ -1,7 +1,7 @@
package electrosphere.game.collision.collidable; package electrosphere.game.collision.collidable;
import com.bulletphysics.collision.shapes.CollisionShape; import electrosphere.collision.shapes.CollisionShape;
import com.bulletphysics.dynamics.RigidBody; import electrosphere.dynamics.RigidBody;
import electrosphere.entity.Entity; import electrosphere.entity.Entity;
import electrosphere.entity.state.movement.Impulse; import electrosphere.entity.state.movement.Impulse;
import java.util.LinkedList; import java.util.LinkedList;