Advertisement
Guest User

Untitled

a guest
Jul 16th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.70 KB | None | 0 0
  1. enum contents {
  2. contents_empty = 0x0,
  3. contents_solid = 0x1,
  4. contents_window = 0x2,
  5. contents_aux = 0x4,
  6. contents_grate = 0x8,
  7. contents_slime = 0x10,
  8. contents_water = 0x20,
  9. contents_blocklos = 0x40,
  10. contents_opaque = 0x80,
  11. contents_testfogvolume = 0x100,
  12. contents_unused = 0x200,
  13. contents_blocklight = 0x400,
  14. contents_team1 = 0x800,
  15. contents_team2 = 0x1000,
  16. contents_ignore_nodraw_opaque = 0x2000,
  17. contents_moveable = 0x4000,
  18. contents_areaportal = 0x8000,
  19. contents_playerclip = 0x10000,
  20. contents_monsterclip = 0x20000,
  21. contents_current0 = 0x40000,
  22. contents_current90 = 0x80000,
  23. contents_current180 = 0x100000,
  24. contents_current270 = 0x200000,
  25. contents_current_up = 0x400000,
  26. contents_current_down = 0x800000,
  27. contents_origin = 0x1000000,
  28. contents_monster = 0x2000000,
  29. contents_debris = 0x4000000,
  30. contents_detail = 0x8000000,
  31. contents_translucent = 0x10000000,
  32. contents_ladder = 0x20000000,
  33. contents_hitbox = 0x40000000,
  34.  
  35. last_visible_contents = contents_opaque,
  36. all_visible_contents = last_visible_contents | last_visible_contents - 1
  37. };
  38.  
  39. enum surf {
  40. surf_light = 0x1,
  41. surf_sky2d = 0x2,
  42. surf_sky = 0x4,
  43. surf_warp = 0x8,
  44. surf_trans = 0x10,
  45. surf_noportal = 0x20,
  46. surf_trigger = 0x40,
  47. surf_nodraw = 0x80,
  48. surf_hint = 0x100,
  49. surf_skip = 0x200,
  50. surf_nolight = 0x400,
  51. surf_bumplight = 0x800,
  52. surf_noshadows = 0x1000,
  53. surf_nodecals = 0x2000,
  54. surf_nopaint = surf_nodecals,
  55. surf_nochop = 0x4000,
  56. surf_hitbox = 0x8000
  57. };
  58.  
  59. enum mask {
  60. mask_all = 0xFFFFFFFF,
  61. mask_solid = ( contents_solid | contents_moveable | contents_window | contents_monster | contents_grate ),
  62. mask_playersolid = ( contents_solid | contents_moveable | contents_playerclip | contents_window | contents_monster | contents_grate ),
  63. mask_npcsolid = ( contents_solid | contents_moveable | contents_monsterclip | contents_window | contents_monster | contents_grate ),
  64. mask_npcfluid = ( contents_solid | contents_moveable | contents_monsterclip | contents_window | contents_monster ),
  65. mask_water = ( contents_water | contents_moveable | contents_slime ),
  66. mask_opaque = ( contents_water | contents_moveable | contents_opaque ),
  67. mask_opaque_npc = ( mask_opaque | contents_monster ),
  68. mask_blocklos = ( contents_solid | contents_moveable | contents_slime ),
  69. mask_blocklos_npc = ( mask_blocklos | contents_monster ),
  70. mask_visible = ( mask_opaque | contents_ignore_nodraw_opaque ),
  71. mask_visible_npc = ( mask_opaque_npc | contents_ignore_nodraw_opaque ),
  72. mask_shot = ( contents_solid | contents_moveable | contents_monster | contents_window | contents_debris | contents_hitbox ),
  73. mask_shot_brushonly = ( contents_solid | contents_moveable | contents_window | contents_debris ),
  74. mask_shot_hull = ( contents_solid | contents_moveable | contents_monster | contents_window | contents_debris | contents_grate ),
  75. mask_shot_portal = ( contents_solid | contents_moveable | contents_window | contents_monster ),
  76. mask_solid_brushonly = ( contents_solid | contents_moveable | contents_window | contents_grate ),
  77. mask_playersolid_brushonly = ( contents_solid | contents_moveable | contents_window | contents_playerclip | contents_grate ),
  78. mask_npcsolid_brushonly = ( contents_solid | contents_moveable | contents_window | contents_monsterclip | contents_grate ),
  79. mask_npcworldstatic = ( contents_solid | contents_window | contents_monsterclip | contents_grate ),
  80. mask_npcworldstatic_fluid = ( contents_solid | contents_window | contents_monsterclip ),
  81. mask_splitareaportal = ( contents_water | contents_slime ),
  82. mask_current = ( contents_current0 | contents_current90 | contents_current180 | contents_current270 | contents_current_up | contents_current_down ),
  83. mask_deadsolid = ( contents_solid | contents_playerclip | contents_window | contents_grate )
  84. };
  85.  
  86. /*
  87. * trace_type
  88. */
  89. enum trace_type {
  90. TRACE_EVERYTHING = 0,
  91. TRACE_WORLD_ONLY,
  92. TRACE_ENTITIES_ONLY,
  93. TRACE_EVERYTHING_FILTER_PROPS,
  94. };
  95.  
  96. /*
  97. * ray
  98. */
  99. struct ray {
  100. vector_aligned start;
  101. vector_aligned delta;
  102. vector_aligned start_offset;
  103. vector_aligned extents;
  104.  
  105. const mat3x4 *world_axis;
  106. bool is_ray;
  107. bool is_swept;
  108.  
  109. ray( ) : world_axis( nullptr ), is_ray( false ), is_swept( false ) { }
  110.  
  111. ray( vec3 const &_start, vec3 const &_end ) {
  112. init( _start, _end );
  113. }
  114.  
  115. ray( vec3 _start, vec3 _end, vec3 _mins, vec3 _maxs ) {
  116. init( _start, _end, _mins, _maxs );
  117. }
  118.  
  119. void init( vec3 _start, vec3 _end ) {
  120. start = _start;
  121. delta = _end - _start;
  122. is_swept = fabs( delta.length_sqr( ) ) != 0.f;
  123. extents.clear( );
  124. world_axis = nullptr;
  125. is_ray = true;
  126. start_offset.clear( );
  127. }
  128.  
  129. void init( vec3 _start, vec3 _end, vec3 _mins, vec3 _maxs ) {
  130. //m_Delta = VectorAligned(Vector(end - start));
  131. delta.x = _end.x - _start.x;
  132. delta.y = _end.y - _start.y;
  133. delta.z = _end.z - _start.z;
  134.  
  135. world_axis = nullptr;
  136. is_swept = delta.length_sqr( ) != 0.f;
  137.  
  138. //m_Extents = VectorAligned(Vector(maxs - mins));
  139. extents.x = _maxs.x - _mins.x;
  140. extents.y = _maxs.y - _mins.y;
  141. extents.z = _maxs.z - _mins.z;
  142.  
  143. extents *= 0.5f;
  144. is_ray = extents.length_sqr( ) < 1e-6;
  145.  
  146. //m_StartOffset = VectorAligned(Vector(mins + maxs));
  147. start_offset.x = _mins.x + _maxs.x;
  148. start_offset.y = _mins.y + _maxs.y;
  149. start_offset.z = _mins.z + _maxs.z;
  150.  
  151. start_offset *= 0.5f;
  152.  
  153. //m_Start = VectorAligned(Vector(start + m_StartOffset));
  154. start.x = _start.x + start_offset.x;
  155. start.y = _start.y + start_offset.y;
  156. start.z = _start.z + start_offset.z;
  157.  
  158. start_offset *= -1.0f;
  159. }
  160. };
  161.  
  162.  
  163. /*
  164. * c_trace_filter
  165. * Trace
  166. */
  167. class c_trace_filter {
  168. public:
  169. explicit c_trace_filter( c_player *entity, trace_type tracetype = TRACE_EVERYTHING ) {
  170. skip_entity = entity;
  171. type = tracetype;
  172. }
  173.  
  174. virtual bool should_hit( c_player *entity, int mask ) {
  175. return entity != skip_entity;
  176. }
  177.  
  178. virtual trace_type get_trace_type( ) {
  179. return type;
  180. }
  181.  
  182. c_player *skip_entity;
  183. trace_type type;
  184. };
  185.  
  186. /*
  187. * c_trace
  188. * Trace Class
  189. */
  190. class c_trace {
  191. public:
  192. bool disp_surface( ) const {
  193. return ( disp_flags & 1 << 0 ) != 0;
  194. }
  195. bool disp_walkable( ) const {
  196. return ( disp_flags & 1 << 1 ) != 0;
  197. }
  198. bool disp_buildable( ) const {
  199. return ( disp_flags & 1 << 2 ) != 0;
  200. }
  201. bool disp_prop_one( ) const {
  202. return ( disp_flags & 1 << 3 ) != 0;
  203. }
  204. bool disp_prop_two( ) const {
  205. return ( disp_flags & 1 << 4 ) != 0;
  206. }
  207.  
  208. vec3 startpos;
  209. vec3 endpos;
  210. c_plane plane;
  211. float fraction;
  212. int contents;
  213. unsigned short disp_flags;
  214. bool allsolid;
  215. bool startsolid;
  216.  
  217. float fractionleftsolid;
  218. c_surface surface;
  219. int hitgroup;
  220. short physicsbone;
  221. unsigned short world_surface_index;
  222. c_player *ent;
  223. int hitbox;
  224.  
  225. bool hit( ) const {
  226. return fraction < 1.f || allsolid || startsolid;
  227. }
  228. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement