mirror of
https://github.com/JulianGro/overte.git
synced 2025-05-06 17:49:05 +02:00
Push down OctreeQueryNode lock to OctreeQuery and use for conical views
Possibly related to https://highfidelity.manuscript.com/f/cases/14165/entity-server-doesn-t-always-relay-added-entities-to-clients
This commit is contained in:
parent
cf917514b4
commit
9bb966dd1d
4 changed files with 19 additions and 13 deletions
|
@ -34,6 +34,8 @@ int OctreeQuery::getBroadcastData(unsigned char* destinationBuffer) {
|
||||||
memcpy(destinationBuffer, &_connectionID, sizeof(_connectionID));
|
memcpy(destinationBuffer, &_connectionID, sizeof(_connectionID));
|
||||||
destinationBuffer += sizeof(_connectionID);
|
destinationBuffer += sizeof(_connectionID);
|
||||||
|
|
||||||
|
{
|
||||||
|
QMutexLocker lock(&_conicalViewsLock);
|
||||||
// Number of frustums
|
// Number of frustums
|
||||||
uint8_t numFrustums = (uint8_t)_conicalViews.size();
|
uint8_t numFrustums = (uint8_t)_conicalViews.size();
|
||||||
memcpy(destinationBuffer, &numFrustums, sizeof(numFrustums));
|
memcpy(destinationBuffer, &numFrustums, sizeof(numFrustums));
|
||||||
|
@ -42,6 +44,7 @@ int OctreeQuery::getBroadcastData(unsigned char* destinationBuffer) {
|
||||||
for (const auto& view : _conicalViews) {
|
for (const auto& view : _conicalViews) {
|
||||||
destinationBuffer += view.serialize(destinationBuffer);
|
destinationBuffer += view.serialize(destinationBuffer);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// desired Max Octree PPS
|
// desired Max Octree PPS
|
||||||
memcpy(destinationBuffer, &_maxQueryPPS, sizeof(_maxQueryPPS));
|
memcpy(destinationBuffer, &_maxQueryPPS, sizeof(_maxQueryPPS));
|
||||||
|
@ -108,12 +111,15 @@ int OctreeQuery::parseData(ReceivedMessage& message) {
|
||||||
memcpy(&numFrustums, sourceBuffer, sizeof(numFrustums));
|
memcpy(&numFrustums, sourceBuffer, sizeof(numFrustums));
|
||||||
sourceBuffer += sizeof(numFrustums);
|
sourceBuffer += sizeof(numFrustums);
|
||||||
|
|
||||||
|
{
|
||||||
|
QMutexLocker lock(&_conicalViewsLock);
|
||||||
_conicalViews.clear();
|
_conicalViews.clear();
|
||||||
for (int i = 0; i < numFrustums; ++i) {
|
for (int i = 0; i < numFrustums; ++i) {
|
||||||
ConicalViewFrustum view;
|
ConicalViewFrustum view;
|
||||||
sourceBuffer += view.deserialize(sourceBuffer);
|
sourceBuffer += view.deserialize(sourceBuffer);
|
||||||
_conicalViews.push_back(view);
|
_conicalViews.push_back(view);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// desired Max Octree PPS
|
// desired Max Octree PPS
|
||||||
memcpy(&_maxQueryPPS, sourceBuffer, sizeof(_maxQueryPPS));
|
memcpy(&_maxQueryPPS, sourceBuffer, sizeof(_maxQueryPPS));
|
||||||
|
|
|
@ -60,6 +60,7 @@ public slots:
|
||||||
void setBoundaryLevelAdjust(int boundaryLevelAdjust) { _boundaryLevelAdjust = boundaryLevelAdjust; }
|
void setBoundaryLevelAdjust(int boundaryLevelAdjust) { _boundaryLevelAdjust = boundaryLevelAdjust; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
QMutex _conicalViewsLock;
|
||||||
ConicalViewFrustums _conicalViews;
|
ConicalViewFrustums _conicalViews;
|
||||||
|
|
||||||
// octree server sending items
|
// octree server sending items
|
||||||
|
|
|
@ -153,7 +153,7 @@ bool OctreeQueryNode::updateCurrentViewFrustum() {
|
||||||
bool currentViewFrustumChanged = false;
|
bool currentViewFrustumChanged = false;
|
||||||
|
|
||||||
{ // if there has been a change, then recalculate
|
{ // if there has been a change, then recalculate
|
||||||
QMutexLocker viewLocker(&_viewMutex);
|
QMutexLocker lock(&_conicalViewsLock);
|
||||||
|
|
||||||
if (_conicalViews.size() == _currentConicalViews.size()) {
|
if (_conicalViews.size() == _currentConicalViews.size()) {
|
||||||
for (size_t i = 0; i < _conicalViews.size(); ++i) {
|
for (size_t i = 0; i < _conicalViews.size(); ++i) {
|
||||||
|
|
|
@ -95,7 +95,6 @@ private:
|
||||||
int _duplicatePacketCount { 0 };
|
int _duplicatePacketCount { 0 };
|
||||||
quint64 _firstSuppressedPacket { usecTimestampNow() };
|
quint64 _firstSuppressedPacket { usecTimestampNow() };
|
||||||
|
|
||||||
mutable QMutex _viewMutex { QMutex::Recursive };
|
|
||||||
ConicalViewFrustums _currentConicalViews;
|
ConicalViewFrustums _currentConicalViews;
|
||||||
bool _viewFrustumChanging { false };
|
bool _viewFrustumChanging { false };
|
||||||
bool _viewFrustumJustStoppedChanging { true };
|
bool _viewFrustumJustStoppedChanging { true };
|
||||||
|
|
Loading…
Reference in a new issue