From 1fb1622beb5d6e2e8ddd6baaadbbb12ac0c5f7ec Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Mon, 15 Jul 2013 16:27:23 -0700 Subject: [PATCH 01/19] added sleep to sendVoxelOperation() to keep from overwhelming server --- interface/src/Application.cpp | 41 +++++++++++++++++++++++++----- libraries/voxels/src/VoxelTree.cpp | 2 +- 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 75f45e8d91..96e3dbd3d6 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1333,7 +1333,9 @@ struct SendVoxelsOperationArgs { unsigned char* newBaseOctCode; unsigned char messageBuffer[MAXIMUM_EDIT_VOXEL_MESSAGE_SIZE]; int bufferInUse; - + uint64_t lastSendTime; + int packetsSent; + uint64_t bytesSent; }; bool Application::sendVoxelsOperation(VoxelNode* node, void* extraData) { @@ -1365,17 +1367,30 @@ bool Application::sendVoxelsOperation(VoxelNode* node, void* extraData) { codeColorBuffer[bytesInCode + GREEN_INDEX] = node->getColor()[GREEN_INDEX]; codeColorBuffer[bytesInCode + BLUE_INDEX ] = node->getColor()[BLUE_INDEX ]; - // TODO: sendVoxelsOperation() is sending voxels too fast. - // This printf function accidently slowed down sending - // and hot-fixed the bug when importing - // large PNG models (256x256 px and more) - static unsigned int sendVoxelsOperationCalled = 0; printf("sending voxel #%u\n", ++sendVoxelsOperationCalled); - // if we have room don't have room in the buffer, then send the previously generated message first if (args->bufferInUse + codeAndColorLength > MAXIMUM_EDIT_VOXEL_MESSAGE_SIZE) { + + args->packetsSent++; + args->bytesSent += args->bufferInUse; + controlledBroadcastToNodes(args->messageBuffer, args->bufferInUse, & NODE_TYPE_VOXEL_SERVER, 1); args->bufferInUse = numBytesForPacketHeader((unsigned char*) &PACKET_TYPE_SET_VOXEL_DESTRUCTIVE) + sizeof(unsigned short int); // reset + + uint64_t now = usecTimestampNow(); + // dynamically sleep until we need to fire off the next set of voxels + const uint64_t CLIENT_TO_SERVER_VOXEL_SEND_INTERVAL_USECS = 1000 * 5; // 1 packet every 10 milliseconds + uint64_t elapsed = now - args->lastSendTime; + int usecToSleep = CLIENT_TO_SERVER_VOXEL_SEND_INTERVAL_USECS - elapsed; + if (usecToSleep > 0) { + printLog("sendVoxelsOperation: packet: %d bytes:%ld elapsed %ld usecs, sleeping for %d usecs!\n", + args->packetsSent, args->bytesSent, elapsed, usecToSleep); + usleep(usecToSleep); + } else { + printLog("sendVoxelsOperation: packet: %d bytes:%ld elapsed %ld usecs, no need to sleep!\n", + args->packetsSent, args->bytesSent, elapsed); + } + args->lastSendTime = now; } // copy this node's code color details into our buffer. @@ -1442,6 +1457,9 @@ void Application::importVoxels() { // the server as an set voxel message, this will also rebase the voxels to the new location unsigned char* calculatedOctCode = NULL; SendVoxelsOperationArgs args; + args.lastSendTime = usecTimestampNow(); + args.packetsSent = 0; + args.bytesSent = 0; int numBytesPacketHeader = populateTypeAndVersion(args.messageBuffer, PACKET_TYPE_SET_VOXEL_DESTRUCTIVE); @@ -1462,6 +1480,9 @@ void Application::importVoxels() { // If we have voxels left in the packet, then send the packet if (args.bufferInUse > (numBytesPacketHeader + sizeof(unsigned short int))) { controlledBroadcastToNodes(args.messageBuffer, args.bufferInUse, & NODE_TYPE_VOXEL_SERVER, 1); + printLog("sending packet: %d\n", ++args.packetsSent); + args.bytesSent += args.bufferInUse; + printLog("total bytes sent: %ld\n", args.bytesSent); } if (calculatedOctCode) { @@ -1495,6 +1516,9 @@ void Application::pasteVoxels() { // Recurse the clipboard tree, where everything is root relative, and send all the colored voxels to // the server as an set voxel message, this will also rebase the voxels to the new location SendVoxelsOperationArgs args; + args.lastSendTime = usecTimestampNow(); + args.packetsSent = 0; + args.bytesSent = 0; int numBytesPacketHeader = populateTypeAndVersion(args.messageBuffer, PACKET_TYPE_SET_VOXEL_DESTRUCTIVE); @@ -1516,6 +1540,9 @@ void Application::pasteVoxels() { // If we have voxels left in the packet, then send the packet if (args.bufferInUse > (numBytesPacketHeader + sizeof(unsigned short int))) { controlledBroadcastToNodes(args.messageBuffer, args.bufferInUse, & NODE_TYPE_VOXEL_SERVER, 1); + printLog("sending packet: %d\n", ++args.packetsSent); + args.bytesSent += args.bufferInUse; + printLog("total bytes sent: %ld\n", args.bytesSent); } if (calculatedOctCode) { diff --git a/libraries/voxels/src/VoxelTree.cpp b/libraries/voxels/src/VoxelTree.cpp index b84b374309..66fa81c425 100644 --- a/libraries/voxels/src/VoxelTree.cpp +++ b/libraries/voxels/src/VoxelTree.cpp @@ -1251,7 +1251,7 @@ int VoxelTree::encodeTreeBitstreamRecursion(VoxelNode* node, unsigned char* outp } // wants occlusion culling & isLeaf() - bool shouldRender = childNode->calculateShouldRender(params.viewFrustum, params.boundaryLevelAdjust); + bool shouldRender = !params.viewFrustum ? true : childNode->calculateShouldRender(params.viewFrustum, params.boundaryLevelAdjust); // track children with actual color, only if the child wasn't previously in view! if (shouldRender && !childIsOccluded) { From 099fa4b4b10446912fe21cfbdf819ce580e35d14 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Mon, 15 Jul 2013 16:40:00 -0700 Subject: [PATCH 02/19] fixed server persistance issue --- voxel-server/src/main.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/voxel-server/src/main.cpp b/voxel-server/src/main.cpp index 254b1d2d96..e336234838 100644 --- a/voxel-server/src/main.cpp +++ b/voxel-server/src/main.cpp @@ -313,6 +313,9 @@ void deepestLevelVoxelDistributor(NodeList* nodeList, uint64_t lastPersistVoxels = 0; void persistVoxelsWhenDirty() { uint64_t now = usecTimestampNow(); + if (::lastPersistVoxels == 0) { + ::lastPersistVoxels = now; + } int sinceLastTime = (now - ::lastPersistVoxels) / 1000; // check the dirty bit and persist here... From a3009981d0e04e573b6efd79ccbc7d110551b967 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Mon, 15 Jul 2013 17:54:50 -0700 Subject: [PATCH 03/19] added Import Voxels to Clipboard --- interface/src/Application.cpp | 37 +++++++++++++++++++++++++++++++++++ interface/src/Application.h | 1 + 2 files changed, 38 insertions(+) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index bcbe92f3bb..77f56fdd6b 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1419,6 +1419,42 @@ void Application::exportVoxels() { _window->activateWindow(); } +void Application::importVoxelsToClipboard() { + QString desktopLocation = QDesktopServices::storageLocation(QDesktopServices::DesktopLocation); + QString fileNameString = QFileDialog::getOpenFileName( + _glWidget, tr("Import Voxels to Clipboard"), desktopLocation, + tr("Sparse Voxel Octree Files, Square PNG, Schematic Files (*.svo *.png *.schematic)")); + + QByteArray fileNameAscii = fileNameString.toAscii(); + const char* fileName = fileNameAscii.data(); + + _clipboardTree.eraseAllVoxels(); + if (fileNameString.endsWith(".png", Qt::CaseInsensitive)) { + QImage pngImage = QImage(fileName); + if (pngImage.height() != pngImage.width()) { + printLog("ERROR: Bad PNG size: height != width.\n"); + return; + } + + const uint32_t* pixels; + if (pngImage.format() == QImage::Format_ARGB32) { + pixels = reinterpret_cast(pngImage.constBits()); + } else { + QImage tmp = pngImage.convertToFormat(QImage::Format_ARGB32); + pixels = reinterpret_cast(tmp.constBits()); + } + + _clipboardTree.readFromSquareARGB32Pixels(pixels, pngImage.height()); + } else if (fileNameString.endsWith(".svo", Qt::CaseInsensitive)) { + _clipboardTree.readFromSVOFile(fileName); + } else if (fileNameString.endsWith(".schematic", Qt::CaseInsensitive)) { + _clipboardTree.readFromSchematicFile(fileName); + } + + // restore the main window's active state + _window->activateWindow(); +} + void Application::importVoxels() { QString desktopLocation = QDesktopServices::storageLocation(QDesktopServices::DesktopLocation); QString fileNameString = QFileDialog::getOpenFileName( @@ -1658,6 +1694,7 @@ void Application::initMenu() { voxelMenu->addAction("Export Voxels", this, SLOT(exportVoxels()), Qt::CTRL | Qt::Key_E); voxelMenu->addAction("Import Voxels", this, SLOT(importVoxels()), Qt::CTRL | Qt::Key_I); + voxelMenu->addAction("Import Voxels to Clipboard", this, SLOT(importVoxelsToClipboard()), Qt::SHIFT | Qt::CTRL | Qt::Key_I); voxelMenu->addAction("Cut Voxels", this, SLOT(cutVoxels()), Qt::CTRL | Qt::Key_X); voxelMenu->addAction("Copy Voxels", this, SLOT(copyVoxels()), Qt::CTRL | Qt::Key_C); voxelMenu->addAction("Paste Voxels", this, SLOT(pasteVoxels()), Qt::CTRL | Qt::Key_V); diff --git a/interface/src/Application.h b/interface/src/Application.h index cb1335887d..4c1cfa5969 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -153,6 +153,7 @@ private slots: void exportSettings(); void exportVoxels(); void importVoxels(); + void importVoxelsToClipboard(); void cutVoxels(); void copyVoxels(); void pasteVoxels(); From 42e5440b7b8406b0fb158777f314ae13c8509936 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Tue, 16 Jul 2013 10:00:55 -0700 Subject: [PATCH 04/19] CR feedback --- interface/src/Application.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index fa36847805..772cae733d 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1455,11 +1455,11 @@ void Application::exportVoxels() { _window->activateWindow(); } +const char* IMPORT_FILE_TYPES = "Sparse Voxel Octree Files, Square PNG, Schematic Files (*.svo *.png *.schematic)"; void Application::importVoxelsToClipboard() { QString desktopLocation = QDesktopServices::storageLocation(QDesktopServices::DesktopLocation); - QString fileNameString = QFileDialog::getOpenFileName( - _glWidget, tr("Import Voxels to Clipboard"), desktopLocation, - tr("Sparse Voxel Octree Files, Square PNG, Schematic Files (*.svo *.png *.schematic)")); + QString fileNameString = QFileDialog::getOpenFileName(_glWidget, tr("Import Voxels to Clipboard"), desktopLocation, + tr(IMPORT_FILE_TYPES)); QByteArray fileNameAscii = fileNameString.toAscii(); const char* fileName = fileNameAscii.data(); @@ -1493,9 +1493,8 @@ void Application::importVoxelsToClipboard() { void Application::importVoxels() { QString desktopLocation = QDesktopServices::storageLocation(QDesktopServices::DesktopLocation); - QString fileNameString = QFileDialog::getOpenFileName( - _glWidget, tr("Import Voxels"), desktopLocation, - tr("Sparse Voxel Octree Files, Square PNG, Schematic Files (*.svo *.png *.schematic)")); + QString fileNameString = QFileDialog::getOpenFileName(_glWidget, tr("Import Voxels"), desktopLocation, + tr(IMPORT_FILE_TYPES)); QByteArray fileNameAscii = fileNameString.toAscii(); const char* fileName = fileNameAscii.data(); From 440352c584da853d8469572d3bd72d2b7b33cef9 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Tue, 16 Jul 2013 10:02:27 -0700 Subject: [PATCH 05/19] white space --- interface/src/Application.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 772cae733d..c28c8a9097 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1479,8 +1479,7 @@ void Application::importVoxelsToClipboard() { QImage tmp = pngImage.convertToFormat(QImage::Format_ARGB32); pixels = reinterpret_cast(tmp.constBits()); } - - _clipboardTree.readFromSquareARGB32Pixels(pixels, pngImage.height()); + _clipboardTree.readFromSquareARGB32Pixels(pixels, pngImage.height()); } else if (fileNameString.endsWith(".svo", Qt::CaseInsensitive)) { _clipboardTree.readFromSVOFile(fileName); } else if (fileNameString.endsWith(".schematic", Qt::CaseInsensitive)) { From 64ba01e23cedba83097b695563e1303d09611460 Mon Sep 17 00:00:00 2001 From: atlante45 Date: Tue, 16 Jul 2013 10:54:58 -0700 Subject: [PATCH 06/19] added scale to settings --- interface/src/Avatar.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/interface/src/Avatar.cpp b/interface/src/Avatar.cpp index a1175e3b23..7638ca0047 100755 --- a/interface/src/Avatar.cpp +++ b/interface/src/Avatar.cpp @@ -1321,7 +1321,11 @@ void Avatar::loadData(QSettings* settings) { _voxels.setVoxelURL(settings->value("voxelURL").toUrl()); _leanScale = loadSetting(settings, "leanScale", 0.5f); - + + _scale = loadSetting(settings, "scale", 1.0f); + setScale(_scale); + Application::getInstance()->getCamera()->setScale(_scale); + settings->endGroup(); } @@ -1344,6 +1348,7 @@ void Avatar::saveData(QSettings* set) { set->setValue("voxelURL", _voxels.getVoxelURL()); set->setValue("leanScale", _leanScale); + set->setValue("scale", _scale); set->endGroup(); } From afe49bc75617e0fd3b61799ac8e397352ec55335 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 16 Jul 2013 11:07:22 -0700 Subject: [PATCH 07/19] switch calls to printLog to QDebug --- animation-server/CMakeLists.txt | 2 +- audio-mixer/CMakeLists.txt | 2 +- avatar-mixer/CMakeLists.txt | 2 +- cmake/macros/SetupHifiLibrary.cmake | 10 ++- cmake/macros/SetupHifiProject.cmake | 12 ++- domain-server/CMakeLists.txt | 2 +- eve/CMakeLists.txt | 2 +- injector/CMakeLists.txt | 2 +- interface/src/Application.cpp | 26 +++--- interface/src/Application.h | 19 +++-- interface/src/Audio.cpp | 47 ++++++----- interface/src/Audio.h | 1 - interface/src/Avatar.cpp | 17 ++-- interface/src/Avatar.h | 11 ++- interface/src/AvatarVoxelSystem.cpp | 4 +- interface/src/BandwidthMeter.cpp | 1 - interface/src/Camera.cpp | 3 +- interface/src/LogDisplay.cpp | 31 +------ interface/src/LogDisplay.h | 10 +-- interface/src/SerialInterface.cpp | 30 ++++++- interface/src/SerialInterface.h | 39 +++------ interface/src/Transmitter.cpp | 8 +- interface/src/Util.cpp | 25 +++--- interface/src/VoxelSystem.cpp | 61 +++++++------- interface/src/Webcam.cpp | 21 +++-- interface/src/main.cpp | 7 +- interface/src/starfield/Config.h | 1 - interface/src/starfield/Loader.h | 10 +-- interface/src/ui/BandwidthDialog.cpp | 2 - libraries/shared/src/Log.cpp | 15 ---- libraries/shared/src/Log.h | 21 ----- libraries/shared/src/Node.cpp | 31 ++++--- libraries/shared/src/Node.h | 9 +- libraries/shared/src/NodeList.cpp | 19 ++--- libraries/shared/src/OctalCode.cpp | 10 ++- libraries/shared/src/PacketHeaders.cpp | 5 +- libraries/shared/src/PerfStat.cpp | 23 ++--- libraries/shared/src/SharedUtil.cpp | 27 +++--- libraries/shared/src/UDPSocket.cpp | 15 ++-- libraries/shared/src/UrlReader.cpp | 5 +- libraries/voxels/src/CoverageMap.cpp | 83 ++++++++++--------- libraries/voxels/src/CoverageMapV2.cpp | 20 +++-- libraries/voxels/src/GeometryUtil.cpp | 3 +- libraries/voxels/src/Plane.cpp | 2 - libraries/voxels/src/Tags.cpp | 11 ++- libraries/voxels/src/ViewFrustum.cpp | 51 ++++++------ libraries/voxels/src/ViewFrustum.h | 8 +- libraries/voxels/src/VoxelNode.cpp | 22 ++--- .../voxels/src/VoxelProjectedPolygon.cpp | 13 +-- libraries/voxels/src/VoxelTree.cpp | 66 ++++++++------- pairing-server/CMakeLists.txt | 2 +- space-server/CMakeLists.txt | 2 +- voxel-edit/CMakeLists.txt | 2 +- voxel-server/CMakeLists.txt | 2 +- 54 files changed, 420 insertions(+), 455 deletions(-) delete mode 100644 libraries/shared/src/Log.cpp delete mode 100644 libraries/shared/src/Log.h diff --git a/animation-server/CMakeLists.txt b/animation-server/CMakeLists.txt index e9662366af..de04acd8f7 100644 --- a/animation-server/CMakeLists.txt +++ b/animation-server/CMakeLists.txt @@ -14,7 +14,7 @@ include_glm(${TARGET_NAME} ${ROOT_DIR}) include(${MACRO_DIR}/SetupHifiProject.cmake) -setup_hifi_project(${TARGET_NAME}) +setup_hifi_project(${TARGET_NAME} TRUE) # link in the shared library include(${MACRO_DIR}/LinkHifiLibrary.cmake) diff --git a/audio-mixer/CMakeLists.txt b/audio-mixer/CMakeLists.txt index 7e83e6fc1a..472327de42 100644 --- a/audio-mixer/CMakeLists.txt +++ b/audio-mixer/CMakeLists.txt @@ -9,7 +9,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../cmake set(TARGET_NAME audio-mixer) include(${MACRO_DIR}/SetupHifiProject.cmake) -setup_hifi_project(${TARGET_NAME}) +setup_hifi_project(${TARGET_NAME} TRUE) # set up the external glm library include(${MACRO_DIR}/IncludeGLM.cmake) diff --git a/avatar-mixer/CMakeLists.txt b/avatar-mixer/CMakeLists.txt index da25b6e981..33f603e228 100644 --- a/avatar-mixer/CMakeLists.txt +++ b/avatar-mixer/CMakeLists.txt @@ -10,7 +10,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../cmake # setup the project include(${MACRO_DIR}/SetupHifiProject.cmake) -setup_hifi_project(${TARGET_NAME}) +setup_hifi_project(${TARGET_NAME} TRUE) # include glm include(${MACRO_DIR}/IncludeGLM.cmake) diff --git a/cmake/macros/SetupHifiLibrary.cmake b/cmake/macros/SetupHifiLibrary.cmake index 156ca186b2..b7d0af7499 100644 --- a/cmake/macros/SetupHifiLibrary.cmake +++ b/cmake/macros/SetupHifiLibrary.cmake @@ -1,9 +1,15 @@ MACRO(SETUP_HIFI_LIBRARY TARGET) - project(${TARGET_NAME}) + project(${TARGET}) # grab the implemenation and header files file(GLOB LIB_SRCS src/*.h src/*.cpp) # create a library and set the property so it can be referenced later - add_library(${TARGET_NAME} ${LIB_SRCS}) + add_library(${TARGET} ${LIB_SRCS}) + + find_package(Qt4 REQUIRED QtCore) + include(${QT_USE_FILE}) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${QT_QTGUI_INCLUDE_DIR}") + + target_link_libraries(${TARGET} ${QT_LIBRARIES}) ENDMACRO(SETUP_HIFI_LIBRARY _target) \ No newline at end of file diff --git a/cmake/macros/SetupHifiProject.cmake b/cmake/macros/SetupHifiProject.cmake index 3b6f130073..8360dc66b6 100644 --- a/cmake/macros/SetupHifiProject.cmake +++ b/cmake/macros/SetupHifiProject.cmake @@ -1,4 +1,4 @@ -MACRO(SETUP_HIFI_PROJECT TARGET) +MACRO(SETUP_HIFI_PROJECT TARGET INCLUDE_QT) project(${TARGET}) # grab the implemenation and header files @@ -6,4 +6,12 @@ MACRO(SETUP_HIFI_PROJECT TARGET) # add the executable add_executable(${TARGET} ${TARGET_SRCS}) -ENDMACRO(SETUP_HIFI_PROJECT _target) \ No newline at end of file + + IF (${INCLUDE_QT}) + find_package(Qt4 REQUIRED QtCore) + include(${QT_USE_FILE}) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${QT_QTGUI_INCLUDE_DIR}") + ENDIF() + + target_link_libraries(${TARGET} ${QT_LIBRARIES}) +ENDMACRO(SETUP_HIFI_PROJECT _target _include_qt) \ No newline at end of file diff --git a/domain-server/CMakeLists.txt b/domain-server/CMakeLists.txt index 27863f01df..4e1f0de298 100644 --- a/domain-server/CMakeLists.txt +++ b/domain-server/CMakeLists.txt @@ -6,7 +6,7 @@ set(MACRO_DIR ${ROOT_DIR}/cmake/macros) set(TARGET_NAME domain-server) include(${MACRO_DIR}/SetupHifiProject.cmake) -setup_hifi_project(${TARGET_NAME}) +setup_hifi_project(${TARGET_NAME} TRUE) # link the shared hifi library include(${MACRO_DIR}/LinkHifiLibrary.cmake) diff --git a/eve/CMakeLists.txt b/eve/CMakeLists.txt index acca9520ed..0a7691b781 100644 --- a/eve/CMakeLists.txt +++ b/eve/CMakeLists.txt @@ -9,7 +9,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../cmake set(TARGET_NAME eve) include(${MACRO_DIR}/SetupHifiProject.cmake) -setup_hifi_project(${TARGET_NAME}) +setup_hifi_project(${TARGET_NAME} TRUE) include(${MACRO_DIR}/IncludeGLM.cmake) include_glm(${TARGET_NAME} ${ROOT_DIR}) diff --git a/injector/CMakeLists.txt b/injector/CMakeLists.txt index 2c022b0e92..ae9ed3d8ad 100644 --- a/injector/CMakeLists.txt +++ b/injector/CMakeLists.txt @@ -9,7 +9,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../cmake set(TARGET_NAME injector) include(${MACRO_DIR}/SetupHifiProject.cmake) -setup_hifi_project(${TARGET_NAME}) +setup_hifi_project(${TARGET_NAME} TRUE) # set up the external glm library include(${MACRO_DIR}/IncludeGLM.cmake) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 4ea6e0bf84..a85fad9060 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -210,7 +210,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : { _applicationStartupTime = startup_time; _window->setWindowTitle("Interface"); - printLog("Interface Startup:\n"); + qDebug("Interface Startup:\n"); unsigned int listenPort = 0; // bind to an ephemeral port by default const char** constArgv = const_cast(argv); @@ -233,7 +233,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : // Handle Local Domain testing with the --local command line if (cmdOptionExists(argc, constArgv, "--local")) { - printLog("Local Domain MODE!\n"); + qDebug("Local Domain MODE!\n"); NodeList::getInstance()->setDomainIPToLocalhost(); } @@ -297,7 +297,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : } void Application::initializeGL() { - printLog( "Created Display Window.\n" ); + qDebug( "Created Display Window.\n" ); // initialize glut for shape drawing; Qt apparently initializes it on OS X #ifndef __APPLE__ @@ -312,10 +312,10 @@ void Application::initializeGL() { _viewFrustumOffsetCamera.setFarClip(500.0 * TREE_SCALE); initDisplay(); - printLog( "Initialized Display.\n" ); + qDebug( "Initialized Display.\n" ); init(); - printLog( "Init() complete.\n" ); + qDebug( "Init() complete.\n" ); // Check to see if the user passed in a command line option for randomizing colors bool wantColorRandomizer = !arguments().contains("--NoColorRandomizer"); @@ -324,13 +324,13 @@ void Application::initializeGL() { // Voxel File. If so, load it now. if (!_voxelsFilename.isEmpty()) { _voxels.loadVoxelsFile(_voxelsFilename.constData(), wantColorRandomizer); - printLog("Local Voxel File loaded.\n"); + qDebug("Local Voxel File loaded.\n"); } // create thread for receipt of data via UDP if (_enableNetworkThread) { pthread_create(&_networkReceiveThread, NULL, networkReceive, NULL); - printLog("Network receive thread created.\n"); + qDebug("Network receive thread created.\n"); } // call terminate before exiting @@ -352,7 +352,7 @@ void Application::initializeGL() { _justStarted = false; char title[50]; sprintf(title, "Interface: %4.2f seconds\n", startupTime); - printLog("%s", title); + qDebug("%s", title); _window->setWindowTitle(title); const char LOGSTASH_INTERFACE_START_TIME_KEY[] = "interface-start-time"; @@ -1446,7 +1446,7 @@ void Application::importVoxels() { if (fileNameString.endsWith(".png", Qt::CaseInsensitive)) { QImage pngImage = QImage(fileName); if (pngImage.height() != pngImage.width()) { - printLog("ERROR: Bad PNG size: height != width.\n"); + qDebug("ERROR: Bad PNG size: height != width.\n"); return; } @@ -1758,7 +1758,7 @@ void Application::init() { _audio.setJitterBufferSamples(_audioJitterBufferSamples); } - printLog("Loaded settings.\n"); + qDebug("Loaded settings.\n"); sendAvatarVoxelURLMessage(_myAvatar.getVoxels()->getVoxelURL()); @@ -2771,7 +2771,7 @@ glm::vec2 Application::getScaledScreenPoint(glm::vec2 projectedPoint) { // render the coverage map on screen void Application::renderCoverageMapV2() { - //printLog("renderCoverageMap()\n"); + //qDebug("renderCoverageMap()\n"); glDisable(GL_LIGHTING); glLineWidth(2.0); @@ -2816,7 +2816,7 @@ void Application::renderCoverageMapsV2Recursively(CoverageMapV2* map) { // render the coverage map on screen void Application::renderCoverageMap() { - //printLog("renderCoverageMap()\n"); + //qDebug("renderCoverageMap()\n"); glDisable(GL_LIGHTING); glLineWidth(2.0); @@ -3147,7 +3147,7 @@ void Application::eyedropperVoxelUnderCursor() { } void Application::goHome() { - printLog("Going Home!\n"); + qDebug("Going Home!\n"); _myAvatar.setPosition(START_LOCATION); } diff --git a/interface/src/Application.h b/interface/src/Application.h index 4e4101408f..f6332aef64 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -21,27 +21,28 @@ #include -#include "BandwidthMeter.h" -#include "ui/BandwidthDialog.h" - #ifndef _WIN32 #include "Audio.h" #endif +#include "Avatar.h" +#include "BandwidthMeter.h" #include "Camera.h" #include "Environment.h" #include "HandControl.h" +#include "PacketHeaders.h" +#include "ParticleSystem.h" +#include "renderer/GeometryCache.h" #include "SerialInterface.h" #include "Stars.h" +#include "Swatch.h" +#include "ToolsPalette.h" +#include "ui/ChatEntry.h" +#include "ui/BandwidthDialog.h" #include "ViewFrustum.h" #include "VoxelSystem.h" -#include "PacketHeaders.h" #include "Webcam.h" -#include "renderer/GeometryCache.h" -#include "ui/ChatEntry.h" -#include "ToolsPalette.h" -#include "Swatch.h" -#include "ParticleSystem.h" + class QAction; class QActionGroup; diff --git a/interface/src/Audio.cpp b/interface/src/Audio.cpp index 63fc24f56d..4c707de938 100644 --- a/interface/src/Audio.cpp +++ b/interface/src/Audio.cpp @@ -7,24 +7,25 @@ // #ifndef _WIN32 -#include +#include #include + +#include #include #include -#include -#include -#include -#include -#include + +#include #include #include -#include +#include +#include +#include +#include #include "Application.h" #include "Audio.h" #include "Util.h" -#include "Log.h" // Uncomment the following definition to test audio device latency by copying output to input //#define TEST_AUDIO_LOOPBACK @@ -151,7 +152,7 @@ inline void Audio::performIO(int16_t* inputLeft, int16_t* outputLeft, int16_t* o // If not enough audio has arrived to start playback, keep waiting // #ifdef SHOW_AUDIO_DEBUG - printLog("%i,%i,%i,%i\n", + qDebug("%i,%i,%i,%i\n", _packetsReceivedThisPlayback, ringBuffer->diffLastWriteNextOutput(), PACKET_LENGTH_SAMPLES, @@ -168,7 +169,7 @@ inline void Audio::performIO(int16_t* inputLeft, int16_t* outputLeft, int16_t* o _packetsReceivedThisPlayback = 0; _wasStarved = 10; // Frames for which to render the indication that the system was starved. #ifdef SHOW_AUDIO_DEBUG - printLog("Starved, remaining samples = %d\n", + qDebug("Starved, remaining samples = %d\n", ringBuffer->diffLastWriteNextOutput()); #endif @@ -179,7 +180,7 @@ inline void Audio::performIO(int16_t* inputLeft, int16_t* outputLeft, int16_t* o if (!ringBuffer->isStarted()) { ringBuffer->setStarted(true); #ifdef SHOW_AUDIO_DEBUG - printLog("starting playback %0.1f msecs delayed, jitter = %d, pkts recvd: %d \n", + qDebug("starting playback %0.1f msecs delayed, jitter = %d, pkts recvd: %d \n", (usecTimestampNow() - usecTimestamp(&_firstPacketReceivedTime))/1000.0, _jitterBufferSamples, _packetsReceivedThisPlayback); @@ -299,8 +300,8 @@ int Audio::audioCallback (const void* inputBuffer, static void outputPortAudioError(PaError error) { if (error != paNoError) { - printLog("-- portaudio termination error --\n"); - printLog("PortAudio error (%d): %s\n", error, Pa_GetErrorText(error)); + qDebug("-- portaudio termination error --\n"); + qDebug("PortAudio error (%d): %s\n", error, Pa_GetErrorText(error)); } } @@ -349,7 +350,7 @@ Audio::Audio(Oscilloscope* scope, int16_t initialJitterBufferSamples) : outputParameters.device = Pa_GetDefaultOutputDevice(); if (inputParameters.device == -1 || outputParameters.device == -1) { - printLog("Audio: Missing device.\n"); + qDebug("Audio: Missing device.\n"); outputPortAudioError(Pa_Terminate()); return; } @@ -384,12 +385,12 @@ Audio::Audio(Oscilloscope* scope, int16_t initialJitterBufferSamples) : outputPortAudioError(Pa_StartStream(_stream)); // Uncomment these lines to see the system-reported latency - //printLog("Default low input, output latency (secs): %0.4f, %0.4f\n", + //qDebug("Default low input, output latency (secs): %0.4f, %0.4f\n", // Pa_GetDeviceInfo(Pa_GetDefaultInputDevice())->defaultLowInputLatency, // Pa_GetDeviceInfo(Pa_GetDefaultOutputDevice())->defaultLowOutputLatency); const PaStreamInfo* streamInfo = Pa_GetStreamInfo(_stream); - printLog("Started audio with reported latency msecs In/Out: %.0f, %.0f\n", streamInfo->inputLatency * 1000.f, + qDebug("Started audio with reported latency msecs In/Out: %.0f, %.0f\n", streamInfo->inputLatency * 1000.f, streamInfo->outputLatency * 1000.f); gettimeofday(&_lastReceiveTime, NULL); @@ -650,7 +651,7 @@ inline void Audio::eventuallySendRecvPing(int16_t* inputLeft, int16_t* outputLef // As of the next frame, we'll be recoding PING_FRAMES_TO_RECORD from // the mic (pointless to start now as we can't record unsent audio). _isSendingEchoPing = false; - printLog("Send audio ping\n"); + qDebug("Send audio ping\n"); } else if (_pingFramesToRecord > 0) { @@ -664,7 +665,7 @@ inline void Audio::eventuallySendRecvPing(int16_t* inputLeft, int16_t* outputLef if (_pingFramesToRecord == 0) { _pingAnalysisPending = true; - printLog("Received ping echo\n"); + qDebug("Received ping echo\n"); } } } @@ -688,25 +689,25 @@ inline void Audio::analyzePing() { // Determine extrema int botAt = findExtremum(_echoSamplesLeft, PING_SAMPLES_TO_ANALYZE, -1); if (botAt == -1) { - printLog("Audio Ping: Minimum not found.\n"); + qDebug("Audio Ping: Minimum not found.\n"); return; } int topAt = findExtremum(_echoSamplesLeft, PING_SAMPLES_TO_ANALYZE, 1); if (topAt == -1) { - printLog("Audio Ping: Maximum not found.\n"); + qDebug("Audio Ping: Maximum not found.\n"); return; } // Determine peak amplitude - warn if low int ampli = (_echoSamplesLeft[topAt] - _echoSamplesLeft[botAt]) / 2; if (ampli < PING_MIN_AMPLI) { - printLog("Audio Ping unreliable - low amplitude %d.\n", ampli); + qDebug("Audio Ping unreliable - low amplitude %d.\n", ampli); } // Determine period - warn if doesn't look like our signal int halfPeriod = abs(topAt - botAt); if (abs(halfPeriod-PING_HALF_PERIOD) > PING_MAX_PERIOD_DIFFERENCE) { - printLog("Audio Ping unreliable - peak distance %d vs. %d\n", halfPeriod, PING_HALF_PERIOD); + qDebug("Audio Ping unreliable - peak distance %d vs. %d\n", halfPeriod, PING_HALF_PERIOD); } // Ping is sent: @@ -747,7 +748,7 @@ inline void Audio::analyzePing() { int delay = (botAt + topAt) / 2 + PING_PERIOD; - printLog("\n| Audio Ping results:\n+----- ---- --- - - - - -\n\n" + qDebug("\n| Audio Ping results:\n+----- ---- --- - - - - -\n\n" "Delay = %d samples (%d ms)\nPeak amplitude = %d\n\n", delay, (delay * 1000) / int(SAMPLE_RATE), ampli); } diff --git a/interface/src/Audio.h b/interface/src/Audio.h index a3c8cf1046..d11a14444a 100644 --- a/interface/src/Audio.h +++ b/interface/src/Audio.h @@ -14,7 +14,6 @@ #include #include "Oscilloscope.h" -#include "Avatar.h" static const int NUM_AUDIO_CHANNELS = 2; diff --git a/interface/src/Avatar.cpp b/interface/src/Avatar.cpp index a1175e3b23..27ec1dd671 100755 --- a/interface/src/Avatar.cpp +++ b/interface/src/Avatar.cpp @@ -5,24 +5,25 @@ // Created by Philip Rosedale on 9/11/12. // Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +#include + #include #include #include -#include + +#include +#include +#include +#include #include -#include "world.h" + #include "Application.h" #include "Avatar.h" #include "Hand.h" #include "Head.h" -#include "Log.h" #include "Physics.h" +#include "world.h" #include "ui/TextRenderer.h" -#include -#include -#include -#include - using namespace std; diff --git a/interface/src/Avatar.h b/interface/src/Avatar.h index 643a187a67..f41094173c 100755 --- a/interface/src/Avatar.h +++ b/interface/src/Avatar.h @@ -10,18 +10,21 @@ #include #include -#include + #include -#include "world.h" + +#include + #include "AvatarTouch.h" #include "AvatarVoxelSystem.h" -#include "InterfaceConfig.h" -#include "SerialInterface.h" #include "Balls.h" #include "Hand.h" #include "Head.h" +#include "InterfaceConfig.h" #include "Skeleton.h" +#include "SerialInterface.h" #include "Transmitter.h" +#include "world.h" const float BODY_BALL_RADIUS_PELVIS = 0.07; const float BODY_BALL_RADIUS_TORSO = 0.065; diff --git a/interface/src/AvatarVoxelSystem.cpp b/interface/src/AvatarVoxelSystem.cpp index 99514ce7d0..c85ea1a343 100644 --- a/interface/src/AvatarVoxelSystem.cpp +++ b/interface/src/AvatarVoxelSystem.cpp @@ -93,7 +93,7 @@ const Mode MODES[] = { void AvatarVoxelSystem::cycleMode() { _mode = (_mode + 1) % (sizeof(MODES) / sizeof(MODES[0])); - printLog("Voxeltar bind mode %d.\n", _mode); + qDebug("Voxeltar bind mode %d.\n", _mode); // rebind QUrl url = _voxelURL; @@ -255,7 +255,7 @@ void AvatarVoxelSystem::handleVoxelDownloadProgress(qint64 bytesReceived, qint64 } void AvatarVoxelSystem::handleVoxelReplyError() { - printLog("%s\n", _voxelReply->errorString().toAscii().constData()); + qDebug("%s\n", _voxelReply->errorString().toAscii().constData()); _voxelReply->disconnect(this); _voxelReply->deleteLater(); diff --git a/interface/src/BandwidthMeter.cpp b/interface/src/BandwidthMeter.cpp index 5e0d63d6c5..1c1fa62297 100644 --- a/interface/src/BandwidthMeter.cpp +++ b/interface/src/BandwidthMeter.cpp @@ -9,7 +9,6 @@ #include "BandwidthMeter.h" #include "InterfaceConfig.h" -#include "Log.h" #include "Util.h" namespace { // .cpp-local diff --git a/interface/src/Camera.cpp b/interface/src/Camera.cpp index 8aaec5b899..a9db96e65c 100644 --- a/interface/src/Camera.cpp +++ b/interface/src/Camera.cpp @@ -5,9 +5,10 @@ // Copyright (c) 2013 High Fidelity, Inc. All rights reserved. #include + #include #include -#include "Log.h" + #include "Camera.h" #include "Util.h" diff --git a/interface/src/LogDisplay.cpp b/interface/src/LogDisplay.cpp index 6a65c30021..708bb192d3 100644 --- a/interface/src/LogDisplay.cpp +++ b/interface/src/LogDisplay.cpp @@ -26,9 +26,7 @@ LogDisplay LogDisplay::instance; // State management // -LogDisplay::LogDisplay() : - - +LogDisplay::LogDisplay() : _textRenderer(SANS_FONT_FAMILY, -1, -1, false, TextRenderer::SHADOW_EFFECT), _stream(DEFAULT_STREAM), _chars(0l), @@ -53,8 +51,6 @@ LogDisplay::LogDisplay() : memset(_lines, 0, LINE_BUFFER_SIZE * sizeof(char*)); setCharacterSize(DEFAULT_CHAR_WIDTH, DEFAULT_CHAR_HEIGHT); - - printLog = & printLogHandler; } @@ -92,31 +88,6 @@ void LogDisplay::setCharacterSize(unsigned width, unsigned height) { // Logging // -int LogDisplay::printLogHandler(char const* fmt, ...) { - - va_list args; - int n; - char buf[MAX_MESSAGE_LENGTH]; - va_start(args,fmt); - - // print to buffer - n = vsnprintf(buf, MAX_MESSAGE_LENGTH, fmt, args); - if (n > 0) { - - // all fine? log the message - instance.addMessage(buf); - - } else { - - // error? -> mutter on stream or stderr - fprintf(instance._stream != 0l ? instance._stream : stderr, - "Log: Failed to log message with format string = \"%s\".\n", fmt); - } - - va_end(args); - return n; -} - inline void LogDisplay::addMessage(char const* ptr) { pthread_mutex_lock(& _mutex); diff --git a/interface/src/LogDisplay.h b/interface/src/LogDisplay.h index f699cb5279..bb74872dbd 100644 --- a/interface/src/LogDisplay.h +++ b/interface/src/LogDisplay.h @@ -12,7 +12,6 @@ #include #include -#include "Log.h" #include "ui/TextRenderer.h" class LogDisplay { @@ -21,6 +20,9 @@ public: static LogDisplay instance; void render(unsigned screenWidth, unsigned screenHeight); + + // log formatted message + inline void addMessage(char const*); // settings @@ -50,12 +52,6 @@ private: LogDisplay(LogDisplay const&); // = delete; LogDisplay& operator=(LogDisplay const&); // = delete; - // format and log message - entrypoint used to replace global 'printLog' - static int printLogHandler(char const* fmt, ...); - - // log formatted message (called by printLogHandler) - inline void addMessage(char const*); - TextRenderer _textRenderer; FILE* _stream; // FILE as secondary destination for log messages char* _chars; // character buffer base address diff --git a/interface/src/SerialInterface.cpp b/interface/src/SerialInterface.cpp index aac1f8f1f2..0f90ee8dd7 100644 --- a/interface/src/SerialInterface.cpp +++ b/interface/src/SerialInterface.cpp @@ -36,6 +36,28 @@ const int LONG_TERM_RATE_SAMPLES = 1000; const bool USING_INVENSENSE_MPU9150 = 1; +SerialInterface::SerialInterface() : + _active(false), + _gravity(0, 0, 0), + _averageRotationRates(0, 0, 0), + _averageAcceleration(0, 0, 0), + _estimatedRotation(0, 0, 0), + _estimatedPosition(0, 0, 0), + _estimatedVelocity(0, 0, 0), + _lastAcceleration(0, 0, 0), + _lastRotationRates(0, 0, 0), + _compassMinima(-211, -132, -186), + _compassMaxima(89, 95, 98), + _angularVelocityToLinearAccel(0.003f, -0.001f, -0.006f, + -0.005f, -0.001f, -0.006f, + 0.010f, 0.004f, 0.007f), + _angularAccelToLinearAccel(0.0f, 0.0f, 0.002f, + 0.0f, 0.0f, 0.001f, + -0.002f, -0.002f, 0.0f) +{ + +} + void SerialInterface::pair() { #ifndef _WIN32 @@ -75,10 +97,10 @@ void SerialInterface::initializePort(char* portname) { #ifndef _WIN32 _serialDescriptor = open(portname, O_RDWR | O_NOCTTY | O_NDELAY); - printLog("Opening SerialUSB %s: ", portname); + qDebug("Opening SerialUSB %s: ", portname); if (_serialDescriptor == -1) { - printLog("Failed.\n"); + qDebug("Failed.\n"); return; } @@ -112,7 +134,7 @@ void SerialInterface::initializePort(char* portname) { mpu_set_sensors(INV_XYZ_GYRO | INV_XYZ_ACCEL | INV_XYZ_COMPASS); } - printLog("Connected.\n"); + qDebug("Connected.\n"); resetSerial(); _active = true; @@ -351,7 +373,7 @@ void SerialInterface::readData(float deltaTime) { gettimeofday(&now, NULL); if (diffclock(&lastGoodRead, &now) > NO_READ_MAXIMUM_MSECS) { - printLog("No data - Shutting down SerialInterface.\n"); + qDebug("No data - Shutting down SerialInterface.\n"); resetSerial(); } } else { diff --git a/interface/src/SerialInterface.h b/interface/src/SerialInterface.h index 6398953456..711ff56757 100644 --- a/interface/src/SerialInterface.h +++ b/interface/src/SerialInterface.h @@ -1,17 +1,14 @@ // // SerialInterface.h -// - +// hifi +// +// Created by Stephen Birarda on 2/15/13. +// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// #ifndef __interface__SerialInterface__ #define __interface__SerialInterface__ -#include -#include "Util.h" -#include "world.h" -#include "InterfaceConfig.h" -#include "Log.h" - // These includes are for serial port reading/writing #ifndef _WIN32 #include @@ -20,30 +17,16 @@ #include #endif +#include + +#include "InterfaceConfig.h" +#include "Util.h" + extern const bool USING_INVENSENSE_MPU9150; class SerialInterface { public: - SerialInterface() : _active(false), - _gravity(0, 0, 0), - _averageRotationRates(0, 0, 0), - _averageAcceleration(0, 0, 0), - _estimatedRotation(0, 0, 0), - _estimatedPosition(0, 0, 0), - _estimatedVelocity(0, 0, 0), - _lastAcceleration(0, 0, 0), - _lastRotationRates(0, 0, 0), - _compassMinima(-211, -132, -186), - _compassMaxima(89, 95, 98), - _angularVelocityToLinearAccel( - 0.003f, -0.001f, -0.006f, - -0.005f, -0.001f, -0.006f, - 0.010f, 0.004f, 0.007f), - _angularAccelToLinearAccel( - 0.0f, 0.0f, 0.002f, - 0.0f, 0.0f, 0.001f, - -0.002f, -0.002f, 0.0f) - {} + SerialInterface(); void pair(); void readData(float deltaTime); diff --git a/interface/src/Transmitter.cpp b/interface/src/Transmitter.cpp index b16fb79295..eac769ead7 100644 --- a/interface/src/Transmitter.cpp +++ b/interface/src/Transmitter.cpp @@ -13,11 +13,9 @@ #include #include "InterfaceConfig.h" -#include "Log.h" #include "Transmitter.h" #include "Util.h" - const float DELTA_TIME = 1.f / 60.f; const float DECAY_RATE = 0.15f; @@ -40,7 +38,7 @@ void Transmitter::checkForLostTransmitter() { int msecsSinceLast = diffclock(_lastReceivedPacket, &now); if (msecsSinceLast > TIME_TO_ASSUME_LOST_MSECS) { resetLevels(); - printLog("Transmitter signal lost.\n"); + qDebug("Transmitter signal lost.\n"); } } } @@ -95,12 +93,12 @@ void Transmitter::processIncomingData(unsigned char* packetData, int numBytes) { _estimatedRotation.y *= (1.f - DECAY_RATE * DELTA_TIME); if (!_isConnected) { - printLog("Transmitter Connected.\n"); + qDebug("Transmitter Connected.\n"); _isConnected = true; _estimatedRotation *= 0.0; } } else { - printLog("Transmitter packet read error, %d bytes.\n", numBytes); + qDebug("Transmitter packet read error, %d bytes.\n", numBytes); } } diff --git a/interface/src/Util.cpp b/interface/src/Util.cpp index 65a277b623..20f33f924a 100644 --- a/interface/src/Util.cpp +++ b/interface/src/Util.cpp @@ -6,7 +6,6 @@ // Copyright (c) 2012 High Fidelity, Inc. All rights reserved. // -#include "InterfaceConfig.h" #include #include #include @@ -15,16 +14,16 @@ #include #include #include + #include #include -#include "Log.h" +#include "InterfaceConfig.h" #include "ui/TextRenderer.h" -#include "world.h" -#include "Util.h" - - #include "VoxelConstants.h" +#include "world.h" + +#include "Util.h" using namespace std; @@ -452,7 +451,7 @@ void renderOrientationDirections(glm::vec3 position, const glm::quat& orientatio bool closeEnoughForGovernmentWork(float a, float b) { float distance = std::abs(a-b); - //printLog("closeEnoughForGovernmentWork() a=%1.10f b=%1.10f distance=%1.10f\n",a,b,distance); + //qDebug("closeEnoughForGovernmentWork() a=%1.10f b=%1.10f distance=%1.10f\n",a,b,distance); return (distance < 0.00001f); } @@ -470,7 +469,7 @@ void runTimingTests() { gettimeofday(&endTime, NULL); } elapsedMsecs = diffclock(&startTime, &endTime); - printLog("gettimeofday() usecs: %f\n", 1000.0f * elapsedMsecs / (float) numTests); + qDebug("gettimeofday() usecs: %f\n", 1000.0f * elapsedMsecs / (float) numTests); // Random number generation gettimeofday(&startTime, NULL); @@ -479,7 +478,7 @@ void runTimingTests() { } gettimeofday(&endTime, NULL); elapsedMsecs = diffclock(&startTime, &endTime); - printLog("rand() stored in array usecs: %f\n", 1000.0f * elapsedMsecs / (float) numTests); + qDebug("rand() stored in array usecs: %f\n", 1000.0f * elapsedMsecs / (float) numTests); // Random number generation using randFloat() gettimeofday(&startTime, NULL); @@ -488,7 +487,7 @@ void runTimingTests() { } gettimeofday(&endTime, NULL); elapsedMsecs = diffclock(&startTime, &endTime); - printLog("randFloat() stored in array usecs: %f\n", 1000.0f * elapsedMsecs / (float) numTests); + qDebug("randFloat() stored in array usecs: %f\n", 1000.0f * elapsedMsecs / (float) numTests); // PowF function fTest = 1145323.2342f; @@ -498,7 +497,7 @@ void runTimingTests() { } gettimeofday(&endTime, NULL); elapsedMsecs = diffclock(&startTime, &endTime); - printLog("powf(f, 0.5) usecs: %f\n", 1000.0f * elapsedMsecs / (float) numTests); + qDebug("powf(f, 0.5) usecs: %f\n", 1000.0f * elapsedMsecs / (float) numTests); // Vector Math float distance; @@ -511,7 +510,7 @@ void runTimingTests() { } gettimeofday(&endTime, NULL); elapsedMsecs = diffclock(&startTime, &endTime); - printLog("vector math usecs: %f [%f msecs total for %d tests]\n", + qDebug("vector math usecs: %f [%f msecs total for %d tests]\n", 1000.0f * elapsedMsecs / (float) numTests, elapsedMsecs, numTests); // Vec3 test @@ -525,7 +524,7 @@ void runTimingTests() { } gettimeofday(&endTime, NULL); elapsedMsecs = diffclock(&startTime, &endTime); - printLog("vec3 assign and dot() usecs: %f\n", 1000.0f * elapsedMsecs / (float) numTests); + qDebug("vec3 assign and dot() usecs: %f\n", 1000.0f * elapsedMsecs / (float) numTests); } diff --git a/interface/src/VoxelSystem.cpp b/interface/src/VoxelSystem.cpp index 2801d16748..f219e38dc6 100644 --- a/interface/src/VoxelSystem.cpp +++ b/interface/src/VoxelSystem.cpp @@ -5,28 +5,31 @@ // Created by Philip on 12/31/12. // Copyright (c) 2012 High Fidelity, Inc. All rights reserved. // + #ifdef _WIN32 #define _timeval_ #define _USE_MATH_DEFINES #endif + #include #include #include // to load voxels from file #include // to load voxels from file +#include + #include -#include + +#include #include #include -#include -#include +#include + #include "Application.h" -#include "Log.h" -#include "VoxelConstants.h" #include "CoverageMap.h" #include "CoverageMapV2.h" #include "InterfaceConfig.h" #include "renderer/ProgramObject.h" - +#include "VoxelConstants.h" #include "VoxelSystem.h" float identityVertices[] = { 0,0,0, 1,0,0, 1,1,0, 0,1,0, 0,0,1, 1,0,1, 1,1,1, 0,1,1, @@ -141,16 +144,16 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) { int commandLength = strlen(command); // commands are null terminated strings int totalLength = 1+commandLength+1; - printLog("got Z message len(%d)= %s\n", numBytes, command); + qDebug("got Z message len(%d)= %s\n", numBytes, command); while (totalLength <= numBytes) { if (0==strcmp(command,(char*)"erase all")) { - printLog("got Z message == erase all\n"); + qDebug("got Z message == erase all\n"); _tree->eraseAllVoxels(); _voxelsInReadArrays = _voxelsInWriteArrays = 0; // better way to do this?? } if (0==strcmp(command,(char*)"add scene")) { - printLog("got Z message == add scene - NOT SUPPORTED ON INTERFACE\n"); + qDebug("got Z message == add scene - NOT SUPPORTED ON INTERFACE\n"); } totalLength += commandLength+1; } @@ -705,7 +708,7 @@ bool VoxelSystem::randomColorOperation(VoxelNode* node, void* extraData) { void VoxelSystem::randomizeVoxelColors() { _nodeCount = 0; _tree->recurseTreeWithOperation(randomColorOperation); - printLog("setting randomized true color for %d nodes\n", _nodeCount); + qDebug("setting randomized true color for %d nodes\n", _nodeCount); setupNewVoxelsForDrawing(); } @@ -719,7 +722,7 @@ bool VoxelSystem::falseColorizeRandomOperation(VoxelNode* node, void* extraData) void VoxelSystem::falseColorizeRandom() { _nodeCount = 0; _tree->recurseTreeWithOperation(falseColorizeRandomOperation); - printLog("setting randomized false color for %d nodes\n", _nodeCount); + qDebug("setting randomized false color for %d nodes\n", _nodeCount); setupNewVoxelsForDrawing(); } @@ -733,7 +736,7 @@ void VoxelSystem::trueColorize() { PerformanceWarning warn(true, "trueColorize()",true); _nodeCount = 0; _tree->recurseTreeWithOperation(trueColorizeOperation); - printLog("setting true color for %d nodes\n", _nodeCount); + qDebug("setting true color for %d nodes\n", _nodeCount); setupNewVoxelsForDrawing(); } @@ -753,7 +756,7 @@ bool VoxelSystem::falseColorizeInViewOperation(VoxelNode* node, void* extraData) void VoxelSystem::falseColorizeInView(ViewFrustum* viewFrustum) { _nodeCount = 0; _tree->recurseTreeWithOperation(falseColorizeInViewOperation,(void*)viewFrustum); - printLog("setting in view false color for %d nodes\n", _nodeCount); + qDebug("setting in view false color for %d nodes\n", _nodeCount); setupNewVoxelsForDrawing(); } @@ -803,10 +806,10 @@ void VoxelSystem::falseColorizeDistanceFromView(ViewFrustum* viewFrustum) { _maxDistance = 0.0; _minDistance = FLT_MAX; _tree->recurseTreeWithOperation(getDistanceFromViewRangeOperation,(void*)viewFrustum); - printLog("determining distance range for %d nodes\n", _nodeCount); + qDebug("determining distance range for %d nodes\n", _nodeCount); _nodeCount = 0; _tree->recurseTreeWithOperation(falseColorizeDistanceFromViewOperation,(void*)viewFrustum); - printLog("setting in distance false color for %d nodes\n", _nodeCount); + qDebug("setting in distance false color for %d nodes\n", _nodeCount); setupNewVoxelsForDrawing(); } @@ -918,7 +921,7 @@ void VoxelSystem::removeOutOfView() { } bool showRemoveDebugDetails = false; if (showRemoveDebugDetails) { - printLog("removeOutOfView() scanned=%ld removed=%ld inside=%ld intersect=%ld outside=%ld _removedVoxels.count()=%d \n", + qDebug("removeOutOfView() scanned=%ld removed=%ld inside=%ld intersect=%ld outside=%ld _removedVoxels.count()=%d \n", args.nodesScanned, args.nodesRemoved, args.nodesInside, args.nodesIntersect, args.nodesOutside, _removedVoxels.count() ); @@ -984,7 +987,7 @@ bool VoxelSystem::falseColorizeRandomEveryOtherOperation(VoxelNode* node, void* void VoxelSystem::falseColorizeRandomEveryOther() { falseColorizeRandomEveryOtherArgs args; _tree->recurseTreeWithOperation(falseColorizeRandomEveryOtherOperation,&args); - printLog("randomized false color for every other node: total %ld, colorable %ld, colored %ld\n", + qDebug("randomized false color for every other node: total %ld, colorable %ld, colored %ld\n", args.totalNodes, args.colorableNodes, args.coloredNodes); setupNewVoxelsForDrawing(); } @@ -1045,7 +1048,7 @@ bool VoxelSystem::collectStatsForTreesAndVBOsOperation(VoxelNode* node, void* ex unsigned long nodeIndex = node->getBufferIndex(); if (args->hasIndexFound[nodeIndex]) { args->duplicateVBOIndex++; - printLog("duplicateVBO found... index=%ld, isDirty=%s, shouldRender=%s \n", nodeIndex, + qDebug("duplicateVBO found... index=%ld, isDirty=%s, shouldRender=%s \n", nodeIndex, debug::valueOf(node->isDirty()), debug::valueOf(node->getShouldRender())); } else { args->hasIndexFound[nodeIndex] = true; @@ -1080,13 +1083,13 @@ void VoxelSystem::collectStatsForTreesAndVBOs() { args.expectedMax = _voxelsInWriteArrays; _tree->recurseTreeWithOperation(collectStatsForTreesAndVBOsOperation,&args); - printLog("Local Voxel Tree Statistics:\n total nodes %ld \n leaves %ld \n dirty %ld \n colored %ld \n shouldRender %ld \n", + qDebug("Local Voxel Tree Statistics:\n total nodes %ld \n leaves %ld \n dirty %ld \n colored %ld \n shouldRender %ld \n", args.totalNodes, args.leafNodes, args.dirtyNodes, args.coloredNodes, args.shouldRenderNodes); - printLog(" _voxelsDirty=%s \n _voxelsInWriteArrays=%ld \n minDirty=%ld \n maxDirty=%ld \n", debug::valueOf(_voxelsDirty), + qDebug(" _voxelsDirty=%s \n _voxelsInWriteArrays=%ld \n minDirty=%ld \n maxDirty=%ld \n", debug::valueOf(_voxelsDirty), _voxelsInWriteArrays, minDirty, maxDirty); - printLog(" inVBO %ld \n nodesInVBOOverExpectedMax %ld \n duplicateVBOIndex %ld \n nodesInVBONotShouldRender %ld \n", + qDebug(" inVBO %ld \n nodesInVBOOverExpectedMax %ld \n duplicateVBOIndex %ld \n nodesInVBONotShouldRender %ld \n", args.nodesInVBO, args.nodesInVBOOverExpectedMax, args.duplicateVBOIndex, args.nodesInVBONotShouldRender); glBufferIndex minInVBO = GLBUFFER_INDEX_UNKNOWN; @@ -1099,7 +1102,7 @@ void VoxelSystem::collectStatsForTreesAndVBOs() { } } - printLog(" minInVBO=%ld \n maxInVBO=%ld \n _voxelsInWriteArrays=%ld \n _voxelsInReadArrays=%ld \n", + qDebug(" minInVBO=%ld \n maxInVBO=%ld \n _voxelsInWriteArrays=%ld \n _voxelsInReadArrays=%ld \n", minInVBO, maxInVBO, _voxelsInWriteArrays, _voxelsInReadArrays); } @@ -1124,7 +1127,7 @@ void VoxelSystem::createVoxel(float x, float y, float z, float s, unsigned char red, unsigned char green, unsigned char blue, bool destructive) { pthread_mutex_lock(&_treeLock); - //printLog("VoxelSystem::createVoxel(%f,%f,%f,%f)\n",x,y,z,s); + //qDebug("VoxelSystem::createVoxel(%f,%f,%f,%f)\n",x,y,z,s); _tree->createVoxel(x, y, z, s, red, green, blue, destructive); setupNewVoxelsForDrawing(); @@ -1250,9 +1253,9 @@ bool VoxelSystem::falseColorizeOccludedOperation(VoxelNode* node, void* extraDat args->occludedVoxels++; } else if (result == STORED) { args->notOccludedVoxels++; - //printLog("***** falseColorizeOccludedOperation() NODE is STORED *****\n"); + //qDebug("***** falseColorizeOccludedOperation() NODE is STORED *****\n"); } else if (result == DOESNT_FIT) { - //printLog("***** falseColorizeOccludedOperation() NODE DOESNT_FIT???? *****\n"); + //qDebug("***** falseColorizeOccludedOperation() NODE DOESNT_FIT???? *****\n"); } } return true; // keep going! @@ -1285,7 +1288,7 @@ void VoxelSystem::falseColorizeOccluded() { _tree->recurseTreeWithOperationDistanceSorted(falseColorizeOccludedOperation, position, (void*)&args); - printLog("falseColorizeOccluded()\n position=(%f,%f)\n total=%ld\n colored=%ld\n occluded=%ld\n notOccluded=%ld\n outOfView=%ld\n subtreeVoxelsSkipped=%ld\n stagedForDeletion=%ld\n nonLeaves=%ld\n nonLeavesOutOfView=%ld\n nonLeavesOccluded=%ld\n pointInside_calls=%ld\n occludes_calls=%ld\n intersects_calls=%ld\n", + qDebug("falseColorizeOccluded()\n position=(%f,%f)\n total=%ld\n colored=%ld\n occluded=%ld\n notOccluded=%ld\n outOfView=%ld\n subtreeVoxelsSkipped=%ld\n stagedForDeletion=%ld\n nonLeaves=%ld\n nonLeavesOutOfView=%ld\n nonLeavesOccluded=%ld\n pointInside_calls=%ld\n occludes_calls=%ld\n intersects_calls=%ld\n", position.x, position.y, args.totalVoxels, args.coloredVoxels, args.occludedVoxels, args.notOccludedVoxels, args.outOfView, args.subtreeVoxelsSkipped, @@ -1371,9 +1374,9 @@ bool VoxelSystem::falseColorizeOccludedV2Operation(VoxelNode* node, void* extraD args->occludedVoxels++; } else if (result == V2_STORED) { args->notOccludedVoxels++; - //printLog("***** falseColorizeOccludedOperation() NODE is STORED *****\n"); + //qDebug("***** falseColorizeOccludedOperation() NODE is STORED *****\n"); } else if (result == V2_DOESNT_FIT) { - //printLog("***** falseColorizeOccludedOperation() NODE DOESNT_FIT???? *****\n"); + //qDebug("***** falseColorizeOccludedOperation() NODE DOESNT_FIT???? *****\n"); } delete voxelPolygon; // V2 maps don't store polygons, so we're always in charge of freeing } @@ -1410,7 +1413,7 @@ void VoxelSystem::falseColorizeOccludedV2() { _tree->recurseTreeWithOperationDistanceSorted(falseColorizeOccludedV2Operation, position, (void*)&args); - printLog("falseColorizeOccludedV2()\n position=(%f,%f)\n total=%ld\n colored=%ld\n occluded=%ld\n notOccluded=%ld\n outOfView=%ld\n subtreeVoxelsSkipped=%ld\n stagedForDeletion=%ld\n nonLeaves=%ld\n nonLeavesOutOfView=%ld\n nonLeavesOccluded=%ld\n pointInside_calls=%ld\n occludes_calls=%ld\n intersects_calls=%ld\n", + qDebug("falseColorizeOccludedV2()\n position=(%f,%f)\n total=%ld\n colored=%ld\n occluded=%ld\n notOccluded=%ld\n outOfView=%ld\n subtreeVoxelsSkipped=%ld\n stagedForDeletion=%ld\n nonLeaves=%ld\n nonLeavesOutOfView=%ld\n nonLeavesOccluded=%ld\n pointInside_calls=%ld\n occludes_calls=%ld\n intersects_calls=%ld\n", position.x, position.y, args.totalVoxels, args.coloredVoxels, args.occludedVoxels, args.notOccludedVoxels, args.outOfView, args.subtreeVoxelsSkipped, diff --git a/interface/src/Webcam.cpp b/interface/src/Webcam.cpp index 0d417583d2..f9dd5ffe2c 100644 --- a/interface/src/Webcam.cpp +++ b/interface/src/Webcam.cpp @@ -8,7 +8,6 @@ #include #include -#include #include #ifdef __APPLE__ @@ -157,7 +156,7 @@ void Webcam::setFrame(const Mat& frame, int format, const Mat& depth, const Rota glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, _frameWidth = image.width, _frameHeight = image.height, 0, format, GL_UNSIGNED_BYTE, image.imageData); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - printLog("Capturing video at %dx%d.\n", _frameWidth, _frameHeight); + qDebug("Capturing video at %dx%d.\n", _frameWidth, _frameHeight); } else { glBindTexture(GL_TEXTURE_2D, _frameTextureID); @@ -173,7 +172,7 @@ void Webcam::setFrame(const Mat& frame, int format, const Mat& depth, const Rota glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, _depthWidth = depthImage.width, _depthHeight = depthImage.height, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, depthImage.imageData); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - printLog("Capturing depth at %dx%d.\n", _depthWidth, _depthHeight); + qDebug("Capturing depth at %dx%d.\n", _depthWidth, _depthHeight); } else { glBindTexture(GL_TEXTURE_2D, _depthTextureID); @@ -331,26 +330,26 @@ static glm::quat xnToGLM(const XnMatrix3X3& matrix) { } static void XN_CALLBACK_TYPE newUser(UserGenerator& generator, XnUserID id, void* cookie) { - printLog("Found user %d.\n", id); + qDebug("Found user %d.\n", id); generator.GetSkeletonCap().RequestCalibration(id, false); } static void XN_CALLBACK_TYPE lostUser(UserGenerator& generator, XnUserID id, void* cookie) { - printLog("Lost user %d.\n", id); + qDebug("Lost user %d.\n", id); } static void XN_CALLBACK_TYPE calibrationStarted(SkeletonCapability& capability, XnUserID id, void* cookie) { - printLog("Calibration started for user %d.\n", id); + qDebug("Calibration started for user %d.\n", id); } static void XN_CALLBACK_TYPE calibrationCompleted(SkeletonCapability& capability, XnUserID id, XnCalibrationStatus status, void* cookie) { if (status == XN_CALIBRATION_STATUS_OK) { - printLog("Calibration completed for user %d.\n", id); + qDebug("Calibration completed for user %d.\n", id); capability.StartTracking(id); } else { - printLog("Calibration failed to user %d.\n", id); + qDebug("Calibration failed to user %d.\n", id); capability.RequestCalibration(id, true); } } @@ -439,7 +438,7 @@ void FrameGrabber::grabFrame() { // make sure it's in the format we expect if (image->nChannels != 3 || image->depth != IPL_DEPTH_8U || image->dataOrder != IPL_DATA_ORDER_PIXEL || image->origin != 0) { - printLog("Invalid webcam image format.\n"); + qDebug("Invalid webcam image format.\n"); return; } frame = image; @@ -486,7 +485,7 @@ bool FrameGrabber::init() { // load our face cascade switchToResourcesParentIfRequired(); if (_faceCascade.empty() && !_faceCascade.load("resources/haarcascades/haarcascade_frontalface_alt.xml")) { - printLog("Failed to load Haar cascade for face tracking.\n"); + qDebug("Failed to load Haar cascade for face tracking.\n"); return false; } @@ -514,7 +513,7 @@ bool FrameGrabber::init() { // next, an ordinary webcam if ((_capture = cvCaptureFromCAM(-1)) == 0) { - printLog("Failed to open webcam.\n"); + qDebug("Failed to open webcam.\n"); return false; } const int IDEAL_FRAME_WIDTH = 320; diff --git a/interface/src/main.cpp b/interface/src/main.cpp index 20347014f0..98ed4fb231 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -16,15 +16,16 @@ // #include "Application.h" -#include "Log.h" + +#include int main(int argc, const char * argv[]) { timeval startup_time; gettimeofday(&startup_time, NULL); Application app(argc, const_cast(argv), startup_time); - printLog( "Created QT Application.\n" ); + qDebug( "Created QT Application.\n" ); int exitCode = app.exec(); - printLog("Normal exit.\n"); + qDebug("Normal exit.\n"); return exitCode; } diff --git a/interface/src/starfield/Config.h b/interface/src/starfield/Config.h index c11fe68e38..3cbff171c7 100644 --- a/interface/src/starfield/Config.h +++ b/interface/src/starfield/Config.h @@ -39,7 +39,6 @@ #include "InterfaceConfig.h" #include "renderer/ProgramObject.h" -#include "Log.h" #include #include diff --git a/interface/src/starfield/Loader.h b/interface/src/starfield/Loader.h index e4e87516ea..e2f6105f33 100644 --- a/interface/src/starfield/Loader.h +++ b/interface/src/starfield/Loader.h @@ -38,12 +38,12 @@ namespace starfield { if (! UrlReader::readUrl(url, *this, cacheFile)) { - printLog("%s:%d: %s\n", + qDebug("%s:%d: %s\n", _urlStr, _lineNo, getError()); return false; } - printLog("Loaded %u stars.\n", _recordsRead); + qDebug("Loaded %u stars.\n", _recordsRead); return true; } @@ -63,7 +63,7 @@ namespace starfield { _vertices->clear(); _vertices->reserve(_limit); -// printLog("Stars.cpp: loader begin %s\n", url); +// qDebug("Stars.cpp: loader begin %s\n", url); } size_t transfer(char* input, size_t bytes) { @@ -103,7 +103,7 @@ namespace starfield { } else { - printLog("Stars.cpp:%d: Bad input from %s\n", + qDebug("Stars.cpp:%d: Bad input from %s\n", _lineNo, _urlStr); } @@ -128,7 +128,7 @@ namespace starfield { // remember the brightness at its top if (_recordsRead == _limit) { -// printLog("Stars.cpp: vertex limit reached -> heap mode\n"); +// qDebug("Stars.cpp: vertex limit reached -> heap mode\n"); make_heap( _vertices->begin(), _vertices->end(), diff --git a/interface/src/ui/BandwidthDialog.cpp b/interface/src/ui/BandwidthDialog.cpp index 1e0e2e616e..4ff9a9878e 100644 --- a/interface/src/ui/BandwidthDialog.cpp +++ b/interface/src/ui/BandwidthDialog.cpp @@ -7,8 +7,6 @@ #include #include -#include "Log.h" - BandwidthDialog::BandwidthDialog(QWidget* parent, BandwidthMeter* model) : QDialog(parent, Qt::Window | Qt::WindowCloseButtonHint | Qt::WindowStaysOnTopHint), _model(model) { diff --git a/libraries/shared/src/Log.cpp b/libraries/shared/src/Log.cpp deleted file mode 100644 index 2db1ab4288..0000000000 --- a/libraries/shared/src/Log.cpp +++ /dev/null @@ -1,15 +0,0 @@ -// -// Log.cpp -// hifi -// -// Created by Tobias Schwinger on 4/17/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. -// - -#include "Log.h" - -#include - -using namespace std; -int (* printLog)(char const*, ...) = & printf; - diff --git a/libraries/shared/src/Log.h b/libraries/shared/src/Log.h deleted file mode 100644 index e2bc77e1e8..0000000000 --- a/libraries/shared/src/Log.h +++ /dev/null @@ -1,21 +0,0 @@ -// -// Log.h -// hifi -// -// Created by Tobias Schwinger on 4/17/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. -// - -#ifndef __hifi__shared_Log__ -#define __hifi__shared_Log__ - -// -// Pointer to log function -// -// An application may reset this variable to receive the log messages -// issued using 'printLog'. It defaults to a pointer to 'printf'. -// -extern int (* printLog)(char const*, ...); - -#endif /* defined(__hifi__shared_Log__) */ - diff --git a/libraries/shared/src/Node.cpp b/libraries/shared/src/Node.cpp index f7c9758fd0..41936d3a99 100644 --- a/libraries/shared/src/Node.cpp +++ b/libraries/shared/src/Node.cpp @@ -6,15 +6,9 @@ // Copyright (c) 2013 High Fidelity, Inc. All rights reserved. // -#include "stdio.h" - -#include -#include "Node.h" -#include "NodeTypes.h" #include -#include "Log.h" -#include "UDPSocket.h" -#include "SharedUtil.h" +#include +#include #ifdef _WIN32 #include "Syssocket.h" @@ -22,6 +16,13 @@ #include #endif +#include "Node.h" +#include "NodeTypes.h" +#include "SharedUtil.h" +#include "UDPSocket.h" + +#include + int unpackNodeId(unsigned char* packedData, uint16_t* nodeId) { memcpy(nodeId, packedData, sizeof(uint16_t)); return sizeof(uint16_t); @@ -140,18 +141,14 @@ float Node::getAverageKilobitsPerSecond() { } } -void Node::printLog(Node const& node) { - +QDebug operator<<(QDebug debug, const Node &node) { char publicAddressBuffer[16] = {'\0'}; - unsigned short publicAddressPort = loadBufferWithSocketInfo(publicAddressBuffer, node._publicSocket); + unsigned short publicAddressPort = loadBufferWithSocketInfo(publicAddressBuffer, node.getPublicSocket()); //char localAddressBuffer[16] = {'\0'}; //unsigned short localAddressPort = loadBufferWithSocketInfo(localAddressBuffer, node.localSocket); - ::printLog("# %d %s (%c) @ %s:%d\n", - node._nodeID, - node.getTypeName(), - node._type, - publicAddressBuffer, - publicAddressPort); + debug << "#" << node.getNodeID() << node.getTypeName() << node.getType(); + debug.nospace() << publicAddressBuffer << ":" << publicAddressPort; + return debug.space(); } diff --git a/libraries/shared/src/Node.h b/libraries/shared/src/Node.h index aa88cb158c..46bf90ed43 100644 --- a/libraries/shared/src/Node.h +++ b/libraries/shared/src/Node.h @@ -9,8 +9,8 @@ #ifndef __hifi__Node__ #define __hifi__Node__ -#include #include +#include #ifdef _WIN32 #include "Syssocket.h" @@ -18,8 +18,10 @@ #include #endif -#include "SimpleMovingAverage.h" +#include + #include "NodeData.h" +#include "SimpleMovingAverage.h" class Node { public: @@ -89,8 +91,9 @@ private: pthread_mutex_t _mutex; }; - int unpackNodeId(unsigned char *packedData, uint16_t *nodeId); int packNodeId(unsigned char *packStore, uint16_t nodeId); +QDebug operator<<(QDebug debug, const Node &message); + #endif /* defined(__hifi__Node__) */ diff --git a/libraries/shared/src/NodeList.cpp b/libraries/shared/src/NodeList.cpp index 004568584d..6ba71613de 100644 --- a/libraries/shared/src/NodeList.cpp +++ b/libraries/shared/src/NodeList.cpp @@ -11,11 +11,12 @@ #include #include +#include + #include "NodeList.h" #include "NodeTypes.h" #include "PacketHeaders.h" #include "SharedUtil.h" -#include "Log.h" #ifdef _WIN32 #include "Syssocket.h" @@ -42,7 +43,7 @@ NodeList* NodeList::createInstance(char ownerType, unsigned int socketListenPort if (!_sharedInstance) { _sharedInstance = new NodeList(ownerType, socketListenPort); } else { - printLog("NodeList createInstance called with existing instance.\n"); + qDebug("NodeList createInstance called with existing instance.\n"); } return _sharedInstance; @@ -50,7 +51,7 @@ NodeList* NodeList::createInstance(char ownerType, unsigned int socketListenPort NodeList* NodeList::getInstance() { if (!_sharedInstance) { - printLog("NodeList getInstance called before call to createInstance. Returning NULL pointer.\n"); + qDebug("NodeList getInstance called before call to createInstance. Returning NULL pointer.\n"); } return _sharedInstance; @@ -274,12 +275,12 @@ void NodeList::sendDomainServerCheckIn() { sockaddr_in tempAddress; memcpy(&tempAddress.sin_addr, pHostInfo->h_addr_list[0], pHostInfo->h_length); strcpy(_domainIP, inet_ntoa(tempAddress.sin_addr)); - printLog("Domain Server: %s \n", _domainHostname); + qDebug("Domain Server: %s \n", _domainHostname); } else { - printLog("Failed domain server lookup\n"); + qDebug("Failed domain server lookup\n"); } } else if (!printedDomainServerIP) { - printLog("Domain Server IP: %s\n", _domainIP); + qDebug("Domain Server IP: %s\n", _domainIP); printedDomainServerIP = true; } @@ -418,8 +419,7 @@ void NodeList::addNodeToList(Node* newNode) { ++_numNodes; - printLog("Added "); - Node::printLog(*newNode); + qDebug() << "Added " << *newNode; } unsigned NodeList::broadcastToNodes(unsigned char *broadcastData, size_t dataBytes, const char* nodeTypes, int numNodeTypes) { @@ -474,8 +474,7 @@ void *removeSilentNodes(void *args) { if ((checkTimeUSecs - node->getLastHeardMicrostamp()) > NODE_SILENCE_THRESHOLD_USECS && node->getType() != NODE_TYPE_VOXEL_SERVER) { - printLog("Killed "); - Node::printLog(*node); + qDebug() << "Killed" << *node; node->setAlive(false); } diff --git a/libraries/shared/src/OctalCode.cpp b/libraries/shared/src/OctalCode.cpp index e9eaa1c49a..3b92869104 100644 --- a/libraries/shared/src/OctalCode.cpp +++ b/libraries/shared/src/OctalCode.cpp @@ -6,12 +6,14 @@ // Copyright (c) 2013 HighFidelity, Inc. All rights reserved. // -#include #include // std:min +#include #include + +#include + #include "SharedUtil.h" #include "OctalCode.h" -#include "Log.h" int numberOfThreeBitSectionsInCode(unsigned char * octalCode) { if (*octalCode == 255) { @@ -23,12 +25,12 @@ int numberOfThreeBitSectionsInCode(unsigned char * octalCode) { void printOctalCode(unsigned char * octalCode) { if (!octalCode) { - printLog("NULL\n"); + qDebug("NULL\n"); } else { for (int i = 0; i < bytesRequiredForCodeLength(*octalCode); i++) { outputBits(octalCode[i],false); } - printLog("\n"); + qDebug("\n"); } } diff --git a/libraries/shared/src/PacketHeaders.cpp b/libraries/shared/src/PacketHeaders.cpp index 230ca5bacc..7b4a0509f3 100644 --- a/libraries/shared/src/PacketHeaders.cpp +++ b/libraries/shared/src/PacketHeaders.cpp @@ -8,8 +8,9 @@ #include +#include + #include "PacketHeaders.h" -#include "Log.h" PACKET_VERSION versionForPacketType(PACKET_TYPE type) { switch (type) { @@ -28,7 +29,7 @@ bool packetVersionMatch(unsigned char* packetHeader) { if (packetHeader[1] == versionForPacketType(packetHeader[0])) { return true; } else { - printLog("There is a packet version mismatch for packet with header %c\n", packetHeader[0]); + qDebug("There is a packet version mismatch for packet with header %c\n", packetHeader[0]); return false; } } diff --git a/libraries/shared/src/PerfStat.cpp b/libraries/shared/src/PerfStat.cpp index d3547b384e..86985eb038 100644 --- a/libraries/shared/src/PerfStat.cpp +++ b/libraries/shared/src/PerfStat.cpp @@ -10,12 +10,13 @@ // // -#include "PerfStat.h" #include -#include #include +#include -#include "Log.h" +#include + +#include "PerfStat.h" // Static class members initialization here! std::map > PerfStat::groupHistoryMap; @@ -58,11 +59,11 @@ PerfStat::~PerfStat() { } if (wantDebugOut) { - printLog("PerfStats: %s elapsed:%f average:%lf count:%ld total:%lf ut:%d us:%d ue:%d t:%ld s:%ld e:%ld\n", - this->group.c_str(),elapsed,average,count,totalTime, - (end.tv_usec-start.tv_usec),start.tv_usec,end.tv_usec, - (end.tv_sec-start.tv_sec),start.tv_sec,end.tv_sec - ); + qDebug("PerfStats: %s elapsed:%f average:%lf count:%ld total:%lf ut:%d us:%d ue:%d t:%ld s:%ld e:%ld\n", + this->group.c_str(),elapsed,average,count,totalTime, + (end.tv_usec-start.tv_usec),start.tv_usec,end.tv_usec, + (end.tv_sec-start.tv_sec),start.tv_sec,end.tv_sec + ); } }; @@ -110,12 +111,12 @@ PerformanceWarning::~PerformanceWarning() { if ((_alwaysDisplay || _renderWarningsOn) && elapsedmsec > 1) { if (elapsedmsec > 1000) { double elapsedsec = (end - _start) / 1000000.0; - printLog("%s%s took %lf seconds\n", (_alwaysDisplay ? "" : "WARNING!"), _message, elapsedsec); + qDebug("%s%s took %lf seconds\n", (_alwaysDisplay ? "" : "WARNING!"), _message, elapsedsec); } else { - printLog("%s%s took %lf milliseconds\n", (_alwaysDisplay ? "" : "WARNING!"), _message, elapsedmsec); + qDebug("%s%s took %lf milliseconds\n", (_alwaysDisplay ? "" : "WARNING!"), _message, elapsedmsec); } } else if (_alwaysDisplay) { - printLog("%s took %lf milliseconds\n", _message, elapsedmsec); + qDebug("%s took %lf milliseconds\n", _message, elapsedmsec); } }; diff --git a/libraries/shared/src/SharedUtil.cpp b/libraries/shared/src/SharedUtil.cpp index eb46458b2c..23b889bdab 100644 --- a/libraries/shared/src/SharedUtil.cpp +++ b/libraries/shared/src/SharedUtil.cpp @@ -20,7 +20,8 @@ #include #endif -#include "Log.h" +#include + #include "OctalCode.h" #include "PacketHeaders.h" #include "SharedUtil.h" @@ -64,24 +65,24 @@ void outputBufferBits(unsigned char* buffer, int length, bool withNewLine) { outputBits(buffer[i], false); } if (withNewLine) { - printLog("\n"); + qDebug("\n"); } } void outputBits(unsigned char byte, bool withNewLine) { if (isalnum(byte)) { - printLog("[ %d (%c): ", byte, byte); + qDebug("[ %d (%c): ", byte, byte); } else { - printLog("[ %d (0x%x): ", byte, byte); + qDebug("[ %d (0x%x): ", byte, byte); } for (int i = 0; i < 8; i++) { - printLog("%d", byte >> (7 - i) & 1); + qDebug("%d", byte >> (7 - i) & 1); } - printLog(" ] "); + qDebug(" ] "); if (withNewLine) { - printLog("\n"); + qDebug("\n"); } } @@ -385,14 +386,14 @@ void printVoxelCode(unsigned char* voxelCode) { unsigned int voxelSizeInOctets = (voxelSizeInBits/3); unsigned int voxelBufferSize = voxelSizeInBytes+1+3; // 1 for size, 3 for color - printLog("octets=%d\n",octets); - printLog("voxelSizeInBits=%d\n",voxelSizeInBits); - printLog("voxelSizeInBytes=%d\n",voxelSizeInBytes); - printLog("voxelSizeInOctets=%d\n",voxelSizeInOctets); - printLog("voxelBufferSize=%d\n",voxelBufferSize); + qDebug("octets=%d\n",octets); + qDebug("voxelSizeInBits=%d\n",voxelSizeInBits); + qDebug("voxelSizeInBytes=%d\n",voxelSizeInBytes); + qDebug("voxelSizeInOctets=%d\n",voxelSizeInOctets); + qDebug("voxelBufferSize=%d\n",voxelBufferSize); for(int i=0;i #include #include +#include #include #ifdef _WIN32 @@ -21,7 +20,9 @@ #include #endif -#include "Log.h" +#include + +#include "UDPSocket.h" sockaddr_in destSockaddr, senderAddress; @@ -123,7 +124,7 @@ UDPSocket::UDPSocket(int listeningPort) : listeningPort(listeningPort), blocking handle = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); if (handle <= 0) { - printLog("Failed to create socket.\n"); + qDebug("Failed to create socket.\n"); return; } @@ -136,7 +137,7 @@ UDPSocket::UDPSocket(int listeningPort) : listeningPort(listeningPort), blocking bind_address.sin_port = htons((uint16_t) listeningPort); if (bind(handle, (const sockaddr*) &bind_address, sizeof(sockaddr_in)) < 0) { - printLog("Failed to bind socket to port %d.\n", listeningPort); + qDebug("Failed to bind socket to port %d.\n", listeningPort); return; } @@ -153,7 +154,7 @@ UDPSocket::UDPSocket(int listeningPort) : listeningPort(listeningPort), blocking tv.tv_usec = 500000; setsockopt(handle, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof tv); - printLog("Created UDP socket listening on port %d.\n", listeningPort); + qDebug("Created UDP socket listening on port %d.\n", listeningPort); } UDPSocket::~UDPSocket() { @@ -233,7 +234,7 @@ int UDPSocket::send(sockaddr* destAddress, const void* data, size_t byteLength) 0, (sockaddr *) destAddress, sizeof(sockaddr_in)); if (sent_bytes != byteLength) { - printLog("Failed to send packet: %s\n", strerror(errno)); + qDebug("Failed to send packet: %s\n", strerror(errno)); return false; } diff --git a/libraries/shared/src/UrlReader.cpp b/libraries/shared/src/UrlReader.cpp index 638134f4dd..3f98326726 100644 --- a/libraries/shared/src/UrlReader.cpp +++ b/libraries/shared/src/UrlReader.cpp @@ -6,20 +6,17 @@ // Copyright (c) 2013 High Fidelity, Inc. All rights reserved. // -#include "UrlReader.h" - #include #include #include -#include "Log.h" - #ifndef _WIN32 // (Windows port is incomplete and the build files do not support CURL, yet) #include +#include "UrlReader.h" // // ATTENTION: A certain part of the implementation lives in inlined code diff --git a/libraries/voxels/src/CoverageMap.cpp b/libraries/voxels/src/CoverageMap.cpp index d30e0a4290..31bcfb64cb 100644 --- a/libraries/voxels/src/CoverageMap.cpp +++ b/libraries/voxels/src/CoverageMap.cpp @@ -6,10 +6,13 @@ // Copyright (c) 2013 High Fidelity, Inc. All rights reserved. // -#include "CoverageMap.h" -#include #include -#include "Log.h" + +#include + +#include + +#include "CoverageMap.h" int CoverageMap::_mapCount = 0; int CoverageMap::_checkMapRootCalls = 0; @@ -60,7 +63,7 @@ CoverageMap::CoverageMap(BoundingBox boundingBox, bool isRoot, bool managePolygo { _mapCount++; init(); - //printLog("CoverageMap created... _mapCount=%d\n",_mapCount); + //qDebug("CoverageMap created... _mapCount=%d\n",_mapCount); }; CoverageMap::~CoverageMap() { @@ -68,19 +71,19 @@ CoverageMap::~CoverageMap() { }; void CoverageMap::printStats() { - printLog("CoverageMap::printStats()...\n"); - printLog("MINIMUM_POLYGON_AREA_TO_STORE=%f\n",MINIMUM_POLYGON_AREA_TO_STORE); - printLog("_mapCount=%d\n",_mapCount); - printLog("_checkMapRootCalls=%d\n",_checkMapRootCalls); - printLog("_notAllInView=%d\n",_notAllInView); - printLog("_maxPolygonsUsed=%d\n",CoverageRegion::_maxPolygonsUsed); - printLog("_totalPolygons=%d\n",CoverageRegion::_totalPolygons); - printLog("_occlusionTests=%d\n",CoverageRegion::_occlusionTests); - printLog("_regionSkips=%d\n",CoverageRegion::_regionSkips); - printLog("_tooSmallSkips=%d\n",CoverageRegion::_tooSmallSkips); - printLog("_regionFullSkips=%d\n",CoverageRegion::_regionFullSkips); - printLog("_outOfOrderPolygon=%d\n",CoverageRegion::_outOfOrderPolygon); - printLog("_clippedPolygons=%d\n",CoverageRegion::_clippedPolygons); + qDebug("CoverageMap::printStats()...\n"); + qDebug("MINIMUM_POLYGON_AREA_TO_STORE=%f\n",MINIMUM_POLYGON_AREA_TO_STORE); + qDebug("_mapCount=%d\n",_mapCount); + qDebug("_checkMapRootCalls=%d\n",_checkMapRootCalls); + qDebug("_notAllInView=%d\n",_notAllInView); + qDebug("_maxPolygonsUsed=%d\n",CoverageRegion::_maxPolygonsUsed); + qDebug("_totalPolygons=%d\n",CoverageRegion::_totalPolygons); + qDebug("_occlusionTests=%d\n",CoverageRegion::_occlusionTests); + qDebug("_regionSkips=%d\n",CoverageRegion::_regionSkips); + qDebug("_tooSmallSkips=%d\n",CoverageRegion::_tooSmallSkips); + qDebug("_regionFullSkips=%d\n",CoverageRegion::_regionFullSkips); + qDebug("_outOfOrderPolygon=%d\n",CoverageRegion::_outOfOrderPolygon); + qDebug("_clippedPolygons=%d\n",CoverageRegion::_clippedPolygons); } void CoverageMap::erase() { @@ -99,7 +102,7 @@ void CoverageMap::erase() { } if (_isRoot && wantDebugging) { - printLog("CoverageMap last to be deleted...\n"); + qDebug("CoverageMap last to be deleted...\n"); printStats(); CoverageRegion::_maxPolygonsUsed = 0; @@ -184,7 +187,7 @@ CoverageMapStorageResult CoverageMap::checkMap(VoxelProjectedPolygon* polygon, b if (_isRoot) { _checkMapRootCalls++; - //printLog("CoverageMap::checkMap()... storeIt=%s\n", debug::valueOf(storeIt)); + //qDebug("CoverageMap::checkMap()... storeIt=%s\n", debug::valueOf(storeIt)); //polygon->printDebugDetails(); } @@ -193,7 +196,7 @@ CoverageMapStorageResult CoverageMap::checkMap(VoxelProjectedPolygon* polygon, b // not in view, then we just discard it with a DOESNT_FIT, this saves us time checking values later. if (!polygon->getAllInView()) { _notAllInView++; - //printLog("CoverageMap2::checkMap()... V2_OCCLUDED\n"); + //qDebug("CoverageMap2::checkMap()... V2_OCCLUDED\n"); return DOESNT_FIT; } @@ -240,9 +243,9 @@ CoverageMapStorageResult CoverageMap::checkMap(VoxelProjectedPolygon* polygon, b /* if (result == STORED) - printLog("CoverageMap2::checkMap()... STORED\n"); + qDebug("CoverageMap2::checkMap()... STORED\n"); else - printLog("CoverageMap2::checkMap()... OCCLUDED\n"); + qDebug("CoverageMap2::checkMap()... OCCLUDED\n"); */ return result; @@ -265,16 +268,16 @@ CoverageMapStorageResult CoverageMap::checkMap(VoxelProjectedPolygon* polygon, b /* switch (result) { case STORED: - printLog("checkMap() = STORED\n"); + qDebug("checkMap() = STORED\n"); break; case NOT_STORED: - printLog("checkMap() = NOT_STORED\n"); + qDebug("checkMap() = NOT_STORED\n"); break; case OCCLUDED: - printLog("checkMap() = OCCLUDED\n"); + qDebug("checkMap() = OCCLUDED\n"); break; default: - printLog("checkMap() = ????? \n"); + qDebug("checkMap() = ????? \n"); break; } */ @@ -287,27 +290,27 @@ CoverageMapStorageResult CoverageMap::checkMap(VoxelProjectedPolygon* polygon, b // any of our child bounding boxes, so we should add it here. if (storeIt) { if (polygon->getBoundingBox().area() > CoverageMap::MINIMUM_POLYGON_AREA_TO_STORE) { - //printLog("storing polygon of area: %f\n",polygon->getBoundingBox().area()); + //qDebug("storing polygon of area: %f\n",polygon->getBoundingBox().area()); if (storeIn->getPolygonCount() < MAX_POLYGONS_PER_REGION) { storeIn->storeInArray(polygon); - //printLog("CoverageMap2::checkMap()... STORED\n"); + //qDebug("CoverageMap2::checkMap()... STORED\n"); return STORED; } else { CoverageRegion::_regionFullSkips++; - //printLog("CoverageMap2::checkMap()... NOT_STORED\n"); + //qDebug("CoverageMap2::checkMap()... NOT_STORED\n"); return NOT_STORED; } } else { CoverageRegion::_tooSmallSkips++; - //printLog("CoverageMap2::checkMap()... NOT_STORED\n"); + //qDebug("CoverageMap2::checkMap()... NOT_STORED\n"); return NOT_STORED; } } else { - //printLog("CoverageMap2::checkMap()... NOT_STORED\n"); + //qDebug("CoverageMap2::checkMap()... NOT_STORED\n"); return NOT_STORED; } } - //printLog("CoverageMap2::checkMap()... DOESNT_FIT\n"); + //qDebug("CoverageMap2::checkMap()... DOESNT_FIT\n"); return DOESNT_FIT; } @@ -338,11 +341,11 @@ void CoverageRegion::erase() { /** if (_polygonCount) { - printLog("CoverageRegion::erase()...\n"); - printLog("_polygonCount=%d\n",_polygonCount); + qDebug("CoverageRegion::erase()...\n"); + qDebug("_polygonCount=%d\n",_polygonCount); _myBoundingBox.printDebugDetails(getRegionName()); //for (int i = 0; i < _polygonCount; i++) { - // printLog("_polygons[%d]=",i); + // qDebug("_polygons[%d]=",i); // _polygons[i]->getBoundingBox().printDebugDetails(); //} } @@ -390,7 +393,7 @@ void CoverageRegion::growPolygonArray() { _polygonDistances = newDistances; _polygonSizes = newSizes; _polygonArraySize = _polygonArraySize + DEFAULT_GROW_SIZE; - //printLog("CoverageMap::growPolygonArray() _polygonArraySize=%d...\n",_polygonArraySize); + //qDebug("CoverageMap::growPolygonArray() _polygonArraySize=%d...\n",_polygonArraySize); } const char* CoverageRegion::getRegionName() const { @@ -435,7 +438,7 @@ bool CoverageRegion::mergeItemsInArray(VoxelProjectedPolygon* seed, bool seedInA _totalPolygons--; } - //printLog("_polygonCount=%d\n",_polygonCount); + //qDebug("_polygonCount=%d\n",_polygonCount); // clean up if (_managePolygons) { @@ -483,7 +486,7 @@ void CoverageRegion::storeInArray(VoxelProjectedPolygon* polygon) { // insertion point in this array, and shift the array accordingly float area = polygon->getBoundingBox().area(); float reverseArea = 4.0f - area; - //printLog("store by size area=%f reverse area=%f\n", area, reverseArea); + //qDebug("store by size area=%f reverse area=%f\n", area, reverseArea); _polygonCount = insertIntoSortedArrays((void*)polygon, reverseArea, IGNORED, (void**)_polygons, _polygonSizes, IGNORED, _polygonCount, _polygonArraySize); @@ -497,10 +500,10 @@ void CoverageRegion::storeInArray(VoxelProjectedPolygon* polygon) { // Debugging and Optimization Tuning code. if (_polygonCount > _maxPolygonsUsed) { _maxPolygonsUsed = _polygonCount; - //printLog("CoverageRegion new _maxPolygonsUsed reached=%d region=%s\n",_maxPolygonsUsed, getRegionName()); + //qDebug("CoverageRegion new _maxPolygonsUsed reached=%d region=%s\n",_maxPolygonsUsed, getRegionName()); //_myBoundingBox.printDebugDetails("map._myBoundingBox"); } else { - //printLog("CoverageRegion::storeInArray() _polygonCount=%d region=%s\n",_polygonCount, getRegionName()); + //qDebug("CoverageRegion::storeInArray() _polygonCount=%d region=%s\n",_polygonCount, getRegionName()); } } diff --git a/libraries/voxels/src/CoverageMapV2.cpp b/libraries/voxels/src/CoverageMapV2.cpp index f5591bb324..0e382d7f12 100644 --- a/libraries/voxels/src/CoverageMapV2.cpp +++ b/libraries/voxels/src/CoverageMapV2.cpp @@ -7,11 +7,13 @@ // #include +#include + +#include + +#include #include "CoverageMapV2.h" -#include -#include -#include "Log.h" int CoverageMapV2::_mapCount = 0; int CoverageMapV2::_checkMapRootCalls = 0; @@ -59,7 +61,7 @@ CoverageMapV2::CoverageMapV2(BoundingBox boundingBox, bool isRoot, bool isCovere { _mapCount++; init(); - //printLog("CoverageMapV2 created... _mapCount=%d\n",_mapCount); + //qDebug("CoverageMapV2 created... _mapCount=%d\n",_mapCount); }; CoverageMapV2::~CoverageMapV2() { @@ -76,11 +78,11 @@ void CoverageMapV2::erase() { } if (_isRoot && wantDebugging) { - printLog("CoverageMapV2 last to be deleted...\n"); - printLog("MINIMUM_POLYGON_AREA_TO_STORE=%f\n",MINIMUM_POLYGON_AREA_TO_STORE); - printLog("_mapCount=%d\n",_mapCount); - printLog("_checkMapRootCalls=%d\n",_checkMapRootCalls); - printLog("_notAllInView=%d\n",_notAllInView); + qDebug("CoverageMapV2 last to be deleted...\n"); + qDebug("MINIMUM_POLYGON_AREA_TO_STORE=%f\n",MINIMUM_POLYGON_AREA_TO_STORE); + qDebug("_mapCount=%d\n",_mapCount); + qDebug("_checkMapRootCalls=%d\n",_checkMapRootCalls); + qDebug("_notAllInView=%d\n",_notAllInView); _mapCount = 0; _checkMapRootCalls = 0; _notAllInView = 0; diff --git a/libraries/voxels/src/GeometryUtil.cpp b/libraries/voxels/src/GeometryUtil.cpp index af2a6dfc95..894f43ee3c 100644 --- a/libraries/voxels/src/GeometryUtil.cpp +++ b/libraries/voxels/src/GeometryUtil.cpp @@ -7,7 +7,8 @@ #include -#include +#include + #include #include "GeometryUtil.h" diff --git a/libraries/voxels/src/Plane.cpp b/libraries/voxels/src/Plane.cpp index 5a99bf29c4..0a1a7ed86c 100755 --- a/libraries/voxels/src/Plane.cpp +++ b/libraries/voxels/src/Plane.cpp @@ -12,8 +12,6 @@ #include -#include "Log.h" - // These are some useful utilities that vec3 is missing void printVec3(const char* name, const glm::vec3& v) { printf("%s x=%f y=%f z=%f\n", name, v.x, v.y, v.z); diff --git a/libraries/voxels/src/Tags.cpp b/libraries/voxels/src/Tags.cpp index 8f7dab5390..e6875f36a6 100644 --- a/libraries/voxels/src/Tags.cpp +++ b/libraries/voxels/src/Tags.cpp @@ -6,14 +6,13 @@ // Copyright (c) 2013 High Fidelity, Inc. All rights reserved. // -#include "Tags.h" -#include - -#include -#include - #include +#include +#include + +#include "Tags.h" + Tag::Tag(int tagId, std::stringstream &ss) : _tagId(tagId) { int size = ss.get() << 8 | ss.get(); diff --git a/libraries/voxels/src/ViewFrustum.cpp b/libraries/voxels/src/ViewFrustum.cpp index dd4562cd8d..c13da815f8 100644 --- a/libraries/voxels/src/ViewFrustum.cpp +++ b/libraries/voxels/src/ViewFrustum.cpp @@ -3,24 +3,23 @@ // hifi // // Created by Brad Hefta-Gaub on 04/11/13. +// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. // // Simple view frustum class. // -// #include #include -#include "SharedUtil.h" -#include "Log.h" +#include #include "CoverageMap.h" #include "GeometryUtil.h" +#include "SharedUtil.h" #include "ViewFrustum.h" #include "VoxelConstants.h" - using namespace std; ViewFrustum::ViewFrustum() : @@ -323,40 +322,40 @@ bool ViewFrustum::matches(const ViewFrustum& compareTo, bool debug) const { testMatches(compareTo._eyeOffsetOrientation, _eyeOffsetOrientation); if (!result && debug) { - printLog("ViewFrustum::matches()... result=%s\n", debug::valueOf(result)); - printLog("%s -- compareTo._position=%f,%f,%f _position=%f,%f,%f\n", + qDebug("ViewFrustum::matches()... result=%s\n", debug::valueOf(result)); + qDebug("%s -- compareTo._position=%f,%f,%f _position=%f,%f,%f\n", (testMatches(compareTo._position,_position) ? "MATCHES " : "NO MATCH"), compareTo._position.x, compareTo._position.y, compareTo._position.z, _position.x, _position.y, _position.z ); - printLog("%s -- compareTo._direction=%f,%f,%f _direction=%f,%f,%f\n", + qDebug("%s -- compareTo._direction=%f,%f,%f _direction=%f,%f,%f\n", (testMatches(compareTo._direction, _direction) ? "MATCHES " : "NO MATCH"), compareTo._direction.x, compareTo._direction.y, compareTo._direction.z, _direction.x, _direction.y, _direction.z ); - printLog("%s -- compareTo._up=%f,%f,%f _up=%f,%f,%f\n", + qDebug("%s -- compareTo._up=%f,%f,%f _up=%f,%f,%f\n", (testMatches(compareTo._up, _up) ? "MATCHES " : "NO MATCH"), compareTo._up.x, compareTo._up.y, compareTo._up.z, _up.x, _up.y, _up.z ); - printLog("%s -- compareTo._right=%f,%f,%f _right=%f,%f,%f\n", + qDebug("%s -- compareTo._right=%f,%f,%f _right=%f,%f,%f\n", (testMatches(compareTo._right, _right) ? "MATCHES " : "NO MATCH"), compareTo._right.x, compareTo._right.y, compareTo._right.z, _right.x, _right.y, _right.z ); - printLog("%s -- compareTo._fieldOfView=%f _fieldOfView=%f\n", + qDebug("%s -- compareTo._fieldOfView=%f _fieldOfView=%f\n", (testMatches(compareTo._fieldOfView, _fieldOfView) ? "MATCHES " : "NO MATCH"), compareTo._fieldOfView, _fieldOfView); - printLog("%s -- compareTo._aspectRatio=%f _aspectRatio=%f\n", + qDebug("%s -- compareTo._aspectRatio=%f _aspectRatio=%f\n", (testMatches(compareTo._aspectRatio, _aspectRatio) ? "MATCHES " : "NO MATCH"), compareTo._aspectRatio, _aspectRatio); - printLog("%s -- compareTo._nearClip=%f _nearClip=%f\n", + qDebug("%s -- compareTo._nearClip=%f _nearClip=%f\n", (testMatches(compareTo._nearClip, _nearClip) ? "MATCHES " : "NO MATCH"), compareTo._nearClip, _nearClip); - printLog("%s -- compareTo._farClip=%f _farClip=%f\n", + qDebug("%s -- compareTo._farClip=%f _farClip=%f\n", (testMatches(compareTo._farClip, _farClip) ? "MATCHES " : "NO MATCH"), compareTo._farClip, _farClip); - printLog("%s -- compareTo._eyeOffsetPosition=%f,%f,%f _eyeOffsetPosition=%f,%f,%f\n", + qDebug("%s -- compareTo._eyeOffsetPosition=%f,%f,%f _eyeOffsetPosition=%f,%f,%f\n", (testMatches(compareTo._eyeOffsetPosition, _eyeOffsetPosition) ? "MATCHES " : "NO MATCH"), compareTo._eyeOffsetPosition.x, compareTo._eyeOffsetPosition.y, compareTo._eyeOffsetPosition.z, _eyeOffsetPosition.x, _eyeOffsetPosition.y, _eyeOffsetPosition.z); - printLog("%s -- compareTo._eyeOffsetOrientation=%f,%f,%f,%f _eyeOffsetOrientation=%f,%f,%f,%f\n", + qDebug("%s -- compareTo._eyeOffsetOrientation=%f,%f,%f,%f _eyeOffsetOrientation=%f,%f,%f,%f\n", (testMatches(compareTo._eyeOffsetOrientation, _eyeOffsetOrientation) ? "MATCHES " : "NO MATCH"), compareTo._eyeOffsetOrientation.x, compareTo._eyeOffsetOrientation.y, compareTo._eyeOffsetOrientation.z, compareTo._eyeOffsetOrientation.w, @@ -419,17 +418,17 @@ void ViewFrustum::computeOffAxisFrustum(float& left, float& right, float& bottom } void ViewFrustum::printDebugDetails() const { - printLog("ViewFrustum::printDebugDetails()... \n"); - printLog("_position=%f,%f,%f\n", _position.x, _position.y, _position.z ); - printLog("_direction=%f,%f,%f\n", _direction.x, _direction.y, _direction.z ); - printLog("_up=%f,%f,%f\n", _up.x, _up.y, _up.z ); - printLog("_right=%f,%f,%f\n", _right.x, _right.y, _right.z ); - printLog("_fieldOfView=%f\n", _fieldOfView); - printLog("_aspectRatio=%f\n", _aspectRatio); - printLog("_nearClip=%f\n", _nearClip); - printLog("_farClip=%f\n", _farClip); - printLog("_eyeOffsetPosition=%f,%f,%f\n", _eyeOffsetPosition.x, _eyeOffsetPosition.y, _eyeOffsetPosition.z ); - printLog("_eyeOffsetOrientation=%f,%f,%f,%f\n", _eyeOffsetOrientation.x, _eyeOffsetOrientation.y, _eyeOffsetOrientation.z, + qDebug("ViewFrustum::printDebugDetails()... \n"); + qDebug("_position=%f,%f,%f\n", _position.x, _position.y, _position.z ); + qDebug("_direction=%f,%f,%f\n", _direction.x, _direction.y, _direction.z ); + qDebug("_up=%f,%f,%f\n", _up.x, _up.y, _up.z ); + qDebug("_right=%f,%f,%f\n", _right.x, _right.y, _right.z ); + qDebug("_fieldOfView=%f\n", _fieldOfView); + qDebug("_aspectRatio=%f\n", _aspectRatio); + qDebug("_nearClip=%f\n", _nearClip); + qDebug("_farClip=%f\n", _farClip); + qDebug("_eyeOffsetPosition=%f,%f,%f\n", _eyeOffsetPosition.x, _eyeOffsetPosition.y, _eyeOffsetPosition.z ); + qDebug("_eyeOffsetOrientation=%f,%f,%f,%f\n", _eyeOffsetOrientation.x, _eyeOffsetOrientation.y, _eyeOffsetOrientation.z, _eyeOffsetOrientation.w ); } diff --git a/libraries/voxels/src/ViewFrustum.h b/libraries/voxels/src/ViewFrustum.h index e364816c59..188b85c0de 100644 --- a/libraries/voxels/src/ViewFrustum.h +++ b/libraries/voxels/src/ViewFrustum.h @@ -3,18 +3,20 @@ // hifi // // Created by Brad Hefta-Gaub on 04/11/13. +// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. // // Simple view frustum class. // -// #ifndef __hifi__ViewFrustum__ #define __hifi__ViewFrustum__ #include #include -#include "Plane.h" + #include "AABox.h" +#include "Plane.h" + #include "VoxelProjectedPolygon.h" const float DEFAULT_KEYHOLE_RADIUS = 3.0f; @@ -135,7 +137,7 @@ private: glm::vec3 _nearBottomLeft; glm::vec3 _nearBottomRight; enum { TOP_PLANE = 0, BOTTOM_PLANE, LEFT_PLANE, RIGHT_PLANE, NEAR_PLANE, FAR_PLANE }; - Plane _planes[6]; // How will this be used? + ::Plane _planes[6]; // How will this be used? const char* debugPlaneName (int plane) const; diff --git a/libraries/voxels/src/VoxelNode.cpp b/libraries/voxels/src/VoxelNode.cpp index 61a174f90b..76fae500dd 100644 --- a/libraries/voxels/src/VoxelNode.cpp +++ b/libraries/voxels/src/VoxelNode.cpp @@ -3,19 +3,21 @@ // hifi // // Created by Stephen Birarda on 3/13/13. -// +// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. // -#include #include #include +#include + +#include + +#include "AABox.h" +#include "OctalCode.h" #include "SharedUtil.h" -#include "Log.h" +#include "VoxelConstants.h" #include "VoxelNode.h" #include "VoxelTree.h" -#include "VoxelConstants.h" -#include "OctalCode.h" -#include "AABox.h" VoxelNode::VoxelNode() { unsigned char* rootCode = new unsigned char[1]; @@ -257,7 +259,7 @@ bool VoxelNode::collapseIdenticalLeaves() { // if no child, child isn't a leaf, or child doesn't have a color if (!_children[i] || _children[i]->isStagedForDeletion() || !_children[i]->isLeaf() || !_children[i]->isColored()) { allChildrenMatch=false; - //printLog("SADNESS child missing or not colored! i=%d\n",i); + //qDebug("SADNESS child missing or not colored! i=%d\n",i); break; } else { if (i==0) { @@ -274,7 +276,7 @@ bool VoxelNode::collapseIdenticalLeaves() { if (allChildrenMatch) { - //printLog("allChildrenMatch: pruning tree\n"); + //qDebug("allChildrenMatch: pruning tree\n"); for (int i = 0; i < NUMBER_OF_CHILDREN; i++) { delete _children[i]; // delete all the child nodes _children[i]=NULL; // set it to NULL @@ -308,13 +310,13 @@ void VoxelNode::printDebugDetails(const char* label) const { } } - printLog("%s - Voxel at corner=(%f,%f,%f) size=%f\n isLeaf=%s isColored=%s (%d,%d,%d,%d) isDirty=%s shouldRender=%s\n children=", label, + qDebug("%s - Voxel at corner=(%f,%f,%f) size=%f\n isLeaf=%s isColored=%s (%d,%d,%d,%d) isDirty=%s shouldRender=%s\n children=", label, _box.getCorner().x, _box.getCorner().y, _box.getCorner().z, _box.getSize().x, debug::valueOf(isLeaf()), debug::valueOf(isColored()), getColor()[0], getColor()[1], getColor()[2], getColor()[3], debug::valueOf(isDirty()), debug::valueOf(getShouldRender())); outputBits(childBits, false); - printLog("\n octalCode="); + qDebug("\n octalCode="); printOctalCode(_octalCode); } diff --git a/libraries/voxels/src/VoxelProjectedPolygon.cpp b/libraries/voxels/src/VoxelProjectedPolygon.cpp index 95c66b6821..8a39d7f358 100644 --- a/libraries/voxels/src/VoxelProjectedPolygon.cpp +++ b/libraries/voxels/src/VoxelProjectedPolygon.cpp @@ -6,10 +6,13 @@ // #include -#include "VoxelProjectedPolygon.h" + +#include + #include "GeometryUtil.h" -#include "Log.h" #include "SharedUtil.h" +#include "VoxelProjectedPolygon.h" + glm::vec2 BoundingBox::getVertex(int vertexNumber) const { switch (vertexNumber) { @@ -88,11 +91,11 @@ void BoundingBox::explandToInclude(const BoundingBox& box) { void BoundingBox::printDebugDetails(const char* label) const { if (label) { - printLog(label); + qDebug() << label; } else { - printLog("BoundingBox"); + qDebug("BoundingBox"); } - printLog("\n _set=%s\n corner=%f,%f size=%f,%f\n bounds=[(%f,%f) to (%f,%f)]\n", + qDebug("\n _set=%s\n corner=%f,%f size=%f,%f\n bounds=[(%f,%f) to (%f,%f)]\n", debug::valueOf(_set), corner.x, corner.y, size.x, size.y, corner.x, corner.y, corner.x+size.x, corner.y+size.y); } diff --git a/libraries/voxels/src/VoxelTree.cpp b/libraries/voxels/src/VoxelTree.cpp index b84b374309..803bea8038 100644 --- a/libraries/voxels/src/VoxelTree.cpp +++ b/libraries/voxels/src/VoxelTree.cpp @@ -9,26 +9,28 @@ #ifdef _WIN32 #define _USE_MATH_DEFINES #endif + #include #include #include -#include "SharedUtil.h" -#include "Log.h" -#include "PacketHeaders.h" -#include "OctalCode.h" -#include "GeometryUtil.h" -#include "VoxelTree.h" -#include "VoxelNodeBag.h" -#include "ViewFrustum.h" #include // to load voxels from file -#include "VoxelConstants.h" -#include "CoverageMap.h" -#include "SquarePixelMap.h" -#include "Tags.h" - #include +#include + +#include "CoverageMap.h" +#include "GeometryUtil.h" +#include "OctalCode.h" +#include "PacketHeaders.h" +#include "SharedUtil.h" +#include "SquarePixelMap.h" +#include "Tags.h" +#include "ViewFrustum.h" +#include "VoxelConstants.h" +#include "VoxelNodeBag.h" +#include "VoxelTree.h" + float boundaryDistanceForRenderLevel(unsigned int renderLevel) { const float voxelSizeScale = 50000.0f; return voxelSizeScale / powf(2, renderLevel); @@ -155,7 +157,7 @@ void VoxelTree::recurseNodeWithOperationDistanceSorted(VoxelNode* node, RecurseV if (childNode) { // chance to optimize, doesn't need to be actual distance!! Could be distance squared float distanceSquared = childNode->distanceSquareToPoint(point); - //printLog("recurseNodeWithOperationDistanceSorted() CHECKING child[%d] point=%f,%f center=%f,%f distance=%f...\n", i, point.x, point.y, center.x, center.y, distance); + //qDebug("recurseNodeWithOperationDistanceSorted() CHECKING child[%d] point=%f,%f center=%f,%f distance=%f...\n", i, point.x, point.y, center.x, center.y, distance); //childNode->printDebugDetails(""); currentCount = insertIntoSortedArrays((void*)childNode, distanceSquared, i, (void**)&sortedChildren, (float*)&distancesToChildren, @@ -166,7 +168,7 @@ void VoxelTree::recurseNodeWithOperationDistanceSorted(VoxelNode* node, RecurseV for (int i = 0; i < currentCount; i++) { VoxelNode* childNode = sortedChildren[i]; if (childNode) { - //printLog("recurseNodeWithOperationDistanceSorted() PROCESSING child[%d] distance=%f...\n", i, distancesToChildren[i]); + //qDebug("recurseNodeWithOperationDistanceSorted() PROCESSING child[%d] distance=%f...\n", i, distancesToChildren[i]); //childNode->printDebugDetails(""); recurseNodeWithOperationDistanceSorted(childNode, operation, point, extraData); } @@ -458,7 +460,7 @@ void VoxelTree::deleteVoxelCodeFromTreeRecursion(VoxelNode* node, void* extraDat // isn't a colored leaf, and the child branch doesn't exist, so there's nothing to do below and // we can safely return, ending the recursion and unwinding if (!childNode) { - //printLog("new___deleteVoxelCodeFromTree() child branch doesn't exist, but parent is not a leaf, just unwind\n"); + //qDebug("new___deleteVoxelCodeFromTree() child branch doesn't exist, but parent is not a leaf, just unwind\n"); return; } @@ -546,7 +548,7 @@ void VoxelTree::readCodeColorBufferToTreeRecursion(VoxelNode* node, void* extraD } } else { if (!node->isLeaf()) { - printLog("WARNING! operation would require deleting children, add Voxel ignored!\n "); + qDebug("WARNING! operation would require deleting children, add Voxel ignored!\n "); } } @@ -619,13 +621,13 @@ void VoxelTree::printTreeForDebugging(VoxelNode *startNode) { } } - printLog("color mask: "); + qDebug("color mask: "); outputBits(colorMask); // output the colors we have for (int j = 0; j < NUMBER_OF_CHILDREN; j++) { if (startNode->getChildAtIndex(j) && startNode->getChildAtIndex(j)->isColored()) { - printLog("color %d : ",j); + qDebug("color %d : ",j); for (int c = 0; c < 3; c++) { outputBits(startNode->getChildAtIndex(j)->getTrueColor()[c],false); } @@ -641,7 +643,7 @@ void VoxelTree::printTreeForDebugging(VoxelNode *startNode) { } } - printLog("child mask: "); + qDebug("child mask: "); outputBits(childMask); if (childMask > 0) { @@ -686,7 +688,7 @@ void VoxelTree::loadVoxelsFile(const char* fileName, bool wantColorRandomizer) { int totalBytesRead = 0; if(file.is_open()) { - printLog("loading file...\n"); + qDebug("loading file...\n"); bool bail = false; while (!file.eof() && !bail) { file.get(octets); @@ -711,14 +713,14 @@ void VoxelTree::loadVoxelsFile(const char* fileName, bool wantColorRandomizer) { file.get(colorRead); blue = (unsigned char)colorRead; - printLog("voxel color from file red:%d, green:%d, blue:%d \n",red,green,blue); + qDebug("voxel color from file red:%d, green:%d, blue:%d \n",red,green,blue); vCount++; int colorRandomizer = wantColorRandomizer ? randIntInRange (-5, 5) : 0; voxelData[lengthInBytes+1] = std::max(0,std::min(255,red + colorRandomizer)); voxelData[lengthInBytes+2] = std::max(0,std::min(255,green + colorRandomizer)); voxelData[lengthInBytes+3] = std::max(0,std::min(255,blue + colorRandomizer)); - printLog("voxel color after rand red:%d, green:%d, blue:%d\n", + qDebug("voxel color after rand red:%d, green:%d, blue:%d\n", voxelData[lengthInBytes+1], voxelData[lengthInBytes+2], voxelData[lengthInBytes+3]); //printVoxelCode(voxelData); @@ -819,7 +821,7 @@ void VoxelTree::createSphere(float radius, float xc, float yc, float zc, float v if (debug) { int percentComplete = 100 * (thisRadius/radius); - printLog("percentComplete=%d\n",percentComplete); + qDebug("percentComplete=%d\n",percentComplete); } for (float theta=0.0; theta <= 2 * M_PI; theta += angleDelta) { @@ -835,7 +837,7 @@ void VoxelTree::createSphere(float radius, float xc, float yc, float zc, float v // 2) In all modes, we will use our "outer" color to draw the voxels. Otherwise we will use the average color if (lastLayer) { if (false && debug) { - printLog("adding candy shell: theta=%f phi=%f thisRadius=%f radius=%f\n", + qDebug("adding candy shell: theta=%f phi=%f thisRadius=%f radius=%f\n", theta, phi, thisRadius,radius); } switch (mode) { @@ -859,7 +861,7 @@ void VoxelTree::createSphere(float radius, float xc, float yc, float zc, float v green = (unsigned char)std::min(255, std::max(0, (int)(g1 + ((g2 - g1) * gradient)))); blue = (unsigned char)std::min(255, std::max(0, (int)(b1 + ((b2 - b1) * gradient)))); if (debug) { - printLog("perlin=%f gradient=%f color=(%d,%d,%d)\n",perlin, gradient, red, green, blue); + qDebug("perlin=%f gradient=%f color=(%d,%d,%d)\n",perlin, gradient, red, green, blue); } } break; } @@ -1176,7 +1178,7 @@ int VoxelTree::encodeTreeBitstreamRecursion(VoxelNode* node, unsigned char* outp if (childNode) { // chance to optimize, doesn't need to be actual distance!! Could be distance squared //float distanceSquared = childNode->distanceSquareToPoint(point); - //printLog("recurseNodeWithOperationDistanceSorted() CHECKING child[%d] point=%f,%f center=%f,%f distance=%f...\n", i, point.x, point.y, center.x, center.y, distance); + //qDebug("recurseNodeWithOperationDistanceSorted() CHECKING child[%d] point=%f,%f center=%f,%f distance=%f...\n", i, point.x, point.y, center.x, center.y, distance); //childNode->printDebugDetails(""); float distance = params.viewFrustum ? childNode->distanceToCamera(*params.viewFrustum) : 0; @@ -1432,7 +1434,7 @@ int VoxelTree::encodeTreeBitstreamRecursion(VoxelNode* node, unsigned char* outp bool VoxelTree::readFromSVOFile(const char* fileName) { std::ifstream file(fileName, std::ios::in|std::ios::binary|std::ios::ate); if(file.is_open()) { - printLog("loading file %s...\n", fileName); + qDebug("loading file %s...\n", fileName); // get file length.... unsigned long fileLength = file.tellg(); @@ -1460,14 +1462,14 @@ bool VoxelTree::readFromSchematicFile(const char *fileName) { std::stringstream ss; int err = retrieveData(fileName, ss); if (err && ss.get() != TAG_Compound) { - printLog("[ERROR] Invalid schematic file.\n"); + qDebug("[ERROR] Invalid schematic file.\n"); return false; } ss.get(); TagCompound schematics(ss); if (!schematics.getBlocksId() || !schematics.getBlocksData()) { - printLog("[ERROR] Invalid schematic file.\n"); + qDebug("[ERROR] Invalid schematic file.\n"); return false; } @@ -1530,7 +1532,7 @@ bool VoxelTree::readFromSchematicFile(const char *fileName) { } } - printLog("Created %d voxels from minecraft import.\n", count); + qDebug("Created %d voxels from minecraft import.\n", count); return true; } @@ -1540,7 +1542,7 @@ void VoxelTree::writeToSVOFile(const char* fileName, VoxelNode* node) const { std::ofstream file(fileName, std::ios::out|std::ios::binary); if(file.is_open()) { - printLog("saving to file %s...\n", fileName); + qDebug("saving to file %s...\n", fileName); VoxelNodeBag nodeBag; // If we were given a specific node, start from there, otherwise start from root diff --git a/pairing-server/CMakeLists.txt b/pairing-server/CMakeLists.txt index 9feb1aa424..5e0adcb378 100644 --- a/pairing-server/CMakeLists.txt +++ b/pairing-server/CMakeLists.txt @@ -6,7 +6,7 @@ set(MACRO_DIR ${ROOT_DIR}/cmake/macros) set(TARGET_NAME pairing-server) include(${MACRO_DIR}/SetupHifiProject.cmake) -setup_hifi_project(${TARGET_NAME}) +setup_hifi_project(${TARGET_NAME} TRUE) # link the shared hifi library include(${MACRO_DIR}/LinkHifiLibrary.cmake) diff --git a/space-server/CMakeLists.txt b/space-server/CMakeLists.txt index 5b34f86a4c..c821992378 100644 --- a/space-server/CMakeLists.txt +++ b/space-server/CMakeLists.txt @@ -7,7 +7,7 @@ set(TARGET_NAME space-server) include(${MACRO_DIR}/SetupHifiProject.cmake) -setup_hifi_project(${TARGET_NAME}) +setup_hifi_project(${TARGET_NAME} TRUE) include(${MACRO_DIR}/LinkHifiLibrary.cmake) link_hifi_library(shared ${TARGET_NAME} ${ROOT_DIR}) \ No newline at end of file diff --git a/voxel-edit/CMakeLists.txt b/voxel-edit/CMakeLists.txt index f7acb26e92..de056cdd86 100644 --- a/voxel-edit/CMakeLists.txt +++ b/voxel-edit/CMakeLists.txt @@ -14,7 +14,7 @@ include_glm(${TARGET_NAME} ${ROOT_DIR}) include(${MACRO_DIR}/SetupHifiProject.cmake) -setup_hifi_project(${TARGET_NAME}) +setup_hifi_project(${TARGET_NAME} FALSE) # link in the shared library include(${MACRO_DIR}/LinkHifiLibrary.cmake) diff --git a/voxel-server/CMakeLists.txt b/voxel-server/CMakeLists.txt index 2bdba8f6e3..c401a8033c 100644 --- a/voxel-server/CMakeLists.txt +++ b/voxel-server/CMakeLists.txt @@ -14,7 +14,7 @@ include_glm(${TARGET_NAME} ${ROOT_DIR}) include(${MACRO_DIR}/SetupHifiProject.cmake) -setup_hifi_project(${TARGET_NAME}) +setup_hifi_project(${TARGET_NAME} TRUE) # link in the shared library include(${MACRO_DIR}/LinkHifiLibrary.cmake) From 89d3cfdb6fe3b3f694ff623d4d08f6d2b7b4dac7 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 16 Jul 2013 11:16:51 -0700 Subject: [PATCH 08/19] remove now extraneous newlines after switch to QDebug --- interface/src/Application.cpp | 26 +++---- interface/src/Audio.cpp | 44 ++++++------ interface/src/AvatarVoxelSystem.cpp | 4 +- interface/src/SerialInterface.cpp | 6 +- interface/src/Transmitter.cpp | 6 +- interface/src/Util.cpp | 14 ++-- interface/src/VoxelSystem.cpp | 46 ++++++------ interface/src/Webcam.cpp | 20 +++--- interface/src/main.cpp | 4 +- interface/src/starfield/Loader.h | 10 +-- libraries/shared/src/NodeList.cpp | 12 ++-- libraries/shared/src/OctalCode.cpp | 4 +- libraries/shared/src/PacketHeaders.cpp | 2 +- libraries/shared/src/PerfStat.cpp | 8 +-- libraries/shared/src/SharedUtil.cpp | 14 ++-- libraries/shared/src/UDPSocket.cpp | 8 +-- libraries/voxels/src/CoverageMap.cpp | 72 +++++++++---------- libraries/voxels/src/CoverageMapV2.cpp | 12 ++-- libraries/voxels/src/ViewFrustum.cpp | 44 ++++++------ libraries/voxels/src/VoxelNode.cpp | 8 +-- .../voxels/src/VoxelProjectedPolygon.cpp | 2 +- libraries/voxels/src/VoxelTree.cpp | 32 ++++----- 22 files changed, 199 insertions(+), 199 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index a85fad9060..a32832318a 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -210,7 +210,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : { _applicationStartupTime = startup_time; _window->setWindowTitle("Interface"); - qDebug("Interface Startup:\n"); + qDebug("Interface Startup:"); unsigned int listenPort = 0; // bind to an ephemeral port by default const char** constArgv = const_cast(argv); @@ -233,7 +233,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : // Handle Local Domain testing with the --local command line if (cmdOptionExists(argc, constArgv, "--local")) { - qDebug("Local Domain MODE!\n"); + qDebug("Local Domain MODE!"); NodeList::getInstance()->setDomainIPToLocalhost(); } @@ -297,7 +297,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : } void Application::initializeGL() { - qDebug( "Created Display Window.\n" ); + qDebug( "Created Display Window." ); // initialize glut for shape drawing; Qt apparently initializes it on OS X #ifndef __APPLE__ @@ -312,10 +312,10 @@ void Application::initializeGL() { _viewFrustumOffsetCamera.setFarClip(500.0 * TREE_SCALE); initDisplay(); - qDebug( "Initialized Display.\n" ); + qDebug( "Initialized Display." ); init(); - qDebug( "Init() complete.\n" ); + qDebug( "Init() complete." ); // Check to see if the user passed in a command line option for randomizing colors bool wantColorRandomizer = !arguments().contains("--NoColorRandomizer"); @@ -324,13 +324,13 @@ void Application::initializeGL() { // Voxel File. If so, load it now. if (!_voxelsFilename.isEmpty()) { _voxels.loadVoxelsFile(_voxelsFilename.constData(), wantColorRandomizer); - qDebug("Local Voxel File loaded.\n"); + qDebug("Local Voxel File loaded."); } // create thread for receipt of data via UDP if (_enableNetworkThread) { pthread_create(&_networkReceiveThread, NULL, networkReceive, NULL); - qDebug("Network receive thread created.\n"); + qDebug("Network receive thread created."); } // call terminate before exiting @@ -351,7 +351,7 @@ void Application::initializeGL() { float startupTime = (usecTimestampNow() - usecTimestamp(&_applicationStartupTime)) / 1000000.0; _justStarted = false; char title[50]; - sprintf(title, "Interface: %4.2f seconds\n", startupTime); + sprintf(title, "Interface: %4.2f seconds", startupTime); qDebug("%s", title); _window->setWindowTitle(title); @@ -1446,7 +1446,7 @@ void Application::importVoxels() { if (fileNameString.endsWith(".png", Qt::CaseInsensitive)) { QImage pngImage = QImage(fileName); if (pngImage.height() != pngImage.width()) { - qDebug("ERROR: Bad PNG size: height != width.\n"); + qDebug("ERROR: Bad PNG size: height != width."); return; } @@ -1758,7 +1758,7 @@ void Application::init() { _audio.setJitterBufferSamples(_audioJitterBufferSamples); } - qDebug("Loaded settings.\n"); + qDebug("Loaded settings."); sendAvatarVoxelURLMessage(_myAvatar.getVoxels()->getVoxelURL()); @@ -2771,7 +2771,7 @@ glm::vec2 Application::getScaledScreenPoint(glm::vec2 projectedPoint) { // render the coverage map on screen void Application::renderCoverageMapV2() { - //qDebug("renderCoverageMap()\n"); + //qDebug("renderCoverageMap()"); glDisable(GL_LIGHTING); glLineWidth(2.0); @@ -2816,7 +2816,7 @@ void Application::renderCoverageMapsV2Recursively(CoverageMapV2* map) { // render the coverage map on screen void Application::renderCoverageMap() { - //qDebug("renderCoverageMap()\n"); + //qDebug("renderCoverageMap()"); glDisable(GL_LIGHTING); glLineWidth(2.0); @@ -3147,7 +3147,7 @@ void Application::eyedropperVoxelUnderCursor() { } void Application::goHome() { - qDebug("Going Home!\n"); + qDebug("Going Home!"); _myAvatar.setPosition(START_LOCATION); } diff --git a/interface/src/Audio.cpp b/interface/src/Audio.cpp index 4c707de938..4bacc274ad 100644 --- a/interface/src/Audio.cpp +++ b/interface/src/Audio.cpp @@ -152,11 +152,11 @@ inline void Audio::performIO(int16_t* inputLeft, int16_t* outputLeft, int16_t* o // If not enough audio has arrived to start playback, keep waiting // #ifdef SHOW_AUDIO_DEBUG - qDebug("%i,%i,%i,%i\n", - _packetsReceivedThisPlayback, - ringBuffer->diffLastWriteNextOutput(), - PACKET_LENGTH_SAMPLES, - _jitterBufferSamples); + qDebug("%i,%i,%i,%i", + _packetsReceivedThisPlayback, + ringBuffer->diffLastWriteNextOutput(), + PACKET_LENGTH_SAMPLES, + _jitterBufferSamples); #endif } else if (ringBuffer->isStarted() && ringBuffer->diffLastWriteNextOutput() == 0) { // @@ -169,7 +169,7 @@ inline void Audio::performIO(int16_t* inputLeft, int16_t* outputLeft, int16_t* o _packetsReceivedThisPlayback = 0; _wasStarved = 10; // Frames for which to render the indication that the system was starved. #ifdef SHOW_AUDIO_DEBUG - qDebug("Starved, remaining samples = %d\n", + qDebug("Starved, remaining samples = %d", ringBuffer->diffLastWriteNextOutput()); #endif @@ -180,10 +180,10 @@ inline void Audio::performIO(int16_t* inputLeft, int16_t* outputLeft, int16_t* o if (!ringBuffer->isStarted()) { ringBuffer->setStarted(true); #ifdef SHOW_AUDIO_DEBUG - qDebug("starting playback %0.1f msecs delayed, jitter = %d, pkts recvd: %d \n", - (usecTimestampNow() - usecTimestamp(&_firstPacketReceivedTime))/1000.0, - _jitterBufferSamples, - _packetsReceivedThisPlayback); + qDebug("starting playback %0.1f msecs delayed, jitter = %d, pkts recvd: %d", + (usecTimestampNow() - usecTimestamp(&_firstPacketReceivedTime))/1000.0, + _jitterBufferSamples, + _packetsReceivedThisPlayback); #endif } @@ -300,8 +300,8 @@ int Audio::audioCallback (const void* inputBuffer, static void outputPortAudioError(PaError error) { if (error != paNoError) { - qDebug("-- portaudio termination error --\n"); - qDebug("PortAudio error (%d): %s\n", error, Pa_GetErrorText(error)); + qDebug("-- portaudio termination error --"); + qDebug("PortAudio error (%d): %s", error, Pa_GetErrorText(error)); } } @@ -350,7 +350,7 @@ Audio::Audio(Oscilloscope* scope, int16_t initialJitterBufferSamples) : outputParameters.device = Pa_GetDefaultOutputDevice(); if (inputParameters.device == -1 || outputParameters.device == -1) { - qDebug("Audio: Missing device.\n"); + qDebug("Audio: Missing device."); outputPortAudioError(Pa_Terminate()); return; } @@ -385,12 +385,12 @@ Audio::Audio(Oscilloscope* scope, int16_t initialJitterBufferSamples) : outputPortAudioError(Pa_StartStream(_stream)); // Uncomment these lines to see the system-reported latency - //qDebug("Default low input, output latency (secs): %0.4f, %0.4f\n", + //qDebug("Default low input, output latency (secs): %0.4f, %0.4f", // Pa_GetDeviceInfo(Pa_GetDefaultInputDevice())->defaultLowInputLatency, // Pa_GetDeviceInfo(Pa_GetDefaultOutputDevice())->defaultLowOutputLatency); const PaStreamInfo* streamInfo = Pa_GetStreamInfo(_stream); - qDebug("Started audio with reported latency msecs In/Out: %.0f, %.0f\n", streamInfo->inputLatency * 1000.f, + qDebug("Started audio with reported latency msecs In/Out: %.0f, %.0f", streamInfo->inputLatency * 1000.f, streamInfo->outputLatency * 1000.f); gettimeofday(&_lastReceiveTime, NULL); @@ -651,7 +651,7 @@ inline void Audio::eventuallySendRecvPing(int16_t* inputLeft, int16_t* outputLef // As of the next frame, we'll be recoding PING_FRAMES_TO_RECORD from // the mic (pointless to start now as we can't record unsent audio). _isSendingEchoPing = false; - qDebug("Send audio ping\n"); + qDebug("Send audio ping"); } else if (_pingFramesToRecord > 0) { @@ -665,7 +665,7 @@ inline void Audio::eventuallySendRecvPing(int16_t* inputLeft, int16_t* outputLef if (_pingFramesToRecord == 0) { _pingAnalysisPending = true; - qDebug("Received ping echo\n"); + qDebug("Received ping echo"); } } } @@ -689,25 +689,25 @@ inline void Audio::analyzePing() { // Determine extrema int botAt = findExtremum(_echoSamplesLeft, PING_SAMPLES_TO_ANALYZE, -1); if (botAt == -1) { - qDebug("Audio Ping: Minimum not found.\n"); + qDebug("Audio Ping: Minimum not found."); return; } int topAt = findExtremum(_echoSamplesLeft, PING_SAMPLES_TO_ANALYZE, 1); if (topAt == -1) { - qDebug("Audio Ping: Maximum not found.\n"); + qDebug("Audio Ping: Maximum not found."); return; } // Determine peak amplitude - warn if low int ampli = (_echoSamplesLeft[topAt] - _echoSamplesLeft[botAt]) / 2; if (ampli < PING_MIN_AMPLI) { - qDebug("Audio Ping unreliable - low amplitude %d.\n", ampli); + qDebug("Audio Ping unreliable - low amplitude %d.", ampli); } // Determine period - warn if doesn't look like our signal int halfPeriod = abs(topAt - botAt); if (abs(halfPeriod-PING_HALF_PERIOD) > PING_MAX_PERIOD_DIFFERENCE) { - qDebug("Audio Ping unreliable - peak distance %d vs. %d\n", halfPeriod, PING_HALF_PERIOD); + qDebug("Audio Ping unreliable - peak distance %d vs. %d", halfPeriod, PING_HALF_PERIOD); } // Ping is sent: @@ -748,7 +748,7 @@ inline void Audio::analyzePing() { int delay = (botAt + topAt) / 2 + PING_PERIOD; - qDebug("\n| Audio Ping results:\n+----- ---- --- - - - - -\n\n" + qDebug("\n| Audio Ping results:\n+----- ---- --- - - - - -\n" "Delay = %d samples (%d ms)\nPeak amplitude = %d\n\n", delay, (delay * 1000) / int(SAMPLE_RATE), ampli); } diff --git a/interface/src/AvatarVoxelSystem.cpp b/interface/src/AvatarVoxelSystem.cpp index c85ea1a343..a341ecaa38 100644 --- a/interface/src/AvatarVoxelSystem.cpp +++ b/interface/src/AvatarVoxelSystem.cpp @@ -93,7 +93,7 @@ const Mode MODES[] = { void AvatarVoxelSystem::cycleMode() { _mode = (_mode + 1) % (sizeof(MODES) / sizeof(MODES[0])); - qDebug("Voxeltar bind mode %d.\n", _mode); + qDebug("Voxeltar bind mode %d.", _mode); // rebind QUrl url = _voxelURL; @@ -255,7 +255,7 @@ void AvatarVoxelSystem::handleVoxelDownloadProgress(qint64 bytesReceived, qint64 } void AvatarVoxelSystem::handleVoxelReplyError() { - qDebug("%s\n", _voxelReply->errorString().toAscii().constData()); + qDebug("%s", _voxelReply->errorString().toAscii().constData()); _voxelReply->disconnect(this); _voxelReply->deleteLater(); diff --git a/interface/src/SerialInterface.cpp b/interface/src/SerialInterface.cpp index 0f90ee8dd7..e17feb48d7 100644 --- a/interface/src/SerialInterface.cpp +++ b/interface/src/SerialInterface.cpp @@ -100,7 +100,7 @@ void SerialInterface::initializePort(char* portname) { qDebug("Opening SerialUSB %s: ", portname); if (_serialDescriptor == -1) { - qDebug("Failed.\n"); + qDebug("Failed."); return; } @@ -134,7 +134,7 @@ void SerialInterface::initializePort(char* portname) { mpu_set_sensors(INV_XYZ_GYRO | INV_XYZ_ACCEL | INV_XYZ_COMPASS); } - qDebug("Connected.\n"); + qDebug("Connected."); resetSerial(); _active = true; @@ -373,7 +373,7 @@ void SerialInterface::readData(float deltaTime) { gettimeofday(&now, NULL); if (diffclock(&lastGoodRead, &now) > NO_READ_MAXIMUM_MSECS) { - qDebug("No data - Shutting down SerialInterface.\n"); + qDebug("No data - Shutting down SerialInterface."); resetSerial(); } } else { diff --git a/interface/src/Transmitter.cpp b/interface/src/Transmitter.cpp index eac769ead7..ce0180e501 100644 --- a/interface/src/Transmitter.cpp +++ b/interface/src/Transmitter.cpp @@ -38,7 +38,7 @@ void Transmitter::checkForLostTransmitter() { int msecsSinceLast = diffclock(_lastReceivedPacket, &now); if (msecsSinceLast > TIME_TO_ASSUME_LOST_MSECS) { resetLevels(); - qDebug("Transmitter signal lost.\n"); + qDebug("Transmitter signal lost."); } } } @@ -93,12 +93,12 @@ void Transmitter::processIncomingData(unsigned char* packetData, int numBytes) { _estimatedRotation.y *= (1.f - DECAY_RATE * DELTA_TIME); if (!_isConnected) { - qDebug("Transmitter Connected.\n"); + qDebug("Transmitter Connected."); _isConnected = true; _estimatedRotation *= 0.0; } } else { - qDebug("Transmitter packet read error, %d bytes.\n", numBytes); + qDebug("Transmitter packet read error, %d bytes.", numBytes); } } diff --git a/interface/src/Util.cpp b/interface/src/Util.cpp index 20f33f924a..7bc4e50d96 100644 --- a/interface/src/Util.cpp +++ b/interface/src/Util.cpp @@ -451,7 +451,7 @@ void renderOrientationDirections(glm::vec3 position, const glm::quat& orientatio bool closeEnoughForGovernmentWork(float a, float b) { float distance = std::abs(a-b); - //qDebug("closeEnoughForGovernmentWork() a=%1.10f b=%1.10f distance=%1.10f\n",a,b,distance); + //qDebug("closeEnoughForGovernmentWork() a=%1.10f b=%1.10f distance=%1.10f",a,b,distance); return (distance < 0.00001f); } @@ -469,7 +469,7 @@ void runTimingTests() { gettimeofday(&endTime, NULL); } elapsedMsecs = diffclock(&startTime, &endTime); - qDebug("gettimeofday() usecs: %f\n", 1000.0f * elapsedMsecs / (float) numTests); + qDebug("gettimeofday() usecs: %f", 1000.0f * elapsedMsecs / (float) numTests); // Random number generation gettimeofday(&startTime, NULL); @@ -478,7 +478,7 @@ void runTimingTests() { } gettimeofday(&endTime, NULL); elapsedMsecs = diffclock(&startTime, &endTime); - qDebug("rand() stored in array usecs: %f\n", 1000.0f * elapsedMsecs / (float) numTests); + qDebug("rand() stored in array usecs: %f", 1000.0f * elapsedMsecs / (float) numTests); // Random number generation using randFloat() gettimeofday(&startTime, NULL); @@ -487,7 +487,7 @@ void runTimingTests() { } gettimeofday(&endTime, NULL); elapsedMsecs = diffclock(&startTime, &endTime); - qDebug("randFloat() stored in array usecs: %f\n", 1000.0f * elapsedMsecs / (float) numTests); + qDebug("randFloat() stored in array usecs: %f", 1000.0f * elapsedMsecs / (float) numTests); // PowF function fTest = 1145323.2342f; @@ -497,7 +497,7 @@ void runTimingTests() { } gettimeofday(&endTime, NULL); elapsedMsecs = diffclock(&startTime, &endTime); - qDebug("powf(f, 0.5) usecs: %f\n", 1000.0f * elapsedMsecs / (float) numTests); + qDebug("powf(f, 0.5) usecs: %f", 1000.0f * elapsedMsecs / (float) numTests); // Vector Math float distance; @@ -510,7 +510,7 @@ void runTimingTests() { } gettimeofday(&endTime, NULL); elapsedMsecs = diffclock(&startTime, &endTime); - qDebug("vector math usecs: %f [%f msecs total for %d tests]\n", + qDebug("vector math usecs: %f [%f msecs total for %d tests]", 1000.0f * elapsedMsecs / (float) numTests, elapsedMsecs, numTests); // Vec3 test @@ -524,7 +524,7 @@ void runTimingTests() { } gettimeofday(&endTime, NULL); elapsedMsecs = diffclock(&startTime, &endTime); - qDebug("vec3 assign and dot() usecs: %f\n", 1000.0f * elapsedMsecs / (float) numTests); + qDebug("vec3 assign and dot() usecs: %f", 1000.0f * elapsedMsecs / (float) numTests); } diff --git a/interface/src/VoxelSystem.cpp b/interface/src/VoxelSystem.cpp index f219e38dc6..0b4777a12f 100644 --- a/interface/src/VoxelSystem.cpp +++ b/interface/src/VoxelSystem.cpp @@ -144,16 +144,16 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) { int commandLength = strlen(command); // commands are null terminated strings int totalLength = 1+commandLength+1; - qDebug("got Z message len(%d)= %s\n", numBytes, command); + qDebug("got Z message len(%d)= %s", numBytes, command); while (totalLength <= numBytes) { if (0==strcmp(command,(char*)"erase all")) { - qDebug("got Z message == erase all\n"); + qDebug("got Z message == erase all"); _tree->eraseAllVoxels(); _voxelsInReadArrays = _voxelsInWriteArrays = 0; // better way to do this?? } if (0==strcmp(command,(char*)"add scene")) { - qDebug("got Z message == add scene - NOT SUPPORTED ON INTERFACE\n"); + qDebug("got Z message == add scene - NOT SUPPORTED ON INTERFACE"); } totalLength += commandLength+1; } @@ -708,7 +708,7 @@ bool VoxelSystem::randomColorOperation(VoxelNode* node, void* extraData) { void VoxelSystem::randomizeVoxelColors() { _nodeCount = 0; _tree->recurseTreeWithOperation(randomColorOperation); - qDebug("setting randomized true color for %d nodes\n", _nodeCount); + qDebug("setting randomized true color for %d nodes", _nodeCount); setupNewVoxelsForDrawing(); } @@ -722,7 +722,7 @@ bool VoxelSystem::falseColorizeRandomOperation(VoxelNode* node, void* extraData) void VoxelSystem::falseColorizeRandom() { _nodeCount = 0; _tree->recurseTreeWithOperation(falseColorizeRandomOperation); - qDebug("setting randomized false color for %d nodes\n", _nodeCount); + qDebug("setting randomized false color for %d nodes", _nodeCount); setupNewVoxelsForDrawing(); } @@ -736,7 +736,7 @@ void VoxelSystem::trueColorize() { PerformanceWarning warn(true, "trueColorize()",true); _nodeCount = 0; _tree->recurseTreeWithOperation(trueColorizeOperation); - qDebug("setting true color for %d nodes\n", _nodeCount); + qDebug("setting true color for %d nodes", _nodeCount); setupNewVoxelsForDrawing(); } @@ -756,7 +756,7 @@ bool VoxelSystem::falseColorizeInViewOperation(VoxelNode* node, void* extraData) void VoxelSystem::falseColorizeInView(ViewFrustum* viewFrustum) { _nodeCount = 0; _tree->recurseTreeWithOperation(falseColorizeInViewOperation,(void*)viewFrustum); - qDebug("setting in view false color for %d nodes\n", _nodeCount); + qDebug("setting in view false color for %d nodes", _nodeCount); setupNewVoxelsForDrawing(); } @@ -806,10 +806,10 @@ void VoxelSystem::falseColorizeDistanceFromView(ViewFrustum* viewFrustum) { _maxDistance = 0.0; _minDistance = FLT_MAX; _tree->recurseTreeWithOperation(getDistanceFromViewRangeOperation,(void*)viewFrustum); - qDebug("determining distance range for %d nodes\n", _nodeCount); + qDebug("determining distance range for %d nodes", _nodeCount); _nodeCount = 0; _tree->recurseTreeWithOperation(falseColorizeDistanceFromViewOperation,(void*)viewFrustum); - qDebug("setting in distance false color for %d nodes\n", _nodeCount); + qDebug("setting in distance false color for %d nodes", _nodeCount); setupNewVoxelsForDrawing(); } @@ -921,7 +921,7 @@ void VoxelSystem::removeOutOfView() { } bool showRemoveDebugDetails = false; if (showRemoveDebugDetails) { - qDebug("removeOutOfView() scanned=%ld removed=%ld inside=%ld intersect=%ld outside=%ld _removedVoxels.count()=%d \n", + qDebug("removeOutOfView() scanned=%ld removed=%ld inside=%ld intersect=%ld outside=%ld _removedVoxels.count()=%d ", args.nodesScanned, args.nodesRemoved, args.nodesInside, args.nodesIntersect, args.nodesOutside, _removedVoxels.count() ); @@ -987,7 +987,7 @@ bool VoxelSystem::falseColorizeRandomEveryOtherOperation(VoxelNode* node, void* void VoxelSystem::falseColorizeRandomEveryOther() { falseColorizeRandomEveryOtherArgs args; _tree->recurseTreeWithOperation(falseColorizeRandomEveryOtherOperation,&args); - qDebug("randomized false color for every other node: total %ld, colorable %ld, colored %ld\n", + qDebug("randomized false color for every other node: total %ld, colorable %ld, colored %ld", args.totalNodes, args.colorableNodes, args.coloredNodes); setupNewVoxelsForDrawing(); } @@ -1048,7 +1048,7 @@ bool VoxelSystem::collectStatsForTreesAndVBOsOperation(VoxelNode* node, void* ex unsigned long nodeIndex = node->getBufferIndex(); if (args->hasIndexFound[nodeIndex]) { args->duplicateVBOIndex++; - qDebug("duplicateVBO found... index=%ld, isDirty=%s, shouldRender=%s \n", nodeIndex, + qDebug("duplicateVBO found... index=%ld, isDirty=%s, shouldRender=%s ", nodeIndex, debug::valueOf(node->isDirty()), debug::valueOf(node->getShouldRender())); } else { args->hasIndexFound[nodeIndex] = true; @@ -1083,13 +1083,13 @@ void VoxelSystem::collectStatsForTreesAndVBOs() { args.expectedMax = _voxelsInWriteArrays; _tree->recurseTreeWithOperation(collectStatsForTreesAndVBOsOperation,&args); - qDebug("Local Voxel Tree Statistics:\n total nodes %ld \n leaves %ld \n dirty %ld \n colored %ld \n shouldRender %ld \n", + qDebug("Local Voxel Tree Statistics:\n total nodes %ld \n leaves %ld \n dirty %ld \n colored %ld \n shouldRender %ld ", args.totalNodes, args.leafNodes, args.dirtyNodes, args.coloredNodes, args.shouldRenderNodes); - qDebug(" _voxelsDirty=%s \n _voxelsInWriteArrays=%ld \n minDirty=%ld \n maxDirty=%ld \n", debug::valueOf(_voxelsDirty), + qDebug(" _voxelsDirty=%s \n _voxelsInWriteArrays=%ld \n minDirty=%ld \n maxDirty=%ld ", debug::valueOf(_voxelsDirty), _voxelsInWriteArrays, minDirty, maxDirty); - qDebug(" inVBO %ld \n nodesInVBOOverExpectedMax %ld \n duplicateVBOIndex %ld \n nodesInVBONotShouldRender %ld \n", + qDebug(" inVBO %ld \n nodesInVBOOverExpectedMax %ld \n duplicateVBOIndex %ld \n nodesInVBONotShouldRender %ld ", args.nodesInVBO, args.nodesInVBOOverExpectedMax, args.duplicateVBOIndex, args.nodesInVBONotShouldRender); glBufferIndex minInVBO = GLBUFFER_INDEX_UNKNOWN; @@ -1102,7 +1102,7 @@ void VoxelSystem::collectStatsForTreesAndVBOs() { } } - qDebug(" minInVBO=%ld \n maxInVBO=%ld \n _voxelsInWriteArrays=%ld \n _voxelsInReadArrays=%ld \n", + qDebug(" minInVBO=%ld \n maxInVBO=%ld \n _voxelsInWriteArrays=%ld \n _voxelsInReadArrays=%ld ", minInVBO, maxInVBO, _voxelsInWriteArrays, _voxelsInReadArrays); } @@ -1127,7 +1127,7 @@ void VoxelSystem::createVoxel(float x, float y, float z, float s, unsigned char red, unsigned char green, unsigned char blue, bool destructive) { pthread_mutex_lock(&_treeLock); - //qDebug("VoxelSystem::createVoxel(%f,%f,%f,%f)\n",x,y,z,s); + //qDebug("VoxelSystem::createVoxel(%f,%f,%f,%f)",x,y,z,s); _tree->createVoxel(x, y, z, s, red, green, blue, destructive); setupNewVoxelsForDrawing(); @@ -1253,9 +1253,9 @@ bool VoxelSystem::falseColorizeOccludedOperation(VoxelNode* node, void* extraDat args->occludedVoxels++; } else if (result == STORED) { args->notOccludedVoxels++; - //qDebug("***** falseColorizeOccludedOperation() NODE is STORED *****\n"); + //qDebug("***** falseColorizeOccludedOperation() NODE is STORED *****"); } else if (result == DOESNT_FIT) { - //qDebug("***** falseColorizeOccludedOperation() NODE DOESNT_FIT???? *****\n"); + //qDebug("***** falseColorizeOccludedOperation() NODE DOESNT_FIT???? *****"); } } return true; // keep going! @@ -1288,7 +1288,7 @@ void VoxelSystem::falseColorizeOccluded() { _tree->recurseTreeWithOperationDistanceSorted(falseColorizeOccludedOperation, position, (void*)&args); - qDebug("falseColorizeOccluded()\n position=(%f,%f)\n total=%ld\n colored=%ld\n occluded=%ld\n notOccluded=%ld\n outOfView=%ld\n subtreeVoxelsSkipped=%ld\n stagedForDeletion=%ld\n nonLeaves=%ld\n nonLeavesOutOfView=%ld\n nonLeavesOccluded=%ld\n pointInside_calls=%ld\n occludes_calls=%ld\n intersects_calls=%ld\n", + qDebug("falseColorizeOccluded()\n position=(%f,%f)\n total=%ld\n colored=%ld\n occluded=%ld\n notOccluded=%ld\n outOfView=%ld\n subtreeVoxelsSkipped=%ld\n stagedForDeletion=%ld\n nonLeaves=%ld\n nonLeavesOutOfView=%ld\n nonLeavesOccluded=%ld\n pointInside_calls=%ld\n occludes_calls=%ld\n intersects_calls=%ld", position.x, position.y, args.totalVoxels, args.coloredVoxels, args.occludedVoxels, args.notOccludedVoxels, args.outOfView, args.subtreeVoxelsSkipped, @@ -1374,9 +1374,9 @@ bool VoxelSystem::falseColorizeOccludedV2Operation(VoxelNode* node, void* extraD args->occludedVoxels++; } else if (result == V2_STORED) { args->notOccludedVoxels++; - //qDebug("***** falseColorizeOccludedOperation() NODE is STORED *****\n"); + //qDebug("***** falseColorizeOccludedOperation() NODE is STORED *****"); } else if (result == V2_DOESNT_FIT) { - //qDebug("***** falseColorizeOccludedOperation() NODE DOESNT_FIT???? *****\n"); + //qDebug("***** falseColorizeOccludedOperation() NODE DOESNT_FIT???? *****"); } delete voxelPolygon; // V2 maps don't store polygons, so we're always in charge of freeing } @@ -1413,7 +1413,7 @@ void VoxelSystem::falseColorizeOccludedV2() { _tree->recurseTreeWithOperationDistanceSorted(falseColorizeOccludedV2Operation, position, (void*)&args); - qDebug("falseColorizeOccludedV2()\n position=(%f,%f)\n total=%ld\n colored=%ld\n occluded=%ld\n notOccluded=%ld\n outOfView=%ld\n subtreeVoxelsSkipped=%ld\n stagedForDeletion=%ld\n nonLeaves=%ld\n nonLeavesOutOfView=%ld\n nonLeavesOccluded=%ld\n pointInside_calls=%ld\n occludes_calls=%ld\n intersects_calls=%ld\n", + qDebug("falseColorizeOccludedV2()\n position=(%f,%f)\n total=%ld\n colored=%ld\n occluded=%ld\n notOccluded=%ld\n outOfView=%ld\n subtreeVoxelsSkipped=%ld\n stagedForDeletion=%ld\n nonLeaves=%ld\n nonLeavesOutOfView=%ld\n nonLeavesOccluded=%ld\n pointInside_calls=%ld\n occludes_calls=%ld\n intersects_calls=%ld", position.x, position.y, args.totalVoxels, args.coloredVoxels, args.occludedVoxels, args.notOccludedVoxels, args.outOfView, args.subtreeVoxelsSkipped, diff --git a/interface/src/Webcam.cpp b/interface/src/Webcam.cpp index f9dd5ffe2c..3831f39893 100644 --- a/interface/src/Webcam.cpp +++ b/interface/src/Webcam.cpp @@ -156,7 +156,7 @@ void Webcam::setFrame(const Mat& frame, int format, const Mat& depth, const Rota glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, _frameWidth = image.width, _frameHeight = image.height, 0, format, GL_UNSIGNED_BYTE, image.imageData); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - qDebug("Capturing video at %dx%d.\n", _frameWidth, _frameHeight); + qDebug("Capturing video at %dx%d.", _frameWidth, _frameHeight); } else { glBindTexture(GL_TEXTURE_2D, _frameTextureID); @@ -172,7 +172,7 @@ void Webcam::setFrame(const Mat& frame, int format, const Mat& depth, const Rota glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, _depthWidth = depthImage.width, _depthHeight = depthImage.height, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, depthImage.imageData); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - qDebug("Capturing depth at %dx%d.\n", _depthWidth, _depthHeight); + qDebug("Capturing depth at %dx%d.", _depthWidth, _depthHeight); } else { glBindTexture(GL_TEXTURE_2D, _depthTextureID); @@ -330,26 +330,26 @@ static glm::quat xnToGLM(const XnMatrix3X3& matrix) { } static void XN_CALLBACK_TYPE newUser(UserGenerator& generator, XnUserID id, void* cookie) { - qDebug("Found user %d.\n", id); + qDebug("Found user %d.", id); generator.GetSkeletonCap().RequestCalibration(id, false); } static void XN_CALLBACK_TYPE lostUser(UserGenerator& generator, XnUserID id, void* cookie) { - qDebug("Lost user %d.\n", id); + qDebug("Lost user %d.", id); } static void XN_CALLBACK_TYPE calibrationStarted(SkeletonCapability& capability, XnUserID id, void* cookie) { - qDebug("Calibration started for user %d.\n", id); + qDebug("Calibration started for user %d.", id); } static void XN_CALLBACK_TYPE calibrationCompleted(SkeletonCapability& capability, XnUserID id, XnCalibrationStatus status, void* cookie) { if (status == XN_CALIBRATION_STATUS_OK) { - qDebug("Calibration completed for user %d.\n", id); + qDebug("Calibration completed for user %d.", id); capability.StartTracking(id); } else { - qDebug("Calibration failed to user %d.\n", id); + qDebug("Calibration failed to user %d.", id); capability.RequestCalibration(id, true); } } @@ -438,7 +438,7 @@ void FrameGrabber::grabFrame() { // make sure it's in the format we expect if (image->nChannels != 3 || image->depth != IPL_DEPTH_8U || image->dataOrder != IPL_DATA_ORDER_PIXEL || image->origin != 0) { - qDebug("Invalid webcam image format.\n"); + qDebug("Invalid webcam image format."); return; } frame = image; @@ -485,7 +485,7 @@ bool FrameGrabber::init() { // load our face cascade switchToResourcesParentIfRequired(); if (_faceCascade.empty() && !_faceCascade.load("resources/haarcascades/haarcascade_frontalface_alt.xml")) { - qDebug("Failed to load Haar cascade for face tracking.\n"); + qDebug("Failed to load Haar cascade for face tracking."); return false; } @@ -513,7 +513,7 @@ bool FrameGrabber::init() { // next, an ordinary webcam if ((_capture = cvCaptureFromCAM(-1)) == 0) { - qDebug("Failed to open webcam.\n"); + qDebug("Failed to open webcam."); return false; } const int IDEAL_FRAME_WIDTH = 320; diff --git a/interface/src/main.cpp b/interface/src/main.cpp index 98ed4fb231..7bcef42e88 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -24,8 +24,8 @@ int main(int argc, const char * argv[]) { gettimeofday(&startup_time, NULL); Application app(argc, const_cast(argv), startup_time); - qDebug( "Created QT Application.\n" ); + qDebug( "Created QT Application." ); int exitCode = app.exec(); - qDebug("Normal exit.\n"); + qDebug("Normal exit."); return exitCode; } diff --git a/interface/src/starfield/Loader.h b/interface/src/starfield/Loader.h index e2f6105f33..8aa1527ad5 100644 --- a/interface/src/starfield/Loader.h +++ b/interface/src/starfield/Loader.h @@ -38,12 +38,12 @@ namespace starfield { if (! UrlReader::readUrl(url, *this, cacheFile)) { - qDebug("%s:%d: %s\n", + qDebug("%s:%d: %s", _urlStr, _lineNo, getError()); return false; } - qDebug("Loaded %u stars.\n", _recordsRead); + qDebug("Loaded %u stars.", _recordsRead); return true; } @@ -63,7 +63,7 @@ namespace starfield { _vertices->clear(); _vertices->reserve(_limit); -// qDebug("Stars.cpp: loader begin %s\n", url); +// qDebug("Stars.cpp: loader begin %s", url); } size_t transfer(char* input, size_t bytes) { @@ -103,7 +103,7 @@ namespace starfield { } else { - qDebug("Stars.cpp:%d: Bad input from %s\n", + qDebug("Stars.cpp:%d: Bad input from %s", _lineNo, _urlStr); } @@ -128,7 +128,7 @@ namespace starfield { // remember the brightness at its top if (_recordsRead == _limit) { -// qDebug("Stars.cpp: vertex limit reached -> heap mode\n"); +// qDebug("Stars.cpp: vertex limit reached -> heap mode"); make_heap( _vertices->begin(), _vertices->end(), diff --git a/libraries/shared/src/NodeList.cpp b/libraries/shared/src/NodeList.cpp index 6ba71613de..0781d8ed1b 100644 --- a/libraries/shared/src/NodeList.cpp +++ b/libraries/shared/src/NodeList.cpp @@ -43,7 +43,7 @@ NodeList* NodeList::createInstance(char ownerType, unsigned int socketListenPort if (!_sharedInstance) { _sharedInstance = new NodeList(ownerType, socketListenPort); } else { - qDebug("NodeList createInstance called with existing instance.\n"); + qDebug("NodeList createInstance called with existing instance."); } return _sharedInstance; @@ -51,7 +51,7 @@ NodeList* NodeList::createInstance(char ownerType, unsigned int socketListenPort NodeList* NodeList::getInstance() { if (!_sharedInstance) { - qDebug("NodeList getInstance called before call to createInstance. Returning NULL pointer.\n"); + qDebug("NodeList getInstance called before call to createInstance. Returning NULL pointer."); } return _sharedInstance; @@ -275,12 +275,12 @@ void NodeList::sendDomainServerCheckIn() { sockaddr_in tempAddress; memcpy(&tempAddress.sin_addr, pHostInfo->h_addr_list[0], pHostInfo->h_length); strcpy(_domainIP, inet_ntoa(tempAddress.sin_addr)); - qDebug("Domain Server: %s \n", _domainHostname); + qDebug("Domain Server: %s ", _domainHostname); } else { - qDebug("Failed domain server lookup\n"); + qDebug("Failed domain server lookup"); } } else if (!printedDomainServerIP) { - qDebug("Domain Server IP: %s\n", _domainIP); + qDebug("Domain Server IP: %s", _domainIP); printedDomainServerIP = true; } @@ -419,7 +419,7 @@ void NodeList::addNodeToList(Node* newNode) { ++_numNodes; - qDebug() << "Added " << *newNode; + qDebug() << "Added" << *newNode; } unsigned NodeList::broadcastToNodes(unsigned char *broadcastData, size_t dataBytes, const char* nodeTypes, int numNodeTypes) { diff --git a/libraries/shared/src/OctalCode.cpp b/libraries/shared/src/OctalCode.cpp index 3b92869104..336c89093e 100644 --- a/libraries/shared/src/OctalCode.cpp +++ b/libraries/shared/src/OctalCode.cpp @@ -25,12 +25,12 @@ int numberOfThreeBitSectionsInCode(unsigned char * octalCode) { void printOctalCode(unsigned char * octalCode) { if (!octalCode) { - qDebug("NULL\n"); + qDebug("NULL"); } else { for (int i = 0; i < bytesRequiredForCodeLength(*octalCode); i++) { outputBits(octalCode[i],false); } - qDebug("\n"); + qDebug(""); } } diff --git a/libraries/shared/src/PacketHeaders.cpp b/libraries/shared/src/PacketHeaders.cpp index 7b4a0509f3..a91fd1f351 100644 --- a/libraries/shared/src/PacketHeaders.cpp +++ b/libraries/shared/src/PacketHeaders.cpp @@ -29,7 +29,7 @@ bool packetVersionMatch(unsigned char* packetHeader) { if (packetHeader[1] == versionForPacketType(packetHeader[0])) { return true; } else { - qDebug("There is a packet version mismatch for packet with header %c\n", packetHeader[0]); + qDebug("There is a packet version mismatch for packet with header %c", packetHeader[0]); return false; } } diff --git a/libraries/shared/src/PerfStat.cpp b/libraries/shared/src/PerfStat.cpp index 86985eb038..344e9885e6 100644 --- a/libraries/shared/src/PerfStat.cpp +++ b/libraries/shared/src/PerfStat.cpp @@ -59,7 +59,7 @@ PerfStat::~PerfStat() { } if (wantDebugOut) { - qDebug("PerfStats: %s elapsed:%f average:%lf count:%ld total:%lf ut:%d us:%d ue:%d t:%ld s:%ld e:%ld\n", + qDebug("PerfStats: %s elapsed:%f average:%lf count:%ld total:%lf ut:%d us:%d ue:%d t:%ld s:%ld e:%ld", this->group.c_str(),elapsed,average,count,totalTime, (end.tv_usec-start.tv_usec),start.tv_usec,end.tv_usec, (end.tv_sec-start.tv_sec),start.tv_sec,end.tv_sec @@ -111,12 +111,12 @@ PerformanceWarning::~PerformanceWarning() { if ((_alwaysDisplay || _renderWarningsOn) && elapsedmsec > 1) { if (elapsedmsec > 1000) { double elapsedsec = (end - _start) / 1000000.0; - qDebug("%s%s took %lf seconds\n", (_alwaysDisplay ? "" : "WARNING!"), _message, elapsedsec); + qDebug("%s%s took %lf seconds", (_alwaysDisplay ? "" : "WARNING!"), _message, elapsedsec); } else { - qDebug("%s%s took %lf milliseconds\n", (_alwaysDisplay ? "" : "WARNING!"), _message, elapsedmsec); + qDebug("%s%s took %lf milliseconds", (_alwaysDisplay ? "" : "WARNING!"), _message, elapsedmsec); } } else if (_alwaysDisplay) { - qDebug("%s took %lf milliseconds\n", _message, elapsedmsec); + qDebug("%s took %lf milliseconds", _message, elapsedmsec); } }; diff --git a/libraries/shared/src/SharedUtil.cpp b/libraries/shared/src/SharedUtil.cpp index 23b889bdab..fdcf142d4d 100644 --- a/libraries/shared/src/SharedUtil.cpp +++ b/libraries/shared/src/SharedUtil.cpp @@ -65,7 +65,7 @@ void outputBufferBits(unsigned char* buffer, int length, bool withNewLine) { outputBits(buffer[i], false); } if (withNewLine) { - qDebug("\n"); + qDebug(""); } } @@ -82,7 +82,7 @@ void outputBits(unsigned char byte, bool withNewLine) { qDebug(" ] "); if (withNewLine) { - qDebug("\n"); + qDebug(""); } } @@ -386,11 +386,11 @@ void printVoxelCode(unsigned char* voxelCode) { unsigned int voxelSizeInOctets = (voxelSizeInBits/3); unsigned int voxelBufferSize = voxelSizeInBytes+1+3; // 1 for size, 3 for color - qDebug("octets=%d\n",octets); - qDebug("voxelSizeInBits=%d\n",voxelSizeInBits); - qDebug("voxelSizeInBytes=%d\n",voxelSizeInBytes); - qDebug("voxelSizeInOctets=%d\n",voxelSizeInOctets); - qDebug("voxelBufferSize=%d\n",voxelBufferSize); + qDebug("octets=%d",octets); + qDebug("voxelSizeInBits=%d",voxelSizeInBits); + qDebug("voxelSizeInBytes=%d",voxelSizeInBytes); + qDebug("voxelSizeInOctets=%d",voxelSizeInOctets); + qDebug("voxelBufferSize=%d",voxelBufferSize); for(int i=0;iprintDebugDetails(); } @@ -196,7 +196,7 @@ CoverageMapStorageResult CoverageMap::checkMap(VoxelProjectedPolygon* polygon, b // not in view, then we just discard it with a DOESNT_FIT, this saves us time checking values later. if (!polygon->getAllInView()) { _notAllInView++; - //qDebug("CoverageMap2::checkMap()... V2_OCCLUDED\n"); + //qDebug("CoverageMap2::checkMap()... V2_OCCLUDED"); return DOESNT_FIT; } @@ -243,9 +243,9 @@ CoverageMapStorageResult CoverageMap::checkMap(VoxelProjectedPolygon* polygon, b /* if (result == STORED) - qDebug("CoverageMap2::checkMap()... STORED\n"); + qDebug("CoverageMap2::checkMap()... STORED"); else - qDebug("CoverageMap2::checkMap()... OCCLUDED\n"); + qDebug("CoverageMap2::checkMap()... OCCLUDED"); */ return result; @@ -268,16 +268,16 @@ CoverageMapStorageResult CoverageMap::checkMap(VoxelProjectedPolygon* polygon, b /* switch (result) { case STORED: - qDebug("checkMap() = STORED\n"); + qDebug("checkMap() = STORED"); break; case NOT_STORED: - qDebug("checkMap() = NOT_STORED\n"); + qDebug("checkMap() = NOT_STORED"); break; case OCCLUDED: - qDebug("checkMap() = OCCLUDED\n"); + qDebug("checkMap() = OCCLUDED"); break; default: - qDebug("checkMap() = ????? \n"); + qDebug("checkMap() = ????? "); break; } */ @@ -290,27 +290,27 @@ CoverageMapStorageResult CoverageMap::checkMap(VoxelProjectedPolygon* polygon, b // any of our child bounding boxes, so we should add it here. if (storeIt) { if (polygon->getBoundingBox().area() > CoverageMap::MINIMUM_POLYGON_AREA_TO_STORE) { - //qDebug("storing polygon of area: %f\n",polygon->getBoundingBox().area()); + //qDebug("storing polygon of area: %f",polygon->getBoundingBox().area()); if (storeIn->getPolygonCount() < MAX_POLYGONS_PER_REGION) { storeIn->storeInArray(polygon); - //qDebug("CoverageMap2::checkMap()... STORED\n"); + //qDebug("CoverageMap2::checkMap()... STORED"); return STORED; } else { CoverageRegion::_regionFullSkips++; - //qDebug("CoverageMap2::checkMap()... NOT_STORED\n"); + //qDebug("CoverageMap2::checkMap()... NOT_STORED"); return NOT_STORED; } } else { CoverageRegion::_tooSmallSkips++; - //qDebug("CoverageMap2::checkMap()... NOT_STORED\n"); + //qDebug("CoverageMap2::checkMap()... NOT_STORED"); return NOT_STORED; } } else { - //qDebug("CoverageMap2::checkMap()... NOT_STORED\n"); + //qDebug("CoverageMap2::checkMap()... NOT_STORED"); return NOT_STORED; } } - //qDebug("CoverageMap2::checkMap()... DOESNT_FIT\n"); + //qDebug("CoverageMap2::checkMap()... DOESNT_FIT"); return DOESNT_FIT; } @@ -341,8 +341,8 @@ void CoverageRegion::erase() { /** if (_polygonCount) { - qDebug("CoverageRegion::erase()...\n"); - qDebug("_polygonCount=%d\n",_polygonCount); + qDebug("CoverageRegion::erase()..."); + qDebug("_polygonCount=%d",_polygonCount); _myBoundingBox.printDebugDetails(getRegionName()); //for (int i = 0; i < _polygonCount; i++) { // qDebug("_polygons[%d]=",i); @@ -393,7 +393,7 @@ void CoverageRegion::growPolygonArray() { _polygonDistances = newDistances; _polygonSizes = newSizes; _polygonArraySize = _polygonArraySize + DEFAULT_GROW_SIZE; - //qDebug("CoverageMap::growPolygonArray() _polygonArraySize=%d...\n",_polygonArraySize); + //qDebug("CoverageMap::growPolygonArray() _polygonArraySize=%d...",_polygonArraySize); } const char* CoverageRegion::getRegionName() const { @@ -438,7 +438,7 @@ bool CoverageRegion::mergeItemsInArray(VoxelProjectedPolygon* seed, bool seedInA _totalPolygons--; } - //qDebug("_polygonCount=%d\n",_polygonCount); + //qDebug("_polygonCount=%d",_polygonCount); // clean up if (_managePolygons) { @@ -486,7 +486,7 @@ void CoverageRegion::storeInArray(VoxelProjectedPolygon* polygon) { // insertion point in this array, and shift the array accordingly float area = polygon->getBoundingBox().area(); float reverseArea = 4.0f - area; - //qDebug("store by size area=%f reverse area=%f\n", area, reverseArea); + //qDebug("store by size area=%f reverse area=%f", area, reverseArea); _polygonCount = insertIntoSortedArrays((void*)polygon, reverseArea, IGNORED, (void**)_polygons, _polygonSizes, IGNORED, _polygonCount, _polygonArraySize); @@ -500,10 +500,10 @@ void CoverageRegion::storeInArray(VoxelProjectedPolygon* polygon) { // Debugging and Optimization Tuning code. if (_polygonCount > _maxPolygonsUsed) { _maxPolygonsUsed = _polygonCount; - //qDebug("CoverageRegion new _maxPolygonsUsed reached=%d region=%s\n",_maxPolygonsUsed, getRegionName()); + //qDebug("CoverageRegion new _maxPolygonsUsed reached=%d region=%s",_maxPolygonsUsed, getRegionName()); //_myBoundingBox.printDebugDetails("map._myBoundingBox"); } else { - //qDebug("CoverageRegion::storeInArray() _polygonCount=%d region=%s\n",_polygonCount, getRegionName()); + //qDebug("CoverageRegion::storeInArray() _polygonCount=%d region=%s",_polygonCount, getRegionName()); } } diff --git a/libraries/voxels/src/CoverageMapV2.cpp b/libraries/voxels/src/CoverageMapV2.cpp index 0e382d7f12..9d4e92fd17 100644 --- a/libraries/voxels/src/CoverageMapV2.cpp +++ b/libraries/voxels/src/CoverageMapV2.cpp @@ -61,7 +61,7 @@ CoverageMapV2::CoverageMapV2(BoundingBox boundingBox, bool isRoot, bool isCovere { _mapCount++; init(); - //qDebug("CoverageMapV2 created... _mapCount=%d\n",_mapCount); + //qDebug("CoverageMapV2 created... _mapCount=%d",_mapCount); }; CoverageMapV2::~CoverageMapV2() { @@ -78,11 +78,11 @@ void CoverageMapV2::erase() { } if (_isRoot && wantDebugging) { - qDebug("CoverageMapV2 last to be deleted...\n"); - qDebug("MINIMUM_POLYGON_AREA_TO_STORE=%f\n",MINIMUM_POLYGON_AREA_TO_STORE); - qDebug("_mapCount=%d\n",_mapCount); - qDebug("_checkMapRootCalls=%d\n",_checkMapRootCalls); - qDebug("_notAllInView=%d\n",_notAllInView); + qDebug("CoverageMapV2 last to be deleted..."); + qDebug("MINIMUM_POLYGON_AREA_TO_STORE=%f",MINIMUM_POLYGON_AREA_TO_STORE); + qDebug("_mapCount=%d",_mapCount); + qDebug("_checkMapRootCalls=%d",_checkMapRootCalls); + qDebug("_notAllInView=%d",_notAllInView); _mapCount = 0; _checkMapRootCalls = 0; _notAllInView = 0; diff --git a/libraries/voxels/src/ViewFrustum.cpp b/libraries/voxels/src/ViewFrustum.cpp index c13da815f8..3a871f37b9 100644 --- a/libraries/voxels/src/ViewFrustum.cpp +++ b/libraries/voxels/src/ViewFrustum.cpp @@ -322,40 +322,40 @@ bool ViewFrustum::matches(const ViewFrustum& compareTo, bool debug) const { testMatches(compareTo._eyeOffsetOrientation, _eyeOffsetOrientation); if (!result && debug) { - qDebug("ViewFrustum::matches()... result=%s\n", debug::valueOf(result)); - qDebug("%s -- compareTo._position=%f,%f,%f _position=%f,%f,%f\n", + qDebug("ViewFrustum::matches()... result=%s", debug::valueOf(result)); + qDebug("%s -- compareTo._position=%f,%f,%f _position=%f,%f,%f", (testMatches(compareTo._position,_position) ? "MATCHES " : "NO MATCH"), compareTo._position.x, compareTo._position.y, compareTo._position.z, _position.x, _position.y, _position.z ); - qDebug("%s -- compareTo._direction=%f,%f,%f _direction=%f,%f,%f\n", + qDebug("%s -- compareTo._direction=%f,%f,%f _direction=%f,%f,%f", (testMatches(compareTo._direction, _direction) ? "MATCHES " : "NO MATCH"), compareTo._direction.x, compareTo._direction.y, compareTo._direction.z, _direction.x, _direction.y, _direction.z ); - qDebug("%s -- compareTo._up=%f,%f,%f _up=%f,%f,%f\n", + qDebug("%s -- compareTo._up=%f,%f,%f _up=%f,%f,%f", (testMatches(compareTo._up, _up) ? "MATCHES " : "NO MATCH"), compareTo._up.x, compareTo._up.y, compareTo._up.z, _up.x, _up.y, _up.z ); - qDebug("%s -- compareTo._right=%f,%f,%f _right=%f,%f,%f\n", + qDebug("%s -- compareTo._right=%f,%f,%f _right=%f,%f,%f", (testMatches(compareTo._right, _right) ? "MATCHES " : "NO MATCH"), compareTo._right.x, compareTo._right.y, compareTo._right.z, _right.x, _right.y, _right.z ); - qDebug("%s -- compareTo._fieldOfView=%f _fieldOfView=%f\n", + qDebug("%s -- compareTo._fieldOfView=%f _fieldOfView=%f", (testMatches(compareTo._fieldOfView, _fieldOfView) ? "MATCHES " : "NO MATCH"), compareTo._fieldOfView, _fieldOfView); - qDebug("%s -- compareTo._aspectRatio=%f _aspectRatio=%f\n", + qDebug("%s -- compareTo._aspectRatio=%f _aspectRatio=%f", (testMatches(compareTo._aspectRatio, _aspectRatio) ? "MATCHES " : "NO MATCH"), compareTo._aspectRatio, _aspectRatio); - qDebug("%s -- compareTo._nearClip=%f _nearClip=%f\n", + qDebug("%s -- compareTo._nearClip=%f _nearClip=%f", (testMatches(compareTo._nearClip, _nearClip) ? "MATCHES " : "NO MATCH"), compareTo._nearClip, _nearClip); - qDebug("%s -- compareTo._farClip=%f _farClip=%f\n", + qDebug("%s -- compareTo._farClip=%f _farClip=%f", (testMatches(compareTo._farClip, _farClip) ? "MATCHES " : "NO MATCH"), compareTo._farClip, _farClip); - qDebug("%s -- compareTo._eyeOffsetPosition=%f,%f,%f _eyeOffsetPosition=%f,%f,%f\n", + qDebug("%s -- compareTo._eyeOffsetPosition=%f,%f,%f _eyeOffsetPosition=%f,%f,%f", (testMatches(compareTo._eyeOffsetPosition, _eyeOffsetPosition) ? "MATCHES " : "NO MATCH"), compareTo._eyeOffsetPosition.x, compareTo._eyeOffsetPosition.y, compareTo._eyeOffsetPosition.z, _eyeOffsetPosition.x, _eyeOffsetPosition.y, _eyeOffsetPosition.z); - qDebug("%s -- compareTo._eyeOffsetOrientation=%f,%f,%f,%f _eyeOffsetOrientation=%f,%f,%f,%f\n", + qDebug("%s -- compareTo._eyeOffsetOrientation=%f,%f,%f,%f _eyeOffsetOrientation=%f,%f,%f,%f", (testMatches(compareTo._eyeOffsetOrientation, _eyeOffsetOrientation) ? "MATCHES " : "NO MATCH"), compareTo._eyeOffsetOrientation.x, compareTo._eyeOffsetOrientation.y, compareTo._eyeOffsetOrientation.z, compareTo._eyeOffsetOrientation.w, @@ -418,17 +418,17 @@ void ViewFrustum::computeOffAxisFrustum(float& left, float& right, float& bottom } void ViewFrustum::printDebugDetails() const { - qDebug("ViewFrustum::printDebugDetails()... \n"); - qDebug("_position=%f,%f,%f\n", _position.x, _position.y, _position.z ); - qDebug("_direction=%f,%f,%f\n", _direction.x, _direction.y, _direction.z ); - qDebug("_up=%f,%f,%f\n", _up.x, _up.y, _up.z ); - qDebug("_right=%f,%f,%f\n", _right.x, _right.y, _right.z ); - qDebug("_fieldOfView=%f\n", _fieldOfView); - qDebug("_aspectRatio=%f\n", _aspectRatio); - qDebug("_nearClip=%f\n", _nearClip); - qDebug("_farClip=%f\n", _farClip); - qDebug("_eyeOffsetPosition=%f,%f,%f\n", _eyeOffsetPosition.x, _eyeOffsetPosition.y, _eyeOffsetPosition.z ); - qDebug("_eyeOffsetOrientation=%f,%f,%f,%f\n", _eyeOffsetOrientation.x, _eyeOffsetOrientation.y, _eyeOffsetOrientation.z, + qDebug("ViewFrustum::printDebugDetails()... "); + qDebug("_position=%f,%f,%f", _position.x, _position.y, _position.z ); + qDebug("_direction=%f,%f,%f", _direction.x, _direction.y, _direction.z ); + qDebug("_up=%f,%f,%f", _up.x, _up.y, _up.z ); + qDebug("_right=%f,%f,%f", _right.x, _right.y, _right.z ); + qDebug("_fieldOfView=%f", _fieldOfView); + qDebug("_aspectRatio=%f", _aspectRatio); + qDebug("_nearClip=%f", _nearClip); + qDebug("_farClip=%f", _farClip); + qDebug("_eyeOffsetPosition=%f,%f,%f", _eyeOffsetPosition.x, _eyeOffsetPosition.y, _eyeOffsetPosition.z ); + qDebug("_eyeOffsetOrientation=%f,%f,%f,%f", _eyeOffsetOrientation.x, _eyeOffsetOrientation.y, _eyeOffsetOrientation.z, _eyeOffsetOrientation.w ); } diff --git a/libraries/voxels/src/VoxelNode.cpp b/libraries/voxels/src/VoxelNode.cpp index 76fae500dd..e94c9756d9 100644 --- a/libraries/voxels/src/VoxelNode.cpp +++ b/libraries/voxels/src/VoxelNode.cpp @@ -259,7 +259,7 @@ bool VoxelNode::collapseIdenticalLeaves() { // if no child, child isn't a leaf, or child doesn't have a color if (!_children[i] || _children[i]->isStagedForDeletion() || !_children[i]->isLeaf() || !_children[i]->isColored()) { allChildrenMatch=false; - //qDebug("SADNESS child missing or not colored! i=%d\n",i); + //qDebug("SADNESS child missing or not colored! i=%d",i); break; } else { if (i==0) { @@ -276,7 +276,7 @@ bool VoxelNode::collapseIdenticalLeaves() { if (allChildrenMatch) { - //qDebug("allChildrenMatch: pruning tree\n"); + //qDebug("allChildrenMatch: pruning tree"); for (int i = 0; i < NUMBER_OF_CHILDREN; i++) { delete _children[i]; // delete all the child nodes _children[i]=NULL; // set it to NULL @@ -310,13 +310,13 @@ void VoxelNode::printDebugDetails(const char* label) const { } } - qDebug("%s - Voxel at corner=(%f,%f,%f) size=%f\n isLeaf=%s isColored=%s (%d,%d,%d,%d) isDirty=%s shouldRender=%s\n children=", label, + qDebug("%s - Voxel at corner=(%f,%f,%f) size=%f\n isLeaf=%s isColored=%s (%d,%d,%d,%d) isDirty=%s shouldRender=%s children=", label, _box.getCorner().x, _box.getCorner().y, _box.getCorner().z, _box.getSize().x, debug::valueOf(isLeaf()), debug::valueOf(isColored()), getColor()[0], getColor()[1], getColor()[2], getColor()[3], debug::valueOf(isDirty()), debug::valueOf(getShouldRender())); outputBits(childBits, false); - qDebug("\n octalCode="); + qDebug(" octalCode="); printOctalCode(_octalCode); } diff --git a/libraries/voxels/src/VoxelProjectedPolygon.cpp b/libraries/voxels/src/VoxelProjectedPolygon.cpp index 8a39d7f358..71f43a0c04 100644 --- a/libraries/voxels/src/VoxelProjectedPolygon.cpp +++ b/libraries/voxels/src/VoxelProjectedPolygon.cpp @@ -95,7 +95,7 @@ void BoundingBox::printDebugDetails(const char* label) const { } else { qDebug("BoundingBox"); } - qDebug("\n _set=%s\n corner=%f,%f size=%f,%f\n bounds=[(%f,%f) to (%f,%f)]\n", + qDebug("\n _set=%s\n corner=%f,%f size=%f,%f\n bounds=[(%f,%f) to (%f,%f)]", debug::valueOf(_set), corner.x, corner.y, size.x, size.y, corner.x, corner.y, corner.x+size.x, corner.y+size.y); } diff --git a/libraries/voxels/src/VoxelTree.cpp b/libraries/voxels/src/VoxelTree.cpp index 803bea8038..62191bad2b 100644 --- a/libraries/voxels/src/VoxelTree.cpp +++ b/libraries/voxels/src/VoxelTree.cpp @@ -157,7 +157,7 @@ void VoxelTree::recurseNodeWithOperationDistanceSorted(VoxelNode* node, RecurseV if (childNode) { // chance to optimize, doesn't need to be actual distance!! Could be distance squared float distanceSquared = childNode->distanceSquareToPoint(point); - //qDebug("recurseNodeWithOperationDistanceSorted() CHECKING child[%d] point=%f,%f center=%f,%f distance=%f...\n", i, point.x, point.y, center.x, center.y, distance); + //qDebug("recurseNodeWithOperationDistanceSorted() CHECKING child[%d] point=%f,%f center=%f,%f distance=%f...", i, point.x, point.y, center.x, center.y, distance); //childNode->printDebugDetails(""); currentCount = insertIntoSortedArrays((void*)childNode, distanceSquared, i, (void**)&sortedChildren, (float*)&distancesToChildren, @@ -168,7 +168,7 @@ void VoxelTree::recurseNodeWithOperationDistanceSorted(VoxelNode* node, RecurseV for (int i = 0; i < currentCount; i++) { VoxelNode* childNode = sortedChildren[i]; if (childNode) { - //qDebug("recurseNodeWithOperationDistanceSorted() PROCESSING child[%d] distance=%f...\n", i, distancesToChildren[i]); + //qDebug("recurseNodeWithOperationDistanceSorted() PROCESSING child[%d] distance=%f...", i, distancesToChildren[i]); //childNode->printDebugDetails(""); recurseNodeWithOperationDistanceSorted(childNode, operation, point, extraData); } @@ -460,7 +460,7 @@ void VoxelTree::deleteVoxelCodeFromTreeRecursion(VoxelNode* node, void* extraDat // isn't a colored leaf, and the child branch doesn't exist, so there's nothing to do below and // we can safely return, ending the recursion and unwinding if (!childNode) { - //qDebug("new___deleteVoxelCodeFromTree() child branch doesn't exist, but parent is not a leaf, just unwind\n"); + //qDebug("new___deleteVoxelCodeFromTree() child branch doesn't exist, but parent is not a leaf, just unwind"); return; } @@ -548,7 +548,7 @@ void VoxelTree::readCodeColorBufferToTreeRecursion(VoxelNode* node, void* extraD } } else { if (!node->isLeaf()) { - qDebug("WARNING! operation would require deleting children, add Voxel ignored!\n "); + qDebug("WARNING! operation would require deleting children, add Voxel ignored! "); } } @@ -688,7 +688,7 @@ void VoxelTree::loadVoxelsFile(const char* fileName, bool wantColorRandomizer) { int totalBytesRead = 0; if(file.is_open()) { - qDebug("loading file...\n"); + qDebug("loading file..."); bool bail = false; while (!file.eof() && !bail) { file.get(octets); @@ -713,14 +713,14 @@ void VoxelTree::loadVoxelsFile(const char* fileName, bool wantColorRandomizer) { file.get(colorRead); blue = (unsigned char)colorRead; - qDebug("voxel color from file red:%d, green:%d, blue:%d \n",red,green,blue); + qDebug("voxel color from file red:%d, green:%d, blue:%d ",red,green,blue); vCount++; int colorRandomizer = wantColorRandomizer ? randIntInRange (-5, 5) : 0; voxelData[lengthInBytes+1] = std::max(0,std::min(255,red + colorRandomizer)); voxelData[lengthInBytes+2] = std::max(0,std::min(255,green + colorRandomizer)); voxelData[lengthInBytes+3] = std::max(0,std::min(255,blue + colorRandomizer)); - qDebug("voxel color after rand red:%d, green:%d, blue:%d\n", + qDebug("voxel color after rand red:%d, green:%d, blue:%d", voxelData[lengthInBytes+1], voxelData[lengthInBytes+2], voxelData[lengthInBytes+3]); //printVoxelCode(voxelData); @@ -821,7 +821,7 @@ void VoxelTree::createSphere(float radius, float xc, float yc, float zc, float v if (debug) { int percentComplete = 100 * (thisRadius/radius); - qDebug("percentComplete=%d\n",percentComplete); + qDebug("percentComplete=%d",percentComplete); } for (float theta=0.0; theta <= 2 * M_PI; theta += angleDelta) { @@ -837,7 +837,7 @@ void VoxelTree::createSphere(float radius, float xc, float yc, float zc, float v // 2) In all modes, we will use our "outer" color to draw the voxels. Otherwise we will use the average color if (lastLayer) { if (false && debug) { - qDebug("adding candy shell: theta=%f phi=%f thisRadius=%f radius=%f\n", + qDebug("adding candy shell: theta=%f phi=%f thisRadius=%f radius=%f", theta, phi, thisRadius,radius); } switch (mode) { @@ -861,7 +861,7 @@ void VoxelTree::createSphere(float radius, float xc, float yc, float zc, float v green = (unsigned char)std::min(255, std::max(0, (int)(g1 + ((g2 - g1) * gradient)))); blue = (unsigned char)std::min(255, std::max(0, (int)(b1 + ((b2 - b1) * gradient)))); if (debug) { - qDebug("perlin=%f gradient=%f color=(%d,%d,%d)\n",perlin, gradient, red, green, blue); + qDebug("perlin=%f gradient=%f color=(%d,%d,%d)",perlin, gradient, red, green, blue); } } break; } @@ -1178,7 +1178,7 @@ int VoxelTree::encodeTreeBitstreamRecursion(VoxelNode* node, unsigned char* outp if (childNode) { // chance to optimize, doesn't need to be actual distance!! Could be distance squared //float distanceSquared = childNode->distanceSquareToPoint(point); - //qDebug("recurseNodeWithOperationDistanceSorted() CHECKING child[%d] point=%f,%f center=%f,%f distance=%f...\n", i, point.x, point.y, center.x, center.y, distance); + //qDebug("recurseNodeWithOperationDistanceSorted() CHECKING child[%d] point=%f,%f center=%f,%f distance=%f...", i, point.x, point.y, center.x, center.y, distance); //childNode->printDebugDetails(""); float distance = params.viewFrustum ? childNode->distanceToCamera(*params.viewFrustum) : 0; @@ -1434,7 +1434,7 @@ int VoxelTree::encodeTreeBitstreamRecursion(VoxelNode* node, unsigned char* outp bool VoxelTree::readFromSVOFile(const char* fileName) { std::ifstream file(fileName, std::ios::in|std::ios::binary|std::ios::ate); if(file.is_open()) { - qDebug("loading file %s...\n", fileName); + qDebug("loading file %s...", fileName); // get file length.... unsigned long fileLength = file.tellg(); @@ -1462,14 +1462,14 @@ bool VoxelTree::readFromSchematicFile(const char *fileName) { std::stringstream ss; int err = retrieveData(fileName, ss); if (err && ss.get() != TAG_Compound) { - qDebug("[ERROR] Invalid schematic file.\n"); + qDebug("[ERROR] Invalid schematic file."); return false; } ss.get(); TagCompound schematics(ss); if (!schematics.getBlocksId() || !schematics.getBlocksData()) { - qDebug("[ERROR] Invalid schematic file.\n"); + qDebug("[ERROR] Invalid schematic file."); return false; } @@ -1532,7 +1532,7 @@ bool VoxelTree::readFromSchematicFile(const char *fileName) { } } - qDebug("Created %d voxels from minecraft import.\n", count); + qDebug("Created %d voxels from minecraft import.", count); return true; } @@ -1542,7 +1542,7 @@ void VoxelTree::writeToSVOFile(const char* fileName, VoxelNode* node) const { std::ofstream file(fileName, std::ios::out|std::ios::binary); if(file.is_open()) { - qDebug("saving to file %s...\n", fileName); + qDebug("saving to file %s...", fileName); VoxelNodeBag nodeBag; // If we were given a specific node, start from there, otherwise start from root From 51d1e6ae80a38d559d0944f162c53b9830bdb1f4 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 16 Jul 2013 11:50:40 -0700 Subject: [PATCH 09/19] add a message handler to send messages over to LogDisplay --- interface/src/Application.cpp | 7 +++++++ interface/src/LogDisplay.cpp | 4 ++-- interface/src/LogDisplay.h | 4 ++-- libraries/shared/src/NodeList.cpp | 8 ++++---- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index a32832318a..d537f9b8c1 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -164,6 +164,11 @@ void GLCanvas::wheelEvent(QWheelEvent* event) { Application::getInstance()->wheelEvent(event); } +void messageHandler(QtMsgType type, const char* message) { + printf("%s\n", message); + LogDisplay::instance.addMessage(message); +} + Application::Application(int& argc, char** argv, timeval &startup_time) : QApplication(argc, argv), _window(new QMainWindow(desktop())), @@ -212,6 +217,8 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : _window->setWindowTitle("Interface"); qDebug("Interface Startup:"); + qInstallMsgHandler(messageHandler); + unsigned int listenPort = 0; // bind to an ephemeral port by default const char** constArgv = const_cast(argv); const char* portStr = getCmdOption(argc, constArgv, "--listenPort"); diff --git a/interface/src/LogDisplay.cpp b/interface/src/LogDisplay.cpp index 708bb192d3..247ea4beb5 100644 --- a/interface/src/LogDisplay.cpp +++ b/interface/src/LogDisplay.cpp @@ -15,7 +15,7 @@ #include "Util.h" using namespace std; -FILE* const LogDisplay::DEFAULT_STREAM = stdout; +FILE* const LogDisplay::DEFAULT_STREAM = 0l; // // Singleton constructor @@ -88,7 +88,7 @@ void LogDisplay::setCharacterSize(unsigned width, unsigned height) { // Logging // -inline void LogDisplay::addMessage(char const* ptr) { +void LogDisplay::addMessage(const char* ptr) { pthread_mutex_lock(& _mutex); diff --git a/interface/src/LogDisplay.h b/interface/src/LogDisplay.h index bb74872dbd..6f90df3724 100644 --- a/interface/src/LogDisplay.h +++ b/interface/src/LogDisplay.h @@ -21,8 +21,8 @@ public: void render(unsigned screenWidth, unsigned screenHeight); - // log formatted message - inline void addMessage(char const*); + // log formatted message + void addMessage(const char* message); // settings diff --git a/libraries/shared/src/NodeList.cpp b/libraries/shared/src/NodeList.cpp index 0781d8ed1b..87a3f5f70b 100644 --- a/libraries/shared/src/NodeList.cpp +++ b/libraries/shared/src/NodeList.cpp @@ -43,7 +43,7 @@ NodeList* NodeList::createInstance(char ownerType, unsigned int socketListenPort if (!_sharedInstance) { _sharedInstance = new NodeList(ownerType, socketListenPort); } else { - qDebug("NodeList createInstance called with existing instance."); + qDebug("NodeList createInstance called with existing instance.\n"); } return _sharedInstance; @@ -51,7 +51,7 @@ NodeList* NodeList::createInstance(char ownerType, unsigned int socketListenPort NodeList* NodeList::getInstance() { if (!_sharedInstance) { - qDebug("NodeList getInstance called before call to createInstance. Returning NULL pointer."); + qDebug("NodeList getInstance called before call to createInstance. Returning NULL pointer.\n"); } return _sharedInstance; @@ -275,9 +275,9 @@ void NodeList::sendDomainServerCheckIn() { sockaddr_in tempAddress; memcpy(&tempAddress.sin_addr, pHostInfo->h_addr_list[0], pHostInfo->h_length); strcpy(_domainIP, inet_ntoa(tempAddress.sin_addr)); - qDebug("Domain Server: %s ", _domainHostname); + qDebug("Domain Server: %s", _domainHostname); } else { - qDebug("Failed domain server lookup"); + qDebug("Failed domain server lookup\n"); } } else if (!printedDomainServerIP) { qDebug("Domain Server IP: %s", _domainIP); From 063094f96c8c8f36bea2512a8f04e2ec379e832d Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 16 Jul 2013 12:00:14 -0700 Subject: [PATCH 10/19] correctly break on end of qDebug message in LogDisplay --- interface/src/LogDisplay.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/interface/src/LogDisplay.cpp b/interface/src/LogDisplay.cpp index 247ea4beb5..49e4886b00 100644 --- a/interface/src/LogDisplay.cpp +++ b/interface/src/LogDisplay.cpp @@ -97,8 +97,9 @@ void LogDisplay::addMessage(const char* ptr) { fprintf(_stream, "%s", ptr); } - while (*ptr != '\0') { + while (true) { // process the characters + bool isEndOfMessage = (*ptr == '\0'); char c = *ptr++; if (c == '\t') { @@ -150,6 +151,10 @@ void LogDisplay::addMessage(const char* ptr) { _writeLineStartPos = _writePos; _writtenInLine = 0; } + + if (isEndOfMessage) { + break; + } } pthread_mutex_unlock(& _mutex); From 13762da7d822a63dfe28d25b9fd5345a24aa5bb2 Mon Sep 17 00:00:00 2001 From: atlante45 Date: Tue, 16 Jul 2013 12:03:07 -0700 Subject: [PATCH 11/19] Changed shortcuts to ALT+ +/- --- interface/src/Application.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 644d5524f0..67763ae3bf 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1669,8 +1669,8 @@ void Application::initMenu() { "First Person", this, SLOT(setRenderFirstPerson(bool)), Qt::Key_P))->setCheckable(true); (_manualThirdPerson = renderMenu->addAction( "Third Person", this, SLOT(setRenderThirdPerson(bool))))->setCheckable(true); - renderMenu->addAction("Increase Avatar Size", this, SLOT(increaseAvatarSize()), Qt::SHIFT | Qt::Key_Plus); - renderMenu->addAction("Decrease Avatar Size", this, SLOT(decreaseAvatarSize()), Qt::SHIFT | Qt::Key_Minus); + renderMenu->addAction("Increase Avatar Size", this, SLOT(increaseAvatarSize()), Qt::ALT | Qt::Key_Plus); + renderMenu->addAction("Decrease Avatar Size", this, SLOT(decreaseAvatarSize()), Qt::ALT | Qt::Key_Minus); QMenu* toolsMenu = menuBar->addMenu("Tools"); From f713bb961db2fbb1f34cd1ee2416fb447705abcf Mon Sep 17 00:00:00 2001 From: atlante45 Date: Tue, 16 Jul 2013 12:04:22 -0700 Subject: [PATCH 12/19] Adapt avatar message size to the avatars --- interface/src/Avatar.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/src/Avatar.cpp b/interface/src/Avatar.cpp index a1175e3b23..d67a2ffdb9 100755 --- a/interface/src/Avatar.cpp +++ b/interface/src/Avatar.cpp @@ -1047,7 +1047,7 @@ void Avatar::render(bool lookingInMirror, bool renderAvatarBalls) { } glPushMatrix(); - glm::vec3 chatPosition = _bodyBall[BODY_BALL_HEAD_BASE].position + getBodyUpDirection() * chatMessageHeight; + glm::vec3 chatPosition = _bodyBall[BODY_BALL_HEAD_BASE].position + getBodyUpDirection() * chatMessageHeight * _scale; glTranslatef(chatPosition.x, chatPosition.y, chatPosition.z); glm::quat chatRotation = Application::getInstance()->getCamera()->getRotation(); glm::vec3 chatAxis = glm::axis(chatRotation); @@ -1057,7 +1057,7 @@ void Avatar::render(bool lookingInMirror, bool renderAvatarBalls) { glColor3f(0, 0.8, 0); glRotatef(180, 0, 1, 0); glRotatef(180, 0, 0, 1); - glScalef(chatMessageScale, chatMessageScale, 1.0f); + glScalef(_scale * chatMessageScale, _scale * chatMessageScale, 1.0f); glDisable(GL_LIGHTING); glDepthMask(false); From e81fed2622df57fef7316172ae093545fb8f88eb Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Tue, 16 Jul 2013 12:31:58 -0700 Subject: [PATCH 13/19] Calling glInterleavedArrays enables the client vertex/color array states, so we need to disable them afterwards. --- interface/src/starfield/renderer/Renderer.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/interface/src/starfield/renderer/Renderer.h b/interface/src/starfield/renderer/Renderer.h index 92fe53f69f..7eab70d178 100644 --- a/interface/src/starfield/renderer/Renderer.h +++ b/interface/src/starfield/renderer/Renderer.h @@ -509,6 +509,8 @@ namespace starfield { _program.release(); glDisable(GL_VERTEX_PROGRAM_POINT_SIZE); glDisable(GL_POINT_SMOOTH); + glDisableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_COLOR_ARRAY); glPopMatrix(); } From 1b48d4f0fc414ea94611a01cf0948db4c44621d6 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 16 Jul 2013 12:46:32 -0700 Subject: [PATCH 14/19] revert removal of extraneous newlines --- interface/src/Application.cpp | 26 +++---- interface/src/Audio.cpp | 44 ++++++------ interface/src/AvatarVoxelSystem.cpp | 4 +- interface/src/SerialInterface.cpp | 6 +- interface/src/Transmitter.cpp | 6 +- interface/src/Util.cpp | 14 ++-- interface/src/VoxelSystem.cpp | 46 ++++++------ interface/src/Webcam.cpp | 20 +++--- interface/src/main.cpp | 4 +- interface/src/starfield/Loader.h | 10 +-- libraries/shared/src/NodeList.cpp | 7 +- libraries/shared/src/OctalCode.cpp | 4 +- libraries/shared/src/PacketHeaders.cpp | 2 +- libraries/shared/src/PerfStat.cpp | 8 +-- libraries/shared/src/SharedUtil.cpp | 14 ++-- libraries/shared/src/UDPSocket.cpp | 8 +-- libraries/voxels/src/CoverageMap.cpp | 72 +++++++++---------- libraries/voxels/src/CoverageMapV2.cpp | 12 ++-- libraries/voxels/src/ViewFrustum.cpp | 44 ++++++------ libraries/voxels/src/VoxelNode.cpp | 8 +-- .../voxels/src/VoxelProjectedPolygon.cpp | 2 +- libraries/voxels/src/VoxelTree.cpp | 32 ++++----- 22 files changed, 197 insertions(+), 196 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index d537f9b8c1..e5455eb604 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -215,7 +215,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : { _applicationStartupTime = startup_time; _window->setWindowTitle("Interface"); - qDebug("Interface Startup:"); + qDebug("Interface Startup:\n"); qInstallMsgHandler(messageHandler); @@ -240,7 +240,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : // Handle Local Domain testing with the --local command line if (cmdOptionExists(argc, constArgv, "--local")) { - qDebug("Local Domain MODE!"); + qDebug("Local Domain MODE!\n"); NodeList::getInstance()->setDomainIPToLocalhost(); } @@ -304,7 +304,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : } void Application::initializeGL() { - qDebug( "Created Display Window." ); + qDebug( "Created Display Window.\n" ); // initialize glut for shape drawing; Qt apparently initializes it on OS X #ifndef __APPLE__ @@ -319,10 +319,10 @@ void Application::initializeGL() { _viewFrustumOffsetCamera.setFarClip(500.0 * TREE_SCALE); initDisplay(); - qDebug( "Initialized Display." ); + qDebug( "Initialized Display.\n" ); init(); - qDebug( "Init() complete." ); + qDebug( "Init() complete.\n" ); // Check to see if the user passed in a command line option for randomizing colors bool wantColorRandomizer = !arguments().contains("--NoColorRandomizer"); @@ -331,13 +331,13 @@ void Application::initializeGL() { // Voxel File. If so, load it now. if (!_voxelsFilename.isEmpty()) { _voxels.loadVoxelsFile(_voxelsFilename.constData(), wantColorRandomizer); - qDebug("Local Voxel File loaded."); + qDebug("Local Voxel File loaded.\n"); } // create thread for receipt of data via UDP if (_enableNetworkThread) { pthread_create(&_networkReceiveThread, NULL, networkReceive, NULL); - qDebug("Network receive thread created."); + qDebug("Network receive thread created.\n"); } // call terminate before exiting @@ -358,7 +358,7 @@ void Application::initializeGL() { float startupTime = (usecTimestampNow() - usecTimestamp(&_applicationStartupTime)) / 1000000.0; _justStarted = false; char title[50]; - sprintf(title, "Interface: %4.2f seconds", startupTime); + sprintf(title, "Interface: %4.2f seconds\n", startupTime); qDebug("%s", title); _window->setWindowTitle(title); @@ -1453,7 +1453,7 @@ void Application::importVoxels() { if (fileNameString.endsWith(".png", Qt::CaseInsensitive)) { QImage pngImage = QImage(fileName); if (pngImage.height() != pngImage.width()) { - qDebug("ERROR: Bad PNG size: height != width."); + qDebug("ERROR: Bad PNG size: height != width.\n"); return; } @@ -1765,7 +1765,7 @@ void Application::init() { _audio.setJitterBufferSamples(_audioJitterBufferSamples); } - qDebug("Loaded settings."); + qDebug("Loaded settings.\n"); sendAvatarVoxelURLMessage(_myAvatar.getVoxels()->getVoxelURL()); @@ -2778,7 +2778,7 @@ glm::vec2 Application::getScaledScreenPoint(glm::vec2 projectedPoint) { // render the coverage map on screen void Application::renderCoverageMapV2() { - //qDebug("renderCoverageMap()"); + //qDebug("renderCoverageMap()\n"); glDisable(GL_LIGHTING); glLineWidth(2.0); @@ -2823,7 +2823,7 @@ void Application::renderCoverageMapsV2Recursively(CoverageMapV2* map) { // render the coverage map on screen void Application::renderCoverageMap() { - //qDebug("renderCoverageMap()"); + //qDebug("renderCoverageMap()\n"); glDisable(GL_LIGHTING); glLineWidth(2.0); @@ -3154,7 +3154,7 @@ void Application::eyedropperVoxelUnderCursor() { } void Application::goHome() { - qDebug("Going Home!"); + qDebug("Going Home!\n"); _myAvatar.setPosition(START_LOCATION); } diff --git a/interface/src/Audio.cpp b/interface/src/Audio.cpp index 4bacc274ad..4c707de938 100644 --- a/interface/src/Audio.cpp +++ b/interface/src/Audio.cpp @@ -152,11 +152,11 @@ inline void Audio::performIO(int16_t* inputLeft, int16_t* outputLeft, int16_t* o // If not enough audio has arrived to start playback, keep waiting // #ifdef SHOW_AUDIO_DEBUG - qDebug("%i,%i,%i,%i", - _packetsReceivedThisPlayback, - ringBuffer->diffLastWriteNextOutput(), - PACKET_LENGTH_SAMPLES, - _jitterBufferSamples); + qDebug("%i,%i,%i,%i\n", + _packetsReceivedThisPlayback, + ringBuffer->diffLastWriteNextOutput(), + PACKET_LENGTH_SAMPLES, + _jitterBufferSamples); #endif } else if (ringBuffer->isStarted() && ringBuffer->diffLastWriteNextOutput() == 0) { // @@ -169,7 +169,7 @@ inline void Audio::performIO(int16_t* inputLeft, int16_t* outputLeft, int16_t* o _packetsReceivedThisPlayback = 0; _wasStarved = 10; // Frames for which to render the indication that the system was starved. #ifdef SHOW_AUDIO_DEBUG - qDebug("Starved, remaining samples = %d", + qDebug("Starved, remaining samples = %d\n", ringBuffer->diffLastWriteNextOutput()); #endif @@ -180,10 +180,10 @@ inline void Audio::performIO(int16_t* inputLeft, int16_t* outputLeft, int16_t* o if (!ringBuffer->isStarted()) { ringBuffer->setStarted(true); #ifdef SHOW_AUDIO_DEBUG - qDebug("starting playback %0.1f msecs delayed, jitter = %d, pkts recvd: %d", - (usecTimestampNow() - usecTimestamp(&_firstPacketReceivedTime))/1000.0, - _jitterBufferSamples, - _packetsReceivedThisPlayback); + qDebug("starting playback %0.1f msecs delayed, jitter = %d, pkts recvd: %d \n", + (usecTimestampNow() - usecTimestamp(&_firstPacketReceivedTime))/1000.0, + _jitterBufferSamples, + _packetsReceivedThisPlayback); #endif } @@ -300,8 +300,8 @@ int Audio::audioCallback (const void* inputBuffer, static void outputPortAudioError(PaError error) { if (error != paNoError) { - qDebug("-- portaudio termination error --"); - qDebug("PortAudio error (%d): %s", error, Pa_GetErrorText(error)); + qDebug("-- portaudio termination error --\n"); + qDebug("PortAudio error (%d): %s\n", error, Pa_GetErrorText(error)); } } @@ -350,7 +350,7 @@ Audio::Audio(Oscilloscope* scope, int16_t initialJitterBufferSamples) : outputParameters.device = Pa_GetDefaultOutputDevice(); if (inputParameters.device == -1 || outputParameters.device == -1) { - qDebug("Audio: Missing device."); + qDebug("Audio: Missing device.\n"); outputPortAudioError(Pa_Terminate()); return; } @@ -385,12 +385,12 @@ Audio::Audio(Oscilloscope* scope, int16_t initialJitterBufferSamples) : outputPortAudioError(Pa_StartStream(_stream)); // Uncomment these lines to see the system-reported latency - //qDebug("Default low input, output latency (secs): %0.4f, %0.4f", + //qDebug("Default low input, output latency (secs): %0.4f, %0.4f\n", // Pa_GetDeviceInfo(Pa_GetDefaultInputDevice())->defaultLowInputLatency, // Pa_GetDeviceInfo(Pa_GetDefaultOutputDevice())->defaultLowOutputLatency); const PaStreamInfo* streamInfo = Pa_GetStreamInfo(_stream); - qDebug("Started audio with reported latency msecs In/Out: %.0f, %.0f", streamInfo->inputLatency * 1000.f, + qDebug("Started audio with reported latency msecs In/Out: %.0f, %.0f\n", streamInfo->inputLatency * 1000.f, streamInfo->outputLatency * 1000.f); gettimeofday(&_lastReceiveTime, NULL); @@ -651,7 +651,7 @@ inline void Audio::eventuallySendRecvPing(int16_t* inputLeft, int16_t* outputLef // As of the next frame, we'll be recoding PING_FRAMES_TO_RECORD from // the mic (pointless to start now as we can't record unsent audio). _isSendingEchoPing = false; - qDebug("Send audio ping"); + qDebug("Send audio ping\n"); } else if (_pingFramesToRecord > 0) { @@ -665,7 +665,7 @@ inline void Audio::eventuallySendRecvPing(int16_t* inputLeft, int16_t* outputLef if (_pingFramesToRecord == 0) { _pingAnalysisPending = true; - qDebug("Received ping echo"); + qDebug("Received ping echo\n"); } } } @@ -689,25 +689,25 @@ inline void Audio::analyzePing() { // Determine extrema int botAt = findExtremum(_echoSamplesLeft, PING_SAMPLES_TO_ANALYZE, -1); if (botAt == -1) { - qDebug("Audio Ping: Minimum not found."); + qDebug("Audio Ping: Minimum not found.\n"); return; } int topAt = findExtremum(_echoSamplesLeft, PING_SAMPLES_TO_ANALYZE, 1); if (topAt == -1) { - qDebug("Audio Ping: Maximum not found."); + qDebug("Audio Ping: Maximum not found.\n"); return; } // Determine peak amplitude - warn if low int ampli = (_echoSamplesLeft[topAt] - _echoSamplesLeft[botAt]) / 2; if (ampli < PING_MIN_AMPLI) { - qDebug("Audio Ping unreliable - low amplitude %d.", ampli); + qDebug("Audio Ping unreliable - low amplitude %d.\n", ampli); } // Determine period - warn if doesn't look like our signal int halfPeriod = abs(topAt - botAt); if (abs(halfPeriod-PING_HALF_PERIOD) > PING_MAX_PERIOD_DIFFERENCE) { - qDebug("Audio Ping unreliable - peak distance %d vs. %d", halfPeriod, PING_HALF_PERIOD); + qDebug("Audio Ping unreliable - peak distance %d vs. %d\n", halfPeriod, PING_HALF_PERIOD); } // Ping is sent: @@ -748,7 +748,7 @@ inline void Audio::analyzePing() { int delay = (botAt + topAt) / 2 + PING_PERIOD; - qDebug("\n| Audio Ping results:\n+----- ---- --- - - - - -\n" + qDebug("\n| Audio Ping results:\n+----- ---- --- - - - - -\n\n" "Delay = %d samples (%d ms)\nPeak amplitude = %d\n\n", delay, (delay * 1000) / int(SAMPLE_RATE), ampli); } diff --git a/interface/src/AvatarVoxelSystem.cpp b/interface/src/AvatarVoxelSystem.cpp index a341ecaa38..c85ea1a343 100644 --- a/interface/src/AvatarVoxelSystem.cpp +++ b/interface/src/AvatarVoxelSystem.cpp @@ -93,7 +93,7 @@ const Mode MODES[] = { void AvatarVoxelSystem::cycleMode() { _mode = (_mode + 1) % (sizeof(MODES) / sizeof(MODES[0])); - qDebug("Voxeltar bind mode %d.", _mode); + qDebug("Voxeltar bind mode %d.\n", _mode); // rebind QUrl url = _voxelURL; @@ -255,7 +255,7 @@ void AvatarVoxelSystem::handleVoxelDownloadProgress(qint64 bytesReceived, qint64 } void AvatarVoxelSystem::handleVoxelReplyError() { - qDebug("%s", _voxelReply->errorString().toAscii().constData()); + qDebug("%s\n", _voxelReply->errorString().toAscii().constData()); _voxelReply->disconnect(this); _voxelReply->deleteLater(); diff --git a/interface/src/SerialInterface.cpp b/interface/src/SerialInterface.cpp index e17feb48d7..0f90ee8dd7 100644 --- a/interface/src/SerialInterface.cpp +++ b/interface/src/SerialInterface.cpp @@ -100,7 +100,7 @@ void SerialInterface::initializePort(char* portname) { qDebug("Opening SerialUSB %s: ", portname); if (_serialDescriptor == -1) { - qDebug("Failed."); + qDebug("Failed.\n"); return; } @@ -134,7 +134,7 @@ void SerialInterface::initializePort(char* portname) { mpu_set_sensors(INV_XYZ_GYRO | INV_XYZ_ACCEL | INV_XYZ_COMPASS); } - qDebug("Connected."); + qDebug("Connected.\n"); resetSerial(); _active = true; @@ -373,7 +373,7 @@ void SerialInterface::readData(float deltaTime) { gettimeofday(&now, NULL); if (diffclock(&lastGoodRead, &now) > NO_READ_MAXIMUM_MSECS) { - qDebug("No data - Shutting down SerialInterface."); + qDebug("No data - Shutting down SerialInterface.\n"); resetSerial(); } } else { diff --git a/interface/src/Transmitter.cpp b/interface/src/Transmitter.cpp index ce0180e501..eac769ead7 100644 --- a/interface/src/Transmitter.cpp +++ b/interface/src/Transmitter.cpp @@ -38,7 +38,7 @@ void Transmitter::checkForLostTransmitter() { int msecsSinceLast = diffclock(_lastReceivedPacket, &now); if (msecsSinceLast > TIME_TO_ASSUME_LOST_MSECS) { resetLevels(); - qDebug("Transmitter signal lost."); + qDebug("Transmitter signal lost.\n"); } } } @@ -93,12 +93,12 @@ void Transmitter::processIncomingData(unsigned char* packetData, int numBytes) { _estimatedRotation.y *= (1.f - DECAY_RATE * DELTA_TIME); if (!_isConnected) { - qDebug("Transmitter Connected."); + qDebug("Transmitter Connected.\n"); _isConnected = true; _estimatedRotation *= 0.0; } } else { - qDebug("Transmitter packet read error, %d bytes.", numBytes); + qDebug("Transmitter packet read error, %d bytes.\n", numBytes); } } diff --git a/interface/src/Util.cpp b/interface/src/Util.cpp index 7bc4e50d96..20f33f924a 100644 --- a/interface/src/Util.cpp +++ b/interface/src/Util.cpp @@ -451,7 +451,7 @@ void renderOrientationDirections(glm::vec3 position, const glm::quat& orientatio bool closeEnoughForGovernmentWork(float a, float b) { float distance = std::abs(a-b); - //qDebug("closeEnoughForGovernmentWork() a=%1.10f b=%1.10f distance=%1.10f",a,b,distance); + //qDebug("closeEnoughForGovernmentWork() a=%1.10f b=%1.10f distance=%1.10f\n",a,b,distance); return (distance < 0.00001f); } @@ -469,7 +469,7 @@ void runTimingTests() { gettimeofday(&endTime, NULL); } elapsedMsecs = diffclock(&startTime, &endTime); - qDebug("gettimeofday() usecs: %f", 1000.0f * elapsedMsecs / (float) numTests); + qDebug("gettimeofday() usecs: %f\n", 1000.0f * elapsedMsecs / (float) numTests); // Random number generation gettimeofday(&startTime, NULL); @@ -478,7 +478,7 @@ void runTimingTests() { } gettimeofday(&endTime, NULL); elapsedMsecs = diffclock(&startTime, &endTime); - qDebug("rand() stored in array usecs: %f", 1000.0f * elapsedMsecs / (float) numTests); + qDebug("rand() stored in array usecs: %f\n", 1000.0f * elapsedMsecs / (float) numTests); // Random number generation using randFloat() gettimeofday(&startTime, NULL); @@ -487,7 +487,7 @@ void runTimingTests() { } gettimeofday(&endTime, NULL); elapsedMsecs = diffclock(&startTime, &endTime); - qDebug("randFloat() stored in array usecs: %f", 1000.0f * elapsedMsecs / (float) numTests); + qDebug("randFloat() stored in array usecs: %f\n", 1000.0f * elapsedMsecs / (float) numTests); // PowF function fTest = 1145323.2342f; @@ -497,7 +497,7 @@ void runTimingTests() { } gettimeofday(&endTime, NULL); elapsedMsecs = diffclock(&startTime, &endTime); - qDebug("powf(f, 0.5) usecs: %f", 1000.0f * elapsedMsecs / (float) numTests); + qDebug("powf(f, 0.5) usecs: %f\n", 1000.0f * elapsedMsecs / (float) numTests); // Vector Math float distance; @@ -510,7 +510,7 @@ void runTimingTests() { } gettimeofday(&endTime, NULL); elapsedMsecs = diffclock(&startTime, &endTime); - qDebug("vector math usecs: %f [%f msecs total for %d tests]", + qDebug("vector math usecs: %f [%f msecs total for %d tests]\n", 1000.0f * elapsedMsecs / (float) numTests, elapsedMsecs, numTests); // Vec3 test @@ -524,7 +524,7 @@ void runTimingTests() { } gettimeofday(&endTime, NULL); elapsedMsecs = diffclock(&startTime, &endTime); - qDebug("vec3 assign and dot() usecs: %f", 1000.0f * elapsedMsecs / (float) numTests); + qDebug("vec3 assign and dot() usecs: %f\n", 1000.0f * elapsedMsecs / (float) numTests); } diff --git a/interface/src/VoxelSystem.cpp b/interface/src/VoxelSystem.cpp index 0b4777a12f..f219e38dc6 100644 --- a/interface/src/VoxelSystem.cpp +++ b/interface/src/VoxelSystem.cpp @@ -144,16 +144,16 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) { int commandLength = strlen(command); // commands are null terminated strings int totalLength = 1+commandLength+1; - qDebug("got Z message len(%d)= %s", numBytes, command); + qDebug("got Z message len(%d)= %s\n", numBytes, command); while (totalLength <= numBytes) { if (0==strcmp(command,(char*)"erase all")) { - qDebug("got Z message == erase all"); + qDebug("got Z message == erase all\n"); _tree->eraseAllVoxels(); _voxelsInReadArrays = _voxelsInWriteArrays = 0; // better way to do this?? } if (0==strcmp(command,(char*)"add scene")) { - qDebug("got Z message == add scene - NOT SUPPORTED ON INTERFACE"); + qDebug("got Z message == add scene - NOT SUPPORTED ON INTERFACE\n"); } totalLength += commandLength+1; } @@ -708,7 +708,7 @@ bool VoxelSystem::randomColorOperation(VoxelNode* node, void* extraData) { void VoxelSystem::randomizeVoxelColors() { _nodeCount = 0; _tree->recurseTreeWithOperation(randomColorOperation); - qDebug("setting randomized true color for %d nodes", _nodeCount); + qDebug("setting randomized true color for %d nodes\n", _nodeCount); setupNewVoxelsForDrawing(); } @@ -722,7 +722,7 @@ bool VoxelSystem::falseColorizeRandomOperation(VoxelNode* node, void* extraData) void VoxelSystem::falseColorizeRandom() { _nodeCount = 0; _tree->recurseTreeWithOperation(falseColorizeRandomOperation); - qDebug("setting randomized false color for %d nodes", _nodeCount); + qDebug("setting randomized false color for %d nodes\n", _nodeCount); setupNewVoxelsForDrawing(); } @@ -736,7 +736,7 @@ void VoxelSystem::trueColorize() { PerformanceWarning warn(true, "trueColorize()",true); _nodeCount = 0; _tree->recurseTreeWithOperation(trueColorizeOperation); - qDebug("setting true color for %d nodes", _nodeCount); + qDebug("setting true color for %d nodes\n", _nodeCount); setupNewVoxelsForDrawing(); } @@ -756,7 +756,7 @@ bool VoxelSystem::falseColorizeInViewOperation(VoxelNode* node, void* extraData) void VoxelSystem::falseColorizeInView(ViewFrustum* viewFrustum) { _nodeCount = 0; _tree->recurseTreeWithOperation(falseColorizeInViewOperation,(void*)viewFrustum); - qDebug("setting in view false color for %d nodes", _nodeCount); + qDebug("setting in view false color for %d nodes\n", _nodeCount); setupNewVoxelsForDrawing(); } @@ -806,10 +806,10 @@ void VoxelSystem::falseColorizeDistanceFromView(ViewFrustum* viewFrustum) { _maxDistance = 0.0; _minDistance = FLT_MAX; _tree->recurseTreeWithOperation(getDistanceFromViewRangeOperation,(void*)viewFrustum); - qDebug("determining distance range for %d nodes", _nodeCount); + qDebug("determining distance range for %d nodes\n", _nodeCount); _nodeCount = 0; _tree->recurseTreeWithOperation(falseColorizeDistanceFromViewOperation,(void*)viewFrustum); - qDebug("setting in distance false color for %d nodes", _nodeCount); + qDebug("setting in distance false color for %d nodes\n", _nodeCount); setupNewVoxelsForDrawing(); } @@ -921,7 +921,7 @@ void VoxelSystem::removeOutOfView() { } bool showRemoveDebugDetails = false; if (showRemoveDebugDetails) { - qDebug("removeOutOfView() scanned=%ld removed=%ld inside=%ld intersect=%ld outside=%ld _removedVoxels.count()=%d ", + qDebug("removeOutOfView() scanned=%ld removed=%ld inside=%ld intersect=%ld outside=%ld _removedVoxels.count()=%d \n", args.nodesScanned, args.nodesRemoved, args.nodesInside, args.nodesIntersect, args.nodesOutside, _removedVoxels.count() ); @@ -987,7 +987,7 @@ bool VoxelSystem::falseColorizeRandomEveryOtherOperation(VoxelNode* node, void* void VoxelSystem::falseColorizeRandomEveryOther() { falseColorizeRandomEveryOtherArgs args; _tree->recurseTreeWithOperation(falseColorizeRandomEveryOtherOperation,&args); - qDebug("randomized false color for every other node: total %ld, colorable %ld, colored %ld", + qDebug("randomized false color for every other node: total %ld, colorable %ld, colored %ld\n", args.totalNodes, args.colorableNodes, args.coloredNodes); setupNewVoxelsForDrawing(); } @@ -1048,7 +1048,7 @@ bool VoxelSystem::collectStatsForTreesAndVBOsOperation(VoxelNode* node, void* ex unsigned long nodeIndex = node->getBufferIndex(); if (args->hasIndexFound[nodeIndex]) { args->duplicateVBOIndex++; - qDebug("duplicateVBO found... index=%ld, isDirty=%s, shouldRender=%s ", nodeIndex, + qDebug("duplicateVBO found... index=%ld, isDirty=%s, shouldRender=%s \n", nodeIndex, debug::valueOf(node->isDirty()), debug::valueOf(node->getShouldRender())); } else { args->hasIndexFound[nodeIndex] = true; @@ -1083,13 +1083,13 @@ void VoxelSystem::collectStatsForTreesAndVBOs() { args.expectedMax = _voxelsInWriteArrays; _tree->recurseTreeWithOperation(collectStatsForTreesAndVBOsOperation,&args); - qDebug("Local Voxel Tree Statistics:\n total nodes %ld \n leaves %ld \n dirty %ld \n colored %ld \n shouldRender %ld ", + qDebug("Local Voxel Tree Statistics:\n total nodes %ld \n leaves %ld \n dirty %ld \n colored %ld \n shouldRender %ld \n", args.totalNodes, args.leafNodes, args.dirtyNodes, args.coloredNodes, args.shouldRenderNodes); - qDebug(" _voxelsDirty=%s \n _voxelsInWriteArrays=%ld \n minDirty=%ld \n maxDirty=%ld ", debug::valueOf(_voxelsDirty), + qDebug(" _voxelsDirty=%s \n _voxelsInWriteArrays=%ld \n minDirty=%ld \n maxDirty=%ld \n", debug::valueOf(_voxelsDirty), _voxelsInWriteArrays, minDirty, maxDirty); - qDebug(" inVBO %ld \n nodesInVBOOverExpectedMax %ld \n duplicateVBOIndex %ld \n nodesInVBONotShouldRender %ld ", + qDebug(" inVBO %ld \n nodesInVBOOverExpectedMax %ld \n duplicateVBOIndex %ld \n nodesInVBONotShouldRender %ld \n", args.nodesInVBO, args.nodesInVBOOverExpectedMax, args.duplicateVBOIndex, args.nodesInVBONotShouldRender); glBufferIndex minInVBO = GLBUFFER_INDEX_UNKNOWN; @@ -1102,7 +1102,7 @@ void VoxelSystem::collectStatsForTreesAndVBOs() { } } - qDebug(" minInVBO=%ld \n maxInVBO=%ld \n _voxelsInWriteArrays=%ld \n _voxelsInReadArrays=%ld ", + qDebug(" minInVBO=%ld \n maxInVBO=%ld \n _voxelsInWriteArrays=%ld \n _voxelsInReadArrays=%ld \n", minInVBO, maxInVBO, _voxelsInWriteArrays, _voxelsInReadArrays); } @@ -1127,7 +1127,7 @@ void VoxelSystem::createVoxel(float x, float y, float z, float s, unsigned char red, unsigned char green, unsigned char blue, bool destructive) { pthread_mutex_lock(&_treeLock); - //qDebug("VoxelSystem::createVoxel(%f,%f,%f,%f)",x,y,z,s); + //qDebug("VoxelSystem::createVoxel(%f,%f,%f,%f)\n",x,y,z,s); _tree->createVoxel(x, y, z, s, red, green, blue, destructive); setupNewVoxelsForDrawing(); @@ -1253,9 +1253,9 @@ bool VoxelSystem::falseColorizeOccludedOperation(VoxelNode* node, void* extraDat args->occludedVoxels++; } else if (result == STORED) { args->notOccludedVoxels++; - //qDebug("***** falseColorizeOccludedOperation() NODE is STORED *****"); + //qDebug("***** falseColorizeOccludedOperation() NODE is STORED *****\n"); } else if (result == DOESNT_FIT) { - //qDebug("***** falseColorizeOccludedOperation() NODE DOESNT_FIT???? *****"); + //qDebug("***** falseColorizeOccludedOperation() NODE DOESNT_FIT???? *****\n"); } } return true; // keep going! @@ -1288,7 +1288,7 @@ void VoxelSystem::falseColorizeOccluded() { _tree->recurseTreeWithOperationDistanceSorted(falseColorizeOccludedOperation, position, (void*)&args); - qDebug("falseColorizeOccluded()\n position=(%f,%f)\n total=%ld\n colored=%ld\n occluded=%ld\n notOccluded=%ld\n outOfView=%ld\n subtreeVoxelsSkipped=%ld\n stagedForDeletion=%ld\n nonLeaves=%ld\n nonLeavesOutOfView=%ld\n nonLeavesOccluded=%ld\n pointInside_calls=%ld\n occludes_calls=%ld\n intersects_calls=%ld", + qDebug("falseColorizeOccluded()\n position=(%f,%f)\n total=%ld\n colored=%ld\n occluded=%ld\n notOccluded=%ld\n outOfView=%ld\n subtreeVoxelsSkipped=%ld\n stagedForDeletion=%ld\n nonLeaves=%ld\n nonLeavesOutOfView=%ld\n nonLeavesOccluded=%ld\n pointInside_calls=%ld\n occludes_calls=%ld\n intersects_calls=%ld\n", position.x, position.y, args.totalVoxels, args.coloredVoxels, args.occludedVoxels, args.notOccludedVoxels, args.outOfView, args.subtreeVoxelsSkipped, @@ -1374,9 +1374,9 @@ bool VoxelSystem::falseColorizeOccludedV2Operation(VoxelNode* node, void* extraD args->occludedVoxels++; } else if (result == V2_STORED) { args->notOccludedVoxels++; - //qDebug("***** falseColorizeOccludedOperation() NODE is STORED *****"); + //qDebug("***** falseColorizeOccludedOperation() NODE is STORED *****\n"); } else if (result == V2_DOESNT_FIT) { - //qDebug("***** falseColorizeOccludedOperation() NODE DOESNT_FIT???? *****"); + //qDebug("***** falseColorizeOccludedOperation() NODE DOESNT_FIT???? *****\n"); } delete voxelPolygon; // V2 maps don't store polygons, so we're always in charge of freeing } @@ -1413,7 +1413,7 @@ void VoxelSystem::falseColorizeOccludedV2() { _tree->recurseTreeWithOperationDistanceSorted(falseColorizeOccludedV2Operation, position, (void*)&args); - qDebug("falseColorizeOccludedV2()\n position=(%f,%f)\n total=%ld\n colored=%ld\n occluded=%ld\n notOccluded=%ld\n outOfView=%ld\n subtreeVoxelsSkipped=%ld\n stagedForDeletion=%ld\n nonLeaves=%ld\n nonLeavesOutOfView=%ld\n nonLeavesOccluded=%ld\n pointInside_calls=%ld\n occludes_calls=%ld\n intersects_calls=%ld", + qDebug("falseColorizeOccludedV2()\n position=(%f,%f)\n total=%ld\n colored=%ld\n occluded=%ld\n notOccluded=%ld\n outOfView=%ld\n subtreeVoxelsSkipped=%ld\n stagedForDeletion=%ld\n nonLeaves=%ld\n nonLeavesOutOfView=%ld\n nonLeavesOccluded=%ld\n pointInside_calls=%ld\n occludes_calls=%ld\n intersects_calls=%ld\n", position.x, position.y, args.totalVoxels, args.coloredVoxels, args.occludedVoxels, args.notOccludedVoxels, args.outOfView, args.subtreeVoxelsSkipped, diff --git a/interface/src/Webcam.cpp b/interface/src/Webcam.cpp index 3831f39893..f9dd5ffe2c 100644 --- a/interface/src/Webcam.cpp +++ b/interface/src/Webcam.cpp @@ -156,7 +156,7 @@ void Webcam::setFrame(const Mat& frame, int format, const Mat& depth, const Rota glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, _frameWidth = image.width, _frameHeight = image.height, 0, format, GL_UNSIGNED_BYTE, image.imageData); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - qDebug("Capturing video at %dx%d.", _frameWidth, _frameHeight); + qDebug("Capturing video at %dx%d.\n", _frameWidth, _frameHeight); } else { glBindTexture(GL_TEXTURE_2D, _frameTextureID); @@ -172,7 +172,7 @@ void Webcam::setFrame(const Mat& frame, int format, const Mat& depth, const Rota glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, _depthWidth = depthImage.width, _depthHeight = depthImage.height, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, depthImage.imageData); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - qDebug("Capturing depth at %dx%d.", _depthWidth, _depthHeight); + qDebug("Capturing depth at %dx%d.\n", _depthWidth, _depthHeight); } else { glBindTexture(GL_TEXTURE_2D, _depthTextureID); @@ -330,26 +330,26 @@ static glm::quat xnToGLM(const XnMatrix3X3& matrix) { } static void XN_CALLBACK_TYPE newUser(UserGenerator& generator, XnUserID id, void* cookie) { - qDebug("Found user %d.", id); + qDebug("Found user %d.\n", id); generator.GetSkeletonCap().RequestCalibration(id, false); } static void XN_CALLBACK_TYPE lostUser(UserGenerator& generator, XnUserID id, void* cookie) { - qDebug("Lost user %d.", id); + qDebug("Lost user %d.\n", id); } static void XN_CALLBACK_TYPE calibrationStarted(SkeletonCapability& capability, XnUserID id, void* cookie) { - qDebug("Calibration started for user %d.", id); + qDebug("Calibration started for user %d.\n", id); } static void XN_CALLBACK_TYPE calibrationCompleted(SkeletonCapability& capability, XnUserID id, XnCalibrationStatus status, void* cookie) { if (status == XN_CALIBRATION_STATUS_OK) { - qDebug("Calibration completed for user %d.", id); + qDebug("Calibration completed for user %d.\n", id); capability.StartTracking(id); } else { - qDebug("Calibration failed to user %d.", id); + qDebug("Calibration failed to user %d.\n", id); capability.RequestCalibration(id, true); } } @@ -438,7 +438,7 @@ void FrameGrabber::grabFrame() { // make sure it's in the format we expect if (image->nChannels != 3 || image->depth != IPL_DEPTH_8U || image->dataOrder != IPL_DATA_ORDER_PIXEL || image->origin != 0) { - qDebug("Invalid webcam image format."); + qDebug("Invalid webcam image format.\n"); return; } frame = image; @@ -485,7 +485,7 @@ bool FrameGrabber::init() { // load our face cascade switchToResourcesParentIfRequired(); if (_faceCascade.empty() && !_faceCascade.load("resources/haarcascades/haarcascade_frontalface_alt.xml")) { - qDebug("Failed to load Haar cascade for face tracking."); + qDebug("Failed to load Haar cascade for face tracking.\n"); return false; } @@ -513,7 +513,7 @@ bool FrameGrabber::init() { // next, an ordinary webcam if ((_capture = cvCaptureFromCAM(-1)) == 0) { - qDebug("Failed to open webcam."); + qDebug("Failed to open webcam.\n"); return false; } const int IDEAL_FRAME_WIDTH = 320; diff --git a/interface/src/main.cpp b/interface/src/main.cpp index 7bcef42e88..98ed4fb231 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -24,8 +24,8 @@ int main(int argc, const char * argv[]) { gettimeofday(&startup_time, NULL); Application app(argc, const_cast(argv), startup_time); - qDebug( "Created QT Application." ); + qDebug( "Created QT Application.\n" ); int exitCode = app.exec(); - qDebug("Normal exit."); + qDebug("Normal exit.\n"); return exitCode; } diff --git a/interface/src/starfield/Loader.h b/interface/src/starfield/Loader.h index 8aa1527ad5..e2f6105f33 100644 --- a/interface/src/starfield/Loader.h +++ b/interface/src/starfield/Loader.h @@ -38,12 +38,12 @@ namespace starfield { if (! UrlReader::readUrl(url, *this, cacheFile)) { - qDebug("%s:%d: %s", + qDebug("%s:%d: %s\n", _urlStr, _lineNo, getError()); return false; } - qDebug("Loaded %u stars.", _recordsRead); + qDebug("Loaded %u stars.\n", _recordsRead); return true; } @@ -63,7 +63,7 @@ namespace starfield { _vertices->clear(); _vertices->reserve(_limit); -// qDebug("Stars.cpp: loader begin %s", url); +// qDebug("Stars.cpp: loader begin %s\n", url); } size_t transfer(char* input, size_t bytes) { @@ -103,7 +103,7 @@ namespace starfield { } else { - qDebug("Stars.cpp:%d: Bad input from %s", + qDebug("Stars.cpp:%d: Bad input from %s\n", _lineNo, _urlStr); } @@ -128,7 +128,7 @@ namespace starfield { // remember the brightness at its top if (_recordsRead == _limit) { -// qDebug("Stars.cpp: vertex limit reached -> heap mode"); +// qDebug("Stars.cpp: vertex limit reached -> heap mode\n"); make_heap( _vertices->begin(), _vertices->end(), diff --git a/libraries/shared/src/NodeList.cpp b/libraries/shared/src/NodeList.cpp index 87a3f5f70b..2f811f48c2 100644 --- a/libraries/shared/src/NodeList.cpp +++ b/libraries/shared/src/NodeList.cpp @@ -275,12 +275,13 @@ void NodeList::sendDomainServerCheckIn() { sockaddr_in tempAddress; memcpy(&tempAddress.sin_addr, pHostInfo->h_addr_list[0], pHostInfo->h_length); strcpy(_domainIP, inet_ntoa(tempAddress.sin_addr)); - qDebug("Domain Server: %s", _domainHostname); + + qDebug("Domain Server: %s\n", _domainHostname); } else { qDebug("Failed domain server lookup\n"); } } else if (!printedDomainServerIP) { - qDebug("Domain Server IP: %s", _domainIP); + qDebug("Domain Server IP: %s\n", _domainIP); printedDomainServerIP = true; } @@ -419,7 +420,7 @@ void NodeList::addNodeToList(Node* newNode) { ++_numNodes; - qDebug() << "Added" << *newNode; + qDebug() << "Added " << *newNode; } unsigned NodeList::broadcastToNodes(unsigned char *broadcastData, size_t dataBytes, const char* nodeTypes, int numNodeTypes) { diff --git a/libraries/shared/src/OctalCode.cpp b/libraries/shared/src/OctalCode.cpp index 336c89093e..3b92869104 100644 --- a/libraries/shared/src/OctalCode.cpp +++ b/libraries/shared/src/OctalCode.cpp @@ -25,12 +25,12 @@ int numberOfThreeBitSectionsInCode(unsigned char * octalCode) { void printOctalCode(unsigned char * octalCode) { if (!octalCode) { - qDebug("NULL"); + qDebug("NULL\n"); } else { for (int i = 0; i < bytesRequiredForCodeLength(*octalCode); i++) { outputBits(octalCode[i],false); } - qDebug(""); + qDebug("\n"); } } diff --git a/libraries/shared/src/PacketHeaders.cpp b/libraries/shared/src/PacketHeaders.cpp index a91fd1f351..7b4a0509f3 100644 --- a/libraries/shared/src/PacketHeaders.cpp +++ b/libraries/shared/src/PacketHeaders.cpp @@ -29,7 +29,7 @@ bool packetVersionMatch(unsigned char* packetHeader) { if (packetHeader[1] == versionForPacketType(packetHeader[0])) { return true; } else { - qDebug("There is a packet version mismatch for packet with header %c", packetHeader[0]); + qDebug("There is a packet version mismatch for packet with header %c\n", packetHeader[0]); return false; } } diff --git a/libraries/shared/src/PerfStat.cpp b/libraries/shared/src/PerfStat.cpp index 344e9885e6..86985eb038 100644 --- a/libraries/shared/src/PerfStat.cpp +++ b/libraries/shared/src/PerfStat.cpp @@ -59,7 +59,7 @@ PerfStat::~PerfStat() { } if (wantDebugOut) { - qDebug("PerfStats: %s elapsed:%f average:%lf count:%ld total:%lf ut:%d us:%d ue:%d t:%ld s:%ld e:%ld", + qDebug("PerfStats: %s elapsed:%f average:%lf count:%ld total:%lf ut:%d us:%d ue:%d t:%ld s:%ld e:%ld\n", this->group.c_str(),elapsed,average,count,totalTime, (end.tv_usec-start.tv_usec),start.tv_usec,end.tv_usec, (end.tv_sec-start.tv_sec),start.tv_sec,end.tv_sec @@ -111,12 +111,12 @@ PerformanceWarning::~PerformanceWarning() { if ((_alwaysDisplay || _renderWarningsOn) && elapsedmsec > 1) { if (elapsedmsec > 1000) { double elapsedsec = (end - _start) / 1000000.0; - qDebug("%s%s took %lf seconds", (_alwaysDisplay ? "" : "WARNING!"), _message, elapsedsec); + qDebug("%s%s took %lf seconds\n", (_alwaysDisplay ? "" : "WARNING!"), _message, elapsedsec); } else { - qDebug("%s%s took %lf milliseconds", (_alwaysDisplay ? "" : "WARNING!"), _message, elapsedmsec); + qDebug("%s%s took %lf milliseconds\n", (_alwaysDisplay ? "" : "WARNING!"), _message, elapsedmsec); } } else if (_alwaysDisplay) { - qDebug("%s took %lf milliseconds", _message, elapsedmsec); + qDebug("%s took %lf milliseconds\n", _message, elapsedmsec); } }; diff --git a/libraries/shared/src/SharedUtil.cpp b/libraries/shared/src/SharedUtil.cpp index fdcf142d4d..23b889bdab 100644 --- a/libraries/shared/src/SharedUtil.cpp +++ b/libraries/shared/src/SharedUtil.cpp @@ -65,7 +65,7 @@ void outputBufferBits(unsigned char* buffer, int length, bool withNewLine) { outputBits(buffer[i], false); } if (withNewLine) { - qDebug(""); + qDebug("\n"); } } @@ -82,7 +82,7 @@ void outputBits(unsigned char byte, bool withNewLine) { qDebug(" ] "); if (withNewLine) { - qDebug(""); + qDebug("\n"); } } @@ -386,11 +386,11 @@ void printVoxelCode(unsigned char* voxelCode) { unsigned int voxelSizeInOctets = (voxelSizeInBits/3); unsigned int voxelBufferSize = voxelSizeInBytes+1+3; // 1 for size, 3 for color - qDebug("octets=%d",octets); - qDebug("voxelSizeInBits=%d",voxelSizeInBits); - qDebug("voxelSizeInBytes=%d",voxelSizeInBytes); - qDebug("voxelSizeInOctets=%d",voxelSizeInOctets); - qDebug("voxelBufferSize=%d",voxelBufferSize); + qDebug("octets=%d\n",octets); + qDebug("voxelSizeInBits=%d\n",voxelSizeInBits); + qDebug("voxelSizeInBytes=%d\n",voxelSizeInBytes); + qDebug("voxelSizeInOctets=%d\n",voxelSizeInOctets); + qDebug("voxelBufferSize=%d\n",voxelBufferSize); for(int i=0;iprintDebugDetails(); } @@ -196,7 +196,7 @@ CoverageMapStorageResult CoverageMap::checkMap(VoxelProjectedPolygon* polygon, b // not in view, then we just discard it with a DOESNT_FIT, this saves us time checking values later. if (!polygon->getAllInView()) { _notAllInView++; - //qDebug("CoverageMap2::checkMap()... V2_OCCLUDED"); + //qDebug("CoverageMap2::checkMap()... V2_OCCLUDED\n"); return DOESNT_FIT; } @@ -243,9 +243,9 @@ CoverageMapStorageResult CoverageMap::checkMap(VoxelProjectedPolygon* polygon, b /* if (result == STORED) - qDebug("CoverageMap2::checkMap()... STORED"); + qDebug("CoverageMap2::checkMap()... STORED\n"); else - qDebug("CoverageMap2::checkMap()... OCCLUDED"); + qDebug("CoverageMap2::checkMap()... OCCLUDED\n"); */ return result; @@ -268,16 +268,16 @@ CoverageMapStorageResult CoverageMap::checkMap(VoxelProjectedPolygon* polygon, b /* switch (result) { case STORED: - qDebug("checkMap() = STORED"); + qDebug("checkMap() = STORED\n"); break; case NOT_STORED: - qDebug("checkMap() = NOT_STORED"); + qDebug("checkMap() = NOT_STORED\n"); break; case OCCLUDED: - qDebug("checkMap() = OCCLUDED"); + qDebug("checkMap() = OCCLUDED\n"); break; default: - qDebug("checkMap() = ????? "); + qDebug("checkMap() = ????? \n"); break; } */ @@ -290,27 +290,27 @@ CoverageMapStorageResult CoverageMap::checkMap(VoxelProjectedPolygon* polygon, b // any of our child bounding boxes, so we should add it here. if (storeIt) { if (polygon->getBoundingBox().area() > CoverageMap::MINIMUM_POLYGON_AREA_TO_STORE) { - //qDebug("storing polygon of area: %f",polygon->getBoundingBox().area()); + //qDebug("storing polygon of area: %f\n",polygon->getBoundingBox().area()); if (storeIn->getPolygonCount() < MAX_POLYGONS_PER_REGION) { storeIn->storeInArray(polygon); - //qDebug("CoverageMap2::checkMap()... STORED"); + //qDebug("CoverageMap2::checkMap()... STORED\n"); return STORED; } else { CoverageRegion::_regionFullSkips++; - //qDebug("CoverageMap2::checkMap()... NOT_STORED"); + //qDebug("CoverageMap2::checkMap()... NOT_STORED\n"); return NOT_STORED; } } else { CoverageRegion::_tooSmallSkips++; - //qDebug("CoverageMap2::checkMap()... NOT_STORED"); + //qDebug("CoverageMap2::checkMap()... NOT_STORED\n"); return NOT_STORED; } } else { - //qDebug("CoverageMap2::checkMap()... NOT_STORED"); + //qDebug("CoverageMap2::checkMap()... NOT_STORED\n"); return NOT_STORED; } } - //qDebug("CoverageMap2::checkMap()... DOESNT_FIT"); + //qDebug("CoverageMap2::checkMap()... DOESNT_FIT\n"); return DOESNT_FIT; } @@ -341,8 +341,8 @@ void CoverageRegion::erase() { /** if (_polygonCount) { - qDebug("CoverageRegion::erase()..."); - qDebug("_polygonCount=%d",_polygonCount); + qDebug("CoverageRegion::erase()...\n"); + qDebug("_polygonCount=%d\n",_polygonCount); _myBoundingBox.printDebugDetails(getRegionName()); //for (int i = 0; i < _polygonCount; i++) { // qDebug("_polygons[%d]=",i); @@ -393,7 +393,7 @@ void CoverageRegion::growPolygonArray() { _polygonDistances = newDistances; _polygonSizes = newSizes; _polygonArraySize = _polygonArraySize + DEFAULT_GROW_SIZE; - //qDebug("CoverageMap::growPolygonArray() _polygonArraySize=%d...",_polygonArraySize); + //qDebug("CoverageMap::growPolygonArray() _polygonArraySize=%d...\n",_polygonArraySize); } const char* CoverageRegion::getRegionName() const { @@ -438,7 +438,7 @@ bool CoverageRegion::mergeItemsInArray(VoxelProjectedPolygon* seed, bool seedInA _totalPolygons--; } - //qDebug("_polygonCount=%d",_polygonCount); + //qDebug("_polygonCount=%d\n",_polygonCount); // clean up if (_managePolygons) { @@ -486,7 +486,7 @@ void CoverageRegion::storeInArray(VoxelProjectedPolygon* polygon) { // insertion point in this array, and shift the array accordingly float area = polygon->getBoundingBox().area(); float reverseArea = 4.0f - area; - //qDebug("store by size area=%f reverse area=%f", area, reverseArea); + //qDebug("store by size area=%f reverse area=%f\n", area, reverseArea); _polygonCount = insertIntoSortedArrays((void*)polygon, reverseArea, IGNORED, (void**)_polygons, _polygonSizes, IGNORED, _polygonCount, _polygonArraySize); @@ -500,10 +500,10 @@ void CoverageRegion::storeInArray(VoxelProjectedPolygon* polygon) { // Debugging and Optimization Tuning code. if (_polygonCount > _maxPolygonsUsed) { _maxPolygonsUsed = _polygonCount; - //qDebug("CoverageRegion new _maxPolygonsUsed reached=%d region=%s",_maxPolygonsUsed, getRegionName()); + //qDebug("CoverageRegion new _maxPolygonsUsed reached=%d region=%s\n",_maxPolygonsUsed, getRegionName()); //_myBoundingBox.printDebugDetails("map._myBoundingBox"); } else { - //qDebug("CoverageRegion::storeInArray() _polygonCount=%d region=%s",_polygonCount, getRegionName()); + //qDebug("CoverageRegion::storeInArray() _polygonCount=%d region=%s\n",_polygonCount, getRegionName()); } } diff --git a/libraries/voxels/src/CoverageMapV2.cpp b/libraries/voxels/src/CoverageMapV2.cpp index 9d4e92fd17..0e382d7f12 100644 --- a/libraries/voxels/src/CoverageMapV2.cpp +++ b/libraries/voxels/src/CoverageMapV2.cpp @@ -61,7 +61,7 @@ CoverageMapV2::CoverageMapV2(BoundingBox boundingBox, bool isRoot, bool isCovere { _mapCount++; init(); - //qDebug("CoverageMapV2 created... _mapCount=%d",_mapCount); + //qDebug("CoverageMapV2 created... _mapCount=%d\n",_mapCount); }; CoverageMapV2::~CoverageMapV2() { @@ -78,11 +78,11 @@ void CoverageMapV2::erase() { } if (_isRoot && wantDebugging) { - qDebug("CoverageMapV2 last to be deleted..."); - qDebug("MINIMUM_POLYGON_AREA_TO_STORE=%f",MINIMUM_POLYGON_AREA_TO_STORE); - qDebug("_mapCount=%d",_mapCount); - qDebug("_checkMapRootCalls=%d",_checkMapRootCalls); - qDebug("_notAllInView=%d",_notAllInView); + qDebug("CoverageMapV2 last to be deleted...\n"); + qDebug("MINIMUM_POLYGON_AREA_TO_STORE=%f\n",MINIMUM_POLYGON_AREA_TO_STORE); + qDebug("_mapCount=%d\n",_mapCount); + qDebug("_checkMapRootCalls=%d\n",_checkMapRootCalls); + qDebug("_notAllInView=%d\n",_notAllInView); _mapCount = 0; _checkMapRootCalls = 0; _notAllInView = 0; diff --git a/libraries/voxels/src/ViewFrustum.cpp b/libraries/voxels/src/ViewFrustum.cpp index 3a871f37b9..c13da815f8 100644 --- a/libraries/voxels/src/ViewFrustum.cpp +++ b/libraries/voxels/src/ViewFrustum.cpp @@ -322,40 +322,40 @@ bool ViewFrustum::matches(const ViewFrustum& compareTo, bool debug) const { testMatches(compareTo._eyeOffsetOrientation, _eyeOffsetOrientation); if (!result && debug) { - qDebug("ViewFrustum::matches()... result=%s", debug::valueOf(result)); - qDebug("%s -- compareTo._position=%f,%f,%f _position=%f,%f,%f", + qDebug("ViewFrustum::matches()... result=%s\n", debug::valueOf(result)); + qDebug("%s -- compareTo._position=%f,%f,%f _position=%f,%f,%f\n", (testMatches(compareTo._position,_position) ? "MATCHES " : "NO MATCH"), compareTo._position.x, compareTo._position.y, compareTo._position.z, _position.x, _position.y, _position.z ); - qDebug("%s -- compareTo._direction=%f,%f,%f _direction=%f,%f,%f", + qDebug("%s -- compareTo._direction=%f,%f,%f _direction=%f,%f,%f\n", (testMatches(compareTo._direction, _direction) ? "MATCHES " : "NO MATCH"), compareTo._direction.x, compareTo._direction.y, compareTo._direction.z, _direction.x, _direction.y, _direction.z ); - qDebug("%s -- compareTo._up=%f,%f,%f _up=%f,%f,%f", + qDebug("%s -- compareTo._up=%f,%f,%f _up=%f,%f,%f\n", (testMatches(compareTo._up, _up) ? "MATCHES " : "NO MATCH"), compareTo._up.x, compareTo._up.y, compareTo._up.z, _up.x, _up.y, _up.z ); - qDebug("%s -- compareTo._right=%f,%f,%f _right=%f,%f,%f", + qDebug("%s -- compareTo._right=%f,%f,%f _right=%f,%f,%f\n", (testMatches(compareTo._right, _right) ? "MATCHES " : "NO MATCH"), compareTo._right.x, compareTo._right.y, compareTo._right.z, _right.x, _right.y, _right.z ); - qDebug("%s -- compareTo._fieldOfView=%f _fieldOfView=%f", + qDebug("%s -- compareTo._fieldOfView=%f _fieldOfView=%f\n", (testMatches(compareTo._fieldOfView, _fieldOfView) ? "MATCHES " : "NO MATCH"), compareTo._fieldOfView, _fieldOfView); - qDebug("%s -- compareTo._aspectRatio=%f _aspectRatio=%f", + qDebug("%s -- compareTo._aspectRatio=%f _aspectRatio=%f\n", (testMatches(compareTo._aspectRatio, _aspectRatio) ? "MATCHES " : "NO MATCH"), compareTo._aspectRatio, _aspectRatio); - qDebug("%s -- compareTo._nearClip=%f _nearClip=%f", + qDebug("%s -- compareTo._nearClip=%f _nearClip=%f\n", (testMatches(compareTo._nearClip, _nearClip) ? "MATCHES " : "NO MATCH"), compareTo._nearClip, _nearClip); - qDebug("%s -- compareTo._farClip=%f _farClip=%f", + qDebug("%s -- compareTo._farClip=%f _farClip=%f\n", (testMatches(compareTo._farClip, _farClip) ? "MATCHES " : "NO MATCH"), compareTo._farClip, _farClip); - qDebug("%s -- compareTo._eyeOffsetPosition=%f,%f,%f _eyeOffsetPosition=%f,%f,%f", + qDebug("%s -- compareTo._eyeOffsetPosition=%f,%f,%f _eyeOffsetPosition=%f,%f,%f\n", (testMatches(compareTo._eyeOffsetPosition, _eyeOffsetPosition) ? "MATCHES " : "NO MATCH"), compareTo._eyeOffsetPosition.x, compareTo._eyeOffsetPosition.y, compareTo._eyeOffsetPosition.z, _eyeOffsetPosition.x, _eyeOffsetPosition.y, _eyeOffsetPosition.z); - qDebug("%s -- compareTo._eyeOffsetOrientation=%f,%f,%f,%f _eyeOffsetOrientation=%f,%f,%f,%f", + qDebug("%s -- compareTo._eyeOffsetOrientation=%f,%f,%f,%f _eyeOffsetOrientation=%f,%f,%f,%f\n", (testMatches(compareTo._eyeOffsetOrientation, _eyeOffsetOrientation) ? "MATCHES " : "NO MATCH"), compareTo._eyeOffsetOrientation.x, compareTo._eyeOffsetOrientation.y, compareTo._eyeOffsetOrientation.z, compareTo._eyeOffsetOrientation.w, @@ -418,17 +418,17 @@ void ViewFrustum::computeOffAxisFrustum(float& left, float& right, float& bottom } void ViewFrustum::printDebugDetails() const { - qDebug("ViewFrustum::printDebugDetails()... "); - qDebug("_position=%f,%f,%f", _position.x, _position.y, _position.z ); - qDebug("_direction=%f,%f,%f", _direction.x, _direction.y, _direction.z ); - qDebug("_up=%f,%f,%f", _up.x, _up.y, _up.z ); - qDebug("_right=%f,%f,%f", _right.x, _right.y, _right.z ); - qDebug("_fieldOfView=%f", _fieldOfView); - qDebug("_aspectRatio=%f", _aspectRatio); - qDebug("_nearClip=%f", _nearClip); - qDebug("_farClip=%f", _farClip); - qDebug("_eyeOffsetPosition=%f,%f,%f", _eyeOffsetPosition.x, _eyeOffsetPosition.y, _eyeOffsetPosition.z ); - qDebug("_eyeOffsetOrientation=%f,%f,%f,%f", _eyeOffsetOrientation.x, _eyeOffsetOrientation.y, _eyeOffsetOrientation.z, + qDebug("ViewFrustum::printDebugDetails()... \n"); + qDebug("_position=%f,%f,%f\n", _position.x, _position.y, _position.z ); + qDebug("_direction=%f,%f,%f\n", _direction.x, _direction.y, _direction.z ); + qDebug("_up=%f,%f,%f\n", _up.x, _up.y, _up.z ); + qDebug("_right=%f,%f,%f\n", _right.x, _right.y, _right.z ); + qDebug("_fieldOfView=%f\n", _fieldOfView); + qDebug("_aspectRatio=%f\n", _aspectRatio); + qDebug("_nearClip=%f\n", _nearClip); + qDebug("_farClip=%f\n", _farClip); + qDebug("_eyeOffsetPosition=%f,%f,%f\n", _eyeOffsetPosition.x, _eyeOffsetPosition.y, _eyeOffsetPosition.z ); + qDebug("_eyeOffsetOrientation=%f,%f,%f,%f\n", _eyeOffsetOrientation.x, _eyeOffsetOrientation.y, _eyeOffsetOrientation.z, _eyeOffsetOrientation.w ); } diff --git a/libraries/voxels/src/VoxelNode.cpp b/libraries/voxels/src/VoxelNode.cpp index e94c9756d9..76fae500dd 100644 --- a/libraries/voxels/src/VoxelNode.cpp +++ b/libraries/voxels/src/VoxelNode.cpp @@ -259,7 +259,7 @@ bool VoxelNode::collapseIdenticalLeaves() { // if no child, child isn't a leaf, or child doesn't have a color if (!_children[i] || _children[i]->isStagedForDeletion() || !_children[i]->isLeaf() || !_children[i]->isColored()) { allChildrenMatch=false; - //qDebug("SADNESS child missing or not colored! i=%d",i); + //qDebug("SADNESS child missing or not colored! i=%d\n",i); break; } else { if (i==0) { @@ -276,7 +276,7 @@ bool VoxelNode::collapseIdenticalLeaves() { if (allChildrenMatch) { - //qDebug("allChildrenMatch: pruning tree"); + //qDebug("allChildrenMatch: pruning tree\n"); for (int i = 0; i < NUMBER_OF_CHILDREN; i++) { delete _children[i]; // delete all the child nodes _children[i]=NULL; // set it to NULL @@ -310,13 +310,13 @@ void VoxelNode::printDebugDetails(const char* label) const { } } - qDebug("%s - Voxel at corner=(%f,%f,%f) size=%f\n isLeaf=%s isColored=%s (%d,%d,%d,%d) isDirty=%s shouldRender=%s children=", label, + qDebug("%s - Voxel at corner=(%f,%f,%f) size=%f\n isLeaf=%s isColored=%s (%d,%d,%d,%d) isDirty=%s shouldRender=%s\n children=", label, _box.getCorner().x, _box.getCorner().y, _box.getCorner().z, _box.getSize().x, debug::valueOf(isLeaf()), debug::valueOf(isColored()), getColor()[0], getColor()[1], getColor()[2], getColor()[3], debug::valueOf(isDirty()), debug::valueOf(getShouldRender())); outputBits(childBits, false); - qDebug(" octalCode="); + qDebug("\n octalCode="); printOctalCode(_octalCode); } diff --git a/libraries/voxels/src/VoxelProjectedPolygon.cpp b/libraries/voxels/src/VoxelProjectedPolygon.cpp index 71f43a0c04..8a39d7f358 100644 --- a/libraries/voxels/src/VoxelProjectedPolygon.cpp +++ b/libraries/voxels/src/VoxelProjectedPolygon.cpp @@ -95,7 +95,7 @@ void BoundingBox::printDebugDetails(const char* label) const { } else { qDebug("BoundingBox"); } - qDebug("\n _set=%s\n corner=%f,%f size=%f,%f\n bounds=[(%f,%f) to (%f,%f)]", + qDebug("\n _set=%s\n corner=%f,%f size=%f,%f\n bounds=[(%f,%f) to (%f,%f)]\n", debug::valueOf(_set), corner.x, corner.y, size.x, size.y, corner.x, corner.y, corner.x+size.x, corner.y+size.y); } diff --git a/libraries/voxels/src/VoxelTree.cpp b/libraries/voxels/src/VoxelTree.cpp index 62191bad2b..803bea8038 100644 --- a/libraries/voxels/src/VoxelTree.cpp +++ b/libraries/voxels/src/VoxelTree.cpp @@ -157,7 +157,7 @@ void VoxelTree::recurseNodeWithOperationDistanceSorted(VoxelNode* node, RecurseV if (childNode) { // chance to optimize, doesn't need to be actual distance!! Could be distance squared float distanceSquared = childNode->distanceSquareToPoint(point); - //qDebug("recurseNodeWithOperationDistanceSorted() CHECKING child[%d] point=%f,%f center=%f,%f distance=%f...", i, point.x, point.y, center.x, center.y, distance); + //qDebug("recurseNodeWithOperationDistanceSorted() CHECKING child[%d] point=%f,%f center=%f,%f distance=%f...\n", i, point.x, point.y, center.x, center.y, distance); //childNode->printDebugDetails(""); currentCount = insertIntoSortedArrays((void*)childNode, distanceSquared, i, (void**)&sortedChildren, (float*)&distancesToChildren, @@ -168,7 +168,7 @@ void VoxelTree::recurseNodeWithOperationDistanceSorted(VoxelNode* node, RecurseV for (int i = 0; i < currentCount; i++) { VoxelNode* childNode = sortedChildren[i]; if (childNode) { - //qDebug("recurseNodeWithOperationDistanceSorted() PROCESSING child[%d] distance=%f...", i, distancesToChildren[i]); + //qDebug("recurseNodeWithOperationDistanceSorted() PROCESSING child[%d] distance=%f...\n", i, distancesToChildren[i]); //childNode->printDebugDetails(""); recurseNodeWithOperationDistanceSorted(childNode, operation, point, extraData); } @@ -460,7 +460,7 @@ void VoxelTree::deleteVoxelCodeFromTreeRecursion(VoxelNode* node, void* extraDat // isn't a colored leaf, and the child branch doesn't exist, so there's nothing to do below and // we can safely return, ending the recursion and unwinding if (!childNode) { - //qDebug("new___deleteVoxelCodeFromTree() child branch doesn't exist, but parent is not a leaf, just unwind"); + //qDebug("new___deleteVoxelCodeFromTree() child branch doesn't exist, but parent is not a leaf, just unwind\n"); return; } @@ -548,7 +548,7 @@ void VoxelTree::readCodeColorBufferToTreeRecursion(VoxelNode* node, void* extraD } } else { if (!node->isLeaf()) { - qDebug("WARNING! operation would require deleting children, add Voxel ignored! "); + qDebug("WARNING! operation would require deleting children, add Voxel ignored!\n "); } } @@ -688,7 +688,7 @@ void VoxelTree::loadVoxelsFile(const char* fileName, bool wantColorRandomizer) { int totalBytesRead = 0; if(file.is_open()) { - qDebug("loading file..."); + qDebug("loading file...\n"); bool bail = false; while (!file.eof() && !bail) { file.get(octets); @@ -713,14 +713,14 @@ void VoxelTree::loadVoxelsFile(const char* fileName, bool wantColorRandomizer) { file.get(colorRead); blue = (unsigned char)colorRead; - qDebug("voxel color from file red:%d, green:%d, blue:%d ",red,green,blue); + qDebug("voxel color from file red:%d, green:%d, blue:%d \n",red,green,blue); vCount++; int colorRandomizer = wantColorRandomizer ? randIntInRange (-5, 5) : 0; voxelData[lengthInBytes+1] = std::max(0,std::min(255,red + colorRandomizer)); voxelData[lengthInBytes+2] = std::max(0,std::min(255,green + colorRandomizer)); voxelData[lengthInBytes+3] = std::max(0,std::min(255,blue + colorRandomizer)); - qDebug("voxel color after rand red:%d, green:%d, blue:%d", + qDebug("voxel color after rand red:%d, green:%d, blue:%d\n", voxelData[lengthInBytes+1], voxelData[lengthInBytes+2], voxelData[lengthInBytes+3]); //printVoxelCode(voxelData); @@ -821,7 +821,7 @@ void VoxelTree::createSphere(float radius, float xc, float yc, float zc, float v if (debug) { int percentComplete = 100 * (thisRadius/radius); - qDebug("percentComplete=%d",percentComplete); + qDebug("percentComplete=%d\n",percentComplete); } for (float theta=0.0; theta <= 2 * M_PI; theta += angleDelta) { @@ -837,7 +837,7 @@ void VoxelTree::createSphere(float radius, float xc, float yc, float zc, float v // 2) In all modes, we will use our "outer" color to draw the voxels. Otherwise we will use the average color if (lastLayer) { if (false && debug) { - qDebug("adding candy shell: theta=%f phi=%f thisRadius=%f radius=%f", + qDebug("adding candy shell: theta=%f phi=%f thisRadius=%f radius=%f\n", theta, phi, thisRadius,radius); } switch (mode) { @@ -861,7 +861,7 @@ void VoxelTree::createSphere(float radius, float xc, float yc, float zc, float v green = (unsigned char)std::min(255, std::max(0, (int)(g1 + ((g2 - g1) * gradient)))); blue = (unsigned char)std::min(255, std::max(0, (int)(b1 + ((b2 - b1) * gradient)))); if (debug) { - qDebug("perlin=%f gradient=%f color=(%d,%d,%d)",perlin, gradient, red, green, blue); + qDebug("perlin=%f gradient=%f color=(%d,%d,%d)\n",perlin, gradient, red, green, blue); } } break; } @@ -1178,7 +1178,7 @@ int VoxelTree::encodeTreeBitstreamRecursion(VoxelNode* node, unsigned char* outp if (childNode) { // chance to optimize, doesn't need to be actual distance!! Could be distance squared //float distanceSquared = childNode->distanceSquareToPoint(point); - //qDebug("recurseNodeWithOperationDistanceSorted() CHECKING child[%d] point=%f,%f center=%f,%f distance=%f...", i, point.x, point.y, center.x, center.y, distance); + //qDebug("recurseNodeWithOperationDistanceSorted() CHECKING child[%d] point=%f,%f center=%f,%f distance=%f...\n", i, point.x, point.y, center.x, center.y, distance); //childNode->printDebugDetails(""); float distance = params.viewFrustum ? childNode->distanceToCamera(*params.viewFrustum) : 0; @@ -1434,7 +1434,7 @@ int VoxelTree::encodeTreeBitstreamRecursion(VoxelNode* node, unsigned char* outp bool VoxelTree::readFromSVOFile(const char* fileName) { std::ifstream file(fileName, std::ios::in|std::ios::binary|std::ios::ate); if(file.is_open()) { - qDebug("loading file %s...", fileName); + qDebug("loading file %s...\n", fileName); // get file length.... unsigned long fileLength = file.tellg(); @@ -1462,14 +1462,14 @@ bool VoxelTree::readFromSchematicFile(const char *fileName) { std::stringstream ss; int err = retrieveData(fileName, ss); if (err && ss.get() != TAG_Compound) { - qDebug("[ERROR] Invalid schematic file."); + qDebug("[ERROR] Invalid schematic file.\n"); return false; } ss.get(); TagCompound schematics(ss); if (!schematics.getBlocksId() || !schematics.getBlocksData()) { - qDebug("[ERROR] Invalid schematic file."); + qDebug("[ERROR] Invalid schematic file.\n"); return false; } @@ -1532,7 +1532,7 @@ bool VoxelTree::readFromSchematicFile(const char *fileName) { } } - qDebug("Created %d voxels from minecraft import.", count); + qDebug("Created %d voxels from minecraft import.\n", count); return true; } @@ -1542,7 +1542,7 @@ void VoxelTree::writeToSVOFile(const char* fileName, VoxelNode* node) const { std::ofstream file(fileName, std::ios::out|std::ios::binary); if(file.is_open()) { - qDebug("saving to file %s...", fileName); + qDebug("saving to file %s...\n", fileName); VoxelNodeBag nodeBag; // If we were given a specific node, start from there, otherwise start from root From 16d603e203dca018679bb1bcd1465f114a1d0351 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 16 Jul 2013 12:53:43 -0700 Subject: [PATCH 15/19] clean up extra new lines and LogDisplay line break --- interface/src/Application.cpp | 3 +-- interface/src/LogDisplay.cpp | 7 +------ libraries/shared/src/Node.cpp | 2 +- libraries/shared/src/NodeList.cpp | 4 ++-- 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index e5455eb604..0b29d6714d 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -165,7 +165,7 @@ void GLCanvas::wheelEvent(QWheelEvent* event) { } void messageHandler(QtMsgType type, const char* message) { - printf("%s\n", message); + printf("%s", message); LogDisplay::instance.addMessage(message); } @@ -215,7 +215,6 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : { _applicationStartupTime = startup_time; _window->setWindowTitle("Interface"); - qDebug("Interface Startup:\n"); qInstallMsgHandler(messageHandler); diff --git a/interface/src/LogDisplay.cpp b/interface/src/LogDisplay.cpp index 49e4886b00..247ea4beb5 100644 --- a/interface/src/LogDisplay.cpp +++ b/interface/src/LogDisplay.cpp @@ -97,9 +97,8 @@ void LogDisplay::addMessage(const char* ptr) { fprintf(_stream, "%s", ptr); } - while (true) { + while (*ptr != '\0') { // process the characters - bool isEndOfMessage = (*ptr == '\0'); char c = *ptr++; if (c == '\t') { @@ -151,10 +150,6 @@ void LogDisplay::addMessage(const char* ptr) { _writeLineStartPos = _writePos; _writtenInLine = 0; } - - if (isEndOfMessage) { - break; - } } pthread_mutex_unlock(& _mutex); diff --git a/libraries/shared/src/Node.cpp b/libraries/shared/src/Node.cpp index 41936d3a99..d7cf429558 100644 --- a/libraries/shared/src/Node.cpp +++ b/libraries/shared/src/Node.cpp @@ -150,5 +150,5 @@ QDebug operator<<(QDebug debug, const Node &node) { debug << "#" << node.getNodeID() << node.getTypeName() << node.getType(); debug.nospace() << publicAddressBuffer << ":" << publicAddressPort; - return debug.space(); + return debug.nospace(); } diff --git a/libraries/shared/src/NodeList.cpp b/libraries/shared/src/NodeList.cpp index 2f811f48c2..87ee133dbb 100644 --- a/libraries/shared/src/NodeList.cpp +++ b/libraries/shared/src/NodeList.cpp @@ -420,7 +420,7 @@ void NodeList::addNodeToList(Node* newNode) { ++_numNodes; - qDebug() << "Added " << *newNode; + qDebug() << "Added" << *newNode << "\n"; } unsigned NodeList::broadcastToNodes(unsigned char *broadcastData, size_t dataBytes, const char* nodeTypes, int numNodeTypes) { @@ -475,7 +475,7 @@ void *removeSilentNodes(void *args) { if ((checkTimeUSecs - node->getLastHeardMicrostamp()) > NODE_SILENCE_THRESHOLD_USECS && node->getType() != NODE_TYPE_VOXEL_SERVER) { - qDebug() << "Killed" << *node; + qDebug() << "Killed" << *node << "\n"; node->setAlive(false); } From ce0c9e2e1a5aa67a885f4411506529dec448c9f2 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 16 Jul 2013 12:58:16 -0700 Subject: [PATCH 16/19] flush stdout in case non new-line output is received --- interface/src/Application.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 0b29d6714d..6ebb4239b4 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -166,6 +166,8 @@ void GLCanvas::wheelEvent(QWheelEvent* event) { void messageHandler(QtMsgType type, const char* message) { printf("%s", message); + fflush(stdout); + LogDisplay::instance.addMessage(message); } From e66c1ca552a840b8980db37eb978ffabd45ed990 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 16 Jul 2013 13:01:46 -0700 Subject: [PATCH 17/19] link Qt to the shared library --- libraries/shared/CMakeLists.txt | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/libraries/shared/CMakeLists.txt b/libraries/shared/CMakeLists.txt index 23f198f730..cf1c603b7d 100644 --- a/libraries/shared/CMakeLists.txt +++ b/libraries/shared/CMakeLists.txt @@ -1,14 +1,13 @@ cmake_minimum_required(VERSION 2.8) +set(ROOT_DIR ../..) +set(MACRO_DIR ${ROOT_DIR}/cmake/macros) + set(TARGET_NAME shared) project(${TARGET_NAME}) -# grab the implemenation and header files -file(GLOB HIFI_SHARED_SRCS src/*.h src/*.cpp) - -# create a library and set the property so it can be referenced later -add_library(${TARGET_NAME} ${HIFI_SHARED_SRCS}) -set(HIFI_SHARED_LIBRARY ${TARGET_NAME}) +include(${MACRO_DIR}/SetupHifiLibrary.cmake) +setup_hifi_library(${TARGET_NAME}) set(EXTERNAL_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external) From c78759da16d6e033b400328beb963620f3ff7b66 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 16 Jul 2013 13:37:16 -0700 Subject: [PATCH 18/19] cleanup printLogs reintroduce on merge with upstream master --- interface/src/Application.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 48dffccfc9..77881cd25a 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1421,12 +1421,12 @@ bool Application::sendVoxelsOperation(VoxelNode* node, void* extraData) { uint64_t elapsed = now - args->lastSendTime; int usecToSleep = CLIENT_TO_SERVER_VOXEL_SEND_INTERVAL_USECS - elapsed; if (usecToSleep > 0) { - printLog("sendVoxelsOperation: packet: %d bytes:%ld elapsed %ld usecs, sleeping for %d usecs!\n", - args->packetsSent, args->bytesSent, elapsed, usecToSleep); + qDebug("sendVoxelsOperation: packet: %d bytes:%ld elapsed %lld usecs, sleeping for %d usecs!\n", + args->packetsSent, args->bytesSent, elapsed, usecToSleep); usleep(usecToSleep); } else { - printLog("sendVoxelsOperation: packet: %d bytes:%ld elapsed %ld usecs, no need to sleep!\n", - args->packetsSent, args->bytesSent, elapsed); + qDebug("sendVoxelsOperation: packet: %d bytes:%ld elapsed %lld usecs, no need to sleep!\n", + args->packetsSent, args->bytesSent, elapsed); } args->lastSendTime = now; } @@ -1504,7 +1504,7 @@ void Application::importVoxels() { if (fileNameString.endsWith(".png", Qt::CaseInsensitive)) { QImage pngImage = QImage(fileName); if (pngImage.height() != pngImage.width()) { - printLog("ERROR: Bad PNG size: height != width.\n"); + qDebug("ERROR: Bad PNG size: height != width.\n"); return; } @@ -1609,9 +1609,9 @@ void Application::pasteVoxels() { // If we have voxels left in the packet, then send the packet if (args.bufferInUse > (numBytesPacketHeader + sizeof(unsigned short int))) { controlledBroadcastToNodes(args.messageBuffer, args.bufferInUse, & NODE_TYPE_VOXEL_SERVER, 1); - printLog("sending packet: %d\n", ++args.packetsSent); + qDebug("sending packet: %d\n", ++args.packetsSent); args.bytesSent += args.bufferInUse; - printLog("total bytes sent: %ld\n", args.bytesSent); + qDebug("total bytes sent: %ld\n", args.bytesSent); } if (calculatedOctCode) { From 8464a013fea10a54c3bf35e453665905d13b6dfb Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 16 Jul 2013 13:39:24 -0700 Subject: [PATCH 19/19] fix format string warnings in Application --- interface/src/Application.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 77881cd25a..731bf7fe0f 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1421,11 +1421,11 @@ bool Application::sendVoxelsOperation(VoxelNode* node, void* extraData) { uint64_t elapsed = now - args->lastSendTime; int usecToSleep = CLIENT_TO_SERVER_VOXEL_SEND_INTERVAL_USECS - elapsed; if (usecToSleep > 0) { - qDebug("sendVoxelsOperation: packet: %d bytes:%ld elapsed %lld usecs, sleeping for %d usecs!\n", + qDebug("sendVoxelsOperation: packet: %d bytes:%lld elapsed %lld usecs, sleeping for %d usecs!\n", args->packetsSent, args->bytesSent, elapsed, usecToSleep); usleep(usecToSleep); } else { - qDebug("sendVoxelsOperation: packet: %d bytes:%ld elapsed %lld usecs, no need to sleep!\n", + qDebug("sendVoxelsOperation: packet: %d bytes:%lld elapsed %lld usecs, no need to sleep!\n", args->packetsSent, args->bytesSent, elapsed); } args->lastSendTime = now; @@ -1611,7 +1611,7 @@ void Application::pasteVoxels() { controlledBroadcastToNodes(args.messageBuffer, args.bufferInUse, & NODE_TYPE_VOXEL_SERVER, 1); qDebug("sending packet: %d\n", ++args.packetsSent); args.bytesSent += args.bufferInUse; - qDebug("total bytes sent: %ld\n", args.bytesSent); + qDebug("total bytes sent: %lld\n", args.bytesSent); } if (calculatedOctCode) {