mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-07-16 17:18:14 +02:00
move view frustum calculation into VoxelAgentData, added last known and current
This commit is contained in:
parent
fa37b88fa8
commit
2ff8da2b46
2 changed files with 14 additions and 11 deletions
|
@ -53,21 +53,21 @@ VoxelAgentData* VoxelAgentData::clone() const {
|
||||||
|
|
||||||
void VoxelAgentData::updateViewFrustum() {
|
void VoxelAgentData::updateViewFrustum() {
|
||||||
// save our currentViewFrustum into our lastKnownViewFrustum
|
// save our currentViewFrustum into our lastKnownViewFrustum
|
||||||
lastKnownViewFrustum = currentViewFrustum;
|
_lastKnownViewFrustum = _currentViewFrustum;
|
||||||
|
|
||||||
// get position and orientation details from the camera
|
// get position and orientation details from the camera
|
||||||
currentViewFrustum.setPosition(getCameraPosition());
|
_currentViewFrustum.setPosition(getCameraPosition());
|
||||||
currentViewFrustum.setOrientation(getCameraDirection(), getCameraUp(), getCameraRight());
|
_currentViewFrustum.setOrientation(getCameraDirection(), getCameraUp(), getCameraRight());
|
||||||
|
|
||||||
// Also make sure it's got the correct lens details from the camera
|
// Also make sure it's got the correct lens details from the camera
|
||||||
currentViewFrustum.setFieldOfView(getCameraFov());
|
_currentViewFrustum.setFieldOfView(getCameraFov());
|
||||||
currentViewFrustum.setAspectRatio(getCameraAspectRatio());
|
_currentViewFrustum.setAspectRatio(getCameraAspectRatio());
|
||||||
currentViewFrustum.setNearClip(getCameraNearClip());
|
_currentViewFrustum.setNearClip(getCameraNearClip());
|
||||||
currentViewFrustum.setFarClip(getCameraFarClip());
|
_currentViewFrustum.setFarClip(getCameraFarClip());
|
||||||
|
|
||||||
// if there has been a change, then recalculate
|
// if there has been a change, then recalculate
|
||||||
if (!lastKnownViewFrustum.matches(currentViewFrustum)) {
|
if (!_lastKnownViewFrustum.matches(_currentViewFrustum)) {
|
||||||
currentViewFrustum.calculate();
|
_currentViewFrustum.calculate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,8 +41,8 @@ public:
|
||||||
|
|
||||||
VoxelNodeBag nodeBag;
|
VoxelNodeBag nodeBag;
|
||||||
|
|
||||||
ViewFrustum currentViewFrustum;
|
ViewFrustum& getCurrentViewFrustum() { return _currentViewFrustum; };
|
||||||
ViewFrustum lastKnownViewFrustum;
|
ViewFrustum& getLastKnownViewFrustum() { return _lastKnownViewFrustum; };
|
||||||
|
|
||||||
void updateViewFrustum();
|
void updateViewFrustum();
|
||||||
|
|
||||||
|
@ -53,6 +53,9 @@ private:
|
||||||
bool _voxelPacketWaiting;
|
bool _voxelPacketWaiting;
|
||||||
int _maxSearchLevel;
|
int _maxSearchLevel;
|
||||||
int _maxLevelReachedInLastSearch;
|
int _maxLevelReachedInLastSearch;
|
||||||
|
ViewFrustum _currentViewFrustum;
|
||||||
|
ViewFrustum _lastKnownViewFrustum;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* defined(__hifi__VoxelAgentData__) */
|
#endif /* defined(__hifi__VoxelAgentData__) */
|
||||||
|
|
Loading…
Reference in a new issue