mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-01-30 03:32:55 +00:00
overlays: Move vertex & vector utility classes to new file
This commit is contained in:
parent
192912131e
commit
28770c1580
@ -1,67 +1,10 @@
|
||||
#pragma once
|
||||
#include "Utilities/types.h"
|
||||
#include "Utilities/geometry.h"
|
||||
#include "overlay_utils.h"
|
||||
|
||||
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
|
||||
{
|
||||
struct compiled_resource;
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include "Utilities/types.h"
|
||||
#include "Utilities/geometry.h"
|
||||
#include "Utilities/File.h"
|
||||
#include "overlay_utils.h"
|
||||
#include "Emu/System.h"
|
||||
|
||||
#include <string>
|
||||
@ -51,78 +52,6 @@ namespace rsx
|
||||
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
|
||||
{
|
||||
const u32 width = 1024;
|
||||
|
148
rpcs3/Emu/RSX/Overlays/overlay_utils.h
Normal file
148
rpcs3/Emu/RSX/Overlays/overlay_utils.h
Normal file
@ -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\RSX\Common\texture_cache_helpers.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_native.h" />
|
||||
<ClInclude Include="util\atomic.hpp" />
|
||||
@ -657,4 +658,4 @@
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
</Project>
|
@ -1606,5 +1606,8 @@
|
||||
<ClInclude Include="Emu\RSX\Overlays\Shaders\shader_loading_dialog.h">
|
||||
<Filter>Emu\GPU\RSX\Overlays\Shaders</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Emu\RSX\Overlays\overlay_utils.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
Loading…
x
Reference in New Issue
Block a user