Original Post
I'm currently trying to design a physics engine. The engine is constructed of objects of the RigidBody type. Since I want to experiment with different ways of partitioning the object space I want to make a base class "PartitionedSpace" which the different methods (trees, grids,...) can inherit from. The interface of this base class gives the client the ability to add RigidBodies to the space, update the position of the objects in the space upon movement, and get a list of potential collisions. I have two questions about this: 1) Since every type of space partition will need the objects to store different information (such as cache information from the last collision checks) where should I store this information? It can't be stored in the RB itself because then I'd have to change the RB structure whenever I wanted to try out a new partitioning class. Should every partitioning class have it's own wrapper for the rigid bodies that it hold and store the information in that wrapper together with the RB? That seems sort of wasteful to me. 2) I only want to update the positions of the RBs in the partitioned space if they move. Does that mean that each RB will need to have the ability to update itself whenever it moves? If that's true then how can that be implemented without each rigid body having to point to information in the PartitionedSpace class? Thanks.