Decouple Rift head tracking from avatar's head position

This makes the Rift's view reflect the user's physical movements exactly
while the avatar follows the movements as best it can.
This commit is contained in:
David Rowe 2014-09-19 14:26:44 -07:00
parent 76f78e77d1
commit a11bf7f15b
6 changed files with 15 additions and 7 deletions

View file

@ -682,7 +682,7 @@ void Application::paintGL() {
if (whichCamera.getMode() == CAMERA_MODE_MIRROR) {
OculusManager::display(whichCamera.getRotation(), whichCamera.getPosition(), whichCamera);
} else {
OculusManager::display(_myAvatar->getWorldAlignedOrientation(), whichCamera.getPosition(), whichCamera);
OculusManager::display(_myAvatar->getWorldAlignedOrientation(), _myAvatar->getUprightHeadPosition(), whichCamera);
}
} else if (TV3DManager::isConnected()) {

View file

@ -1028,10 +1028,6 @@ float Avatar::getPelvisFloatingHeight() const {
return -_skeletonModel.getBindExtents().minimum.y;
}
float Avatar::getPelvisToHeadLength() const {
return glm::distance(_position, getHead()->getPosition());
}
void Avatar::setShowDisplayName(bool showDisplayName) {
if (!Menu::getInstance()->isOptionChecked(MenuOption::NamesAboveHeads)) {
_displayNameAlpha = 0.0f;

View file

@ -223,7 +223,6 @@ protected:
float getSkeletonHeight() const;
float getHeadHeight() const;
float getPelvisFloatingHeight() const;
float getPelvisToHeadLength() const;
glm::vec3 getDisplayNamePosition();
void renderDisplayName();

View file

@ -977,7 +977,7 @@ void MyAvatar::clearLookAtTargetAvatar() {
}
glm::vec3 MyAvatar::getUprightHeadPosition() const {
return _position + getWorldAlignedOrientation() * glm::vec3(0.0f, getPelvisToHeadLength(), 0.0f);
return _position + getWorldAlignedOrientation() * _skeletonModel.getDefaultHeadModelPosition();
}
const float SCRIPT_PRIORITY = DEFAULT_PRIORITY + 1.0f;

View file

@ -656,6 +656,13 @@ void SkeletonModel::buildShapes() {
// This method moves the shapes to their default positions in Model frame.
computeBoundingShape(geometry);
int headJointIndex = _geometry->getFBXGeometry().headJointIndex;
if (0 <= headJointIndex && headJointIndex < _jointStates.size()) {
getJointPosition(headJointIndex, _defaultHeadModelPosition);
} else {
_defaultHeadModelPosition = glm::vec3(0.f, 0.f, 0.f);
}
// While the shapes are in their default position we disable collisions between
// joints that are currently colliding.
disableCurrentSelfCollisions();

View file

@ -97,6 +97,10 @@ public:
/// \return whether or not both eye meshes were found
bool getEyePositions(glm::vec3& firstEyePosition, glm::vec3& secondEyePosition) const;
/// Gets the default position of the head in model frame coordinates.
/// \return whether or not the head was found.
glm::vec3 getDefaultHeadModelPosition() const { return _defaultHeadModelPosition; }
virtual void updateVisibleJointStates();
SkeletonRagdoll* buildRagdoll();
@ -146,6 +150,8 @@ private:
CapsuleShape _boundingShape;
glm::vec3 _boundingShapeLocalOffset;
SkeletonRagdoll* _ragdoll;
glm::vec3 _defaultHeadModelPosition;
};
#endif // hifi_SkeletonModel_h