home *** CD-ROM | disk | FTP | other *** search
/ Cutting-Edge 3D Game Programming with C++ / CE3DC++.ISO / BOOK / CHAP11 / MORPH / POINT2D.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1995-11-06  |  1.2 KB  |  45 lines

  1. //
  2. // File name: Poin2D.CPP
  3. //
  4. // Description: Support file for the Point2D.HPP header file
  5. //
  6. // Author: John De Goes
  7. //
  8. // Project: Cutting Edge 3D Game Programming
  9. //
  10.  
  11. #ifndef POINT2DHPP
  12.   #define POINT2DHPP
  13.   #include "Point2D.HPP"
  14. #endif
  15.  
  16. // Function designed to search through List in an attempt
  17. // to determine uniqueness of vertex V:
  18. int UniqueVert ( Point2D &V, Point2D *List, int Range )
  19.   {
  20.   // Loop through list of vertices:
  21.   for ( int Count = 0; Count < Range; Count++ )
  22.       {
  23.       // If it's not unique, return false:
  24.       if ( V == List [ Count ] )
  25.          return 0;
  26.       }
  27.   // Return true (it's unique):
  28.   return 1;
  29.   }
  30.  
  31. // Function designed to search through List in an attempt
  32. // to locate the index of a vertex that matches V:
  33. unsigned int GetVertIndex ( Point2D &V, Point2D *List, unsigned int Range )
  34.   {
  35.   // Loop through the list of vertices:
  36.   for ( unsigned int Count = 0; Count < Range; Count++ )
  37.       {
  38.       // If the vertex matches, return the index:
  39.       if ( V == List [ Count ] )
  40.          return Count;
  41.       }
  42.   // Return zero as default - Note: this code should
  43.   // never be reached.
  44.   return 0;
  45.   }