Guest User

Untitled

a guest
Nov 14th, 2025
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.99 KB | None | 0 0
  1. // === NEW VERSION ===
  2. void UFGearArcadeAssists::updateAntiRollBars()
  3. {
  4.     // === Wheels ===
  5.     UFGearWheel* mFlw = mAxles[0]->getLeftWheel();  // front-left
  6.     UFGearWheel* mFrw = mAxles[0]->getRightWheel(); // front-right
  7.     UFGearWheel* mRlw = mAxles[1]->getLeftWheel();  // rear-left
  8.     UFGearWheel* mRrw = mAxles[1]->getRightWheel(); // rear-right
  9.  
  10.     // === Compression ratios (0-1) ===
  11.     float flCompress = mFlw->getSuspensionCompressRatio();
  12.     float frCompress = mFrw->getSuspensionCompressRatio();
  13.     float rlCompress = mRlw->getSuspensionCompressRatio();
  14.     float rrCompress = mRrw->getSuspensionCompressRatio();
  15.  
  16.     // === Travel (cm to mm) & spring rate (N/mm) ===
  17.     // >> Only left wheels, right have same values (symmetric)
  18.     float frontTravel     = mFlw->getSuspensionTotalLength() * 10.0f; // cm to mm
  19.     float rearTravel      = mRlw->getSuspensionTotalLength() * 10.0f; // cm to mm
  20.     float frontSpringRate = mFlw->getSuspensionSpring();              // N/mm
  21.     float rearSpringRate  = mRlw->getSuspensionSpring();              // N/mm
  22.  
  23.     // === Signed compression differences ===
  24.     // Removed Abs() + Ifs | Direction matters = opposite forces.
  25.     float frontDiff = flCompress - frCompress;  // positive = left more compressed
  26.     float rearDiff  = rlCompress - rrCompress;
  27.  
  28.     // === *100 to good range effect, Slider 0-100 ===
  29.     // Using Front:4 (~18kN), Rear:4 (~18kN) | 50-100K max for extreme heavy vehicles
  30.     float frontPower = mFrontAntiRollPower * 100.0f;
  31.     float rearPower  = mRearAntiRollPower  * 100.0f;
  32.  
  33.     // === Final ARB forces ===
  34.     float frontForce = frontDiff * frontPower * frontTravel * frontSpringRate;
  35.     float rearForce  = rearDiff  * rearPower  * rearTravel  * rearSpringRate;
  36.  
  37.     // === Apply opposite forces ===
  38.     mFlw->applyVerticalForce( frontForce); // lift left  / push right
  39.     mFrw->applyVerticalForce(-frontForce); // push right / lift left
  40.     mRlw->applyVerticalForce( rearForce);
  41.     mRrw->applyVerticalForce(-rearForce);
  42. }
Advertisement
Add Comment
Please, Sign In to add comment