2022-07-26 12:40:54 +08:00
|
|
|
module;
|
|
|
|
#include <d2d1.h>
|
2022-08-05 23:50:08 +08:00
|
|
|
#include <concepts>
|
2022-07-26 12:40:54 +08:00
|
|
|
|
|
|
|
export module Math;
|
|
|
|
|
|
|
|
export
|
|
|
|
{
|
|
|
|
struct Vector2 : D2D1_POINT_2F
|
|
|
|
{
|
|
|
|
|
|
|
|
};
|
|
|
|
struct Rect : D2D1_RECT_F
|
|
|
|
{
|
2022-08-01 17:19:30 +08:00
|
|
|
Vector2 size() const&
|
|
|
|
{
|
|
|
|
return { right - left, bottom - top };
|
|
|
|
}
|
2022-07-26 12:40:54 +08:00
|
|
|
};
|
2022-08-05 23:50:08 +08:00
|
|
|
|
|
|
|
inline bool isIntersection(const Rect& lhs, const Rect& rhs)
|
|
|
|
{
|
|
|
|
auto ox1 = (lhs.left + lhs.right) * 0.5f;
|
|
|
|
auto oy1 = (lhs.top + lhs.bottom) * 0.5f;
|
|
|
|
auto ox2 = (rhs.left + rhs.right) * 0.5f;
|
|
|
|
auto oy2 = (rhs.top + rhs.bottom) * 0.5f;
|
|
|
|
|
|
|
|
auto rx1 = abs(lhs.right - lhs.left) * 0.5f;
|
|
|
|
auto ry1 = abs(lhs.top - lhs.bottom) * 0.5f;
|
|
|
|
auto rx2 = abs(rhs.right - rhs.left) * 0.5f;
|
|
|
|
auto ry2 = abs(rhs.top - rhs.bottom) * 0.5f;
|
|
|
|
|
|
|
|
return ((abs(ox1 - ox2) - (rx1 + rx2)) < -20.f) && ((abs(oy1 - oy2) - (ry1 + ry2)) < -20.f);
|
|
|
|
}
|
2022-07-26 12:40:54 +08:00
|
|
|
}
|