diff options
Diffstat (limited to 'src/cgame')
-rw-r--r-- | src/cgame/cg_ents.c | 42 | ||||
-rw-r--r-- | src/cgame/cg_local.h | 18 | ||||
-rw-r--r-- | src/cgame/cg_predict.c | 50 | ||||
-rw-r--r-- | src/cgame/cg_public.h | 2 | ||||
-rw-r--r-- | src/cgame/cg_syscalls.asm | 2 | ||||
-rw-r--r-- | src/cgame/cg_syscalls.c | 17 |
6 files changed, 88 insertions, 43 deletions
diff --git a/src/cgame/cg_ents.c b/src/cgame/cg_ents.c index f2f593cf..0c279a31 100644 --- a/src/cgame/cg_ents.c +++ b/src/cgame/cg_ents.c @@ -670,10 +670,10 @@ static void CG_LightFlare( centity_t *cent ) float radiusMod = 1.0f - ( 180.0f - RAD2DEG( acos( DotProduct( delta, forward ) ) ) ) / maxAngle; - if( es->eFlags & EF_NODRAW ) - flare.radius *= radiusMod; - else if( radiusMod < 0.0f ) - flare.radius = 0.0f; + if( radiusMod < 0.0f ) + radiusMod = 0.0f; + + flare.radius *= radiusMod; } if( flare.radius < 0.0f ) @@ -684,34 +684,14 @@ static void CG_LightFlare( centity_t *cent ) if( cg_lightFlare.integer == FLARE_REALFADE ) { - //draw "correct" albeit inefficient flares - srLocal = cent->lfs.lastSrcRadius; - - //flare radius is likely to be the same as last frame so start with it - do - { - srLocal += RADIUSSTEP; - SETBOUNDS( mins, maxs, srLocal ); - CG_Trace( &tr, start, mins, maxs, end, - entityNum, MASK_SHOT ); - - } while( ( tr.fraction == 1.0f && !tr.startsolid ) && ( srLocal < srcRadius ) ); - - srLocal -= RADIUSSTEP; + //"correct" flares + CG_BiSphereTrace( &tr, cg.refdef.vieworg, end, + 1.0f, srcRadius, entityNum, MASK_SHOT ); - //shink the flare until there is a los - do - { - SETBOUNDS( mins, maxs, srLocal ); - CG_Trace( &tr, start, mins, maxs, end, - entityNum, MASK_SHOT ); - - srLocal -= RADIUSSTEP; - } while( ( tr.fraction < 1.0f || tr.startsolid ) && ( srLocal > 0.0f ) ); - - ratio = srLocal / srcRadius; - - cent->lfs.lastSrcRadius = srLocal; + if( tr.fraction < 1.0f ) + ratio = tr.lateralFraction; + else + ratio = 1.0f; } else if( cg_lightFlare.integer == FLARE_TIMEFADE ) { diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h index b88d8d0c..b319e547 100644 --- a/src/cgame/cg_local.h +++ b/src/cgame/cg_local.h @@ -591,7 +591,6 @@ typedef struct typedef struct lightFlareStatus_s { - float lastSrcRadius; //caching of likely flare source radius float lastRadius; //caching of likely flare radius float lastRatio; //caching of likely flare ratio int lastTime; //last time flare was visible/occluded @@ -1637,10 +1636,12 @@ void CG_ModelDoor( centity_t *cent ); void CG_BuildSolidList( void ); int CG_PointContents( const vec3_t point, int passEntityNum ); -void CG_Trace( trace_t *result, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, - int skipNumber, int mask ); -void CG_CapTrace( trace_t *result, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, - int skipNumber, int mask ); +void CG_Trace( trace_t *result, const vec3_t start, const vec3_t mins, const vec3_t maxs, + const vec3_t end, int skipNumber, int mask ); +void CG_CapTrace( trace_t *result, const vec3_t start, const vec3_t mins, const vec3_t maxs, + const vec3_t end, int skipNumber, int mask ); +void CG_BiSphereTrace( trace_t *result, const vec3_t start, const vec3_t end, + const float startRadius, const float endRadius, int skipNumber, int mask ); void CG_PredictPlayerState( void ); @@ -1891,6 +1892,13 @@ void trap_CM_TransformedCapsuleTrace( trace_t *results, const vec3_t st const vec3_t mins, const vec3_t maxs, clipHandle_t model, int brushmask, const vec3_t origin, const vec3_t angles ); +void trap_CM_BiSphereTrace( trace_t *results, const vec3_t start, + const vec3_t end, float startRad, float endRad, + clipHandle_t model, int mask ); +void trap_CM_TransformedBiSphereTrace( trace_t *results, const vec3_t start, + const vec3_t end, float startRad, float endRad, + clipHandle_t model, int mask, + const vec3_t origin ); // Returns the projection of a polygon onto the solid brushes in the world int trap_CM_MarkFragments( int numPoints, const vec3_t *points, diff --git a/src/cgame/cg_predict.c b/src/cgame/cg_predict.c index 5d2950cb..8c4bc8e3 100644 --- a/src/cgame/cg_predict.c +++ b/src/cgame/cg_predict.c @@ -87,8 +87,9 @@ CG_ClipMoveToEntities ==================== */ -static void CG_ClipMoveToEntities ( const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, - int skipNumber, int mask, trace_t *tr, qboolean capsule ) +static void CG_ClipMoveToEntities ( const vec3_t start, const vec3_t mins, + const vec3_t maxs, const vec3_t end, int skipNumber, + int mask, trace_t *tr, traceType_t collisionType ) { int i, j, x, zd, zu; trace_t trace; @@ -145,21 +146,34 @@ static void CG_ClipMoveToEntities ( const vec3_t start, const vec3_t mins, const } - if( capsule ) + if( collisionType == TT_CAPSULE ) { trap_CM_TransformedCapsuleTrace ( &trace, start, end, mins, maxs, cmodel, mask, origin, angles ); } - else + else if( collisionType == TT_AABB ) { trap_CM_TransformedBoxTrace ( &trace, start, end, mins, maxs, cmodel, mask, origin, angles ); } + else if( collisionType == TT_BISPHERE ) + { + trap_CM_TransformedBiSphereTrace( &trace, start, end, + mins[ 0 ], maxs[ 0 ], cmodel, mask, origin ); + } if( trace.allsolid || trace.fraction < tr->fraction ) { trace.entityNum = ent->number; - *tr = trace; + + if( tr->lateralFraction < trace.lateralFraction ) + { + float oldLateralFraction = tr->lateralFraction; + *tr = trace; + tr->lateralFraction = oldLateralFraction; + } + else + *tr = trace; } else if( trace.startsolid ) tr->startsolid = qtrue; @@ -182,7 +196,7 @@ void CG_Trace( trace_t *result, const vec3_t start, const vec3_t mins, const ve trap_CM_BoxTrace( &t, start, end, mins, maxs, 0, mask ); t.entityNum = t.fraction != 1.0 ? ENTITYNUM_WORLD : ENTITYNUM_NONE; // check all other solid models - CG_ClipMoveToEntities( start, mins, maxs, end, skipNumber, mask, &t, qfalse ); + CG_ClipMoveToEntities( start, mins, maxs, end, skipNumber, mask, &t, TT_AABB ); *result = t; } @@ -200,7 +214,29 @@ void CG_CapTrace( trace_t *result, const vec3_t start, const vec3_t mins, const trap_CM_CapsuleTrace( &t, start, end, mins, maxs, 0, mask ); t.entityNum = t.fraction != 1.0 ? ENTITYNUM_WORLD : ENTITYNUM_NONE; // check all other solid models - CG_ClipMoveToEntities( start, mins, maxs, end, skipNumber, mask, &t, qtrue ); + CG_ClipMoveToEntities( start, mins, maxs, end, skipNumber, mask, &t, TT_CAPSULE ); + + *result = t; +} + +/* +================ +CG_BiSphereTrace +================ +*/ +void CG_BiSphereTrace( trace_t *result, const vec3_t start, const vec3_t end, + const float startRadius, const float endRadius, int skipNumber, int mask ) +{ + trace_t t; + vec3_t mins, maxs; + + mins[ 0 ] = startRadius; + maxs[ 0 ] = endRadius; + + trap_CM_BiSphereTrace( &t, start, end, startRadius, endRadius, 0, mask ); + t.entityNum = t.fraction != 1.0 ? ENTITYNUM_WORLD : ENTITYNUM_NONE; + // check all other solid models + CG_ClipMoveToEntities( start, mins, maxs, end, skipNumber, mask, &t, TT_BISPHERE ); *result = t; } diff --git a/src/cgame/cg_public.h b/src/cgame/cg_public.h index aa0298a2..958e96a6 100644 --- a/src/cgame/cg_public.h +++ b/src/cgame/cg_public.h @@ -167,6 +167,8 @@ typedef enum CG_FS_SEEK, CG_FS_GETFILELIST, CG_LITERAL_ARGS, + CG_CM_BISPHERETRACE, + CG_CM_TRANSFORMEDBISPHERETRACE, CG_MEMSET = 100, CG_MEMCPY, diff --git a/src/cgame/cg_syscalls.asm b/src/cgame/cg_syscalls.asm index ffa14c64..ee2ad7ab 100644 --- a/src/cgame/cg_syscalls.asm +++ b/src/cgame/cg_syscalls.asm @@ -92,6 +92,8 @@ equ trap_R_inPVS -89 equ trap_FS_Seek -90 equ trap_FS_GetFileList -91 equ trap_LiteralArgs -92 +equ trap_CM_BiSphereTrace -93 +equ trap_CM_TransformedBiSphereTrace -94 equ memset -101 equ memcpy -102 diff --git a/src/cgame/cg_syscalls.c b/src/cgame/cg_syscalls.c index 65a5e9c4..a5c42229 100644 --- a/src/cgame/cg_syscalls.c +++ b/src/cgame/cg_syscalls.c @@ -219,6 +219,23 @@ void trap_CM_TransformedCapsuleTrace( trace_t *results, const vec3_t start, con syscall( CG_CM_TRANSFORMEDCAPSULETRACE, results, start, end, mins, maxs, model, brushmask, origin, angles ); } +void trap_CM_BiSphereTrace( trace_t *results, const vec3_t start, + const vec3_t end, float startRad, float endRad, + clipHandle_t model, int mask ) +{ + syscall( CG_CM_BISPHERETRACE, results, start, end, + PASSFLOAT( startRad ), PASSFLOAT( endRad ), model, mask ); +} + +void trap_CM_TransformedBiSphereTrace( trace_t *results, const vec3_t start, + const vec3_t end, float startRad, float endRad, + clipHandle_t model, int mask, + const vec3_t origin ) +{ + syscall( CG_CM_TRANSFORMEDBISPHERETRACE, results, start, end, PASSFLOAT( startRad ), + PASSFLOAT( endRad ), model, mask, origin ); +} + int trap_CM_MarkFragments( int numPoints, const vec3_t *points, const vec3_t projection, int maxPoints, vec3_t pointBuffer, |