mirror of
https://github.com/overte-org/overte.git
synced 2025-04-22 16:13:28 +02:00
short circuit node recursion for delta sending
This commit is contained in:
parent
ab8e2916d3
commit
34cebc36c7
4 changed files with 28 additions and 10 deletions
|
@ -1182,7 +1182,26 @@ int VoxelTree::encodeTreeBitstreamRecursion(VoxelNode* node, unsigned char* outp
|
|||
if (!node->isInView(*params.viewFrustum)) {
|
||||
return bytesAtThisLevel;
|
||||
}
|
||||
|
||||
// Ok, we are in view, but if we're in delta mode, then we also want to make sure we weren't already in view
|
||||
// because we don't send nodes from the previously know in view frustum.
|
||||
bool wasInView = false;
|
||||
|
||||
if (params.deltaViewFrustum && params.lastViewFrustum) {
|
||||
ViewFrustum::location location = node->inFrustum(*params.lastViewFrustum);
|
||||
|
||||
// If we're a leaf, then either intersect or inside is considered "formerly in view"
|
||||
if (node->isLeaf()) {
|
||||
wasInView = location != ViewFrustum::OUTSIDE;
|
||||
} else {
|
||||
wasInView = location == ViewFrustum::INSIDE;
|
||||
}
|
||||
}
|
||||
|
||||
// If we were in view, then bail out early!
|
||||
if (wasInView) {
|
||||
return bytesAtThisLevel;
|
||||
}
|
||||
|
||||
// If the user also asked for occlusion culling, check if this node is occluded, but only if it's not a leaf.
|
||||
// leaf occlusion is handled down below when we check child nodes
|
||||
|
@ -1200,16 +1219,9 @@ int VoxelTree::encodeTreeBitstreamRecursion(VoxelNode* node, unsigned char* outp
|
|||
CoverageMapStorageResult result = params.map->checkMap(voxelPolygon, false);
|
||||
delete voxelPolygon; // cleanup
|
||||
if (result == OCCLUDED) {
|
||||
//node->printDebugDetails("upper section, non-Leaf is occluded!! node=");
|
||||
//args->nonLeavesOccluded++;
|
||||
|
||||
//args->subtreeVoxelsSkipped += (subArgs.voxelsTouched - 1);
|
||||
//args->totalVoxels += (subArgs.voxelsTouched - 1);
|
||||
|
||||
return bytesAtThisLevel;
|
||||
}
|
||||
} else {
|
||||
//node->printDebugDetails("upper section, shadow Not in view node=");
|
||||
// If this shadow wasn't "all in view" then we ignored it for occlusion culling, but
|
||||
// we do need to clean up memory and proceed as normal...
|
||||
delete voxelPolygon;
|
||||
|
|
|
@ -17,7 +17,8 @@ VoxelNodeData::VoxelNodeData(Node* owningNode) :
|
|||
_voxelPacketAvailableBytes(MAX_VOXEL_PACKET_SIZE),
|
||||
_maxSearchLevel(1),
|
||||
_maxLevelReachedInLastSearch(1),
|
||||
_lastTimeBagEmpty(0)
|
||||
_lastTimeBagEmpty(0),
|
||||
_viewFrustumChanging(false)
|
||||
{
|
||||
_voxelPacket = new unsigned char[MAX_VOXEL_PACKET_SIZE];
|
||||
_voxelPacketAt = _voxelPacket;
|
||||
|
@ -27,7 +28,8 @@ VoxelNodeData::VoxelNodeData(Node* owningNode) :
|
|||
|
||||
|
||||
void VoxelNodeData::resetVoxelPacket() {
|
||||
_voxelPacket[0] = getWantColor() ? PACKET_HEADER_VOXEL_DATA : PACKET_HEADER_VOXEL_DATA_MONOCHROME;
|
||||
bool wantColor = getWantColor();
|
||||
_voxelPacket[0] = wantColor ? PACKET_HEADER_VOXEL_DATA : PACKET_HEADER_VOXEL_DATA_MONOCHROME;
|
||||
_voxelPacketAt = &_voxelPacket[1];
|
||||
_voxelPacketAvailableBytes = MAX_VOXEL_PACKET_SIZE - 1;
|
||||
_voxelPacketWaiting = false;
|
||||
|
@ -63,6 +65,7 @@ bool VoxelNodeData::updateCurrentViewFrustum() {
|
|||
_currentViewFrustum.calculate();
|
||||
currentViewFrustumChanged = true;
|
||||
}
|
||||
_viewFrustumChanging = currentViewFrustumChanged;
|
||||
return currentViewFrustumChanged;
|
||||
}
|
||||
|
||||
|
|
|
@ -67,6 +67,7 @@ private:
|
|||
ViewFrustum _currentViewFrustum;
|
||||
ViewFrustum _lastKnownViewFrustum;
|
||||
long long _lastTimeBagEmpty;
|
||||
bool _viewFrustumChanging;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -128,6 +128,8 @@ void deepestLevelVoxelDistributor(NodeList* nodeList,
|
|||
|
||||
// FOR NOW... node tells us if it wants to receive only view frustum deltas
|
||||
bool wantDelta = viewFrustumChanged && nodeData->getWantDelta();
|
||||
bool wantColor = nodeData->getWantColor();
|
||||
|
||||
const ViewFrustum* lastViewFrustum = wantDelta ? &nodeData->getLastKnownViewFrustum() : NULL;
|
||||
|
||||
if (::debugVoxelSending) {
|
||||
|
@ -227,7 +229,7 @@ void deepestLevelVoxelDistributor(NodeList* nodeList,
|
|||
bool wantOcclusionCulling = nodeData->getWantOcclusionCulling();
|
||||
CoverageMap* coverageMap = wantOcclusionCulling ? &nodeData->map : IGNORE_COVERAGE_MAP;
|
||||
|
||||
EncodeBitstreamParams params(INT_MAX, &nodeData->getCurrentViewFrustum(), nodeData->getWantColor(),
|
||||
EncodeBitstreamParams params(INT_MAX, &nodeData->getCurrentViewFrustum(), wantColor,
|
||||
WANT_EXISTS_BITS, DONT_CHOP, wantDelta, lastViewFrustum,
|
||||
wantOcclusionCulling, coverageMap);
|
||||
|
||||
|
|
Loading…
Reference in a new issue