The discussion on physics refactoring is for future work and do not
need to happen now. I just wanted to open the discussion so that when
we have more time for refactoring, we know which direction to go. I
agree with Harry that performance is a big problem right now and it
needs to be addressed urgently. The bigger physics refactoring can
happen later.
My two cents so far on the discussion:
* [Harry] The constraint receives the indices because we wanted
precisely the Representation to not have the indices (in our old code
base, the Representation had their own index). We just need to keep in
mind that these indices are not fixed and are dynamically assigned by
the PhysicsManager when processing the constraints (this will be very
useful when we will introduce Island type architecture in physics). So
far, we kept that information on the PhysicsManager level and this is
why it is passed on to the Constraint and not coming from the
Representation.
Potential problem that can arise from displacing the indices:
If the RepresentationIndex is pushed in the Representation, the
problem that can occur is that an MLCP build with a set of index is
backed-up or passed on to the Fast-Haptic, and the indices are not
part of it anymore but rather known by the Representation. If the
simulation keeps running and a new constraint configuration arises in
the scene, the PhysicsManager will re-assign the indices accordingly,
modifying the index with which our MLCP was build.
These indices are MLCP related (maybe a renaming would be in order ?)
and should stay close to the MLCP. The PhysicsManagerState was a good
spot to have them, right along with the MLCP. If they have to move,
they should go in the MlcpPhysicsProblem itself.
* [Paul] 1) If I understood properly, you see a 10ms time difference
between calling addFMDK and calling the individual methods. That is
actually very big in physics simulation. Keep in mind that the time
step is 1ms, so the real time taken to solve 1 time step should be as
close to 1ms as possible. In light of that, switching to calling the
individual methods will make us 10 times slower than we should already
be.
Even if we change the time step to 10ms, that means only calling the
individual methods is already chewing up all our time, not counting
the linear system resolution.
* [Paul] 2) What do you call not noticeable ?
* [Paul] 3) If switching from a diagonal matrix to a dense matrix has
no effect in time, I would argue we should drop Eigen for something
else ! I suspect, from your 2 comments, that we are doing the wrong
thing somewhere...and we should look into it.
Performance is a crucial factor in real time simulation and we need to
focus on it more. So any future refactoring that could potentially
make performances worst should be thought twice.
Finally, these refactoring can certainly happen in stages.
-- Julien