From 24d32bcdc82cf3f9d4e3b3f63c3c55e0e43d2b76 Mon Sep 17 00:00:00 2001 From: Mark Peng Date: Thu, 11 Jul 2013 10:40:57 -0700 Subject: [PATCH] Fix style mistakes according to code review for eyecontact code. --- interface/src/Application.cpp | 7 ++++--- interface/src/Application.h | 2 +- interface/src/Head.h | 4 ++-- interface/src/Util.cpp | 4 ++-- interface/src/Util.h | 2 +- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index c5ac0e5494..b7ed7a45ae 100755 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1734,14 +1734,15 @@ void Application::init() { const float MAX_AVATAR_EDIT_VELOCITY = 1.0f; const float MAX_VOXEL_EDIT_DISTANCE = 20.0f; +const float HEAD_SPHERE_RADIUS = 0.07; -bool Application::isLookingAtOtherAvatar(glm::vec3 &mouseRayOrigin, glm::vec3 &mouseRayDirection, glm::vec3 &eyePosition) { +bool Application::isLookingAtOtherAvatar(glm::vec3& mouseRayOrigin, glm::vec3& mouseRayDirection, glm::vec3& eyePosition) { NodeList* nodeList = NodeList::getInstance(); for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) { if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) { - Avatar *avatar = (Avatar *)node->getLinkedData(); + Avatar* avatar = (Avatar *) node->getLinkedData(); glm::vec3 headPosition = avatar->getHead().getPosition(); - if (rayIntersectsSphere(mouseRayOrigin, mouseRayDirection, headPosition, 0.07)) { + if (rayIntersectsSphere(mouseRayOrigin, mouseRayDirection, headPosition, HEAD_SPHERE_RADIUS)) { eyePosition = avatar->getHead().getEyeLevelPosition(); return true; } diff --git a/interface/src/Application.h b/interface/src/Application.h index d6386c8383..e6f0abecfa 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -181,7 +181,7 @@ private: void init(); void update(float deltaTime); - bool isLookingAtOtherAvatar(glm::vec3 &mouseRayOrigin, glm::vec3 &mouseRayDirection, glm::vec3 &eyePosition); + bool isLookingAtOtherAvatar(glm::vec3& mouseRayOrigin, glm::vec3& mouseRayDirection, glm::vec3& eyePosition); void updateAvatar(float deltaTime); void loadViewFrustum(Camera& camera, ViewFrustum& viewFrustum); diff --git a/interface/src/Head.h b/interface/src/Head.h index fce98826de..3cb41f81ec 100644 --- a/interface/src/Head.h +++ b/interface/src/Head.h @@ -53,8 +53,8 @@ public: glm::quat getOrientation() const; glm::quat getCameraOrientation () const; - glm::vec3 getPosition() const { return _position; } - glm::vec3 getEyeLevelPosition() const { return _eyeLevelPosition; } + glm::vec3 getPosition() const { return _position; } + const glm::vec3& getEyeLevelPosition() const { return _eyeLevelPosition; } glm::vec3 getRightDirection() const { return getOrientation() * IDENTITY_RIGHT; } glm::vec3 getUpDirection () const { return getOrientation() * IDENTITY_UP; } glm::vec3 getFrontDirection() const { return getOrientation() * IDENTITY_FRONT; } diff --git a/interface/src/Util.cpp b/interface/src/Util.cpp index 549cf49f98..65a277b623 100644 --- a/interface/src/Util.cpp +++ b/interface/src/Util.cpp @@ -538,10 +538,10 @@ float loadSetting(QSettings* settings, const char* name, float defaultValue) { return value; } -bool rayIntersectsSphere(glm::vec3 &rayStarting, glm::vec3 &rayNormalizedDirection, glm::vec3 &sphereCenter, double sphereRadius) { +bool rayIntersectsSphere(glm::vec3& rayStarting, glm::vec3& rayNormalizedDirection, glm::vec3& sphereCenter, double sphereRadius) { glm::vec3 vecFromRayToSphereCenter = sphereCenter - rayStarting; double projection = glm::dot(vecFromRayToSphereCenter, rayNormalizedDirection); - double shortestDistance = sqrt(glm::dot(vecFromRayToSphereCenter, vecFromRayToSphereCenter) - projection*projection); + double shortestDistance = sqrt(glm::dot(vecFromRayToSphereCenter, vecFromRayToSphereCenter) - projection * projection); if (shortestDistance <= sphereRadius) { return true; } diff --git a/interface/src/Util.h b/interface/src/Util.h index 6a4a25995c..37bd0595ec 100644 --- a/interface/src/Util.h +++ b/interface/src/Util.h @@ -71,6 +71,6 @@ void runTimingTests(); float loadSetting(QSettings* settings, const char* name, float defaultValue); -bool rayIntersectsSphere(glm::vec3 &rayStarting, glm::vec3 &rayNormalizedDirection, glm::vec3 &sphereCenter, double sphereRadius); +bool rayIntersectsSphere(glm::vec3& rayStarting, glm::vec3& rayNormalizedDirection, glm::vec3& sphereCenter, double sphereRadius); #endif