From 275772bb3d3cd800d615e78397fc0b6cd70eb084 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Thu, 2 May 2013 12:26:51 -0700 Subject: [PATCH] debugging voxel sending behavior --- interface/src/VoxelSystem.cpp | 11 +++++++++-- interface/src/VoxelSystem.h | 2 ++ interface/src/main.cpp | 17 +++++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/interface/src/VoxelSystem.cpp b/interface/src/VoxelSystem.cpp index a1f4404e20..72a153ded2 100644 --- a/interface/src/VoxelSystem.cpp +++ b/interface/src/VoxelSystem.cpp @@ -423,10 +423,17 @@ void VoxelSystem::render() { int VoxelSystem::_nodeCount = 0; +void VoxelSystem::killLocalVoxels() { + _tree->eraseAllVoxels(); + _voxelsInArrays = 0; // better way to do this?? + //setupNewVoxelsForDrawing(); +} + + bool VoxelSystem::randomColorOperation(VoxelNode* node, void* extraData) { _nodeCount++; if (node->isColored()) { - nodeColor newColor = { randomColorValue(150), randomColorValue(150), randomColorValue(150), 1 }; + nodeColor newColor = { 255, randomColorValue(150), randomColorValue(150), 1 }; node->setColor(newColor); } return true; @@ -442,7 +449,7 @@ void VoxelSystem::randomizeVoxelColors() { bool VoxelSystem::falseColorizeRandomOperation(VoxelNode* node, void* extraData) { _nodeCount++; // always false colorize - node->setFalseColor(randomColorValue(150), randomColorValue(150), randomColorValue(150)); + node->setFalseColor(255, randomColorValue(150), randomColorValue(150)); return true; // keep going! } diff --git a/interface/src/VoxelSystem.h b/interface/src/VoxelSystem.h index e6798f9fd1..63f3b8622e 100644 --- a/interface/src/VoxelSystem.h +++ b/interface/src/VoxelSystem.h @@ -58,6 +58,8 @@ public: void falseColorizeInView(ViewFrustum* viewFrustum); void falseColorizeDistanceFromView(ViewFrustum* viewFrustum); + void killLocalVoxels(); + private: // Operation functions for tree recursion methods static int _nodeCount; diff --git a/interface/src/main.cpp b/interface/src/main.cpp index 08b1666d05..d5c28770be 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -130,6 +130,9 @@ glm::vec3 box(WORLD_SIZE,WORLD_SIZE,WORLD_SIZE); VoxelSystem voxels; +bool wantToKillLocalVoxels = false; + + #ifndef _WIN32 Audio audio(&audioScope, &myAvatar); #endif @@ -1071,6 +1074,13 @@ int setFrustumRenderMode(int state) { return ::frustumDrawingMode; } +int doKillLocalVoxels(int state) { + if (state == MENU_ROW_PICKED) { + ::wantToKillLocalVoxels = true; + } + return state; +} + int doRandomizeVoxelColors(int state) { if (state == MENU_ROW_PICKED) { ::voxels.randomizeVoxelColors(); @@ -1168,6 +1178,7 @@ void initMenu() { // Debug menuColumnDebug = menu.addColumn("Debug"); + menuColumnDebug->addRow("Kill Local Voxels", doKillLocalVoxels); menuColumnDebug->addRow("Randomize Voxel TRUE Colors", doRandomizeVoxelColors); menuColumnDebug->addRow("FALSE Color Voxels Randomly", doFalseRandomizeVoxelColors); menuColumnDebug->addRow("FALSE Color Voxels by Distance", doFalseColorizeByDistance); @@ -1412,6 +1423,12 @@ void* networkReceive(void* args) ssize_t bytesReceived; while (!stopNetworkReceiveThread) { + // check to see if the UI thread asked us to kill the voxel tree. since we're the only thread allowed to do that + if (::wantToKillLocalVoxels) { + ::voxels.killLocalVoxels(); + ::wantToKillLocalVoxels = false; + } + if (AgentList::getInstance()->getAgentSocket().receive(&senderAddress, incomingPacket, &bytesReceived)) { packetCount++; bytesCount += bytesReceived;