Merge branch 'master' of git://github.com/worklist/hifi into the_midget_are_coming

This commit is contained in:
Atlante45 2013-07-11 14:10:40 -07:00
commit 7f0ab0289e
12 changed files with 133 additions and 55 deletions

View file

@ -1236,12 +1236,16 @@ void Application::doTreeStats() {
_voxels.collectStatsForTreesAndVBOs(); _voxels.collectStatsForTreesAndVBOs();
} }
void Application::setWantsLowResMoving(bool wantsLowResMoving) {
_myAvatar.setWantLowResMoving(wantsLowResMoving);
}
void Application::setWantsMonochrome(bool wantsMonochrome) { void Application::setWantsMonochrome(bool wantsMonochrome) {
_myAvatar.setWantColor(!wantsMonochrome); _myAvatar.setWantColor(!wantsMonochrome);
} }
void Application::setWantsDelta(bool wantsDelta) { void Application::disableDeltaSending(bool disableDeltaSending) {
_myAvatar.setWantDelta(wantsDelta); _myAvatar.setWantDelta(!disableDeltaSending);
} }
void Application::disableOcclusionCulling(bool disableOcclusionCulling) { void Application::disableOcclusionCulling(bool disableOcclusionCulling) {
@ -1635,9 +1639,11 @@ void Application::initMenu() {
renderDebugMenu->addAction("FALSE Color Occluded V2 Voxels", this, SLOT(doFalseColorizeOccludedV2()), Qt::CTRL | Qt::Key_P); renderDebugMenu->addAction("FALSE Color Occluded V2 Voxels", this, SLOT(doFalseColorizeOccludedV2()), Qt::CTRL | Qt::Key_P);
renderDebugMenu->addAction("Show TRUE Colors", this, SLOT(doTrueVoxelColors()), Qt::CTRL | Qt::Key_T); renderDebugMenu->addAction("Show TRUE Colors", this, SLOT(doTrueVoxelColors()), Qt::CTRL | Qt::Key_T);
debugMenu->addAction("Wants Monochrome", this, SLOT(setWantsMonochrome(bool)))->setCheckable(true);
debugMenu->addAction("Wants View Delta Sending", this, SLOT(setWantsDelta(bool)))->setCheckable(true);
(_shouldLowPassFilter = debugMenu->addAction("Test: LowPass filter"))->setCheckable(true); (_shouldLowPassFilter = debugMenu->addAction("Test: LowPass filter"))->setCheckable(true);
debugMenu->addAction("Wants Monochrome", this, SLOT(setWantsMonochrome(bool)))->setCheckable(true);
debugMenu->addAction("Use Lower Resolution While Moving", this, SLOT(setWantsLowResMoving(bool)))->setCheckable(true);
debugMenu->addAction("Disable Delta Sending", this, SLOT(disableDeltaSending(bool)))->setCheckable(true);
debugMenu->addAction("Disable Occlusion Culling", this, SLOT(disableOcclusionCulling(bool)), debugMenu->addAction("Disable Occlusion Culling", this, SLOT(disableOcclusionCulling(bool)),
Qt::SHIFT | Qt::Key_C)->setCheckable(true); Qt::SHIFT | Qt::Key_C)->setCheckable(true);

View file

@ -136,7 +136,8 @@ private slots:
void doTrueVoxelColors(); void doTrueVoxelColors();
void doTreeStats(); void doTreeStats();
void setWantsMonochrome(bool wantsMonochrome); void setWantsMonochrome(bool wantsMonochrome);
void setWantsDelta(bool wantsDelta); void setWantsLowResMoving(bool wantsLowResMoving);
void disableDeltaSending(bool disableDeltaSending);
void disableOcclusionCulling(bool disableOcclusionCulling); void disableOcclusionCulling(bool disableOcclusionCulling);
void updateVoxelModeActions(); void updateVoxelModeActions();
void decreaseVoxelSize(); void decreaseVoxelSize();

View file

@ -31,7 +31,7 @@ const short NO_READ_MAXIMUM_MSECS = 3000;
const int GRAVITY_SAMPLES = 60; // Use the first few samples to baseline values const int GRAVITY_SAMPLES = 60; // Use the first few samples to baseline values
const int NORTH_SAMPLES = 30; const int NORTH_SAMPLES = 30;
const int ACCELERATION_SENSOR_FUSION_SAMPLES = 20; const int ACCELERATION_SENSOR_FUSION_SAMPLES = 20;
const int COMPASS_SENSOR_FUSION_SAMPLES = 200; const int COMPASS_SENSOR_FUSION_SAMPLES = 100;
const int LONG_TERM_RATE_SAMPLES = 1000; const int LONG_TERM_RATE_SAMPLES = 1000;
const bool USING_INVENSENSE_MPU9150 = 1; const bool USING_INVENSENSE_MPU9150 = 1;
@ -383,7 +383,7 @@ void SerialInterface::resetSerial() {
glm::vec3 SerialInterface::recenterCompass(const glm::vec3& compass) { glm::vec3 SerialInterface::recenterCompass(const glm::vec3& compass) {
// compensate for "hard iron" distortion by subtracting the midpoint on each axis; see // compensate for "hard iron" distortion by subtracting the midpoint on each axis; see
// http://www.sensorsmag.com/sensors/motion-velocity-displacement/compensating-tilt-hard-iron-and-soft-iron-effects-6475 // http://www.sensorsmag.com/sensors/motion-velocity-displacement/compensating-tilt-hard-iron-and-soft-iron-effects-6475
return compass - (_compassMinima + _compassMaxima) * 0.5f; return (compass - (_compassMinima + _compassMaxima) * 0.5f) / (_compassMaxima - _compassMinima);
} }

View file

@ -33,8 +33,8 @@ public:
_estimatedVelocity(0, 0, 0), _estimatedVelocity(0, 0, 0),
_lastAcceleration(0, 0, 0), _lastAcceleration(0, 0, 0),
_lastRotationRates(0, 0, 0), _lastRotationRates(0, 0, 0),
_compassMinima(-235, -132, -184), // experimentally derived initial values follow _compassMinima(-211, -132, -186),
_compassMaxima(83, 155, 120), _compassMaxima(89, 95, 98),
_angularVelocityToLinearAccel( _angularVelocityToLinearAccel(
0.003f, -0.001f, -0.006f, 0.003f, -0.001f, -0.006f,
-0.005f, -0.001f, -0.006f, -0.005f, -0.001f, -0.006f,

View file

@ -891,13 +891,11 @@ bool VoxelSystem::removeOutOfViewOperation(VoxelNode* node, void* extraData) {
bool VoxelSystem::isViewChanging() { bool VoxelSystem::isViewChanging() {
bool result = false; // assume the best bool result = false; // assume the best
/** TEMPORARY HACK ******
// If our viewFrustum has changed since our _lastKnowViewFrustum // If our viewFrustum has changed since our _lastKnowViewFrustum
if (_viewFrustum && !_lastKnowViewFrustum.matches(_viewFrustum)) { if (!_lastKnowViewFrustum.matches(Application::getInstance()->getViewFrustum())) {
result = true; result = true;
_lastKnowViewFrustum = *_viewFrustum; // save last known _lastKnowViewFrustum = *Application::getInstance()->getViewFrustum(); // save last known
} }
**/
return result; return result;
} }

View file

@ -33,7 +33,8 @@ AvatarData::AvatarData(Node* owningNode) :
_cameraFarClip(0.0f), _cameraFarClip(0.0f),
_keyState(NO_KEY_DOWN), _keyState(NO_KEY_DOWN),
_wantColor(true), _wantColor(true),
_wantDelta(false), _wantDelta(true),
_wantLowResMoving(false),
_wantOcclusionCulling(true), _wantOcclusionCulling(true),
_headData(NULL), _headData(NULL),
_handData(NULL) _handData(NULL)
@ -112,8 +113,9 @@ int AvatarData::getBroadcastData(unsigned char* destinationBuffer) {
// bitMask of less than byte wide items // bitMask of less than byte wide items
unsigned char bitItems = 0; unsigned char bitItems = 0;
if (_wantColor) { setAtBit(bitItems, WANT_COLOR_AT_BIT); } if (_wantLowResMoving) { setAtBit(bitItems, WANT_LOW_RES_MOVING_BIT); }
if (_wantDelta) { setAtBit(bitItems, WANT_DELTA_AT_BIT); } if (_wantColor) { setAtBit(bitItems, WANT_COLOR_AT_BIT); }
if (_wantDelta) { setAtBit(bitItems, WANT_DELTA_AT_BIT); }
if (_wantOcclusionCulling) { setAtBit(bitItems, WANT_OCCLUSION_CULLING_BIT); } if (_wantOcclusionCulling) { setAtBit(bitItems, WANT_OCCLUSION_CULLING_BIT); }
// key state // key state
@ -239,8 +241,9 @@ int AvatarData::parseData(unsigned char* sourceBuffer, int numBytes) {
// voxel sending features... // voxel sending features...
unsigned char bitItems = 0; unsigned char bitItems = 0;
bitItems = (unsigned char)*sourceBuffer++; bitItems = (unsigned char)*sourceBuffer++;
_wantColor = oneAtBit(bitItems, WANT_COLOR_AT_BIT); _wantLowResMoving = oneAtBit(bitItems, WANT_LOW_RES_MOVING_BIT);
_wantDelta = oneAtBit(bitItems, WANT_DELTA_AT_BIT); _wantColor = oneAtBit(bitItems, WANT_COLOR_AT_BIT);
_wantDelta = oneAtBit(bitItems, WANT_DELTA_AT_BIT);
_wantOcclusionCulling = oneAtBit(bitItems, WANT_OCCLUSION_CULLING_BIT); _wantOcclusionCulling = oneAtBit(bitItems, WANT_OCCLUSION_CULLING_BIT);
// key state, stored as a semi-nibble in the bitItems // key state, stored as a semi-nibble in the bitItems

View file

@ -20,7 +20,7 @@
#include "HeadData.h" #include "HeadData.h"
#include "HandData.h" #include "HandData.h"
const int UNUSED_BIT = 0; // this bit is available to use const int WANT_LOW_RES_MOVING_BIT = 0;
const int WANT_COLOR_AT_BIT = 1; const int WANT_COLOR_AT_BIT = 1;
const int WANT_DELTA_AT_BIT = 2; const int WANT_DELTA_AT_BIT = 2;
const int KEY_STATE_START_BIT = 3; // 4th and 5th bits const int KEY_STATE_START_BIT = 3; // 4th and 5th bits
@ -91,11 +91,14 @@ public:
const std::string& chatMessage () const { return _chatMessage; } const std::string& chatMessage () const { return _chatMessage; }
// related to Voxel Sending strategies // related to Voxel Sending strategies
bool getWantColor() const { return _wantColor; } bool getWantColor() const { return _wantColor; }
bool getWantDelta() const { return _wantDelta; } bool getWantDelta() const { return _wantDelta; }
bool getWantLowResMoving() const { return _wantLowResMoving; }
bool getWantOcclusionCulling() const { return _wantOcclusionCulling; } bool getWantOcclusionCulling() const { return _wantOcclusionCulling; }
void setWantColor(bool wantColor) { _wantColor = wantColor; }
void setWantDelta(bool wantDelta) { _wantDelta = wantDelta; } void setWantColor(bool wantColor) { _wantColor = wantColor; }
void setWantDelta(bool wantDelta) { _wantDelta = wantDelta; }
void setWantLowResMoving(bool wantLowResMoving) { _wantLowResMoving = wantLowResMoving; }
void setWantOcclusionCulling(bool wantOcclusionCulling) { _wantOcclusionCulling = wantOcclusionCulling; } void setWantOcclusionCulling(bool wantOcclusionCulling) { _wantOcclusionCulling = wantOcclusionCulling; }
void setHeadData(HeadData* headData) { _headData = headData; } void setHeadData(HeadData* headData) { _headData = headData; }
@ -130,6 +133,7 @@ protected:
// voxel server sending items // voxel server sending items
bool _wantColor; bool _wantColor;
bool _wantDelta; bool _wantDelta;
bool _wantLowResMoving;
bool _wantOcclusionCulling; bool _wantOcclusionCulling;
std::vector<JointData> _joints; std::vector<JointData> _joints;

View file

@ -1169,7 +1169,7 @@ int VoxelTree::encodeTreeBitstreamRecursion(VoxelNode* node, unsigned char* outp
// caller can pass NULL as viewFrustum if they want everything // caller can pass NULL as viewFrustum if they want everything
if (params.viewFrustum) { if (params.viewFrustum) {
float distance = node->distanceToCamera(*params.viewFrustum); float distance = node->distanceToCamera(*params.viewFrustum);
float boundaryDistance = boundaryDistanceForRenderLevel(*node->getOctalCode() + 1); float boundaryDistance = boundaryDistanceForRenderLevel(node->getLevel() + params.boundaryLevelAdjust);
// If we're too far away for our render level, then just return // If we're too far away for our render level, then just return
if (distance >= boundaryDistance) { if (distance >= boundaryDistance) {
@ -1182,7 +1182,26 @@ int VoxelTree::encodeTreeBitstreamRecursion(VoxelNode* node, unsigned char* outp
if (!node->isInView(*params.viewFrustum)) { if (!node->isInView(*params.viewFrustum)) {
return bytesAtThisLevel; 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. // 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 // 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); CoverageMapStorageResult result = params.map->checkMap(voxelPolygon, false);
delete voxelPolygon; // cleanup delete voxelPolygon; // cleanup
if (result == OCCLUDED) { 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; return bytesAtThisLevel;
} }
} else { } 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 // 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... // we do need to clean up memory and proceed as normal...
delete voxelPolygon; delete voxelPolygon;
@ -1285,7 +1297,8 @@ int VoxelTree::encodeTreeBitstreamRecursion(VoxelNode* node, unsigned char* outp
if (childIsInView) { if (childIsInView) {
// Before we determine consider this further, let's see if it's in our LOD scope... // Before we determine consider this further, let's see if it's in our LOD scope...
float distance = distancesToChildren[i]; // params.viewFrustum ? childNode->distanceToCamera(*params.viewFrustum) : 0; float distance = distancesToChildren[i]; // params.viewFrustum ? childNode->distanceToCamera(*params.viewFrustum) : 0;
float boundaryDistance = params.viewFrustum ? boundaryDistanceForRenderLevel(*childNode->getOctalCode() + 1) : 1; float boundaryDistance = !params.viewFrustum ? 1 :
boundaryDistanceForRenderLevel(childNode->getLevel() + params.boundaryLevelAdjust);
if (distance < boundaryDistance) { if (distance < boundaryDistance) {
inViewCount++; inViewCount++;
@ -1341,7 +1354,8 @@ int VoxelTree::encodeTreeBitstreamRecursion(VoxelNode* node, unsigned char* outp
if (params.viewFrustum && childNode->isColored() && !childNode->isLeaf()) { if (params.viewFrustum && childNode->isColored() && !childNode->isLeaf()) {
int grandChildrenInView = 0; int grandChildrenInView = 0;
int grandChildrenInLOD = 0; int grandChildrenInLOD = 0;
float grandChildBoundaryDistance = boundaryDistanceForRenderLevel(childNode->getLevel() + 2); float grandChildBoundaryDistance = boundaryDistanceForRenderLevel(childNode->getLevel() +
1 + params.boundaryLevelAdjust);
for (int grandChildIndex = 0; grandChildIndex < NUMBER_OF_CHILDREN; grandChildIndex++) { for (int grandChildIndex = 0; grandChildIndex < NUMBER_OF_CHILDREN; grandChildIndex++) {
VoxelNode* grandChild = childNode->getChildAtIndex(grandChildIndex); VoxelNode* grandChild = childNode->getChildAtIndex(grandChildIndex);

View file

@ -33,6 +33,8 @@ typedef enum {GRADIENT, RANDOM, NATURAL} creationMode;
#define WANT_OCCLUSION_CULLING true #define WANT_OCCLUSION_CULLING true
#define IGNORE_COVERAGE_MAP NULL #define IGNORE_COVERAGE_MAP NULL
#define DONT_CHOP 0 #define DONT_CHOP 0
#define NO_BOUNDARY_ADJUST 0
#define LOW_RES_MOVING_ADJUST 1
class EncodeBitstreamParams { class EncodeBitstreamParams {
public: public:
@ -46,6 +48,7 @@ public:
const ViewFrustum* lastViewFrustum; const ViewFrustum* lastViewFrustum;
bool wantOcclusionCulling; bool wantOcclusionCulling;
long childWasInViewDiscarded; long childWasInViewDiscarded;
int boundaryLevelAdjust;
CoverageMap* map; CoverageMap* map;
@ -58,18 +61,20 @@ public:
bool deltaViewFrustum = false, bool deltaViewFrustum = false,
const ViewFrustum* lastViewFrustum = IGNORE_VIEW_FRUSTUM, const ViewFrustum* lastViewFrustum = IGNORE_VIEW_FRUSTUM,
bool wantOcclusionCulling= NO_OCCLUSION_CULLING, bool wantOcclusionCulling= NO_OCCLUSION_CULLING,
CoverageMap* map = IGNORE_COVERAGE_MAP) : CoverageMap* map = IGNORE_COVERAGE_MAP,
maxEncodeLevel (maxEncodeLevel), int boundaryLevelAdjust = NO_BOUNDARY_ADJUST) :
maxLevelReached (0), maxEncodeLevel (maxEncodeLevel),
viewFrustum (viewFrustum), maxLevelReached (0),
includeColor (includeColor), viewFrustum (viewFrustum),
includeExistsBits (includeExistsBits), includeColor (includeColor),
chopLevels (chopLevels), includeExistsBits (includeExistsBits),
deltaViewFrustum (deltaViewFrustum), chopLevels (chopLevels),
lastViewFrustum (lastViewFrustum), deltaViewFrustum (deltaViewFrustum),
wantOcclusionCulling(wantOcclusionCulling), lastViewFrustum (lastViewFrustum),
childWasInViewDiscarded(0), wantOcclusionCulling (wantOcclusionCulling),
map (map) childWasInViewDiscarded (0),
boundaryLevelAdjust (boundaryLevelAdjust),
map (map)
{} {}
}; };

View file

@ -17,7 +17,9 @@ VoxelNodeData::VoxelNodeData(Node* owningNode) :
_voxelPacketAvailableBytes(MAX_VOXEL_PACKET_SIZE), _voxelPacketAvailableBytes(MAX_VOXEL_PACKET_SIZE),
_maxSearchLevel(1), _maxSearchLevel(1),
_maxLevelReachedInLastSearch(1), _maxLevelReachedInLastSearch(1),
_lastTimeBagEmpty(0) _lastTimeBagEmpty(0),
_viewFrustumChanging(false),
_currentPacketIsColor(true)
{ {
_voxelPacket = new unsigned char[MAX_VOXEL_PACKET_SIZE]; _voxelPacket = new unsigned char[MAX_VOXEL_PACKET_SIZE];
_voxelPacketAt = _voxelPacket; _voxelPacketAt = _voxelPacket;
@ -27,7 +29,10 @@ VoxelNodeData::VoxelNodeData(Node* owningNode) :
void VoxelNodeData::resetVoxelPacket() { void VoxelNodeData::resetVoxelPacket() {
PACKET_TYPE voxelPacketType = getWantColor() ? PACKET_TYPE_VOXEL_DATA : PACKET_TYPE_VOXEL_DATA_MONOCHROME; // If we're moving, and the client asked for low res, then we force monochrome, otherwise, use
// the clients requested color state.
_currentPacketIsColor = (getWantLowResMoving() && _viewFrustumChanging) ? false : getWantColor();
PACKET_TYPE voxelPacketType = _currentPacketIsColor ? PACKET_TYPE_VOXEL_DATA : PACKET_TYPE_VOXEL_DATA_MONOCHROME;
int numBytesPacketHeader = populateTypeAndVersion(_voxelPacket, voxelPacketType); int numBytesPacketHeader = populateTypeAndVersion(_voxelPacket, voxelPacketType);
_voxelPacketAt = _voxelPacket + numBytesPacketHeader; _voxelPacketAt = _voxelPacket + numBytesPacketHeader;
_voxelPacketAvailableBytes = MAX_VOXEL_PACKET_SIZE - numBytesPacketHeader; _voxelPacketAvailableBytes = MAX_VOXEL_PACKET_SIZE - numBytesPacketHeader;
@ -64,6 +69,7 @@ bool VoxelNodeData::updateCurrentViewFrustum() {
_currentViewFrustum.calculate(); _currentViewFrustum.calculate();
currentViewFrustumChanged = true; currentViewFrustumChanged = true;
} }
_viewFrustumChanging = currentViewFrustumChanged;
return currentViewFrustumChanged; return currentViewFrustumChanged;
} }

View file

@ -53,6 +53,7 @@ public:
uint64_t getLastTimeBagEmpty() const { return _lastTimeBagEmpty; }; uint64_t getLastTimeBagEmpty() const { return _lastTimeBagEmpty; };
void setLastTimeBagEmpty(uint64_t lastTimeBagEmpty) { _lastTimeBagEmpty = lastTimeBagEmpty; }; void setLastTimeBagEmpty(uint64_t lastTimeBagEmpty) { _lastTimeBagEmpty = lastTimeBagEmpty; };
bool getCurrentPacketIsColor() const { return _currentPacketIsColor; };
private: private:
VoxelNodeData(const VoxelNodeData &); VoxelNodeData(const VoxelNodeData &);
VoxelNodeData& operator= (const VoxelNodeData&); VoxelNodeData& operator= (const VoxelNodeData&);
@ -67,7 +68,8 @@ private:
ViewFrustum _currentViewFrustum; ViewFrustum _currentViewFrustum;
ViewFrustum _lastKnownViewFrustum; ViewFrustum _lastKnownViewFrustum;
uint64_t _lastTimeBagEmpty; uint64_t _lastTimeBagEmpty;
bool _viewFrustumChanging;
bool _currentPacketIsColor;
}; };
#endif /* defined(__hifi__VoxelNodeData__) */ #endif /* defined(__hifi__VoxelNodeData__) */

View file

@ -123,9 +123,47 @@ void deepestLevelVoxelDistributor(NodeList* nodeList,
int maxLevelReached = 0; int maxLevelReached = 0;
uint64_t start = usecTimestampNow(); uint64_t start = usecTimestampNow();
int truePacketsSent = 0;
int trueBytesSent = 0;
// 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 = viewFrustumChanged && nodeData->getWantDelta(); bool wantDelta = viewFrustumChanged && nodeData->getWantDelta();
// If our packet already has content in it, then we must use the color choice of the waiting packet.
// If we're starting a fresh packet, then...
// If we're moving, and the client asked for low res, then we force monochrome, otherwise, use
// the clients requested color state.
bool wantColor = ((nodeData->getWantLowResMoving() && viewFrustumChanged) ? false : nodeData->getWantColor());
// If we have a packet waiting, and our desired want color, doesn't match the current waiting packets color
// then let's just send that waiting packet.
if (wantColor != nodeData->getCurrentPacketIsColor()) {
if (nodeData->isPacketWaiting()) {
if (::debugVoxelSending) {
printf("wantColor=%s --- SENDING PARTIAL PACKET! nodeData->getCurrentPacketIsColor()=%s\n",
debug::valueOf(wantColor), debug::valueOf(nodeData->getCurrentPacketIsColor()));
}
nodeList->getNodeSocket()->send(node->getActiveSocket(),
nodeData->getPacket(), nodeData->getPacketLength());
trueBytesSent += nodeData->getPacketLength();
truePacketsSent++;
nodeData->resetVoxelPacket();
} else {
if (::debugVoxelSending) {
printf("wantColor=%s --- FIXING HEADER! nodeData->getCurrentPacketIsColor()=%s\n",
debug::valueOf(wantColor), debug::valueOf(nodeData->getCurrentPacketIsColor()));
}
nodeData->resetVoxelPacket();
}
}
if (::debugVoxelSending) {
printf("wantColor=%s getCurrentPacketIsColor()=%s, viewFrustumChanged=%s, getWantLowResMoving()=%s\n",
debug::valueOf(wantColor), debug::valueOf(nodeData->getCurrentPacketIsColor()),
debug::valueOf(viewFrustumChanged), debug::valueOf(nodeData->getWantLowResMoving()));
}
const ViewFrustum* lastViewFrustum = wantDelta ? &nodeData->getLastKnownViewFrustum() : NULL; const ViewFrustum* lastViewFrustum = wantDelta ? &nodeData->getLastKnownViewFrustum() : NULL;
if (::debugVoxelSending) { if (::debugVoxelSending) {
@ -149,9 +187,11 @@ void deepestLevelVoxelDistributor(NodeList* nodeList,
} else { } else {
printf("elapsed time to send scene = %f seconds", elapsedSceneSend); printf("elapsed time to send scene = %f seconds", elapsedSceneSend);
} }
printf(" [occlusionCulling: %s]\n", debug::valueOf(nodeData->getWantOcclusionCulling())); printf(" [occlusionCulling:%s, wantDelta:%s, wantColor:%s ]\n",
debug::valueOf(nodeData->getWantOcclusionCulling()), debug::valueOf(wantDelta),
debug::valueOf(wantColor));
} }
nodeData->setLastTimeBagEmpty(now); nodeData->setLastTimeBagEmpty(now); // huh? why is this inside debug? probably not what we want
} }
// if our view has changed, we need to reset these things... // if our view has changed, we need to reset these things...
@ -199,8 +239,6 @@ void deepestLevelVoxelDistributor(NodeList* nodeList,
static unsigned char tempOutputBuffer[MAX_VOXEL_PACKET_SIZE - 1]; // save on allocs by making this static static unsigned char tempOutputBuffer[MAX_VOXEL_PACKET_SIZE - 1]; // save on allocs by making this static
int bytesWritten = 0; int bytesWritten = 0;
int packetsSentThisInterval = 0; int packetsSentThisInterval = 0;
int truePacketsSent = 0;
int trueBytesSent = 0;
uint64_t start = usecTimestampNow(); uint64_t start = usecTimestampNow();
bool shouldSendEnvironments = shouldDo(ENVIRONMENT_SEND_INTERVAL_USECS, VOXEL_SEND_INTERVAL_USECS); bool shouldSendEnvironments = shouldDo(ENVIRONMENT_SEND_INTERVAL_USECS, VOXEL_SEND_INTERVAL_USECS);
@ -224,10 +262,12 @@ void deepestLevelVoxelDistributor(NodeList* nodeList,
VoxelNode* subTree = nodeData->nodeBag.extract(); VoxelNode* subTree = nodeData->nodeBag.extract();
bool wantOcclusionCulling = nodeData->getWantOcclusionCulling(); bool wantOcclusionCulling = nodeData->getWantOcclusionCulling();
CoverageMap* coverageMap = wantOcclusionCulling ? &nodeData->map : IGNORE_COVERAGE_MAP; CoverageMap* coverageMap = wantOcclusionCulling ? &nodeData->map : IGNORE_COVERAGE_MAP;
int boundaryLevelAdjust = viewFrustumChanged && nodeData->getWantLowResMoving()
? LOW_RES_MOVING_ADJUST : NO_BOUNDARY_ADJUST;
EncodeBitstreamParams params(INT_MAX, &nodeData->getCurrentViewFrustum(), nodeData->getWantColor(), EncodeBitstreamParams params(INT_MAX, &nodeData->getCurrentViewFrustum(), wantColor,
WANT_EXISTS_BITS, DONT_CHOP, wantDelta, lastViewFrustum, WANT_EXISTS_BITS, DONT_CHOP, wantDelta, lastViewFrustum,
wantOcclusionCulling, coverageMap); wantOcclusionCulling, coverageMap, boundaryLevelAdjust);
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);
@ -254,7 +294,6 @@ void deepestLevelVoxelDistributor(NodeList* nodeList,
trueBytesSent += nodeData->getPacketLength(); trueBytesSent += nodeData->getPacketLength();
truePacketsSent++; truePacketsSent++;
nodeData->resetVoxelPacket(); nodeData->resetVoxelPacket();
} }
packetsSentThisInterval = PACKETS_PER_CLIENT_PER_INTERVAL; // done for now, no nodes left packetsSentThisInterval = PACKETS_PER_CLIENT_PER_INTERVAL; // done for now, no nodes left
} }