Browse Source

engine: common: add generic trace_t initialize function

pull/2/head
Alibek Omarov 3 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 );
int PM_PointContents( 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 ); 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 // 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
VectorSubtract( end, offset, end_l ); VectorSubtract( end, offset, end_l );
} }
memset( &trace_bbox, 0, sizeof( trace_bbox )); PM_InitPMTrace( &trace_bbox, end );
VectorCopy( end, trace_bbox.endpos );
trace_bbox.allsolid = true;
trace_bbox.fraction = 1.0f;
if( hullcount < 1 ) if( hullcount < 1 )
{ {
@ -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++ ) for( last_hitgroup = 0, j = 0; j < hullcount; j++ )
{ {
memset( &trace_hitbox, 0, sizeof( trace_hitbox )); PM_InitPMTrace( &trace_hitbox, end );
VectorCopy( end, trace_hitbox.endpos );
trace_hitbox.allsolid = true;
trace_hitbox.fraction = 1.0f;
PM_RecursiveHullCheck( &hull[j], hull[j].firstclipnode, 0, 1, start_l, end_l, &trace_hitbox ); 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
{ {
pmtrace_t trace; pmtrace_t trace;
memset( &trace, 0, sizeof( trace )); PM_InitPMTrace( &trace, pos );
VectorCopy( pos, trace.endpos );
trace.allsolid = true;
trace.fraction = 1.0f;
// run custom sweep callback // run custom sweep callback
if( pmove->server || Host_IsLocalClient( )) 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
qboolean rotated, transform_bbox; qboolean rotated, transform_bbox;
matrix4x4 matrix; matrix4x4 matrix;
memset( trace, 0, sizeof( trace_t )); PM_InitTrace( trace, end );
VectorCopy( end, trace->endpos );
trace->fraction = 1.0f;
trace->allsolid = 1;
model = SV_ModelHandle( ent->v.modelindex ); 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
for( i = 0; i < hullcount; i++ ) for( i = 0; i < hullcount; i++ )
{ {
memset( &trace_hitbox, 0, sizeof( trace_t )); PM_InitTrace( &trace_hitbox, end );
VectorCopy( end, trace_hitbox.endpos );
trace_hitbox.fraction = 1.0;
trace_hitbox.allsolid = 1;
PM_RecursiveHullCheck( &hull[i], hull[i].firstclipnode, 0.0f, 1.0f, start_l, end_l, (pmtrace_t *)&trace_hitbox ); 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
void SV_CustomClipMoveToEntity( edict_t *ent, const vec3_t start, vec3_t mins, vec3_t maxs, const vec3_t end, trace_t *trace ) 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 // initialize custom trace
memset( trace, 0, sizeof( trace_t )); PM_InitTrace( trace, end );
VectorCopy( end, trace->endpos );
trace->allsolid = true;
trace->fraction = 1.0f;
if( svgame.physFuncs.ClipMoveToEntity != NULL ) if( svgame.physFuncs.ClipMoveToEntity != NULL )
{ {

Loading…
Cancel
Save