149 float gear_ratio = car->_gearRatio[car->_gear + car->_gearOffset];
155 float turbo_target = 0.1f;
156 float turbo_target_vol = 0.0f;
163 float turbo_target_pitch = turbo_target * car->_enginerpm / 600.0f;
175 float rev_cor = car->_enginerpm/car->_enginerpmRedLine;
176 float rev_cor2 = rev_cor * rev_cor;
210 for (wheelIndex = 0; wheelIndex < 4; wheelIndex++) {
211 wheel[wheelIndex].skid.a = 0.0f;
212 wheel[wheelIndex].skid.f = 1.0f;
221 bool wheelSpinning =
false;
222 for (wheelIndex = 0; wheelIndex < 4; wheelIndex++) {
223 if (car->_wheelSpinVel(wheelIndex) > 0.1f) {
224 wheelSpinning =
true;
230 if ((car->
pub.
speed < 0.3f) && !wheelSpinning) {
234 for (wheelIndex = 0; wheelIndex<4; wheelIndex++) {
238 tdble ride = 0.001f * car->_reaction[wheelIndex];
241 tdble otherSurfaceContribution = 0.0f;
242 tdble otherRoughnessFreq = 1.0f;
245 if (onOtherSurface) {
257 otherRoughnessFreq, tmpvol, ride, wheelIndex, car->_reaction[wheelIndex]);
262 bool onOtherDifferentSurface =
265 tdble roadContribution = 0.0f;
266 tdble dirtContribution = 0.0f;
268 if (onOtherDifferentSurface) {
270 if (mainSurfaceIsOffroad) {
271 dirtContribution = 1.0f - otherSurfaceContribution;
272 roadContribution = otherSurfaceContribution;
274 roadContribution = 1.0f - otherSurfaceContribution;
275 dirtContribution = otherSurfaceContribution;
279 if (mainSurfaceIsOffroad) {
280 dirtContribution = 1.0f;
282 roadContribution = 1.0f;
287 if (roadContribution > 0.0f) {
289 otherRoughnessFreq, tmpvol, ride, wheelIndex, car->_skid[wheelIndex],
290 car->_wheelSlipAccel(wheelIndex), car->_reaction[wheelIndex]);
294 if (dirtContribution > 0.0f) {
295 tdble dirtRoughnessFreq = 0.0f;
296 tdble dirtRoughness = 0.0f;
298 getDirtRoughnessParams(car, wheelIndex, mainSurfaceIsOffroad, roughnessFreq, otherRoughnessFreq, dirtRoughnessFreq, dirtRoughness);
299 handleDirtContribution(dirtContribution, dirtRoughnessFreq, dirtRoughness, car->_skid[wheelIndex], tmpvol, ride);
303 for (wheelIndex = 0; wheelIndex<4; wheelIndex++) {
304 tdble az = car->_yaw;
305 tdble Sinz = sin(az);
306 tdble Cosz = cos(az);
311 tdble dx = x * Cosz -
y * Sinz;
312 tdble dy = x * Sinz +
y * Cosz;
314 tdble dux_initial = -car->_yaw_rate *
y;
315 tdble duy_initial = car->_yaw_rate * x;
317 tdble dux = dux_initial * Cosz - duy_initial * Sinz;
318 tdble duy = dux_initial * Sinz + duy_initial * Cosz;
397 bool mainSurfaceIsOffroad,
398 tdble roadContribution,
400 tdble otherRoughnessFreq,
405 tdble wheelSlipAccel,
408 if (roadContribution > 0.0f) {
409 tdble roadRoughnessFreq;
410 if (!mainSurfaceIsOffroad) {
411 roadRoughnessFreq = roughnessFreq;
413 roadRoughnessFreq = otherRoughnessFreq;
416 tdble roadpitch = tmpvol*(0.75f+0.25f*roadRoughnessFreq);
417 tdble wind_noise = 1.0f;
418 tdble road_noise = 0.25f;
419 tdble roadvol = tmpvol*(wind_noise + ride*road_noise)*roadContribution;
420 if (
road.a < roadvol) {
425 if (wheelSkid > 0.05f) {
426 wheel[wheelIndex].skid.a = (float)(wheelSkid-0.05f)*roadContribution;
427 float wsa = tanh((wheelSlipAccel+10.0f)*0.01f);
428 wheel[wheelIndex].skid.f = (0.3f - 0.3f*wsa + 0.3f*roadRoughnessFreq)/(1.0f+0.5f*tanh(wheelReaction*0.0001f));
437 tdble otherSurfaceContribution,
438 tdble curbRoughnessFreq,
439 tdble otherRoughnessFreq,
445 if (wheelReaction > 0.0f) {
446 tdble curbContribution = 0.0f;
448 curbContribution = 1.0f - otherSurfaceContribution;
450 curbContribution = otherSurfaceContribution;
451 curbRoughnessFreq = otherRoughnessFreq;
454 if (curbContribution > 0.0f) {
456 float curbpitch = tmpvol*(0.75f+0.25f*curbRoughnessFreq);
457 float curbvol = tmpvol*(5.0f + ride/3.0f)*curbContribution;
459 if (
curb.a < curbvol) {
void getDirtRoughnessParams(tCarElt *car, int wheelIndex, bool mainSurfaceIsOffroad, tdble roughnessFreq, tdble otherRoughnessFreq, tdble &dirtRoughnessFreq, tdble &dirtRoughness)
void handleCurbContribution(tPrivCar *car, bool onOtherSurface, tdble otherSurfaceContribution, tdble curbRoughnessFreq, tdble otherRoughnessFreq, tdble tmpvol, tdble ride, int wheelIndex, tdble wheelReaction)
void handleRoadContribution(bool mainSurfaceIsOffroad, tdble roadContribution, tdble roughnessFreq, tdble otherRoughnessFreq, tdble tmpvol, tdble ride, int wheelIndex, tdble wheelSkid, tdble wheelSlipAccel, tdble wheelReaction)