adding jurisdiction to scene stats to implement add/drop effect, added command line to voxel server to not send environments

This commit is contained in:
ZappoMan 2013-08-05 16:30:08 -07:00
parent 7a3d254aca
commit 01ba5ee81a
5 changed files with 51 additions and 5 deletions

View file

@ -24,7 +24,9 @@ PACKET_VERSION versionForPacketType(PACKET_TYPE type) {
case PACKET_TYPE_AVATAR_FACE_VIDEO:
return 1;
case PACKET_TYPE_VOXEL_STATS:
return 1;
default:
return 0;
}

View file

@ -30,6 +30,8 @@ public:
bool writeToFile(const char* filename);
bool readFromFile(const char* filename);
unsigned char* getRootOctalCode() const { return _rootOctalCode; }
private:
void clear();

View file

@ -22,9 +22,10 @@ VoxelSceneStats::VoxelSceneStats() :
reset();
_isReadyToSend = false;
_isStarted = false;
_jurisdictionRoot = NULL;
}
void VoxelSceneStats::sceneStarted(bool isFullScene, bool isMoving, VoxelNode* root) {
void VoxelSceneStats::sceneStarted(bool isFullScene, bool isMoving, VoxelNode* root, JurisdictionMap* jurisdictionMap) {
reset(); // resets packet and voxel stats
_isStarted = true;
_start = usecTimestampNow();
@ -34,6 +35,7 @@ void VoxelSceneStats::sceneStarted(bool isFullScene, bool isMoving, VoxelNode* r
_isFullScene = isFullScene;
_isMoving = isMoving;
_jurisdictionRoot = jurisdictionMap->getRootOctalCode();
}
void VoxelSceneStats::sceneCompleted() {
@ -273,6 +275,20 @@ int VoxelSceneStats::packIntoMessage(unsigned char* destinationBuffer, int avail
destinationBuffer += sizeof(_existsInPacketBitsWritten);
memcpy(destinationBuffer, &_treesRemoved, sizeof(_treesRemoved));
destinationBuffer += sizeof(_treesRemoved);
// add the root jurisdiction
if (_jurisdictionRoot) {
// copy the
int bytes = bytesRequiredForCodeLength(numberOfThreeBitSectionsInCode(_jurisdictionRoot));
memcpy(destinationBuffer, &bytes, sizeof(bytes));
destinationBuffer += sizeof(bytes);
memcpy(destinationBuffer, _jurisdictionRoot, bytes);
destinationBuffer += bytes;
} else {
int bytes = 0;
memcpy(destinationBuffer, &bytes, sizeof(bytes));
destinationBuffer += sizeof(bytes);
}
return destinationBuffer - bufferStart; // includes header!
}
@ -363,6 +379,19 @@ int VoxelSceneStats::unpackFromMessage(unsigned char* sourceBuffer, int availabl
sourceBuffer += sizeof(_existsInPacketBitsWritten);
memcpy(&_treesRemoved, sourceBuffer, sizeof(_treesRemoved));
sourceBuffer += sizeof(_treesRemoved);
// read the root jurisdiction
int bytes = 0;
memcpy(&bytes, sourceBuffer, sizeof(bytes));
sourceBuffer += sizeof(bytes);
if (bytes == 0) {
_jurisdictionRoot = NULL;
} else {
_jurisdictionRoot = new unsigned char[bytes];
memcpy(_jurisdictionRoot, sourceBuffer, bytes);
sourceBuffer += bytes;
}
// running averages
_elapsedAverage.updateAverage((float)_elapsed);

View file

@ -12,6 +12,7 @@
#include <stdint.h>
#include <NodeList.h>
#include "JurisdictionMap.h"
class VoxelNode;
@ -19,7 +20,7 @@ class VoxelSceneStats {
public:
VoxelSceneStats();
void reset();
void sceneStarted(bool fullScene, bool moving, VoxelNode* root);
void sceneStarted(bool fullScene, bool moving, VoxelNode* root, JurisdictionMap* jurisdictionMap);
void sceneCompleted();
void printDebugDetails();
@ -165,6 +166,8 @@ private:
static ItemInfo _ITEMS[];
static int const MAX_ITEM_VALUE_LENGTH = 128;
char _itemValueBuffer[MAX_ITEM_VALUE_LENGTH];
unsigned char* _jurisdictionRoot;
};
#endif /* defined(__hifi__VoxelSceneStats__) */

View file

@ -64,6 +64,7 @@ bool debugVoxelSending = false;
bool shouldShowAnimationDebug = false;
bool displayVoxelStats = false;
bool debugVoxelReceiving = false;
bool sendEnvironments = true;
EnvironmentData environmentData[3];
@ -255,7 +256,7 @@ void deepestLevelVoxelDistributor(NodeList* nodeList,
// start tracking our stats
bool isFullScene = (!viewFrustumChanged || !nodeData->getWantDelta()) && nodeData->getViewFrustumJustStoppedChanging();
nodeData->stats.sceneStarted(isFullScene, viewFrustumChanged, ::serverTree.rootNode);
nodeData->stats.sceneStarted(isFullScene, viewFrustumChanged, ::serverTree.rootNode, ::jurisdiction);
}
// If we have something in our nodeBag, then turn them into packets and send them out...
@ -265,7 +266,7 @@ void deepestLevelVoxelDistributor(NodeList* nodeList,
int packetsSentThisInterval = 0;
uint64_t start = usecTimestampNow();
bool shouldSendEnvironments = shouldDo(ENVIRONMENT_SEND_INTERVAL_USECS, VOXEL_SEND_INTERVAL_USECS);
bool shouldSendEnvironments = ::sendEnvironments && shouldDo(ENVIRONMENT_SEND_INTERVAL_USECS, VOXEL_SEND_INTERVAL_USECS);
while (packetsSentThisInterval < PACKETS_PER_CLIENT_PER_INTERVAL - (shouldSendEnvironments ? 1 : 0)) {
// Check to see if we're taking too long, and if so bail early...
uint64_t now = usecTimestampNow();
@ -473,6 +474,15 @@ int main(int argc, const char * argv[]) {
jurisdiction = new JurisdictionMap(jurisdictionRoot, jurisdictionEndNodes);
}
}
// should we send environments? Default is yes, but this command line suppresses sending
const char* DONT_SEND_ENVIRONMENTS = "--dontSendEnvironments";
bool dontSendEnvironments = cmdOptionExists(argc, argv, DONT_SEND_ENVIRONMENTS);
if (dontSendEnvironments) {
printf("Sending environments suppressed...\n");
::sendEnvironments = false;
}
printf("Sending environments=%s\n", debug::valueOf(::sendEnvironments));
NodeList* nodeList = NodeList::createInstance(NODE_TYPE_VOXEL_SERVER, listenPort);
setvbuf(stdout, NULL, _IOLBF, 0);