code review comments, cleanup Avatar constructor

This commit is contained in:
Stephen Birarda 2013-05-20 16:12:38 -07:00
parent de84b7803f
commit 570dfba934
5 changed files with 54 additions and 86 deletions

View file

@ -1356,22 +1356,6 @@ void Application::updateAvatar(float deltaTime) {
_headMouseY = max(_headMouseY, 0);
_headMouseY = min(_headMouseY, _glWidget->height());
// Update head and body pitch and yaw based on measured gyro rates
if (_gyroLook->isChecked()) {
// Render Yaw
/* NOTE: PER - Leave here until I get back and can modify to couple gyros to head pitch, yaw
float renderYawSpring = fabs(_headMouseX - _glWidget->width() / 2.f) / (_glWidget->width() / 2.f);
const float RENDER_YAW_MULTIPLY = 4.f;
_myAvatar.setRenderYaw((1.f - renderYawSpring * deltaTime) * _myAvatar.getRenderYaw() +
renderYawSpring * deltaTime * -_myAvatar.getHeadYaw() * RENDER_YAW_MULTIPLY);
// Render Pitch
float renderPitchSpring = fabs(_headMouseY - _glWidget->height() / 2.f) / (_glWidget->height() / 2.f);
const float RENDER_PITCH_MULTIPLY = 4.f;
_myAvatar.setRenderPitch((1.f - renderPitchSpring * deltaTime) * _myAvatar.getRenderPitch() +
renderPitchSpring * deltaTime * -_myAvatar.getHeadPitch() * RENDER_PITCH_MULTIPLY);
*/
}
if (OculusManager::isConnected()) {
float yaw, pitch, roll;
OculusManager::getEulerAngles(yaw, pitch, roll);

View file

@ -59,61 +59,62 @@ bool usingBigSphereCollisionTest = true;
float chatMessageScale = 0.0015;
float chatMessageHeight = 0.45;
Avatar::Avatar(bool isMine) : _head() {
Avatar::Avatar(bool isMine) :
_isMine(isMine),
_TEST_bigSphereRadius(0.4f),
_TEST_bigSpherePosition(5.0f, _TEST_bigSphereRadius, 5.0f),
_mousePressed(false),
_bodyPitchDelta(0.0f),
_bodyYawDelta(0.0f),
_bodyRollDelta(0.0f),
_movedHandOffset(0.0f, 0.0f, 0.0f),
_rotation(0.0f, 0.0f, 0.0f, 0.0f),
_mode(AVATAR_MODE_STANDING),
_handHoldingPosition(0.0f, 0.0f, 0.0f),
_velocity(0.0f, 0.0f, 0.0f),
_thrust(0.0f, 0.0f, 0.0f),
_speed(0.0f),
_maxArmLength(0.0f),
_orientation(),
_transmitterIsFirstData(true),
_transmitterHz(0.0f),
_transmitterPackets(0),
_transmitterInitialReading(0.0f, 0.0f, 0.0f),
_isTransmitterV2Connected(false),
_pelvisStandingHeight(0.0f),
_displayingHead(true),
_distanceToNearestAvatar(std::numeric_limits<float>::max()),
_gravity(0.0f, -1.0f, 0.0f),
_mouseRayOrigin(0.0f, 0.0f, 0.0f),
_mouseRayDirection(0.0f, 0.0f, 0.0f),
_cameraPosition(0.0f, 0.0f, 0.0f),
_interactingOther(NULL),
_cumulativeMouseYaw(0.0f),
_isMouseTurningRight(false)
{
// give the pointer to our head to inherited _headData variable from AvatarData
_headData = &_head;
_orientation.setToIdentity();
_velocity = glm::vec3(0.0f, 0.0f, 0.0f);
_thrust = glm::vec3(0.0f, 0.0f, 0.0f);
_rotation = glm::quat(0.0f, 0.0f, 0.0f, 0.0f);
_bodyYaw = -90.0;
_bodyPitch = 0.0;
_bodyRoll = 0.0;
_bodyPitchDelta = 0.0;
_bodyYawDelta = 0.0;
_bodyRollDelta = 0.0;
_mousePressed = false;
_mode = AVATAR_MODE_STANDING;
_isMine = isMine;
_maxArmLength = 0.0;
_transmitterHz = 0.0;
_transmitterPackets = 0;
_transmitterIsFirstData = true;
_transmitterInitialReading = glm::vec3(0.f, 0.f, 0.f);
_isTransmitterV2Connected = false;
_speed = 0.0;
_pelvisStandingHeight = 0.0f;
_displayingHead = true;
_TEST_bigSphereRadius = 0.4f;
_TEST_bigSpherePosition = glm::vec3(5.0f, _TEST_bigSphereRadius, 5.0f);
_mouseRayOrigin = glm::vec3(0.0f, 0.0f, 0.0f);
_mouseRayDirection = glm::vec3(0.0f, 0.0f, 0.0f);
_cameraPosition = glm::vec3(0.0f, 0.0f, 0.0f);
_interactingOther = NULL;
for (int i = 0; i < MAX_DRIVE_KEYS; i++) _driveKeys[i] = false;
_movedHandOffset = glm::vec3(0.0f, 0.0f, 0.0f);
_handHoldingPosition = glm::vec3(0.0f, 0.0f, 0.0f);
_distanceToNearestAvatar = std::numeric_limits<float>::max();
_gravity = glm::vec3(0.0f, -1.0f, 0.0f);
_cumulativeMouseYaw = 0.f;
_isMouseTurningRight = false;
for (int i = 0; i < MAX_DRIVE_KEYS; i++) {
_driveKeys[i] = false;
}
initializeSkeleton();
_avatarTouch.setReachableRadius(PERIPERSONAL_RADIUS);
if (BALLS_ON) { _balls = new Balls(100); }
else { _balls = NULL; }
if (BALLS_ON) {
_balls = new Balls(100);
} else {
_balls = NULL;
}
}
Avatar::~Avatar() {
// if _balls is something that's sticking around other than Philip playing around it needs to be delete here too
_headData = NULL;
delete _balls;
}
void Avatar::reset() {

View file

@ -165,8 +165,8 @@ private:
Head _head;
bool _isMine;
glm::vec3 _TEST_bigSpherePosition;
float _TEST_bigSphereRadius;
glm::vec3 _TEST_bigSpherePosition;
bool _mousePressed;
float _bodyPitchDelta;
float _bodyYawDelta;
@ -182,8 +182,6 @@ private:
float _maxArmLength;
Orientation _orientation;
int _driveKeys[MAX_DRIVE_KEYS];
float _renderYaw;
float _renderPitch; // Pitch from view frustum when this is own head
bool _transmitterIsFirstData;
timeval _transmitterTimeLastReceived;
timeval _transmitterTimer;

View file

@ -17,28 +17,6 @@ HeadData::HeadData() :
}
void HeadData::setYaw(float yaw) {
const float MAX_YAW = 85;
const float MIN_YAW = -85;
_yaw = glm::clamp(yaw, MIN_YAW, MAX_YAW);
}
void HeadData::setPitch(float pitch) {
// set head pitch and apply limits
const float MAX_PITCH = 60;
const float MIN_PITCH = -60;
_pitch = glm::clamp(pitch, MIN_PITCH, MAX_PITCH);
}
void HeadData::setRoll(float roll) {
const float MAX_ROLL = 50;
const float MIN_ROLL = -50;
_roll = glm::clamp(roll, MIN_ROLL, MAX_ROLL);
}
void HeadData::addYaw(float yaw) {
setYaw(_yaw + yaw);
}

View file

@ -13,18 +13,25 @@
#include <glm/glm.hpp>
const float MIN_HEAD_YAW = -85;
const float MAX_HEAD_YAW = 85;
const float MIN_HEAD_PITCH = -60;
const float MAX_HEAD_PITCH = 60;
const float MIN_HEAD_ROLL = -50;
const float MAX_HEAD_ROLL = 50;
class HeadData {
public:
HeadData();
float getYaw() const { return _yaw; }
void setYaw(float yaw);
void setYaw(float yaw) { _yaw = glm::clamp(yaw, MIN_HEAD_YAW, MAX_HEAD_YAW); }
float getPitch() const { return _pitch; }
void setPitch(float pitch);
void setPitch(float pitch) { _pitch = glm::clamp(pitch, MIN_HEAD_PITCH, MAX_HEAD_PITCH); }
float getRoll() const { return _roll; }
void setRoll(float roll);
void setRoll(float roll) { _roll = glm::clamp(roll, MIN_HEAD_ROLL, MAX_HEAD_ROLL); }
void addYaw(float yaw);
void addPitch(float pitch);