mirror of
https://github.com/overte-org/overte.git
synced 2025-04-25 13:53:38 +02:00
optimization for when physics engine doesn't step
This commit is contained in:
parent
aebdd3b335
commit
d5c0c200de
2 changed files with 22 additions and 17 deletions
|
@ -29,23 +29,27 @@ PhysicsEngine::~PhysicsEngine() {
|
||||||
|
|
||||||
// begin EntitySimulation overrides
|
// begin EntitySimulation overrides
|
||||||
void PhysicsEngine::updateEntitiesInternal(const quint64& now) {
|
void PhysicsEngine::updateEntitiesInternal(const quint64& now) {
|
||||||
// NOTE: the grand order of operations is:
|
// no need to send updates unless the physics simulation has actually stepped
|
||||||
// (1) relay incoming changes
|
if (_lastNumSubstepsAtUpdateInternal != _numSubsteps) {
|
||||||
// (2) step simulation
|
_lastNumSubstepsAtUpdateInternal = _numSubsteps;
|
||||||
// (3) synchronize outgoing motion states
|
// NOTE: the grand order of operations is:
|
||||||
// (4) send outgoing packets
|
// (1) relay incoming changes
|
||||||
|
// (2) step simulation
|
||||||
// this is step (4)
|
// (3) synchronize outgoing motion states
|
||||||
QSet<ObjectMotionState*>::iterator stateItr = _outgoingPackets.begin();
|
// (4) send outgoing packets
|
||||||
while (stateItr != _outgoingPackets.end()) {
|
|
||||||
ObjectMotionState* state = *stateItr;
|
// this is step (4)
|
||||||
if (state->doesNotNeedToSendUpdate()) {
|
QSet<ObjectMotionState*>::iterator stateItr = _outgoingPackets.begin();
|
||||||
stateItr = _outgoingPackets.erase(stateItr);
|
while (stateItr != _outgoingPackets.end()) {
|
||||||
} else if (state->shouldSendUpdate(_numSubsteps)) {
|
ObjectMotionState* state = *stateItr;
|
||||||
state->sendUpdate(_entityPacketSender, _numSubsteps);
|
if (state->doesNotNeedToSendUpdate()) {
|
||||||
++stateItr;
|
stateItr = _outgoingPackets.erase(stateItr);
|
||||||
} else {
|
} else if (state->shouldSendUpdate(_numSubsteps)) {
|
||||||
++stateItr;
|
state->sendUpdate(_entityPacketSender, _numSubsteps);
|
||||||
|
++stateItr;
|
||||||
|
} else {
|
||||||
|
++stateItr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,6 +114,7 @@ private:
|
||||||
|
|
||||||
ContactMap _contactMap;
|
ContactMap _contactMap;
|
||||||
uint32_t _numContactFrames = 0;
|
uint32_t _numContactFrames = 0;
|
||||||
|
uint32_t _lastNumSubstepsAtUpdateInternal = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_PhysicsEngine_h
|
#endif // hifi_PhysicsEngine_h
|
||||||
|
|
Loading…
Reference in a new issue