mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 13:49:46 +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;
|
bool canBeKinematic = region <= workload::Region::R3;
|
||||||
if (motionState) {
|
if (motionState) {
|
||||||
if (!shouldBePhysical) {
|
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);
|
_incomingChanges.remove(motionState);
|
||||||
_physicalObjects.remove(motionState);
|
_physicalObjects.remove(motionState);
|
||||||
removeOwnershipData(motionState);
|
removeOwnershipData(motionState);
|
||||||
|
|
Loading…
Reference in a new issue