Use primary hand direction/location as trigger for buttons

This commit is contained in:
Simon 2022-11-16 22:34:41 +00:00
parent f014078518
commit 85f642e9e7
3 changed files with 34 additions and 12 deletions

View file

@ -414,6 +414,9 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG
VectorSet(vr.weaponangles, -degrees(atanf(y / zxDist)), VectorSet(vr.weaponangles, -degrees(atanf(y / zxDist)),
-degrees(atan2f(x, -z)), vr.weaponangles[ROLL] / -degrees(atan2f(x, -z)), vr.weaponangles[ROLL] /
2.0f); //Dampen roll on stabilised weapon 2.0f); //Dampen roll on stabilised weapon
VectorCopy(vr.hmdposition, vr.weaponposition);
VectorClear(vr.weaponoffset);
vr.weaponposition[1] += 0.1; vr.weaponposition[1] += 0.1;
} }
} }
@ -585,7 +588,7 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG
if ((primaryButtonsNew & primaryButton2) != (primaryButtonsOld & primaryButton2)) { if ((primaryButtonsNew & primaryButton2) != (primaryButtonsOld & primaryButton2)) {
if (vr.cgzoommode) if (vr.cgzoommode)
{ {
sendButtonActionSimple("exitzoom"); sendButtonActionSimple("exitscope");
} }
else if (cl.frame.ps.weapon == WP_SABER && vr.velocitytriggered) else if (cl.frame.ps.weapon == WP_SABER && vr.velocitytriggered)
{ {

View file

@ -25,6 +25,7 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
#include "g_functions.h" #include "g_functions.h"
#include "b_local.h" #include "b_local.h"
#include "anims.h" #include "anims.h"
#include "bg_local.h"
#define ENTDIST_PLAYER 1 #define ENTDIST_PLAYER 1
#define ENTDIST_NPC 2 #define ENTDIST_NPC 2
@ -228,7 +229,16 @@ void Touch_Multi( gentity_t *self, gentity_t *other, trace_t *trace )
if ( other->client ) if ( other->client )
{ {
AngleVectors( other->client->ps.viewangles, forward, NULL, NULL ); if (other->client->ps.clientNum == 0)
{
vec3_t origin, angles;
BG_CalculateVRWeaponPosition(origin, angles);
AngleVectors( angles, forward, NULL, NULL );
}
else
{
AngleVectors( other->client->ps.viewangles, forward, NULL, NULL );
}
} }
else else
{ {

View file

@ -230,6 +230,8 @@ void G_PlayEffect( const char *name, const int modelIndex, const int boltIndex,
extern void cgi_S_StartSound( vec3_t origin, int entityNum, int entchannel, sfxHandle_t sfx ); extern void cgi_S_StartSound( vec3_t origin, int entityNum, int entchannel, sfxHandle_t sfx );
#include "../cgame/cg_media.h" //access to cgs #include "../cgame/cg_media.h" //access to cgs
#include "bg_local.h"
extern void CG_TryPlayCustomSound( vec3_t origin, int entityNum, soundChannel_t channel, const char *soundName, int customSoundSet ); extern void CG_TryPlayCustomSound( vec3_t origin, int entityNum, soundChannel_t channel, const char *soundName, int customSoundSet );
//NOTE: Do NOT Try to use this before the cgame DLL is valid, it will NOT work! //NOTE: Do NOT Try to use this before the cgame DLL is valid, it will NOT work!
void G_SoundOnEnt (gentity_t *ent, soundChannel_t channel, const char *soundPath) void G_SoundOnEnt (gentity_t *ent, soundChannel_t channel, const char *soundPath)
@ -1267,22 +1269,29 @@ Try and use an entity in the world, directly ahead of us
#define USE_DISTANCE 64.0f #define USE_DISTANCE 64.0f
void TryUse( gentity_t *ent ) void TryUse( gentity_t *ent ) {
{ gentity_t *target;
gentity_t *target; trace_t trace;
trace_t trace; vec3_t src, dest, vf;
vec3_t src, dest, vf;
if ( ent->s.number == 0 && ent->client->NPC_class == CLASS_ATST ) if (ent->s.number == 0 &&
{//a player trying to get out of his ATST ent->client->NPC_class == CLASS_ATST) {//a player trying to get out of his ATST
GEntity_UseFunc( ent->activator, ent, ent ); GEntity_UseFunc(ent->activator, ent, ent);
return; return;
} }
//FIXME: this does not match where the new accurate crosshair aims... //FIXME: this does not match where the new accurate crosshair aims...
//cg.refdef.vieworg, basically //cg.refdef.vieworg, basically
VectorCopy( ent->client->renderInfo.eyePoint, src ); if (ent->client->ps.clientNum == 0) {
vec3_t angles;
BG_CalculateVRWeaponPosition(src, angles);
AngleVectors(angles, vf, NULL, NULL);
} else {
VectorCopy(ent->client->renderInfo.eyePoint, src);
AngleVectors(ent->client->ps.viewangles, vf, NULL,
NULL);//ent->client->renderInfo.eyeAngles was cg.refdef.viewangles, basically
}
AngleVectors( ent->client->ps.viewangles, vf, NULL, NULL );//ent->client->renderInfo.eyeAngles was cg.refdef.viewangles, basically
//extend to find end of use trace //extend to find end of use trace
VectorMA( src, USE_DISTANCE, vf, dest ); VectorMA( src, USE_DISTANCE, vf, dest );