From 6e5ed6435b17ab903ba95704facfc9e61c0b5688 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Thu, 23 May 2013 12:06:59 -0700 Subject: [PATCH 1/5] added shortcut key to log menu --- interface/src/Application.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index a66b56b809..45823246f1 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1239,6 +1239,7 @@ void Application::initMenu() { _renderStatsOn->setShortcut(Qt::Key_Slash); (_logOn = toolsMenu->addAction("Log"))->setCheckable(true); _logOn->setChecked(true); + _logOn->setShortcut(Qt::CTRL | Qt::Key_L); QMenu* voxelMenu = menuBar->addMenu("Voxels"); _voxelModeActions = new QActionGroup(this); From 213057203422464a0adf298ed1821fe7a5f8c1ea Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Thu, 23 May 2013 12:07:56 -0700 Subject: [PATCH 2/5] fixed color initialization on VoxelNode construction --- libraries/voxels/src/VoxelNode.cpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/libraries/voxels/src/VoxelNode.cpp b/libraries/voxels/src/VoxelNode.cpp index dd6c02c1f3..f542fe0dd4 100644 --- a/libraries/voxels/src/VoxelNode.cpp +++ b/libraries/voxels/src/VoxelNode.cpp @@ -29,9 +29,12 @@ VoxelNode::VoxelNode(unsigned char * octalCode) { void VoxelNode::init(unsigned char * octalCode) { _octalCode = octalCode; -#ifdef HAS_FALSE_COLOR +#ifndef NO_FALSE_COLOR // !NO_FALSE_COLOR means, does have false color _falseColored = false; // assume true color + _currentColor[0] = _currentColor[1] = _currentColor[2] = _currentColor[3] = 0; #endif + _trueColor[0] = _trueColor[1] = _trueColor[2] = _trueColor[3] = 0; + // default pointers to child nodes to NULL for (int i = 0; i < NUMBER_OF_CHILDREN; i++) { @@ -104,13 +107,6 @@ VoxelNode* VoxelNode::removeChildAtIndex(int childIndex) { void VoxelNode::addChildAtIndex(int childIndex) { if (!_children[childIndex]) { _children[childIndex] = new VoxelNode(childOctalCode(_octalCode, childIndex)); - - // XXXBHG - When the node is constructed, it should be cleanly set up as - // true colored, but for some reason, not so much. I've added a a basecamp - // to-do to research this. But for now we'll use belt and suspenders and set - // it to not-false-colored here! - _children[childIndex]->setFalseColored(false); - _isDirty = true; _childCount++; } @@ -273,10 +269,10 @@ void VoxelNode::printDebugDetails(const char* label) const { } } - printLog("%s - Voxel at corner=(%f,%f,%f) size=%f\n isLeaf=%s isColored=%s isDirty=%s shouldRender=%s\n children=", label, + 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, _box.getCorner().x, _box.getCorner().y, _box.getCorner().z, _box.getSize().x, - debug::valueOf(isLeaf()), debug::valueOf(isColored()), debug::valueOf(isDirty()), - debug::valueOf(getShouldRender())); + debug::valueOf(isLeaf()), debug::valueOf(isColored()), getColor()[0], getColor()[1], getColor()[2], getColor()[3], + debug::valueOf(isDirty()), debug::valueOf(getShouldRender())); outputBits(childBits, false); printLog("\n octalCode="); From 25700ae490b4edd1e28a5a0184a6674248ac4154 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Thu, 23 May 2013 12:08:51 -0700 Subject: [PATCH 3/5] fixes to coloring bugs, coding standard cleanup --- libraries/voxels/src/VoxelTree.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/libraries/voxels/src/VoxelTree.cpp b/libraries/voxels/src/VoxelTree.cpp index 2c29e35903..798b447d6c 100644 --- a/libraries/voxels/src/VoxelTree.cpp +++ b/libraries/voxels/src/VoxelTree.cpp @@ -68,18 +68,18 @@ void VoxelTree::recurseNodeWithOperation(VoxelNode* node,RecurseVoxelTreeOperati } } -VoxelNode * VoxelTree::nodeForOctalCode(VoxelNode *ancestorNode, unsigned char * needleCode, VoxelNode** parentOfFoundNode) const { +VoxelNode * VoxelTree::nodeForOctalCode(VoxelNode* ancestorNode, unsigned char* needleCode, VoxelNode** parentOfFoundNode) const { // find the appropriate branch index based on this ancestorNode if (*needleCode > 0) { int branchForNeedle = branchIndexWithDescendant(ancestorNode->getOctalCode(), needleCode); - VoxelNode *childNode = ancestorNode->getChildAtIndex(branchForNeedle); + VoxelNode* childNode = ancestorNode->getChildAtIndex(branchForNeedle); if (childNode) { if (*childNode->getOctalCode() == *needleCode) { // If the caller asked for the parent, then give them that too... if (parentOfFoundNode) { - *parentOfFoundNode=ancestorNode; + *parentOfFoundNode = ancestorNode; } // the fact that the number of sections is equivalent does not always guarantee // that this is the same node, however due to the recursive traversal @@ -276,6 +276,9 @@ void VoxelTree::deleteVoxelCodeFromTree(unsigned char* codeBuffer, bool stage, b nodeToDelete->stageForDeletion(); } else { parentNode->deleteChildAtIndex(childIndex); + if (_shouldReaverage) { + parentNode->setColorFromAverageOfChildren(); + } } // If we're not a colored leaf, and we have no children, then delete ourselves @@ -296,7 +299,9 @@ void VoxelTree::deleteVoxelCodeFromTree(unsigned char* codeBuffer, bool stage, b for (int i = 0; i < 8; i++) { if (i != index) { ancestorNode->addChildAtIndex(i); - ancestorNode->getChildAtIndex(i)->setColor(nodeToDelete->getColor()); + if (nodeToDelete->isColored()) { + ancestorNode->getChildAtIndex(i)->setColor(nodeToDelete->getColor()); + } } } if (*ancestorNode->getOctalCode() == *codeBuffer - 1) { @@ -304,7 +309,9 @@ void VoxelTree::deleteVoxelCodeFromTree(unsigned char* codeBuffer, bool stage, b } ancestorNode->addChildAtIndex(index); ancestorNode = ancestorNode->getChildAtIndex(index); - ancestorNode->setColor(nodeToDelete->getColor()); + if (nodeToDelete->isColored()) { + ancestorNode->setColor(nodeToDelete->getColor()); + } } _isDirty = true; } @@ -319,7 +326,6 @@ void VoxelTree::eraseAllVoxels() { void VoxelTree::readCodeColorBufferToTree(unsigned char *codeColorBuffer, bool destructive) { VoxelNode* lastCreatedNode = nodeForOctalCode(rootNode, codeColorBuffer, NULL); - // create the node if it does not exist if (*lastCreatedNode->getOctalCode() != *codeColorBuffer) { lastCreatedNode = createMissingNode(lastCreatedNode, codeColorBuffer); From bf9c8676117455de2e1aeb9ef49edb19707b4a07 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Thu, 23 May 2013 12:09:55 -0700 Subject: [PATCH 4/5] make voxel server tree NOT a reaveraging tree, also, don't rebroadcast some Z commands to clients --- voxel-server/src/main.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/voxel-server/src/main.cpp b/voxel-server/src/main.cpp index 70eea1befd..a83fef2c3b 100644 --- a/voxel-server/src/main.cpp +++ b/voxel-server/src/main.cpp @@ -49,7 +49,7 @@ int PACKETS_PER_CLIENT_PER_INTERVAL = 50; const int MAX_VOXEL_TREE_DEPTH_LEVELS = 4; -VoxelTree randomTree(true); // this is a reaveraging tree +VoxelTree randomTree(false); // this is NOT a reaveraging tree bool wantVoxelPersist = true; bool wantLocalDomain = false; @@ -643,16 +643,19 @@ int main(int argc, const char * argv[]) { int totalLength = sizeof(PACKET_HEADER_Z_COMMAND) + commandLength + 1; // 1 for null termination printf("got Z message len(%ld)= %s\n", receivedBytes, command); + + bool rebroadcast = true; // be default rebroadcast while (totalLength <= receivedBytes) { if (strcmp(command, ERASE_ALL_COMMAND) == 0) { printf("got Z message == erase all\n"); - eraseVoxelTreeAndCleanupAgentVisitData(); + rebroadcast = false; } if (strcmp(command, ADD_SCENE_COMMAND) == 0) { printf("got Z message == add scene\n"); addSphereScene(&randomTree); + rebroadcast = false; } if (strcmp(command, TEST_COMMAND) == 0) { printf("got Z message == a message, nothing to do, just report\n"); @@ -660,9 +663,11 @@ int main(int argc, const char * argv[]) { totalLength += commandLength + 1; // 1 for null termination } - // Now send this to the connected agents so they can also process these messages - printf("rebroadcasting Z message to connected agents... agentList.broadcastToAgents()\n"); - agentList->broadcastToAgents(packetData, receivedBytes, &AGENT_TYPE_AVATAR, 1); + if (rebroadcast) { + // Now send this to the connected agents so they can also process these messages + printf("rebroadcasting Z message to connected agents... agentList.broadcastToAgents()\n"); + agentList->broadcastToAgents(packetData, receivedBytes, &AGENT_TYPE_AVATAR, 1); + } } // If we got a PACKET_HEADER_HEAD_DATA, then we're talking to an AGENT_TYPE_AVATAR, and we // need to make sure we have it in our agentList. From 29f84ebbb52fbae931df9b5e9c11b173c2f99d16 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Thu, 23 May 2013 12:11:38 -0700 Subject: [PATCH 5/5] code cleanup --- voxel-server/src/main.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/voxel-server/src/main.cpp b/voxel-server/src/main.cpp index a83fef2c3b..b1a3ed56ee 100644 --- a/voxel-server/src/main.cpp +++ b/voxel-server/src/main.cpp @@ -641,10 +641,8 @@ int main(int argc, const char * argv[]) { char* command = (char*) &packetData[1]; // start of the command int commandLength = strlen(command); // commands are null terminated strings int totalLength = sizeof(PACKET_HEADER_Z_COMMAND) + commandLength + 1; // 1 for null termination - printf("got Z message len(%ld)= %s\n", receivedBytes, command); - - bool rebroadcast = true; // be default rebroadcast + bool rebroadcast = true; // by default rebroadcast while (totalLength <= receivedBytes) { if (strcmp(command, ERASE_ALL_COMMAND) == 0) {