Browse Source

ref: simplify efx api, move efrags to engine

pull/2/head
mittorn 6 years ago
parent
commit
c55b7dcda7
  1. 20
      engine/client/cl_efrag.c
  2. 30
      engine/client/cl_efx.c
  3. 2
      engine/client/cl_game.c
  4. 8
      engine/client/cl_parse.c
  5. 6
      engine/client/cl_qparse.c
  6. 2
      engine/client/cl_render.c
  7. 1
      engine/client/cl_tent.h
  8. 6
      engine/client/client.h
  9. 4
      engine/client/ref_common.c
  10. 12
      engine/ref_api.h
  11. 4
      ref_gl/gl_context.c
  12. 5
      ref_gl/gl_local.h
  13. 25
      ref_gl/gl_rpart.c
  14. 6
      ref_gl/gl_rsurf.c

20
ref_gl/gl_refrag.c → engine/client/cl_efrag.c

@ -13,10 +13,12 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
*/ */
#include "gl_local.h" #include "common.h"
#include "entity_types.h" #include "entity_types.h"
#include "studio.h" #include "studio.h"
#include "world.h" // BOX_ON_PLANE_SIDE #include "world.h" // BOX_ON_PLANE_SIDE
#include "client.h"
#include "mathlib.h"
/* /*
=============================================================================== ===============================================================================
@ -65,8 +67,8 @@ void R_RemoveEfrags( cl_entity_t *ent )
ef = ef->entnext; ef = ef->entnext;
// put it on the free list // put it on the free list
old->entnext = gEngfuncs.GetEfragsFreeList(); old->entnext = clgame.free_efrags;
gEngfuncs.SetEfragsFreeList( old ); clgame.free_efrags = old;
} }
ent->efrag = NULL; ent->efrag = NULL;
} }
@ -94,14 +96,14 @@ static void R_SplitEntityOnNode( mnode_t *node )
leaf = (mleaf_t *)node; leaf = (mleaf_t *)node;
// grab an efrag off the free list // grab an efrag off the free list
ef = gEngfuncs.GetEfragsFreeList(); ef = clgame.free_efrags;
if( !ef ) if( !ef )
{ {
gEngfuncs.Con_Printf( S_ERROR "too many efrags!\n" ); Con_Printf( S_ERROR "too many efrags!\n" );
return; // no free fragments... return; // no free fragments...
} }
gEngfuncs.SetEfragsFreeList( ef->entnext ); clgame.free_efrags = ef->entnext;
ef->entity = r_addent; ef->entity = r_addent;
// add the entity link // add the entity link
@ -159,7 +161,7 @@ void R_AddEfrags( cl_entity_t *ent )
r_emaxs[i] = ent->origin[i] + outmaxs[i]; r_emaxs[i] = ent->origin[i] + outmaxs[i];
} }
R_SplitEntityOnNode( WORLDMODEL->nodes ); R_SplitEntityOnNode( cl.worldmodel->nodes );
ent->topnode = r_pefragtopnode; ent->topnode = r_pefragtopnode;
} }
@ -190,10 +192,10 @@ void R_StoreEfrags( efrag_t **ppefrag, int framecount )
if( pent->visframe != framecount ) if( pent->visframe != framecount )
{ {
if( gEngfuncs.CL_AddVisibleEntity( pent, ET_FRAGMENTED )) if( CL_AddVisibleEntity( pent, ET_FRAGMENTED ))
{ {
// mark that we've recorded this entity for this frame // mark that we've recorded this entity for this frame
pent->curstate.messagenum = gpGlobals->parsecount; pent->curstate.messagenum = cl.parsecount;
pent->visframe = framecount; pent->visframe = framecount;
} }
} }

30
engine/client/cl_efx.c

@ -21,22 +21,6 @@ static int ramp2[8] = { 0x6f, 0x6e, 0x6d, 0x6c, 0x6b, 0x6a, 0x68, 0x66 };
static int ramp3[6] = { 0x6d, 0x6b, 6, 5, 4, 3 }; static int ramp3[6] = { 0x6d, 0x6b, 6, 5, 4, 3 };
static int gSparkRamp[9] = { 0xfe, 0xfd, 0xfc, 0x6f, 0x6e, 0x6d, 0x6c, 0x67, 0x60 }; static int gSparkRamp[9] = { 0xfe, 0xfd, 0xfc, 0x6f, 0x6e, 0x6d, 0x6c, 0x67, 0x60 };
static color24 gTracerColors[] =
{
{ 255, 255, 255 }, // White
{ 255, 0, 0 }, // Red
{ 0, 255, 0 }, // Green
{ 0, 0, 255 }, // Blue
{ 0, 0, 0 }, // Tracer default, filled in from cvars, etc.
{ 255, 167, 17 }, // Yellow-orange sparks
{ 255, 130, 90 }, // Yellowish streaks (garg)
{ 55, 60, 144 }, // Blue egon streak
{ 255, 130, 90 }, // More Yellowish streaks (garg)
{ 255, 140, 90 }, // More Yellowish streaks (garg)
{ 200, 130, 90 }, // More red streaks (garg)
{ 255, 120, 70 }, // Darker red streaks (garg)
};
convar_t *tracerspeed; convar_t *tracerspeed;
convar_t *tracerlength; convar_t *tracerlength;
convar_t *traceroffset; convar_t *traceroffset;
@ -83,14 +67,6 @@ short R_LookupColor( byte r, byte g, byte b )
return best; return best;
} }
color24 *R_GetTracerColor( uint idx )
{
if( idx > ARRAYSIZE( gTracerColors ))
return NULL;
return &gTracerColors[idx];
}
/* /*
================ ================
R_GetPackedColor R_GetPackedColor
@ -1879,12 +1855,6 @@ void R_UserTracerParticle( float *org, float *vel, float life, int colorIndex, f
if( colorIndex < 0 ) if( colorIndex < 0 )
return; return;
if( colorIndex > ARRAYSIZE( gTracerColors ))
{
Con_Printf( S_ERROR "UserTracer with color > %d\n", ARRAYSIZE( gTracerColors ));
return;
}
if(( p = R_AllocTracer( org, vel, life )) != NULL ) if(( p = R_AllocTracer( org, vel, life )) != NULL )
{ {
p->context = deathcontext; p->context = deathcontext;

2
engine/client/cl_game.c

@ -1096,7 +1096,7 @@ void CL_LinkUserMessage( char *pszName, const int svc_num, int iSize )
void CL_FreeEntity( cl_entity_t *pEdict ) void CL_FreeEntity( cl_entity_t *pEdict )
{ {
Assert( pEdict != NULL ); Assert( pEdict != NULL );
ref.dllFuncs.R_RemoveEfrags( pEdict ); R_RemoveEfrags( pEdict );
CL_KillDeadBeams( pEdict ); CL_KillDeadBeams( pEdict );
} }

8
engine/client/cl_parse.c

@ -352,7 +352,7 @@ void CL_ParseStaticEntity( sizebuf_t *msg )
} }
} }
ref.dllFuncs.R_AddEfrags( ent ); // add link R_AddEfrags( ent ); // add link
} }
@ -1023,8 +1023,8 @@ void CL_ParseClientData( sizebuf_t *msg )
} }
} }
refState.parsecount = cl.parsecount = i; // ack'd incoming messages. cl.parsecount = i; // ack'd incoming messages.
refState.parsecountmod = cl.parsecountmod = cl.parsecount & CL_UPDATE_MASK; // index into window. cl.parsecountmod = cl.parsecount & CL_UPDATE_MASK; // index into window.
frame = &cl.frames[cl.parsecountmod]; // frame at index. frame = &cl.frames[cl.parsecountmod]; // frame at index.
frame->time = cl.mtime[0]; // mark network received time frame->time = cl.mtime[0]; // mark network received time
@ -2559,7 +2559,7 @@ void CL_LegacyParseStaticEntity( sizebuf_t *msg )
} }
} }
ref.dllFuncs.R_AddEfrags( ent ); // add link R_AddEfrags( ent ); // add link
} }

6
engine/client/cl_qparse.c

@ -349,8 +349,8 @@ static void CL_ParseQuakeClientData( sizebuf_t *msg )
// this is the frame update that this message corresponds to // this is the frame update that this message corresponds to
i = cls.netchan.incoming_sequence; i = cls.netchan.incoming_sequence;
refState.parsecount = cl.parsecount = i; // ack'd incoming messages. cl.parsecount = i; // ack'd incoming messages.
refState.parsecountmod = cl.parsecountmod = cl.parsecount & CL_UPDATE_MASK; // index into window. cl.parsecountmod = cl.parsecount & CL_UPDATE_MASK; // index into window.
frame = &cl.frames[cl.parsecountmod]; // frame at index. frame = &cl.frames[cl.parsecountmod]; // frame at index.
frame->time = cl.mtime[0]; // mark network received time frame->time = cl.mtime[0]; // mark network received time
frame->receivedtime = host.realtime; // time now that we are parsing. frame->receivedtime = host.realtime; // time now that we are parsing.
@ -683,7 +683,7 @@ static void CL_ParseQuakeStaticEntity( sizebuf_t *msg )
} }
} }
ref.dllFuncs.R_AddEfrags( ent ); // add link R_AddEfrags( ent ); // add link
} }
/* /*

2
engine/client/cl_render.c

@ -260,7 +260,7 @@ qboolean R_InitRenderAPI( void )
gRenderAPI.GetFrameTime = ref.dllFuncs.GetFrameTime; gRenderAPI.GetFrameTime = ref.dllFuncs.GetFrameTime;
gRenderAPI.R_SetCurrentEntity = ref.dllFuncs.R_SetCurrentEntity; gRenderAPI.R_SetCurrentEntity = ref.dllFuncs.R_SetCurrentEntity;
gRenderAPI.R_SetCurrentModel = ref.dllFuncs.R_SetCurrentModel; gRenderAPI.R_SetCurrentModel = ref.dllFuncs.R_SetCurrentModel;
gRenderAPI.R_StoreEfrags = ref.dllFuncs.R_StoreEfrags; gRenderAPI.R_StoreEfrags = R_StoreEfrags;
gRenderAPI.GL_FindTexture = ref.dllFuncs.GL_FindTexture; gRenderAPI.GL_FindTexture = ref.dllFuncs.GL_FindTexture;
gRenderAPI.GL_TextureName = ref.dllFuncs.GL_TextureName; gRenderAPI.GL_TextureName = ref.dllFuncs.GL_TextureName;
gRenderAPI.GL_TextureData = ref.dllFuncs.GL_TextureData; gRenderAPI.GL_TextureData = ref.dllFuncs.GL_TextureData;

1
engine/client/cl_tent.h

@ -91,7 +91,6 @@ int CL_DecalIndex( int id );
// RefAPI // RefAPI
struct particle_s *CL_AllocParticleFast( void ); struct particle_s *CL_AllocParticleFast( void );
color24 *R_GetTracerColor( uint idx );
// Beams // Beams
struct beam_s *R_BeamLightning( vec3_t start, vec3_t end, int modelIndex, float life, float width, float amplitude, float brightness, float speed ); struct beam_s *R_BeamLightning( vec3_t start, vec3_t end, int modelIndex, float life, float width, float amplitude, float brightness, float speed );

6
engine/client/client.h

@ -963,6 +963,12 @@ lightstyle_t *CL_GetLightStyle( int number );
int R_FatPVS( const vec3_t org, float radius, byte *visbuffer, qboolean merge, qboolean fullvis ); int R_FatPVS( const vec3_t org, float radius, byte *visbuffer, qboolean merge, qboolean fullvis );
const ref_overview_t *GL_GetOverviewParms( void ); const ref_overview_t *GL_GetOverviewParms( void );
//
// cl_efrag.c
//
void R_StoreEfrags( efrag_t **ppefrag, int framecount );
void R_AddEfrags( cl_entity_t *ent );
void R_RemoveEfrags( cl_entity_t *ent );
// //
// cl_tent.c // cl_tent.c
// //

4
engine/client/ref_common.c

@ -292,11 +292,9 @@ static ref_api_t gEngfuncs =
CL_ThinkParticle, CL_ThinkParticle,
R_FreeDeadParticles, R_FreeDeadParticles,
CL_AllocParticleFast, CL_AllocParticleFast,
pfnGetEfragsFreeList,
pfnSetEfragsFreeList,
R_GetTracerColor,
CL_AllocElight, CL_AllocElight,
pfnGetDefaultSprite, pfnGetDefaultSprite,
R_StoreEfrags,
Mod_ForName, Mod_ForName,
pfnMod_Extradata, pfnMod_Extradata,

12
engine/ref_api.h

@ -80,16 +80,12 @@ typedef struct
typedef struct ref_globals_s typedef struct ref_globals_s
{ {
qboolean developer; qboolean developer;
qboolean video_prepped;
float time; // cl.time float time; // cl.time
float oldtime; // cl.oldtime float oldtime; // cl.oldtime
double realtime; // host.realtime double realtime; // host.realtime
double frametime; // host.frametime double frametime; // host.frametime
int parsecount; // cl.parsecount
int parsecountmod; // cl.parsecountmod
// viewport width and height // viewport width and height
int width; int width;
int height; int height;
@ -313,11 +309,9 @@ typedef struct ref_api_s
void (*CL_ThinkParticle)( double frametime, particle_t *p ); void (*CL_ThinkParticle)( double frametime, particle_t *p );
void (*R_FreeDeadParticles)( particle_t **ppparticles ); void (*R_FreeDeadParticles)( particle_t **ppparticles );
particle_t *(*CL_AllocParticleFast)( void ); // unconditionally give new particle pointer from cl_free_particles particle_t *(*CL_AllocParticleFast)( void ); // unconditionally give new particle pointer from cl_free_particles
efrag_t* (*GetEfragsFreeList)( void ); // clgame.free_efrags
void (*SetEfragsFreeList)( efrag_t* ); // clgame.free_efrags
color24 *(*GetTracerColors)( uint num );
struct dlight_s *(*CL_AllocElight)( int key ); struct dlight_s *(*CL_AllocElight)( int key );
struct model_s *(*GetDefaultSprite)( enum ref_defaultsprite_e spr ); struct model_s *(*GetDefaultSprite)( enum ref_defaultsprite_e spr );
void (*R_StoreEfrags)( struct efrag_s **ppefrag, int framecount );// store efrags for static entities
// model management // model management
model_t *(*Mod_ForName)( const char *name, qboolean crash, qboolean trackCRC ); model_t *(*Mod_ForName)( const char *name, qboolean crash, qboolean trackCRC );
@ -494,9 +488,6 @@ typedef struct ref_interface_s
// light // light
colorVec (*R_LightPoint)( const float *p ); colorVec (*R_LightPoint)( const float *p );
void (*R_AddEfrags)( struct cl_entity_s *ent );
void (*R_RemoveEfrags)( struct cl_entity_s *ent );
// decals // decals
// Shoots a decal onto the surface of the BSP. position is the center of the decal in world coords // Shoots a decal onto the surface of the BSP. position is the center of the decal in world coords
void (*R_DecalShoot)( int textureIndex, int entityIndex, int modelIndex, vec3_t pos, int flags, float scale ); void (*R_DecalShoot)( int textureIndex, int entityIndex, int modelIndex, vec3_t pos, int flags, float scale );
@ -539,7 +530,6 @@ typedef struct ref_interface_s
// Set renderer info (tell engine about changes) // Set renderer info (tell engine about changes)
void (*R_SetCurrentEntity)( struct cl_entity_s *ent ); // tell engine about both currententity and currentmodel void (*R_SetCurrentEntity)( struct cl_entity_s *ent ); // tell engine about both currententity and currentmodel
void (*R_SetCurrentModel)( struct model_s *mod ); // change currentmodel but leave currententity unchanged void (*R_SetCurrentModel)( struct model_s *mod ); // change currentmodel but leave currententity unchanged
void (*R_StoreEfrags)( struct efrag_s **ppefrag, int framecount );// store efrags for static entities
// Texture tools // Texture tools
int (*GL_FindTexture)( const char *name ); int (*GL_FindTexture)( const char *name );

4
ref_gl/gl_context.c

@ -432,9 +432,6 @@ ref_interface_t gReffuncs =
R_LightPoint, R_LightPoint,
R_AddEfrags,
R_RemoveEfrags,
R_DecalShoot, R_DecalShoot,
R_DecalRemoveAll, R_DecalRemoveAll,
R_CreateDecalList, R_CreateDecalList,
@ -466,7 +463,6 @@ ref_interface_t gReffuncs =
R_SetCurrentEntity, R_SetCurrentEntity,
R_SetCurrentModel, R_SetCurrentModel,
R_StoreEfrags,
GL_FindTexture, GL_FindTexture,
GL_TextureName, GL_TextureName,

5
ref_gl/gl_local.h

@ -359,11 +359,6 @@ void R_TextureList_f( void );
void R_InitImages( void ); void R_InitImages( void );
void R_ShutdownImages( void ); void R_ShutdownImages( void );
//
// gl_refrag.c
//
void R_StoreEfrags( efrag_t **ppefrag, int framecount );
// //
// gl_rlight.c // gl_rlight.c
// //

25
ref_gl/gl_rpart.c

@ -23,6 +23,21 @@ GNU General Public License for more details.
#include "studio.h" #include "studio.h"
static float gTracerSize[11] = { 1.5f, 0.5f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f }; static float gTracerSize[11] = { 1.5f, 0.5f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f };
static color24 gTracerColors[] =
{
{ 255, 255, 255 }, // White
{ 255, 0, 0 }, // Red
{ 0, 255, 0 }, // Green
{ 0, 0, 255 }, // Blue
{ 0, 0, 0 }, // Tracer default, filled in from cvars, etc.
{ 255, 167, 17 }, // Yellow-orange sparks
{ 255, 130, 90 }, // Yellowish streaks (garg)
{ 55, 60, 144 }, // Blue egon streak
{ 255, 130, 90 }, // More Yellowish streaks (garg)
{ 255, 140, 90 }, // More Yellowish streaks (garg)
{ 200, 130, 90 }, // More red streaks (garg)
{ 255, 120, 70 }, // Darker red streaks (garg)
};
/* /*
================ ================
@ -153,7 +168,7 @@ void CL_DrawTracers( double frametime, particle_t *cl_active_tracers )
// update tracer color if this is changed // update tracer color if this is changed
if( FBitSet( tracerred->flags|tracergreen->flags|tracerblue->flags|traceralpha->flags, FCVAR_CHANGED )) if( FBitSet( tracerred->flags|tracergreen->flags|tracerblue->flags|traceralpha->flags, FCVAR_CHANGED ))
{ {
color24 *customColors = gEngfuncs.GetTracerColors( 4 ); color24 *customColors = &gTracerColors[4];
customColors->r = (byte)(tracerred->value * traceralpha->value * 255); customColors->r = (byte)(tracerred->value * traceralpha->value * 255);
customColors->g = (byte)(tracergreen->value * traceralpha->value * 255); customColors->g = (byte)(tracergreen->value * traceralpha->value * 255);
customColors->b = (byte)(tracerblue->value * traceralpha->value * 255); customColors->b = (byte)(tracerblue->value * traceralpha->value * 255);
@ -215,7 +230,13 @@ void CL_DrawTracers( double frametime, particle_t *cl_active_tracers )
VectorAdd( verts[0], delta, verts[2] ); VectorAdd( verts[0], delta, verts[2] );
VectorAdd( verts[1], delta, verts[3] ); VectorAdd( verts[1], delta, verts[3] );
pColor = gEngfuncs.GetTracerColors( p->color ); if( p->color > sizeof( gTracerColors ) / sizeof( color24 ) )
{
gEngfuncs.Con_Printf( S_ERROR "UserTracer with color > %d\n", sizeof( gTracerColors ) / sizeof( color24 ));
p->color = 0;
}
pColor = &gTracerColors[p->color];
pglColor4ub( pColor->r, pColor->g, pColor->b, p->packedColor ); pglColor4ub( pColor->r, pColor->g, pColor->b, p->packedColor );
pglBegin( GL_QUADS ); pglBegin( GL_QUADS );

6
ref_gl/gl_rsurf.c

@ -3069,7 +3069,7 @@ loc0:
// deal with model fragments in this leaf // deal with model fragments in this leaf
if( pleaf->efrags ) if( pleaf->efrags )
R_StoreEfrags( &pleaf->efrags, tr.realframecount ); gEngfuncs.R_StoreEfrags( &pleaf->efrags, tr.realframecount );
r_stats.c_world_leafs++; r_stats.c_world_leafs++;
return; return;
@ -3163,7 +3163,7 @@ static void R_DrawTopViewLeaf( mleaf_t *pleaf, uint clipflags )
// deal with model fragments in this leaf // deal with model fragments in this leaf
if( pleaf->efrags ) if( pleaf->efrags )
R_StoreEfrags( &pleaf->efrags, tr.realframecount ); gEngfuncs.R_StoreEfrags( &pleaf->efrags, tr.realframecount );
r_stats.c_world_leafs++; r_stats.c_world_leafs++;
} }
@ -3492,7 +3492,7 @@ void GL_RebuildLightmaps( void )
int i, j; int i, j;
model_t *m; model_t *m;
if( !gpGlobals->video_prepped ) if( !gEngfuncs.CL_GetRenderParm( PARM_CLIENT_ACTIVE, 0 ) )
return; // wait for worldmodel return; // wait for worldmodel
ClearBits( vid_brightness->flags, FCVAR_CHANGED ); ClearBits( vid_brightness->flags, FCVAR_CHANGED );

Loading…
Cancel
Save