Regardless of whether I use functors or not, I would basically need a class like this, correct?
class CollisionSystem{public: int TestIntersection(Point* point, Point* another_point); int TestIntersection(Point* point, Segment* segment); int TestIntersection(Point* point, Ray* ray); int TestIntersection(Point* point, Line* line); int TestIntersection(Point* point, Plane* plane); int TestIntersection(Point* point, Sphere* sphere); int TestIntersection(Point* point, Box* box); int TestIntersection(Point* point, Frustum* frustum); int TestIntersection(Point* point, Cone* cone); int TestIntersection(Point* point, Cylinder* cylinder); int TestIntersection(Segment* segment, Point* point); int TestIntersection(Segment* segment, Segment* another_segment); int TestIntersection(Segment* segment, Ray* ray); int TestIntersection(Segment* segment, Line* line); int TestIntersection(Segment* segment, Plane* plane); int TestIntersection(Segment* segment, Sphere* sphere); int TestIntersection(Segment* segment, Box* box); int TestIntersection(Segment* segment, Frustum* frustum); int TestIntersection(Segment* segment, Cone* cone); int TestIntersection(Segment* segment, Cylinder* cylinder); int TestIntersection(Ray* ray, Point* point); int TestIntersection(Ray* ray, Segment* segment); int TestIntersection(Ray* ray, Ray* another_ray); int TestIntersection(Ray* ray, Line* line); int TestIntersection(Ray* ray, Plane* plane); int TestIntersection(Ray* ray, Sphere* sphere); int TestIntersection(Ray* ray, Box* box); int TestIntersection(Ray* ray, Frustum* frustum); int TestIntersection(Ray* ray, Cone* cone); int TestIntersection(Ray* ray, Cylinder* cylinder); int TestIntersection(Line* line, Point* point); int TestIntersection(Line* line, Segment* segment); int TestIntersection(Line* line, Ray* ray); int TestIntersection(Line* line, Line* another_line); int TestIntersection(Line* line, Plane* plane); int TestIntersection(Line* line, Sphere* sphere); int TestIntersection(Line* line, Box* box); int TestIntersection(Line* line, Frustum* frustum); int TestIntersection(Line* line, Cone* cone); int TestIntersection(Line* line, Cylinder* cylinder); int TestIntersection(Plane* plane, Point* point); int TestIntersection(Plane* plane, Segment* segment); int TestIntersection(Plane* plane, Ray* ray); int TestIntersection(Plane* plane, Line* line); int TestIntersection(Plane* plane, Plane* another_plane); int TestIntersection(Plane* plane, Sphere* sphere); int TestIntersection(Plane* plane, Box* box); int TestIntersection(Plane* plane, Frustum* frustum); int TestIntersection(Plane* plane, Cone* cone); int TestIntersection(Plane* plane, Cylinder* cylinder); int TestIntersection(Sphere* sphere, Point* point); int TestIntersection(Sphere* sphere, Segment* segment); int TestIntersection(Sphere* sphere, Ray* ray); int TestIntersection(Sphere* sphere, Line* line); int TestIntersection(Sphere* sphere, Plane* plane); int TestIntersection(Sphere* sphere, Sphere* another_sphere); int TestIntersection(Sphere* sphere, Box* box); int TestIntersection(Sphere* sphere, Frustum* frustum); int TestIntersection(Sphere* sphere, Cone* cone); int TestIntersection(Sphere* sphere, Cylinder* cylinder); int TestIntersection(Box* box, Point* point); int TestIntersection(Box* box, Segment* segment); int TestIntersection(Box* box, Ray* ray); int TestIntersection(Box* box, Line* line); int TestIntersection(Box* box, Plane* plane); int TestIntersection(Box* box, Sphere* sphere); int TestIntersection(Box* box, Box* another_box); int TestIntersection(Box* box, Frustum* frustum); int TestIntersection(Box* box, Cone* cone); int TestIntersection(Box* box, Cylinder* cylinder); int TestIntersection(Frustum* frustum, Point* point); int TestIntersection(Frustum* frustum, Segment* segment); int TestIntersection(Frustum* frustum, Ray* ray); int TestIntersection(Frustum* frustum, Line* line); int TestIntersection(Frustum* frustum, Plane* plane); int TestIntersection(Frustum* frustum, Sphere* sphere); int TestIntersection(Frustum* frustum, Box* box); int TestIntersection(Frustum* frustum, Frustum* another_frustum); int TestIntersection(Frustum* frustum, Cone* cone); int TestIntersection(Frustum* frustum, Cylinder* cylinder); int TestIntersection(Cone* cone, Point* point); int TestIntersection(Cone* cone, Segment* segment); int TestIntersection(Cone* cone, Ray* ray); int TestIntersection(Cone* cone, Line* line); int TestIntersection(Cone* cone, Plane* plane); int TestIntersection(Cone* cone, Sphere* sphere); int TestIntersection(Cone* cone, Box* box); int TestIntersection(Cone* cone, Frustum* frustum); int TestIntersection(Cone* cone, Cone* another_cone); int TestIntersection(Cone* cone, Cylinder* cylinder); int TestIntersection(Cylinder* cylinder, Point* point); int TestIntersection(Cylinder* cylinder, Segment* segment); int TestIntersection(Cylinder* cylinder, Ray* ray); int TestIntersection(Cylinder* cylinder, Line* line); int TestIntersection(Cylinder* cylinder, Plane* plane); int TestIntersection(Cylinder* cylinder, Sphere* sphere); int TestIntersection(Cylinder* cylinder, Box* box); int TestIntersection(Cylinder* cylinder, Frustum* frustum); int TestIntersection(Cylinder* cylinder, Cone* cone); int TestIntersection(Cylinder* cylinder, Cylinder* another_cylinder);};
note: You may notice semi-duplicate functions in there, like TestIntersection(Ray*, Line*) and TestIntersection(Line*, Ray*). One of the functions would simply call the other, to allow the functions to be used either way.It would be quite large, and it really seems like there could be a better way. Every time a new class is added I would add another block of TestIntersection() functions.
evolutional, with your method of using the shape pair as an index to functors, how do you get the type of the shapes at run-time? Do you simply have a GetType() function and an enumerated list of object types?
Any other thoughts?
- Mike