fix for issue #1157 (can't enable a TranslationalLimitMotor)
This commit is contained in:
parent
3c74fe539c
commit
30d1ecaec2
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2009-2012 jMonkeyEngine
|
* Copyright (c) 2009-2019 jMonkeyEngine
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@ -232,6 +232,43 @@ extern "C" {
|
|||||||
motor->m_restitution = value;
|
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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -281,6 +281,11 @@ public class SixDofJoint extends PhysicsJoint {
|
|||||||
getTranslationalLimitMotor().setLowerLimit((Vector3f) capsule.readSavable("transMotor_LowerLimit", Vector3f.ZERO));
|
getTranslationalLimitMotor().setLowerLimit((Vector3f) capsule.readSavable("transMotor_LowerLimit", Vector3f.ZERO));
|
||||||
getTranslationalLimitMotor().setRestitution(capsule.readFloat("transMotor_Restitution", 0.5f));
|
getTranslationalLimitMotor().setRestitution(capsule.readFloat("transMotor_Restitution", 0.5f));
|
||||||
getTranslationalLimitMotor().setUpperLimit((Vector3f) capsule.readSavable("transMotor_UpperLimit", Vector3f.ZERO));
|
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().getLowerLimit(), "transMotor_LowerLimit", Vector3f.ZERO);
|
||||||
capsule.write(getTranslationalLimitMotor().getRestitution(), "transMotor_Restitution", 0.5f);
|
capsule.write(getTranslationalLimitMotor().getRestitution(), "transMotor_Restitution", 0.5f);
|
||||||
capsule.write(getTranslationalLimitMotor().getUpperLimit(), "transMotor_UpperLimit", Vector3f.ZERO);
|
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.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* 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);
|
private native void setRestitution(long motorId, float restitution);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable or disable the indexed axis.
|
||||||
|
*
|
||||||
|
* @param axisIndex which axis: 0→X, 1→Y, 2→Z
|
||||||
|
* @param enableMotor true→enable, false→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→X, 1→Y, 2→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…
x
Reference in New Issue
Block a user