]> icculus.org git repositories - divverent/darkplaces.git/blob - world.h
if a skyboxskinframe is missing, don't draw that sky surface (fixes crash if some...
[divverent/darkplaces.git] / world.h
1 /*
2 Copyright (C) 1996-1997 Id Software, Inc.
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13 See the GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18
19 */
20 // world.h
21
22 #ifndef WORLD_H
23 #define WORLD_H
24
25 #include "collision.h"
26
27 #define MOVE_NORMAL     0
28 #define MOVE_NOMONSTERS 1
29 #define MOVE_MISSILE    2
30 #define MOVE_WORLDONLY  3
31 #define MOVE_HITMODEL   4
32
33 #define AREA_GRID 128
34 #define AREA_GRIDNODES (AREA_GRID * AREA_GRID)
35
36 typedef struct link_s
37 {
38         int entitynumber;
39         struct link_s   *prev, *next;
40 } link_t;
41
42 typedef struct world_physics_s
43 {
44         // for ODE physics engine
45         qboolean ode; // if true then ode is activated
46         void *ode_world;
47         void *ode_space;
48         void *ode_contactgroup;
49         // number of constraint solver iterations to use (for dWorldStepFast)
50         int ode_iterations;
51         // actual step (server frametime / ode_iterations)
52         vec_t ode_step;
53         // stats
54         int ode_numobjects; // total objects cound
55         int ode_activeovjects; // active objects count
56         // max velocity for a 1-unit radius object at current step to prevent
57         // missed collisions
58         vec_t ode_movelimit;
59 }
60 world_physics_t;
61
62 typedef struct world_s
63 {
64         // convenient fields
65         char filename[MAX_QPATH];
66         vec3_t mins;
67         vec3_t maxs;
68
69         int areagrid_stats_calls;
70         int areagrid_stats_nodechecks;
71         int areagrid_stats_entitychecks;
72
73         link_t areagrid[AREA_GRIDNODES];
74         link_t areagrid_outside;
75         vec3_t areagrid_bias;
76         vec3_t areagrid_scale;
77         vec3_t areagrid_mins;
78         vec3_t areagrid_maxs;
79         vec3_t areagrid_size;
80         int areagrid_marknumber;
81
82         // if the QC uses a physics engine, the data for it is here
83         world_physics_t physics;
84 }
85 world_t;
86
87 struct prvm_edict_s;
88
89 // cyclic doubly-linked list functions
90 void World_ClearLink(link_t *l);
91 void World_RemoveLink(link_t *l);
92 void World_InsertLinkBefore(link_t *l, link_t *before, int entitynumber);
93
94 void World_Init(void);
95 void World_Shutdown(void);
96
97 /// called after the world model has been loaded, before linking any entities
98 void World_SetSize(world_t *world, const char *filename, const vec3_t mins, const vec3_t maxs);
99 /// unlinks all entities (used before reallocation of edicts)
100 void World_UnlinkAll(world_t *world);
101
102 void World_PrintAreaStats(world_t *world, const char *worldname);
103
104 /// call before removing an entity, and before trying to move one,
105 /// so it doesn't clip against itself
106 void World_UnlinkEdict(struct prvm_edict_s *ent);
107
108 /// Needs to be called any time an entity changes origin, mins, maxs
109 void World_LinkEdict(world_t *world, struct prvm_edict_s *ent, const vec3_t mins, const vec3_t maxs);
110
111 /// \returns list of entities touching a box
112 int World_EntitiesInBox(world_t *world, const vec3_t mins, const vec3_t maxs, int maxlist, struct prvm_edict_s **list);
113
114 void World_Start(world_t *world);
115 void World_End(world_t *world);
116
117 // update physics
118 // this is called by SV_Physics
119 void World_Physics_Frame(world_t *world, double frametime, double gravity);
120
121 // remove physics data from entity
122 // this is called by entity removal
123 struct prvm_edict_s;
124 void World_Physics_RemoveFromEntity(world_t *world, struct prvm_edict_s *ed);
125 void World_Physics_RemoveJointFromEntity(world_t *world, struct prvm_edict_s *ed);
126
127 #endif
128