From 4ed231670f46316ddffe3fb24c9c9277ab4f5fe7 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 11 Jul 2013 10:04:27 -0700 Subject: [PATCH 1/2] put back the missing voxels --- interface/src/VoxelSystem.cpp | 6 +++--- interface/src/VoxelSystem.h | 8 ++++---- libraries/voxels/src/VoxelConstants.h | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/interface/src/VoxelSystem.cpp b/interface/src/VoxelSystem.cpp index dbaf0760df..4dad137385 100644 --- a/interface/src/VoxelSystem.cpp +++ b/interface/src/VoxelSystem.cpp @@ -170,16 +170,16 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) { void VoxelSystem::setupNewVoxelsForDrawing() { PerformanceWarning warn(_renderWarningsOn, "setupNewVoxelsForDrawing()"); // would like to include _voxelsInArrays, _voxelsUpdated uint64_t start = usecTimestampNow(); - int sinceLastTime = (start - _setupNewVoxelsForDrawingLastFinished) / 1000; + uint64_t sinceLastTime = (start - _setupNewVoxelsForDrawingLastFinished) / 1000; bool iAmDebugging = false; // if you're debugging set this to true, so you won't get skipped for slow debugging - if (!iAmDebugging && sinceLastTime <= std::max(_setupNewVoxelsForDrawingLastElapsed, SIXTY_FPS_IN_MILLISECONDS)) { + if (!iAmDebugging && sinceLastTime <= std::max((float) _setupNewVoxelsForDrawingLastElapsed, SIXTY_FPS_IN_MILLISECONDS)) { return; // bail early, it hasn't been long enough since the last time we ran } int sinceLastViewCulling = (start - _lastViewCulling) / 1000; // If the view frustum is no longer changing, but has changed, since last time, then remove nodes that are out of view - if ((sinceLastViewCulling >= std::max(_lastViewCullingElapsed, VIEW_CULLING_RATE_IN_MILLISECONDS)) + if ((sinceLastViewCulling >= std::max((float) _lastViewCullingElapsed, VIEW_CULLING_RATE_IN_MILLISECONDS)) && !isViewChanging() && hasViewChanged()) { _lastViewCulling = start; diff --git a/interface/src/VoxelSystem.h b/interface/src/VoxelSystem.h index 470ec79aa2..411ae2f81f 100644 --- a/interface/src/VoxelSystem.h +++ b/interface/src/VoxelSystem.h @@ -160,10 +160,10 @@ private: bool _writeRenderFullVBO; bool _readRenderFullVBO; - double _setupNewVoxelsForDrawingLastElapsed; - double _setupNewVoxelsForDrawingLastFinished; - double _lastViewCulling; - double _lastViewCullingElapsed; + int _setupNewVoxelsForDrawingLastElapsed; + uint64_t _setupNewVoxelsForDrawingLastFinished; + uint64_t _lastViewCulling; + int _lastViewCullingElapsed; GLuint _vboVerticesID; GLuint _vboNormalsID; diff --git a/libraries/voxels/src/VoxelConstants.h b/libraries/voxels/src/VoxelConstants.h index d0ae6f538a..30a0427292 100644 --- a/libraries/voxels/src/VoxelConstants.h +++ b/libraries/voxels/src/VoxelConstants.h @@ -34,7 +34,7 @@ const int COLOR_VALUES_PER_VOXEL = NUMBER_OF_COLORS * VERTICES_PER_VOXEL; typedef unsigned long int glBufferIndex; const glBufferIndex GLBUFFER_INDEX_UNKNOWN = ULONG_MAX; -const double SIXTY_FPS_IN_MILLISECONDS = 1000.0/60; -const double VIEW_CULLING_RATE_IN_MILLISECONDS = 1000.0; // once a second is fine +const float SIXTY_FPS_IN_MILLISECONDS = 1000.0f / 60.0f; +const float VIEW_CULLING_RATE_IN_MILLISECONDS = 1000.0f; // once a second is fine #endif From beb89e3d2b572d18c7f0ed5eae075ba408d1155c Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 11 Jul 2013 10:09:00 -0700 Subject: [PATCH 2/2] change some timing types from int to uint64_t to avoid costly assumptions --- animation-server/src/main.cpp | 2 +- interface/src/VoxelSystem.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/animation-server/src/main.cpp b/animation-server/src/main.cpp index 8123fa439c..70296298ff 100644 --- a/animation-server/src/main.cpp +++ b/animation-server/src/main.cpp @@ -646,7 +646,7 @@ void* animateVoxels(void* args) { } uint64_t end = usecTimestampNow(); - int elapsedSeconds = (end - ::start) / 1000000; + uint64_t elapsedSeconds = (end - ::start) / 1000000; if (::shouldShowPacketsPerSecond) { printf("packetsSent=%ld, bytesSent=%ld pps=%f bps=%f\n",packetsSent,bytesSent, (float)(packetsSent/elapsedSeconds),(float)(bytesSent/elapsedSeconds)); diff --git a/interface/src/VoxelSystem.cpp b/interface/src/VoxelSystem.cpp index 4dad137385..8c7cc40514 100644 --- a/interface/src/VoxelSystem.cpp +++ b/interface/src/VoxelSystem.cpp @@ -177,7 +177,7 @@ void VoxelSystem::setupNewVoxelsForDrawing() { return; // bail early, it hasn't been long enough since the last time we ran } - int sinceLastViewCulling = (start - _lastViewCulling) / 1000; + uint64_t sinceLastViewCulling = (start - _lastViewCulling) / 1000; // If the view frustum is no longer changing, but has changed, since last time, then remove nodes that are out of view if ((sinceLastViewCulling >= std::max((float) _lastViewCullingElapsed, VIEW_CULLING_RATE_IN_MILLISECONDS)) && !isViewChanging() && hasViewChanged()) {