mirror of
https://github.com/overte-org/overte.git
synced 2025-04-23 07:53:52 +02:00
make send only changed bits work better
This commit is contained in:
parent
74eaf72d53
commit
677e2580e1
5 changed files with 34 additions and 15 deletions
libraries/voxels/src
voxel-server/src
|
@ -1114,14 +1114,12 @@ int VoxelTree::encodeTreeBitstreamRecursion(VoxelNode* node, unsigned char* outp
|
|||
return bytesAtThisLevel;
|
||||
}
|
||||
|
||||
/** Not ready for production - coming soon.
|
||||
// If we're not in delta sending mode, but the voxel hasn't changed, then we can also bail early...
|
||||
if (!params.deltaViewFrustum && !node->hasChangedSince(params.lastViewFrustumSent - CHANGE_FUDGE)) {
|
||||
printf("not delta sending, and the node hasn't changed, bail early... lastSent=%lld getLastChanged=%lld\n",
|
||||
params.lastViewFrustumSent, node->getLastChanged());
|
||||
// If we're not in delta sending mode, and we weren't asked to do a force send, and the voxel hasn't changed,
|
||||
// then we can also bail early and save bits
|
||||
if (!params.forceSendScene && !params.deltaViewFrustum &&
|
||||
!node->hasChangedSince(params.lastViewFrustumSent - CHANGE_FUDGE)) {
|
||||
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
|
||||
|
|
|
@ -51,7 +51,7 @@ public:
|
|||
long childWasInViewDiscarded;
|
||||
int boundaryLevelAdjust;
|
||||
uint64_t lastViewFrustumSent;
|
||||
|
||||
bool forceSendScene;
|
||||
CoverageMap* map;
|
||||
|
||||
EncodeBitstreamParams(
|
||||
|
@ -65,7 +65,8 @@ public:
|
|||
bool wantOcclusionCulling= NO_OCCLUSION_CULLING,
|
||||
CoverageMap* map = IGNORE_COVERAGE_MAP,
|
||||
int boundaryLevelAdjust = NO_BOUNDARY_ADJUST,
|
||||
uint64_t lastViewFrustumSent = IGNORE_LAST_SENT) :
|
||||
uint64_t lastViewFrustumSent = IGNORE_LAST_SENT,
|
||||
bool forceSendScene = true) :
|
||||
maxEncodeLevel (maxEncodeLevel),
|
||||
maxLevelReached (0),
|
||||
viewFrustum (viewFrustum),
|
||||
|
@ -78,6 +79,7 @@ public:
|
|||
childWasInViewDiscarded (0),
|
||||
boundaryLevelAdjust (boundaryLevelAdjust),
|
||||
lastViewFrustumSent (lastViewFrustumSent),
|
||||
forceSendScene (forceSendScene),
|
||||
map (map)
|
||||
{}
|
||||
};
|
||||
|
|
|
@ -20,6 +20,7 @@ VoxelNodeData::VoxelNodeData(Node* owningNode) :
|
|||
_maxLevelReachedInLastSearch(1),
|
||||
_lastTimeBagEmpty(0),
|
||||
_viewFrustumChanging(false),
|
||||
_viewFrustumJustStoppedChanging(true),
|
||||
_currentPacketIsColor(true)
|
||||
{
|
||||
_voxelPacket = new unsigned char[MAX_VOXEL_PACKET_SIZE];
|
||||
|
@ -69,10 +70,25 @@ bool VoxelNodeData::updateCurrentViewFrustum() {
|
|||
_currentViewFrustum.calculate();
|
||||
currentViewFrustumChanged = true;
|
||||
}
|
||||
|
||||
// When we first detect that the view stopped changing, we record this.
|
||||
// but we don't change it back to false until we've completely sent this
|
||||
// scene.
|
||||
if (_viewFrustumChanging && !currentViewFrustumChanged) {
|
||||
_viewFrustumJustStoppedChanging = true;
|
||||
}
|
||||
_viewFrustumChanging = currentViewFrustumChanged;
|
||||
return currentViewFrustumChanged;
|
||||
}
|
||||
|
||||
void VoxelNodeData::setViewSent(bool viewSent) {
|
||||
_viewSent = viewSent;
|
||||
if (viewSent) {
|
||||
_viewFrustumJustStoppedChanging = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void VoxelNodeData::updateLastKnownViewFrustum() {
|
||||
bool frustumChanges = !_lastKnownViewFrustum.matches(_currentViewFrustum);
|
||||
|
||||
|
|
|
@ -48,7 +48,11 @@ public:
|
|||
void updateLastKnownViewFrustum();
|
||||
|
||||
bool getViewSent() const { return _viewSent; };
|
||||
void setViewSent(bool viewSent) { _viewSent = viewSent; }
|
||||
void setViewSent(bool viewSent);
|
||||
|
||||
bool getViewFrustumChanging() const { return _viewFrustumChanging; };
|
||||
bool getViewFrustumJustStoppedChanging() const { return _viewFrustumJustStoppedChanging; };
|
||||
|
||||
|
||||
uint64_t getLastTimeBagEmpty() const { return _lastTimeBagEmpty; };
|
||||
void setLastTimeBagEmpty(uint64_t lastTimeBagEmpty) { _lastTimeBagEmpty = lastTimeBagEmpty; };
|
||||
|
@ -69,6 +73,7 @@ private:
|
|||
ViewFrustum _lastKnownViewFrustum;
|
||||
uint64_t _lastTimeBagEmpty;
|
||||
bool _viewFrustumChanging;
|
||||
bool _viewFrustumJustStoppedChanging;
|
||||
bool _currentPacketIsColor;
|
||||
};
|
||||
|
||||
|
|
|
@ -205,6 +205,7 @@ void deepestLevelVoxelDistributor(NodeList* nodeList,
|
|||
}
|
||||
}
|
||||
|
||||
// This is the start of "resending" the scene.
|
||||
nodeData->nodeBag.insert(serverTree.rootNode);
|
||||
}
|
||||
|
||||
|
@ -242,15 +243,12 @@ void deepestLevelVoxelDistributor(NodeList* nodeList,
|
|||
EncodeBitstreamParams params(INT_MAX, &nodeData->getCurrentViewFrustum(), wantColor,
|
||||
WANT_EXISTS_BITS, DONT_CHOP, wantDelta, lastViewFrustum,
|
||||
wantOcclusionCulling, coverageMap, boundaryLevelAdjust,
|
||||
nodeData->getLastTimeBagEmpty());
|
||||
|
||||
nodeData->getLastTimeBagEmpty(),
|
||||
nodeData->getViewFrustumJustStoppedChanging());
|
||||
|
||||
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);
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue