Bit of cleanup

This commit is contained in:
Atlante45 2015-12-14 11:57:52 -08:00
parent 0c1ae5bb61
commit bd7fa266cf
5 changed files with 37 additions and 63 deletions

View file

@ -20,39 +20,11 @@
#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() {
_isShuttingDown = true;
if (_octreeSendThread) {
forceNodeShutdown();
}
delete[] _lastOctreePayload;
}
void OctreeQueryNode::nodeKilled() {
@ -105,7 +77,7 @@ bool OctreeQueryNode::packetIsDuplicate() const {
// of the entire packet, we need to compare only the packet content...
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->getPayloadSize() - OCTREE_PACKET_EXTRA_HEADERS_SIZE) == 0) {
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
// packet send rate.
_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
// the clients requested color state.

View file

@ -29,7 +29,7 @@ class OctreeServer;
class OctreeQueryNode : public OctreeQuery {
Q_OBJECT
public:
OctreeQueryNode();
OctreeQueryNode() {}
virtual ~OctreeQueryNode();
void init(); // called after creation to set up some virtual items
@ -110,43 +110,44 @@ private slots:
private:
OctreeQueryNode(const OctreeQueryNode &);
OctreeQueryNode& operator= (const OctreeQueryNode&);
bool _viewSent;
bool _viewSent { false };
std::unique_ptr<NLPacket> _octreePacket;
bool _octreePacketWaiting;
char* _lastOctreePayload = nullptr;
unsigned int _lastOctreePacketLength;
int _duplicatePacketCount;
quint64 _firstSuppressedPacket;
unsigned int _lastOctreePacketLength { 0 };
int _duplicatePacketCount { 0 };
quint64 _firstSuppressedPacket { usecTimestampNow() };
int _maxSearchLevel;
int _maxLevelReachedInLastSearch;
int _maxSearchLevel { 1 };
int _maxLevelReachedInLastSearch { 1 };
ViewFrustum _currentViewFrustum;
ViewFrustum _lastKnownViewFrustum;
quint64 _lastTimeBagEmpty;
bool _viewFrustumChanging;
bool _viewFrustumJustStoppedChanging;
quint64 _lastTimeBagEmpty { 0 };
bool _viewFrustumChanging { false };
bool _viewFrustumJustStoppedChanging { true };
OctreeSendThread* _octreeSendThread;
OctreeSendThread* _octreeSendThread { nullptr };
// watch for LOD changes
int _lastClientBoundaryLevelAdjust;
float _lastClientOctreeSizeScale;
bool _lodChanged;
bool _lodInitialized;
int _lastClientBoundaryLevelAdjust { 0 };
float _lastClientOctreeSizeScale { DEFAULT_OCTREE_SIZE_SCALE };
bool _lodChanged { false };
bool _lodInitialized { false };
OCTREE_PACKET_SEQUENCE _sequenceNumber;
OCTREE_PACKET_SEQUENCE _sequenceNumber { 0 };
quint64 _lastRootTimestamp;
quint64 _lastRootTimestamp { 0 };
PacketType _myPacketType;
bool _isShuttingDown;
PacketType _myPacketType { PacketType::Unknown };
bool _isShuttingDown { false };
SentPacketHistory _sentPacketHistory;
QQueue<OCTREE_PACKET_SEQUENCE> _nackedSequenceNumbers;
quint64 _sceneSendStartTime = 0;
std::array<char, udt::MAX_PACKET_SIZE> _lastOctreePayload;
};
#endif // hifi_OctreeQueryNode_h

View file

@ -14,6 +14,7 @@
#include <udt/PacketHeaders.h>
#include <PerfStat.h>
#include "OctreeQueryNode.h"
#include "OctreeSendThread.h"
#include "OctreeServer.h"
#include "OctreeServerConsts.h"
@ -25,10 +26,7 @@ quint64 endSceneSleepTime = 0;
OctreeSendThread::OctreeSendThread(OctreeServer* myServer, const SharedNodePointer& node) :
_myServer(myServer),
_node(node),
_nodeUUID(node->getUUID()),
_packetData(),
_nodeMissingCount(0),
_isShuttingDown(false)
_nodeUUID(node->getUUID())
{
QString safeServerName("Octree");
@ -46,6 +44,8 @@ OctreeSendThread::OctreeSendThread(OctreeServer* myServer, const SharedNodePoint
}
OctreeSendThread::~OctreeSendThread() {
setIsShuttingDown();
QString safeServerName("Octree");
if (_myServer) {
safeServerName = _myServer->getMyServerName();

View file

@ -18,8 +18,7 @@
#include <GenericThread.h>
#include "OctreeQueryNode.h"
class OctreeQueryNode;
class OctreeServer;
using AtomicUIntStat = std::atomic<uintmax_t>;
@ -48,17 +47,18 @@ protected:
virtual bool process();
private:
OctreeServer* _myServer;
int handlePacketSend(OctreeQueryNode* nodeData, int& trueBytesSent, int& truePacketsSent);
int packetDistributor(OctreeQueryNode* nodeData, bool viewFrustumChanged);
OctreeServer* _myServer { nullptr };
SharedNodePointer _node;
QUuid _nodeUUID;
int handlePacketSend(OctreeQueryNode* nodeData, int& trueBytesSent, int& truePacketsSent);
int packetDistributor(OctreeQueryNode* nodeData, bool viewFrustumChanged);
OctreePacketData _packetData;
int _nodeMissingCount;
bool _isShuttingDown;
int _nodeMissingCount { 0 };
bool _isShuttingDown { false };
};
#endif // hifi_OctreeSendThread_h

View file

@ -25,6 +25,7 @@
#include "../AssignmentClient.h"
#include "OctreeQueryNode.h"
#include "OctreeServerConsts.h"
OctreeServer* OctreeServer::_instance = NULL;