History

Merge pull request #7827 from AndrewMeadows/threadsafe-viewfrustum

resurrection of threadsafe ViewFrustum

Brad Hefta-Gaub committed 10 years ago

Commit d7eee982 parents 466b535 db9a4d651 files · +622 −552Browse files

Unified · Split

51 files
  1. assignment-client/src/octree/OctreeQueryNode.cpp +30 −15
  2. assignment-client/src/octree/OctreeQueryNode.h +6 −4
  3. assignment-client/src/octree/OctreeSendThread.cpp +9 −7
  4. interface/src/Application.cpp +66 −61
  5. interface/src/Application.h +5 −6
  6. interface/src/LODManager.cpp +2 −3
  7. interface/src/Stars.cpp +2 −2
  8. interface/src/avatar/Avatar.cpp +21 −18
  9. interface/src/avatar/Avatar.h +1 −1
  10. interface/src/avatar/Head.cpp +0 −3
  11. interface/src/avatar/Head.h +2 −3
  12. interface/src/avatar/MyAvatar.cpp +11 −12
  13. interface/src/avatar/MyAvatar.h +1 −1
  14. interface/src/ui/overlays/Grid3DOverlay.cpp +1 −1
  15. interface/src/ui/overlays/LocalModelsOverlay.cpp +2 −2
  16. libraries/entities-renderer/src/RenderableTextEntityItem.cpp +1 −1
  17. libraries/entities/src/EntityTreeElement.cpp +7 −5
  18. libraries/octree/src/Octree.cpp +28 −32
  19. libraries/octree/src/Octree.h +13 −16
  20. libraries/octree/src/OctreeElement.cpp +4 −3
  21. libraries/octree/src/OctreeElement.h +2 −2
  22. libraries/octree/src/OctreeHeadlessViewer.cpp +1 −3
  23. libraries/octree/src/OctreeHeadlessViewer.h +1 −2
  24. libraries/octree/src/OctreeQuery.cpp +0 −1
  25. libraries/octree/src/OctreeRenderer.cpp +3 −4
  26. libraries/octree/src/OctreeRenderer.h +4 −4
  27. libraries/octree/src/OctreeUtils.cpp +71 −0
  28. libraries/octree/src/OctreeUtils.h +30 −0
  29. libraries/render-utils/src/AbstractViewStateInterface.h +5 −5
  30. libraries/render-utils/src/AmbientOcclusionEffect.cpp +4 −4
  31. libraries/render-utils/src/AntialiasingEffect.cpp +4 −4
  32. libraries/render-utils/src/DebugDeferredBuffer.cpp +6 −6
  33. libraries/render-utils/src/DeferredLightingEffect.cpp +5 −5
  34. libraries/render-utils/src/HitEffect.cpp +5 −5
  35. libraries/render-utils/src/LightStage.cpp +4 −5
  36. libraries/render-utils/src/LightStage.h +1 −1
  37. libraries/render-utils/src/RenderDeferredTask.cpp +14 −14
  38. libraries/render-utils/src/RenderShadowTask.cpp +5 −6
  39. libraries/render/src/render/CullTask.cpp +16 −20
  40. libraries/render/src/render/DrawSceneOctree.cpp +8 −7
  41. libraries/render/src/render/DrawStatus.cpp +3 −3
  42. libraries/render/src/render/DrawTask.cpp +1 −1
  43. libraries/render/src/render/SortTask.cpp +3 −3
  44. libraries/shared/src/CubeProjectedPolygon.cpp +48 −48
  45. libraries/shared/src/CubeProjectedPolygon.h +39 −39
  46. libraries/shared/src/PIDController.cpp +1 −1
  47. libraries/shared/src/Plane.cpp +5 −5
  48. libraries/shared/src/Plane.h +5 −4
  49. libraries/shared/src/RenderArgs.h +22 −10
  50. libraries/shared/src/ViewFrustum.cpp +66 −107
  51. libraries/shared/src/ViewFrustum.h +28 −37
