home *** CD-ROM | disk | FTP | other *** search
/ AI Game Programming Wisdom / AIGameProgrammingWisdom.iso / SourceCode / 04 Pathfinding and Movement / 03 Tozour / Listing1.cpp
Encoding:
Text File  |  2001-12-09  |  864 b   |  25 lines

  1. /* Copyright (C) Paul Tozour, 2001. 
  2.  * All rights reserved worldwide.
  3.  *
  4.  * This software is provided "as is" without express or implied
  5.  * warranties. You may freely copy and compile this source into
  6.  * applications you distribute provided that the copyright text
  7.  * below is included in the resulting source code, for example:
  8.  * "Portions Copyright (C) Paul Tozour, 2001"
  9.  */
  10. function Subdivide(Polygon p, Obstacle o)
  11. {
  12.     if p is totally inside o { delete p and return }
  13.     if p is totally outside o { return }
  14.  
  15.     // we now know p is partly inside and partly outside o
  16.     if the surface area of p is below a minimum threshold
  17.     { delete p and return }
  18.  
  19.     // we now subdivide and call this function recursively
  20.     // for each new node
  21.     create new sub-polygons from p (one poly per vertex)
  22.     for each sub-polygon
  23.     { Subdivide(the sub-polygon,o) }
  24. }
  25.