cleanup names that use "keyhole"

This commit is contained in:
Andrew Meadows 2016-02-23 10:12:22 -08:00
parent 9558258f64
commit 2591c5ee3e
9 changed files with 37 additions and 39 deletions

View file

@ -153,7 +153,7 @@ bool OctreeQueryNode::updateCurrentViewFrustum() {
newestViewFrustum.setPosition(getCameraPosition()); newestViewFrustum.setPosition(getCameraPosition());
newestViewFrustum.setOrientation(getCameraOrientation()); newestViewFrustum.setOrientation(getCameraOrientation());
newestViewFrustum.setKeyholeRadius(getKeyholeRadius()); newestViewFrustum.setCenterRadius(getCameraCenterRadius());
// 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
float originalFOV = getCameraFov(); float originalFOV = getCameraFov();

View file

@ -3387,7 +3387,7 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType, Node
_octreeQuery.setCameraNearClip(_viewFrustum.getNearClip()); _octreeQuery.setCameraNearClip(_viewFrustum.getNearClip());
_octreeQuery.setCameraFarClip(_viewFrustum.getFarClip()); _octreeQuery.setCameraFarClip(_viewFrustum.getFarClip());
_octreeQuery.setCameraEyeOffsetPosition(glm::vec3()); _octreeQuery.setCameraEyeOffsetPosition(glm::vec3());
_octreeQuery.setKeyholeRadius(_viewFrustum.getKeyholeRadius()); _octreeQuery.setCameraCenterRadius(_viewFrustum.getCenterRadius());
auto lodManager = DependencyManager::get<LODManager>(); auto lodManager = DependencyManager::get<LODManager>();
_octreeQuery.setOctreeSizeScale(lodManager->getOctreeSizeScale()); _octreeQuery.setOctreeSizeScale(lodManager->getOctreeSizeScale());
_octreeQuery.setBoundaryLevelAdjust(lodManager->getBoundaryLevelAdjust()); _octreeQuery.setBoundaryLevelAdjust(lodManager->getBoundaryLevelAdjust());

View file

@ -52,7 +52,7 @@ void OctreeHeadlessViewer::queryOctree() {
_octreeQuery.setCameraNearClip(_viewFrustum.getNearClip()); _octreeQuery.setCameraNearClip(_viewFrustum.getNearClip());
_octreeQuery.setCameraFarClip(_viewFrustum.getFarClip()); _octreeQuery.setCameraFarClip(_viewFrustum.getFarClip());
_octreeQuery.setCameraEyeOffsetPosition(glm::vec3()); _octreeQuery.setCameraEyeOffsetPosition(glm::vec3());
_octreeQuery.setKeyholeRadius(_viewFrustum.getKeyholeRadius()); _octreeQuery.setCameraCenterRadius(_viewFrustum.getCenterRadius());
_octreeQuery.setOctreeSizeScale(_voxelSizeScale); _octreeQuery.setOctreeSizeScale(_voxelSizeScale);
_octreeQuery.setBoundaryLevelAdjust(_boundaryLevelAdjust); _octreeQuery.setBoundaryLevelAdjust(_boundaryLevelAdjust);

View file

@ -46,7 +46,7 @@ public slots:
// setters for camera attributes // setters for camera attributes
void setPosition(const glm::vec3& position) { _viewFrustum.setPosition(position); } void setPosition(const glm::vec3& position) { _viewFrustum.setPosition(position); }
void setOrientation(const glm::quat& orientation) { _viewFrustum.setOrientation(orientation); } void setOrientation(const glm::quat& orientation) { _viewFrustum.setOrientation(orientation); }
void setKeyholeRadius(float keyholdRadius) { _viewFrustum.setKeyholeRadius(keyholdRadius); } void setCenterRadius(float radius) { _viewFrustum.setCenterRadius(radius); }
// setters for LOD and PPS // setters for LOD and PPS
void setVoxelSizeScale(float sizeScale) { _voxelSizeScale = sizeScale; } void setVoxelSizeScale(float sizeScale) { _voxelSizeScale = sizeScale; }

View file

@ -64,8 +64,8 @@ int OctreeQuery::getBroadcastData(unsigned char* destinationBuffer) {
memcpy(destinationBuffer, &_boundaryLevelAdjust, sizeof(_boundaryLevelAdjust)); memcpy(destinationBuffer, &_boundaryLevelAdjust, sizeof(_boundaryLevelAdjust));
destinationBuffer += sizeof(_boundaryLevelAdjust); destinationBuffer += sizeof(_boundaryLevelAdjust);
memcpy(destinationBuffer, &_keyholeRadius, sizeof(_keyholeRadius)); memcpy(destinationBuffer, &_cameraCenterRadius, sizeof(_cameraCenterRadius));
destinationBuffer += sizeof(_keyholeRadius); destinationBuffer += sizeof(_cameraCenterRadius);
return destinationBuffer - bufferStart; return destinationBuffer - bufferStart;
} }
@ -109,9 +109,9 @@ int OctreeQuery::parseData(ReceivedMessage& message) {
auto bytesRead = sourceBuffer - startPosition; auto bytesRead = sourceBuffer - startPosition;
auto bytesLeft = message.getSize() - bytesRead; auto bytesLeft = message.getSize() - bytesRead;
if (bytesLeft >= (int)sizeof(_keyholeRadius)) { if (bytesLeft >= (int)sizeof(_cameraCenterRadius)) {
memcpy(&_keyholeRadius, sourceBuffer, sizeof(_keyholeRadius)); memcpy(&_cameraCenterRadius, sourceBuffer, sizeof(_cameraCenterRadius));
sourceBuffer += sizeof(_keyholeRadius); sourceBuffer += sizeof(_cameraCenterRadius);
} }
return sourceBuffer - startPosition; return sourceBuffer - startPosition;
} }

