mirror of
https://github.com/overte-org/overte.git
synced 2025-04-23 13:33:26 +02:00
reset simulation bid counters on object activation
This commit is contained in:
parent
4df87ec4e8
commit
8d41960cc3
3 changed files with 6 additions and 9 deletions
libraries/physics/src
|
@ -180,10 +180,6 @@ btCollisionShape* EntityMotionState::computeNewShape() {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
// RELIABLE_SEND_HACK: until we have truly reliable resends of non-moving updates
|
||||
// we alwasy resend packets for objects that have stopped moving up to some max limit.
|
||||
const int MAX_NUM_NON_MOVING_UPDATES = 5;
|
||||
|
||||
bool EntityMotionState::isCandidateForOwnership(const QUuid& sessionID) const {
|
||||
if (!_body || !_entity) {
|
||||
return false;
|
||||
|
@ -495,6 +491,10 @@ void EntityMotionState::measureBodyAcceleration() {
|
|||
glm::vec3 velocity = bulletToGLM(_body->getLinearVelocity());
|
||||
_measuredAcceleration = (velocity / powf(1.0f - _body->getLinearDamping(), dt) - _lastVelocity) * invDt;
|
||||
_lastVelocity = velocity;
|
||||
if (numSubsteps > PHYSICS_ENGINE_MAX_NUM_SUBSTEPS && !_candidateForOwnership) {
|
||||
_loopsSinceOwnershipBid = 0;
|
||||
_loopsWithoutOwner = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
glm::vec3 EntityMotionState::getObjectLinearVelocityChange() const {
|
||||
|
|
|
@ -53,8 +53,6 @@ const uint32_t OUTGOING_DIRTY_PHYSICS_FLAGS = EntityItem::DIRTY_TRANSFORM | Enti
|
|||
class OctreeEditPacketSender;
|
||||
class PhysicsEngine;
|
||||
|
||||
extern const int MAX_NUM_NON_MOVING_UPDATES;
|
||||
|
||||
class ObjectMotionState : public btMotionState {
|
||||
public:
|
||||
// These poroperties of the PhysicsEngine are "global" within the context of all ObjectMotionStates
|
||||
|
|
|
@ -227,8 +227,7 @@ void PhysicsEngine::stepSimulation() {
|
|||
// (3) synchronize outgoing motion states
|
||||
// (4) send outgoing packets
|
||||
|
||||
const int MAX_NUM_SUBSTEPS = 4;
|
||||
const float MAX_TIMESTEP = (float)MAX_NUM_SUBSTEPS * PHYSICS_ENGINE_FIXED_SUBSTEP;
|
||||
const float MAX_TIMESTEP = (float)PHYSICS_ENGINE_MAX_NUM_SUBSTEPS * PHYSICS_ENGINE_FIXED_SUBSTEP;
|
||||
float dt = 1.0e-6f * (float)(_clock.getTimeMicroseconds());
|
||||
_clock.reset();
|
||||
float timeStep = btMin(dt, MAX_TIMESTEP);
|
||||
|
@ -245,7 +244,7 @@ void PhysicsEngine::stepSimulation() {
|
|||
_characterController->preSimulation(timeStep);
|
||||
}
|
||||
|
||||
int numSubsteps = _dynamicsWorld->stepSimulation(timeStep, MAX_NUM_SUBSTEPS, PHYSICS_ENGINE_FIXED_SUBSTEP);
|
||||
int numSubsteps = _dynamicsWorld->stepSimulation(timeStep, PHYSICS_ENGINE_MAX_NUM_SUBSTEPS, PHYSICS_ENGINE_FIXED_SUBSTEP);
|
||||
if (numSubsteps > 0) {
|
||||
BT_PROFILE("postSimulation");
|
||||
_numSubsteps += (uint32_t)numSubsteps;
|
||||
|
|
Loading…
Reference in a new issue