Inexor
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Macros | Functions | Variables
physics.cpp File Reference
#include <boost/algorithm/clamp.hpp>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <memory>
#include "inexor/engine/material.hpp"
#include "inexor/engine/octa.hpp"
#include "inexor/engine/octree.hpp"
#include "inexor/engine/rendergl.hpp"
#include "inexor/engine/world.hpp"
#include "inexor/fpsgame/client.hpp"
#include "inexor/fpsgame/entities.hpp"
#include "inexor/fpsgame/fps.hpp"
#include "inexor/fpsgame/player.hpp"
#include "inexor/fpsgame/weapon.hpp"
#include "inexor/io/Logging.hpp"
#include "inexor/model/model.hpp"
#include "inexor/model/rendermodel.hpp"
#include "inexor/network/SharedVar.hpp"
#include "inexor/physics/bih.hpp"
#include "inexor/physics/mpr.hpp"
#include "inexor/physics/physics.hpp"
#include "inexor/shared/command.hpp"
#include "inexor/shared/cube_loops.hpp"
#include "inexor/shared/cube_types.hpp"
#include "inexor/shared/cube_vector.hpp"
#include "inexor/shared/ents.hpp"
#include "inexor/shared/geom.hpp"
#include "inexor/shared/tools.hpp"
#include "inexor/util/legacy_time.hpp"

Classes

struct  ShadowRayCache
 
struct  dynentcacheentry
 
struct  platforment
 
struct  platformcollision
 

Macros

#define INTERSECTPLANES(setentry, exit)
 
#define INTERSECTBOX(setentry, exit)
 
#define entintersect(mask, type, func)
 
#define INITRAYCUBE
 
#define CHECKINSIDEWORLD
 
#define DOWNOCTREE(disttoent, earlyexit)
 
#define FINDCLOSEST(xclosest, yclosest, zclosest)
 
#define UPOCTREE(exitworld)
 
#define DYNENTCACHESIZE   1024
 
#define DYNENTHASH(x, y)   (((((x)^(y))<<5) + (((x)^(y))>>5)) & (DYNENTCACHESIZE - 1))
 
#define loopdynentcache(curx, cury, o, radius)
 
#define CHECKSIDE(side, distval, dotval, margin, normal)
 
#define PHYSFRAMETIME   5
 
#define dir(name, v, d, s, os)   ICOMMAND(name, "D", (int *down), { player->s = *down!=0; player->v = player->s ? d : (player->os ? -(d) : 0); });
 

Functions

static clipplanesgetclipplanes (const cube &c, const ivec &o, int size, bool collide=true, int offset=0)
 
void resetclipplanes ()
 
static bool pointinbox (const vec &v, const vec &bo, const vec &br)
 
bool pointincube (const clipplanes &p, const vec &v)
 
static bool raycubeintersect (const clipplanes &p, const cube &c, const vec &v, const vec &ray, const vec &invray, float &dist)
 
void entselectionbox (const entity &e, vec &eo, vec &es)
 
static float disttoent (octaentities *oc, const vec &o, const vec &ray, float radius, int mode, extentity *t)
 
static float disttooutsideent (const vec &o, const vec &ray, float radius, int mode, extentity *t)
 
static float shadowent (octaentities *oc, const vec &o, const vec &ray, float radius, int mode, extentity *t)
 
float raycube (const vec &o, const vec &ray, float radius, int mode, int size, extentity *t)
 
float shadowray (const vec &o, const vec &ray, float radius, int mode, extentity *t)
 
ShadowRayCachenewshadowraycache ()
 
void freeshadowraycache (ShadowRayCache *&cache)
 
void resetshadowraycache (ShadowRayCache *cache)
 
float shadowray (ShadowRayCache *cache, const vec &o, const vec &ray, float radius, int mode, extentity *t)
 
float rayent (const vec &o, const vec &ray, float radius, int mode, int size, int &orient, int &ent)
 
float raycubepos (const vec &o, const vec &ray, vec &hitpos, float radius, int mode, int size)
 
bool raycubelos (const vec &o, const vec &dest, vec &hitpos)
 
