//--
    void
    UniformGridHashBucket::CheckCollisions(int i32LastFrame, ISpatialObject* pObject)
    {        
        // [rad] Update timestamp
        m_i32LastFrame = i32LastFrame;
        
        
        /*
        // [rad] Iterate over all objects in this bucket
        std::vector<ISpatialObject*>::iterator iter_object;
        for(iter_object = m_vecObjects.begin(); iter_object != m_vecObjects.end(); iter_object++)
        {
            // [rad] Skip self
            if(pObject != (*iter_object))
            {
                // [rad] Check and report collision if there's one..
                if((*iter_object)->VCheckCollision(pObject))
                {
                    // [rad] Mark both as in collision
                    pObject->VCollisionOn();
                    (*iter_object)->VCollisionOn();
                }

            }
        }
        */
        
        // [rad] Iterate over all objects in this bucket
        ISpatialObject* pIter = m_pObjects;
        while(pIter)
        {
            if(pIter != pObject)
            {
                if(pIter->VCheckCollision(pObject))
                {
                    pObject->VCollisionOn();
                    pIter->VCollisionOn();
                }
            }
            
            pIter = pIter->VGetNext();
        }
    }
 //--
 void
 LooseOctreeNode::CheckCollisions(ISpatialObject* pObject)
 {        
     
     // [rad] Check if the object is completely outside the boundary
     // for this node
     //if(!CheckContains(pObject))
     if(!CheckBoundaries(pObject))
     {
         // [rad] Object is outside of this node
         return;
     }
     
     // [rad] Check children recursively
     for(int i = 0; i < 8; i++)
     {
         if(m_pChildren[i])
         {
             m_pChildren[i]->CheckCollisions(pObject);
         }
     }   
     
     
     // [rad] Check all objects in this node
     ISpatialObject* pIter = m_pObjects;
     while(pIter)
     {
         // [rad] Skip self check
         if(pIter != pObject)
         {
             if(pIter->VCheckCollision(pObject))
             {
                 // [rad] Mark both as in collision
                 pObject->VCollisionOn();
                 pIter->VCollisionOn();
             }
         }
         
         pIter = pIter->VGetNext();
     }
 }
Esempio n. 3
0
 //--
 void
 KDTreeNode::CheckCollisions(ISpatialObject* pObject)
 {
     Vector3 vec3Center = pObject->VGetPosition();
     float f32Radius = pObject->VGetRadius();
     
     // [rad] Check collisions against objects in this node
     if(m_i32ObjectCount)
     {
         ISpatialObject* pIter = m_pObjects;
         while(pIter)
         {
             if(pIter != pObject)
             {
                 if(pIter->VCheckCollision(pObject))
                 {
                     pIter->VCollisionOn();
                     pObject->VCollisionOn();
                 }
             }
             
             pIter = pIter->VGetNext();
         }
     }
     
     
     
     // [rad] Recurse into left child
     if(m_pChildLeft && m_pChildLeft->m_i32ObjectCount && vec3Center[m_i32SplitPane] + f32Radius <= m_f32SplitPosition)
     {
        m_pChildLeft->CheckCollisions(pObject);
     }
     
     if(m_pChildRight && m_pChildRight->m_i32ObjectCount && vec3Center[m_i32SplitPane] - f32Radius >= m_f32SplitPosition)
     {
         // [rad] Recurse into right child
         m_pChildRight->CheckCollisions(pObject);
     }
 }