DarkPlaces
Game engine based on the Quake 1 engine by id Software, developed by LadyHavoc
 
world.h
Go to the documentation of this file.
1/*
2Copyright (C) 1996-1997 Id Software, Inc.
3
4This program is free software; you can redistribute it and/or
5modify it under the terms of the GNU General Public License
6as published by the Free Software Foundation; either version 2
7of the License, or (at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13See the GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program; if not, write to the Free Software
17Foundation, 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 "qtypes.h"
26#include "collision.h"
27
28#define MOVE_NORMAL 0
29#define MOVE_NOMONSTERS 1
30#define MOVE_MISSILE 2
31#define MOVE_WORLDONLY 3
32#define MOVE_HITMODEL 4
33
34#define AREA_GRID 128
35#define AREA_GRIDNODES (AREA_GRID * AREA_GRID)
36
37typedef struct link_s
38{
41} link_t;
42
43typedef struct world_physics_s
44{
45 // for ODE physics engine
46 qbool ode; // if true then ode is activated
47 void *ode_world;
48 void *ode_space;
50 // number of constraint solver iterations to use (for dWorldQuickStep)
52 // actual step (server frametime / ode_iterations)
54 // time we need to simulate, for constantstep
56 // stats
57 int ode_numobjects; // total objects cound
58 int ode_activeovjects; // active objects count
59 // max velocity for a 1-unit radius object at current step to prevent
60 // missed collisions
62}
64
65struct prvm_prog_s;
66
67typedef struct world_s
68{
69 // convenient fields
70 char filename[MAX_QPATH];
73 struct prvm_prog_s *prog;
74
78
87
88 // if the QC uses a physics engine, the data for it is here
90}
92
93struct prvm_edict_s;
94
95// cyclic doubly-linked list functions
96void World_ClearLink(link_t *l);
98void World_InsertLinkBefore(link_t *l, link_t *before, int entitynumber);
99
100void World_Init(void);
101void World_Shutdown(void);
102
104void World_SetSize(world_t *world, const char *filename, const vec3_t mins, const vec3_t maxs, struct prvm_prog_s *prog);
107
108void World_PrintAreaStats(world_t *world, const char *worldname);
109
112void World_UnlinkEdict(struct prvm_edict_s *ent);
113
115void World_LinkEdict(world_t *world, struct prvm_edict_s *ent, const vec3_t mins, const vec3_t maxs, qbool link_solid_not);
116
118int World_EntitiesInBox(world_t *world, const vec3_t mins, const vec3_t maxs, int maxlist, struct prvm_edict_s **list);
119
121void World_End(world_t *world);
122
123// update physics
124// this is called by SV_Physics
125void World_Physics_Frame(world_t *world, double frametime, double gravity);
126
127// change physics properties of entity
128struct prvm_edict_s;
129struct edict_odefunc_s;
130void World_Physics_ApplyCmd(struct prvm_edict_s *ed, struct edict_odefunc_s *f);
131
132// remove physics data from entity
133// this is called by entity removal
134void World_Physics_RemoveFromEntity(world_t *world, struct prvm_edict_s *ed);
135void World_Physics_RemoveJointFromEntity(world_t *world, struct prvm_edict_s *ed);
136
137#endif
138
float frametime
vector mins
entity world
vector maxs
#define MAX_QPATH
max length of a quake game pathname
Definition qdefs.h:169
float vec_t
Definition qtypes.h:68
vec_t vec3_t[3]
Definition qtypes.h:71
bool qbool
Definition qtypes.h:9
float f
int ode_numobjects
Definition world.h:57
void * ode_world
Definition world.h:47
qbool ode
Definition world.h:46
vec_t ode_time
Definition world.h:55
void * ode_space
Definition world.h:48
void * ode_contactgroup
Definition world.h:49
vec_t ode_step
Definition world.h:53
int ode_iterations
Definition world.h:51
int ode_activeovjects
Definition world.h:58
vec_t ode_movelimit
Definition world.h:61
link_t areagrid_outside
Definition world.h:80
int areagrid_stats_calls
Definition world.h:75
vec3_t maxs
Definition world.h:72
vec3_t areagrid_bias
Definition world.h:81
vec3_t areagrid_scale
Definition world.h:82
int areagrid_stats_entitychecks
Definition world.h:77
struct prvm_prog_s * prog
Definition world.h:73
vec3_t areagrid_size
Definition world.h:85
world_physics_t physics
Definition world.h:89
vec3_t areagrid_mins
Definition world.h:83
vec3_t areagrid_maxs
Definition world.h:84
vec3_t mins
Definition world.h:71
int areagrid_marknumber
Definition world.h:86
int areagrid_stats_nodechecks
Definition world.h:76
void World_Physics_ApplyCmd(struct prvm_edict_s *ed, struct edict_odefunc_s *f)
void World_Physics_RemoveJointFromEntity(world_t *world, struct prvm_edict_s *ed)
void World_PrintAreaStats(world_t *world, const char *worldname)
Definition world.c:104
#define AREA_GRIDNODES
Definition world.h:35
void World_Init(void)
Definition world.c:38
void World_InsertLinkBefore(link_t *l, link_t *before, int entitynumber)
Definition world.c:90
int World_EntitiesInBox(world_t *world, const vec3_t mins, const vec3_t maxs, int maxlist, struct prvm_edict_s **list)
void World_ClearLink(link_t *l)
World_ClearLink is used for new headnodes.
Definition world.c:79
void World_Physics_Frame(world_t *world, double frametime, double gravity)
void World_SetSize(world_t *world, const char *filename, const vec3_t mins, const vec3_t maxs, struct prvm_prog_s *prog)
called after the world model has been loaded, before linking any entities
void World_UnlinkAll(world_t *world)
unlinks all entities (used before reallocation of edicts)
Definition world.c:159
void World_RemoveLink(link_t *l)
Definition world.c:85
void World_UnlinkEdict(struct prvm_edict_s *ent)
call before removing an entity, and before trying to move one, so it doesn't clip against itself
void World_LinkEdict(world_t *world, struct prvm_edict_s *ent, const vec3_t mins, const vec3_t maxs, qbool link_solid_not)
Needs to be called any time an entity changes origin, mins, maxs.
void World_Start(world_t *world)
Definition world.c:59
void World_End(world_t *world)
Definition world.c:69
void World_Shutdown(void)
Definition world.c:49
void World_Physics_RemoveFromEntity(world_t *world, struct prvm_edict_s *ed)