From 614bffa9ae2d7a5bd70aafd6709dfd80aa5065bc Mon Sep 17 00:00:00 2001 From: phr00t Date: Sat, 9 Nov 2013 22:32:27 +0000 Subject: [PATCH] Native bullet raytest m_flags now accessible to Java, updated bullet builds incoming... git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10881 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../com_jme3_bullet_PhysicsSpace.cpp | 3 ++- .../com_jme3_bullet_PhysicsSpace.h | 4 ++-- .../bullet/com/jme3/bullet/PhysicsSpace.java | 23 ++++++++++++++++--- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/engine/src/bullet-native/com_jme3_bullet_PhysicsSpace.cpp b/engine/src/bullet-native/com_jme3_bullet_PhysicsSpace.cpp index 8d0c41ca2..e20448d5a 100644 --- a/engine/src/bullet-native/com_jme3_bullet_PhysicsSpace.cpp +++ b/engine/src/bullet-native/com_jme3_bullet_PhysicsSpace.cpp @@ -419,7 +419,7 @@ extern "C" { } JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_rayTest_1native - (JNIEnv * env, jobject object, jobject from, jobject to, jlong spaceId, jobject resultlist) { + (JNIEnv * env, jobject object, jobject from, jobject to, jlong spaceId, jobject resultlist, jint flags) { jmePhysicsSpace* space = reinterpret_cast (spaceId); if (space == NULL) { @@ -463,6 +463,7 @@ extern "C" { AllRayResultCallback resultCallback(native_from, native_to); resultCallback.env = env; resultCallback.resultlist = resultlist; + resultCallback.m_flags = flags; space->getDynamicsWorld()->rayTest(native_from, native_to, resultCallback); return; } diff --git a/engine/src/bullet-native/com_jme3_bullet_PhysicsSpace.h b/engine/src/bullet-native/com_jme3_bullet_PhysicsSpace.h index 8eb2f34de..922f7b1e7 100644 --- a/engine/src/bullet-native/com_jme3_bullet_PhysicsSpace.h +++ b/engine/src/bullet-native/com_jme3_bullet_PhysicsSpace.h @@ -144,10 +144,10 @@ JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_setGravity /* * Class: com_jme3_bullet_PhysicsSpace * Method: rayTest_native - * Signature: (Lcom/jme3/math/Vector3f;Lcom/jme3/math/Vector3f;JLjava/util/List;)V + * Signature: (Lcom/jme3/math/Vector3f;Lcom/jme3/math/Vector3f;JLjava/util/List;I)V */ JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_rayTest_1native - (JNIEnv *, jobject, jobject, jobject, jlong, jobject); + (JNIEnv *, jobject, jobject, jobject, jlong, jobject, jint); /* * Class: com_jme3_bullet_PhysicsSpace diff --git a/engine/src/bullet/com/jme3/bullet/PhysicsSpace.java b/engine/src/bullet/com/jme3/bullet/PhysicsSpace.java index 623f8e06f..fd12dcb89 100644 --- a/engine/src/bullet/com/jme3/bullet/PhysicsSpace.java +++ b/engine/src/bullet/com/jme3/bullet/PhysicsSpace.java @@ -99,7 +99,7 @@ public class PhysicsSpace { private Vector3f worldMin = new Vector3f(-10000f, -10000f, -10000f); private Vector3f worldMax = new Vector3f(10000f, 10000f, 10000f); private float accuracy = 1f / 60f; - private int maxSubSteps = 4; + private int maxSubSteps = 4, rayTestFlags = 1 << 2; private AssetManager debugManager; static { @@ -787,17 +787,34 @@ public class PhysicsSpace { return (List) results; } + /** + * Sets m_flags for raytest, see https://code.google.com/p/bullet/source/browse/trunk/src/BulletCollision/NarrowPhaseCollision/btRaycastCallback.h + * for possible options. Defaults to using the faster, approximate raytest. + */ + public void SetRayTestFlags(int flags) { + rayTestFlags = flags; + } + + /** + * Gets m_flags for raytest, see https://code.google.com/p/bullet/source/browse/trunk/src/BulletCollision/NarrowPhaseCollision/btRaycastCallback.h + * for possible options. + * @return rayTestFlags + */ + public int GetRayTestFlags() { + return rayTestFlags; + } + /** * Performs a ray collision test and returns the results as a list of * PhysicsRayTestResults */ public List rayTest(Vector3f from, Vector3f to, List results) { results.clear(); - rayTest_native(from, to, physicsSpaceId, results); + rayTest_native(from, to, physicsSpaceId, results, rayTestFlags); return results; } - public native void rayTest_native(Vector3f from, Vector3f to, long physicsSpaceId, List results); + public native void rayTest_native(Vector3f from, Vector3f to, long physicsSpaceId, List results, int flags); // private class InternalRayListener extends CollisionWorld.RayResultCallback { //