ok I found the going to sleep when not in equilibrium bug and I fixed.
The but was no on the contact function, it was here
../newton-dynamics\coreLibrary_300\source\physics\dgWorldDynamicsSimpleSolver.cpp
- Code: Select all
void dgWorldDynamicUpdate::CalculateReactionsForces(const dgIsland* const island, dgInt32 threadIndex, dgFloat32 timestep, dgFloat32 maxAccNorm) const
{
if (island->m_jointCount == 0) {
ApplyExternalForcesAndAcceleration (island, threadIndex, timestep, 0.0f);
// } else if (island->m_jointCount == 1) {
// CalculateSimpleBodyReactionsForces (island, rowStart, threadIndex, timestep, maxAccNorm);
// ApplyExternalForcesAndAcceleration (island, rowStart, threadIndex, timestep, maxAccNorm * dgFloat32 (0.001f));
} else {
dgWorld* const world = (dgWorld*) this;
if (world->m_solverMode && !island->m_hasExactSolverJoints) {
CalculateForcesGameMode (island, threadIndex, timestep, maxAccNorm);
} else {
dgAssert (timestep > dgFloat32 (0.0f));
// remember to make the change for the impulsive solver for CC
CalculateForcesSimulationMode (island, threadIndex, timestep, maxAccNorm);
}
}
}
if you look at the code, at some point I commnetd out the solver for small set of joints. That solev was a special case of the exact solver,
which is a line search algorithm for find the forces.
In theory that solver for one join sodu find the solution is one step (constant time), in pratice
I found that because the contact usually do not no sow a condition know as eigenvectors clustering, the function was taking a number of passes equal to the number of different unique eige vectors of the system matrix.
what the mean is the following, say you collide with a flat polygon or with a convex shape.
the collision system find foru contacts. each contact has two friction rows so the total number of row in the system matrix is 12
the contact normal will point on the same direction, so three, an singular value decomposition of the system matrix will find those four row to have the same eigen vectors,
the friction rows if the body does no have angular velocity, 4 friction contact will have the same direction, and the other 4 for also the same direction perpendicular to the first friction and the normal.
so the SBD will find only three different Eigen vectors. this mean that the exact solver will find the solution in three iterations, in practice it will do the equivalent of four because the initial set up step count as one pass.
the Is the absolute best that can be done.
In practice bodies do have angular velocity all the time, which means that each friction row will have his own unique direction, plus most objects collide with different polygons of meshed (differenct normal directions),
in general a collision between a box and a collision trees will have 12 or more rows, all with different Eigen vectors. which means at most 12 iterations but guarantee more than 4
That makes the exact solver also slower than the iterative one even when the iterative one takes many mare cheaper iterations.
I decided to comment out that special solver. an see how that worked for core 300.
The was all good, however my mistake was that I forget the exact solver uses very small tolerances, since in theory it should calculate exact values.
it turned out that the iterative solver with good initial guess is also very good specially with small number of joints,
so by using small tolerances with the iterative solver when the number of joint is 2 or less, that should make it almost identical to the exact solver.
please sync and try again let us see if the problem is fixed.
also please try the bounce bug again after you sync, I know do not think these are the same bug.
this
Sweenie wrote:So I need to run NewtonUpdate once with at least one body in the world before running the two simulation runs to get the same result both runs.
I guess the first call to NewtonUpdate initialize something that affects the results.
should not be necessary, but it is a good observation,
verify again with the ne code please,
I will also check what is up with that.