Add CMake build and cross-platform cleanup

This commit is contained in:
Bram Verhulst
2026-04-12 23:15:20 +02:00
parent 81746db9ae
commit 1ba1c1f2cc
25 changed files with 350 additions and 56 deletions

View File

@@ -233,15 +233,15 @@ void utils::FillPolygon(const std::vector<Vector2f>& vertices) {
void utils::DrawArrow(const Vector2f& start, const Vector2f& end, float lineWidth, float arrowSize) {
// Origin is bottom left
utils::DrawLine(start, end);
utils::DrawLine(start, end, lineWidth);
const float arrowAngle = atan2f(end.y - start.y, end.x - start.x);
const float arrowAngle1 = arrowAngle + g_Pi + 0.4f;
const float arrowAngle2 = arrowAngle + g_Pi - 0.4f;
const Vector2f arrow1 { end.x + arrowSize * cosf(arrowAngle1), end.y + arrowSize * sinf(arrowAngle1) };
const Vector2f arrow2 { end.x + arrowSize * cosf(arrowAngle2), end.y + arrowSize * sinf(arrowAngle2) };
utils::DrawLine(end, arrow1);
utils::DrawLine(end, arrow2);
utils::DrawLine(end, arrow1, lineWidth);
utils::DrawLine(end, arrow2, lineWidth);
}
void utils::FillPolygon(const Vector2f* pVertices, size_t nrVertices) {
@@ -610,11 +610,14 @@ bool utils::IsRectInRect(const Rectf& r1, const Rectf& r2) {
bool utils::RayVsRect(const Vector2f& rayOrigin, const Vector2f& rayDir, const Rectf& target,
Vector2f& contactPoint, Vector2f& contactNormal, float& t_hit_near) {
// Vector2f t_near = Vector2f{(target.BottomLeft() - rayOrigin).x / rayDir.x, (target.BottomLeft() - rayOrigin).y / rayDir.y};
// Vector2f t_far = Vector2f{(target.BottomLeft() + Vector2f{target.width, target.height} - rayOrigin).x / rayDir.x, (target.BottomLeft() + Vector2f{target.width, target.height} - rayOrigin).y / rayDir.y};
Vector2f t_near {};
Vector2f t_far {};
Vector2f t_near {
(target.left - rayOrigin.x) / rayDir.x,
(target.bottom - rayOrigin.y) / rayDir.y
};
Vector2f t_far {
(target.left + target.width - rayOrigin.x) / rayDir.x,
(target.bottom + target.height - rayOrigin.y) / rayDir.y
};
if (std::isnan(t_far.y) || std::isnan(t_far.x))
return false;
@@ -757,4 +760,3 @@ bool utils::isMouseDown(int button) {
}
//utils::getScrollMovement()