1 /* 2 world.h 3 4 @description@ 5 6 Copyright (C) 1996-1997 Id Software, Inc. 7 8 This program is free software; you can redistribute it and/or 9 modify it under the terms of the GNU General Public License 10 as published by the Free Software Foundation; either version 2 11 of the License, or (at your option) any later version. 12 13 This program is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 17 See the GNU General Public License for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with this program; if not, write to: 21 22 Free Software Foundation, Inc. 23 59 Temple Place - Suite 330 24 Boston, MA 02111-1307, USA 25 26 */ 27 28 #ifndef __world_h 29 #define __world_h 30 31 #include "QF/link.h" 32 #include "QF/mathlib.h" 33 #include "QF/model.h" 34 35 typedef struct { 36 qboolean present; 37 vec3_t laggedpos; 38 } laggedentinfo_t; 39 40 typedef enum { 41 tr_point, 42 tr_box, 43 tr_ellipsoid, 44 } trace_e; 45 46 typedef struct trace_s { 47 qboolean allsolid; // if true, plane is not valid 48 qboolean startsolid; // if true, the initial point was in a solid area 49 qboolean inopen, inwater; 50 float fraction; // time completed, 1.0 = didn't hit anything 51 vec3_t extents; // 1/2 size of traced box 52 trace_e type; // type of trace to perform 53 vec3_t endpos; // final position 54 plane_t plane; // surface normal at impact 55 struct edict_s *ent; // entity the surface is on 56 unsigned contents; // contents of leafs touched by trace 57 } trace_t; 58 59 60 #define MOVE_NORMAL 0 61 #define MOVE_NOMONSTERS 1 62 #define MOVE_MISSILE 2 63 #define MOVE_HITMODEL 4 64 #define MOVE_RESERVED 8 65 #define MOVE_TRIGGERS 16 //triggers must be marked with FINDABLE_NONSOLID (an alternative to solid-corpse) 66 #define MOVE_EVERYTHING 32 //can return triggers and non-solid items if they're marked with FINDABLE_NONSOLID (works even if the items are not properly linked) 67 #define MOVE_LAGGED 64 //trace touches current last-known-state, instead of actual ents (just affects players for now) 68 #define MOVE_ENTCHAIN 128 //chain of impacted ents, otherwise result shows only world 69 70 typedef struct areanode_s { 71 int axis; // -1 = leaf node 72 float dist; 73 struct areanode_s *children[2]; 74 link_t trigger_edicts; 75 link_t solid_edicts; 76 } areanode_t; 77 78 #define AREA_DEPTH 4 79 #define AREA_NODES 32 80 81 extern areanode_t sv_areanodes[AREA_NODES]; 82 83 void SV_FreeAllEdictLeafs (void); 84 85 void SV_InitHull (hull_t *hull, mclipnode_t *clipnodes, plane_t *planes); 86 87 void SV_ClearWorld (void); 88 // called after the world model has been loaded, before linking any entities 89 90 void SV_UnlinkEdict (struct edict_s *ent); 91 // call before removing an entity, and before trying to move one, 92 // so it doesn't clip against itself 93 // flags ent->v.modified 94 95 void SV_LinkEdict (struct edict_s *ent, qboolean touch_triggers); 96 // Needs to be called any time an entity changes origin, mins, maxs, or solid 97 // flags ent->v.modified 98 // sets ent->v.absmin and ent->v.absmax 99 // if touchtriggers, calls prog functions for the intersected triggers 100 101 int SV_PointContents (const vec3_t p); 102 int SV_TruePointContents (const vec3_t p); 103 // returns the CONTENTS_* value from the world at the given point. 104 // does not check any entities at all 105 // the non-true version remaps the water current contents to content_water 106 107 struct edict_s *SV_TestEntityPosition (struct edict_s *ent); 108 109 trace_t SV_Move (const vec3_t start, const vec3_t mins, const vec3_t maxs, 110 const vec3_t end, int type, struct edict_s *passedict); 111 // mins and maxs are reletive 112 113 // if the entire move stays in a solid volume, trace.allsolid will be set 114 115 // if the starting point is in a solid, it will be allowed to move out 116 // to an open area 117 118 // nomonsters is used for line of sight or edge testing, where mosnters 119 // shouldn't be considered solid objects 120 121 // passedict is explicitly excluded from clipping checks (normally NULL) 122 123 struct edict_s *SV_TestPlayerPosition (struct edict_s *ent, 124 const vec3_t origin); 125 126 int SV_HullPointContents (hull_t *hull, int num, const vec3_t p); 127 hull_t *SV_HullForEntity (struct edict_s *ent, const vec3_t mins, 128 const vec3_t maxs, vec3_t extents, vec3_t offset); 129 void MOD_TraceLine (hull_t *hull, int num, 130 const vec3_t start, const vec3_t end, trace_t *trace); 131 int MOD_HullContents (hull_t *hull, int num, const vec3_t origin, 132 trace_t *trace); 133 134 typedef struct clipport_s { 135 int planenum; 136 struct clipport_s *next[2]; ///< front, back 137 struct clipleaf_s *leafs[2]; ///< front, back 138 struct winding_s *winding; 139 struct winding_s *edges; ///< unit vectors along edges 140 } clipport_t; 141 142 typedef struct clipleaf_s { 143 clipport_t *portals; 144 int contents; 145 int test_count; 146 } clipleaf_t; 147 148 typedef struct nodeleaf_s { 149 clipleaf_t *leafs[2]; ///< front, back. If null, node's child is a node 150 } nodeleaf_t; 151 152 nodeleaf_t *MOD_BuildBrushes (hull_t *hull); 153 void MOD_FreeBrushes (hull_t *hull); 154 155 #endif // __world_h 156