Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
2.9 KiB

  1. //-----------------------------------------------------------------------------
  2. // File: node.h
  3. //
  4. // Desc: Node stuff
  5. //
  6. // Copyright (c) 1994-2000 Microsoft Corporation
  7. //-----------------------------------------------------------------------------
  8. #ifndef __node_h__
  9. #define __node_h__
  10. #define NUM_NODE (NUM_DIV - 1) // num nodes in longest dimension
  11. // maximum weighting of going straight for direction choosing functions
  12. #define MAX_WEIGHT_STRAIGHT 100
  13. //-----------------------------------------------------------------------------
  14. // Name: Node class
  15. // Desc:
  16. //-----------------------------------------------------------------------------
  17. class Node
  18. {
  19. public:
  20. void MarkAsTaken() { m_empty = FALSE; }
  21. void MarkAsEmpty() { m_empty = TRUE; }
  22. BOOL IsEmpty() { return m_empty; }
  23. private:
  24. BOOL m_empty;
  25. };
  26. //-----------------------------------------------------------------------------
  27. // Name: Node array class
  28. // Desc: - 3d array of nodes
  29. // - Functions to access node neighbours, query if taken or not, etc.
  30. // - Not only is this the node array, but a set of methods that operates on it
  31. //-----------------------------------------------------------------------------
  32. class NODE_ARRAY
  33. {
  34. public:
  35. NODE_ARRAY();
  36. ~NODE_ARRAY();
  37. void Resize( IPOINT3D *pNewSize ); // new array size
  38. void Reset(); // set all nodes to empty
  39. int ChooseRandomDirection( IPOINT3D *pos, int dir, int weight );
  40. int ChoosePreferredDirection( IPOINT3D *pos, int dir, int *prefDirs,
  41. int nPrefDirs );
  42. int ChooseNewTurnDirection( IPOINT3D *pos, int dir );
  43. int FindClearestDirection( IPOINT3D *pos );
  44. int GetBestPossibleTurns( IPOINT3D *pos, int dir, int *turnDirs );
  45. BOOL FindRandomEmptyNode( IPOINT3D *ip3dEmpty );
  46. BOOL FindRandomEmptyNode2D( IPOINT3D *pos, int plane, int *box );
  47. BOOL TakeClosestEmptyNode( IPOINT3D *newPos, IPOINT3D *pos );
  48. void NodeVisited( IPOINT3D *pos );
  49. void GetNodeCount( IPOINT3D *pos );
  50. private:
  51. Node* m_nodes; // ptr to node array
  52. int m_lock; // semaphore lock for >1 drawing pipes
  53. IPOINT3D m_numNodes; // x,y,z dimensions of node array
  54. int m_nodeDirInc[NUM_DIRS]; // array offset between nodes for each dir
  55. void GetNeighbours( IPOINT3D *pos, Node **nNode );
  56. Node* GetNode( IPOINT3D *pos );
  57. Node* GetNextNode( IPOINT3D *pos, int dir );
  58. BOOL GetNextNodePos( IPOINT3D *curPos, IPOINT3D *nextPos, int dir );
  59. int GetEmptyNeighbours( Node **nNode, int *nEmpty );
  60. int GetEmptyTurnNeighbours( Node **nNode, int *nEmpty, int lastDir );
  61. int GetEmptyNeighboursAlongDir( IPOINT3D *pos, int dir,
  62. int searchRadius );
  63. };
  64. #endif // __node_h__