Most of these counter and ofs variables were part of histogram in original code which i haven't translated since they are just for debugging variables. i admit my translation of the code looks very rough and bad, so it may need another re-translation to get it right
I was suspecting force and torque newton callback to have an error and the code i uploaded isn't proper since i was doing some experiments there, this should be proper callback routine (still doesn't fix the issue):
Code:
procedure BaseBodyForceAndTorqueCallback(const body: PNewtonBody); cdecl;
var
veh: PRCVehicle;
Force, torque, v: Vector;
i: integer;
begin
veh := NewtonBodyGetUserData(body);
force:= veh.vTotal;
torque:= makevector(0,0,0);
for i:= 0 to 3 do
begin
force:= AddVectors(force, veh.sRay[i].vTotal);
v:= RotateVector(veh.sRay[i].vlCol, veh.mBody);
torque:= AddVectors(torque, MulVectors(v, veh.sRay[i].vTotal));
end;
torque:= AddVectors(torque, veh.vTorque);
NewtonBodyAddForce(veh.pBody, @force);
NewtonBodyAddTorque(veh.pBody, @torque);
NewtonBodyGetForce(veh.pBody, @force);
NewtonBodyGetTorque(veh.pBody, @torque);
end;
Bookmarks