(def B2JointDefInterface)
| 276 | } |
| 277 | |
| 278 | func (world *B2World) CreateJoint(def B2JointDefInterface) B2JointInterface { |
| 279 | B2Assert(world.IsLocked() == false) |
| 280 | if world.IsLocked() { |
| 281 | return nil |
| 282 | } |
| 283 | |
| 284 | j := B2JointCreate(def) |
| 285 | |
| 286 | // Connect to the world list. |
| 287 | j.SetPrev(nil) |
| 288 | j.SetNext(world.M_jointList) |
| 289 | if world.M_jointList != nil { |
| 290 | world.M_jointList.SetPrev(j) |
| 291 | } |
| 292 | world.M_jointList = j |
| 293 | world.M_jointCount++ |
| 294 | |
| 295 | // Connect to the bodies' doubly linked lists. |
| 296 | j.GetEdgeA().Joint = j |
| 297 | j.GetEdgeA().Other = j.GetBodyB() |
| 298 | j.GetEdgeA().Prev = nil |
| 299 | j.GetEdgeA().Next = j.GetBodyA().M_jointList |
| 300 | if j.GetBodyA().M_jointList != nil { |
| 301 | j.GetBodyA().M_jointList.Prev = j.GetEdgeA() |
| 302 | } |
| 303 | |
| 304 | j.GetBodyA().M_jointList = j.GetEdgeA() |
| 305 | |
| 306 | j.GetEdgeB().Joint = j |
| 307 | j.GetEdgeB().Other = j.GetBodyA() |
| 308 | j.GetEdgeB().Prev = nil |
| 309 | j.GetEdgeB().Next = j.GetBodyB().M_jointList |
| 310 | if j.GetBodyB().M_jointList != nil { |
| 311 | j.GetBodyB().M_jointList.Prev = j.GetEdgeB() |
| 312 | } |
| 313 | j.GetBodyB().M_jointList = j.GetEdgeB() |
| 314 | |
| 315 | bodyA := def.GetBodyA() |
| 316 | bodyB := def.GetBodyB() |
| 317 | |
| 318 | // If the joint prevents collisions, then flag any contacts for filtering. |
| 319 | if def.IsCollideConnected() == false { |
| 320 | edge := bodyB.GetContactList() |
| 321 | for edge != nil { |
| 322 | if edge.Other == bodyA { |
| 323 | // Flag the contact for filtering at the next time step (where either |
| 324 | // body is awake). |
| 325 | edge.Contact.FlagForFiltering() |
| 326 | } |
| 327 | |
| 328 | edge = edge.Next |
| 329 | } |
| 330 | } |
| 331 | |
| 332 | // Note: creating a joint doesn't wake the bodies. |
| 333 | |
| 334 | return j |
| 335 | } |
nothing calls this directly
no test coverage detected