static int pfnPointContents( float *p, int *truecontents ) { int cont, truecont; truecont = cont = SV_TruePointContents( p ); if( truecontents ) *truecontents = truecont; if( cont <= CONTENTS_CURRENT_0 && cont >= CONTENTS_CURRENT_DOWN ) cont = CONTENTS_WATER; return cont; }
/* ============= SV_CheckWater ============= */ qboolean SV_CheckWater (edict_t *ent) { vec3_t point; int cont; #ifdef QUAKE2 int truecont; #endif point[0] = ent->v.origin[0]; point[1] = ent->v.origin[1]; point[2] = ent->v.origin[2] + ent->v.mins[2] + 1; ent->v.waterlevel = 0; ent->v.watertype = CONTENTS_EMPTY; cont = SV_PointContents (point); if (cont <= CONTENTS_WATER) { #ifdef QUAKE2 truecont = SV_TruePointContents (point); #endif ent->v.watertype = cont; ent->v.waterlevel = 1; point[2] = ent->v.origin[2] + (ent->v.mins[2] + ent->v.maxs[2])*0.5; cont = SV_PointContents (point); if (cont <= CONTENTS_WATER) { ent->v.waterlevel = 2; point[2] = ent->v.origin[2] + ent->v.view_ofs[2]; cont = SV_PointContents (point); if (cont <= CONTENTS_WATER) ent->v.waterlevel = 3; } #ifdef QUAKE2 if (truecont <= CONTENTS_CURRENT_0 && truecont >= CONTENTS_CURRENT_DOWN) { static vec3_t current_table[] = { {1, 0, 0}, {0, 1, 0}, {-1, 0, 0}, {0, -1, 0}, {0, 0, 1}, {0, 0, -1} }; VectorMA (ent->v.basevelocity, 150.0*ent->v.waterlevel/3.0, current_table[CONTENTS_CURRENT_0 - truecont], ent->v.basevelocity); } #endif } return ent->v.waterlevel > 1; }
/* ============= SV_CheckWater ============= */ qboolean SV_CheckWater( edict_t *ent ) { int cont, truecont; vec3_t point; point[0] = (ent->v.absmax[0] + ent->v.absmin[0]) * 0.5f; point[1] = (ent->v.absmax[1] + ent->v.absmin[1]) * 0.5f; point[2] = (ent->v.absmin[2] + 1.0f); ent->v.watertype = CONTENTS_EMPTY; svs.groupmask = ent->v.groupinfo; ent->v.waterlevel = 0; cont = SV_PointContents( point ); if( cont <= CONTENTS_WATER && cont > CONTENTS_TRANSLUCENT ) { svs.groupmask = ent->v.groupinfo; truecont = SV_TruePointContents( point ); ent->v.watertype = cont; ent->v.waterlevel = 1; if( ent->v.absmin[2] == ent->v.absmax[2] ) { // a point entity ent->v.waterlevel = 3; } else { point[2] = (ent->v.absmin[2] + ent->v.absmax[2]) * 0.5f; svs.groupmask = ent->v.groupinfo; cont = SV_PointContents( point ); if( cont <= CONTENTS_WATER && cont > CONTENTS_TRANSLUCENT ) { ent->v.waterlevel = 2; VectorAdd( point, ent->v.view_ofs, point ); svs.groupmask = ent->v.groupinfo; cont = SV_PointContents( point ); if( cont <= CONTENTS_WATER && cont > CONTENTS_TRANSLUCENT ) ent->v.waterlevel = 3; } } // Quake2 feature. Probably never was used in Half-Life... if( truecont <= CONTENTS_CURRENT_0 && truecont >= CONTENTS_CURRENT_DOWN ) { float speed = 50.0f * ent->v.waterlevel; const float *dir = current_table[CONTENTS_CURRENT_0 - truecont]; VectorMA( ent->v.basevelocity, speed, dir, ent->v.basevelocity ); } } return (ent->v.waterlevel > 1); //-V602 }
static int pfnTruePointContents( float *p ) { return SV_TruePointContents( p ); }