float rayfloor (const vec &o, vec &floor, int mode, float radius)
 
bool ellipseboxcollide (physent *d, const vec &dir, const vec &o, const vec &center, float yaw, float xr, float yr, float hi, float lo)
 
bool ellipsecollide (physent *d, const vec &dir, const vec &o, const vec &center, float yaw, float xr, float yr, float hi, float lo)
 
void cleardynentcache ()
 
 VARF (dynentsize, 4, 7, 12, cleardynentcache())
 
const vector< physent * > & checkdynentcache (int x, int y)
 
void updatedynentcache (physent *d)
 
bool overlapsdynent (const vec &o, float radius)
 
template<class E , class O >
static bool plcollide (physent *d, const vec &dir, physent *o)
 
bool plcollide (physent *d, const vec &dir)
 
void rotatebb (vec &center, vec &radius, int yaw)
 
template<class E , class M >
static bool mmcollide (physent *d, const vec &dir, const extentity &e, const vec &center, const vec &radius, float yaw)
 
bool mmcollide (physent *d, const vec &dir, octaentities &oc)
 
template<class E >
static bool fuzzycollidesolid (physent *d, const vec &dir, float cutoff, const cube &c, const ivec &co, int size)
 
template<class E >
static bool clampcollide (const clipplanes &p, const E &entvol, const plane &w, const vec &pw)
 
template<class E >
static bool fuzzycollideplanes (physent *d, const vec &dir, float cutoff, const cube &c, const ivec &co, int size)
 
template<class E >
static bool cubecollidesolid (physent *d, const vec &dir, float cutoff, const cube &c, const ivec &co, int size)
 
template<class E >
static bool cubecollideplanes (physent *d, const vec &dir, float cutoff, const cube &c, const ivec &co, int size)
 
static bool cubecollide (physent *d, const vec &dir, float cutoff, const cube &c, const ivec &co, int size, bool solid)
 
static bool octacollide (physent *d, const vec &dir, float cutoff, const ivec &bo, const ivec &bs, const cube *c, const ivec &cor, int size)
 
static bool octacollide (physent *d, const vec &dir, float cutoff, const ivec &bo, const ivec &bs)
 
bool collide (physent *d, const vec &dir, float cutoff, bool playercol)
 
void recalcdir (physent *d, const vec &oldvel, vec &dir)
 
void slideagainst (physent *d, vec &dir, const vec &obstacle, bool foundfloor, bool slidecollide)
 
void switchfloor (physent *d, vec &dir, const vec &floor)
 
bool trystepup (physent *d, vec &dir, const vec &obstacle, float maxstep, const vec &floor)
 
bool trystepdown (physent *d, vec &dir, float step, float xy, float z, bool init=false)
 
bool trystepdown (physent *d, vec &dir, bool init=false)
 
void falling (physent *d, vec &dir, const vec &floor)
 
void landing (physent *d, vec &dir, const vec &floor, bool collided)
 
bool findfloor (physent *d, bool collided, const vec &obstacle, bool &slide, vec &floor)
 
bool move (physent *d, vec &dir)
 
bool bounce (physent *d, float secs, float elasticity, float waterfric, float grav)
 
void avoidcollision (physent *d, const vec &dir, physent *obstacle, float space)
 
bool movecamera (physent *pl, const vec &dir, float dist, float stepdist)
 
bool droptofloor (vec &o, float radius, float height)
 
float dropheight (entity &e)
 
void dropenttofloor (entity *e)
 
void phystest ()
 
 COMMAND (phystest,"")
 
void vecfromyawpitch (float yaw, float pitch, int move, int strafe, vec &m)
 
void vectoyawpitch (const vec &v, float &yaw, float &pitch)
 
 VARP (maxroll, 0, 0, 20)
 
 FVAR (straferoll, 0, 0.033f, 90)
 
 FVAR (faderoll, 0, 0.95f, 1)
 
 VAR (floatspeed, 1, 100, 10000)
 
void modifyvelocity (physent *pl, bool local, bool water, bool floating, int curtime)
 
void modifygravity (physent *pl, bool water, int curtime)
 
bool moveplayer (physent *pl, int moveres, bool local, int curtime)
 
