mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-10 00:36:34 +02:00
Merge pull request #247 from ZappoMan/render_voxels_optimization
Use different voxel persist files for local or server mode
This commit is contained in:
commit
ed9a7ae900
5 changed files with 19 additions and 10 deletions
|
@ -503,6 +503,7 @@ bool VoxelSystem::trueColorizeOperation(VoxelNode* node, void* extraData) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void VoxelSystem::trueColorize() {
|
void VoxelSystem::trueColorize() {
|
||||||
|
PerformanceWarning warn(true, "trueColorize()",true);
|
||||||
_nodeCount = 0;
|
_nodeCount = 0;
|
||||||
_tree->recurseTreeWithOperation(trueColorizeOperation);
|
_tree->recurseTreeWithOperation(trueColorizeOperation);
|
||||||
printLog("setting true color for %d nodes\n", _nodeCount);
|
printLog("setting true color for %d nodes\n", _nodeCount);
|
||||||
|
|
|
@ -108,15 +108,16 @@ int PerfStat::DumpStats(char** array) {
|
||||||
PerformanceWarning::~PerformanceWarning() {
|
PerformanceWarning::~PerformanceWarning() {
|
||||||
double end = usecTimestampNow();
|
double end = usecTimestampNow();
|
||||||
double elapsedmsec = (end - _start) / 1000.0;
|
double elapsedmsec = (end - _start) / 1000.0;
|
||||||
if (_renderWarningsOn && elapsedmsec > 1) {
|
if ((_alwaysDisplay || _renderWarningsOn) && elapsedmsec > 1) {
|
||||||
if (elapsedmsec > 1000) {
|
if (elapsedmsec > 1000) {
|
||||||
double elapsedsec = (end - _start) / 1000000.0;
|
double elapsedsec = (end - _start) / 1000000.0;
|
||||||
printLog("WARNING! %s took %lf seconds\n", _message, elapsedsec);
|
printLog("WARNING! %s took %lf seconds\n", _message, elapsedsec);
|
||||||
} else {
|
} else {
|
||||||
printLog("WARNING! %s took %lf milliseconds\n", _message, elapsedmsec);
|
printLog("WARNING! %s took %lf milliseconds\n", _message, elapsedmsec);
|
||||||
}
|
}
|
||||||
|
} else if (_alwaysDisplay) {
|
||||||
|
printLog("WARNING! %s took %lf milliseconds\n", _message, elapsedmsec);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -87,11 +87,13 @@ private:
|
||||||
double _start;
|
double _start;
|
||||||
const char* _message;
|
const char* _message;
|
||||||
bool _renderWarningsOn;
|
bool _renderWarningsOn;
|
||||||
|
bool _alwaysDisplay;
|
||||||
public:
|
public:
|
||||||
PerformanceWarning(bool renderWarnings, const char* message) :
|
PerformanceWarning(bool renderWarnings, const char* message, bool alwaysDisplay = false) :
|
||||||
_start(usecTimestampNow()),
|
_start(usecTimestampNow()),
|
||||||
_message(message),
|
_message(message),
|
||||||
_renderWarningsOn(renderWarnings) { };
|
_renderWarningsOn(renderWarnings),
|
||||||
|
_alwaysDisplay(alwaysDisplay) { };
|
||||||
|
|
||||||
~PerformanceWarning();
|
~PerformanceWarning();
|
||||||
};
|
};
|
||||||
|
|
|
@ -933,7 +933,7 @@ int VoxelTree::encodeTreeBitstreamRecursion(int maxEncodeLevel, int& currentEnco
|
||||||
bool VoxelTree::readFromFileV2(const char* fileName) {
|
bool VoxelTree::readFromFileV2(const char* fileName) {
|
||||||
std::ifstream file(fileName, std::ios::in|std::ios::binary|std::ios::ate);
|
std::ifstream file(fileName, std::ios::in|std::ios::binary|std::ios::ate);
|
||||||
if(file.is_open()) {
|
if(file.is_open()) {
|
||||||
printLog("loading file...\n");
|
printLog("loading file %s...\n", fileName);
|
||||||
|
|
||||||
// get file length....
|
// get file length....
|
||||||
unsigned long fileLength = file.tellg();
|
unsigned long fileLength = file.tellg();
|
||||||
|
@ -956,6 +956,8 @@ void VoxelTree::writeToFileV2(const char* fileName) const {
|
||||||
std::ofstream file(fileName, std::ios::out|std::ios::binary);
|
std::ofstream file(fileName, std::ios::out|std::ios::binary);
|
||||||
|
|
||||||
if(file.is_open()) {
|
if(file.is_open()) {
|
||||||
|
printLog("saving to file %s...\n", fileName);
|
||||||
|
|
||||||
VoxelNodeBag nodeBag;
|
VoxelNodeBag nodeBag;
|
||||||
nodeBag.insert(rootNode);
|
nodeBag.insert(rootNode);
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,8 @@
|
||||||
#include <ifaddrs.h>
|
#include <ifaddrs.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const char* VOXELS_PERSIST_FILE = "resources/voxels.hio2";
|
const char* LOCAL_VOXELS_PERSIST_FILE = "resources/voxels.hio2";
|
||||||
|
const char* VOXELS_PERSIST_FILE = "/etc/highfidelity/voxel-server/resources/voxels.hio2";
|
||||||
|
|
||||||
const int VOXEL_LISTEN_PORT = 40106;
|
const int VOXEL_LISTEN_PORT = 40106;
|
||||||
|
|
||||||
|
@ -47,6 +48,8 @@ const int MAX_VOXEL_TREE_DEPTH_LEVELS = 4;
|
||||||
|
|
||||||
VoxelTree randomTree;
|
VoxelTree randomTree;
|
||||||
bool wantVoxelPersist = true;
|
bool wantVoxelPersist = true;
|
||||||
|
bool wantLocalDomain = false;
|
||||||
|
|
||||||
|
|
||||||
bool wantColorRandomizer = false;
|
bool wantColorRandomizer = false;
|
||||||
bool debugVoxelSending = false;
|
bool debugVoxelSending = false;
|
||||||
|
@ -207,7 +210,7 @@ void persistVoxelsWhenDirty() {
|
||||||
// check the dirty bit and persist here...
|
// check the dirty bit and persist here...
|
||||||
if (::wantVoxelPersist && ::randomTree.isDirty()) {
|
if (::wantVoxelPersist && ::randomTree.isDirty()) {
|
||||||
printf("saving voxels to file...\n");
|
printf("saving voxels to file...\n");
|
||||||
randomTree.writeToFileV2(VOXELS_PERSIST_FILE);
|
randomTree.writeToFileV2(::wantLocalDomain ? LOCAL_VOXELS_PERSIST_FILE : VOXELS_PERSIST_FILE);
|
||||||
randomTree.clearDirtyBit(); // tree is clean after saving
|
randomTree.clearDirtyBit(); // tree is clean after saving
|
||||||
printf("DONE saving voxels to file...\n");
|
printf("DONE saving voxels to file...\n");
|
||||||
}
|
}
|
||||||
|
@ -270,8 +273,8 @@ int main(int argc, const char * argv[])
|
||||||
|
|
||||||
// Handle Local Domain testing with the --local command line
|
// Handle Local Domain testing with the --local command line
|
||||||
const char* local = "--local";
|
const char* local = "--local";
|
||||||
bool wantLocalDomain = cmdOptionExists(argc, argv,local);
|
::wantLocalDomain = cmdOptionExists(argc, argv,local);
|
||||||
if (wantLocalDomain) {
|
if (::wantLocalDomain) {
|
||||||
printf("Local Domain MODE!\n");
|
printf("Local Domain MODE!\n");
|
||||||
int ip = getLocalAddress();
|
int ip = getLocalAddress();
|
||||||
sprintf(DOMAIN_IP,"%d.%d.%d.%d", (ip & 0xFF), ((ip >> 8) & 0xFF),((ip >> 16) & 0xFF), ((ip >> 24) & 0xFF));
|
sprintf(DOMAIN_IP,"%d.%d.%d.%d", (ip & 0xFF), ((ip >> 8) & 0xFF),((ip >> 16) & 0xFF), ((ip >> 24) & 0xFF));
|
||||||
|
@ -302,7 +305,7 @@ int main(int argc, const char * argv[])
|
||||||
bool persistantFileRead = false;
|
bool persistantFileRead = false;
|
||||||
if (::wantVoxelPersist) {
|
if (::wantVoxelPersist) {
|
||||||
printf("loading voxels from file...\n");
|
printf("loading voxels from file...\n");
|
||||||
persistantFileRead = ::randomTree.readFromFileV2(VOXELS_PERSIST_FILE);
|
persistantFileRead = ::randomTree.readFromFileV2(::wantLocalDomain ? LOCAL_VOXELS_PERSIST_FILE : VOXELS_PERSIST_FILE);
|
||||||
::randomTree.clearDirtyBit(); // the tree is clean since we just loaded it
|
::randomTree.clearDirtyBit(); // the tree is clean since we just loaded it
|
||||||
printf("DONE loading voxels from file... fileRead=%s\n", persistantFileRead ? "yes" : "no" );
|
printf("DONE loading voxels from file... fileRead=%s\n", persistantFileRead ? "yes" : "no" );
|
||||||
unsigned long nodeCount = ::randomTree.getVoxelCount();
|
unsigned long nodeCount = ::randomTree.getVoxelCount();
|
||||||
|
|
Loading…
Reference in a new issue