mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-14 16:43:14 +02:00
first cut at dirty bit sending support
This commit is contained in:
parent
1a2921e3e8
commit
538fc89739
7 changed files with 39 additions and 8 deletions
|
@ -47,6 +47,8 @@ void VoxelNode::init(unsigned char * octalCode) {
|
|||
_shouldRender = false;
|
||||
_isStagedForDeletion = false;
|
||||
|
||||
_lastChanged = usecTimestampNow();
|
||||
|
||||
calculateAABox();
|
||||
}
|
||||
|
||||
|
@ -66,6 +68,7 @@ void VoxelNode::setShouldRender(bool shouldRender) {
|
|||
if (shouldRender != _shouldRender) {
|
||||
_shouldRender = shouldRender;
|
||||
_isDirty = true;
|
||||
_lastChanged = usecTimestampNow();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -89,6 +92,7 @@ void VoxelNode::deleteChildAtIndex(int childIndex) {
|
|||
delete _children[childIndex];
|
||||
_children[childIndex] = NULL;
|
||||
_isDirty = true;
|
||||
_lastChanged = usecTimestampNow();
|
||||
_childCount--;
|
||||
}
|
||||
}
|
||||
|
@ -99,6 +103,7 @@ VoxelNode* VoxelNode::removeChildAtIndex(int childIndex) {
|
|||
if (_children[childIndex]) {
|
||||
_children[childIndex] = NULL;
|
||||
_isDirty = true;
|
||||
_lastChanged = usecTimestampNow();
|
||||
_childCount--;
|
||||
}
|
||||
return returnedChild;
|
||||
|
@ -108,6 +113,7 @@ void VoxelNode::addChildAtIndex(int childIndex) {
|
|||
if (!_children[childIndex]) {
|
||||
_children[childIndex] = new VoxelNode(childOctalCode(_octalCode, childIndex));
|
||||
_isDirty = true;
|
||||
_lastChanged = usecTimestampNow();
|
||||
_childCount++;
|
||||
}
|
||||
}
|
||||
|
@ -135,6 +141,7 @@ void VoxelNode::safeDeepDeleteChildAtIndex(int childIndex, bool& stagedForDeleti
|
|||
deleteChildAtIndex(childIndex);
|
||||
_isDirty = true;
|
||||
}
|
||||
_lastChanged = usecTimestampNow();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -178,6 +185,7 @@ void VoxelNode::setFalseColor(colorPart red, colorPart green, colorPart blue) {
|
|||
_currentColor[2] = blue;
|
||||
_currentColor[3] = 1; // XXXBHG - False colors are always considered set
|
||||
_isDirty = true;
|
||||
_lastChanged = usecTimestampNow();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -189,6 +197,7 @@ void VoxelNode::setFalseColored(bool isFalseColored) {
|
|||
}
|
||||
_falseColored = isFalseColored;
|
||||
_isDirty = true;
|
||||
_lastChanged = usecTimestampNow();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -202,6 +211,7 @@ void VoxelNode::setColor(const nodeColor& color) {
|
|||
memcpy(&_currentColor,&color,sizeof(nodeColor));
|
||||
}
|
||||
_isDirty = true;
|
||||
_lastChanged = usecTimestampNow();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -36,6 +36,8 @@ private:
|
|||
void calculateAABox();
|
||||
|
||||
void init(unsigned char * octalCode);
|
||||
|
||||
double _lastChanged;
|
||||
|
||||
public:
|
||||
VoxelNode(); // root node constructor
|
||||
|
@ -75,6 +77,8 @@ public:
|
|||
void printDebugDetails(const char* label) const;
|
||||
bool isDirty() const { return _isDirty; };
|
||||
void clearDirtyBit() { _isDirty = false; };
|
||||
bool hasChangedSince(double time) const { return (_lastChanged > time); };
|
||||
|
||||
glBufferIndex getBufferIndex() const { return _glBufferIndex; };
|
||||
bool isKnownBufferIndex() const { return (_glBufferIndex != GLBUFFER_INDEX_UNKNOWN); };
|
||||
void setBufferIndex(glBufferIndex index) { _glBufferIndex = index; };
|
||||
|
|
|
@ -862,7 +862,8 @@ int VoxelTree::searchForColoredNodesRecursion(int maxSearchLevel, int& currentSe
|
|||
|
||||
int VoxelTree::encodeTreeBitstream(int maxEncodeLevel, VoxelNode* node, unsigned char* outputBuffer, int availableBytes,
|
||||
VoxelNodeBag& bag, const ViewFrustum* viewFrustum, bool includeColor, bool includeExistsBits,
|
||||
bool deltaViewFrustum, const ViewFrustum* lastViewFrustum) const {
|
||||
bool deltaViewFrustum, const ViewFrustum* lastViewFrustum,
|
||||
double lastViewFrustumSent) const {
|
||||
|
||||
// How many bytes have we written so far at this level;
|
||||
int bytesWritten = 0;
|
||||
|
@ -883,7 +884,7 @@ int VoxelTree::encodeTreeBitstream(int maxEncodeLevel, VoxelNode* node, unsigned
|
|||
int currentEncodeLevel = 0;
|
||||
int childBytesWritten = encodeTreeBitstreamRecursion(maxEncodeLevel, currentEncodeLevel, node, outputBuffer, availableBytes,
|
||||
bag, viewFrustum, includeColor, includeExistsBits,
|
||||
deltaViewFrustum, lastViewFrustum);
|
||||
deltaViewFrustum, lastViewFrustum, lastViewFrustumSent);
|
||||
|
||||
// if childBytesWritten == 1 then something went wrong... that's not possible
|
||||
assert(childBytesWritten != 1);
|
||||
|
@ -907,7 +908,8 @@ int VoxelTree::encodeTreeBitstream(int maxEncodeLevel, VoxelNode* node, unsigned
|
|||
int VoxelTree::encodeTreeBitstreamRecursion(int maxEncodeLevel, int& currentEncodeLevel, VoxelNode* node,
|
||||
unsigned char* outputBuffer, int availableBytes, VoxelNodeBag& bag,
|
||||
const ViewFrustum* viewFrustum, bool includeColor, bool includeExistsBits,
|
||||
bool deltaViewFrustum, const ViewFrustum* lastViewFrustum) const {
|
||||
bool deltaViewFrustum, const ViewFrustum* lastViewFrustum,
|
||||
double lastViewFrustumSent) const {
|
||||
|
||||
// How many bytes have we written so far at this level;
|
||||
int bytesAtThisLevel = 0;
|
||||
|
@ -992,7 +994,8 @@ int VoxelTree::encodeTreeBitstreamRecursion(int maxEncodeLevel, int& currentEnco
|
|||
(lastViewFrustum && ViewFrustum::INSIDE == childNode->inFrustum(*lastViewFrustum)));
|
||||
|
||||
// track children with actual color, only if the child wasn't previously in view!
|
||||
if (childNode && childNode->isColored() && !childWasInView) {
|
||||
if (childNode && childNode->isColored() &&
|
||||
(!childWasInView || childNode->hasChangedSince(lastViewFrustumSent) )) {
|
||||
childrenColoredBits += (1 << (7 - i));
|
||||
inViewWithColorCount++;
|
||||
}
|
||||
|
@ -1063,7 +1066,7 @@ int VoxelTree::encodeTreeBitstreamRecursion(int maxEncodeLevel, int& currentEnco
|
|||
int childTreeBytesOut = encodeTreeBitstreamRecursion(maxEncodeLevel, thisLevel, childNode,
|
||||
outputBuffer, availableBytes, bag,
|
||||
viewFrustum, includeColor, includeExistsBits,
|
||||
deltaViewFrustum, lastViewFrustum);
|
||||
deltaViewFrustum, lastViewFrustum, lastViewFrustumSent);
|
||||
|
||||
// if the child wrote 0 bytes, it means that nothing below exists or was in view, or we ran out of space,
|
||||
// basically, the children below don't contain any info.
|
||||
|
|
|
@ -71,7 +71,8 @@ public:
|
|||
int encodeTreeBitstream(int maxEncodeLevel, VoxelNode* node, unsigned char* outputBuffer, int availableBytes,
|
||||
VoxelNodeBag& bag, const ViewFrustum* viewFrustum,
|
||||
bool includeColor = WANT_COLOR, bool includeExistsBits = WANT_EXISTS_BITS,
|
||||
bool deltaViewFrustum = false, const ViewFrustum* lastViewFrustum = NULL) const;
|
||||
bool deltaViewFrustum = false, const ViewFrustum* lastViewFrustum = NULL,
|
||||
double lastViewFrustumSent = 0) const;
|
||||
|
||||
int searchForColoredNodes(int maxSearchLevel, VoxelNode* node, const ViewFrustum& viewFrustum, VoxelNodeBag& bag,
|
||||
bool deltaViewFrustum = false, const ViewFrustum* lastViewFrustum = NULL);
|
||||
|
@ -100,7 +101,8 @@ private:
|
|||
int encodeTreeBitstreamRecursion(int maxEncodeLevel, int& currentEncodeLevel,
|
||||
VoxelNode* node, unsigned char* outputBuffer, int availableBytes, VoxelNodeBag& bag,
|
||||
const ViewFrustum* viewFrustum, bool includeColor, bool includeExistsBits,
|
||||
bool deltaViewFrustum, const ViewFrustum* lastViewFrustum) const;
|
||||
bool deltaViewFrustum, const ViewFrustum* lastViewFrustum,
|
||||
double lastViewFrustumSent) const;
|
||||
|
||||
int searchForColoredNodesRecursion(int maxSearchLevel, int& currentSearchLevel,
|
||||
VoxelNode* node, const ViewFrustum& viewFrustum, VoxelNodeBag& bag,
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include "PacketHeaders.h"
|
||||
#include "VoxelAgentData.h"
|
||||
#include "SharedUtil.h"
|
||||
#include <cstring>
|
||||
#include <cstdio>
|
||||
|
||||
|
@ -20,6 +21,7 @@ VoxelAgentData::VoxelAgentData(Agent* owningAgent) :
|
|||
{
|
||||
_voxelPacket = new unsigned char[MAX_VOXEL_PACKET_SIZE];
|
||||
_voxelPacketAt = _voxelPacket;
|
||||
_lastViewFrustumSent = 0;
|
||||
|
||||
resetVoxelPacket();
|
||||
}
|
||||
|
@ -72,5 +74,10 @@ void VoxelAgentData::updateLastKnownViewFrustum() {
|
|||
// save our currentViewFrustum into our lastKnownViewFrustum
|
||||
_lastKnownViewFrustum = _currentViewFrustum;
|
||||
}
|
||||
|
||||
// save that we know the view has been sent.
|
||||
double now = usecTimestampNow();
|
||||
printf("updateLastKnownViewFrustum() setLastViewSent() to %lf\n", now);
|
||||
setLastViewSent(now);
|
||||
}
|
||||
|
||||
|
|
|
@ -48,6 +48,9 @@ public:
|
|||
bool getViewSent() const { return _viewSent; };
|
||||
void setViewSent(bool viewSent) { _viewSent = viewSent; }
|
||||
|
||||
double getLastViewSent() const { return _lastViewFrustumSent; };
|
||||
void setLastViewSent(double viewSent) { _lastViewFrustumSent = viewSent; }
|
||||
|
||||
private:
|
||||
VoxelAgentData(const VoxelAgentData &);
|
||||
VoxelAgentData& operator= (const VoxelAgentData&);
|
||||
|
@ -61,6 +64,7 @@ private:
|
|||
int _maxLevelReachedInLastSearch;
|
||||
ViewFrustum _currentViewFrustum;
|
||||
ViewFrustum _lastKnownViewFrustum;
|
||||
double _lastViewFrustumSent;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -314,7 +314,7 @@ void deepestLevelVoxelDistributor(AgentList* agentList,
|
|||
&tempOutputBuffer[0], MAX_VOXEL_PACKET_SIZE - 1,
|
||||
agentData->nodeBag, &agentData->getCurrentViewFrustum(),
|
||||
agentData->getWantColor(), WANT_EXISTS_BITS,
|
||||
wantDelta, lastViewFrustum);
|
||||
wantDelta, lastViewFrustum, agentData->getLastViewSent());
|
||||
|
||||
if (agentData->getAvailable() >= bytesWritten) {
|
||||
agentData->writeToPacket(&tempOutputBuffer[0], bytesWritten);
|
||||
|
@ -370,6 +370,7 @@ void deepestLevelVoxelDistributor(AgentList* agentList,
|
|||
// if after sending packets we've emptied our bag, then we want to remember that we've sent all
|
||||
// the voxels from the current view frustum
|
||||
if (agentData->nodeBag.isEmpty()) {
|
||||
printf("agentData->nodeBag.isEmpty()...\n");
|
||||
agentData->updateLastKnownViewFrustum();
|
||||
agentData->setViewSent(true);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue