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

Method DestroyJoint

DynamicsB2World.go:337–416  ·  view source on GitHub ↗
(j B2JointInterface)

Source from the content-addressed store, hash-verified

335}
336
337func (world *B2World) DestroyJoint(j B2JointInterface) { // j backed by pointer
338 B2Assert(world.IsLocked() == false)
339 if world.IsLocked() {
340 return
341 }
342
343 collideConnected := j.IsCollideConnected()
344
345 // Remove from the doubly linked list.
346 if j.GetPrev() != nil {
347 j.GetPrev().SetNext(j.GetNext())
348 }
349
350 if j.GetNext() != nil {
351 j.GetNext().SetPrev(j.GetPrev())
352 }
353
354 if j == world.M_jointList {
355 world.M_jointList = j.GetNext()
356 }
357
358 // Disconnect from island graph.
359 bodyA := j.GetBodyA()
360 bodyB := j.GetBodyB()
361
362 // Wake up connected bodies.
363 bodyA.SetAwake(true)
364 bodyB.SetAwake(true)
365
366 // Remove from body 1.
367 if j.GetEdgeA().Prev != nil {
368 j.GetEdgeA().Prev.Next = j.GetEdgeA().Next
369 }
370
371 if j.GetEdgeA().Next != nil {
372 j.GetEdgeA().Next.Prev = j.GetEdgeA().Prev
373 }
374
375 if j.GetEdgeA() == bodyA.M_jointList {
376 bodyA.M_jointList = j.GetEdgeA().Next
377 }
378
379 j.GetEdgeA().Prev = nil
380 j.GetEdgeA().Next = nil
381
382 // Remove from body 2
383 if j.GetEdgeB().Prev != nil {
384 j.GetEdgeB().Prev.Next = j.GetEdgeB().Next
385 }
386
387 if j.GetEdgeB().Next != nil {
388 j.GetEdgeB().Next.Prev = j.GetEdgeB().Prev
389 }
390
391 if j.GetEdgeB() == bodyB.M_jointList {
392 bodyB.M_jointList = j.GetEdgeB().Next
393 }
394

Callers 1

DestroyBodyMethod · 0.95

Calls 15

IsLockedMethod · 0.95
B2AssertFunction · 0.85
B2JointDestroyFunction · 0.85
SetAwakeMethod · 0.80
IsCollideConnectedMethod · 0.65
GetPrevMethod · 0.65
SetNextMethod · 0.65
GetNextMethod · 0.65
SetPrevMethod · 0.65
GetBodyAMethod · 0.65
GetBodyBMethod · 0.65
GetEdgeAMethod · 0.65

Tested by

no test coverage detected