mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-29 20:42:56 +02:00
Bit of cleanup
This commit is contained in:
parent
0c1ae5bb61
commit
bd7fa266cf
5 changed files with 37 additions and 63 deletions
|
@ -20,39 +20,11 @@
|
||||||
|
|
||||||
#include "OctreeSendThread.h"
|
#include "OctreeSendThread.h"
|
||||||
|
|
||||||
OctreeQueryNode::OctreeQueryNode() :
|
|
||||||
_viewSent(false),
|
|
||||||
_octreePacket(),
|
|
||||||
_octreePacketWaiting(false),
|
|
||||||
_lastOctreePayload(new char[udt::MAX_PACKET_SIZE]),
|
|
||||||
_lastOctreePacketLength(0),
|
|
||||||
_duplicatePacketCount(0),
|
|
||||||
_firstSuppressedPacket(usecTimestampNow()),
|
|
||||||
_maxSearchLevel(1),
|
|
||||||
_maxLevelReachedInLastSearch(1),
|
|
||||||
_lastTimeBagEmpty(0),
|
|
||||||
_viewFrustumChanging(false),
|
|
||||||
_viewFrustumJustStoppedChanging(true),
|
|
||||||
_octreeSendThread(NULL),
|
|
||||||
_lastClientBoundaryLevelAdjust(0),
|
|
||||||
_lastClientOctreeSizeScale(DEFAULT_OCTREE_SIZE_SCALE),
|
|
||||||
_lodChanged(false),
|
|
||||||
_lodInitialized(false),
|
|
||||||
_sequenceNumber(0),
|
|
||||||
_lastRootTimestamp(0),
|
|
||||||
_myPacketType(PacketType::Unknown),
|
|
||||||
_isShuttingDown(false),
|
|
||||||
_sentPacketHistory()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
OctreeQueryNode::~OctreeQueryNode() {
|
OctreeQueryNode::~OctreeQueryNode() {
|
||||||
_isShuttingDown = true;
|
_isShuttingDown = true;
|
||||||
if (_octreeSendThread) {
|
if (_octreeSendThread) {
|
||||||
forceNodeShutdown();
|
forceNodeShutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
delete[] _lastOctreePayload;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OctreeQueryNode::nodeKilled() {
|
void OctreeQueryNode::nodeKilled() {
|
||||||
|
@ -105,7 +77,7 @@ bool OctreeQueryNode::packetIsDuplicate() const {
|
||||||
// of the entire packet, we need to compare only the packet content...
|
// of the entire packet, we need to compare only the packet content...
|
||||||
|
|
||||||
if (_lastOctreePacketLength == _octreePacket->getPayloadSize()) {
|
if (_lastOctreePacketLength == _octreePacket->getPayloadSize()) {
|
||||||
if (memcmp(_lastOctreePayload + OCTREE_PACKET_EXTRA_HEADERS_SIZE,
|
if (memcmp(&_lastOctreePayload + OCTREE_PACKET_EXTRA_HEADERS_SIZE,
|
||||||
_octreePacket->getPayload() + OCTREE_PACKET_EXTRA_HEADERS_SIZE,
|
_octreePacket->getPayload() + OCTREE_PACKET_EXTRA_HEADERS_SIZE,
|
||||||
_octreePacket->getPayloadSize() - OCTREE_PACKET_EXTRA_HEADERS_SIZE) == 0) {
|
_octreePacket->getPayloadSize() - OCTREE_PACKET_EXTRA_HEADERS_SIZE) == 0) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -173,7 +145,7 @@ void OctreeQueryNode::resetOctreePacket() {
|
||||||
// scene information, (e.g. the root node packet of a static scene), we can use this as a strategy for reducing
|
// scene information, (e.g. the root node packet of a static scene), we can use this as a strategy for reducing
|
||||||
// packet send rate.
|
// packet send rate.
|
||||||
_lastOctreePacketLength = _octreePacket->getPayloadSize();
|
_lastOctreePacketLength = _octreePacket->getPayloadSize();
|
||||||
memcpy(_lastOctreePayload, _octreePacket->getPayload(), _lastOctreePacketLength);
|
memcpy(&_lastOctreePayload, _octreePacket->getPayload(), _lastOctreePacketLength);
|
||||||
|
|
||||||
// If we're moving, and the client asked for low res, then we force monochrome, otherwise, use
|
// If we're moving, and the client asked for low res, then we force monochrome, otherwise, use
|
||||||
// the clients requested color state.
|
// the clients requested color state.
|
||||||
|
|
|
@ -29,7 +29,7 @@ class OctreeServer;
|
||||||
class OctreeQueryNode : public OctreeQuery {
|
class OctreeQueryNode : public OctreeQuery {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
OctreeQueryNode();
|
OctreeQueryNode() {}
|
||||||
virtual ~OctreeQueryNode();
|
virtual ~OctreeQueryNode();
|
||||||
|
|
||||||
void init(); // called after creation to set up some virtual items
|
void init(); // called after creation to set up some virtual items
|
||||||
|
@ -111,42 +111,43 @@ private:
|
||||||
OctreeQueryNode(const OctreeQueryNode &);
|
OctreeQueryNode(const OctreeQueryNode &);
|
||||||
OctreeQueryNode& operator= (const OctreeQueryNode&);
|
OctreeQueryNode& operator= (const OctreeQueryNode&);
|
||||||
|
|
||||||
bool _viewSent;
|
bool _viewSent { false };
|
||||||
std::unique_ptr<NLPacket> _octreePacket;
|
std::unique_ptr<NLPacket> _octreePacket;
|
||||||
bool _octreePacketWaiting;
|
bool _octreePacketWaiting;
|
||||||
|
|
||||||
char* _lastOctreePayload = nullptr;
|
unsigned int _lastOctreePacketLength { 0 };
|
||||||
unsigned int _lastOctreePacketLength;
|
int _duplicatePacketCount { 0 };
|
||||||
int _duplicatePacketCount;
|
quint64 _firstSuppressedPacket { usecTimestampNow() };
|
||||||
quint64 _firstSuppressedPacket;
|
|
||||||
|
|
||||||
int _maxSearchLevel;
|
int _maxSearchLevel { 1 };
|
||||||
int _maxLevelReachedInLastSearch;
|
int _maxLevelReachedInLastSearch { 1 };
|
||||||
ViewFrustum _currentViewFrustum;
|
ViewFrustum _currentViewFrustum;
|
||||||
ViewFrustum _lastKnownViewFrustum;
|
ViewFrustum _lastKnownViewFrustum;
|
||||||
quint64 _lastTimeBagEmpty;
|
quint64 _lastTimeBagEmpty { 0 };
|
||||||
bool _viewFrustumChanging;
|
bool _viewFrustumChanging { false };
|
||||||
bool _viewFrustumJustStoppedChanging;
|
bool _viewFrustumJustStoppedChanging { true };
|
||||||
|
|
||||||
OctreeSendThread* _octreeSendThread;
|
OctreeSendThread* _octreeSendThread { nullptr };
|
||||||
|
|
||||||
// watch for LOD changes
|
// watch for LOD changes
|
||||||
int _lastClientBoundaryLevelAdjust;
|
int _lastClientBoundaryLevelAdjust { 0 };
|
||||||
float _lastClientOctreeSizeScale;
|
float _lastClientOctreeSizeScale { DEFAULT_OCTREE_SIZE_SCALE };
|
||||||
bool _lodChanged;
|
bool _lodChanged { false };
|
||||||
bool _lodInitialized;
|
bool _lodInitialized { false };
|
||||||
|
|
||||||
OCTREE_PACKET_SEQUENCE _sequenceNumber;
|
OCTREE_PACKET_SEQUENCE _sequenceNumber { 0 };
|
||||||
|
|
||||||
quint64 _lastRootTimestamp;
|
quint64 _lastRootTimestamp { 0 };
|
||||||
|
|
||||||
PacketType _myPacketType;
|
PacketType _myPacketType { PacketType::Unknown };
|
||||||
bool _isShuttingDown;
|
bool _isShuttingDown { false };
|
||||||
|
|
||||||
SentPacketHistory _sentPacketHistory;
|
SentPacketHistory _sentPacketHistory;
|
||||||
QQueue<OCTREE_PACKET_SEQUENCE> _nackedSequenceNumbers;
|
QQueue<OCTREE_PACKET_SEQUENCE> _nackedSequenceNumbers;
|
||||||
|
|
||||||
quint64 _sceneSendStartTime = 0;
|
quint64 _sceneSendStartTime = 0;
|
||||||
|
|
||||||
|
std::array<char, udt::MAX_PACKET_SIZE> _lastOctreePayload;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_OctreeQueryNode_h
|
#endif // hifi_OctreeQueryNode_h
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include <udt/PacketHeaders.h>
|
#include <udt/PacketHeaders.h>
|
||||||
#include <PerfStat.h>
|
#include <PerfStat.h>
|
||||||
|
|
||||||
|
#include "OctreeQueryNode.h"
|
||||||
#include "OctreeSendThread.h"
|
#include "OctreeSendThread.h"
|
||||||
#include "OctreeServer.h"
|
#include "OctreeServer.h"
|
||||||
#include "OctreeServerConsts.h"
|
#include "OctreeServerConsts.h"
|
||||||
|
@ -25,10 +26,7 @@ quint64 endSceneSleepTime = 0;
|
||||||
OctreeSendThread::OctreeSendThread(OctreeServer* myServer, const SharedNodePointer& node) :
|
OctreeSendThread::OctreeSendThread(OctreeServer* myServer, const SharedNodePointer& node) :
|
||||||
_myServer(myServer),
|
_myServer(myServer),
|
||||||
_node(node),
|
_node(node),
|
||||||
_nodeUUID(node->getUUID()),
|
_nodeUUID(node->getUUID())
|
||||||
_packetData(),
|
|
||||||
_nodeMissingCount(0),
|
|
||||||
_isShuttingDown(false)
|
|
||||||
{
|
{
|
||||||
QString safeServerName("Octree");
|
QString safeServerName("Octree");
|
||||||
|
|
||||||
|
@ -46,6 +44,8 @@ OctreeSendThread::OctreeSendThread(OctreeServer* myServer, const SharedNodePoint
|
||||||
}
|
}
|
||||||
|
|
||||||
OctreeSendThread::~OctreeSendThread() {
|
OctreeSendThread::~OctreeSendThread() {
|
||||||
|
setIsShuttingDown();
|
||||||
|
|
||||||
QString safeServerName("Octree");
|
QString safeServerName("Octree");
|
||||||
if (_myServer) {
|
if (_myServer) {
|
||||||
safeServerName = _myServer->getMyServerName();
|
safeServerName = _myServer->getMyServerName();
|
||||||
|
|
|
@ -18,8 +18,7 @@
|
||||||
|
|
||||||
#include <GenericThread.h>
|
#include <GenericThread.h>
|
||||||
|
|
||||||
#include "OctreeQueryNode.h"
|
class OctreeQueryNode;
|
||||||
|
|
||||||
class OctreeServer;
|
class OctreeServer;
|
||||||
|
|
||||||
using AtomicUIntStat = std::atomic<uintmax_t>;
|
using AtomicUIntStat = std::atomic<uintmax_t>;
|
||||||
|
@ -48,17 +47,18 @@ protected:
|
||||||
virtual bool process();
|
virtual bool process();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OctreeServer* _myServer;
|
|
||||||
SharedNodePointer _node;
|
|
||||||
QUuid _nodeUUID;
|
|
||||||
|
|
||||||
int handlePacketSend(OctreeQueryNode* nodeData, int& trueBytesSent, int& truePacketsSent);
|
int handlePacketSend(OctreeQueryNode* nodeData, int& trueBytesSent, int& truePacketsSent);
|
||||||
int packetDistributor(OctreeQueryNode* nodeData, bool viewFrustumChanged);
|
int packetDistributor(OctreeQueryNode* nodeData, bool viewFrustumChanged);
|
||||||
|
|
||||||
|
|
||||||
|
OctreeServer* _myServer { nullptr };
|
||||||
|
SharedNodePointer _node;
|
||||||
|
QUuid _nodeUUID;
|
||||||
|
|
||||||
OctreePacketData _packetData;
|
OctreePacketData _packetData;
|
||||||
|
|
||||||
int _nodeMissingCount;
|
int _nodeMissingCount { 0 };
|
||||||
bool _isShuttingDown;
|
bool _isShuttingDown { false };
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_OctreeSendThread_h
|
#endif // hifi_OctreeSendThread_h
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
|
|
||||||
#include "../AssignmentClient.h"
|
#include "../AssignmentClient.h"
|
||||||
|
|
||||||
|
#include "OctreeQueryNode.h"
|
||||||
#include "OctreeServerConsts.h"
|
#include "OctreeServerConsts.h"
|
||||||
|
|
||||||
OctreeServer* OctreeServer::_instance = NULL;
|
OctreeServer* OctreeServer::_instance = NULL;
|
||||||
|
|
Loading…
Reference in a new issue