fix for issue #1157 (can't enable a TranslationalLimitMotor)

fix-openal-soft-deadlink
Stephen Gold 5 years ago
parent 3c74fe539c
commit 30d1ecaec2
  1. 39
      jme3-bullet-native/src/native/cpp/com_jme3_bullet_joints_motors_TranslationalLimitMotor.cpp
  2. 10
      jme3-bullet/src/main/java/com/jme3/bullet/joints/SixDofJoint.java
  3. 28
      jme3-bullet/src/main/java/com/jme3/bullet/joints/motors/TranslationalLimitMotor.java

@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2012 jMonkeyEngine
* Copyright (c) 2009-2019 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -232,6 +232,43 @@ extern "C" {
motor->m_restitution = value;
}
/*
* Class: com_jme3_bullet_joints_motors_TranslationalLimitMotor
* Method: setEnabled
* Signature: (JIZ)V
*/
JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_motors_TranslationalLimitMotor_setEnabled
(JNIEnv *env, jobject object, jlong motorId, jint axisIndex, jboolean newSetting) {
btTranslationalLimitMotor *pMotor
= reinterpret_cast<btTranslationalLimitMotor *> (motorId);
if (pMotor == NULL) {
jclass newExc = env->FindClass("java/lang/NullPointerException");
env->ThrowNew(newExc, "The native object does not exist.");
return;
}
pMotor->m_enableMotor[axisIndex] = (bool)newSetting;
}
/*
* Class: com_jme3_bullet_joints_motors_TranslationalLimitMotor
* Method: isEnabled
* Signature: (JI)Z
*/
JNIEXPORT jboolean JNICALL Java_com_jme3_bullet_joints_motors_TranslationalLimitMotor_isEnabled
(JNIEnv *env, jobject object, jlong motorId, jint axisIndex) {
btTranslationalLimitMotor *pMotor
= reinterpret_cast<btTranslationalLimitMotor *> (motorId);
if (pMotor == NULL) {
jclass newExc = env->FindClass("java/lang/NullPointerException");
env->ThrowNew(newExc, "The native object does not exist.");
return 0;
}
bool result = pMotor->m_enableMotor[axisIndex];
return (jboolean) result;
}
#ifdef __cplusplus
}
#endif

@ -281,6 +281,11 @@ public class SixDofJoint extends PhysicsJoint {
getTranslationalLimitMotor().setLowerLimit((Vector3f) capsule.readSavable("transMotor_LowerLimit", Vector3f.ZERO));
getTranslationalLimitMotor().setRestitution(capsule.readFloat("transMotor_Restitution", 0.5f));
getTranslationalLimitMotor().setUpperLimit((Vector3f) capsule.readSavable("transMotor_UpperLimit", Vector3f.ZERO));
for (int axisIndex = 0; axisIndex < 3; ++axisIndex) {
translationalMotor.setEnabled(axisIndex, capsule.readBoolean(
"transMotor_Enable" + axisIndex, false));
}
}
/**
@ -318,5 +323,10 @@ public class SixDofJoint extends PhysicsJoint {
capsule.write(getTranslationalLimitMotor().getLowerLimit(), "transMotor_LowerLimit", Vector3f.ZERO);
capsule.write(getTranslationalLimitMotor().getRestitution(), "transMotor_Restitution", 0.5f);
capsule.write(getTranslationalLimitMotor().getUpperLimit(), "transMotor_UpperLimit", Vector3f.ZERO);
for (int axisIndex = 0; axisIndex < 3; ++axisIndex) {
capsule.write(translationalMotor.isEnabled(axisIndex),
"transMotor_Enable" + axisIndex, false);
}
}
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2018 jMonkeyEngine
* Copyright (c) 2009-2019 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -204,4 +204,30 @@ public class TranslationalLimitMotor {
}
private native void setRestitution(long motorId, float restitution);
/**
* Enable or disable the indexed axis.
*
* @param axisIndex which axis: 0&rarr;X, 1&rarr;Y, 2&rarr;Z
* @param enableMotor true&rarr;enable, false&rarr;disable (default=false)
*/
public void setEnabled(int axisIndex, boolean enableMotor) {
setEnabled(motorId, axisIndex, enableMotor);
}
native private void setEnabled(long motorId, int axisIndex,
boolean enableMotor);
/**
* Test whether the indexed axis is enabled.
*
* @param axisIndex which axis: 0&rarr;X, 1&rarr;Y, 2&rarr;Z
* @return true if enabled, otherwise false
*/
public boolean isEnabled(int axisIndex) {
boolean result = isEnabled(motorId, axisIndex);
return result;
}
native private boolean isEnabled(long motorId, int axisIndex);
}

Loading…
Cancel
Save