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

Method AddPair

DynamicsB2ContactManager.go:151–262  ·  view source on GitHub ↗
(proxyUserDataA interface{}, proxyUserDataB interface{})

Source from the content-addressed store, hash-verified

149}
150
151func (mgr *B2ContactManager) AddPair(proxyUserDataA interface{}, proxyUserDataB interface{}) {
152
153 proxyA := proxyUserDataA.(*B2FixtureProxy)
154 proxyB := proxyUserDataB.(*B2FixtureProxy)
155
156 fixtureA := proxyA.Fixture
157 fixtureB := proxyB.Fixture
158
159 indexA := proxyA.ChildIndex
160 indexB := proxyB.ChildIndex
161
162 bodyA := fixtureA.GetBody()
163 bodyB := fixtureB.GetBody()
164
165 // Are the fixtures on the same body?
166 if bodyA == bodyB {
167 return
168 }
169
170 // TODO_ERIN use a hash table to remove a potential bottleneck when both
171 // bodies have a lot of contacts.
172 // Does a contact already exist?
173 edge := bodyB.GetContactList()
174 for edge != nil {
175 if edge.Other == bodyA {
176 fA := edge.Contact.GetFixtureA()
177 fB := edge.Contact.GetFixtureB()
178 iA := edge.Contact.GetChildIndexA()
179 iB := edge.Contact.GetChildIndexB()
180
181 if fA == fixtureA && fB == fixtureB && iA == indexA && iB == indexB {
182 // A contact already exists.
183 return
184 }
185
186 if fA == fixtureB && fB == fixtureA && iA == indexB && iB == indexA {
187 // A contact already exists.
188 return
189 }
190 }
191
192 edge = edge.Next
193 }
194
195 // Does a joint override collision? Is at least one body dynamic?
196 if bodyB.ShouldCollide(bodyA) == false {
197 return
198 }
199
200 // Check user filtering.
201 if mgr.M_contactFilter != nil && mgr.M_contactFilter.ShouldCollide(fixtureA, fixtureB) == false {
202 return
203 }
204
205 // Call the factory.
206 c := B2ContactFactory(fixtureA, indexA, fixtureB, indexB)
207 if c == nil {
208 return

Callers

nothing calls this directly

Calls 14

B2ContactFactoryFunction · 0.85
GetBodyMethod · 0.80
IsSensorMethod · 0.80
SetAwakeMethod · 0.80
GetFixtureAMethod · 0.65
GetFixtureBMethod · 0.65
GetChildIndexAMethod · 0.65
GetChildIndexBMethod · 0.65
ShouldCollideMethod · 0.65
SetPrevMethod · 0.65
SetNextMethod · 0.65
GetNodeAMethod · 0.65

Tested by

no test coverage detected