Browse Source

engine: common: add generic trace_t initialize function

pull/2/head
Alibek Omarov 2 years ago
parent
commit
c076f4ff8e
  1. 16
      engine/common/pm_local.h
  2. 15
      engine/common/pm_trace.c
  3. 15
      engine/server/sv_world.c

16
engine/common/pm_local.h

@ -40,6 +40,22 @@ int PM_TruePointContents( playermove_t *pmove, const vec3_t p ); @@ -40,6 +40,22 @@ int PM_TruePointContents( playermove_t *pmove, const vec3_t p );
int PM_PointContents( playermove_t *pmove, const vec3_t p );
void PM_ConvertTrace( trace_t *out, pmtrace_t *in, edict_t *ent );
static inline void PM_InitTrace( trace_t *trace, const vec3_t end )
{
memset( trace, 0, sizeof( *trace ));
VectorCopy( end, trace->endpos );
trace->allsolid = true;
trace->fraction = 1.0f;
}
static inline void PM_InitPMTrace( pmtrace_t *trace, const vec3_t end )
{
memset( trace, 0, sizeof( *trace ));
VectorCopy( end, trace->endpos );
trace->allsolid = true;
trace->fraction = 1.0f;
}
//
// pm_surface.c
//

15
engine/common/pm_trace.c

@ -446,10 +446,7 @@ pmtrace_t PM_PlayerTraceExt( playermove_t *pmove, vec3_t start, vec3_t end, int @@ -446,10 +446,7 @@ pmtrace_t PM_PlayerTraceExt( playermove_t *pmove, vec3_t start, vec3_t end, int
VectorSubtract( end, offset, end_l );
}
memset( &trace_bbox, 0, sizeof( trace_bbox ));
VectorCopy( end, trace_bbox.endpos );
trace_bbox.allsolid = true;
trace_bbox.fraction = 1.0f;
PM_InitPMTrace( &trace_bbox, end );
if( hullcount < 1 )
{
@ -475,10 +472,7 @@ pmtrace_t PM_PlayerTraceExt( playermove_t *pmove, vec3_t start, vec3_t end, int @@ -475,10 +472,7 @@ pmtrace_t PM_PlayerTraceExt( playermove_t *pmove, vec3_t start, vec3_t end, int
for( last_hitgroup = 0, j = 0; j < hullcount; j++ )
{
memset( &trace_hitbox, 0, sizeof( trace_hitbox ));
VectorCopy( end, trace_hitbox.endpos );
trace_hitbox.allsolid = true;
trace_hitbox.fraction = 1.0f;
PM_InitPMTrace( &trace_hitbox, end );
PM_RecursiveHullCheck( &hull[j], hull[j].firstclipnode, 0, 1, start_l, end_l, &trace_hitbox );
@ -622,10 +616,7 @@ int PM_TestPlayerPosition( playermove_t *pmove, vec3_t pos, pmtrace_t *ptrace, p @@ -622,10 +616,7 @@ int PM_TestPlayerPosition( playermove_t *pmove, vec3_t pos, pmtrace_t *ptrace, p
{
pmtrace_t trace;
memset( &trace, 0, sizeof( trace ));
VectorCopy( pos, trace.endpos );
trace.allsolid = true;
trace.fraction = 1.0f;
PM_InitPMTrace( &trace, pos );
// run custom sweep callback
if( pmove->server || Host_IsLocalClient( ))

15
engine/server/sv_world.c

@ -871,10 +871,7 @@ void SV_ClipMoveToEntity( edict_t *ent, const vec3_t start, vec3_t mins, vec3_t @@ -871,10 +871,7 @@ void SV_ClipMoveToEntity( edict_t *ent, const vec3_t start, vec3_t mins, vec3_t
qboolean rotated, transform_bbox;
matrix4x4 matrix;
memset( trace, 0, sizeof( trace_t ));
VectorCopy( end, trace->endpos );
trace->fraction = 1.0f;
trace->allsolid = 1;
PM_InitTrace( trace, end );
model = SV_ModelHandle( ent->v.modelindex );
@ -945,10 +942,7 @@ void SV_ClipMoveToEntity( edict_t *ent, const vec3_t start, vec3_t mins, vec3_t @@ -945,10 +942,7 @@ void SV_ClipMoveToEntity( edict_t *ent, const vec3_t start, vec3_t mins, vec3_t
for( i = 0; i < hullcount; i++ )
{
memset( &trace_hitbox, 0, sizeof( trace_t ));
VectorCopy( end, trace_hitbox.endpos );
trace_hitbox.fraction = 1.0;
trace_hitbox.allsolid = 1;
PM_InitTrace( &trace_hitbox, end );
PM_RecursiveHullCheck( &hull[i], hull[i].firstclipnode, 0.0f, 1.0f, start_l, end_l, (pmtrace_t *)&trace_hitbox );
@ -1114,10 +1108,7 @@ or custom physics implementation @@ -1114,10 +1108,7 @@ or custom physics implementation
void SV_CustomClipMoveToEntity( edict_t *ent, const vec3_t start, vec3_t mins, vec3_t maxs, const vec3_t end, trace_t *trace )
{
// initialize custom trace
memset( trace, 0, sizeof( trace_t ));
VectorCopy( end, trace->endpos );
trace->allsolid = true;
trace->fraction = 1.0f;
PM_InitTrace( trace, end );
if( svgame.physFuncs.ClipMoveToEntity != NULL )
{

Loading…
Cancel
Save