mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 05:03:31 +02:00
Merge pull request #9 from AndrewMeadows/motor-action
remove unused parameters from Hinge and ConeTwist constraints
This commit is contained in:
commit
f40c7bde71
5 changed files with 28 additions and 127 deletions
|
@ -59,11 +59,9 @@ void ObjectActionMotor::updateActionWorker(btScalar deltaTimeStep) {
|
|||
|
||||
if (_angularTimeScale < MAX_MOTOR_TIMESCALE) {
|
||||
|
||||
if (!_otherID.isNull()) {
|
||||
if (other) {
|
||||
glm::vec3 otherAngularVelocity = other->getAngularVelocity();
|
||||
rigidBody->setAngularVelocity(glmToBullet(_angularVelocityTarget + otherAngularVelocity));
|
||||
}
|
||||
if (other) {
|
||||
glm::vec3 otherAngularVelocity = other->getAngularVelocity();
|
||||
rigidBody->setAngularVelocity(glmToBullet(_angularVelocityTarget + otherAngularVelocity));
|
||||
} else {
|
||||
rigidBody->setAngularVelocity(glmToBullet(_angularVelocityTarget));
|
||||
}
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
#include "ObjectConstraintConeTwist.h"
|
||||
#include "PhysicsLogging.h"
|
||||
|
||||
|
||||
const uint16_t ObjectConstraintConeTwist::constraintVersion = 1;
|
||||
const uint16_t CONE_TWIST_VERSION_WITH_UNUSED_PAREMETERS = 1;
|
||||
const uint16_t ObjectConstraintConeTwist::constraintVersion = 2;
|
||||
const glm::vec3 DEFAULT_CONE_TWIST_AXIS(1.0f, 0.0f, 0.0f);
|
||||
|
||||
ObjectConstraintConeTwist::ObjectConstraintConeTwist(const QUuid& id, EntityItemPointer ownerEntity) :
|
||||
|
@ -56,18 +56,12 @@ void ObjectConstraintConeTwist::updateConeTwist() {
|
|||
float swingSpan1;
|
||||
float swingSpan2;
|
||||
float twistSpan;
|
||||
float softness;
|
||||
float biasFactor;
|
||||
float relaxationFactor;
|
||||
|
||||
withReadLock([&]{
|
||||
constraint = static_cast<btConeTwistConstraint*>(_constraint);
|
||||
swingSpan1 = _swingSpan1;
|
||||
swingSpan2 = _swingSpan2;
|
||||
twistSpan = _twistSpan;
|
||||
softness = _softness;
|
||||
biasFactor = _biasFactor;
|
||||
relaxationFactor = _relaxationFactor;
|
||||
});
|
||||
|
||||
if (!constraint) {
|
||||
|
@ -76,10 +70,7 @@ void ObjectConstraintConeTwist::updateConeTwist() {
|
|||
|
||||
constraint->setLimit(swingSpan1,
|
||||
swingSpan2,
|
||||
twistSpan,
|
||||
softness,
|
||||
biasFactor,
|
||||
relaxationFactor);
|
||||
twistSpan);
|
||||
}
|
||||
|
||||
|
||||
|
@ -171,9 +162,6 @@ bool ObjectConstraintConeTwist::updateArguments(QVariantMap arguments) {
|
|||
float swingSpan1;
|
||||
float swingSpan2;
|
||||
float twistSpan;
|
||||
float softness;
|
||||
float biasFactor;
|
||||
float relaxationFactor;
|
||||
|
||||
bool needUpdate = false;
|
||||
bool somethingChanged = ObjectDynamic::updateArguments(arguments);
|
||||
|
@ -227,25 +215,6 @@ bool ObjectConstraintConeTwist::updateArguments(QVariantMap arguments) {
|
|||
twistSpan = _twistSpan;
|
||||
}
|
||||
|
||||
ok = true;
|
||||
softness = EntityDynamicInterface::extractFloatArgument("coneTwist constraint", arguments, "softness", ok, false);
|
||||
if (!ok) {
|
||||
softness = _softness;
|
||||
}
|
||||
|
||||
ok = true;
|
||||
biasFactor = EntityDynamicInterface::extractFloatArgument("coneTwist constraint", arguments, "biasFactor", ok, false);
|
||||
if (!ok) {
|
||||
biasFactor = _biasFactor;
|
||||
}
|
||||
|
||||
ok = true;
|
||||
relaxationFactor =
|
||||
EntityDynamicInterface::extractFloatArgument("coneTwist constraint", arguments, "relaxationFactor", ok, false);
|
||||
if (!ok) {
|
||||
relaxationFactor = _relaxationFactor;
|
||||
}
|
||||
|
||||
if (somethingChanged ||
|
||||
pivotInA != _pivotInA ||
|
||||
axisInA != _axisInA ||
|
||||
|
@ -254,10 +223,7 @@ bool ObjectConstraintConeTwist::updateArguments(QVariantMap arguments) {
|
|||
axisInB != _axisInB ||
|
||||
swingSpan1 != _swingSpan1 ||
|
||||
swingSpan2 != _swingSpan2 ||
|
||||
twistSpan != _twistSpan ||
|
||||
softness != _softness ||
|
||||
biasFactor != _biasFactor ||
|
||||
relaxationFactor != _relaxationFactor) {
|
||||
twistSpan != _twistSpan) {
|
||||
// something changed
|
||||
needUpdate = true;
|
||||
}
|
||||
|
@ -273,9 +239,6 @@ bool ObjectConstraintConeTwist::updateArguments(QVariantMap arguments) {
|
|||
_swingSpan1 = swingSpan1;
|
||||
_swingSpan2 = swingSpan2;
|
||||
_twistSpan = twistSpan;
|
||||
_softness = softness;
|
||||
_biasFactor = biasFactor;
|
||||
_relaxationFactor = relaxationFactor;
|
||||
|
||||
_active = true;
|
||||
|
||||
|
@ -303,9 +266,6 @@ QVariantMap ObjectConstraintConeTwist::getArguments() {
|
|||
arguments["swingSpan1"] = _swingSpan1;
|
||||
arguments["swingSpan2"] = _swingSpan2;
|
||||
arguments["twistSpan"] = _twistSpan;
|
||||
arguments["softness"] = _softness;
|
||||
arguments["biasFactor"] = _biasFactor;
|
||||
arguments["relaxationFactor"] = _relaxationFactor;
|
||||
});
|
||||
return arguments;
|
||||
}
|
||||
|
@ -330,9 +290,6 @@ QByteArray ObjectConstraintConeTwist::serialize() const {
|
|||
dataStream << _swingSpan1;
|
||||
dataStream << _swingSpan2;
|
||||
dataStream << _twistSpan;
|
||||
dataStream << _softness;
|
||||
dataStream << _biasFactor;
|
||||
dataStream << _relaxationFactor;
|
||||
});
|
||||
|
||||
return serializedConstraintArguments;
|
||||
|
@ -351,7 +308,7 @@ void ObjectConstraintConeTwist::deserialize(QByteArray serializedArguments) {
|
|||
|
||||
uint16_t serializationVersion;
|
||||
dataStream >> serializationVersion;
|
||||
if (serializationVersion != ObjectConstraintConeTwist::constraintVersion) {
|
||||
if (serializationVersion > ObjectConstraintConeTwist::constraintVersion) {
|
||||
assert(false);
|
||||
return;
|
||||
}
|
||||
|
@ -370,9 +327,12 @@ void ObjectConstraintConeTwist::deserialize(QByteArray serializedArguments) {
|
|||
dataStream >> _swingSpan1;
|
||||
dataStream >> _swingSpan2;
|
||||
dataStream >> _twistSpan;
|
||||
dataStream >> _softness;
|
||||
dataStream >> _biasFactor;
|
||||
dataStream >> _relaxationFactor;
|
||||
if (serializationVersion == CONE_TWIST_VERSION_WITH_UNUSED_PAREMETERS) {
|
||||
float softness, biasFactor, relaxationFactor;
|
||||
dataStream >> softness;
|
||||
dataStream >> biasFactor;
|
||||
dataStream >> relaxationFactor;
|
||||
}
|
||||
|
||||
_active = true;
|
||||
});
|
||||
|
|
|
@ -46,9 +46,6 @@ protected:
|
|||
float _swingSpan1 { TWO_PI };
|
||||
float _swingSpan2 { TWO_PI };;
|
||||
float _twistSpan { TWO_PI };;
|
||||
float _softness { 1.0f };
|
||||
float _biasFactor {0.3f };
|
||||
float _relaxationFactor { 1.0f };
|
||||
};
|
||||
|
||||
#endif // hifi_ObjectConstraintConeTwist_h
|
||||
|
|
|
@ -16,7 +16,8 @@
|
|||
#include "PhysicsLogging.h"
|
||||
|
||||
|
||||
const uint16_t ObjectConstraintHinge::constraintVersion = 1;
|
||||
const uint16_t HINGE_VERSION_WITH_UNUSED_PAREMETERS = 1;
|
||||
const uint16_t ObjectConstraintHinge::constraintVersion = 2;
|
||||
const glm::vec3 DEFAULT_HINGE_AXIS(1.0f, 0.0f, 0.0f);
|
||||
|
||||
ObjectConstraintHinge::ObjectConstraintHinge(const QUuid& id, EntityItemPointer ownerEntity) :
|
||||
|
@ -56,25 +57,19 @@ void ObjectConstraintHinge::updateHinge() {
|
|||
glm::vec3 axisInA;
|
||||
float low;
|
||||
float high;
|
||||
float softness;
|
||||
float biasFactor;
|
||||
float relaxationFactor;
|
||||
|
||||
withReadLock([&]{
|
||||
axisInA = _axisInA;
|
||||
constraint = static_cast<btHingeConstraint*>(_constraint);
|
||||
low = _low;
|
||||
high = _high;
|
||||
biasFactor = _biasFactor;
|
||||
relaxationFactor = _relaxationFactor;
|
||||
softness = _softness;
|
||||
});
|
||||
|
||||
if (!constraint) {
|
||||
return;
|
||||
}
|
||||
|
||||
constraint->setLimit(low, high, softness, biasFactor, relaxationFactor);
|
||||
constraint->setLimit(low, high);
|
||||
}
|
||||
|
||||
|
||||
|
@ -159,9 +154,6 @@ bool ObjectConstraintHinge::updateArguments(QVariantMap arguments) {
|
|||
glm::vec3 axisInB;
|
||||
float low;
|
||||
float high;
|
||||
float softness;
|
||||
float biasFactor;
|
||||
float relaxationFactor;
|
||||
|
||||
bool needUpdate = false;
|
||||
bool somethingChanged = ObjectDynamic::updateArguments(arguments);
|
||||
|
@ -209,25 +201,6 @@ bool ObjectConstraintHinge::updateArguments(QVariantMap arguments) {
|
|||
high = _high;
|
||||
}
|
||||
|
||||
ok = true;
|
||||
softness = EntityDynamicInterface::extractFloatArgument("hinge constraint", arguments, "softness", ok, false);
|
||||
if (!ok) {
|
||||
softness = _softness;
|
||||
}
|
||||
|
||||
ok = true;
|
||||
biasFactor = EntityDynamicInterface::extractFloatArgument("hinge constraint", arguments, "biasFactor", ok, false);
|
||||
if (!ok) {
|
||||
biasFactor = _biasFactor;
|
||||
}
|
||||
|
||||
ok = true;
|
||||
relaxationFactor = EntityDynamicInterface::extractFloatArgument("hinge constraint", arguments,
|
||||
"relaxationFactor", ok, false);
|
||||
if (!ok) {
|
||||
relaxationFactor = _relaxationFactor;
|
||||
}
|
||||
|
||||
if (somethingChanged ||
|
||||
pivotInA != _pivotInA ||
|
||||
axisInA != _axisInA ||
|
||||
|
@ -235,10 +208,7 @@ bool ObjectConstraintHinge::updateArguments(QVariantMap arguments) {
|
|||
pivotInB != _pivotInB ||
|
||||
axisInB != _axisInB ||
|
||||
low != _low ||
|
||||
high != _high ||
|
||||
softness != _softness ||
|
||||
biasFactor != _biasFactor ||
|
||||
relaxationFactor != _relaxationFactor) {
|
||||
high != _high) {
|
||||
// something changed
|
||||
needUpdate = true;
|
||||
}
|
||||
|
@ -253,9 +223,6 @@ bool ObjectConstraintHinge::updateArguments(QVariantMap arguments) {
|
|||
_axisInB = axisInB;
|
||||
_low = low;
|
||||
_high = high;
|
||||
_softness = softness;
|
||||
_biasFactor = biasFactor;
|
||||
_relaxationFactor = relaxationFactor;
|
||||
|
||||
_active = true;
|
||||
|
||||
|
@ -282,9 +249,6 @@ QVariantMap ObjectConstraintHinge::getArguments() {
|
|||
arguments["otherAxis"] = glmToQMap(_axisInB);
|
||||
arguments["low"] = _low;
|
||||
arguments["high"] = _high;
|
||||
arguments["softness"] = _softness;
|
||||
arguments["biasFactor"] = _biasFactor;
|
||||
arguments["relaxationFactor"] = _relaxationFactor;
|
||||
if (_constraint) {
|
||||
arguments["angle"] = static_cast<btHingeConstraint*>(_constraint)->getHingeAngle(); // [-PI,PI]
|
||||
} else {
|
||||
|
@ -310,9 +274,6 @@ QByteArray ObjectConstraintHinge::serialize() const {
|
|||
dataStream << _axisInB;
|
||||
dataStream << _low;
|
||||
dataStream << _high;
|
||||
dataStream << _softness;
|
||||
dataStream << _biasFactor;
|
||||
dataStream << _relaxationFactor;
|
||||
|
||||
dataStream << localTimeToServerTime(_expires);
|
||||
dataStream << _tag;
|
||||
|
@ -334,7 +295,7 @@ void ObjectConstraintHinge::deserialize(QByteArray serializedArguments) {
|
|||
|
||||
uint16_t serializationVersion;
|
||||
dataStream >> serializationVersion;
|
||||
if (serializationVersion != ObjectConstraintHinge::constraintVersion) {
|
||||
if (serializationVersion > ObjectConstraintHinge::constraintVersion) {
|
||||
assert(false);
|
||||
return;
|
||||
}
|
||||
|
@ -347,9 +308,12 @@ void ObjectConstraintHinge::deserialize(QByteArray serializedArguments) {
|
|||
dataStream >> _axisInB;
|
||||
dataStream >> _low;
|
||||
dataStream >> _high;
|
||||
dataStream >> _softness;
|
||||
dataStream >> _biasFactor;
|
||||
dataStream >> _relaxationFactor;
|
||||
if (serializationVersion == HINGE_VERSION_WITH_UNUSED_PAREMETERS) {
|
||||
float softness, biasFactor, relaxationFactor;
|
||||
dataStream >> softness;
|
||||
dataStream >> biasFactor;
|
||||
dataStream >> relaxationFactor;
|
||||
}
|
||||
|
||||
quint64 serverExpires;
|
||||
dataStream >> serverExpires;
|
||||
|
|
|
@ -48,27 +48,9 @@ protected:
|
|||
|
||||
// https://gamedev.stackexchange.com/questions/71436/what-are-the-parameters-for-bthingeconstraintsetlimit
|
||||
//
|
||||
// softness: a negative measure of the friction that determines how much the hinge rotates for a given force. A high
|
||||
// softness would make the hinge rotate easily like it's oiled then.
|
||||
// biasFactor: an offset for the relaxed rotation of the hinge. It won't be right in the middle of the low and high angles
|
||||
// anymore. 1.0f is the neural value.
|
||||
// relaxationFactor: a measure of how much force is applied internally to bring the hinge in its central rotation.
|
||||
// This is right in the middle of the low and high angles. For example, consider a western swing door. After
|
||||
// walking through it will swing in both directions but at the end it stays right in the middle.
|
||||
|
||||
// http://javadoc.jmonkeyengine.org/com/jme3/bullet/joints/HingeJoint.html
|
||||
//
|
||||
// _softness - the factor at which the velocity error correction starts operating, i.e. a softness of 0.9 means that
|
||||
// the vel. corr starts at 90% of the limit range.
|
||||
// _biasFactor - the magnitude of the position correction. It tells you how strictly the position error (drift) is
|
||||
// corrected.
|
||||
// _relaxationFactor - the rate at which velocity errors are corrected. This can be seen as the strength of the
|
||||
// limits. A low value will make the the limits more spongy.
|
||||
|
||||
|
||||
float _softness { 0.9f };
|
||||
float _biasFactor { 0.3f };
|
||||
float _relaxationFactor { 1.0f };
|
||||
// softness: unused
|
||||
// biasFactor: unused
|
||||
// relaxationFactor: unused
|
||||
};
|
||||
|
||||
#endif // hifi_ObjectConstraintHinge_h
|
||||
|
|
Loading…
Reference in a new issue