added total voxel count to stats

This commit is contained in:
ZappoMan 2013-07-20 15:49:04 -07:00
parent 86ad0da09f
commit de7cd4db03
6 changed files with 86 additions and 20 deletions

View file

@ -44,6 +44,8 @@ void VoxelNode::init(unsigned char * octalCode) {
_children[i] = NULL;
}
_childCount = 0;
_subtreeNodeCount = 1; // that's me
_subtreeLeafNodeCount = 0; // that's me
_glBufferIndex = GLBUFFER_INDEX_UNKNOWN;
_isDirty = true;
@ -79,6 +81,24 @@ void VoxelNode::handleSubtreeChanged(VoxelTree* myTree) {
if (myTree->getShouldReaverage()) {
setColorFromAverageOfChildren();
}
recalculateSubTreeNodeCount();
}
void VoxelNode::recalculateSubTreeNodeCount() {
// Assuming the tree below me as changed, I need to recalculate my node count
_subtreeNodeCount = 1; // that's me
if (isLeaf()) {
_subtreeLeafNodeCount = 1;
} else {
_subtreeLeafNodeCount = 0;
for (int i = 0; i < NUMBER_OF_CHILDREN; i++) {
if (_children[i]) {
_subtreeNodeCount += _children[i]->_subtreeNodeCount;
_subtreeLeafNodeCount += _children[i]->_subtreeLeafNodeCount;
}
}
}
}

View file

@ -107,6 +107,12 @@ public:
static int addDeleteHook(VoxelNodeDeleteHook hook, void* extraData = NULL);
static void removeDeleteHook(int hookID);
void recalculateSubTreeNodeCount();
unsigned long getSubTreeNodeCount() const { return _subtreeNodeCount; };
unsigned long getSubTreeInternalNodeCount() const { return _subtreeNodeCount - _subtreeLeafNodeCount; };
unsigned long getSubTreeLeafNodeCount() const { return _subtreeLeafNodeCount; };
private:
void calculateAABox();
void init(unsigned char * octalCode);
@ -126,6 +132,8 @@ private:
unsigned char* _octalCode;
VoxelNode* _children[8];
int _childCount;
unsigned long _subtreeNodeCount;
unsigned long _subtreeLeafNodeCount;
float _density; // If leaf: density = 1, if internal node: 0-1 density of voxels inside
static VoxelNodeDeleteHook _hooks[VOXEL_NODE_MAX_DELETE_HOOKS];

View file

@ -21,9 +21,13 @@ VoxelSceneStats::VoxelSceneStats() {
VoxelSceneStats::~VoxelSceneStats() {
}
void VoxelSceneStats::sceneStarted(bool fullScene, bool moving) {
_start = usecTimestampNow();
void VoxelSceneStats::sceneStarted(bool fullScene, bool moving, VoxelNode* root) {
reset(); // resets packet and voxel stats
_start = usecTimestampNow();
_totalVoxels = root->getSubTreeNodeCount();
_totalInternal = root->getSubTreeInternalNodeCount();
_totalLeaves = root->getSubTreeLeafNodeCount();
_fullSceneDraw = fullScene;
_moving = moving;
}
@ -53,6 +57,10 @@ void VoxelSceneStats::reset() {
_bytes = 0;
_passes = 0;
_totalVoxels = 0;
_totalInternal = 0;
_totalLeaves = 0;
_traversed = 0;
_internal = 0;
_leaves = 0;
@ -214,6 +222,10 @@ int VoxelSceneStats::packIntoMessage(unsigned char* destinationBuffer, int avail
memcpy(destinationBuffer, &_bytes, sizeof(_bytes));
destinationBuffer += sizeof(_bytes);
memcpy(destinationBuffer, &_totalInternal, sizeof(_totalInternal));
destinationBuffer += sizeof(_totalInternal);
memcpy(destinationBuffer, &_totalLeaves, sizeof(_totalLeaves));
destinationBuffer += sizeof(_totalLeaves);
memcpy(destinationBuffer, &_internal, sizeof(_internal));
destinationBuffer += sizeof(_internal);
memcpy(destinationBuffer, &_leaves, sizeof(_leaves));
@ -281,12 +293,19 @@ int VoxelSceneStats::unpackFromMessage(unsigned char* sourceBuffer, int availabl
sourceBuffer += sizeof(_packets);
memcpy(&_bytes, sourceBuffer, sizeof(_bytes));
sourceBuffer += sizeof(_bytes);
memcpy(&_totalInternal, sourceBuffer, sizeof(_totalInternal));
sourceBuffer += sizeof(_totalInternal);
memcpy(&_totalLeaves, sourceBuffer, sizeof(_totalLeaves));
sourceBuffer += sizeof(_totalLeaves);
_totalVoxels = _totalInternal + _totalLeaves;
memcpy(&_internal, sourceBuffer, sizeof(_internal));
sourceBuffer += sizeof(_internal);
memcpy(&_leaves, sourceBuffer, sizeof(_leaves));
sourceBuffer += sizeof(_leaves);
_traversed = _internal + _leaves;
memcpy(&_internalSkippedDistance, sourceBuffer, sizeof(_internalSkippedDistance));
sourceBuffer += sizeof(_internalSkippedDistance);
memcpy(&_leavesSkippedDistance, sourceBuffer, sizeof(_leavesSkippedDistance));
@ -356,6 +375,9 @@ void VoxelSceneStats::printDebugDetails() {
qDebug(" packets: %d\n", _packets);
qDebug(" bytes : %ld\n", _bytes);
qDebug("\n");
qDebug(" total voxels : %lu\n", _totalVoxels );
qDebug(" internal : %lu\n", _totalInternal );
qDebug(" leaves : %lu\n", _totalLeaves );
qDebug(" traversed : %lu\n", _traversed );
qDebug(" internal : %lu\n", _internal );
qDebug(" leaves : %lu\n", _leaves );
@ -393,18 +415,19 @@ VoxelSceneStats::ItemInfo VoxelSceneStats::_ITEMS[] = {
{ "Elapsed" , 0x40ff40d0 },
{ "Encode" , 0xffef40c0 },
{ "Network" , 0xd0d0d0a0 },
{ "Voxels Sent" , 0x40ff40d0 },
{ "Colors Sent" , 0xffef40c0 },
{ "Bitmasks Sent" , 0xd0d0d0a0 },
{ "Traversed" , 0x40ff40d0 },
{ "Skipped - Total" , 0xffef40c0 },
{ "Skipped - Distance" , 0xd0d0d0a0 },
{ "Skipped - Out of View", 0x40ff40d0 },
{ "Skipped - Was in View", 0xffef40c0 },
{ "Skipped - No Change" , 0xd0d0d0a0 },
{ "Skipped - Occluded" , 0x40ff40d0 },
{ "Didn't fit in packet" , 0xffef40c0 },
{ "Mode" , 0xd0d0d0a0 },
{ "Voxels on Server" , 0x40ff40d0 },
{ "Voxels Sent" , 0xffef40c0 },
{ "Colors Sent" , 0xd0d0d0a0 },
{ "Bitmasks Sent" , 0x40ff40d0 },
{ "Traversed" , 0xffef40c0 },
{ "Skipped - Total" , 0xd0d0d0a0 },
{ "Skipped - Distance" , 0x40ff40d0 },
{ "Skipped - Out of View", 0xffef40c0 },
{ "Skipped - Was in View", 0xd0d0d0a0 },
{ "Skipped - No Change" , 0x40ff40d0 },
{ "Skipped - Occluded" , 0xffef40c0 },
{ "Didn't fit in packet" , 0xd0d0d0a0 },
{ "Mode" , 0x40ff40d0 },
};
char* VoxelSceneStats::getItemValue(int item) {
@ -426,10 +449,15 @@ char* VoxelSceneStats::getItemValue(int item) {
sprintf(_itemValueBuffer, "%d packets %lu bytes (%d kbps)", _packets, _bytes, calculatedKBPS);
break;
}
case ITEM_VOXELS_SERVER: {
sprintf(_itemValueBuffer, "%lu total %lu internal %lu leaves",
_totalVoxels, _totalInternal, _totalLeaves);
break;
}
case ITEM_VOXELS: {
unsigned long total = _existsInPacketBitsWritten + _colorSent;
float calculatedBPV = total == 0 ? 0 : (_bytes * 8) / total;
sprintf(_itemValueBuffer, "%lu total (%.2f bits/voxel) %lu internal %lu leaves",
sprintf(_itemValueBuffer, "%lu (%.2f bits/voxel) %lu internal %lu leaves",
total, calculatedBPV, _existsInPacketBitsWritten, _colorSent);
break;
}

View file

@ -19,7 +19,7 @@ public:
VoxelSceneStats();
~VoxelSceneStats();
void reset();
void sceneStarted(bool fullScene, bool moving);
void sceneStarted(bool fullScene, bool moving, VoxelNode* root);
void sceneCompleted();
void printDebugDetails();
@ -53,6 +53,7 @@ public:
ITEM_ELAPSED,
ITEM_ENCODE,
ITEM_PACKETS,
ITEM_VOXELS_SERVER,
ITEM_VOXELS,
ITEM_COLORS,
ITEM_BITS,
@ -91,6 +92,10 @@ private:
uint64_t _encodeStart;
// scene voxel related data
unsigned long _totalVoxels;
unsigned long _totalInternal;
unsigned long _totalLeaves;
unsigned long _traversed;
unsigned long _internal;
unsigned long _leaves;

View file

@ -673,6 +673,9 @@ void VoxelTree::reaverageVoxelColors(VoxelNode *startNode) {
if (hasChildren && !startNode->collapseIdenticalLeaves()) {
startNode->setColorFromAverageOfChildren();
}
// this is also a good time to recalculateSubTreeNodeCount()
startNode->recalculateSubTreeNodeCount();
}
}

View file

@ -250,7 +250,7 @@ void deepestLevelVoxelDistributor(NodeList* nodeList,
// start tracking our stats
bool fullScene = (!viewFrustumChanged || !nodeData->getWantDelta()) && nodeData->getViewFrustumJustStoppedChanging();
nodeData->stats.sceneStarted(fullScene, viewFrustumChanged);
nodeData->stats.sceneStarted(fullScene, viewFrustumChanged, ::serverTree.rootNode);
}
// If we have something in our nodeBag, then turn them into packets and send them out...
@ -486,8 +486,10 @@ int main(int argc, const char * argv[]) {
::serverTree.clearDirtyBit(); // the tree is clean since we just loaded it
printf("DONE loading voxels from file... fileRead=%s\n", debug::valueOf(persistantFileRead));
unsigned long nodeCount = ::serverTree.getVoxelCount();
printf("Nodes after loading scene %ld nodes\n", nodeCount);
unsigned long nodeCount = ::serverTree.rootNode->getSubTreeNodeCount();
unsigned long internalNodeCount = ::serverTree.rootNode->getSubTreeInternalNodeCount();
unsigned long leafNodeCount = ::serverTree.rootNode->getSubTreeLeafNodeCount();
printf("Nodes after loading scene %lu nodes %lu internal %lu leaves\n", nodeCount, internalNodeCount, leafNodeCount);
}
// Check to see if the user passed in a command line option for loading an old style local