refactor: detection collision

refactor:

+ Collision pour tout les objets, les objets differents d'une sphere seront traites comme des cubes
This commit is contained in:
StratiX0 2024-04-26 13:20:35 +02:00
parent 51771906ce
commit a8d9543c29
2 changed files with 5 additions and 9 deletions

View File

@ -7,7 +7,7 @@ Pos=1139,42
Size=392,214
[Window][Objects]
Pos=53,55
Pos=20,556
Size=637,299
[Window][Terrain]

View File

@ -83,14 +83,6 @@ bool Physics::IsColliding(Object* object1, Object* object2)
std::string type1 = object1->GetName();
std::string type2 = object2->GetName();
// Treat "plane" objects as "cube"
if (type1 == "plane") type1 = "cube";
if (type2 == "plane") type2 = "cube";
if (type1 == "cube" && type2 == "cube")
{
return CubesOverlap(object1, object2);
}
if (type1 == "sphere" && type2 == "sphere")
{
return SpheresOverlap(object1, object2);
@ -106,6 +98,10 @@ bool Physics::IsColliding(Object* object1, Object* object2)
return SphereCubeOverlap(object2, object1);
}
}
else
{
return CubesOverlap(object1, object2);
}
return false;
}