mirror of
https://github.com/lubosz/overte.git
synced 2025-04-24 06:53:59 +02:00
use SharedNodePointer in place of Node where appropriate
This commit is contained in:
parent
97a7369c76
commit
c1132726bf
21 changed files with 45 additions and 47 deletions
|
@ -88,7 +88,7 @@ void OctreeInboundPacketProcessor::processPacket(const SharedNodePointer& sendin
|
|||
int editDataBytesRead = _myServer->getOctree()->processEditPacketData(packetType,
|
||||
reinterpret_cast<const unsigned char*>(packet.data()),
|
||||
packet.size(),
|
||||
editData, maxSize, sendingNode.data());
|
||||
editData, maxSize, sendingNode);
|
||||
_myServer->getOctree()->unlock();
|
||||
quint64 endProcess = usecTimestampNow();
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ bool OctreeSendThread::process() {
|
|||
if (_myServer->wantsDebugSending() && _myServer->wantsVerboseDebug()) {
|
||||
printf("nodeData->updateCurrentViewFrustum() changed=%s\n", debug::valueOf(viewFrustumChanged));
|
||||
}
|
||||
packetsSent = packetDistributor(node.data(), nodeData, viewFrustumChanged);
|
||||
packetsSent = packetDistributor(node, nodeData, viewFrustumChanged);
|
||||
}
|
||||
|
||||
node->getMutex().unlock(); // we're done with this node for now.
|
||||
|
@ -86,7 +86,7 @@ quint64 OctreeSendThread::_totalBytes = 0;
|
|||
quint64 OctreeSendThread::_totalWastedBytes = 0;
|
||||
quint64 OctreeSendThread::_totalPackets = 0;
|
||||
|
||||
int OctreeSendThread::handlePacketSend(Node* node, OctreeQueryNode* nodeData, int& trueBytesSent, int& truePacketsSent) {
|
||||
int OctreeSendThread::handlePacketSend(const SharedNodePointer& node, OctreeQueryNode* nodeData, int& trueBytesSent, int& truePacketsSent) {
|
||||
bool debug = _myServer->wantsDebugSending();
|
||||
quint64 now = usecTimestampNow();
|
||||
|
||||
|
@ -212,7 +212,7 @@ int OctreeSendThread::handlePacketSend(Node* node, OctreeQueryNode* nodeData, in
|
|||
}
|
||||
|
||||
/// Version of voxel distributor that sends the deepest LOD level at once
|
||||
int OctreeSendThread::packetDistributor(Node* node, OctreeQueryNode* nodeData, bool viewFrustumChanged) {
|
||||
int OctreeSendThread::packetDistributor(const SharedNodePointer& node, OctreeQueryNode* nodeData, bool viewFrustumChanged) {
|
||||
bool forceDebugging = false;
|
||||
|
||||
int truePacketsSent = 0;
|
||||
|
|
|
@ -36,8 +36,8 @@ private:
|
|||
QUuid _nodeUUID;
|
||||
OctreeServer* _myServer;
|
||||
|
||||
int handlePacketSend(Node* node, OctreeQueryNode* nodeData, int& trueBytesSent, int& truePacketsSent);
|
||||
int packetDistributor(Node* node, OctreeQueryNode* nodeData, bool viewFrustumChanged);
|
||||
int handlePacketSend(const SharedNodePointer& node, OctreeQueryNode* nodeData, int& trueBytesSent, int& truePacketsSent);
|
||||
int packetDistributor(const SharedNodePointer& node, OctreeQueryNode* nodeData, bool viewFrustumChanged);
|
||||
|
||||
OctreePacketData _packetData;
|
||||
};
|
||||
|
|
|
@ -58,8 +58,8 @@ public:
|
|||
|
||||
// subclass may implement these method
|
||||
virtual void beforeRun() { };
|
||||
virtual bool hasSpecialPacketToSend(Node* node) { return false; }
|
||||
virtual int sendSpecialPacket(Node* node) { return 0; }
|
||||
virtual bool hasSpecialPacketToSend(const SharedNodePointer& node) { return false; }
|
||||
virtual int sendSpecialPacket(const SharedNodePointer& node) { return 0; }
|
||||
|
||||
static void attachQueryNodeToNode(Node* newNode);
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ void ParticleServer::beforeRun() {
|
|||
pruneDeletedParticlesTimer->start(PRUNE_DELETED_PARTICLES_INTERVAL_MSECS);
|
||||
}
|
||||
|
||||
void ParticleServer::particleCreated(const Particle& newParticle, Node* node) {
|
||||
void ParticleServer::particleCreated(const Particle& newParticle, const SharedNodePointer& senderNode) {
|
||||
unsigned char outputBuffer[MAX_PACKET_SIZE];
|
||||
unsigned char* copyAt = outputBuffer;
|
||||
|
||||
|
@ -63,12 +63,12 @@ void ParticleServer::particleCreated(const Particle& newParticle, Node* node) {
|
|||
copyAt += sizeof(particleID);
|
||||
packetLength += sizeof(particleID);
|
||||
|
||||
NodeList::getInstance()->writeDatagram((char*) outputBuffer, packetLength, SharedNodePointer(node));
|
||||
NodeList::getInstance()->writeDatagram((char*) outputBuffer, packetLength, senderNode);
|
||||
}
|
||||
|
||||
|
||||
// ParticleServer will use the "special packets" to send list of recently deleted particles
|
||||
bool ParticleServer::hasSpecialPacketToSend(Node* node) {
|
||||
bool ParticleServer::hasSpecialPacketToSend(const SharedNodePointer& node) {
|
||||
bool shouldSendDeletedParticles = false;
|
||||
|
||||
// check to see if any new particles have been added since we last sent to this node...
|
||||
|
@ -83,7 +83,7 @@ bool ParticleServer::hasSpecialPacketToSend(Node* node) {
|
|||
return shouldSendDeletedParticles;
|
||||
}
|
||||
|
||||
int ParticleServer::sendSpecialPacket(Node* node) {
|
||||
int ParticleServer::sendSpecialPacket(const SharedNodePointer& node) {
|
||||
unsigned char outputBuffer[MAX_PACKET_SIZE];
|
||||
size_t packetLength = 0;
|
||||
|
||||
|
|
|
@ -34,10 +34,10 @@ public:
|
|||
|
||||
// subclass may implement these method
|
||||
virtual void beforeRun();
|
||||
virtual bool hasSpecialPacketToSend(Node* node);
|
||||
virtual int sendSpecialPacket(Node* node);
|
||||
virtual bool hasSpecialPacketToSend(const SharedNodePointer& node);
|
||||
virtual int sendSpecialPacket(const SharedNodePointer& node);
|
||||
|
||||
virtual void particleCreated(const Particle& newParticle, Node* senderNode);
|
||||
virtual void particleCreated(const Particle& newParticle, const SharedNodePointer& senderNode);
|
||||
|
||||
public slots:
|
||||
void pruneDeletedParticles();
|
||||
|
|
|
@ -32,12 +32,12 @@ Octree* VoxelServer::createTree() {
|
|||
return new VoxelTree(true);
|
||||
}
|
||||
|
||||
bool VoxelServer::hasSpecialPacketToSend(Node* node) {
|
||||
bool VoxelServer::hasSpecialPacketToSend(const SharedNodePointer& node) {
|
||||
bool shouldSendEnvironments = _sendEnvironments && shouldDo(ENVIRONMENT_SEND_INTERVAL_USECS, OCTREE_SEND_INTERVAL_USECS);
|
||||
return shouldSendEnvironments;
|
||||
}
|
||||
|
||||
int VoxelServer::sendSpecialPacket(Node* node) {
|
||||
int VoxelServer::sendSpecialPacket(const SharedNodePointer& node) {
|
||||
int numBytesPacketHeader = populatePacketHeader(reinterpret_cast<char*>(_tempOutputBuffer), PacketTypeEnvironmentData);
|
||||
int envPacketLength = numBytesPacketHeader;
|
||||
int environmentsToSend = getSendMinimalEnvironment() ? 1 : getEnvironmentDataCount();
|
||||
|
|
|
@ -43,8 +43,8 @@ public:
|
|||
|
||||
// subclass may implement these method
|
||||
virtual void beforeRun();
|
||||
virtual bool hasSpecialPacketToSend(Node* node);
|
||||
virtual int sendSpecialPacket(Node* node);
|
||||
virtual bool hasSpecialPacketToSend(const SharedNodePointer& node);
|
||||
virtual int sendSpecialPacket(const SharedNodePointer& node);
|
||||
|
||||
|
||||
private:
|
||||
|
|
|
@ -123,7 +123,6 @@ void ParticleTreeRenderer::renderElement(OctreeElement* element, RenderArgs* arg
|
|||
}
|
||||
}
|
||||
|
||||
void ParticleTreeRenderer::processEraseMessage(const QByteArray& dataByteArray, const HifiSockAddr& senderSockAddr,
|
||||
Node* sourceNode) {
|
||||
static_cast<ParticleTree*>(_tree)->processEraseMessage(dataByteArray, senderSockAddr, sourceNode);
|
||||
void ParticleTreeRenderer::processEraseMessage(const QByteArray& dataByteArray, const SharedNodePointer& sourceNode) {
|
||||
static_cast<ParticleTree*>(_tree)->processEraseMessage(dataByteArray, sourceNode);
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ public:
|
|||
|
||||
ParticleTree* getTree() { return (ParticleTree*)_tree; }
|
||||
|
||||
void processEraseMessage(const QByteArray& dataByteArray, const HifiSockAddr& senderSockAddr, Node* sourceNode);
|
||||
void processEraseMessage(const QByteArray& dataByteArray, const SharedNodePointer& sourceNode);
|
||||
|
||||
virtual void init();
|
||||
virtual void render();
|
||||
|
|
|
@ -66,11 +66,11 @@ void VoxelPacketProcessor::processPacket(const SharedNodePointer& sendingNode, c
|
|||
|
||||
switch(voxelPacketType) {
|
||||
case PacketTypeParticleErase: {
|
||||
app->_particles.processEraseMessage(mutablePacket, *sendingNode->getActiveSocket(), sendingNode.data());
|
||||
app->_particles.processEraseMessage(mutablePacket, sendingNode);
|
||||
} break;
|
||||
|
||||
case PacketTypeParticleData: {
|
||||
app->_particles.processDatagram(mutablePacket, *sendingNode->getActiveSocket(), sendingNode.data());
|
||||
app->_particles.processDatagram(mutablePacket, sendingNode);
|
||||
} break;
|
||||
|
||||
case PacketTypeEnvironmentData: {
|
||||
|
|
|
@ -1347,7 +1347,7 @@ bool Octree::readFromSVOFile(const char* fileName) {
|
|||
fileOk = true; // assume the file is ok
|
||||
}
|
||||
if (fileOk) {
|
||||
ReadBitstreamToTreeParams args(WANT_COLOR, NO_EXISTS_BITS, NULL, 0, NULL, wantImportProgress);
|
||||
ReadBitstreamToTreeParams args(WANT_COLOR, NO_EXISTS_BITS, NULL, 0, SharedNodePointer(), wantImportProgress);
|
||||
readBitstreamToTree(dataAt, dataLength, args);
|
||||
}
|
||||
delete[] entireFile;
|
||||
|
@ -1485,7 +1485,7 @@ void Octree::copyFromTreeIntoSubTree(Octree* sourceTree, OctreeElement* destinat
|
|||
|
||||
// ask destination tree to read the bitstream
|
||||
bool wantImportProgress = true;
|
||||
ReadBitstreamToTreeParams args(WANT_COLOR, NO_EXISTS_BITS, destinationNode, 0, NULL, wantImportProgress);
|
||||
ReadBitstreamToTreeParams args(WANT_COLOR, NO_EXISTS_BITS, destinationNode, 0, SharedNodePointer(), wantImportProgress);
|
||||
readBitstreamToTree(packetData.getUncompressedData(), packetData.getUncompressedSize(), args);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -156,7 +156,7 @@ public:
|
|||
bool includeExistsBits;
|
||||
OctreeElement* destinationNode;
|
||||
QUuid sourceUUID;
|
||||
Node* sourceNode;
|
||||
SharedNodePointer sourceNode;
|
||||
bool wantImportProgress;
|
||||
|
||||
ReadBitstreamToTreeParams(
|
||||
|
@ -164,7 +164,7 @@ public:
|
|||
bool includeExistsBits = WANT_EXISTS_BITS,
|
||||
OctreeElement* destinationNode = NULL,
|
||||
QUuid sourceUUID = QUuid(),
|
||||
Node* sourceNode = NULL,
|
||||
SharedNodePointer sourceNode = SharedNodePointer(),
|
||||
bool wantImportProgress = false) :
|
||||
includeColor(includeColor),
|
||||
includeExistsBits(includeExistsBits),
|
||||
|
@ -190,7 +190,7 @@ public:
|
|||
virtual PacketType expectedDataPacketType() const { return PacketTypeUnknown; }
|
||||
virtual bool handlesEditPacketType(PacketType packetType) const { return false; }
|
||||
virtual int processEditPacketData(PacketType packetType, const unsigned char* packetData, int packetLength,
|
||||
const unsigned char* editData, int maxLength, Node* senderNode) { return 0; }
|
||||
const unsigned char* editData, int maxLength, const SharedNodePointer& sourceNode) { return 0; }
|
||||
|
||||
|
||||
virtual void update() { }; // nothing to do by default
|
||||
|
|
|
@ -26,7 +26,7 @@ void OctreeRenderer::init() {
|
|||
OctreeRenderer::~OctreeRenderer() {
|
||||
}
|
||||
|
||||
void OctreeRenderer::processDatagram(const QByteArray& dataByteArray, const HifiSockAddr& senderSockAddr, Node* sourceNode) {
|
||||
void OctreeRenderer::processDatagram(const QByteArray& dataByteArray, const SharedNodePointer& sourceNode) {
|
||||
bool showTimingDetails = false; // Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
|
||||
bool extraDebugging = false; // Menu::getInstance()->isOptionChecked(MenuOption::ExtraDebugging)
|
||||
PerformanceWarning warn(showTimingDetails, "OctreeRenderer::processDatagram()",showTimingDetails);
|
||||
|
|
|
@ -43,7 +43,7 @@ public:
|
|||
virtual void renderElement(OctreeElement* element, RenderArgs* args) = 0;
|
||||
|
||||
/// process incoming data
|
||||
virtual void processDatagram(const QByteArray& dataByteArray, const HifiSockAddr& senderSockAddr, Node* sourceNode);
|
||||
virtual void processDatagram(const QByteArray& dataByteArray, const SharedNodePointer& sourceNode);
|
||||
|
||||
/// initialize and GPU/rendering related resources
|
||||
virtual void init();
|
||||
|
|
|
@ -90,7 +90,7 @@ bool ParticleTree::findAndUpdateOperation(OctreeElement* element, void* extraDat
|
|||
return true;
|
||||
}
|
||||
|
||||
void ParticleTree::storeParticle(const Particle& particle, Node* senderNode) {
|
||||
void ParticleTree::storeParticle(const Particle& particle, const SharedNodePointer& senderNode) {
|
||||
// First, look for the existing particle in the tree..
|
||||
FindAndUpdateParticleArgs args = { particle, false };
|
||||
recurseTreeWithOperation(findAndUpdateOperation, &args);
|
||||
|
@ -101,7 +101,7 @@ void ParticleTree::storeParticle(const Particle& particle, Node* senderNode) {
|
|||
float size = std::max(MINIMUM_PARTICLE_ELEMENT_SIZE, particle.getRadius());
|
||||
ParticleTreeElement* element = (ParticleTreeElement*)getOrCreateChildElementAt(position.x, position.y, position.z, size);
|
||||
|
||||
element->storeParticle(particle, senderNode);
|
||||
element->storeParticle(particle);
|
||||
}
|
||||
// what else do we need to do here to get reaveraging to work
|
||||
_isDirty = true;
|
||||
|
@ -386,7 +386,7 @@ const Particle* ParticleTree::findParticleByID(uint32_t id, bool alreadyLocked)
|
|||
|
||||
|
||||
int ParticleTree::processEditPacketData(PacketType packetType, const unsigned char* packetData, int packetLength,
|
||||
const unsigned char* editData, int maxLength, Node* senderNode) {
|
||||
const unsigned char* editData, int maxLength, const SharedNodePointer& senderNode) {
|
||||
|
||||
int processedBytes = 0;
|
||||
// we handle these types of "edit" packets
|
||||
|
@ -415,7 +415,7 @@ int ParticleTree::processEditPacketData(PacketType packetType, const unsigned ch
|
|||
return processedBytes;
|
||||
}
|
||||
|
||||
void ParticleTree::notifyNewlyCreatedParticle(const Particle& newParticle, Node* senderNode) {
|
||||
void ParticleTree::notifyNewlyCreatedParticle(const Particle& newParticle, const SharedNodePointer& senderNode) {
|
||||
_newlyCreatedHooksLock.lockForRead();
|
||||
for (size_t i = 0; i < _newlyCreatedHooks.size(); i++) {
|
||||
_newlyCreatedHooks[i]->particleCreated(newParticle, senderNode);
|
||||
|
@ -596,8 +596,7 @@ void ParticleTree::forgetParticlesDeletedBefore(quint64 sinceTime) {
|
|||
}
|
||||
|
||||
|
||||
void ParticleTree::processEraseMessage(const QByteArray& dataByteArray, const HifiSockAddr& senderSockAddr,
|
||||
Node* sourceNode) {
|
||||
void ParticleTree::processEraseMessage(const QByteArray& dataByteArray, const SharedNodePointer& sourceNode) {
|
||||
|
||||
const unsigned char* packetData = (const unsigned char*)dataByteArray.constData();
|
||||
const unsigned char* dataAt = packetData;
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
class NewlyCreatedParticleHook {
|
||||
public:
|
||||
virtual void particleCreated(const Particle& newParticle, Node* senderNode) = 0;
|
||||
virtual void particleCreated(const Particle& newParticle, const SharedNodePointer& senderNode) = 0;
|
||||
};
|
||||
|
||||
class ParticleTree : public Octree {
|
||||
|
@ -35,11 +35,11 @@ public:
|
|||
virtual PacketType expectedDataPacketType() const { return PacketTypeParticleData; }
|
||||
virtual bool handlesEditPacketType(PacketType packetType) const;
|
||||
virtual int processEditPacketData(PacketType packetType, const unsigned char* packetData, int packetLength,
|
||||
const unsigned char* editData, int maxLength, Node* senderNode);
|
||||
const unsigned char* editData, int maxLength, const SharedNodePointer& senderNode);
|
||||
|
||||
virtual void update();
|
||||
|
||||
void storeParticle(const Particle& particle, Node* senderNode = NULL);
|
||||
void storeParticle(const Particle& particle, const SharedNodePointer& senderNode = SharedNodePointer());
|
||||
void updateParticle(const ParticleID& particleID, const ParticleProperties& properties);
|
||||
void addParticle(const ParticleID& particleID, const ParticleProperties& properties);
|
||||
void deleteParticle(const ParticleID& particleID);
|
||||
|
@ -67,7 +67,7 @@ public:
|
|||
bool encodeParticlesDeletedSince(quint64& sinceTime, unsigned char* packetData, size_t maxLength, size_t& outputLength);
|
||||
void forgetParticlesDeletedBefore(quint64 sinceTime);
|
||||
|
||||
void processEraseMessage(const QByteArray& dataByteArray, const HifiSockAddr& senderSockAddr, Node* sourceNode);
|
||||
void processEraseMessage(const QByteArray& dataByteArray, const SharedNodePointer& sourceNode);
|
||||
void handleAddParticleResponse(const QByteArray& packet);
|
||||
|
||||
private:
|
||||
|
@ -82,7 +82,7 @@ private:
|
|||
static bool findAndDeleteOperation(OctreeElement* element, void* extraData);
|
||||
static bool findAndUpdateParticleIDOperation(OctreeElement* element, void* extraData);
|
||||
|
||||
void notifyNewlyCreatedParticle(const Particle& newParticle, Node* senderNode);
|
||||
void notifyNewlyCreatedParticle(const Particle& newParticle, const SharedNodePointer& senderNode);
|
||||
|
||||
QReadWriteLock _newlyCreatedHooksLock;
|
||||
std::vector<NewlyCreatedParticleHook*> _newlyCreatedHooks;
|
||||
|
|
|
@ -332,7 +332,7 @@ bool ParticleTreeElement::collapseChildren() {
|
|||
}
|
||||
|
||||
|
||||
void ParticleTreeElement::storeParticle(const Particle& particle, Node* senderNode) {
|
||||
void ParticleTreeElement::storeParticle(const Particle& particle) {
|
||||
_particles->push_back(particle);
|
||||
markWithChangedTime();
|
||||
}
|
||||
|
|
|
@ -121,7 +121,7 @@ public:
|
|||
protected:
|
||||
virtual void init(unsigned char * octalCode);
|
||||
|
||||
void storeParticle(const Particle& particle, Node* senderNode = NULL);
|
||||
void storeParticle(const Particle& particle);
|
||||
|
||||
ParticleTree* _myTree;
|
||||
QList<Particle>* _particles;
|
||||
|
|
|
@ -522,7 +522,7 @@ bool VoxelTree::handlesEditPacketType(PacketType packetType) const {
|
|||
}
|
||||
|
||||
int VoxelTree::processEditPacketData(PacketType packetType, const unsigned char* packetData, int packetLength,
|
||||
const unsigned char* editData, int maxLength, Node* senderNode) {
|
||||
const unsigned char* editData, int maxLength, const SharedNodePointer& node) {
|
||||
|
||||
// we handle these types of "edit" packets
|
||||
switch (packetType) {
|
||||
|
|
|
@ -54,7 +54,7 @@ public:
|
|||
virtual PacketType expectedDataPacketType() const { return PacketTypeVoxelData; }
|
||||
virtual bool handlesEditPacketType(PacketType packetType) const;
|
||||
virtual int processEditPacketData(PacketType packetType, const unsigned char* packetData, int packetLength,
|
||||
const unsigned char* editData, int maxLength, Node* senderNode);
|
||||
const unsigned char* editData, int maxLength, const SharedNodePointer& node);
|
||||
void processSetVoxelsBitstream(const unsigned char* bitstream, int bufferSizeBytes);
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue