Exemplo n.º 1
0
        public bool m_needcleanup;				// Need to run cleanup?

        public DbvtBroadphase(IOverlappingPairCache paircache)
        {
            for (int i = 0; i < m_sets.Length; i++)
                m_sets[i] = new Dbvt();
            m_deferedcollide = false;
            m_needcleanup = true;
            m_releasepaircache = (paircache != null) ? false : true;
            m_prediction = 0;
            m_stageCurrent = 0;
            m_fixedleft = 0;
            m_fupdates = 1;
            m_dupdates = 0;
            m_cupdates = 10;
            m_newpairs = 1;
            m_updates_call = 0;
            m_updates_done = 0;
            m_updates_ratio = 0;
            m_paircache = (paircache != null) ? paircache : new HashedOverlappingPairCache();
            m_gid = 0;
            m_pid = 0;
            m_cid = 0;
            for (int i = 0; i <= STAGECOUNT; ++i)
            {
                m_stageRoots[i] = null;
            }
#if DBVT_BP_PROFILE
	        clear(m_profiling);
#endif
        }
Exemplo n.º 2
0
Arquivo: Dbvt.cs Projeto: himapo/ccm
 private static DbvtNode createnode(Dbvt pdbvt,
                                    DbvtNode parent,
                                    ref DbvtAabbMm volume,
                                    object data)
 {
     DbvtNode node = createnode(pdbvt, parent, data);
     node.volume = volume;
     return (node);
 }
Exemplo n.º 3
0
Arquivo: Dbvt.cs Projeto: himapo/ccm
 static DbvtNode createnode(Dbvt pdbvt,
                                    DbvtNode parent,
                                    object data)
 {
     DbvtNode node;
     if (pdbvt.m_free != null)
     {
         node = pdbvt.m_free;
         pdbvt.m_free = null;
     }
     else
     {
         node = new DbvtNode();
     }
     node.parent = parent;
     node.data = data;
     node.childs[1] = null;
     return (node);
 }
Exemplo n.º 4
0
Arquivo: Dbvt.cs Projeto: himapo/ccm
 private static DbvtNode createnode(Dbvt pdbvt,
                                    DbvtNode parent,
                                    ref DbvtAabbMm volume0,
                                    ref DbvtAabbMm volume1,
                                    object data)
 {
     DbvtNode node = createnode(pdbvt, parent, data);
     Merge(ref volume0,ref volume1,ref node.volume);
     return (node);
 }
Exemplo n.º 5
0
Arquivo: Dbvt.cs Projeto: himapo/ccm
 static void deletenode(Dbvt pdbvt, DbvtNode node)
 {
     //btAlignedFree(pdbvt->m_free);
     pdbvt.m_free = node;
 }
Exemplo n.º 6
0
Arquivo: Dbvt.cs Projeto: himapo/ccm
 //
 static DbvtNode removeleaf(Dbvt pdbvt, DbvtNode leaf)
 {
     if (leaf == pdbvt.m_root)
     {
         pdbvt.m_root = null;
         return null;
     }
     else
     {
         DbvtNode parent = leaf.parent;
         DbvtNode prev = parent.parent;
         DbvtNode sibling = parent.childs[1 - indexof(leaf)];
         if (prev != null)
         {
             prev.childs[indexof(parent)] = sibling;
             sibling.parent = prev;
             deletenode(pdbvt, parent);
             while (prev != null)
             {
                 DbvtAabbMm pb = prev.volume;
                 Merge(ref prev.childs[0].volume,ref prev.childs[1].volume,ref prev.volume);
                 if (NotEqual(ref pb, ref prev.volume))
                 {
                     prev = prev.parent;
                 }
                 else break;
             }
             return (prev != null ? prev : pdbvt.m_root);
         }
         else
         {
             pdbvt.m_root = sibling;
             sibling.parent = null;
             deletenode(pdbvt, parent);
             return (pdbvt.m_root);
         }
     }
 }
Exemplo n.º 7
0
Arquivo: Dbvt.cs Projeto: himapo/ccm
 private static void insertleaf(Dbvt pdbvt,
                                    DbvtNode root,
                                    DbvtNode leaf)
 {
     if (pdbvt.m_root == null)
     {
         pdbvt.m_root = leaf;
         leaf.parent = null;
     }
     else
     {
         if (!root.isleaf())
         {
             do
             {
                 root = root.childs[Select(ref leaf.volume,
                     ref root.childs[0].volume,
                     ref root.childs[1].volume)];
             } while (!root.isleaf());
         }
         DbvtNode prev = root.parent;
         DbvtNode node = createnode(pdbvt, prev,ref leaf.volume,ref root.volume, null);
         if (prev != null)
         {
             prev.childs[indexof(root)] = node;
             node.childs[0] = root; root.parent = node;
             node.childs[1] = leaf; leaf.parent = node;
             do
             {
                 if (!prev.volume.Contain(ref node.volume))
                     Merge(ref prev.childs[0].volume,ref prev.childs[1].volume,ref prev.volume);
                 else
                     break;
                 node = prev;
                 prev = node.parent;
             } while (null != prev);
         }
         else
         {
             node.childs[0] = root; root.parent = node;
             node.childs[1] = leaf; leaf.parent = node;
             pdbvt.m_root = node;
         }
     }
 }