the engiene is open source, from file dgBody teh code that integrate the velcity is this
- Code: Select all
void dgBody::IntegrateVelocity (dgFloat32 timestep)
{
...
// IntegrateNotUpdate (timestep);
m_globalCentreOfMass += m_veloc.Scale (timestep);
m_matrix.m_posit = m_globalCentreOfMass - m_matrix.RotateVector(m_localCentreOfMass);
}
and the code that integrate the accelration is this
- Code: Select all
void dgJacobianMemory::ApplyExternalForcesAndAcceleration (dgFloat32 tolerance) const
{
dgFloat32* const force = m_force;
const dgJacobianPair* const Jt = m_Jt;
const dgBodyInfo* const bodyArray = m_bodyArray;
const dgJointInfo* const constraintArray = m_constraintArray;
dgFloat32** const jointForceFeeback = m_jointFeebackForce;
dgJacobian* const internalForces = m_internalForces;
dgVector zero (dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f));
for (dgInt32 i = 0; i < m_bodyCount; i ++) {
internalForces[i].m_linear = zero;
internalForces[i].m_angular = zero;
}
dgInt32 hasJointFeeback = 0;
dgFloat32 accelTol2 = tolerance * tolerance;
for (dgInt32 i = 0; i < m_jointCount; i ++) {
dgInt32 first = constraintArray[i].m_autoPairstart;
dgInt32 count = constraintArray[i].m_autoPaircount;
dgInt32 m0 = constraintArray[i].m_m0;
dgInt32 m1 = constraintArray[i].m_m1;
dgJacobian y0;
dgJacobian y1;
y0.m_linear = zero;
y0.m_angular = zero;
y1.m_linear = zero;
y1.m_angular = zero;
for (dgInt32 j = 0; j < count; j ++) {
dgInt32 index = j + first;
dgFloat32 val = force[index];
_ASSERTE (dgCheckFloat(val));
jointForceFeeback[index][0] = val;
y0.m_linear += Jt[index].m_jacobian_IM0.m_linear.Scale (val);
y0.m_angular += Jt[index].m_jacobian_IM0.m_angular.Scale (val);
y1.m_linear += Jt[index].m_jacobian_IM1.m_linear.Scale (val);
y1.m_angular += Jt[index].m_jacobian_IM1.m_angular.Scale (val);
}
hasJointFeeback |= (constraintArray[i].m_joint->m_updaFeedbackCallback ? 1 : 0);
internalForces[m0].m_linear += y0.m_linear;
internalForces[m0].m_angular += y0.m_angular;
internalForces[m1].m_linear += y1.m_linear;
internalForces[m1].m_angular += y1.m_angular;
}
for (dgInt32 i = 1; i < m_bodyCount; i ++) {
dgBody* const body = bodyArray[i].m_body;
body->m_accel += internalForces[i].m_linear;
body->m_alpha += internalForces[i].m_angular;
dgVector accel (body->m_accel.Scale (body->m_invMass.m_w));
dgVector alpha (body->m_invWorldInertiaMatrix.RotateVector (body->m_alpha));
dgFloat32 error = accel % accel;
if (error < accelTol2) {
accel = zero;
body->m_accel = zero;
}
error = alpha % alpha;
if (error < accelTol2) {
alpha = zero;
body->m_alpha = zero;
}
body->m_netForce = body->m_accel;
body->m_netTorque = body->m_alpha;
body->m_veloc += accel.Scale(m_timeStep);
body->m_omega += alpha.Scale(m_timeStep);
}
}
Basically it adds the internal forces calculated by the joint solver to the external forces applyed in force and torque callback,
the result is divided by the mass of the body to get the acceleration, in you case both internal and external forces are both zero.
therefore the net acceleration soudl be zero too, and soudl no modify the velocity when integrate by the time step
body->m_netForce = body->m_accel;
body->m_netTorque = body->m_alpha;
body->m_veloc += accel.Scale(m_timeStep);
body->m_omega += alpha.Scale(m_timeStep);
and after the what followed in the integration of the velocity, is something is changing the velocity it must be that you are calling with a variable force, or you are printing some wrong variable.
Even if the time step is variable the velocity should be more or less const, and I see that it is an increasing quantity in your listing, even when is goes down, the next print recover, so somewhere the value is being saved.
these functions are used in all version of Newton, so I do no know what could be causing that, I do no even have 1.53 anymore.