MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / Simulate

Method Simulate

engine/Poseidon/World/Scene/Thing.cpp:437–796  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

435}
436
437void 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

Callers

nothing calls this directly

Calls 15

floatMinFunction · 0.85
GetCenterOfMassFunction · 0.85
InvMassFunction · 0.85
ColorClass · 0.85
FrictionFunction · 0.85
floatMaxFunction · 0.85
TransformFunction · 0.85
TypeFunction · 0.70
GetMassFunction · 0.70
GetRadiusFunction · 0.70
Vector3Class · 0.50
AUTO_STATIC_ARRAYFunction · 0.50

Tested by

no test coverage detected