Binary Function - Design Pattern Question
Hi,
so lets assume i wanted to write i collision system that can determine wheter some objects collide (e.g. sphere - cuboid, or triangle cylinder, or whatever).
The thing is, that all these objects should be stored in a container, e.g.
Code:
typedef Set<IGeometricObject*> MyContainer;
So how can i test wheter 2 objects of this container collide? The problem is, that i do not know the original type of the objects anymore. So i end up with something like:
Code:
bool is_collision(const IGeometricObject &r_lhs, const IGeometricObject &r_rhs)
{
// Hmmm... what now?
// check with type-id/dynamic cast?
}
So whats the best way to solve this without having long if blocks with dynamic casts and type-id checks?