예제 #1
0
SpatialMarkup
RangeConvex::testNode(const SpatialVector & v0,
			const SpatialVector & v1,
			const SpatialVector & v2) {
  // Start with testing the vertices for the QuadNode with this convex.

  int vsum = testVertex(v0) + testVertex(v1) + testVertex(v2);

#ifdef DIAGNOSE
  char name[10];
  SpatialVector v = v0 + v1 + v2;
  cout << index_->nameById(index_->idByPoint(v),name)
       << " " << vsum << " " << endl;
#endif

  SpatialMarkup mark =
    testTriangle( v0, v1, v2, vsum);


#ifdef DIAGNOSE
  cout << ( mark == pARTIAL ? " partial " :
	    ( mark ==  fULL ? " full " :
	      ( mark == rEJECT ? " reject " :
		" dontknow " ) ) ) << name << endl;
    /*
       << v0 << "," << v1 << "," << v2 << " " << endl;
       << V(NV(0)) << " , " << V(NV(1)) << " , " << V(NV(2)) << endl
       << " (" << V(NV(0)).ra() << "," << V(NV(0)).dec() << ")"
       << " (" << V(NV(1)).ra() << "," << V(NV(1)).dec() << ")"
       << " (" << V(NV(2)).ra() << "," << V(NV(2)).dec() << ")"
       << endl;
    */
#endif

  // since we cannot play games using the on-the-fly triangles,
  // substitute dontknow with partial.
  if (mark == dONTKNOW)
    mark = pARTIAL;

  return mark;
}
예제 #2
0
	int testVertex( int v , Vec3D& vtx )
	{
		int cx = int( vtx.x() / m_cellLen );
		int cy = int( vtx.y() / m_cellLen );
		int cz = int( vtx.z() / m_cellLen );

		for ( int i = -1 ; i <= 1 ; ++i )
		for ( int j = -1 ; j <= 1 ; ++j )
		for ( int k = -1 ; k <= 1 ; ++k )
		{
			unsigned cell = computeHashCellIndex( cx + i , cy + j , cz + j );
			int vT = testVertex( vtx , cell );

			if ( vT != -1)
				return vT;
		}

		unsigned cell = computeHashCellIndex( cx  , cy  , cz  );
		m_cell[cell].push_back( v );

		return -1;
	}
예제 #3
0
bool ConvexFeature::collide(ConvexFeature& cf,CollisionList* cList, F32 tol)
{
   // Our vertices vs. other faces
   const Point3F* vert = mVertexList.begin();
   const Point3F* vend = mVertexList.end();
   while (vert != vend) {
      cf.testVertex(*vert,cList,false, tol);
      vert++;
   }

   // Other vertices vs. our faces
   vert = cf.mVertexList.begin();
   vend = cf.mVertexList.end();
   while (vert != vend) {
      U32 storeCount = cList->getCount();
      testVertex(*vert,cList,true, tol);

      // Fix up last reference.  material and object are copied from this rather
      //  than the object we're colliding against.
      if (storeCount != cList->getCount()) 
      {
         Collision &col = (*cList)[cList->getCount() - 1];
         col.material = cf.material;
         col.object   = cf.object;
      }
      vert++;
   }

   // Edge vs. Edge
   const Edge* edge = mEdgeList.begin();
   const Edge* eend = mEdgeList.end();
   while (edge != eend) {
      cf.testEdge(this,mVertexList[edge->vertex[0]],
         mVertexList[edge->vertex[1]],cList, tol);
      edge++;
   }

   return true;
}
예제 #4
0
/////////////TESTNODE/////////////////////////////////////
// testNode: tests the QuadNodes for intersections.
//
SpatialMarkup
RangeConvex::testNode(uint64 id)
		      //uint64 id)
		      // const struct SpatialIndex::QuadNode *indexNode)
{
  const SpatialVector *v0, *v1, *v2;
  // const struct SpatialIndex::QuadNode &indexNode = index_->nodes_[id];
  const struct SpatialIndex::QuadNode *indexNode = &index_->nodes_[id];
  int m;
  m = indexNode->v_[0];
  v0 = &index_->vertices_[m];				// the vertex vector m

  m = indexNode->v_[1];
  v1 = &index_->vertices_[m];

  m = indexNode->v_[2];
  v2 = &index_->vertices_[m];


  // testNode(V(NV(0)),V(NV(1)),V(NV(2)));
  // #define NV(m)   indexNode.v_[(m)]			// the vertices of n
  // #define NV(m)   index_->nodes_[id].v_[(m)]		// the vertices of n
  // #define V(m)    index_->vertices_[(m)]		// the vertex vector m

  // Start with testing the vertices for the QuadNode with this convex.


  int vsum = testVertex(v0) + testVertex(v1) + testVertex(v2);

#ifdef DIAGNOSE
  char name[10];
  SpatialVector v = v0 + v1 + v2;
  cout << index_->nameById(index_->idByPoint(v),name)
       << " " << vsum << " " << endl;
#endif

  SpatialMarkup mark =
    testTriangle( *v0, *v1, *v2, vsum);


#ifdef DIAGNOSE
  cout << ( mark == pARTIAL ? " partial " :
	    ( mark ==  fULL ? " full " :
	      ( mark == rEJECT ? " reject " :
		" dontknow " ) ) ) << name << endl;
    /*
       << v0 << "," << v1 << "," << v2 << " " << endl;
       << V(NV(0)) << " , " << V(NV(1)) << " , " << V(NV(2)) << endl
       << " (" << V(NV(0)).ra() << "," << V(NV(0)).dec() << ")"
       << " (" << V(NV(1)).ra() << "," << V(NV(1)).dec() << ")"
       << " (" << V(NV(2)).ra() << "," << V(NV(2)).dec() << ")"
       << endl;
    */
#endif

  // since we cannot play games using the on-the-fly triangles,
  // substitute dontknow with partial.
  if (mark == dONTKNOW)
    mark = pARTIAL;

  return mark;
}