MCPcopy Create free account
hub / github.com/ByteArena/box2d / Step

Method Step

DynamicsB2World.go:890–947  ·  view source on GitHub ↗
(dt float64, velocityIterations int, positionIterations int)

Source from the content-addressed store, hash-verified

888}
889
890func (world *B2World) Step(dt float64, velocityIterations int, positionIterations int) {
891 stepTimer := MakeB2Timer()
892
893 // If new fixtures were added, we need to find the new contacts.
894 if (world.M_flags & B2World_Flags.E_newFixture) != 0x0000 {
895 world.M_contactManager.FindNewContacts()
896 world.M_flags &= ^B2World_Flags.E_newFixture
897 }
898
899 world.M_flags |= B2World_Flags.E_locked
900
901 step := MakeB2TimeStep()
902 step.Dt = dt
903 step.VelocityIterations = velocityIterations
904 step.PositionIterations = positionIterations
905 if dt > 0.0 {
906 step.Inv_dt = 1.0 / dt
907 } else {
908 step.Inv_dt = 0.0
909 }
910
911 step.DtRatio = world.M_inv_dt0 * dt
912
913 step.WarmStarting = world.M_warmStarting
914
915 // Update contacts. This is where some contacts are destroyed.
916 {
917 timer := MakeB2Timer()
918 world.M_contactManager.Collide()
919 world.M_profile.Collide = timer.GetMilliseconds()
920 }
921
922 // Integrate velocities, solve velocity constraints, and integrate positions.
923 if world.M_stepComplete && step.Dt > 0.0 {
924 timer := MakeB2Timer()
925 world.Solve(step)
926 world.M_profile.Solve = timer.GetMilliseconds()
927 }
928
929 // Handle TOI events.
930 if world.M_continuousPhysics && step.Dt > 0.0 {
931 timer := MakeB2Timer()
932 world.SolveTOI(step)
933 world.M_profile.SolveTOI = timer.GetMilliseconds()
934 }
935
936 if step.Dt > 0.0 {
937 world.M_inv_dt0 = step.Inv_dt
938 }
939
940 if (world.M_flags & B2World_Flags.E_clearForces) != 0x0000 {
941 world.ClearForces()
942 }
943
944 world.M_flags &= ^B2World_Flags.E_locked
945
946 world.M_profile.Step = stepTimer.GetMilliseconds()
947}

Callers

nothing calls this directly

Calls 8

SolveMethod · 0.95
SolveTOIMethod · 0.95
ClearForcesMethod · 0.95
MakeB2TimerFunction · 0.85
MakeB2TimeStepFunction · 0.85
FindNewContactsMethod · 0.80
GetMillisecondsMethod · 0.80
CollideMethod · 0.45

Tested by

no test coverage detected