Merge branch 'master' of https://github.com/worklist/hifi into ick

This commit is contained in:
Andrzej Kapolka 2013-10-28 15:59:42 -07:00
commit 6d8f8dc8ed
6 changed files with 56 additions and 25 deletions

View file

@ -2377,16 +2377,14 @@ void Application::queryVoxels() {
}
}
// make sure there's at least one voxel server
// assume there's at least one voxel server
if (voxelServerCount < 1) {
return; // no voxel servers to talk to, we can bail.
voxelServerCount = 1;
}
// set our preferred PPS to be exactly evenly divided among all of the voxel servers...
int perServerPPS = DEFAULT_MAX_VOXEL_PPS/voxelServerCount;
_voxelQuery.setMaxVoxelPacketsPerSecond(perServerPPS);
UDPSocket* nodeSocket = NodeList::getInstance()->getNodeSocket();
for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
// only send to the NodeTypes that are NODE_TYPE_VOXEL_SERVER
@ -2408,6 +2406,12 @@ void Application::queryVoxels() {
ViewFrustum::location serverFrustumLocation = _viewFrustum.boxInFrustum(serverBounds);
if (serverFrustumLocation != ViewFrustum::OUTSIDE) {
//printf("_voxelQuery.setMaxVoxelPacketsPerSecond(perServerPPS=%d)\n",perServerPPS);
_voxelQuery.setMaxVoxelPacketsPerSecond(perServerPPS);
} else {
//printf("_voxelQuery.setMaxVoxelPacketsPerSecond(0)\n");
_voxelQuery.setMaxVoxelPacketsPerSecond(0);
}
// set up the packet for sending...
unsigned char* endOfVoxelQueryPacket = voxelQueryPacket;
@ -2429,7 +2433,6 @@ void Application::queryVoxels() {
}
}
}
}
}
/////////////////////////////////////////////////////////////////////////////////////

View file

@ -20,7 +20,9 @@ void NodeWatcher::nodeKilled(Node* node) {
// Use this to cleanup our node
if (node->getType() == NODE_TYPE_AGENT) {
VoxelNodeData* nodeData = (VoxelNodeData*)node->getLinkedData();
if (nodeData) {
node->setLinkedData(NULL);
delete nodeData;
}
}
};

View file

@ -108,6 +108,7 @@ void VoxelNodeData::writeToPacket(unsigned char* buffer, int bytes) {
VoxelNodeData::~VoxelNodeData() {
delete[] _voxelPacket;
delete[] _lastVoxelPacket;
if (_voxelSendThread) {
_voxelSendThread->terminate();

View file

@ -63,6 +63,7 @@ void VoxelSendThread::handlePacketSend(Node* node, VoxelNodeData* nodeData, int&
// obscure the packet and not send it. This allows the callers and upper level logic to not need to know about
// this rate control savings.
if (nodeData->shouldSuppressDuplicatePacket()) {
nodeData->resetVoxelPacket(); // we still need to reset it though!
return; // without sending...
}

View file

@ -76,6 +76,11 @@ void VoxelNode::init(unsigned char * octalCode) {
}
#endif // def HAS_AUDIT_CHILDREN
#ifdef SIMPLE_CHILD_ARRAY
for (int i = 0; i < NUMBER_OF_CHILDREN; i++) {
_simpleChildArray[i] = NULL;
}
#endif
_unknownBufferIndex = true;
setBufferIndex(GLBUFFER_INDEX_UNKNOWN);
@ -320,6 +325,9 @@ uint64_t VoxelNode::_couldStoreFourChildrenInternally = 0;
uint64_t VoxelNode::_couldNotStoreFourChildrenInternally = 0;
VoxelNode* VoxelNode::getChildAtIndex(int childIndex) const {
#ifdef SIMPLE_CHILD_ARRAY
return _simpleChildArray[childIndex];
#else
PerformanceWarning warn(false,"getChildAtIndex",false,&_getChildAtIndexTime,&_getChildAtIndexCalls);
VoxelNode* result = NULL;
int childCount = getChildCount();
@ -428,6 +436,7 @@ VoxelNode* VoxelNode::getChildAtIndex(int childIndex) const {
}
#endif // def HAS_AUDIT_CHILDREN
return result;
#endif
}
void VoxelNode::storeTwoChildren(VoxelNode* childOne, VoxelNode* childTwo) {
@ -680,6 +689,14 @@ void VoxelNode::deleteAllChildren() {
}
void VoxelNode::setChildAtIndex(int childIndex, VoxelNode* child) {
#ifdef SIMPLE_CHILD_ARRAY
if (child) {
setAtBit(_childBitmask, childIndex);
} else {
clearAtBit(_childBitmask, childIndex);
}
_simpleChildArray[childIndex] = child;
#else
PerformanceWarning warn(false,"setChildAtIndex",false,&_setChildAtIndexTime,&_setChildAtIndexCalls);
// Here's how we store things...
@ -1020,6 +1037,8 @@ void VoxelNode::setChildAtIndex(int childIndex, VoxelNode* child) {
_childrenArray[childIndex] = child;
auditChildren("setChildAtIndex()");
#endif // def HAS_AUDIT_CHILDREN
#endif
}

View file

@ -10,6 +10,7 @@
#define __hifi__VoxelNode__
//#define HAS_AUDIT_CHILDREN
#define SIMPLE_CHILD_ARRAY
#include <SharedUtil.h>
#include "AABox.h"
@ -172,6 +173,10 @@ private:
uint64_t _lastChanged; /// Client and server, timestamp this node was last changed, 8 bytes
/// Client and server, pointers to child nodes, various encodings
#ifdef SIMPLE_CHILD_ARRAY
VoxelNode* _simpleChildArray[8]; /// Only used when HAS_AUDIT_CHILDREN is enabled to help debug children encoding
#endif
union children_t {
VoxelNode* single;
int32_t offsetsTwoChildren[2];