View file

@ -58,7 +58,7 @@ public:
float getCameraNearClip() const { return _cameraNearClip; } float getCameraNearClip() const { return _cameraNearClip; }
float getCameraFarClip() const { return _cameraFarClip; } float getCameraFarClip() const { return _cameraFarClip; }
const glm::vec3& getCameraEyeOffsetPosition() const { return _cameraEyeOffsetPosition; } const glm::vec3& getCameraEyeOffsetPosition() const { return _cameraEyeOffsetPosition; }
float getKeyholeRadius() const { return _keyholeRadius; } float getCameraCenterRadius() const { return _cameraCenterRadius; }
glm::vec3 calculateCameraDirection() const; glm::vec3 calculateCameraDirection() const;
@ -70,7 +70,7 @@ public:
void setCameraNearClip(float nearClip) { _cameraNearClip = nearClip; } void setCameraNearClip(float nearClip) { _cameraNearClip = nearClip; }
void setCameraFarClip(float farClip) { _cameraFarClip = farClip; } void setCameraFarClip(float farClip) { _cameraFarClip = farClip; }
void setCameraEyeOffsetPosition(const glm::vec3& eyeOffsetPosition) { _cameraEyeOffsetPosition = eyeOffsetPosition; } void setCameraEyeOffsetPosition(const glm::vec3& eyeOffsetPosition) { _cameraEyeOffsetPosition = eyeOffsetPosition; }
void setKeyholeRadius(float keyholeRadius) { _keyholeRadius = keyholeRadius; } void setCameraCenterRadius(float radius) { _cameraCenterRadius = radius; }
// related to Octree Sending strategies // related to Octree Sending strategies
int getMaxQueryPacketsPerSecond() const { return _maxQueryPPS; } int getMaxQueryPacketsPerSecond() const { return _maxQueryPPS; }
@ -90,7 +90,7 @@ protected:
float _cameraAspectRatio = 1.0f; float _cameraAspectRatio = 1.0f;
float _cameraNearClip = 0.0f; float _cameraNearClip = 0.0f;
float _cameraFarClip = 0.0f; float _cameraFarClip = 0.0f;
float _keyholeRadius { 0.0f }; float _cameraCenterRadius { 0.0f };
glm::vec3 _cameraEyeOffsetPosition = glm::vec3(0.0f); glm::vec3 _cameraEyeOffsetPosition = glm::vec3(0.0f);
// octree server sending items // octree server sending items

View file

