Beispiel #1
0
 //-------------------------------------------------------------------------------
 //-------------------------------------------------------------------------------
 private void AddObjects(AddObjectsFunctionDelegate <T> findFunc, object data)
 {
     if (findFunc != null)
     {
         findFunc(this, data);
     }
 }
        public ProximityMap(SearchFunctionDelegate <T> searchFunc,
                            AddObjectsFunctionDelegate <T> findFunc,
                            float fWorldSize,
                            int nMaxDepth,
                            Vector3 v3Center,
                            object searchableData,
                            GraphicsDevice device)
        {
            m_searchFunc = searchFunc;
            m_findFunc   = findFunc;

            OctTreeNode <T> .InitialiseGraphics(device);

            m_octreeRoot = new OctTreeNode <T>(nMaxDepth, 0, fWorldSize, v3Center, findFunc, searchableData);
        }
Beispiel #3
0
        //-------------------------------------------------------------------------------
        //-------------------------------------------------------------------------------
        public OctTreeNode(int nMaxDepth, int nDepth, float fParentWorldSize, Vector3 v3Center, AddObjectsFunctionDelegate <T> findFunc, object searchableData)
        {
            m_containmentList = new List <T>();
            m_fLength         = fParentWorldSize / (float)Math.Pow(2, nDepth);
            m_nDepth          = nDepth;
            m_nMaxDepth       = nMaxDepth;
            m_v3Center        = v3Center;
            int   nNextDepth = nDepth + 1;
            float fQuater    = m_fLength / 4;

            AddObjects(findFunc, searchableData);

            if (nNextDepth <= nMaxDepth)
            {
                AddChild(new OctTreeNode <T>(nMaxDepth, nNextDepth, fParentWorldSize, m_v3Center + new Vector3(-fQuater, fQuater, -fQuater), findFunc, searchableData));
                AddChild(new OctTreeNode <T>(nMaxDepth, nNextDepth, fParentWorldSize, m_v3Center + new Vector3(fQuater, fQuater, -fQuater), findFunc, searchableData));
                AddChild(new OctTreeNode <T>(nMaxDepth, nNextDepth, fParentWorldSize, m_v3Center + new Vector3(-fQuater, fQuater, fQuater), findFunc, searchableData));
                AddChild(new OctTreeNode <T>(nMaxDepth, nNextDepth, fParentWorldSize, m_v3Center + new Vector3(fQuater, fQuater, fQuater), findFunc, searchableData));
                AddChild(new OctTreeNode <T>(nMaxDepth, nNextDepth, fParentWorldSize, m_v3Center + new Vector3(-fQuater, -fQuater, -fQuater), findFunc, searchableData));
                AddChild(new OctTreeNode <T>(nMaxDepth, nNextDepth, fParentWorldSize, m_v3Center + new Vector3(fQuater, -fQuater, -fQuater), findFunc, searchableData));
                AddChild(new OctTreeNode <T>(nMaxDepth, nNextDepth, fParentWorldSize, m_v3Center + new Vector3(-fQuater, -fQuater, fQuater), findFunc, searchableData));
                AddChild(new OctTreeNode <T>(nMaxDepth, nNextDepth, fParentWorldSize, m_v3Center + new Vector3(fQuater, -fQuater, fQuater), findFunc, searchableData));
            }
        }