Fix style mistakes according to code review for eyecontact code.

This commit is contained in:
Mark Peng 2013-07-11 10:40:57 -07:00
parent 29d1e08f48
commit 24d32bcdc8
5 changed files with 10 additions and 9 deletions

View file

@ -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;
}

View file

@ -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);

View file

@ -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; }

View file

@ -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;
}

View file

@ -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