overlays: Move vertex & vector utility classes to new file
This commit is contained in:
@@ -1,67 +1,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "Utilities/types.h"
|
#include "Utilities/types.h"
|
||||||
#include "Utilities/geometry.h"
|
#include "Utilities/geometry.h"
|
||||||
|
#include "overlay_utils.h"
|
||||||
|
|
||||||
namespace rsx
|
namespace rsx
|
||||||
{
|
{
|
||||||
template<typename T>
|
|
||||||
struct vector3_base : public position3_base<T>
|
|
||||||
{
|
|
||||||
using position3_base<T>::position3_base;
|
|
||||||
|
|
||||||
vector3_base<T>(T x, T y, T z)
|
|
||||||
{
|
|
||||||
this->x = x;
|
|
||||||
this->y = y;
|
|
||||||
this->z = z;
|
|
||||||
}
|
|
||||||
|
|
||||||
vector3_base<T>(const position3_base<T>& other)
|
|
||||||
{
|
|
||||||
this->x = other.x;
|
|
||||||
this->y = other.y;
|
|
||||||
this->z = other.z;
|
|
||||||
}
|
|
||||||
|
|
||||||
vector3_base<T> operator * (const vector3_base<T>& rhs) const
|
|
||||||
{
|
|
||||||
return { this->x * rhs.x, this->y * rhs.y, this->z * rhs.z };
|
|
||||||
}
|
|
||||||
|
|
||||||
vector3_base<T> operator * (T rhs) const
|
|
||||||
{
|
|
||||||
return { this->x * rhs, this->y * rhs, this->z * rhs };
|
|
||||||
}
|
|
||||||
|
|
||||||
void operator *= (const vector3_base<T>& rhs)
|
|
||||||
{
|
|
||||||
this->x *= rhs.x;
|
|
||||||
this->y *= rhs.y;
|
|
||||||
this->z *= rhs.z;
|
|
||||||
}
|
|
||||||
|
|
||||||
void operator *= (T rhs)
|
|
||||||
{
|
|
||||||
this->x *= rhs;
|
|
||||||
this->y *= rhs;
|
|
||||||
this->z *= rhs;
|
|
||||||
}
|
|
||||||
|
|
||||||
T dot(const vector3_base<T>& rhs) const
|
|
||||||
{
|
|
||||||
return (this->x * rhs.x) + (this->y * rhs.y) + (this->z * rhs.z);
|
|
||||||
}
|
|
||||||
|
|
||||||
T distance(const vector3_base<T>& rhs) const
|
|
||||||
{
|
|
||||||
const vector3_base<T> d = *this - rhs;
|
|
||||||
return d.dot(d);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
using vector3i = vector3_base<int>;
|
|
||||||
using vector3f = vector3_base<float>;
|
|
||||||
|
|
||||||
namespace overlays
|
namespace overlays
|
||||||
{
|
{
|
||||||
struct compiled_resource;
|
struct compiled_resource;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#include "Utilities/types.h"
|
#include "Utilities/types.h"
|
||||||
#include "Utilities/geometry.h"
|
#include "Utilities/geometry.h"
|
||||||
#include "Utilities/File.h"
|
#include "Utilities/File.h"
|
||||||
|
#include "overlay_utils.h"
|
||||||
#include "Emu/System.h"
|
#include "Emu/System.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
@@ -51,78 +52,6 @@ namespace rsx
|
|||||||
line_strip = 3
|
line_strip = 3
|
||||||
};
|
};
|
||||||
|
|
||||||
struct vertex
|
|
||||||
{
|
|
||||||
float values[4];
|
|
||||||
|
|
||||||
vertex() = default;
|
|
||||||
|
|
||||||
vertex(float x, float y)
|
|
||||||
{
|
|
||||||
vec2(x, y);
|
|
||||||
}
|
|
||||||
|
|
||||||
vertex(float x, float y, float z)
|
|
||||||
{
|
|
||||||
vec3(x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
vertex(float x, float y, float z, float w)
|
|
||||||
{
|
|
||||||
vec4(x, y, z, w);
|
|
||||||
}
|
|
||||||
|
|
||||||
vertex(int x, int y, int z, int w)
|
|
||||||
{
|
|
||||||
vec4(static_cast<f32>(x), static_cast<f32>(y), static_cast<f32>(z), static_cast<f32>(w));
|
|
||||||
}
|
|
||||||
|
|
||||||
float& operator[](int index)
|
|
||||||
{
|
|
||||||
return values[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
void vec2(float x, float y)
|
|
||||||
{
|
|
||||||
values[0] = x;
|
|
||||||
values[1] = y;
|
|
||||||
values[2] = 0.f;
|
|
||||||
values[3] = 1.f;
|
|
||||||
}
|
|
||||||
|
|
||||||
void vec3(float x, float y, float z)
|
|
||||||
{
|
|
||||||
values[0] = x;
|
|
||||||
values[1] = y;
|
|
||||||
values[2] = z;
|
|
||||||
values[3] = 1.f;
|
|
||||||
}
|
|
||||||
|
|
||||||
void vec4(float x, float y, float z, float w)
|
|
||||||
{
|
|
||||||
values[0] = x;
|
|
||||||
values[1] = y;
|
|
||||||
values[2] = z;
|
|
||||||
values[3] = w;
|
|
||||||
}
|
|
||||||
|
|
||||||
void operator += (const vertex& other)
|
|
||||||
{
|
|
||||||
values[0] += other.values[0];
|
|
||||||
values[1] += other.values[1];
|
|
||||||
values[2] += other.values[2];
|
|
||||||
values[3] += other.values[3];
|
|
||||||
}
|
|
||||||
|
|
||||||
void operator -= (const vertex& other)
|
|
||||||
{
|
|
||||||
values[0] -= other.values[0];
|
|
||||||
values[1] -= other.values[1];
|
|
||||||
values[2] -= other.values[2];
|
|
||||||
values[3] -= other.values[3];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct font
|
struct font
|
||||||
{
|
{
|
||||||
const u32 width = 1024;
|
const u32 width = 1024;
|
||||||
|
|||||||
@@ -0,0 +1,148 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
struct vertex
|
||||||
|
{
|
||||||
|
float values[4];
|
||||||
|
|
||||||
|
vertex() = default;
|
||||||
|
|
||||||
|
vertex(float x, float y)
|
||||||
|
{
|
||||||
|
vec2(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
vertex(float x, float y, float z)
|
||||||
|
{
|
||||||
|
vec3(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
vertex(float x, float y, float z, float w)
|
||||||
|
{
|
||||||
|
vec4(x, y, z, w);
|
||||||
|
}
|
||||||
|
|
||||||
|
vertex(int x, int y, int z, int w)
|
||||||
|
{
|
||||||
|
vec4(static_cast<f32>(x), static_cast<f32>(y), static_cast<f32>(z), static_cast<f32>(w));
|
||||||
|
}
|
||||||
|
|
||||||
|
float& operator[](int index)
|
||||||
|
{
|
||||||
|
return values[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
void vec2(float x, float y)
|
||||||
|
{
|
||||||
|
values[0] = x;
|
||||||
|
values[1] = y;
|
||||||
|
values[2] = 0.f;
|
||||||
|
values[3] = 1.f;
|
||||||
|
}
|
||||||
|
|
||||||
|
void vec3(float x, float y, float z)
|
||||||
|
{
|
||||||
|
values[0] = x;
|
||||||
|
values[1] = y;
|
||||||
|
values[2] = z;
|
||||||
|
values[3] = 1.f;
|
||||||
|
}
|
||||||
|
|
||||||
|
void vec4(float x, float y, float z, float w)
|
||||||
|
{
|
||||||
|
values[0] = x;
|
||||||
|
values[1] = y;
|
||||||
|
values[2] = z;
|
||||||
|
values[3] = w;
|
||||||
|
}
|
||||||
|
|
||||||
|
void operator += (const vertex& other)
|
||||||
|
{
|
||||||
|
values[0] += other.values[0];
|
||||||
|
values[1] += other.values[1];
|
||||||
|
values[2] += other.values[2];
|
||||||
|
values[3] += other.values[3];
|
||||||
|
}
|
||||||
|
|
||||||
|
void operator -= (const vertex& other)
|
||||||
|
{
|
||||||
|
values[0] -= other.values[0];
|
||||||
|
values[1] -= other.values[1];
|
||||||
|
values[2] -= other.values[2];
|
||||||
|
values[3] -= other.values[3];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
struct vector3_base : public position3_base<T>
|
||||||
|
{
|
||||||
|
using position3_base<T>::position3_base;
|
||||||
|
|
||||||
|
vector3_base<T>(T x, T y, T z)
|
||||||
|
{
|
||||||
|
this->x = x;
|
||||||
|
this->y = y;
|
||||||
|
this->z = z;
|
||||||
|
}
|
||||||
|
|
||||||
|
vector3_base<T>(const position3_base<T>& other)
|
||||||
|
{
|
||||||
|
this->x = other.x;
|
||||||
|
this->y = other.y;
|
||||||
|
this->z = other.z;
|
||||||
|
}
|
||||||
|
|
||||||
|
T dot(const vector3_base<T>& rhs) const
|
||||||
|
{
|
||||||
|
return (this->x * rhs.x) + (this->y * rhs.y) + (this->z * rhs.z);
|
||||||
|
}
|
||||||
|
|
||||||
|
T distance(const vector3_base<T>& rhs) const
|
||||||
|
{
|
||||||
|
const vector3_base<T> d = *this - rhs;
|
||||||
|
return d.dot(d);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
vector3_base<T> operator * (const vector3_base<T>& lhs, const vector3_base<T>& rhs)
|
||||||
|
{
|
||||||
|
return { lhs.x * rhs.x, lhs.y * rhs.y, lhs.z * rhs.z };
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
vector3_base<T> operator * (const vector3_base<T>& lhs, T rhs)
|
||||||
|
{
|
||||||
|
return { lhs.x * rhs, lhs.y * rhs, lhs.z * rhs };
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
vector3_base<T> operator * (T lhs, const vector3_base<T>& rhs)
|
||||||
|
{
|
||||||
|
return { lhs * rhs.x, lhs * rhs.y, lhs * rhs.z };
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void operator *= (const vector3_base<T>& lhs, const vector3_base<T>& rhs)
|
||||||
|
{
|
||||||
|
lhs.x *= rhs.x;
|
||||||
|
lhs.y *= rhs.y;
|
||||||
|
lhs.z *= rhs.z;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void operator *= (const vector3_base<T>& lhs, T rhs)
|
||||||
|
{
|
||||||
|
lhs.x *= rhs;
|
||||||
|
lhs.y *= rhs;
|
||||||
|
lhs.z *= rhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void operator < (const vector3_base<T>& lhs, T rhs)
|
||||||
|
{
|
||||||
|
return lhs.x < rhs.x && lhs.y < rhs.y && lhs.z < rhs.z;
|
||||||
|
}
|
||||||
|
|
||||||
|
using vector3i = vector3_base<int>;
|
||||||
|
using vector3f = vector3_base<float>;
|
||||||
@@ -398,6 +398,7 @@
|
|||||||
<ClInclude Include="Emu\Io\Keyboard.h" />
|
<ClInclude Include="Emu\Io\Keyboard.h" />
|
||||||
<ClInclude Include="Emu\RSX\Common\texture_cache_helpers.h" />
|
<ClInclude Include="Emu\RSX\Common\texture_cache_helpers.h" />
|
||||||
<ClInclude Include="Emu\RSX\Overlays\overlay_perf_metrics.h" />
|
<ClInclude Include="Emu\RSX\Overlays\overlay_perf_metrics.h" />
|
||||||
|
<ClInclude Include="Emu\RSX\Overlays\overlay_utils.h" />
|
||||||
<ClInclude Include="Emu\RSX\Overlays\Shaders\shader_loading_dialog.h" />
|
<ClInclude Include="Emu\RSX\Overlays\Shaders\shader_loading_dialog.h" />
|
||||||
<ClInclude Include="Emu\RSX\Overlays\Shaders\shader_loading_dialog_native.h" />
|
<ClInclude Include="Emu\RSX\Overlays\Shaders\shader_loading_dialog_native.h" />
|
||||||
<ClInclude Include="util\atomic.hpp" />
|
<ClInclude Include="util\atomic.hpp" />
|
||||||
@@ -657,4 +658,4 @@
|
|||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
</Project>
|
</Project>
|
||||||
@@ -1606,5 +1606,8 @@
|
|||||||
<ClInclude Include="Emu\RSX\Overlays\Shaders\shader_loading_dialog.h">
|
<ClInclude Include="Emu\RSX\Overlays\Shaders\shader_loading_dialog.h">
|
||||||
<Filter>Emu\GPU\RSX\Overlays\Shaders</Filter>
|
<Filter>Emu\GPU\RSX\Overlays\Shaders</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="Emu\RSX\Overlays\overlay_utils.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
Reference in New Issue
Block a user