mirror of
https://github.com/overte-org/overte.git
synced 2025-08-05 06:49:41 +02:00
tweaks to delta sending
This commit is contained in:
parent
d809f5b774
commit
4e92f5d3d8
5 changed files with 24 additions and 5 deletions
|
@ -121,6 +121,8 @@ int AvatarData::getBroadcastData(unsigned char* destinationBuffer) {
|
|||
// called on the other agents - assigns it to my views of the others
|
||||
int AvatarData::parseData(unsigned char* sourceBuffer, int numBytes) {
|
||||
|
||||
//printf("AvatarData::parseData()\n");
|
||||
|
||||
// increment to push past the packet header
|
||||
sourceBuffer += sizeof(PACKET_HEADER_HEAD_DATA);
|
||||
|
||||
|
|
|
@ -853,10 +853,8 @@ int VoxelTree::encodeTreeBitstreamRecursion(int maxEncodeLevel, int& currentEnco
|
|||
for (int i = 0; i < NUMBER_OF_CHILDREN; i++) {
|
||||
VoxelNode* childNode = node->getChildAtIndex(i);
|
||||
bool childIsInView = (childNode && (!viewFrustum || childNode->isInView(*viewFrustum)));
|
||||
bool childWasInView = (childNode && deltaViewFrustum &&
|
||||
(lastViewFrustum && ViewFrustum::INSIDE == childNode->inFrustum(*lastViewFrustum)));
|
||||
|
||||
if (childIsInView && !childWasInView) {
|
||||
if (childIsInView) {
|
||||
// Before we determine consider this further, let's see if it's in our LOD scope...
|
||||
float distance = viewFrustum ? childNode->distanceToCamera(*viewFrustum) : 0;
|
||||
float boundaryDistance = viewFrustum ? boundaryDistanceForRenderLevel(*childNode->getOctalCode() + 1) : 1;
|
||||
|
@ -871,9 +869,12 @@ int VoxelTree::encodeTreeBitstreamRecursion(int maxEncodeLevel, int& currentEnco
|
|||
childrenExistBits += (1 << (7 - i));
|
||||
inViewNotLeafCount++;
|
||||
}
|
||||
|
||||
bool childWasInView = (childNode && deltaViewFrustum &&
|
||||
(lastViewFrustum && ViewFrustum::INSIDE == childNode->inFrustum(*lastViewFrustum)));
|
||||
|
||||
// track children with actual color
|
||||
if (childNode && childNode->isColored()) {
|
||||
// track children with actual color, only if the child wasn't previously in view!
|
||||
if (childNode && childNode->isColored() && !childWasInView) {
|
||||
childrenColoredBits += (1 << (7 - i));
|
||||
inViewWithColorCount++;
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ void VoxelAgentData::init() {
|
|||
_maxSearchLevel = 1;
|
||||
_maxLevelReachedInLastSearch = 1;
|
||||
resetVoxelPacket();
|
||||
_viewSent = false;
|
||||
}
|
||||
|
||||
void VoxelAgentData::resetVoxelPacket() {
|
||||
|
|
|
@ -49,7 +49,11 @@ public:
|
|||
bool updateCurrentViewFrustum();
|
||||
void updateLastKnownViewFrustum();
|
||||
|
||||
bool getViewSent() const { return _viewSent; };
|
||||
void setViewSent(bool viewSent) { _viewSent = viewSent; }
|
||||
|
||||
private:
|
||||
bool _viewSent;
|
||||
unsigned char* _voxelPacket;
|
||||
unsigned char* _voxelPacketAt;
|
||||
int _voxelPacketAvailableBytes;
|
||||
|
|
|
@ -234,12 +234,21 @@ void deepestLevelVoxelDistributor(AgentList* agentList,
|
|||
bool wantDelta = agentData->getWantDelta();
|
||||
const ViewFrustum* lastViewFrustum = wantDelta ? &agentData->getLastKnownViewFrustum() : NULL;
|
||||
|
||||
printf("deepestLevelVoxelDistributor() viewFrustumChanged=%s, nodeBag.isEmpty=%s, viewSent=%s\n",
|
||||
viewFrustumChanged ? "yes" : "no",
|
||||
agentData->nodeBag.isEmpty() ? "yes" : "no",
|
||||
agentData->getViewSent() ? "yes" : "no"
|
||||
);
|
||||
|
||||
// If the current view frustum has changed OR we have nothing to send, then search against
|
||||
// the current view frustum for things to send.
|
||||
if (viewFrustumChanged || agentData->nodeBag.isEmpty()) {
|
||||
// If the bag was empty, then send everything in view, not just the delta
|
||||
maxLevelReached = randomTree.searchForColoredNodes(INT_MAX, randomTree.rootNode, agentData->getCurrentViewFrustum(),
|
||||
agentData->nodeBag, wantDelta, lastViewFrustum);
|
||||
|
||||
agentData->setViewSent(false);
|
||||
|
||||
}
|
||||
double end = usecTimestampNow();
|
||||
double elapsedmsec = (end - start)/1000.0;
|
||||
|
@ -323,6 +332,7 @@ void deepestLevelVoxelDistributor(AgentList* agentList,
|
|||
// the voxels from the current view frustum
|
||||
if (agentData->nodeBag.isEmpty()) {
|
||||
agentData->updateLastKnownViewFrustum();
|
||||
agentData->setViewSent(true);
|
||||
}
|
||||
|
||||
|
||||
|
@ -354,6 +364,7 @@ void *distributeVoxelsToListeners(void *args) {
|
|||
// Sometimes the agent data has not yet been linked, in which case we can't really do anything
|
||||
if (agentData) {
|
||||
bool viewFrustumChanged = agentData->updateCurrentViewFrustum();
|
||||
printf("agentData->updateCurrentViewFrustum() viewFrustumChanged=%s\n", (viewFrustumChanged ? "yes" : "no"));
|
||||
|
||||
if (agentData->getWantResIn()) {
|
||||
resInVoxelDistributor(agentList, agent, agentData);
|
||||
|
|
Loading…
Reference in a new issue