25 Jan 2015

This commit is contained in:
g-cont 2015-01-25 00:00:00 +03:00 committed by Alibek Omarov
parent 2ebfb437c9
commit 275aaa0883
15 changed files with 103 additions and 8 deletions

View File

@ -2,6 +2,7 @@ build 2900
Console: add detection for Paranoia 2 maps (show message in console)
Engine: fix playing video when fps_max is 0 and framerate too high
Engine: add function TraceSurface into pmove, EventAPI and PhysicAPI interfaces
build 2867

View File

@ -48,6 +48,7 @@ typedef struct event_api_s
const char *(*EV_EventForIndex)( unsigned short index );
void ( *EV_PlayerTraceExt )( float *start, float *end, int traceFlags, int (*pfnIgnore)( struct physent_s *pe ), struct pmtrace_s *tr );
const char *(*EV_SoundForIndex)( int index );
struct msurface_s *( *EV_TraceSurface )( int ground, float *vstart, float *vend );
} event_api_t;
#endif//EVENT_API_H

View File

@ -2349,6 +2349,23 @@ static const char *pfnTraceTexture( int ground, float *vstart, float *vend )
pe = &clgame.pmove->physents[ground];
return PM_TraceTexture( pe, vstart, vend );
}
/*
=============
pfnTraceSurface
=============
*/
static struct msurface_s *pfnTraceSurface( int ground, float *vstart, float *vend )
{
physent_t *pe;
if( ground < 0 || ground >= clgame.pmove->numphysent )
return NULL; // bad ground
pe = &clgame.pmove->physents[ground];
return PM_TraceSurface( pe, vstart, vend );
}
/*
=============
@ -3698,6 +3715,7 @@ static event_api_t gEventApi =
CL_IndexEvent,
CL_PlayerTraceExt,
CL_SoundFromIndex,
pfnTraceSurface,
};
static demo_api_t gDemoApi =

View File

@ -594,6 +594,17 @@ static pmtrace_t *pfnTraceLineEx( float *start, float *end, int flags, int usehu
return &tr;
}
static struct msurface_s *pfnTraceSurface( int ground, float *vstart, float *vend )
{
physent_t *pe;
if( ground < 0 || ground >= clgame.pmove->numphysent )
return NULL; // bad ground
pe = &clgame.pmove->physents[ground];
return PM_TraceSurface( pe, vstart, vend );
}
/*
===============
CL_InitClientMove
@ -654,6 +665,7 @@ void CL_InitClientMove( void )
clgame.pmove->PM_PlayerTraceEx = pfnPlayerTraceEx;
clgame.pmove->PM_TestPlayerPositionEx = pfnTestPlayerPositionEx;
clgame.pmove->PM_TraceLineEx = pfnTraceLineEx;
clgame.pmove->PM_TraceSurface = pfnTraceSurface;
// initalize pmove
clgame.dllFuncs.pfnPlayerMoveInit( clgame.pmove );

View File

@ -1594,7 +1594,7 @@ static const char *GL_TextureName( unsigned int texnum )
return R_GetTexture( texnum )->name;
}
static const byte *GL_TextureData( unsigned int texnum )
const byte *GL_TextureData( unsigned int texnum )
{
rgbdata_t *pic = R_GetTexture( texnum )->original;

View File

@ -3456,6 +3456,9 @@ static void R_StudioLoadTexture( model_t *mod, studiohdr_t *phdr, mstudiotexture
ptexture->index = (int)((byte *)phdr) + ptexture->index;
size = sizeof( mstudiotexture_t ) + ptexture->width * ptexture->height + 768;
if( host.features & ENGINE_DISABLE_HDTEXTURES && ptexture->flags & STUDIO_NF_TRANSPARENT )
flags |= TF_KEEP_8BIT; // Paranoia2 alpha-tracing
// build the texname
Q_snprintf( texname, sizeof( texname ), "#%s/%s.mdl", mdlname, name );
ptexture->index = GL_LoadTexture( texname, (byte *)ptexture, size, flags, filter );

View File

@ -842,6 +842,7 @@ void COM_SetRandomSeed( long lSeed );
long Com_RandomLong( long lMin, long lMax );
float Com_RandomFloat( float fMin, float fMax );
void TrimSpace( const char *source, char *dest );
const byte *GL_TextureData( unsigned int texnum );
void GL_FreeImage( const char *name );
void VID_RestoreGamma( void );
void UI_SetActiveMenu( qboolean fActive );

View File

@ -35,5 +35,6 @@ int PM_HullPointContents( hull_t *hull, int num, const vec3_t p );
//
const char *PM_TraceTexture( physent_t *pe, vec3_t vstart, vec3_t vend );
msurface_t *PM_RecursiveSurfCheck( model_t *model, mnode_t *node, vec3_t p1, vec3_t p2 );
msurface_t *PM_TraceSurface( physent_t *pe, vec3_t start, vec3_t end );
#endif//PM_LOCAL_H

View File

@ -98,9 +98,8 @@ find the face where the traceline hit
assume physentity is valid
==================
*/
const char *PM_TraceTexture( physent_t *pe, vec3_t start, vec3_t end )
msurface_t *PM_TraceSurface( physent_t *pe, vec3_t start, vec3_t end )
{
msurface_t *surf;
matrix4x4 matrix;
model_t *bmodel;
hull_t *hull;
@ -127,7 +126,20 @@ const char *PM_TraceTexture( physent_t *pe, vec3_t start, vec3_t end )
Matrix4x4_VectorITransform( matrix, end, end_l );
}
surf = PM_RecursiveSurfCheck( bmodel, &bmodel->nodes[hull->firstclipnode], start_l, end_l );
return PM_RecursiveSurfCheck( bmodel, &bmodel->nodes[hull->firstclipnode], start_l, end_l );
}
/*
==================
PM_TraceTexture
find the face where the traceline hit
assume physentity is valid
==================
*/
const char *PM_TraceTexture( physent_t *pe, vec3_t start, vec3_t end )
{
msurface_t *surf = PM_TraceSurface( pe, start, end );
if( !surf || !surf->texinfo || !surf->texinfo->texture )
return NULL;

View File

@ -58,6 +58,12 @@ typedef struct server_physics_api_s
const char *( *pfnGetLightStyle )( int style ); // read custom appreance for selected lightstyle
void ( *pfnUpdateFogSettings )( unsigned int packed_fog );
char **(*pfnGetFilesList)( const char *pattern, int *numFiles, int gamedironly );
struct msurface_s *(*pfnTraceSurface)( edict_t *pTextureEntity, const float *v1, const float *v2 );
const byte *(*pfnGetTextureData)( unsigned int texnum );
// static allocations
void *(*pfnMemAlloc)( size_t cb, const char *filename, const int fileline );
void (*pfnMemFree)( void *mem, const char *filename, const int fileline );
} server_physics_api_t;
// physic callbacks

