Pseudo-code:
struct Corner{ union { float Position[3]; struct { float x, y, z; }; }; Corner* Prev[3]; Corner* Next[3]; int Order[3];};struct AABB{ Corner LowerCorner; Corner UpperCorner;};
Link together and maintain sort of all LowerCorner.x and UpperCorner.x,
Link together and maintain sort of all LowerCorner.y and UpperCorner.y,
Link together and maintain sort of all LowerCorner.z and UpperCorner.z,
While sorting, keep track of sort order along each axis so that you know how many corner elements between the lower corner and upper corner components. Choose the one with the least number, and then check for collision only with those corner elements between the lower corner and upper corner along the chosen axis.
I had tolerable performance even with 1500 rapidly moving entities.
Value of good ideas: 10 cents per dozen.
Implementation of the good ideas: Priceless.
Proxima Rebellion - A 3D action sim with a hint of strategy
[edited by - BS-er on March 27, 2003 11:31:55 PM]