mirror of
https://github.com/JulianGro/overte.git
synced 2025-06-04 02:20:20 +02:00
change NodeList container to QHash with QSharedPointer
This commit is contained in:
parent
0e25c85eef
commit
7d1a64ca8c
35 changed files with 355 additions and 737 deletions
|
@ -182,15 +182,13 @@ void AudioMixer::addBufferToMixForListeningNodeWithBuffer(PositionalAudioRingBuf
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioMixer::prepareMixForListeningNode(Node* node) {
|
void AudioMixer::prepareMixForListeningNode(Node* node) {
|
||||||
NodeList* nodeList = NodeList::getInstance();
|
|
||||||
|
|
||||||
AvatarAudioRingBuffer* nodeRingBuffer = ((AudioMixerClientData*) node->getLinkedData())->getAvatarAudioRingBuffer();
|
AvatarAudioRingBuffer* nodeRingBuffer = ((AudioMixerClientData*) node->getLinkedData())->getAvatarAudioRingBuffer();
|
||||||
|
|
||||||
// zero out the client mix for this node
|
// zero out the client mix for this node
|
||||||
memset(_clientSamples, 0, sizeof(_clientSamples));
|
memset(_clientSamples, 0, sizeof(_clientSamples));
|
||||||
|
|
||||||
// loop through all other nodes that have sufficient audio to mix
|
// loop through all other nodes that have sufficient audio to mix
|
||||||
for (NodeList::iterator otherNode = nodeList->begin(); otherNode != nodeList->end(); otherNode++) {
|
foreach(SharedNodePointer otherNode, NodeList::getInstance()->getNodeHash()) {
|
||||||
if (otherNode->getLinkedData()) {
|
if (otherNode->getLinkedData()) {
|
||||||
|
|
||||||
AudioMixerClientData* otherNodeClientData = (AudioMixerClientData*) otherNode->getLinkedData();
|
AudioMixerClientData* otherNodeClientData = (AudioMixerClientData*) otherNode->getLinkedData();
|
||||||
|
@ -220,10 +218,10 @@ void AudioMixer::processDatagram(const QByteArray& dataByteArray, const HifiSock
|
||||||
|
|
||||||
NodeList* nodeList = NodeList::getInstance();
|
NodeList* nodeList = NodeList::getInstance();
|
||||||
|
|
||||||
Node* matchingNode = nodeList->nodeWithUUID(nodeUUID);
|
SharedNodePointer matchingNode = nodeList->nodeWithUUID(nodeUUID);
|
||||||
|
|
||||||
if (matchingNode) {
|
if (matchingNode) {
|
||||||
nodeList->updateNodeWithData(matchingNode, senderSockAddr, (unsigned char*) dataByteArray.data(), dataByteArray.size());
|
nodeList->updateNodeWithData(matchingNode.data(), senderSockAddr, (unsigned char*) dataByteArray.data(), dataByteArray.size());
|
||||||
|
|
||||||
if (!matchingNode->getActiveSocket()) {
|
if (!matchingNode->getActiveSocket()) {
|
||||||
// we don't have an active socket for this node, but they're talking to us
|
// we don't have an active socket for this node, but they're talking to us
|
||||||
|
@ -265,13 +263,13 @@ void AudioMixer::run() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
|
foreach(SharedNodePointer node, nodeList->getNodeHash()) {
|
||||||
if (node->getLinkedData()) {
|
if (node->getLinkedData()) {
|
||||||
((AudioMixerClientData*) node->getLinkedData())->checkBuffersBeforeFrameSend(JITTER_BUFFER_SAMPLES);
|
((AudioMixerClientData*) node->getLinkedData())->checkBuffersBeforeFrameSend(JITTER_BUFFER_SAMPLES);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
|
foreach(SharedNodePointer node, nodeList->getNodeHash()) {
|
||||||
if (node->getType() == NODE_TYPE_AGENT && node->getActiveSocket() && node->getLinkedData()
|
if (node->getType() == NODE_TYPE_AGENT && node->getActiveSocket() && node->getLinkedData()
|
||||||
&& ((AudioMixerClientData*) node->getLinkedData())->getAvatarAudioRingBuffer()) {
|
&& ((AudioMixerClientData*) node->getLinkedData())->getAvatarAudioRingBuffer()) {
|
||||||
prepareMixForListeningNode(&(*node));
|
prepareMixForListeningNode(&(*node));
|
||||||
|
@ -284,12 +282,13 @@ void AudioMixer::run() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// push forward the next output pointers for any audio buffers we used
|
// push forward the next output pointers for any audio buffers we used
|
||||||
for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
|
foreach(SharedNodePointer node, nodeList->getNodeHash()) {
|
||||||
if (node->getLinkedData()) {
|
if (node->getLinkedData()) {
|
||||||
((AudioMixerClientData*) node->getLinkedData())->pushBuffersAfterFrameSend();
|
((AudioMixerClientData*) node->getLinkedData())->pushBuffersAfterFrameSend();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int usecToSleep = usecTimestamp(&startTime) + (++nextFrame * BUFFER_SEND_INTERVAL_USECS) - usecTimestampNow();
|
int usecToSleep = usecTimestamp(&startTime) + (++nextFrame * BUFFER_SEND_INTERVAL_USECS) - usecTimestampNow();
|
||||||
|
|
||||||
if (usecToSleep > 0) {
|
if (usecToSleep > 0) {
|
||||||
|
|
|
@ -67,7 +67,7 @@ void broadcastAvatarData() {
|
||||||
|
|
||||||
NodeList* nodeList = NodeList::getInstance();
|
NodeList* nodeList = NodeList::getInstance();
|
||||||
|
|
||||||
for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
|
foreach(SharedNodePointer node, nodeList->getNodeHash()) {
|
||||||
if (node->getLinkedData() && node->getType() == NODE_TYPE_AGENT && node->getActiveSocket()) {
|
if (node->getLinkedData() && node->getType() == NODE_TYPE_AGENT && node->getActiveSocket()) {
|
||||||
|
|
||||||
// reset packet pointers for this node
|
// reset packet pointers for this node
|
||||||
|
@ -76,7 +76,7 @@ void broadcastAvatarData() {
|
||||||
|
|
||||||
// this is an AGENT we have received head data from
|
// this is an AGENT we have received head data from
|
||||||
// send back a packet with other active node data to this node
|
// send back a packet with other active node data to this node
|
||||||
for (NodeList::iterator otherNode = nodeList->begin(); otherNode != nodeList->end(); otherNode++) {
|
foreach(SharedNodePointer otherNode, nodeList->getNodeHash()) {
|
||||||
if (otherNode->getLinkedData() && otherNode->getUUID() != node->getUUID()) {
|
if (otherNode->getLinkedData() && otherNode->getUUID() != node->getUUID()) {
|
||||||
|
|
||||||
unsigned char* avatarDataEndpoint = addNodeToBroadcastPacket((unsigned char*)&avatarDataBuffer[0],
|
unsigned char* avatarDataEndpoint = addNodeToBroadcastPacket((unsigned char*)&avatarDataBuffer[0],
|
||||||
|
@ -109,13 +109,11 @@ void broadcastAvatarData() {
|
||||||
|
|
||||||
packetsSent++;
|
packetsSent++;
|
||||||
//printf("packetsSent=%d packetLength=%d\n", packetsSent, packetLength);
|
//printf("packetsSent=%d packetLength=%d\n", packetsSent, packetLength);
|
||||||
NodeList::getInstance()->getNodeSocket().writeDatagram((char*) broadcastPacket, currentBufferPosition - broadcastPacket,
|
nodeList->getNodeSocket().writeDatagram((char*) broadcastPacket, currentBufferPosition - broadcastPacket,
|
||||||
node->getActiveSocket()->getAddress(),
|
node->getActiveSocket()->getAddress(),
|
||||||
node->getActiveSocket()->getPort());
|
node->getActiveSocket()->getPort());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AvatarMixer::processDatagram(const QByteArray& dataByteArray, const HifiSockAddr& senderSockAddr) {
|
void AvatarMixer::processDatagram(const QByteArray& dataByteArray, const HifiSockAddr& senderSockAddr) {
|
||||||
|
@ -128,11 +126,11 @@ void AvatarMixer::processDatagram(const QByteArray& dataByteArray, const HifiSoc
|
||||||
NUM_BYTES_RFC4122_UUID));
|
NUM_BYTES_RFC4122_UUID));
|
||||||
|
|
||||||
// add or update the node in our list
|
// add or update the node in our list
|
||||||
Node* avatarNode = nodeList->nodeWithUUID(nodeUUID);
|
SharedNodePointer avatarNode = nodeList->nodeWithUUID(nodeUUID);
|
||||||
|
|
||||||
if (avatarNode) {
|
if (avatarNode) {
|
||||||
// parse positional data from an node
|
// parse positional data from an node
|
||||||
nodeList->updateNodeWithData(avatarNode, senderSockAddr,
|
nodeList->updateNodeWithData(avatarNode.data(), senderSockAddr,
|
||||||
(unsigned char*) dataByteArray.data(), dataByteArray.size());
|
(unsigned char*) dataByteArray.data(), dataByteArray.size());
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
|
@ -144,7 +142,7 @@ void AvatarMixer::processDatagram(const QByteArray& dataByteArray, const HifiSoc
|
||||||
QUuid nodeUUID = QUuid::fromRfc4122(dataByteArray.mid(numBytesForPacketHeader((unsigned char*) dataByteArray.data()),
|
QUuid nodeUUID = QUuid::fromRfc4122(dataByteArray.mid(numBytesForPacketHeader((unsigned char*) dataByteArray.data()),
|
||||||
NUM_BYTES_RFC4122_UUID));
|
NUM_BYTES_RFC4122_UUID));
|
||||||
// let everyone else know about the update
|
// let everyone else know about the update
|
||||||
for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
|
foreach(SharedNodePointer node, nodeList->getNodeHash()) {
|
||||||
if (node->getActiveSocket() && node->getUUID() != nodeUUID) {
|
if (node->getActiveSocket() && node->getUUID() != nodeUUID) {
|
||||||
nodeList->getNodeSocket().writeDatagram(dataByteArray,
|
nodeList->getNodeSocket().writeDatagram(dataByteArray,
|
||||||
node->getActiveSocket()->getAddress(),
|
node->getActiveSocket()->getAddress(),
|
||||||
|
|
|
@ -77,7 +77,7 @@ DomainServer::DomainServer(int argc, char* argv[]) :
|
||||||
// Start the web server.
|
// Start the web server.
|
||||||
mg_start(&callbacks, NULL, options);
|
mg_start(&callbacks, NULL, options);
|
||||||
|
|
||||||
nodeList->addHook(this);
|
connect(nodeList, SIGNAL(nodeKilled(SharedNodePointer)), SLOT(nodeKilled(SharedNodePointer)));
|
||||||
|
|
||||||
if (!_staticAssignmentFile.exists() || _voxelServerConfig) {
|
if (!_staticAssignmentFile.exists() || _voxelServerConfig) {
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ void DomainServer::readAvailableDatagrams() {
|
||||||
nodeLocalAddress,
|
nodeLocalAddress,
|
||||||
nodeUUID)))
|
nodeUUID)))
|
||||||
{
|
{
|
||||||
Node* checkInNode = nodeList->addOrUpdateNode(nodeUUID,
|
SharedNodePointer checkInNode = nodeList->addOrUpdateNode(nodeUUID,
|
||||||
nodeType,
|
nodeType,
|
||||||
nodePublicAddress,
|
nodePublicAddress,
|
||||||
nodeLocalAddress);
|
nodeLocalAddress);
|
||||||
|
@ -201,7 +201,7 @@ void DomainServer::readAvailableDatagrams() {
|
||||||
|
|
||||||
if (numInterestTypes > 0) {
|
if (numInterestTypes > 0) {
|
||||||
// if the node has sent no types of interest, assume they want nothing but their own ID back
|
// if the node has sent no types of interest, assume they want nothing but their own ID back
|
||||||
for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
|
foreach(SharedNodePointer node, nodeList->getNodeHash()) {
|
||||||
if (node->getUUID() != nodeUUID &&
|
if (node->getUUID() != nodeUUID &&
|
||||||
memchr(nodeTypesOfInterest, node->getType(), numInterestTypes)) {
|
memchr(nodeTypesOfInterest, node->getType(), numInterestTypes)) {
|
||||||
|
|
||||||
|
@ -318,9 +318,7 @@ int DomainServer::civetwebRequestHandler(struct mg_connection *connection) {
|
||||||
QJsonObject assignedNodesJSON;
|
QJsonObject assignedNodesJSON;
|
||||||
|
|
||||||
// enumerate the NodeList to find the assigned nodes
|
// enumerate the NodeList to find the assigned nodes
|
||||||
NodeList* nodeList = NodeList::getInstance();
|
foreach(SharedNodePointer node, NodeList::getInstance()->getNodeHash()) {
|
||||||
|
|
||||||
for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
|
|
||||||
if (node->getLinkedData()) {
|
if (node->getLinkedData()) {
|
||||||
// add the node using the UUID as the key
|
// add the node using the UUID as the key
|
||||||
QString uuidString = uuidStringWithoutCurlyBraces(node->getUUID());
|
QString uuidString = uuidStringWithoutCurlyBraces(node->getUUID());
|
||||||
|
@ -372,10 +370,10 @@ int DomainServer::civetwebRequestHandler(struct mg_connection *connection) {
|
||||||
// enumerate the NodeList to find the assigned nodes
|
// enumerate the NodeList to find the assigned nodes
|
||||||
NodeList* nodeList = NodeList::getInstance();
|
NodeList* nodeList = NodeList::getInstance();
|
||||||
|
|
||||||
for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
|
foreach(SharedNodePointer node, nodeList->getNodeHash()) {
|
||||||
// add the node using the UUID as the key
|
// add the node using the UUID as the key
|
||||||
QString uuidString = uuidStringWithoutCurlyBraces(node->getUUID());
|
QString uuidString = uuidStringWithoutCurlyBraces(node->getUUID());
|
||||||
nodesJSON[uuidString] = jsonObjectForNode(&(*node));
|
nodesJSON[uuidString] = jsonObjectForNode(node.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
rootJSON["nodes"] = nodesJSON;
|
rootJSON["nodes"] = nodesJSON;
|
||||||
|
@ -410,14 +408,14 @@ int DomainServer::civetwebRequestHandler(struct mg_connection *connection) {
|
||||||
QUuid deleteUUID = QUuid(QString(ri->uri + strlen(URI_NODE) + sizeof('/')));
|
QUuid deleteUUID = QUuid(QString(ri->uri + strlen(URI_NODE) + sizeof('/')));
|
||||||
|
|
||||||
if (!deleteUUID.isNull()) {
|
if (!deleteUUID.isNull()) {
|
||||||
Node *nodeToKill = NodeList::getInstance()->nodeWithUUID(deleteUUID);
|
SharedNodePointer nodeToKill = NodeList::getInstance()->nodeWithUUID(deleteUUID);
|
||||||
|
|
||||||
if (nodeToKill) {
|
if (nodeToKill) {
|
||||||
// start with a 200 response
|
// start with a 200 response
|
||||||
mg_printf(connection, "%s", RESPONSE_200);
|
mg_printf(connection, "%s", RESPONSE_200);
|
||||||
|
|
||||||
// we have a valid UUID and node - kill the node that has this assignment
|
// we have a valid UUID and node - kill the node that has this assignment
|
||||||
NodeList::getInstance()->killNode(nodeToKill);
|
NodeList::getInstance()->killNodeWithUUID(deleteUUID);
|
||||||
|
|
||||||
// successfully processed request
|
// successfully processed request
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -494,10 +492,6 @@ void DomainServer::addReleasedAssignmentBackToQueue(Assignment* releasedAssignme
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DomainServer::nodeAdded(Node* node) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void DomainServer::nodeKilled(Node* node) {
|
void DomainServer::nodeKilled(Node* node) {
|
||||||
// if this node has linked data it was from an assignment
|
// if this node has linked data it was from an assignment
|
||||||
if (node->getLinkedData()) {
|
if (node->getLinkedData()) {
|
||||||
|
@ -741,7 +735,7 @@ bool DomainServer::checkInWithUUIDMatchesExistingNode(const HifiSockAddr& nodePu
|
||||||
const QUuid& checkInUUID) {
|
const QUuid& checkInUUID) {
|
||||||
NodeList* nodeList = NodeList::getInstance();
|
NodeList* nodeList = NodeList::getInstance();
|
||||||
|
|
||||||
for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
|
foreach(SharedNodePointer node, nodeList->getNodeHash()) {
|
||||||
if (node->getLinkedData()
|
if (node->getLinkedData()
|
||||||
&& nodePublicSocket == node->getPublicSocket()
|
&& nodePublicSocket == node->getPublicSocket()
|
||||||
&& nodeLocalSocket == node->getLocalSocket()
|
&& nodeLocalSocket == node->getLocalSocket()
|
||||||
|
@ -773,7 +767,7 @@ void DomainServer::addStaticAssignmentsBackToQueueAfterRestart() {
|
||||||
NodeList* nodeList = NodeList::getInstance();
|
NodeList* nodeList = NodeList::getInstance();
|
||||||
|
|
||||||
// enumerate the nodes and check if there is one with an attached assignment with matching UUID
|
// enumerate the nodes and check if there is one with an attached assignment with matching UUID
|
||||||
for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
|
foreach(SharedNodePointer node, nodeList->getNodeHash()) {
|
||||||
if (node->getLinkedData()) {
|
if (node->getLinkedData()) {
|
||||||
Assignment* linkedAssignment = (Assignment*) node->getLinkedData();
|
Assignment* linkedAssignment = (Assignment*) node->getLinkedData();
|
||||||
if (linkedAssignment->getUUID() == _staticAssignments[i].getUUID()) {
|
if (linkedAssignment->getUUID() == _staticAssignments[i].getUUID()) {
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
const int MAX_STATIC_ASSIGNMENT_FILE_ASSIGNMENTS = 1000;
|
const int MAX_STATIC_ASSIGNMENT_FILE_ASSIGNMENTS = 1000;
|
||||||
|
|
||||||
class DomainServer : public QCoreApplication, public NodeListHook {
|
class DomainServer : public QCoreApplication {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
DomainServer(int argc, char* argv[]);
|
DomainServer(int argc, char* argv[]);
|
||||||
|
@ -31,10 +31,10 @@ public:
|
||||||
|
|
||||||
static void setDomainServerInstance(DomainServer* domainServer);
|
static void setDomainServerInstance(DomainServer* domainServer);
|
||||||
|
|
||||||
/// Called by NodeList to inform us that a node has been added.
|
public slots:
|
||||||
void nodeAdded(Node* node);
|
|
||||||
/// Called by NodeList to inform us that a node has been killed.
|
/// Called by NodeList to inform us that a node has been killed.
|
||||||
void nodeKilled(Node* node);
|
void nodeKilled(Node* node);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static int civetwebRequestHandler(struct mg_connection *connection);
|
static int civetwebRequestHandler(struct mg_connection *connection);
|
||||||
static void civetwebUploadHandler(struct mg_connection *connection, const char *path);
|
static void civetwebUploadHandler(struct mg_connection *connection, const char *path);
|
||||||
|
|
|
@ -174,8 +174,10 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
|
||||||
|
|
||||||
audioThread->start();
|
audioThread->start();
|
||||||
|
|
||||||
nodeList->addHook(&_voxels);
|
connect(nodeList, SIGNAL(nodeKilled(SharedNodePointer)), SLOT(nodeKilled(SharedNodePointer)));
|
||||||
nodeList->addHook(this);
|
connect(nodeList, SIGNAL(nodeAdded(SharedNodePointer)), &_voxels, SLOT(nodeAdded(SharedNodePointer)));
|
||||||
|
connect(nodeList, SIGNAL(nodeKilled(SharedNodePointer)), &_voxels, SLOT(nodeKilled(SharedNodePointer)));
|
||||||
|
|
||||||
nodeList->addDomainListener(this);
|
nodeList->addDomainListener(this);
|
||||||
|
|
||||||
// network receive thread and voxel parsing thread are both controlled by the --nonblocking command line
|
// network receive thread and voxel parsing thread are both controlled by the --nonblocking command line
|
||||||
|
@ -263,8 +265,6 @@ Application::~Application() {
|
||||||
_audio.thread()->wait();
|
_audio.thread()->wait();
|
||||||
|
|
||||||
storeSizeAndPosition();
|
storeSizeAndPosition();
|
||||||
NodeList::getInstance()->removeHook(&_voxels);
|
|
||||||
NodeList::getInstance()->removeHook(this);
|
|
||||||
NodeList::getInstance()->removeDomainListener(this);
|
NodeList::getInstance()->removeDomainListener(this);
|
||||||
|
|
||||||
_sharedVoxelSystem.changeTree(new VoxelTree);
|
_sharedVoxelSystem.changeTree(new VoxelTree);
|
||||||
|
@ -1441,7 +1441,7 @@ void Application::terminate() {
|
||||||
static Avatar* processAvatarMessageHeader(unsigned char*& packetData, size_t& dataBytes) {
|
static Avatar* processAvatarMessageHeader(unsigned char*& packetData, size_t& dataBytes) {
|
||||||
// record the packet for stats-tracking
|
// record the packet for stats-tracking
|
||||||
Application::getInstance()->getBandwidthMeter()->inputStream(BandwidthMeter::AVATARS).updateValue(dataBytes);
|
Application::getInstance()->getBandwidthMeter()->inputStream(BandwidthMeter::AVATARS).updateValue(dataBytes);
|
||||||
Node* avatarMixerNode = NodeList::getInstance()->soloNodeOfType(NODE_TYPE_AVATAR_MIXER);
|
SharedNodePointer avatarMixerNode = NodeList::getInstance()->soloNodeOfType(NODE_TYPE_AVATAR_MIXER);
|
||||||
if (avatarMixerNode) {
|
if (avatarMixerNode) {
|
||||||
avatarMixerNode->recordBytesReceived(dataBytes);
|
avatarMixerNode->recordBytesReceived(dataBytes);
|
||||||
}
|
}
|
||||||
|
@ -1458,7 +1458,7 @@ static Avatar* processAvatarMessageHeader(unsigned char*& packetData, size_t& da
|
||||||
dataBytes -= NUM_BYTES_RFC4122_UUID;
|
dataBytes -= NUM_BYTES_RFC4122_UUID;
|
||||||
|
|
||||||
// make sure the node exists
|
// make sure the node exists
|
||||||
Node* node = NodeList::getInstance()->nodeWithUUID(nodeUUID);
|
SharedNodePointer node = NodeList::getInstance()->nodeWithUUID(nodeUUID);
|
||||||
if (!node || !node->getLinkedData()) {
|
if (!node || !node->getLinkedData()) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -1985,11 +1985,11 @@ void Application::updateLookatTargetAvatar(const glm::vec3& mouseRayOrigin, cons
|
||||||
Avatar* Application::findLookatTargetAvatar(const glm::vec3& mouseRayOrigin, const glm::vec3& mouseRayDirection,
|
Avatar* Application::findLookatTargetAvatar(const glm::vec3& mouseRayOrigin, const glm::vec3& mouseRayDirection,
|
||||||
glm::vec3& eyePosition, QUuid& nodeUUID = DEFAULT_NODE_ID_REF) {
|
glm::vec3& eyePosition, QUuid& nodeUUID = DEFAULT_NODE_ID_REF) {
|
||||||
|
|
||||||
NodeList* nodeList = NodeList::getInstance();
|
foreach(SharedNodePointer node, NodeList::getInstance()->getNodeHash()) {
|
||||||
for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
|
|
||||||
if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) {
|
if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) {
|
||||||
Avatar* avatar = (Avatar*)node->getLinkedData();
|
Avatar* avatar = (Avatar*)node->getLinkedData();
|
||||||
float distance;
|
float distance;
|
||||||
|
|
||||||
if (avatar->findRayIntersection(mouseRayOrigin, mouseRayDirection, distance)) {
|
if (avatar->findRayIntersection(mouseRayOrigin, mouseRayDirection, distance)) {
|
||||||
// rescale to compensate for head embiggening
|
// rescale to compensate for head embiggening
|
||||||
eyePosition = (avatar->getHead().calculateAverageEyePosition() - avatar->getHead().getScalePivot()) *
|
eyePosition = (avatar->getHead().calculateAverageEyePosition() - avatar->getHead().getScalePivot()) *
|
||||||
|
@ -2002,6 +2002,7 @@ Avatar* Application::findLookatTargetAvatar(const glm::vec3& mouseRayOrigin, con
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2026,71 +2027,6 @@ void Application::renderLookatIndicator(glm::vec3 pointOfInterest) {
|
||||||
renderCircle(haloOrigin, INDICATOR_RADIUS, IDENTITY_UP, NUM_SEGMENTS);
|
renderCircle(haloOrigin, INDICATOR_RADIUS, IDENTITY_UP, NUM_SEGMENTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
void maybeBeginFollowIndicator(bool& began) {
|
|
||||||
if (!began) {
|
|
||||||
Application::getInstance()->getGlowEffect()->begin();
|
|
||||||
glLineWidth(5);
|
|
||||||
glBegin(GL_LINES);
|
|
||||||
began = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Application::renderFollowIndicator() {
|
|
||||||
NodeList* nodeList = NodeList::getInstance();
|
|
||||||
|
|
||||||
// initialize lazily so that we don't enable the glow effect unnecessarily
|
|
||||||
bool began = false;
|
|
||||||
|
|
||||||
for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); ++node) {
|
|
||||||
if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) {
|
|
||||||
Avatar* avatar = (Avatar *) node->getLinkedData();
|
|
||||||
Avatar* leader = NULL;
|
|
||||||
|
|
||||||
if (!avatar->getLeaderUUID().isNull()) {
|
|
||||||
if (avatar->getLeaderUUID() == NodeList::getInstance()->getOwnerUUID()) {
|
|
||||||
leader = &_myAvatar;
|
|
||||||
} else {
|
|
||||||
for (NodeList::iterator it = nodeList->begin(); it != nodeList->end(); ++it) {
|
|
||||||
if(it->getUUID() == avatar->getLeaderUUID()
|
|
||||||
&& it->getType() == NODE_TYPE_AGENT) {
|
|
||||||
leader = (Avatar*) it->getLinkedData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (leader != NULL) {
|
|
||||||
maybeBeginFollowIndicator(began);
|
|
||||||
glColor3f(1.f, 0.f, 0.f);
|
|
||||||
glVertex3f((avatar->getHead().getPosition().x + avatar->getPosition().x) / 2.f,
|
|
||||||
(avatar->getHead().getPosition().y + avatar->getPosition().y) / 2.f,
|
|
||||||
(avatar->getHead().getPosition().z + avatar->getPosition().z) / 2.f);
|
|
||||||
glColor3f(0.f, 1.f, 0.f);
|
|
||||||
glVertex3f((leader->getHead().getPosition().x + leader->getPosition().x) / 2.f,
|
|
||||||
(leader->getHead().getPosition().y + leader->getPosition().y) / 2.f,
|
|
||||||
(leader->getHead().getPosition().z + leader->getPosition().z) / 2.f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_myAvatar.getLeadingAvatar() != NULL) {
|
|
||||||
maybeBeginFollowIndicator(began);
|
|
||||||
glColor3f(1.f, 0.f, 0.f);
|
|
||||||
glVertex3f((_myAvatar.getHead().getPosition().x + _myAvatar.getPosition().x) / 2.f,
|
|
||||||
(_myAvatar.getHead().getPosition().y + _myAvatar.getPosition().y) / 2.f,
|
|
||||||
(_myAvatar.getHead().getPosition().z + _myAvatar.getPosition().z) / 2.f);
|
|
||||||
glColor3f(0.f, 1.f, 0.f);
|
|
||||||
glVertex3f((_myAvatar.getLeadingAvatar()->getHead().getPosition().x + _myAvatar.getLeadingAvatar()->getPosition().x) / 2.f,
|
|
||||||
(_myAvatar.getLeadingAvatar()->getHead().getPosition().y + _myAvatar.getLeadingAvatar()->getPosition().y) / 2.f,
|
|
||||||
(_myAvatar.getLeadingAvatar()->getHead().getPosition().z + _myAvatar.getLeadingAvatar()->getPosition().z) / 2.f);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (began) {
|
|
||||||
glEnd();
|
|
||||||
_glowEffect.end();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Application::renderHighlightVoxel(VoxelDetail voxel) {
|
void Application::renderHighlightVoxel(VoxelDetail voxel) {
|
||||||
glDisable(GL_LIGHTING);
|
glDisable(GL_LIGHTING);
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
|
@ -2108,9 +2044,8 @@ void Application::renderHighlightVoxel(VoxelDetail voxel) {
|
||||||
void Application::updateAvatars(float deltaTime, glm::vec3 mouseRayOrigin, glm::vec3 mouseRayDirection) {
|
void Application::updateAvatars(float deltaTime, glm::vec3 mouseRayOrigin, glm::vec3 mouseRayDirection) {
|
||||||
bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
|
bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
|
||||||
PerformanceWarning warn(showWarnings, "Application::updateAvatars()");
|
PerformanceWarning warn(showWarnings, "Application::updateAvatars()");
|
||||||
NodeList* nodeList = NodeList::getInstance();
|
|
||||||
|
|
||||||
for(NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
|
foreach(SharedNodePointer node, NodeList::getInstance()->getNodeHash()) {
|
||||||
node->lock();
|
node->lock();
|
||||||
if (node->getLinkedData()) {
|
if (node->getLinkedData()) {
|
||||||
Avatar *avatar = (Avatar *)node->getLinkedData();
|
Avatar *avatar = (Avatar *)node->getLinkedData();
|
||||||
|
@ -2739,15 +2674,12 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node
|
||||||
|
|
||||||
unsigned char voxelQueryPacket[MAX_PACKET_SIZE];
|
unsigned char voxelQueryPacket[MAX_PACKET_SIZE];
|
||||||
|
|
||||||
NodeList* nodeList = NodeList::getInstance();
|
|
||||||
|
|
||||||
// Iterate all of the nodes, and get a count of how many voxel servers we have...
|
// Iterate all of the nodes, and get a count of how many voxel servers we have...
|
||||||
int totalServers = 0;
|
int totalServers = 0;
|
||||||
int inViewServers = 0;
|
int inViewServers = 0;
|
||||||
int unknownJurisdictionServers = 0;
|
int unknownJurisdictionServers = 0;
|
||||||
|
|
||||||
for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
|
foreach(SharedNodePointer node, NodeList::getInstance()->getNodeHash()) {
|
||||||
|
|
||||||
// only send to the NodeTypes that are serverType
|
// only send to the NodeTypes that are serverType
|
||||||
if (node->getActiveSocket() != NULL && node->getType() == serverType) {
|
if (node->getActiveSocket() != NULL && node->getType() == serverType) {
|
||||||
totalServers++;
|
totalServers++;
|
||||||
|
@ -2805,7 +2737,9 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node
|
||||||
qDebug("perServerPPS: %d perUnknownServer: %d\n", perServerPPS, perUnknownServer);
|
qDebug("perServerPPS: %d perUnknownServer: %d\n", perServerPPS, perUnknownServer);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
|
NodeList* nodeList = NodeList::getInstance();
|
||||||
|
|
||||||
|
foreach(SharedNodePointer node, nodeList->getNodeHash()) {
|
||||||
// only send to the NodeTypes that are serverType
|
// only send to the NodeTypes that are serverType
|
||||||
if (node->getActiveSocket() != NULL && node->getType() == serverType) {
|
if (node->getActiveSocket() != NULL && node->getType() == serverType) {
|
||||||
|
|
||||||
|
@ -3252,12 +3186,6 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
|
||||||
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
|
|
||||||
"Application::displaySide() ... renderFollowIndicator...");
|
|
||||||
renderFollowIndicator();
|
|
||||||
}
|
|
||||||
|
|
||||||
// render transmitter pick ray, if non-empty
|
// render transmitter pick ray, if non-empty
|
||||||
if (_transmitterPickStart != _transmitterPickEnd) {
|
if (_transmitterPickStart != _transmitterPickEnd) {
|
||||||
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
|
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
|
||||||
|
@ -3384,12 +3312,12 @@ void Application::displayOverlay() {
|
||||||
glPointSize(1.0f);
|
glPointSize(1.0f);
|
||||||
char nodes[100];
|
char nodes[100];
|
||||||
|
|
||||||
NodeList* nodeList = NodeList::getInstance();
|
|
||||||
int totalAvatars = 0, totalServers = 0;
|
int totalAvatars = 0, totalServers = 0;
|
||||||
|
|
||||||
for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
|
foreach(SharedNodePointer node, NodeList::getInstance()->getNodeHash()) {
|
||||||
node->getType() == NODE_TYPE_AGENT ? totalAvatars++ : totalServers++;
|
node->getType() == NODE_TYPE_AGENT ? totalAvatars++ : totalServers++;
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(nodes, "Servers: %d, Avatars: %d\n", totalServers, totalAvatars);
|
sprintf(nodes, "Servers: %d, Avatars: %d\n", totalServers, totalAvatars);
|
||||||
drawtext(_glWidget->width() - 150, 20, 0.10, 0, 1.0, 0, nodes, 1, 0, 0);
|
drawtext(_glWidget->width() - 150, 20, 0.10, 0, 1.0, 0, nodes, 1, 0, 0);
|
||||||
}
|
}
|
||||||
|
@ -3489,8 +3417,8 @@ void Application::displayStats() {
|
||||||
int pingAudio = 0, pingAvatar = 0, pingVoxel = 0, pingVoxelMax = 0;
|
int pingAudio = 0, pingAvatar = 0, pingVoxel = 0, pingVoxelMax = 0;
|
||||||
|
|
||||||
NodeList* nodeList = NodeList::getInstance();
|
NodeList* nodeList = NodeList::getInstance();
|
||||||
Node* audioMixerNode = nodeList->soloNodeOfType(NODE_TYPE_AUDIO_MIXER);
|
SharedNodePointer audioMixerNode = nodeList->soloNodeOfType(NODE_TYPE_AUDIO_MIXER);
|
||||||
Node* avatarMixerNode = nodeList->soloNodeOfType(NODE_TYPE_AVATAR_MIXER);
|
SharedNodePointer avatarMixerNode = nodeList->soloNodeOfType(NODE_TYPE_AVATAR_MIXER);
|
||||||
|
|
||||||
pingAudio = audioMixerNode ? audioMixerNode->getPingMs() : 0;
|
pingAudio = audioMixerNode ? audioMixerNode->getPingMs() : 0;
|
||||||
pingAvatar = avatarMixerNode ? avatarMixerNode->getPingMs() : 0;
|
pingAvatar = avatarMixerNode ? avatarMixerNode->getPingMs() : 0;
|
||||||
|
@ -3499,7 +3427,8 @@ void Application::displayStats() {
|
||||||
// Now handle voxel servers, since there could be more than one, we average their ping times
|
// Now handle voxel servers, since there could be more than one, we average their ping times
|
||||||
unsigned long totalPingVoxel = 0;
|
unsigned long totalPingVoxel = 0;
|
||||||
int voxelServerCount = 0;
|
int voxelServerCount = 0;
|
||||||
for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
|
|
||||||
|
foreach(SharedNodePointer node, nodeList->getNodeHash()) {
|
||||||
if (node->getType() == NODE_TYPE_VOXEL_SERVER) {
|
if (node->getType() == NODE_TYPE_VOXEL_SERVER) {
|
||||||
totalPingVoxel += node->getPingMs();
|
totalPingVoxel += node->getPingMs();
|
||||||
voxelServerCount++;
|
voxelServerCount++;
|
||||||
|
@ -3508,6 +3437,7 @@ void Application::displayStats() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (voxelServerCount) {
|
if (voxelServerCount) {
|
||||||
pingVoxel = totalPingVoxel/voxelServerCount;
|
pingVoxel = totalPingVoxel/voxelServerCount;
|
||||||
}
|
}
|
||||||
|
@ -3524,7 +3454,7 @@ void Application::displayStats() {
|
||||||
sprintf(avatarStats, "Avatar: pos %.3f, %.3f, %.3f, vel %.1f, yaw = %.2f", avatarPos.x, avatarPos.y, avatarPos.z, glm::length(_myAvatar.getVelocity()), _myAvatar.getBodyYaw());
|
sprintf(avatarStats, "Avatar: pos %.3f, %.3f, %.3f, vel %.1f, yaw = %.2f", avatarPos.x, avatarPos.y, avatarPos.z, glm::length(_myAvatar.getVelocity()), _myAvatar.getBodyYaw());
|
||||||
drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, avatarStats);
|
drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, avatarStats);
|
||||||
|
|
||||||
Node* avatarMixer = NodeList::getInstance()->soloNodeOfType(NODE_TYPE_AVATAR_MIXER);
|
SharedNodePointer avatarMixer = NodeList::getInstance()->soloNodeOfType(NODE_TYPE_AVATAR_MIXER);
|
||||||
char avatarMixerStats[200];
|
char avatarMixerStats[200];
|
||||||
if (avatarMixer) {
|
if (avatarMixer) {
|
||||||
sprintf(avatarMixerStats, "Avatar Mixer: %.f kbps, %.f pps",
|
sprintf(avatarMixerStats, "Avatar Mixer: %.f kbps, %.f pps",
|
||||||
|
@ -3849,7 +3779,7 @@ void Application::renderAvatars(bool forceRenderHead, bool selfAvatarOnly) {
|
||||||
// Render avatars of other nodes
|
// Render avatars of other nodes
|
||||||
NodeList* nodeList = NodeList::getInstance();
|
NodeList* nodeList = NodeList::getInstance();
|
||||||
|
|
||||||
for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
|
foreach(SharedNodePointer node, nodeList->getNodeHash()) {
|
||||||
node->lock();
|
node->lock();
|
||||||
|
|
||||||
if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) {
|
if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) {
|
||||||
|
@ -4106,18 +4036,6 @@ void Application::eyedropperVoxelUnderCursor() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::toggleFollowMode() {
|
|
||||||
glm::vec3 mouseRayOrigin, mouseRayDirection;
|
|
||||||
_viewFrustum.computePickRay(_pieMenu.getX() / (float)_glWidget->width(),
|
|
||||||
_pieMenu.getY() / (float)_glWidget->height(),
|
|
||||||
mouseRayOrigin, mouseRayDirection);
|
|
||||||
glm::vec3 eyePositionIgnored;
|
|
||||||
QUuid nodeUUIDIgnored;
|
|
||||||
Avatar* leadingAvatar = findLookatTargetAvatar(mouseRayOrigin, mouseRayDirection, eyePositionIgnored, nodeUUIDIgnored);
|
|
||||||
|
|
||||||
_myAvatar.follow(leadingAvatar);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Application::resetSensors() {
|
void Application::resetSensors() {
|
||||||
_headMouseX = _mouseX = _glWidget->width() / 2;
|
_headMouseX = _mouseX = _glWidget->width() / 2;
|
||||||
_headMouseY = _mouseY = _glWidget->height() / 2;
|
_headMouseY = _mouseY = _glWidget->height() / 2;
|
||||||
|
@ -4200,11 +4118,7 @@ void Application::domainChanged(QString domain) {
|
||||||
updateLocalOctreeCache();
|
updateLocalOctreeCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::nodeAdded(Node* node) {
|
void Application::nodeKilled(SharedNodePointer node) {
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void Application::nodeKilled(Node* node) {
|
|
||||||
if (node->getType() == NODE_TYPE_VOXEL_SERVER) {
|
if (node->getType() == NODE_TYPE_VOXEL_SERVER) {
|
||||||
QUuid nodeUUID = node->getUUID();
|
QUuid nodeUUID = node->getUUID();
|
||||||
// see if this is the first we've heard of this node...
|
// see if this is the first we've heard of this node...
|
||||||
|
@ -4284,7 +4198,7 @@ void Application::trackIncomingVoxelPacket(unsigned char* messageData, ssize_t m
|
||||||
const HifiSockAddr& senderSockAddr, bool wasStatsPacket) {
|
const HifiSockAddr& senderSockAddr, bool wasStatsPacket) {
|
||||||
|
|
||||||
// Attempt to identify the sender from it's address.
|
// Attempt to identify the sender from it's address.
|
||||||
Node* serverNode = NodeList::getInstance()->nodeWithAddress(senderSockAddr);
|
SharedNodePointer serverNode = NodeList::getInstance()->nodeWithAddress(senderSockAddr);
|
||||||
if (serverNode) {
|
if (serverNode) {
|
||||||
QUuid nodeUUID = serverNode->getUUID();
|
QUuid nodeUUID = serverNode->getUUID();
|
||||||
|
|
||||||
|
@ -4301,7 +4215,7 @@ void Application::trackIncomingVoxelPacket(unsigned char* messageData, ssize_t m
|
||||||
int Application::parseOctreeStats(unsigned char* messageData, ssize_t messageLength, const HifiSockAddr& senderSockAddr) {
|
int Application::parseOctreeStats(unsigned char* messageData, ssize_t messageLength, const HifiSockAddr& senderSockAddr) {
|
||||||
|
|
||||||
// But, also identify the sender, and keep track of the contained jurisdiction root for this server
|
// But, also identify the sender, and keep track of the contained jurisdiction root for this server
|
||||||
Node* server = NodeList::getInstance()->nodeWithAddress(senderSockAddr);
|
SharedNodePointer server = NodeList::getInstance()->nodeWithAddress(senderSockAddr);
|
||||||
|
|
||||||
// parse the incoming stats datas stick it in a temporary object for now, while we
|
// parse the incoming stats datas stick it in a temporary object for now, while we
|
||||||
// determine which server it belongs to
|
// determine which server it belongs to
|
||||||
|
|
|
@ -95,7 +95,7 @@ static const float NODE_KILLED_RED = 1.0f;
|
||||||
static const float NODE_KILLED_GREEN = 0.0f;
|
static const float NODE_KILLED_GREEN = 0.0f;
|
||||||
static const float NODE_KILLED_BLUE = 0.0f;
|
static const float NODE_KILLED_BLUE = 0.0f;
|
||||||
|
|
||||||
class Application : public QApplication, public NodeListHook, public PacketSenderNotify, public DomainChangeListener {
|
class Application : public QApplication, public PacketSenderNotify, public DomainChangeListener {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
friend class VoxelPacketProcessor;
|
friend class VoxelPacketProcessor;
|
||||||
|
@ -194,8 +194,7 @@ public:
|
||||||
void computeOffAxisFrustum(float& left, float& right, float& bottom, float& top, float& near,
|
void computeOffAxisFrustum(float& left, float& right, float& bottom, float& top, float& near,
|
||||||
float& far, glm::vec4& nearClipPlane, glm::vec4& farClipPlane) const;
|
float& far, glm::vec4& nearClipPlane, glm::vec4& farClipPlane) const;
|
||||||
|
|
||||||
virtual void nodeAdded(Node* node);
|
|
||||||
virtual void nodeKilled(Node* node);
|
|
||||||
virtual void packetSentNotification(ssize_t length);
|
virtual void packetSentNotification(ssize_t length);
|
||||||
|
|
||||||
virtual void domainChanged(QString domain);
|
virtual void domainChanged(QString domain);
|
||||||
|
@ -214,6 +213,8 @@ public:
|
||||||
void setIsHighlightVoxel(bool isHighlightVoxel) { _isHighlightVoxel = isHighlightVoxel; }
|
void setIsHighlightVoxel(bool isHighlightVoxel) { _isHighlightVoxel = isHighlightVoxel; }
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
void nodeKilled(SharedNodePointer node);
|
||||||
|
|
||||||
void sendAvatarFaceVideoMessage(int frameCount, const QByteArray& data);
|
void sendAvatarFaceVideoMessage(int frameCount, const QByteArray& data);
|
||||||
void exportVoxels();
|
void exportVoxels();
|
||||||
void importVoxels();
|
void importVoxels();
|
||||||
|
@ -250,8 +251,6 @@ private slots:
|
||||||
|
|
||||||
glm::vec2 getScaledScreenPoint(glm::vec2 projectedPoint);
|
glm::vec2 getScaledScreenPoint(glm::vec2 projectedPoint);
|
||||||
|
|
||||||
void toggleFollowMode();
|
|
||||||
|
|
||||||
void closeMirrorView();
|
void closeMirrorView();
|
||||||
void restoreMirrorView();
|
void restoreMirrorView();
|
||||||
void shrinkMirrorView();
|
void shrinkMirrorView();
|
||||||
|
@ -301,7 +300,6 @@ private:
|
||||||
bool isLookingAtMyAvatar(Avatar* avatar);
|
bool isLookingAtMyAvatar(Avatar* avatar);
|
||||||
|
|
||||||
void renderLookatIndicator(glm::vec3 pointOfInterest);
|
void renderLookatIndicator(glm::vec3 pointOfInterest);
|
||||||
void renderFollowIndicator();
|
|
||||||
void renderHighlightVoxel(VoxelDetail voxel);
|
void renderHighlightVoxel(VoxelDetail voxel);
|
||||||
|
|
||||||
void updateAvatar(float deltaTime);
|
void updateAvatar(float deltaTime);
|
||||||
|
|
|
@ -365,9 +365,9 @@ void Audio::handleAudioInput() {
|
||||||
NETWORK_BUFFER_LENGTH_SAMPLES_PER_CHANNEL);
|
NETWORK_BUFFER_LENGTH_SAMPLES_PER_CHANNEL);
|
||||||
|
|
||||||
NodeList* nodeList = NodeList::getInstance();
|
NodeList* nodeList = NodeList::getInstance();
|
||||||
Node* audioMixer = nodeList->soloNodeOfType(NODE_TYPE_AUDIO_MIXER);
|
SharedNodePointer audioMixer = nodeList->soloNodeOfType(NODE_TYPE_AUDIO_MIXER);
|
||||||
|
|
||||||
if (audioMixer && nodeList->getNodeActiveSocketOrPing(audioMixer)) {
|
if (audioMixer && nodeList->getNodeActiveSocketOrPing(audioMixer.data())) {
|
||||||
MyAvatar* interfaceAvatar = Application::getInstance()->getAvatar();
|
MyAvatar* interfaceAvatar = Application::getInstance()->getAvatar();
|
||||||
|
|
||||||
glm::vec3 headPosition = interfaceAvatar->getHeadJointPosition();
|
glm::vec3 headPosition = interfaceAvatar->getHeadJointPosition();
|
||||||
|
|
|
@ -144,8 +144,8 @@ void DataServerClient::processSendFromDataServer(unsigned char* packetData, int
|
||||||
Application::getInstance()->getProfile()->setFaceModelURL(QUrl(valueList[i]));
|
Application::getInstance()->getProfile()->setFaceModelURL(QUrl(valueList[i]));
|
||||||
} else {
|
} else {
|
||||||
// mesh URL for a UUID, find avatar in our list
|
// mesh URL for a UUID, find avatar in our list
|
||||||
NodeList* nodeList = NodeList::getInstance();
|
|
||||||
for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
|
foreach(SharedNodePointer node, NodeList::getInstance()->getNodeHash()) {
|
||||||
if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) {
|
if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) {
|
||||||
Avatar* avatar = (Avatar *) node->getLinkedData();
|
Avatar* avatar = (Avatar *) node->getLinkedData();
|
||||||
|
|
||||||
|
@ -163,8 +163,7 @@ void DataServerClient::processSendFromDataServer(unsigned char* packetData, int
|
||||||
Application::getInstance()->getProfile()->setSkeletonModelURL(QUrl(valueList[i]));
|
Application::getInstance()->getProfile()->setSkeletonModelURL(QUrl(valueList[i]));
|
||||||
} else {
|
} else {
|
||||||
// skeleton URL for a UUID, find avatar in our list
|
// skeleton URL for a UUID, find avatar in our list
|
||||||
NodeList* nodeList = NodeList::getInstance();
|
foreach(SharedNodePointer node, NodeList::getInstance()->getNodeHash()) {
|
||||||
for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
|
|
||||||
if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) {
|
if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) {
|
||||||
Avatar* avatar = (Avatar *) node->getLinkedData();
|
Avatar* avatar = (Avatar *) node->getLinkedData();
|
||||||
|
|
||||||
|
|
|
@ -26,10 +26,6 @@ MetavoxelSystem::MetavoxelSystem() :
|
||||||
_buffer(QOpenGLBuffer::VertexBuffer) {
|
_buffer(QOpenGLBuffer::VertexBuffer) {
|
||||||
}
|
}
|
||||||
|
|
||||||
MetavoxelSystem::~MetavoxelSystem() {
|
|
||||||
NodeList::getInstance()->removeHook(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MetavoxelSystem::init() {
|
void MetavoxelSystem::init() {
|
||||||
if (!_program.isLinked()) {
|
if (!_program.isLinked()) {
|
||||||
switchToResourcesParentIfRequired();
|
switchToResourcesParentIfRequired();
|
||||||
|
@ -39,7 +35,10 @@ void MetavoxelSystem::init() {
|
||||||
_pointScaleLocation = _program.uniformLocation("pointScale");
|
_pointScaleLocation = _program.uniformLocation("pointScale");
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeList::getInstance()->addHook(this);
|
NodeList* nodeList = NodeList::getInstance();
|
||||||
|
|
||||||
|
connect(nodeList, SIGNAL(nodeAdded(SharedNodePointer)), SLOT(nodeAdded(SharedNodePointer)));
|
||||||
|
connect(nodeList, SIGNAL(nodeKilled(SharedNodePointer)), SLOT(nodeKilled(SharedNodePointer)));
|
||||||
|
|
||||||
AttributeRegistry::getInstance()->configureScriptEngine(&_scriptEngine);
|
AttributeRegistry::getInstance()->configureScriptEngine(&_scriptEngine);
|
||||||
|
|
||||||
|
@ -117,14 +116,14 @@ void MetavoxelSystem::render() {
|
||||||
_program.release();
|
_program.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MetavoxelSystem::nodeAdded(Node* node) {
|
void MetavoxelSystem::nodeAdded(SharedNodePointer node) {
|
||||||
if (node->getType() == NODE_TYPE_METAVOXEL_SERVER) {
|
if (node->getType() == NODE_TYPE_METAVOXEL_SERVER) {
|
||||||
QMetaObject::invokeMethod(this, "addClient", Q_ARG(const QUuid&, node->getUUID()),
|
QMetaObject::invokeMethod(this, "addClient", Q_ARG(const QUuid&, node->getUUID()),
|
||||||
Q_ARG(const HifiSockAddr&, node->getLocalSocket()));
|
Q_ARG(const HifiSockAddr&, node->getLocalSocket()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MetavoxelSystem::nodeKilled(Node* node) {
|
void MetavoxelSystem::nodeKilled(SharedNodePointer node) {
|
||||||
if (node->getType() == NODE_TYPE_METAVOXEL_SERVER) {
|
if (node->getType() == NODE_TYPE_METAVOXEL_SERVER) {
|
||||||
QMetaObject::invokeMethod(this, "removeClient", Q_ARG(const QUuid&, node->getUUID()));
|
QMetaObject::invokeMethod(this, "removeClient", Q_ARG(const QUuid&, node->getUUID()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,13 +26,11 @@
|
||||||
class MetavoxelClient;
|
class MetavoxelClient;
|
||||||
|
|
||||||
/// Renders a metavoxel tree.
|
/// Renders a metavoxel tree.
|
||||||
class MetavoxelSystem : public QObject, public NodeListHook {
|
class MetavoxelSystem : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
MetavoxelSystem();
|
MetavoxelSystem();
|
||||||
~MetavoxelSystem();
|
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
|
@ -41,9 +39,9 @@ public:
|
||||||
void simulate(float deltaTime);
|
void simulate(float deltaTime);
|
||||||
void render();
|
void render();
|
||||||
|
|
||||||
virtual void nodeAdded(Node* node);
|
public slots:
|
||||||
virtual void nodeKilled(Node* node);
|
void nodeAdded(SharedNodePointer node);
|
||||||
|
void nodeKilled(SharedNodePointer node);
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Q_INVOKABLE void addClient(const QUuid& uuid, const HifiSockAddr& address);
|
Q_INVOKABLE void addClient(const QUuid& uuid, const HifiSockAddr& address);
|
||||||
|
|
|
@ -57,12 +57,13 @@ void VoxelPacketProcessor::processPacket(const HifiSockAddr& senderSockAddr, uns
|
||||||
if (Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) {
|
if (Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) {
|
||||||
app->trackIncomingVoxelPacket(packetData, messageLength, senderSockAddr, wasStatsPacket);
|
app->trackIncomingVoxelPacket(packetData, messageLength, senderSockAddr, wasStatsPacket);
|
||||||
|
|
||||||
Node* serverNode = NodeList::getInstance()->nodeWithAddress(senderSockAddr);
|
SharedNodePointer serverNode = NodeList::getInstance()->nodeWithAddress(senderSockAddr);
|
||||||
if (serverNode && serverNode->getActiveSocket() && *serverNode->getActiveSocket() == senderSockAddr) {
|
if (serverNode && serverNode->getActiveSocket() && *serverNode->getActiveSocket() == senderSockAddr) {
|
||||||
|
|
||||||
switch(packetData[0]) {
|
switch(packetData[0]) {
|
||||||
case PACKET_TYPE_PARTICLE_DATA: {
|
case PACKET_TYPE_PARTICLE_DATA: {
|
||||||
app->_particles.processDatagram(QByteArray((char*) packetData, messageLength), senderSockAddr, serverNode);
|
app->_particles.processDatagram(QByteArray((char*) packetData, messageLength),
|
||||||
|
senderSockAddr, serverNode.data());
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case PACKET_TYPE_ENVIRONMENT_DATA: {
|
case PACKET_TYPE_ENVIRONMENT_DATA: {
|
||||||
|
|
|
@ -1604,8 +1604,8 @@ void VoxelSystem::falseColorizeBySource() {
|
||||||
};
|
};
|
||||||
|
|
||||||
// create a bunch of colors we'll use during colorization
|
// create a bunch of colors we'll use during colorization
|
||||||
NodeList* nodeList = NodeList::getInstance();
|
|
||||||
for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
|
foreach(SharedNodePointer node, NodeList::getInstance()->getNodeHash()) {
|
||||||
if (node->getType() == NODE_TYPE_VOXEL_SERVER) {
|
if (node->getType() == NODE_TYPE_VOXEL_SERVER) {
|
||||||
uint16_t nodeID = VoxelTreeElement::getSourceNodeUUIDKey(node->getUUID());
|
uint16_t nodeID = VoxelTreeElement::getSourceNodeUUIDKey(node->getUUID());
|
||||||
int groupColor = voxelServerCount % NUMBER_OF_COLOR_GROUPS;
|
int groupColor = voxelServerCount % NUMBER_OF_COLOR_GROUPS;
|
||||||
|
@ -2683,7 +2683,7 @@ void VoxelSystem::falseColorizeOccludedV2() {
|
||||||
setupNewVoxelsForDrawing();
|
setupNewVoxelsForDrawing();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VoxelSystem::nodeAdded(Node* node) {
|
void VoxelSystem::nodeAdded(SharedNodePointer node) {
|
||||||
if (node->getType() == NODE_TYPE_VOXEL_SERVER) {
|
if (node->getType() == NODE_TYPE_VOXEL_SERVER) {
|
||||||
qDebug("VoxelSystem... voxel server %s added...\n", node->getUUID().toString().toLocal8Bit().constData());
|
qDebug("VoxelSystem... voxel server %s added...\n", node->getUUID().toString().toLocal8Bit().constData());
|
||||||
_voxelServerCount++;
|
_voxelServerCount++;
|
||||||
|
@ -2704,7 +2704,7 @@ bool VoxelSystem::killSourceVoxelsOperation(OctreeElement* element, void* extraD
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VoxelSystem::nodeKilled(Node* node) {
|
void VoxelSystem::nodeKilled(SharedNodePointer node) {
|
||||||
if (node->getType() == NODE_TYPE_VOXEL_SERVER) {
|
if (node->getType() == NODE_TYPE_VOXEL_SERVER) {
|
||||||
_voxelServerCount--;
|
_voxelServerCount--;
|
||||||
QUuid nodeUUID = node->getUUID();
|
QUuid nodeUUID = node->getUUID();
|
||||||
|
|
|
@ -37,8 +37,7 @@ struct VoxelShaderVBOData
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class VoxelSystem : public NodeData, public OctreeElementDeleteHook, public OctreeElementUpdateHook,
|
class VoxelSystem : public NodeData, public OctreeElementDeleteHook, public OctreeElementUpdateHook {
|
||||||
public NodeListHook {
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
friend class VoxelHideShowThread;
|
friend class VoxelHideShowThread;
|
||||||
|
@ -112,8 +111,6 @@ public:
|
||||||
|
|
||||||
virtual void elementDeleted(OctreeElement* element);
|
virtual void elementDeleted(OctreeElement* element);
|
||||||
virtual void elementUpdated(OctreeElement* element);
|
virtual void elementUpdated(OctreeElement* element);
|
||||||
virtual void nodeAdded(Node* node);
|
|
||||||
virtual void nodeKilled(Node* node);
|
|
||||||
|
|
||||||
bool treeIsBusy() const { return _treeIsBusy; }
|
bool treeIsBusy() const { return _treeIsBusy; }
|
||||||
|
|
||||||
|
@ -124,6 +121,9 @@ signals:
|
||||||
void importProgress(int progress);
|
void importProgress(int progress);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
void nodeAdded(SharedNodePointer node);
|
||||||
|
void nodeKilled(SharedNodePointer node);
|
||||||
|
|
||||||
void collectStatsForTreesAndVBOs();
|
void collectStatsForTreesAndVBOs();
|
||||||
|
|
||||||
// Methods that recurse tree
|
// Methods that recurse tree
|
||||||
|
|
|
@ -95,7 +95,6 @@ Avatar::Avatar(Node* owningNode) :
|
||||||
_mouseRayOrigin(0.0f, 0.0f, 0.0f),
|
_mouseRayOrigin(0.0f, 0.0f, 0.0f),
|
||||||
_mouseRayDirection(0.0f, 0.0f, 0.0f),
|
_mouseRayDirection(0.0f, 0.0f, 0.0f),
|
||||||
_isCollisionsOn(true),
|
_isCollisionsOn(true),
|
||||||
_leadingAvatar(NULL),
|
|
||||||
_moving(false),
|
_moving(false),
|
||||||
_initialized(false),
|
_initialized(false),
|
||||||
_handHoldingPosition(0.0f, 0.0f, 0.0f),
|
_handHoldingPosition(0.0f, 0.0f, 0.0f),
|
||||||
|
@ -146,27 +145,7 @@ glm::quat Avatar::getWorldAlignedOrientation () const {
|
||||||
return computeRotationFromBodyToWorldUp() * getOrientation();
|
return computeRotationFromBodyToWorldUp() * getOrientation();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Avatar::follow(Avatar* leadingAvatar) {
|
|
||||||
const float MAX_STRING_LENGTH = 2;
|
|
||||||
|
|
||||||
_leadingAvatar = leadingAvatar;
|
|
||||||
if (_leadingAvatar != NULL) {
|
|
||||||
_leaderUUID = leadingAvatar->getOwningNode()->getUUID();
|
|
||||||
_stringLength = glm::length(_position - _leadingAvatar->getPosition()) / _scale;
|
|
||||||
if (_stringLength > MAX_STRING_LENGTH) {
|
|
||||||
_stringLength = MAX_STRING_LENGTH;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
_leaderUUID = QUuid();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Avatar::simulate(float deltaTime, Transmitter* transmitter) {
|
void Avatar::simulate(float deltaTime, Transmitter* transmitter) {
|
||||||
|
|
||||||
if (_leadingAvatar && !_leadingAvatar->getOwningNode()->isAlive()) {
|
|
||||||
follow(NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_scale != _newScale) {
|
if (_scale != _newScale) {
|
||||||
setScale(_newScale);
|
setScale(_newScale);
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,7 +135,6 @@ public:
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
void simulate(float deltaTime, Transmitter* transmitter);
|
void simulate(float deltaTime, Transmitter* transmitter);
|
||||||
void follow(Avatar* leadingAvatar);
|
|
||||||
void render(bool forceRenderHead);
|
void render(bool forceRenderHead);
|
||||||
|
|
||||||
//setters
|
//setters
|
||||||
|
@ -217,7 +216,6 @@ protected:
|
||||||
glm::vec3 _mouseRayOrigin;
|
glm::vec3 _mouseRayOrigin;
|
||||||
glm::vec3 _mouseRayDirection;
|
glm::vec3 _mouseRayDirection;
|
||||||
bool _isCollisionsOn;
|
bool _isCollisionsOn;
|
||||||
Avatar* _leadingAvatar;
|
|
||||||
float _stringLength;
|
float _stringLength;
|
||||||
|
|
||||||
bool _moving; ///< set when position is changing
|
bool _moving; ///< set when position is changing
|
||||||
|
|
|
@ -368,8 +368,7 @@ void Hand::updateCollisions() {
|
||||||
glm::vec3 totalPenetration;
|
glm::vec3 totalPenetration;
|
||||||
|
|
||||||
// check other avatars
|
// check other avatars
|
||||||
NodeList* nodeList = NodeList::getInstance();
|
foreach(SharedNodePointer node, NodeList::getInstance()->getNodeHash()) {
|
||||||
for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
|
|
||||||
if (node->getLinkedData() && node->getType() == NODE_TYPE_AGENT) {
|
if (node->getLinkedData() && node->getType() == NODE_TYPE_AGENT) {
|
||||||
Avatar* otherAvatar = (Avatar*)node->getLinkedData();
|
Avatar* otherAvatar = (Avatar*)node->getLinkedData();
|
||||||
if (Menu::getInstance()->isOptionChecked(MenuOption::PlaySlaps)) {
|
if (Menu::getInstance()->isOptionChecked(MenuOption::PlaySlaps)) {
|
||||||
|
|
|
@ -87,15 +87,6 @@ void MyAvatar::simulate(float deltaTime, Transmitter* transmitter) {
|
||||||
_elapsedTimeMoving += deltaTime;
|
_elapsedTimeMoving += deltaTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_leadingAvatar && !_leadingAvatar->getOwningNode()->isAlive()) {
|
|
||||||
follow(NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ajust, scale, position and lookAt position when following an other avatar
|
|
||||||
if (_leadingAvatar && _newScale != _leadingAvatar->getScale()) {
|
|
||||||
_newScale = _leadingAvatar->getScale();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_scale != _newScale) {
|
if (_scale != _newScale) {
|
||||||
float scale = (1.f - SMOOTHING_RATIO) * _scale + SMOOTHING_RATIO * _newScale;
|
float scale = (1.f - SMOOTHING_RATIO) * _scale + SMOOTHING_RATIO * _newScale;
|
||||||
setScale(scale);
|
setScale(scale);
|
||||||
|
@ -327,9 +318,7 @@ void MyAvatar::updateFromGyrosAndOrWebcam(bool turnWithHead) {
|
||||||
estimatedRotation = webcam->getEstimatedRotation();
|
estimatedRotation = webcam->getEstimatedRotation();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (!_leadingAvatar) {
|
|
||||||
_head.setPitch(_head.getMousePitch());
|
_head.setPitch(_head.getMousePitch());
|
||||||
}
|
|
||||||
_head.getVideoFace().clearFrame();
|
_head.getVideoFace().clearFrame();
|
||||||
|
|
||||||
// restore rotation, lean to neutral positions
|
// restore rotation, lean to neutral positions
|
||||||
|
@ -634,47 +623,6 @@ void MyAvatar::updateThrust(float deltaTime, Transmitter * transmitter) {
|
||||||
_shouldJump = false;
|
_shouldJump = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Add thrusts from leading avatar
|
|
||||||
const float FOLLOWING_RATE = 0.02f;
|
|
||||||
const float MIN_YAW = 5.0f;
|
|
||||||
const float MIN_PITCH = 1.0f;
|
|
||||||
const float PITCH_RATE = 0.1f;
|
|
||||||
const float MIN_YAW_BEFORE_PITCH = 30.0f;
|
|
||||||
|
|
||||||
if (_leadingAvatar != NULL) {
|
|
||||||
glm::vec3 toTarget = _leadingAvatar->getPosition() - _position;
|
|
||||||
|
|
||||||
if (glm::length(_position - _leadingAvatar->getPosition()) > _scale * _stringLength) {
|
|
||||||
_position += toTarget * FOLLOWING_RATE;
|
|
||||||
} else {
|
|
||||||
toTarget = _leadingAvatar->getHead().getLookAtPosition() - _head.getPosition();
|
|
||||||
}
|
|
||||||
toTarget = glm::vec3(glm::dot(right, toTarget),
|
|
||||||
glm::dot(up , toTarget),
|
|
||||||
glm::dot(front, toTarget));
|
|
||||||
|
|
||||||
float yawAngle = angleBetween(-IDENTITY_FRONT, glm::vec3(toTarget.x, 0.f, toTarget.z));
|
|
||||||
if (glm::abs(yawAngle) > MIN_YAW){
|
|
||||||
if (IDENTITY_RIGHT.x * toTarget.x + IDENTITY_RIGHT.y * toTarget.y + IDENTITY_RIGHT.z * toTarget.z > 0) {
|
|
||||||
_bodyYawDelta -= yawAngle;
|
|
||||||
} else {
|
|
||||||
_bodyYawDelta += yawAngle;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
float pitchAngle = glm::abs(90.0f - angleBetween(IDENTITY_UP, toTarget));
|
|
||||||
if (glm::abs(pitchAngle) > MIN_PITCH && yawAngle < MIN_YAW_BEFORE_PITCH){
|
|
||||||
if (IDENTITY_UP.x * toTarget.x + IDENTITY_UP.y * toTarget.y + IDENTITY_UP.z * toTarget.z > 0) {
|
|
||||||
_head.setMousePitch(_head.getMousePitch() + PITCH_RATE * pitchAngle);
|
|
||||||
} else {
|
|
||||||
_head.setMousePitch(_head.getMousePitch() - PITCH_RATE * pitchAngle);
|
|
||||||
}
|
|
||||||
_head.setPitch(_head.getMousePitch());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Add thrusts from Transmitter
|
// Add thrusts from Transmitter
|
||||||
if (transmitter) {
|
if (transmitter) {
|
||||||
transmitter->checkForLostTransmitter();
|
transmitter->checkForLostTransmitter();
|
||||||
|
@ -873,15 +821,7 @@ void MyAvatar::updateAvatarCollisions(float deltaTime) {
|
||||||
// Reset detector for nearest avatar
|
// Reset detector for nearest avatar
|
||||||
_distanceToNearestAvatar = std::numeric_limits<float>::max();
|
_distanceToNearestAvatar = std::numeric_limits<float>::max();
|
||||||
|
|
||||||
// loop through all the other avatars for potential interactions...
|
// loop through all the other avatars for potential interactions
|
||||||
NodeList* nodeList = NodeList::getInstance();
|
|
||||||
for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
|
|
||||||
if (node->getLinkedData() && node->getType() == NODE_TYPE_AGENT) {
|
|
||||||
//Avatar *otherAvatar = (Avatar *)node->getLinkedData();
|
|
||||||
//
|
|
||||||
// Placeholder: Add code here when we want to add Avatar<->Avatar collision stuff
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class SortedAvatar {
|
class SortedAvatar {
|
||||||
|
@ -902,8 +842,8 @@ void MyAvatar::updateChatCircle(float deltaTime) {
|
||||||
|
|
||||||
// find all circle-enabled members and sort by distance
|
// find all circle-enabled members and sort by distance
|
||||||
QVector<SortedAvatar> sortedAvatars;
|
QVector<SortedAvatar> sortedAvatars;
|
||||||
NodeList* nodeList = NodeList::getInstance();
|
|
||||||
for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
|
foreach(SharedNodePointer node, NodeList::getInstance()->getNodeHash()) {
|
||||||
if (node->getLinkedData() && node->getType() == NODE_TYPE_AGENT) {
|
if (node->getLinkedData() && node->getType() == NODE_TYPE_AGENT) {
|
||||||
SortedAvatar sortedAvatar;
|
SortedAvatar sortedAvatar;
|
||||||
sortedAvatar.avatar = (Avatar*)node->getLinkedData();
|
sortedAvatar.avatar = (Avatar*)node->getLinkedData();
|
||||||
|
@ -914,6 +854,7 @@ void MyAvatar::updateChatCircle(float deltaTime) {
|
||||||
sortedAvatars.append(sortedAvatar);
|
sortedAvatars.append(sortedAvatar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
qSort(sortedAvatars.begin(), sortedAvatars.end());
|
qSort(sortedAvatars.begin(), sortedAvatars.end());
|
||||||
|
|
||||||
// compute the accumulated centers
|
// compute the accumulated centers
|
||||||
|
|
|
@ -51,7 +51,6 @@ public:
|
||||||
float getAbsoluteHeadYaw() const;
|
float getAbsoluteHeadYaw() const;
|
||||||
const glm::vec3& getMouseRayOrigin() const { return _mouseRayOrigin; }
|
const glm::vec3& getMouseRayOrigin() const { return _mouseRayOrigin; }
|
||||||
const glm::vec3& getMouseRayDirection() const { return _mouseRayDirection; }
|
const glm::vec3& getMouseRayDirection() const { return _mouseRayDirection; }
|
||||||
Avatar* getLeadingAvatar() const { return _leadingAvatar; }
|
|
||||||
glm::vec3 getGravity() const { return _gravity; }
|
glm::vec3 getGravity() const { return _gravity; }
|
||||||
glm::vec3 getUprightHeadPosition() const;
|
glm::vec3 getUprightHeadPosition() const;
|
||||||
glm::vec3 getEyeLevelPosition() const;
|
glm::vec3 getEyeLevelPosition() const;
|
||||||
|
|
|
@ -243,7 +243,8 @@ void VoxelStatsDialog::showOctreeServersOfType(int& serverCount, NODE_TYPE serve
|
||||||
QLocale locale(QLocale::English);
|
QLocale locale(QLocale::English);
|
||||||
|
|
||||||
NodeList* nodeList = NodeList::getInstance();
|
NodeList* nodeList = NodeList::getInstance();
|
||||||
for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
|
|
||||||
|
foreach(SharedNodePointer node, nodeList->getNodeHash()) {
|
||||||
// only send to the NodeTypes that are NODE_TYPE_VOXEL_SERVER
|
// only send to the NodeTypes that are NODE_TYPE_VOXEL_SERVER
|
||||||
if (node->getType() == serverType) {
|
if (node->getType() == serverType) {
|
||||||
serverCount++;
|
serverCount++;
|
||||||
|
@ -391,7 +392,7 @@ void VoxelStatsDialog::showOctreeServersOfType(int& serverCount, NODE_TYPE serve
|
||||||
serverDetails << linkDetails.str();
|
serverDetails << linkDetails.str();
|
||||||
_labels[_voxelServerLables[serverCount - 1]]->setText(serverDetails.str().c_str());
|
_labels[_voxelServerLables[serverCount - 1]]->setText(serverDetails.str().c_str());
|
||||||
} // is VOXEL_SERVER
|
} // is VOXEL_SERVER
|
||||||
} // Node Loop
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VoxelStatsDialog::reject() {
|
void VoxelStatsDialog::reject() {
|
||||||
|
|
|
@ -103,9 +103,9 @@ void AudioInjector::injectAudio() {
|
||||||
|
|
||||||
|
|
||||||
// grab our audio mixer from the NodeList, if it exists
|
// grab our audio mixer from the NodeList, if it exists
|
||||||
Node* audioMixer = nodeList->soloNodeOfType(NODE_TYPE_AUDIO_MIXER);
|
SharedNodePointer audioMixer = nodeList->soloNodeOfType(NODE_TYPE_AUDIO_MIXER);
|
||||||
|
|
||||||
if (audioMixer && nodeList->getNodeActiveSocketOrPing(audioMixer)) {
|
if (audioMixer && nodeList->getNodeActiveSocketOrPing(audioMixer.data())) {
|
||||||
// send off this audio packet
|
// send off this audio packet
|
||||||
nodeList->getNodeSocket().writeDatagram((char*) injectedAudioPacket,
|
nodeList->getNodeSocket().writeDatagram((char*) injectedAudioPacket,
|
||||||
(currentPacketPosition - injectedAudioPacket) + bytesToCopy,
|
(currentPacketPosition - injectedAudioPacket) + bytesToCopy,
|
||||||
|
|
|
@ -30,7 +30,6 @@ AvatarData::AvatarData(Node* owningNode) :
|
||||||
_bodyPitch(0.0),
|
_bodyPitch(0.0),
|
||||||
_bodyRoll(0.0),
|
_bodyRoll(0.0),
|
||||||
_newScale(1.0f),
|
_newScale(1.0f),
|
||||||
_leaderUUID(),
|
|
||||||
_handState(0),
|
_handState(0),
|
||||||
_keyState(NO_KEY_DOWN),
|
_keyState(NO_KEY_DOWN),
|
||||||
_isChatCirclingEnabled(false),
|
_isChatCirclingEnabled(false),
|
||||||
|
@ -78,10 +77,6 @@ int AvatarData::getBroadcastData(unsigned char* destinationBuffer) {
|
||||||
// Body scale
|
// Body scale
|
||||||
destinationBuffer += packFloatRatioToTwoByte(destinationBuffer, _newScale);
|
destinationBuffer += packFloatRatioToTwoByte(destinationBuffer, _newScale);
|
||||||
|
|
||||||
// Follow mode info
|
|
||||||
memcpy(destinationBuffer, _leaderUUID.toRfc4122().constData(), NUM_BYTES_RFC4122_UUID);
|
|
||||||
destinationBuffer += NUM_BYTES_RFC4122_UUID;
|
|
||||||
|
|
||||||
// Head rotation (NOTE: This needs to become a quaternion to save two bytes)
|
// Head rotation (NOTE: This needs to become a quaternion to save two bytes)
|
||||||
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _headData->_yaw);
|
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _headData->_yaw);
|
||||||
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _headData->_pitch);
|
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _headData->_pitch);
|
||||||
|
@ -200,10 +195,6 @@ int AvatarData::parseData(unsigned char* sourceBuffer, int numBytes) {
|
||||||
// Body scale
|
// Body scale
|
||||||
sourceBuffer += unpackFloatRatioFromTwoByte(sourceBuffer, _newScale);
|
sourceBuffer += unpackFloatRatioFromTwoByte(sourceBuffer, _newScale);
|
||||||
|
|
||||||
// Follow mode info
|
|
||||||
_leaderUUID = QUuid::fromRfc4122(QByteArray((char*) sourceBuffer, NUM_BYTES_RFC4122_UUID));
|
|
||||||
sourceBuffer += NUM_BYTES_RFC4122_UUID;
|
|
||||||
|
|
||||||
// Head rotation (NOTE: This needs to become a quaternion to save two bytes)
|
// Head rotation (NOTE: This needs to become a quaternion to save two bytes)
|
||||||
float headYaw, headPitch, headRoll;
|
float headYaw, headPitch, headRoll;
|
||||||
sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t*) sourceBuffer, &headYaw);
|
sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t*) sourceBuffer, &headYaw);
|
||||||
|
|
|
@ -101,8 +101,6 @@ public:
|
||||||
|
|
||||||
bool isChatCirclingEnabled() const { return _isChatCirclingEnabled; }
|
bool isChatCirclingEnabled() const { return _isChatCirclingEnabled; }
|
||||||
|
|
||||||
const QUuid& getLeaderUUID() const { return _leaderUUID; }
|
|
||||||
|
|
||||||
const HeadData* getHeadData() const { return _headData; }
|
const HeadData* getHeadData() const { return _headData; }
|
||||||
const HandData* getHandData() const { return _handData; }
|
const HandData* getHandData() const { return _handData; }
|
||||||
|
|
||||||
|
@ -134,9 +132,6 @@ protected:
|
||||||
// Body scale
|
// Body scale
|
||||||
float _newScale;
|
float _newScale;
|
||||||
|
|
||||||
// Following mode infos
|
|
||||||
QUuid _leaderUUID;
|
|
||||||
|
|
||||||
// Hand state (are we grabbing something or not)
|
// Hand state (are we grabbing something or not)
|
||||||
char _handState;
|
char _handState;
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ void OctreeInboundPacketProcessor::processPacket(const HifiSockAddr& senderSockA
|
||||||
PerformanceWarning warn(debugProcessPacket, "processPacket KNOWN TYPE",debugProcessPacket);
|
PerformanceWarning warn(debugProcessPacket, "processPacket KNOWN TYPE",debugProcessPacket);
|
||||||
_receivedPacketCount++;
|
_receivedPacketCount++;
|
||||||
|
|
||||||
Node* senderNode = NodeList::getInstance()->nodeWithAddress(senderSockAddr);
|
SharedNodePointer senderNode = NodeList::getInstance()->nodeWithAddress(senderSockAddr);
|
||||||
|
|
||||||
unsigned short int sequence = (*((unsigned short int*)(packetData + numBytesPacketHeader)));
|
unsigned short int sequence = (*((unsigned short int*)(packetData + numBytesPacketHeader)));
|
||||||
uint64_t sentAt = (*((uint64_t*)(packetData + numBytesPacketHeader + sizeof(sequence))));
|
uint64_t sentAt = (*((uint64_t*)(packetData + numBytesPacketHeader + sizeof(sequence))));
|
||||||
|
@ -87,7 +87,9 @@ void OctreeInboundPacketProcessor::processPacket(const HifiSockAddr& senderSockA
|
||||||
_myServer->getOctree()->lockForWrite();
|
_myServer->getOctree()->lockForWrite();
|
||||||
uint64_t startProcess = usecTimestampNow();
|
uint64_t startProcess = usecTimestampNow();
|
||||||
int editDataBytesRead = _myServer->getOctree()->processEditPacketData(packetType,
|
int editDataBytesRead = _myServer->getOctree()->processEditPacketData(packetType,
|
||||||
packetData, packetLength, editData, maxSize, senderNode);
|
packetData,
|
||||||
|
packetLength,
|
||||||
|
editData, maxSize, senderNode.data());
|
||||||
_myServer->getOctree()->unlock();
|
_myServer->getOctree()->unlock();
|
||||||
uint64_t endProcess = usecTimestampNow();
|
uint64_t endProcess = usecTimestampNow();
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ bool OctreeSendThread::process() {
|
||||||
|
|
||||||
// don't do any send processing until the initial load of the octree is complete...
|
// don't do any send processing until the initial load of the octree is complete...
|
||||||
if (_myServer->isInitialLoadComplete()) {
|
if (_myServer->isInitialLoadComplete()) {
|
||||||
Node* node = NodeList::getInstance()->nodeWithUUID(_nodeUUID);
|
SharedNodePointer node = NodeList::getInstance()->nodeWithUUID(_nodeUUID);
|
||||||
|
|
||||||
if (node) {
|
if (node) {
|
||||||
// make sure the node list doesn't kill our node while we're using it
|
// make sure the node list doesn't kill our node while we're using it
|
||||||
|
@ -48,7 +48,7 @@ bool OctreeSendThread::process() {
|
||||||
if (_myServer->wantsDebugSending() && _myServer->wantsVerboseDebug()) {
|
if (_myServer->wantsDebugSending() && _myServer->wantsVerboseDebug()) {
|
||||||
printf("nodeData->updateCurrentViewFrustum() changed=%s\n", debug::valueOf(viewFrustumChanged));
|
printf("nodeData->updateCurrentViewFrustum() changed=%s\n", debug::valueOf(viewFrustumChanged));
|
||||||
}
|
}
|
||||||
packetsSent = packetDistributor(node, nodeData, viewFrustumChanged);
|
packetsSent = packetDistributor(node.data(), nodeData, viewFrustumChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
node->unlock(); // we're done with this node for now.
|
node->unlock(); // we're done with this node for now.
|
||||||
|
|
|
@ -27,11 +27,7 @@ void OctreeServer::attachQueryNodeToNode(Node* newNode) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OctreeServer::nodeAdded(Node* node) {
|
void OctreeServer::nodeKilled(SharedNodePointer node) {
|
||||||
// do nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
void OctreeServer::nodeKilled(Node* node) {
|
|
||||||
// Use this to cleanup our node
|
// Use this to cleanup our node
|
||||||
if (node->getType() == NODE_TYPE_AGENT) {
|
if (node->getType() == NODE_TYPE_AGENT) {
|
||||||
OctreeQueryNode* nodeData = (OctreeQueryNode*)node->getLinkedData();
|
OctreeQueryNode* nodeData = (OctreeQueryNode*)node->getLinkedData();
|
||||||
|
@ -91,9 +87,6 @@ OctreeServer::~OctreeServer() {
|
||||||
delete _persistThread;
|
delete _persistThread;
|
||||||
}
|
}
|
||||||
|
|
||||||
// tell our NodeList we're done with notifications
|
|
||||||
NodeList::getInstance()->removeHook(this);
|
|
||||||
|
|
||||||
delete _jurisdiction;
|
delete _jurisdiction;
|
||||||
_jurisdiction = NULL;
|
_jurisdiction = NULL;
|
||||||
|
|
||||||
|
@ -524,10 +517,10 @@ void OctreeServer::processDatagram(const QByteArray& dataByteArray, const HifiSo
|
||||||
QUuid nodeUUID = QUuid::fromRfc4122(dataByteArray.mid(numBytesPacketHeader,
|
QUuid nodeUUID = QUuid::fromRfc4122(dataByteArray.mid(numBytesPacketHeader,
|
||||||
NUM_BYTES_RFC4122_UUID));
|
NUM_BYTES_RFC4122_UUID));
|
||||||
|
|
||||||
Node* node = nodeList->nodeWithUUID(nodeUUID);
|
SharedNodePointer node = nodeList->nodeWithUUID(nodeUUID);
|
||||||
|
|
||||||
if (node) {
|
if (node) {
|
||||||
nodeList->updateNodeWithData(node, senderSockAddr, (unsigned char *) dataByteArray.data(),
|
nodeList->updateNodeWithData(node.data(), senderSockAddr, (unsigned char *) dataByteArray.data(),
|
||||||
dataByteArray.size());
|
dataByteArray.size());
|
||||||
if (!node->getActiveSocket()) {
|
if (!node->getActiveSocket()) {
|
||||||
// we don't have an active socket for this node, but they're talking to us
|
// we don't have an active socket for this node, but they're talking to us
|
||||||
|
@ -612,7 +605,7 @@ void OctreeServer::run() {
|
||||||
setvbuf(stdout, NULL, _IOLBF, 0);
|
setvbuf(stdout, NULL, _IOLBF, 0);
|
||||||
|
|
||||||
// tell our NodeList about our desire to get notifications
|
// tell our NodeList about our desire to get notifications
|
||||||
nodeList->addHook(this);
|
connect(nodeList, SIGNAL(nodeKilled(SharedNodePointer)), SLOT(nodeKilled(SharedNodePointer)));
|
||||||
nodeList->linkedDataCreateCallback = &OctreeServer::attachQueryNodeToNode;
|
nodeList->linkedDataCreateCallback = &OctreeServer::attachQueryNodeToNode;
|
||||||
|
|
||||||
srand((unsigned)time(0));
|
srand((unsigned)time(0));
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
#include "OctreeInboundPacketProcessor.h"
|
#include "OctreeInboundPacketProcessor.h"
|
||||||
|
|
||||||
/// Handles assignments of type OctreeServer - sending octrees to various clients.
|
/// Handles assignments of type OctreeServer - sending octrees to various clients.
|
||||||
class OctreeServer : public ThreadedAssignment, public NodeListHook {
|
class OctreeServer : public ThreadedAssignment {
|
||||||
public:
|
public:
|
||||||
OctreeServer(const unsigned char* dataBuffer, int numBytes);
|
OctreeServer(const unsigned char* dataBuffer, int numBytes);
|
||||||
~OctreeServer();
|
~OctreeServer();
|
||||||
|
@ -61,15 +61,13 @@ public:
|
||||||
|
|
||||||
static void attachQueryNodeToNode(Node* newNode);
|
static void attachQueryNodeToNode(Node* newNode);
|
||||||
|
|
||||||
// NodeListHook
|
|
||||||
virtual void nodeAdded(Node* node);
|
|
||||||
virtual void nodeKilled(Node* node);
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
/// runs the voxel server assignment
|
/// runs the voxel server assignment
|
||||||
void run();
|
void run();
|
||||||
void processDatagram(const QByteArray& dataByteArray, const HifiSockAddr& senderSockAddr);
|
void processDatagram(const QByteArray& dataByteArray, const HifiSockAddr& senderSockAddr);
|
||||||
|
|
||||||
|
void nodeKilled(SharedNodePointer node);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int _argc;
|
int _argc;
|
||||||
const char** _argv;
|
const char** _argv;
|
||||||
|
|
|
@ -15,29 +15,20 @@
|
||||||
#include <PacketHeaders.h>
|
#include <PacketHeaders.h>
|
||||||
#include "JurisdictionListener.h"
|
#include "JurisdictionListener.h"
|
||||||
|
|
||||||
|
|
||||||
JurisdictionListener::JurisdictionListener(NODE_TYPE type, PacketSenderNotify* notify) :
|
JurisdictionListener::JurisdictionListener(NODE_TYPE type, PacketSenderNotify* notify) :
|
||||||
PacketSender(notify, JurisdictionListener::DEFAULT_PACKETS_PER_SECOND)
|
PacketSender(notify, JurisdictionListener::DEFAULT_PACKETS_PER_SECOND)
|
||||||
{
|
{
|
||||||
_nodeType = type;
|
_nodeType = type;
|
||||||
ReceivedPacketProcessor::_dontSleep = true; // we handle sleeping so this class doesn't need to
|
ReceivedPacketProcessor::_dontSleep = true; // we handle sleeping so this class doesn't need to
|
||||||
NodeList* nodeList = NodeList::getInstance();
|
NodeList* nodeList = NodeList::getInstance();
|
||||||
nodeList->addHook(this);
|
|
||||||
|
connect(nodeList, SIGNAL(nodeKilled(SharedNodePointer)), SLOT(nodeKilled(SharedNodePointer)));
|
||||||
|
|
||||||
//qDebug("JurisdictionListener::JurisdictionListener(NODE_TYPE type=%c)\n", type);
|
//qDebug("JurisdictionListener::JurisdictionListener(NODE_TYPE type=%c)\n", type);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JurisdictionListener::~JurisdictionListener() {
|
void JurisdictionListener::nodeKilled(SharedNodePointer node) {
|
||||||
NodeList* nodeList = NodeList::getInstance();
|
|
||||||
nodeList->removeHook(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void JurisdictionListener::nodeAdded(Node* node) {
|
|
||||||
// nothing to do. But need to implement it.
|
|
||||||
}
|
|
||||||
|
|
||||||
void JurisdictionListener::nodeKilled(Node* node) {
|
|
||||||
if (_jurisdictions.find(node->getUUID()) != _jurisdictions.end()) {
|
if (_jurisdictions.find(node->getUUID()) != _jurisdictions.end()) {
|
||||||
_jurisdictions.erase(_jurisdictions.find(node->getUUID()));
|
_jurisdictions.erase(_jurisdictions.find(node->getUUID()));
|
||||||
}
|
}
|
||||||
|
@ -52,7 +43,8 @@ bool JurisdictionListener::queueJurisdictionRequest() {
|
||||||
int nodeCount = 0;
|
int nodeCount = 0;
|
||||||
|
|
||||||
NodeList* nodeList = NodeList::getInstance();
|
NodeList* nodeList = NodeList::getInstance();
|
||||||
for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
|
|
||||||
|
foreach(SharedNodePointer node, nodeList->getNodeHash()) {
|
||||||
if (nodeList->getNodeActiveSocketOrPing(&(*node)) &&
|
if (nodeList->getNodeActiveSocketOrPing(&(*node)) &&
|
||||||
node->getType() == getNodeType()) {
|
node->getType() == getNodeType()) {
|
||||||
const HifiSockAddr* nodeAddress = node->getActiveSocket();
|
const HifiSockAddr* nodeAddress = node->getActiveSocket();
|
||||||
|
@ -73,7 +65,7 @@ bool JurisdictionListener::queueJurisdictionRequest() {
|
||||||
|
|
||||||
void JurisdictionListener::processPacket(const HifiSockAddr& senderAddress, unsigned char* packetData, ssize_t packetLength) {
|
void JurisdictionListener::processPacket(const HifiSockAddr& senderAddress, unsigned char* packetData, ssize_t packetLength) {
|
||||||
if (packetData[0] == PACKET_TYPE_JURISDICTION) {
|
if (packetData[0] == PACKET_TYPE_JURISDICTION) {
|
||||||
Node* node = NodeList::getInstance()->nodeWithAddress(senderAddress);
|
SharedNodePointer node = NodeList::getInstance()->nodeWithAddress(senderAddress);
|
||||||
if (node) {
|
if (node) {
|
||||||
QUuid nodeUUID = node->getUUID();
|
QUuid nodeUUID = node->getUUID();
|
||||||
JurisdictionMap map;
|
JurisdictionMap map;
|
||||||
|
|
|
@ -15,32 +15,32 @@
|
||||||
#include <PacketSender.h>
|
#include <PacketSender.h>
|
||||||
#include <ReceivedPacketProcessor.h>
|
#include <ReceivedPacketProcessor.h>
|
||||||
|
|
||||||
|
|
||||||
#include "JurisdictionMap.h"
|
#include "JurisdictionMap.h"
|
||||||
|
|
||||||
/// Sends out PACKET_TYPE_JURISDICTION_REQUEST packets to all voxel servers and then listens for and processes
|
/// Sends out PACKET_TYPE_JURISDICTION_REQUEST packets to all voxel servers and then listens for and processes
|
||||||
/// the PACKET_TYPE_JURISDICTION packets it receives in order to maintain an accurate state of all jurisidictions
|
/// the PACKET_TYPE_JURISDICTION packets it receives in order to maintain an accurate state of all jurisidictions
|
||||||
/// within the domain. As with other ReceivedPacketProcessor classes the user is responsible for reading inbound packets
|
/// within the domain. As with other ReceivedPacketProcessor classes the user is responsible for reading inbound packets
|
||||||
/// and adding them to the processing queue by calling queueReceivedPacket()
|
/// and adding them to the processing queue by calling queueReceivedPacket()
|
||||||
class JurisdictionListener : public NodeListHook, public PacketSender, public ReceivedPacketProcessor {
|
class JurisdictionListener : public PacketSender, public ReceivedPacketProcessor {
|
||||||
public:
|
public:
|
||||||
static const int DEFAULT_PACKETS_PER_SECOND = 1;
|
static const int DEFAULT_PACKETS_PER_SECOND = 1;
|
||||||
static const int NO_SERVER_CHECK_RATE = 60; // if no servers yet detected, keep checking at 60fps
|
static const int NO_SERVER_CHECK_RATE = 60; // if no servers yet detected, keep checking at 60fps
|
||||||
|
|
||||||
JurisdictionListener(NODE_TYPE type = NODE_TYPE_VOXEL_SERVER, PacketSenderNotify* notify = NULL);
|
JurisdictionListener(NODE_TYPE type = NODE_TYPE_VOXEL_SERVER, PacketSenderNotify* notify = NULL);
|
||||||
~JurisdictionListener();
|
|
||||||
|
|
||||||
virtual bool process();
|
virtual bool process();
|
||||||
|
|
||||||
NodeToJurisdictionMap* getJurisdictions() { return &_jurisdictions; };
|
NodeToJurisdictionMap* getJurisdictions() { return &_jurisdictions; };
|
||||||
|
|
||||||
/// Called by NodeList to inform us that a node has been added.
|
|
||||||
void nodeAdded(Node* node);
|
|
||||||
/// Called by NodeList to inform us that a node has been killed.
|
|
||||||
void nodeKilled(Node* node);
|
|
||||||
|
|
||||||
NODE_TYPE getNodeType() const { return _nodeType; }
|
NODE_TYPE getNodeType() const { return _nodeType; }
|
||||||
void setNodeType(NODE_TYPE type) { _nodeType = type; }
|
void setNodeType(NODE_TYPE type) { _nodeType = type; }
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
/// Called by NodeList to inform us that a node has been killed.
|
||||||
|
void nodeKilled(SharedNodePointer node);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/// Callback for processing of received packets. Will process any queued PACKET_TYPE_JURISDICTION and update the
|
/// Callback for processing of received packets. Will process any queued PACKET_TYPE_JURISDICTION and update the
|
||||||
/// jurisdiction map member variable
|
/// jurisdiction map member variable
|
||||||
|
|
|
@ -32,7 +32,7 @@ JurisdictionSender::~JurisdictionSender() {
|
||||||
|
|
||||||
void JurisdictionSender::processPacket(const HifiSockAddr& senderAddress, unsigned char* packetData, ssize_t packetLength) {
|
void JurisdictionSender::processPacket(const HifiSockAddr& senderAddress, unsigned char* packetData, ssize_t packetLength) {
|
||||||
if (packetData[0] == PACKET_TYPE_JURISDICTION_REQUEST) {
|
if (packetData[0] == PACKET_TYPE_JURISDICTION_REQUEST) {
|
||||||
Node* node = NodeList::getInstance()->nodeWithAddress(senderAddress);
|
SharedNodePointer node = NodeList::getInstance()->nodeWithAddress(senderAddress);
|
||||||
if (node) {
|
if (node) {
|
||||||
QUuid nodeUUID = node->getUUID();
|
QUuid nodeUUID = node->getUUID();
|
||||||
lockRequestingNodes();
|
lockRequestingNodes();
|
||||||
|
@ -64,7 +64,7 @@ bool JurisdictionSender::process() {
|
||||||
|
|
||||||
QUuid nodeUUID = _nodesRequestingJurisdictions.front();
|
QUuid nodeUUID = _nodesRequestingJurisdictions.front();
|
||||||
_nodesRequestingJurisdictions.pop();
|
_nodesRequestingJurisdictions.pop();
|
||||||
Node* node = NodeList::getInstance()->nodeWithUUID(nodeUUID);
|
SharedNodePointer node = NodeList::getInstance()->nodeWithUUID(nodeUUID);
|
||||||
|
|
||||||
if (node->getActiveSocket() != NULL) {
|
if (node->getActiveSocket() != NULL) {
|
||||||
const HifiSockAddr* nodeAddress = node->getActiveSocket();
|
const HifiSockAddr* nodeAddress = node->getActiveSocket();
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
/// to requesting parties. As with other ReceivedPacketProcessor classes the user is responsible for reading inbound packets
|
/// to requesting parties. As with other ReceivedPacketProcessor classes the user is responsible for reading inbound packets
|
||||||
/// and adding them to the processing queue by calling queueReceivedPacket()
|
/// and adding them to the processing queue by calling queueReceivedPacket()
|
||||||
class JurisdictionSender : public PacketSender, public ReceivedPacketProcessor {
|
class JurisdictionSender : public PacketSender, public ReceivedPacketProcessor {
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
static const int DEFAULT_PACKETS_PER_SECOND = 1;
|
static const int DEFAULT_PACKETS_PER_SECOND = 1;
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,8 @@ bool OctreeEditPacketSender::serversExist() const {
|
||||||
bool hasServers = false;
|
bool hasServers = false;
|
||||||
bool atLeastOnJurisdictionMissing = false; // assume the best
|
bool atLeastOnJurisdictionMissing = false; // assume the best
|
||||||
NodeList* nodeList = NodeList::getInstance();
|
NodeList* nodeList = NodeList::getInstance();
|
||||||
for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
|
|
||||||
|
foreach(SharedNodePointer node, nodeList->getNodeHash()) {
|
||||||
// only send to the NodeTypes that are getMyNodeType()
|
// only send to the NodeTypes that are getMyNodeType()
|
||||||
if (node->getType() == getMyNodeType()) {
|
if (node->getType() == getMyNodeType()) {
|
||||||
if (nodeList->getNodeActiveSocketOrPing(&(*node))) {
|
if (nodeList->getNodeActiveSocketOrPing(&(*node))) {
|
||||||
|
@ -77,6 +78,7 @@ bool OctreeEditPacketSender::serversExist() const {
|
||||||
break; // no point in looking further...
|
break; // no point in looking further...
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (hasServers && !atLeastOnJurisdictionMissing);
|
return (hasServers && !atLeastOnJurisdictionMissing);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +86,8 @@ bool OctreeEditPacketSender::serversExist() const {
|
||||||
// a known nodeID.
|
// a known nodeID.
|
||||||
void OctreeEditPacketSender::queuePacketToNode(const QUuid& nodeUUID, unsigned char* buffer, ssize_t length) {
|
void OctreeEditPacketSender::queuePacketToNode(const QUuid& nodeUUID, unsigned char* buffer, ssize_t length) {
|
||||||
NodeList* nodeList = NodeList::getInstance();
|
NodeList* nodeList = NodeList::getInstance();
|
||||||
for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
|
|
||||||
|
foreach(SharedNodePointer node, nodeList->getNodeHash()) {
|
||||||
// only send to the NodeTypes that are getMyNodeType()
|
// only send to the NodeTypes that are getMyNodeType()
|
||||||
if (node->getType() == getMyNodeType() &&
|
if (node->getType() == getMyNodeType() &&
|
||||||
((node->getUUID() == nodeUUID) || (nodeUUID.isNull()))) {
|
((node->getUUID() == nodeUUID) || (nodeUUID.isNull()))) {
|
||||||
|
@ -166,8 +169,8 @@ void OctreeEditPacketSender::queuePacketToNodes(unsigned char* buffer, ssize_t l
|
||||||
// But we can't really do that with a packed message, since each edit message could be destined
|
// But we can't really do that with a packed message, since each edit message could be destined
|
||||||
// for a different server... So we need to actually manage multiple queued packets... one
|
// for a different server... So we need to actually manage multiple queued packets... one
|
||||||
// for each server
|
// for each server
|
||||||
NodeList* nodeList = NodeList::getInstance();
|
|
||||||
for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
|
foreach(SharedNodePointer node, NodeList::getInstance()->getNodeHash()) {
|
||||||
// only send to the NodeTypes that are getMyNodeType()
|
// only send to the NodeTypes that are getMyNodeType()
|
||||||
if (node->getActiveSocket() != NULL && node->getType() == getMyNodeType()) {
|
if (node->getActiveSocket() != NULL && node->getType() == getMyNodeType()) {
|
||||||
QUuid nodeUUID = node->getUUID();
|
QUuid nodeUUID = node->getUUID();
|
||||||
|
@ -212,8 +215,8 @@ void OctreeEditPacketSender::queueOctreeEditMessage(PACKET_TYPE type, unsigned c
|
||||||
// But we can't really do that with a packed message, since each edit message could be destined
|
// But we can't really do that with a packed message, since each edit message could be destined
|
||||||
// for a different server... So we need to actually manage multiple queued packets... one
|
// for a different server... So we need to actually manage multiple queued packets... one
|
||||||
// for each server
|
// for each server
|
||||||
NodeList* nodeList = NodeList::getInstance();
|
|
||||||
for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
|
foreach(SharedNodePointer node, NodeList::getInstance()->getNodeHash()) {
|
||||||
// only send to the NodeTypes that are getMyNodeType()
|
// only send to the NodeTypes that are getMyNodeType()
|
||||||
if (node->getActiveSocket() != NULL && node->getType() == getMyNodeType()) {
|
if (node->getActiveSocket() != NULL && node->getType() == getMyNodeType()) {
|
||||||
QUuid nodeUUID = node->getUUID();
|
QUuid nodeUUID = node->getUUID();
|
||||||
|
|
|
@ -187,8 +187,8 @@ void ParticleCollisionSystem::updateCollisionWithAvatars(Particle* particle) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// loop through all the other avatars for potential interactions...
|
// loop through all the other avatars for potential interactions...
|
||||||
NodeList* nodeList = NodeList::getInstance();
|
|
||||||
for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
|
foreach(SharedNodePointer node, NodeList::getInstance()->getNodeHash()) {
|
||||||
//qDebug() << "updateCollisionWithAvatars()... node:" << *node << "\n";
|
//qDebug() << "updateCollisionWithAvatars()... node:" << *node << "\n";
|
||||||
if (node->getLinkedData() && node->getType() == NODE_TYPE_AGENT) {
|
if (node->getLinkedData() && node->getType() == NODE_TYPE_AGENT) {
|
||||||
// TODO: dot collidingPalm and hand velocities and skip collision when they are moving apart.
|
// TODO: dot collidingPalm and hand velocities and skip collision when they are moving apart.
|
||||||
|
|
|
@ -52,10 +52,9 @@ NodeList* NodeList::getInstance() {
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeList::NodeList(char newOwnerType, unsigned short int newSocketListenPort) :
|
NodeList::NodeList(char newOwnerType, unsigned short int newSocketListenPort) :
|
||||||
|
_nodeHash(),
|
||||||
_domainHostname(DEFAULT_DOMAIN_HOSTNAME),
|
_domainHostname(DEFAULT_DOMAIN_HOSTNAME),
|
||||||
_domainSockAddr(HifiSockAddr(QHostAddress::Null, DEFAULT_DOMAIN_SERVER_PORT)),
|
_domainSockAddr(HifiSockAddr(QHostAddress::Null, DEFAULT_DOMAIN_SERVER_PORT)),
|
||||||
_nodeBuckets(),
|
|
||||||
_numNodes(0),
|
|
||||||
_nodeSocket(),
|
_nodeSocket(),
|
||||||
_ownerType(newOwnerType),
|
_ownerType(newOwnerType),
|
||||||
_nodeTypesOfInterest(NULL),
|
_nodeTypesOfInterest(NULL),
|
||||||
|
@ -108,7 +107,7 @@ void NodeList::setDomainHostname(const QString& domainHostname) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeList::timePingReply(const HifiSockAddr& nodeAddress, unsigned char *packetData) {
|
void NodeList::timePingReply(const HifiSockAddr& nodeAddress, unsigned char *packetData) {
|
||||||
for(NodeList::iterator node = begin(); node != end(); node++) {
|
foreach(SharedNodePointer node, _nodeHash) {
|
||||||
if (node->getPublicSocket() == nodeAddress ||
|
if (node->getPublicSocket() == nodeAddress ||
|
||||||
node->getLocalSocket() == nodeAddress) {
|
node->getLocalSocket() == nodeAddress) {
|
||||||
|
|
||||||
|
@ -184,10 +183,9 @@ void NodeList::processNodeData(const HifiSockAddr& senderSockAddr, unsigned char
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeList::processBulkNodeData(const HifiSockAddr& senderAddress, unsigned char *packetData, int numTotalBytes) {
|
void NodeList::processBulkNodeData(const HifiSockAddr& senderAddress, unsigned char *packetData, int numTotalBytes) {
|
||||||
|
SharedNodePointer bulkSendNode = nodeWithAddress(senderAddress);
|
||||||
|
|
||||||
// find the avatar mixer in our node list and update the lastRecvTime from it
|
// find the avatar mixer in our node list and update the lastRecvTime from it
|
||||||
Node* bulkSendNode = nodeWithAddress(senderAddress);
|
|
||||||
|
|
||||||
if (bulkSendNode) {
|
if (bulkSendNode) {
|
||||||
|
|
||||||
bulkSendNode->setLastHeardMicrostamp(usecTimestampNow());
|
bulkSendNode->setLastHeardMicrostamp(usecTimestampNow());
|
||||||
|
@ -209,14 +207,14 @@ void NodeList::processBulkNodeData(const HifiSockAddr& senderAddress, unsigned c
|
||||||
numTotalBytes - (currentPosition - startPosition));
|
numTotalBytes - (currentPosition - startPosition));
|
||||||
|
|
||||||
QUuid nodeUUID = QUuid::fromRfc4122(QByteArray((char*)currentPosition, NUM_BYTES_RFC4122_UUID));
|
QUuid nodeUUID = QUuid::fromRfc4122(QByteArray((char*)currentPosition, NUM_BYTES_RFC4122_UUID));
|
||||||
Node* matchingNode = nodeWithUUID(nodeUUID);
|
SharedNodePointer matchingNode = nodeWithUUID(nodeUUID);
|
||||||
|
|
||||||
if (!matchingNode) {
|
if (!matchingNode) {
|
||||||
// we're missing this node, we need to add it to the list
|
// we're missing this node, we need to add it to the list
|
||||||
matchingNode = addOrUpdateNode(nodeUUID, NODE_TYPE_AGENT, HifiSockAddr(), HifiSockAddr());
|
matchingNode = addOrUpdateNode(nodeUUID, NODE_TYPE_AGENT, HifiSockAddr(), HifiSockAddr());
|
||||||
}
|
}
|
||||||
|
|
||||||
currentPosition += updateNodeWithData(matchingNode,
|
currentPosition += updateNodeWithData(matchingNode.data(),
|
||||||
HifiSockAddr(),
|
HifiSockAddr(),
|
||||||
packetHolder,
|
packetHolder,
|
||||||
numTotalBytes - (currentPosition - startPosition));
|
numTotalBytes - (currentPosition - startPosition));
|
||||||
|
@ -253,53 +251,39 @@ int NodeList::updateNodeWithData(Node *node, const HifiSockAddr& senderSockAddr,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Node* NodeList::nodeWithAddress(const HifiSockAddr &senderSockAddr) {
|
QSharedPointer<Node> NodeList::nodeWithAddress(const HifiSockAddr &senderSockAddr) {
|
||||||
for(NodeList::iterator node = begin(); node != end(); node++) {
|
// naively returns the first node that has a matching active HifiSockAddr
|
||||||
|
// note that there can be multiple nodes that have a matching active socket, so this isn't a good way to uniquely identify
|
||||||
|
foreach(QSharedPointer<Node> node, _nodeHash) {
|
||||||
if (node->getActiveSocket() && *node->getActiveSocket() == senderSockAddr) {
|
if (node->getActiveSocket() && *node->getActiveSocket() == senderSockAddr) {
|
||||||
return &(*node);
|
return node;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return QSharedPointer<Node>(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
Node* NodeList::nodeWithUUID(const QUuid& nodeUUID) {
|
QSharedPointer<Node> NodeList::nodeWithUUID(const QUuid& nodeUUID) {
|
||||||
for(NodeList::iterator node = begin(); node != end(); node++) {
|
QHash<QUuid, QSharedPointer<Node> >::const_iterator foundIterator = _nodeHash.find(nodeUUID);
|
||||||
if (node->getUUID() == nodeUUID) {
|
if (foundIterator != _nodeHash.end()) {
|
||||||
return &(*node);
|
return foundIterator.value();
|
||||||
|
} else {
|
||||||
|
return QSharedPointer<Node>(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int NodeList::getNumAliveNodes() const {
|
|
||||||
int numAliveNodes = 0;
|
|
||||||
|
|
||||||
for (NodeList::iterator node = begin(); node != end(); node++) {
|
|
||||||
if (node->isAlive()) {
|
|
||||||
++numAliveNodes;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return numAliveNodes;
|
|
||||||
}
|
|
||||||
|
|
||||||
void NodeList::clear() {
|
void NodeList::clear() {
|
||||||
qDebug() << "Clearing the NodeList. Deleting all nodes in list.\n";
|
qDebug() << "Clearing the NodeList. Deleting all nodes in list.\n";
|
||||||
|
|
||||||
// delete all of the nodes in the list, set the pointers back to NULL and the number of nodes to 0
|
NodeHash::iterator nodeItem = _nodeHash.begin();
|
||||||
for (int i = 0; i < _numNodes; i++) {
|
|
||||||
Node** nodeBucket = _nodeBuckets[i / NODES_PER_BUCKET];
|
|
||||||
Node* node = nodeBucket[i % NODES_PER_BUCKET];
|
|
||||||
|
|
||||||
node->lock();
|
// iterate the nodes in the list
|
||||||
notifyHooksOfKilledNode(&*node);
|
while (nodeItem != _nodeHash.end()) {
|
||||||
|
// emit our signal to say this node has been killed
|
||||||
delete node;
|
emit nodeKilled(nodeItem.value());
|
||||||
|
// erase the node from our node hash
|
||||||
|
_nodeHash.erase(nodeItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
_numNodes = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeList::reset() {
|
void NodeList::reset() {
|
||||||
|
@ -457,6 +441,14 @@ void NodeList::processSTUNResponse(unsigned char* packetData, size_t dataBytes)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NodeList::killNodeWithUUID(const QUuid& nodeUUID) {
|
||||||
|
NodeHash::iterator nodeToKill = _nodeHash.find(nodeUUID);
|
||||||
|
if (nodeToKill != _nodeHash.end()) {
|
||||||
|
emit nodeKilled(nodeToKill.value());
|
||||||
|
_nodeHash.erase(nodeToKill);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void NodeList::sendKillNode(const char* nodeTypes, int numNodeTypes) {
|
void NodeList::sendKillNode(const char* nodeTypes, int numNodeTypes) {
|
||||||
unsigned char packet[MAX_PACKET_SIZE];
|
unsigned char packet[MAX_PACKET_SIZE];
|
||||||
unsigned char* packetPosition = packet;
|
unsigned char* packetPosition = packet;
|
||||||
|
@ -483,9 +475,10 @@ void NodeList::processKillNode(unsigned char* packetData, size_t dataBytes) {
|
||||||
dataBytes -= NUM_BYTES_RFC4122_UUID;
|
dataBytes -= NUM_BYTES_RFC4122_UUID;
|
||||||
|
|
||||||
// make sure the node exists
|
// make sure the node exists
|
||||||
Node* node = nodeWithUUID(nodeUUID);
|
NodeHash::iterator nodeToKill = _nodeHash.find(nodeUUID);
|
||||||
if (node) {
|
if (nodeToKill != _nodeHash.end()) {
|
||||||
killNode(node, true);
|
emit nodeKilled(nodeToKill.value());
|
||||||
|
_nodeHash.erase(nodeToKill);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -681,26 +674,24 @@ void NodeList::pingPublicAndLocalSocketsForInactiveNode(Node* node) {
|
||||||
node->getPublicSocket().getAddress(), node->getPublicSocket().getPort());
|
node->getPublicSocket().getAddress(), node->getPublicSocket().getPort());
|
||||||
}
|
}
|
||||||
|
|
||||||
Node* NodeList::addOrUpdateNode(const QUuid& uuid, char nodeType,
|
SharedNodePointer NodeList::addOrUpdateNode(const QUuid& uuid, char nodeType,
|
||||||
const HifiSockAddr& publicSocket, const HifiSockAddr& localSocket) {
|
const HifiSockAddr& publicSocket, const HifiSockAddr& localSocket) {
|
||||||
NodeList::iterator node = end();
|
NodeHash::iterator matchingNodeItem = _nodeHash.find(uuid);
|
||||||
|
|
||||||
for (node = begin(); node != end(); node++) {
|
if (matchingNodeItem == _nodeHash.end()) {
|
||||||
if (node->getUUID() == uuid) {
|
|
||||||
// we already have this node, stop checking
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (node == end()) {
|
|
||||||
// we didn't have this node, so add them
|
// we didn't have this node, so add them
|
||||||
Node* newNode = new Node(uuid, nodeType, publicSocket, localSocket);
|
Node* newNode = new Node(uuid, nodeType, publicSocket, localSocket);
|
||||||
|
|
||||||
addNodeToList(newNode);
|
NodeHash::iterator addedItem = _nodeHash.insert(newNode->getUUID(), SharedNodePointer(newNode));
|
||||||
|
|
||||||
return newNode;
|
qDebug() << "Added" << *newNode << "\n";
|
||||||
|
|
||||||
|
emit nodeAdded(addedItem.value());
|
||||||
|
|
||||||
|
return SharedNodePointer(newNode);
|
||||||
} else {
|
} else {
|
||||||
node->lock();
|
SharedNodePointer node = matchingNodeItem.value();
|
||||||
|
matchingNodeItem.value()->lock();
|
||||||
|
|
||||||
if (node->getType() == NODE_TYPE_AUDIO_MIXER ||
|
if (node->getType() == NODE_TYPE_AUDIO_MIXER ||
|
||||||
node->getType() == NODE_TYPE_VOXEL_SERVER ||
|
node->getType() == NODE_TYPE_VOXEL_SERVER ||
|
||||||
|
@ -724,33 +715,17 @@ Node* NodeList::addOrUpdateNode(const QUuid& uuid, char nodeType,
|
||||||
node->unlock();
|
node->unlock();
|
||||||
|
|
||||||
// we had this node already, do nothing for now
|
// we had this node already, do nothing for now
|
||||||
return &*node;
|
return node;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeList::addNodeToList(Node* newNode) {
|
|
||||||
// find the correct array to add this node to
|
|
||||||
int bucketIndex = _numNodes / NODES_PER_BUCKET;
|
|
||||||
|
|
||||||
if (!_nodeBuckets[bucketIndex]) {
|
|
||||||
_nodeBuckets[bucketIndex] = new Node*[NODES_PER_BUCKET]();
|
|
||||||
}
|
|
||||||
|
|
||||||
_nodeBuckets[bucketIndex][_numNodes % NODES_PER_BUCKET] = newNode;
|
|
||||||
|
|
||||||
++_numNodes;
|
|
||||||
|
|
||||||
qDebug() << "Added" << *newNode << "\n";
|
|
||||||
|
|
||||||
notifyHooksOfAddedNode(newNode);
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned NodeList::broadcastToNodes(unsigned char* broadcastData, size_t dataBytes, const char* nodeTypes, int numNodeTypes) {
|
unsigned NodeList::broadcastToNodes(unsigned char* broadcastData, size_t dataBytes, const char* nodeTypes, int numNodeTypes) {
|
||||||
unsigned n = 0;
|
unsigned n = 0;
|
||||||
for(NodeList::iterator node = begin(); node != end(); node++) {
|
|
||||||
|
foreach(SharedNodePointer node, _nodeHash) {
|
||||||
// only send to the NodeTypes we are asked to send to.
|
// only send to the NodeTypes we are asked to send to.
|
||||||
if (memchr(nodeTypes, node->getType(), numNodeTypes)) {
|
if (memchr(nodeTypes, node->getType(), numNodeTypes)) {
|
||||||
if (getNodeActiveSocketOrPing(&(*node))) {
|
if (getNodeActiveSocketOrPing(node.data())) {
|
||||||
// we know which socket is good for this node, send there
|
// we know which socket is good for this node, send there
|
||||||
_nodeSocket.writeDatagram((char*) broadcastData, dataBytes,
|
_nodeSocket.writeDatagram((char*) broadcastData, dataBytes,
|
||||||
node->getActiveSocket()->getAddress(), node->getActiveSocket()->getPort());
|
node->getActiveSocket()->getAddress(), node->getActiveSocket()->getPort());
|
||||||
|
@ -758,14 +733,15 @@ unsigned NodeList::broadcastToNodes(unsigned char* broadcastData, size_t dataByt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeList::pingInactiveNodes() {
|
void NodeList::pingInactiveNodes() {
|
||||||
for(NodeList::iterator node = begin(); node != end(); node++) {
|
foreach(SharedNodePointer node, _nodeHash) {
|
||||||
if (!node->getActiveSocket()) {
|
if (!node->getActiveSocket()) {
|
||||||
// we don't have an active link to this node, ping it to set that up
|
// we don't have an active link to this node, ping it to set that up
|
||||||
pingPublicAndLocalSocketsForInactiveNode(&(*node));
|
pingPublicAndLocalSocketsForInactiveNode(node.data());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -780,7 +756,8 @@ const HifiSockAddr* NodeList::getNodeActiveSocketOrPing(Node* node) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeList::activateSocketFromNodeCommunication(const HifiSockAddr& nodeAddress) {
|
void NodeList::activateSocketFromNodeCommunication(const HifiSockAddr& nodeAddress) {
|
||||||
for(NodeList::iterator node = begin(); node != end(); node++) {
|
|
||||||
|
foreach(SharedNodePointer node, _nodeHash) {
|
||||||
if (!node->getActiveSocket()) {
|
if (!node->getActiveSocket()) {
|
||||||
// check both the public and local addresses for each node to see if we find a match
|
// check both the public and local addresses for each node to see if we find a match
|
||||||
// prioritize the private address so that we prune erroneous local matches
|
// prioritize the private address so that we prune erroneous local matches
|
||||||
|
@ -795,48 +772,37 @@ void NodeList::activateSocketFromNodeCommunication(const HifiSockAddr& nodeAddre
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Node* NodeList::soloNodeOfType(char nodeType) {
|
SharedNodePointer NodeList::soloNodeOfType(char nodeType) {
|
||||||
|
|
||||||
if (memchr(SOLO_NODE_TYPES, nodeType, sizeof(SOLO_NODE_TYPES)) != NULL) {
|
if (memchr(SOLO_NODE_TYPES, nodeType, sizeof(SOLO_NODE_TYPES)) != NULL) {
|
||||||
for(NodeList::iterator node = begin(); node != end(); node++) {
|
foreach(SharedNodePointer node, _nodeHash) {
|
||||||
if (node->getType() == nodeType) {
|
if (node->getType() == nodeType) {
|
||||||
return &(*node);
|
return node;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return SharedNodePointer(NULL);
|
||||||
}
|
|
||||||
|
|
||||||
void NodeList::killNode(Node* node, bool mustLockNode) {
|
|
||||||
if (mustLockNode) {
|
|
||||||
node->lock();
|
|
||||||
}
|
|
||||||
|
|
||||||
qDebug() << "Killed " << *node << "\n";
|
|
||||||
|
|
||||||
notifyHooksOfKilledNode(&*node);
|
|
||||||
|
|
||||||
node->setAlive(false);
|
|
||||||
|
|
||||||
if (mustLockNode) {
|
|
||||||
node->unlock();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeList::removeSilentNodes() {
|
void NodeList::removeSilentNodes() {
|
||||||
NodeList* nodeList = NodeList::getInstance();
|
|
||||||
|
|
||||||
for(NodeList::iterator node = nodeList->begin(); node != nodeList->end(); ++node) {
|
NodeHash::iterator nodeItem = _nodeHash.begin();
|
||||||
node->lock();
|
|
||||||
|
while (nodeItem != _nodeHash.end()) {
|
||||||
|
nodeItem.value()->lock();
|
||||||
|
|
||||||
|
if ((usecTimestampNow() - nodeItem.value()->getLastHeardMicrostamp()) > NODE_SILENCE_THRESHOLD_USECS) {
|
||||||
|
SharedNodePointer node = nodeItem.value();
|
||||||
|
|
||||||
if ((usecTimestampNow() - node->getLastHeardMicrostamp()) > NODE_SILENCE_THRESHOLD_USECS) {
|
|
||||||
// kill this node, don't lock - we already did it
|
// kill this node, don't lock - we already did it
|
||||||
nodeList->killNode(&(*node), false);
|
_nodeHash.erase(nodeItem);
|
||||||
}
|
|
||||||
|
|
||||||
|
// unlock the node
|
||||||
node->unlock();
|
node->unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const QString QSETTINGS_GROUP_NAME = "NodeList";
|
const QString QSETTINGS_GROUP_NAME = "NodeList";
|
||||||
const QString DOMAIN_SERVER_SETTING_KEY = "domainServerHostname";
|
const QString DOMAIN_SERVER_SETTING_KEY = "domainServerHostname";
|
||||||
|
@ -868,80 +834,6 @@ void NodeList::saveData(QSettings* settings) {
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeList::iterator NodeList::begin() const {
|
|
||||||
Node** nodeBucket = NULL;
|
|
||||||
|
|
||||||
for (int i = 0; i < _numNodes; i++) {
|
|
||||||
if (i % NODES_PER_BUCKET == 0) {
|
|
||||||
nodeBucket = _nodeBuckets[i / NODES_PER_BUCKET];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nodeBucket[i % NODES_PER_BUCKET]->isAlive()) {
|
|
||||||
return NodeListIterator(this, i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// there's no alive node to start from - return the end
|
|
||||||
return end();
|
|
||||||
}
|
|
||||||
|
|
||||||
NodeList::iterator NodeList::end() const {
|
|
||||||
return NodeListIterator(this, _numNodes);
|
|
||||||
}
|
|
||||||
|
|
||||||
NodeListIterator::NodeListIterator(const NodeList* nodeList, int nodeIndex) :
|
|
||||||
_nodeIndex(nodeIndex) {
|
|
||||||
_nodeList = nodeList;
|
|
||||||
}
|
|
||||||
|
|
||||||
NodeListIterator& NodeListIterator::operator=(const NodeListIterator& otherValue) {
|
|
||||||
_nodeList = otherValue._nodeList;
|
|
||||||
_nodeIndex = otherValue._nodeIndex;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool NodeListIterator::operator==(const NodeListIterator &otherValue) {
|
|
||||||
return _nodeIndex == otherValue._nodeIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool NodeListIterator::operator!=(const NodeListIterator &otherValue) {
|
|
||||||
return !(*this == otherValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
Node& NodeListIterator::operator*() {
|
|
||||||
Node** nodeBucket = _nodeList->_nodeBuckets[_nodeIndex / NODES_PER_BUCKET];
|
|
||||||
return *nodeBucket[_nodeIndex % NODES_PER_BUCKET];
|
|
||||||
}
|
|
||||||
|
|
||||||
Node* NodeListIterator::operator->() {
|
|
||||||
Node** nodeBucket = _nodeList->_nodeBuckets[_nodeIndex / NODES_PER_BUCKET];
|
|
||||||
return nodeBucket[_nodeIndex % NODES_PER_BUCKET];
|
|
||||||
}
|
|
||||||
|
|
||||||
NodeListIterator& NodeListIterator::operator++() {
|
|
||||||
skipDeadAndStopIncrement();
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
NodeList::iterator NodeListIterator::operator++(int) {
|
|
||||||
NodeListIterator newIterator = NodeListIterator(*this);
|
|
||||||
skipDeadAndStopIncrement();
|
|
||||||
return newIterator;
|
|
||||||
}
|
|
||||||
|
|
||||||
void NodeListIterator::skipDeadAndStopIncrement() {
|
|
||||||
while (_nodeIndex != _nodeList->_numNodes) {
|
|
||||||
++_nodeIndex;
|
|
||||||
|
|
||||||
if (_nodeIndex == _nodeList->_numNodes) {
|
|
||||||
break;
|
|
||||||
} else if ((*(*this)).isAlive()) {
|
|
||||||
// skip over the dead nodes
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void NodeList::addDomainListener(DomainChangeListener* listener) {
|
void NodeList::addDomainListener(DomainChangeListener* listener) {
|
||||||
_domainListeners.push_back(listener);
|
_domainListeners.push_back(listener);
|
||||||
QString domain = _domainHostname.isEmpty() ? _domainSockAddr.getAddress().toString() : _domainHostname;
|
QString domain = _domainHostname.isEmpty() ? _domainSockAddr.getAddress().toString() : _domainHostname;
|
||||||
|
@ -957,33 +849,6 @@ void NodeList::removeDomainListener(DomainChangeListener* listener) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeList::addHook(NodeListHook* hook) {
|
|
||||||
_hooks.push_back(hook);
|
|
||||||
}
|
|
||||||
|
|
||||||
void NodeList::removeHook(NodeListHook* hook) {
|
|
||||||
for (int i = 0; i < _hooks.size(); i++) {
|
|
||||||
if (_hooks[i] == hook) {
|
|
||||||
_hooks.erase(_hooks.begin() + i);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void NodeList::notifyHooksOfAddedNode(Node* node) {
|
|
||||||
for (int i = 0; i < _hooks.size(); i++) {
|
|
||||||
//printf("NodeList::notifyHooksOfAddedNode() i=%d\n", i);
|
|
||||||
_hooks[i]->nodeAdded(node);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void NodeList::notifyHooksOfKilledNode(Node* node) {
|
|
||||||
for (int i = 0; i < _hooks.size(); i++) {
|
|
||||||
//printf("NodeList::notifyHooksOfKilledNode() i=%d\n", i);
|
|
||||||
_hooks[i]->nodeKilled(node);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void NodeList::notifyDomainChanged() {
|
void NodeList::notifyDomainChanged() {
|
||||||
for (int i = 0; i < _domainListeners.size(); i++) {
|
for (int i = 0; i < _domainListeners.size(); i++) {
|
||||||
_domainListeners[i]->domainChanged(_domainHostname);
|
_domainListeners[i]->domainChanged(_domainHostname);
|
||||||
|
|
|
@ -14,9 +14,10 @@
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <QtCore/QSettings>
|
||||||
|
#include <QtCore/QSharedPointer>
|
||||||
#include <QtNetwork/QHostAddress>
|
#include <QtNetwork/QHostAddress>
|
||||||
#include <QtNetwork/QUdpSocket>
|
#include <QtNetwork/QUdpSocket>
|
||||||
#include <QtCore/QSettings>
|
|
||||||
|
|
||||||
#include "Node.h"
|
#include "Node.h"
|
||||||
#include "NodeTypes.h"
|
#include "NodeTypes.h"
|
||||||
|
@ -43,31 +44,21 @@ const int MAX_SILENT_DOMAIN_SERVER_CHECK_INS = 5;
|
||||||
|
|
||||||
class Assignment;
|
class Assignment;
|
||||||
class HifiSockAddr;
|
class HifiSockAddr;
|
||||||
class NodeListIterator;
|
|
||||||
|
|
||||||
// Callers who want to hook add/kill callbacks should implement this class
|
|
||||||
class NodeListHook {
|
|
||||||
public:
|
|
||||||
virtual void nodeAdded(Node* node) = 0;
|
|
||||||
virtual void nodeKilled(Node* node) = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
class DomainChangeListener {
|
class DomainChangeListener {
|
||||||
public:
|
public:
|
||||||
virtual void domainChanged(QString domain) = 0;
|
virtual void domainChanged(QString domain) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef QSharedPointer<Node> SharedNodePointer;
|
||||||
|
typedef QHash<QUuid, SharedNodePointer> NodeHash;
|
||||||
|
|
||||||
class NodeList : public QObject {
|
class NodeList : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
static NodeList* createInstance(char ownerType, unsigned short int socketListenPort = 0);
|
static NodeList* createInstance(char ownerType, unsigned short int socketListenPort = 0);
|
||||||
static NodeList* getInstance();
|
static NodeList* getInstance();
|
||||||
|
|
||||||
typedef NodeListIterator iterator;
|
|
||||||
|
|
||||||
NodeListIterator begin() const;
|
|
||||||
NodeListIterator end() const;
|
|
||||||
|
|
||||||
NODE_TYPE getOwnerType() const { return _ownerType; }
|
NODE_TYPE getOwnerType() const { return _ownerType; }
|
||||||
void setOwnerType(NODE_TYPE ownerType) { _ownerType = ownerType; }
|
void setOwnerType(NODE_TYPE ownerType) { _ownerType = ownerType; }
|
||||||
|
|
||||||
|
@ -88,8 +79,9 @@ public:
|
||||||
|
|
||||||
void(*linkedDataCreateCallback)(Node *);
|
void(*linkedDataCreateCallback)(Node *);
|
||||||
|
|
||||||
int size() { return _numNodes; }
|
const NodeHash& getNodeHash() { return _nodeHash; }
|
||||||
int getNumAliveNodes() const;
|
|
||||||
|
int size() const { return _nodeHash.size(); }
|
||||||
|
|
||||||
int getNumNoReplyDomainCheckIns() const { return _numNoReplyDomainCheckIns; }
|
int getNumNoReplyDomainCheckIns() const { return _numNoReplyDomainCheckIns; }
|
||||||
|
|
||||||
|
@ -107,13 +99,13 @@ public:
|
||||||
int fillPingReplyPacket(unsigned char* pingBuffer, unsigned char* replyBuffer);
|
int fillPingReplyPacket(unsigned char* pingBuffer, unsigned char* replyBuffer);
|
||||||
void pingPublicAndLocalSocketsForInactiveNode(Node* node);
|
void pingPublicAndLocalSocketsForInactiveNode(Node* node);
|
||||||
|
|
||||||
|
void killNodeWithUUID(const QUuid& nodeUUID);
|
||||||
void sendKillNode(const char* nodeTypes, int numNodeTypes);
|
void sendKillNode(const char* nodeTypes, int numNodeTypes);
|
||||||
|
|
||||||
Node* nodeWithAddress(const HifiSockAddr& senderSockAddr);
|
SharedNodePointer nodeWithAddress(const HifiSockAddr& senderSockAddr);
|
||||||
Node* nodeWithUUID(const QUuid& nodeUUID);
|
SharedNodePointer nodeWithUUID(const QUuid& nodeUUID);
|
||||||
|
|
||||||
Node* addOrUpdateNode(const QUuid& uuid, char nodeType, const HifiSockAddr& publicSocket, const HifiSockAddr& localSocket);
|
SharedNodePointer addOrUpdateNode(const QUuid& uuid, char nodeType, const HifiSockAddr& publicSocket, const HifiSockAddr& localSocket);
|
||||||
void killNode(Node* node, bool mustLockNode = true);
|
|
||||||
|
|
||||||
void processNodeData(const HifiSockAddr& senderSockAddr, unsigned char *packetData, size_t dataBytes);
|
void processNodeData(const HifiSockAddr& senderSockAddr, unsigned char *packetData, size_t dataBytes);
|
||||||
void processBulkNodeData(const HifiSockAddr& senderSockAddr, unsigned char *packetData, int numTotalBytes);
|
void processBulkNodeData(const HifiSockAddr& senderSockAddr, unsigned char *packetData, int numTotalBytes);
|
||||||
|
@ -122,18 +114,11 @@ public:
|
||||||
|
|
||||||
unsigned broadcastToNodes(unsigned char *broadcastData, size_t dataBytes, const char* nodeTypes, int numNodeTypes);
|
unsigned broadcastToNodes(unsigned char *broadcastData, size_t dataBytes, const char* nodeTypes, int numNodeTypes);
|
||||||
|
|
||||||
Node* soloNodeOfType(char nodeType);
|
SharedNodePointer soloNodeOfType(char nodeType);
|
||||||
|
|
||||||
void loadData(QSettings* settings);
|
void loadData(QSettings* settings);
|
||||||
void saveData(QSettings* settings);
|
void saveData(QSettings* settings);
|
||||||
|
|
||||||
friend class NodeListIterator;
|
|
||||||
|
|
||||||
void addHook(NodeListHook* hook);
|
|
||||||
void removeHook(NodeListHook* hook);
|
|
||||||
void notifyHooksOfAddedNode(Node* node);
|
|
||||||
void notifyHooksOfKilledNode(Node* node);
|
|
||||||
|
|
||||||
void addDomainListener(DomainChangeListener* listener);
|
void addDomainListener(DomainChangeListener* listener);
|
||||||
void removeDomainListener(DomainChangeListener* listener);
|
void removeDomainListener(DomainChangeListener* listener);
|
||||||
|
|
||||||
|
@ -142,6 +127,9 @@ public slots:
|
||||||
void sendDomainServerCheckIn();
|
void sendDomainServerCheckIn();
|
||||||
void pingInactiveNodes();
|
void pingInactiveNodes();
|
||||||
void removeSilentNodes();
|
void removeSilentNodes();
|
||||||
|
signals:
|
||||||
|
void nodeAdded(QSharedPointer<Node>);
|
||||||
|
void nodeKilled(QSharedPointer<Node>);
|
||||||
private:
|
private:
|
||||||
static NodeList* _sharedInstance;
|
static NodeList* _sharedInstance;
|
||||||
|
|
||||||
|
@ -150,17 +138,14 @@ private:
|
||||||
NodeList(NodeList const&); // Don't implement, needed to avoid copies of singleton
|
NodeList(NodeList const&); // Don't implement, needed to avoid copies of singleton
|
||||||
void operator=(NodeList const&); // Don't implement, needed to avoid copies of singleton
|
void operator=(NodeList const&); // Don't implement, needed to avoid copies of singleton
|
||||||
|
|
||||||
void addNodeToList(Node* newNode);
|
|
||||||
|
|
||||||
void sendSTUNRequest();
|
void sendSTUNRequest();
|
||||||
void processSTUNResponse(unsigned char* packetData, size_t dataBytes);
|
void processSTUNResponse(unsigned char* packetData, size_t dataBytes);
|
||||||
|
|
||||||
void processKillNode(unsigned char* packetData, size_t dataBytes);
|
void processKillNode(unsigned char* packetData, size_t dataBytes);
|
||||||
|
|
||||||
|
NodeHash _nodeHash;
|
||||||
QString _domainHostname;
|
QString _domainHostname;
|
||||||
HifiSockAddr _domainSockAddr;
|
HifiSockAddr _domainSockAddr;
|
||||||
Node** _nodeBuckets[MAX_NUM_NODES / NODES_PER_BUCKET];
|
|
||||||
int _numNodes;
|
|
||||||
QUdpSocket _nodeSocket;
|
QUdpSocket _nodeSocket;
|
||||||
char _ownerType;
|
char _ownerType;
|
||||||
char* _nodeTypesOfInterest;
|
char* _nodeTypesOfInterest;
|
||||||
|
@ -174,7 +159,6 @@ private:
|
||||||
void activateSocketFromNodeCommunication(const HifiSockAddr& nodeSockAddr);
|
void activateSocketFromNodeCommunication(const HifiSockAddr& nodeSockAddr);
|
||||||
void timePingReply(const HifiSockAddr& nodeAddress, unsigned char *packetData);
|
void timePingReply(const HifiSockAddr& nodeAddress, unsigned char *packetData);
|
||||||
|
|
||||||
std::vector<NodeListHook*> _hooks;
|
|
||||||
std::vector<DomainChangeListener*> _domainListeners;
|
std::vector<DomainChangeListener*> _domainListeners;
|
||||||
|
|
||||||
void resetDomainData(char domainField[], const char* domainData);
|
void resetDomainData(char domainField[], const char* domainData);
|
||||||
|
@ -182,27 +166,4 @@ private:
|
||||||
void domainLookup();
|
void domainLookup();
|
||||||
};
|
};
|
||||||
|
|
||||||
class NodeListIterator : public std::iterator<std::input_iterator_tag, Node> {
|
|
||||||
public:
|
|
||||||
NodeListIterator(const NodeList* nodeList, int nodeIndex);
|
|
||||||
|
|
||||||
int getNodeIndex() { return _nodeIndex; }
|
|
||||||
|
|
||||||
NodeListIterator& operator=(const NodeListIterator& otherValue);
|
|
||||||
|
|
||||||
bool operator==(const NodeListIterator& otherValue);
|
|
||||||
bool operator!= (const NodeListIterator& otherValue);
|
|
||||||
|
|
||||||
Node& operator*();
|
|
||||||
Node* operator->();
|
|
||||||
|
|
||||||
NodeListIterator& operator++();
|
|
||||||
NodeListIterator operator++(int);
|
|
||||||
private:
|
|
||||||
void skipDeadAndStopIncrement();
|
|
||||||
|
|
||||||
const NodeList* _nodeList;
|
|
||||||
int _nodeIndex;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* defined(__hifi__NodeList__) */
|
#endif /* defined(__hifi__NodeList__) */
|
||||||
|
|
|
@ -18,7 +18,7 @@ ReceivedPacketProcessor::ReceivedPacketProcessor() {
|
||||||
|
|
||||||
void ReceivedPacketProcessor::queueReceivedPacket(const HifiSockAddr& address, unsigned char* packetData, ssize_t packetLength) {
|
void ReceivedPacketProcessor::queueReceivedPacket(const HifiSockAddr& address, unsigned char* packetData, ssize_t packetLength) {
|
||||||
// Make sure our Node and NodeList knows we've heard from this node.
|
// Make sure our Node and NodeList knows we've heard from this node.
|
||||||
Node* node = NodeList::getInstance()->nodeWithAddress(address);
|
SharedNodePointer node = NodeList::getInstance()->nodeWithAddress(address);
|
||||||
if (node) {
|
if (node) {
|
||||||
node->setLastHeardMicrostamp(usecTimestampNow());
|
node->setLastHeardMicrostamp(usecTimestampNow());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue