improvements to delta sending

This commit is contained in:
ZappoMan 2013-07-10 19:49:50 -07:00
parent dc70675c22
commit ab8e2916d3
3 changed files with 31 additions and 9 deletions

View file

@ -1331,10 +1331,6 @@ int VoxelTree::encodeTreeBitstreamRecursion(VoxelNode* node, unsigned char* outp
} // wants occlusion culling & isLeaf()
bool childWasInView = (childNode && params.deltaViewFrustum &&
(params.lastViewFrustum && ViewFrustum::INSIDE == childNode->inFrustum(*params.lastViewFrustum)));
// There are two types of nodes for which we want to send colors:
// 1) Leaves - obviously
// 2) Non-leaves who's children would be visible and beyond our LOD.
@ -1360,15 +1356,34 @@ int VoxelTree::encodeTreeBitstreamRecursion(VoxelNode* node, unsigned char* outp
}
// if any of our grandchildren ARE in view, then we don't want to include our color. If none are, then
// we do want to include our color
if (grandChildrenInView > 0 && grandChildrenInLOD==0) {
if (grandChildrenInView > 0 && grandChildrenInLOD == 0) {
isLeafOrLOD = true;
}
}
// track children with actual color, only if the child wasn't previously in view!
if (childNode && isLeafOrLOD && childNode->isColored() && !childWasInView && !childIsOccluded) {
childrenColoredBits += (1 << (7 - originalIndex));
inViewWithColorCount++;
if (childNode && isLeafOrLOD && childNode->isColored() && !childIsOccluded) {
bool childWasInView = false;
if (childNode && params.deltaViewFrustum && params.lastViewFrustum) {
ViewFrustum::location location = childNode->inFrustum(*params.lastViewFrustum);
// If we're a leaf, then either intersect or inside is considered "formerly in view"
if (childNode->isLeaf()) {
childWasInView = location != ViewFrustum::OUTSIDE;
} else {
childWasInView = location == ViewFrustum::INSIDE;
}
}
// If our child wasn't in view (or we're ignoring wasInView) then we add it to our sending items
if (!childWasInView) {
childrenColoredBits += (1 << (7 - originalIndex));
inViewWithColorCount++;
} else {
// otherwise just track stats of the items we discarded
params.childWasInViewDiscarded++;
}
}
}
}

View file

@ -45,6 +45,8 @@ public:
bool deltaViewFrustum;
const ViewFrustum* lastViewFrustum;
bool wantOcclusionCulling;
long childWasInViewDiscarded;
CoverageMap* map;
EncodeBitstreamParams(
@ -66,6 +68,7 @@ public:
deltaViewFrustum (deltaViewFrustum),
lastViewFrustum (lastViewFrustum),
wantOcclusionCulling(wantOcclusionCulling),
childWasInViewDiscarded(0),
map (map)
{}
};

View file

@ -127,7 +127,7 @@ void deepestLevelVoxelDistributor(NodeList* nodeList,
long long start = usecTimestampNow();
// FOR NOW... node tells us if it wants to receive only view frustum deltas
bool wantDelta = nodeData->getWantDelta();
bool wantDelta = viewFrustumChanged && nodeData->getWantDelta();
const ViewFrustum* lastViewFrustum = wantDelta ? &nodeData->getLastKnownViewFrustum() : NULL;
if (::debugVoxelSending) {
@ -233,6 +233,10 @@ void deepestLevelVoxelDistributor(NodeList* nodeList,
bytesWritten = serverTree.encodeTreeBitstream(subTree, &tempOutputBuffer[0], MAX_VOXEL_PACKET_SIZE - 1,
nodeData->nodeBag, params);
if (::debugVoxelSending && wantDelta) {
printf("encodeTreeBitstream() childWasInViewDiscarded=%ld\n", params.childWasInViewDiscarded);
}
if (nodeData->getAvailable() >= bytesWritten) {
nodeData->writeToPacket(&tempOutputBuffer[0], bytesWritten);