Fix the car elevating logic in SimCarCollideZ

git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@6312 30fe4595-0a0c-4342-8851-515496e4dcbd

Former-commit-id: 6fbe931ea88e324ea50701be6f14b6a758751cbe
Former-commit-id: 3c56977a3bf8c946306f5b8f60901505cd3fb79a
This commit is contained in:
kakukri 2015-12-22 00:18:02 +00:00
parent 4f9541a021
commit e62dce7011

View file

@ -29,6 +29,7 @@ void SimCarCollideZ(tCar *car)
tdble dotProd; tdble dotProd;
tWheel *wheel; tWheel *wheel;
const float CRASH_THRESHOLD = -5.0f; const float CRASH_THRESHOLD = -5.0f;
tdble dz = 0.0f;
if (car->carElt->_state & RM_CAR_STATE_NO_SIMU) { if (car->carElt->_state & RM_CAR_STATE_NO_SIMU) {
return; return;
@ -36,8 +37,9 @@ void SimCarCollideZ(tCar *car)
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
wheel = &(car->wheel[i]); wheel = &(car->wheel[i]);
if (wheel->state & SIM_SUSP_COMP) { if ( (wheel->state & SIM_SUSP_COMP)&&(!(wheel->state & SIM_WH_INAIR)) ) {
car->DynGCg.pos.z += wheel->susp.spring.packers - wheel->rideHeight; dz = MAX(dz, wheel->susp.spring.packers - wheel->rideHeight);
wheel->rideHeight = wheel->susp.spring.packers;
RtTrackSurfaceNormalL(&(wheel->trkPos), &normal); RtTrackSurfaceNormalL(&(wheel->trkPos), &normal);
dotProd = (car->DynGCg.vel.x * normal.x + car->DynGCg.vel.y * normal.y + car->DynGCg.vel.z * normal.z) * wheel->trkPos.seg->surface->kRebound; dotProd = (car->DynGCg.vel.x * normal.x + car->DynGCg.vel.y * normal.y + car->DynGCg.vel.z * normal.z) * wheel->trkPos.seg->surface->kRebound;
if (dotProd < 0.0f) { if (dotProd < 0.0f) {
@ -59,6 +61,7 @@ void SimCarCollideZ(tCar *car)
} }
} }
} }
car->DynGCg.pos.z += dz; //elevate car when it is slightly sinken into ground
} }
const tdble BorderFriction = 0.0f; const tdble BorderFriction = 0.0f;