| 868 | } |
| 869 | |
| 870 | void PhysicsShape::applyRadialImpulse( const Point3F &origin, F32 radius, F32 magnitude ) |
| 871 | { |
| 872 | if ( !mPhysicsRep || !mPhysicsRep->isDynamic() ) |
| 873 | return; |
| 874 | |
| 875 | // TODO: Find a better approximation of the |
| 876 | // force vector using the object box. |
| 877 | |
| 878 | VectorF force = getWorldBox().getCenter() - origin; |
| 879 | F32 dist = force.magnitudeSafe(); |
| 880 | force.normalize(); |
| 881 | |
| 882 | if ( dist == 0.0f ) |
| 883 | force *= magnitude; |
| 884 | else |
| 885 | force *= mClampF( radius / dist, 0.0f, 1.0f ) * magnitude; |
| 886 | |
| 887 | mPhysicsRep->applyImpulse( origin, force ); |
| 888 | |
| 889 | // TODO: There is no simple way to really sync this sort of an |
| 890 | // event with the client. |
| 891 | // |
| 892 | // The best is to send the current physics snapshot, calculate the |
| 893 | // time difference from when this event occured and the time when the |
| 894 | // client recieves it, and then extrapolate where it should be. |
| 895 | // |
| 896 | // Even then its impossible to be absolutely sure its synced. |
| 897 | // |
| 898 | // Bottom line... you shouldn't use physics over the network like this. |
| 899 | // |
| 900 | |
| 901 | // Cheat for single player. |
| 902 | //if ( getClientObject() ) |
| 903 | //((PhysicsShape*)getClientObject())->mPhysicsRep->applyImpulse( origin, force ); |
| 904 | } |
| 905 | |
| 906 | void PhysicsShape::interpolateTick( F32 delta ) |
| 907 | { |
no test coverage detected