Original Post
Hey all, Is there a way to abstract collision volumes without RTTI? RTTI doesn't seem like the most flexible method, but I can't think of another way to accomplish it. I don't know if it's going to be such a big deal though, since collision bodies are rarely going to change. Here's what I mean:
class Body
{
virtual bool Collides(Body other);
}
class Rectangle : Body
{
virtual bool Collides(Body other)
{
if(other is Rectangle) {}
else if(other is Circle) {}
// etc, for every body.
}
}
class Circle : Body
{
virtual bool Collides(Body other)
{
if(other is Rectangle) {}
else if(other is Circle) {}
}
}
Every time you add a new body, you'll need go in and change every other body. I doubt that'll happen more than once or twice at best, but it's still not the safest of methods. However, tests can be very different between bodies. Stuck between a rock and a hard place... Ideas?