Re #924: Add SimAxleReConfig, SimCarReConfig, SimSuspReConfig, SimWheelReConfig
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@6226 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: a372c2b87ae42906a0f0466ad62e15c482753e98 Former-commit-id: ac74d56653cf420fbe8ffd331ef2cc841c112a38
This commit is contained in:
parent
da0064ed57
commit
e36be8197a
7 changed files with 513 additions and 83 deletions
|
@ -349,12 +349,11 @@ SimWingConfig(tCar *car, int index)
|
|||
wing->Kx3 = 1.0f;
|
||||
wing->Kx4 = 0.9f;
|
||||
}
|
||||
SimWingReConfig(car, index);
|
||||
}
|
||||
|
||||
void
|
||||
SimWingReConfig(tCar *car, int index)
|
||||
{
|
||||
{/* called by SimCarReConfig() in car.cpp */
|
||||
tWing *wing = &(car->wing[index]);
|
||||
tCarSetupItem *angle = &(car->carElt->setup.wingAngle[index]);
|
||||
|
||||
|
|
|
@ -22,26 +22,39 @@
|
|||
static const char *AxleSect[2] = {SECT_FRNTAXLE, SECT_REARAXLE};
|
||||
static const char *WheelSect[4] = {SECT_FRNTRGTWHEEL, SECT_FRNTLFTWHEEL, SECT_REARRGTWHEEL, SECT_REARLFTWHEEL};
|
||||
|
||||
void SimAxleConfig(tCar *car, int index, tdble weight0)
|
||||
void SimAxleConfig(tCar *car, int index)
|
||||
{
|
||||
void *hdle = car->params;
|
||||
tdble x0r, x0l;
|
||||
|
||||
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]);
|
||||
|
||||
axle->xpos = GfParmGetNum(hdle, AxleSect[index], PRM_XPOS, (char*)NULL, 0.0f);
|
||||
axle->I = GfParmGetNum(hdle, AxleSect[index], PRM_INERTIA, (char*)NULL, 0.15f);
|
||||
x0r = GfParmGetNum(hdle, WheelSect[index*2], PRM_RIDEHEIGHT, (char*)NULL, 0.20f);
|
||||
x0l = GfParmGetNum(hdle, WheelSect[index*2+1], PRM_RIDEHEIGHT, (char*)NULL, 0.20f);
|
||||
|
||||
setupRideHeightR->desired_value = setupRideHeightR->min = setupRideHeightR->max = 0.20f;
|
||||
GfParmGetNumWithLimits(hdle, WheelSect[index*2], PRM_RIDEHEIGHT, (char*)NULL, &(setupRideHeightR->desired_value), &(setupRideHeightR->min), &(setupRideHeightR->max));
|
||||
setupRideHeightR->changed = TRUE;
|
||||
setupRideHeightR->stepsize = 0.001;
|
||||
|
||||
setupRideHeightL->desired_value = setupRideHeightL->min = setupRideHeightL->max = 0.20f;
|
||||
GfParmGetNumWithLimits(hdle, WheelSect[index*2+1], PRM_RIDEHEIGHT, (char*)NULL, &(setupRideHeightL->desired_value), &(setupRideHeightL->min), &(setupRideHeightL->max));
|
||||
setupRideHeightL->changed = TRUE;
|
||||
setupRideHeightL->stepsize = 0.001;
|
||||
|
||||
if (index == 0) {
|
||||
SimSuspConfig(hdle, SECT_FRNTARB, &(axle->arbSusp), 0, 0);
|
||||
axle->arbSusp.spring.K = -axle->arbSusp.spring.K;
|
||||
SimSuspConfig(hdle, SECT_FRNTHEAVE, &(axle->heaveSusp), weight0, (tdble) (0.5*(x0r+x0l)));
|
||||
setupArbK->desired_value = setupArbK->min = setupArbK->max = 175000.0f;
|
||||
GfParmGetNumWithLimits(hdle, SECT_FRNTARB, PRM_SPR, (char*)NULL, &(setupArbK->desired_value), &(setupArbK->min), &(setupArbK->max));
|
||||
setupArbK->changed = TRUE;
|
||||
setupArbK->stepsize = 1000;
|
||||
SimSuspConfig(car, hdle, SECT_FRNTHEAVE, &(axle->heaveSusp), 4);
|
||||
} else {
|
||||
SimSuspConfig(hdle, SECT_REARARB, &(axle->arbSusp), 0, 0);
|
||||
axle->arbSusp.spring.K = -axle->arbSusp.spring.K;
|
||||
SimSuspConfig(hdle, SECT_REARHEAVE, &(axle->heaveSusp), weight0, (tdble) (0.5*(x0r+x0l)));
|
||||
setupArbK->desired_value = setupArbK->min = setupArbK->max = 175000.0f;
|
||||
GfParmGetNumWithLimits(hdle, SECT_REARARB, PRM_SPR, (char*)NULL, &(setupArbK->desired_value), &(setupArbK->min), &(setupArbK->max));
|
||||
setupArbK->changed = TRUE;
|
||||
setupArbK->stepsize = 1000;
|
||||
SimSuspConfig(car, hdle, SECT_REARHEAVE, &(axle->heaveSusp), 5);
|
||||
}
|
||||
|
||||
car->wheel[index*2].feedBack.I += (tdble) (axle->I / 2.0);
|
||||
|
@ -49,7 +62,40 @@ void SimAxleConfig(tCar *car, int index, tdble weight0)
|
|||
}
|
||||
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
if (setupRideHeightR->changed) {
|
||||
x0r = MIN(setupRideHeightR->max, MAX(setupRideHeightR->min, setupRideHeightR->desired_value));
|
||||
setupRideHeightR->value = x0r;
|
||||
setupRideHeightR->changed = FALSE;
|
||||
} else {
|
||||
x0r = setupRideHeightR->value;
|
||||
}
|
||||
if (setupRideHeightL->changed) {
|
||||
x0l = MIN(setupRideHeightL->max, MAX(setupRideHeightL->min, setupRideHeightL->desired_value));
|
||||
setupRideHeightL->value = x0l;
|
||||
setupRideHeightL->changed = FALSE;
|
||||
} else {
|
||||
x0l = setupRideHeightL->value;
|
||||
}
|
||||
if (index==0) {
|
||||
SimSuspReConfig(car, &(axle->heaveSusp), 4, weight0, (tdble) (0.5*(x0r+x0l)));
|
||||
} else {
|
||||
SimSuspReConfig(car, &(axle->heaveSusp), 5, weight0, (tdble) (0.5*(x0r+x0l)));
|
||||
}
|
||||
}
|
||||
|
||||
void SimAxleUpdate(tCar *car, int index)
|
||||
{
|
||||
|
|
|
@ -102,13 +102,11 @@ SimBrakeSystemConfig(tCar *car)
|
|||
setupBrkPress->stepsize = 1000;
|
||||
|
||||
car->brkSyst.ebrake_pressure = GfParmGetNum(hdle, SECT_BRKSYST, PRM_EBRKPRESS, (char*)NULL, 0.0);
|
||||
|
||||
SimBrakeSystemReConfig(car);
|
||||
}
|
||||
|
||||
void
|
||||
SimBrakeSystemReConfig(tCar *car)
|
||||
{
|
||||
{/* called by SimCarReConfig() in car.cpp */
|
||||
tCarSetupItem *setupBrkRep = &(car->carElt->setup.brakeRepartition);
|
||||
tCarSetupItem *setupBrkPress = &(car->carElt->setup.brakePressure);
|
||||
|
||||
|
|
|
@ -42,6 +42,10 @@ SimCarConfig(tCar *car)
|
|||
int i;
|
||||
tCarElt *carElt = car->carElt;
|
||||
const char *enabling;
|
||||
tCarSetupItem *setupGcfr = &(car->carElt->setup.FRWeightRep);
|
||||
tCarSetupItem *setupGcfrl = &(car->carElt->setup.FRLWeightRep);
|
||||
tCarSetupItem *setupGcrrl = &(car->carElt->setup.RRLWeightRep);
|
||||
tCarSetupItem *setupFuel = &(car->carElt->setup.fuel);
|
||||
|
||||
/* get features first */
|
||||
car->features = 0;
|
||||
|
@ -88,20 +92,38 @@ SimCarConfig(tCar *car)
|
|||
|
||||
|
||||
/* continue with car parameters */
|
||||
setupGcfr->desired_value = setupGcfr->min = setupGcfr->max = 0.5;
|
||||
GfParmGetNumWithLimits(hdle, SECT_CAR, PRM_FRWEIGHTREP, (char*)NULL, &(setupGcfr->desired_value), &(setupGcfr->min), &(setupGcfr->max));
|
||||
setupGcfr->changed = TRUE;
|
||||
setupGcfr->stepsize = 0.005;
|
||||
gcfr = setupGcfr->desired_value;
|
||||
|
||||
setupGcfrl->desired_value = setupGcfrl->min = setupGcfrl->max = 0.5;
|
||||
GfParmGetNumWithLimits(hdle, SECT_CAR, PRM_FRLWEIGHTREP, (char*)NULL, &(setupGcfrl->desired_value), &(setupGcfrl->min), &(setupGcfrl->max));
|
||||
setupGcfrl->changed = TRUE;
|
||||
setupGcfrl->stepsize = 0.005;
|
||||
gcfrl = setupGcfrl->desired_value;
|
||||
|
||||
setupGcrrl->desired_value = setupGcrrl->min = setupGcrrl->max = 0.5;
|
||||
GfParmGetNumWithLimits(hdle, SECT_CAR, PRM_RRLWEIGHTREP, (char*)NULL, &(setupGcrrl->desired_value), &(setupGcrrl->min), &(setupGcrrl->max));
|
||||
setupGcrrl->changed = TRUE;
|
||||
setupGcrrl->stepsize = 0.005;
|
||||
gcrrl = setupGcrrl->desired_value;
|
||||
|
||||
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->changed = TRUE;
|
||||
setupFuel->stepsize = 1.0;
|
||||
|
||||
car->dimension.x = GfParmGetNum(hdle, SECT_CAR, PRM_LEN, (char*)NULL, 4.7f);
|
||||
car->dimension.y = GfParmGetNum(hdle, SECT_CAR, PRM_WIDTH, (char*)NULL, 1.9f);
|
||||
overallwidth = GfParmGetNum(hdle, SECT_CAR, PRM_OVERALLWIDTH, (char*)NULL, car->dimension.y);
|
||||
car->dimension.z = GfParmGetNum(hdle, SECT_CAR, PRM_HEIGHT, (char*)NULL, 1.2f);
|
||||
car->mass = GfParmGetNum(hdle, SECT_CAR, PRM_MASS, (char*)NULL, 1500);
|
||||
car->Minv = (tdble) (1.0 / car->mass);
|
||||
gcfr = GfParmGetNum(hdle, SECT_CAR, PRM_FRWEIGHTREP, (char*)NULL, .5);
|
||||
gcfrl = GfParmGetNum(hdle, SECT_CAR, PRM_FRLWEIGHTREP, (char*)NULL, .5);
|
||||
gcrrl = GfParmGetNum(hdle, SECT_CAR, PRM_RRLWEIGHTREP, (char*)NULL, .5);
|
||||
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);
|
||||
car->fuel = GfParmGetNum(hdle, SECT_CAR, PRM_FUEL, (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);
|
||||
|
@ -110,21 +132,35 @@ 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 (car->fuel > car->tank) {
|
||||
car->fuel = 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)));
|
||||
car->Iinv.z = (tdble) (12.0 / (car->mass * k * (car->dimension.y * car->dimension.y + car->dimension.x * car->dimension.x)));
|
||||
|
||||
/* configure components */
|
||||
tCarSetupItem *setupSpring;
|
||||
tdble K[4], Kfheave, Krheave;
|
||||
for (i = 0; i < 4; i++) {
|
||||
K[i] = GfParmGetNum(hdle, SuspSect[i], PRM_SPR, (char*)NULL, 175000.0f);
|
||||
setupSpring = &(car->carElt->setup.suspSpring[i]);
|
||||
setupSpring->desired_value = setupSpring->min = setupSpring-> max = 175000.0f;
|
||||
GfParmGetNumWithLimits(hdle, SuspSect[i], PRM_SPR, (char*)NULL, &(setupSpring->desired_value), &(setupSpring->min), &(setupSpring->max));
|
||||
setupSpring->changed = TRUE;
|
||||
setupSpring->stepsize = 1000;
|
||||
K[i] = setupSpring->desired_value;
|
||||
}
|
||||
Kfheave = GfParmGetNum(hdle, SECT_FRNTHEAVE, PRM_SPR, (char*)NULL, 0.0f);
|
||||
Krheave = GfParmGetNum(hdle, SECT_REARHEAVE, PRM_SPR, (char*)NULL, 0.0f);
|
||||
setupSpring = &(car->carElt->setup.heaveSpring[0]);
|
||||
setupSpring->desired_value = setupSpring->min = setupSpring-> max = 0.0f;
|
||||
GfParmGetNumWithLimits(hdle, SECT_FRNTHEAVE, PRM_SPR, (char*)NULL, &(setupSpring->desired_value), &(setupSpring->min), &(setupSpring->max));
|
||||
setupSpring->changed = TRUE;
|
||||
setupSpring->stepsize = 1000;
|
||||
Kfheave = setupSpring->desired_value;
|
||||
setupSpring = &(car->carElt->setup.heaveSpring[1]);
|
||||
setupSpring->desired_value = setupSpring->min = setupSpring-> max = 0.0f;
|
||||
GfParmGetNumWithLimits(hdle, SECT_REARHEAVE, PRM_SPR, (char*)NULL, &(setupSpring->desired_value), &(setupSpring->min), &(setupSpring->max));
|
||||
setupSpring->changed = TRUE;
|
||||
setupSpring->stepsize = 1000;
|
||||
Krheave = setupSpring->desired_value;
|
||||
|
||||
/* wheel force bugfix is needed for heave springs */
|
||||
if ( (Kfheave > 0.0f) || (Krheave > 0.0f) )
|
||||
{car->features = car->features | FEAT_FIXEDWHEELFORCE;}
|
||||
|
@ -139,17 +175,9 @@ SimCarConfig(tCar *car)
|
|||
car->wheel[REAR_RGT].weight0 = wr0 * gcrrl * K[REAR_RGT] / (K[REAR_RGT] + 0.5f*Krheave);
|
||||
car->wheel[REAR_LFT].weight0 = wr0 * (1 - gcrrl) * K[REAR_LFT] / (K[REAR_LFT] + 0.5f*Krheave);
|
||||
|
||||
/*for (i = 0; i < 2; i++) {
|
||||
SimAxleConfig(car, i, 0.0);
|
||||
}*/
|
||||
if (Kfheave > 0.0f) {
|
||||
wf0 = (wf0 - car->wheel[FRNT_RGT].weight0 - car->wheel[FRNT_LFT].weight0);
|
||||
SimAxleConfig(car, FRNT, wf0);
|
||||
} else { SimAxleConfig(car, FRNT, 0.0f); }
|
||||
if (Krheave > 0.0f) {
|
||||
wr0 = (wr0 - car->wheel[REAR_RGT].weight0 - car->wheel[REAR_LFT].weight0);
|
||||
SimAxleConfig(car, REAR, wr0);
|
||||
} else { SimAxleConfig(car, REAR, 0.0f); }
|
||||
for (i = 0; i < 2; i++) {
|
||||
SimAxleConfig(car, i);
|
||||
}
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
SimWheelConfig(car, i);
|
||||
|
@ -216,6 +244,113 @@ SimCarConfig(tCar *car)
|
|||
car->wing[i].staticPos.z -= car->statGC.z;
|
||||
}
|
||||
}
|
||||
|
||||
SimCarReConfig(car);
|
||||
|
||||
/*
|
||||
for(i=0;i<4;i++) {
|
||||
printf("Wheel%d: opl=%g toe=%g° cam=%g°\n",i,car->wheel[i].opLoad,RAD2DEG(car->wheel[i].staticPos.az),RAD2DEG(car->wheel[i].staticPos.ax));
|
||||
}
|
||||
for(i=0;i<4;i++) {
|
||||
printf("WS%d K=%g bc=%g ine=%g\n",i,car->wheel[i].susp.spring.K,car->wheel[i].susp.spring.bellcrank,car->wheel[i].susp.inertance);
|
||||
printf(" c=%g p=%g x0=%g F0=%g\n",car->wheel[i].susp.spring.xMax,car->wheel[i].susp.spring.packers,car->wheel[i].susp.spring.x0,car->wheel[i].susp.spring.F0);
|
||||
printf(" SB=%g SR=%g FB=%g FR=%g BV=%g RV=%g\n",car->wheel[i].susp.damper.bump.C1,car->wheel[i].susp.damper.rebound.C1,car->wheel[i].susp.damper.bump.C2,car->wheel[i].susp.damper.rebound.C2,car->wheel[i].susp.damper.bump.v1,car->wheel[i].susp.damper.rebound.v1);
|
||||
}
|
||||
for(i=0;i<2;i++) {
|
||||
printf("ARB%d K=%g\n",i,car->axle[i].arbSusp.spring.K);
|
||||
}
|
||||
for(i=0;i<2;i++) {
|
||||
printf("H%d K=%g bc=%g ine=%g\n",i,car->axle[i].heaveSusp.spring.K,car->axle[i].heaveSusp.spring.bellcrank,car->axle[i].heaveSusp.inertance);
|
||||
printf(" c=%g p=%g x0=%g F0=%g\n",car->axle[i].heaveSusp.spring.xMax,car->axle[i].heaveSusp.spring.packers,car->axle[i].heaveSusp.spring.x0,car->axle[i].heaveSusp.spring.F0);
|
||||
printf(" SB=%g SR=%g FB=%g FR=%g BV=%g RV=%g\n",car->axle[i].heaveSusp.damper.bump.C1,car->axle[i].heaveSusp.damper.rebound.C1,car->axle[i].heaveSusp.damper.bump.C2,car->axle[i].heaveSusp.damper.rebound.C2,car->axle[i].heaveSusp.damper.bump.v1,car->axle[i].heaveSusp.damper.rebound.v1);
|
||||
}
|
||||
printf("BrakeBal=%g p=%g\n",car->brkSyst.rep,car->brkSyst.coeff);
|
||||
printf("FWing=%g° Rwing=%g°\n",RAD2DEG(car->wing[0].angle),RAD2DEG(car->wing[1].angle));
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SimCarReConfig(tCar *car)
|
||||
{
|
||||
int i;
|
||||
tdble w;
|
||||
tdble gcfrl, gcrrl, gcfr;
|
||||
tdble wf0, wr0;
|
||||
tdble K[4], Kfheave, Krheave;
|
||||
tCarSetupItem *setupSpring;
|
||||
tCarSetupItem *setupGcfr = &(car->carElt->setup.FRWeightRep);
|
||||
tCarSetupItem *setupGcfrl = &(car->carElt->setup.FRLWeightRep);
|
||||
tCarSetupItem *setupGcrrl = &(car->carElt->setup.RRLWeightRep);
|
||||
tCarSetupItem *setupFuel = &(car->carElt->setup.fuel);
|
||||
|
||||
if (setupFuel->changed) {
|
||||
car->fuel = MIN(setupFuel->max, MAX(setupFuel->min, setupFuel->desired_value));
|
||||
if (car->fuel > car->tank) {car->fuel = car->tank;}
|
||||
setupFuel->value = car->fuel;
|
||||
setupFuel->changed = FALSE;
|
||||
}
|
||||
|
||||
if (setupGcfr->changed) {
|
||||
gcfr = MIN(setupGcfr->max, MAX(setupGcfr->min, setupGcfr->desired_value));
|
||||
setupGcfr->value = gcfr;
|
||||
setupGcfr->changed = FALSE;
|
||||
} else {
|
||||
gcfr = setupGcfr->value;
|
||||
}
|
||||
|
||||
if (setupGcfrl->changed) {
|
||||
gcfrl = MIN(setupGcfrl->max, MAX(setupGcfrl->min, setupGcfrl->desired_value));
|
||||
setupGcfrl->value = gcfrl;
|
||||
setupGcfrl->changed = FALSE;
|
||||
} else {
|
||||
gcfrl = setupGcfrl->value;
|
||||
}
|
||||
|
||||
if (setupGcrrl->changed) {
|
||||
gcrrl = MIN(setupGcrrl->max, MAX(setupGcrrl->min, setupGcrrl->desired_value));
|
||||
setupGcrrl->value = gcrrl;
|
||||
setupGcrrl->changed = FALSE;
|
||||
} else {
|
||||
gcrrl = setupGcrrl->value;
|
||||
}
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
setupSpring = &(car->carElt->setup.suspSpring[i]);
|
||||
K[i] = MIN(setupSpring->max, MAX(setupSpring->min, setupSpring->desired_value));
|
||||
}
|
||||
setupSpring = &(car->carElt->setup.heaveSpring[0]);
|
||||
Kfheave = MIN(setupSpring->max, MAX(setupSpring->min, setupSpring->desired_value));
|
||||
setupSpring = &(car->carElt->setup.heaveSpring[1]);
|
||||
Krheave = MIN(setupSpring->max, MAX(setupSpring->min, setupSpring->desired_value));
|
||||
|
||||
/* calculate wheel loads */
|
||||
w = car->mass * G;
|
||||
wf0 = w * gcfr;
|
||||
wr0 = w * (1 - gcfr);
|
||||
|
||||
car->wheel[FRNT_RGT].weight0 = wf0 * gcfrl * K[FRNT_RGT] / (K[FRNT_RGT] + 0.5f*Kfheave);
|
||||
car->wheel[FRNT_LFT].weight0 = wf0 * (1 - gcfrl) * K[FRNT_LFT] / (K[FRNT_LFT] + 0.5f*Kfheave);
|
||||
car->wheel[REAR_RGT].weight0 = wr0 * gcrrl * K[REAR_RGT] / (K[REAR_RGT] + 0.5f*Krheave);
|
||||
car->wheel[REAR_LFT].weight0 = wr0 * (1 - gcrrl) * K[REAR_LFT] / (K[REAR_LFT] + 0.5f*Krheave);
|
||||
|
||||
/* reconfigure components */
|
||||
if (Kfheave > 0.0f) {
|
||||
wf0 = (wf0 - car->wheel[FRNT_RGT].weight0 - car->wheel[FRNT_LFT].weight0);
|
||||
SimAxleReConfig(car, FRNT, wf0);
|
||||
} else { SimAxleReConfig(car, FRNT, 0.0f); }
|
||||
if (Krheave > 0.0f) {
|
||||
wr0 = (wr0 - car->wheel[REAR_RGT].weight0 - car->wheel[REAR_LFT].weight0);
|
||||
SimAxleReConfig(car, REAR, wr0);
|
||||
} else { SimAxleReConfig(car, REAR, 0.0f); }
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
SimWheelReConfig(car, i);
|
||||
}
|
||||
SimBrakeSystemReConfig(car);
|
||||
for (i = 0; i < 2; i++) {
|
||||
SimWingReConfig(car, i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -267,7 +402,7 @@ SimCarUpdateForces(tCar *car)
|
|||
car->wheel[i].forces.y * car->wheel[i].staticPos.x;
|
||||
F.M.z += car->wheel[i].torques.z;
|
||||
}
|
||||
|
||||
|
||||
/* Aero Drag */
|
||||
F.F.x += car->aero.drag;
|
||||
|
||||
|
|
|
@ -46,18 +46,22 @@ extern void SimUpdateSingleCar(int index, double deltaTime,tSituation *s);
|
|||
extern tDynPt* GetSimCarTable(int index);
|
||||
|
||||
|
||||
extern void SimAxleConfig(tCar *car, int index, tdble weight0);
|
||||
extern void SimAxleConfig(tCar *car, int index);
|
||||
extern void SimAxleReConfig(tCar *car, int index, tdble weight0);
|
||||
extern void SimAxleUpdate(tCar *car, int index);
|
||||
|
||||
extern void SimCarConfig(tCar *car);
|
||||
extern void SimCarReConfig(tCar *car);
|
||||
extern void SimCarUpdate(tCar *car, tSituation*);
|
||||
extern void SimCarUpdate2(tCar *car, tSituation*);
|
||||
|
||||
extern void SimSuspCheckIn(tSuspension *susp);
|
||||
extern void SimSuspUpdate(tSuspension *susp);
|
||||
extern void SimSuspConfig(void *hdle, const char *section, tSuspension *susp, tdble F0, tdble X0);
|
||||
extern void SimSuspConfig(tCar *car, void *hdle, const char *section, tSuspension *susp, int index);
|
||||
extern void SimSuspReConfig(tCar *car, tSuspension *susp, int index, tdble F0, tdble X0);
|
||||
|
||||
extern void SimWheelConfig(tCar *car, int index);
|
||||
extern void SimWheelReConfig(tCar *car, int index);
|
||||
extern void SimWheelUpdateRide(tCar *car, int index);
|
||||
extern void SimWheelUpdateForce(tCar *car, int index);
|
||||
extern void SimWheelUpdateRotation(tCar *car);
|
||||
|
|
|
@ -122,31 +122,215 @@ void SimSuspUpdate(tSuspension *susp)
|
|||
|
||||
|
||||
|
||||
void SimSuspConfig(void *hdle, const char *section, tSuspension *susp, tdble F0, tdble X0)
|
||||
void SimSuspConfig(tCar *car, void *hdle, const char *section, tSuspension *susp, int index)
|
||||
{
|
||||
/* F0 == 0 means heave, by default do not use it */
|
||||
if ( F0 < 1e-6 ) {
|
||||
susp->spring.K = GfParmGetNum(hdle, section, PRM_SPR, (char*)NULL, 0.0f);
|
||||
} else {
|
||||
susp->spring.K = GfParmGetNum(hdle, section, PRM_SPR, (char*)NULL, 175000.0f);
|
||||
tCarSetupItem *setupSpring, *setupBellcrank, *setupInertance;
|
||||
tCarSetupItem *setupFastBump, *setupSlowBump, *setupBumpLvel;
|
||||
tCarSetupItem *setupFastReb, *setupSlowReb, *setupRebLvel;
|
||||
tCarSetupItem *setupCourse, *setupPacker;
|
||||
|
||||
if (index < 4) {//corner spring
|
||||
setupSpring = &(car->carElt->setup.suspSpring[index]);
|
||||
setupBellcrank = &(car->carElt->setup.suspBellcrank[index]);
|
||||
setupInertance = &(car->carElt->setup.suspInertance[index]);
|
||||
setupFastBump = &(car->carElt->setup.suspFastBump[index]);
|
||||
setupSlowBump = &(car->carElt->setup.suspSlowBump[index]);
|
||||
setupBumpLvel = &(car->carElt->setup.suspBumpLvel[index]);
|
||||
setupFastReb = &(car->carElt->setup.suspFastRebound[index]);
|
||||
setupSlowReb = &(car->carElt->setup.suspSlowRebound[index]);
|
||||
setupRebLvel = &(car->carElt->setup.suspReboundLvel[index]);
|
||||
setupCourse = &(car->carElt->setup.suspCourse[index]);
|
||||
setupPacker = &(car->carElt->setup.suspPacker[index]);
|
||||
} else {//heave spring
|
||||
setupSpring = &(car->carElt->setup.heaveSpring[index-4]);
|
||||
setupBellcrank = &(car->carElt->setup.heaveBellcrank[index-4]);
|
||||
setupInertance = &(car->carElt->setup.heaveInertance[index-4]);
|
||||
setupFastBump = &(car->carElt->setup.heaveFastBump[index-4]);
|
||||
setupSlowBump = &(car->carElt->setup.heaveSlowBump[index-4]);
|
||||
setupBumpLvel = &(car->carElt->setup.heaveBumpLvel[index-4]);
|
||||
setupFastReb = &(car->carElt->setup.heaveFastRebound[index-4]);
|
||||
setupSlowReb = &(car->carElt->setup.heaveSlowRebound[index-4]);
|
||||
setupRebLvel = &(car->carElt->setup.heaveReboundLvel[index-4]);
|
||||
setupCourse = NULL;
|
||||
setupPacker = NULL;
|
||||
}
|
||||
susp->spring.xMax = GfParmGetNum(hdle, section, PRM_SUSPCOURSE, (char*)NULL, 0.5f);
|
||||
susp->spring.bellcrank = GfParmGetNum(hdle, section, PRM_BELLCRANK, (char*)NULL, 1.0f);
|
||||
susp->spring.packers = GfParmGetNum(hdle, section, PRM_PACKERS, (char*)NULL, 0.0f);
|
||||
susp->damper.bump.C1 = GfParmGetNum(hdle, section, PRM_SLOWBUMP, (char*)NULL, 0.0f);
|
||||
susp->damper.rebound.C1 = GfParmGetNum(hdle, section, PRM_SLOWREBOUND, (char*)NULL, 0.0f);
|
||||
susp->damper.bump.C2 = GfParmGetNum(hdle, section, PRM_FASTBUMP, (char*)NULL, 0.0f);
|
||||
susp->damper.rebound.C2 = GfParmGetNum(hdle, section, PRM_FASTREBOUND, (char*)NULL, 0.0f);
|
||||
susp->damper.bump.v1 = GfParmGetNum(hdle, section, PRM_BUMPLVEL, (char*)NULL, 0.5f);
|
||||
susp->damper.rebound.v1 = GfParmGetNum(hdle, section, PRM_REBOUNDLVEL, (char*)NULL, 0.5f);
|
||||
susp->inertance = 0.0;
|
||||
|
||||
susp->spring.x0 = susp->spring.bellcrank * X0;
|
||||
susp->spring.F0 = F0 / susp->spring.bellcrank;
|
||||
susp->spring.K = - susp->spring.K;
|
||||
susp->damper.bump.b1 = 0.0f;
|
||||
susp->damper.rebound.b1 = 0.0f;
|
||||
if ( index < 4 ) {
|
||||
setupSpring->desired_value = setupSpring->min = setupSpring-> max = 175000.0f;
|
||||
} else {/* default heave = 0 */
|
||||
setupSpring->desired_value = setupSpring->min = setupSpring-> max = 0.0f;
|
||||
}
|
||||
GfParmGetNumWithLimits(hdle, section, PRM_SPR, (char*)NULL, &(setupSpring->desired_value), &(setupSpring->min), &(setupSpring->max));
|
||||
setupSpring->changed = TRUE;
|
||||
setupSpring->stepsize = 1000;
|
||||
|
||||
initDamper(susp);
|
||||
setupBellcrank->desired_value = setupBellcrank->min = setupBellcrank-> max = 1.0f;
|
||||
GfParmGetNumWithLimits(hdle, section, PRM_BELLCRANK, (char*)NULL, &(setupBellcrank->desired_value), &(setupBellcrank->min), &(setupBellcrank->max));
|
||||
setupBellcrank->changed = TRUE;
|
||||
setupBellcrank->stepsize = 0.1;
|
||||
|
||||
setupInertance->desired_value = setupInertance->min = setupInertance-> max = 0.0f;
|
||||
//Inertance is not yet used in car setup files.
|
||||
setupInertance->changed = TRUE;
|
||||
setupInertance->stepsize = 0.0;
|
||||
|
||||
setupSlowBump->desired_value = setupSlowBump->min = setupSlowBump->max = 0.0f;
|
||||
GfParmGetNumWithLimits(hdle, section, PRM_SLOWBUMP, (char*)NULL, &(setupSlowBump->desired_value), &(setupSlowBump->min), &(setupSlowBump->max));
|
||||
setupSlowBump->changed = TRUE;
|
||||
setupSlowBump->stepsize = 100;
|
||||
|
||||
setupSlowReb->desired_value = setupSlowReb->min = setupSlowReb->max = 0.0f;
|
||||
GfParmGetNumWithLimits(hdle, section, PRM_SLOWREBOUND, (char*)NULL, &(setupSlowReb->desired_value), &(setupSlowReb->min), &(setupSlowReb->max));
|
||||
setupSlowReb->changed = TRUE;
|
||||
setupSlowReb->stepsize = 100;
|
||||
|
||||
setupFastBump->desired_value = setupFastBump->min = setupFastBump->max = 0.0f;
|
||||
GfParmGetNumWithLimits(hdle, section, PRM_FASTBUMP, (char*)NULL, &(setupFastBump->desired_value), &(setupFastBump->min), &(setupFastBump->max));
|
||||
setupFastBump->changed = TRUE;
|
||||
setupFastBump->stepsize = 100;
|
||||
|
||||
setupFastReb->desired_value = setupFastReb->min = setupFastReb->max = 0.0f;
|
||||
GfParmGetNumWithLimits(hdle, section, PRM_FASTREBOUND, (char*)NULL, &(setupFastReb->desired_value), &(setupFastReb->min), &(setupFastReb->max));
|
||||
setupFastReb->changed = TRUE;
|
||||
setupFastReb->stepsize = 100;
|
||||
|
||||
setupBumpLvel->desired_value = setupBumpLvel->min = setupBumpLvel->max = 0.5f;
|
||||
GfParmGetNumWithLimits(hdle, section, PRM_BUMPLVEL, (char*)NULL, &(setupBumpLvel->desired_value), &(setupBumpLvel->min), &(setupBumpLvel->max));
|
||||
setupBumpLvel->changed = TRUE;
|
||||
setupBumpLvel->stepsize = 0.01;
|
||||
|
||||
setupRebLvel->desired_value = setupRebLvel->min = setupRebLvel->max = 0.5f;
|
||||
GfParmGetNumWithLimits(hdle, section, PRM_REBOUNDLVEL, (char*)NULL, &(setupRebLvel->desired_value), &(setupRebLvel->min), &(setupRebLvel->max));
|
||||
setupRebLvel->changed = TRUE;
|
||||
setupRebLvel->stepsize = 0.01;
|
||||
|
||||
if (index<4) {
|
||||
setupCourse->desired_value = setupCourse->min = setupCourse->max = 0.5f;
|
||||
GfParmGetNumWithLimits(hdle, section, PRM_SUSPCOURSE, (char*)NULL, &(setupCourse->desired_value), &(setupCourse->min), &(setupCourse->max));
|
||||
setupCourse->changed = TRUE;
|
||||
setupCourse->stepsize = 0.001;
|
||||
|
||||
setupPacker->desired_value = setupPacker->min = setupPacker->max = 0.0f;
|
||||
GfParmGetNumWithLimits(hdle, section, PRM_PACKERS, (char*)NULL, &(setupPacker->desired_value), &(setupPacker->min), &(setupPacker->max));
|
||||
setupPacker->changed = TRUE;
|
||||
setupPacker->stepsize = 0.001;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SimSuspReConfig(tCar *car, tSuspension *susp, int index, tdble F0, tdble X0)
|
||||
{/* called by SimWheelReConfig() in wheel.cpp or SimAxleReConfig() in axle.cpp */
|
||||
tCarSetupItem *setupSpring, *setupBellcrank, *setupInertance;
|
||||
tCarSetupItem *setupFastBump, *setupSlowBump, *setupBumpLvel;
|
||||
tCarSetupItem *setupFastReb, *setupSlowReb, *setupRebLvel;
|
||||
tCarSetupItem *setupCourse, *setupPacker;
|
||||
bool damperchanged = FALSE;
|
||||
|
||||
if (index < 4) {//corner springs
|
||||
setupSpring = &(car->carElt->setup.suspSpring[index]);
|
||||
setupBellcrank = &(car->carElt->setup.suspBellcrank[index]);
|
||||
setupInertance = &(car->carElt->setup.suspInertance[index]);
|
||||
setupFastBump = &(car->carElt->setup.suspFastBump[index]);
|
||||
setupSlowBump = &(car->carElt->setup.suspSlowBump[index]);
|
||||
setupBumpLvel = &(car->carElt->setup.suspBumpLvel[index]);
|
||||
setupFastReb = &(car->carElt->setup.suspFastRebound[index]);
|
||||
setupSlowReb = &(car->carElt->setup.suspSlowRebound[index]);
|
||||
setupRebLvel = &(car->carElt->setup.suspReboundLvel[index]);
|
||||
setupCourse = &(car->carElt->setup.suspCourse[index]);
|
||||
setupPacker = &(car->carElt->setup.suspPacker[index]);
|
||||
} else {//heave springs: 4 = front heave, 5 = rear heave
|
||||
setupSpring = &(car->carElt->setup.heaveSpring[index-4]);
|
||||
setupBellcrank = &(car->carElt->setup.heaveBellcrank[index-4]);
|
||||
setupInertance = &(car->carElt->setup.heaveInertance[index-4]);
|
||||
setupFastBump = &(car->carElt->setup.heaveFastBump[index-4]);
|
||||
setupSlowBump = &(car->carElt->setup.heaveSlowBump[index-4]);
|
||||
setupBumpLvel = &(car->carElt->setup.heaveBumpLvel[index-4]);
|
||||
setupFastReb = &(car->carElt->setup.heaveFastRebound[index-4]);
|
||||
setupSlowReb = &(car->carElt->setup.heaveSlowRebound[index-4]);
|
||||
setupRebLvel = &(car->carElt->setup.heaveReboundLvel[index-4]);
|
||||
setupCourse = NULL;
|
||||
setupPacker = NULL;
|
||||
}
|
||||
|
||||
if (setupSpring->changed) {
|
||||
susp->spring.K = - MIN(setupSpring->max, MAX(setupSpring->min, setupSpring->desired_value));
|
||||
setupSpring->value = - susp->spring.K;
|
||||
setupSpring->changed = FALSE;
|
||||
}
|
||||
|
||||
if (setupBellcrank->changed) {
|
||||
susp->spring.bellcrank = MIN(setupBellcrank->max, MAX(setupBellcrank->min, setupBellcrank->desired_value));
|
||||
setupBellcrank->value = susp->spring.bellcrank;
|
||||
setupBellcrank->changed = FALSE;
|
||||
}
|
||||
susp->spring.x0 = susp->spring.bellcrank * X0;
|
||||
susp->spring.F0 = F0 / susp->spring.bellcrank;
|
||||
|
||||
if (setupInertance->changed) {
|
||||
susp->inertance = MIN(setupInertance->max, MAX(setupInertance->min, setupInertance->desired_value));
|
||||
setupInertance->value = susp->inertance;
|
||||
setupInertance->changed = FALSE;
|
||||
}
|
||||
|
||||
if (setupSlowBump->changed) {
|
||||
susp->damper.bump.C1 = MIN(setupSlowBump->max, MAX(setupSlowBump->min, setupSlowBump->desired_value));
|
||||
setupSlowBump->value = susp->damper.bump.C1;
|
||||
setupSlowBump->changed = FALSE;
|
||||
damperchanged = TRUE;
|
||||
}
|
||||
|
||||
if (setupSlowReb->changed) {
|
||||
susp->damper.rebound.C1 = MIN(setupSlowReb->max, MAX(setupSlowReb->min, setupSlowReb->desired_value));
|
||||
setupSlowReb->value = susp->damper.rebound.C1;
|
||||
setupSlowReb->changed = FALSE;
|
||||
damperchanged = TRUE;
|
||||
}
|
||||
|
||||
if (setupFastBump->changed) {
|
||||
susp->damper.bump.C2 = MIN(setupFastBump->max, MAX(setupFastBump->min, setupFastBump->desired_value));
|
||||
setupFastBump->value = susp->damper.bump.C2;
|
||||
setupFastBump->changed = FALSE;
|
||||
damperchanged = TRUE;
|
||||
}
|
||||
|
||||
if (setupFastReb->changed) {
|
||||
susp->damper.rebound.C2 = MIN(setupFastReb->max, MAX(setupFastReb->min, setupFastReb->desired_value));
|
||||
setupFastReb->value = susp->damper.rebound.C2;
|
||||
setupFastReb->changed = FALSE;
|
||||
damperchanged = TRUE;
|
||||
}
|
||||
|
||||
if (setupBumpLvel->changed) {
|
||||
susp->damper.bump.v1 = MIN(setupBumpLvel->max, MAX(setupBumpLvel->min, setupBumpLvel->desired_value));
|
||||
setupBumpLvel->value = susp->damper.bump.v1;
|
||||
setupBumpLvel->changed = FALSE;
|
||||
damperchanged = TRUE;
|
||||
}
|
||||
|
||||
if (setupRebLvel->changed) {
|
||||
susp->damper.rebound.v1 = MIN(setupRebLvel->max, MAX(setupRebLvel->min, setupRebLvel->desired_value));
|
||||
setupRebLvel->value = susp->damper.rebound.v1;
|
||||
setupRebLvel->changed = FALSE;
|
||||
damperchanged = TRUE;
|
||||
}
|
||||
|
||||
if (damperchanged) {
|
||||
susp->damper.bump.b1 = 0.0f;
|
||||
susp->damper.rebound.b1 = 0.0f;
|
||||
|
||||
initDamper(susp);
|
||||
}
|
||||
|
||||
if (index<4) {
|
||||
if (setupCourse->changed) {
|
||||
susp->spring.xMax = MIN(setupCourse->max, MAX(setupCourse->min, setupCourse->desired_value));
|
||||
setupCourse->value = susp->spring.xMax;
|
||||
setupCourse->changed = FALSE;
|
||||
}
|
||||
if (setupPacker->changed) {
|
||||
susp->spring.packers = MIN(setupPacker->max, MAX(setupPacker->min, setupPacker->desired_value));
|
||||
setupPacker->value = susp->spring.packers;
|
||||
setupPacker->changed = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,10 +33,35 @@ SimWheelConfig(tCar *car, int index)
|
|||
void *hdle = car->params;
|
||||
tCarElt *carElt = car->carElt;
|
||||
tWheel *wheel = &(car->wheel[index]);
|
||||
tdble rimdiam, tirewidth, tireratio, pressure, tireheight;
|
||||
tdble x0, Ca, RFactor, EFactor, patchLen;
|
||||
tdble rimdiam, tirewidth, tireratio, tireheight;
|
||||
tdble Ca, RFactor, EFactor;
|
||||
tCarSetupItem *setupToe = &(car->carElt->setup.toe[index]);
|
||||
tCarSetupItem *setupCamber = &(car->carElt->setup.camber[index]);
|
||||
tCarSetupItem *setupPressure = &(car->carElt->setup.tirePressure[index]);
|
||||
tCarSetupItem *setupOpLoad = &(car->carElt->setup.tireOpLoad[index]);
|
||||
|
||||
/* Note: ride height is already read in SimAxleConfig() */
|
||||
|
||||
setupToe->desired_value = setupToe->min = setupToe->max = 0.0f;
|
||||
GfParmGetNumWithLimits(hdle, WheelSect[index], PRM_TOE, (char*)NULL, &(setupToe->desired_value), &(setupToe->min), &(setupToe->max));
|
||||
setupToe->changed = TRUE;
|
||||
setupToe->stepsize = DEG2RAD(0.1);
|
||||
|
||||
setupCamber->desired_value = setupCamber->min = setupCamber->max = 0.0f;
|
||||
GfParmGetNumWithLimits(hdle, WheelSect[index], PRM_CAMBER, (char*)NULL, &(setupCamber->desired_value), &(setupCamber->min), &(setupCamber->max));
|
||||
setupCamber->changed = TRUE;
|
||||
setupCamber->stepsize = DEG2RAD(0.1);
|
||||
|
||||
pressure = GfParmGetNum(hdle, WheelSect[index], PRM_PRESSURE, (char*)NULL, 275600);
|
||||
setupPressure->desired_value = setupPressure->min = setupPressure->max = 275600;
|
||||
GfParmGetNumWithLimits(hdle, WheelSect[index], PRM_PRESSURE, (char*)NULL, &(setupPressure->desired_value), &(setupPressure->min), &(setupPressure->max));
|
||||
setupPressure->changed = TRUE;
|
||||
setupPressure->stepsize = 10000;
|
||||
|
||||
setupOpLoad->desired_value = setupOpLoad->min = setupOpLoad->max = wheel->weight0 * 1.2f;
|
||||
GfParmGetNumWithLimits(hdle, WheelSect[index], PRM_OPLOAD, (char*)NULL, &(setupOpLoad->desired_value), &(setupOpLoad->min), &(setupOpLoad->max));
|
||||
setupOpLoad->changed = TRUE;
|
||||
setupOpLoad->stepsize = 100;
|
||||
|
||||
rimdiam = GfParmGetNum(hdle, WheelSect[index], PRM_RIMDIAM, (char*)NULL, 0.33f);
|
||||
tirewidth = GfParmGetNum(hdle, WheelSect[index], PRM_TIREWIDTH, (char*)NULL, 0.145f);
|
||||
tireheight = GfParmGetNum(hdle, WheelSect[index], PRM_TIREHEIGHT, (char*)NULL, -1.0f);
|
||||
|
@ -46,25 +71,13 @@ SimWheelConfig(tCar *car, int index)
|
|||
//BUG: the next line should go after SimBrakeConfig to have an effect
|
||||
wheel->I += wheel->brake.I; // add brake inertia
|
||||
wheel->staticPos.y = GfParmGetNum(hdle, WheelSect[index], PRM_YPOS, (char*)NULL, 0.0f);
|
||||
x0 = GfParmGetNum(hdle, WheelSect[index], PRM_RIDEHEIGHT, (char*)NULL, 0.20f);
|
||||
wheel->staticPos.az = GfParmGetNum(hdle, WheelSect[index], PRM_TOE, (char*)NULL, 0.0f);
|
||||
wheel->staticPos.ax = GfParmGetNum(hdle, WheelSect[index], PRM_CAMBER, (char*)NULL, 0.0f);
|
||||
Ca = GfParmGetNum(hdle, WheelSect[index], PRM_CA, (char*)NULL, 30.0f);
|
||||
RFactor = GfParmGetNum(hdle, WheelSect[index], PRM_RFACTOR, (char*)NULL, 0.8f);
|
||||
EFactor = GfParmGetNum(hdle, WheelSect[index], PRM_EFACTOR, (char*)NULL, 0.7f);
|
||||
wheel->lfMax = GfParmGetNum(hdle, WheelSect[index], PRM_LOADFMAX, (char*)NULL, 1.6f);
|
||||
wheel->lfMin = GfParmGetNum(hdle, WheelSect[index], PRM_LOADFMIN, (char*)NULL, 0.8f);
|
||||
wheel->opLoad = GfParmGetNum(hdle, WheelSect[index], PRM_OPLOAD, (char*)NULL, wheel->weight0 * 1.2f);
|
||||
wheel->mass = GfParmGetNum(hdle, WheelSect[index], PRM_MASS, (char*)NULL, 20.0f);
|
||||
|
||||
if (index % 2) {
|
||||
wheel->relPos.ax = -wheel->staticPos.ax;
|
||||
} else {
|
||||
wheel->relPos.ax = wheel->staticPos.ax;
|
||||
}
|
||||
wheel->cosax = cos(wheel->relPos.ax);
|
||||
wheel->sinax = sin(wheel->relPos.ax);
|
||||
|
||||
wheel->lfMin = MIN(0.9f, wheel->lfMin);
|
||||
wheel->lfMax = MAX(1.1f, wheel->lfMax);
|
||||
|
||||
|
@ -72,15 +85,13 @@ SimWheelConfig(tCar *car, int index)
|
|||
RFactor = MAX(0.1f, RFactor);
|
||||
EFactor = MIN(1.0f, EFactor);
|
||||
|
||||
patchLen = wheel->weight0 / (tirewidth * pressure);
|
||||
|
||||
if (tireheight > 0.0)
|
||||
wheel->radius = rimdiam / 2.0f + tireheight;
|
||||
else
|
||||
wheel->radius = rimdiam / 2.0f + tirewidth * tireratio;
|
||||
wheel->tireSpringRate = wheel->weight0 / (wheel->radius * (1.0f - cos(asin(patchLen / (2.0f * wheel->radius)))));
|
||||
wheel->relPos.x = wheel->staticPos.x = car->axle[index/2].xpos;
|
||||
wheel->relPos.y = wheel->staticPos.y;
|
||||
/* BUG? susp.spring.x0 is still 0 here, maybe move after SimSuspReConfig in SimWheelReConfig? */
|
||||
wheel->relPos.z = wheel->radius - wheel->susp.spring.x0;
|
||||
wheel->relPos.ay = wheel->relPos.az = 0.0f;
|
||||
wheel->steer = 0.0f;
|
||||
|
@ -110,7 +121,7 @@ SimWheelConfig(tCar *car, int index)
|
|||
wheel->muTDoffset[1] = wheel->muTDoffset[1] - wheel->muTDmult[1] * wheel->critTreadDepth;
|
||||
|
||||
/* components */
|
||||
SimSuspConfig(hdle, SuspSect[index], &(wheel->susp), wheel->weight0, x0);
|
||||
SimSuspConfig(car, hdle, SuspSect[index], &(wheel->susp), index);
|
||||
SimBrakeConfig(hdle, BrkSect[index], &(wheel->brake));
|
||||
|
||||
carElt->_rimRadius(index) = rimdiam / 2.0f;
|
||||
|
@ -143,6 +154,59 @@ SimWheelConfig(tCar *car, int index)
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
SimWheelReConfig(tCar *car, int index)
|
||||
{/* called by SimCarReConfig in car.cpp */
|
||||
tCarElt *carElt = car->carElt;
|
||||
tWheel *wheel = &(car->wheel[index]);
|
||||
tdble x0;
|
||||
|
||||
tCarSetupItem *setupRideHeight = &(car->carElt->setup.rideHeight[index]);
|
||||
tCarSetupItem *setupToe = &(car->carElt->setup.toe[index]);
|
||||
tCarSetupItem *setupCamber = &(car->carElt->setup.camber[index]);
|
||||
tCarSetupItem *setupPressure = &(car->carElt->setup.tirePressure[index]);
|
||||
tCarSetupItem *setupOpLoad = &(car->carElt->setup.tireOpLoad[index]);
|
||||
tdble pressure, patchLen;
|
||||
|
||||
if (setupToe->changed) {
|
||||
wheel->staticPos.az = MIN(setupToe->max, MAX(setupToe->min, setupToe->desired_value));
|
||||
setupToe->value = wheel->staticPos.az;
|
||||
setupToe->changed = FALSE;
|
||||
}
|
||||
|
||||
if (setupCamber->changed) {
|
||||
wheel->staticPos.ax = MIN(setupCamber->max, MAX(setupCamber->min, setupCamber->desired_value));
|
||||
if (index % 2) {
|
||||
wheel->relPos.ax = -wheel->staticPos.ax;
|
||||
} else {
|
||||
wheel->relPos.ax = wheel->staticPos.ax;
|
||||
}
|
||||
wheel->cosax = cos(wheel->relPos.ax);
|
||||
wheel->sinax = sin(wheel->relPos.ax);
|
||||
setupCamber->value = wheel->staticPos.ax;
|
||||
setupCamber -> changed = FALSE;
|
||||
}
|
||||
|
||||
if ( setupPressure->changed ||car->carElt->setup.FRWeightRep.changed ) {
|
||||
/* NOTE: these variables are unused as of 2015.11.14. */
|
||||
pressure = MIN(setupPressure->max, MAX(setupPressure->min, setupPressure->desired_value));
|
||||
patchLen = wheel->weight0 / (carElt->_tireWidth(index) * pressure);
|
||||
wheel->tireSpringRate = wheel->weight0 / (wheel->radius * (1.0f - cos(asin(patchLen / (2.0f * wheel->radius)))));
|
||||
setupPressure->value = pressure;
|
||||
setupPressure->changed = FALSE;
|
||||
}
|
||||
|
||||
if (setupOpLoad->changed) {
|
||||
wheel->opLoad = MIN(setupOpLoad->max, MAX(setupOpLoad->min, setupOpLoad->desired_value));
|
||||
setupOpLoad->value = wheel->opLoad;
|
||||
setupOpLoad->changed = FALSE;
|
||||
}
|
||||
|
||||
x0 = setupRideHeight->value;
|
||||
SimSuspReConfig(car, &(wheel->susp), index, wheel->weight0, x0);
|
||||
}
|
||||
|
||||
|
||||
void SimWheelUpdateRide(tCar *car, int index)
|
||||
{
|
||||
tWheel *wheel = &(car->wheel[index]);
|
||||
|
|
Loading…
Reference in a new issue