merge branch assignee with upstream/master

This commit is contained in:
Stephen Birarda 2013-07-16 14:41:08 -07:00
commit be32ffff77
57 changed files with 560 additions and 490 deletions

View file

@ -14,7 +14,7 @@ include_glm(${TARGET_NAME} ${ROOT_DIR})
include(${MACRO_DIR}/SetupHifiProject.cmake) include(${MACRO_DIR}/SetupHifiProject.cmake)
setup_hifi_project(${TARGET_NAME}) setup_hifi_project(${TARGET_NAME} TRUE)
# link in the shared library # link in the shared library
include(${MACRO_DIR}/LinkHifiLibrary.cmake) include(${MACRO_DIR}/LinkHifiLibrary.cmake)

View file

@ -9,7 +9,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../cmake
set(TARGET_NAME audio-mixer) set(TARGET_NAME audio-mixer)
include(${MACRO_DIR}/SetupHifiProject.cmake) include(${MACRO_DIR}/SetupHifiProject.cmake)
setup_hifi_project(${TARGET_NAME}) setup_hifi_project(${TARGET_NAME} TRUE)
# set up the external glm library # set up the external glm library
include(${MACRO_DIR}/IncludeGLM.cmake) include(${MACRO_DIR}/IncludeGLM.cmake)

View file

@ -10,7 +10,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../cmake
# setup the project # setup the project
include(${MACRO_DIR}/SetupHifiProject.cmake) include(${MACRO_DIR}/SetupHifiProject.cmake)
setup_hifi_project(${TARGET_NAME}) setup_hifi_project(${TARGET_NAME} TRUE)
# include glm # include glm
include(${MACRO_DIR}/IncludeGLM.cmake) include(${MACRO_DIR}/IncludeGLM.cmake)

View file

