Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // === NEW VERSION ===
- void UFGearArcadeAssists::updateAntiRollBars()
- {
- // === Wheels ===
- UFGearWheel* mFlw = mAxles[0]->getLeftWheel(); // front-left
- UFGearWheel* mFrw = mAxles[0]->getRightWheel(); // front-right
- UFGearWheel* mRlw = mAxles[1]->getLeftWheel(); // rear-left
- UFGearWheel* mRrw = mAxles[1]->getRightWheel(); // rear-right
- // === Compression ratios (0-1) ===
- float flCompress = mFlw->getSuspensionCompressRatio();
- float frCompress = mFrw->getSuspensionCompressRatio();
- float rlCompress = mRlw->getSuspensionCompressRatio();
- float rrCompress = mRrw->getSuspensionCompressRatio();
- // === Travel (cm to mm) & spring rate (N/mm) ===
- // >> Only left wheels, right have same values (symmetric)
- float frontTravel = mFlw->getSuspensionTotalLength() * 10.0f; // cm to mm
- float rearTravel = mRlw->getSuspensionTotalLength() * 10.0f; // cm to mm
- float frontSpringRate = mFlw->getSuspensionSpring(); // N/mm
- float rearSpringRate = mRlw->getSuspensionSpring(); // N/mm
- // === Signed compression differences ===
- // Removed Abs() + Ifs | Direction matters = opposite forces.
- float frontDiff = flCompress - frCompress; // positive = left more compressed
- float rearDiff = rlCompress - rrCompress;
- // === *100 to good range effect, Slider 0-100 ===
- // Using Front:4 (~18kN), Rear:4 (~18kN) | 50-100K max for extreme heavy vehicles
- float frontPower = mFrontAntiRollPower * 100.0f;
- float rearPower = mRearAntiRollPower * 100.0f;
- // === Final ARB forces ===
- float frontForce = frontDiff * frontPower * frontTravel * frontSpringRate;
- float rearForce = rearDiff * rearPower * rearTravel * rearSpringRate;
- // === Apply opposite forces ===
- mFlw->applyVerticalForce( frontForce); // lift left / push right
- mFrw->applyVerticalForce(-frontForce); // push right / lift left
- mRlw->applyVerticalForce( rearForce);
- mRrw->applyVerticalForce(-rearForce);
- }
Advertisement
Add Comment
Please, Sign In to add comment