mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 15:49:33 +02:00
code review comments, cleanup Avatar constructor
This commit is contained in:
parent
de84b7803f
commit
570dfba934
5 changed files with 54 additions and 86 deletions
|
@ -1356,22 +1356,6 @@ void Application::updateAvatar(float deltaTime) {
|
||||||
_headMouseY = max(_headMouseY, 0);
|
_headMouseY = max(_headMouseY, 0);
|
||||||
_headMouseY = min(_headMouseY, _glWidget->height());
|
_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()) {
|
if (OculusManager::isConnected()) {
|
||||||
float yaw, pitch, roll;
|
float yaw, pitch, roll;
|
||||||
OculusManager::getEulerAngles(yaw, pitch, roll);
|
OculusManager::getEulerAngles(yaw, pitch, roll);
|
||||||
|
|
|
@ -59,61 +59,62 @@ bool usingBigSphereCollisionTest = true;
|
||||||
float chatMessageScale = 0.0015;
|
float chatMessageScale = 0.0015;
|
||||||
float chatMessageHeight = 0.45;
|
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
|
// give the pointer to our head to inherited _headData variable from AvatarData
|
||||||
_headData = &_head;
|
_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;
|
|
||||||
|
for (int i = 0; i < MAX_DRIVE_KEYS; i++) {
|
||||||
_movedHandOffset = glm::vec3(0.0f, 0.0f, 0.0f);
|
_driveKeys[i] = false;
|
||||||
_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;
|
|
||||||
|
|
||||||
initializeSkeleton();
|
initializeSkeleton();
|
||||||
|
|
||||||
_avatarTouch.setReachableRadius(PERIPERSONAL_RADIUS);
|
_avatarTouch.setReachableRadius(PERIPERSONAL_RADIUS);
|
||||||
|
|
||||||
if (BALLS_ON) { _balls = new Balls(100); }
|
if (BALLS_ON) {
|
||||||
else { _balls = NULL; }
|
_balls = new Balls(100);
|
||||||
|
} else {
|
||||||
|
_balls = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Avatar::~Avatar() {
|
Avatar::~Avatar() {
|
||||||
// if _balls is something that's sticking around other than Philip playing around it needs to be delete here too
|
|
||||||
_headData = NULL;
|
_headData = NULL;
|
||||||
|
delete _balls;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Avatar::reset() {
|
void Avatar::reset() {
|
||||||
|
|
|
@ -165,8 +165,8 @@ private:
|
||||||
|
|
||||||
Head _head;
|
Head _head;
|
||||||
bool _isMine;
|
bool _isMine;
|
||||||
glm::vec3 _TEST_bigSpherePosition;
|
|
||||||
float _TEST_bigSphereRadius;
|
float _TEST_bigSphereRadius;
|
||||||
|
glm::vec3 _TEST_bigSpherePosition;
|
||||||
bool _mousePressed;
|
bool _mousePressed;
|
||||||
float _bodyPitchDelta;
|
float _bodyPitchDelta;
|
||||||
float _bodyYawDelta;
|
float _bodyYawDelta;
|
||||||
|
@ -182,8 +182,6 @@ private:
|
||||||
float _maxArmLength;
|
float _maxArmLength;
|
||||||
Orientation _orientation;
|
Orientation _orientation;
|
||||||
int _driveKeys[MAX_DRIVE_KEYS];
|
int _driveKeys[MAX_DRIVE_KEYS];
|
||||||
float _renderYaw;
|
|
||||||
float _renderPitch; // Pitch from view frustum when this is own head
|
|
||||||
bool _transmitterIsFirstData;
|
bool _transmitterIsFirstData;
|
||||||
timeval _transmitterTimeLastReceived;
|
timeval _transmitterTimeLastReceived;
|
||||||
timeval _transmitterTimer;
|
timeval _transmitterTimer;
|
||||||
|
|
|
@ -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) {
|
void HeadData::addYaw(float yaw) {
|
||||||
setYaw(_yaw + yaw);
|
setYaw(_yaw + yaw);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,18 +13,25 @@
|
||||||
|
|
||||||
#include <glm/glm.hpp>
|
#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 {
|
class HeadData {
|
||||||
public:
|
public:
|
||||||
HeadData();
|
HeadData();
|
||||||
|
|
||||||
float getYaw() const { return _yaw; }
|
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; }
|
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; }
|
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 addYaw(float yaw);
|
||||||
void addPitch(float pitch);
|
void addPitch(float pitch);
|
||||||
|
|
Loading…
Reference in a new issue