diff options
Diffstat (limited to 'src/engine/physics.cpp')
| -rw-r--r-- | src/engine/physics.cpp | 32 |
1 files changed, 5 insertions, 27 deletions
diff --git a/src/engine/physics.cpp b/src/engine/physics.cpp index 19eee8b..db30a43 100644 --- a/src/engine/physics.cpp +++ b/src/engine/physics.cpp @@ -268,8 +268,7 @@ float raycube(const vec &o, const vec &ray, float radius, int mode, int size, ex cube &c = *lc; if((dist>0 || !(mode&RAY_SKIPFIRST)) && - (((mode&RAY_CLIPMAT) && isclipped(c.material&MATF_VOLUME)) || - ((mode&RAY_EDITMAT) && c.material != MAT_AIR) || + (((mode&RAY_EDITMAT) && c.material != MAT_AIR) || (!(mode&RAY_PASS) && lsize==size && !isempty(c)) || isentirelysolid(c) || dent < dist)) @@ -1008,7 +1007,7 @@ static inline bool octacollide(physent *d, const vec &dir, float cutoff, const i { case MAT_NOCLIP: continue; case MAT_GAMECLIP: if(d->type==ENT_AI) solid = true; break; - case MAT_CLIP: if(isclipped(c[i].material&MATF_VOLUME) || d->type<ENT_CAMERA) solid = true; break; + case MAT_CLIP: if(d->type<ENT_CAMERA) solid = true; break; } if(!solid && isempty(c[i])) continue; if(cubecollide(d, dir, cutoff, c[i], o, size, solid)) return true; @@ -1038,7 +1037,7 @@ static inline bool octacollide(physent *d, const vec &dir, float cutoff, const i { case MAT_NOCLIP: return false; case MAT_GAMECLIP: if(d->type==ENT_AI) solid = true; break; - case MAT_CLIP: if(isclipped(c->material&MATF_VOLUME) || d->type<ENT_CAMERA) solid = true; break; + case MAT_CLIP: if(d->type<ENT_CAMERA) solid = true; break; } if(!solid && isempty(*c)) return false; int csize = 2<<scale, cmask = ~(csize-1); @@ -1404,14 +1403,7 @@ bool bounce(physent *d, float secs, float elasticity, float waterfric, float gra { // make sure bouncers don't start inside geometry if(d->physstate!=PHYS_BOUNCE && collide(d, vec(0, 0, 0), 0, false)) return true; - int mat = lookupmaterial(vec(d->o.x, d->o.y, d->o.z + (d->aboveeye - d->eyeheight)/2)); - bool water = isliquid(mat); - if(water) - { - d->vel.z -= grav*GRAVITY/16*secs; - d->vel.mul(max(1.0f - secs/waterfric, 0.0f)); - } - else d->vel.z -= grav*GRAVITY*secs; + d->vel.z -= grav*GRAVITY*secs; vec old(d->o); loopi(2) { @@ -1643,11 +1635,6 @@ void modifygravity(physent *pl, bool water, int curtime) float fric = water ? 2.0f : 6.0f, c = water ? 1.0f : clamp((pl->floor.z - SLOPEZ)/(FLOORZ-SLOPEZ), 0.0f, 1.0f); pl->falling.mul(pow(1 - c/fric, curtime/20.0f)); -// old fps friction -// float friction = water ? 2.0f : 6.0f, -// fpsfric = friction/curtime*20.0f, -// c = water ? 1.0f : clamp((pl->floor.z - SLOPEZ)/(FLOORZ-SLOPEZ), 0.0f, 1.0f); -// pl->falling.mul(1 - c/fpsfric); } } @@ -1658,7 +1645,6 @@ void modifygravity(physent *pl, bool water, int curtime) bool moveplayer(physent *pl, int moveres, bool local, int curtime) { int material = lookupmaterial(vec(pl->o.x, pl->o.y, pl->o.z + (3*pl->aboveeye - pl->eyeheight)/4)); - bool water = isliquid(material&MATF_VOLUME); bool floating = pl->type==ENT_PLAYER && (pl->state==CS_EDITING || pl->state==CS_SPECTATOR); float secs = curtime/1000.f; @@ -1705,15 +1691,7 @@ bool moveplayer(physent *pl, int moveres, bool local, int curtime) if(pl->strafe && maxroll) pl->roll = clamp(pl->roll - pow(clamp(1.0f + pl->strafe*pl->roll/maxroll, 0.0f, 1.0f), 0.33f)*pl->strafe*curtime*straferoll, -maxroll, maxroll); else pl->roll *= curtime == PHYSFRAMETIME ? faderoll : pow(faderoll, curtime/float(PHYSFRAMETIME)); - // play sounds on water transitions - - if(pl->inwater && !water) - { - material = lookupmaterial(vec(pl->o.x, pl->o.y, pl->o.z + (pl->aboveeye - pl->eyeheight)/2)); - water = isliquid(material&MATF_VOLUME); - } - if(!pl->inwater && water) game::physicstrigger(pl, local, 0, -1, material&MATF_VOLUME); - else if(pl->inwater && !water) game::physicstrigger(pl, local, 0, 1, pl->inwater); + if(pl->inwater) game::physicstrigger(pl, local, 0, 1, pl->inwater); pl->inwater = water ? material&MATF_VOLUME : MAT_AIR; if(pl->state==CS_ALIVE && (pl->o.z < 0 || material&MAT_DEATH)) game::suicide(pl); |
