mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 12:28:02 +02:00
Merge pull request #3749 from ZappoMan/entityBugs
Fix the bug where sometimes entity changes don't get sent to all viewers
This commit is contained in:
commit
372d8946d0
5 changed files with 15 additions and 6 deletions
|
@ -452,11 +452,10 @@ int OctreeSendThread::packetDistributor(OctreeQueryNode* nodeData, bool viewFrus
|
||||||
_myServer->getOctree()->lockForRead();
|
_myServer->getOctree()->lockForRead();
|
||||||
quint64 lockWaitEnd = usecTimestampNow();
|
quint64 lockWaitEnd = usecTimestampNow();
|
||||||
lockWaitElapsedUsec = (float)(lockWaitEnd - lockWaitStart);
|
lockWaitElapsedUsec = (float)(lockWaitEnd - lockWaitStart);
|
||||||
|
|
||||||
quint64 encodeStart = usecTimestampNow();
|
quint64 encodeStart = usecTimestampNow();
|
||||||
|
|
||||||
bytesWritten = _myServer->getOctree()->encodeTreeBitstream(subTree, &_packetData, nodeData->elementBag, params);
|
bytesWritten = _myServer->getOctree()->encodeTreeBitstream(subTree, &_packetData, nodeData->elementBag, params);
|
||||||
|
|
||||||
quint64 encodeEnd = usecTimestampNow();
|
quint64 encodeEnd = usecTimestampNow();
|
||||||
encodeElapsedUsec = (float)(encodeEnd - encodeStart);
|
encodeElapsedUsec = (float)(encodeEnd - encodeStart);
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,7 @@ void EntityItem::initFromEntityItemID(const EntityItemID& entityItemID) {
|
||||||
|
|
||||||
_lastUpdated = 0;
|
_lastUpdated = 0;
|
||||||
_created = 0; // TODO: when do we actually want to make this "now"
|
_created = 0; // TODO: when do we actually want to make this "now"
|
||||||
|
_changedOnServer = 0;
|
||||||
|
|
||||||
_position = glm::vec3(0,0,0);
|
_position = glm::vec3(0,0,0);
|
||||||
_rotation = DEFAULT_ROTATION;
|
_rotation = DEFAULT_ROTATION;
|
||||||
|
@ -87,6 +88,7 @@ EntityItem::EntityItem(const EntityItemID& entityItemID) {
|
||||||
_lastEditedFromRemoteInRemoteTime = 0;
|
_lastEditedFromRemoteInRemoteTime = 0;
|
||||||
_lastUpdated = 0;
|
_lastUpdated = 0;
|
||||||
_created = 0;
|
_created = 0;
|
||||||
|
_changedOnServer = 0;
|
||||||
initFromEntityItemID(entityItemID);
|
initFromEntityItemID(entityItemID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,6 +99,7 @@ EntityItem::EntityItem(const EntityItemID& entityItemID, const EntityItemPropert
|
||||||
_lastEditedFromRemoteInRemoteTime = 0;
|
_lastEditedFromRemoteInRemoteTime = 0;
|
||||||
_lastUpdated = 0;
|
_lastUpdated = 0;
|
||||||
_created = properties.getCreated();
|
_created = properties.getCreated();
|
||||||
|
_changedOnServer = 0;
|
||||||
initFromEntityItemID(entityItemID);
|
initFromEntityItemID(entityItemID);
|
||||||
setProperties(properties, true); // force copy
|
setProperties(properties, true); // force copy
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,10 +70,14 @@ public:
|
||||||
|
|
||||||
/// Last edited time of this entity universal usecs
|
/// Last edited time of this entity universal usecs
|
||||||
quint64 getLastEdited() const { return _lastEdited; }
|
quint64 getLastEdited() const { return _lastEdited; }
|
||||||
void setLastEdited(quint64 lastEdited) { _lastEdited = _lastUpdated = lastEdited; }
|
void setLastEdited(quint64 lastEdited)
|
||||||
|
{ _lastEdited = _lastUpdated = lastEdited; _changedOnServer = glm::max(lastEdited, _changedOnServer); }
|
||||||
float getEditedAgo() const /// Elapsed seconds since this entity was last edited
|
float getEditedAgo() const /// Elapsed seconds since this entity was last edited
|
||||||
{ return (float)(usecTimestampNow() - getLastEdited()) / (float)USECS_PER_SECOND; }
|
{ return (float)(usecTimestampNow() - getLastEdited()) / (float)USECS_PER_SECOND; }
|
||||||
|
|
||||||
|
void markAsChangedOnServer() { _changedOnServer = usecTimestampNow(); }
|
||||||
|
quint64 getLastChangedOnServer() const { return _changedOnServer; }
|
||||||
|
|
||||||
// TODO: eventually only include properties changed since the params.lastViewFrustumSent time
|
// TODO: eventually only include properties changed since the params.lastViewFrustumSent time
|
||||||
virtual EntityPropertyFlags getEntityProperties(EncodeBitstreamParams& params) const;
|
virtual EntityPropertyFlags getEntityProperties(EncodeBitstreamParams& params) const;
|
||||||
|
|
||||||
|
@ -268,6 +272,7 @@ protected:
|
||||||
quint64 _lastEditedFromRemote; // this is the last time we received and edit from the server
|
quint64 _lastEditedFromRemote; // this is the last time we received and edit from the server
|
||||||
quint64 _lastEditedFromRemoteInRemoteTime; // time in server time space the last time we received and edit from the server
|
quint64 _lastEditedFromRemoteInRemoteTime; // time in server time space the last time we received and edit from the server
|
||||||
quint64 _created;
|
quint64 _created;
|
||||||
|
quint64 _changedOnServer;
|
||||||
|
|
||||||
glm::vec3 _position;
|
glm::vec3 _position;
|
||||||
glm::vec3 _dimensions;
|
glm::vec3 _dimensions;
|
||||||
|
|
|
@ -497,6 +497,7 @@ int EntityTree::processEditPacketData(PacketType packetType, const unsigned char
|
||||||
// if the entityItem exists, then update it
|
// if the entityItem exists, then update it
|
||||||
if (existingEntity) {
|
if (existingEntity) {
|
||||||
updateEntity(entityItemID, properties);
|
updateEntity(entityItemID, properties);
|
||||||
|
existingEntity->markAsChangedOnServer();
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "User attempted to edit an unknown entity. ID:" << entityItemID;
|
qDebug() << "User attempted to edit an unknown entity. ID:" << entityItemID;
|
||||||
}
|
}
|
||||||
|
@ -505,6 +506,7 @@ int EntityTree::processEditPacketData(PacketType packetType, const unsigned char
|
||||||
entityItemID = assignEntityID(entityItemID);
|
entityItemID = assignEntityID(entityItemID);
|
||||||
EntityItem* newEntity = addEntity(entityItemID, properties);
|
EntityItem* newEntity = addEntity(entityItemID, properties);
|
||||||
if (newEntity) {
|
if (newEntity) {
|
||||||
|
newEntity->markAsChangedOnServer();
|
||||||
notifyNewlyCreatedEntity(*newEntity, senderNode);
|
notifyNewlyCreatedEntity(*newEntity, senderNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -238,7 +238,7 @@ void EntityTreeElement::elementEncodeComplete(EncodeBitstreamParams& params, Oct
|
||||||
|
|
||||||
OctreeElement::AppendState EntityTreeElement::appendElementData(OctreePacketData* packetData,
|
OctreeElement::AppendState EntityTreeElement::appendElementData(OctreePacketData* packetData,
|
||||||
EncodeBitstreamParams& params) const {
|
EncodeBitstreamParams& params) const {
|
||||||
|
|
||||||
OctreeElement::AppendState appendElementState = OctreeElement::COMPLETED; // assume the best...
|
OctreeElement::AppendState appendElementState = OctreeElement::COMPLETED; // assume the best...
|
||||||
|
|
||||||
// first, check the params.extraEncodeData to see if there's any partial re-encode data for this element
|
// first, check the params.extraEncodeData to see if there's any partial re-encode data for this element
|
||||||
|
@ -289,7 +289,8 @@ OctreeElement::AppendState EntityTreeElement::appendElementData(OctreePacketData
|
||||||
for (uint16_t i = 0; i < _entityItems->size(); i++) {
|
for (uint16_t i = 0; i < _entityItems->size(); i++) {
|
||||||
EntityItem* entity = (*_entityItems)[i];
|
EntityItem* entity = (*_entityItems)[i];
|
||||||
bool includeThisEntity = true;
|
bool includeThisEntity = true;
|
||||||
if (!params.forceSendScene && entity->getLastEdited() < params.lastViewFrustumSent) {
|
|
||||||
|
if (!params.forceSendScene && entity->getLastChangedOnServer() < params.lastViewFrustumSent) {
|
||||||
includeThisEntity = false;
|
includeThisEntity = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -324,7 +325,6 @@ OctreeElement::AppendState EntityTreeElement::appendElementData(OctreePacketData
|
||||||
if (successAppendEntityCount) {
|
if (successAppendEntityCount) {
|
||||||
foreach (uint16_t i, indexesOfEntitiesToInclude) {
|
foreach (uint16_t i, indexesOfEntitiesToInclude) {
|
||||||
EntityItem* entity = (*_entityItems)[i];
|
EntityItem* entity = (*_entityItems)[i];
|
||||||
|
|
||||||
LevelDetails entityLevel = packetData->startLevel();
|
LevelDetails entityLevel = packetData->startLevel();
|
||||||
OctreeElement::AppendState appendEntityState = entity->appendEntityData(packetData,
|
OctreeElement::AppendState appendEntityState = entity->appendEntityData(packetData,
|
||||||
params, entityTreeElementExtraEncodeData);
|
params, entityTreeElementExtraEncodeData);
|
||||||
|
|
Loading…
Reference in a new issue