From 0c70a05732caea290f59de248d6fe419d9f87878 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Fri, 4 Oct 2013 21:36:21 -0700 Subject: [PATCH] make view frustum oversend and don't remove oversend in client --- interface/src/VoxelSystem.cpp | 14 ++++++++++---- .../voxel-server-library/src/VoxelNodeData.cpp | 5 ++++- libraries/voxels/src/VoxelConstants.h | 2 ++ 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/interface/src/VoxelSystem.cpp b/interface/src/VoxelSystem.cpp index 0e2c37af81..753a97d738 100644 --- a/interface/src/VoxelSystem.cpp +++ b/interface/src/VoxelSystem.cpp @@ -1416,7 +1416,7 @@ void VoxelSystem::falseColorizeDistanceFromView() { class removeOutOfViewArgs { public: VoxelSystem* thisVoxelSystem; - ViewFrustum* thisViewFrustum; + ViewFrustum thisViewFrustum; VoxelNodeBag dontRecurseBag; unsigned long nodesScanned; unsigned long nodesRemoved; @@ -1426,14 +1426,20 @@ public: removeOutOfViewArgs(VoxelSystem* voxelSystem) : thisVoxelSystem(voxelSystem), - thisViewFrustum(voxelSystem->getViewFrustum()), + thisViewFrustum(*voxelSystem->getViewFrustum()), dontRecurseBag(), nodesScanned(0), nodesRemoved(0), nodesInside(0), nodesIntersect(0), nodesOutside(0) - { } + { + // Widen the FOV for trimming + float originalFOV = thisViewFrustum.getFieldOfView(); + float wideFOV = originalFOV + VIEW_FRUSTUM_FOV_OVERSEND; + thisViewFrustum.setFieldOfView(wideFOV); // hack + thisViewFrustum.calculate(); + } }; void VoxelSystem::cancelImport() { @@ -1459,7 +1465,7 @@ bool VoxelSystem::removeOutOfViewOperation(VoxelNode* node, void* extraData) { for (int i = 0; i < NUMBER_OF_CHILDREN; i++) { VoxelNode* childNode = node->getChildAtIndex(i); if (childNode) { - ViewFrustum::location inFrustum = childNode->inFrustum(*args->thisViewFrustum); + ViewFrustum::location inFrustum = childNode->inFrustum(args->thisViewFrustum); switch (inFrustum) { case ViewFrustum::OUTSIDE: { args->nodesOutside++; diff --git a/libraries/voxel-server-library/src/VoxelNodeData.cpp b/libraries/voxel-server-library/src/VoxelNodeData.cpp index 43d87c2f89..811e3bc63a 100644 --- a/libraries/voxel-server-library/src/VoxelNodeData.cpp +++ b/libraries/voxel-server-library/src/VoxelNodeData.cpp @@ -74,7 +74,10 @@ bool VoxelNodeData::updateCurrentViewFrustum() { newestViewFrustum.setOrientation(getCameraOrientation()); // Also make sure it's got the correct lens details from the camera - newestViewFrustum.setFieldOfView(getCameraFov()); + float originalFOV = getCameraFov(); + float wideFOV = originalFOV + VIEW_FRUSTUM_FOV_OVERSEND; + + newestViewFrustum.setFieldOfView(wideFOV); // hack newestViewFrustum.setAspectRatio(getCameraAspectRatio()); newestViewFrustum.setNearClip(getCameraNearClip()); newestViewFrustum.setFarClip(getCameraFarClip()); diff --git a/libraries/voxels/src/VoxelConstants.h b/libraries/voxels/src/VoxelConstants.h index 1871aa8e31..64a3f3cc44 100644 --- a/libraries/voxels/src/VoxelConstants.h +++ b/libraries/voxels/src/VoxelConstants.h @@ -52,4 +52,6 @@ const float VIEW_CULLING_RATE_IN_MILLISECONDS = 1000.0f; // once a second is fin const uint64_t CLIENT_TO_SERVER_VOXEL_SEND_INTERVAL_USECS = 1000 * 5; // 1 packet every 50 milliseconds +const float VIEW_FRUSTUM_FOV_OVERSEND = 60.0f; + #endif \ No newline at end of file