mirror of
https://github.com/DrBeef/JKXR.git
synced 2025-02-16 08:51:50 +00:00
Ensure controlling an NPC allows time for the view angles to be set correctly
This commit is contained in:
parent
9e138c64ce
commit
7821de9e7e
5 changed files with 16 additions and 6 deletions
|
@ -187,7 +187,6 @@ void VR_SetHMDPosition(float x, float y, float z )
|
||||||
//Reset snap turn too if in a cinematic
|
//Reset snap turn too if in a cinematic
|
||||||
vr.snapTurn = 0;
|
vr.snapTurn = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
vr.take_snap = false;
|
vr.take_snap = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,7 +230,7 @@ void VR_GetMove(float *forward, float *side, float *pos_forward, float *pos_side
|
||||||
*up = 0.0f;
|
*up = 0.0f;
|
||||||
*side = remote_movementSideways;
|
*side = remote_movementSideways;
|
||||||
*pos_side = 0.0f;
|
*pos_side = 0.0f;
|
||||||
*yaw = vr.snapTurn + vr.hmdorientation[YAW] - vr.hmdorientation_first[YAW];
|
*yaw = vr.hmdorientation[YAW] + vr.snapTurn;
|
||||||
*pitch = vr.hmdorientation[PITCH];
|
*pitch = vr.hmdorientation[PITCH];
|
||||||
*roll = 0.0f;
|
*roll = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,9 @@ typedef struct {
|
||||||
bool emplaced_gun; // controlling an emplaced gun
|
bool emplaced_gun; // controlling an emplaced gun
|
||||||
bool remote_droid; // controlling a remote droid
|
bool remote_droid; // controlling a remote droid
|
||||||
bool remote_npc; // controlling a remote NPC (will also be true when controlling a droid)
|
bool remote_npc; // controlling a remote NPC (will also be true when controlling a droid)
|
||||||
|
vec3_t remote_angles; // The view angles of the remote thing we are controlling
|
||||||
|
float remote_snapTurn; // how much turn has been applied to the yaw by joystick for a remote controlled entity
|
||||||
|
int remote_cooldown;
|
||||||
|
|
||||||
bool using_screen_layer;
|
bool using_screen_layer;
|
||||||
bool third_person;
|
bool third_person;
|
||||||
|
|
|
@ -2980,8 +2980,13 @@ void CG_DrawActive( stereoFrame_t stereoView ) {
|
||||||
if (vr->remote_npc &&
|
if (vr->remote_npc &&
|
||||||
!vr->remote_droid)
|
!vr->remote_droid)
|
||||||
{
|
{
|
||||||
|
if (vr->remote_cooldown > cg.time)
|
||||||
|
{
|
||||||
|
VectorCopy(cg.refdefViewAngles, vr->remote_angles);
|
||||||
|
vr->take_snap = true;
|
||||||
|
}
|
||||||
VectorCopy(vr->hmdorientation, cg.refdef.viewangles);
|
VectorCopy(vr->hmdorientation, cg.refdef.viewangles);
|
||||||
cg.refdef.viewangles[YAW] = cg.refdefViewAngles[YAW];
|
cg.refdef.viewangles[YAW] = vr->remote_angles[YAW] + (vr->hmdorientation[YAW] - vr->hmdorientation_snap[YAW]) + (vr->snapTurn - vr->remote_snapTurn);
|
||||||
AnglesToAxis(cg.refdef.viewangles, cg.refdef.viewaxis);
|
AnglesToAxis(cg.refdef.viewangles, cg.refdef.viewaxis);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -205,9 +205,9 @@ void CG_SetClientViewAngles( vec3_t angles, qboolean overrideViewEnt )
|
||||||
{//don't clamp angles when looking through a viewEntity
|
{//don't clamp angles when looking through a viewEntity
|
||||||
for( int i = 0; i < 3; i++ )
|
for( int i = 0; i < 3; i++ )
|
||||||
{
|
{
|
||||||
cg.predicted_player_state.viewangles[PITCH] = angles[i];
|
cg.predicted_player_state.viewangles[i] = angles[i];
|
||||||
cg.predicted_player_state.delta_angles[i] = 0;
|
cg.predicted_player_state.delta_angles[i] = 0;
|
||||||
cg.snap->ps.viewangles[PITCH] = angles[i];
|
cg.snap->ps.viewangles[i] = angles[i];
|
||||||
cg.snap->ps.delta_angles[i] = 0;
|
cg.snap->ps.delta_angles[i] = 0;
|
||||||
g_entities[0].client->pers.cmd_angles[i] = ANGLE2SHORT(angles[i]);
|
g_entities[0].client->pers.cmd_angles[i] = ANGLE2SHORT(angles[i]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -217,7 +217,10 @@ void G_SetViewEntity( gentity_t *self, gentity_t *viewEntity )
|
||||||
{
|
{
|
||||||
//vec3_t clear = {0,0,0};
|
//vec3_t clear = {0,0,0};
|
||||||
CG_SetClientViewAngles( viewEntity->client->ps.viewangles, qtrue );
|
CG_SetClientViewAngles( viewEntity->client->ps.viewangles, qtrue );
|
||||||
vr->snapTurn = 0;
|
VectorCopy(viewEntity->client->ps.viewangles, vr->remote_angles);
|
||||||
|
vr->remote_snapTurn = vr->snapTurn;
|
||||||
|
vr->take_snap = true;
|
||||||
|
vr->remote_cooldown = cg.time + 250;
|
||||||
|
|
||||||
//SetClientViewAngle( self, viewEntity->client->ps.viewangles );
|
//SetClientViewAngle( self, viewEntity->client->ps.viewangles );
|
||||||
//SetClientViewAngle( viewEntity, clear );
|
//SetClientViewAngle( viewEntity, clear );
|
||||||
|
|
Loading…
Reference in a new issue