@ -115,10 +115,6 @@ void ViewFrustum::calculate() {
// Our ModelViewProjection : multiplication of our 3 matrices (note: model is identity, so we can drop it) // Our ModelViewProjection : multiplication of our 3 matrices (note: model is identity, so we can drop it)
_ourModelViewProjectionMatrix = _projection * view; // Remember, matrix multiplication is the other way around _ourModelViewProjectionMatrix = _projection * view; // Remember, matrix multiplication is the other way around
// Set up our keyhole bounding box...
glm::vec3 corner = _position - _keyholeRadius;
_keyholeBoundingCube = AACube(corner,(_keyholeRadius * 2.0f));
} }
//enum { TOP_PLANE = 0, BOTTOM_PLANE, LEFT_PLANE, RIGHT_PLANE, NEAR_PLANE, FAR_PLANE }; //enum { TOP_PLANE = 0, BOTTOM_PLANE, LEFT_PLANE, RIGHT_PLANE, NEAR_PLANE, FAR_PLANE };
@ -207,14 +203,14 @@ ViewFrustum::location ViewFrustum::cubeInKeyhole(const AACube& cube) const {
float distance = glm::length(cubeOffset); float distance = glm::length(cubeOffset);
if (distance > EPSILON) { if (distance > EPSILON) {
glm::vec3 vertex = cube.getFarthestVertex(cubeOffset) - _position; glm::vec3 vertex = cube.getFarthestVertex(cubeOffset) - _position;
if (glm::dot(vertex, cubeOffset) < _keyholeRadius * distance) { if (glm::dot(vertex, cubeOffset) < _centerSphereRadius * distance) {
// the most outward cube vertex is inside central sphere // the most outward cube vertex is inside central sphere
return INSIDE; return INSIDE;
} }
if (!cube.touchesSphere(_position, _keyholeRadius)) { if (!cube.touchesSphere(_position, _centerSphereRadius)) {
sphereResult = OUTSIDE; sphereResult = OUTSIDE;
} }
} else if (_keyholeRadius > HALF_SQRT_THREE * cube.getScale()) { } else if (_centerSphereRadius > HALF_SQRT_THREE * cube.getScale()) {
// the cube is in center of sphere and its bounding radius is inside // the cube is in center of sphere and its bounding radius is inside
return INSIDE; return INSIDE;
} }
@ -227,7 +223,7 @@ ViewFrustum::location ViewFrustum::cubeInKeyhole(const AACube& cube) const {
bool ViewFrustum::sphereTouchesKeyhole(const glm::vec3& center, float radius) const { bool ViewFrustum::sphereTouchesKeyhole(const glm::vec3& center, float radius) const {
// check positive touch against central sphere // check positive touch against central sphere
if (glm::length(center - _position) <= (radius + _keyholeRadius)) { if (glm::length(center - _position) <= (radius + _centerSphereRadius)) {
return true; return true;
} }
// check negative touches against frustum planes // check negative touches against frustum planes
@ -241,7 +237,7 @@ bool ViewFrustum::sphereTouchesKeyhole(const glm::vec3& center, float radius) co
bool ViewFrustum::cubeTouchesKeyhole(const AACube& cube) const { bool ViewFrustum::cubeTouchesKeyhole(const AACube& cube) const {
// check positive touch against central sphere // check positive touch against central sphere
if (cube.touchesSphere(_position, _keyholeRadius)) { if (cube.touchesSphere(_position, _centerSphereRadius)) {
return true; return true;
} }
// check negative touches against frustum planes // check negative touches against frustum planes
@ -256,7 +252,7 @@ bool ViewFrustum::cubeTouchesKeyhole(const AACube& cube) const {
bool ViewFrustum::boxTouchesKeyhole(const AABox& box) const { bool ViewFrustum::boxTouchesKeyhole(const AABox& box) const {
// check positive touch against central sphere // check positive touch against central sphere
if (box.touchesSphere(_position, _keyholeRadius)) { if (box.touchesSphere(_position, _centerSphereRadius)) {
return true; return true;
} }
// check negative touches against frustum planes // check negative touches against frustum planes
@ -448,7 +444,7 @@ void ViewFrustum::printDebugDetails() const {
qCDebug(octree, "_right=%f,%f,%f", (double)_right.x, (double)_right.y, (double)_right.z ); qCDebug(octree, "_right=%f,%f,%f", (double)_right.x, (double)_right.y, (double)_right.z );
qCDebug(octree, "_fieldOfView=%f", (double)_fieldOfView); qCDebug(octree, "_fieldOfView=%f", (double)_fieldOfView);
qCDebug(octree, "_aspectRatio=%f", (double)_aspectRatio); qCDebug(octree, "_aspectRatio=%f", (double)_aspectRatio);
qCDebug(octree, "_keyHoleRadius=%f", (double)_keyholeRadius); qCDebug(octree, "_centerSphereRadius=%f", (double)_centerSphereRadius);
qCDebug(octree, "_nearClip=%f", (double)_nearClip); qCDebug(octree, "_nearClip=%f", (double)_nearClip);
qCDebug(octree, "_farClip=%f", (double)_farClip); qCDebug(octree, "_farClip=%f", (double)_farClip);
qCDebug(octree, "_focalLength=%f", (double)_focalLength); qCDebug(octree, "_focalLength=%f", (double)_focalLength);

View file

@ -27,12 +27,15 @@
#include "OctreeConstants.h" #include "OctreeConstants.h"
#include "OctreeProjectedPolygon.h" #include "OctreeProjectedPolygon.h"
const float DEFAULT_KEYHOLE_RADIUS = 3.0f; const float DEFAULT_CENTER_SPHERE_RADIUS = 3.0f;
const float DEFAULT_FIELD_OF_VIEW_DEGREES = 45.0f; const float DEFAULT_FIELD_OF_VIEW_DEGREES = 45.0f;
const float DEFAULT_ASPECT_RATIO = 16.0f/9.0f; const float DEFAULT_ASPECT_RATIO = 16.0f/9.0f;
const float DEFAULT_NEAR_CLIP = 0.08f; const float DEFAULT_NEAR_CLIP = 0.08f;
const float DEFAULT_FAR_CLIP = (float)HALF_TREE_SCALE; const float DEFAULT_FAR_CLIP = (float)HALF_TREE_SCALE;
// the "ViewFrustum" has a "keyhole" shape: a regular frustum for stuff that is "visible" with
// a central sphere for stuff that is nearby (for physics simulation).
class ViewFrustum { class ViewFrustum {
public: public:
// setters for camera attributes // setters for camera attributes
@ -83,9 +86,9 @@ public:
const glm::vec3& getNearBottomLeft() const { return _cornersWorld[BOTTOM_LEFT_NEAR]; } const glm::vec3& getNearBottomLeft() const { return _cornersWorld[BOTTOM_LEFT_NEAR]; }
const glm::vec3& getNearBottomRight() const { return _cornersWorld[BOTTOM_RIGHT_NEAR]; } const glm::vec3& getNearBottomRight() const { return _cornersWorld[BOTTOM_RIGHT_NEAR]; }
// get/set for keyhole attribute // get/set for central spherek attribute
void setKeyholeRadius(float keyholdRadius) { _keyholeRadius = keyholdRadius; } void setCenterRadius(float radius) { _centerSphereRadius = radius; }
float getKeyholeRadius() const { return _keyholeRadius; } float getCenterRadius() const { return _centerSphereRadius; }
void calculate(); void calculate();
@ -96,6 +99,7 @@ public:
ViewFrustum::location cubeInFrustum(const AACube& cube) const; ViewFrustum::location cubeInFrustum(const AACube& cube) const;
ViewFrustum::location boxInFrustum(const AABox& box) const; ViewFrustum::location boxInFrustum(const AABox& box) const;
/// @return INSIDE, INTERSECT, or OUTSIDE depending on how cube intersects the keyhole shape
ViewFrustum::location cubeInKeyhole(const AACube& cube) const; ViewFrustum::location cubeInKeyhole(const AACube& cube) const;
// more efficient methods when only need boolean result // more efficient methods when only need boolean result
@ -151,9 +155,7 @@ private:
glm::vec3 _up = IDENTITY_UP; glm::vec3 _up = IDENTITY_UP;
glm::vec3 _right = IDENTITY_RIGHT; glm::vec3 _right = IDENTITY_RIGHT;
// keyhole attributes float _centerSphereRadius = DEFAULT_CENTER_SPHERE_RADIUS;
float _keyholeRadius = DEFAULT_KEYHOLE_RADIUS;
AACube _keyholeBoundingCube;
// Calculated values // Calculated values
glm::mat4 _inverseProjection; glm::mat4 _inverseProjection;

View file

@ -50,7 +50,7 @@ void ViewFrustumTests::testInit() {
view.setProjection(glm::perspective(fovX, aspect, nearClip, farClip)); view.setProjection(glm::perspective(fovX, aspect, nearClip, farClip));
view.setPosition(center); view.setPosition(center);
view.setOrientation(rotation); view.setOrientation(rotation);
view.setKeyholeRadius(holeRadius); view.setCenterRadius(holeRadius);
view.calculate(); view.calculate();
// check frustum dimensions // check frustum dimensions
@ -96,7 +96,7 @@ void ViewFrustumTests::testPointInFrustum() {
view.setProjection(glm::perspective(fovX, aspect, nearClip, farClip)); view.setProjection(glm::perspective(fovX, aspect, nearClip, farClip));
view.setPosition(center); view.setPosition(center);
view.setOrientation(rotation); view.setOrientation(rotation);
view.setKeyholeRadius(holeRadius); view.setCenterRadius(holeRadius);
view.calculate(); view.calculate();
float delta = 0.1f; float delta = 0.1f;
@ -190,7 +190,7 @@ void ViewFrustumTests::testSphereInFrustum() {
view.setProjection(glm::perspective(fovX, aspect, nearClip, farClip)); view.setProjection(glm::perspective(fovX, aspect, nearClip, farClip));
view.setPosition(center); view.setPosition(center);
view.setOrientation(rotation); view.setOrientation(rotation);
view.setKeyholeRadius(holeRadius); view.setCenterRadius(holeRadius);
view.calculate(); view.calculate();
float delta = 0.1f; float delta = 0.1f;
@ -319,7 +319,7 @@ void ViewFrustumTests::testCubeInFrustum() {
view.setProjection(glm::perspective(fovX, aspect, nearClip, farClip)); view.setProjection(glm::perspective(fovX, aspect, nearClip, farClip));
view.setPosition(center); view.setPosition(center);
view.setOrientation(rotation); view.setOrientation(rotation);
view.setKeyholeRadius(holeRadius); view.setCenterRadius(holeRadius);
view.calculate(); view.calculate();
float delta = 0.1f; float delta = 0.1f;
@ -465,7 +465,7 @@ void ViewFrustumTests::testBoxInFrustum() {
view.setProjection(glm::perspective(fovX, aspect, nearClip, farClip)); view.setProjection(glm::perspective(fovX, aspect, nearClip, farClip));
view.setPosition(center); view.setPosition(center);
view.setOrientation(rotation); view.setOrientation(rotation);
view.setKeyholeRadius(holeRadius); view.setCenterRadius(holeRadius);
view.calculate(); view.calculate();
float delta = 0.1f; float delta = 0.1f;
@ -610,7 +610,7 @@ void ViewFrustumTests::testCubeInKeyhole() {
view.setProjection(glm::perspective(fovX, aspect, nearClip, farClip)); view.setProjection(glm::perspective(fovX, aspect, nearClip, farClip));
view.setPosition(center); view.setPosition(center);
view.setOrientation(rotation); view.setOrientation(rotation);
view.setKeyholeRadius(holeRadius); view.setCenterRadius(holeRadius);
view.calculate(); view.calculate();
float delta = 0.1f; float delta = 0.1f;
@ -808,7 +808,7 @@ void ViewFrustumTests::testSphereTouchesKeyhole() {
view.setProjection(glm::perspective(fovX, aspect, nearClip, farClip)); view.setProjection(glm::perspective(fovX, aspect, nearClip, farClip));
view.setPosition(center); view.setPosition(center);
view.setOrientation(rotation); view.setOrientation(rotation);
view.setKeyholeRadius(holeRadius); view.setCenterRadius(holeRadius);
view.calculate(); view.calculate();
float delta = 0.1f; float delta = 0.1f;
@ -976,7 +976,7 @@ void ViewFrustumTests::testCubeTouchesKeyhole() {
view.setProjection(glm::perspective(fovX, aspect, nearClip, farClip)); view.setProjection(glm::perspective(fovX, aspect, nearClip, farClip));
view.setPosition(center); view.setPosition(center);
view.setOrientation(rotation); view.setOrientation(rotation);
view.setKeyholeRadius(holeRadius); view.setCenterRadius(holeRadius);
view.calculate(); view.calculate();
float delta = 0.1f; float delta = 0.1f;
@ -1170,7 +1170,7 @@ void ViewFrustumTests::testBoxTouchesKeyhole() {
view.setProjection(glm::perspective(fovX, aspect, nearClip, farClip)); view.setProjection(glm::perspective(fovX, aspect, nearClip, farClip));
view.setPosition(center); view.setPosition(center);
view.setOrientation(rotation); view.setOrientation(rotation);
view.setKeyholeRadius(holeRadius); view.setCenterRadius(holeRadius);
view.calculate(); view.calculate();
float delta = 0.1f; float delta = 0.1f;