Skip to content

Commit

Permalink
Fix camera rig's reset while docked
Browse files Browse the repository at this point in the history
GearVRf-DCO-1.0-Signed-off-by: Mihail Marinov <[email protected]>
  • Loading branch information
liaxim committed Jun 30, 2016
1 parent 76d80ed commit bb50fc1
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 bb50fc1

Please sign in to comment.