In the frames of a number crunching compatible programming language (say.. C++), what would be an elegant solution for adding self collision, external collision and integration step (Euler, etc.) updates to an object? (say the already abused mass spring system).
Say the object class is this one:
class DeformableObject
{
public:
DeformableObject();
virtual ~DeformableObject();
protected:
vector <vec3<Real> > pos;
vec3<real> fEval(int idx); // - the internal force due to ellasticity at the idx-th node
friend class Integrator;
}
For example, in case of the integration method, I was thinking of having an abstract Integrator class and derive from it to add specific methods (Euler, Verlet, Midpoint, you name it).:
class Integrator
{
public:
Integrator();
virtual ~Integrator();
vec3<Real> Step(Real DTime, DeformableObject * dObject, int idx);
}
Now, since I'd like to switch or perhaps let different instances of the same deformable object use integration method A and the other use integration method B (for "benchmarking" purposes), is it safe to "think inside the box" and refer to either the Bridge or Strategy pattern? Which is more suitable and less ambiguous, especially performance-wise?
What about a self collision controller approach? Should I just add a self collision method to the DeformableObject
class or "befriend" it with a Collider class? And what about external collisions, with different objects - how should that aspect be approached, at least at the conceptual level: considering the naive, brute pair-to-pair collision queries, if two objects collide, their points must be updated in the sense that velocities and forces are added to the points' own dynamic quantities (e.g. restitution forces, penalty forces, friction forces, reflected velocities, impulse conservation velocity changes, etc.).
I know this is a broad topic, but I don't know which book does tackle these natural problems for a novice programmer. Thanks for your patience in reading this question!