Hey all,

So I'm working on a rigid-body physics engine, it's supposed to be easily compatible with Ogre and fairly straightforward to use, for beginning game programmers.

I'm working on collision detection and contact resolution, and have gotten stuck at checking to see if two cubes (rectangular prisms, strictly speaking) are colliding.

The approach I'm taking is to check for point-face collision (when a corner point of the cube is inside the other cube) and edge-edge collision (when two edges are touching), as the other types are negligible and will likely become another type of contact in the next frame anyways.

Point-face collision is easy, but edge-edge collision is tricky. How do I check to see if two of the edges of a cube are colliding?

My cube data structure is something like this:

// Vect3 is a struct containing an x, y, and z elements, also equipped with normal vector operations like // getMagnitude, Normalize, scalar and vector products, etc. class Box : public Geometry { private: Vect3 m_halfSize; // Half-size in x, y, z coordinates // The Geometry class is equipped with a transform matrix to transform // world coordinates into the object's local coordinates. public: // ... // Returns true if this box is touching the given sphere. virtual bool isTouching(Sphere* s) const; // Returns true if this box is touching the given box. virtual bool isTouching(Box* b) const; // virtual unsigned int GenerateContacts(Sphere* s) = 0; // virtual unsigned int GenerateContacts(Box* b) = 0; };

Really I just need the math behind this, I've looked online but can't find anything useful.