mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 04:44:11 +02:00
send all TerseUpdate properties when one changes
This commit is contained in:
parent
ac0609ea92
commit
8177512432
5 changed files with 35 additions and 2 deletions
|
@ -925,6 +925,21 @@ EntityItemProperties EntityItem::getProperties() const {
|
|||
return properties;
|
||||
}
|
||||
|
||||
void EntityItem::getAllTerseUpdateProperties(EntityItemProperties& properties) const {
|
||||
// a TerseUpdate includes the transform and its derivatives
|
||||
properties._position = _position;
|
||||
properties._velocity = _velocity;
|
||||
properties._rotation = _rotation;
|
||||
properties._angularVelocity = _angularVelocity;
|
||||
properties._acceleration = _acceleration;
|
||||
|
||||
properties._positionChanged = true;
|
||||
properties._velocityChanged = true;
|
||||
properties._rotationChanged = true;
|
||||
properties._angularVelocityChanged = true;
|
||||
properties._accelerationChanged = true;
|
||||
}
|
||||
|
||||
bool EntityItem::setProperties(const EntityItemProperties& properties) {
|
||||
bool somethingChanged = false;
|
||||
|
||||
|
|
|
@ -347,6 +347,8 @@ public:
|
|||
|
||||
quint64 getLastEditedFromRemote() { return _lastEditedFromRemote; }
|
||||
|
||||
void getAllTerseUpdateProperties(EntityItemProperties& properties) const;
|
||||
|
||||
protected:
|
||||
|
||||
static bool _sendPhysicsUpdates;
|
||||
|
|
|
@ -1156,4 +1156,7 @@ AABox EntityItemProperties::getAABox() const {
|
|||
return AABox(rotatedExtentsRelativeToRegistrationPoint);
|
||||
}
|
||||
|
||||
|
||||
bool EntityItemProperties::hasTerseUpdateChanges() const {
|
||||
// a TerseUpdate includes the transform and its derivatives
|
||||
return _positionChanged || _velocityChanged || _rotationChanged || _angularVelocityChanged || _accelerationChanged;
|
||||
}
|
||||
|
|
|
@ -195,6 +195,8 @@ public:
|
|||
|
||||
void setVoxelDataDirty() { _voxelDataChanged = true; }
|
||||
|
||||
bool hasTerseUpdateChanges() const;
|
||||
|
||||
private:
|
||||
QUuid _id;
|
||||
bool _idSet;
|
||||
|
@ -215,6 +217,7 @@ private:
|
|||
QStringList _textureNames;
|
||||
glm::vec3 _naturalDimensions;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(EntityItemProperties);
|
||||
QScriptValue EntityItemPropertiesToScriptValue(QScriptEngine* engine, const EntityItemProperties& properties);
|
||||
QScriptValue EntityItemNonDefaultPropertiesToScriptValue(QScriptEngine* engine, const EntityItemProperties& properties);
|
||||
|
|
|
@ -146,7 +146,17 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties&
|
|||
EntityItemProperties modifiedProperties = properties;
|
||||
entity->setLastBroadcast(usecTimestampNow());
|
||||
modifiedProperties.setType(entity->getType());
|
||||
bidForSimulationOwnership(modifiedProperties);
|
||||
if (modifiedProperties.hasTerseUpdateChanges()) {
|
||||
// we make a bid for (or assert) our simulation ownership
|
||||
auto nodeList = DependencyManager::get<NodeList>();
|
||||
const QUuid myNodeID = nodeList->getSessionUUID();
|
||||
modifiedProperties.setSimulatorID(myNodeID);
|
||||
|
||||
if (entity->getSimulatorID() == myNodeID) {
|
||||
// we think we already own simulation, so make sure we send ALL TerseUpdate properties
|
||||
entity->getAllTerseUpdateProperties(modifiedProperties);
|
||||
}
|
||||
}
|
||||
queueEntityMessage(PacketTypeEntityEdit, entityID, modifiedProperties);
|
||||
return id;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue