mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 09:57:26 +02:00
don't run motor for other's hinge
This commit is contained in:
parent
59950236d3
commit
e9461f812d
2 changed files with 14 additions and 6 deletions
|
@ -52,6 +52,13 @@ void ObjectConstraintHinge::prepareForPhysicsSimulation() {
|
||||||
// setting the motor velocity doesn't appear to work for anyone. constantly adjusting the
|
// setting the motor velocity doesn't appear to work for anyone. constantly adjusting the
|
||||||
// target angle seems to work.
|
// target angle seems to work.
|
||||||
// https://www.bulletphysics.org/Bullet/phpBB3/viewtopic.php?f=9&t=7020
|
// https://www.bulletphysics.org/Bullet/phpBB3/viewtopic.php?f=9&t=7020
|
||||||
|
|
||||||
|
if (!isMine()) {
|
||||||
|
// XXX
|
||||||
|
// don't activate motor for someone else's action?
|
||||||
|
// maybe don't if this interface isn't the sim owner?
|
||||||
|
return;
|
||||||
|
}
|
||||||
uint64_t now = usecTimestampNow();
|
uint64_t now = usecTimestampNow();
|
||||||
withWriteLock([&]{
|
withWriteLock([&]{
|
||||||
btHingeConstraint* constraint = static_cast<btHingeConstraint*>(_constraint);
|
btHingeConstraint* constraint = static_cast<btHingeConstraint*>(_constraint);
|
||||||
|
@ -69,12 +76,12 @@ void ObjectConstraintHinge::prepareForPhysicsSimulation() {
|
||||||
float dt = (float)(now - _previousMotorTime) / (float)USECS_PER_SECOND;
|
float dt = (float)(now - _previousMotorTime) / (float)USECS_PER_SECOND;
|
||||||
float t = (float)(now - _startMotorTime) / (float)USECS_PER_SECOND;
|
float t = (float)(now - _startMotorTime) / (float)USECS_PER_SECOND;
|
||||||
float motorTarget = _motorVelocity * t;
|
float motorTarget = _motorVelocity * t;
|
||||||
while (motorTarget > PI) {
|
|
||||||
motorTarget -= PI;
|
// brige motorTarget into the range of [-PI, PI]
|
||||||
}
|
motorTarget += PI;
|
||||||
while (motorTarget < PI) {
|
motorTarget = fmodf(motorTarget, 2.0f * PI);
|
||||||
motorTarget += PI;
|
motorTarget -= PI;
|
||||||
}
|
|
||||||
if (!_motorEnabled) {
|
if (!_motorEnabled) {
|
||||||
constraint->enableMotor(true);
|
constraint->enableMotor(true);
|
||||||
_motorEnabled = true;
|
_motorEnabled = true;
|
||||||
|
|
|
@ -2490,6 +2490,7 @@ SelectionDisplay = (function() {
|
||||||
y: 0,
|
y: 0,
|
||||||
z: vector.z
|
z: vector.z
|
||||||
});
|
});
|
||||||
|
print("translateXZTool " + JSON.stringify(newPosition));
|
||||||
Entities.editEntity(SelectionManager.selections[i], {
|
Entities.editEntity(SelectionManager.selections[i], {
|
||||||
position: newPosition,
|
position: newPosition,
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue