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
2866 glMateriali(GL_FRONT, GL_SHININESS, 96);2866 glMateriali(GL_FRONT, GL_SHININESS, 96);
2867}2867}
2868 2868
2869void 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
2869void Application::computeOffAxisFrustum(float& left, float& right, float& bottom, float& top, float& near,2875void Application::computeOffAxisFrustum(float& left, float& right, float& bottom, float& top, float& near,
2870 float& far, glm::vec4& nearClipPlane, glm::vec4& farClipPlane) const {2876 float& far, glm::vec4& nearClipPlane, glm::vec4& farClipPlane) const {
2871 2877
@@ -2899,7 +2905,11 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 27 unmodified lines
2899 glm::vec3 axis = glm::axis(rotation);2905 glm::vec3 axis = glm::axis(rotation);
2900 glRotatef(-glm::angle(rotation), axis.x, axis.y, axis.z);2906 glRotatef(-glm::angle(rotation), axis.x, axis.y, axis.z);
2901 2907
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);
2903 2913
2904 // Setup 3D lights (after the camera transform, so that they are positioned in world space)2914 // Setup 3D lights (after the camera transform, so that they are positioned in world space)
2905 setupWorldLight(whichCamera);2915 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