mirror of
https://github.com/astromaddie/lambda1-vr.git
synced 2026-10-23 09:00:12 +02:00
Flashlight Render now using same logic as weapon
This prevents it from dragging behind player movement. Looks WAY better
This commit is contained in:
1 parent
d032696011
commit
daaf6ef848
9 files changed
+61
-74
No files matched your search
@@ -1315,15 +1315,6 @@ void CL_AddEntities( void )
|
||||
|
||||
clgame.dllFuncs.pfnCreateEntities();
|
||||
|
||||
// add flashlight model if required
|
||||
if( cl.frame.client.flags & FL_HAS_FLASHLIGHT &&
|
||||
cl.refdef.weapon.flags != 1 && // Make sure weapon isn't being stabilised
|
||||
vr_flashlight_model->integer &&
|
||||
vr_headtorch->value == 0.0f)
|
||||
{
|
||||
CL_AttachFlashlightEntityToPlayer( "models/v_torch.mdl", cl.refdef.flashlight.org, cl.refdef.flashlight.angles.adjusted);
|
||||
}
|
||||
|
||||
CL_FireEvents(); // so tempents can be created immediately
|
||||
CL_AddTempEnts();
|
||||
|
||||
|
||||
@@ -3838,7 +3838,6 @@ static efx_api_t gEfxApi =
|
||||
(void*)CL_DecalIndexFromName,
|
||||
CL_DecalShoot,
|
||||
CL_AttachTentToPlayer,
|
||||
CL_AttachFlashlightEntityToPlayer,
|
||||
CL_KillAttachedTents,
|
||||
(void*)CL_BeamCirclePoints,
|
||||
(void*)CL_BeamEntPoint,
|
||||
|
||||
@@ -657,68 +657,6 @@ void GAME_EXPORT CL_AttachTentToPlayer( int client, int modelIndex, float zoffse
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==============
|
||||
CL_AttachFlashlightEntityToPlayer
|
||||
|
||||
Attaches flashlight entity to player
|
||||
==============
|
||||
*/
|
||||
void GAME_EXPORT CL_AttachFlashlightEntityToPlayer( const char* name, vec3_t position, vec3_t angles)
|
||||
{
|
||||
TEMPENTITY *pFlashlight = NULL;
|
||||
|
||||
// ignore in thirdperson, camera view or client is died
|
||||
if( cl.thirdperson || cl.refdef.health <= 0 || cl.refdef.viewentity != ( cl.playernum + 1 ))
|
||||
return;
|
||||
|
||||
cl_entity_t *pClient;
|
||||
pClient = CL_GetEntityByIndex(cl.playernum + 1);
|
||||
if (!pClient) {
|
||||
MsgDev(D_INFO, "Couldn't get ClientEntity for %i\n", 1);
|
||||
return;
|
||||
}
|
||||
|
||||
vec3_t flashlightLocation;
|
||||
VectorAdd(pClient->origin, position, flashlightLocation);
|
||||
|
||||
model_t *pModel = Mod_ForName(name, false);
|
||||
if (!pModel) {
|
||||
MsgDev(D_INFO, "No model %s!\n", name);
|
||||
return;
|
||||
}
|
||||
|
||||
pFlashlight = CL_TempEntAllocHigh(flashlightLocation, pModel);
|
||||
if (!pFlashlight) {
|
||||
MsgDev(D_INFO, "No temp ent.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
//If flashlight is on, then do something.. actually.. maybe not
|
||||
/*if (pClient->curstate.effects & EF_DIMLIGHT)
|
||||
{
|
||||
pFlashlight->entity.curstate.renderfx = kRenderFxGlowShell;
|
||||
} else*/
|
||||
{
|
||||
pFlashlight->entity.curstate.renderfx = kRenderFxNone;
|
||||
}
|
||||
|
||||
pFlashlight->entity.curstate.rendermode = kRenderNormal;
|
||||
pFlashlight->entity.curstate.renderamt = pFlashlight->entity.baseline.renderamt = 192;
|
||||
|
||||
pFlashlight->clientIndex = cl.playernum + 1;
|
||||
|
||||
VectorCopy(angles, pFlashlight->entity.angles);
|
||||
pFlashlight->entity.angles[0] *= -1.0f;
|
||||
|
||||
//Die immediately on next frame
|
||||
pFlashlight->die = cl.time;
|
||||
|
||||
// no animation support for attached clientside studio models.
|
||||
pFlashlight->frameMax = 0;
|
||||
pFlashlight->entity.curstate.frame = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
==============
|
||||
CL_KillAttachedTents
|
||||
|
||||
@@ -56,7 +56,6 @@ void CL_FizzEffect( cl_entity_t *pent, int modelIndex, int density );
|
||||
void CL_Bubbles( const vec3_t mins, const vec3_t maxs, float height, int modelIndex, int count, float speed );
|
||||
void CL_BubbleTrail( const vec3_t start, const vec3_t end, float flWaterZ, int modelIndex, int count, float speed );
|
||||
void CL_AttachTentToPlayer( int client, int modelIndex, float zoffset, float life );
|
||||
void CL_AttachFlashlightEntityToPlayer( const char* name, vec3_t position, vec3_t angles );
|
||||
void CL_KillAttachedTents( int client );
|
||||
void CL_RicochetSprite( const vec3_t pos, model_t *pmodel, float duration, float scale );
|
||||
void CL_RocketFlare( const vec3_t pos );
|
||||
|
||||
@@ -162,7 +162,6 @@ void V_SetupRefDef( void )
|
||||
|
||||
//Flashlight
|
||||
convertFromVRtoHL(flashlightoffset, cl.refdef.flashlight.org);
|
||||
cl.refdef.flashlight.org[2] += cl.refdef.viewheight[2]; // Have to do this for some reason..
|
||||
VectorCopy(flashlightangles, cl.refdef.flashlight.angles.adjusted);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -414,6 +414,7 @@ typedef struct
|
||||
|
||||
efrag_t *free_efrags; // linked efrags
|
||||
cl_entity_t viewent; // viewmodel
|
||||
cl_entity_t flashlightEntity; // flashlight
|
||||
} clgame_static_t;
|
||||
|
||||
typedef struct
|
||||
|
||||
@@ -494,6 +494,7 @@ void Mod_UnloadBrushModel( struct model_s *mod );
|
||||
void GL_SetRenderMode( int mode );
|
||||
void R_RunViewmodelEvents( void );
|
||||
void R_DrawViewModel( void );
|
||||
void R_DrawFlashlightModel( void );
|
||||
int R_GetSpriteTexture( const struct model_s *m_pSpriteModel, int frame );
|
||||
void R_DecalShoot( int textureIndex, int entityIndex, int modelIndex, vec3_t pos, int flags, vec3_t saxis, float scale );
|
||||
void R_RemoveEfrags( struct cl_entity_s *ent );
|
||||
|
||||
@@ -1205,6 +1205,7 @@ void R_DrawEntitiesOnList( void )
|
||||
pglDisable( GL_BLEND ); // Trinity Render issues
|
||||
|
||||
R_DrawViewModel();
|
||||
R_DrawFlashlightModel();
|
||||
|
||||
CL_ExtraUpdate();
|
||||
}
|
||||
|
||||
@@ -3792,6 +3792,64 @@ void R_DrawViewModel( void )
|
||||
RI.currentmodel = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
R_DrawFlashlightModel
|
||||
=================
|
||||
*/
|
||||
extern convar_t *vr_flashlight_model;
|
||||
extern convar_t *vr_headtorch;
|
||||
void R_DrawFlashlightModel( void )
|
||||
{
|
||||
if( RI.refdef.onlyClientDraw || r_drawviewmodel->integer == 0 || bScopeEngaged())
|
||||
return;
|
||||
|
||||
// ignore in thirdperson, camera view or client is died
|
||||
if( cl.thirdperson || cl.refdef.health <= 0 || cl.refdef.viewentity != ( cl.playernum + 1 ))
|
||||
return;
|
||||
|
||||
if( RI.params & RP_NONVIEWERREF )
|
||||
return;
|
||||
|
||||
// draw flashlight model if required
|
||||
if( cl.frame.client.flags & FL_HAS_FLASHLIGHT &&
|
||||
cl.refdef.weapon.flags != 1 && // Make sure weapon isn't being stabilised
|
||||
vr_flashlight_model->integer &&
|
||||
vr_headtorch->value == 0.0f) {
|
||||
|
||||
clgame.flashlightEntity.model = Mod_ForName("models/v_torch.mdl", false);
|
||||
if (!clgame.flashlightEntity.model) {
|
||||
MsgDev(D_INFO, "No model for flashlight!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
VectorAdd(cl.refdef.vieworg, cl.refdef.flashlight.org, clgame.flashlightEntity.origin);
|
||||
VectorCopy(cl.refdef.flashlight.angles.adjusted, clgame.flashlightEntity.curstate.angles);
|
||||
clgame.flashlightEntity.curstate.angles[0] *= -1.0f;
|
||||
|
||||
RI.currententity = &clgame.flashlightEntity;
|
||||
RI.currentmodel = clgame.flashlightEntity.model;
|
||||
RI.currententity->curstate.renderamt = 192;
|
||||
|
||||
// hack the depth range to prevent flashlight model from poking into walls
|
||||
pglDepthRange(gldepthmin, gldepthmin + 0.3f * (gldepthmax - gldepthmin));
|
||||
|
||||
RI.currententity->curstate.scale = 1.0f;
|
||||
RI.currententity->curstate.frame = 0;
|
||||
RI.currententity->curstate.framerate = 1.0f;
|
||||
RI.currententity->curstate.animtime = 0;
|
||||
RI.currententity->curstate.sequence = 0;
|
||||
|
||||
pStudioDraw->StudioDrawModel(STUDIO_RENDER);
|
||||
|
||||
// restore depth range
|
||||
pglDepthRange(gldepthmin, gldepthmax);
|
||||
|
||||
RI.currententity = NULL;
|
||||
RI.currentmodel = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
R_StudioLoadTexture
|
||||
|
||||
Reference in new issue
Block a user