void physicsframe ()
 
 VAR (physinterp, 0, 1, 1)
 
void interppos (physent *pl)
 
void moveplayer (physent *pl, int moveres, bool local)
 
bool bounce (physent *d, float elasticity, float waterfric, float grav)
 
void updatephysstate (physent *d)
 
template<class E , class O >
static bool platformcollide (physent *d, const vec &dir, physent *o, float margin)
 
bool platformcollide (physent *d, physent *o, const vec &dir, float margin=0)
 
bool moveplatform (physent *p, const vec &dir)
 
 ICOMMAND (attack,"D",(int *down),{game::doattack(*down!=0);})
 
 ICOMMAND (jump,"D",(int *down),{if(!*down||game::canjump()) player->jumping=*down!=0;})
 
 dir (backward, move,-1, k_down, k_up)
 
 dir (forward, move, 1, k_up, k_down)
 
 dir (left, strafe, 1, k_left, k_right)
 
 dir (right, strafe,-1, k_right, k_left)
 
bool entinmap (dynent *d, bool avoidplayers)
 

Variables

const int MAXCLIPPLANES = 1024
 
static clipplanes clipcache [MAXCLIPPLANES]
 
static int clipcacheversion = -2
 
vec hitsurface
 
float hitentdist
 
int hitent
 
int hitorient
 
bool collideinside
 
physentcollideplayer
 
vec collidewall
 
const float STAIRHEIGHT = 4.1f
 
const float FLOORZ = 0.867f
 
const float SLOPEZ = 0.5f
 
const float WALLZ = 0.2f
 
const float JUMPVEL = 125.0f
 
const float GRAVITY = 200.0f
 
static uint dynentframe = 0
 
static struct dynentcacheentry dynentcache [DYNENTCACHESIZE]
 
int physsteps = 0
 
int physframetime = PHYSFRAMETIME
 
int lastphysframe = 0
 
const float PLATFORMMARGIN = 0.2f
 
const float PLATFORMBORDER = 10.0f
 

Class Documentation

struct dynentcacheentry
Class Members
vector< physent * > dynents
uint frame
int x
int y

Macro Definition Documentation

#define CHECKINSIDEWORLD
Value:
if(!insideworld(o)) \
{ \
float disttoworld = 0, exitworld = 1e16f; \
loopi(3) \
{ \
float c = v[i]; \
if(c<0 || c>=worldsize) \
{ \
float d = ((invray[i]>0?0:worldsize)-c)*invray[i]; \
if(d<0) return (radius>0?radius:-1); \
disttoworld = max(disttoworld, 0.1f + d); \
} \
float e = ((invray[i]>0?worldsize:0)-c)*invray[i]; \
exitworld = min(exitworld, e); \
} \
if(disttoworld > exitworld) return (radius>0?radius:-1); \
v.add(vec(ray).mul(disttoworld)); \
dist += disttoworld; \
}
const T & max(const inexor::rpc::SharedVar< T > &a, const T &b)
Definition: SharedVar.hpp:224
SharedVar< int > worldsize
ICOMMAND * f(float *a, float *b), floatret(*a **b)
else loopi(numargs)
Definition: command.cpp:3019
static bool insideworld(const vec &o)
Definition: octa.hpp:67
vector with 3 floats and some useful methods.
Definition: geom.hpp:110
const T & min(const inexor::rpc::SharedVar< T > &a, const T &b)
Definition: SharedVar.hpp:210
if(NOT DEFINED PROJECT_ARCH) message(FATAL_ERROR"You are generating from the wrong folder! \"Where is the Source
Definition: CMakeLists.txt:2
int d
Definition: octaedit.cpp:1749

Referenced by raycube(), and shadowray().

#define CHECKSIDE (   side,
  distval,
  dotval,
  margin,
  normal 
)
Value:
if(visible&(1<<side)) do \
{ \
float dist = distval; \
if(dist > 0) return false; \
if(dist <= bestdist) continue; \
if(!dir.iszero()) \
{ \
if(dotval >= -cutoff*dir.magnitude()) continue; \
if(d->type<ENT_CAMERA && dotval < 0 && dist < margin) continue; \
} \
bestdist = dist; \
} while(0)
Definition: normal.cpp:31
vec collidewall
Definition: physics.cpp:484
Definition: ents.hpp:124
if(NOT DEFINED PROJECT_ARCH) message(FATAL_ERROR"You are generating from the wrong folder! \"Where is the Source
Definition: CMakeLists.txt:2
int d
Definition: octaedit.cpp:1749
#define dir(name, v, d, s, os)
Definition: physics.cpp:2014

Referenced by cubecollideplanes(), cubecollidesolid(), fuzzycollideplanes(), and fuzzycollidesolid().

#define dir (   name,
  v,
  d,
  s,
  os 
)    ICOMMAND(name, "D", (int *down), { player->s = *down!=0; player->v = player->s ? d : (player->os ? -(d) : 0); });

Referenced by decalrenderer::adddecal(), bounce(), calcavatarpos(), ragdolldata::constraindist(), mpr::EntOBB::contactface(), mpr::ModelOBB::contactface(), mpr::ModelEllipse::contactface(), cubecollide(), pvsworker::cullpvs(), damagecompass(), shadowmaptexture::dorender(), game::hideandseekclientmode::drawblip(), game::ctfclientmode::drawblip(), game::bombclientmode::drawblip(), game::collectclientmode::drawblip(), game::captureclientmode::drawblips(), drawconlines(), game::drawminimap(), game::drawteammate(), entautoview(), entpush(), entities::entradius(), fireballrenderer::finddepthfxranges(), findfile(), ai::findorientation(), gendynlightvariant(), genpoly(), inexor::filesystem::getmediapath(), game::gotoplayer(), game::gotosel(), guessshadowdir(), insideface(), ai::jumpto(), vertcommands< MDL >::loadpart(), skelcommands< MDL >::loadpart(), ai::lockon(), main(), menuinfrontofplayer(), mergepolys(), mergetexs(), mmcollide(), ragdolldata::move(), mpeditface(), game::newbouncer(), game::nextfollow(), game::nextweapon(), offsetvec(), game::parsemessages(), server::parsepacket(), game::parsepositions(), platformcollide(), plcollide(), game::projdamage(), pushsel(), game::radialbombeffect(), game::radialeffect(), recomputecamera(), animmodel::render(), renderentradius(), fireballrenderer::renderpart(), screenshot(), game::sendposition(), skelcommands< MDL >::setanim(), modelcommands< MDL, struct MDL::vertmesh >::setbumpmap(), setconskip(), modelcommands< MDL, struct MDL::vertmesh >::setdir(), skelcommands< MDL >::setpitchtarget(), modelcommands< MDL, struct MDL::vertmesh >::setskin(), sortmaterials(), gui::start(), entities::teleport(), filesval::update(), ragdolldata::updatepos(), and filesval::~filesval().

#define DOWNOCTREE (   disttoent,
  earlyexit 
)
Value:
cube *lc = levels[lshift]; \
for(;;) \
{ \
lshift--; \
lc += octastep(x, y, z, lshift); \
if(lc->ext && lc->ext->ents && lshift < elvl) \
{ \
float edist = disttoent(lc->ext->ents, o, ray, dent, mode, t); \
if(edist < dent) \
{ \
earlyexit return min(edist, dist); \
elvl = lshift; \
dent = min(dent, edist); \
} \
} \
if(lc->children==NULL) break; \
lc = lc->children; \
levels[lshift] = lc; \
}
cubeext * ext
Definition: octree.hpp:211
#define NULL
Definition: cube_types.hpp:35
static float disttoent(octaentities *oc, const vec &o, const vec &ray, float radius, int mode, extentity *t)
Definition: physics.cpp:150
const T & min(const inexor::rpc::SharedVar< T > &a, const T &b)
Definition: SharedVar.hpp:210
#define octastep(x, y, z, scale)
Definition: octree.hpp:310
if(NOT DEFINED PROJECT_ARCH) message(FATAL_ERROR"You are generating from the wrong folder! \"Where is the Source
Definition: CMakeLists.txt:2
void t(T x, const char *cmp)
Definition: utilTest.cpp:52
cube * children
Definition: octree.hpp:210
octaentities * ents
Definition: octree.hpp:200
Definition: octree.hpp:208

Referenced by raycube(), and shadowray().

#define DYNENTCACHESIZE   1024

Referenced by cleardynentcache().

#define DYNENTHASH (   x,
 
)    (((((x)^(y))<<5) + (((x)^(y))>>5)) & (DYNENTCACHESIZE - 1))
#define entintersect (   mask,
  type,
  func 
)
Value:
{\
if((mode&(mask))==(mask)) loopv(oc->type) \
{ \
extentity &e = *ents[oc->type[i]]; \
if(!(e.flags&EF_OCTA) || &e==t) continue; \
func; \
if(f<dist && f>0 && vec(ray).mul(f).add(o).insidebb(oc->o, oc->size)) \
{ \
hitentdist = dist = f; \
hitent = oc->type[i]; \
} \
} \
}
int hitorient
Definition: physics.cpp:148
vector< extentity * > ents
Definition: entities.cpp:75
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
Definition: glexts.hpp:299
int hitent
Definition: physics.cpp:148
ICOMMAND * f(float *a, float *b), floatret(*a **b)
vector with 3 floats and some useful methods.
Definition: geom.hpp:110
float hitentdist
Definition: physics.cpp:147
if(NOT DEFINED PROJECT_ARCH) message(FATAL_ERROR"You are generating from the wrong folder! \"Where is the Source
Definition: CMakeLists.txt:2
int orient
Definition: octaedit.cpp:164
void t(T x, const char *cmp)
Definition: utilTest.cpp:52
GLuint GLuint GLintptr GLsizeiptr size
Definition: glexts.hpp:412
Definition: ents.hpp:96
#define loopv(v)
Definition: cube_loops.hpp:21

Referenced by disttoent().

#define FINDCLOSEST (   xclosest,
  yclosest,
  zclosest 
)
Value:
float dx = (lo.x+(lsizemask.x<<lshift)-v.x)*invray.x, \
dy = (lo.y+(lsizemask.y<<lshift)-v.y)*invray.y, \
dz = (lo.z+(lsizemask.z<<lshift)-v.z)*invray.z; \
float disttonext = dx; \
xclosest; \
if(dy < disttonext) { disttonext = dy; yclosest; } \
if(dz < disttonext) { disttonext = dz; zclosest; } \
disttonext += 0.1f; \
v.add(vec(ray).mul(disttonext)); \
dist += disttonext;
vector with 3 floats and some useful methods.
Definition: geom.hpp:110
if(NOT DEFINED PROJECT_ARCH) message(FATAL_ERROR"You are generating from the wrong folder! \"Where is the Source
Definition: CMakeLists.txt:2

Referenced by raycube(), and shadowray().

#define INITRAYCUBE
Value:
float dist = 0, dent = radius > 0 ? radius : 1e16f; \
vec v(o), invray(ray.x ? 1/ray.x : 1e16f, ray.y ? 1/ray.y : 1e16f, ray.z ? 1/ray.z : 1e16f); \
cube *levels[20]; \
levels[worldscale] = worldroot; \
int lshift = worldscale, elvl = mode&RAY_BB ? worldscale : 0; \
ivec lsizemask(invray.x>0 ? 1 : 0, invray.y>0 ? 1 : 0, invray.z>0 ? 1 : 0); \
SharedVar< int > worldscale
cube * worldroot
Definition: octa.cpp:33
Definition: physics.hpp:23

Referenced by raycube(), and shadowray().

#define INTERSECTBOX (   setentry,
  exit 
)
Value:
loop(i, 3) \
{ \
if(ray[i]) \
{ \
float prad = fabs(p.r[i] * invray[i]), pdist = (p.o[i] - v[i]) * invray[i], pmin = pdist - prad, pmax = pdist + prad; \
if(pmin > enterdist) \
{ \
if(pmin > exitdist) exit; \
enterdist = pmin; \
setentry; \
} \
if(pmax < exitdist) \
{ \
if(pmax < enterdist) exit; \
exitdist = pmax; \
} \
} \
else if(v[i] < p.o[i]-p.r[i] || v[i] > p.o[i]+p.r[i]) exit; \
}
#define loop(v, m)
Legacy file defining loops.
Definition: cube_loops.hpp:7
if(NOT DEFINED PROJECT_ARCH) message(FATAL_ERROR"You are generating from the wrong folder! \"Where is the Source
Definition: CMakeLists.txt:2

Referenced by raycubeintersect(), and shadowray().

#define INTERSECTPLANES (   setentry,
  exit 
)
Value:
float enterdist = -1e16f, exitdist = 1e16f; \
loopi(p.size) \
{ \
float pdist = p.p[i].dist(v), facing = ray.dot(p.p[i]); \
if(facing < 0) \
{ \
pdist /= -facing; \
if(pdist > enterdist) \
{ \
if(pdist > exitdist) exit; \
enterdist = pdist; \
setentry; \
} \
} \
else if(facing > 0) \
{ \
pdist /= -facing; \
if(pdist < exitdist) \
{ \
if(pdist < enterdist) exit; \
exitdist = pdist; \
} \
} \
else if(pdist > 0) exit; \
}
else loopi(numargs)
Definition: command.cpp:3019
if(NOT DEFINED PROJECT_ARCH) message(FATAL_ERROR"You are generating from the wrong folder! \"Where is the Source
Definition: CMakeLists.txt:2

Referenced by raycubeintersect(), and shadowray().

#define loopdynentcache (   curx,
  cury,
  o,
  radius 
)
Value:
for(int curx = max(int(o.x-radius), 0)>>dynentsize, endx = min(int(o.x+radius), worldsize-1)>>dynentsize; curx <= endx; curx++) \
for(int cury = max(int(o.y-radius), 0)>>dynentsize, endy = min(int(o.y+radius), worldsize-1)>>dynentsize; cury <= endy; cury++)
const T & max(const inexor::rpc::SharedVar< T > &a, const T &b)
Definition: SharedVar.hpp:224
SharedVar< int > worldsize
const T & min(const inexor::rpc::SharedVar< T > &a, const T &b)
Definition: SharedVar.hpp:210

