示例#1
0
void Octree::UpdateObject(CollisionMesh& object)
{
    Partition* partition = object.GetPartition();
    Partition* newPartition = nullptr;
    assert(partition);

    if(!IsAllInsidePartition(object, *partition))
    {
        // Move upwards until object is fully inside a single partition
        Partition* parent = partition->GetParent();
        while(parent && !IsAllInsidePartition(object, *parent))
        {
            parent = parent->GetParent();
        }

        // Will be in found partition or one of the children
        newPartition = FindPartition(object, parent ? *parent : *m_octree);
    }
    else
    {
        // Can only be in partition and partition's children
        newPartition = FindPartition(object, *partition);
    }

    assert(newPartition);
    if(newPartition != partition)
    {
        // connect object and new partition together
        partition->RemoveNode(object);
        newPartition->AddNode(object);
        object.SetPartition(newPartition);
    }
}
示例#2
0
void Octree::IterateOctree(CollisionMesh& node)
{
    if(m_iteratorFn)
    {
        auto& partition = *node.GetPartition();
        IterateUpOctree(node, partition);
        IterateDownOctree(node, partition);
    }
}
示例#3
0
void Octree::RemoveObject(CollisionMesh& object)
{
    object.GetPartition()->RemoveNode(object);
    object.SetPartition(nullptr);
}