aas_create.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*
  2. ===========================================================================
  3. Copyright (C) 1999-2005 Id Software, Inc.
  4. This file is part of Quake III Arena source code.
  5. Quake III Arena source code is free software; you can redistribute it
  6. and/or modify it under the terms of the GNU General Public License as
  7. published by the Free Software Foundation; either version 2 of the License,
  8. or (at your option) any later version.
  9. Quake III Arena source code is distributed in the hope that it will be
  10. useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with Foobar; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  16. ===========================================================================
  17. */
  18. #define AREA_PORTAL 1
  19. //temporary AAS face
  20. typedef struct tmp_face_s
  21. {
  22. int num; //face number
  23. int planenum; //number of the plane the face is in
  24. winding_t *winding; //winding of the face
  25. struct tmp_area_s *frontarea; //area at the front of the face
  26. struct tmp_area_s *backarea; //area at the back of the face
  27. int faceflags; //flags of this face
  28. int aasfacenum; //the number of the aas face used for this face
  29. //double link list pointers for front and back area
  30. struct tmp_face_s *prev[2], *next[2];
  31. //links in the list with faces
  32. struct tmp_face_s *l_prev, *l_next;
  33. } tmp_face_t;
  34. //temporary AAS area settings
  35. typedef struct tmp_areasettings_s
  36. {
  37. //could also add all kind of statistic fields
  38. int contents; //contents of the area
  39. int modelnum; //bsp model inside this area
  40. int areaflags; //area flags
  41. int presencetype; //how a bot can be present in this area
  42. int numreachableareas; //number of reachable areas from this one
  43. int firstreachablearea; //first reachable area in the reachable area index
  44. } tmp_areasettings_t;
  45. //temporary AAS area
  46. typedef struct tmp_area_s
  47. {
  48. int areanum; //number of the area
  49. struct tmp_face_s *tmpfaces; //the faces of the area
  50. int presencetype; //presence type of the area
  51. int contents; //area contents
  52. int modelnum; //bsp model inside this area
  53. int invalid; //true if the area is invalid
  54. tmp_areasettings_t *settings; //area settings
  55. struct tmp_area_s *mergedarea; //points to the new area after merging
  56. //when mergedarea != 0 the area has only the
  57. //seperating face of the merged areas
  58. int aasareanum; //number of the aas area created for this tmp area
  59. //links in the list with areas
  60. struct tmp_area_s *l_prev, *l_next;
  61. } tmp_area_t;
  62. //temporary AAS node
  63. typedef struct tmp_node_s
  64. {
  65. int planenum; //node plane number
  66. struct tmp_area_s *tmparea; //points to an area if this node is an area
  67. struct tmp_node_s *children[2]; //child nodes of this node
  68. } tmp_node_t;
  69. #define NODEBUF_SIZE 128
  70. //node buffer
  71. typedef struct tmp_nodebuf_s
  72. {
  73. int numnodes;
  74. struct tmp_nodebuf_s *next;
  75. tmp_node_t nodes[NODEBUF_SIZE];
  76. } tmp_nodebuf_t;
  77. //the whole temorary AAS
  78. typedef struct tmp_aas_s
  79. {
  80. //faces
  81. int numfaces;
  82. int facenum;
  83. tmp_face_t *faces;
  84. //areas
  85. int numareas;
  86. int areanum;
  87. tmp_area_t *areas;
  88. //area settings
  89. int numareasettings;
  90. tmp_areasettings_t *areasettings;
  91. //nodes
  92. int numnodes;
  93. tmp_node_t *nodes;
  94. //node buffer
  95. tmp_nodebuf_t *nodebuffer;
  96. } tmp_aas_t;
  97. extern tmp_aas_t tmpaasworld;
  98. //creates a .AAS file with the given name from an already loaded map
  99. void AAS_Create(char *aasfile);
  100. //adds a face side to an area
  101. void AAS_AddFaceSideToArea(tmp_face_t *tmpface, int side, tmp_area_t *tmparea);
  102. //remvoes a face from an area
  103. void AAS_RemoveFaceFromArea(tmp_face_t *tmpface, tmp_area_t *tmparea);
  104. //allocate a tmp face
  105. tmp_face_t *AAS_AllocTmpFace(void);
  106. //free the tmp face
  107. void AAS_FreeTmpFace(tmp_face_t *tmpface);
  108. //allocate a tmp area
  109. tmp_area_t *AAS_AllocTmpArea(void);
  110. //free a tmp area
  111. void AAS_FreeTmpArea(tmp_area_t *tmparea);
  112. //allocate a tmp node
  113. tmp_node_t *AAS_AllocTmpNode(void);
  114. //free a tmp node
  115. void AAS_FreeTmpNode(tmp_node_t *node);
  116. //checks if an area is ok
  117. void AAS_CheckArea(tmp_area_t *tmparea);
  118. //flips the area faces where needed
  119. void AAS_FlipAreaFaces(tmp_area_t *tmparea);
  120. //returns true if the face is a gap seen from the given side
  121. int AAS_GapFace(tmp_face_t *tmpface, int side);
  122. //returns true if the face is a ground face
  123. int AAS_GroundFace(tmp_face_t *tmpface);