@ -1,9 +1,15 @@
MACRO(SETUP_HIFI_LIBRARY TARGET) MACRO(SETUP_HIFI_LIBRARY TARGET)
project(${TARGET_NAME}) project(${TARGET})
# grab the implemenation and header files # grab the implemenation and header files
file(GLOB LIB_SRCS src/*.h src/*.cpp) file(GLOB LIB_SRCS src/*.h src/*.cpp)
# create a library and set the property so it can be referenced later # 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) ENDMACRO(SETUP_HIFI_LIBRARY _target)

View file

@ -1,4 +1,4 @@
MACRO(SETUP_HIFI_PROJECT TARGET) MACRO(SETUP_HIFI_PROJECT TARGET INCLUDE_QT)
project(${TARGET}) project(${TARGET})
# grab the implemenation and header files # grab the implemenation and header files
@ -6,4 +6,12 @@ MACRO(SETUP_HIFI_PROJECT TARGET)
# add the executable # add the executable
add_executable(${TARGET} ${TARGET_SRCS}) add_executable(${TARGET} ${TARGET_SRCS})
ENDMACRO(SETUP_HIFI_PROJECT _target)
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)

View file

@ -6,7 +6,7 @@ set(MACRO_DIR ${ROOT_DIR}/cmake/macros)
set(TARGET_NAME domain-server) set(TARGET_NAME domain-server)
include(${MACRO_DIR}/SetupHifiProject.cmake) include(${MACRO_DIR}/SetupHifiProject.cmake)
setup_hifi_project(${TARGET_NAME}) setup_hifi_project(${TARGET_NAME} TRUE)
# link the shared hifi library # link the shared hifi library
include(${MACRO_DIR}/LinkHifiLibrary.cmake) include(${MACRO_DIR}/LinkHifiLibrary.cmake)

View file

@ -9,7 +9,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../cmake
set(TARGET_NAME eve) set(TARGET_NAME eve)
include(${MACRO_DIR}/SetupHifiProject.cmake) include(${MACRO_DIR}/SetupHifiProject.cmake)
setup_hifi_project(${TARGET_NAME}) setup_hifi_project(${TARGET_NAME} TRUE)
include(${MACRO_DIR}/IncludeGLM.cmake) include(${MACRO_DIR}/IncludeGLM.cmake)
include_glm(${TARGET_NAME} ${ROOT_DIR}) include_glm(${TARGET_NAME} ${ROOT_DIR})
@ -18,4 +18,4 @@ include_glm(${TARGET_NAME} ${ROOT_DIR})
include(${MACRO_DIR}/LinkHifiLibrary.cmake) include(${MACRO_DIR}/LinkHifiLibrary.cmake)
link_hifi_library(shared ${TARGET_NAME} ${ROOT_DIR}) link_hifi_library(shared ${TARGET_NAME} ${ROOT_DIR})
link_hifi_library(avatars ${TARGET_NAME} ${ROOT_DIR}) link_hifi_library(avatars ${TARGET_NAME} ${ROOT_DIR})
# link_hifi_library(audio ${TARGET_NAME} ${ROOT_DIR}) # link_hifi_library(audio ${TARGET_NAME} ${ROOT_DIR})

View file

@ -9,7 +9,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../cmake
set(TARGET_NAME injector) set(TARGET_NAME injector)
include(${MACRO_DIR}/SetupHifiProject.cmake) include(${MACRO_DIR}/SetupHifiProject.cmake)
setup_hifi_project(${TARGET_NAME}) setup_hifi_project(${TARGET_NAME} TRUE)
# set up the external glm library # set up the external glm library
include(${MACRO_DIR}/IncludeGLM.cmake) include(${MACRO_DIR}/IncludeGLM.cmake)

View file

@ -164,6 +164,13 @@ void GLCanvas::wheelEvent(QWheelEvent* event) {
Application::getInstance()->wheelEvent(event); Application::getInstance()->wheelEvent(event);
} }
void messageHandler(QtMsgType type, const char* message) {
printf("%s", message);
fflush(stdout);
LogDisplay::instance.addMessage(message);
}
Application::Application(int& argc, char** argv, timeval &startup_time) : Application::Application(int& argc, char** argv, timeval &startup_time) :
QApplication(argc, argv), QApplication(argc, argv),
_window(new QMainWindow(desktop())), _window(new QMainWindow(desktop())),
@ -210,7 +217,8 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
{ {
_applicationStartupTime = startup_time; _applicationStartupTime = startup_time;
_window->setWindowTitle("Interface"); _window->setWindowTitle("Interface");
printLog("Interface Startup:\n");
qInstallMsgHandler(messageHandler);
unsigned int listenPort = 0; // bind to an ephemeral port by default unsigned int listenPort = 0; // bind to an ephemeral port by default
const char** constArgv = const_cast<const char**>(argv); const char** constArgv = const_cast<const char**>(argv);
@ -233,7 +241,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
// Handle Local Domain testing with the --local command line // Handle Local Domain testing with the --local command line
if (cmdOptionExists(argc, constArgv, "--local")) { if (cmdOptionExists(argc, constArgv, "--local")) {
printLog("Local Domain MODE!\n"); qDebug("Local Domain MODE!\n");
NodeList::getInstance()->setDomainIPToLocalhost(); NodeList::getInstance()->setDomainIPToLocalhost();
} }
@ -297,7 +305,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
} }
void Application::initializeGL() { 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 // initialize glut for shape drawing; Qt apparently initializes it on OS X
#ifndef __APPLE__ #ifndef __APPLE__
@ -312,10 +320,10 @@ void Application::initializeGL() {
_viewFrustumOffsetCamera.setFarClip(500.0 * TREE_SCALE); _viewFrustumOffsetCamera.setFarClip(500.0 * TREE_SCALE);
initDisplay(); initDisplay();
printLog( "Initialized Display.\n" ); qDebug( "Initialized Display.\n" );
init(); init();
printLog( "Init() complete.\n" ); qDebug( "Init() complete.\n" );
// Check to see if the user passed in a command line option for randomizing colors // Check to see if the user passed in a command line option for randomizing colors
bool wantColorRandomizer = !arguments().contains("--NoColorRandomizer"); bool wantColorRandomizer = !arguments().contains("--NoColorRandomizer");
@ -324,13 +332,13 @@ void Application::initializeGL() {
// Voxel File. If so, load it now. // Voxel File. If so, load it now.
if (!_voxelsFilename.isEmpty()) { if (!_voxelsFilename.isEmpty()) {
_voxels.loadVoxelsFile(_voxelsFilename.constData(), wantColorRandomizer); _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 // create thread for receipt of data via UDP
if (_enableNetworkThread) { if (_enableNetworkThread) {
pthread_create(&_networkReceiveThread, NULL, networkReceive, NULL); pthread_create(&_networkReceiveThread, NULL, networkReceive, NULL);
printLog("Network receive thread created.\n"); qDebug("Network receive thread created.\n");
} }
// call terminate before exiting // call terminate before exiting
@ -352,7 +360,7 @@ void Application::initializeGL() {
_justStarted = false; _justStarted = false;
char title[50]; char title[50];
sprintf(title, "Interface: %4.2f seconds\n", startupTime); sprintf(title, "Interface: %4.2f seconds\n", startupTime);
printLog("%s", title); qDebug("%s", title);
_window->setWindowTitle(title); _window->setWindowTitle(title);
const char LOGSTASH_INTERFACE_START_TIME_KEY[] = "interface-start-time"; const char LOGSTASH_INTERFACE_START_TIME_KEY[] = "interface-start-time";
@ -1363,7 +1371,9 @@ struct SendVoxelsOperationArgs {
unsigned char* newBaseOctCode; unsigned char* newBaseOctCode;
unsigned char messageBuffer[MAXIMUM_EDIT_VOXEL_MESSAGE_SIZE]; unsigned char messageBuffer[MAXIMUM_EDIT_VOXEL_MESSAGE_SIZE];
int bufferInUse; int bufferInUse;
uint64_t lastSendTime;
int packetsSent;
uint64_t bytesSent;
}; };
bool Application::sendVoxelsOperation(VoxelNode* node, void* extraData) { bool Application::sendVoxelsOperation(VoxelNode* node, void* extraData) {
@ -1395,17 +1405,30 @@ bool Application::sendVoxelsOperation(VoxelNode* node, void* extraData) {
codeColorBuffer[bytesInCode + GREEN_INDEX] = node->getColor()[GREEN_INDEX]; codeColorBuffer[bytesInCode + GREEN_INDEX] = node->getColor()[GREEN_INDEX];
codeColorBuffer[bytesInCode + BLUE_INDEX ] = node->getColor()[BLUE_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 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) { 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); controlledBroadcastToNodes(args->messageBuffer, args->bufferInUse, & NODE_TYPE_VOXEL_SERVER, 1);
args->bufferInUse = numBytesForPacketHeader((unsigned char*) &PACKET_TYPE_SET_VOXEL_DESTRUCTIVE) args->bufferInUse = numBytesForPacketHeader((unsigned char*) &PACKET_TYPE_SET_VOXEL_DESTRUCTIVE)
+ sizeof(unsigned short int); // reset + 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) {
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:%lld elapsed %lld usecs, no need to sleep!\n",
args->packetsSent, args->bytesSent, elapsed);
}
args->lastSendTime = now;
} }
// copy this node's code color details into our buffer. // copy this node's code color details into our buffer.
@ -1434,19 +1457,54 @@ void Application::exportVoxels() {
_window->activateWindow(); _window->activateWindow();
} }
void Application::importVoxels() { 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 desktopLocation = QDesktopServices::storageLocation(QDesktopServices::DesktopLocation);
QString fileNameString = QFileDialog::getOpenFileName( QString fileNameString = QFileDialog::getOpenFileName(_glWidget, tr("Import Voxels to Clipboard"), desktopLocation,
_glWidget, tr("Import Voxels"), desktopLocation, tr(IMPORT_FILE_TYPES));
tr("Sparse Voxel Octree Files, Square PNG, Schematic Files (*.svo *.png *.schematic)"));
const char* fileName = fileNameString.toAscii().data();
QByteArray fileNameAscii = fileNameString.toAscii();
const char* fileName = fileNameAscii.data();
_clipboardTree.eraseAllVoxels(); _clipboardTree.eraseAllVoxels();
if (fileNameString.endsWith(".png", Qt::CaseInsensitive)) { if (fileNameString.endsWith(".png", Qt::CaseInsensitive)) {
QImage pngImage = QImage(fileName); QImage pngImage = QImage(fileName);
if (pngImage.height() != pngImage.width()) { if (pngImage.height() != pngImage.width()) {
printLog("ERROR: Bad PNG size: height != width.\n"); qDebug("ERROR: Bad PNG size: height != width.\n");
return;
}
const uint32_t* pixels;
if (pngImage.format() == QImage::Format_ARGB32) {
pixels = reinterpret_cast<const uint32_t*>(pngImage.constBits());
} else {
QImage tmp = pngImage.convertToFormat(QImage::Format_ARGB32);
pixels = reinterpret_cast<const uint32_t*>(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(_glWidget, tr("Import Voxels"), desktopLocation,
tr(IMPORT_FILE_TYPES));
QByteArray fileNameAscii = fileNameString.toAscii();
const char* fileName = fileNameAscii.data();
VoxelTree importVoxels;
if (fileNameString.endsWith(".png", Qt::CaseInsensitive)) {
QImage pngImage = QImage(fileName);
if (pngImage.height() != pngImage.width()) {
qDebug("ERROR: Bad PNG size: height != width.\n");
return; return;
} }
@ -1458,11 +1516,46 @@ void Application::importVoxels() {
pixels = reinterpret_cast<const uint32_t*>(tmp.constBits()); pixels = reinterpret_cast<const uint32_t*>(tmp.constBits());
} }
_clipboardTree.readFromSquareARGB32Pixels(pixels, pngImage.height()); importVoxels.readFromSquareARGB32Pixels(pixels, pngImage.height());
} else if (fileNameString.endsWith(".svo", Qt::CaseInsensitive)) { } else if (fileNameString.endsWith(".svo", Qt::CaseInsensitive)) {
_clipboardTree.readFromSVOFile(fileName); importVoxels.readFromSVOFile(fileName);
} else if (fileNameString.endsWith(".schematic", Qt::CaseInsensitive)) { } else if (fileNameString.endsWith(".schematic", Qt::CaseInsensitive)) {
_clipboardTree.readFromSchematicFile(fileName); importVoxels.readFromSchematicFile(fileName);
}
VoxelNode* selectedNode = _voxels.getVoxelAt(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z, _mouseVoxel.s);
// Recurse the Import Voxels 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
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);
unsigned short int* sequenceAt = (unsigned short int*)&args.messageBuffer[numBytesPacketHeader];
*sequenceAt = 0;
args.bufferInUse = numBytesPacketHeader + sizeof(unsigned short int); // set to command + sequence
// we only need the selected voxel to get the newBaseOctCode, which we can actually calculate from the
// voxel size/position details.
if (selectedNode) {
args.newBaseOctCode = selectedNode->getOctalCode();
} else {
args.newBaseOctCode = calculatedOctCode = pointToVoxel(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z, _mouseVoxel.s);
}
importVoxels.recurseTreeWithOperation(sendVoxelsOperation, &args);
// 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);
}
if (calculatedOctCode) {
delete[] calculatedOctCode;
} }
// restore the main window's active state // restore the main window's active state
@ -1492,6 +1585,9 @@ void Application::pasteVoxels() {
// Recurse the clipboard tree, where everything is root relative, and send all the colored voxels to // 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 // the server as an set voxel message, this will also rebase the voxels to the new location
SendVoxelsOperationArgs args; SendVoxelsOperationArgs args;
args.lastSendTime = usecTimestampNow();
args.packetsSent = 0;
args.bytesSent = 0;
int numBytesPacketHeader = populateTypeAndVersion(args.messageBuffer, PACKET_TYPE_SET_VOXEL_DESTRUCTIVE); int numBytesPacketHeader = populateTypeAndVersion(args.messageBuffer, PACKET_TYPE_SET_VOXEL_DESTRUCTIVE);
@ -1513,6 +1609,9 @@ void Application::pasteVoxels() {
// If we have voxels left in the packet, then send the packet // If we have voxels left in the packet, then send the packet
if (args.bufferInUse > (numBytesPacketHeader + sizeof(unsigned short int))) { if (args.bufferInUse > (numBytesPacketHeader + sizeof(unsigned short int))) {
controlledBroadcastToNodes(args.messageBuffer, args.bufferInUse, & NODE_TYPE_VOXEL_SERVER, 1); 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: %lld\n", args.bytesSent);
} }
if (calculatedOctCode) { if (calculatedOctCode) {
@ -1578,8 +1677,8 @@ void Application::initMenu() {
"First Person", this, SLOT(setRenderFirstPerson(bool)), Qt::Key_P))->setCheckable(true); "First Person", this, SLOT(setRenderFirstPerson(bool)), Qt::Key_P))->setCheckable(true);
(_manualThirdPerson = renderMenu->addAction( (_manualThirdPerson = renderMenu->addAction(
"Third Person", this, SLOT(setRenderThirdPerson(bool))))->setCheckable(true); "Third Person", this, SLOT(setRenderThirdPerson(bool))))->setCheckable(true);
renderMenu->addAction("Increase Avatar Size", this, SLOT(increaseAvatarSize()), Qt::SHIFT | Qt::Key_Plus); renderMenu->addAction("Increase Avatar Size", this, SLOT(increaseAvatarSize()), Qt::ALT | Qt::Key_Plus);
renderMenu->addAction("Decrease Avatar Size", this, SLOT(decreaseAvatarSize()), Qt::SHIFT | Qt::Key_Minus); renderMenu->addAction("Decrease Avatar Size", this, SLOT(decreaseAvatarSize()), Qt::ALT | Qt::Key_Minus);
QMenu* toolsMenu = menuBar->addMenu("Tools"); QMenu* toolsMenu = menuBar->addMenu("Tools");
@ -1630,6 +1729,7 @@ void Application::initMenu() {
voxelMenu->addAction("Export Voxels", this, SLOT(exportVoxels()), Qt::CTRL | Qt::Key_E); 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", 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("Cut Voxels", this, SLOT(cutVoxels()), Qt::CTRL | Qt::Key_X);
voxelMenu->addAction("Copy Voxels", this, SLOT(copyVoxels()), Qt::CTRL | Qt::Key_C); voxelMenu->addAction("Copy Voxels", this, SLOT(copyVoxels()), Qt::CTRL | Qt::Key_C);
voxelMenu->addAction("Paste Voxels", this, SLOT(pasteVoxels()), Qt::CTRL | Qt::Key_V); voxelMenu->addAction("Paste Voxels", this, SLOT(pasteVoxels()), Qt::CTRL | Qt::Key_V);
@ -1758,7 +1858,7 @@ void Application::init() {
_audio.setJitterBufferSamples(_audioJitterBufferSamples); _audio.setJitterBufferSamples(_audioJitterBufferSamples);
} }
printLog("Loaded settings.\n"); qDebug("Loaded settings.\n");
sendAvatarVoxelURLMessage(_myAvatar.getVoxels()->getVoxelURL()); sendAvatarVoxelURLMessage(_myAvatar.getVoxels()->getVoxelURL());
@ -2771,7 +2871,7 @@ glm::vec2 Application::getScaledScreenPoint(glm::vec2 projectedPoint) {
// render the coverage map on screen // render the coverage map on screen
void Application::renderCoverageMapV2() { void Application::renderCoverageMapV2() {
//printLog("renderCoverageMap()\n"); //qDebug("renderCoverageMap()\n");
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
glLineWidth(2.0); glLineWidth(2.0);
@ -2816,7 +2916,7 @@ void Application::renderCoverageMapsV2Recursively(CoverageMapV2* map) {
// render the coverage map on screen // render the coverage map on screen
void Application::renderCoverageMap() { void Application::renderCoverageMap() {
//printLog("renderCoverageMap()\n"); //qDebug("renderCoverageMap()\n");
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
glLineWidth(2.0); glLineWidth(2.0);
@ -3147,7 +3247,7 @@ void Application::eyedropperVoxelUnderCursor() {
} }
void Application::goHome() { void Application::goHome() {
printLog("Going Home!\n"); qDebug("Going Home!\n");
_myAvatar.setPosition(START_LOCATION); _myAvatar.setPosition(START_LOCATION);
} }

View file

@ -21,27 +21,28 @@
#include <NodeList.h> #include <NodeList.h>
#include "BandwidthMeter.h"
#include "ui/BandwidthDialog.h"
#ifndef _WIN32 #ifndef _WIN32
#include "Audio.h" #include "Audio.h"
#endif #endif
#include "Avatar.h"
#include "BandwidthMeter.h"
#include "Camera.h" #include "Camera.h"
#include "Environment.h" #include "Environment.h"
#include "HandControl.h" #include "HandControl.h"
#include "PacketHeaders.h"
#include "ParticleSystem.h"
#include "renderer/GeometryCache.h"
#include "SerialInterface.h" #include "SerialInterface.h"
#include "Stars.h" #include "Stars.h"
#include "Swatch.h"
#include "ToolsPalette.h"
#include "ui/ChatEntry.h"
#include "ui/BandwidthDialog.h"
#include "ViewFrustum.h" #include "ViewFrustum.h"
#include "VoxelSystem.h" #include "VoxelSystem.h"
#include "PacketHeaders.h"
#include "Webcam.h" #include "Webcam.h"
#include "renderer/GeometryCache.h"
#include "ui/ChatEntry.h"
#include "ToolsPalette.h"
#include "Swatch.h"
#include "ParticleSystem.h"
class QAction; class QAction;
class QActionGroup; class QActionGroup;
@ -154,6 +155,7 @@ private slots:
void exportSettings(); void exportSettings();
void exportVoxels(); void exportVoxels();
void importVoxels(); void importVoxels();
void importVoxelsToClipboard();
void cutVoxels(); void cutVoxels();
void copyVoxels(); void copyVoxels();
void pasteVoxels(); void pasteVoxels();

View file

@ -7,24 +7,25 @@
// //
#ifndef _WIN32 #ifndef _WIN32
#include <iostream> #include <cstring>
#include <fstream> #include <fstream>
#include <iostream>
#include <pthread.h> #include <pthread.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <cstring>
#include <StdDev.h>
#include <UDPSocket.h> #include <AngleUtil.h>
#include <SharedUtil.h>
#include <PacketHeaders.h>
#include <NodeList.h> #include <NodeList.h>
#include <NodeTypes.h> #include <NodeTypes.h>
#include <AngleUtil.h> #include <PacketHeaders.h>
#include <SharedUtil.h>
#include <StdDev.h>
#include <UDPSocket.h>
#include "Application.h" #include "Application.h"
#include "Audio.h" #include "Audio.h"
#include "Util.h" #include "Util.h"
#include "Log.h"
// Uncomment the following definition to test audio device latency by copying output to input // Uncomment the following definition to test audio device latency by copying output to input
//#define TEST_AUDIO_LOOPBACK //#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 // If not enough audio has arrived to start playback, keep waiting
// //
#ifdef SHOW_AUDIO_DEBUG #ifdef SHOW_AUDIO_DEBUG
printLog("%i,%i,%i,%i\n", qDebug("%i,%i,%i,%i\n",
_packetsReceivedThisPlayback, _packetsReceivedThisPlayback,
ringBuffer->diffLastWriteNextOutput(), ringBuffer->diffLastWriteNextOutput(),
PACKET_LENGTH_SAMPLES, PACKET_LENGTH_SAMPLES,
@ -168,7 +169,7 @@ inline void Audio::performIO(int16_t* inputLeft, int16_t* outputLeft, int16_t* o
_packetsReceivedThisPlayback = 0; _packetsReceivedThisPlayback = 0;
_wasStarved = 10; // Frames for which to render the indication that the system was starved. _wasStarved = 10; // Frames for which to render the indication that the system was starved.
#ifdef SHOW_AUDIO_DEBUG #ifdef SHOW_AUDIO_DEBUG
printLog("Starved, remaining samples = %d\n", qDebug("Starved, remaining samples = %d\n",
ringBuffer->diffLastWriteNextOutput()); ringBuffer->diffLastWriteNextOutput());
#endif #endif
@ -179,7 +180,7 @@ inline void Audio::performIO(int16_t* inputLeft, int16_t* outputLeft, int16_t* o
if (!ringBuffer->isStarted()) { if (!ringBuffer->isStarted()) {
ringBuffer->setStarted(true); ringBuffer->setStarted(true);
#ifdef SHOW_AUDIO_DEBUG #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, (usecTimestampNow() - usecTimestamp(&_firstPacketReceivedTime))/1000.0,
_jitterBufferSamples, _jitterBufferSamples,
_packetsReceivedThisPlayback); _packetsReceivedThisPlayback);
@ -299,8 +300,8 @@ int Audio::audioCallback (const void* inputBuffer,
static void outputPortAudioError(PaError error) { static void outputPortAudioError(PaError error) {
if (error != paNoError) { if (error != paNoError) {
printLog("-- portaudio termination error --\n"); qDebug("-- portaudio termination error --\n");
printLog("PortAudio error (%d): %s\n", error, Pa_GetErrorText(error)); 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(); outputParameters.device = Pa_GetDefaultOutputDevice();
if (inputParameters.device == -1 || outputParameters.device == -1) { if (inputParameters.device == -1 || outputParameters.device == -1) {
printLog("Audio: Missing device.\n"); qDebug("Audio: Missing device.\n");
outputPortAudioError(Pa_Terminate()); outputPortAudioError(Pa_Terminate());
return; return;
} }
@ -384,12 +385,12 @@ Audio::Audio(Oscilloscope* scope, int16_t initialJitterBufferSamples) :
outputPortAudioError(Pa_StartStream(_stream)); outputPortAudioError(Pa_StartStream(_stream));
// Uncomment these lines to see the system-reported latency // 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_GetDefaultInputDevice())->defaultLowInputLatency,
// Pa_GetDeviceInfo(Pa_GetDefaultOutputDevice())->defaultLowOutputLatency); // Pa_GetDeviceInfo(Pa_GetDefaultOutputDevice())->defaultLowOutputLatency);
const PaStreamInfo* streamInfo = Pa_GetStreamInfo(_stream); 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); streamInfo->outputLatency * 1000.f);
gettimeofday(&_lastReceiveTime, NULL); 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 // 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). // the mic (pointless to start now as we can't record unsent audio).
_isSendingEchoPing = false; _isSendingEchoPing = false;
printLog("Send audio ping\n"); qDebug("Send audio ping\n");
} else if (_pingFramesToRecord > 0) { } else if (_pingFramesToRecord > 0) {
@ -664,7 +665,7 @@ inline void Audio::eventuallySendRecvPing(int16_t* inputLeft, int16_t* outputLef
if (_pingFramesToRecord == 0) { if (_pingFramesToRecord == 0) {
_pingAnalysisPending = true; _pingAnalysisPending = true;
printLog("Received ping echo\n"); qDebug("Received ping echo\n");
} }
} }
} }
@ -688,25 +689,25 @@ inline void Audio::analyzePing() {
// Determine extrema // Determine extrema
int botAt = findExtremum(_echoSamplesLeft, PING_SAMPLES_TO_ANALYZE, -1); int botAt = findExtremum(_echoSamplesLeft, PING_SAMPLES_TO_ANALYZE, -1);
if (botAt == -1) { if (botAt == -1) {
printLog("Audio Ping: Minimum not found.\n"); qDebug("Audio Ping: Minimum not found.\n");
return; return;
} }
int topAt = findExtremum(_echoSamplesLeft, PING_SAMPLES_TO_ANALYZE, 1); int topAt = findExtremum(_echoSamplesLeft, PING_SAMPLES_TO_ANALYZE, 1);
if (topAt == -1) { if (topAt == -1) {
printLog("Audio Ping: Maximum not found.\n"); qDebug("Audio Ping: Maximum not found.\n");
return; return;
} }
// Determine peak amplitude - warn if low // Determine peak amplitude - warn if low
int ampli = (_echoSamplesLeft[topAt] - _echoSamplesLeft[botAt]) / 2; int ampli = (_echoSamplesLeft[topAt] - _echoSamplesLeft[botAt]) / 2;
if (ampli < PING_MIN_AMPLI) { 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 // Determine period - warn if doesn't look like our signal
int halfPeriod = abs(topAt - botAt); int halfPeriod = abs(topAt - botAt);
if (abs(halfPeriod-PING_HALF_PERIOD) > PING_MAX_PERIOD_DIFFERENCE) { 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: // Ping is sent:
@ -747,7 +748,7 @@ inline void Audio::analyzePing() {
int delay = (botAt + topAt) / 2 + PING_PERIOD; 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 = %d samples (%d ms)\nPeak amplitude = %d\n\n",
delay, (delay * 1000) / int(SAMPLE_RATE), ampli); delay, (delay * 1000) / int(SAMPLE_RATE), ampli);
} }

View file

@ -14,7 +14,6 @@
#include <StdDev.h> #include <StdDev.h>
#include "Oscilloscope.h" #include "Oscilloscope.h"
#include "Avatar.h"
static const int NUM_AUDIO_CHANNELS = 2; static const int NUM_AUDIO_CHANNELS = 2;

View file

@ -5,24 +5,25 @@
// Created by Philip Rosedale on 9/11/12. // Created by Philip Rosedale on 9/11/12.
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. // Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
#include <vector>
#include <glm/glm.hpp> #include <glm/glm.hpp>
#include <glm/gtx/quaternion.hpp> #include <glm/gtx/quaternion.hpp>
#include <glm/gtx/vector_angle.hpp> #include <glm/gtx/vector_angle.hpp>
#include <vector>
#include <NodeList.h>
#include <NodeTypes.h>
#include <OculusManager.h>
#include <PacketHeaders.h>
#include <SharedUtil.h> #include <SharedUtil.h>
#include "world.h"
#include "Application.h" #include "Application.h"
#include "Avatar.h" #include "Avatar.h"
#include "Hand.h" #include "Hand.h"
#include "Head.h" #include "Head.h"
#include "Log.h"
#include "Physics.h" #include "Physics.h"
#include "world.h"
#include "ui/TextRenderer.h" #include "ui/TextRenderer.h"
#include <NodeList.h>
#include <NodeTypes.h>
#include <PacketHeaders.h>
#include <OculusManager.h>
using namespace std; using namespace std;
@ -1047,7 +1048,7 @@ void Avatar::render(bool lookingInMirror, bool renderAvatarBalls) {
} }
glPushMatrix(); 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); glTranslatef(chatPosition.x, chatPosition.y, chatPosition.z);
glm::quat chatRotation = Application::getInstance()->getCamera()->getRotation(); glm::quat chatRotation = Application::getInstance()->getCamera()->getRotation();
glm::vec3 chatAxis = glm::axis(chatRotation); glm::vec3 chatAxis = glm::axis(chatRotation);
@ -1057,7 +1058,7 @@ void Avatar::render(bool lookingInMirror, bool renderAvatarBalls) {
glColor3f(0, 0.8, 0); glColor3f(0, 0.8, 0);
glRotatef(180, 0, 1, 0); glRotatef(180, 0, 1, 0);
glRotatef(180, 0, 0, 1); glRotatef(180, 0, 0, 1);
glScalef(chatMessageScale, chatMessageScale, 1.0f); glScalef(_scale * chatMessageScale, _scale * chatMessageScale, 1.0f);
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
glDepthMask(false); glDepthMask(false);
@ -1321,7 +1322,11 @@ void Avatar::loadData(QSettings* settings) {
_voxels.setVoxelURL(settings->value("voxelURL").toUrl()); _voxels.setVoxelURL(settings->value("voxelURL").toUrl());
_leanScale = loadSetting(settings, "leanScale", 0.5f); _leanScale = loadSetting(settings, "leanScale", 0.5f);
_scale = loadSetting(settings, "scale", 1.0f);
setScale(_scale);
Application::getInstance()->getCamera()->setScale(_scale);
settings->endGroup(); settings->endGroup();
} }
@ -1344,6 +1349,7 @@ void Avatar::saveData(QSettings* set) {
set->setValue("voxelURL", _voxels.getVoxelURL()); set->setValue("voxelURL", _voxels.getVoxelURL());
set->setValue("leanScale", _leanScale); set->setValue("leanScale", _leanScale);
set->setValue("scale", _scale);
set->endGroup(); set->endGroup();
} }

View file

@ -10,18 +10,21 @@
#include <glm/glm.hpp> #include <glm/glm.hpp>
#include <glm/gtc/quaternion.hpp> #include <glm/gtc/quaternion.hpp>
#include <AvatarData.h>
#include <QSettings> #include <QSettings>
#include "world.h"
#include <AvatarData.h>
#include "AvatarTouch.h" #include "AvatarTouch.h"
#include "AvatarVoxelSystem.h" #include "AvatarVoxelSystem.h"
#include "InterfaceConfig.h"
#include "SerialInterface.h"
#include "Balls.h" #include "Balls.h"
#include "Hand.h" #include "Hand.h"
#include "Head.h" #include "Head.h"
#include "InterfaceConfig.h"
#include "Skeleton.h" #include "Skeleton.h"
#include "SerialInterface.h"
#include "Transmitter.h" #include "Transmitter.h"
#include "world.h"
const float BODY_BALL_RADIUS_PELVIS = 0.07; const float BODY_BALL_RADIUS_PELVIS = 0.07;
const float BODY_BALL_RADIUS_TORSO = 0.065; const float BODY_BALL_RADIUS_TORSO = 0.065;

View file

@ -93,7 +93,7 @@ const Mode MODES[] = {
void AvatarVoxelSystem::cycleMode() { void AvatarVoxelSystem::cycleMode() {
_mode = (_mode + 1) % (sizeof(MODES) / sizeof(MODES[0])); _mode = (_mode + 1) % (sizeof(MODES) / sizeof(MODES[0]));
printLog("Voxeltar bind mode %d.\n", _mode); qDebug("Voxeltar bind mode %d.\n", _mode);
// rebind // rebind
QUrl url = _voxelURL; QUrl url = _voxelURL;
@ -255,7 +255,7 @@ void AvatarVoxelSystem::handleVoxelDownloadProgress(qint64 bytesReceived, qint64
} }
void AvatarVoxelSystem::handleVoxelReplyError() { void AvatarVoxelSystem::handleVoxelReplyError() {
printLog("%s\n", _voxelReply->errorString().toAscii().constData()); qDebug("%s\n", _voxelReply->errorString().toAscii().constData());
_voxelReply->disconnect(this); _voxelReply->disconnect(this);
_voxelReply->deleteLater(); _voxelReply->deleteLater();

View file

@ -9,7 +9,6 @@
#include "BandwidthMeter.h" #include "BandwidthMeter.h"
#include "InterfaceConfig.h" #include "InterfaceConfig.h"
#include "Log.h"
#include "Util.h" #include "Util.h"
namespace { // .cpp-local namespace { // .cpp-local

View file

@ -5,9 +5,10 @@
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. // Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
#include <glm/gtx/quaternion.hpp> #include <glm/gtx/quaternion.hpp>
#include <SharedUtil.h> #include <SharedUtil.h>
#include <VoxelConstants.h> #include <VoxelConstants.h>
#include "Log.h"
#include "Camera.h" #include "Camera.h"
#include "Util.h" #include "Util.h"

View file

@ -15,7 +15,7 @@
#include "Util.h" #include "Util.h"
using namespace std; using namespace std;
FILE* const LogDisplay::DEFAULT_STREAM = stdout; FILE* const LogDisplay::DEFAULT_STREAM = 0l;
// //
// Singleton constructor // Singleton constructor
@ -26,9 +26,7 @@ LogDisplay LogDisplay::instance;
// State management // State management
// //
LogDisplay::LogDisplay() : LogDisplay::LogDisplay() :
_textRenderer(SANS_FONT_FAMILY, -1, -1, false, TextRenderer::SHADOW_EFFECT), _textRenderer(SANS_FONT_FAMILY, -1, -1, false, TextRenderer::SHADOW_EFFECT),
_stream(DEFAULT_STREAM), _stream(DEFAULT_STREAM),
_chars(0l), _chars(0l),
@ -53,8 +51,6 @@ LogDisplay::LogDisplay() :
memset(_lines, 0, LINE_BUFFER_SIZE * sizeof(char*)); memset(_lines, 0, LINE_BUFFER_SIZE * sizeof(char*));
setCharacterSize(DEFAULT_CHAR_WIDTH, DEFAULT_CHAR_HEIGHT); setCharacterSize(DEFAULT_CHAR_WIDTH, DEFAULT_CHAR_HEIGHT);
printLog = & printLogHandler;
} }
@ -92,32 +88,7 @@ void LogDisplay::setCharacterSize(unsigned width, unsigned height) {
// Logging // Logging
// //
int LogDisplay::printLogHandler(char const* fmt, ...) { void LogDisplay::addMessage(const char* ptr) {
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); pthread_mutex_lock(& _mutex);

View file

@ -12,7 +12,6 @@
#include <stdarg.h> #include <stdarg.h>
#include <pthread.h> #include <pthread.h>
#include "Log.h"
#include "ui/TextRenderer.h" #include "ui/TextRenderer.h"
class LogDisplay { class LogDisplay {
@ -21,6 +20,9 @@ public:
static LogDisplay instance; static LogDisplay instance;
void render(unsigned screenWidth, unsigned screenHeight); void render(unsigned screenWidth, unsigned screenHeight);
// log formatted message
void addMessage(const char* message);
// settings // settings
@ -50,12 +52,6 @@ private:
LogDisplay(LogDisplay const&); // = delete; LogDisplay(LogDisplay const&); // = delete;
LogDisplay& operator=(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; TextRenderer _textRenderer;
FILE* _stream; // FILE as secondary destination for log messages FILE* _stream; // FILE as secondary destination for log messages
char* _chars; // character buffer base address char* _chars; // character buffer base address

View file

@ -36,6 +36,28 @@ const int LONG_TERM_RATE_SAMPLES = 1000;
const bool USING_INVENSENSE_MPU9150 = 1; 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() { void SerialInterface::pair() {
#ifndef _WIN32 #ifndef _WIN32
@ -75,10 +97,10 @@ void SerialInterface::initializePort(char* portname) {
#ifndef _WIN32 #ifndef _WIN32
_serialDescriptor = open(portname, O_RDWR | O_NOCTTY | O_NDELAY); _serialDescriptor = open(portname, O_RDWR | O_NOCTTY | O_NDELAY);
printLog("Opening SerialUSB %s: ", portname); qDebug("Opening SerialUSB %s: ", portname);
if (_serialDescriptor == -1) { if (_serialDescriptor == -1) {
printLog("Failed.\n"); qDebug("Failed.\n");
return; return;
} }
@ -112,7 +134,7 @@ void SerialInterface::initializePort(char* portname) {
mpu_set_sensors(INV_XYZ_GYRO | INV_XYZ_ACCEL | INV_XYZ_COMPASS); mpu_set_sensors(INV_XYZ_GYRO | INV_XYZ_ACCEL | INV_XYZ_COMPASS);
} }
printLog("Connected.\n"); qDebug("Connected.\n");
resetSerial(); resetSerial();
_active = true; _active = true;
@ -351,7 +373,7 @@ void SerialInterface::readData(float deltaTime) {
gettimeofday(&now, NULL); gettimeofday(&now, NULL);
if (diffclock(&lastGoodRead, &now) > NO_READ_MAXIMUM_MSECS) { if (diffclock(&lastGoodRead, &now) > NO_READ_MAXIMUM_MSECS) {
printLog("No data - Shutting down SerialInterface.\n"); qDebug("No data - Shutting down SerialInterface.\n");
resetSerial(); resetSerial();
} }
} else { } else {

View file

@ -1,17 +1,14 @@
// //
// SerialInterface.h // SerialInterface.h
// // hifi
//
// Created by Stephen Birarda on 2/15/13.
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
//
#ifndef __interface__SerialInterface__ #ifndef __interface__SerialInterface__
#define __interface__SerialInterface__ #define __interface__SerialInterface__
#include <glm/glm.hpp>
#include "Util.h"
#include "world.h"
#include "InterfaceConfig.h"
#include "Log.h"
// These includes are for serial port reading/writing // These includes are for serial port reading/writing
#ifndef _WIN32 #ifndef _WIN32
#include <unistd.h> #include <unistd.h>
@ -20,30 +17,16 @@
#include <dirent.h> #include <dirent.h>
#endif #endif
#include <glm/glm.hpp>
#include "InterfaceConfig.h"
#include "Util.h"
extern const bool USING_INVENSENSE_MPU9150; extern const bool USING_INVENSENSE_MPU9150;
class SerialInterface { class SerialInterface {
public: public:
SerialInterface() : _active(false), SerialInterface();
_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 pair(); void pair();
void readData(float deltaTime); void readData(float deltaTime);

View file

@ -13,11 +13,9 @@
#include <PacketHeaders.h> #include <PacketHeaders.h>
#include "InterfaceConfig.h" #include "InterfaceConfig.h"
#include "Log.h"
#include "Transmitter.h" #include "Transmitter.h"
#include "Util.h" #include "Util.h"
const float DELTA_TIME = 1.f / 60.f; const float DELTA_TIME = 1.f / 60.f;
const float DECAY_RATE = 0.15f; const float DECAY_RATE = 0.15f;
@ -40,7 +38,7 @@ void Transmitter::checkForLostTransmitter() {
int msecsSinceLast = diffclock(_lastReceivedPacket, &now); int msecsSinceLast = diffclock(_lastReceivedPacket, &now);
if (msecsSinceLast > TIME_TO_ASSUME_LOST_MSECS) { if (msecsSinceLast > TIME_TO_ASSUME_LOST_MSECS) {
resetLevels(); 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); _estimatedRotation.y *= (1.f - DECAY_RATE * DELTA_TIME);
if (!_isConnected) { if (!_isConnected) {
printLog("Transmitter Connected.\n"); qDebug("Transmitter Connected.\n");
_isConnected = true; _isConnected = true;
_estimatedRotation *= 0.0; _estimatedRotation *= 0.0;
} }
} else { } else {
printLog("Transmitter packet read error, %d bytes.\n", numBytes); qDebug("Transmitter packet read error, %d bytes.\n", numBytes);
} }
} }

View file

@ -6,7 +6,6 @@
// Copyright (c) 2012 High Fidelity, Inc. All rights reserved. // Copyright (c) 2012 High Fidelity, Inc. All rights reserved.
// //
#include "InterfaceConfig.h"
#include <iostream> #include <iostream>
#include <cstring> #include <cstring>
#include <time.h> #include <time.h>
@ -15,16 +14,16 @@
#include <glm/glm.hpp> #include <glm/glm.hpp>
#include <glm/gtc/noise.hpp> #include <glm/gtc/noise.hpp>
#include <glm/gtx/quaternion.hpp> #include <glm/gtx/quaternion.hpp>
#include <AvatarData.h> #include <AvatarData.h>
#include <SharedUtil.h> #include <SharedUtil.h>
#include "Log.h" #include "InterfaceConfig.h"
#include "ui/TextRenderer.h" #include "ui/TextRenderer.h"
#include "world.h"
#include "Util.h"
#include "VoxelConstants.h" #include "VoxelConstants.h"
#include "world.h"
#include "Util.h"
using namespace std; using namespace std;
@ -452,7 +451,7 @@ void renderOrientationDirections(glm::vec3 position, const glm::quat& orientatio
bool closeEnoughForGovernmentWork(float a, float b) { bool closeEnoughForGovernmentWork(float a, float b) {
float distance = std::abs(a-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); return (distance < 0.00001f);
} }
@ -470,7 +469,7 @@ void runTimingTests() {
gettimeofday(&endTime, NULL); gettimeofday(&endTime, NULL);
} }
elapsedMsecs = diffclock(&startTime, &endTime); 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 // Random number generation
gettimeofday(&startTime, NULL); gettimeofday(&startTime, NULL);
@ -479,7 +478,7 @@ void runTimingTests() {
} }
gettimeofday(&endTime, NULL); gettimeofday(&endTime, NULL);
elapsedMsecs = diffclock(&startTime, &endTime); 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() // Random number generation using randFloat()
gettimeofday(&startTime, NULL); gettimeofday(&startTime, NULL);
@ -488,7 +487,7 @@ void runTimingTests() {
} }
gettimeofday(&endTime, NULL); gettimeofday(&endTime, NULL);
elapsedMsecs = diffclock(&startTime, &endTime); 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 // PowF function
fTest = 1145323.2342f; fTest = 1145323.2342f;
@ -498,7 +497,7 @@ void runTimingTests() {
} }
gettimeofday(&endTime, NULL); gettimeofday(&endTime, NULL);
elapsedMsecs = diffclock(&startTime, &endTime); 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 // Vector Math
float distance; float distance;
@ -511,7 +510,7 @@ void runTimingTests() {
} }
gettimeofday(&endTime, NULL); gettimeofday(&endTime, NULL);
elapsedMsecs = diffclock(&startTime, &endTime); 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); 1000.0f * elapsedMsecs / (float) numTests, elapsedMsecs, numTests);
// Vec3 test // Vec3 test
@ -525,7 +524,7 @@ void runTimingTests() {
} }
gettimeofday(&endTime, NULL); gettimeofday(&endTime, NULL);
elapsedMsecs = diffclock(&startTime, &endTime); 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);
} }

View file

@ -5,28 +5,31 @@
// Created by Philip on 12/31/12. // Created by Philip on 12/31/12.
// Copyright (c) 2012 High Fidelity, Inc. All rights reserved. // Copyright (c) 2012 High Fidelity, Inc. All rights reserved.
// //
#ifdef _WIN32 #ifdef _WIN32
#define _timeval_ #define _timeval_
#define _USE_MATH_DEFINES #define _USE_MATH_DEFINES
#endif #endif
#include <cstring> #include <cstring>
#include <cmath> #include <cmath>
#include <iostream> // to load voxels from file #include <iostream> // to load voxels from file
#include <fstream> // to load voxels from file #include <fstream> // to load voxels from file
#include <pthread.h>
#include <glm/gtc/random.hpp> #include <glm/gtc/random.hpp>
#include <SharedUtil.h>
#include <OctalCode.h>
#include <PacketHeaders.h> #include <PacketHeaders.h>
#include <PerfStat.h> #include <PerfStat.h>
#include <OctalCode.h> #include <SharedUtil.h>
#include <pthread.h>
#include "Application.h" #include "Application.h"
#include "Log.h"
#include "VoxelConstants.h"
#include "CoverageMap.h" #include "CoverageMap.h"
#include "CoverageMapV2.h" #include "CoverageMapV2.h"
#include "InterfaceConfig.h" #include "InterfaceConfig.h"
#include "renderer/ProgramObject.h" #include "renderer/ProgramObject.h"
#include "VoxelConstants.h"
#include "VoxelSystem.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, 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 commandLength = strlen(command); // commands are null terminated strings
int totalLength = 1+commandLength+1; 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) { while (totalLength <= numBytes) {
if (0==strcmp(command,(char*)"erase all")) { if (0==strcmp(command,(char*)"erase all")) {
printLog("got Z message == erase all\n"); qDebug("got Z message == erase all\n");
_tree->eraseAllVoxels(); _tree->eraseAllVoxels();
_voxelsInReadArrays = _voxelsInWriteArrays = 0; // better way to do this?? _voxelsInReadArrays = _voxelsInWriteArrays = 0; // better way to do this??
} }
if (0==strcmp(command,(char*)"add scene")) { 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; totalLength += commandLength+1;
} }
@ -705,7 +708,7 @@ bool VoxelSystem::randomColorOperation(VoxelNode* node, void* extraData) {
void VoxelSystem::randomizeVoxelColors() { void VoxelSystem::randomizeVoxelColors() {
_nodeCount = 0; _nodeCount = 0;
_tree->recurseTreeWithOperation(randomColorOperation); _tree->recurseTreeWithOperation(randomColorOperation);
printLog("setting randomized true color for %d nodes\n", _nodeCount); qDebug("setting randomized true color for %d nodes\n", _nodeCount);
setupNewVoxelsForDrawing(); setupNewVoxelsForDrawing();
} }
@ -719,7 +722,7 @@ bool VoxelSystem::falseColorizeRandomOperation(VoxelNode* node, void* extraData)
void VoxelSystem::falseColorizeRandom() { void VoxelSystem::falseColorizeRandom() {
_nodeCount = 0; _nodeCount = 0;
_tree->recurseTreeWithOperation(falseColorizeRandomOperation); _tree->recurseTreeWithOperation(falseColorizeRandomOperation);
printLog("setting randomized false color for %d nodes\n", _nodeCount); qDebug("setting randomized false color for %d nodes\n", _nodeCount);
setupNewVoxelsForDrawing(); setupNewVoxelsForDrawing();
} }
@ -733,7 +736,7 @@ void VoxelSystem::trueColorize() {
PerformanceWarning warn(true, "trueColorize()",true); PerformanceWarning warn(true, "trueColorize()",true);
_nodeCount = 0; _nodeCount = 0;
_tree->recurseTreeWithOperation(trueColorizeOperation); _tree->recurseTreeWithOperation(trueColorizeOperation);
printLog("setting true color for %d nodes\n", _nodeCount); qDebug("setting true color for %d nodes\n", _nodeCount);
setupNewVoxelsForDrawing(); setupNewVoxelsForDrawing();
} }
@ -753,7 +756,7 @@ bool VoxelSystem::falseColorizeInViewOperation(VoxelNode* node, void* extraData)
void VoxelSystem::falseColorizeInView(ViewFrustum* viewFrustum) { void VoxelSystem::falseColorizeInView(ViewFrustum* viewFrustum) {
_nodeCount = 0; _nodeCount = 0;
_tree->recurseTreeWithOperation(falseColorizeInViewOperation,(void*)viewFrustum); _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(); setupNewVoxelsForDrawing();
} }
@ -803,10 +806,10 @@ void VoxelSystem::falseColorizeDistanceFromView(ViewFrustum* viewFrustum) {
_maxDistance = 0.0; _maxDistance = 0.0;
_minDistance = FLT_MAX; _minDistance = FLT_MAX;
_tree->recurseTreeWithOperation(getDistanceFromViewRangeOperation,(void*)viewFrustum); _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; _nodeCount = 0;
_tree->recurseTreeWithOperation(falseColorizeDistanceFromViewOperation,(void*)viewFrustum); _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(); setupNewVoxelsForDrawing();
} }
@ -918,7 +921,7 @@ void VoxelSystem::removeOutOfView() {
} }
bool showRemoveDebugDetails = false; bool showRemoveDebugDetails = false;
if (showRemoveDebugDetails) { 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.nodesScanned, args.nodesRemoved, args.nodesInside,
args.nodesIntersect, args.nodesOutside, _removedVoxels.count() args.nodesIntersect, args.nodesOutside, _removedVoxels.count()
); );
@ -984,7 +987,7 @@ bool VoxelSystem::falseColorizeRandomEveryOtherOperation(VoxelNode* node, void*
void VoxelSystem::falseColorizeRandomEveryOther() { void VoxelSystem::falseColorizeRandomEveryOther() {
falseColorizeRandomEveryOtherArgs args; falseColorizeRandomEveryOtherArgs args;
_tree->recurseTreeWithOperation(falseColorizeRandomEveryOtherOperation,&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); args.totalNodes, args.colorableNodes, args.coloredNodes);
setupNewVoxelsForDrawing(); setupNewVoxelsForDrawing();
} }
@ -1045,7 +1048,7 @@ bool VoxelSystem::collectStatsForTreesAndVBOsOperation(VoxelNode* node, void* ex
unsigned long nodeIndex = node->getBufferIndex(); unsigned long nodeIndex = node->getBufferIndex();
if (args->hasIndexFound[nodeIndex]) { if (args->hasIndexFound[nodeIndex]) {
args->duplicateVBOIndex++; 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())); debug::valueOf(node->isDirty()), debug::valueOf(node->getShouldRender()));
} else { } else {
args->hasIndexFound[nodeIndex] = true; args->hasIndexFound[nodeIndex] = true;
@ -1080,13 +1083,13 @@ void VoxelSystem::collectStatsForTreesAndVBOs() {
args.expectedMax = _voxelsInWriteArrays; args.expectedMax = _voxelsInWriteArrays;
_tree->recurseTreeWithOperation(collectStatsForTreesAndVBOsOperation,&args); _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); 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); _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); args.nodesInVBO, args.nodesInVBOOverExpectedMax, args.duplicateVBOIndex, args.nodesInVBONotShouldRender);
glBufferIndex minInVBO = GLBUFFER_INDEX_UNKNOWN; 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); 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) { unsigned char red, unsigned char green, unsigned char blue, bool destructive) {
pthread_mutex_lock(&_treeLock); 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); _tree->createVoxel(x, y, z, s, red, green, blue, destructive);
setupNewVoxelsForDrawing(); setupNewVoxelsForDrawing();
@ -1250,9 +1253,9 @@ bool VoxelSystem::falseColorizeOccludedOperation(VoxelNode* node, void* extraDat
args->occludedVoxels++; args->occludedVoxels++;
} else if (result == STORED) { } else if (result == STORED) {
args->notOccludedVoxels++; args->notOccludedVoxels++;
//printLog("***** falseColorizeOccludedOperation() NODE is STORED *****\n"); //qDebug("***** falseColorizeOccludedOperation() NODE is STORED *****\n");
} else if (result == DOESNT_FIT) { } else if (result == DOESNT_FIT) {
//printLog("***** falseColorizeOccludedOperation() NODE DOESNT_FIT???? *****\n"); //qDebug("***** falseColorizeOccludedOperation() NODE DOESNT_FIT???? *****\n");
} }
} }
return true; // keep going! return true; // keep going!
@ -1285,7 +1288,7 @@ void VoxelSystem::falseColorizeOccluded() {
_tree->recurseTreeWithOperationDistanceSorted(falseColorizeOccludedOperation, position, (void*)&args); _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, position.x, position.y,
args.totalVoxels, args.coloredVoxels, args.occludedVoxels, args.totalVoxels, args.coloredVoxels, args.occludedVoxels,
args.notOccludedVoxels, args.outOfView, args.subtreeVoxelsSkipped, args.notOccludedVoxels, args.outOfView, args.subtreeVoxelsSkipped,
@ -1371,9 +1374,9 @@ bool VoxelSystem::falseColorizeOccludedV2Operation(VoxelNode* node, void* extraD
args->occludedVoxels++; args->occludedVoxels++;
} else if (result == V2_STORED) { } else if (result == V2_STORED) {
args->notOccludedVoxels++; args->notOccludedVoxels++;
//printLog("***** falseColorizeOccludedOperation() NODE is STORED *****\n"); //qDebug("***** falseColorizeOccludedOperation() NODE is STORED *****\n");
} else if (result == V2_DOESNT_FIT) { } 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 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); _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, position.x, position.y,
args.totalVoxels, args.coloredVoxels, args.occludedVoxels, args.totalVoxels, args.coloredVoxels, args.occludedVoxels,
args.notOccludedVoxels, args.outOfView, args.subtreeVoxelsSkipped, args.notOccludedVoxels, args.outOfView, args.subtreeVoxelsSkipped,

View file

@ -8,7 +8,6 @@
#include <QTimer> #include <QTimer>
#include <QtDebug> #include <QtDebug>
#include <Log.h>
#include <SharedUtil.h> #include <SharedUtil.h>
#ifdef __APPLE__ #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, glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, _frameWidth = image.width, _frameHeight = image.height, 0, format,
GL_UNSIGNED_BYTE, image.imageData); GL_UNSIGNED_BYTE, image.imageData);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 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 { } else {
glBindTexture(GL_TEXTURE_2D, _frameTextureID); 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, glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, _depthWidth = depthImage.width, _depthHeight = depthImage.height, 0,
GL_LUMINANCE, GL_UNSIGNED_BYTE, depthImage.imageData); GL_LUMINANCE, GL_UNSIGNED_BYTE, depthImage.imageData);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 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 { } else {
glBindTexture(GL_TEXTURE_2D, _depthTextureID); 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) { 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); generator.GetSkeletonCap().RequestCalibration(id, false);
} }
static void XN_CALLBACK_TYPE lostUser(UserGenerator& generator, XnUserID id, void* cookie) { 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) { 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, static void XN_CALLBACK_TYPE calibrationCompleted(SkeletonCapability& capability,
XnUserID id, XnCalibrationStatus status, void* cookie) { XnUserID id, XnCalibrationStatus status, void* cookie) {
if (status == XN_CALIBRATION_STATUS_OK) { 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); capability.StartTracking(id);
} else { } else {
printLog("Calibration failed to user %d.\n", id); qDebug("Calibration failed to user %d.\n", id);
capability.RequestCalibration(id, true); capability.RequestCalibration(id, true);
} }
} }
@ -439,7 +438,7 @@ void FrameGrabber::grabFrame() {
// make sure it's in the format we expect // make sure it's in the format we expect
if (image->nChannels != 3 || image->depth != IPL_DEPTH_8U || image->dataOrder != IPL_DATA_ORDER_PIXEL || if (image->nChannels != 3 || image->depth != IPL_DEPTH_8U || image->dataOrder != IPL_DATA_ORDER_PIXEL ||
image->origin != 0) { image->origin != 0) {
printLog("Invalid webcam image format.\n"); qDebug("Invalid webcam image format.\n");
return; return;
} }
frame = image; frame = image;
@ -486,7 +485,7 @@ bool FrameGrabber::init() {
// load our face cascade // load our face cascade
switchToResourcesParentIfRequired(); switchToResourcesParentIfRequired();
if (_faceCascade.empty() && !_faceCascade.load("resources/haarcascades/haarcascade_frontalface_alt.xml")) { 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; return false;
} }
@ -514,7 +513,7 @@ bool FrameGrabber::init() {
// next, an ordinary webcam // next, an ordinary webcam
if ((_capture = cvCaptureFromCAM(-1)) == 0) { if ((_capture = cvCaptureFromCAM(-1)) == 0) {
printLog("Failed to open webcam.\n"); qDebug("Failed to open webcam.\n");
return false; return false;
} }
const int IDEAL_FRAME_WIDTH = 320; const int IDEAL_FRAME_WIDTH = 320;

View file

@ -16,15 +16,16 @@
// //
#include "Application.h" #include "Application.h"
#include "Log.h"
#include <QDebug>
int main(int argc, const char * argv[]) { int main(int argc, const char * argv[]) {
timeval startup_time; timeval startup_time;
gettimeofday(&startup_time, NULL); gettimeofday(&startup_time, NULL);
Application app(argc, const_cast<char**>(argv), startup_time); Application app(argc, const_cast<char**>(argv), startup_time);
printLog( "Created QT Application.\n" ); qDebug( "Created QT Application.\n" );
int exitCode = app.exec(); int exitCode = app.exec();
printLog("Normal exit.\n"); qDebug("Normal exit.\n");
return exitCode; return exitCode;
} }

View file

@ -39,7 +39,6 @@
#include "InterfaceConfig.h" #include "InterfaceConfig.h"
#include "renderer/ProgramObject.h" #include "renderer/ProgramObject.h"
#include "Log.h"
#include <cstddef> #include <cstddef>
#include <cfloat> #include <cfloat>

View file

@ -38,12 +38,12 @@ namespace starfield {
if (! UrlReader::readUrl(url, *this, cacheFile)) if (! UrlReader::readUrl(url, *this, cacheFile))
{ {
printLog("%s:%d: %s\n", qDebug("%s:%d: %s\n",
_urlStr, _lineNo, getError()); _urlStr, _lineNo, getError());
return false; return false;
} }
printLog("Loaded %u stars.\n", _recordsRead); qDebug("Loaded %u stars.\n", _recordsRead);
return true; return true;
} }
@ -63,7 +63,7 @@ namespace starfield {
_vertices->clear(); _vertices->clear();
_vertices->reserve(_limit); _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) { size_t transfer(char* input, size_t bytes) {
@ -103,7 +103,7 @@ namespace starfield {
} else { } else {
printLog("Stars.cpp:%d: Bad input from %s\n", qDebug("Stars.cpp:%d: Bad input from %s\n",
_lineNo, _urlStr); _lineNo, _urlStr);
} }
@ -128,7 +128,7 @@ namespace starfield {
// remember the brightness at its top // remember the brightness at its top
if (_recordsRead == _limit) { if (_recordsRead == _limit) {
// printLog("Stars.cpp: vertex limit reached -> heap mode\n"); // qDebug("Stars.cpp: vertex limit reached -> heap mode\n");
make_heap( make_heap(
_vertices->begin(), _vertices->end(), _vertices->begin(), _vertices->end(),

View file

@ -509,6 +509,8 @@ namespace starfield {
_program.release(); _program.release();
glDisable(GL_VERTEX_PROGRAM_POINT_SIZE); glDisable(GL_VERTEX_PROGRAM_POINT_SIZE);
glDisable(GL_POINT_SMOOTH); glDisable(GL_POINT_SMOOTH);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
glPopMatrix(); glPopMatrix();
} }

View file

@ -7,8 +7,6 @@
#include <QPalette> #include <QPalette>
#include <QColor> #include <QColor>
#include "Log.h"
BandwidthDialog::BandwidthDialog(QWidget* parent, BandwidthMeter* model) : BandwidthDialog::BandwidthDialog(QWidget* parent, BandwidthMeter* model) :
QDialog(parent, Qt::Window | Qt::WindowCloseButtonHint | Qt::WindowStaysOnTopHint), QDialog(parent, Qt::Window | Qt::WindowCloseButtonHint | Qt::WindowStaysOnTopHint),
_model(model) { _model(model) {

View file

@ -3,18 +3,11 @@ cmake_minimum_required(VERSION 2.8)
set(ROOT_DIR ../..) set(ROOT_DIR ../..)
set(MACRO_DIR ${ROOT_DIR}/cmake/macros) set(MACRO_DIR ${ROOT_DIR}/cmake/macros)
# setup for find modules
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/")
set(TARGET_NAME shared) set(TARGET_NAME shared)
project(${TARGET_NAME}) project(${TARGET_NAME})
# grab the implemenation and header files include(${MACRO_DIR}/SetupHifiLibrary.cmake)
file(GLOB HIFI_SHARED_SRCS src/*.h src/*.cpp) setup_hifi_library(${TARGET_NAME})
# 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})
set(EXTERNAL_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external) set(EXTERNAL_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external)
@ -35,4 +28,4 @@ endif (UNIX AND NOT APPLE)
# include GLM # include GLM
include(${MACRO_DIR}/IncludeGLM.cmake) include(${MACRO_DIR}/IncludeGLM.cmake)
include_glm(${TARGET_NAME} ${ROOT_DIR}) include_glm(${TARGET_NAME} ${ROOT_DIR})

View file

@ -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 <cstdio>
using namespace std;
int (* printLog)(char const*, ...) = & printf;

View file

@ -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__) */

View file

@ -6,15 +6,9 @@
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. // Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
// //
#include "stdio.h"
#include <pthread.h>
#include "Node.h"
#include "NodeTypes.h"
#include <cstring> #include <cstring>
#include "Log.h" #include <pthread.h>
#include "UDPSocket.h" #include <stdio.h>
#include "SharedUtil.h"
#ifdef _WIN32 #ifdef _WIN32
#include "Syssocket.h" #include "Syssocket.h"
@ -22,6 +16,13 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#endif #endif
#include "Node.h"
#include "NodeTypes.h"
#include "SharedUtil.h"
#include "UDPSocket.h"
#include <QDebug>
int unpackNodeId(unsigned char* packedData, uint16_t* nodeId) { int unpackNodeId(unsigned char* packedData, uint16_t* nodeId) {
memcpy(nodeId, packedData, sizeof(uint16_t)); memcpy(nodeId, packedData, sizeof(uint16_t));
return sizeof(uint16_t); return sizeof(uint16_t);
@ -143,18 +144,14 @@ float Node::getAverageKilobitsPerSecond() {
} }
} }
void Node::printLog(Node const& node) { QDebug operator<<(QDebug debug, const Node &node) {
char publicAddressBuffer[16] = {'\0'}; char publicAddressBuffer[16] = {'\0'};
unsigned short publicAddressPort = loadBufferWithSocketInfo(publicAddressBuffer, node._publicSocket); unsigned short publicAddressPort = loadBufferWithSocketInfo(publicAddressBuffer, node.getPublicSocket());
//char localAddressBuffer[16] = {'\0'}; //char localAddressBuffer[16] = {'\0'};
//unsigned short localAddressPort = loadBufferWithSocketInfo(localAddressBuffer, node.localSocket); //unsigned short localAddressPort = loadBufferWithSocketInfo(localAddressBuffer, node.localSocket);
::printLog("# %d %s (%c) @ %s:%d\n", debug << "#" << node.getNodeID() << node.getTypeName() << node.getType();
node._nodeID, debug.nospace() << publicAddressBuffer << ":" << publicAddressPort;
node.getTypeName(), return debug.nospace();
node._type,
publicAddressBuffer,
publicAddressPort);
} }

