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

Function MakeB2ContactSolver

DynamicsB2ContactSolver.go:86–168  ·  view source on GitHub ↗
(def *B2ContactSolverDef)

Source from the content-addressed store, hash-verified

84}
85
86func MakeB2ContactSolver(def *B2ContactSolverDef) B2ContactSolver {
87 solver := B2ContactSolver{}
88
89 solver.M_step = def.Step
90 solver.M_count = def.Count
91 solver.M_positionConstraints = make([]B2ContactPositionConstraint, solver.M_count)
92 solver.M_velocityConstraints = make([]B2ContactVelocityConstraint, solver.M_count)
93 solver.M_positions = def.Positions
94 solver.M_velocities = def.Velocities
95 solver.M_contacts = def.Contacts
96
97 // Initialize position independent portions of the constraints.
98 for i := 0; i < solver.M_count; i++ {
99 contact := solver.M_contacts[i]
100
101 fixtureA := contact.GetFixtureA()
102 fixtureB := contact.GetFixtureB()
103 shapeA := fixtureA.GetShape()
104 shapeB := fixtureB.GetShape()
105 radiusA := shapeA.GetRadius()
106 radiusB := shapeB.GetRadius()
107 bodyA := fixtureA.GetBody()
108 bodyB := fixtureB.GetBody()
109 manifold := contact.GetManifold()
110
111 pointCount := manifold.PointCount
112 B2Assert(pointCount > 0)
113
114 vc := &solver.M_velocityConstraints[i]
115 vc.Friction = contact.GetFriction()
116 vc.Restitution = contact.GetRestitution()
117 vc.TangentSpeed = contact.GetTangentSpeed()
118 vc.IndexA = bodyA.M_islandIndex
119 vc.IndexB = bodyB.M_islandIndex
120 vc.InvMassA = bodyA.M_invMass
121 vc.InvMassB = bodyB.M_invMass
122 vc.InvIA = bodyA.M_invI
123 vc.InvIB = bodyB.M_invI
124 vc.ContactIndex = i
125 vc.PointCount = pointCount
126 vc.K.SetZero()
127 vc.NormalMass.SetZero()
128
129 pc := &solver.M_positionConstraints[i]
130 pc.IndexA = bodyA.M_islandIndex
131 pc.IndexB = bodyB.M_islandIndex
132 pc.InvMassA = bodyA.M_invMass
133 pc.InvMassB = bodyB.M_invMass
134 pc.LocalCenterA = bodyA.M_sweep.LocalCenter
135 pc.LocalCenterB = bodyB.M_sweep.LocalCenter
136 pc.InvIA = bodyA.M_invI
137 pc.InvIB = bodyB.M_invI
138 pc.LocalNormal = manifold.LocalNormal
139 pc.LocalPoint = manifold.LocalPoint
140 pc.PointCount = pointCount
141 pc.RadiusA = radiusA
142 pc.RadiusB = radiusB
143 pc.Type = manifold.Type

Callers 2

SolveMethod · 0.85
SolveTOIMethod · 0.85

Calls 11

B2AssertFunction · 0.85
GetShapeMethod · 0.80
GetBodyMethod · 0.80
GetFixtureAMethod · 0.65
GetFixtureBMethod · 0.65
GetRadiusMethod · 0.65
GetManifoldMethod · 0.65
GetFrictionMethod · 0.65
GetRestitutionMethod · 0.65
GetTangentSpeedMethod · 0.65
SetZeroMethod · 0.45

Tested by

no test coverage detected