Referenced by overlapsdynent(), plcollide(), and updatedynentcache().

#define PHYSFRAMETIME   5

Referenced by moveplayer(), and physicsframe().

#define UPOCTREE (   exitworld)
Value:
x = int(v.x); \
y = int(v.y); \
z = int(v.z); \
uint diff = uint(lo.x^x)|uint(lo.y^y)|uint(lo.z^z); \
if(diff >= uint(worldsize)) exitworld; \
diff >>= lshift; \
if(!diff) exitworld; \
do \
{ \
lshift++; \
diff >>= 1; \
} while(diff);
unsigned int uint
Definition: cube_types.hpp:9
SharedVar< int > worldsize
if(NOT DEFINED PROJECT_ARCH) message(FATAL_ERROR"You are generating from the wrong folder! \"Where is the Source
Definition: CMakeLists.txt:2

Referenced by raycube(), and shadowray().

Function Documentation

void avoidcollision ( physent d,
const vec dir,
physent obstacle,
float  space 
)
bool bounce ( physent d,
float  secs,
float  elasticity,
float  waterfric,
float  grav 
)
bool bounce ( physent d,
float  elasticity,
float  waterfric,
float  grav 
)
const vector<physent *>& checkdynentcache ( int  x,
int  y 
)
template<class E >
static bool clampcollide ( const clipplanes p,
const E &  entvol,
const plane w,
const vec pw 
)
inlinestatic
void cleardynentcache ( )
bool collide ( physent d,
const vec dir,
float  cutoff,
bool  playercol 
)
COMMAND ( phystest  ,
""   
)
static bool cubecollide ( physent d,
const vec dir,
float  cutoff,
const cube c,
const ivec co,
int  size,
bool  solid 
)
inlinestatic
template<class E >
static bool cubecollideplanes ( physent d,
const vec dir,
float  cutoff,
const cube c,
const ivec co,
int  size 
)
static
template<class E >
static bool cubecollidesolid ( physent d,
const vec dir,
float  cutoff,
const cube c,
const ivec co,
int  size 
)
static
dir ( backward  ,
move  ,
1,
k_down  ,
k_up   
)
dir ( forward  ,
move  ,
,
k_up  ,
k_down   
)
dir ( left  ,
strafe  ,
,
k_left  ,
k_right   
)
dir ( right  ,
strafe  ,
1,
k_right  ,
k_left   
)
static float disttoent ( octaentities oc,
const vec o,
const vec ray,
float  radius,
int  mode,
extentity t 
)
static
static float disttooutsideent ( const vec o,
const vec ray,
float  radius,
int  mode,
extentity t 
)
static
void dropenttofloor ( entity e)

References dropheight(), droptofloor(), and entity::o.

Referenced by dropentity().

float dropheight ( entity e)
bool droptofloor ( vec o,
float  radius,
float  height 
)
bool ellipseboxcollide ( physent d,
const vec dir,
const vec o,
const vec center,
float  yaw,
float  xr,
float  yr,
float  hi,
float  lo 
)
bool ellipsecollide ( physent d,
const vec dir,
const vec o,
const vec center,
float  yaw,
float  xr,
float  yr,
float  hi,
float  lo 
)
bool entinmap ( dynent d,
bool  avoidplayers 
)
void entselectionbox ( const entity e,
vec eo,
vec es 
)
void falling ( physent d,
vec dir,
const vec floor 
)
bool findfloor ( physent d,
bool  collided,
const vec obstacle,
bool &  slide,
vec floor 
)
void freeshadowraycache ( ShadowRayCache *&  cache)
template<class E >
static bool fuzzycollideplanes ( physent d,
const vec dir,
float  cutoff,
const cube c,
const ivec co,
int  size 
)
static
template<class E >
static bool fuzzycollidesolid ( physent d,
const vec dir,
float  cutoff,
const cube c,
const ivec co,
int  size 
)
static
FVAR ( straferoll  ,
,
0.  033f,
90   
)
FVAR ( faderoll  ,
,
0.  95f,
 
)
static clipplanes& getclipplanes ( const cube c,
const ivec o,
int  size,
bool  collide = true,
int  offset = 0 
)
inlinestatic
ICOMMAND ( attack  ,
"D"  ,
(int *down)  ,
{game::doattack(*down!=0);}   
)
ICOMMAND ( jump  ,
"D"  ,
(int *down)  ,
{if(!*down||game::canjump()) player->jumping=*down!=0;}   
)
void interppos ( physent pl)
void landing ( physent d,
vec dir,
const vec floor,
bool  collided 
)
template<class E , class M >
static bool mmcollide ( physent d,
const vec dir,
const extentity e,
const vec center,
const vec radius,
float  yaw 
)
inlinestatic
bool mmcollide ( physent d,
const vec dir,
octaentities oc 
)
void modifygravity ( physent pl,
bool  water,
int  curtime 
)
void modifyvelocity ( physent pl,
bool  local,
bool  water,
bool  floating,
int  curtime 
)
bool move ( physent d,
vec dir 
)
bool movecamera ( physent pl,
const vec dir,
float  dist,
float  stepdist 
)
bool moveplatform ( physent p,
const vec dir 
)
bool moveplayer ( physent pl,
int  moveres,
bool  local,
int  curtime 
)
void moveplayer ( physent pl,
int  moveres,
bool  local 
)
ShadowRayCache* newshadowraycache ( )
static bool octacollide ( physent d,
const vec dir,
float  cutoff,
const ivec bo,
const ivec bs,
const cube c,
const ivec cor,
int  size 
)
inlinestatic
static bool octacollide ( physent d,
const vec dir,
float  cutoff,
const ivec bo,
const ivec bs 
)
inlinestatic
bool overlapsdynent ( const vec o,
float  radius 
)
void physicsframe ( )
void phystest ( )
template<class E , class O >
static bool platformcollide ( physent d,
const vec dir,
physent o,
float  margin 
)
inlinestatic
bool platformcollide ( physent d,
physent o,
const vec dir,
float  margin = 0 
)
template<class E , class O >
static bool plcollide ( physent d,
const vec dir,
physent o 
)
inlinestatic
bool plcollide ( physent d,
const vec dir 
)
static bool pointinbox ( const vec v,
const vec bo,
const vec br 
)
inlinestatic

Referenced by pointincube().

bool pointincube ( const clipplanes p,
const vec v 
)
float raycube ( const vec o,
const vec ray,
float  radius,
int  mode,
int  size,
extentity t 
)
static bool raycubeintersect ( const clipplanes p,
const cube c,
const vec v,
const vec ray,
const vec invray,
float &  dist 
)
inlinestatic
bool raycubelos ( const vec o,
const vec dest,
vec hitpos 
)
float raycubepos ( const vec o,
const vec ray,
vec hitpos,
float  radius,
int  mode,
int  size 
)
float rayent ( const vec o,
const vec ray,
float  radius,
int  mode,
int  size,
int &  orient,
int &  ent 
)
float rayfloor ( const vec o,
vec floor,
int  mode,
float  radius 
)

References hitsurface, and raycube().

Referenced by partrenderer::calc().

void recalcdir ( physent d,
const vec oldvel,
vec dir 
)
void resetclipplanes ( )

References clipcacheversion.

Referenced by allchanged(), and commitchanges().

void resetshadowraycache ( ShadowRayCache cache)
void rotatebb ( vec center,
vec radius,
int  yaw 
)
static float shadowent ( octaentities oc,
const vec o,
const vec ray,
float  radius,
int  mode,
extentity t 
)
static
float shadowray ( const vec o,
const vec ray,
float  radius,
int  mode,
extentity t 
)
float shadowray ( ShadowRayCache cache,
const vec o,
const vec ray,
float  radius,
int  mode,
extentity t 
)
void slideagainst ( physent d,
vec dir,
const vec obstacle,
bool  foundfloor,
bool  slidecollide 
)
void switchfloor ( physent d,
vec dir,
const vec floor 
)
bool trystepdown ( physent d,
vec dir,
float  step,
float  xy,
float  z,
bool  init = false 
)
bool trystepdown ( physent d,
vec dir,
bool  init = false 
)
bool trystepup ( physent d,
vec dir,
const vec obstacle,
float  maxstep,
const vec floor 
)
void updatedynentcache ( physent d)
void updatephysstate ( physent d)
VAR ( floatspeed  ,
,
100  ,
10000   
)
VAR ( physinterp  ,
,
,
 
)
VARF ( dynentsize  ,
,
,
12  ,
cleardynentcache()   
)
VARP ( maxroll  ,
,
,
20   
)
void vecfromyawpitch ( float  yaw,
float  pitch,
int  move,
int  strafe,
vec m 
)
void vectoyawpitch ( const vec v,
float &  yaw,
float &  pitch 
)

Variable Documentation

clipplanes clipcache[MAXCLIPPLANES]
static
int clipcacheversion = -2
static

Referenced by getclipplanes(), and resetclipplanes().

bool collideinside
physent* collideplayer

Referenced by bounce().

vec collidewall
struct dynentcacheentry dynentcache[DYNENTCACHESIZE]
static
uint dynentframe = 0
static
const float FLOORZ = 0.867f
const float GRAVITY = 200.0f
int hitent

Referenced by disttooutsideent(), and rayent().

float hitentdist

Referenced by disttooutsideent(), and rayent().

int hitorient

Referenced by disttooutsideent(), and rayent().

vec hitsurface

Referenced by rayfloor().

const float JUMPVEL = 125.0f

Referenced by modifyvelocity().

int lastphysframe = 0

Referenced by physicsframe().

const int MAXCLIPPLANES = 1024

Referenced by getclipplanes(), and shadowray().

int physframetime = PHYSFRAMETIME
int physsteps = 0

Referenced by game::updatemovables().

const float PLATFORMBORDER = 10.0f
const float PLATFORMMARGIN = 0.2f
const float SLOPEZ = 0.5f
const float STAIRHEIGHT = 4.1f

Referenced by move(), trystepdown(), and updatephysstate().

const float WALLZ = 0.2f

Referenced by falling(), findfloor(), and move().