View file

@ -9,8 +9,8 @@
#ifndef __hifi__Node__ #ifndef __hifi__Node__
#define __hifi__Node__ #define __hifi__Node__
#include <stdint.h>
#include <ostream> #include <ostream>
#include <stdint.h>
#ifdef _WIN32 #ifdef _WIN32
#include "Syssocket.h" #include "Syssocket.h"
@ -18,8 +18,10 @@
#include <sys/socket.h> #include <sys/socket.h>
#endif #endif
#include "SimpleMovingAverage.h" #include <QDebug>
#include "NodeData.h" #include "NodeData.h"
#include "SimpleMovingAverage.h"
class Node { class Node {
public: public:
@ -89,8 +91,9 @@ private:
pthread_mutex_t _mutex; pthread_mutex_t _mutex;
}; };
int unpackNodeId(unsigned char *packedData, uint16_t *nodeId); int unpackNodeId(unsigned char *packedData, uint16_t *nodeId);
int packNodeId(unsigned char *packStore, uint16_t nodeId); int packNodeId(unsigned char *packStore, uint16_t nodeId);
QDebug operator<<(QDebug debug, const Node &message);
#endif /* defined(__hifi__Node__) */ #endif /* defined(__hifi__Node__) */

View file

@ -11,11 +11,12 @@
#include <cstdlib> #include <cstdlib>
#include <cstdio> #include <cstdio>
#include <QDebug>
#include "NodeList.h" #include "NodeList.h"
#include "NodeTypes.h" #include "NodeTypes.h"
#include "PacketHeaders.h" #include "PacketHeaders.h"
#include "SharedUtil.h" #include "SharedUtil.h"
#include "Log.h"
#ifdef _WIN32 #ifdef _WIN32
#include "Syssocket.h" #include "Syssocket.h"
@ -42,7 +43,7 @@ NodeList* NodeList::createInstance(char ownerType, unsigned int socketListenPort
if (!_sharedInstance) { if (!_sharedInstance) {
_sharedInstance = new NodeList(ownerType, socketListenPort); _sharedInstance = new NodeList(ownerType, socketListenPort);
} else { } else {
printLog("NodeList createInstance called with existing instance.\n"); qDebug("NodeList createInstance called with existing instance.\n");
} }
return _sharedInstance; return _sharedInstance;
@ -50,7 +51,7 @@ NodeList* NodeList::createInstance(char ownerType, unsigned int socketListenPort
NodeList* NodeList::getInstance() { NodeList* NodeList::getInstance() {
if (!_sharedInstance) { 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; return _sharedInstance;
@ -274,12 +275,13 @@ void NodeList::sendDomainServerCheckIn() {
sockaddr_in tempAddress; sockaddr_in tempAddress;
memcpy(&tempAddress.sin_addr, pHostInfo->h_addr_list[0], pHostInfo->h_length); memcpy(&tempAddress.sin_addr, pHostInfo->h_addr_list[0], pHostInfo->h_length);
strcpy(_domainIP, inet_ntoa(tempAddress.sin_addr)); strcpy(_domainIP, inet_ntoa(tempAddress.sin_addr));
printLog("Domain Server: %s \n", _domainHostname);
qDebug("Domain Server: %s\n", _domainHostname);
} else { } else {
printLog("Failed domain server lookup\n"); qDebug("Failed domain server lookup\n");
} }
} else if (!printedDomainServerIP) { } else if (!printedDomainServerIP) {
printLog("Domain Server IP: %s\n", _domainIP); qDebug("Domain Server IP: %s\n", _domainIP);
printedDomainServerIP = true; printedDomainServerIP = true;
} }
@ -428,8 +430,7 @@ void NodeList::addNodeToList(Node* newNode) {
++_numNodes; ++_numNodes;
printLog("Added "); qDebug() << "Added" << *newNode << "\n";
Node::printLog(*newNode);
} }
unsigned NodeList::broadcastToNodes(unsigned char *broadcastData, size_t dataBytes, const char* nodeTypes, int numNodeTypes) { unsigned NodeList::broadcastToNodes(unsigned char *broadcastData, size_t dataBytes, const char* nodeTypes, int numNodeTypes) {
@ -484,8 +485,7 @@ void *removeSilentNodes(void *args) {
if ((checkTimeUSecs - node->getLastHeardMicrostamp()) > NODE_SILENCE_THRESHOLD_USECS if ((checkTimeUSecs - node->getLastHeardMicrostamp()) > NODE_SILENCE_THRESHOLD_USECS
&& node->getType() != NODE_TYPE_VOXEL_SERVER) { && node->getType() != NODE_TYPE_VOXEL_SERVER) {
printLog("Killed "); qDebug() << "Killed" << *node << "\n";
Node::printLog(*node);
node->setAlive(false); node->setAlive(false);
} }

View file

@ -6,12 +6,14 @@
// Copyright (c) 2013 HighFidelity, Inc. All rights reserved. // Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
// //
#include <cmath>
#include <algorithm> // std:min #include <algorithm> // std:min
#include <cmath>
#include <cstring> #include <cstring>
#include <QDebug>
#include "SharedUtil.h" #include "SharedUtil.h"
#include "OctalCode.h" #include "OctalCode.h"
#include "Log.h"
int numberOfThreeBitSectionsInCode(unsigned char * octalCode) { int numberOfThreeBitSectionsInCode(unsigned char * octalCode) {
if (*octalCode == 255) { if (*octalCode == 255) {
@ -23,12 +25,12 @@ int numberOfThreeBitSectionsInCode(unsigned char * octalCode) {
void printOctalCode(unsigned char * octalCode) { void printOctalCode(unsigned char * octalCode) {
if (!octalCode) { if (!octalCode) {
printLog("NULL\n"); qDebug("NULL\n");
} else { } else {
for (int i = 0; i < bytesRequiredForCodeLength(*octalCode); i++) { for (int i = 0; i < bytesRequiredForCodeLength(*octalCode); i++) {
outputBits(octalCode[i],false); outputBits(octalCode[i],false);
} }
printLog("\n"); qDebug("\n");
} }
} }

View file

@ -8,8 +8,9 @@
#include <stdio.h> #include <stdio.h>
#include <QDebug>
#include "PacketHeaders.h" #include "PacketHeaders.h"
#include "Log.h"
PACKET_VERSION versionForPacketType(PACKET_TYPE type) { PACKET_VERSION versionForPacketType(PACKET_TYPE type) {
switch (type) { switch (type) {
@ -28,7 +29,7 @@ bool packetVersionMatch(unsigned char* packetHeader) {
if (packetHeader[1] == versionForPacketType(packetHeader[0])) { if (packetHeader[1] == versionForPacketType(packetHeader[0])) {
return true; return true;
} else { } 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; return false;
} }
} }

View file

@ -10,12 +10,13 @@
// //
// //
#include "PerfStat.h"
#include <cstdio> #include <cstdio>
#include <string>
#include <map> #include <map>
#include <string>
#include "Log.h" #include <QDebug>
#include "PerfStat.h"
// Static class members initialization here! // Static class members initialization here!
std::map<std::string,PerfStatHistory,std::less<std::string> > PerfStat::groupHistoryMap; std::map<std::string,PerfStatHistory,std::less<std::string> > PerfStat::groupHistoryMap;
@ -58,11 +59,11 @@ PerfStat::~PerfStat() {
} }
if (wantDebugOut) { 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", 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, this->group.c_str(),elapsed,average,count,totalTime,
(end.tv_usec-start.tv_usec),start.tv_usec,end.tv_usec, (end.tv_usec-start.tv_usec),start.tv_usec,end.tv_usec,
(end.tv_sec-start.tv_sec),start.tv_sec,end.tv_sec (end.tv_sec-start.tv_sec),start.tv_sec,end.tv_sec
); );
} }
}; };
@ -110,12 +111,12 @@ PerformanceWarning::~PerformanceWarning() {
if ((_alwaysDisplay || _renderWarningsOn) && elapsedmsec > 1) { if ((_alwaysDisplay || _renderWarningsOn) && elapsedmsec > 1) {
if (elapsedmsec > 1000) { if (elapsedmsec > 1000) {
double elapsedsec = (end - _start) / 1000000.0; 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 { } 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) { } else if (_alwaysDisplay) {
printLog("%s took %lf milliseconds\n", _message, elapsedmsec); qDebug("%s took %lf milliseconds\n", _message, elapsedmsec);
} }
}; };

View file

@ -20,7 +20,8 @@
#include <CoreFoundation/CoreFoundation.h> #include <CoreFoundation/CoreFoundation.h>
#endif #endif
#include "Log.h" #include <QDebug>
#include "OctalCode.h" #include "OctalCode.h"
#include "PacketHeaders.h" #include "PacketHeaders.h"
#include "SharedUtil.h" #include "SharedUtil.h"
@ -64,24 +65,24 @@ void outputBufferBits(unsigned char* buffer, int length, bool withNewLine) {
outputBits(buffer[i], false); outputBits(buffer[i], false);
} }
if (withNewLine) { if (withNewLine) {
printLog("\n"); qDebug("\n");
} }
} }
void outputBits(unsigned char byte, bool withNewLine) { void outputBits(unsigned char byte, bool withNewLine) {
if (isalnum(byte)) { if (isalnum(byte)) {
printLog("[ %d (%c): ", byte, byte); qDebug("[ %d (%c): ", byte, byte);
} else { } else {
printLog("[ %d (0x%x): ", byte, byte); qDebug("[ %d (0x%x): ", byte, byte);
} }
for (int i = 0; i < 8; i++) { for (int i = 0; i < 8; i++) {
printLog("%d", byte >> (7 - i) & 1); qDebug("%d", byte >> (7 - i) & 1);
} }
printLog(" ] "); qDebug(" ] ");
if (withNewLine) { if (withNewLine) {
printLog("\n"); qDebug("\n");
} }
} }
@ -385,14 +386,14 @@ void printVoxelCode(unsigned char* voxelCode) {
unsigned int voxelSizeInOctets = (voxelSizeInBits/3); unsigned int voxelSizeInOctets = (voxelSizeInBits/3);
unsigned int voxelBufferSize = voxelSizeInBytes+1+3; // 1 for size, 3 for color unsigned int voxelBufferSize = voxelSizeInBytes+1+3; // 1 for size, 3 for color
printLog("octets=%d\n",octets); qDebug("octets=%d\n",octets);
printLog("voxelSizeInBits=%d\n",voxelSizeInBits); qDebug("voxelSizeInBits=%d\n",voxelSizeInBits);
printLog("voxelSizeInBytes=%d\n",voxelSizeInBytes); qDebug("voxelSizeInBytes=%d\n",voxelSizeInBytes);
printLog("voxelSizeInOctets=%d\n",voxelSizeInOctets); qDebug("voxelSizeInOctets=%d\n",voxelSizeInOctets);
printLog("voxelBufferSize=%d\n",voxelBufferSize); qDebug("voxelBufferSize=%d\n",voxelBufferSize);
for(int i=0;i<voxelBufferSize;i++) { for(int i=0;i<voxelBufferSize;i++) {
printLog("i=%d ",i); qDebug("i=%d ",i);
outputBits(voxelCode[i]); outputBits(voxelCode[i]);
} }
} }

View file

@ -6,10 +6,9 @@
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. // Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
// //
#include "UDPSocket.h"
#include <fcntl.h>
#include <cstdio> #include <cstdio>
#include <errno.h> #include <errno.h>
#include <fcntl.h>
#include <string.h> #include <string.h>
#ifdef _WIN32 #ifdef _WIN32
@ -21,7 +20,9 @@
#include <unistd.h> #include <unistd.h>
#endif #endif
#include "Log.h" #include <QDebug>
#include "UDPSocket.h"
sockaddr_in destSockaddr, senderAddress; sockaddr_in destSockaddr, senderAddress;
@ -134,7 +135,7 @@ UDPSocket::UDPSocket(int listeningPort) : listeningPort(listeningPort), blocking
handle = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); handle = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (handle <= 0) { if (handle <= 0) {
printLog("Failed to create socket.\n"); qDebug("Failed to create socket.\n");
return; return;
} }
@ -147,7 +148,7 @@ UDPSocket::UDPSocket(int listeningPort) : listeningPort(listeningPort), blocking
bind_address.sin_port = htons((uint16_t) listeningPort); bind_address.sin_port = htons((uint16_t) listeningPort);
if (bind(handle, (const sockaddr*) &bind_address, sizeof(sockaddr_in)) < 0) { 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; return;
} }
@ -164,7 +165,7 @@ UDPSocket::UDPSocket(int listeningPort) : listeningPort(listeningPort), blocking
tv.tv_usec = 500000; tv.tv_usec = 500000;
setsockopt(handle, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof tv); 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() { UDPSocket::~UDPSocket() {
@ -244,7 +245,7 @@ int UDPSocket::send(sockaddr* destAddress, const void* data, size_t byteLength)
0, (sockaddr *) destAddress, sizeof(sockaddr_in)); 0, (sockaddr *) destAddress, sizeof(sockaddr_in));
if (sent_bytes != byteLength) { if (sent_bytes != byteLength) {
printLog("Failed to send packet: %s\n", strerror(errno)); qDebug("Failed to send packet: %s\n", strerror(errno));
return false; return false;
} }

