PhysicsSpace: add method to set solver iterations
Thanks to Seppes (see thread: http://hub.jmonkeyengine.org/t/how-to-access-native-bullets-constraintsolver-numiterations)
This commit is contained in:
parent
f7d544f453
commit
cd1d145005
@ -529,6 +529,18 @@ extern "C" {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_setSolverNumIterations
|
||||||
|
(JNIEnv *env, jobject object, jlong spaceId, jint value) {
|
||||||
|
jmePhysicsSpace* space = reinterpret_cast<jmePhysicsSpace*>(spaceId);
|
||||||
|
if (space == NULL) {
|
||||||
|
jclass newExc = env->FindClass("java/lang/NullPointerException");
|
||||||
|
env->ThrowNew(newExc, "The physics space does not exist.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
space->getDynamicsWorld()->getSolverInfo().m_numIterations = value;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -174,6 +174,14 @@ JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_finalizeNative
|
|||||||
JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_sweepTest_1native
|
JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_sweepTest_1native
|
||||||
(JNIEnv *, jobject, jlong, jobject, jobject, jlong, jobject, jfloat);
|
(JNIEnv *, jobject, jlong, jobject, jobject, jlong, jobject, jfloat);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: com_jme3_bullet_PhysicsSpace
|
||||||
|
* Method: setSolverNumIterations
|
||||||
|
* Signature: (JI)V
|
||||||
|
*/
|
||||||
|
JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_setSolverNumIterations
|
||||||
|
(JNIEnv *, jobject, jlong, jint);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -102,6 +102,7 @@ public class PhysicsSpace {
|
|||||||
private Vector3f worldMax = new Vector3f(10000f, 10000f, 10000f);
|
private Vector3f worldMax = new Vector3f(10000f, 10000f, 10000f);
|
||||||
private float accuracy = 1f / 60f;
|
private float accuracy = 1f / 60f;
|
||||||
private int maxSubSteps = 4, rayTestFlags = 1 << 2;
|
private int maxSubSteps = 4, rayTestFlags = 1 << 2;
|
||||||
|
private int solverNumIterations = 10;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
// System.loadLibrary("bulletjme");
|
// System.loadLibrary("bulletjme");
|
||||||
@ -958,6 +959,29 @@ public class PhysicsSpace {
|
|||||||
this.worldMax.set(worldMax);
|
this.worldMax.set(worldMax);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the number of iterations used by the contact solver.
|
||||||
|
*
|
||||||
|
* The default is 10. Use 4 for low quality, 20 for high quality.
|
||||||
|
*
|
||||||
|
* @param numIterations The number of iterations used by the contact & constraint solver.
|
||||||
|
*/
|
||||||
|
public void setSolverNumIterations(int numIterations) {
|
||||||
|
this.solverNumIterations = numIterations;
|
||||||
|
setSolverNumIterations(physicsSpaceId, numIterations);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the number of iterations used by the contact solver.
|
||||||
|
*
|
||||||
|
* @return The number of iterations used by the contact & constraint solver.
|
||||||
|
*/
|
||||||
|
public int getSolverNumIterations() {
|
||||||
|
return solverNumIterations;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static native void setSolverNumIterations(long physicsSpaceId, int numIterations);
|
||||||
|
|
||||||
public static native void initNativePhysics();
|
public static native void initNativePhysics();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -876,6 +876,21 @@ public class PhysicsSpace {
|
|||||||
this.worldMax.set(worldMax);
|
this.worldMax.set(worldMax);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the number of iterations used by the contact solver.
|
||||||
|
*
|
||||||
|
* The default is 10. Use 4 for low quality, 20 for high quality.
|
||||||
|
*
|
||||||
|
* @param numIterations The number of iterations used by the contact & constraint solver.
|
||||||
|
*/
|
||||||
|
public void setSolverNumIterations(int numIterations) {
|
||||||
|
dynamicsWorld.getSolverInfo().numIterations = numIterations;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSolverNumIterations() {
|
||||||
|
return dynamicsWorld.getSolverInfo().numIterations;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* interface with Broadphase types
|
* interface with Broadphase types
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user