mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-29 19:22:57 +02:00
Merge pull request #11282 from sethalves/fix-winking-dynamic-children-1
fix a bug that caused dynamic children to wink in and out and then vanish
This commit is contained in:
commit
4b8840f307
4 changed files with 18 additions and 14 deletions
|
@ -92,6 +92,7 @@ void EntityMotionState::updateServerPhysicsVariables() {
|
||||||
|
|
||||||
Transform localTransform;
|
Transform localTransform;
|
||||||
_entity->getLocalTransformAndVelocities(localTransform, _serverVelocity, _serverAngularVelocity);
|
_entity->getLocalTransformAndVelocities(localTransform, _serverVelocity, _serverAngularVelocity);
|
||||||
|
_serverVariablesSet = true;
|
||||||
_serverPosition = localTransform.getTranslation();
|
_serverPosition = localTransform.getTranslation();
|
||||||
_serverRotation = localTransform.getRotation();
|
_serverRotation = localTransform.getRotation();
|
||||||
_serverAcceleration = _entity->getAcceleration();
|
_serverAcceleration = _entity->getAcceleration();
|
||||||
|
@ -99,18 +100,19 @@ void EntityMotionState::updateServerPhysicsVariables() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityMotionState::handleDeactivation() {
|
void EntityMotionState::handleDeactivation() {
|
||||||
// copy _server data to entity
|
if (_serverVariablesSet) {
|
||||||
bool success;
|
// copy _server data to entity
|
||||||
_entity->setPosition(_serverPosition, success, false);
|
Transform localTransform = _entity->getLocalTransform();
|
||||||
_entity->setOrientation(_serverRotation, success, false);
|
localTransform.setTranslation(_serverPosition);
|
||||||
_entity->setVelocity(ENTITY_ITEM_ZERO_VEC3);
|
localTransform.setRotation(_serverRotation);
|
||||||
_entity->setAngularVelocity(ENTITY_ITEM_ZERO_VEC3);
|
_entity->setLocalTransformAndVelocities(localTransform, ENTITY_ITEM_ZERO_VEC3, ENTITY_ITEM_ZERO_VEC3);
|
||||||
// and also to RigidBody
|
// and also to RigidBody
|
||||||
btTransform worldTrans;
|
btTransform worldTrans;
|
||||||
worldTrans.setOrigin(glmToBullet(_serverPosition));
|
worldTrans.setOrigin(glmToBullet(_entity->getPosition()));
|
||||||
worldTrans.setRotation(glmToBullet(_serverRotation));
|
worldTrans.setRotation(glmToBullet(_entity->getRotation()));
|
||||||
_body->setWorldTransform(worldTrans);
|
_body->setWorldTransform(worldTrans);
|
||||||
// no need to update velocities... should already be zero
|
// no need to update velocities... should already be zero
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// virtual
|
// virtual
|
||||||
|
@ -339,6 +341,7 @@ bool EntityMotionState::remoteSimulationOutOfSync(uint32_t simulationStep) {
|
||||||
// if we've never checked before, our _lastStep will be 0, and we need to initialize our state
|
// if we've never checked before, our _lastStep will be 0, and we need to initialize our state
|
||||||
if (_lastStep == 0) {
|
if (_lastStep == 0) {
|
||||||
btTransform xform = _body->getWorldTransform();
|
btTransform xform = _body->getWorldTransform();
|
||||||
|
_serverVariablesSet = true;
|
||||||
_serverPosition = worldToLocal.transform(bulletToGLM(xform.getOrigin()));
|
_serverPosition = worldToLocal.transform(bulletToGLM(xform.getOrigin()));
|
||||||
_serverRotation = worldToLocal.getRotation() * bulletToGLM(xform.getRotation());
|
_serverRotation = worldToLocal.getRotation() * bulletToGLM(xform.getRotation());
|
||||||
_serverVelocity = worldVelocityToLocal.transform(getBodyLinearVelocityGTSigma());
|
_serverVelocity = worldVelocityToLocal.transform(getBodyLinearVelocityGTSigma());
|
||||||
|
|
|
@ -107,6 +107,7 @@ protected:
|
||||||
// Meanwhile we also keep a raw EntityItem* for internal stuff where the pointer is guaranteed valid.
|
// Meanwhile we also keep a raw EntityItem* for internal stuff where the pointer is guaranteed valid.
|
||||||
EntityItem* _entity;
|
EntityItem* _entity;
|
||||||
|
|
||||||
|
bool _serverVariablesSet { false };
|
||||||
glm::vec3 _serverPosition; // in simulation-frame (not world-frame)
|
glm::vec3 _serverPosition; // in simulation-frame (not world-frame)
|
||||||
glm::quat _serverRotation;
|
glm::quat _serverRotation;
|
||||||
glm::vec3 _serverVelocity;
|
glm::vec3 _serverVelocity;
|
||||||
|
|
|
@ -731,7 +731,7 @@ void SpatiallyNestable::setScale(float value) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const Transform SpatiallyNestable::getLocalTransform() const {
|
Transform SpatiallyNestable::getLocalTransform() const {
|
||||||
Transform result;
|
Transform result;
|
||||||
_transformLock.withReadLock([&] {
|
_transformLock.withReadLock([&] {
|
||||||
result =_transform;
|
result =_transform;
|
||||||
|
|
|
@ -121,7 +121,7 @@ public:
|
||||||
virtual glm::vec3 getScale(int jointIndex) const;
|
virtual glm::vec3 getScale(int jointIndex) const;
|
||||||
|
|
||||||
// object's parent's frame
|
// object's parent's frame
|
||||||
virtual const Transform getLocalTransform() const;
|
virtual Transform getLocalTransform() const;
|
||||||
virtual void setLocalTransform(const Transform& transform);
|
virtual void setLocalTransform(const Transform& transform);
|
||||||
|
|
||||||
virtual glm::vec3 getLocalPosition() const;
|
virtual glm::vec3 getLocalPosition() const;
|
||||||
|
|
Loading…
Reference in a new issue