diff --git a/src/modules/simu/simuv4/axle.cpp b/src/modules/simu/simuv4/axle.cpp index 68a364fe4..6ab4e0913 100644 --- a/src/modules/simu/simuv4/axle.cpp +++ b/src/modules/simu/simuv4/axle.cpp @@ -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)); diff --git a/src/modules/simu/simuv4/car.cpp b/src/modules/simu/simuv4/car.cpp index e4d4d5f4f..ab4aa6466 100644 --- a/src/modules/simu/simuv4/car.cpp +++ b/src/modules/simu/simuv4/car.cpp @@ -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 diff --git a/src/modules/simu/simuv4/sim.h b/src/modules/simu/simuv4/sim.h index e8b41ab1b..74c291adc 100644 --- a/src/modules/simu/simuv4/sim.h +++ b/src/modules/simu/simuv4/sim.h @@ -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); diff --git a/src/modules/simu/simuv4/simu.cpp b/src/modules/simu/simuv4/simu.cpp index a4a3ff9fc..8179ab96b 100644 --- a/src/modules/simu/simuv4/simu.cpp +++ b/src/modules/simu/simuv4/simu.cpp @@ -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);