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.

74 lines
2.7 KiB

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