mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-16 08:00:12 +02:00
if nodes are fighting over phyics variables, squash physics-related properties in the updates from the loser of the race
This commit is contained in:
parent
c69aaa806b
commit
deec577db6
2 changed files with 18 additions and 4 deletions
|
@ -338,6 +338,7 @@
|
|||
T get##N() const { return _##n; } \
|
||||
void set##N(T value) { _##n = value; _##n##Changed = true; } \
|
||||
bool n##Changed() const { return _##n##Changed; } \
|
||||
void set##N##Changed(bool value) { _##n##Changed = value; } \
|
||||
private: \
|
||||
T _##n; \
|
||||
bool _##n##Changed;
|
||||
|
@ -347,6 +348,7 @@
|
|||
const T& get##N() const { return _##n; } \
|
||||
void set##N(const T& value) { _##n = value; _##n##Changed = true; } \
|
||||
bool n##Changed() const { return _##n##Changed; } \
|
||||
void set##N##Changed(bool value) { _##n##Changed = value; } \
|
||||
private: \
|
||||
T _##n; \
|
||||
bool _##n##Changed;
|
||||
|
@ -356,6 +358,7 @@
|
|||
const T& get##N() const { return _##n; } \
|
||||
void set##N(const T& value); \
|
||||
bool n##Changed() const; \
|
||||
void set##N##Changed(bool value) { _##n##Changed = value; } \
|
||||
private: \
|
||||
T _##n; \
|
||||
bool _##n##Changed;
|
||||
|
@ -365,6 +368,7 @@
|
|||
T get##N() const; \
|
||||
void set##N(const T& value); \
|
||||
bool n##Changed() const; \
|
||||
void set##N##Changed(bool value) { _##n##Changed = value; } \
|
||||
private: \
|
||||
T _##n; \
|
||||
bool _##n##Changed;
|
||||
|
@ -376,6 +380,7 @@
|
|||
bool n##Changed() const { return _##n##Changed; } \
|
||||
QString get##N##AsString() const; \
|
||||
void set##N##FromString(const QString& name); \
|
||||
void set##N##Changed(bool value) { _##n##Changed = value; } \
|
||||
private: \
|
||||
T _##n; \
|
||||
bool _##n##Changed;
|
||||
|
|
|
@ -24,6 +24,10 @@
|
|||
#include "EntitiesLogging.h"
|
||||
#include "RecurseOctreeToMapOperator.h"
|
||||
|
||||
|
||||
const quint64 SIMULATOR_CHANGE_LOCKOUT_PERIOD = 0.2 * USECS_PER_SECOND;
|
||||
|
||||
|
||||
EntityTree::EntityTree(bool shouldReaverage) :
|
||||
Octree(shouldReaverage),
|
||||
_fbxService(NULL),
|
||||
|
@ -108,9 +112,9 @@ bool EntityTree::updateEntity(EntityItem* entity, const EntityItemProperties& pr
|
|||
return updateEntityWithElement(entity, properties, containingElement, allowLockChange);
|
||||
}
|
||||
|
||||
bool EntityTree::updateEntityWithElement(EntityItem* entity, const EntityItemProperties& properties,
|
||||
bool EntityTree::updateEntityWithElement(EntityItem* entity, const EntityItemProperties& origProperties,
|
||||
EntityTreeElement* containingElement, bool allowLockChange) {
|
||||
|
||||
EntityItemProperties properties = origProperties;
|
||||
if (!allowLockChange && (entity->getLocked() != properties.getLocked())) {
|
||||
qCDebug(entities) << "Refusing disallowed lock adjustment.";
|
||||
return false;
|
||||
|
@ -136,8 +140,13 @@ bool EntityTree::updateEntityWithElement(EntityItem* entity, const EntityItemPro
|
|||
// A Node is trying to take ownership of the simulation of this entity from another Node. Only allow this
|
||||
// if ownership hasn't recently changed.
|
||||
quint64 now = usecTimestampNow();
|
||||
if (now - entity->getSimulatorIDChangedTime() < 2 * USECS_PER_SECOND) { // XXX pick time and put in constant
|
||||
qDebug() << "TOO SOON";
|
||||
if (now - entity->getSimulatorIDChangedTime() < SIMULATOR_CHANGE_LOCKOUT_PERIOD) {
|
||||
qDebug() << "SIMULATOR_CHANGE_LOCKOUT_PERIOD";
|
||||
// squash the physics-related changes.
|
||||
properties.setSimulatorIDChanged(false);
|
||||
properties.setPositionChanged(false);
|
||||
properties.setVelocityChanged(false);
|
||||
properties.setAccelerationChanged(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue