From 1347e23597d3e932bf2794fc16da7619f44a8aa4 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Sat, 23 Jun 2018 15:01:02 -1000 Subject: [PATCH] Add clip-space constructor for CVector4f --- include/zeus/CMatrix4f.hpp | 7 +++++++ include/zeus/CVector4f.hpp | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/include/zeus/CMatrix4f.hpp b/include/zeus/CMatrix4f.hpp index c674ecd..fe98579 100644 --- a/include/zeus/CMatrix4f.hpp +++ b/include/zeus/CMatrix4f.hpp @@ -117,6 +117,13 @@ public: return xfVec.toVec3f() / xfVec.w; } + inline CVector3f multiplyOneOverW(const CVector3f& point, float& wOut) const + { + CVector4f xfVec = *this * point; + wOut = xfVec.w; + return xfVec.toVec3f() / xfVec.w; + } + union { float m[4][4]; struct diff --git a/include/zeus/CVector4f.hpp b/include/zeus/CVector4f.hpp index ff9a957..6814739 100644 --- a/include/zeus/CVector4f.hpp +++ b/include/zeus/CVector4f.hpp @@ -89,6 +89,13 @@ public: w = 1.0f; } + static CVector4f ToClip(const zeus::CVector3f& v, float w) + { + CVector4f ret(v * w); + ret.w = w; + return ret; + } + inline CVector3f toVec3f() const { #if __SSE__