diff options
Diffstat (limited to 'src/cgame')
-rw-r--r-- | src/cgame/cg_buildable.c | 40 | ||||
-rw-r--r-- | src/cgame/cg_local.h | 2 | ||||
-rw-r--r-- | src/cgame/cg_players.c | 24 | ||||
-rw-r--r-- | src/cgame/cg_predict.c | 33 |
4 files changed, 79 insertions, 20 deletions
diff --git a/src/cgame/cg_buildable.c b/src/cgame/cg_buildable.c index 7e8ed9c8..efe56a8a 100644 --- a/src/cgame/cg_buildable.c +++ b/src/cgame/cg_buildable.c @@ -286,6 +286,7 @@ static void CG_BuildableAnimation( centity_t *cent, int *old, int *now, float *b *backLerp = cent->lerpFrame.backlerp; } +#define TRACE_DEPTH 128.0f /* ================== @@ -297,6 +298,8 @@ void CG_Buildable( centity_t *cent ) refEntity_t ent; refEntity_t ent2; entityState_t *es; + vec3_t forward, surfNormal, end, start, mins, maxs; + trace_t tr; es = ¢->currentState; if ( es->modelindex >= bg_numItems ) @@ -312,13 +315,40 @@ void CG_Buildable( centity_t *cent ) memset ( &ent, 0, sizeof( ent ) ); - VectorCopy( es->angles, cent->lerpAngles ); - AnglesToAxis( cent->lerpAngles, ent.axis ); + VectorCopy( cent->lerpOrigin, ent.origin ); + VectorCopy( cent->lerpOrigin, ent.oldorigin ); - ent.hModel = cg_items[es->modelindex].models[0]; + VectorCopy( es->origin2, surfNormal ); + BG_FindBBoxForBuildable( es->clientNum, mins, maxs ); + + if( surfNormal[ 2 ] != 1.0f ) + { + AngleVectors( cent->lerpAngles, forward, NULL, NULL ); + VectorCopy( surfNormal, ent.axis[2] ); + ProjectPointOnPlane( ent.axis[0], forward, ent.axis[2] ); + if( !VectorNormalize( ent.axis[0] ) ) + { + AngleVectors( cent->lerpAngles, NULL, NULL, forward ); + ProjectPointOnPlane( ent.axis[0], forward, ent.axis[2] ); + VectorNormalize( ent.axis[0] ); + } + CrossProduct( ent.axis[0], ent.axis[2], ent.axis[1] ); + ent.axis[1][0] = -ent.axis[1][0]; + ent.axis[1][1] = -ent.axis[1][1]; + ent.axis[1][2] = -ent.axis[1][2]; + + VectorMA( ent.origin, -TRACE_DEPTH, surfNormal, end ); + VectorMA( ent.origin, 1.0f, surfNormal, start ); + CG_CapTrace( &tr, start, mins, maxs, end, es->number, MASK_PLAYERSOLID ); + VectorMA( ent.origin, tr.fraction * -TRACE_DEPTH, surfNormal, ent.origin ); + + VectorCopy( ent.origin, ent.lightingOrigin ); + VectorCopy( ent.origin, ent.oldorigin ); // don't positionally lerp at all + } + else + AnglesToAxis( es->angles, ent.axis ); - VectorCopy( cent->lerpOrigin, ent.origin); - VectorCopy( cent->lerpOrigin, ent.oldorigin); + ent.hModel = cg_items[es->modelindex].models[0]; ent.nonNormalizedAxes = qfalse; diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h index 74d7f6b6..f87d1b90 100644 --- a/src/cgame/cg_local.h +++ b/src/cgame/cg_local.h @@ -1357,6 +1357,8 @@ 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_PredictPlayerState( void ); void CG_LoadDeferredPlayers( void ); diff --git a/src/cgame/cg_players.c b/src/cgame/cg_players.c index c876ed17..7dba674c 100644 --- a/src/cgame/cg_players.c +++ b/src/cgame/cg_players.c @@ -1781,6 +1781,7 @@ int CG_AmbientLight( vec3_t point ) return (int)((float)( result[0] + result[1] + result[2] ) / 3.0f ); } +#define TRACE_DEPTH 128.0f /* =============== @@ -1793,10 +1794,11 @@ void CG_Player( centity_t *cent ) refEntity_t legs; refEntity_t torso; refEntity_t head; - int clientNum; - int renderfx; - qboolean shadow; - float shadowPlane; + int clientNum; + int renderfx; + qboolean shadow; + float shadowPlane; + entityState_t *es = ¢->currentState; // the client number is stored in clientNum. It can't be derived // from the entity number, because a single client may have @@ -1870,17 +1872,12 @@ void CG_Player( centity_t *cent ) !( cent->currentState.eFlags & EF_DEAD ) && !( cg.intermissionStarted ) ) { - vec3_t forward, surfNormal; + vec3_t forward, surfNormal, start, end, mins, maxs; trace_t tr; VectorCopy( cent->currentState.angles2, surfNormal ); + BG_FindBBoxForClass( ( es->powerups >> 8 ) & 0xFF, mins, maxs, NULL, NULL, NULL ); - /*CG_Printf( "%d: ", cent->currentState.number ); - CG_Printf( "%f ", surfNormal[ 0 ] ); - CG_Printf( "%f ", surfNormal[ 1 ] ); - CG_Printf( "%f ", surfNormal[ 2 ] ); - CG_Printf( "\n" );*/ - AngleVectors( cent->lerpAngles, forward, NULL, NULL ); VectorCopy( surfNormal, legs.axis[2] ); ProjectPointOnPlane( legs.axis[0], forward, legs.axis[2] ); @@ -1895,6 +1892,11 @@ void CG_Player( centity_t *cent ) legs.axis[1][1] = -legs.axis[1][1]; legs.axis[1][2] = -legs.axis[1][2]; + VectorMA( legs.origin, -TRACE_DEPTH, surfNormal, end ); + VectorMA( legs.origin, 1.0f, surfNormal, start ); + CG_CapTrace( &tr, start, mins, maxs, end, es->number, MASK_PLAYERSOLID ); + VectorMA( legs.origin, tr.fraction * -TRACE_DEPTH, surfNormal, legs.origin ); + VectorCopy( legs.origin, legs.lightingOrigin ); VectorCopy( legs.origin, legs.oldorigin ); // don't positionally lerp at all } diff --git a/src/cgame/cg_predict.c b/src/cgame/cg_predict.c index 71045d16..3ff351ad 100644 --- a/src/cgame/cg_predict.c +++ b/src/cgame/cg_predict.c @@ -87,7 +87,7 @@ 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 ) { + int skipNumber, int mask, trace_t *tr, qboolean capsule ) { int i, x, zd, zu; trace_t trace; entityState_t *ent; @@ -126,8 +126,16 @@ static void CG_ClipMoveToEntities ( const vec3_t start, const vec3_t mins, const } - trap_CM_TransformedBoxTrace ( &trace, start, end, - mins, maxs, cmodel, mask, origin, angles); + if( capsule ) + { + trap_CM_TransformedCapsuleTrace ( &trace, start, end, + mins, maxs, cmodel, mask, origin, angles); + } + else + { + trap_CM_TransformedBoxTrace ( &trace, start, end, + mins, maxs, cmodel, mask, origin, angles); + } if (trace.allsolid || trace.fraction < tr->fraction) { trace.entityNum = ent->number; @@ -153,7 +161,24 @@ 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); + CG_ClipMoveToEntities (start, mins, maxs, end, skipNumber, mask, &t, qfalse); + + *result = t; +} + +/* +================ +CG_CapTrace +================ +*/ +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 ) { + trace_t t; + + 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); *result = t; } |