/***************************************************************************
*                                                                          *
*  Copyright (C) Golaem S.A.  All Rights Reserved.                         *
*                                                                          *
***************************************************************************/

#pragma once

#include "glmMathBase.h"
#include "glmVector2.h"

namespace glm
{
	class Triangle2;
	class Segment2;

	bool GLM_CORE_API areColliding(const Triangle2& triangle1, const Triangle2& triangle2, float precision = GLM_NUMERICAL_PRECISION);
    bool GLM_CORE_API areCollidingNoDegenerates(const Triangle2& triangle1, const Triangle2& triangle2);
    bool GLM_CORE_API areColliding(const Segment2& segment, const Vector2& rectMin, const Vector2& rectMax, float precision = GLM_NUMERICAL_PRECISION);
	bool GLM_CORE_API areColliding(const Triangle2& triangle, const Vector2& rectMin, const Vector2& rectMax, float precision = GLM_NUMERICAL_PRECISION);
	bool areColliding(const Vector2 & point, const Vector2 & min, const Vector2 & max, float precision = GLM_NUMERICAL_PRECISION);

    bool GLM_CORE_API areColliding(const Vector2& min1, const Vector2& max1, const Vector2& min2, const Vector2& max2, float precision = GLM_EPSILON);
}

//-----------------------------------------------------------------------------
inline bool glm::areColliding(const Vector2& point, const Vector2& min, const Vector2& max, float precision)
{
	Vector2 actualMin = min - Vector2(precision, precision);
	Vector2 actualMax = max + Vector2(precision, precision);
	return point.x >= actualMin.x && point.x <= actualMax.x &&
		point.y >= actualMin.y && point.y <= actualMax.y;
}