View File

@ -617,6 +617,7 @@ trace_t SV_TraceHull( edict_t *ent, int hullNum, const vec3_t start, vec3_t mins
trace_t SV_Move( const vec3_t start, vec3_t mins, vec3_t maxs, const vec3_t end, int type, edict_t *e );
trace_t SV_MoveNoEnts( const vec3_t start, vec3_t mins, vec3_t maxs, const vec3_t end, int type, edict_t *e );
const char *SV_TraceTexture( edict_t *ent, const vec3_t start, const vec3_t end );
msurface_t *SV_TraceSurface( edict_t *ent, const vec3_t start, const vec3_t end );
trace_t SV_MoveToss( edict_t *tossent, edict_t *ignore );
void SV_LinkEdict( edict_t *ent, qboolean touch_triggers );
void SV_TouchLinks( edict_t *ent, areanode_t *node );

View File

@ -1912,6 +1912,16 @@ static char **pfnGetFilesList( const char *pattern, int *numFiles, int gamediron
return t->filenames;
}
static void *pfnMem_Alloc( size_t cb, const char *filename, const int fileline )
{
return _Mem_Alloc( svgame.mempool, cb, filename, fileline );
}
static void pfnMem_Free( void *mem, const char *filename, const int fileline )
{
_Mem_Free( mem, filename, fileline );
}
static server_physics_api_t gPhysicsAPI =
{
SV_LinkEdict,
@ -1930,6 +1940,10 @@ static server_physics_api_t gPhysicsAPI =
SV_GetLightStyle,
SV_UpdateFogSettings,
pfnGetFilesList,
SV_TraceSurface,
GL_TextureData,
pfnMem_Alloc,
pfnMem_Free,
};
/*

View File

@ -524,6 +524,17 @@ static pmtrace_t *pfnTraceLineEx( float *start, float *end, int flags, int usehu
return &tr;
}
static struct msurface_s *pfnTraceSurface( int ground, float *vstart, float *vend )
{
physent_t *pe;
if( ground < 0 || ground >= svgame.pmove->numphysent )
return NULL; // bad ground
pe = &svgame.pmove->physents[ground];
return PM_TraceSurface( pe, vstart, vend );
}
/*
===============
SV_InitClientMove
@ -584,6 +595,7 @@ void SV_InitClientMove( void )
svgame.pmove->PM_PlayerTraceEx = pfnPlayerTraceEx;
svgame.pmove->PM_TestPlayerPositionEx = pfnTestPlayerPositionEx;
svgame.pmove->PM_TraceLineEx = pfnTraceLineEx;
svgame.pmove->PM_TraceSurface = pfnTraceSurface;
// initalize pmove
svgame.dllFuncs.pfnPM_Init( svgame.pmove );

View File

@ -1353,15 +1353,14 @@ trace_t SV_MoveNoEnts( const vec3_t start, vec3_t mins, vec3_t maxs, const vec3_
/*
==================
SV_TraceTexture
SV_TraceSurface
find the face where the traceline hit
assume pTextureEntity is valid
==================
*/
const char *SV_TraceTexture( edict_t *ent, const vec3_t start, const vec3_t end )
msurface_t *SV_TraceSurface( edict_t *ent, const vec3_t start, const vec3_t end )
{
msurface_t *surf;
matrix4x4 matrix;
model_t *bmodel;
hull_t *hull;
@ -1385,7 +1384,20 @@ const char *SV_TraceTexture( edict_t *ent, const vec3_t start, const vec3_t end
Matrix4x4_VectorITransform( matrix, end, end_l );
}
surf = PM_RecursiveSurfCheck( bmodel, &bmodel->nodes[hull->firstclipnode], start_l, end_l );
return PM_RecursiveSurfCheck( bmodel, &bmodel->nodes[hull->firstclipnode], start_l, end_l );
}
/*
==================
SV_TraceTexture
find the face where the traceline hit
assume pTextureEntity is valid
==================
*/
const char *SV_TraceTexture( edict_t *ent, const vec3_t start, const vec3_t end )
{
msurface_t *surf = SV_TraceSurface( ent, start, end );
if( !surf || !surf->texinfo || !surf->texinfo->texture )
return NULL;

View File

@ -216,5 +216,6 @@ typedef struct playermove_s
pmtrace_t (*PM_PlayerTraceEx) (float *start, float *end, int traceFlags, int (*pfnIgnore)( physent_t *pe ));
int (*PM_TestPlayerPositionEx) (float *pos, pmtrace_t *ptrace, int (*pfnIgnore)( physent_t *pe ));
struct pmtrace_s *(*PM_TraceLineEx)( float *start, float *end, int flags, int usehulll, int (*pfnIgnore)( physent_t *pe ));
struct msurface_s *(*PM_TraceSurface)( int ground, float *vstart, float *vend );
} playermove_t;
#endif//PM_DEFS_H