From 952365a1b7a6ab248e43bf6dd92d75d4b443496b Mon Sep 17 00:00:00 2001 From: Brad Hefta-Gaub Date: Wed, 15 Jan 2014 12:50:36 -0800 Subject: [PATCH] clean up comments and tab spacing --- assignment-client/src/audio/AudioMixer.cpp | 11 +-- domain-server/src/DomainServer.cpp | 45 ++++++----- interface/CMakeLists.txt | 32 ++++---- interface/src/Application.cpp | 92 +++++++++++----------- 4 files changed, 90 insertions(+), 90 deletions(-) diff --git a/assignment-client/src/audio/AudioMixer.cpp b/assignment-client/src/audio/AudioMixer.cpp index bad297e5df..aa54c874ef 100644 --- a/assignment-client/src/audio/AudioMixer.cpp +++ b/assignment-client/src/audio/AudioMixer.cpp @@ -217,12 +217,12 @@ void AudioMixer::processDatagram(const QByteArray& dataByteArray, const HifiSock NUM_BYTES_RFC4122_UUID)); NodeList* nodeList = NodeList::getInstance(); - + SharedNodePointer matchingNode = nodeList->nodeWithUUID(nodeUUID); - + if (matchingNode) { nodeList->updateNodeWithData(matchingNode.data(), senderSockAddr, (unsigned char*) dataByteArray.data(), dataByteArray.size()); - + if (!matchingNode->getActiveSocket()) { // we don't have an active socket for this node, but they're talking to us // this means they've heard from us and can reply, let's assume public is active @@ -252,6 +252,7 @@ void AudioMixer::run() { gettimeofday(&startTime, NULL); int numBytesPacketHeader = numBytesForPacketHeader((unsigned char*) &PACKET_TYPE_MIXED_AUDIO); + // note: Visual Studio 2010 doesn't support variable sized local arrays #ifdef _WIN32 unsigned char clientPacket[MAX_PACKET_SIZE]; #else @@ -266,7 +267,7 @@ void AudioMixer::run() { if (_isFinished) { break; } - + foreach (const SharedNodePointer& node, nodeList->getNodeHash()) { if (node->getLinkedData()) { ((AudioMixerClientData*) node->getLinkedData())->checkBuffersBeforeFrameSend(JITTER_BUFFER_SAMPLES); @@ -277,7 +278,7 @@ void AudioMixer::run() { if (node->getType() == NODE_TYPE_AGENT && node->getActiveSocket() && node->getLinkedData() && ((AudioMixerClientData*) node->getLinkedData())->getAvatarAudioRingBuffer()) { prepareMixForListeningNode(node.data()); - + memcpy(clientPacket + numBytesPacketHeader, _clientSamples, sizeof(_clientSamples)); nodeList->getNodeSocket().writeDatagram((char*) clientPacket, sizeof(clientPacket), node->getActiveSocket()->getAddress(), diff --git a/domain-server/src/DomainServer.cpp b/domain-server/src/DomainServer.cpp index 9997d6e7ef..744d16b58e 100644 --- a/domain-server/src/DomainServer.cpp +++ b/domain-server/src/DomainServer.cpp @@ -6,7 +6,6 @@ // Copyright (c) 2013 HighFidelity, Inc. All rights reserved. // -//#include // not available on windows, apparently not needed on mac #include #include @@ -76,9 +75,9 @@ DomainServer::DomainServer(int argc, char* argv[]) : // Start the web server. mg_start(&callbacks, NULL, options); - + connect(nodeList, SIGNAL(nodeKilled(SharedNodePointer)), this, SLOT(nodeKilled(SharedNodePointer))); - + if (!_staticAssignmentFile.exists() || _voxelServerConfig) { if (_voxelServerConfig) { @@ -177,7 +176,7 @@ void DomainServer::readAvailableDatagrams() { nodeType, nodePublicAddress, nodeLocalAddress); - + if (matchingStaticAssignment) { // this was a newly added node with a matching static assignment @@ -230,10 +229,10 @@ void DomainServer::readAvailableDatagrams() { if (_assignmentQueue.size() > 0) { // construct the requested assignment from the packet data Assignment requestAssignment(packetData, receivedBytes); - + qDebug("Received a request for assignment type %i from %s.", requestAssignment.getType(), qPrintable(senderSockAddr.getAddress().toString())); - + Assignment* assignmentToDeploy = deployableAssignmentForRequest(requestAssignment); if (assignmentToDeploy) { @@ -372,7 +371,7 @@ int DomainServer::civetwebRequestHandler(struct mg_connection *connection) { // enumerate the NodeList to find the assigned nodes NodeList* nodeList = NodeList::getInstance(); - + foreach (const SharedNodePointer& node, nodeList->getNodeHash()) { // add the node using the UUID as the key QString uuidString = uuidStringWithoutCurlyBraces(node->getUUID()); @@ -412,14 +411,14 @@ int DomainServer::civetwebRequestHandler(struct mg_connection *connection) { if (!deleteUUID.isNull()) { SharedNodePointer nodeToKill = NodeList::getInstance()->nodeWithUUID(deleteUUID); - + if (nodeToKill) { // start with a 200 response mg_printf(connection, "%s", RESPONSE_200); // we have a valid UUID and node - kill the node that has this assignment NodeList::getInstance()->killNodeWithUUID(deleteUUID); - + // successfully processed request return 1; } @@ -464,9 +463,9 @@ void DomainServer::civetwebUploadHandler(struct mg_connection *connection, const // rename the saved script to the GUID of the assignment and move it to the script host locaiton rename(path, newPath.toLocal8Bit().constData()); - + qDebug("Saved a script for assignment at %s", newPath.toLocal8Bit().constData()); - + // add the script assigment to the assignment queue // lock the assignment queue mutex since we're operating on a different thread than DS main domainServerInstance->_assignmentQueueMutex.lock(); @@ -476,7 +475,7 @@ void DomainServer::civetwebUploadHandler(struct mg_connection *connection, const void DomainServer::addReleasedAssignmentBackToQueue(Assignment* releasedAssignment) { qDebug() << "Adding assignment" << *releasedAssignment << " back to queue."; - + // find this assignment in the static file for (int i = 0; i < MAX_STATIC_ASSIGNMENT_FILE_ASSIGNMENTS; i++) { if (_staticAssignments[i].getUUID() == releasedAssignment->getUUID()) { @@ -534,16 +533,16 @@ void DomainServer::prepopulateStaticAssignmentFile() { if (_voxelServerConfig) { qDebug("Reading Voxel Server Configuration."); qDebug() << "config: " << _voxelServerConfig; - + QString multiConfig((const char*) _voxelServerConfig); QStringList multiConfigList = multiConfig.split(";"); // read each config to a payload for a VS assignment for (int i = 0; i < multiConfigList.size(); i++) { QString config = multiConfigList.at(i); - + qDebug("config[%d]=%s", i, config.toLocal8Bit().constData()); - + // Now, parse the config to check for a pool const char ASSIGNMENT_CONFIG_POOL_OPTION[] = "--pool"; QString assignmentPool; @@ -576,16 +575,16 @@ void DomainServer::prepopulateStaticAssignmentFile() { if (_particleServerConfig) { qDebug("Reading Particle Server Configuration."); qDebug() << "config: " << _particleServerConfig; - + QString multiConfig((const char*) _particleServerConfig); QStringList multiConfigList = multiConfig.split(";"); // read each config to a payload for a VS assignment for (int i = 0; i < multiConfigList.size(); i++) { QString config = multiConfigList.at(i); - + qDebug("config[%d]=%s", i, config.toLocal8Bit().constData()); - + // Now, parse the config to check for a pool const char ASSIGNMENT_CONFIG_POOL_OPTION[] = "--pool"; QString assignmentPool; @@ -620,9 +619,9 @@ void DomainServer::prepopulateStaticAssignmentFile() { if (_metavoxelServerConfig) { metavoxelAssignment.setPayload((const unsigned char*)_metavoxelServerConfig, strlen(_metavoxelServerConfig)); } - + qDebug() << "Adding" << numFreshStaticAssignments << "static assignments to fresh file."; - + _staticAssignmentFile.open(QIODevice::WriteOnly); _staticAssignmentFile.write((char*) &freshStaticAssignments, sizeof(freshStaticAssignments)); _staticAssignmentFile.resize(MAX_STATIC_ASSIGNMENT_FILE_ASSIGNMENTS * sizeof(Assignment)); @@ -737,7 +736,7 @@ bool DomainServer::checkInWithUUIDMatchesExistingNode(const HifiSockAddr& nodePu const HifiSockAddr& nodeLocalSocket, const QUuid& checkInUUID) { NodeList* nodeList = NodeList::getInstance(); - + foreach (const SharedNodePointer& node, nodeList->getNodeHash()) { if (node->getLinkedData() && nodePublicSocket == node->getPublicSocket() @@ -783,9 +782,9 @@ void DomainServer::addStaticAssignmentsBackToQueueAfterRestart() { if (!foundMatchingAssignment) { // this assignment has not been fulfilled - reset the UUID and add it to the assignment queue _staticAssignments[i].resetUUID(); - + qDebug() << "Adding static assignment to queue -" << _staticAssignments[i]; - + _assignmentQueueMutex.lock(); _assignmentQueue.push_back(&_staticAssignments[i]); _assignmentQueueMutex.unlock(); diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index f3cdbf2c22..c97e01f1c9 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -36,17 +36,17 @@ if (WIN32) add_definitions( -D_USE_MATH_DEFINES ) # apparently needed to get M_PI and other defines from cmath/math.h add_definitions( -DWINDOWS_LEAN_AND_MEAN ) # needed to make sure windows doesn't go to crazy with its defines - # windows build needs an external glut, we're using freeglut + # windows build needs an external glut, we're using freeglut set(GLUT_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/external/freeglut) - set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${GLUT_ROOT_PATH}) + set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${GLUT_ROOT_PATH}) - # windows build needs glew (opengl extention wrangler) this will handle providing access to OpenGL methods after 1.1 - # which are not accessible on windows without glew or some other dynamic linking mechanism + # windows build needs glew (opengl extention wrangler) this will handle providing access to OpenGL methods after 1.1 + # which are not accessible on windows without glew or some other dynamic linking mechanism set(GLEW_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/external/glew) - set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${GLEW_ROOT_PATH}) + set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${GLEW_ROOT_PATH}) include_directories(SYSTEM ${GLEW_ROOT_PATH}/include) - # windows still using pthreads, TODO: switch to QThreads + # windows still using pthreads, TODO: switch to QThreads set(PTHREADS_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/external/pthreads) #set(GL_HEADERS "#define GLEW_STATIC\n#define FREEGLUT_STATIC\n#define FREEGLUT_LIB_PRAGMAS 0\n#include \n#include \n#include \n#include ") @@ -252,18 +252,18 @@ endif (APPLE) # link target to external libraries if (WIN32) target_link_libraries( - ${TARGET_NAME} - ${OPENCV_LIBRARIES} - #${FACESHIFT_LIBRARIES} + ${TARGET_NAME} + ${OPENCV_LIBRARIES} + #${FACESHIFT_LIBRARIES} - ${CMAKE_CURRENT_SOURCE_DIR}/external/glew/lib/Release/Win32/glew32s.lib - ${GLUT_ROOT_PATH}/lib/freeglut.lib + ${CMAKE_CURRENT_SOURCE_DIR}/external/glew/lib/Release/Win32/glew32s.lib + ${GLUT_ROOT_PATH}/lib/freeglut.lib - # note: the pthreads stuff was in the /external/glut before, that's not right, I moved it to it's own location - # but really we need to switch over to QThreads - ${PTHREADS_ROOT_PATH}/WIN32/pthread_lib.lib - wsock32.lib - opengl32.lib + # note: the pthreads stuff was in the /external/glut before, that's not right, I moved it to it's own location + # but really we need to switch over to QThreads + ${PTHREADS_ROOT_PATH}/WIN32/pthread_lib.lib + wsock32.lib + opengl32.lib ) else (WIN32) # link required libraries on UNIX diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 115581ab9d..cb60116b37 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -170,7 +170,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : } NodeList* nodeList = NodeList::createInstance(NODE_TYPE_AGENT, listenPort); - + // connect our processDatagrams slot to the QUDPSocket readyRead() signal connect(&nodeList->getNodeSocket(), SIGNAL(readyRead()), SLOT(processDatagrams())); @@ -181,7 +181,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : connect(audioThread, SIGNAL(started()), &_audio, SLOT(start())); audioThread->start(); - + connect(nodeList, SIGNAL(domainChanged(const QString&)), SLOT(domainChanged(const QString&))); connect(nodeList, SIGNAL(nodeKilled(SharedNodePointer)), SLOT(nodeKilled(SharedNodePointer))); @@ -321,7 +321,7 @@ void Application::initializeGL() { glutInit(&argc, 0); #endif - #ifdef WIN32 + #ifdef WIN32 GLenum err = glewInit(); if (GLEW_OK != err) { /* Problem: glewInit failed, something is seriously wrong. */ @@ -1982,12 +1982,12 @@ Avatar* Application::findLookatTargetAvatar(const glm::vec3& mouseRayOrigin, con if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) { Avatar* avatar = (Avatar*)node->getLinkedData(); float distance; - + if (avatar->findRayIntersection(mouseRayOrigin, mouseRayDirection, distance)) { // rescale to compensate for head embiggening eyePosition = (avatar->getHead().calculateAverageEyePosition() - avatar->getHead().getScalePivot()) * (avatar->getScale() / avatar->getHead().getScale()) + avatar->getHead().getScalePivot(); - + _lookatIndicatorScale = avatar->getHead().getScale(); _lookatOtherPosition = avatar->getHead().getPosition(); nodeUUID = avatar->getOwningNode()->getUUID(); @@ -1995,7 +1995,7 @@ Avatar* Application::findLookatTargetAvatar(const glm::vec3& mouseRayOrigin, con } } } - + return NULL; } @@ -2037,7 +2037,7 @@ void Application::renderHighlightVoxel(VoxelDetail voxel) { void Application::updateAvatars(float deltaTime, glm::vec3 mouseRayOrigin, glm::vec3 mouseRayDirection) { bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); PerformanceWarning warn(showWarnings, "Application::updateAvatars()"); - + foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) { QMutexLocker(&node->getMutex()); if (node->getLinkedData()) { @@ -2054,11 +2054,11 @@ void Application::updateAvatars(float deltaTime, glm::vec3 mouseRayOrigin, glm:: for (vector::iterator fade = _avatarFades.begin(); fade != _avatarFades.end(); fade++) { Avatar* avatar = *fade; const float SHRINK_RATE = 0.9f; - + avatar->setTargetScale(avatar->getScale() * SHRINK_RATE); - + const float MIN_FADE_SCALE = 0.001f; - + if (avatar->getTargetScale() < MIN_FADE_SCALE) { delete avatar; _avatarFades.erase(fade--); @@ -2629,32 +2629,32 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node int totalServers = 0; int inViewServers = 0; int unknownJurisdictionServers = 0; - + foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) { // only send to the NodeTypes that are serverType if (node->getActiveSocket() != NULL && node->getType() == serverType) { totalServers++; - + // get the server bounds for this server QUuid nodeUUID = node->getUUID(); - + // if we haven't heard from this voxel server, go ahead and send it a query, so we // can get the jurisdiction... if (jurisdictions.find(nodeUUID) == jurisdictions.end()) { unknownJurisdictionServers++; } else { const JurisdictionMap& map = (jurisdictions)[nodeUUID]; - + unsigned char* rootCode = map.getRootOctalCode(); - + if (rootCode) { VoxelPositionSize rootDetails; voxelDetailsForCode(rootCode, rootDetails); AABox serverBounds(glm::vec3(rootDetails.x, rootDetails.y, rootDetails.z), rootDetails.s); serverBounds.scale(TREE_SCALE); - + ViewFrustum::location serverFrustumLocation = _viewFrustum.boxInFrustum(serverBounds); - + if (serverFrustumLocation != ViewFrustum::OUTSIDE) { inViewServers++; } @@ -2687,20 +2687,20 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node if (wantExtraDebugging && unknownJurisdictionServers > 0) { qDebug("perServerPPS: %d perUnknownServer: %d", perServerPPS, perUnknownServer); } - + NodeList* nodeList = NodeList::getInstance(); - + foreach (const SharedNodePointer& node, nodeList->getNodeHash()) { // only send to the NodeTypes that are serverType if (node->getActiveSocket() != NULL && node->getType() == serverType) { - - + + // get the server bounds for this server QUuid nodeUUID = node->getUUID(); - + bool inView = false; bool unknownView = false; - + // if we haven't heard from this voxel server, go ahead and send it a query, so we // can get the jurisdiction... if (jurisdictions.find(nodeUUID) == jurisdictions.end()) { @@ -2710,15 +2710,15 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node } } else { const JurisdictionMap& map = (jurisdictions)[nodeUUID]; - + unsigned char* rootCode = map.getRootOctalCode(); - + if (rootCode) { VoxelPositionSize rootDetails; voxelDetailsForCode(rootCode, rootDetails); AABox serverBounds(glm::vec3(rootDetails.x, rootDetails.y, rootDetails.z), rootDetails.s); serverBounds.scale(TREE_SCALE); - + ViewFrustum::location serverFrustumLocation = _viewFrustum.boxInFrustum(serverBounds); if (serverFrustumLocation != ViewFrustum::OUTSIDE) { inView = true; @@ -2731,7 +2731,7 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node } } } - + if (inView) { _voxelQuery.setMaxOctreePacketsPerSecond(perServerPPS); } else if (unknownView) { @@ -2739,7 +2739,7 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node qDebug() << "no known jurisdiction for node " << *node << ", give it budget of " << perUnknownServer << " to send us jurisdiction."; } - + // set the query's position/orientation to be degenerate in a manner that will get the scene quickly // If there's only one server, then don't do this, and just let the normal voxel query pass through // as expected... this way, we will actually get a valid scene if there is one to be seen @@ -2763,24 +2763,24 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node } // set up the packet for sending... unsigned char* endOfVoxelQueryPacket = voxelQueryPacket; - + // insert packet type/version and node UUID endOfVoxelQueryPacket += populateTypeAndVersion(endOfVoxelQueryPacket, packetType); QByteArray ownerUUID = nodeList->getOwnerUUID().toRfc4122(); memcpy(endOfVoxelQueryPacket, ownerUUID.constData(), ownerUUID.size()); endOfVoxelQueryPacket += ownerUUID.size(); - + // encode the query data... endOfVoxelQueryPacket += _voxelQuery.getBroadcastData(endOfVoxelQueryPacket); - + int packetLength = endOfVoxelQueryPacket - voxelQueryPacket; - + // make sure we still have an active socket if (node->getActiveSocket()) { nodeList->getNodeSocket().writeDatagram((char*) voxelQueryPacket, packetLength, node->getActiveSocket()->getAddress(), node->getActiveSocket()->getPort()); } - + // Feed number of bytes to corresponding channel of the bandwidth meter _bandwidthMeter.outputStream(BandwidthMeter::VOXELS).updateValue(packetLength); } @@ -3260,7 +3260,7 @@ void Application::displayOverlay() { char nodes[100]; int totalAvatars = 0, totalServers = 0; - + foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) { node->getType() == NODE_TYPE_AGENT ? totalAvatars++ : totalServers++; } @@ -3375,7 +3375,7 @@ void Application::displayStats() { // Now handle voxel servers, since there could be more than one, we average their ping times unsigned long totalPingVoxel = 0; int voxelServerCount = 0; - + foreach (const SharedNodePointer& node, nodeList->getNodeHash()) { if (node->getType() == NODE_TYPE_VOXEL_SERVER) { totalPingVoxel += node->getPingMs(); @@ -3385,7 +3385,7 @@ void Application::displayStats() { } } } - + if (voxelServerCount) { pingVoxel = totalPingVoxel/voxelServerCount; } @@ -3707,10 +3707,10 @@ void Application::renderAvatars(bool forceRenderHead, bool selfAvatarOnly) { if (!selfAvatarOnly) { // Render avatars of other nodes NodeList* nodeList = NodeList::getInstance(); - + foreach (const SharedNodePointer& node, nodeList->getNodeHash()) { QMutexLocker(&node->getMutex()); - + if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) { Avatar *avatar = (Avatar *)node->getLinkedData(); if (!avatar->isInitialized()) { @@ -4208,28 +4208,28 @@ void Application::processDatagrams() { MAX_PACKET_SIZE, senderSockAddr.getAddressPointer(), senderSockAddr.getPortPointer()))) { - + _packetCount++; _bytesCount += bytesReceived; - + if (packetVersionMatch(_incomingPacket)) { // only process this packet if we have a match on the packet version switch (_incomingPacket[0]) { case PACKET_TYPE_TRANSMITTER_DATA_V2: // V2 = IOS transmitter app _myTransmitter.processIncomingData(_incomingPacket, bytesReceived); - + break; case PACKET_TYPE_MIXED_AUDIO: QMetaObject::invokeMethod(&_audio, "addReceivedAudioToBuffer", Qt::QueuedConnection, Q_ARG(QByteArray, QByteArray((char*) _incomingPacket, bytesReceived))); break; - + case PACKET_TYPE_PARTICLE_ADD_RESPONSE: // look up our ParticleEditHanders.... ParticleEditHandle::handleAddResponse(_incomingPacket, bytesReceived); break; - + case PACKET_TYPE_PARTICLE_DATA: case PACKET_TYPE_VOXEL_DATA: case PACKET_TYPE_VOXEL_ERASE: @@ -4237,7 +4237,7 @@ void Application::processDatagrams() { case PACKET_TYPE_ENVIRONMENT_DATA: { PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "Application::networkReceive()... _voxelProcessor.queueReceivedPacket()"); - + bool wantExtraDebugging = getLogger()->extraDebugging(); if (wantExtraDebugging && _incomingPacket[0] == PACKET_TYPE_VOXEL_DATA) { int numBytesPacketHeader = numBytesForPacketHeader(_incomingPacket); @@ -4249,10 +4249,10 @@ void Application::processDatagrams() { dataAt += sizeof(VOXEL_PACKET_SENT_TIME); VOXEL_PACKET_SENT_TIME arrivedAt = usecTimestampNow(); int flightTime = arrivedAt - sentAt; - + printf("got PACKET_TYPE_VOXEL_DATA, sequence:%d flightTime:%d\n", sequence, flightTime); } - + // add this packet to our list of voxel packets and process them on the voxel processing _voxelProcessor.queueReceivedPacket(senderSockAddr, _incomingPacket, bytesReceived); break;