From 3c3e8deb17fe7320425aefff715c610f4c303a98 Mon Sep 17 00:00:00 2001 From: Dario Manesku Date: Fri, 26 Feb 2016 16:46:33 +0100 Subject: [PATCH] Amend for the previous commit. --- include/bx/fpumath.h | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/include/bx/fpumath.h b/include/bx/fpumath.h index 76465f5..ea2d13d 100644 --- a/include/bx/fpumath.h +++ b/include/bx/fpumath.h @@ -649,10 +649,12 @@ namespace bx inline void mtxProjRh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, float _far, bool _oglNdc = false) { - const float width = 2.0f / (_rt - _lt); - const float height = 2.0f / (_ut - _dt); - const float xx = (_lt + _rt) * width * 0.5f; - const float yy = (_ut + _dt) * height * 0.5f; + const float invDiffRl = 1.0f/(_rt - _lt); + const float invDiffUd = 1.0f/(_ut - _dt); + const float width = 2.0f*_near * invDiffRl; + const float height = 2.0f*_near * invDiffUd; + const float xx = (_rt + _lt) * invDiffRl; + const float yy = (_ut + _dt) * invDiffUd; mtxProjRhXYWH(_result, xx, yy, width, height, _near, _far, _oglNdc); } @@ -686,10 +688,12 @@ namespace bx inline void mtxProjLh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, float _far, bool _oglNdc = false) { - const float width = 2.0f / (_rt - _lt); - const float height = 2.0f / (_ut - _dt); - const float xx = (_lt + _rt) * width * 0.5f; - const float yy = (_ut + _dt) * height * 0.5f; + const float invDiffRl = 1.0f/(_rt - _lt); + const float invDiffUd = 1.0f/(_ut - _dt); + const float width = 2.0f*_near * invDiffRl; + const float height = 2.0f*_near * invDiffUd; + const float xx = (_rt + _lt) * invDiffRl; + const float yy = (_ut + _dt) * invDiffUd; mtxProjLhXYWH(_result, xx, yy, width, height, _near, _far, _oglNdc); }