mirror of
https://github.com/overte-org/overte.git
synced 2025-04-19 13:43:49 +02:00
Fixing frustum perspective bug
This commit is contained in:
parent
012b0973b9
commit
4ccdc78866
1 changed files with 4 additions and 3 deletions
|
@ -65,9 +65,10 @@ void ViewFrustum::setProjection(const glm::mat4& projection) {
|
|||
_farClip = -_corners[BOTTOM_LEFT_FAR].z;
|
||||
_aspectRatio = (_corners[TOP_RIGHT_NEAR].x - _corners[BOTTOM_LEFT_NEAR].x) /
|
||||
(_corners[TOP_RIGHT_NEAR].y - _corners[BOTTOM_LEFT_NEAR].y);
|
||||
glm::vec3 right = glm::normalize(glm::vec3(_corners[TOP_RIGHT_NEAR]));
|
||||
glm::vec3 left = glm::normalize(glm::vec3(_corners[TOP_LEFT_NEAR]));
|
||||
_fieldOfView = abs(glm::degrees(glm::angle(right, left)));
|
||||
vec4 top = _inverseProjection * vec4(0, 1, -1, 1);
|
||||
top /= top.w;
|
||||
static const vec3 center(0, 0, -1);
|
||||
_fieldOfView = glm::degrees(2.0f * abs(glm::angle(center, glm::normalize(vec3(top)))));
|
||||
}
|
||||
|
||||
// ViewFrustum::calculateViewFrustum()
|
||||
|
|
Loading…
Reference in a new issue