d/ns: Fix all warnings and tidy code

This commit is contained in:
Jakob Bornecrantz 2020-02-11 13:55:49 +00:00
parent d4e034dd44
commit 68422f6e3e
3 changed files with 63 additions and 20 deletions

View file

@ -221,10 +221,10 @@ OpticalSystem::SolveDisplayUVToRenderUV(Vector2 inputUV,
Vector2 error = curDisplayUV - inputUV;
Vector2 step = Vector2::zero();
if (!displayUVGradX.x == 0.f || !displayUVGradX.y == 0.f) {
if ((!displayUVGradX.x) == 0.f || (!displayUVGradX.y) == 0.f) {
step = step + (displayUVGradX * error.x);
}
if (!displayUVGradY.x == 0.f || !displayUVGradY.y == 0.f) {
if ((!displayUVGradY.x) == 0.f || (!displayUVGradY.y) == 0.f) {
step = step + (displayUVGradY * error.y);
}

View file

@ -4,15 +4,10 @@
#pragma once
#include <map>
#include "utility_northstar.h"
#include "../ns_hmd.h"
#include <chrono>
#include <map>
using namespace std::chrono;
static char *s_strLeftEye = "leftEye";
static char *s_strRightEye = "rightEye";
class OpticalSystem
{
@ -71,9 +66,6 @@ public:
void
UpdateClipToWorld(Matrix4x4 eyeRotationMatrix)
{
// TEST DELETEME
float time = clock() / (float)CLOCKS_PER_SEC;
float osc = sinf(time * 2 * LP_PI);
Matrix4x4 eyeToWorld =
Matrix4x4::Translate(eyePosition) * eyeRotationMatrix;
eyeToWorld.m02 *= -1;
@ -99,7 +91,7 @@ public:
clipToWorld.MultiplyPoint(tmp * 2.f) - cameraPosition;
float mag = dir.Magnitude();
out = dir / dir.Magnitude();
out = dir / mag;
return;
}

View file

@ -44,6 +44,15 @@ public:
z = 0.f;
};
constexpr Vector3 &
operator=(const Vector3 &lhr)
{
this->x = lhr.x;
this->y = lhr.y;
this->z = lhr.z;
return *this;
}
inline static Vector3
Up()
{
@ -139,14 +148,6 @@ public:
return ret;
}
inline void
copy(Vector3 &lhs, Vector3 rhs)
{
rhs.x = lhs.x;
rhs.y = lhs.y;
rhs.z = lhs.z;
}
inline float static Dot(Vector3 lhs, Vector3 rhs)
{
float result =
@ -300,6 +301,14 @@ public:
y = _y;
};
constexpr Vector2 &
operator=(const Vector2 &lhr)
{
this->x = lhr.x;
this->y = lhr.y;
return *this;
}
inline static Vector2
zero()
{
@ -434,6 +443,28 @@ public:
m33 = in33;
};
constexpr Matrix4x4 &
operator=(const Matrix4x4 &lhr)
{
this->m00 = lhr.m00;
this->m01 = lhr.m01;
this->m02 = lhr.m02;
this->m03 = lhr.m03;
this->m10 = lhr.m10;
this->m11 = lhr.m11;
this->m12 = lhr.m12;
this->m13 = lhr.m13;
this->m20 = lhr.m20;
this->m21 = lhr.m21;
this->m22 = lhr.m22;
this->m23 = lhr.m23;
this->m30 = lhr.m30;
this->m31 = lhr.m31;
this->m32 = lhr.m32;
this->m33 = lhr.m33;
return *this;
};
inline static Matrix4x4
Identity()
{
@ -688,6 +719,16 @@ public:
w = in.w;
}
constexpr Vector4 &
operator=(const Vector4 &lhr)
{
this->x = lhr.x;
this->y = lhr.y;
this->z = lhr.z;
this->w = lhr.w;
return *this;
}
inline Matrix4x4
ComposeProjection()
{
@ -784,6 +825,16 @@ public:
w = _in.w;
};
constexpr Quaternion &
operator=(const Quaternion &lhr)
{
this->x = lhr.x;
this->y = lhr.y;
this->z = lhr.z;
this->w = lhr.w;
return *this;
}
inline static Quaternion
Identity()
{