Skip to content

Commit

Permalink
Merge pull request #655 from liaxim/fixreset
Browse files Browse the repository at this point in the history
Fix camera rig's reset while docked
  • Loading branch information
liaxim authored Jul 7, 2016
2 parents 64b2a45 + bb50fc1 commit 21c7c8a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,19 +139,6 @@ void CameraRig::predict(float time) {
}

void CameraRig::predict(float time, const RotationSensorData& rotationSensorData) {
long long clock_time = getCurrentTime();
float time_diff = (clock_time - rotationSensorData.time_stamp())
/ 1000000000.0f;

glm::vec3 axis = rotationSensorData.gyro();
//the magnitude of the gyro vector should be the angular velocity, rad/sec
float angle = glm::length(axis);

//normalize the axis
if (angle != 0.0f) {
axis /= angle;
}

setRotation(complementary_rotation_*rotationSensorData.quaternion());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@ void OculusHeadRotation::predict(GVRActivity& gvrActivity, const ovrFrameParms&
tracking = vrapi_ApplyHeadModel(gvrActivity.getOculusHeadModelParms(), &tracking);

const ovrQuatf& orientation = tracking.HeadPose.Pose.Orientation;
glm::quat quat(orientation.w, orientation.x, orientation.y, orientation.z);
gvrActivity.cameraRig_->setRotation(glm::conjugate(glm::inverse(quat)));
const glm::quat tmp(orientation.w, orientation.x, orientation.y, orientation.z);
const glm::quat quat = glm::conjugate(glm::inverse(tmp));
gvrActivity.cameraRig_->setRotationSensorData(0, quat.w, quat.x, quat.y, quat.z, 0, 0, 0);
gvrActivity.cameraRig_->predict(0);

const ovrVector3f& position = tracking.HeadPose.Pose.Position;
glm::vec3 pos(position.x, position.y, position.z);
const glm::vec3 pos(position.x, position.y, position.z);
gvrActivity.cameraRig_->setPosition(pos);
} else if (nullptr != gvrActivity.cameraRig_) {
gvrActivity.cameraRig_->predict(time);
Expand Down

0 comments on commit 21c7c8a

Please sign in to comment.