MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/PhysX / processGears

Function processGears

physx/source/physxvehicle/src/PxVehicleUpdate.cpp:1339–1408  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1337////////////////////////////////////////////////////////////////////////////
1338
1339void processGears(const PxF32 timestep, const PxVehicleGearsData& gears, PxVehicleDriveDynData& car)
1340{
1341 //const PxVehicleGearsData& gears=car.mVehicleSimData.getGearsData();
1342
1343 //Process the gears.
1344 if(car.getGearUp() && gears.mNbRatios-1!=car.getCurrentGear() && car.getCurrentGear()==car.getTargetGear())
1345 {
1346 //Car wants to go up a gear and can go up a gear and not already undergoing a gear change.
1347 if(PxVehicleGearsData::eREVERSE==car.getCurrentGear())
1348 {
1349 //In reverse so switch to first through neutral.
1350 car.setGearSwitchTime(0);
1351 car.setTargetGear(PxVehicleGearsData::eFIRST);
1352 car.setCurrentGear(PxVehicleGearsData::eNEUTRAL);
1353 }
1354 else if(PxVehicleGearsData::eNEUTRAL==car.getCurrentGear())
1355 {
1356 //In neutral so switch to first and stay in neutral.
1357 car.setGearSwitchTime(0);
1358 car.setTargetGear(PxVehicleGearsData::eFIRST);
1359 car.setCurrentGear(PxVehicleGearsData::eNEUTRAL);
1360 }
1361 else
1362 {
1363 //Switch up a gear through neutral.
1364 car.setGearSwitchTime(0);
1365 car.setTargetGear(car.getCurrentGear() + 1);
1366 car.setCurrentGear(PxVehicleGearsData::eNEUTRAL);
1367 }
1368 }
1369 if(car.getGearDown() && PxVehicleGearsData::eREVERSE!=car.getCurrentGear() && car.getCurrentGear()==car.getTargetGear())
1370 {
1371 //Car wants to go down a gear and can go down a gear and not already undergoing a gear change
1372 if(PxVehicleGearsData::eFIRST==car.getCurrentGear())
1373 {
1374 //In first so switch to reverse through neutral.
1375 car.setGearSwitchTime(0);
1376 car.setTargetGear(PxVehicleGearsData::eREVERSE);
1377 car.setCurrentGear(PxVehicleGearsData::eNEUTRAL);
1378 }
1379 else if(PxVehicleGearsData::eNEUTRAL==car.getCurrentGear())
1380 {
1381 //In neutral so switch to reverse and stay in neutral.
1382 car.setGearSwitchTime(0);
1383 car.setTargetGear(PxVehicleGearsData::eREVERSE);
1384 car.setCurrentGear(PxVehicleGearsData::eNEUTRAL);
1385 }
1386 else
1387 {
1388 //Switch down a gear through neutral.
1389 car.setGearSwitchTime(0);
1390 car.setTargetGear(car.getCurrentGear() - 1);
1391 car.setCurrentGear(PxVehicleGearsData::eNEUTRAL);
1392 }
1393 }
1394 if(car.getCurrentGear()!=car.getTargetGear())
1395 {
1396 if(car.getGearSwitchTime()>gears.mSwitchTime)

Callers 3

updateDrive4WMethod · 0.85
updateDriveNWMethod · 0.85
updateTankMethod · 0.85

Calls 10

getCurrentGearMethod · 0.80
getTargetGearMethod · 0.80
setGearSwitchTimeMethod · 0.80
setTargetGearMethod · 0.80
setCurrentGearMethod · 0.80
getGearSwitchTimeMethod · 0.80
getGearUpMethod · 0.45
getGearDownMethod · 0.45
setGearDownMethod · 0.45
setGearUpMethod · 0.45

Tested by

no test coverage detected