Re #924: deal with instant setup changes and pit stops in simuv4
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@6252 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 30b5528cfc7f9a72a37725db3db1b757579b8889 Former-commit-id: 671d172dd4fc66ac376677eab4a127c9f8307f82
This commit is contained in:
parent
cae541787b
commit
3d8091c201
4 changed files with 92 additions and 13 deletions
|
@ -61,20 +61,25 @@ void SimAxleConfig(tCar *car, int index)
|
|||
car->wheel[index*2+1].feedBack.I += (tdble) (axle->I / 2.0);
|
||||
}
|
||||
|
||||
void SimArbReConfig(tCar *car, int index)
|
||||
{
|
||||
tCarSetupItem *setupArbK = &(car->carElt->setup.arbSpring[index]);
|
||||
tSuspension *arb = &(car->axle[index].arbSusp);
|
||||
if (setupArbK->changed) {
|
||||
arb->spring.K = MIN(setupArbK->max, MAX(setupArbK->min, setupArbK->desired_value));
|
||||
setupArbK->value = arb->spring.K;
|
||||
setupArbK->changed = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
void SimAxleReConfig(tCar *car, int index, tdble weight0)
|
||||
{/* called by SimCarReConfig() in car.cpp */
|
||||
tCarSetupItem *setupArbK = &(car->carElt->setup.arbSpring[index]);
|
||||
tCarSetupItem *setupRideHeightR = &(car->carElt->setup.rideHeight[index*2]);
|
||||
tCarSetupItem *setupRideHeightL = &(car->carElt->setup.rideHeight[index*2+1]);
|
||||
tAxle *axle = &(car->axle[index]);
|
||||
tdble x0r, x0l;
|
||||
|
||||
if (setupArbK->changed) {
|
||||
axle->arbSusp.spring.K = MIN(setupArbK->max, MAX(setupArbK->min, setupArbK->desired_value));
|
||||
setupArbK->value = axle->arbSusp.spring.K;
|
||||
setupArbK->changed = FALSE;
|
||||
}
|
||||
SimArbReConfig(car, index);
|
||||
|
||||
if (setupRideHeightR->changed) {
|
||||
x0r = MIN(setupRideHeightR->max, MAX(setupRideHeightR->min, setupRideHeightR->desired_value));
|
||||
|
|
|
@ -110,8 +110,12 @@ SimCarConfig(tCar *car)
|
|||
setupGcrrl->stepsize = 0.005;
|
||||
gcrrl = setupGcrrl->desired_value;
|
||||
|
||||
car->tank = GfParmGetNum(hdle, SECT_CAR, PRM_TANK, (char*)NULL, 80);
|
||||
|
||||
setupFuel->desired_value = setupFuel->min = setupFuel->max = 80.0;
|
||||
GfParmGetNumWithLimits(hdle, SECT_CAR, PRM_FUEL, (char*)NULL, &(setupFuel->desired_value), &(setupFuel->min), &(setupFuel->max));
|
||||
setupFuel->min = 0.0;
|
||||
setupFuel->max = car->tank;
|
||||
setupFuel->changed = TRUE;
|
||||
setupFuel->stepsize = 1.0;
|
||||
|
||||
|
@ -123,7 +127,6 @@ SimCarConfig(tCar *car)
|
|||
car->Minv = (tdble) (1.0 / car->mass);
|
||||
car->statGC.y = (tdble) (- (gcfr * gcfrl + (1 - gcfr) * gcrrl) * car->dimension.y + car->dimension.y / 2.0);
|
||||
car->statGC.z = GfParmGetNum(hdle, SECT_CAR, PRM_GCHEIGHT, (char*)NULL, .5);
|
||||
car->tank = GfParmGetNum(hdle, SECT_CAR, PRM_TANK, (char*)NULL, 80);
|
||||
k = GfParmGetNum(hdle, SECT_CAR, PRM_CENTR, (char*)NULL, 1.0);
|
||||
carElt->_drvPos_x = GfParmGetNum(hdle, SECT_DRIVER, PRM_XPOS, (char*)NULL, 0.0);
|
||||
carElt->_drvPos_y = GfParmGetNum(hdle, SECT_DRIVER, PRM_YPOS, (char*)NULL, 0.0);
|
||||
|
@ -132,9 +135,6 @@ SimCarConfig(tCar *car)
|
|||
carElt->_bonnetPos_y = GfParmGetNum(hdle, SECT_BONNET, PRM_YPOS, (char*)NULL, carElt->_drvPos_y);
|
||||
carElt->_bonnetPos_z = GfParmGetNum(hdle, SECT_BONNET, PRM_ZPOS, (char*)NULL, carElt->_drvPos_z);
|
||||
|
||||
if (setupFuel->max > car->tank) {setupFuel->max = car->tank;}
|
||||
if (setupFuel->min > car->tank) {setupFuel->min = car->tank;}
|
||||
|
||||
k = k * k;
|
||||
car->Iinv.x = (tdble) (12.0 / (car->mass * k * (car->dimension.y * car->dimension.y + car->dimension.z * car->dimension.z)));
|
||||
car->Iinv.y = (tdble) (12.0 / (car->mass * k * (car->dimension.x * car->dimension.x + car->dimension.z * car->dimension.z)));
|
||||
|
@ -927,6 +927,15 @@ SimCarUpdate(tCar *car, tSituation * /* s */)
|
|||
CHECK(car);
|
||||
SimCarCollideXYScene(car);
|
||||
CHECK(car);
|
||||
|
||||
/* update car->carElt->setup.reqRepair with damage */
|
||||
tCarSetupItem *repair = &(car->carElt->setup.reqRepair);
|
||||
if ((repair->desired_value > 0.0) && (repair->max == repair->desired_value)) {
|
||||
repair->max = repair->desired_value = car->dammage;
|
||||
} else {
|
||||
repair->max = car->dammage;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -48,6 +48,7 @@ extern tDynPt* GetSimCarTable(int index);
|
|||
|
||||
extern void SimAxleConfig(tCar *car, int index);
|
||||
extern void SimAxleReConfig(tCar *car, int index, tdble weight0);
|
||||
extern void SimArbReConfig(tCar *car, int index);
|
||||
extern void SimAxleUpdate(tCar *car, int index);
|
||||
|
||||
extern void SimCarConfig(tCar *car);
|
||||
|
|
|
@ -206,14 +206,74 @@ SimReConfig(tCarElt *carElt)
|
|||
car->dammage -= carElt->pitcmd.repair;
|
||||
if (car->dammage < 0) car->dammage = 0;
|
||||
}
|
||||
carElt->setup.reqRepair.desired_value = 0.0;
|
||||
|
||||
for(i=0; i<4; i++) {
|
||||
car->wheel[i].treadDepth = 1.0;
|
||||
car->wheel[i].Ttire = car->wheel[i].Tinit;
|
||||
if (carElt->setup.reqTireset.desired_value > 0.9) {
|
||||
for(i=0; i<4; i++) {
|
||||
car->wheel[i].treadDepth = 1.0;
|
||||
car->wheel[i].Ttire = car->wheel[i].Tinit;
|
||||
}
|
||||
}
|
||||
|
||||
SimWingReConfig(car, 0);
|
||||
SimWingReConfig(car, 1);
|
||||
}
|
||||
|
||||
|
||||
/* deal with dashboardInstant changes */
|
||||
void
|
||||
SimInstantReConfig(tCar *car)
|
||||
{
|
||||
tCarSetupItem *setup;
|
||||
|
||||
if (car->ctrl->setupChangeCmd) {
|
||||
setup = (car->ctrl->setupChangeCmd->setup);
|
||||
} else return;
|
||||
|
||||
switch (car->ctrl->setupChangeCmd->type) {
|
||||
case DI_BRAKE_REPARTITION:
|
||||
SimBrakeSystemReConfig(car);
|
||||
break;
|
||||
case DI_FRONT_ANTIROLLBAR:
|
||||
SimArbReConfig(car, 0);
|
||||
break;
|
||||
case DI_REAR_ANTIROLLBAR:
|
||||
SimArbReConfig(car, 1);
|
||||
break;
|
||||
case DI_FRONT_DIFF_MAX_SLIP_BIAS:
|
||||
car->transmission.differential[TRANS_FRONT_DIFF].dSlipMax = setup->desired_value;
|
||||
setup->value = car->transmission.differential[TRANS_FRONT_DIFF].dSlipMax;
|
||||
setup->changed = FALSE;
|
||||
break;
|
||||
case DI_FRONT_DIFF_COAST_MAX_SLIP_BIAS:
|
||||
car->transmission.differential[TRANS_FRONT_DIFF].dCoastSlipMax = setup->desired_value;
|
||||
setup->value = car->transmission.differential[TRANS_FRONT_DIFF].dCoastSlipMax;
|
||||
setup->changed = FALSE;
|
||||
break;
|
||||
case DI_REAR_DIFF_MAX_SLIP_BIAS:
|
||||
car->transmission.differential[TRANS_REAR_DIFF].dSlipMax = setup->desired_value;
|
||||
setup->value = car->transmission.differential[TRANS_REAR_DIFF].dSlipMax;
|
||||
setup->changed = FALSE;
|
||||
break;
|
||||
case DI_REAR_DIFF_COAST_MAX_SLIP_BIAS:
|
||||
car->transmission.differential[TRANS_REAR_DIFF].dCoastSlipMax = setup->desired_value;
|
||||
setup->value = car->transmission.differential[TRANS_REAR_DIFF].dCoastSlipMax;
|
||||
setup->changed = FALSE;
|
||||
break;
|
||||
case DI_CENTRAL_DIFF_MAX_SLIP_BIAS:
|
||||
car->transmission.differential[TRANS_CENTRAL_DIFF].dSlipMax = setup->desired_value;
|
||||
setup->value = car->transmission.differential[TRANS_CENTRAL_DIFF].dSlipMax;
|
||||
setup->changed = FALSE;
|
||||
break;
|
||||
case DI_CENTRAL_DIFF_COAST_MAX_SLIP_BIAS:
|
||||
car->transmission.differential[TRANS_CENTRAL_DIFF].dCoastSlipMax = setup->desired_value;
|
||||
setup->value = car->transmission.differential[TRANS_CENTRAL_DIFF].dCoastSlipMax;
|
||||
setup->changed = FALSE;
|
||||
break;
|
||||
}
|
||||
car->ctrl->setupChangeCmd = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
RemoveCar(tCar *car, tSituation *s)
|
||||
{
|
||||
|
@ -408,6 +468,8 @@ SimUpdate(tSituation *s, double deltaTime)
|
|||
CHECK(car);
|
||||
ctrlCheck(car);
|
||||
CHECK(car);
|
||||
SimInstantReConfig(car);
|
||||
CHECK(car);
|
||||
SimSteerUpdate(car);
|
||||
CHECK(car);
|
||||
SimGearboxUpdate(car);
|
||||
|
@ -554,6 +616,8 @@ SimUpdateSingleCar(int index, double deltaTime,tSituation *s)
|
|||
CHECK(car);
|
||||
ctrlCheck(car);
|
||||
CHECK(car);
|
||||
SimInstantReConfig(car);
|
||||
CHECK(car);
|
||||
SimSteerUpdate(car);
|
||||
CHECK(car);
|
||||
SimGearboxUpdate(car);
|
||||
|
|
Loading…
Reference in a new issue