mirror of
https://github.com/overte-org/overte.git
synced 2025-04-25 17:35:45 +02:00
don't accept updates to queryAACube if this interface is simulation owner
This commit is contained in:
parent
f75e59c0a6
commit
ae70f091c3
2 changed files with 30 additions and 9 deletions
|
@ -717,6 +717,14 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef
|
||||||
weOwnSimulation = _simulationOwner.matchesValidID(myNodeID);
|
weOwnSimulation = _simulationOwner.matchesValidID(myNodeID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto lastEdited = lastEditedFromBufferAdjusted;
|
||||||
|
bool otherOverwrites = overwriteLocalData && !weOwnSimulation;
|
||||||
|
auto shouldUpdate = [lastEdited, otherOverwrites, filterRejection](quint64 updatedTimestamp, bool valueChanged) {
|
||||||
|
bool simulationChanged = lastEdited > updatedTimestamp;
|
||||||
|
return otherOverwrites && simulationChanged && (valueChanged || filterRejection);
|
||||||
|
};
|
||||||
|
|
||||||
{ // When we own the simulation we don't accept updates to the entity's transform/velocities
|
{ // When we own the simulation we don't accept updates to the entity's transform/velocities
|
||||||
// we also want to ignore any duplicate packets that have the same "recently updated" values
|
// we also want to ignore any duplicate packets that have the same "recently updated" values
|
||||||
// as a packet we've already recieved. This is because we want multiple edits of the same
|
// as a packet we've already recieved. This is because we want multiple edits of the same
|
||||||
|
@ -729,12 +737,6 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef
|
||||||
|
|
||||||
// Note: duplicate packets are expected and not wrong. They may be sent for any number of
|
// Note: duplicate packets are expected and not wrong. They may be sent for any number of
|
||||||
// reasons and the contract is that the client handles them in an idempotent manner.
|
// reasons and the contract is that the client handles them in an idempotent manner.
|
||||||
auto lastEdited = lastEditedFromBufferAdjusted;
|
|
||||||
bool otherOverwrites = overwriteLocalData && !weOwnSimulation;
|
|
||||||
auto shouldUpdate = [lastEdited, otherOverwrites, filterRejection](quint64 updatedTimestamp, bool valueChanged) {
|
|
||||||
bool simulationChanged = lastEdited > updatedTimestamp;
|
|
||||||
return otherOverwrites && simulationChanged && (valueChanged || filterRejection);
|
|
||||||
};
|
|
||||||
auto customUpdatePositionFromNetwork = [this, shouldUpdate, lastEdited](glm::vec3 value){
|
auto customUpdatePositionFromNetwork = [this, shouldUpdate, lastEdited](glm::vec3 value){
|
||||||
if (shouldUpdate(_lastUpdatedPositionTimestamp, value != _lastUpdatedPositionValue)) {
|
if (shouldUpdate(_lastUpdatedPositionTimestamp, value != _lastUpdatedPositionValue)) {
|
||||||
updatePositionFromNetwork(value);
|
updatePositionFromNetwork(value);
|
||||||
|
@ -780,8 +782,6 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef
|
||||||
READ_ENTITY_PROPERTY(PROP_VELOCITY, glm::vec3, customUpdateVelocityFromNetwork);
|
READ_ENTITY_PROPERTY(PROP_VELOCITY, glm::vec3, customUpdateVelocityFromNetwork);
|
||||||
READ_ENTITY_PROPERTY(PROP_ANGULAR_VELOCITY, glm::vec3, customUpdateAngularVelocityFromNetwork);
|
READ_ENTITY_PROPERTY(PROP_ANGULAR_VELOCITY, glm::vec3, customUpdateAngularVelocityFromNetwork);
|
||||||
READ_ENTITY_PROPERTY(PROP_ACCELERATION, glm::vec3, customSetAcceleration);
|
READ_ENTITY_PROPERTY(PROP_ACCELERATION, glm::vec3, customSetAcceleration);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
READ_ENTITY_PROPERTY(PROP_DIMENSIONS, glm::vec3, updateDimensions);
|
READ_ENTITY_PROPERTY(PROP_DIMENSIONS, glm::vec3, updateDimensions);
|
||||||
|
@ -846,7 +846,18 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef
|
||||||
overwriteLocalData = oldOverwrite;
|
overwriteLocalData = oldOverwrite;
|
||||||
}
|
}
|
||||||
|
|
||||||
READ_ENTITY_PROPERTY(PROP_QUERY_AA_CUBE, AACube, setQueryAACube);
|
|
||||||
|
{
|
||||||
|
auto customUpdateQueryAACubeFromNetwork = [this, shouldUpdate, lastEdited](AACube value){
|
||||||
|
if (shouldUpdate(_lastUpdatedQueryAACubeTimestamp, value != _lastUpdatedQueryAACubeValue)) {
|
||||||
|
updateQueryAACubeFromNetwork(value);
|
||||||
|
_lastUpdatedQueryAACubeTimestamp = lastEdited;
|
||||||
|
_lastUpdatedQueryAACubeValue = value;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
READ_ENTITY_PROPERTY(PROP_QUERY_AA_CUBE, AACube, customUpdateQueryAACubeFromNetwork);
|
||||||
|
}
|
||||||
|
|
||||||
READ_ENTITY_PROPERTY(PROP_LAST_EDITED_BY, QUuid, setLastEditedBy);
|
READ_ENTITY_PROPERTY(PROP_LAST_EDITED_BY, QUuid, setLastEditedBy);
|
||||||
|
|
||||||
bytesRead += readEntitySubclassDataFromBuffer(dataAt, (bytesLeftToRead - bytesRead), args,
|
bytesRead += readEntitySubclassDataFromBuffer(dataAt, (bytesLeftToRead - bytesRead), args,
|
||||||
|
@ -1846,6 +1857,13 @@ void EntityItem::updateVelocityFromNetwork(const glm::vec3& value) {
|
||||||
updateVelocity(value);
|
updateVelocity(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EntityItem::updateQueryAACubeFromNetwork(const AACube& value) {
|
||||||
|
if (shouldSuppressLocationEdits()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setQueryAACube(value);
|
||||||
|
}
|
||||||
|
|
||||||
void EntityItem::updateDamping(float value) {
|
void EntityItem::updateDamping(float value) {
|
||||||
auto clampedDamping = glm::clamp(value, 0.0f, 1.0f);
|
auto clampedDamping = glm::clamp(value, 0.0f, 1.0f);
|
||||||
if (_damping != clampedDamping) {
|
if (_damping != clampedDamping) {
|
||||||
|
|
|
@ -364,6 +364,7 @@ public:
|
||||||
void updateMass(float value);
|
void updateMass(float value);
|
||||||
void updateVelocity(const glm::vec3& value);
|
void updateVelocity(const glm::vec3& value);
|
||||||
void updateVelocityFromNetwork(const glm::vec3& value);
|
void updateVelocityFromNetwork(const glm::vec3& value);
|
||||||
|
void updateQueryAACubeFromNetwork(const AACube& value);
|
||||||
void updateDamping(float value);
|
void updateDamping(float value);
|
||||||
void updateRestitution(float value);
|
void updateRestitution(float value);
|
||||||
void updateFriction(float value);
|
void updateFriction(float value);
|
||||||
|
@ -631,12 +632,14 @@ protected:
|
||||||
glm::vec3 _lastUpdatedVelocityValue;
|
glm::vec3 _lastUpdatedVelocityValue;
|
||||||
glm::vec3 _lastUpdatedAngularVelocityValue;
|
glm::vec3 _lastUpdatedAngularVelocityValue;
|
||||||
glm::vec3 _lastUpdatedAccelerationValue;
|
glm::vec3 _lastUpdatedAccelerationValue;
|
||||||
|
AACube _lastUpdatedQueryAACubeValue;
|
||||||
|
|
||||||
quint64 _lastUpdatedPositionTimestamp { 0 };
|
quint64 _lastUpdatedPositionTimestamp { 0 };
|
||||||
quint64 _lastUpdatedRotationTimestamp { 0 };
|
quint64 _lastUpdatedRotationTimestamp { 0 };
|
||||||
quint64 _lastUpdatedVelocityTimestamp { 0 };
|
quint64 _lastUpdatedVelocityTimestamp { 0 };
|
||||||
quint64 _lastUpdatedAngularVelocityTimestamp { 0 };
|
quint64 _lastUpdatedAngularVelocityTimestamp { 0 };
|
||||||
quint64 _lastUpdatedAccelerationTimestamp { 0 };
|
quint64 _lastUpdatedAccelerationTimestamp { 0 };
|
||||||
|
quint64 _lastUpdatedQueryAACubeTimestamp { 0 };
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue