History

Work around precision issues with multiplying matrices with high translation magnitudes (by using relative translation).

Andrzej Kapolka committed 13 years ago

Commit b2ed29d1 parent 4cc65085 files · +37 −19Browse files

Showing the changes to interface/src/Application.cpp (1 of 5 files). Show all

Unified · Split

interface/src/Application.cpp+11−1
@@ -2866,6 +2866,12 @@ void Application::setupWorldLight(Camera& whichCamera) { · 2865 unmodified lines
28662866 glMateriali(GL_FRONT, GL_SHININESS, 96);
28672867 }
28682868
2869+void Application::loadTranslatedViewMatrix(const glm::vec3& translation) {
2870+ glLoadMatrixf((const GLfloat*)&_untranslatedViewMatrix);
2871+ glTranslatef(translation.x + _viewMatrixTranslation.x, translation.y + _viewMatrixTranslation.y,
2872+ translation.z + _viewMatrixTranslation.z);
2873+}
2874+
28692875 void Application::computeOffAxisFrustum(float& left, float& right, float& bottom, float& top, float& near,
28702876 float& far, glm::vec4& nearClipPlane, glm::vec4& farClipPlane) const {
28712877
@@ -2899,7 +2905,11 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 27 unmodified lines
28992905 glm::vec3 axis = glm::axis(rotation);
29002906 glRotatef(-glm::angle(rotation), axis.x, axis.y, axis.z);
29012907
2902− glTranslatef(-whichCamera.getPosition().x, -whichCamera.getPosition().y, -whichCamera.getPosition().z);
2908+ // store view matrix without translation, which we'll use for precision-sensitive objects
2909+ glGetFloatv(GL_MODELVIEW_MATRIX, (GLfloat*)&_untranslatedViewMatrix);
2910+ _viewMatrixTranslation = -whichCamera.getPosition();
2911+
2912+ glTranslatef(_viewMatrixTranslation.x, _viewMatrixTranslation.y, _viewMatrixTranslation.z);
29032913
29042914 // Setup 3D lights (after the camera transform, so that they are positioned in world space)
29052915 setupWorldLight(whichCamera);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t