<commit_before>#include "PCollide.hpp"

namespace Core
{
	bool CollideObjects(const PObject& obj1, const PObject& obj2)
	{
		if(!obj1.GetAABB().Intersect(obj2.GetAABB()))
		{
			return false;
		}

		return true;

		if(obj1.GetShape()->GetType() == PShape::e_poly && obj2.GetShape()->GetType() == PShape::e_poly)
		{
			PPoly &s1 = *((PPoly*)obj1.GetShape()),
				  &s2 = *((PPoly*)obj2.GetShape());


		}

	}
}<commit_msg>Refined collision detection for PPolys with SAT<commit_after>#include "PCollide.hpp"

namespace Core
{
	bool CollideObjects(const PObject& obj1, const PObject& obj2)
	{
		if(!obj1.GetAABB().Intersect(obj2.GetAABB()))
		{
			return false;
		}

		//return true;

		if(obj1.GetShape()->GetType() == PShape::e_poly && obj2.GetShape()->GetType() == PShape::e_poly)
		{
			PPoly s1(*(PPoly*)obj1.GetShape()),
				  s2(*(PPoly*)obj2.GetShape());

			for(int i = 0; i < s1.GetVertexCount(); i++)
			{
				const_cast<PVec2&>(s2.GetVertex(i)).Rotate(obj1.GetAngle());
				const_cast<PVec2&>(s2.GetVertex(i)) += obj1.GetPosition();
			}

			for(int i = 0; i < s2.GetVertexCount(); i++)
			{
				const_cast<PVec2&>(s2.GetVertex(i)).Rotate(obj2.GetAngle());
				const_cast<PVec2&>(s2.GetVertex(i)) += obj2.GetPosition();
			}

			PVec2 p1, p2;
			PSegm o1, o2;

			p1 = s1.GetVertex(s1.GetVertexCount() - 1);

			for(int i = 0; i < s1.GetVertexCount(); i++)
			{
				p2 = s1.GetVertex(i);
				PVec2 edge = p1 - p2;
				edge.Normalize();

				o1.Clear();
				o2.Clear();

				for(int j = 0; j < s1.GetVertexCount(); j++)
				{
					o1.AddPoint(s1.GetVertex(j).Dot(edge));
				}

				for(int j = 0; j < s2.GetVertexCount(); j++)
				{
					o2.AddPoint(s2.GetVertex(j).Dot(edge));
				}

				if(!o1.Intersect(o2))
				{
					return false;
				}

				p1 = p2;
			}

			p1 = s2.GetVertex(s2.GetVertexCount() - 1);

			for(int i = 0; i < s2.GetVertexCount(); i++)
			{
				p2 = s2.GetVertex(i);
				PVec2 edge = p1 - p2;
				edge.Normalize();

				o1.Clear();
				o2.Clear();

				for(int j = 0; j < s1.GetVertexCount(); j++)
				{
					o1.AddPoint(s1.GetVertex(j).Dot(edge));
				}

				for(int j = 0; j < s2.GetVertexCount(); j++)
				{
					o2.AddPoint(s2.GetVertex(j).Dot(edge));
				}

				if(!o1.Intersect(o2))
				{
					return false;
				}

				p1 = p2;
			}

		}

		return true;
	}


}
{'fraction_non_alphanumeric': 0.19721375707444494, 'fraction_numerical': 0.039616891597736174, 'mean_word_length': 2.8236272878535775, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1426748', 'n_tokens_mistral': 1200, 'n_tokens_neox': 968, 'n_words': 154}