| 435 | } |
| 436 | |
| 437 | void ThingEffectLight::Simulate(float deltaT, SimulationImportance prec) |
| 438 | { |
| 439 | _submerged += Type()->_submergeSpeed * deltaT; |
| 440 | _timeToLive -= deltaT; |
| 441 | |
| 442 | base::Simulate(deltaT, prec); |
| 443 | |
| 444 | #define SIM_STEP_LIMIT 1 |
| 445 | |
| 446 | #if SIM_STEP_LIMIT |
| 447 | float rest = deltaT; |
| 448 | float simStep = 0.05; |
| 449 | while (rest > 0) |
| 450 | #endif |
| 451 | { |
| 452 | #if SIM_STEP_LIMIT |
| 453 | float deltaT = floatMin(rest, simStep); |
| 454 | rest -= simStep; |
| 455 | #endif |
| 456 | |
| 457 | Vector3Val speed = ModelSpeed(); |
| 458 | |
| 459 | // calculate all forces, frictions and torques |
| 460 | Vector3 force(VZero), friction(VZero); |
| 461 | Vector3 torque(VZero), torqueFriction(VZero); |
| 462 | |
| 463 | Vector3 pForce(VZero); // partial force |
| 464 | Vector3 pCenter(VZero); // partial force application point |
| 465 | |
| 466 | // simulate left/right engine |
| 467 | Vector3 wCenter(VFastTransform, ModelToWorld(), GetCenterOfMass()); |
| 468 | |
| 469 | // apply gravity |
| 470 | pForce = Vector3(0, -G_CONST * GetMass(), 0); |
| 471 | force += pForce; |
| 472 | |
| 473 | #if ARROWS |
| 474 | AddForce(wCenter, pForce * InvMass(), Color(1, 1, 0, 0.1)); |
| 475 | #endif |
| 476 | |
| 477 | // angular velocity causes also some angular friction |
| 478 | // this should be simulated as torque |
| 479 | if (_landContact || _objectContact) |
| 480 | { |
| 481 | torqueFriction = _angMomentum * 0.2; |
| 482 | } |
| 483 | else |
| 484 | { |
| 485 | torqueFriction = _angMomentum * 0.05; |
| 486 | } |
| 487 | |
| 488 | // calculate new position |
| 489 | Matrix4 movePos; |
| 490 | ApplySpeed(movePos, deltaT); |
| 491 | |
| 492 | Frame moveTrans; |
| 493 | moveTrans.SetTransform(movePos); |
| 494 |
nothing calls this directly
no test coverage detected