Go to the documentation of this file.
211 while (
m_nodes[index].IsLeaf() ==
false)
223 float cost = 2.0f * combinedArea;
226 float inheritanceCost = 2.0f * (combinedArea - area);
234 cost1 = aabb.GetPerimeter() + inheritanceCost;
241 float newArea = aabb.GetPerimeter();
242 cost1 = (newArea - oldArea) + inheritanceCost;
251 cost2 = aabb.GetPerimeter() + inheritanceCost;
258 float newArea = aabb.GetPerimeter();
259 cost2 = newArea - oldArea + inheritanceCost;
263 if (cost < cost1 && cost < cost2)
279 int32 sibling = index;
292 if (
m_nodes[oldParent].child1 == sibling)
348 if (
m_nodes[parent].child1 == leaf)
360 if (
m_nodes[grandParent].child1 == parent)
372 int32 index = grandParent;
403 if (
A->IsLeaf() ||
A->height < 2)
560 float rootArea =
root->aabb.GetPerimeter();
562 float totalArea = 0.0f;
575 return totalArea / rootArea;
591 return 1 +
b2Max(height1, height2);
661 height = 1 +
b2Max(height1, height2);
697 int32 maxBalance = 0;
711 maxBalance =
b2Max(maxBalance, balance);
746 int32 iMin = -1, jMin = -1;
747 for (
int32 i = 0; i < count; ++i)
751 for (
int32 j = i + 1; j < count; ++j)
766 int32 index1 = nodes[iMin];
767 int32 index2 = nodes[jMin];
779 child1->
parent = parentIndex;
780 child2->
parent = parentIndex;
782 nodes[jMin] = nodes[count-1];
783 nodes[iMin] = parentIndex;
void Validate() const
Validate this tree. For testing.
void RebuildBottomUp()
Build an optimal tree. Very expensive. For testing.
void * b2Alloc(int32 size)
Implement this function to use your own memory allocator.
void ValidateMetrics(int32 index) const
void ValidateStructure(int32 index) const
b2Vec2 upperBound
the upper vertex
b2AABB aabb
Enlarged AABB.
b2DynamicTree()
Constructing the tree initializes the node pool.
void FreeNode(int32 node)
void InsertLeaf(int32 node)
int32 ComputeHeight() const
An axis aligned bounding box.
void DestroyProxy(int32 proxyId)
Destroy a proxy. This asserts if the id is invalid.
void Combine(const b2AABB &aabb)
Combine an AABB into this one.
int32 CreateProxy(const b2AABB &aabb, void *userData)
Create a proxy. Provide a tight fitting AABB and a userData pointer.
void RemoveLeaf(int32 node)
A node in the dynamic tree. The client does not interact with this directly.
float GetAreaRatio() const
Get the ratio of the sum of the node areas to the root area.
void ShiftOrigin(const b2Vec2 &newOrigin)
bool MoveProxy(int32 proxyId, const b2AABB &aabb1, const b2Vec2 &displacement)
int32 GetMaxBalance() const
int32 Balance(int32 index)
void b2Free(void *mem)
If you implement b2Alloc, you should also implement this function.
bool Contains(const b2AABB &aabb) const
Does this aabb contain the provided AABB.
float GetPerimeter() const
Get the perimeter length.
#define b2_aabbMultiplier
b2Vec2 lowerBound
the lower vertex
~b2DynamicTree()
Destroy the tree, freeing the node pool.
mvsim
Author(s):
autogenerated on Wed May 28 2025 02:13:07