mirror of
https://github.com/overte-org/overte.git
synced 2025-04-22 10:33:40 +02:00
send ownership removal packet when dynamic object leaves bullet
This commit is contained in:
parent
3d16c9014f
commit
b1fcb43246
1 changed files with 15 additions and 1 deletions
|
@ -130,7 +130,21 @@ void PhysicalEntitySimulation::changeEntityInternal(EntityItemPointer entity) {
|
|||
bool canBeKinematic = region <= workload::Region::R3;
|
||||
if (motionState) {
|
||||
if (!shouldBePhysical) {
|
||||
// the entity should be removed from the physical simulation
|
||||
if (motionState->isLocallyOwned()) {
|
||||
// zero velocities by first deactivating the RigidBody
|
||||
btRigidBody* body = motionState->getRigidBody();
|
||||
if (body) {
|
||||
body->forceActivationState(ISLAND_SLEEPING);
|
||||
motionState->updateSendVelocities(); // has side-effect of zeroing entity velocities for inactive body
|
||||
}
|
||||
|
||||
// send packet to remove ownership
|
||||
// NOTE: this packet will NOT be resent if lost, but the good news is:
|
||||
// the entity-server will eventually clear velocity and ownership for timeout
|
||||
motionState->sendUpdate(_entityPacketSender, _physicsEngine->getNumSubsteps());
|
||||
}
|
||||
|
||||
// remove from the physical simulation
|
||||
_incomingChanges.remove(motionState);
|
||||
_physicalObjects.remove(motionState);
|
||||
removeOwnershipData(motionState);
|
||||
|
|
Loading…
Reference in a new issue