Also following patch for trimesh,geometry,trianglepickresult,pickresult and boundingpickresult (which only had to add the requiredOnBit in the method header because of the abstract PickResult-signature):
I will commit this, this evening:
Index: src/com/jme/intersection/BoundingPickResults.java
===================================================================
--- src/com/jme/intersection/BoundingPickResults.java (revision 4766)
+++ src/com/jme/intersection/BoundingPickResults.java (working copy)
@@ -56,10 +56,16 @@
* @see com.jme.intersection.PickResults#addPick(Ray, Geometry)
*/
public void addPick(Ray ray, Geometry g) {
+ addPick(ray,g,1);
+ }
+
+ @Override
+ public void addPick(Ray ray, Geometry g, int requiredOnBits) {
PickData data = new PickData(ray, g, willCheckDistance());
addPickData(data);
}
-
+
+
/**
* empty implementation, it is highly recommended that you override this
* method to handle any picks as needed.
@@ -70,4 +76,5 @@
}
+
}
Index: src/com/jme/intersection/PickResults.java
===================================================================
--- src/com/jme/intersection/PickResults.java (revision 4766)
+++ src/com/jme/intersection/PickResults.java (working copy)
@@ -118,8 +118,10 @@
* should order the object.
* @param ray the ray that was cast for the pick calculation.
* @param g the object to add to the pick data.
+ * @param requiredOnBits Collision will only be considered if 'this'
+ * has these bits of its collision mask set.
*/
- public abstract void addPick(Ray ray, Geometry g);
+ public abstract void addPick(Ray ray, Geometry g, int requiredOnBits);
/**
* Optional method that can be implemented by sub classes to define
Index: src/com/jme/intersection/TrianglePickResults.java
===================================================================
--- src/com/jme/intersection/TrianglePickResults.java (revision 4766)
+++ src/com/jme/intersection/TrianglePickResults.java (working copy)
@@ -54,6 +54,17 @@
*/
public class TrianglePickResults extends PickResults {
+ /**
+ * Convenience wrapper for
+ * addPick(Ray, Geometry, int)
+ * collidability (first bit of the collidable bit mask).
+ *
+ * @see #addPick(Ray, Geometry, int)
+ */
+ public void addPick(Ray ray, Geometry g) {
+ addPick(ray,g,1);
+ }
+
/**
* <code>addPick</code> adds a Geometry object to the pick list. If the
* Geometry object is not a TriMesh, the process stops here. However, if the
@@ -64,9 +75,12 @@
* the ray that is doing the picking.
* @param g
* the Geometry to add to the pick list.
+ * @param requiredOnBits TrianglePick will only be considered if 'this'
+ * has these bits of its collision masks set.
+ *
* @see com.jme.intersection.PickResults#addPick(Ray, Geometry)
- */
- public void addPick(Ray ray, Geometry g) {
+ */
+ public void addPick(Ray ray, Geometry g, int requiredOnBits) {
//find the triangle that is being hit.
//add this node and the triangle to the CollisionResults
// list.
@@ -75,8 +89,9 @@
addPickData(data);
} else {
ArrayList<Integer> a = new ArrayList<Integer>();
- ((TriMesh) g).findTrianglePick(ray, a);
+ ((TriMesh) g).findTrianglePick(ray, a, requiredOnBits);
PickData data = new TrianglePickData(ray, ((TriMesh) g), a, willCheckDistance());
+
addPickData(data);
}
}
Index: src/com/jme/scene/Geometry.java
===================================================================
--- src/com/jme/scene/Geometry.java (revision 4788)
+++ src/com/jme/scene/Geometry.java (working copy)
@@ -649,7 +649,7 @@
if (getWorldBound().intersects(ray)) {
// find the triangle that is being hit.
// add this node and the triangle to the PickResults list.
- results.addPick(ray, this);
+ results.addPick(ray, this,requiredOnBits);
}
}
Index: src/com/jme/scene/TriMesh.java
===================================================================
--- src/com/jme/scene/TriMesh.java (revision 4766)
+++ src/com/jme/scene/TriMesh.java (working copy)
@@ -411,6 +411,16 @@
}
}
+
+ /**
+ * Convenience wrapper for findTrianglePick(Ray, ArrayList<Integer>,int) using default
+ * collision mask (bit 1 set).
+ */
+ public void findTrianglePick(Ray toTest, ArrayList<Integer> results) {
+ findTrianglePick(toTest, results, 1);
+ }
+
+
/**
* <code>findTrianglePick</code> determines the triangles of this trimesh
* that are being touched by the ray. The indices of the triangles are
@@ -421,9 +431,11 @@
* (length 1).
* @param results
* the indices to the triangles.
+ * @param requiredOnBits Pick will only be considered if 'this'
+ * has these bits of its collision masks set.
*/
- public void findTrianglePick(Ray toTest, ArrayList<Integer> results) {
- if (worldBound == null || !isCollidable()) {
+ public void findTrianglePick(Ray toTest, ArrayList<Integer> results,int requiredOnBits) {
+ if (worldBound == null || !isCollidable(requiredOnBits)) {
return;
}