Solve precision problem that causes jagged movement.

This commit is contained in:
Kalle Bladin
2016-05-27 11:09:07 -04:00
parent e0814a23dd
commit 060298f74b
3 changed files with 9 additions and 10 deletions

View File

@@ -73,9 +73,9 @@ namespace openspace {
// now working with float precision. To be changed to double later.
// The reason double does not work yet is because of the setUniform function
// in ghoul::opengl
typedef glm::quat Quat;
typedef glm::mat4 Mat4;
typedef glm::vec3 Vec3;
typedef glm::dquat Quat;
typedef glm::dmat4 Mat4;
typedef glm::dvec3 Vec3;
// Static constants
static const Vec3 _VIEW_DIRECTION_CAMERA_SPACE;

View File

@@ -940,10 +940,10 @@ void GlobeBrowsingInteractionMode::updateCameraStateFromMouseStates() {
0);
glm::dquat rotationDiffCamSpace = glm::dquat(eulerAngles);
glm::dquat newRotationCamspace =
_globalCameraRotation * rotationDiffCamSpace;
glm::dquat rotationDiffWorldSpace =
newRotationCamspace * glm::inverse(_globalCameraRotation);
_globalCameraRotation *
rotationDiffCamSpace *
glm::inverse(_globalCameraRotation);
glm::dvec3 rotationDiffVec3 =
(distFromCenterToCamera * directionFromSurfaceToCamera)

View File

@@ -43,8 +43,8 @@ namespace openspace {
, _focusPosition()
{
_scaling.local = glm::vec2(1.f, 0.f);
_position.local = Vec3(0, 0, 0);
Vec3 eulerAngles(0, 0, 0);
_position.local = Vec3(1.0, 1.0, 1.0);
Vec3 eulerAngles(1.0, 1.0, 1.0);
_rotation.local = Quat(eulerAngles);
}
@@ -153,9 +153,8 @@ namespace openspace {
const Camera::Mat4& Camera::combinedViewMatrix() const {
if (_cachedCombinedViewMatrix.isDirty) {
Vec3 cameraPosition = position().vec3();
Mat4 cameraTranslation =
glm::inverse(glm::translate(Mat4(1.0), cameraPosition));
glm::inverse(glm::translate(Mat4(1.0), _position.shared));
_cachedCombinedViewMatrix.datum =
Mat4(viewRotationMatrix()) * cameraTranslation;
}