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

Method MoveProxy

CollisionB2DynamicTree.go:290–328  ·  view source on GitHub ↗
(proxyId int, aabb B2AABB, displacement B2Vec2)

Source from the content-addressed store, hash-verified

288}
289
290func (tree *B2DynamicTree) MoveProxy(proxyId int, aabb B2AABB, displacement B2Vec2) bool {
291
292 B2Assert(0 <= proxyId && proxyId < tree.M_nodeCapacity)
293
294 B2Assert(tree.M_nodes[proxyId].IsLeaf())
295
296 if tree.M_nodes[proxyId].Aabb.Contains(aabb) {
297 return false
298 }
299
300 tree.RemoveLeaf(proxyId)
301
302 // Extend AABB.
303 b := aabb.Clone()
304 r := MakeB2Vec2(B2_aabbExtension, B2_aabbExtension)
305 b.LowerBound = B2Vec2Sub(b.LowerBound, r)
306 b.UpperBound = B2Vec2Add(b.UpperBound, r)
307
308 // Predict AABB displacement.
309 d := B2Vec2MulScalar(B2_aabbMultiplier, displacement)
310
311 if d.X < 0.0 {
312 b.LowerBound.X += d.X
313 } else {
314 b.UpperBound.X += d.X
315 }
316
317 if d.Y < 0.0 {
318 b.LowerBound.Y += d.Y
319 } else {
320 b.UpperBound.Y += d.Y
321 }
322
323 tree.M_nodes[proxyId].Aabb = b
324
325 tree.InsertLeaf(proxyId)
326
327 return true
328}
329
330func (tree *B2DynamicTree) InsertLeaf(leaf int) {
331 tree.M_insertionCount++

Callers

nothing calls this directly

Calls 10

RemoveLeafMethod · 0.95
InsertLeafMethod · 0.95
B2AssertFunction · 0.85
MakeB2Vec2Function · 0.85
B2Vec2SubFunction · 0.85
B2Vec2AddFunction · 0.85
B2Vec2MulScalarFunction · 0.85
IsLeafMethod · 0.80
ContainsMethod · 0.80
CloneMethod · 0.65

Tested by

no test coverage detected