Logo Search packages:      
Sourcecode: blender version File versions  Download package

int btTriangleMesh::findOrAddVertex ( const btVector3 &  vertex,
bool  removeDuplicateVertices 
)

Todo:
: could use acceleration structure for this

Definition at line 78 of file btTriangleMesh.cpp.

References btAlignedObjectArray< T >::push_back(), and btAlignedObjectArray< T >::size().

Referenced by addTriangle().

{
      //return index of new/existing vertex
      ///@todo: could use acceleration structure for this
      if (m_use4componentVertices)
      {
            if (removeDuplicateVertices)
                  {
                  for (int i=0;i< m_4componentVertices.size();i++)
                  {
                        if ((m_4componentVertices[i]-vertex).length2() <= m_weldingThreshold)
                        {
                              return i;
                        }
                  }
            }
            m_indexedMeshes[0].m_numVertices++;
            m_4componentVertices.push_back(vertex);
            m_indexedMeshes[0].m_vertexBase = (unsigned char*)&m_4componentVertices[0];

            return m_4componentVertices.size()-1;
            
      } else
      {
            
            if (removeDuplicateVertices)
            {
                  for (int i=0;i< m_3componentVertices.size();i+=3)
                  {
                        btVector3 vtx(m_3componentVertices[i],m_3componentVertices[i+1],m_3componentVertices[i+2]);
                        if ((vtx-vertex).length2() <= m_weldingThreshold)
                        {
                              return i/3;
                        }
                  }
      }
            m_3componentVertices.push_back((float)vertex.getX());
            m_3componentVertices.push_back((float)vertex.getY());
            m_3componentVertices.push_back((float)vertex.getZ());
            m_indexedMeshes[0].m_numVertices++;
            m_indexedMeshes[0].m_vertexBase = (unsigned char*)&m_3componentVertices[0];
            return (m_3componentVertices.size()/3)-1;
      }

}


Generated by  Doxygen 1.6.0   Back to index