From 7e0dab622498e09548564988fb9d5fee63963245 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 25 Apr 2013 16:18:17 -0700 Subject: [PATCH] spacing fixes in Avatar class --- interface/src/Avatar.cpp | 25 ++--- interface/src/Avatar.h | 200 +++++++++++++++++++-------------------- 2 files changed, 107 insertions(+), 118 deletions(-) diff --git a/interface/src/Avatar.cpp b/interface/src/Avatar.cpp index 68c453e41a..a12aefe8fc 100644 --- a/interface/src/Avatar.cpp +++ b/interface/src/Avatar.cpp @@ -357,28 +357,21 @@ void Avatar::simulate(float deltaTime) { _interactingOther = NULL; } - if ( usingBigSphereCollisionTest ) { - + if (usingBigSphereCollisionTest) { // test for avatar collision response (using a big sphere :) - updateAvatarCollisionDetectionAndResponse - ( - _TEST_bigSpherePosition, - _TEST_bigSphereRadius, - _TEST_bigSphereRadius, - glm::vec3( 0.0, 1.0, 0.0 ), - deltaTime - ); + updateAvatarCollisionDetectionAndResponse(_TEST_bigSpherePosition, + _TEST_bigSphereRadius, + _TEST_bigSphereRadius, + glm::vec3( 0.0, 1.0, 0.0 ), + deltaTime); } if ( AVATAR_GRAVITY ) { if ( _position.y > _bone[ AVATAR_BONE_RIGHT_FOOT ].radius * 2.0 ) { _velocity += glm::dvec3( 0.0, -1.0, 0.0 ) * ( 6.0 * deltaTime ); - } - else { - if ( _position.y < _bone[ AVATAR_BONE_RIGHT_FOOT ].radius ) { - _position.y = _bone[ AVATAR_BONE_RIGHT_FOOT ].radius; - _velocity.y = 0.0; - } + } else if ( _position.y < _bone[ AVATAR_BONE_RIGHT_FOOT ].radius ) { + _position.y = _bone[ AVATAR_BONE_RIGHT_FOOT ].radius; + _velocity.y = 0.0; } } diff --git a/interface/src/Avatar.h b/interface/src/Avatar.h index 46aad8ba53..8b3f79dd89 100644 --- a/interface/src/Avatar.h +++ b/interface/src/Avatar.h @@ -157,112 +157,108 @@ struct AvatarHead class Avatar : public AvatarData { - public: - Avatar(bool isMine); - ~Avatar(); - Avatar(const Avatar &otherAvatar); - Avatar* clone() const; +public: + Avatar(bool isMine); + ~Avatar(); + Avatar(const Avatar &otherAvatar); + Avatar* clone() const; + + void reset(); + void UpdateGyros(float frametime, SerialInterface * serialInterface, glm::vec3 * gravity); + void setNoise (float mag) { _head.noise = mag; } + void setScale(float s) {_head.scale = s; }; + void setRenderYaw(float y) {_renderYaw = y;} + void setRenderPitch(float p) {_renderPitch = p;} + float getRenderYaw() {return _renderYaw;} + float getRenderPitch() {return _renderPitch;} + void setLeanForward(float dist); + void setLeanSideways(float dist); + void addLean(float x, float z); + float getLastMeasuredHeadYaw() const {return _head.yawRate;} + float getBodyYaw() {return _bodyYaw;}; + void addBodyYaw(float y) {_bodyYaw += y;}; + + 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(); - void reset(); - void UpdateGyros(float frametime, SerialInterface * serialInterface, glm::vec3 * gravity); - void setNoise (float mag) { _head.noise = mag; } - void setScale(float s) {_head.scale = s; }; - void setRenderYaw(float y) {_renderYaw = y;} - void setRenderPitch(float p) {_renderPitch = p;} - float getRenderYaw() {return _renderYaw;} - float getRenderPitch() {return _renderPitch;} - void setLeanForward(float dist); - void setLeanSideways(float dist); - void addLean(float x, float z); - float getLastMeasuredHeadYaw() const {return _head.yawRate;} - float getBodyYaw() {return _bodyYaw;}; - void addBodyYaw(float y) {_bodyYaw += y;}; + AvatarMode getMode(); - 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(); - - AvatarMode getMode(); - - void setMousePressed( bool pressed ); - void render(bool lookingInMirror); - void renderBody(); - void renderHead(bool lookingInMirror); - void simulate(float); - void startHandMovement(); - void stopHandMovement(); - void setHandMovementValues( glm::vec3 movement ); - void updateHandMovement( float deltaTime ); - void updateArmIKAndConstraints( float deltaTime ); - - float getAverageLoudness() {return _head.averageLoudness;}; - void setAverageLoudness(float al) {_head.averageLoudness = al;}; - - void SetNewHeadTarget(float, float); + void setMousePressed( bool pressed ); + void render(bool lookingInMirror); + void renderBody(); + void renderHead(bool lookingInMirror); + void simulate(float); + void startHandMovement(); + void stopHandMovement(); + void setHandMovementValues( glm::vec3 movement ); + void updateHandMovement( float deltaTime ); + void updateArmIKAndConstraints( float deltaTime ); - // Set what driving keys are being pressed to control thrust levels - void setDriveKeys(int key, bool val) { _driveKeys[key] = val; }; - bool getDriveKeys(int key) { return _driveKeys[key]; }; + float getAverageLoudness() {return _head.averageLoudness;}; + void setAverageLoudness(float al) {_head.averageLoudness = al;}; + + void SetNewHeadTarget(float, float); + + // Set what driving keys are being pressed to control thrust levels + void setDriveKeys(int key, bool val) { _driveKeys[key] = val; }; + bool getDriveKeys(int key) { return _driveKeys[key]; }; + + // Set/Get update the thrust that will move the avatar around + void setThrust(glm::vec3 newThrust) { _thrust = newThrust; }; + void addThrust(glm::vec3 newThrust) { _thrust += newThrust; }; + glm::vec3 getThrust() { return _thrust; }; + + // Related to getting transmitter UDP data used to animate the avatar hand + void processTransmitterData(unsigned char * packetData, int numBytes); + float getTransmitterHz() { return _transmitterHz; }; + +private: + AvatarHead _head; + bool _isMine; + glm::vec3 _TEST_bigSpherePosition; + float _TEST_bigSphereRadius; + bool _mousePressed; + float _bodyYawDelta; + bool _usingBodySprings; + glm::vec3 _movedHandOffset; + float _springVelocityDecay; + float _springForce; + glm::quat _rotation; // the rotation of the avatar body as a whole expressed as a quaternion + AvatarBone _bone[ NUM_AVATAR_BONES ]; + AvatarMode _mode; + AvatarHandHolding _handHolding; + glm::dvec3 _velocity; + glm::vec3 _thrust; + float _maxArmLength; + Orientation _orientation; + int _driveKeys[MAX_DRIVE_KEYS]; + GLUquadric* _sphere; + float _renderYaw; + float _renderPitch; // Pitch from view frustum when this is own head + timeval _transmitterTimer; + float _transmitterHz; + int _transmitterPackets; + Avatar* _interactingOther; + bool _interactingOtherIsNearby; - // Set/Get update the thrust that will move the avatar around - void setThrust(glm::vec3 newThrust) { _thrust = newThrust; }; - void addThrust(glm::vec3 newThrust) { _thrust += newThrust; }; - glm::vec3 getThrust() { return _thrust; }; - - // Related to getting transmitter UDP data used to animate the avatar hand - void processTransmitterData(unsigned char * packetData, int numBytes); - float getTransmitterHz() { return _transmitterHz; }; - - private: - AvatarHead _head; - bool _isMine; - glm::vec3 _TEST_bigSpherePosition; - float _TEST_bigSphereRadius; - bool _mousePressed; - float _bodyYawDelta; - bool _usingBodySprings; - glm::vec3 _movedHandOffset; - float _springVelocityDecay; - float _springForce; - glm::quat _rotation; // the rotation of the avatar body as a whole expressed as a quaternion - AvatarBone _bone[ NUM_AVATAR_BONES ]; - AvatarMode _mode; - AvatarHandHolding _handHolding; - glm::dvec3 _velocity; - glm::vec3 _thrust; - float _maxArmLength; - Orientation _orientation; - int _driveKeys[MAX_DRIVE_KEYS]; - GLUquadric* _sphere; - float _renderYaw; - float _renderPitch; // Pitch from view frustum when this is own head - timeval _transmitterTimer; - float _transmitterHz; - int _transmitterPackets; - Avatar* _interactingOther; - bool _interactingOtherIsNearby; - - // private methods... - void initializeSkeleton(); - void updateSkeleton(); - void initializeBodySprings(); - void updateBodySprings( float deltaTime ); - void calculateBoneLengths(); - void readSensors(); - void renderBoneAsBlock( AvatarBoneID b ); - void updateAvatarCollisionDetectionAndResponse - ( - glm::vec3 collisionPosition, - float collisionGirth, - float collisionHeight, - glm::vec3 collisionUpVector, - float deltaTime - ); + void initializeSkeleton(); + void updateSkeleton(); + void initializeBodySprings(); + void updateBodySprings( float deltaTime ); + void calculateBoneLengths(); + void readSensors(); + void renderBoneAsBlock( AvatarBoneID b ); + void updateAvatarCollisionDetectionAndResponse(glm::vec3 collisionPosition, + float collisionGirth, + float collisionHeight, + glm::vec3 collisionUpVector, + float deltaTime); }; #endif