mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 20:29:40 +02:00
improvements to delta sending
This commit is contained in:
parent
dc70675c22
commit
ab8e2916d3
3 changed files with 31 additions and 9 deletions
|
@ -1331,10 +1331,6 @@ int VoxelTree::encodeTreeBitstreamRecursion(VoxelNode* node, unsigned char* outp
|
||||||
} // wants occlusion culling & isLeaf()
|
} // 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:
|
// There are two types of nodes for which we want to send colors:
|
||||||
// 1) Leaves - obviously
|
// 1) Leaves - obviously
|
||||||
// 2) Non-leaves who's children would be visible and beyond our LOD.
|
// 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
|
// 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
|
// we do want to include our color
|
||||||
if (grandChildrenInView > 0 && grandChildrenInLOD==0) {
|
if (grandChildrenInView > 0 && grandChildrenInLOD == 0) {
|
||||||
isLeafOrLOD = true;
|
isLeafOrLOD = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// track children with actual color, only if the child wasn't previously in view!
|
// track children with actual color, only if the child wasn't previously in view!
|
||||||
if (childNode && isLeafOrLOD && childNode->isColored() && !childWasInView && !childIsOccluded) {
|
if (childNode && isLeafOrLOD && childNode->isColored() && !childIsOccluded) {
|
||||||
childrenColoredBits += (1 << (7 - originalIndex));
|
bool childWasInView = false;
|
||||||
inViewWithColorCount++;
|
|
||||||
|
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++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,6 +45,8 @@ public:
|
||||||
bool deltaViewFrustum;
|
bool deltaViewFrustum;
|
||||||
const ViewFrustum* lastViewFrustum;
|
const ViewFrustum* lastViewFrustum;
|
||||||
bool wantOcclusionCulling;
|
bool wantOcclusionCulling;
|
||||||
|
long childWasInViewDiscarded;
|
||||||
|
|
||||||
CoverageMap* map;
|
CoverageMap* map;
|
||||||
|
|
||||||
EncodeBitstreamParams(
|
EncodeBitstreamParams(
|
||||||
|
@ -66,6 +68,7 @@ public:
|
||||||
deltaViewFrustum (deltaViewFrustum),
|
deltaViewFrustum (deltaViewFrustum),
|
||||||
lastViewFrustum (lastViewFrustum),
|
lastViewFrustum (lastViewFrustum),
|
||||||
wantOcclusionCulling(wantOcclusionCulling),
|
wantOcclusionCulling(wantOcclusionCulling),
|
||||||
|
childWasInViewDiscarded(0),
|
||||||
map (map)
|
map (map)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
|
@ -127,7 +127,7 @@ void deepestLevelVoxelDistributor(NodeList* nodeList,
|
||||||
long long start = usecTimestampNow();
|
long long start = usecTimestampNow();
|
||||||
|
|
||||||
// FOR NOW... node tells us if it wants to receive only view frustum deltas
|
// 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;
|
const ViewFrustum* lastViewFrustum = wantDelta ? &nodeData->getLastKnownViewFrustum() : NULL;
|
||||||
|
|
||||||
if (::debugVoxelSending) {
|
if (::debugVoxelSending) {
|
||||||
|
@ -233,6 +233,10 @@ void deepestLevelVoxelDistributor(NodeList* nodeList,
|
||||||
|
|
||||||
bytesWritten = serverTree.encodeTreeBitstream(subTree, &tempOutputBuffer[0], MAX_VOXEL_PACKET_SIZE - 1,
|
bytesWritten = serverTree.encodeTreeBitstream(subTree, &tempOutputBuffer[0], MAX_VOXEL_PACKET_SIZE - 1,
|
||||||
nodeData->nodeBag, params);
|
nodeData->nodeBag, params);
|
||||||
|
|
||||||
|
if (::debugVoxelSending && wantDelta) {
|
||||||
|
printf("encodeTreeBitstream() childWasInViewDiscarded=%ld\n", params.childWasInViewDiscarded);
|
||||||
|
}
|
||||||
|
|
||||||
if (nodeData->getAvailable() >= bytesWritten) {
|
if (nodeData->getAvailable() >= bytesWritten) {
|
||||||
nodeData->writeToPacket(&tempOutputBuffer[0], bytesWritten);
|
nodeData->writeToPacket(&tempOutputBuffer[0], bytesWritten);
|
||||||
|
|
Loading…
Reference in a new issue