From 215efe3b786181ae2380b173375684e13271b3ba Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 25 Apr 2013 16:10:55 -0700 Subject: [PATCH] bunch of const changes for glm::vec3 in Avatar and Orientation --- interface/src/Avatar.cpp | 43 ++--------------------------- interface/src/Avatar.h | 12 ++++---- interface/src/Util.cpp | 6 ++-- libraries/avatars/src/Orientation.h | 14 +++++----- 4 files changed, 18 insertions(+), 57 deletions(-) diff --git a/interface/src/Avatar.cpp b/interface/src/Avatar.cpp index c79eb2ce2b..68c453e41a 100644 --- a/interface/src/Avatar.cpp +++ b/interface/src/Avatar.cpp @@ -557,11 +557,6 @@ float Avatar::getHeight() { return COLLISION_HEIGHT; } - -glm::vec3 Avatar::getBodyUpDirection() { - return _orientation.getUp(); -} - // This is a workspace for testing avatar body collision detection and response void Avatar::updateAvatarCollisionDetectionAndResponse(glm::vec3 collisionPosition, float collisionGirth, @@ -1028,49 +1023,15 @@ void Avatar::updateBodySprings( float deltaTime ) { } } -glm::vec3 Avatar::getHeadLookatDirection() { - return glm::vec3 - ( - _orientation.getFront().x, - _orientation.getFront().y, - _orientation.getFront().z - ); -} - -glm::vec3 Avatar::getHeadLookatDirectionUp() { - return glm::vec3 - ( - _orientation.getUp().x, - _orientation.getUp().y, - _orientation.getUp().z - ); -} - -glm::vec3 Avatar::getHeadLookatDirectionRight() { - return glm::vec3 - ( - _orientation.getRight().x, - _orientation.getRight().y, - _orientation.getRight().z - ); -} - -glm::vec3 Avatar::getHeadPosition() { +const glm::vec3& Avatar::getHeadPosition() const { - if ( _usingBodySprings ) { + if (_usingBodySprings) { return _bone[ AVATAR_BONE_HEAD ].springyPosition; } return _bone[ AVATAR_BONE_HEAD ].position; } - -glm::vec3 Avatar::getBonePosition( AvatarBoneID b ) { - return _bone[b].position; -} - - - void Avatar::updateHandMovement( float deltaTime ) { glm::vec3 transformedHandMovement; diff --git a/interface/src/Avatar.h b/interface/src/Avatar.h index 32d31184a8..46aad8ba53 100644 --- a/interface/src/Avatar.h +++ b/interface/src/Avatar.h @@ -178,12 +178,12 @@ class Avatar : public AvatarData { float getBodyYaw() {return _bodyYaw;}; void addBodyYaw(float y) {_bodyYaw += y;}; - glm::vec3 getHeadLookatDirection(); - glm::vec3 getHeadLookatDirectionUp(); - glm::vec3 getHeadLookatDirectionRight(); - glm::vec3 getHeadPosition(); - glm::vec3 getBonePosition( AvatarBoneID b ); - glm::vec3 getBodyUpDirection(); + const glm::vec3& getHeadLookatDirection() const { return _orientation.getFront(); }; + const glm::vec3& getHeadLookatDirectionUp() const { return _orientation.getUp(); }; + const glm::vec3& getHeadLookatDirectionRight() const { return _orientation.getRight(); }; + const glm::vec3& getHeadPosition() const ; + const glm::vec3& getBonePosition(AvatarBoneID b) const { return _bone[b].position; }; + const glm::vec3& getBodyUpDirection() const { return _orientation.getUp(); }; float getGirth(); float getHeight(); diff --git a/interface/src/Util.cpp b/interface/src/Util.cpp index 17f11cd64c..55b55b12eb 100644 --- a/interface/src/Util.cpp +++ b/interface/src/Util.cpp @@ -278,9 +278,9 @@ void drawGroundPlaneGrid( float size, int resolution ) void renderOrientationDirections( glm::vec3 position, Orientation orientation, float size ) { - glm::vec3 pRight = position + orientation.right * size; - glm::vec3 pUp = position + orientation.up * size; - glm::vec3 pFront = position + orientation.front * size; + glm::vec3 pRight = position + orientation.getRight() * size; + glm::vec3 pUp = position + orientation.getUp() * size; + glm::vec3 pFront = position + orientation.getFront() * size; glColor3f( 1.0f, 0.0f, 0.0f ); glBegin( GL_LINE_STRIP ); diff --git a/libraries/avatars/src/Orientation.h b/libraries/avatars/src/Orientation.h index 06425cf5dc..1b64230812 100755 --- a/libraries/avatars/src/Orientation.h +++ b/libraries/avatars/src/Orientation.h @@ -25,6 +25,10 @@ private: float _pitch; float _roll; + glm::vec3 right; + glm::vec3 up; + glm::vec3 front; + void update(); // actually updates the vectors from yaw, pitch, roll public: @@ -41,13 +45,9 @@ public: void set( Orientation ); void setToIdentity(); - glm::vec3 right; - glm::vec3 up; - glm::vec3 front; - - glm::vec3 getRight() { return right; } - glm::vec3 getUp() { return up; } - glm::vec3 getFront() { return front; } + const glm::vec3& getRight() const { return right; } + const glm::vec3& getUp() const { return up; } + const glm::vec3& getFront() const { return front; } void setRightUpFront( const glm::vec3 &, const glm::vec3 &, const glm::vec3 & );