csg.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. #ifndef HLCSG_H__
  2. #define HLCSG_H__
  3. #if _MSC_VER >= 1000
  4. #pragma once
  5. #endif
  6. #include <deque>
  7. #include <string>
  8. #include <map>
  9. #include "cmdlib.h"
  10. #include "messages.h"
  11. #include "win32fix.h"
  12. #include "log.h"
  13. #include "hlassert.h"
  14. #include "mathlib.h"
  15. #include "scriplib.h"
  16. #include "winding.h"
  17. #include "threads.h"
  18. #include "bspfile.h"
  19. #include "blockmem.h"
  20. #include "filelib.h"
  21. #include "boundingbox.h"
  22. // AJM: added in
  23. #include "wadpath.h"
  24. #ifndef DOUBLEVEC_T
  25. #error you must add -dDOUBLEVEC_T to the project!
  26. #endif
  27. #define DEFAULT_BRUSH_UNION_THRESHOLD 0.0f
  28. #define DEFAULT_TINY_THRESHOLD 0.5
  29. #define DEFAULT_NOCLIP false
  30. #define DEFAULT_ONLYENTS false
  31. #define DEFAULT_WADTEXTURES true
  32. #define DEFAULT_SKYCLIP true
  33. #define DEFAULT_CHART false
  34. #define DEFAULT_INFO true
  35. #ifdef HLCSG_PRECISIONCLIP // KGP
  36. #define FLOOR_Z 0.5
  37. #define DEFAULT_CLIPTYPE clip_legacy
  38. #endif
  39. #ifdef ZHLT_NULLTEX // AJM
  40. #define DEFAULT_NULLTEX true
  41. #endif
  42. #ifdef HLCSG_CLIPECONOMY // AJM
  43. #define DEFAULT_CLIPNAZI true
  44. #endif
  45. #ifdef HLCSG_AUTOWAD // AJM
  46. #define DEFAULT_WADAUTODETECT false
  47. #endif
  48. #ifdef ZHLT_DETAIL // AJM
  49. #define DEFAULT_DETAIL true
  50. #endif
  51. #ifdef ZHLT_PROGRESSFILE // AJM
  52. #define DEFAULT_PROGRESSFILE NULL // progress file is only used if g_progressfile is non-null
  53. #endif
  54. // AJM: added in
  55. #define UNLESS(a) if (!(a))
  56. #ifdef SYSTEM_WIN32
  57. #define DEFAULT_ESTIMATE false
  58. #endif
  59. #ifdef SYSTEM_POSIX
  60. #define DEFAULT_ESTIMATE true
  61. #endif
  62. #define BOGUS_RANGE 8192
  63. typedef struct
  64. {
  65. vec3_t normal;
  66. vec3_t origin;
  67. vec_t dist;
  68. planetypes type;
  69. } plane_t;
  70. typedef struct
  71. {
  72. vec3_t UAxis;
  73. vec3_t VAxis;
  74. vec_t shift[2];
  75. vec_t rotate;
  76. vec_t scale[2];
  77. } valve_vects;
  78. typedef struct
  79. {
  80. float vects[2][4];
  81. } quark_vects;
  82. typedef union
  83. {
  84. valve_vects valve;
  85. quark_vects quark;
  86. }
  87. vects_union;
  88. extern int g_nMapFileVersion; // map file version * 100 (ie 201), zero for pre-Worldcraft 2.0.1 maps
  89. typedef struct
  90. {
  91. char txcommand;
  92. vects_union vects;
  93. char name[32];
  94. } brush_texture_t;
  95. typedef struct side_s
  96. {
  97. brush_texture_t td;
  98. vec_t planepts[3][3];
  99. } side_t;
  100. typedef struct bface_s
  101. {
  102. struct bface_s* next;
  103. int planenum;
  104. plane_t* plane;
  105. Winding* w;
  106. int texinfo;
  107. bool used; // just for face counting
  108. int contents;
  109. int backcontents;
  110. BoundingBox bounds;
  111. } bface_t;
  112. // NUM_HULLS should be no larger than MAX_MAP_HULLS
  113. #define NUM_HULLS 4
  114. typedef struct
  115. {
  116. BoundingBox bounds;
  117. bface_t* faces;
  118. } brushhull_t;
  119. typedef struct brush_s
  120. {
  121. int entitynum;
  122. int brushnum;
  123. int firstside;
  124. int numsides;
  125. #ifdef HLCSG_CLIPECONOMY // AJM
  126. unsigned int noclip; // !!!FIXME: this should be a flag bitfield so we can use it for other stuff (ie. is this a detail brush...)
  127. #endif
  128. int contents;
  129. brushhull_t hulls[NUM_HULLS];
  130. } brush_t;
  131. //=============================================================================
  132. // map.c
  133. extern int g_nummapbrushes;
  134. extern brush_t g_mapbrushes[MAX_MAP_BRUSHES];
  135. #define MAX_MAP_SIDES (MAX_MAP_BRUSHES*6)
  136. extern int g_numbrushsides;
  137. extern side_t g_brushsides[MAX_MAP_SIDES];
  138. extern void TextureAxisFromPlane(const plane_t* const pln, vec3_t xv, vec3_t yv);
  139. extern void LoadMapFile(const char* const filename);
  140. //=============================================================================
  141. // textures.c
  142. typedef std::deque< std::string >::iterator WadInclude_i;
  143. extern std::deque< std::string > g_WadInclude; // List of substrings to wadinclude
  144. extern void WriteMiptex();
  145. extern int TexinfoForBrushTexture(const plane_t* const plane, brush_texture_t* bt, const vec3_t origin);
  146. //=============================================================================
  147. // brush.c
  148. extern brush_t* Brush_LoadEntity(entity_t* ent, int hullnum);
  149. extern contents_t CheckBrushContents(const brush_t* const b);
  150. extern void CreateBrush(int brushnum);
  151. //=============================================================================
  152. // csg.c
  153. extern bool g_chart;
  154. extern bool g_onlyents;
  155. extern bool g_noclip;
  156. extern bool g_wadtextures;
  157. extern bool g_skyclip;
  158. extern bool g_estimate;
  159. extern const char* g_hullfile;
  160. #ifdef ZHLT_NULLTEX // AJM:
  161. extern bool g_bUseNullTex;
  162. #endif
  163. #ifdef ZHLT_DETAIL // AJM
  164. extern bool g_bDetailBrushes;
  165. #endif
  166. #ifdef HLCSG_CLIPECONOMY // AJM:
  167. extern bool g_bClipNazi;
  168. #endif
  169. #ifdef HLCSG_PRECISIONCLIP // KGP
  170. #define EnumPrint(a) #a
  171. typedef enum{clip_smallest,clip_normalized,clip_simple,clip_precise,clip_legacy} cliptype;
  172. extern cliptype g_cliptype;
  173. extern const char* GetClipTypeString(cliptype);
  174. #define TEX_BEVEL 32768
  175. #endif
  176. #ifdef ZHLT_PROGRESSFILE // AJM
  177. extern char* g_progressfile ;
  178. #endif
  179. extern vec_t g_tiny_threshold;
  180. extern vec_t g_BrushUnionThreshold;
  181. extern plane_t g_mapplanes[MAX_INTERNAL_MAP_PLANES];
  182. extern int g_nummapplanes;
  183. extern bface_t* NewFaceFromFace(const bface_t* const in);
  184. extern bface_t* CopyFace(const bface_t* const f);
  185. extern void FreeFace(bface_t* f);
  186. extern bface_t* CopyFaceList(bface_t* f);
  187. extern void FreeFaceList(bface_t* f);
  188. extern void GetParamsFromEnt(entity_t* mapent);
  189. //=============================================================================
  190. // wadinclude.c
  191. // passed 'filename' is extensionless, the function cats ".wic" at runtime
  192. extern void LoadWadincludeFile(const char* const filename);
  193. extern void SaveWadincludeFile(const char* const filename);
  194. extern void HandleWadinclude();
  195. //=============================================================================
  196. // brushunion.c
  197. void CalculateBrushUnions(int brushnum);
  198. //============================================================================
  199. // hullfile.cpp
  200. extern vec3_t g_hull_size[NUM_HULLS][2];
  201. extern void LoadHullfile(const char* filename);
  202. #ifdef HLCSG_WADCFG // AJM:
  203. //============================================================================
  204. // wadcfg.cpp
  205. extern void LoadWadConfigFile();
  206. extern void ProcessWadConfiguration();
  207. extern bool g_bWadConfigsLoaded;
  208. extern void WadCfg_cleanup();
  209. #define MAX_WAD_CFG_NAME 32
  210. extern char wadconfigname[MAX_WAD_CFG_NAME];
  211. //JK: needed in wadcfg.cpp for *nix..
  212. #ifndef SYSTEM_WIN32
  213. extern char *g_apppath;
  214. #endif
  215. //JK:
  216. extern char *g_wadcfgfile;
  217. #endif // HLCSG_WADCFG
  218. #ifdef HLCSG_AUTOWAD
  219. //============================================================================
  220. // autowad.cpp AJM
  221. extern bool g_bWadAutoDetect;
  222. extern int g_numUsedTextures;
  223. extern void GetUsedTextures();
  224. extern bool autowad_IsUsedTexture(const char* const texname);
  225. //extern bool autowad_IsUsedWad(const char* const path);
  226. //extern void autowad_PurgeName(const char* const texname);
  227. extern void autowad_cleanup();
  228. extern void autowad_UpdateUsedWads();
  229. #endif // HLCSG_AUTOWAD
  230. //=============================================================================
  231. // properties.cpp
  232. #ifdef HLCSG_NULLIFY_INVISIBLE // KGP
  233. #include <string>
  234. #include <set>
  235. extern void properties_initialize(const char* filename);
  236. extern std::set<std::string> g_invisible_items;
  237. #endif
  238. //============================================================================
  239. #endif//HLCSG_H__