MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / applyRadialImpulse

Method applyRadialImpulse

Engine/source/T3D/physics/physicsShape.cpp:870–904  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

868}
869
870void 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
906void PhysicsShape::interpolateTick( F32 delta )
907{

Callers 2

gameBase.cppFile · 0.45
_impulseCallbackMethod · 0.45

Calls 6

mClampFFunction · 0.85
isDynamicMethod · 0.45
getCenterMethod · 0.45
magnitudeSafeMethod · 0.45
normalizeMethod · 0.45
applyImpulseMethod · 0.45

Tested by

no test coverage detected