recover follow HMD behavior

This commit is contained in:
Andrew Meadows 2015-10-27 13:51:40 -07:00
parent 43aac813da
commit 8b285fd228
2 changed files with 3 additions and 24 deletions

View file

@ -109,12 +109,8 @@ MyAvatar::MyAvatar(RigPointer rig) :
_goToOrientation(), _goToOrientation(),
_rig(rig), _rig(rig),
_prevShouldDrawHead(true), _prevShouldDrawHead(true),
_audioListenerMode(FROM_HEAD) _audioListenerMode(FROM_HEAD),
#ifdef OLD_HMD_TRACKER _hmdAtRestDetector(glm::vec3(0), glm::quat())
,_hmdAtRestDetector(glm::vec3(0), glm::quat())
#else
,_avatarOffsetFromHMD(0.0f)
#endif // OLD_HMD_TRACKER
{ {
for (int i = 0; i < MAX_DRIVE_KEYS; i++) { for (int i = 0; i < MAX_DRIVE_KEYS; i++) {
_driveKeys[i] = 0.0f; _driveKeys[i] = 0.0f;
@ -159,9 +155,7 @@ void MyAvatar::reset(bool andReload) {
// Reset dynamic state. // Reset dynamic state.
_wasPushing = _isPushing = _isBraking = _billboardValid = false; _wasPushing = _isPushing = _isBraking = _billboardValid = false;
#ifdef OLD_HMD_TRACKER
_isFollowingHMD = false; _isFollowingHMD = false;
#endif // OLD_HMD_TRACKER
_skeletonModel.reset(); _skeletonModel.reset();
getHead()->reset(); getHead()->reset();
_targetVelocity = glm::vec3(0.0f); _targetVelocity = glm::vec3(0.0f);
@ -309,7 +303,6 @@ glm::mat4 MyAvatar::getSensorToWorldMatrix() const {
return _sensorToWorldMatrix; return _sensorToWorldMatrix;
} }
#ifdef OLD_HMD_TRACKER
// returns true if pos is OUTSIDE of the vertical capsule // returns true if pos is OUTSIDE of the vertical capsule
// where the middle cylinder length is defined by capsuleLen and the radius by capsuleRad. // where the middle cylinder length is defined by capsuleLen and the radius by capsuleRad.
static bool pointIsOutsideCapsule(const glm::vec3& pos, float capsuleLen, float capsuleRad) { static bool pointIsOutsideCapsule(const glm::vec3& pos, float capsuleLen, float capsuleRad) {
@ -328,7 +321,6 @@ static bool pointIsOutsideCapsule(const glm::vec3& pos, float capsuleLen, float
return false; return false;
} }
} }
#endif // OLD_HMD_TRACKER
// Pass a recent sample of the HMD to the avatar. // Pass a recent sample of the HMD to the avatar.
// This can also update the avatar's position to follow the HMD // This can also update the avatar's position to follow the HMD
@ -339,7 +331,6 @@ void MyAvatar::updateFromHMDSensorMatrix(const glm::mat4& hmdSensorMatrix) {
_hmdSensorPosition = extractTranslation(hmdSensorMatrix); _hmdSensorPosition = extractTranslation(hmdSensorMatrix);
_hmdSensorOrientation = glm::quat_cast(hmdSensorMatrix); _hmdSensorOrientation = glm::quat_cast(hmdSensorMatrix);
#ifdef OLD_HMD_TRACKER
// calc deltaTime // calc deltaTime
auto now = usecTimestampNow(); auto now = usecTimestampNow();
auto deltaUsecs = now - _lastUpdateFromHMDTime; auto deltaUsecs = now - _lastUpdateFromHMDTime;
@ -374,9 +365,6 @@ void MyAvatar::updateFromHMDSensorMatrix(const glm::mat4& hmdSensorMatrix) {
} }
followHMD(deltaTime); followHMD(deltaTime);
#else
// TODO adebug BOOKMARK -- this is where we need to add the new code for HMD_TRACKER
#endif // OLD_HMD_TRACKER
} }
glm::vec3 MyAvatar::getHMDCorrectionVelocity() const { glm::vec3 MyAvatar::getHMDCorrectionVelocity() const {
@ -384,7 +372,6 @@ glm::vec3 MyAvatar::getHMDCorrectionVelocity() const {
return Vectors::ZERO; return Vectors::ZERO;
} }
#ifdef OLD_HMD_TRACKER
void MyAvatar::beginFollowingHMD() { void MyAvatar::beginFollowingHMD() {
// begin homing toward derived body position. // begin homing toward derived body position.
if (!_isFollowingHMD) { if (!_isFollowingHMD) {
@ -440,7 +427,6 @@ void MyAvatar::followHMD(float deltaTime) {
} }
} }
} }
#endif // USE_OLD
// best called at end of main loop, just before rendering. // best called at end of main loop, just before rendering.
// update sensor to world matrix from current body position and hmd sensor. // update sensor to world matrix from current body position and hmd sensor.

View file

@ -18,10 +18,9 @@
#include <Rig.h> #include <Rig.h>
#include "Avatar.h" #include "Avatar.h"
//#include "AtRestDetector.h" #include "AtRestDetector.h"
#include "MyCharacterController.h" #include "MyCharacterController.h"
//#define OLD_HMD_TRACKER
class ModelItemID; class ModelItemID;
@ -270,11 +269,9 @@ private:
const RecorderPointer getRecorder() const { return _recorder; } const RecorderPointer getRecorder() const { return _recorder; }
const PlayerPointer getPlayer() const { return _player; } const PlayerPointer getPlayer() const { return _player; }
#ifdef OLD_HMD_TRACKER
void beginFollowingHMD(); void beginFollowingHMD();
bool shouldFollowHMD() const; bool shouldFollowHMD() const;
void followHMD(float deltaTime); void followHMD(float deltaTime);
#endif
bool cameraInsideHead() const; bool cameraInsideHead() const;
@ -366,7 +363,6 @@ private:
glm::vec3 _customListenPosition; glm::vec3 _customListenPosition;
glm::quat _customListenOrientation; glm::quat _customListenOrientation;
#ifdef OLD_HMD_TRACKER
bool _isFollowingHMD { false }; bool _isFollowingHMD { false };
float _followHMDAlpha{0.0f}; float _followHMDAlpha{0.0f};
@ -374,9 +370,6 @@ private:
AtRestDetector _hmdAtRestDetector; AtRestDetector _hmdAtRestDetector;
glm::vec3 _lastPosition; glm::vec3 _lastPosition;
bool _lastIsMoving { false }; bool _lastIsMoving { false };
#else
glm::vec3 _avatarOffsetFromHMD;
#endif // OLD_HMD_TRACKER
}; };
QScriptValue audioListenModeToScriptValue(QScriptEngine* engine, const AudioListenerMode& audioListenerMode); QScriptValue audioListenModeToScriptValue(QScriptEngine* engine, const AudioListenerMode& audioListenerMode);