@@ -24,6 +24,9 @@ namespace Box2D.NET
2424{
2525 public static class B2Bodies
2626 {
27+ // Length of body debug name
28+ public const int B2_NAME_LENGTH = 32 ;
29+
2730 // Identity body state, notice the deltaRotation is {1, 0}
2831 public static readonly B2BodyState b2_identityBodyState = new B2BodyState ( )
2932 {
@@ -921,6 +924,7 @@ public static void b2Body_SetTargetTransform(B2BodyId bodyId, B2Transform target
921924 state . angularVelocity = angularVelocity ;
922925 }
923926
927+ /// Get the linear velocity of a local point attached to a body. Usually in meters per second.
924928 public static B2Vec2 b2Body_GetLocalPointVelocity ( B2BodyId bodyId , B2Vec2 localPoint )
925929 {
926930 B2World world = b2GetWorld ( bodyId . world0 ) ;
@@ -939,6 +943,7 @@ public static B2Vec2 b2Body_GetLocalPointVelocity(B2BodyId bodyId, B2Vec2 localP
939943 return v ;
940944 }
941945
946+ /// Get the linear velocity of a world point attached to a body. Usually in meters per second.
942947 public static B2Vec2 b2Body_GetWorldPointVelocity ( B2BodyId bodyId , B2Vec2 worldPoint )
943948 {
944949 B2World world = b2GetWorld ( bodyId . world0 ) ;
@@ -957,6 +962,13 @@ public static B2Vec2 b2Body_GetWorldPointVelocity(B2BodyId bodyId, B2Vec2 worldP
957962 return v ;
958963 }
959964
965+ /// Apply a force at a world point. If the force is not applied at the center of mass,
966+ /// it will generate a torque and affect the angular velocity. This optionally wakes up the body.
967+ /// The force is ignored if the body is not awake.
968+ /// @param bodyId The body id
969+ /// @param force The world force vector, usually in newtons (N)
970+ /// @param point The world position of the point of application
971+ /// @param wake Option to wake up the body
960972 public static void b2Body_ApplyForce ( B2BodyId bodyId , B2Vec2 force , B2Vec2 point , bool wake )
961973 {
962974 B2World world = b2GetWorld ( bodyId . world0 ) ;
@@ -980,6 +992,11 @@ public static void b2Body_ApplyForce(B2BodyId bodyId, B2Vec2 force, B2Vec2 point
980992 }
981993 }
982994
995+ /// Apply a force to the center of mass. This optionally wakes up the body.
996+ /// The force is ignored if the body is not awake.
997+ /// @param bodyId The body id
998+ /// @param force the world force vector, usually in newtons (N).
999+ /// @param wake also wake up the body
9831000 public static void b2Body_ApplyForceToCenter ( B2BodyId bodyId , B2Vec2 force , bool wake )
9841001 {
9851002 B2World world = b2GetWorld ( bodyId . world0 ) ;
@@ -1002,6 +1019,11 @@ public static void b2Body_ApplyForceToCenter(B2BodyId bodyId, B2Vec2 force, bool
10021019 }
10031020 }
10041021
1022+ /// Apply a torque. This affects the angular velocity without affecting the linear velocity.
1023+ /// This optionally wakes the body. The torque is ignored if the body is not awake.
1024+ /// @param bodyId The body id
1025+ /// @param torque about the z-axis (out of the screen), usually in N*m.
1026+ /// @param wake also wake up the body
10051027 public static void b2Body_ApplyTorque ( B2BodyId bodyId , float torque , bool wake )
10061028 {
10071029 B2World world = b2GetWorld ( bodyId . world0 ) ;
@@ -1024,6 +1046,20 @@ public static void b2Body_ApplyTorque(B2BodyId bodyId, float torque, bool wake)
10241046 }
10251047 }
10261048
1049+ /// Clear the force and torque on this body. Forces and torques are automatically cleared after each world
1050+ /// step. So this only needs to be called if the application wants to remove the effect of previous
1051+ /// calls to apply forces and torques before the world step is called.
1052+ /// @param bodyId The body id
1053+ public static void b2Body_ClearForces ( B2BodyId bodyId )
1054+ {
1055+ B2World world = b2GetWorld ( bodyId . world0 ) ;
1056+ B2Body body = b2GetBodyFullId ( world , bodyId ) ;
1057+ B2BodySim bodySim = b2GetBodySim ( world , body ) ;
1058+ bodySim . force = b2Vec2_zero ;
1059+ bodySim . torque = 0.0f ;
1060+ }
1061+
1062+
10271063 /// Apply an impulse at a point. This immediately modifies the velocity.
10281064 /// It also modifies the angular velocity if the point of application
10291065 /// is not at the center of mass. This optionally wakes the body.
@@ -1365,7 +1401,7 @@ public static void b2Body_SetName(B2BodyId bodyId, string name)
13651401 }
13661402 else
13671403 {
1368- body . name = "" ;
1404+ body . name = string . Empty ;
13691405 }
13701406 }
13711407
0 commit comments