(proxyId int, aabb B2AABB, displacement B2Vec2)
| 288 | } |
| 289 | |
| 290 | func (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 | |
| 330 | func (tree *B2DynamicTree) InsertLeaf(leaf int) { |
| 331 | tree.M_insertionCount++ |
nothing calls this directly
no test coverage detected