resolve issue #916

accellbaker
Stephen Gold 6 years ago
parent b2be9ce3f2
commit 697b4a675e
  1. 17
      jme3-bullet/src/main/java/com/jme3/bullet/PhysicsSpace.java
  2. 44
      jme3-jbullet/src/main/java/com/jme3/bullet/PhysicsSpace.java

@ -45,6 +45,7 @@ import com.jme3.math.Transform;
import com.jme3.math.Vector3f;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import com.jme3.util.SafeArrayList;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collection;
@ -54,6 +55,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Comparator;
import java.util.Deque;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
@ -122,9 +124,22 @@ public class PhysicsSpace {
private Map<Long, PhysicsRigidBody> physicsBodies = new ConcurrentHashMap<Long, PhysicsRigidBody>();
private Map<Long, PhysicsJoint> physicsJoints = new ConcurrentHashMap<Long, PhysicsJoint>();
private Map<Long, PhysicsVehicle> physicsVehicles = new ConcurrentHashMap<Long, PhysicsVehicle>();
private ArrayList<PhysicsCollisionListener> collisionListeners = new ArrayList<PhysicsCollisionListener>();
/**
* list of registered collision listeners
*/
final private List<PhysicsCollisionListener> collisionListeners
= new SafeArrayList<>(PhysicsCollisionListener.class);
/**
* queue of collision events not yet distributed to listeners
*/
private ArrayDeque<PhysicsCollisionEvent> collisionEvents = new ArrayDeque<PhysicsCollisionEvent>();
/**
* map from collision groups to registered group listeners
*/
private Map<Integer, PhysicsCollisionGroupListener> collisionGroupListeners = new ConcurrentHashMap<Integer, PhysicsCollisionGroupListener>();
/**
* queue of registered tick listeners
*/
private ConcurrentLinkedQueue<PhysicsTickListener> tickListeners = new ConcurrentLinkedQueue<PhysicsTickListener>();
private PhysicsCollisionEventFactory eventFactory = new PhysicsCollisionEventFactory();
/**

@ -63,7 +63,6 @@ import com.bulletphysics.dynamics.constraintsolver.TypedConstraint;
import com.bulletphysics.dynamics.vehicle.RaycastVehicle;
import com.bulletphysics.extras.gimpact.GImpactCollisionAlgorithm;
import com.jme3.app.AppTask;
import com.jme3.asset.AssetManager;
import com.jme3.bullet.collision.PhysicsCollisionEvent;
import com.jme3.bullet.collision.PhysicsCollisionEventFactory;
import com.jme3.bullet.collision.PhysicsCollisionGroupListener;
@ -84,8 +83,8 @@ import com.jme3.math.Transform;
import com.jme3.math.Vector3f;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import com.jme3.util.SafeArrayList;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedList;
@ -104,9 +103,21 @@ import java.util.logging.Logger;
*/
public class PhysicsSpace {
/**
* message logger for this class
*/
private static final Logger logger = Logger.getLogger(PhysicsSpace.class.getName());
/**
* index of the X axis
*/
public static final int AXIS_X = 0;
/**
* index of the Y axis
*/
public static final int AXIS_Y = 1;
/**
* index of the Z axis
*/
public static final int AXIS_Z = 2;
private static ThreadLocal<ConcurrentLinkedQueue<AppTask<?>>> pQueueTL =
new ThreadLocal<ConcurrentLinkedQueue<AppTask<?>>>() {
@ -129,14 +140,41 @@ public class PhysicsSpace {
private Map<RigidBody, PhysicsRigidBody> physicsBodies = new ConcurrentHashMap<RigidBody, PhysicsRigidBody>();
private Map<TypedConstraint, PhysicsJoint> physicsJoints = new ConcurrentHashMap<TypedConstraint, PhysicsJoint>();
private Map<RaycastVehicle, PhysicsVehicle> physicsVehicles = new ConcurrentHashMap<RaycastVehicle, PhysicsVehicle>();
/**
* map from collision groups to registered group listeners
*/
private Map<Integer, PhysicsCollisionGroupListener> collisionGroupListeners = new ConcurrentHashMap<Integer, PhysicsCollisionGroupListener>();
/**
* queue of registered tick listeners
*/
private ConcurrentLinkedQueue<PhysicsTickListener> tickListeners = new ConcurrentLinkedQueue<PhysicsTickListener>();
private ArrayList<PhysicsCollisionListener> collisionListeners = new ArrayList<PhysicsCollisionListener>();
/**
* list of registered collision listeners
*/
final private List<PhysicsCollisionListener> collisionListeners
= new SafeArrayList<>(PhysicsCollisionListener.class);
/**
* queue of collision events not yet distributed to listeners
*/
private ArrayDeque<PhysicsCollisionEvent> collisionEvents = new ArrayDeque<PhysicsCollisionEvent>();
private PhysicsCollisionEventFactory eventFactory = new PhysicsCollisionEventFactory();
/**
* copy of minimum coordinate values when using AXIS_SWEEP broadphase
* algorithms
*/
private Vector3f worldMin = new Vector3f(-10000f, -10000f, -10000f);
/**
* copy of maximum coordinate values when using AXIS_SWEEP broadphase
* algorithms
*/
private Vector3f worldMax = new Vector3f(10000f, 10000f, 10000f);
/**
* physics time step (in seconds, &gt;0)
*/
private float accuracy = 1f / 60f;
/**
* maximum number of physics steps per frame (&ge;0, default=4)
*/
private int maxSubSteps = 4;
private javax.vecmath.Vector3f rayVec1 = new javax.vecmath.Vector3f();
private javax.vecmath.Vector3f rayVec2 = new javax.vecmath.Vector3f();

Loading…
Cancel
Save