| 590 | } |
| 591 | |
| 592 | void Entity::ApplyForces(float deltaT, Vector3Par force, Vector3Par torque, Vector3Par friction, |
| 593 | Vector3Par torqueFriction, float staticFric) |
| 594 | { |
| 595 | Vector3 accel = DirectionWorldToModel(force * GetInvMass()); |
| 596 | Vector3 fricAccel = DirectionWorldToModel(friction * GetInvMass()); |
| 597 | Vector3 oldSpeed = _speed; |
| 598 | Vector3 speed(VMultiply, DirWorldToModel(), _speed); |
| 599 | Friction(speed, fricAccel, accel, deltaT); |
| 600 | DirectionModelToWorld(_speed, speed); |
| 601 | if (deltaT > 0) |
| 602 | { |
| 603 | _acceleration = (_speed - oldSpeed) * (1 / deltaT); |
| 604 | } |
| 605 | else |
| 606 | { |
| 607 | _acceleration = VZero; |
| 608 | } |
| 609 | Friction(_angMomentum, torqueFriction, torque, deltaT); |
| 610 | |
| 611 | float rigid = Rigid(); |
| 612 | _speed += _impulseForce * (GetInvMass() * rigid); |
| 613 | _angMomentum += _impulseTorque * rigid; |
| 614 | |
| 615 | float staticCanHold = staticFric * GetInvMass() * deltaT; |
| 616 | if (_speed.SquareSize() < Square(staticCanHold)) |
| 617 | { |
| 618 | _speed = VZero; |
| 619 | } |
| 620 | _impulseTorque = VZero; |
| 621 | _impulseForce = VZero; |
| 622 | |
| 623 | Matrix3Val orientation0 = Transform().Orientation(); |
| 624 | Matrix3Val invOrientation0 = InvTransform().Orientation(); |
| 625 | if (_shape) |
| 626 | { |
| 627 | _invAngInertia = orientation0 * InvInertia() * invOrientation0; |
| 628 | } |
| 629 | else |
| 630 | { |
| 631 | _invAngInertia = M3Zero; |
| 632 | } |
| 633 | |
| 634 | _angVelocity = _invAngInertia * _angMomentum; |
| 635 | } |
| 636 | |
| 637 | inline float fFric(float x) |
| 638 | { |
nothing calls this directly
no test coverage detected