assignment-client/src/octree/OctreeQueryNode.cpp+30−15
@@ -141,6 +141,16 @@ void OctreeQueryNode::writeToPacket(const unsigned char* buffer, unsigned int by · 140 unmodified lines
141 }141 }
142}142}
143 143
144void OctreeQueryNode::copyCurrentViewFrustum(ViewFrustum& viewOut) const {
145 QMutexLocker viewLocker(&_viewMutex);
146 viewOut = _currentViewFrustum;
147}
148
149void OctreeQueryNode::copyLastKnownViewFrustum(ViewFrustum& viewOut) const {
150 QMutexLocker viewLocker(&_viewMutex);
151 viewOut = _lastKnownViewFrustum;
152}
153
144bool OctreeQueryNode::updateCurrentViewFrustum() {154bool OctreeQueryNode::updateCurrentViewFrustum() {
145 // if shutting down, return immediately155 // if shutting down, return immediately
146 if (_isShuttingDown) {156 if (_isShuttingDown) {
@@ -171,11 +181,13 @@ bool OctreeQueryNode::updateCurrentViewFrustum() { · 24 unmodified lines
171 }181 }
172 182
173 183
174 // if there has been a change, then recalculate184 { // if there has been a change, then recalculate
175 if (!newestViewFrustum.isVerySimilar(_currentViewFrustum)) {185 QMutexLocker viewLocker(&_viewMutex);
176 _currentViewFrustum = newestViewFrustum;186 if (!newestViewFrustum.isVerySimilar(_currentViewFrustum)) {
177 _currentViewFrustum.calculate();187 _currentViewFrustum = newestViewFrustum;
178 currentViewFrustumChanged = true;188 _currentViewFrustum.calculate();
189 currentViewFrustumChanged = true;
190 }
179 }191 }
180 192
181 // Also check for LOD changes from the client193 // Also check for LOD changes from the client
@@ -219,11 +231,14 @@ void OctreeQueryNode::updateLastKnownViewFrustum() { · 37 unmodified lines
219 return;231 return;
220 }232 }
221 233
222 bool frustumChanges = !_lastKnownViewFrustum.isVerySimilar(_currentViewFrustum);234 {
235 QMutexLocker viewLocker(&_viewMutex);
236 bool frustumChanges = !_lastKnownViewFrustum.isVerySimilar(_currentViewFrustum);
223 237
224 if (frustumChanges) {238 if (frustumChanges) {
225 // save our currentViewFrustum into our lastKnownViewFrustum239 // save our currentViewFrustum into our lastKnownViewFrustum
226 _lastKnownViewFrustum = _currentViewFrustum;240 _lastKnownViewFrustum = _currentViewFrustum;
241 }
227 }242 }
228 243
229 // save that we know the view has been sent.244 // save that we know the view has been sent.
@@ -237,15 +252,13 @@ bool OctreeQueryNode::moveShouldDump() const { · 7 unmodified lines
237 return false;252 return false;
238 }253 }
239 254
255 QMutexLocker viewLocker(&_viewMutex);
240 glm::vec3 oldPosition = _lastKnownViewFrustum.getPosition();256 glm::vec3 oldPosition = _lastKnownViewFrustum.getPosition();
241 glm::vec3 newPosition = _currentViewFrustum.getPosition();257 glm::vec3 newPosition = _currentViewFrustum.getPosition();
242 258
243 // theoretically we could make this slightly larger but relative to avatar scale.259 // theoretically we could make this slightly larger but relative to avatar scale.
244 const float MAXIMUM_MOVE_WITHOUT_DUMP = 0.0f;260 const float MAXIMUM_MOVE_WITHOUT_DUMP = 0.0f;
245 if (glm::distance(newPosition, oldPosition) > MAXIMUM_MOVE_WITHOUT_DUMP) {261 return glm::distance(newPosition, oldPosition) > MAXIMUM_MOVE_WITHOUT_DUMP;
246 return true;
247 }
248 return false;
249}262}
250 263
251void OctreeQueryNode::dumpOutOfView() {264void OctreeQueryNode::dumpOutOfView() {
@@ -257,8 +270,10 @@ void OctreeQueryNode::dumpOutOfView() { · 5 unmodified lines
257 int stillInView = 0;270 int stillInView = 0;
258 int outOfView = 0;271 int outOfView = 0;
259 OctreeElementBag tempBag;272 OctreeElementBag tempBag;
273 ViewFrustum viewCopy;
274 copyCurrentViewFrustum(viewCopy);
260 while (OctreeElementPointer elementToCheck = elementBag.extract()) {275 while (OctreeElementPointer elementToCheck = elementBag.extract()) {
261 if (elementToCheck->isInView(_currentViewFrustum)) {276 if (elementToCheck->isInView(viewCopy)) {
262 tempBag.insert(elementToCheck);277 tempBag.insert(elementToCheck);
263 stillInView++;278 stillInView++;
264 } else {279 } else {
@@ -267,7 +282,7 @@ void OctreeQueryNode::dumpOutOfView() { · 2 unmodified lines
267 }282 }
268 if (stillInView > 0) {283 if (stillInView > 0) {
269 while (OctreeElementPointer elementToKeepInBag = tempBag.extract()) {284 while (OctreeElementPointer elementToKeepInBag = tempBag.extract()) {
270 if (elementToKeepInBag->isInView(_currentViewFrustum)) {285 if (elementToKeepInBag->isInView(viewCopy)) {
271 elementBag.insert(elementToKeepInBag);286 elementBag.insert(elementToKeepInBag);
272 }287 }
273 }288 }
assignment-client/src/octree/OctreeQueryNode.h+6−4
@@ -44,7 +44,7 @@ public: · 43 unmodified lines
44 44
45 bool packetIsDuplicate() const;45 bool packetIsDuplicate() const;
46 bool shouldSuppressDuplicatePacket();46 bool shouldSuppressDuplicatePacket();
47 47
48 unsigned int getAvailable() const { return _octreePacket->bytesAvailableForWrite(); }48 unsigned int getAvailable() const { return _octreePacket->bytesAvailableForWrite(); }
49 int getMaxSearchLevel() const { return _maxSearchLevel; }49 int getMaxSearchLevel() const { return _maxSearchLevel; }
50 void resetMaxSearchLevel() { _maxSearchLevel = 1; }50 void resetMaxSearchLevel() { _maxSearchLevel = 1; }
@@ -56,8 +56,8 @@ public: · 5 unmodified lines
56 OctreeElementBag elementBag;56 OctreeElementBag elementBag;
57 OctreeElementExtraEncodeData extraEncodeData;57 OctreeElementExtraEncodeData extraEncodeData;
58 58
59 ViewFrustum& getCurrentViewFrustum() { return _currentViewFrustum; }59 void copyCurrentViewFrustum(ViewFrustum& viewOut) const;
60 ViewFrustum& getLastKnownViewFrustum() { return _lastKnownViewFrustum; }60 void copyLastKnownViewFrustum(ViewFrustum& viewOut) const;
61 61
62 // These are not classic setters because they are calculating and maintaining state62 // These are not classic setters because they are calculating and maintaining state
63 // which is set asynchronously through the network receive63 // which is set asynchronously through the network receive
@@ -114,6 +114,8 @@ private: · 50 unmodified lines
114 114
115 int _maxSearchLevel { 1 };115 int _maxSearchLevel { 1 };
116 int _maxLevelReachedInLastSearch { 1 };116 int _maxLevelReachedInLastSearch { 1 };
117
118 mutable QMutex _viewMutex { QMutex::Recursive };
117 ViewFrustum _currentViewFrustum;119 ViewFrustum _currentViewFrustum;
118 ViewFrustum _lastKnownViewFrustum;120 ViewFrustum _lastKnownViewFrustum;
119 quint64 _lastTimeBagEmpty { 0 };121 quint64 _lastTimeBagEmpty { 0 };
@@ -139,7 +141,7 @@ private: · 19 unmodified lines
139 QQueue<OCTREE_PACKET_SEQUENCE> _nackedSequenceNumbers;141 QQueue<OCTREE_PACKET_SEQUENCE> _nackedSequenceNumbers;
140 142
141 quint64 _sceneSendStartTime = 0;143 quint64 _sceneSendStartTime = 0;
142 144
143 std::array<char, udt::MAX_PACKET_SIZE> _lastOctreePayload;145 std::array<char, udt::MAX_PACKET_SIZE> _lastOctreePayload;
144};146};
145 147
assignment-client/src/octree/OctreeSendThread.cpp+9−7
@@ -338,8 +338,6 @@ int OctreeSendThread::packetDistributor(SharedNodePointer node, OctreeQueryNode* · 337 unmodified lines
338 338
339 _packetData.changeSettings(true, targetSize); // FIXME - eventually support only compressed packets339 _packetData.changeSettings(true, targetSize); // FIXME - eventually support only compressed packets
340 340
341 const ViewFrustum* lastViewFrustum = viewFrustumChanged ? &nodeData->getLastKnownViewFrustum() : NULL;
342
343 // If the current view frustum has changed OR we have nothing to send, then search against341 // If the current view frustum has changed OR we have nothing to send, then search against
344 // the current view frustum for things to send.342 // the current view frustum for things to send.
345 if (viewFrustumChanged || nodeData->elementBag.isEmpty()) {343 if (viewFrustumChanged || nodeData->elementBag.isEmpty()) {
@@ -417,7 +415,7 @@ int OctreeSendThread::packetDistributor(SharedNodePointer node, OctreeQueryNode* · 71 unmodified lines
417 quint64 lockWaitEnd = usecTimestampNow();415 quint64 lockWaitEnd = usecTimestampNow();
418 lockWaitElapsedUsec = (float)(lockWaitEnd - lockWaitStart);416 lockWaitElapsedUsec = (float)(lockWaitEnd - lockWaitStart);
419 quint64 encodeStart = usecTimestampNow();417 quint64 encodeStart = usecTimestampNow();
420 418
421 OctreeElementPointer subTree = nodeData->elementBag.extract();419 OctreeElementPointer subTree = nodeData->elementBag.extract();
422 if (!subTree) {420 if (!subTree) {
423 return;421 return;
@@ -426,18 +424,22 @@ int OctreeSendThread::packetDistributor(SharedNodePointer node, OctreeQueryNode* · 2 unmodified lines
426 float octreeSizeScale = nodeData->getOctreeSizeScale();424 float octreeSizeScale = nodeData->getOctreeSizeScale();
427 int boundaryLevelAdjustClient = nodeData->getBoundaryLevelAdjust();425 int boundaryLevelAdjustClient = nodeData->getBoundaryLevelAdjust();
428 426
429 int boundaryLevelAdjust = boundaryLevelAdjustClient + 427 int boundaryLevelAdjust = boundaryLevelAdjustClient +
430 (viewFrustumChanged ? LOW_RES_MOVING_ADJUST : NO_BOUNDARY_ADJUST);428 (viewFrustumChanged ? LOW_RES_MOVING_ADJUST : NO_BOUNDARY_ADJUST);
431 429
432 EncodeBitstreamParams params(INT_MAX, &nodeData->getCurrentViewFrustum(), 430 EncodeBitstreamParams params(INT_MAX, WANT_EXISTS_BITS, DONT_CHOP,
433 WANT_EXISTS_BITS, DONT_CHOP, viewFrustumChanged, lastViewFrustum,431 viewFrustumChanged,
434 boundaryLevelAdjust, octreeSizeScale,432 boundaryLevelAdjust, octreeSizeScale,
435 nodeData->getLastTimeBagEmpty(),433 nodeData->getLastTimeBagEmpty(),
436 isFullScene, &nodeData->stats, _myServer->getJurisdiction(),434 isFullScene, &nodeData->stats, _myServer->getJurisdiction(),
437 &nodeData->extraEncodeData);435 &nodeData->extraEncodeData);
436 nodeData->copyCurrentViewFrustum(params.viewFrustum);
437 if (viewFrustumChanged) {
438 nodeData->copyLastKnownViewFrustum(params.lastViewFrustum);
439 }
438 440
439 // Our trackSend() function is implemented by the server subclass, and will be called back441 // Our trackSend() function is implemented by the server subclass, and will be called back
440 // during the encodeTreeBitstream() as new entities/data elements are sent 442 // during the encodeTreeBitstream() as new entities/data elements are sent
441 params.trackSend = [this, node](const QUuid& dataID, quint64 dataEdited) {443 params.trackSend = [this, node](const QUuid& dataID, quint64 dataEdited) {
442 _myServer->trackSend(dataID, dataEdited, node->getUUID());444 _myServer->trackSend(dataID, dataEdited, node->getUUID());
443 };445 };
interface/src/Application.cpp+66−61
@@ -1481,10 +1481,17 @@ void Application::paintGL() { · 1480 unmodified lines
1481 1481
1482 auto lodManager = DependencyManager::get<LODManager>();1482 auto lodManager = DependencyManager::get<LODManager>();
1483 1483
1484 1484 {
1485 RenderArgs renderArgs(_gpuContext, getEntities(), getViewFrustum(), lodManager->getOctreeSizeScale(),1485 QMutexLocker viewLocker(&_viewMutex);
1486 _viewFrustum.calculate();
1487 }
1488 RenderArgs renderArgs(_gpuContext, getEntities(), lodManager->getOctreeSizeScale(),
1486 lodManager->getBoundaryLevelAdjust(), RenderArgs::DEFAULT_RENDER_MODE,1489 lodManager->getBoundaryLevelAdjust(), RenderArgs::DEFAULT_RENDER_MODE,
1487 RenderArgs::MONO, RenderArgs::RENDER_DEBUG_NONE);1490 RenderArgs::MONO, RenderArgs::RENDER_DEBUG_NONE);
1491 {
1492 QMutexLocker viewLocker(&_viewMutex);
1493 renderArgs.setViewFrustum(_viewFrustum);
1494 }
1488 1495
1489 PerformanceWarning::setSuppressShortTimings(Menu::getInstance()->isOptionChecked(MenuOption::SuppressShortTimings));1496 PerformanceWarning::setSuppressShortTimings(Menu::getInstance()->isOptionChecked(MenuOption::SuppressShortTimings));
1490 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);1497 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
@@ -1651,7 +1658,7 @@ void Application::paintGL() { · 160 unmodified lines
1651 renderArgs._context->enableStereo(true);1658 renderArgs._context->enableStereo(true);
1652 mat4 eyeOffsets[2];1659 mat4 eyeOffsets[2];
1653 mat4 eyeProjections[2];1660 mat4 eyeProjections[2];
1654 auto baseProjection = renderArgs._viewFrustum->getProjection();1661 auto baseProjection = renderArgs.getViewFrustum().getProjection();
1655 auto hmdInterface = DependencyManager::get<HMDScriptingInterface>();1662 auto hmdInterface = DependencyManager::get<HMDScriptingInterface>();
1656 float IPDScale = hmdInterface->getIPDScale();1663 float IPDScale = hmdInterface->getIPDScale();
1657 mat4 headPose = displayPlugin->getHeadPose();1664 mat4 headPose = displayPlugin->getHeadPose();
@@ -1781,7 +1788,10 @@ void Application::resizeGL() { · 123 unmodified lines
1781 _myCamera.setProjection(glm::perspective(glm::radians(_fieldOfView.get()), aspectRatio,1788 _myCamera.setProjection(glm::perspective(glm::radians(_fieldOfView.get()), aspectRatio,
1782 DEFAULT_NEAR_CLIP, DEFAULT_FAR_CLIP));1789 DEFAULT_NEAR_CLIP, DEFAULT_FAR_CLIP));
1783 // Possible change in aspect ratio1790 // Possible change in aspect ratio
1784 loadViewFrustum(_myCamera, _viewFrustum);1791 {
1792 QMutexLocker viewLocker(&_viewMutex);
1793 loadViewFrustum(_myCamera, _viewFrustum);
1794 }
1785 1795
1786 auto offscreenUi = DependencyManager::get<OffscreenUi>();1796 auto offscreenUi = DependencyManager::get<OffscreenUi>();
1787 auto uiSize = displayPlugin->getRecommendedUiSize();1797 auto uiSize = displayPlugin->getRecommendedUiSize();
@@ -2108,6 +2118,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 320 unmodified lines
2108 2118
2109 case Qt::Key_J:2119 case Qt::Key_J:
2110 if (isShifted) {2120 if (isShifted) {
2121 QMutexLocker viewLocker(&_viewMutex);
2111 _viewFrustum.setFocalLength(_viewFrustum.getFocalLength() - 0.1f);2122 _viewFrustum.setFocalLength(_viewFrustum.getFocalLength() - 0.1f);
2112 } else {2123 } else {
2113 _myCamera.setEyeOffsetPosition(_myCamera.getEyeOffsetPosition() + glm::vec3(-0.001, 0, 0));2124 _myCamera.setEyeOffsetPosition(_myCamera.getEyeOffsetPosition() + glm::vec3(-0.001, 0, 0));
@@ -2117,6 +2128,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 3 unmodified lines
2117 2128
2118 case Qt::Key_M:2129 case Qt::Key_M:
2119 if (isShifted) {2130 if (isShifted) {
2131 QMutexLocker viewLocker(&_viewMutex);
2120 _viewFrustum.setFocalLength(_viewFrustum.getFocalLength() + 0.1f);2132 _viewFrustum.setFocalLength(_viewFrustum.getFocalLength() + 0.1f);
2121 } else {2133 } else {
2122 _myCamera.setEyeOffsetPosition(_myCamera.getEyeOffsetPosition() + glm::vec3(0.001, 0, 0));2134 _myCamera.setEyeOffsetPosition(_myCamera.getEyeOffsetPosition() + glm::vec3(0.001, 0, 0));
@@ -2965,7 +2977,10 @@ void Application::init() { · 842 unmodified lines
2965 DependencyManager::get<NodeList>()->sendDomainServerCheckIn();2977 DependencyManager::get<NodeList>()->sendDomainServerCheckIn();
2966 2978
2967 getEntities()->init();2979 getEntities()->init();
2968 getEntities()->setViewFrustum(getViewFrustum());2980 {
2981 QMutexLocker viewLocker(&_viewMutex);
2982 getEntities()->setViewFrustum(_viewFrustum);
2983 }
2969 2984
2970 ObjectMotionState::setShapeManager(&_shapeManager);2985 ObjectMotionState::setShapeManager(&_shapeManager);
2971 _physicsEngine->init();2986 _physicsEngine->init();
@@ -2985,7 +3000,10 @@ void Application::init() { · 13 unmodified lines
2985 getEntities()->connectSignalsToSlots(entityScriptingInterface.data());3000 getEntities()->connectSignalsToSlots(entityScriptingInterface.data());
2986 3001
2987 _entityClipboardRenderer.init();3002 _entityClipboardRenderer.init();
2988 _entityClipboardRenderer.setViewFrustum(getViewFrustum());3003 {
3004 QMutexLocker viewLocker(&_viewMutex);
3005 _entityClipboardRenderer.setViewFrustum(_viewFrustum);
3006 }
2989 _entityClipboardRenderer.setTree(_entityClipboard);3007 _entityClipboardRenderer.setTree(_entityClipboard);
2990 3008
2991 // Make sure any new sounds are loaded as soon as know about them.3009 // Make sure any new sounds are loaded as soon as know about them.
@@ -3199,9 +3217,12 @@ void Application::resetPhysicsReadyInformation() { · 207 unmodified lines
3199 3217
3200void Application::reloadResourceCaches() {3218void Application::reloadResourceCaches() {
3201 resetPhysicsReadyInformation();3219 resetPhysicsReadyInformation();
3220 {
3221 QMutexLocker viewLocker(&_viewMutex);
3222 _viewFrustum.setPosition(glm::vec3(0.0f, 0.0f, TREE_SCALE));
3223 _viewFrustum.setOrientation(glm::quat());
3224 }
3202 // Clear entities out of view frustum3225 // Clear entities out of view frustum
3203 _viewFrustum.setPosition(glm::vec3(0.0f, 0.0f, TREE_SCALE));
3204 _viewFrustum.setOrientation(glm::quat());
3205 queryOctree(NodeType::EntityServer, PacketType::EntityQuery, _entityServerJurisdictions);3226 queryOctree(NodeType::EntityServer, PacketType::EntityQuery, _entityServerJurisdictions);
3206 3227
3207 DependencyManager::get<AssetClient>()->clearCache();3228 DependencyManager::get<AssetClient>()->clearCache();
@@ -3490,7 +3511,7 @@ void Application::update(float deltaTime) { · 282 unmodified lines
3490 // actually need to calculate the view frustum planes to send these details3511 // actually need to calculate the view frustum planes to send these details
3491 // to the server.3512 // to the server.
3492 {3513 {
3493 PerformanceTimer perfTimer("loadViewFrustum");3514 QMutexLocker viewLocker(&_viewMutex);
3494 loadViewFrustum(_myCamera, _viewFrustum);3515 loadViewFrustum(_myCamera, _viewFrustum);
3495 }3516 }
3496 3517
@@ -3499,6 +3520,7 @@ void Application::update(float deltaTime) { · 2 unmodified lines
3499 // Update my voxel servers with my current voxel query...3520 // Update my voxel servers with my current voxel query...
3500 {3521 {
3501 PROFILE_RANGE_EX("QueryOctree", 0xffff0000, (uint64_t)getActiveDisplayPlugin()->presentCount());3522 PROFILE_RANGE_EX("QueryOctree", 0xffff0000, (uint64_t)getActiveDisplayPlugin()->presentCount());
3523 QMutexLocker viewLocker(&_viewMutex);
3502 PerformanceTimer perfTimer("queryOctree");3524 PerformanceTimer perfTimer("queryOctree");
3503 quint64 sinceLastQuery = now - _lastQueriedTime;3525 quint64 sinceLastQuery = now - _lastQueriedTime;
3504 const quint64 TOO_LONG_SINCE_LAST_QUERY = 3 * USECS_PER_SECOND;3526 const quint64 TOO_LONG_SINCE_LAST_QUERY = 3 * USECS_PER_SECOND;
@@ -3610,14 +3632,16 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType, Node · 105 unmodified lines
3610 //qCDebug(interfaceapp) << ">>> inside... queryOctree()... _viewFrustum.getFieldOfView()=" << _viewFrustum.getFieldOfView();3632 //qCDebug(interfaceapp) << ">>> inside... queryOctree()... _viewFrustum.getFieldOfView()=" << _viewFrustum.getFieldOfView();
3611 bool wantExtraDebugging = getLogger()->extraDebugging();3633 bool wantExtraDebugging = getLogger()->extraDebugging();
3612 3634
3613 _octreeQuery.setCameraPosition(_viewFrustum.getPosition());3635 ViewFrustum viewFrustum;
3614 _octreeQuery.setCameraOrientation(_viewFrustum.getOrientation());3636 copyViewFrustum(viewFrustum);
3615 _octreeQuery.setCameraFov(_viewFrustum.getFieldOfView());3637 _octreeQuery.setCameraPosition(viewFrustum.getPosition());
3616 _octreeQuery.setCameraAspectRatio(_viewFrustum.getAspectRatio());3638 _octreeQuery.setCameraOrientation(viewFrustum.getOrientation());
3617 _octreeQuery.setCameraNearClip(_viewFrustum.getNearClip());3639 _octreeQuery.setCameraFov(viewFrustum.getFieldOfView());
3618 _octreeQuery.setCameraFarClip(_viewFrustum.getFarClip());3640 _octreeQuery.setCameraAspectRatio(viewFrustum.getAspectRatio());
3641 _octreeQuery.setCameraNearClip(viewFrustum.getNearClip());
3642 _octreeQuery.setCameraFarClip(viewFrustum.getFarClip());
3619 _octreeQuery.setCameraEyeOffsetPosition(glm::vec3());3643 _octreeQuery.setCameraEyeOffsetPosition(glm::vec3());
3620 _octreeQuery.setCameraCenterRadius(_viewFrustum.getCenterRadius());3644 _octreeQuery.setCameraCenterRadius(viewFrustum.getCenterRadius());
3621 auto lodManager = DependencyManager::get<LODManager>();3645 auto lodManager = DependencyManager::get<LODManager>();
3622 _octreeQuery.setOctreeSizeScale(lodManager->getOctreeSizeScale());3646 _octreeQuery.setOctreeSizeScale(lodManager->getOctreeSizeScale());
3623 _octreeQuery.setBoundaryLevelAdjust(lodManager->getBoundaryLevelAdjust());3647 _octreeQuery.setBoundaryLevelAdjust(lodManager->getBoundaryLevelAdjust());
@@ -3653,7 +3677,7 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType, Node · 29 unmodified lines
3653 rootDetails.y * TREE_SCALE,3677 rootDetails.y * TREE_SCALE,
3654 rootDetails.z * TREE_SCALE) - glm::vec3(HALF_TREE_SCALE),3678 rootDetails.z * TREE_SCALE) - glm::vec3(HALF_TREE_SCALE),
3655 rootDetails.s * TREE_SCALE);3679 rootDetails.s * TREE_SCALE);
3656 if (_viewFrustum.cubeIntersectsKeyhole(serverBounds)) {3680 if (viewFrustum.cubeIntersectsKeyhole(serverBounds)) {
3657 inViewServers++;3681 inViewServers++;
3658 }3682 }
3659 }3683 }
@@ -3719,11 +3743,9 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType, Node · 59 unmodified lines
3719 rootDetails.s * TREE_SCALE);3743 rootDetails.s * TREE_SCALE);
3720 3744
3721 3745
3722 inView = _viewFrustum.cubeIntersectsKeyhole(serverBounds);3746 inView = viewFrustum.cubeIntersectsKeyhole(serverBounds);
3723 } else {3747 } else if (wantExtraDebugging) {
3724 if (wantExtraDebugging) {3748 qCDebug(interfaceapp) << "Jurisdiction without RootCode for node " << *node << ". That's unusual!";
3725 qCDebug(interfaceapp) << "Jurisdiction without RootCode for node " << *node << ". That's unusual!";
3726 }
3727 }3749 }
3728 }3750 }
3729 3751
@@ -3814,6 +3836,7 @@ QRect Application::getDesirableApplicationGeometry() const { · 84 unmodified lines
3814// or the "myCamera".3836// or the "myCamera".
3815//3837//
3816void Application::loadViewFrustum(Camera& camera, ViewFrustum& viewFrustum) {3838void Application::loadViewFrustum(Camera& camera, ViewFrustum& viewFrustum) {
3839 PerformanceTimer perfTimer("loadViewFrustum");
3817 PROFILE_RANGE(__FUNCTION__);3840 PROFILE_RANGE(__FUNCTION__);
3818 // We will use these below, from either the camera or head vectors calculated above3841 // We will use these below, from either the camera or head vectors calculated above
3819 viewFrustum.setProjection(camera.getProjection());3842 viewFrustum.setProjection(camera.getProjection());
@@ -3842,7 +3865,8 @@ PickRay Application::computePickRay(float x, float y) const { · 22 unmodified lines
3842 getApplicationCompositor().computeHmdPickRay(pickPoint, result.origin, result.direction);3865 getApplicationCompositor().computeHmdPickRay(pickPoint, result.origin, result.direction);
3843 } else {3866 } else {
3844 pickPoint /= getCanvasSize();3867 pickPoint /= getCanvasSize();
3845 getViewFrustum()->computePickRay(pickPoint.x, pickPoint.y, result.origin, result.direction);3868 QMutexLocker viewLocker(&_viewMutex);
3869 _viewFrustum.computePickRay(pickPoint.x, pickPoint.y, result.origin, result.direction);
3846 }3870 }
3847 return result;3871 return result;
3848}3872}
@@ -3855,44 +3879,19 @@ glm::vec3 Application::getAvatarPosition() const { · 6 unmodified lines
3855 return getMyAvatar()->getPosition();3879 return getMyAvatar()->getPosition();
3856}3880}
3857 3881
3858ViewFrustum* Application::getViewFrustum() {3882void Application::copyViewFrustum(ViewFrustum& viewOut) const {
3859#ifdef DEBUG3883 QMutexLocker viewLocker(&_viewMutex);
3860 if (QThread::currentThread() == activeRenderingThread) {3884 viewOut = _viewFrustum;
3861 // FIXME, figure out a better way to do this
3862 //qWarning() << "Calling Application::getViewFrustum() from the active rendering thread, did you mean Application::getDisplayViewFrustum()?";
3863 }
3864#endif
3865 return &_viewFrustum;
3866}
3867
3868const ViewFrustum* Application::getViewFrustum() const {
3869#ifdef DEBUG
3870 if (QThread::currentThread() == activeRenderingThread) {
3871 // FIXME, figure out a better way to do this
3872 //qWarning() << "Calling Application::getViewFrustum() from the active rendering thread, did you mean Application::getDisplayViewFrustum()?";
3873 }
3874#endif
3875 return &_viewFrustum;
3876}3885}
3877 3886
3878ViewFrustum* Application::getDisplayViewFrustum() {3887void Application::copyDisplayViewFrustum(ViewFrustum& viewOut) const {
3879#ifdef DEBUG3888 QMutexLocker viewLocker(&_viewMutex);
3880 if (QThread::currentThread() != activeRenderingThread) {3889 viewOut = _displayViewFrustum;
3881 // FIXME, figure out a better way to do this
3882 // qWarning() << "Calling Application::getDisplayViewFrustum() from outside the active rendering thread or outside rendering, did you mean Application::getViewFrustum()?";
3883 }
3884#endif
3885 return &_displayViewFrustum;
3886}3890}
3887 3891
3888const ViewFrustum* Application::getDisplayViewFrustum() const {3892void Application::copyShadowViewFrustum(ViewFrustum& viewOut) const {
3889#ifdef DEBUG3893 QMutexLocker viewLocker(&_viewMutex);
3890 if (QThread::currentThread() != activeRenderingThread) {3894 viewOut = _shadowViewFrustum;
3891 // FIXME, figure out a better way to do this
3892 // qWarning() << "Calling Application::getDisplayViewFrustum() from outside the active rendering thread or outside rendering, did you mean Application::getViewFrustum()?";
3893 }
3894#endif
3895 return &_displayViewFrustum;
3896}3895}
3897 3896
3898// WorldBox Render Data & rendering functions3897// WorldBox Render Data & rendering functions
@@ -3957,7 +3956,7 @@ namespace render { · 58 unmodified lines
3957 auto skybox = skyStage->getSkybox();3956 auto skybox = skyStage->getSkybox();
3958 if (skybox) {3957 if (skybox) {
3959 PerformanceTimer perfTimer("skybox");3958 PerformanceTimer perfTimer("skybox");
3960 skybox->render(batch, *(args->_viewFrustum));3959 skybox->render(batch, args->getViewFrustum());
3961 break;3960 break;
3962 }3961 }
3963 }3962 }
@@ -4001,7 +4000,10 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se · 37 unmodified lines
4001 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "Application::displaySide()");4000 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "Application::displaySide()");
4002 4001
4003 // load the view frustum4002 // load the view frustum
4004 loadViewFrustum(theCamera, _displayViewFrustum);4003 {
4004 QMutexLocker viewLocker(&_viewMutex);
4005 loadViewFrustum(theCamera, _displayViewFrustum);
4006 }
4005 4007
4006 // TODO fix shadows and make them use the GPU library4008 // TODO fix shadows and make them use the GPU library
4007 4009
@@ -4069,7 +4071,10 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se · 61 unmodified lines
4069 {4071 {
4070 PerformanceTimer perfTimer("EngineRun");4072 PerformanceTimer perfTimer("EngineRun");
4071 4073
4072 renderArgs->_viewFrustum = getDisplayViewFrustum();4074 {
4075 QMutexLocker viewLocker(&_viewMutex);
4076 renderArgs->setViewFrustum(_displayViewFrustum);
4077 }
4073 _renderEngine->getRenderContext()->args = renderArgs;4078 _renderEngine->getRenderContext()->args = renderArgs;
4074 4079
4075 // Before the deferred pass, let's try to use the render engine4080 // Before the deferred pass, let's try to use the render engine
@@ -5199,10 +5204,10 @@ void Application::updateInputModes() { · 1123 unmodified lines
5199}5204}
5200 5205
5201mat4 Application::getEyeProjection(int eye) const {5206mat4 Application::getEyeProjection(int eye) const {
5207 QMutexLocker viewLocker(&_viewMutex);
5202 if (isHMDMode()) {5208 if (isHMDMode()) {
5203 return getActiveDisplayPlugin()->getEyeProjection((Eye)eye, _viewFrustum.getProjection());5209 return getActiveDisplayPlugin()->getEyeProjection((Eye)eye, _viewFrustum.getProjection());
5204 }5210 }
5205
5206 return _viewFrustum.getProjection();5211 return _viewFrustum.getProjection();
5207}5212}
5208 5213
interface/src/Application.h+5−6
@@ -128,14 +128,12 @@ public: · 127 unmodified lines
128 Camera* getCamera() { return &_myCamera; }128 Camera* getCamera() { return &_myCamera; }
129 const Camera* getCamera() const { return &_myCamera; }129 const Camera* getCamera() const { return &_myCamera; }
130 // Represents the current view frustum of the avatar.130 // Represents the current view frustum of the avatar.
131 ViewFrustum* getViewFrustum();131 void copyViewFrustum(ViewFrustum& viewOut) const;
132 const ViewFrustum* getViewFrustum() const;
133 // Represents the view frustum of the current rendering pass,132 // Represents the view frustum of the current rendering pass,
134 // which might be different from the viewFrustum, i.e. shadowmap133 // which might be different from the viewFrustum, i.e. shadowmap
135 // passes, mirror window passes, etc134 // passes, mirror window passes, etc
136 ViewFrustum* getDisplayViewFrustum();135 void copyDisplayViewFrustum(ViewFrustum& viewOut) const;
137 const ViewFrustum* getDisplayViewFrustum() const;136 void copyShadowViewFrustum(ViewFrustum& viewOut) const override;
138 ViewFrustum* getShadowViewFrustum() override { return &_shadowViewFrustum; }
139 const OctreePacketProcessor& getOctreePacketProcessor() const { return _octreeProcessor; }137 const OctreePacketProcessor& getOctreePacketProcessor() const { return _octreeProcessor; }
140 EntityTreeRenderer* getEntities() const { return DependencyManager::get<EntityTreeRenderer>().data(); }138 EntityTreeRenderer* getEntities() const { return DependencyManager::get<EntityTreeRenderer>().data(); }
141 QUndoStack* getUndoStack() { return &_undoStack; }139 QUndoStack* getUndoStack() { return &_undoStack; }
@@ -169,7 +167,7 @@ public: · 27 unmodified lines
169 virtual controller::ScriptingInterface* getControllerScriptingInterface() { return _controllerScriptingInterface; }167 virtual controller::ScriptingInterface* getControllerScriptingInterface() { return _controllerScriptingInterface; }
170 virtual void registerScriptEngineWithApplicationServices(ScriptEngine* scriptEngine) override;168 virtual void registerScriptEngineWithApplicationServices(ScriptEngine* scriptEngine) override;
171 169
172 virtual ViewFrustum* getCurrentViewFrustum() override { return getDisplayViewFrustum(); }170 virtual void copyCurrentViewFrustum(ViewFrustum& viewOut) const override { copyDisplayViewFrustum(viewOut); }
173 virtual QThread* getMainThread() override { return thread(); }171 virtual QThread* getMainThread() override { return thread(); }
174 virtual PickRay computePickRay(float x, float y) const override;172 virtual PickRay computePickRay(float x, float y) const override;
175 virtual glm::vec3 getAvatarPosition() const override;173 virtual glm::vec3 getAvatarPosition() const override;
@@ -413,6 +411,7 @@ private: · 237 unmodified lines
413 EntityTreeRenderer _entityClipboardRenderer;411 EntityTreeRenderer _entityClipboardRenderer;
414 EntityTreePointer _entityClipboard;412 EntityTreePointer _entityClipboard;
415 413
414 mutable QMutex _viewMutex { QMutex::Recursive };
416 ViewFrustum _viewFrustum; // current state of view frustum, perspective, orientation, etc.415 ViewFrustum _viewFrustum; // current state of view frustum, perspective, orientation, etc.
417 ViewFrustum _lastQueriedViewFrustum; /// last view frustum used to query octree servers (voxels)416 ViewFrustum _lastQueriedViewFrustum; /// last view frustum used to query octree servers (voxels)
418 ViewFrustum _displayViewFrustum;417 ViewFrustum _displayViewFrustum;
interface/src/LODManager.cpp+2−3
@@ -10,6 +10,7 @@ · 9 unmodified lines
10//10//
11 11
12#include <SettingHandle.h>12#include <SettingHandle.h>
13#include <OctreeUtils.h>
13#include <Util.h>14#include <Util.h>
14 15
15#include "Application.h"16#include "Application.h"
@@ -216,7 +217,7 @@ QString LODManager::getLODFeedbackText() { · 200 unmodified lines
216bool LODManager::shouldRender(const RenderArgs* args, const AABox& bounds) {217bool LODManager::shouldRender(const RenderArgs* args, const AABox& bounds) {
217 // FIXME - eventually we want to use the render accuracy as an indicator for the level of detail218 // FIXME - eventually we want to use the render accuracy as an indicator for the level of detail
218 // to use in rendering.219 // to use in rendering.
219 float renderAccuracy = args->_viewFrustum->calculateRenderAccuracy(bounds, args->_sizeScale, args->_boundaryLevelAdjust);220 float renderAccuracy = calculateRenderAccuracy(args->getViewFrustum().getPosition(), bounds, args->_sizeScale, args->_boundaryLevelAdjust);
220 return (renderAccuracy > 0.0f);221 return (renderAccuracy > 0.0f);
221};222};
222 223
@@ -228,7 +229,6 @@ void LODManager::setBoundaryLevelAdjust(int boundaryLevelAdjust) { · 5 unmodified lines
228 _boundaryLevelAdjust = boundaryLevelAdjust;229 _boundaryLevelAdjust = boundaryLevelAdjust;
229}230}
230 231
231
232void LODManager::loadSettings() {232void LODManager::loadSettings() {
233 setDesktopLODDecreaseFPS(desktopLODDecreaseFPS.get());233 setDesktopLODDecreaseFPS(desktopLODDecreaseFPS.get());
234 setHMDLODDecreaseFPS(hmdLODDecreaseFPS.get());234 setHMDLODDecreaseFPS(hmdLODDecreaseFPS.get());
@@ -239,4 +239,3 @@ void LODManager::saveSettings() { · 4 unmodified lines
239 hmdLODDecreaseFPS.set(getHMDLODDecreaseFPS());239 hmdLODDecreaseFPS.set(getHMDLODDecreaseFPS());
240}240}
241 241
242
interface/src/Stars.cpp+2−2
@@ -194,8 +194,8 @@ void Stars::render(RenderArgs* renderArgs, float alpha) { · 193 unmodified lines
194 194
195 gpu::Batch& batch = *renderArgs->_batch;195 gpu::Batch& batch = *renderArgs->_batch;
196 batch.setViewTransform(Transform());196 batch.setViewTransform(Transform());
197 batch.setProjectionTransform(renderArgs->_viewFrustum->getProjection());197 batch.setProjectionTransform(renderArgs->getViewFrustum().getProjection());
198 batch.setModelTransform(Transform().setRotation(glm::inverse(renderArgs->_viewFrustum->getOrientation()) *198 batch.setModelTransform(Transform().setRotation(glm::inverse(renderArgs->getViewFrustum().getOrientation()) *
199 quat(vec3(TILT, 0, 0))));199 quat(vec3(TILT, 0, 0))));
200 batch.setResourceTexture(0, textureCache->getWhiteTexture());200 batch.setResourceTexture(0, textureCache->getWhiteTexture());
201 201
interface/src/avatar/Avatar.cpp+21−18
@@ -25,6 +25,7 @@ · 24 unmodified lines
25#include <LODManager.h>25#include <LODManager.h>
26#include <NodeList.h>26#include <NodeList.h>
27#include <NumericalConstants.h>27#include <NumericalConstants.h>
28#include <OctreeUtils.h>
28#include <udt/PacketHeaders.h>29#include <udt/PacketHeaders.h>
29#include <PerfStat.h>30#include <PerfStat.h>
30#include <SharedUtil.h>31#include <SharedUtil.h>
@@ -171,7 +172,10 @@ void Avatar::simulate(float deltaTime) { · 140 unmodified lines
171 // update the shouldAnimate flag to match whether or not we will render the avatar.172 // update the shouldAnimate flag to match whether or not we will render the avatar.
172 const float MINIMUM_VISIBILITY_FOR_ON = 0.4f;173 const float MINIMUM_VISIBILITY_FOR_ON = 0.4f;
173 const float MAXIMUM_VISIBILITY_FOR_OFF = 0.6f;174 const float MAXIMUM_VISIBILITY_FOR_OFF = 0.6f;
174 float visibility = qApp->getViewFrustum()->calculateRenderAccuracy(getBounds(), DependencyManager::get<LODManager>()->getOctreeSizeScale());175 ViewFrustum viewFrustum;
176 qApp->copyViewFrustum(viewFrustum);
177 float visibility = calculateRenderAccuracy(viewFrustum.getPosition(),
178 getBounds(), DependencyManager::get<LODManager>()->getOctreeSizeScale());
175 if (!_shouldAnimate) {179 if (!_shouldAnimate) {
176 if (visibility > MINIMUM_VISIBILITY_FOR_ON) {180 if (visibility > MINIMUM_VISIBILITY_FOR_ON) {
177 _shouldAnimate = true;181 _shouldAnimate = true;
@@ -184,8 +188,9 @@ void Avatar::simulate(float deltaTime) { · 6 unmodified lines
184 188
185 // simple frustum check189 // simple frustum check
186 float boundingRadius = getBoundingRadius();190 float boundingRadius = getBoundingRadius();
187 bool avatarPositionInView = qApp->getDisplayViewFrustum()->sphereIntersectsFrustum(getPosition(), boundingRadius);191 qApp->copyDisplayViewFrustum(viewFrustum);
188 bool avatarMeshInView = qApp->getDisplayViewFrustum()->boxIntersectsFrustum(_skeletonModel->getRenderableMeshBound());192 bool avatarPositionInView = viewFrustum.sphereIntersectsFrustum(getPosition(), boundingRadius);
193 bool avatarMeshInView = viewFrustum.boxIntersectsFrustum(_skeletonModel->getRenderableMeshBound());
189 194
190 if (_shouldAnimate && !_shouldSkipRender && (avatarPositionInView || avatarMeshInView)) {195 if (_shouldAnimate && !_shouldSkipRender && (avatarPositionInView || avatarMeshInView)) {
191 {196 {
@@ -381,17 +386,16 @@ void Avatar::render(RenderArgs* renderArgs, const glm::vec3& cameraPosition) { · 189 unmodified lines
381 }386 }
382 }387 }
383 388
384 // simple frustum check389 { // simple frustum check
385 float boundingRadius = getBoundingRadius();390 ViewFrustum frustum;
386 ViewFrustum* frustum = nullptr;391 if (renderArgs->_renderMode == RenderArgs::SHADOW_RENDER_MODE) {
387 if (renderArgs->_renderMode == RenderArgs::SHADOW_RENDER_MODE) {392 qApp->copyShadowViewFrustum(frustum);
388 frustum = qApp->getShadowViewFrustum();393 } else {
389 } else {394 qApp->copyDisplayViewFrustum(frustum);
390 frustum = qApp->getDisplayViewFrustum();395 }
391 }396 if (!frustum.sphereIntersectsFrustum(getPosition(), getBoundingRadius())) {
392 397 return;
393 if (!frustum->sphereIntersectsFrustum(getPosition(), boundingRadius)) {398 }
394 return;
395 }399 }
396 400
397 glm::vec3 toTarget = cameraPosition - getPosition();401 glm::vec3 toTarget = cameraPosition - getPosition();
@@ -413,7 +417,7 @@ void Avatar::render(RenderArgs* renderArgs, const glm::vec3& cameraPosition) { · 15 unmodified lines
413 : GLOW_FROM_AVERAGE_LOUDNESS;417 : GLOW_FROM_AVERAGE_LOUDNESS;
414 418
415 // render body419 // render body
416 renderBody(renderArgs, frustum, glowLevel);420 renderBody(renderArgs, glowLevel);
417 421
418 if (renderArgs->_renderMode != RenderArgs::SHADOW_RENDER_MODE) {422 if (renderArgs->_renderMode != RenderArgs::SHADOW_RENDER_MODE) {
419 // add local lights423 // add local lights
@@ -502,9 +506,8 @@ void Avatar::render(RenderArgs* renderArgs, const glm::vec3& cameraPosition) { · 82 unmodified lines
502 506
503 auto cameraMode = qApp->getCamera()->getMode();507 auto cameraMode = qApp->getCamera()->getMode();
504 if (!isMyAvatar() || cameraMode != CAMERA_MODE_FIRST_PERSON) {508 if (!isMyAvatar() || cameraMode != CAMERA_MODE_FIRST_PERSON) {
505 auto& frustum = *renderArgs->_viewFrustum;509 auto& frustum = renderArgs->getViewFrustum();
506 auto textPosition = getDisplayNamePosition();510 auto textPosition = getDisplayNamePosition();
507
508 if (frustum.pointIntersectsFrustum(textPosition)) {511 if (frustum.pointIntersectsFrustum(textPosition)) {
509 renderDisplayName(batch, frustum, textPosition);512 renderDisplayName(batch, frustum, textPosition);
510 }513 }
@@ -553,7 +556,7 @@ void Avatar::fixupModelsInScene() { · 42 unmodified lines
553 scene->enqueuePendingChanges(pendingChanges);556 scene->enqueuePendingChanges(pendingChanges);
554}557}
555 558
556void Avatar::renderBody(RenderArgs* renderArgs, ViewFrustum* renderFrustum, float glowLevel) {559void Avatar::renderBody(RenderArgs* renderArgs, float glowLevel) {
557 fixupModelsInScene();560 fixupModelsInScene();
558 getHead()->renderLookAts(renderArgs);561 getHead()->renderLookAts(renderArgs);
559}562}
interface/src/avatar/Avatar.h+1−1
@@ -232,7 +232,7 @@ protected: · 231 unmodified lines
232 232
233 Transform calculateDisplayNameTransform(const ViewFrustum& view, const glm::vec3& textPosition) const;233 Transform calculateDisplayNameTransform(const ViewFrustum& view, const glm::vec3& textPosition) const;
234 void renderDisplayName(gpu::Batch& batch, const ViewFrustum& view, const glm::vec3& textPosition) const;234 void renderDisplayName(gpu::Batch& batch, const ViewFrustum& view, const glm::vec3& textPosition) const;
235 virtual void renderBody(RenderArgs* renderArgs, ViewFrustum* renderFrustum, float glowLevel = 0.0f);235 virtual void renderBody(RenderArgs* renderArgs, float glowLevel = 0.0f);
236 virtual bool shouldRenderHead(const RenderArgs* renderArgs) const;236 virtual bool shouldRenderHead(const RenderArgs* renderArgs) const;
237 virtual void fixupModelsInScene();237 virtual void fixupModelsInScene();
238 238
interface/src/avatar/Head.cpp+0−3
@@ -316,9 +316,6 @@ void Head::relaxLean(float deltaTime) { · 315 unmodified lines
316 _deltaLeanForward *= relaxationFactor;316 _deltaLeanForward *= relaxationFactor;
317}317}
318 318
319void Head::render(RenderArgs* renderArgs, float alpha, ViewFrustum* renderFrustum) {
320}
321
322void Head::renderLookAts(RenderArgs* renderArgs) {319void Head::renderLookAts(RenderArgs* renderArgs) {
323 renderLookAts(renderArgs, _leftEyePosition, _rightEyePosition);320 renderLookAts(renderArgs, _leftEyePosition, _rightEyePosition);
324}321}
interface/src/avatar/Head.h+2−3
@@ -28,11 +28,10 @@ class Avatar; · 27 unmodified lines
28class Head : public HeadData {28class Head : public HeadData {
29public:29public:
30 explicit Head(Avatar* owningAvatar);30 explicit Head(Avatar* owningAvatar);
31 31
32 void init();32 void init();
33 void reset();33 void reset();
34 void simulate(float deltaTime, bool isMine, bool billboard = false);34 void simulate(float deltaTime, bool isMine, bool billboard = false);
35 void render(RenderArgs* renderArgs, float alpha, ViewFrustum* renderFrustum);
36 void setScale(float scale);35 void setScale(float scale);
37 void setPosition(glm::vec3 position) { _position = position; }36 void setPosition(glm::vec3 position) { _position = position; }
38 void setAverageLoudness(float averageLoudness) { _averageLoudness = averageLoudness; }37 void setAverageLoudness(float averageLoudness) { _averageLoudness = averageLoudness; }
@@ -44,7 +43,7 @@ public: · 5 unmodified lines
44 43
45 /// \return orientationBase+Delta44 /// \return orientationBase+Delta
46 glm::quat getFinalOrientationInLocalFrame() const;45 glm::quat getFinalOrientationInLocalFrame() const;
47 46
48 /// \return orientationBody * (orientationBase+Delta)47 /// \return orientationBody * (orientationBase+Delta)
49 glm::quat getFinalOrientationInWorldFrame() const;48 glm::quat getFinalOrientationInWorldFrame() const;
50 49
interface/src/avatar/MyAvatar.cpp+11−12
@@ -545,7 +545,9 @@ void MyAvatar::updateFromTrackers(float deltaTime) { · 544 unmodified lines
545 head->setDeltaYaw(estimatedRotation.y);545 head->setDeltaYaw(estimatedRotation.y);
546 head->setDeltaRoll(estimatedRotation.z);546 head->setDeltaRoll(estimatedRotation.z);
547 } else {547 } else {
548 float magnifyFieldOfView = qApp->getViewFrustum()->getFieldOfView() / _realWorldFieldOfView.get();548 ViewFrustum viewFrustum;
549 qApp->copyViewFrustum(viewFrustum);
550 float magnifyFieldOfView = viewFrustum.getFieldOfView() / _realWorldFieldOfView.get();
549 head->setDeltaPitch(estimatedRotation.x * magnifyFieldOfView);551 head->setDeltaPitch(estimatedRotation.x * magnifyFieldOfView);
550 head->setDeltaYaw(estimatedRotation.y * magnifyFieldOfView);552 head->setDeltaYaw(estimatedRotation.y * magnifyFieldOfView);
551 head->setDeltaRoll(estimatedRotation.z);553 head->setDeltaRoll(estimatedRotation.z);
@@ -928,15 +930,17 @@ void MyAvatar::updateLookAtTargetAvatar() { · 376 unmodified lines
928 // (We will be adding that offset to the camera position, after making some other adjustments.)930 // (We will be adding that offset to the camera position, after making some other adjustments.)
929 glm::vec3 gazeOffset = lookAtPosition - getHead()->getEyePosition();931 glm::vec3 gazeOffset = lookAtPosition - getHead()->getEyePosition();
930 932
933 ViewFrustum viewFrustum;
934 qApp->copyViewFrustum(viewFrustum);
935
931 // scale gazeOffset by IPD, if wearing an HMD.936 // scale gazeOffset by IPD, if wearing an HMD.
932 if (qApp->isHMDMode()) {937 if (qApp->isHMDMode()) {
933 glm::mat4 leftEye = qApp->getEyeOffset(Eye::Left);938 glm::mat4 leftEye = qApp->getEyeOffset(Eye::Left);
934 glm::mat4 rightEye = qApp->getEyeOffset(Eye::Right);939 glm::mat4 rightEye = qApp->getEyeOffset(Eye::Right);
935 glm::vec3 leftEyeHeadLocal = glm::vec3(leftEye[3]);940 glm::vec3 leftEyeHeadLocal = glm::vec3(leftEye[3]);
936 glm::vec3 rightEyeHeadLocal = glm::vec3(rightEye[3]);941 glm::vec3 rightEyeHeadLocal = glm::vec3(rightEye[3]);
937 auto humanSystem = qApp->getViewFrustum();942 glm::vec3 humanLeftEye = viewFrustum.getPosition() + (viewFrustum.getOrientation() * leftEyeHeadLocal);
938 glm::vec3 humanLeftEye = humanSystem->getPosition() + (humanSystem->getOrientation() * leftEyeHeadLocal);943 glm::vec3 humanRightEye = viewFrustum.getPosition() + (viewFrustum.getOrientation() * rightEyeHeadLocal);
939 glm::vec3 humanRightEye = humanSystem->getPosition() + (humanSystem->getOrientation() * rightEyeHeadLocal);
940 944
941 auto hmdInterface = DependencyManager::get<HMDScriptingInterface>();945 auto hmdInterface = DependencyManager::get<HMDScriptingInterface>();
942 float ipdScale = hmdInterface->getIPDScale();946 float ipdScale = hmdInterface->getIPDScale();
@@ -950,7 +954,7 @@ void MyAvatar::updateLookAtTargetAvatar() { · 7 unmodified lines
950 }954 }
951 955
952 // And now we can finally add that offset to the camera.956 // And now we can finally add that offset to the camera.
953 glm::vec3 corrected = qApp->getViewFrustum()->getPosition() + gazeOffset;957 glm::vec3 corrected = viewFrustum.getPosition() + gazeOffset;
954 958
955 avatar->getHead()->setCorrectedLookAtPosition(corrected);959 avatar->getHead()->setCorrectedLookAtPosition(corrected);
956 960
@@ -1266,7 +1270,7 @@ void MyAvatar::attach(const QString& modelURL, const QString& jointName, · 309 unmodified lines
1266 Avatar::attach(modelURL, jointName, translation, rotation, scale, isSoft, allowDuplicates, useSaved);1270 Avatar::attach(modelURL, jointName, translation, rotation, scale, isSoft, allowDuplicates, useSaved);
1267}1271}
1268 1272
1269void MyAvatar::renderBody(RenderArgs* renderArgs, ViewFrustum* renderFrustum, float glowLevel) {1273void MyAvatar::renderBody(RenderArgs* renderArgs, float glowLevel) {
1270 1274
1271 if (!_skeletonModel->isRenderable()) {1275 if (!_skeletonModel->isRenderable()) {
1272 return; // wait until all models are loaded1276 return; // wait until all models are loaded
@@ -1274,11 +1278,6 @@ void MyAvatar::renderBody(RenderArgs* renderArgs, ViewFrustum* renderFrustum, fl · 1 unmodified line
1274 1278
1275 fixupModelsInScene();1279 fixupModelsInScene();
1276 1280
1277 // Render head so long as the camera isn't inside it
1278 if (shouldRenderHead(renderArgs)) {
1279 getHead()->render(renderArgs, 1.0f, renderFrustum);
1280 }
1281
1282 // This is drawing the lookat vectors from our avatar to wherever we're looking.1281 // This is drawing the lookat vectors from our avatar to wherever we're looking.
1283 if (qApp->isHMDMode()) {1282 if (qApp->isHMDMode()) {
1284 glm::vec3 cameraPosition = qApp->getCamera()->getPosition();1283 glm::vec3 cameraPosition = qApp->getCamera()->getPosition();
@@ -1359,7 +1358,6 @@ void MyAvatar::destroyAnimGraph() { · 74 unmodified lines
1359void MyAvatar::preRender(RenderArgs* renderArgs) {1358void MyAvatar::preRender(RenderArgs* renderArgs) {
1360 1359
1361 render::ScenePointer scene = qApp->getMain3DScene();1360 render::ScenePointer scene = qApp->getMain3DScene();
1362 const bool shouldDrawHead = shouldRenderHead(renderArgs);
1363 1361
1364 if (_skeletonModel->initWhenReady(scene)) {1362 if (_skeletonModel->initWhenReady(scene)) {
1365 initHeadBones();1363 initHeadBones();
@@ -1411,6 +1409,7 @@ void MyAvatar::preRender(RenderArgs* renderArgs) { · 45 unmodified lines
1411 DebugDraw::getInstance().updateMyAvatarPos(getPosition());1409 DebugDraw::getInstance().updateMyAvatarPos(getPosition());
1412 DebugDraw::getInstance().updateMyAvatarRot(getOrientation());1410 DebugDraw::getInstance().updateMyAvatarRot(getOrientation());
1413 1411
1412 const bool shouldDrawHead = shouldRenderHead(renderArgs);
1414 if (shouldDrawHead != _prevShouldDrawHead) {1413 if (shouldDrawHead != _prevShouldDrawHead) {
1415 _skeletonModel->setCauterizeBones(!shouldDrawHead);1414 _skeletonModel->setCauterizeBones(!shouldDrawHead);
1416 }1415 }
interface/src/avatar/MyAvatar.h+1−1
@@ -310,7 +310,7 @@ private: · 309 unmodified lines
310 void simulate(float deltaTime);310 void simulate(float deltaTime);
311 void updateFromTrackers(float deltaTime);311 void updateFromTrackers(float deltaTime);
312 virtual void render(RenderArgs* renderArgs, const glm::vec3& cameraPositio) override;312 virtual void render(RenderArgs* renderArgs, const glm::vec3& cameraPositio) override;
313 virtual void renderBody(RenderArgs* renderArgs, ViewFrustum* renderFrustum, float glowLevel = 0.0f) override;313 virtual void renderBody(RenderArgs* renderArgs, float glowLevel = 0.0f) override;
314 virtual bool shouldRenderHead(const RenderArgs* renderArgs) const override;314 virtual bool shouldRenderHead(const RenderArgs* renderArgs) const override;
315 void setShouldRenderLocally(bool shouldRender) { _shouldRender = shouldRender; setEnableMeshVisible(shouldRender); }315 void setShouldRenderLocally(bool shouldRender) { _shouldRender = shouldRender; setEnableMeshVisible(shouldRender); }
316 bool getShouldRenderLocally() const { return _shouldRender; }316 bool getShouldRenderLocally() const { return _shouldRender; }
interface/src/ui/overlays/Grid3DOverlay.cpp+1−1
@@ -65,7 +65,7 @@ void Grid3DOverlay::render(RenderArgs* args) { · 64 unmodified lines
65 // Get the camera position rounded to the nearest major grid line65 // Get the camera position rounded to the nearest major grid line
66 // This grid is for UI and should lie on worldlines66 // This grid is for UI and should lie on worldlines
67 auto cameraPosition =67 auto cameraPosition =
68 (float)_majorGridEvery * glm::round(args->_viewFrustum->getPosition() / (float)_majorGridEvery);68 (float)_majorGridEvery * glm::round(args->getViewFrustum().getPosition() / (float)_majorGridEvery);
69 69
70 position += glm::vec3(cameraPosition.x, 0.0f, cameraPosition.z);70 position += glm::vec3(cameraPosition.x, 0.0f, cameraPosition.z);
71 }71 }
interface/src/ui/overlays/LocalModelsOverlay.cpp+2−2
@@ -37,10 +37,10 @@ void LocalModelsOverlay::render(RenderArgs* args) { · 36 unmodified lines
37 auto batch = args ->_batch;37 auto batch = args ->_batch;
38 38
39 Transform transform = Transform();39 Transform transform = Transform();
40 transform.setTranslation(args->_viewFrustum->getPosition() + getPosition());40 transform.setTranslation(args->getViewFrustum().getPosition() + getPosition());
41 batch->setViewTransform(transform);41 batch->setViewTransform(transform);
42 _entityTreeRenderer->render(args);42 _entityTreeRenderer->render(args);
43 transform.setTranslation(args->_viewFrustum->getPosition());43 transform.setTranslation(args->getViewFrustum().getPosition());
44 batch->setViewTransform(transform);44 batch->setViewTransform(transform);
45 }45 }
46}46}
libraries/entities-renderer/src/RenderableTextEntityItem.cpp+1−1
@@ -51,7 +51,7 @@ void RenderableTextEntityItem::render(RenderArgs* args) { · 50 unmodified lines
51 }51 }
52 if (getFaceCamera()) {52 if (getFaceCamera()) {
53 //rotate about vertical to face the camera53 //rotate about vertical to face the camera
54 glm::vec3 dPosition = args->_viewFrustum->getPosition() - getPosition();54 glm::vec3 dPosition = args->getViewFrustum().getPosition() - getPosition();
55 // If x and z are 0, atan(x, z) is undefined, so default to 0 degrees55 // If x and z are 0, atan(x, z) is undefined, so default to 0 degrees
56 float yawRotation = dPosition.x == 0.0f && dPosition.z == 0.0f ? 0.0f : glm::atan(dPosition.x, dPosition.z);56 float yawRotation = dPosition.x == 0.0f && dPosition.z == 0.0f ? 0.0f : glm::atan(dPosition.x, dPosition.z);
57 glm::quat orientation = glm::quat(glm::vec3(0.0f, yawRotation, 0.0f));57 glm::quat orientation = glm::quat(glm::vec3(0.0f, yawRotation, 0.0f));
libraries/entities/src/EntityTreeElement.cpp+7−5
@@ -13,6 +13,7 @@ · 12 unmodified lines
13 13
14#include <FBXReader.h>14#include <FBXReader.h>
15#include <GeometryUtil.h>15#include <GeometryUtil.h>
16#include <OctreeUtils.h>
16 17
17#include "EntitiesLogging.h"18#include "EntitiesLogging.h"
18#include "EntityItemProperties.h"19#include "EntityItemProperties.h"
@@ -295,7 +296,7 @@ OctreeElement::AppendState EntityTreeElement::appendElementData(OctreePacketData · 276 unmodified lines
295 entityTreeElementExtraEncodeData->entities.contains(entity->getEntityItemID());296 entityTreeElementExtraEncodeData->entities.contains(entity->getEntityItemID());
296 }297 }
297 298
298 if (includeThisEntity && params.viewFrustum) {299 if (includeThisEntity || params.recurseEverything) {
299 300
300 // we want to use the maximum possible box for this, so that we don't have to worry about the nuance of301 // we want to use the maximum possible box for this, so that we don't have to worry about the nuance of
301 // simulation changing what's visible. consider the case where the entity contains an angular velocity302 // simulation changing what's visible. consider the case where the entity contains an angular velocity
@@ -303,7 +304,7 @@ OctreeElement::AppendState EntityTreeElement::appendElementData(OctreePacketData · 1 unmodified line
303 // frustum culling on rendering.304 // frustum culling on rendering.
304 bool success;305 bool success;
305 AACube entityCube = entity->getQueryAACube(success);306 AACube entityCube = entity->getQueryAACube(success);
306 if (!success || !params.viewFrustum->cubeIntersectsKeyhole(entityCube)) {307 if (!success || !params.viewFrustum.cubeIntersectsKeyhole(entityCube)) {
307 includeThisEntity = false; // out of view, don't include it308 includeThisEntity = false; // out of view, don't include it
308 } else {309 } else {
309 // Check the size of the entity, it's possible that a "too small to see" entity is included in a310 // Check the size of the entity, it's possible that a "too small to see" entity is included in a
@@ -320,9 +321,10 @@ OctreeElement::AppendState EntityTreeElement::appendElementData(OctreePacketData · 10 unmodified lines
320 // AABox. If this happens, fall back to the queryAACube.321 // AABox. If this happens, fall back to the queryAACube.
321 entityBounds = AABox(entityCube);322 entityBounds = AABox(entityCube);
322 }323 }
323 auto renderAccuracy = params.viewFrustum->calculateRenderAccuracy(entityBounds,324 auto renderAccuracy = calculateRenderAccuracy(params.viewFrustum.getPosition(),
324 params.octreeElementSizeScale,325 entityBounds,
325 params.boundaryLevelAdjust);326 params.octreeElementSizeScale,
327 params.boundaryLevelAdjust);
326 if (renderAccuracy <= 0.0f) {328 if (renderAccuracy <= 0.0f) {
327 includeThisEntity = false; // too small, don't include it329 includeThisEntity = false; // too small, don't include it
328 330
libraries/octree/src/Octree.cpp+28−32
@@ -33,6 +33,7 @@ · 32 unmodified lines
33#include <QString>33#include <QString>
34 34
35#include <GeometryUtil.h>35#include <GeometryUtil.h>
36#include <Gzip.h>
36#include <LogHandler.h>37#include <LogHandler.h>
37#include <NetworkAccessManager.h>38#include <NetworkAccessManager.h>
38#include <OctalCode.h>39#include <OctalCode.h>
@@ -40,12 +41,12 @@ · 1 unmodified line
40#include <ResourceManager.h>41#include <ResourceManager.h>
41#include <SharedUtil.h>42#include <SharedUtil.h>
42#include <PathUtils.h>43#include <PathUtils.h>
43#include <Gzip.h>44#include <ViewFrustum.h>
44 45
45#include "OctreeConstants.h"46#include "OctreeConstants.h"
46#include "OctreeElementBag.h"47#include "OctreeElementBag.h"
47#include "Octree.h"48#include "Octree.h"
48#include "ViewFrustum.h"49#include "OctreeUtils.h"
49#include "OctreeLogging.h"50#include "OctreeLogging.h"
50 51
51 52
@@ -898,7 +899,7 @@ int Octree::encodeTreeBitstream(OctreeElementPointer element, · 846 unmodified lines
898 }899 }
899 900
900 // If we're at a element that is out of view, then we can return, because no nodes below us will be in view!901 // If we're at a element that is out of view, then we can return, because no nodes below us will be in view!
901 if (params.viewFrustum && !element->isInView(*params.viewFrustum)) {902 if (!params.recurseEverything && !element->isInView(params.viewFrustum)) {
902 params.stopReason = EncodeBitstreamParams::OUT_OF_VIEW;903 params.stopReason = EncodeBitstreamParams::OUT_OF_VIEW;
903 return bytesWritten;904 return bytesWritten;
904 }905 }
@@ -1014,15 +1015,12 @@ int Octree::encodeTreeBitstreamRecursion(OctreeElementPointer element, · 109 unmodified lines
1014 }1015 }
1015 1016
1016 ViewFrustum::intersection nodeLocationThisView = ViewFrustum::INSIDE; // assume we're inside1017 ViewFrustum::intersection nodeLocationThisView = ViewFrustum::INSIDE; // assume we're inside
1017 1018 if (!params.recurseEverything) {
1018 // caller can pass NULL as viewFrustum if they want everything
1019 if (params.viewFrustum) {
1020 float distance = element->distanceToCamera(*params.viewFrustum);
1021 float boundaryDistance = boundaryDistanceForRenderLevel(element->getLevel() + params.boundaryLevelAdjust,1019 float boundaryDistance = boundaryDistanceForRenderLevel(element->getLevel() + params.boundaryLevelAdjust,
1022 params.octreeElementSizeScale);1020 params.octreeElementSizeScale);
1023 1021
1024 // If we're too far away for our render level, then just return1022 // If we're too far away for our render level, then just return
1025 if (distance >= boundaryDistance) {1023 if (element->distanceToCamera(params.viewFrustum) >= boundaryDistance) {
1026 if (params.stats) {1024 if (params.stats) {
1027 params.stats->skippedDistance(element);1025 params.stats->skippedDistance(element);
1028 }1026 }
@@ -1034,7 +1032,7 @@ int Octree::encodeTreeBitstreamRecursion(OctreeElementPointer element, · 5 unmodified lines
1034 // if we are INSIDE, INTERSECT, or OUTSIDE1032 // if we are INSIDE, INTERSECT, or OUTSIDE
1035 if (parentLocationThisView != ViewFrustum::INSIDE) {1033 if (parentLocationThisView != ViewFrustum::INSIDE) {
1036 assert(parentLocationThisView != ViewFrustum::OUTSIDE); // we shouldn't be here if our parent was OUTSIDE!1034 assert(parentLocationThisView != ViewFrustum::OUTSIDE); // we shouldn't be here if our parent was OUTSIDE!
1037 nodeLocationThisView = element->computeViewIntersection(*params.viewFrustum);1035 nodeLocationThisView = element->computeViewIntersection(params.viewFrustum);
1038 }1036 }
1039 1037
1040 // If we're at a element that is out of view, then we can return, because no nodes below us will be in view!1038 // If we're at a element that is out of view, then we can return, because no nodes below us will be in view!
@@ -1052,8 +1050,8 @@ int Octree::encodeTreeBitstreamRecursion(OctreeElementPointer element, · 11 unmodified lines
1052 // because we don't send nodes from the previously know in view frustum.1050 // because we don't send nodes from the previously know in view frustum.
1053 bool wasInView = false;1051 bool wasInView = false;
1054 1052
1055 if (params.deltaViewFrustum && params.lastViewFrustum) {1053 if (params.deltaView) {
1056 ViewFrustum::intersection location = element->computeViewIntersection(*params.lastViewFrustum);1054 ViewFrustum::intersection location = element->computeViewIntersection(params.lastViewFrustum);
1057 1055
1058 // If we're a leaf, then either intersect or inside is considered "formerly in view"1056 // If we're a leaf, then either intersect or inside is considered "formerly in view"
1059 if (element->isLeaf()) {1057 if (element->isLeaf()) {
@@ -1067,10 +1065,9 @@ int Octree::encodeTreeBitstreamRecursion(OctreeElementPointer element, · 7 unmodified lines
1067 // to it, and so therefore it may now be visible from an LOD perspective, in which case we don't consider it1065 // to it, and so therefore it may now be visible from an LOD perspective, in which case we don't consider it
1068 // as "was in view"...1066 // as "was in view"...
1069 if (wasInView) {1067 if (wasInView) {
1070 float distance = element->distanceToCamera(*params.lastViewFrustum);
1071 float boundaryDistance = boundaryDistanceForRenderLevel(element->getLevel() + params.boundaryLevelAdjust,1068 float boundaryDistance = boundaryDistanceForRenderLevel(element->getLevel() + params.boundaryLevelAdjust,
1072 params.octreeElementSizeScale);1069 params.octreeElementSizeScale);
1073 if (distance >= boundaryDistance) {1070 if (element->distanceToCamera(params.lastViewFrustum) >= boundaryDistance) {
1074 // This would have been invisible... but now should be visible (we wouldn't be here otherwise)...1071 // This would have been invisible... but now should be visible (we wouldn't be here otherwise)...
1075 wasInView = false;1072 wasInView = false;
1076 }1073 }
@@ -1078,9 +1075,9 @@ int Octree::encodeTreeBitstreamRecursion(OctreeElementPointer element, · 1 unmodified line
1078 }1075 }
1079 1076
1080 // If we were previously in the view, then we normally will return out of here and stop recursing. But1077 // If we were previously in the view, then we normally will return out of here and stop recursing. But
1081 // if we're in deltaViewFrustum mode, and this element has changed since it was last sent, then we do1078 // if we're in deltaView mode, and this element has changed since it was last sent, then we do
1082 // need to send it.1079 // need to send it.
1083 if (wasInView && !(params.deltaViewFrustum && element->hasChangedSince(params.lastViewFrustumSent - CHANGE_FUDGE))) {1080 if (wasInView && !(params.deltaView && element->hasChangedSince(params.lastViewFrustumSent - CHANGE_FUDGE))) {
1084 if (params.stats) {1081 if (params.stats) {
1085 params.stats->skippedWasInView(element);1082 params.stats->skippedWasInView(element);
1086 }1083 }
@@ -1090,7 +1087,7 @@ int Octree::encodeTreeBitstreamRecursion(OctreeElementPointer element, · 3 unmodified lines
1090 1087
1091 // If we're not in delta sending mode, and we weren't asked to do a force send, and the voxel hasn't changed,1088 // If we're not in delta sending mode, and we weren't asked to do a force send, and the voxel hasn't changed,
1092 // then we can also bail early and save bits1089 // then we can also bail early and save bits
1093 if (!params.forceSendScene && !params.deltaViewFrustum &&1090 if (!params.forceSendScene && !params.deltaView &&
1094 !element->hasChangedSince(params.lastViewFrustumSent - CHANGE_FUDGE)) {1091 !element->hasChangedSince(params.lastViewFrustumSent - CHANGE_FUDGE)) {
1095 if (params.stats) {1092 if (params.stats) {
1096 params.stats->skippedNoChange(element);1093 params.stats->skippedNoChange(element);
@@ -1179,10 +1176,10 @@ int Octree::encodeTreeBitstreamRecursion(OctreeElementPointer element, · 82 unmodified lines
1179 int originalIndex = indexOfChildren[i];1176 int originalIndex = indexOfChildren[i];
1180 1177
1181 bool childIsInView = (childElement &&1178 bool childIsInView = (childElement &&
1182 ( !params.viewFrustum || // no view frustum was given, everything is assumed in view1179 (params.recurseEverything ||
1183 (nodeLocationThisView == ViewFrustum::INSIDE) || // parent was fully in view, we can assume ALL children are1180 (nodeLocationThisView == ViewFrustum::INSIDE) || // parent was fully in view, we can assume ALL children are
1184 (nodeLocationThisView == ViewFrustum::INTERSECT &&1181 (nodeLocationThisView == ViewFrustum::INTERSECT &&
1185 childElement->isInView(*params.viewFrustum)) // the parent intersects and the child is in view1182 childElement->isInView(params.viewFrustum)) // the parent intersects and the child is in view
1186 ));1183 ));
1187 1184
1188 if (!childIsInView) {1185 if (!childIsInView) {
@@ -1192,12 +1189,11 @@ int Octree::encodeTreeBitstreamRecursion(OctreeElementPointer element, · 3 unmodified lines
1192 }1189 }
1193 } else {1190 } else {
1194 // Before we consider this further, let's see if it's in our LOD scope...1191 // Before we consider this further, let's see if it's in our LOD scope...
1195 float distance = distancesToChildren[i];1192 float boundaryDistance = params.recurseEverything ? 1 :
1196 float boundaryDistance = !params.viewFrustum ? 1 :1193 boundaryDistanceForRenderLevel(childElement->getLevel() + params.boundaryLevelAdjust,
1197 boundaryDistanceForRenderLevel(childElement->getLevel() + params.boundaryLevelAdjust,
1198 params.octreeElementSizeScale);1194 params.octreeElementSizeScale);
1199 1195
1200 if (!(distance < boundaryDistance)) {1196 if (!(distancesToChildren[i] < boundaryDistance)) {
1201 // don't need to check childElement here, because we can't get here with no childElement1197 // don't need to check childElement here, because we can't get here with no childElement
1202 if (params.stats) {1198 if (params.stats) {
1203 params.stats->skippedDistance(childElement);1199 params.stats->skippedDistance(childElement);
@@ -1215,10 +1211,9 @@ int Octree::encodeTreeBitstreamRecursion(OctreeElementPointer element, · 11 unmodified lines
1215 1211
1216 bool childIsOccluded = false; // assume it's not occluded1212 bool childIsOccluded = false; // assume it's not occluded
1217 1213
1218 bool shouldRender = !params.viewFrustum1214 bool shouldRender = params.recurseEverything ||
1219 ? true1215 childElement->calculateShouldRender(params.viewFrustum,
1220 : childElement->calculateShouldRender(params.viewFrustum,1216 params.octreeElementSizeScale, params.boundaryLevelAdjust);
1221 params.octreeElementSizeScale, params.boundaryLevelAdjust);
1222 1217
1223 // track some stats1218 // track some stats
1224 if (params.stats) {1219 if (params.stats) {
@@ -1236,8 +1231,8 @@ int Octree::encodeTreeBitstreamRecursion(OctreeElementPointer element, · 11 unmodified lines
1236 if (shouldRender && !childIsOccluded) {1231 if (shouldRender && !childIsOccluded) {
1237 bool childWasInView = false;1232 bool childWasInView = false;
1238 1233
1239 if (childElement && params.deltaViewFrustum && params.lastViewFrustum) {1234 if (childElement && params.deltaView) {
1240 ViewFrustum::intersection location = childElement->computeViewIntersection(*params.lastViewFrustum);1235 ViewFrustum::intersection location = childElement->computeViewIntersection(params.lastViewFrustum);
1241 1236
1242 // If we're a leaf, then either intersect or inside is considered "formerly in view"1237 // If we're a leaf, then either intersect or inside is considered "formerly in view"
1243 if (childElement->isLeaf()) {1238 if (childElement->isLeaf()) {
@@ -1251,7 +1246,7 @@ int Octree::encodeTreeBitstreamRecursion(OctreeElementPointer element, · 7 unmodified lines
1251 // Or if we were previously in the view, but this element has changed since it was last sent, then we do1246 // Or if we were previously in the view, but this element has changed since it was last sent, then we do
1252 // need to send it.1247 // need to send it.
1253 if (!childWasInView ||1248 if (!childWasInView ||
1254 (params.deltaViewFrustum &&1249 (params.deltaView &&
1255 childElement->hasChangedSince(params.lastViewFrustumSent - CHANGE_FUDGE))){1250 childElement->hasChangedSince(params.lastViewFrustumSent - CHANGE_FUDGE))){
1256 1251
1257 childrenDataBits += (1 << (7 - originalIndex));1252 childrenDataBits += (1 << (7 - originalIndex));
@@ -1456,7 +1451,7 @@ int Octree::encodeTreeBitstreamRecursion(OctreeElementPointer element, · 198 unmodified lines
1456 // called databits), then we wouldn't send the children. So those types of Octree's should tell us to keep1451 // called databits), then we wouldn't send the children. So those types of Octree's should tell us to keep
1457 // recursing, by returning TRUE in recurseChildrenWithData().1452 // recursing, by returning TRUE in recurseChildrenWithData().
1458 1453
1459 if (recurseChildrenWithData() || !params.viewFrustum || !oneAtBit(childrenDataBits, originalIndex)) {1454 if (params.recurseEverything || recurseChildrenWithData() || !oneAtBit(childrenDataBits, originalIndex)) {
1460 1455
1461 // Allow the datatype a chance to determine if it really wants to recurse this tree. Usually this1456 // Allow the datatype a chance to determine if it really wants to recurse this tree. Usually this
1462 // will be true. But if the tree has already been encoded, we will skip this.1457 // will be true. But if the tree has already been encoded, we will skip this.
@@ -1978,7 +1973,8 @@ void Octree::writeToSVOFile(const char* fileName, OctreeElementPointer element) · 515 unmodified lines
1978 bool lastPacketWritten = false;1973 bool lastPacketWritten = false;
1979 1974
1980 while (OctreeElementPointer subTree = elementBag.extract()) {1975 while (OctreeElementPointer subTree = elementBag.extract()) {
1981 EncodeBitstreamParams params(INT_MAX, IGNORE_VIEW_FRUSTUM, NO_EXISTS_BITS);1976 EncodeBitstreamParams params(INT_MAX, NO_EXISTS_BITS);
1977 params.recurseEverything = true;
1982 withReadLock([&] {1978 withReadLock([&] {
1983 params.extraEncodeData = &extraEncodeData;1979 params.extraEncodeData = &extraEncodeData;
1984 bytesWritten = encodeTreeBitstream(subTree, &packetData, elementBag, params);1980 bytesWritten = encodeTreeBitstream(subTree, &packetData, elementBag, params);
libraries/octree/src/Octree.h+13−16
@@ -20,9 +20,9 @@ · 19 unmodified lines
20 20
21#include <shared/ReadWriteLockable.h>21#include <shared/ReadWriteLockable.h>
22#include <SimpleMovingAverage.h>22#include <SimpleMovingAverage.h>
23#include <ViewFrustum.h>
23 24
24#include "JurisdictionMap.h"25#include "JurisdictionMap.h"
25#include "ViewFrustum.h"
26#include "OctreeElement.h"26#include "OctreeElement.h"
27#include "OctreeElementBag.h"27#include "OctreeElementBag.h"
28#include "OctreePacketData.h"28#include "OctreePacketData.h"
@@ -61,22 +61,22 @@ const int LOW_RES_MOVING_ADJUST = 1; · 32 unmodified lines
61const quint64 IGNORE_LAST_SENT = 0;61const quint64 IGNORE_LAST_SENT = 0;
62 62
63#define IGNORE_SCENE_STATS NULL63#define IGNORE_SCENE_STATS NULL
64#define IGNORE_VIEW_FRUSTUM NULL
65#define IGNORE_COVERAGE_MAP NULL64#define IGNORE_COVERAGE_MAP NULL
66#define IGNORE_JURISDICTION_MAP NULL65#define IGNORE_JURISDICTION_MAP NULL
67 66
68class EncodeBitstreamParams {67class EncodeBitstreamParams {
69public:68public:
69 ViewFrustum viewFrustum;
70 ViewFrustum lastViewFrustum;
71 quint64 lastViewFrustumSent;
70 int maxEncodeLevel;72 int maxEncodeLevel;
71 int maxLevelReached;73 int maxLevelReached;
72 const ViewFrustum* viewFrustum;
73 bool includeExistsBits;74 bool includeExistsBits;
74 int chopLevels;75 int chopLevels;
75 bool deltaViewFrustum;76 bool deltaView;
76 const ViewFrustum* lastViewFrustum;77 bool recurseEverything { false };
77 int boundaryLevelAdjust;78 int boundaryLevelAdjust;
78 float octreeElementSizeScale;79 float octreeElementSizeScale;
79 quint64 lastViewFrustumSent;
80 bool forceSendScene;80 bool forceSendScene;
81 OctreeSceneStats* stats;81 OctreeSceneStats* stats;
82 JurisdictionMap* jurisdictionMap;82 JurisdictionMap* jurisdictionMap;
@@ -99,11 +99,9 @@ public: · 16 unmodified lines
99 99
100 EncodeBitstreamParams(100 EncodeBitstreamParams(
101 int maxEncodeLevel = INT_MAX,101 int maxEncodeLevel = INT_MAX,
102 const ViewFrustum* viewFrustum = IGNORE_VIEW_FRUSTUM,
103 bool includeExistsBits = WANT_EXISTS_BITS,102 bool includeExistsBits = WANT_EXISTS_BITS,
104 int chopLevels = 0,103 int chopLevels = 0,
105 bool deltaViewFrustum = false,104 bool useDeltaView = false,
106 const ViewFrustum* lastViewFrustum = IGNORE_VIEW_FRUSTUM,
107 int boundaryLevelAdjust = NO_BOUNDARY_ADJUST,105 int boundaryLevelAdjust = NO_BOUNDARY_ADJUST,
108 float octreeElementSizeScale = DEFAULT_OCTREE_SIZE_SCALE,106 float octreeElementSizeScale = DEFAULT_OCTREE_SIZE_SCALE,
109 quint64 lastViewFrustumSent = IGNORE_LAST_SENT,107 quint64 lastViewFrustumSent = IGNORE_LAST_SENT,
@@ -111,22 +109,22 @@ public: · 1 unmodified line
111 OctreeSceneStats* stats = IGNORE_SCENE_STATS,109 OctreeSceneStats* stats = IGNORE_SCENE_STATS,
112 JurisdictionMap* jurisdictionMap = IGNORE_JURISDICTION_MAP,110 JurisdictionMap* jurisdictionMap = IGNORE_JURISDICTION_MAP,
113 OctreeElementExtraEncodeData* extraEncodeData = NULL) :111 OctreeElementExtraEncodeData* extraEncodeData = NULL) :
112 lastViewFrustumSent(lastViewFrustumSent),
114 maxEncodeLevel(maxEncodeLevel),113 maxEncodeLevel(maxEncodeLevel),
115 maxLevelReached(0),114 maxLevelReached(0),
116 viewFrustum(viewFrustum),
117 includeExistsBits(includeExistsBits),115 includeExistsBits(includeExistsBits),
118 chopLevels(chopLevels),116 chopLevels(chopLevels),
119 deltaViewFrustum(deltaViewFrustum),117 deltaView(useDeltaView),
120 lastViewFrustum(lastViewFrustum),
121 boundaryLevelAdjust(boundaryLevelAdjust),118 boundaryLevelAdjust(boundaryLevelAdjust),
122 octreeElementSizeScale(octreeElementSizeScale),119 octreeElementSizeScale(octreeElementSizeScale),
123 lastViewFrustumSent(lastViewFrustumSent),
124 forceSendScene(forceSendScene),120 forceSendScene(forceSendScene),
125 stats(stats),121 stats(stats),
126 jurisdictionMap(jurisdictionMap),122 jurisdictionMap(jurisdictionMap),
127 extraEncodeData(extraEncodeData),123 extraEncodeData(extraEncodeData),
128 stopReason(UNKNOWN)124 stopReason(UNKNOWN)
129 {}125 {
126 lastViewFrustum.invalidate();
127 }
130 128
131 void displayStopReason() {129 void displayStopReason() {
132 printf("StopReason: ");130 printf("StopReason: ");
@@ -341,7 +339,7 @@ public: · 208 unmodified lines
341 339
342 bool getIsClient() const { return !_isServer; } /// Is this a client based tree. Allows guards for certain operations340 bool getIsClient() const { return !_isServer; } /// Is this a client based tree. Allows guards for certain operations
343 void setIsClient(bool isClient) { _isServer = !isClient; }341 void setIsClient(bool isClient) { _isServer = !isClient; }
344 342
345 virtual void dumpTree() { }343 virtual void dumpTree() { }
346 virtual void pruneTree() { }344 virtual void pruneTree() { }
347 345
@@ -352,7 +350,6 @@ public: · 4 unmodified lines
352 virtual quint64 getAverageCreateTime() const { return 0; }350 virtual quint64 getAverageCreateTime() const { return 0; }
353 virtual quint64 getAverageLoggingTime() const { return 0; }351 virtual quint64 getAverageLoggingTime() const { return 0; }
354 352
355
356signals:353signals:
357 void importSize(float x, float y, float z);354 void importSize(float x, float y, float z);
358 void importProgress(int progress);355 void importProgress(int progress);
libraries/octree/src/OctreeElement.cpp+4−3
@@ -22,10 +22,11 @@ · 21 unmodified lines
22 22
23#include "AACube.h"23#include "AACube.h"
24#include "OctalCode.h"24#include "OctalCode.h"
25#include "Octree.h"
25#include "OctreeConstants.h"26#include "OctreeConstants.h"
26#include "OctreeElement.h"27#include "OctreeElement.h"
27#include "Octree.h"
28#include "OctreeLogging.h"28#include "OctreeLogging.h"
29#include "OctreeUtils.h"
29#include "SharedUtil.h"30#include "SharedUtil.h"
30 31
31AtomicUIntStat OctreeElement::_octreeMemoryUsage { 0 };32AtomicUIntStat OctreeElement::_octreeMemoryUsage { 0 };
@@ -471,11 +472,11 @@ ViewFrustum::intersection OctreeElement::computeViewIntersection(const ViewFrust · 439 unmodified lines
471// Since, if we know the camera position and orientation, we can know which of the corners is the "furthest"472// Since, if we know the camera position and orientation, we can know which of the corners is the "furthest"
472// corner. We can use we can use this corner as our "voxel position" to do our distance calculations off of.473// corner. We can use we can use this corner as our "voxel position" to do our distance calculations off of.
473// By doing this, we don't need to test each child voxel's position vs the LOD boundary474// By doing this, we don't need to test each child voxel's position vs the LOD boundary
474bool OctreeElement::calculateShouldRender(const ViewFrustum* viewFrustum, float voxelScaleSize, int boundaryLevelAdjust) const {475bool OctreeElement::calculateShouldRender(const ViewFrustum& viewFrustum, float voxelScaleSize, int boundaryLevelAdjust) const {
475 bool shouldRender = false;476 bool shouldRender = false;
476 477
477 if (hasContent()) {478 if (hasContent()) {
478 float furthestDistance = furthestDistanceToCamera(*viewFrustum);479 float furthestDistance = furthestDistanceToCamera(viewFrustum);
479 float childBoundary = boundaryDistanceForRenderLevel(getLevel() + 1 + boundaryLevelAdjust, voxelScaleSize);480 float childBoundary = boundaryDistanceForRenderLevel(getLevel() + 1 + boundaryLevelAdjust, voxelScaleSize);
480 bool inChildBoundary = (furthestDistance <= childBoundary);481 bool inChildBoundary = (furthestDistance <= childBoundary);
481 if (hasDetailedContent() && inChildBoundary) {482 if (hasDetailedContent() && inChildBoundary) {
libraries/octree/src/OctreeElement.h+2−2
@@ -21,9 +21,9 @@ · 20 unmodified lines
21 21
22#include <OctalCode.h>22#include <OctalCode.h>
23#include <SharedUtil.h>23#include <SharedUtil.h>
24#include <ViewFrustum.h>
24 25
25#include "AACube.h"26#include "AACube.h"
26#include "ViewFrustum.h"
27#include "OctreeConstants.h"27#include "OctreeConstants.h"
28 28
29using AtomicUIntStat = std::atomic<uintmax_t>;29using AtomicUIntStat = std::atomic<uintmax_t>;
@@ -139,7 +139,7 @@ public: · 109 unmodified lines
139 float distanceToCamera(const ViewFrustum& viewFrustum) const;139 float distanceToCamera(const ViewFrustum& viewFrustum) const;
140 float furthestDistanceToCamera(const ViewFrustum& viewFrustum) const;140 float furthestDistanceToCamera(const ViewFrustum& viewFrustum) const;
141 141
142 bool calculateShouldRender(const ViewFrustum* viewFrustum,142 bool calculateShouldRender(const ViewFrustum& viewFrustum,
143 float voxelSizeScale = DEFAULT_OCTREE_SIZE_SCALE, int boundaryLevelAdjust = 0) const;143 float voxelSizeScale = DEFAULT_OCTREE_SIZE_SCALE, int boundaryLevelAdjust = 0) const;
144 144
145 // points are assumed to be in Voxel Coordinates (not TREE_SCALE'd)145 // points are assumed to be in Voxel Coordinates (not TREE_SCALE'd)
libraries/octree/src/OctreeHeadlessViewer.cpp+1−3
@@ -14,14 +14,12 @@ · 13 unmodified lines
14#include "OctreeLogging.h"14#include "OctreeLogging.h"
15#include "OctreeHeadlessViewer.h"15#include "OctreeHeadlessViewer.h"
16 16
17OctreeHeadlessViewer::OctreeHeadlessViewer() : OctreeRenderer()17OctreeHeadlessViewer::OctreeHeadlessViewer() : OctreeRenderer() {
18{
19 _viewFrustum.setProjection(glm::perspective(glm::radians(DEFAULT_FIELD_OF_VIEW_DEGREES), DEFAULT_ASPECT_RATIO, DEFAULT_NEAR_CLIP, DEFAULT_FAR_CLIP));18 _viewFrustum.setProjection(glm::perspective(glm::radians(DEFAULT_FIELD_OF_VIEW_DEGREES), DEFAULT_ASPECT_RATIO, DEFAULT_NEAR_CLIP, DEFAULT_FAR_CLIP));
20}19}
21 20
22void OctreeHeadlessViewer::init() {21void OctreeHeadlessViewer::init() {
23 OctreeRenderer::init();22 OctreeRenderer::init();
24 setViewFrustum(&_viewFrustum);
25}23}
26 24
27void OctreeHeadlessViewer::queryOctree() {25void OctreeHeadlessViewer::queryOctree() {
libraries/octree/src/OctreeHeadlessViewer.h+1−2
@@ -14,6 +14,7 @@ · 13 unmodified lines
14 14
15#include <udt/PacketHeaders.h>15#include <udt/PacketHeaders.h>
16#include <SharedUtil.h>16#include <SharedUtil.h>
17#include <ViewFrustum.h>
17 18
18#include "JurisdictionListener.h"19#include "JurisdictionListener.h"
19#include "Octree.h"20#include "Octree.h"
@@ -22,7 +23,6 @@ · 2 unmodified lines
22#include "OctreeRenderer.h"23#include "OctreeRenderer.h"
23#include "OctreeSceneStats.h"24#include "OctreeSceneStats.h"
24#include "Octree.h"25#include "Octree.h"
25#include "ViewFrustum.h"
26 26
27// Generic client side Octree renderer class.27// Generic client side Octree renderer class.
28class OctreeHeadlessViewer : public OctreeRenderer {28class OctreeHeadlessViewer : public OctreeRenderer {
@@ -66,7 +66,6 @@ public slots: · 37 unmodified lines
66 unsigned getOctreeElementsCount() const { return _tree->getOctreeElementsCount(); }66 unsigned getOctreeElementsCount() const { return _tree->getOctreeElementsCount(); }
67 67
68private:68private:
69 ViewFrustum _viewFrustum;
70 JurisdictionListener* _jurisdictionListener = nullptr;69 JurisdictionListener* _jurisdictionListener = nullptr;
71 OctreeQuery _octreeQuery;70 OctreeQuery _octreeQuery;
72 71
libraries/octree/src/OctreeQuery.cpp+0−1
@@ -120,4 +120,3 @@ glm::vec3 OctreeQuery::calculateCameraDirection() const { · 119 unmodified lines
120 glm::vec3 direction = glm::vec3(_cameraOrientation * glm::vec4(IDENTITY_FRONT, 0.0f));120 glm::vec3 direction = glm::vec3(_cameraOrientation * glm::vec4(IDENTITY_FRONT, 0.0f));
121 return direction;121 return direction;
122}122}
123
libraries/octree/src/OctreeRenderer.cpp+3−4
@@ -22,8 +22,7 @@ · 21 unmodified lines
22 22
23OctreeRenderer::OctreeRenderer() :23OctreeRenderer::OctreeRenderer() :
24 _tree(NULL),24 _tree(NULL),
25 _managedTree(false),25 _managedTree(false)
26 _viewFrustum(NULL)
27{26{
28}27}
29 28
@@ -201,9 +200,9 @@ void OctreeRenderer::processDatagram(ReceivedMessage& message, SharedNodePointer · 171 unmodified lines
201 200
202bool OctreeRenderer::renderOperation(OctreeElementPointer element, void* extraData) {201bool OctreeRenderer::renderOperation(OctreeElementPointer element, void* extraData) {
203 RenderArgs* args = static_cast<RenderArgs*>(extraData);202 RenderArgs* args = static_cast<RenderArgs*>(extraData);
204 if (element->isInView(*args->_viewFrustum)) {203 if (element->isInView(args->getViewFrustum())) {
205 if (element->hasContent()) {204 if (element->hasContent()) {
206 if (element->calculateShouldRender(args->_viewFrustum, args->_sizeScale, args->_boundaryLevelAdjust)) {205 if (element->calculateShouldRender(args->getViewFrustum(), args->_sizeScale, args->_boundaryLevelAdjust)) {
207 args->_renderer->renderElement(element, args);206 args->_renderer->renderElement(element, args);
208 } else {207 } else {
209 return false; // if we shouldn't render, then we also should stop recursing.208 return false; // if we shouldn't render, then we also should stop recursing.
libraries/octree/src/OctreeRenderer.h+4−4
@@ -20,10 +20,10 @@ · 19 unmodified lines
20#include <udt/PacketHeaders.h>20#include <udt/PacketHeaders.h>
21#include <RenderArgs.h>21#include <RenderArgs.h>
22#include <SharedUtil.h>22#include <SharedUtil.h>
23#include <ViewFrustum.h>
23 24
24#include "Octree.h"25#include "Octree.h"
25#include "OctreePacketData.h"26#include "OctreePacketData.h"
26#include "ViewFrustum.h"
27 27
28class OctreeRenderer;28class OctreeRenderer;
29 29
@@ -51,8 +51,8 @@ public: · 21 unmodified lines
51 /// render the content of the octree51 /// render the content of the octree
52 virtual void render(RenderArgs* renderArgs);52 virtual void render(RenderArgs* renderArgs);
53 53
54 ViewFrustum* getViewFrustum() const { return _viewFrustum; }54 const ViewFrustum& getViewFrustum() const { return _viewFrustum; }
55 void setViewFrustum(ViewFrustum* viewFrustum) { _viewFrustum = viewFrustum; }55 void setViewFrustum(const ViewFrustum& viewFrustum) { _viewFrustum = viewFrustum; }
56 56
57 static bool renderOperation(OctreeElementPointer element, void* extraData);57 static bool renderOperation(OctreeElementPointer element, void* extraData);
58 58
@@ -75,7 +75,7 @@ protected: · 16 unmodified lines
75 75
76 OctreePointer _tree;76 OctreePointer _tree;
77 bool _managedTree;77 bool _managedTree;
78 ViewFrustum* _viewFrustum;78 ViewFrustum _viewFrustum;
79 79
80 SimpleMovingAverage _elementsPerPacket;80 SimpleMovingAverage _elementsPerPacket;
81 SimpleMovingAverage _entitiesPerPacket;81 SimpleMovingAverage _entitiesPerPacket;
libraries/octree/src/OctreeUtils.cpp+71−0
@@ -0,0 +1,71 @@
1//
2// OctreeUtils.cpp
3// libraries/octree/src
4//
5// Created by Andrew Meadows 2016.03.04
6// Copyright 2016 High Fidelity, Inc.
7//
8// Distributed under the Apache License, Version 2.0.
9// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
10//
11
12#include "OctreeUtils.h"
13
14#include <mutex>
15
16#include <glm/glm.hpp>
17
18#include <AABox.h>
19
20
21float calculateRenderAccuracy(const glm::vec3& position,
22 const AABox& bounds,
23 float octreeSizeScale,
24 int boundaryLevelAdjust) {
25 float largestDimension = bounds.getLargestDimension();
26
27 const float maxScale = (float)TREE_SCALE;
28 float visibleDistanceAtMaxScale = boundaryDistanceForRenderLevel(boundaryLevelAdjust, octreeSizeScale) / OCTREE_TO_MESH_RATIO;
29
30 static std::once_flag once;
31 static QMap<float, float> shouldRenderTable;
32 std::call_once(once, [&] {
33 float SMALLEST_SCALE_IN_TABLE = 0.001f; // 1mm is plenty small
34 float scale = maxScale;
35 float factor = 1.0f;
36
37 while (scale > SMALLEST_SCALE_IN_TABLE) {
38 scale /= 2.0f;
39 factor /= 2.0f;
40 shouldRenderTable[scale] = factor;
41 }
42 });
43
44 float closestScale = maxScale;
45 float visibleDistanceAtClosestScale = visibleDistanceAtMaxScale;
46 QMap<float, float>::const_iterator lowerBound = shouldRenderTable.lowerBound(largestDimension);
47 if (lowerBound != shouldRenderTable.constEnd()) {
48 closestScale = lowerBound.key();
49 visibleDistanceAtClosestScale = visibleDistanceAtMaxScale * lowerBound.value();
50 }
51
52 if (closestScale < largestDimension) {
53 visibleDistanceAtClosestScale *= 2.0f;
54 }
55
56 // FIXME - for now, it's either visible or not visible. We want to adjust this to eventually return
57 // a floating point for objects that have small angular size to indicate that they may be rendered
58 // with lower preciscion
59 float distanceToCamera = glm::length(bounds.calcCenter() - position);
60 return (distanceToCamera <= visibleDistanceAtClosestScale) ? 1.0f : 0.0f;
61}
62
63float boundaryDistanceForRenderLevel(unsigned int renderLevel, float voxelSizeScale) {
64 return voxelSizeScale / powf(2.0f, renderLevel);
65}
66
67float getAccuracyAngle(float octreeSizeScale, int boundaryLevelAdjust) {
68 const float maxScale = (float)TREE_SCALE;
69 float visibleDistanceAtMaxScale = boundaryDistanceForRenderLevel(boundaryLevelAdjust, octreeSizeScale) / OCTREE_TO_MESH_RATIO;
70 return atan(maxScale / visibleDistanceAtMaxScale);
71}
libraries/octree/src/OctreeUtils.h+30−0
@@ -0,0 +1,30 @@
1//
2// OctreeUtils.h
3// libraries/octree/src
4//
5// Created by Andrew Meadows 2016.03.04
6// Copyright 2016 High Fidelity, Inc.
7//
8// Distributed under the Apache License, Version 2.0.
9// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
10//
11
12#ifndef hifi_OctreeUtils_h
13#define hifi_OctreeUtils_h
14
15#include "OctreeConstants.h"
16
17class AABox;
18
19/// renderAccuracy represents a floating point "visibility" of an object based on it's view from the camera. At a simple
20/// level it returns 0.0f for things that are so small for the current settings that they could not be visible.
21float calculateRenderAccuracy(const glm::vec3& position,
22 const AABox& bounds,
23 float octreeSizeScale = DEFAULT_OCTREE_SIZE_SCALE,
24 int boundaryLevelAdjust = 0);
25
26float boundaryDistanceForRenderLevel(unsigned int renderLevel, float voxelSizeScale);
27
28float getAccuracyAngle(float octreeSizeScale, int boundaryLevelAdjust);
29
30#endif // hifi_OctreeUtils_h
libraries/render-utils/src/AbstractViewStateInterface.h+5−5
@@ -28,14 +28,14 @@ class PickRay; · 27 unmodified lines
28/// Interface provided by Application to other objects that need access to the current view state details28/// Interface provided by Application to other objects that need access to the current view state details
29class AbstractViewStateInterface {29class AbstractViewStateInterface {
30public:30public:
31 /// gets the current view frustum for rendering the view state31 /// copies the current view frustum for rendering the view state
32 virtual ViewFrustum* getCurrentViewFrustum() = 0;32 virtual void copyCurrentViewFrustum(ViewFrustum& viewOut) const = 0;
33 33
34 /// gets the shadow view frustum for rendering the view state34 /// copies the shadow view frustum for rendering the view state
35 virtual ViewFrustum* getShadowViewFrustum() = 0;35 virtual void copyShadowViewFrustum(ViewFrustum& viewOut) const = 0;
36 36
37 virtual QThread* getMainThread() = 0;37 virtual QThread* getMainThread() = 0;
38 38
39 virtual PickRay computePickRay(float x, float y) const = 0;39 virtual PickRay computePickRay(float x, float y) const = 0;
40 40
41 virtual glm::vec3 getAvatarPosition() const = 0;41 virtual glm::vec3 getAvatarPosition() const = 0;
libraries/render-utils/src/AmbientOcclusionEffect.cpp+4−4
@@ -284,7 +284,7 @@ void AmbientOcclusionEffect::updateGaussianDistribution() { · 283 unmodified lines
284 284
285void AmbientOcclusionEffect::run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext) {285void AmbientOcclusionEffect::run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext) {
286 assert(renderContext->args);286 assert(renderContext->args);
287 assert(renderContext->args->_viewFrustum);287 assert(renderContext->args->hasViewFrustum());
288 288
289 RenderArgs* args = renderContext->args;289 RenderArgs* args = renderContext->args;
290 290
@@ -309,7 +309,7 @@ void AmbientOcclusionEffect::run(const render::SceneContextPointer& sceneContext · 18 unmodified lines
309 auto resolutionLevel = getResolutionLevel();309 auto resolutionLevel = getResolutionLevel();
310 310
311 // Update the depth info with near and far (same for stereo)311 // Update the depth info with near and far (same for stereo)
312 setDepthInfo(args->_viewFrustum->getNearClip(), args->_viewFrustum->getFarClip());312 setDepthInfo(args->getViewFrustum().getNearClip(), args->getViewFrustum().getFarClip());
313 313
314 _frameTransformBuffer.edit<FrameTransform>().pixelInfo = args->_viewport;314 _frameTransformBuffer.edit<FrameTransform>().pixelInfo = args->_viewport;
315 //_parametersBuffer.edit<Parameters>()._ditheringInfo.y += 0.25f;315 //_parametersBuffer.edit<Parameters>()._ditheringInfo.y += 0.25f;
@@ -319,7 +319,7 @@ void AmbientOcclusionEffect::run(const render::SceneContextPointer& sceneContext · 3 unmodified lines
319 if (!isStereo) {319 if (!isStereo) {
320 // Eval the mono projection320 // Eval the mono projection
321 mat4 monoProjMat;321 mat4 monoProjMat;
322 args->_viewFrustum->evalProjectionMatrix(monoProjMat);322 args->getViewFrustum().evalProjectionMatrix(monoProjMat);
323 _frameTransformBuffer.edit<FrameTransform>().projection[0] = monoProjMat;323 _frameTransformBuffer.edit<FrameTransform>().projection[0] = monoProjMat;
324 _frameTransformBuffer.edit<FrameTransform>().stereoInfo = glm::vec4(0.0f, (float)args->_viewport.z, 0.0f, 0.0f);324 _frameTransformBuffer.edit<FrameTransform>().stereoInfo = glm::vec4(0.0f, (float)args->_viewport.z, 0.0f, 0.0f);
325 325
@@ -365,7 +365,7 @@ void AmbientOcclusionEffect::run(const render::SceneContextPointer& sceneContext · 39 unmodified lines
365 365
366 // Pyramid pass366 // Pyramid pass
367 batch.setFramebuffer(pyramidFBO);367 batch.setFramebuffer(pyramidFBO);
368 batch.clearColorFramebuffer(gpu::Framebuffer::BUFFER_COLOR0, glm::vec4(args->_viewFrustum->getFarClip(), 0.0f, 0.0f, 0.0f));368 batch.clearColorFramebuffer(gpu::Framebuffer::BUFFER_COLOR0, glm::vec4(args->getViewFrustum().getFarClip(), 0.0f, 0.0f, 0.0f));
369 batch.setPipeline(pyramidPipeline);369 batch.setPipeline(pyramidPipeline);
370 batch.setResourceTexture(AmbientOcclusionEffect_DepthMapSlot, depthBuffer);370 batch.setResourceTexture(AmbientOcclusionEffect_DepthMapSlot, depthBuffer);
371 batch.draw(gpu::TRIANGLE_STRIP, 4);371 batch.draw(gpu::TRIANGLE_STRIP, 4);
libraries/render-utils/src/AntialiasingEffect.cpp+4−4
@@ -94,7 +94,7 @@ const gpu::PipelinePointer& Antialiasing::getBlendPipeline() { · 93 unmodified lines
94 94
95void Antialiasing::run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext) {95void Antialiasing::run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext) {
96 assert(renderContext->args);96 assert(renderContext->args);
97 assert(renderContext->args->_viewFrustum);97 assert(renderContext->args->hasViewFrustum());
98 98
99 RenderArgs* args = renderContext->args;99 RenderArgs* args = renderContext->args;
100 100
@@ -118,8 +118,8 @@ void Antialiasing::run(const render::SceneContextPointer& sceneContext, const re · 17 unmodified lines
118 118
119 glm::mat4 projMat;119 glm::mat4 projMat;
120 Transform viewMat;120 Transform viewMat;
121 args->_viewFrustum->evalProjectionMatrix(projMat);121 args->getViewFrustum().evalProjectionMatrix(projMat);
122 args->_viewFrustum->evalViewTransform(viewMat);122 args->getViewFrustum().evalViewTransform(viewMat);
123 batch.setProjectionTransform(projMat);123 batch.setProjectionTransform(projMat);
124 batch.setViewTransform(viewMat);124 batch.setViewTransform(viewMat);
125 batch.setModelTransform(Transform());125 batch.setModelTransform(Transform());
@@ -134,7 +134,7 @@ void Antialiasing::run(const render::SceneContextPointer& sceneContext, const re · 8 unmodified lines
134 float left, right, bottom, top, nearVal, farVal;134 float left, right, bottom, top, nearVal, farVal;
135 glm::vec4 nearClipPlane, farClipPlane;135 glm::vec4 nearClipPlane, farClipPlane;
136 136
137 args->_viewFrustum->computeOffAxisFrustum(left, right, bottom, top, nearVal, farVal, nearClipPlane, farClipPlane);137 args->getViewFrustum().computeOffAxisFrustum(left, right, bottom, top, nearVal, farVal, nearClipPlane, farClipPlane);
138 138
139 // float depthScale = (farVal - nearVal) / farVal;139 // float depthScale = (farVal - nearVal) / farVal;
140 // float nearScale = -1.0f / nearVal;140 // float nearScale = -1.0f / nearVal;
libraries/render-utils/src/DebugDeferredBuffer.cpp+6−6
@@ -275,7 +275,7 @@ void DebugDeferredBuffer::configure(const Config& config) { · 274 unmodified lines
275 275
276void DebugDeferredBuffer::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) {276void DebugDeferredBuffer::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) {
277 assert(renderContext->args);277 assert(renderContext->args);
278 assert(renderContext->args->_viewFrustum);278 assert(renderContext->args->hasViewFrustum());
279 RenderArgs* args = renderContext->args;279 RenderArgs* args = renderContext->args;
280 280
281 gpu::doInBatch(args->_context, [&](gpu::Batch& batch) {281 gpu::doInBatch(args->_context, [&](gpu::Batch& batch) {
@@ -283,20 +283,20 @@ void DebugDeferredBuffer::run(const SceneContextPointer& sceneContext, const Ren · 1 unmodified line
283 const auto framebufferCache = DependencyManager::get<FramebufferCache>();283 const auto framebufferCache = DependencyManager::get<FramebufferCache>();
284 const auto textureCache = DependencyManager::get<TextureCache>();284 const auto textureCache = DependencyManager::get<TextureCache>();
285 const auto& lightStage = DependencyManager::get<DeferredLightingEffect>()->getLightStage();285 const auto& lightStage = DependencyManager::get<DeferredLightingEffect>()->getLightStage();
286 286
287 glm::mat4 projMat;287 glm::mat4 projMat;
288 Transform viewMat;288 Transform viewMat;
289 args->_viewFrustum->evalProjectionMatrix(projMat);289 args->getViewFrustum().evalProjectionMatrix(projMat);
290 args->_viewFrustum->evalViewTransform(viewMat);290 args->getViewFrustum().evalViewTransform(viewMat);
291 batch.setProjectionTransform(projMat);291 batch.setProjectionTransform(projMat);
292 batch.setViewTransform(viewMat);292 batch.setViewTransform(viewMat);
293 batch.setModelTransform(Transform());293 batch.setModelTransform(Transform());
294 294
295 // TODO REMOVE: Temporary until UI295 // TODO REMOVE: Temporary until UI
296 auto first = _customPipelines.begin()->first;296 auto first = _customPipelines.begin()->first;
297 297
298 batch.setPipeline(getPipeline(_mode, first));298 batch.setPipeline(getPipeline(_mode, first));
299 299
300 batch.setResourceTexture(Albedo, framebufferCache->getDeferredColorTexture());300 batch.setResourceTexture(Albedo, framebufferCache->getDeferredColorTexture());
301 batch.setResourceTexture(Normal, framebufferCache->getDeferredNormalTexture());301 batch.setResourceTexture(Normal, framebufferCache->getDeferredNormalTexture());
302 batch.setResourceTexture(Specular, framebufferCache->getDeferredSpecularTexture());302 batch.setResourceTexture(Specular, framebufferCache->getDeferredSpecularTexture());
libraries/render-utils/src/DeferredLightingEffect.cpp+5−5
@@ -218,15 +218,15 @@ void DeferredLightingEffect::render(const render::RenderContextPointer& renderCo · 217 unmodified lines
218 float tHeight = args->_viewport.w / (float)framebufferSize.height();218 float tHeight = args->_viewport.w / (float)framebufferSize.height();
219 219
220 // The view frustum is the mono frustum base220 // The view frustum is the mono frustum base
221 auto viewFrustum = args->_viewFrustum;221 auto viewFrustum = args->getViewFrustum();
222 222
223 // Eval the mono projection223 // Eval the mono projection
224 mat4 monoProjMat;224 mat4 monoProjMat;
225 viewFrustum->evalProjectionMatrix(monoProjMat);225 viewFrustum.evalProjectionMatrix(monoProjMat);
226 226
227 // The mono view transform227 // The mono view transform
228 Transform monoViewTransform;228 Transform monoViewTransform;
229 viewFrustum->evalViewTransform(monoViewTransform);229 viewFrustum.evalViewTransform(monoViewTransform);
230 230
231 // THe mono view matrix coming from the mono view transform231 // THe mono view matrix coming from the mono view transform
232 glm::mat4 monoViewMat;232 glm::mat4 monoViewMat;
@@ -296,8 +296,8 @@ void DeferredLightingEffect::render(const render::RenderContextPointer& renderCo · 63 unmodified lines
296 fetchTexcoordRects[0] = glm::vec4(sMin, tMin, sWidth, tHeight);296 fetchTexcoordRects[0] = glm::vec4(sMin, tMin, sWidth, tHeight);
297 }297 }
298 298
299 auto eyePoint = viewFrustum->getPosition();299 auto eyePoint = viewFrustum.getPosition();
300 float nearRadius = glm::distance(eyePoint, viewFrustum->getNearTopLeft());300 float nearRadius = glm::distance(eyePoint, viewFrustum.getNearTopLeft());
301 301
302 302
303 for (int side = 0; side < numPasses; side++) {303 for (int side = 0; side < numPasses; side++) {
libraries/render-utils/src/HitEffect.cpp+5−5
@@ -62,19 +62,19 @@ const gpu::PipelinePointer& HitEffect::getHitEffectPipeline() { · 61 unmodified lines
62 62
63void HitEffect::run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext) {63void HitEffect::run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext) {
64 assert(renderContext->args);64 assert(renderContext->args);
65 assert(renderContext->args->_viewFrustum);65 assert(renderContext->args->hasViewFrustum());
66 RenderArgs* args = renderContext->args;66 RenderArgs* args = renderContext->args;
67 67
68 gpu::doInBatch(args->_context, [&](gpu::Batch& batch) {68 gpu::doInBatch(args->_context, [&](gpu::Batch& batch) {
69 69
70 glm::mat4 projMat;70 glm::mat4 projMat;
71 Transform viewMat;71 Transform viewMat;
72 args->_viewFrustum->evalProjectionMatrix(projMat);72 args->getViewFrustum().evalProjectionMatrix(projMat);
73 args->_viewFrustum->evalViewTransform(viewMat);73 args->getViewFrustum().evalViewTransform(viewMat);
74 batch.setProjectionTransform(projMat);74 batch.setProjectionTransform(projMat);
75 batch.setViewTransform(viewMat);75 batch.setViewTransform(viewMat);
76 batch.setModelTransform(Transform());76 batch.setModelTransform(Transform());
77 77
78 batch.setPipeline(getHitEffectPipeline());78 batch.setPipeline(getHitEffectPipeline());
79 79
80 glm::vec4 color(0.0f, 0.0f, 0.0f, 1.0f);80 glm::vec4 color(0.0f, 0.0f, 0.0f, 1.0f);
libraries/render-utils/src/LightStage.cpp+4−5
@@ -20,7 +20,7 @@ LightStage::Shadow::Shadow(model::LightPointer light) : _light{ light}, _frustum · 19 unmodified lines
20 _schemaBuffer = std::make_shared<gpu::Buffer>(sizeof(Schema), (const gpu::Byte*) &schema);20 _schemaBuffer = std::make_shared<gpu::Buffer>(sizeof(Schema), (const gpu::Byte*) &schema);
21}21}
22 22
23void LightStage::Shadow::setKeylightFrustum(ViewFrustum* viewFrustum, float nearDepth, float farDepth) {23void LightStage::Shadow::setKeylightFrustum(const ViewFrustum& viewFrustum, float nearDepth, float farDepth) {
24 assert(nearDepth < farDepth);24 assert(nearDepth < farDepth);
25 25
26 // Orient the keylight frustum26 // Orient the keylight frustum
@@ -38,14 +38,13 @@ void LightStage::Shadow::setKeylightFrustum(ViewFrustum* viewFrustum, float near · 11 unmodified lines
38 _frustum->setOrientation(orientation);38 _frustum->setOrientation(orientation);
39 39
40 // Position the keylight frustum40 // Position the keylight frustum
41 _frustum->setPosition(viewFrustum->getPosition() - (nearDepth + farDepth)*direction);41 _frustum->setPosition(viewFrustum.getPosition() - (nearDepth + farDepth)*direction);
42 42
43 const Transform view{ _frustum->getView()};43 const Transform view{ _frustum->getView()};
44 const Transform viewInverse{ view.getInverseMatrix() };44 const Transform viewInverse{ view.getInverseMatrix() };
45 45
46 viewFrustum->calculate();46 auto nearCorners = viewFrustum.getCorners(nearDepth);
47 auto nearCorners = viewFrustum->getCorners(nearDepth);47 auto farCorners = viewFrustum.getCorners(farDepth);
48 auto farCorners = viewFrustum->getCorners(farDepth);
49 48
50 vec3 min{ viewInverse.transform(nearCorners.bottomLeft) };49 vec3 min{ viewInverse.transform(nearCorners.bottomLeft) };
51 vec3 max{ min };50 vec3 max{ min };
libraries/render-utils/src/LightStage.h+1−1
@@ -28,7 +28,7 @@ public: · 27 unmodified lines
28 28
29 Shadow(model::LightPointer light);29 Shadow(model::LightPointer light);
30 30
31 void setKeylightFrustum(ViewFrustum* viewFrustum, float nearDepth, float farDepth);31 void setKeylightFrustum(const ViewFrustum& viewFrustum, float nearDepth, float farDepth);
32 32
33 const std::shared_ptr<ViewFrustum> getFrustum() const { return _frustum; }33 const std::shared_ptr<ViewFrustum> getFrustum() const { return _frustum; }
34 34
libraries/render-utils/src/RenderDeferredTask.cpp+14−14
@@ -163,7 +163,7 @@ void RenderDeferredTask::run(const SceneContextPointer& sceneContext, const Rend · 162 unmodified lines
163 163
164 164
165 // Is it possible that we render without a viewFrustum ?165 // Is it possible that we render without a viewFrustum ?
166 if (!(renderContext->args && renderContext->args->_viewFrustum)) {166 if (!(renderContext->args && renderContext->args->hasViewFrustum())) {
167 return;167 return;
168 }168 }
169 169
@@ -174,7 +174,7 @@ void RenderDeferredTask::run(const SceneContextPointer& sceneContext, const Rend · 4 unmodified lines
174 174
175void DrawDeferred::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ItemBounds& inItems) {175void DrawDeferred::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ItemBounds& inItems) {
176 assert(renderContext->args);176 assert(renderContext->args);
177 assert(renderContext->args->_viewFrustum);177 assert(renderContext->args->hasViewFrustum());
178 178
179 auto config = std::static_pointer_cast<Config>(renderContext->jobConfig);179 auto config = std::static_pointer_cast<Config>(renderContext->jobConfig);
180 180
@@ -187,8 +187,8 @@ void DrawDeferred::run(const SceneContextPointer& sceneContext, const RenderCont · 6 unmodified lines
187 187
188 glm::mat4 projMat;188 glm::mat4 projMat;
189 Transform viewMat;189 Transform viewMat;
190 args->_viewFrustum->evalProjectionMatrix(projMat);190 args->getViewFrustum().evalProjectionMatrix(projMat);
191 args->_viewFrustum->evalViewTransform(viewMat);191 args->getViewFrustum().evalViewTransform(viewMat);
192 192
193 batch.setProjectionTransform(projMat);193 batch.setProjectionTransform(projMat);
194 batch.setViewTransform(viewMat);194 batch.setViewTransform(viewMat);
@@ -202,7 +202,7 @@ void DrawDeferred::run(const SceneContextPointer& sceneContext, const RenderCont · 7 unmodified lines
202 202
203void DrawStateSortDeferred::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ItemBounds& inItems) {203void DrawStateSortDeferred::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ItemBounds& inItems) {
204 assert(renderContext->args);204 assert(renderContext->args);
205 assert(renderContext->args->_viewFrustum);205 assert(renderContext->args->hasViewFrustum());
206 206
207 auto config = std::static_pointer_cast<Config>(renderContext->jobConfig);207 auto config = std::static_pointer_cast<Config>(renderContext->jobConfig);
208 208
@@ -215,8 +215,8 @@ void DrawStateSortDeferred::run(const SceneContextPointer& sceneContext, const R · 6 unmodified lines
215 215
216 glm::mat4 projMat;216 glm::mat4 projMat;
217 Transform viewMat;217 Transform viewMat;
218 args->_viewFrustum->evalProjectionMatrix(projMat);218 args->getViewFrustum().evalProjectionMatrix(projMat);
219 args->_viewFrustum->evalViewTransform(viewMat);219 args->getViewFrustum().evalViewTransform(viewMat);
220 220
221 batch.setProjectionTransform(projMat);221 batch.setProjectionTransform(projMat);
222 batch.setViewTransform(viewMat);222 batch.setViewTransform(viewMat);
@@ -240,7 +240,7 @@ DrawOverlay3D::DrawOverlay3D(bool opaque) : · 17 unmodified lines
240 240
241void DrawOverlay3D::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const render::ItemBounds& inItems) {241void DrawOverlay3D::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const render::ItemBounds& inItems) {
242 assert(renderContext->args);242 assert(renderContext->args);
243 assert(renderContext->args->_viewFrustum);243 assert(renderContext->args->hasViewFrustum());
244 244
245 auto config = std::static_pointer_cast<Config>(renderContext->jobConfig);245 auto config = std::static_pointer_cast<Config>(renderContext->jobConfig);
246 246
@@ -268,8 +268,8 @@ void DrawOverlay3D::run(const SceneContextPointer& sceneContext, const RenderCon · 21 unmodified lines
268 268
269 glm::mat4 projMat;269 glm::mat4 projMat;
270 Transform viewMat;270 Transform viewMat;
271 args->_viewFrustum->evalProjectionMatrix(projMat);271 args->getViewFrustum().evalProjectionMatrix(projMat);
272 args->_viewFrustum->evalViewTransform(viewMat);272 args->getViewFrustum().evalViewTransform(viewMat);
273 273
274 batch.setProjectionTransform(projMat);274 batch.setProjectionTransform(projMat);
275 batch.setViewTransform(viewMat);275 batch.setViewTransform(viewMat);
@@ -290,7 +290,7 @@ const gpu::PipelinePointer& DrawStencilDeferred::getOpaquePipeline() { · 14 unmodified lines
290 290
291void DrawStencilDeferred::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) {291void DrawStencilDeferred::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) {
292 assert(renderContext->args);292 assert(renderContext->args);
293 assert(renderContext->args->_viewFrustum);293 assert(renderContext->args->hasViewFrustum());
294 294
295 // from the touched pixel generate the stencil buffer 295 // from the touched pixel generate the stencil buffer
296 RenderArgs* args = renderContext->args;296 RenderArgs* args = renderContext->args;
@@ -316,7 +316,7 @@ void DrawStencilDeferred::run(const SceneContextPointer& sceneContext, const Ren · 19 unmodified lines
316 316
317void DrawBackgroundDeferred::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ItemBounds& inItems) {317void DrawBackgroundDeferred::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ItemBounds& inItems) {
318 assert(renderContext->args);318 assert(renderContext->args);
319 assert(renderContext->args->_viewFrustum);319 assert(renderContext->args->hasViewFrustum());
320 320
321 RenderArgs* args = renderContext->args;321 RenderArgs* args = renderContext->args;
322 doInBatch(args->_context, [&](gpu::Batch& batch) {322 doInBatch(args->_context, [&](gpu::Batch& batch) {
@@ -334,8 +334,8 @@ void DrawBackgroundDeferred::run(const SceneContextPointer& sceneContext, const · 11 unmodified lines
334 334
335 glm::mat4 projMat;335 glm::mat4 projMat;
336 Transform viewMat;336 Transform viewMat;
337 args->_viewFrustum->evalProjectionMatrix(projMat);337 args->getViewFrustum().evalProjectionMatrix(projMat);
338 args->_viewFrustum->evalViewTransform(viewMat);338 args->getViewFrustum().evalViewTransform(viewMat);
339 339
340 batch.setProjectionTransform(projMat);340 batch.setProjectionTransform(projMat);
341 batch.setViewTransform(viewMat);341 batch.setViewTransform(viewMat);
libraries/render-utils/src/RenderShadowTask.cpp+5−6
@@ -34,7 +34,7 @@ using namespace render; · 33 unmodified lines
34void RenderShadowMap::run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext,34void RenderShadowMap::run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext,
35 const render::ShapeBounds& inShapes) {35 const render::ShapeBounds& inShapes) {
36 assert(renderContext->args);36 assert(renderContext->args);
37 assert(renderContext->args->_viewFrustum);37 assert(renderContext->args->hasViewFrustum());
38 38
39 const auto& lightStage = DependencyManager::get<DeferredLightingEffect>()->getLightStage();39 const auto& lightStage = DependencyManager::get<DeferredLightingEffect>()->getLightStage();
40 const auto globalLight = lightStage.lights[0];40 const auto globalLight = lightStage.lights[0];
@@ -146,16 +146,15 @@ void RenderShadowTask::run(const SceneContextPointer& sceneContext, const render · 105 unmodified lines
146 }146 }
147 147
148 // Cache old render args148 // Cache old render args
149 ViewFrustum* viewFrustum = args->_viewFrustum;
150 RenderArgs::RenderMode mode = args->_renderMode;149 RenderArgs::RenderMode mode = args->_renderMode;
151 150
152 auto nearClip = viewFrustum->getNearClip();151 auto nearClip = args->getViewFrustum().getNearClip();
153 float nearDepth = -args->_boomOffset.z;152 float nearDepth = -args->_boomOffset.z;
154 const int SHADOW_FAR_DEPTH = 20;153 const int SHADOW_FAR_DEPTH = 20;
155 globalLight->shadow.setKeylightFrustum(viewFrustum, nearDepth, nearClip + SHADOW_FAR_DEPTH);154 globalLight->shadow.setKeylightFrustum(args->getViewFrustum(), nearDepth, nearClip + SHADOW_FAR_DEPTH);
156 155
157 // Set the keylight render args156 // Set the keylight render args
158 args->_viewFrustum = globalLight->shadow.getFrustum().get();157 args->pushViewFrustum(*(globalLight->shadow.getFrustum()));
159 args->_renderMode = RenderArgs::SHADOW_RENDER_MODE;158 args->_renderMode = RenderArgs::SHADOW_RENDER_MODE;
160 159
161 // TODO: Allow runtime manipulation of culling ShouldRenderFunctor160 // TODO: Allow runtime manipulation of culling ShouldRenderFunctor
@@ -165,6 +164,6 @@ void RenderShadowTask::run(const SceneContextPointer& sceneContext, const render · 3 unmodified lines
165 }164 }
166 165
167 // Reset the render args166 // Reset the render args
168 args->_viewFrustum = viewFrustum;167 args->popViewFrustum();
169 args->_renderMode = mode;168 args->_renderMode = mode;
170};169};
libraries/render/src/render/CullTask.cpp+16−20
@@ -14,6 +14,7 @@ · 13 unmodified lines
14#include <algorithm>14#include <algorithm>
15#include <assert.h>15#include <assert.h>
16 16
17#include <OctreeUtils.h>
17#include <PerfStat.h>18#include <PerfStat.h>
18#include <ViewFrustum.h>19#include <ViewFrustum.h>
19#include <gpu/Context.h>20#include <gpu/Context.h>
@@ -23,10 +24,10 @@ using namespace render; · 3 unmodified lines
23void render::cullItems(const RenderContextPointer& renderContext, const CullFunctor& cullFunctor, RenderDetails::Item& details,24void render::cullItems(const RenderContextPointer& renderContext, const CullFunctor& cullFunctor, RenderDetails::Item& details,
24 const ItemBounds& inItems, ItemBounds& outItems) {25 const ItemBounds& inItems, ItemBounds& outItems) {
25 assert(renderContext->args);26 assert(renderContext->args);
26 assert(renderContext->args->_viewFrustum);27 assert(renderContext->args->hasViewFrustum());
27 28
28 RenderArgs* args = renderContext->args;29 RenderArgs* args = renderContext->args;
29 ViewFrustum* frustum = args->_viewFrustum;30 const ViewFrustum& frustum = args->getViewFrustum();
30 31
31 details._considered += (int)inItems.size();32 details._considered += (int)inItems.size();
32 33
@@ -42,7 +43,7 @@ void render::cullItems(const RenderContextPointer& renderContext, const CullFunc · 9 unmodified lines
42 bool inView;43 bool inView;
43 {44 {
44 PerformanceTimer perfTimer("boxIntersectsFrustum");45 PerformanceTimer perfTimer("boxIntersectsFrustum");
45 inView = frustum->boxIntersectsFrustum(item.bound);46 inView = frustum.boxIntersectsFrustum(item.bound);
46 }47 }
47 if (inView) {48 if (inView) {
48 bool bigEnoughToRender;49 bool bigEnoughToRender;
@@ -64,7 +65,7 @@ void render::cullItems(const RenderContextPointer& renderContext, const CullFunc · 15 unmodified lines
64 65
65void FetchNonspatialItems::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, ItemBounds& outItems) {66void FetchNonspatialItems::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, ItemBounds& outItems) {
66 assert(renderContext->args);67 assert(renderContext->args);
67 assert(renderContext->args->_viewFrustum);68 assert(renderContext->args->hasViewFrustum());
68 auto& scene = sceneContext->_scene;69 auto& scene = sceneContext->_scene;
69 70
70 outItems.clear();71 outItems.clear();
@@ -85,7 +86,7 @@ void FetchSpatialTree::configure(const Config& config) { · 14 unmodified lines
85 86
86void FetchSpatialTree::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, ItemSpatialTree::ItemSelection& outSelection) {87void FetchSpatialTree::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, ItemSpatialTree::ItemSelection& outSelection) {
87 assert(renderContext->args);88 assert(renderContext->args);
88 assert(renderContext->args->_viewFrustum);89 assert(renderContext->args->hasViewFrustum());
89 RenderArgs* args = renderContext->args;90 RenderArgs* args = renderContext->args;
90 auto& scene = sceneContext->_scene;91 auto& scene = sceneContext->_scene;
91 92
@@ -93,22 +94,18 @@ void FetchSpatialTree::run(const SceneContextPointer& sceneContext, const Render · 1 unmodified line
93 outSelection.clear();94 outSelection.clear();
94 95
95 // Eventually use a frozen frustum96 // Eventually use a frozen frustum
96 auto queryFrustum = *args->_viewFrustum;97 auto queryFrustum = args->getViewFrustum();
97 if (_freezeFrustum) {98 if (_freezeFrustum) {
98 if (_justFrozeFrustum) {99 if (_justFrozeFrustum) {
99 _justFrozeFrustum = false;100 _justFrozeFrustum = false;
100 _frozenFrutstum = *args->_viewFrustum;101 _frozenFrutstum = args->getViewFrustum();
101 }102 }
102 queryFrustum = _frozenFrutstum;103 queryFrustum = _frozenFrutstum;
103 }104 }
104 105
105 // Octree selection!106 // Octree selection!
106 107 float angle = glm::degrees(getAccuracyAngle(args->_sizeScale, args->_boundaryLevelAdjust));
107 float angle = glm::degrees(queryFrustum.getAccuracyAngle(args->_sizeScale, args->_boundaryLevelAdjust));
108
109
110 scene->getSpatialTree().selectCellItems(outSelection, _filter, queryFrustum, angle);108 scene->getSpatialTree().selectCellItems(outSelection, _filter, queryFrustum, angle);
111
112}109}
113 110
114void CullSpatialSelection::configure(const Config& config) {111void CullSpatialSelection::configure(const Config& config) {
@@ -120,7 +117,7 @@ void CullSpatialSelection::configure(const Config& config) { · 5 unmodified lines
120void CullSpatialSelection::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext,117void CullSpatialSelection::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext,
121 const ItemSpatialTree::ItemSelection& inSelection, ItemBounds& outItems) {118 const ItemSpatialTree::ItemSelection& inSelection, ItemBounds& outItems) {
122 assert(renderContext->args);119 assert(renderContext->args);
123 assert(renderContext->args->_viewFrustum);120 assert(renderContext->args->hasViewFrustum());
124 RenderArgs* args = renderContext->args;121 RenderArgs* args = renderContext->args;
125 auto& scene = sceneContext->_scene;122 auto& scene = sceneContext->_scene;
126 123
@@ -128,13 +125,12 @@ void CullSpatialSelection::run(const SceneContextPointer& sceneContext, const Re · 1 unmodified line
128 details._considered += (int)inSelection.numItems();125 details._considered += (int)inSelection.numItems();
129 126
130 // Eventually use a frozen frustum127 // Eventually use a frozen frustum
131 auto argFrustum = args->_viewFrustum;
132 if (_freezeFrustum) {128 if (_freezeFrustum) {
133 if (_justFrozeFrustum) {129 if (_justFrozeFrustum) {
134 _justFrozeFrustum = false;130 _justFrozeFrustum = false;
135 _frozenFrutstum = *args->_viewFrustum;131 _frozenFrutstum = args->getViewFrustum();
136 }132 }
137 args->_viewFrustum = &_frozenFrutstum; // replace the true view frustum by the frozen one133 args->pushViewFrustum(_frozenFrutstum); // replace the true view frustum by the frozen one
138 }134 }
139 135
140 // Culling Frustum / solidAngle test helper class136 // Culling Frustum / solidAngle test helper class
@@ -151,8 +147,8 @@ void CullSpatialSelection::run(const SceneContextPointer& sceneContext, const Re · 10 unmodified lines
151 _renderDetails(renderDetails)147 _renderDetails(renderDetails)
152 {148 {
153 // FIXME: Keep this code here even though we don't use it yet149 // FIXME: Keep this code here even though we don't use it yet
154 /*_eyePos = _args->_viewFrustum->getPosition();150 /*_eyePos = _args->getViewFrustum().getPosition();
155 float a = glm::degrees(_args->_viewFrustum->getAccuracyAngle(_args->_sizeScale, _args->_boundaryLevelAdjust));151 float a = glm::degrees(Octree::getAccuracyAngle(_args->_sizeScale, _args->_boundaryLevelAdjust));
156 auto angle = std::min(glm::radians(45.0f), a); // no worse than 45 degrees152 auto angle = std::min(glm::radians(45.0f), a); // no worse than 45 degrees
157 angle = std::max(glm::radians(1.0f / 60.0f), a); // no better than 1 minute of degree153 angle = std::max(glm::radians(1.0f / 60.0f), a); // no better than 1 minute of degree
158 auto tanAlpha = tan(angle);154 auto tanAlpha = tan(angle);
@@ -161,7 +157,7 @@ void CullSpatialSelection::run(const SceneContextPointer& sceneContext, const Re · 2 unmodified lines
161 }157 }
162 158
163 bool frustumTest(const AABox& bound) {159 bool frustumTest(const AABox& bound) {
164 if (!_args->_viewFrustum->boxIntersectsFrustum(bound)) {160 if (!_args->getViewFrustum().boxIntersectsFrustum(bound)) {
165 _renderDetails._outOfView++;161 _renderDetails._outOfView++;
166 return false;162 return false;
167 }163 }
@@ -305,7 +301,7 @@ void CullSpatialSelection::run(const SceneContextPointer& sceneContext, const Re · 137 unmodified lines
305 301
306 // Restore frustum if using the frozen one:302 // Restore frustum if using the frozen one:
307 if (_freezeFrustum) {303 if (_freezeFrustum) {
308 args->_viewFrustum = argFrustum;304 args->popViewFrustum();
309 }305 }
310 306
311 std::static_pointer_cast<Config>(renderContext->jobConfig)->numItems = (int)outItems.size();307 std::static_pointer_cast<Config>(renderContext->jobConfig)->numItems = (int)outItems.size();
libraries/render/src/render/DrawSceneOctree.cpp+8−7
@@ -14,6 +14,7 @@ · 13 unmodified lines
14#include <algorithm>14#include <algorithm>
15#include <assert.h>15#include <assert.h>
16 16
17#include <OctreeUtils.h>
17#include <PerfStat.h>18#include <PerfStat.h>
18#include <RenderArgs.h>19#include <RenderArgs.h>
19 20
@@ -86,7 +87,7 @@ void DrawSceneOctree::configure(const Config& config) { · 66 unmodified lines
86void DrawSceneOctree::run(const SceneContextPointer& sceneContext,87void DrawSceneOctree::run(const SceneContextPointer& sceneContext,
87 const RenderContextPointer& renderContext, const ItemSpatialTree::ItemSelection& inSelection) {88 const RenderContextPointer& renderContext, const ItemSpatialTree::ItemSelection& inSelection) {
88 assert(renderContext->args);89 assert(renderContext->args);
89 assert(renderContext->args->_viewFrustum);90 assert(renderContext->args->hasViewFrustum());
90 RenderArgs* args = renderContext->args;91 RenderArgs* args = renderContext->args;
91 auto& scene = sceneContext->_scene;92 auto& scene = sceneContext->_scene;
92 93
@@ -97,8 +98,8 @@ void DrawSceneOctree::run(const SceneContextPointer& sceneContext, · 4 unmodified lines
97 gpu::doInBatch(args->_context, [&](gpu::Batch& batch) {98 gpu::doInBatch(args->_context, [&](gpu::Batch& batch) {
98 glm::mat4 projMat;99 glm::mat4 projMat;
99 Transform viewMat;100 Transform viewMat;
100 args->_viewFrustum->evalProjectionMatrix(projMat);101 args->getViewFrustum().evalProjectionMatrix(projMat);
101 args->_viewFrustum->evalViewTransform(viewMat);102 args->getViewFrustum().evalViewTransform(viewMat);
102 batch.setViewportTransform(args->_viewport);103 batch.setViewportTransform(args->_viewport);
103 104
104 batch.setProjectionTransform(projMat);105 batch.setProjectionTransform(projMat);
@@ -148,7 +149,7 @@ void DrawSceneOctree::run(const SceneContextPointer& sceneContext, · 43 unmodified lines
148 }149 }
149 // Draw the LOD Reticle150 // Draw the LOD Reticle
150 {151 {
151 float angle = glm::degrees(args->_viewFrustum->getAccuracyAngle(args->_sizeScale, args->_boundaryLevelAdjust));152 float angle = glm::degrees(getAccuracyAngle(args->_sizeScale, args->_boundaryLevelAdjust));
152 Transform crosshairModel;153 Transform crosshairModel;
153 crosshairModel.setTranslation(glm::vec3(0.0, 0.0, -1000.0));154 crosshairModel.setTranslation(glm::vec3(0.0, 0.0, -1000.0));
154 crosshairModel.setScale(1000.0 * tan(glm::radians(angle))); // Scaling at the actual tan of the lod angle => Multiplied by TWO155 crosshairModel.setScale(1000.0 * tan(glm::radians(angle))); // Scaling at the actual tan of the lod angle => Multiplied by TWO
@@ -198,15 +199,15 @@ void DrawItemSelection::configure(const Config& config) { · 43 unmodified lines
198void DrawItemSelection::run(const SceneContextPointer& sceneContext,199void DrawItemSelection::run(const SceneContextPointer& sceneContext,
199 const RenderContextPointer& renderContext, const ItemSpatialTree::ItemSelection& inSelection) {200 const RenderContextPointer& renderContext, const ItemSpatialTree::ItemSelection& inSelection) {
200 assert(renderContext->args);201 assert(renderContext->args);
201 assert(renderContext->args->_viewFrustum);202 assert(renderContext->args->hasViewFrustum());
202 RenderArgs* args = renderContext->args;203 RenderArgs* args = renderContext->args;
203 auto& scene = sceneContext->_scene;204 auto& scene = sceneContext->_scene;
204 205
205 gpu::doInBatch(args->_context, [&](gpu::Batch& batch) {206 gpu::doInBatch(args->_context, [&](gpu::Batch& batch) {
206 glm::mat4 projMat;207 glm::mat4 projMat;
207 Transform viewMat;208 Transform viewMat;
208 args->_viewFrustum->evalProjectionMatrix(projMat);209 args->getViewFrustum().evalProjectionMatrix(projMat);
209 args->_viewFrustum->evalViewTransform(viewMat);210 args->getViewFrustum().evalViewTransform(viewMat);
210 batch.setViewportTransform(args->_viewport);211 batch.setViewportTransform(args->_viewport);
211 212
212 batch.setProjectionTransform(projMat);213 batch.setProjectionTransform(projMat);
libraries/render/src/render/DrawStatus.cpp+3−3
@@ -107,7 +107,7 @@ void DrawStatus::run(const SceneContextPointer& sceneContext, · 106 unmodified lines
107 const RenderContextPointer& renderContext,107 const RenderContextPointer& renderContext,
108 const ItemBounds& inItems) {108 const ItemBounds& inItems) {
109 assert(renderContext->args);109 assert(renderContext->args);
110 assert(renderContext->args->_viewFrustum);110 assert(renderContext->args->hasViewFrustum());
111 RenderArgs* args = renderContext->args;111 RenderArgs* args = renderContext->args;
112 auto& scene = sceneContext->_scene;112 auto& scene = sceneContext->_scene;
113 const int NUM_STATUS_VEC4_PER_ITEM = 2;113 const int NUM_STATUS_VEC4_PER_ITEM = 2;
@@ -183,8 +183,8 @@ void DrawStatus::run(const SceneContextPointer& sceneContext, · 69 unmodified lines
183 gpu::doInBatch(args->_context, [&](gpu::Batch& batch) {183 gpu::doInBatch(args->_context, [&](gpu::Batch& batch) {
184 glm::mat4 projMat;184 glm::mat4 projMat;
185 Transform viewMat;185 Transform viewMat;
186 args->_viewFrustum->evalProjectionMatrix(projMat);186 args->getViewFrustum().evalProjectionMatrix(projMat);
187 args->_viewFrustum->evalViewTransform(viewMat);187 args->getViewFrustum().evalViewTransform(viewMat);
188 batch.setViewportTransform(args->_viewport);188 batch.setViewportTransform(args->_viewport);
189 189
190 batch.setProjectionTransform(projMat);190 batch.setProjectionTransform(projMat);
libraries/render/src/render/DrawTask.cpp+1−1
@@ -120,7 +120,7 @@ void render::renderStateSortShapes(const SceneContextPointer& sceneContext, cons · 119 unmodified lines
120 120
121void DrawLight::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ItemBounds& inLights) {121void DrawLight::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ItemBounds& inLights) {
122 assert(renderContext->args);122 assert(renderContext->args);
123 assert(renderContext->args->_viewFrustum);123 assert(renderContext->args->hasViewFrustum());
124 RenderArgs* args = renderContext->args;124 RenderArgs* args = renderContext->args;
125 125
126 // render lights126 // render lights
libraries/render/src/render/SortTask.cpp+3−3
@@ -1,5 +1,5 @@
1//1//
2// CullTask.cpp2// SortTask.cpp
3// render/src/render3// render/src/render
4//4//
5// Created by Sam Gateau on 2/2/16.5// Created by Sam Gateau on 2/2/16.
@@ -42,7 +42,7 @@ struct BackToFrontSort { · 36 unmodified lines
42 42
43void render::depthSortItems(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, bool frontToBack, const ItemBounds& inItems, ItemBounds& outItems) {43void render::depthSortItems(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, bool frontToBack, const ItemBounds& inItems, ItemBounds& outItems) {
44 assert(renderContext->args);44 assert(renderContext->args);
45 assert(renderContext->args->_viewFrustum);45 assert(renderContext->args->hasViewFrustum());
46 46
47 auto& scene = sceneContext->_scene;47 auto& scene = sceneContext->_scene;
48 RenderArgs* args = renderContext->args;48 RenderArgs* args = renderContext->args;
@@ -60,7 +60,7 @@ void render::depthSortItems(const SceneContextPointer& sceneContext, const Rende · 11 unmodified lines
60 for (auto itemDetails : inItems) {60 for (auto itemDetails : inItems) {
61 auto item = scene->getItem(itemDetails.id);61 auto item = scene->getItem(itemDetails.id);
62 auto bound = itemDetails.bound; // item.getBound();62 auto bound = itemDetails.bound; // item.getBound();
63 float distance = args->_viewFrustum->distanceToCamera(bound.calcCenter());63 float distance = args->getViewFrustum().distanceToCamera(bound.calcCenter());
64 64
65 itemBoundSorts.emplace_back(ItemBoundSort(distance, distance, distance, itemDetails.id, bound));65 itemBoundSorts.emplace_back(ItemBoundSort(distance, distance, distance, itemDetails.id, bound));
66 }66 }
libraries/shared/src/CubeProjectedPolygon.cpprenamed from libraries/octree/src/OctreeProjectedPolygon.cpp+48−48
@@ -1,6 +1,6 @@
1//1//
2// OctreeProjectedPolygon.cpp2// CubeProjectedPolygon.cpp
3// libraries/octree/src3// libraries/shared/src
4//4//
5// Created by Brad Hefta-Gaub on 06/11/13.5// Created by Brad Hefta-Gaub on 06/11/13.
6// Copyright 2013 High Fidelity, Inc.6// Copyright 2013 High Fidelity, Inc.
@@ -15,50 +15,50 @@ · 8 unmodified lines
15 15
16#include "GeometryUtil.h"16#include "GeometryUtil.h"
17#include "SharedUtil.h"17#include "SharedUtil.h"
18#include "OctreeLogging.h"18#include "SharedLogging.h"
19#include "OctreeProjectedPolygon.h"19#include "CubeProjectedPolygon.h"
20 20
21 21
22glm::vec2 BoundingBox::getVertex(int vertexNumber) const {22glm::vec2 BoundingRectangle::getVertex(int vertexNumber) const {
23 switch (vertexNumber) {23 switch (vertexNumber) {
24 case BoundingBox::BOTTOM_LEFT:24 case BoundingRectangle::BOTTOM_LEFT:
25 return corner;25 return corner;
26 case BoundingBox::TOP_LEFT:26 case BoundingRectangle::TOP_LEFT:
27 return glm::vec2(corner.x, corner.y + size.y);27 return glm::vec2(corner.x, corner.y + size.y);
28 case BoundingBox::BOTTOM_RIGHT:28 case BoundingRectangle::BOTTOM_RIGHT:
29 return glm::vec2(corner.x + size.x, corner.y);29 return glm::vec2(corner.x + size.x, corner.y);
30 case BoundingBox::TOP_RIGHT:30 case BoundingRectangle::TOP_RIGHT:
31 return corner + size;31 return corner + size;
32 }32 }
33 assert(false); // not allowed33 assert(false); // not allowed
34 return glm::vec2(0,0);34 return glm::vec2(0,0);
35}35}
36 36
37BoundingBox BoundingBox::topHalf() const {37BoundingRectangle BoundingRectangle::topHalf() const {
38 float halfY = size.y/2.0f;38 float halfY = size.y/2.0f;
39 BoundingBox result(glm::vec2(corner.x,corner.y + halfY), glm::vec2(size.x, halfY));39 BoundingRectangle result(glm::vec2(corner.x,corner.y + halfY), glm::vec2(size.x, halfY));
40 return result;40 return result;
41}41}
42 42
43BoundingBox BoundingBox::bottomHalf() const {43BoundingRectangle BoundingRectangle::bottomHalf() const {
44 float halfY = size.y/2.0f;44 float halfY = size.y/2.0f;
45 BoundingBox result(corner, glm::vec2(size.x, halfY));45 BoundingRectangle result(corner, glm::vec2(size.x, halfY));
46 return result;46 return result;
47}47}
48 48
49BoundingBox BoundingBox::leftHalf() const {49BoundingRectangle BoundingRectangle::leftHalf() const {
50 float halfX = size.x/2.0f;50 float halfX = size.x/2.0f;
51 BoundingBox result(corner, glm::vec2(halfX, size.y));51 BoundingRectangle result(corner, glm::vec2(halfX, size.y));
52 return result;52 return result;
53}53}
54 54
55BoundingBox BoundingBox::rightHalf() const {55BoundingRectangle BoundingRectangle::rightHalf() const {
56 float halfX = size.x/2.0f;56 float halfX = size.x/2.0f;
57 BoundingBox result(glm::vec2(corner.x + halfX , corner.y), glm::vec2(halfX, size.y));57 BoundingRectangle result(glm::vec2(corner.x + halfX , corner.y), glm::vec2(halfX, size.y));
58 return result;58 return result;
59}59}
60 60
61bool BoundingBox::contains(const BoundingBox& box) const {61bool BoundingRectangle::contains(const BoundingRectangle& box) const {
62 return ( _set &&62 return ( _set &&
63 (box.corner.x >= corner.x) &&63 (box.corner.x >= corner.x) &&
64 (box.corner.y >= corner.y) &&64 (box.corner.y >= corner.y) &&
@@ -67,7 +67,7 @@ bool BoundingBox::contains(const BoundingBox& box) const { · 2 unmodified lines
67 );67 );
68}68}
69 69
70bool BoundingBox::contains(const glm::vec2& point) const {70bool BoundingRectangle::contains(const glm::vec2& point) const {
71 return ( _set &&71 return ( _set &&
72 (point.x > corner.x) &&72 (point.x > corner.x) &&
73 (point.y > corner.y) &&73 (point.y > corner.y) &&
@@ -76,7 +76,7 @@ bool BoundingBox::contains(const glm::vec2& point) const { · 2 unmodified lines
76 );76 );
77}77}
78 78
79void BoundingBox::explandToInclude(const BoundingBox& box) {79void BoundingRectangle::explandToInclude(const BoundingRectangle& box) {
80 if (!_set) {80 if (!_set) {
81 corner = box.corner;81 corner = box.corner;
82 size = box.size;82 size = box.size;
@@ -94,20 +94,20 @@ void BoundingBox::explandToInclude(const BoundingBox& box) { · 11 unmodified lines
94}94}
95 95
96 96
97void BoundingBox::printDebugDetails(const char* label) const {97void BoundingRectangle::printDebugDetails(const char* label) const {
98 qCDebug(octree, "%s _set=%s\n corner=%f,%f size=%f,%f\n bounds=[(%f,%f) to (%f,%f)]",98 qCDebug(shared, "%s _set=%s\n corner=%f,%f size=%f,%f\n bounds=[(%f,%f) to (%f,%f)]",
99 (label ? label : "BoundingBox"),99 (label ? label : "BoundingRectangle"),
100 debug::valueOf(_set), (double)corner.x, (double)corner.y, (double)size.x, (double)size.y,100 debug::valueOf(_set), (double)corner.x, (double)corner.y, (double)size.x, (double)size.y,
101 (double)corner.x, (double)corner.y, (double)(corner.x+size.x), (double)(corner.y+size.y));101 (double)corner.x, (double)corner.y, (double)(corner.x+size.x), (double)(corner.y+size.y));
102}102}
103 103
104 104
105long OctreeProjectedPolygon::pointInside_calls = 0;105long CubeProjectedPolygon::pointInside_calls = 0;
106long OctreeProjectedPolygon::occludes_calls = 0;106long CubeProjectedPolygon::occludes_calls = 0;
107long OctreeProjectedPolygon::intersects_calls = 0;107long CubeProjectedPolygon::intersects_calls = 0;
108 108
109 109
110OctreeProjectedPolygon::OctreeProjectedPolygon(const BoundingBox& box) :110CubeProjectedPolygon::CubeProjectedPolygon(const BoundingRectangle& box) :
111 _vertexCount(4),111 _vertexCount(4),
112 _maxX(-FLT_MAX), _maxY(-FLT_MAX), _minX(FLT_MAX), _minY(FLT_MAX),112 _maxX(-FLT_MAX), _maxY(-FLT_MAX), _minX(FLT_MAX), _minY(FLT_MAX),
113 _distance(0)113 _distance(0)
@@ -118,7 +118,7 @@ OctreeProjectedPolygon::OctreeProjectedPolygon(const BoundingBox& box) : · 4 unmodified lines
118}118}
119 119
120 120
121void OctreeProjectedPolygon::setVertex(int vertex, const glm::vec2& point) {121void CubeProjectedPolygon::setVertex(int vertex, const glm::vec2& point) {
122 _vertices[vertex] = point;122 _vertices[vertex] = point;
123 123
124 // keep track of our bounding box124 // keep track of our bounding box
@@ -138,9 +138,9 @@ void OctreeProjectedPolygon::setVertex(int vertex, const glm::vec2& point) { · 13 unmodified lines
138}138}
139 139
140// can be optimized with new pointInside()140// can be optimized with new pointInside()
141bool OctreeProjectedPolygon::occludes(const OctreeProjectedPolygon& occludee, bool checkAllInView) const {141bool CubeProjectedPolygon::occludes(const CubeProjectedPolygon& occludee, bool checkAllInView) const {
142 142
143 OctreeProjectedPolygon::occludes_calls++;143 CubeProjectedPolygon::occludes_calls++;
144 144
145 // if we are completely out of view, then we definitely don't occlude!145 // if we are completely out of view, then we definitely don't occlude!
146 // if the occludee is completely out of view, then we also don't occlude it146 // if the occludee is completely out of view, then we also don't occlude it
@@ -197,12 +197,12 @@ bool OctreeProjectedPolygon::occludes(const OctreeProjectedPolygon& occludee, bo · 50 unmodified lines
197 return false; // if we got this far, then we're not occluded197 return false; // if we got this far, then we're not occluded
198}198}
199 199
200bool OctreeProjectedPolygon::occludes(const BoundingBox& boxOccludee) const {200bool CubeProjectedPolygon::occludes(const BoundingRectangle& boxOccludee) const {
201 OctreeProjectedPolygon testee(boxOccludee);201 CubeProjectedPolygon testee(boxOccludee);
202 return occludes(testee);202 return occludes(testee);
203}203}
204 204
205bool OctreeProjectedPolygon::matches(const OctreeProjectedPolygon& testee) const {205bool CubeProjectedPolygon::matches(const CubeProjectedPolygon& testee) const {
206 if (testee.getVertexCount() != getVertexCount()) {206 if (testee.getVertexCount() != getVertexCount()) {
207 return false;207 return false;
208 }208 }
@@ -231,14 +231,14 @@ bool OctreeProjectedPolygon::matches(const OctreeProjectedPolygon& testee) const · 22 unmodified lines
231 return true; // all of our vertices match, therefore we're the same231 return true; // all of our vertices match, therefore we're the same
232}232}
233 233
234bool OctreeProjectedPolygon::matches(const BoundingBox& box) const {234bool CubeProjectedPolygon::matches(const BoundingRectangle& box) const {
235 OctreeProjectedPolygon testee(box);235 CubeProjectedPolygon testee(box);
236 return matches(testee);236 return matches(testee);
237}237}
238 238
239bool OctreeProjectedPolygon::pointInside(const glm::vec2& point, bool* matchesVertex) const {239bool CubeProjectedPolygon::pointInside(const glm::vec2& point, bool* matchesVertex) const {
240 240
241 OctreeProjectedPolygon::pointInside_calls++;241 CubeProjectedPolygon::pointInside_calls++;
242 242
243 // first check the bounding boxes, the point must be fully within the boounding box of this polygon243 // first check the bounding boxes, the point must be fully within the boounding box of this polygon
244 if ((point.x > getMaxX()) ||244 if ((point.x > getMaxX()) ||
@@ -264,23 +264,23 @@ bool OctreeProjectedPolygon::pointInside(const glm::vec2& point, bool* matchesVe · 19 unmodified lines
264 return true;264 return true;
265}265}
266 266
267void OctreeProjectedPolygon::printDebugDetails() const {267void CubeProjectedPolygon::printDebugDetails() const {
268 qCDebug(octree, "OctreeProjectedPolygon..."268 qCDebug(shared, "CubeProjectedPolygon..."
269 " minX=%f maxX=%f minY=%f maxY=%f", (double)getMinX(), (double)getMaxX(), (double)getMinY(), (double)getMaxY());269 " minX=%f maxX=%f minY=%f maxY=%f", (double)getMinX(), (double)getMaxX(), (double)getMinY(), (double)getMaxY());
270 qCDebug(octree, " vertex count=%d distance=%f", getVertexCount(), (double)getDistance());270 qCDebug(shared, " vertex count=%d distance=%f", getVertexCount(), (double)getDistance());
271 for (int i = 0; i < getVertexCount(); i++) {271 for (int i = 0; i < getVertexCount(); i++) {
272 glm::vec2 point = getVertex(i);272 glm::vec2 point = getVertex(i);
273 qCDebug(octree, " vertex[%d] = %f, %f ", i, (double)point.x, (double)point.y);273 qCDebug(shared, " vertex[%d] = %f, %f ", i, (double)point.x, (double)point.y);
274 }274 }
275}275}
276 276
277bool OctreeProjectedPolygon::intersects(const BoundingBox& box) const {277bool CubeProjectedPolygon::intersects(const BoundingRectangle& box) const {
278 OctreeProjectedPolygon testee(box);278 CubeProjectedPolygon testee(box);
279 return intersects(testee);279 return intersects(testee);
280}280}
281 281
282bool OctreeProjectedPolygon::intersects(const OctreeProjectedPolygon& testee) const {282bool CubeProjectedPolygon::intersects(const CubeProjectedPolygon& testee) const {
283 OctreeProjectedPolygon::intersects_calls++;283 CubeProjectedPolygon::intersects_calls++;
284 return intersectsOnAxes(testee) && testee.intersectsOnAxes(*this);284 return intersectsOnAxes(testee) && testee.intersectsOnAxes(*this);
285}285}
286 286
@@ -294,7 +294,7 @@ bool OctreeProjectedPolygon::intersects(const OctreeProjectedPolygon& testee) co · 7 unmodified lines
294// Note: this only works on convex polygons294// Note: this only works on convex polygons
295//295//
296//296//
297bool OctreeProjectedPolygon::intersectsOnAxes(const OctreeProjectedPolygon& testee) const {297bool CubeProjectedPolygon::intersectsOnAxes(const CubeProjectedPolygon& testee) const {
298 298
299 // consider each edge of this polygon as a potential separating axis299 // consider each edge of this polygon as a potential separating axis
300 for (int i = 0; i < getVertexCount(); i++) {300 for (int i = 0; i < getVertexCount(); i++) {
@@ -324,7 +324,7 @@ bool OctreeProjectedPolygon::intersectsOnAxes(const OctreeProjectedPolygon& test · 23 unmodified lines
324 return true;324 return true;
325}325}
326 326
327bool OctreeProjectedPolygon::canMerge(const OctreeProjectedPolygon& that) const {327bool CubeProjectedPolygon::canMerge(const CubeProjectedPolygon& that) const {
328 328
329 // RIGHT/NEAR329 // RIGHT/NEAR
330 // LEFT/NEAR330 // LEFT/NEAR
@@ -642,7 +642,7 @@ bool OctreeProjectedPolygon::canMerge(const OctreeProjectedPolygon& that) const · 311 unmodified lines
642}642}
643 643
644 644
645void OctreeProjectedPolygon::merge(const OctreeProjectedPolygon& that) {645void CubeProjectedPolygon::merge(const CubeProjectedPolygon& that) {
646 646
647 // RIGHT/NEAR647 // RIGHT/NEAR
648 // LEFT/NEAR648 // LEFT/NEAR
libraries/shared/src/CubeProjectedPolygon.hrenamed from libraries/octree/src/OctreeProjectedPolygon.h+39−39
@@ -1,55 +1,55 @@
1//1//
2// OctreeProjectedPolygon.h2// CubeProjectedPolygon.h
3// libraries/octree/src3// libraries/shared/src
4//4//
5// Created by Brad Hefta-Gaub on 06/11/13.5// Created by Brad Hefta-Gaub on 06/11/13.
6// Copyright 2013 High Fidelity, Inc.6// Copyright 2013 High Fidelity, Inc.
7//7//
8// The projected shadow (on the 2D view plane) for a voxel8// The projected shadow (on the 2D view plane) for a cube
9//9//
10// Distributed under the Apache License, Version 2.0.10// Distributed under the Apache License, Version 2.0.
11// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html11// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
12//12//
13 13
14#ifndef hifi_OctreeProjectedPolygon_h14#ifndef hifi_CubeProjectedPolygon_h
15#define hifi_OctreeProjectedPolygon_h15#define hifi_CubeProjectedPolygon_h
16 16
17#include <glm/glm.hpp>17#include <glm/glm.hpp>
18 18
19// there's a max of 6 vertices of a project polygon, and a max of twice that when clipped to the screen19// there's a max of 6 vertices of a project polygon, and a max of twice that when clipped to the screen
20const int MAX_PROJECTED_POLYGON_VERTEX_COUNT = 6; 20const int MAX_PROJECTED_POLYGON_VERTEX_COUNT = 6;
21const int MAX_CLIPPED_PROJECTED_POLYGON_VERTEX_COUNT = MAX_PROJECTED_POLYGON_VERTEX_COUNT * 2; 21const int MAX_CLIPPED_PROJECTED_POLYGON_VERTEX_COUNT = MAX_PROJECTED_POLYGON_VERTEX_COUNT * 2;
22typedef glm::vec2 ProjectedVertices[MAX_CLIPPED_PROJECTED_POLYGON_VERTEX_COUNT];22typedef glm::vec2 ProjectedVertices[MAX_CLIPPED_PROJECTED_POLYGON_VERTEX_COUNT];
23 23
24class BoundingBox {24class BoundingRectangle {
25public:25public:
26 enum { BOTTOM_LEFT, BOTTOM_RIGHT, TOP_RIGHT, TOP_LEFT, VERTEX_COUNT };26 enum { BOTTOM_LEFT, BOTTOM_RIGHT, TOP_RIGHT, TOP_LEFT, VERTEX_COUNT };
27 27
28 BoundingBox(const glm::vec2 corner, const glm::vec2 size) : corner(corner), size(size), _set(true) {}28 BoundingRectangle(const glm::vec2 corner, const glm::vec2 size) : corner(corner), size(size), _set(true) {}
29 BoundingBox() : _set(false) {}29 BoundingRectangle() : _set(false) {}
30 glm::vec2 corner;30 glm::vec2 corner;
31 glm::vec2 size;31 glm::vec2 size;
32 bool contains(const BoundingBox& box) const;32 bool contains(const BoundingRectangle& box) const;
33 bool contains(const glm::vec2& point) const;33 bool contains(const glm::vec2& point) const;
34 bool pointInside(const glm::vec2& point) const { return contains(point); }34 bool pointInside(const glm::vec2& point) const { return contains(point); }
35 35
36 void explandToInclude(const BoundingBox& box);36 void explandToInclude(const BoundingRectangle& box);
37 37
38 float area() const { return size.x * size.y; }38 float area() const { return size.x * size.y; }
39 39
40 int getVertexCount() const { return VERTEX_COUNT; }40 int getVertexCount() const { return VERTEX_COUNT; }
41 glm::vec2 getVertex(int vertexNumber) const;41 glm::vec2 getVertex(int vertexNumber) const;
42 42
43 BoundingBox topHalf() const;43 BoundingRectangle topHalf() const;
44 BoundingBox bottomHalf() const;44 BoundingRectangle bottomHalf() const;
45 BoundingBox leftHalf() const;45 BoundingRectangle leftHalf() const;
46 BoundingBox rightHalf() const;46 BoundingRectangle rightHalf() const;
47 47
48 float getMaxX() const { return corner.x + size.x; }48 float getMaxX() const { return corner.x + size.x; }
49 float getMaxY() const { return corner.y + size.y; }49 float getMaxY() const { return corner.y + size.y; }
50 float getMinX() const { return corner.x; }50 float getMinX() const { return corner.x; }
51 float getMinY() const { return corner.y; }51 float getMinY() const { return corner.y; }
52 52
53 void printDebugDetails(const char* label=NULL) const;53 void printDebugDetails(const char* label=NULL) const;
54private:54private:
55 bool _set;55 bool _set;
@@ -63,18 +63,18 @@ const int PROJECTION_NEAR = 16; · 7 unmodified lines
63const int PROJECTION_FAR = 32;63const int PROJECTION_FAR = 32;
64const int PROJECTION_CLIPPED = 64;64const int PROJECTION_CLIPPED = 64;
65 65
66class OctreeProjectedPolygon {66class CubeProjectedPolygon {
67 67
68public:68public:
69 OctreeProjectedPolygon(const BoundingBox& box);69 CubeProjectedPolygon(const BoundingRectangle& box);
70 70
71 OctreeProjectedPolygon(int vertexCount = 0) : 71 CubeProjectedPolygon(int vertexCount = 0) :
72 _vertexCount(vertexCount), 72 _vertexCount(vertexCount),
73 _maxX(-FLT_MAX), _maxY(-FLT_MAX), _minX(FLT_MAX), _minY(FLT_MAX),73 _maxX(-FLT_MAX), _maxY(-FLT_MAX), _minX(FLT_MAX), _minY(FLT_MAX),
74 _distance(0)74 _distance(0)
75 { }75 { }
76 76
77 ~OctreeProjectedPolygon() { }77 ~CubeProjectedPolygon() { }
78 const ProjectedVertices& getVertices() const { return _vertices; }78 const ProjectedVertices& getVertices() const { return _vertices; }
79 const glm::vec2& getVertex(int i) const { return _vertices[i]; }79 const glm::vec2& getVertex(int i) const { return _vertices[i]; }
80 void setVertex(int vertex, const glm::vec2& point);80 void setVertex(int vertex, const glm::vec2& point);
@@ -92,28 +92,28 @@ public: · 11 unmodified lines
92 92
93 93
94 bool pointInside(const glm::vec2& point, bool* matchesVertex = NULL) const;94 bool pointInside(const glm::vec2& point, bool* matchesVertex = NULL) const;
95 bool occludes(const OctreeProjectedPolygon& occludee, bool checkAllInView = false) const;95 bool occludes(const CubeProjectedPolygon& occludee, bool checkAllInView = false) const;
96 bool occludes(const BoundingBox& occludee) const;96 bool occludes(const BoundingRectangle& occludee) const;
97 bool intersects(const OctreeProjectedPolygon& testee) const;97 bool intersects(const CubeProjectedPolygon& testee) const;
98 bool intersects(const BoundingBox& box) const;98 bool intersects(const BoundingRectangle& box) const;
99 bool matches(const OctreeProjectedPolygon& testee) const;99 bool matches(const CubeProjectedPolygon& testee) const;
100 bool matches(const BoundingBox& testee) const;100 bool matches(const BoundingRectangle& testee) const;
101 bool intersectsOnAxes(const OctreeProjectedPolygon& testee) const;101 bool intersectsOnAxes(const CubeProjectedPolygon& testee) const;
102 102
103 bool canMerge(const OctreeProjectedPolygon& that) const;103 bool canMerge(const CubeProjectedPolygon& that) const;
104 void merge(const OctreeProjectedPolygon& that); // replaces vertices of this with new merged version104 void merge(const CubeProjectedPolygon& that); // replaces vertices of this with new merged version
105 105
106 float getMaxX() const { return _maxX; }106 float getMaxX() const { return _maxX; }
107 float getMaxY() const { return _maxY; }107 float getMaxY() const { return _maxY; }
108 float getMinX() const { return _minX; }108 float getMinX() const { return _minX; }
109 float getMinY() const { return _minY; }109 float getMinY() const { return _minY; }
110 110
111 BoundingBox getBoundingBox() const { 111 BoundingRectangle getBoundingBox() const {
112 return BoundingBox(glm::vec2(_minX,_minY), glm::vec2(_maxX - _minX, _maxY - _minY)); 112 return BoundingRectangle(glm::vec2(_minX,_minY), glm::vec2(_maxX - _minX, _maxY - _minY));
113 }113 }
114 114
115 void printDebugDetails() const;115 void printDebugDetails() const;
116 116
117 static long pointInside_calls;117 static long pointInside_calls;
118 static long occludes_calls;118 static long occludes_calls;
119 static long intersects_calls;119 static long intersects_calls;
@@ -132,4 +132,4 @@ private: · 12 unmodified lines
132};132};
133 133
134 134
135#endif // hifi_OctreeProjectedPolygon_h135#endif // hifi_CubeProjectedPolygon_h
libraries/shared/src/PIDController.cpp+1−1
@@ -35,7 +35,7 @@ float PIDController::update(float measuredValue, float dt, bool resetAccumulator · 34 unmodified lines
35 updateHistory(measuredValue, dt, error, accumulatedError, changeInError, p, i, d, computedValue);35 updateHistory(measuredValue, dt, error, accumulatedError, changeInError, p, i, d, computedValue);
36 }36 }
37 Q_ASSERT(!glm::isnan(computedValue));37 Q_ASSERT(!glm::isnan(computedValue));
38 38
39 // update state for next time39 // update state for next time
40 _lastError = error;40 _lastError = error;
41 _lastAccumulation = accumulatedError;41 _lastAccumulation = accumulatedError;
libraries/shared/src/Plane.cpprenamed from libraries/octree/src/Plane.cpp+5−5
@@ -1,6 +1,6 @@
1//1//
2// Plane.cpp2// Plane.cpp
3// libraries/octree/src/3// libraries/shared/src/
4//4//
5// Created by Brad Hefta-Gaub on 04/11/13.5// Created by Brad Hefta-Gaub on 04/11/13.
6// Copyright 2013 High Fidelity, Inc.6// Copyright 2013 High Fidelity, Inc.
@@ -13,12 +13,12 @@ · 6 unmodified lines
13//13//
14 14
15#include "Plane.h"15#include "Plane.h"
16#include "OctreeLogging.h"
17
18 16
17#include <stdio.h>
19#include <QtCore/QDebug>18#include <QtCore/QDebug>
20 19
21#include <stdio.h>20#include "SharedLogging.h"
21
22 22
23void Plane::set3Points(const glm::vec3 &v1, const glm::vec3 &v2, const glm::vec3 &v3) {23void Plane::set3Points(const glm::vec3 &v1, const glm::vec3 &v2, const glm::vec3 &v3) {
24 glm::vec3 linev1v2, linev1v3;24 glm::vec3 linev1v2, linev1v3;
@@ -65,7 +65,7 @@ float Plane::distance(const glm::vec3 &point) const { · 40 unmodified lines
65}65}
66 66
67void Plane::print() const {67void Plane::print() const {
68 qCDebug(octree, "Plane - point (x=%f y=%f z=%f) normal (x=%f y=%f z=%f) d=%f",68 qCDebug(shared, "Plane - point (x=%f y=%f z=%f) normal (x=%f y=%f z=%f) d=%f",
69 (double)_point.x, (double)_point.y, (double)_point.z,69 (double)_point.x, (double)_point.y, (double)_point.z,
70 (double)_normal.x, (double)_normal.y, (double)_normal.z, (double)_dCoefficient);70 (double)_normal.x, (double)_normal.y, (double)_normal.z, (double)_dCoefficient);
71}71}
libraries/shared/src/Plane.hrenamed from libraries/octree/src/Plane.h+5−4
@@ -1,6 +1,6 @@
1//1//
2// Plane.h2// Plane.h
3// libraries/octree/src/3// libraries/shared/src/
4//4//
5// Created by Brad Hefta-Gaub on 04/11/13.5// Created by Brad Hefta-Gaub on 04/11/13.
6// Copyright 2013 High Fidelity, Inc.6// Copyright 2013 High Fidelity, Inc.
@@ -20,7 +20,7 @@ · 13 unmodified lines
20class Plane {20class Plane {
21public:21public:
22 Plane(const glm::vec3 &v1, const glm::vec3 &v2, const glm::vec3 &v3) { set3Points(v1,v2,v3); }22 Plane(const glm::vec3 &v1, const glm::vec3 &v2, const glm::vec3 &v3) { set3Points(v1,v2,v3); }
23 Plane() : _normal(0,0,0), _point(0,0,0), _dCoefficient(0) {};23 Plane() : _normal(0.0f), _point(0.0f), _dCoefficient(0.0f) {};
24 ~Plane() {} ;24 ~Plane() {} ;
25 25
26 // methods for defining the plane26 // methods for defining the plane
@@ -28,12 +28,13 @@ public: · 1 unmodified line
28 void setNormalAndPoint(const glm::vec3 &normal, const glm::vec3 &point);28 void setNormalAndPoint(const glm::vec3 &normal, const glm::vec3 &point);
29 void setCoefficients(float a, float b, float c, float d);29 void setCoefficients(float a, float b, float c, float d);
30 30
31 // getters 31 // getters
32 const glm::vec3& getNormal() const { return _normal; };32 const glm::vec3& getNormal() const { return _normal; };
33 const glm::vec3& getPoint() const { return _point; };33 const glm::vec3& getPoint() const { return _point; };
34 float getDCoefficient() const { return _dCoefficient; };34 float getDCoefficient() const { return _dCoefficient; };
35 35
36 // utilities36 // utilities
37 void invalidate() { _normal = glm::vec3(0.0f), _dCoefficient = 1.0e6f; } // distance() never less than 10^6
37 float distance(const glm::vec3 &point) const;38 float distance(const glm::vec3 &point) const;
38 void print() const;39 void print() const;
39 40
@@ -44,4 +45,4 @@ private: · 4 unmodified lines
44};45};
45 46
46 47
47#endif // hifi_Plane_h48#endif // hifi_Plane_h
libraries/shared/src/RenderArgs.h+22−10
@@ -14,12 +14,15 @@ · 13 unmodified lines
14 14
15#include <functional>15#include <functional>
16#include <memory>16#include <memory>
17#include "GLMHelpers.h"17#include <stack>
18
19#include <GLMHelpers.h>
20#include <ViewFrustum.h>
21
18 22
19 23
20class AABox;24class AABox;
21class OctreeRenderer;25class OctreeRenderer;
22class ViewFrustum;
23 26
24namespace gpu {27namespace gpu {
25class Batch;28class Batch;
@@ -39,21 +42,21 @@ public: · 13 unmodified lines
39 SHADOW,42 SHADOW,
40 OTHER43 OTHER
41 };44 };
42 45
43 struct Item {46 struct Item {
44 int _considered = 0;47 int _considered = 0;
45 int _outOfView = 0;48 int _outOfView = 0;
46 int _tooSmall = 0;49 int _tooSmall = 0;
47 int _rendered = 0;50 int _rendered = 0;
48 };51 };
49 52
50 int _materialSwitches = 0;53 int _materialSwitches = 0;
51 int _trianglesRendered = 0;54 int _trianglesRendered = 0;
52 55
53 Item _item;56 Item _item;
54 Item _shadow;57 Item _shadow;
55 Item _other;58 Item _other;
56 59
57 Item& edit(Type type) {60 Item& edit(Type type) {
58 switch (type) {61 switch (type) {
59 case SHADOW:62 case SHADOW:
@@ -77,7 +80,6 @@ public: · 17 unmodified lines
77 80
78 RenderArgs(std::shared_ptr<gpu::Context> context = nullptr,81 RenderArgs(std::shared_ptr<gpu::Context> context = nullptr,
79 OctreeRenderer* renderer = nullptr,82 OctreeRenderer* renderer = nullptr,
80 ViewFrustum* viewFrustum = nullptr,
81 float sizeScale = 1.0f,83 float sizeScale = 1.0f,
82 int boundaryLevelAdjust = 0,84 int boundaryLevelAdjust = 0,
83 RenderMode renderMode = DEFAULT_RENDER_MODE,85 RenderMode renderMode = DEFAULT_RENDER_MODE,
@@ -86,7 +88,6 @@ public: · 2 unmodified lines
86 gpu::Batch* batch = nullptr) :88 gpu::Batch* batch = nullptr) :
87 _context(context),89 _context(context),
88 _renderer(renderer),90 _renderer(renderer),
89 _viewFrustum(viewFrustum),
90 _sizeScale(sizeScale),91 _sizeScale(sizeScale),
91 _boundaryLevelAdjust(boundaryLevelAdjust),92 _boundaryLevelAdjust(boundaryLevelAdjust),
92 _renderMode(renderMode),93 _renderMode(renderMode),
@@ -95,11 +96,22 @@ public: · 2 unmodified lines
95 _batch(batch) {96 _batch(batch) {
96 }97 }
97 98
99 bool hasViewFrustum() const { return _viewFrustums.size() > 0; }
100 void setViewFrustum(const ViewFrustum& viewFrustum) {
101 while (_viewFrustums.size() > 0) {
102 _viewFrustums.pop();
103 }
104 _viewFrustums.push(viewFrustum);
105 }
106 const ViewFrustum& getViewFrustum() const { assert(_viewFrustums.size() > 0); return _viewFrustums.top(); }
107 void pushViewFrustum(const ViewFrustum& viewFrustum) { _viewFrustums.push(viewFrustum); }
108 void popViewFrustum() { _viewFrustums.pop(); }
109
98 std::shared_ptr<gpu::Context> _context = nullptr;110 std::shared_ptr<gpu::Context> _context = nullptr;
99 std::shared_ptr<gpu::Framebuffer> _blitFramebuffer = nullptr;111 std::shared_ptr<gpu::Framebuffer> _blitFramebuffer = nullptr;
100 std::shared_ptr<render::ShapePipeline> _pipeline = nullptr;112 std::shared_ptr<render::ShapePipeline> _pipeline = nullptr;
101 OctreeRenderer* _renderer = nullptr;113 OctreeRenderer* _renderer = nullptr;
102 ViewFrustum* _viewFrustum = nullptr;114 std::stack<ViewFrustum> _viewFrustums;
103 glm::ivec4 _viewport{ 0.0f, 0.0f, 1.0f, 1.0f };115 glm::ivec4 _viewport{ 0.0f, 0.0f, 1.0f, 1.0f };
104 glm::vec3 _boomOffset{ 0.0f, 0.0f, 1.0f };116 glm::vec3 _boomOffset{ 0.0f, 0.0f, 1.0f };
105 float _sizeScale = 1.0f;117 float _sizeScale = 1.0f;
@@ -108,7 +120,7 @@ public: · 2 unmodified lines
108 RenderSide _renderSide = MONO;120 RenderSide _renderSide = MONO;
109 DebugFlags _debugFlags = RENDER_DEBUG_NONE;121 DebugFlags _debugFlags = RENDER_DEBUG_NONE;
110 gpu::Batch* _batch = nullptr;122 gpu::Batch* _batch = nullptr;
111 123
112 std::shared_ptr<gpu::Texture> _whiteTexture;124 std::shared_ptr<gpu::Texture> _whiteTexture;
113 125
114 RenderDetails _details;126 RenderDetails _details;
libraries/shared/src/ViewFrustum.cpprenamed from libraries/octree/src/ViewFrustum.cpp+66−107
@@ -1,6 +1,6 @@
1//1//
2// ViewFrustum.cpp2// ViewFrustum.cpp
3// libraries/octree/src3// libraries/shared/src
4//4//
5// Created by Brad Hefta-Gaub on 04/11/13.5// Created by Brad Hefta-Gaub on 04/11/13.
6// Copyright 2013 High Fidelity, Inc.6// Copyright 2013 High Fidelity, Inc.
@@ -17,13 +17,13 @@ · 10 unmodified lines
17#include <glm/gtx/vector_angle.hpp>17#include <glm/gtx/vector_angle.hpp>
18#include <QtCore/QDebug>18#include <QtCore/QDebug>
19 19
20#include <NumericalConstants.h>
21 20
22#include "GeometryUtil.h"21#include "GeometryUtil.h"
23#include "GLMHelpers.h"22#include "GLMHelpers.h"
23#include "NumericalConstants.h"
24#include "SharedLogging.h"
25//#include "OctreeConstants.h"
24#include "ViewFrustum.h"26#include "ViewFrustum.h"
25#include "OctreeLogging.h"
26#include "OctreeConstants.h"
27 27
28using namespace std;28using namespace std;
29 29
@@ -41,24 +41,24 @@ void ViewFrustum::setPosition(const glm::vec3& position) { · 11 unmodified lines
41}41}
42 42
43// Order cooresponds to the order defined in the BoxVertex enum.43// Order cooresponds to the order defined in the BoxVertex enum.
44static const glm::vec4 NDC_VALUES[8] = {44static const glm::vec4 NDC_VALUES[NUM_FRUSTUM_CORNERS] = {
45 glm::vec4(-1, -1, -1, 1),45 glm::vec4(-1.0f, -1.0f, -1.0f, 1.0f),
46 glm::vec4(1, -1, -1, 1),46 glm::vec4(1.0f, -1.0f, -1.0f, 1.0f),
47 glm::vec4(1, 1, -1, 1),47 glm::vec4(1.0f, 1.0f, -1.0f, 1.0f),
48 glm::vec4(-1, 1, -1, 1),48 glm::vec4(-1.0f, 1.0f, -1.0f, 1.0f),
49 glm::vec4(-1, -1, 1, 1),49 glm::vec4(-1.0f, -1.0f, 1.0f, 1.0f),
50 glm::vec4(1, -1, 1, 1),50 glm::vec4(1.0f, -1.0f, 1.0f, 1.0f),
51 glm::vec4(1, 1, 1, 1),51 glm::vec4(1.0f, 1.0f, 1.0f, 1.0f),
52 glm::vec4(-1, 1, 1, 1),52 glm::vec4(-1.0f, 1.0f, 1.0f, 1.0f),
53};53};
54 54
55void ViewFrustum::setProjection(const glm::mat4& projection) {55void ViewFrustum::setProjection(const glm::mat4& projection) {
56 _projection = projection;56 _projection = projection;
57 _inverseProjection = glm::inverse(projection);57 glm::mat4 inverseProjection = glm::inverse(projection);
58 58
59 // compute our dimensions the usual way59 // compute our dimensions the usual way
60 for (int i = 0; i < 8; ++i) {60 for (int i = 0; i < NUM_FRUSTUM_CORNERS; ++i) {
61 _corners[i] = _inverseProjection * NDC_VALUES[i];61 _corners[i] = inverseProjection * NDC_VALUES[i];
62 _corners[i] /= _corners[i].w;62 _corners[i] /= _corners[i].w;
63 }63 }
64 _nearClip = -_corners[BOTTOM_LEFT_NEAR].z;64 _nearClip = -_corners[BOTTOM_LEFT_NEAR].z;
@@ -66,12 +66,12 @@ void ViewFrustum::setProjection(const glm::mat4& projection) { · 1 unmodified line
66 _aspectRatio = (_corners[TOP_RIGHT_NEAR].x - _corners[BOTTOM_LEFT_NEAR].x) /66 _aspectRatio = (_corners[TOP_RIGHT_NEAR].x - _corners[BOTTOM_LEFT_NEAR].x) /
67 (_corners[TOP_RIGHT_NEAR].y - _corners[BOTTOM_LEFT_NEAR].y);67 (_corners[TOP_RIGHT_NEAR].y - _corners[BOTTOM_LEFT_NEAR].y);
68 68
69 glm::vec4 top = _inverseProjection * vec4(0, 1, -1, 1);69 glm::vec4 top = inverseProjection * vec4(0.0f, 1.0f, -1.0f, 1.0f);
70 top /= top.w;70 top /= top.w;
71 _fieldOfView = abs(glm::degrees(2.0f * abs(glm::angle(vec3(0, 0, -1), glm::normalize(vec3(top))))));71 _fieldOfView = abs(glm::degrees(2.0f * abs(glm::angle(vec3(0.0f, 0.0f, -1.0f), glm::normalize(vec3(top))))));
72}72}
73 73
74// ViewFrustum::calculateViewFrustum()74// ViewFrustum::calculate()
75//75//
76// Description: this will calculate the view frustum bounds for a given position and direction76// Description: this will calculate the view frustum bounds for a given position and direction
77//77//
@@ -84,7 +84,7 @@ void ViewFrustum::calculate() { · 6 unmodified lines
84 // then transform them to world space84 // then transform them to world space
85 glm::mat4 worldMatrix = glm::translate(_position) * glm::mat4(glm::mat3(_right, _up, -_direction));85 glm::mat4 worldMatrix = glm::translate(_position) * glm::mat4(glm::mat3(_right, _up, -_direction));
86 glm::vec4 v;86 glm::vec4 v;
87 for (int i = 0; i < 8; ++i) {87 for (int i = 0; i < NUM_FRUSTUM_CORNERS; ++i) {
88 v = worldMatrix * _corners[i];88 v = worldMatrix * _corners[i];
89 v /= v.w;89 v /= v.w;
90 _cornersWorld[i] = glm::vec3(v);90 _cornersWorld[i] = glm::vec3(v);
@@ -133,7 +133,7 @@ const char* ViewFrustum::debugPlaneName (int plane) const { · 42 unmodified lines
133ViewFrustum::intersection ViewFrustum::calculateCubeFrustumIntersection(const AACube& cube) const {133ViewFrustum::intersection ViewFrustum::calculateCubeFrustumIntersection(const AACube& cube) const {
134 // only check against frustum134 // only check against frustum
135 ViewFrustum::intersection result = INSIDE;135 ViewFrustum::intersection result = INSIDE;
136 for(int i=0; i < 6; i++) {136 for(int i = 0; i < NUM_FRUSTUM_PLANES; i++) {
137 const glm::vec3& normal = _planes[i].getNormal();137 const glm::vec3& normal = _planes[i].getNormal();
138 // check distance to farthest cube point138 // check distance to farthest cube point
139 if ( _planes[i].distance(cube.getFarthestVertex(normal)) < 0.0f) {139 if ( _planes[i].distance(cube.getFarthestVertex(normal)) < 0.0f) {
@@ -178,7 +178,7 @@ ViewFrustum::intersection ViewFrustum::calculateCubeKeyholeIntersection(const AA · 38 unmodified lines
178 178
179bool ViewFrustum::pointIntersectsFrustum(const glm::vec3& point) const {179bool ViewFrustum::pointIntersectsFrustum(const glm::vec3& point) const {
180 // only check against frustum180 // only check against frustum
181 for(int i = 0; i < 6; ++i) {181 for(int i = 0; i < NUM_FRUSTUM_PLANES; ++i) {
182 float distance = _planes[i].distance(point);182 float distance = _planes[i].distance(point);
183 if (distance < 0.0f) {183 if (distance < 0.0f) {
184 return false;184 return false;
@@ -189,7 +189,7 @@ bool ViewFrustum::pointIntersectsFrustum(const glm::vec3& point) const { · 4 unmodified lines
189 189
190bool ViewFrustum::sphereIntersectsFrustum(const glm::vec3& center, float radius) const {190bool ViewFrustum::sphereIntersectsFrustum(const glm::vec3& center, float radius) const {
191 // only check against frustum191 // only check against frustum
192 for(int i=0; i < 6; i++) {192 for(int i = 0; i < NUM_FRUSTUM_PLANES; i++) {
193 float distance = _planes[i].distance(center);193 float distance = _planes[i].distance(center);
194 if (distance < -radius) {194 if (distance < -radius) {
195 // This is outside the regular frustum, so just return the value from checking the keyhole195 // This is outside the regular frustum, so just return the value from checking the keyhole
@@ -201,7 +201,7 @@ bool ViewFrustum::sphereIntersectsFrustum(const glm::vec3& center, float radius) · 5 unmodified lines
201 201
202bool ViewFrustum::boxIntersectsFrustum(const AABox& box) const {202bool ViewFrustum::boxIntersectsFrustum(const AABox& box) const {
203 // only check against frustum203 // only check against frustum
204 for(int i=0; i < 6; i++) {204 for(int i = 0; i < NUM_FRUSTUM_PLANES; i++) {
205 const glm::vec3& normal = _planes[i].getNormal();205 const glm::vec3& normal = _planes[i].getNormal();
206 // check distance to farthest box point206 // check distance to farthest box point
207 if ( _planes[i].distance(box.getFarthestVertex(normal)) < 0.0f) {207 if ( _planes[i].distance(box.getFarthestVertex(normal)) < 0.0f) {
@@ -217,7 +217,7 @@ bool ViewFrustum::sphereIntersectsKeyhole(const glm::vec3& center, float radius) · 9 unmodified lines
217 return true;217 return true;
218 }218 }
219 // check negative touches against frustum planes219 // check negative touches against frustum planes
220 for(int i=0; i < 6; i++) {220 for(int i = 0; i < NUM_FRUSTUM_PLANES; i++) {
221 if ( _planes[i].distance(center) < -radius) {221 if ( _planes[i].distance(center) < -radius) {
222 return false;222 return false;
223 }223 }
@@ -231,7 +231,7 @@ bool ViewFrustum::cubeIntersectsKeyhole(const AACube& cube) const { · 7 unmodified lines
231 return true;231 return true;
232 }232 }
233 // check negative touches against frustum planes233 // check negative touches against frustum planes
234 for(int i=0; i < 6; i++) {234 for(int i = 0; i < NUM_FRUSTUM_PLANES; i++) {
235 const glm::vec3& normal = _planes[i].getNormal();235 const glm::vec3& normal = _planes[i].getNormal();
236 if ( _planes[i].distance(cube.getFarthestVertex(normal)) < 0.0f) {236 if ( _planes[i].distance(cube.getFarthestVertex(normal)) < 0.0f) {
237 return false;237 return false;
@@ -246,7 +246,7 @@ bool ViewFrustum::boxIntersectsKeyhole(const AABox& box) const { · 8 unmodified lines
246 return true;246 return true;
247 }247 }
248 // check negative touches against frustum planes248 // check negative touches against frustum planes
249 for(int i=0; i < 6; i++) {249 for(int i = 0; i < NUM_FRUSTUM_PLANES; i++) {
250 const glm::vec3& normal = _planes[i].getNormal();250 const glm::vec3& normal = _planes[i].getNormal();
251 if ( _planes[i].distance(box.getFarthestVertex(normal)) < 0.0f) {251 if ( _planes[i].distance(box.getFarthestVertex(normal)) < 0.0f) {
252 return false;252 return false;
@@ -281,36 +281,36 @@ bool ViewFrustum::matches(const ViewFrustum& compareTo, bool debug) const { · 28 unmodified lines
281 testMatches(compareTo._focalLength, _focalLength);281 testMatches(compareTo._focalLength, _focalLength);
282 282
283 if (!result && debug) {283 if (!result && debug) {
284 qCDebug(octree, "ViewFrustum::matches()... result=%s", debug::valueOf(result));284 qCDebug(shared, "ViewFrustum::matches()... result=%s", debug::valueOf(result));
285 qCDebug(octree, "%s -- compareTo._position=%f,%f,%f _position=%f,%f,%f",285 qCDebug(shared, "%s -- compareTo._position=%f,%f,%f _position=%f,%f,%f",
286 (testMatches(compareTo._position,_position) ? "MATCHES " : "NO MATCH"),286 (testMatches(compareTo._position,_position) ? "MATCHES " : "NO MATCH"),
287 (double)compareTo._position.x, (double)compareTo._position.y, (double)compareTo._position.z,287 (double)compareTo._position.x, (double)compareTo._position.y, (double)compareTo._position.z,
288 (double)_position.x, (double)_position.y, (double)_position.z);288 (double)_position.x, (double)_position.y, (double)_position.z);
289 qCDebug(octree, "%s -- compareTo._direction=%f,%f,%f _direction=%f,%f,%f",289 qCDebug(shared, "%s -- compareTo._direction=%f,%f,%f _direction=%f,%f,%f",
290 (testMatches(compareTo._direction, _direction) ? "MATCHES " : "NO MATCH"),290 (testMatches(compareTo._direction, _direction) ? "MATCHES " : "NO MATCH"),
291 (double)compareTo._direction.x, (double)compareTo._direction.y, (double)compareTo._direction.z,291 (double)compareTo._direction.x, (double)compareTo._direction.y, (double)compareTo._direction.z,
292 (double)_direction.x, (double)_direction.y, (double)_direction.z );292 (double)_direction.x, (double)_direction.y, (double)_direction.z );
293 qCDebug(octree, "%s -- compareTo._up=%f,%f,%f _up=%f,%f,%f",293 qCDebug(shared, "%s -- compareTo._up=%f,%f,%f _up=%f,%f,%f",
294 (testMatches(compareTo._up, _up) ? "MATCHES " : "NO MATCH"),294 (testMatches(compareTo._up, _up) ? "MATCHES " : "NO MATCH"),
295 (double)compareTo._up.x, (double)compareTo._up.y, (double)compareTo._up.z,295 (double)compareTo._up.x, (double)compareTo._up.y, (double)compareTo._up.z,
296 (double)_up.x, (double)_up.y, (double)_up.z );296 (double)_up.x, (double)_up.y, (double)_up.z );
297 qCDebug(octree, "%s -- compareTo._right=%f,%f,%f _right=%f,%f,%f",297 qCDebug(shared, "%s -- compareTo._right=%f,%f,%f _right=%f,%f,%f",
298 (testMatches(compareTo._right, _right) ? "MATCHES " : "NO MATCH"),298 (testMatches(compareTo._right, _right) ? "MATCHES " : "NO MATCH"),
299 (double)compareTo._right.x, (double)compareTo._right.y, (double)compareTo._right.z,299 (double)compareTo._right.x, (double)compareTo._right.y, (double)compareTo._right.z,
300 (double)_right.x, (double)_right.y, (double)_right.z );300 (double)_right.x, (double)_right.y, (double)_right.z );
301 qCDebug(octree, "%s -- compareTo._fieldOfView=%f _fieldOfView=%f",301 qCDebug(shared, "%s -- compareTo._fieldOfView=%f _fieldOfView=%f",
302 (testMatches(compareTo._fieldOfView, _fieldOfView) ? "MATCHES " : "NO MATCH"),302 (testMatches(compareTo._fieldOfView, _fieldOfView) ? "MATCHES " : "NO MATCH"),
303 (double)compareTo._fieldOfView, (double)_fieldOfView);303 (double)compareTo._fieldOfView, (double)_fieldOfView);
304 qCDebug(octree, "%s -- compareTo._aspectRatio=%f _aspectRatio=%f",304 qCDebug(shared, "%s -- compareTo._aspectRatio=%f _aspectRatio=%f",
305 (testMatches(compareTo._aspectRatio, _aspectRatio) ? "MATCHES " : "NO MATCH"),305 (testMatches(compareTo._aspectRatio, _aspectRatio) ? "MATCHES " : "NO MATCH"),
306 (double)compareTo._aspectRatio, (double)_aspectRatio);306 (double)compareTo._aspectRatio, (double)_aspectRatio);
307 qCDebug(octree, "%s -- compareTo._nearClip=%f _nearClip=%f",307 qCDebug(shared, "%s -- compareTo._nearClip=%f _nearClip=%f",
308 (testMatches(compareTo._nearClip, _nearClip) ? "MATCHES " : "NO MATCH"),308 (testMatches(compareTo._nearClip, _nearClip) ? "MATCHES " : "NO MATCH"),
309 (double)compareTo._nearClip, (double)_nearClip);309 (double)compareTo._nearClip, (double)_nearClip);
310 qCDebug(octree, "%s -- compareTo._farClip=%f _farClip=%f",310 qCDebug(shared, "%s -- compareTo._farClip=%f _farClip=%f",
311 (testMatches(compareTo._farClip, _farClip) ? "MATCHES " : "NO MATCH"),311 (testMatches(compareTo._farClip, _farClip) ? "MATCHES " : "NO MATCH"),
312 (double)compareTo._farClip, (double)_farClip);312 (double)compareTo._farClip, (double)_farClip);
313 qCDebug(octree, "%s -- compareTo._focalLength=%f _focalLength=%f",313 qCDebug(shared, "%s -- compareTo._focalLength=%f _focalLength=%f",
314 (testMatches(compareTo._focalLength, _focalLength) ? "MATCHES " : "NO MATCH"),314 (testMatches(compareTo._focalLength, _focalLength) ? "MATCHES " : "NO MATCH"),
315 (double)compareTo._focalLength, (double)_focalLength);315 (double)compareTo._focalLength, (double)_focalLength);
316 }316 }
@@ -342,34 +342,34 @@ bool ViewFrustum::isVerySimilar(const ViewFrustum& compareTo, bool debug) const · 25 unmodified lines
342 342
343 343
344 if (!result && debug) {344 if (!result && debug) {
345 qCDebug(octree, "ViewFrustum::isVerySimilar()... result=%s\n", debug::valueOf(result));345 qCDebug(shared, "ViewFrustum::isVerySimilar()... result=%s\n", debug::valueOf(result));
346 qCDebug(octree, "%s -- compareTo._position=%f,%f,%f _position=%f,%f,%f",346 qCDebug(shared, "%s -- compareTo._position=%f,%f,%f _position=%f,%f,%f",
347 (testMatches(compareTo._position,_position, POSITION_SIMILAR_ENOUGH) ?347 (testMatches(compareTo._position,_position, POSITION_SIMILAR_ENOUGH) ?
348 "IS SIMILAR ENOUGH " : "IS NOT SIMILAR ENOUGH"),348 "IS SIMILAR ENOUGH " : "IS NOT SIMILAR ENOUGH"),
349 (double)compareTo._position.x, (double)compareTo._position.y, (double)compareTo._position.z,349 (double)compareTo._position.x, (double)compareTo._position.y, (double)compareTo._position.z,
350 (double)_position.x, (double)_position.y, (double)_position.z );350 (double)_position.x, (double)_position.y, (double)_position.z );
351 351
352 qCDebug(octree, "%s -- positionDistance=%f",352 qCDebug(shared, "%s -- positionDistance=%f",
353 (testMatches(0,positionDistance, POSITION_SIMILAR_ENOUGH) ? "IS SIMILAR ENOUGH " : "IS NOT SIMILAR ENOUGH"),353 (testMatches(0,positionDistance, POSITION_SIMILAR_ENOUGH) ? "IS SIMILAR ENOUGH " : "IS NOT SIMILAR ENOUGH"),
354 (double)positionDistance);354 (double)positionDistance);
355 355
356 qCDebug(octree, "%s -- angleOrientation=%f",356 qCDebug(shared, "%s -- angleOrientation=%f",
357 (testMatches(0, angleOrientation, ORIENTATION_SIMILAR_ENOUGH) ? "IS SIMILAR ENOUGH " : "IS NOT SIMILAR ENOUGH"),357 (testMatches(0, angleOrientation, ORIENTATION_SIMILAR_ENOUGH) ? "IS SIMILAR ENOUGH " : "IS NOT SIMILAR ENOUGH"),
358 (double)angleOrientation);358 (double)angleOrientation);
359 359
360 qCDebug(octree, "%s -- compareTo._fieldOfView=%f _fieldOfView=%f",360 qCDebug(shared, "%s -- compareTo._fieldOfView=%f _fieldOfView=%f",
361 (testMatches(compareTo._fieldOfView, _fieldOfView) ? "MATCHES " : "NO MATCH"),361 (testMatches(compareTo._fieldOfView, _fieldOfView) ? "MATCHES " : "NO MATCH"),
362 (double)compareTo._fieldOfView, (double)_fieldOfView);362 (double)compareTo._fieldOfView, (double)_fieldOfView);
363 qCDebug(octree, "%s -- compareTo._aspectRatio=%f _aspectRatio=%f",363 qCDebug(shared, "%s -- compareTo._aspectRatio=%f _aspectRatio=%f",
364 (testMatches(compareTo._aspectRatio, _aspectRatio) ? "MATCHES " : "NO MATCH"),364 (testMatches(compareTo._aspectRatio, _aspectRatio) ? "MATCHES " : "NO MATCH"),
365 (double)compareTo._aspectRatio, (double)_aspectRatio);365 (double)compareTo._aspectRatio, (double)_aspectRatio);
366 qCDebug(octree, "%s -- compareTo._nearClip=%f _nearClip=%f",366 qCDebug(shared, "%s -- compareTo._nearClip=%f _nearClip=%f",
367 (testMatches(compareTo._nearClip, _nearClip) ? "MATCHES " : "NO MATCH"),367 (testMatches(compareTo._nearClip, _nearClip) ? "MATCHES " : "NO MATCH"),
368 (double)compareTo._nearClip, (double)_nearClip);368 (double)compareTo._nearClip, (double)_nearClip);
369 qCDebug(octree, "%s -- compareTo._farClip=%f _farClip=%f",369 qCDebug(shared, "%s -- compareTo._farClip=%f _farClip=%f",
370 (testMatches(compareTo._farClip, _farClip) ? "MATCHES " : "NO MATCH"),370 (testMatches(compareTo._farClip, _farClip) ? "MATCHES " : "NO MATCH"),
371 (double)compareTo._farClip, (double)_farClip);371 (double)compareTo._farClip, (double)_farClip);
372 qCDebug(octree, "%s -- compareTo._focalLength=%f _focalLength=%f",372 qCDebug(shared, "%s -- compareTo._focalLength=%f _focalLength=%f",
373 (testMatches(compareTo._focalLength, _focalLength) ? "MATCHES " : "NO MATCH"),373 (testMatches(compareTo._focalLength, _focalLength) ? "MATCHES " : "NO MATCH"),
374 (double)compareTo._focalLength, (double)_focalLength);374 (double)compareTo._focalLength, (double)_focalLength);
375 }375 }
@@ -394,7 +394,7 @@ void ViewFrustum::computeOffAxisFrustum(float& left, float& right, float& bottom · 18 unmodified lines
394 // find the minimum and maximum z values, which will be our near and far clip distances394 // find the minimum and maximum z values, which will be our near and far clip distances
395 nearValue = FLT_MAX;395 nearValue = FLT_MAX;
396 farValue = -FLT_MAX;396 farValue = -FLT_MAX;
397 for (int i = 0; i < 8; i++) {397 for (int i = 0; i < NUM_FRUSTUM_CORNERS; i++) {
398 nearValue = min(nearValue, -_corners[i].z);398 nearValue = min(nearValue, -_corners[i].z);
399 farValue = max(farValue, -_corners[i].z);399 farValue = max(farValue, -_corners[i].z);
400 }400 }
@@ -427,17 +427,17 @@ void ViewFrustum::computeOffAxisFrustum(float& left, float& right, float& bottom · 26 unmodified lines
427}427}
428 428
429void ViewFrustum::printDebugDetails() const {429void ViewFrustum::printDebugDetails() const {
430 qCDebug(octree, "ViewFrustum::printDebugDetails()...");430 qCDebug(shared, "ViewFrustum::printDebugDetails()...");
431 qCDebug(octree, "_position=%f,%f,%f", (double)_position.x, (double)_position.y, (double)_position.z );431 qCDebug(shared, "_position=%f,%f,%f", (double)_position.x, (double)_position.y, (double)_position.z );
432 qCDebug(octree, "_direction=%f,%f,%f", (double)_direction.x, (double)_direction.y, (double)_direction.z );432 qCDebug(shared, "_direction=%f,%f,%f", (double)_direction.x, (double)_direction.y, (double)_direction.z );
433 qCDebug(octree, "_up=%f,%f,%f", (double)_up.x, (double)_up.y, (double)_up.z );433 qCDebug(shared, "_up=%f,%f,%f", (double)_up.x, (double)_up.y, (double)_up.z );
434 qCDebug(octree, "_right=%f,%f,%f", (double)_right.x, (double)_right.y, (double)_right.z );434 qCDebug(shared, "_right=%f,%f,%f", (double)_right.x, (double)_right.y, (double)_right.z );
435 qCDebug(octree, "_fieldOfView=%f", (double)_fieldOfView);435 qCDebug(shared, "_fieldOfView=%f", (double)_fieldOfView);
436 qCDebug(octree, "_aspectRatio=%f", (double)_aspectRatio);436 qCDebug(shared, "_aspectRatio=%f", (double)_aspectRatio);
437 qCDebug(octree, "_centerSphereRadius=%f", (double)_centerSphereRadius);437 qCDebug(shared, "_centerSphereRadius=%f", (double)_centerSphereRadius);
438 qCDebug(octree, "_nearClip=%f", (double)_nearClip);438 qCDebug(shared, "_nearClip=%f", (double)_nearClip);
439 qCDebug(octree, "_farClip=%f", (double)_farClip);439 qCDebug(shared, "_farClip=%f", (double)_farClip);
440 qCDebug(octree, "_focalLength=%f", (double)_focalLength);440 qCDebug(shared, "_focalLength=%f", (double)_focalLength);
441}441}
442 442
443glm::vec2 ViewFrustum::projectPoint(glm::vec3 point, bool& pointInView) const {443glm::vec2 ViewFrustum::projectPoint(glm::vec3 point, bool& pointInView) const {
@@ -536,7 +536,7 @@ const int hullVertexLookup[MAX_POSSIBLE_COMBINATIONS][MAX_PROJECTED_POLYGON_VERT · 92 unmodified lines
536 {6, TOP_RIGHT_NEAR, TOP_RIGHT_FAR, BOTTOM_RIGHT_FAR, BOTTOM_LEFT_FAR, BOTTOM_LEFT_NEAR, TOP_LEFT_NEAR}, // back, top, left536 {6, TOP_RIGHT_NEAR, TOP_RIGHT_FAR, BOTTOM_RIGHT_FAR, BOTTOM_LEFT_FAR, BOTTOM_LEFT_NEAR, TOP_LEFT_NEAR}, // back, top, left
537};537};
538 538
539OctreeProjectedPolygon ViewFrustum::getProjectedPolygon(const AACube& box) const {539CubeProjectedPolygon ViewFrustum::getProjectedPolygon(const AACube& box) const {
540 const glm::vec3& bottomNearRight = box.getCorner();540 const glm::vec3& bottomNearRight = box.getCorner();
541 glm::vec3 topFarLeft = box.calcTopFarLeft();541 glm::vec3 topFarLeft = box.calcTopFarLeft();
542 542
@@ -549,7 +549,7 @@ OctreeProjectedPolygon ViewFrustum::getProjectedPolygon(const AACube& box) const · 6 unmodified lines
549 549
550 int vertexCount = hullVertexLookup[lookUp][0]; //look up number of vertices550 int vertexCount = hullVertexLookup[lookUp][0]; //look up number of vertices
551 551
552 OctreeProjectedPolygon projectedPolygon(vertexCount);552 CubeProjectedPolygon projectedPolygon(vertexCount);
553 553
554 bool pointInView = true;554 bool pointInView = true;
555 bool allPointsInView = false; // assume the best, but wait till we know we have a vertex555 bool allPointsInView = false; // assume the best, but wait till we know we have a vertex
@@ -630,7 +630,7 @@ void ViewFrustum::getFurthestPointFromCamera(const AACube& box, glm::vec3& furth · 74 unmodified lines
630 }630 }
631}631}
632 632
633const ViewFrustum::Corners ViewFrustum::getCorners(const float& depth) {633const ViewFrustum::Corners ViewFrustum::getCorners(const float& depth) const {
634 glm::vec3 normal = glm::normalize(_direction);634 glm::vec3 normal = glm::normalize(_direction);
635 635
636 auto getCorner = [&](enum::BoxVertex nearCorner, enum::BoxVertex farCorner) {636 auto getCorner = [&](enum::BoxVertex nearCorner, enum::BoxVertex farCorner) {
@@ -662,51 +662,10 @@ void ViewFrustum::evalViewTransform(Transform& view) const { · 25 unmodified lines
662 view.setRotation(getOrientation());662 view.setRotation(getOrientation());
663}663}
664 664
665float ViewFrustum::calculateRenderAccuracy(const AABox& bounds, float octreeSizeScale, int boundaryLevelAdjust) const {665void ViewFrustum::invalidate() {
666 float distanceToCamera = glm::length(bounds.calcCenter() - getPosition());666 // these setting should make nearly all intersection tests fail
667 float largestDimension = bounds.getLargestDimension();667 for (int i = 0; i < NUM_FRUSTUM_PLANES; ++i) {
668 668 _planes[i].invalidate();
669 const float maxScale = (float)TREE_SCALE;
670 float visibleDistanceAtMaxScale = boundaryDistanceForRenderLevel(boundaryLevelAdjust, octreeSizeScale) / OCTREE_TO_MESH_RATIO;
671
672 static std::once_flag once;
673 static QMap<float, float> shouldRenderTable;
674 std::call_once(once, [&] {
675 float SMALLEST_SCALE_IN_TABLE = 0.001f; // 1mm is plenty small
676 float scale = maxScale;
677 float factor = 1.0f;
678
679 while (scale > SMALLEST_SCALE_IN_TABLE) {
680 scale /= 2.0f;
681 factor /= 2.0f;
682 shouldRenderTable[scale] = factor;
683 }
684 });
685
686 float closestScale = maxScale;
687 float visibleDistanceAtClosestScale = visibleDistanceAtMaxScale;
688 QMap<float, float>::const_iterator lowerBound = shouldRenderTable.lowerBound(largestDimension);
689 if (lowerBound != shouldRenderTable.constEnd()) {
690 closestScale = lowerBound.key();
691 visibleDistanceAtClosestScale = visibleDistanceAtMaxScale * lowerBound.value();
692 }
693
694 if (closestScale < largestDimension) {
695 visibleDistanceAtClosestScale *= 2.0f;
696 }669 }
697 670 _centerSphereRadius = -1.0e6f; // -10^6 should be negative enough
698 // FIXME - for now, it's either visible or not visible. We want to adjust this to eventually return
699 // a floating point for objects that have small angular size to indicate that they may be rendered
700 // with lower preciscion
701 return (distanceToCamera <= visibleDistanceAtClosestScale) ? 1.0f : 0.0f;
702}
703
704float boundaryDistanceForRenderLevel(unsigned int renderLevel, float voxelSizeScale) {
705 return voxelSizeScale / powf(2, renderLevel);
706}
707
708float ViewFrustum::getAccuracyAngle(float octreeSizeScale, int boundaryLevelAdjust) const {
709 const float maxScale = (float)TREE_SCALE;
710 float visibleDistanceAtMaxScale = boundaryDistanceForRenderLevel(boundaryLevelAdjust, octreeSizeScale) / OCTREE_TO_MESH_RATIO;
711 return atan(maxScale / visibleDistanceAtMaxScale);
712}671}
libraries/shared/src/ViewFrustum.hrenamed from libraries/octree/src/ViewFrustum.h+28−37
@@ -1,6 +1,6 @@
1//1//
2// ViewFrustum.h2// ViewFrustum.h
3// libraries/octree/src3// libraries/shared/src
4//4//
5// Created by Brad Hefta-Gaub on 04/11/13.5// Created by Brad Hefta-Gaub on 04/11/13.
6// Copyright 2013 High Fidelity, Inc.6// Copyright 2013 High Fidelity, Inc.
@@ -17,21 +17,21 @@ · 10 unmodified lines
17#include <glm/glm.hpp>17#include <glm/glm.hpp>
18#include <glm/gtc/quaternion.hpp>18#include <glm/gtc/quaternion.hpp>
19 19
20#include <GLMHelpers.h>
21#include <RegisteredMetaTypes.h>
22
23#include "Transform.h"
24#include "AABox.h"20#include "AABox.h"
25#include "AACube.h"21#include "AACube.h"
22#include "CubeProjectedPolygon.h"
26#include "Plane.h"23#include "Plane.h"
27#include "OctreeConstants.h"24#include "RegisteredMetaTypes.h"
28#include "OctreeProjectedPolygon.h"25#include "Transform.h"
26
27const int NUM_FRUSTUM_CORNERS = 8;
28const int NUM_FRUSTUM_PLANES = 6;
29 29
30const float DEFAULT_CENTER_SPHERE_RADIUS = 3.0f;30const float DEFAULT_CENTER_SPHERE_RADIUS = 3.0f;
31const float DEFAULT_FIELD_OF_VIEW_DEGREES = 45.0f;31const float DEFAULT_FIELD_OF_VIEW_DEGREES = 45.0f;
32const float DEFAULT_ASPECT_RATIO = 16.0f/9.0f;32const float DEFAULT_ASPECT_RATIO = 16.0f/9.0f;
33const float DEFAULT_NEAR_CLIP = 0.08f;33const float DEFAULT_NEAR_CLIP = 0.08f;
34const float DEFAULT_FAR_CLIP = (float)HALF_TREE_SCALE;34const float DEFAULT_FAR_CLIP = 16384.0f;
35 35
36// the "ViewFrustum" has a "keyhole" shape: a regular frustum for stuff that is "visible" with36// the "ViewFrustum" has a "keyhole" shape: a regular frustum for stuff that is "visible" with
37// a central sphere for stuff that is nearby (for physics simulation).37// a central sphere for stuff that is nearby (for physics simulation).
@@ -74,7 +74,7 @@ public: · 36 unmodified lines
74 glm::vec3 bottomRight;74 glm::vec3 bottomRight;
75 // Get the corners depth units from frustum position, along frustum orientation75 // Get the corners depth units from frustum position, along frustum orientation
76 };76 };
77 const Corners getCorners(const float& depth);77 const Corners getCorners(const float& depth) const;
78 78
79 // getters for corners79 // getters for corners
80 const glm::vec3& getFarTopLeft() const { return _cornersWorld[TOP_LEFT_FAR]; }80 const glm::vec3& getFarTopLeft() const { return _cornersWorld[TOP_LEFT_FAR]; }
@@ -123,7 +123,7 @@ public: · 42 unmodified lines
123 void printDebugDetails() const;123 void printDebugDetails() const;
124 124
125 glm::vec2 projectPoint(glm::vec3 point, bool& pointInView) const;125 glm::vec2 projectPoint(glm::vec3 point, bool& pointInView) const;
126 OctreeProjectedPolygon getProjectedPolygon(const AACube& box) const;126 CubeProjectedPolygon getProjectedPolygon(const AACube& box) const;
127 void getFurthestPointFromCamera(const AACube& box, glm::vec3& furthestPoint) const;127 void getFurthestPointFromCamera(const AACube& box, glm::vec3& furthestPoint) const;
128 128
129 float distanceToCamera(const glm::vec3& point) const;129 float distanceToCamera(const glm::vec3& point) const;
@@ -131,44 +131,37 @@ public: · 1 unmodified line
131 void evalProjectionMatrix(glm::mat4& proj) const;131 void evalProjectionMatrix(glm::mat4& proj) const;
132 void evalViewTransform(Transform& view) const;132 void evalViewTransform(Transform& view) const;
133 133
134 /// renderAccuracy represents a floating point "visibility" of an object based on it's view from the camera. At a simple
135 /// level it returns 0.0f for things that are so small for the current settings that they could not be visible.
136 float calculateRenderAccuracy(const AABox& bounds, float octreeSizeScale = DEFAULT_OCTREE_SIZE_SCALE,
137 int boundaryLevelAdjust = 0) const;
138
139 float getAccuracyAngle(float octreeSizeScale = DEFAULT_OCTREE_SIZE_SCALE, int boundaryLevelAdjust = 0) const;
140
141 enum PlaneIndex { TOP_PLANE = 0, BOTTOM_PLANE, LEFT_PLANE, RIGHT_PLANE, NEAR_PLANE, FAR_PLANE, NUM_PLANES };134 enum PlaneIndex { TOP_PLANE = 0, BOTTOM_PLANE, LEFT_PLANE, RIGHT_PLANE, NEAR_PLANE, FAR_PLANE, NUM_PLANES };
142 135
143 const ::Plane* getPlanes() const { return _planes; }136 const ::Plane* getPlanes() const { return _planes; }
137
138 void invalidate(); // causes all reasonable intersection tests to fail
144private:139private:
145 // camera location/orientation attributes
146 glm::vec3 _position; // the position in world-frame
147 glm::quat _orientation;
148 glm::mat4 _view;140 glm::mat4 _view;
149
150 // Lens attributes
151 glm::mat4 _projection;141 glm::mat4 _projection;
152 142
153 // calculated for orientation143 ::Plane _planes[NUM_FRUSTUM_PLANES]; // plane normals point inside frustum
144
145 glm::vec3 _position; // position in world-frame
146 glm::quat _orientation; // orientation in world-frame
147
148 // calculated from orientation
154 glm::vec3 _direction = IDENTITY_FRONT;149 glm::vec3 _direction = IDENTITY_FRONT;
155 glm::vec3 _up = IDENTITY_UP;150 glm::vec3 _up = IDENTITY_UP;
156 glm::vec3 _right = IDENTITY_RIGHT;151 glm::vec3 _right = IDENTITY_RIGHT;
157 152
153 // calculated from projection
154 glm::vec4 _corners[NUM_FRUSTUM_CORNERS];
155 glm::vec3 _cornersWorld[NUM_FRUSTUM_CORNERS];
158 float _centerSphereRadius = DEFAULT_CENTER_SPHERE_RADIUS;156 float _centerSphereRadius = DEFAULT_CENTER_SPHERE_RADIUS;
157 float _width { 1.0f };
158 float _height { 1.0f };
159 float _aspectRatio { 1.0f };
160 float _focalLength { 0.25f };
161 float _fieldOfView { DEFAULT_FIELD_OF_VIEW_DEGREES };
159 162
160 // Calculated values163 float _nearClip { DEFAULT_NEAR_CLIP };
161 glm::mat4 _inverseProjection;164 float _farClip { DEFAULT_FAR_CLIP };
162 float _width = 1.0f;
163 float _height = 1.0f;
164 float _aspectRatio = 1.0f;
165 float _nearClip = DEFAULT_NEAR_CLIP;
166 float _farClip = DEFAULT_FAR_CLIP;
167 float _focalLength = 0.25f;
168 float _fieldOfView = DEFAULT_FIELD_OF_VIEW_DEGREES;
169 glm::vec4 _corners[8];
170 glm::vec3 _cornersWorld[8];
171 ::Plane _planes[6]; // plane normals point inside frustum
172 165
173 const char* debugPlaneName (int plane) const;166 const char* debugPlaneName (int plane) const;
174 167
@@ -177,6 +170,4 @@ private: · 2 unmodified lines
177};170};
178using ViewFrustumPointer = std::shared_ptr<ViewFrustum>;171using ViewFrustumPointer = std::shared_ptr<ViewFrustum>;
179 172
180float boundaryDistanceForRenderLevel(unsigned int renderLevel, float voxelSizeScale);
181
182#endif // hifi_ViewFrustum_h173#endif // hifi_ViewFrustum_h