Guys, I have problems figuring out the best way to structure my collision algorithms.
Until now I had only two:
1. Collision between a ray and an AABB.
2. Collision between a point and an AABB.
Now that I'm starting to need more different collisions, my code is getting pretty awful.
The first reason for this is the following:
I have two base classes. The class Object is the base class for all static objects.( map, bullets, houses, etc ) and the class Character is the base class for all animated objects.( player, enemies, etc. ). Class Player and class Enemy inherit from the base class Character.
The problem now is that when I want to check a collision between an Object and an Enemy, I need to declare a function something like this:
check_collision( Object& obj, Enemy& enemy ).
And when I need to check collision between an object and a player, I need the same function, but with different parameters:
check_collision( Object& obj, Player& player )
And if I create another class that inherits from Character. I need to make a third check_collision() function. Is it ok to overload the function like that, or is it better to somehow use polymorphism?
And the second problem is that I have different kinds of collisions and I don't know how to structure my code.
1st way is to make the function based on states like that:
check_collision( RAY_AABB, Object& obj, Player& player )
check_collision( SPHERE_AABB, Object& obj, Player& player )
or is it better to just make a different name for the function like this, CheckCollisionRayAABB, and CheckCollisionSphereAABB?
The question is kind of stupid, but I find it really hard to design and name the functions properly, maybe because English is not my mother language, I don't know.
Anyway, thanks for reading, I hope you have some suggestions.