View file

@ -6,20 +6,17 @@
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. // Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
// //
#include "UrlReader.h"
#include <new> #include <new>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include "Log.h"
#ifndef _WIN32 #ifndef _WIN32
// (Windows port is incomplete and the build files do not support CURL, yet) // (Windows port is incomplete and the build files do not support CURL, yet)
#include <curl/curl.h> #include <curl/curl.h>
#include "UrlReader.h"
// //
// ATTENTION: A certain part of the implementation lives in inlined code // ATTENTION: A certain part of the implementation lives in inlined code

View file

@ -6,10 +6,13 @@
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. // Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
// //
#include "CoverageMap.h"
#include <SharedUtil.h>
#include <cstring> #include <cstring>
#include "Log.h"
#include <QDebug>
#include <SharedUtil.h>
#include "CoverageMap.h"
int CoverageMap::_mapCount = 0; int CoverageMap::_mapCount = 0;
int CoverageMap::_checkMapRootCalls = 0; int CoverageMap::_checkMapRootCalls = 0;
@ -60,7 +63,7 @@ CoverageMap::CoverageMap(BoundingBox boundingBox, bool isRoot, bool managePolygo
{ {
_mapCount++; _mapCount++;
init(); init();
//printLog("CoverageMap created... _mapCount=%d\n",_mapCount); //qDebug("CoverageMap created... _mapCount=%d\n",_mapCount);
}; };
CoverageMap::~CoverageMap() { CoverageMap::~CoverageMap() {
@ -68,19 +71,19 @@ CoverageMap::~CoverageMap() {
}; };
void CoverageMap::printStats() { void CoverageMap::printStats() {
printLog("CoverageMap::printStats()...\n"); qDebug("CoverageMap::printStats()...\n");
printLog("MINIMUM_POLYGON_AREA_TO_STORE=%f\n",MINIMUM_POLYGON_AREA_TO_STORE); qDebug("MINIMUM_POLYGON_AREA_TO_STORE=%f\n",MINIMUM_POLYGON_AREA_TO_STORE);
printLog("_mapCount=%d\n",_mapCount); qDebug("_mapCount=%d\n",_mapCount);
printLog("_checkMapRootCalls=%d\n",_checkMapRootCalls); qDebug("_checkMapRootCalls=%d\n",_checkMapRootCalls);
printLog("_notAllInView=%d\n",_notAllInView); qDebug("_notAllInView=%d\n",_notAllInView);
printLog("_maxPolygonsUsed=%d\n",CoverageRegion::_maxPolygonsUsed); qDebug("_maxPolygonsUsed=%d\n",CoverageRegion::_maxPolygonsUsed);
printLog("_totalPolygons=%d\n",CoverageRegion::_totalPolygons); qDebug("_totalPolygons=%d\n",CoverageRegion::_totalPolygons);
printLog("_occlusionTests=%d\n",CoverageRegion::_occlusionTests); qDebug("_occlusionTests=%d\n",CoverageRegion::_occlusionTests);
printLog("_regionSkips=%d\n",CoverageRegion::_regionSkips); qDebug("_regionSkips=%d\n",CoverageRegion::_regionSkips);
printLog("_tooSmallSkips=%d\n",CoverageRegion::_tooSmallSkips); qDebug("_tooSmallSkips=%d\n",CoverageRegion::_tooSmallSkips);
printLog("_regionFullSkips=%d\n",CoverageRegion::_regionFullSkips); qDebug("_regionFullSkips=%d\n",CoverageRegion::_regionFullSkips);
printLog("_outOfOrderPolygon=%d\n",CoverageRegion::_outOfOrderPolygon); qDebug("_outOfOrderPolygon=%d\n",CoverageRegion::_outOfOrderPolygon);
printLog("_clippedPolygons=%d\n",CoverageRegion::_clippedPolygons); qDebug("_clippedPolygons=%d\n",CoverageRegion::_clippedPolygons);
} }
void CoverageMap::erase() { void CoverageMap::erase() {
@ -99,7 +102,7 @@ void CoverageMap::erase() {
} }
if (_isRoot && wantDebugging) { if (_isRoot && wantDebugging) {
printLog("CoverageMap last to be deleted...\n"); qDebug("CoverageMap last to be deleted...\n");
printStats(); printStats();
CoverageRegion::_maxPolygonsUsed = 0; CoverageRegion::_maxPolygonsUsed = 0;
@ -184,7 +187,7 @@ CoverageMapStorageResult CoverageMap::checkMap(VoxelProjectedPolygon* polygon, b
if (_isRoot) { if (_isRoot) {
_checkMapRootCalls++; _checkMapRootCalls++;
//printLog("CoverageMap::checkMap()... storeIt=%s\n", debug::valueOf(storeIt)); //qDebug("CoverageMap::checkMap()... storeIt=%s\n", debug::valueOf(storeIt));
//polygon->printDebugDetails(); //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. // not in view, then we just discard it with a DOESNT_FIT, this saves us time checking values later.
if (!polygon->getAllInView()) { if (!polygon->getAllInView()) {
_notAllInView++; _notAllInView++;
//printLog("CoverageMap2::checkMap()... V2_OCCLUDED\n"); //qDebug("CoverageMap2::checkMap()... V2_OCCLUDED\n");
return DOESNT_FIT; return DOESNT_FIT;
} }
@ -240,9 +243,9 @@ CoverageMapStorageResult CoverageMap::checkMap(VoxelProjectedPolygon* polygon, b
/* /*
if (result == STORED) if (result == STORED)
printLog("CoverageMap2::checkMap()... STORED\n"); qDebug("CoverageMap2::checkMap()... STORED\n");
else else
printLog("CoverageMap2::checkMap()... OCCLUDED\n"); qDebug("CoverageMap2::checkMap()... OCCLUDED\n");
*/ */
return result; return result;
@ -265,16 +268,16 @@ CoverageMapStorageResult CoverageMap::checkMap(VoxelProjectedPolygon* polygon, b
/* /*
switch (result) { switch (result) {
case STORED: case STORED:
printLog("checkMap() = STORED\n"); qDebug("checkMap() = STORED\n");
break; break;
case NOT_STORED: case NOT_STORED:
printLog("checkMap() = NOT_STORED\n"); qDebug("checkMap() = NOT_STORED\n");
break; break;
case OCCLUDED: case OCCLUDED:
printLog("checkMap() = OCCLUDED\n"); qDebug("checkMap() = OCCLUDED\n");
break; break;
default: default:
printLog("checkMap() = ????? \n"); qDebug("checkMap() = ????? \n");
break; break;
} }
*/ */
@ -287,27 +290,27 @@ CoverageMapStorageResult CoverageMap::checkMap(VoxelProjectedPolygon* polygon, b
// any of our child bounding boxes, so we should add it here. // any of our child bounding boxes, so we should add it here.
if (storeIt) { if (storeIt) {
if (polygon->getBoundingBox().area() > CoverageMap::MINIMUM_POLYGON_AREA_TO_STORE) { 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) { if (storeIn->getPolygonCount() < MAX_POLYGONS_PER_REGION) {
storeIn->storeInArray(polygon); storeIn->storeInArray(polygon);
//printLog("CoverageMap2::checkMap()... STORED\n"); //qDebug("CoverageMap2::checkMap()... STORED\n");
return STORED; return STORED;
} else { } else {
CoverageRegion::_regionFullSkips++; CoverageRegion::_regionFullSkips++;
//printLog("CoverageMap2::checkMap()... NOT_STORED\n"); //qDebug("CoverageMap2::checkMap()... NOT_STORED\n");
return NOT_STORED; return NOT_STORED;
} }
} else { } else {
CoverageRegion::_tooSmallSkips++; CoverageRegion::_tooSmallSkips++;
//printLog("CoverageMap2::checkMap()... NOT_STORED\n"); //qDebug("CoverageMap2::checkMap()... NOT_STORED\n");
return NOT_STORED; return NOT_STORED;
} }
} else { } else {
//printLog("CoverageMap2::checkMap()... NOT_STORED\n"); //qDebug("CoverageMap2::checkMap()... NOT_STORED\n");
return NOT_STORED; return NOT_STORED;
} }
} }
//printLog("CoverageMap2::checkMap()... DOESNT_FIT\n"); //qDebug("CoverageMap2::checkMap()... DOESNT_FIT\n");
return DOESNT_FIT; return DOESNT_FIT;
} }
@ -338,11 +341,11 @@ void CoverageRegion::erase() {
/** /**
if (_polygonCount) { if (_polygonCount) {
printLog("CoverageRegion::erase()...\n"); qDebug("CoverageRegion::erase()...\n");
printLog("_polygonCount=%d\n",_polygonCount); qDebug("_polygonCount=%d\n",_polygonCount);
_myBoundingBox.printDebugDetails(getRegionName()); _myBoundingBox.printDebugDetails(getRegionName());
//for (int i = 0; i < _polygonCount; i++) { //for (int i = 0; i < _polygonCount; i++) {
// printLog("_polygons[%d]=",i); // qDebug("_polygons[%d]=",i);
// _polygons[i]->getBoundingBox().printDebugDetails(); // _polygons[i]->getBoundingBox().printDebugDetails();
//} //}
} }
@ -390,7 +393,7 @@ void CoverageRegion::growPolygonArray() {
_polygonDistances = newDistances; _polygonDistances = newDistances;
_polygonSizes = newSizes; _polygonSizes = newSizes;
_polygonArraySize = _polygonArraySize + DEFAULT_GROW_SIZE; _polygonArraySize = _polygonArraySize + DEFAULT_GROW_SIZE;
//printLog("CoverageMap::growPolygonArray() _polygonArraySize=%d...\n",_polygonArraySize); //qDebug("CoverageMap::growPolygonArray() _polygonArraySize=%d...\n",_polygonArraySize);
} }
const char* CoverageRegion::getRegionName() const { const char* CoverageRegion::getRegionName() const {
@ -435,7 +438,7 @@ bool CoverageRegion::mergeItemsInArray(VoxelProjectedPolygon* seed, bool seedInA
_totalPolygons--; _totalPolygons--;
} }
//printLog("_polygonCount=%d\n",_polygonCount); //qDebug("_polygonCount=%d\n",_polygonCount);
// clean up // clean up
if (_managePolygons) { if (_managePolygons) {
@ -483,7 +486,7 @@ void CoverageRegion::storeInArray(VoxelProjectedPolygon* polygon) {
// insertion point in this array, and shift the array accordingly // insertion point in this array, and shift the array accordingly
float area = polygon->getBoundingBox().area(); float area = polygon->getBoundingBox().area();
float reverseArea = 4.0f - 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, _polygonCount = insertIntoSortedArrays((void*)polygon, reverseArea, IGNORED,
(void**)_polygons, _polygonSizes, IGNORED, (void**)_polygons, _polygonSizes, IGNORED,
_polygonCount, _polygonArraySize); _polygonCount, _polygonArraySize);
@ -497,10 +500,10 @@ void CoverageRegion::storeInArray(VoxelProjectedPolygon* polygon) {
// Debugging and Optimization Tuning code. // Debugging and Optimization Tuning code.
if (_polygonCount > _maxPolygonsUsed) { if (_polygonCount > _maxPolygonsUsed) {
_maxPolygonsUsed = _polygonCount; _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"); //_myBoundingBox.printDebugDetails("map._myBoundingBox");
} else { } else {
//printLog("CoverageRegion::storeInArray() _polygonCount=%d region=%s\n",_polygonCount, getRegionName()); //qDebug("CoverageRegion::storeInArray() _polygonCount=%d region=%s\n",_polygonCount, getRegionName());
} }
} }

View file

@ -7,11 +7,13 @@
// //
#include <algorithm> #include <algorithm>
#include <cstring>
#include <QDebug>
#include <SharedUtil.h>
#include "CoverageMapV2.h" #include "CoverageMapV2.h"
#include <SharedUtil.h>
#include <cstring>
#include "Log.h"
int CoverageMapV2::_mapCount = 0; int CoverageMapV2::_mapCount = 0;
int CoverageMapV2::_checkMapRootCalls = 0; int CoverageMapV2::_checkMapRootCalls = 0;
@ -59,7 +61,7 @@ CoverageMapV2::CoverageMapV2(BoundingBox boundingBox, bool isRoot, bool isCovere
{ {
_mapCount++; _mapCount++;
init(); init();
//printLog("CoverageMapV2 created... _mapCount=%d\n",_mapCount); //qDebug("CoverageMapV2 created... _mapCount=%d\n",_mapCount);
}; };
CoverageMapV2::~CoverageMapV2() { CoverageMapV2::~CoverageMapV2() {
@ -76,11 +78,11 @@ void CoverageMapV2::erase() {
} }
if (_isRoot && wantDebugging) { if (_isRoot && wantDebugging) {
printLog("CoverageMapV2 last to be deleted...\n"); qDebug("CoverageMapV2 last to be deleted...\n");
printLog("MINIMUM_POLYGON_AREA_TO_STORE=%f\n",MINIMUM_POLYGON_AREA_TO_STORE); qDebug("MINIMUM_POLYGON_AREA_TO_STORE=%f\n",MINIMUM_POLYGON_AREA_TO_STORE);
printLog("_mapCount=%d\n",_mapCount); qDebug("_mapCount=%d\n",_mapCount);
printLog("_checkMapRootCalls=%d\n",_checkMapRootCalls); qDebug("_checkMapRootCalls=%d\n",_checkMapRootCalls);
printLog("_notAllInView=%d\n",_notAllInView); qDebug("_notAllInView=%d\n",_notAllInView);
_mapCount = 0; _mapCount = 0;
_checkMapRootCalls = 0; _checkMapRootCalls = 0;
_notAllInView = 0; _notAllInView = 0;

View file

@ -7,7 +7,8 @@
#include <cstring> #include <cstring>
#include <Log.h> #include <QDebug>
#include <SharedUtil.h> #include <SharedUtil.h>
#include "GeometryUtil.h" #include "GeometryUtil.h"

View file

@ -12,8 +12,6 @@
#include <stdio.h> #include <stdio.h>
#include "Log.h"
// These are some useful utilities that vec3 is missing // These are some useful utilities that vec3 is missing
void printVec3(const char* name, const glm::vec3& v) { 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); printf("%s x=%f y=%f z=%f\n", name, v.x, v.y, v.z);

View file

@ -6,14 +6,13 @@
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. // Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
// //
#include "Tags.h"
#include <Log.h>
#include <zlib.h>
#include <zconf.h>
#include <iostream> #include <iostream>
#include <zconf.h>
#include <zlib.h>
#include "Tags.h"
Tag::Tag(int tagId, std::stringstream &ss) : _tagId(tagId) { Tag::Tag(int tagId, std::stringstream &ss) : _tagId(tagId) {
int size = ss.get() << 8 | ss.get(); int size = ss.get() << 8 | ss.get();

View file

@ -3,24 +3,23 @@
// hifi // hifi
// //
// Created by Brad Hefta-Gaub on 04/11/13. // Created by Brad Hefta-Gaub on 04/11/13.
// Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
// //
// Simple view frustum class. // Simple view frustum class.
// //
//
#include <algorithm> #include <algorithm>
#include <glm/gtx/transform.hpp> #include <glm/gtx/transform.hpp>
#include "SharedUtil.h" #include <QDebug>
#include "Log.h"
#include "CoverageMap.h" #include "CoverageMap.h"
#include "GeometryUtil.h" #include "GeometryUtil.h"
#include "SharedUtil.h"
#include "ViewFrustum.h" #include "ViewFrustum.h"
#include "VoxelConstants.h" #include "VoxelConstants.h"
using namespace std; using namespace std;
ViewFrustum::ViewFrustum() : ViewFrustum::ViewFrustum() :
@ -323,40 +322,40 @@ bool ViewFrustum::matches(const ViewFrustum& compareTo, bool debug) const {
testMatches(compareTo._eyeOffsetOrientation, _eyeOffsetOrientation); testMatches(compareTo._eyeOffsetOrientation, _eyeOffsetOrientation);
if (!result && debug) { if (!result && debug) {
printLog("ViewFrustum::matches()... result=%s\n", debug::valueOf(result)); qDebug("ViewFrustum::matches()... result=%s\n", debug::valueOf(result));
printLog("%s -- compareTo._position=%f,%f,%f _position=%f,%f,%f\n", qDebug("%s -- compareTo._position=%f,%f,%f _position=%f,%f,%f\n",
(testMatches(compareTo._position,_position) ? "MATCHES " : "NO MATCH"), (testMatches(compareTo._position,_position) ? "MATCHES " : "NO MATCH"),
compareTo._position.x, compareTo._position.y, compareTo._position.z, compareTo._position.x, compareTo._position.y, compareTo._position.z,
_position.x, _position.y, _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"), (testMatches(compareTo._direction, _direction) ? "MATCHES " : "NO MATCH"),
compareTo._direction.x, compareTo._direction.y, compareTo._direction.z, compareTo._direction.x, compareTo._direction.y, compareTo._direction.z,
_direction.x, _direction.y, _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"), (testMatches(compareTo._up, _up) ? "MATCHES " : "NO MATCH"),
compareTo._up.x, compareTo._up.y, compareTo._up.z, compareTo._up.x, compareTo._up.y, compareTo._up.z,
_up.x, _up.y, _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"), (testMatches(compareTo._right, _right) ? "MATCHES " : "NO MATCH"),
compareTo._right.x, compareTo._right.y, compareTo._right.z, compareTo._right.x, compareTo._right.y, compareTo._right.z,
_right.x, _right.y, _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"), (testMatches(compareTo._fieldOfView, _fieldOfView) ? "MATCHES " : "NO MATCH"),
compareTo._fieldOfView, _fieldOfView); 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"), (testMatches(compareTo._aspectRatio, _aspectRatio) ? "MATCHES " : "NO MATCH"),
compareTo._aspectRatio, _aspectRatio); 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"), (testMatches(compareTo._nearClip, _nearClip) ? "MATCHES " : "NO MATCH"),
compareTo._nearClip, _nearClip); 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"), (testMatches(compareTo._farClip, _farClip) ? "MATCHES " : "NO MATCH"),
compareTo._farClip, _farClip); 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"), (testMatches(compareTo._eyeOffsetPosition, _eyeOffsetPosition) ? "MATCHES " : "NO MATCH"),
compareTo._eyeOffsetPosition.x, compareTo._eyeOffsetPosition.y, compareTo._eyeOffsetPosition.z, compareTo._eyeOffsetPosition.x, compareTo._eyeOffsetPosition.y, compareTo._eyeOffsetPosition.z,
_eyeOffsetPosition.x, _eyeOffsetPosition.y, _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"), (testMatches(compareTo._eyeOffsetOrientation, _eyeOffsetOrientation) ? "MATCHES " : "NO MATCH"),
compareTo._eyeOffsetOrientation.x, compareTo._eyeOffsetOrientation.y, compareTo._eyeOffsetOrientation.x, compareTo._eyeOffsetOrientation.y,
compareTo._eyeOffsetOrientation.z, compareTo._eyeOffsetOrientation.w, compareTo._eyeOffsetOrientation.z, compareTo._eyeOffsetOrientation.w,
@ -419,17 +418,17 @@ void ViewFrustum::computeOffAxisFrustum(float& left, float& right, float& bottom
} }
void ViewFrustum::printDebugDetails() const { void ViewFrustum::printDebugDetails() const {
printLog("ViewFrustum::printDebugDetails()... \n"); qDebug("ViewFrustum::printDebugDetails()... \n");
printLog("_position=%f,%f,%f\n", _position.x, _position.y, _position.z ); qDebug("_position=%f,%f,%f\n", _position.x, _position.y, _position.z );
printLog("_direction=%f,%f,%f\n", _direction.x, _direction.y, _direction.z ); qDebug("_direction=%f,%f,%f\n", _direction.x, _direction.y, _direction.z );
printLog("_up=%f,%f,%f\n", _up.x, _up.y, _up.z ); qDebug("_up=%f,%f,%f\n", _up.x, _up.y, _up.z );
printLog("_right=%f,%f,%f\n", _right.x, _right.y, _right.z ); qDebug("_right=%f,%f,%f\n", _right.x, _right.y, _right.z );
printLog("_fieldOfView=%f\n", _fieldOfView); qDebug("_fieldOfView=%f\n", _fieldOfView);
printLog("_aspectRatio=%f\n", _aspectRatio); qDebug("_aspectRatio=%f\n", _aspectRatio);
printLog("_nearClip=%f\n", _nearClip); qDebug("_nearClip=%f\n", _nearClip);
printLog("_farClip=%f\n", _farClip); qDebug("_farClip=%f\n", _farClip);
printLog("_eyeOffsetPosition=%f,%f,%f\n", _eyeOffsetPosition.x, _eyeOffsetPosition.y, _eyeOffsetPosition.z ); qDebug("_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("_eyeOffsetOrientation=%f,%f,%f,%f\n", _eyeOffsetOrientation.x, _eyeOffsetOrientation.y, _eyeOffsetOrientation.z,
_eyeOffsetOrientation.w ); _eyeOffsetOrientation.w );
} }

View file

@ -3,18 +3,20 @@
// hifi // hifi
// //
// Created by Brad Hefta-Gaub on 04/11/13. // Created by Brad Hefta-Gaub on 04/11/13.
// Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
// //
// Simple view frustum class. // Simple view frustum class.
// //
//
#ifndef __hifi__ViewFrustum__ #ifndef __hifi__ViewFrustum__
#define __hifi__ViewFrustum__ #define __hifi__ViewFrustum__
#include <glm/glm.hpp> #include <glm/glm.hpp>
#include <glm/gtc/quaternion.hpp> #include <glm/gtc/quaternion.hpp>
#include "Plane.h"
#include "AABox.h" #include "AABox.h"
#include "Plane.h"
#include "VoxelProjectedPolygon.h" #include "VoxelProjectedPolygon.h"
const float DEFAULT_KEYHOLE_RADIUS = 3.0f; const float DEFAULT_KEYHOLE_RADIUS = 3.0f;
@ -135,7 +137,7 @@ private:
glm::vec3 _nearBottomLeft; glm::vec3 _nearBottomLeft;
glm::vec3 _nearBottomRight; glm::vec3 _nearBottomRight;
enum { TOP_PLANE = 0, BOTTOM_PLANE, LEFT_PLANE, RIGHT_PLANE, NEAR_PLANE, FAR_PLANE }; 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; const char* debugPlaneName (int plane) const;

View file

@ -3,19 +3,21 @@
// hifi // hifi
// //
// Created by Stephen Birarda on 3/13/13. // Created by Stephen Birarda on 3/13/13.
// // Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
// //
#include <stdio.h>
#include <cmath> #include <cmath>
#include <cstring> #include <cstring>
#include <stdio.h>
#include <QDebug>
#include "AABox.h"
#include "OctalCode.h"
#include "SharedUtil.h" #include "SharedUtil.h"
#include "Log.h" #include "VoxelConstants.h"
#include "VoxelNode.h" #include "VoxelNode.h"
#include "VoxelTree.h" #include "VoxelTree.h"
#include "VoxelConstants.h"
#include "OctalCode.h"
#include "AABox.h"
VoxelNode::VoxelNode() { VoxelNode::VoxelNode() {
unsigned char* rootCode = new unsigned char[1]; 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 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()) { if (!_children[i] || _children[i]->isStagedForDeletion() || !_children[i]->isLeaf() || !_children[i]->isColored()) {
allChildrenMatch=false; 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; break;
} else { } else {
if (i==0) { if (i==0) {
@ -274,7 +276,7 @@ bool VoxelNode::collapseIdenticalLeaves() {
if (allChildrenMatch) { if (allChildrenMatch) {
//printLog("allChildrenMatch: pruning tree\n"); //qDebug("allChildrenMatch: pruning tree\n");
for (int i = 0; i < NUMBER_OF_CHILDREN; i++) { for (int i = 0; i < NUMBER_OF_CHILDREN; i++) {
delete _children[i]; // delete all the child nodes delete _children[i]; // delete all the child nodes
_children[i]=NULL; // set it to NULL _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, _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(isLeaf()), debug::valueOf(isColored()), getColor()[0], getColor()[1], getColor()[2], getColor()[3],
debug::valueOf(isDirty()), debug::valueOf(getShouldRender())); debug::valueOf(isDirty()), debug::valueOf(getShouldRender()));
outputBits(childBits, false); outputBits(childBits, false);
printLog("\n octalCode="); qDebug("\n octalCode=");
printOctalCode(_octalCode); printOctalCode(_octalCode);
} }

View file

@ -6,10 +6,13 @@
// //
#include <algorithm> #include <algorithm>
#include "VoxelProjectedPolygon.h"
#include <QDebug>
#include "GeometryUtil.h" #include "GeometryUtil.h"
#include "Log.h"
#include "SharedUtil.h" #include "SharedUtil.h"
#include "VoxelProjectedPolygon.h"
glm::vec2 BoundingBox::getVertex(int vertexNumber) const { glm::vec2 BoundingBox::getVertex(int vertexNumber) const {
switch (vertexNumber) { switch (vertexNumber) {
@ -88,11 +91,11 @@ void BoundingBox::explandToInclude(const BoundingBox& box) {
void BoundingBox::printDebugDetails(const char* label) const { void BoundingBox::printDebugDetails(const char* label) const {
if (label) { if (label) {
printLog(label); qDebug() << label;
} else { } 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); debug::valueOf(_set), corner.x, corner.y, size.x, size.y, corner.x, corner.y, corner.x+size.x, corner.y+size.y);
} }

View file

@ -9,26 +9,28 @@
#ifdef _WIN32 #ifdef _WIN32
#define _USE_MATH_DEFINES #define _USE_MATH_DEFINES
#endif #endif
#include <cstring> #include <cstring>
#include <cstdio> #include <cstdio>
#include <cmath> #include <cmath>
#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 <fstream> // to load voxels from file #include <fstream> // to load voxels from file
#include "VoxelConstants.h"
#include "CoverageMap.h"
#include "SquarePixelMap.h"
#include "Tags.h"
#include <glm/gtc/noise.hpp> #include <glm/gtc/noise.hpp>
#include <QDebug>
#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) { float boundaryDistanceForRenderLevel(unsigned int renderLevel) {
const float voxelSizeScale = 50000.0f; const float voxelSizeScale = 50000.0f;
return voxelSizeScale / powf(2, renderLevel); return voxelSizeScale / powf(2, renderLevel);
@ -155,7 +157,7 @@ void VoxelTree::recurseNodeWithOperationDistanceSorted(VoxelNode* node, RecurseV
if (childNode) { if (childNode) {
// chance to optimize, doesn't need to be actual distance!! Could be distance squared // chance to optimize, doesn't need to be actual distance!! Could be distance squared
float distanceSquared = childNode->distanceSquareToPoint(point); 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(""); //childNode->printDebugDetails("");
currentCount = insertIntoSortedArrays((void*)childNode, distanceSquared, i, currentCount = insertIntoSortedArrays((void*)childNode, distanceSquared, i,
(void**)&sortedChildren, (float*)&distancesToChildren, (void**)&sortedChildren, (float*)&distancesToChildren,
@ -166,7 +168,7 @@ void VoxelTree::recurseNodeWithOperationDistanceSorted(VoxelNode* node, RecurseV
for (int i = 0; i < currentCount; i++) { for (int i = 0; i < currentCount; i++) {
VoxelNode* childNode = sortedChildren[i]; VoxelNode* childNode = sortedChildren[i];
if (childNode) { 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(""); //childNode->printDebugDetails("");
recurseNodeWithOperationDistanceSorted(childNode, operation, point, extraData); 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 // 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 // we can safely return, ending the recursion and unwinding
if (!childNode) { 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; return;
} }
@ -546,7 +548,7 @@ void VoxelTree::readCodeColorBufferToTreeRecursion(VoxelNode* node, void* extraD
} }
} else { } else {
if (!node->isLeaf()) { 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); outputBits(colorMask);
// output the colors we have // output the colors we have
for (int j = 0; j < NUMBER_OF_CHILDREN; j++) { for (int j = 0; j < NUMBER_OF_CHILDREN; j++) {
if (startNode->getChildAtIndex(j) && startNode->getChildAtIndex(j)->isColored()) { if (startNode->getChildAtIndex(j) && startNode->getChildAtIndex(j)->isColored()) {
printLog("color %d : ",j); qDebug("color %d : ",j);
for (int c = 0; c < 3; c++) { for (int c = 0; c < 3; c++) {
outputBits(startNode->getChildAtIndex(j)->getTrueColor()[c],false); outputBits(startNode->getChildAtIndex(j)->getTrueColor()[c],false);
} }
@ -641,7 +643,7 @@ void VoxelTree::printTreeForDebugging(VoxelNode *startNode) {
} }
} }
printLog("child mask: "); qDebug("child mask: ");
outputBits(childMask); outputBits(childMask);
if (childMask > 0) { if (childMask > 0) {
@ -686,7 +688,7 @@ void VoxelTree::loadVoxelsFile(const char* fileName, bool wantColorRandomizer) {
int totalBytesRead = 0; int totalBytesRead = 0;
if(file.is_open()) { if(file.is_open()) {
printLog("loading file...\n"); qDebug("loading file...\n");
bool bail = false; bool bail = false;
while (!file.eof() && !bail) { while (!file.eof() && !bail) {
file.get(octets); file.get(octets);
@ -711,14 +713,14 @@ void VoxelTree::loadVoxelsFile(const char* fileName, bool wantColorRandomizer) {
file.get(colorRead); file.get(colorRead);
blue = (unsigned char)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++; vCount++;
int colorRandomizer = wantColorRandomizer ? randIntInRange (-5, 5) : 0; int colorRandomizer = wantColorRandomizer ? randIntInRange (-5, 5) : 0;
voxelData[lengthInBytes+1] = std::max(0,std::min(255,red + colorRandomizer)); voxelData[lengthInBytes+1] = std::max(0,std::min(255,red + colorRandomizer));
voxelData[lengthInBytes+2] = std::max(0,std::min(255,green + colorRandomizer)); voxelData[lengthInBytes+2] = std::max(0,std::min(255,green + colorRandomizer));
voxelData[lengthInBytes+3] = std::max(0,std::min(255,blue + 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]); voxelData[lengthInBytes+1], voxelData[lengthInBytes+2], voxelData[lengthInBytes+3]);
//printVoxelCode(voxelData); //printVoxelCode(voxelData);
@ -819,7 +821,7 @@ void VoxelTree::createSphere(float radius, float xc, float yc, float zc, float v
if (debug) { if (debug) {
int percentComplete = 100 * (thisRadius/radius); 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) { 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 // 2) In all modes, we will use our "outer" color to draw the voxels. Otherwise we will use the average color
if (lastLayer) { if (lastLayer) {
if (false && debug) { 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); theta, phi, thisRadius,radius);
} }
switch (mode) { 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)))); 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)))); blue = (unsigned char)std::min(255, std::max(0, (int)(b1 + ((b2 - b1) * gradient))));
if (debug) { 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; } break;
} }
@ -1176,7 +1178,7 @@ int VoxelTree::encodeTreeBitstreamRecursion(VoxelNode* node, unsigned char* outp
if (childNode) { if (childNode) {
// chance to optimize, doesn't need to be actual distance!! Could be distance squared // chance to optimize, doesn't need to be actual distance!! Could be distance squared
//float distanceSquared = childNode->distanceSquareToPoint(point); //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(""); //childNode->printDebugDetails("");
float distance = params.viewFrustum ? childNode->distanceToCamera(*params.viewFrustum) : 0; float distance = params.viewFrustum ? childNode->distanceToCamera(*params.viewFrustum) : 0;
@ -1251,7 +1253,7 @@ int VoxelTree::encodeTreeBitstreamRecursion(VoxelNode* node, unsigned char* outp
} // wants occlusion culling & isLeaf() } // 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! // track children with actual color, only if the child wasn't previously in view!
if (shouldRender && !childIsOccluded) { if (shouldRender && !childIsOccluded) {
@ -1432,7 +1434,7 @@ int VoxelTree::encodeTreeBitstreamRecursion(VoxelNode* node, unsigned char* outp
bool VoxelTree::readFromSVOFile(const char* fileName) { bool VoxelTree::readFromSVOFile(const char* fileName) {
std::ifstream file(fileName, std::ios::in|std::ios::binary|std::ios::ate); std::ifstream file(fileName, std::ios::in|std::ios::binary|std::ios::ate);
if(file.is_open()) { if(file.is_open()) {
printLog("loading file %s...\n", fileName); qDebug("loading file %s...\n", fileName);
// get file length.... // get file length....
unsigned long fileLength = file.tellg(); unsigned long fileLength = file.tellg();
@ -1460,14 +1462,14 @@ bool VoxelTree::readFromSchematicFile(const char *fileName) {
std::stringstream ss; std::stringstream ss;
int err = retrieveData(fileName, ss); int err = retrieveData(fileName, ss);
if (err && ss.get() != TAG_Compound) { if (err && ss.get() != TAG_Compound) {
printLog("[ERROR] Invalid schematic file.\n"); qDebug("[ERROR] Invalid schematic file.\n");
return false; return false;
} }
ss.get(); ss.get();
TagCompound schematics(ss); TagCompound schematics(ss);
if (!schematics.getBlocksId() || !schematics.getBlocksData()) { if (!schematics.getBlocksId() || !schematics.getBlocksData()) {
printLog("[ERROR] Invalid schematic file.\n"); qDebug("[ERROR] Invalid schematic file.\n");
return false; 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; 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); std::ofstream file(fileName, std::ios::out|std::ios::binary);
if(file.is_open()) { if(file.is_open()) {
printLog("saving to file %s...\n", fileName); qDebug("saving to file %s...\n", fileName);
VoxelNodeBag nodeBag; VoxelNodeBag nodeBag;
// If we were given a specific node, start from there, otherwise start from root // If we were given a specific node, start from there, otherwise start from root

View file

@ -6,7 +6,7 @@ set(MACRO_DIR ${ROOT_DIR}/cmake/macros)
set(TARGET_NAME pairing-server) set(TARGET_NAME pairing-server)
include(${MACRO_DIR}/SetupHifiProject.cmake) include(${MACRO_DIR}/SetupHifiProject.cmake)
setup_hifi_project(${TARGET_NAME}) setup_hifi_project(${TARGET_NAME} TRUE)
# link the shared hifi library # link the shared hifi library
include(${MACRO_DIR}/LinkHifiLibrary.cmake) include(${MACRO_DIR}/LinkHifiLibrary.cmake)

View file

@ -7,7 +7,7 @@ set(TARGET_NAME space-server)
include(${MACRO_DIR}/SetupHifiProject.cmake) include(${MACRO_DIR}/SetupHifiProject.cmake)
setup_hifi_project(${TARGET_NAME}) setup_hifi_project(${TARGET_NAME} TRUE)
include(${MACRO_DIR}/LinkHifiLibrary.cmake) include(${MACRO_DIR}/LinkHifiLibrary.cmake)
link_hifi_library(shared ${TARGET_NAME} ${ROOT_DIR}) link_hifi_library(shared ${TARGET_NAME} ${ROOT_DIR})

View file

@ -14,7 +14,7 @@ include_glm(${TARGET_NAME} ${ROOT_DIR})
include(${MACRO_DIR}/SetupHifiProject.cmake) include(${MACRO_DIR}/SetupHifiProject.cmake)
setup_hifi_project(${TARGET_NAME}) setup_hifi_project(${TARGET_NAME} FALSE)
# link in the shared library # link in the shared library
include(${MACRO_DIR}/LinkHifiLibrary.cmake) include(${MACRO_DIR}/LinkHifiLibrary.cmake)

View file

@ -14,7 +14,7 @@ include_glm(${TARGET_NAME} ${ROOT_DIR})
include(${MACRO_DIR}/SetupHifiProject.cmake) include(${MACRO_DIR}/SetupHifiProject.cmake)
setup_hifi_project(${TARGET_NAME}) setup_hifi_project(${TARGET_NAME} TRUE)
# link in the shared library # link in the shared library
include(${MACRO_DIR}/LinkHifiLibrary.cmake) include(${MACRO_DIR}/LinkHifiLibrary.cmake)

View file

@ -313,6 +313,9 @@ void deepestLevelVoxelDistributor(NodeList* nodeList,
uint64_t lastPersistVoxels = 0; uint64_t lastPersistVoxels = 0;
void persistVoxelsWhenDirty() { void persistVoxelsWhenDirty() {
uint64_t now = usecTimestampNow(); uint64_t now = usecTimestampNow();
if (::lastPersistVoxels == 0) {
::lastPersistVoxels = now;
}
int sinceLastTime = (now - ::lastPersistVoxels) / 1000; int sinceLastTime = (now - ::lastPersistVoxels) / 1000;
// check the dirty bit and persist here... // check the dirty bit and persist here...