mirror of
https://github.com/DrBeef/JKXR.git
synced 2024-11-25 05:21:00 +00:00
Decouple view angles from 3rd person saber
Feels a lot cleaner, also made the turn mode have 3 options: 0 = Snap turn 1 = Snap turn (1st Person) & Smooth turn (3rd person) 2 = Smooth turn
This commit is contained in:
parent
89f925c373
commit
5c09153f67
11 changed files with 109 additions and 63 deletions
|
@ -1,8 +1,8 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="com.drbeef.jk2quest"
|
package="com.drbeef.jk2quest"
|
||||||
android:versionCode="21"
|
android:versionCode="22"
|
||||||
android:versionName="0.3.2" android:installLocation="auto" >
|
android:versionName="0.3.3" android:installLocation="auto" >
|
||||||
|
|
||||||
<!-- Tell the system this app requires OpenGL ES 3.1. -->
|
<!-- Tell the system this app requires OpenGL ES 3.1. -->
|
||||||
<uses-feature android:glEsVersion="0x00030002" android:required="true"/>
|
<uses-feature android:glEsVersion="0x00030002" android:required="true"/>
|
||||||
|
|
|
@ -809,6 +809,10 @@ void updateHMDOrientation()
|
||||||
|
|
||||||
//Keep this for our records
|
//Keep this for our records
|
||||||
VectorCopy(vr.hmdorientation, vr.hmdorientation_last);
|
VectorCopy(vr.hmdorientation, vr.hmdorientation_last);
|
||||||
|
|
||||||
|
if (!vr.third_person){
|
||||||
|
VectorCopy(vr.hmdorientation, vr.hmdorientation_first);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setHMDPosition( float x, float y, float z )
|
void setHMDPosition( float x, float y, float z )
|
||||||
|
@ -823,18 +827,12 @@ void setHMDPosition( float x, float y, float z )
|
||||||
|
|
||||||
//Record player position on transition
|
//Record player position on transition
|
||||||
VectorSet(vr.hmdposition_snap, x, y, z);
|
VectorSet(vr.hmdposition_snap, x, y, z);
|
||||||
VectorCopy(vr.hmdorientation_snap, vr.hmdorientation);
|
VectorCopy(vr.hmdorientation, vr.hmdorientation_snap);
|
||||||
}
|
}
|
||||||
|
|
||||||
VectorSubtract(vr.hmdposition, vr.hmdposition_snap, vr.hmdposition_offset);
|
VectorSubtract(vr.hmdposition, vr.hmdposition_snap, vr.hmdposition_offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isMultiplayer()
|
|
||||||
{
|
|
||||||
return Cvar_VariableValue("maxclients") > 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
========================
|
========================
|
||||||
JKVR_Vibrate
|
JKVR_Vibrate
|
||||||
|
@ -860,6 +858,7 @@ void JKVR_Vibrate( int duration, int channel, float intensity )
|
||||||
void JKVR_GetMove(float *forward, float *side, float *pos_forward, float *pos_side, float *up,
|
void JKVR_GetMove(float *forward, float *side, float *pos_forward, float *pos_side, float *up,
|
||||||
float *yaw, float *pitch, float *roll)
|
float *yaw, float *pitch, float *roll)
|
||||||
{
|
{
|
||||||
|
if (!vr.third_person) {
|
||||||
*forward = remote_movementForward;
|
*forward = remote_movementForward;
|
||||||
*pos_forward = positional_movementForward;
|
*pos_forward = positional_movementForward;
|
||||||
*up = remote_movementUp;
|
*up = remote_movementUp;
|
||||||
|
@ -868,6 +867,17 @@ void JKVR_GetMove(float *forward, float *side, float *pos_forward, float *pos_si
|
||||||
*yaw = vr.hmdorientation[YAW] + vr.snapTurn;
|
*yaw = vr.hmdorientation[YAW] + vr.snapTurn;
|
||||||
*pitch = vr.hmdorientation[PITCH];
|
*pitch = vr.hmdorientation[PITCH];
|
||||||
*roll = vr.hmdorientation[ROLL];
|
*roll = vr.hmdorientation[ROLL];
|
||||||
|
} else {
|
||||||
|
//in third person just send the bare minimum
|
||||||
|
*forward = remote_movementForward;
|
||||||
|
*pos_forward = 0.0f;
|
||||||
|
*up = 0.0f;
|
||||||
|
*side = remote_movementSideways;
|
||||||
|
*pos_side = 0.0f;
|
||||||
|
*yaw = vr.snapTurn + vr.hmdorientation_first[YAW];
|
||||||
|
*pitch = 0.0f;
|
||||||
|
*roll = 0.0f;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1268,7 +1278,7 @@ void JKVR_Init()
|
||||||
srand(time(NULL));
|
srand(time(NULL));
|
||||||
|
|
||||||
//Create Cvars
|
//Create Cvars
|
||||||
vr_turn_mode = Cvar_Get( "vr_turn_mode", "0", CVAR_ARCHIVE); // 0 = snap, 1 = smooth
|
vr_turn_mode = Cvar_Get( "vr_turn_mode", "0", CVAR_ARCHIVE); // 0 = snap, 1 = smooth (3rd person only), 2 = smooth (all modes)
|
||||||
vr_turn_angle = Cvar_Get( "vr_turn_angle", "45", CVAR_ARCHIVE);
|
vr_turn_angle = Cvar_Get( "vr_turn_angle", "45", CVAR_ARCHIVE);
|
||||||
vr_positional_factor = Cvar_Get( "vr_positional_factor", "12", CVAR_ARCHIVE);
|
vr_positional_factor = Cvar_Get( "vr_positional_factor", "12", CVAR_ARCHIVE);
|
||||||
vr_walkdirection = Cvar_Get( "vr_walkdirection", "1", CVAR_ARCHIVE);
|
vr_walkdirection = Cvar_Get( "vr_walkdirection", "1", CVAR_ARCHIVE);
|
||||||
|
|
|
@ -7,12 +7,12 @@ typedef struct {
|
||||||
bool cin_camera; // cinematic camera taken over
|
bool cin_camera; // cinematic camera taken over
|
||||||
bool misc_camera; // looking through a misc camera view entity
|
bool misc_camera; // looking through a misc camera view entity
|
||||||
bool using_screen_layer;
|
bool using_screen_layer;
|
||||||
|
bool third_person;
|
||||||
float fov;
|
float fov;
|
||||||
bool immersive_cinematics;
|
bool immersive_cinematics;
|
||||||
bool weapon_stabilised;
|
bool weapon_stabilised;
|
||||||
bool right_handed;
|
bool right_handed;
|
||||||
bool player_moving;
|
bool player_moving;
|
||||||
bool mountedgun;
|
|
||||||
int cgzoommode;
|
int cgzoommode;
|
||||||
|
|
||||||
int weaponid;
|
int weaponid;
|
||||||
|
@ -28,6 +28,7 @@ typedef struct {
|
||||||
vec3_t hmdorientation_last; // Don't use this, it is just for calculating delta!
|
vec3_t hmdorientation_last; // Don't use this, it is just for calculating delta!
|
||||||
vec3_t hmdorientation_delta;
|
vec3_t hmdorientation_delta;
|
||||||
vec3_t hmdorientation_snap;
|
vec3_t hmdorientation_snap;
|
||||||
|
vec3_t hmdorientation_first; // only updated when in first person
|
||||||
|
|
||||||
vec3_t weaponangles_saber;
|
vec3_t weaponangles_saber;
|
||||||
vec3_t weaponangles;
|
vec3_t weaponangles;
|
||||||
|
|
|
@ -679,26 +679,18 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Resync Yaw on mounted gun transition
|
//Use smooth in 3rd person
|
||||||
static int usingMountedGun = false;
|
bool usingSnapTurn = vr_turn_mode->integer == 0 ||
|
||||||
if (vr.mountedgun != usingMountedGun) {
|
(vr.third_person && vr_turn_mode->integer == 1);
|
||||||
usingMountedGun = vr.mountedgun;
|
|
||||||
}
|
|
||||||
|
|
||||||
//No snap turn when using mounted gun
|
//No snap turn when using mounted gun
|
||||||
static int syncCount = 0;
|
|
||||||
static int increaseSnap = true;
|
static int increaseSnap = true;
|
||||||
if (!vr.item_selector && !vr.mountedgun && !vr.scopeengaged) {
|
if (!vr.item_selector && !vr.scopeengaged) {
|
||||||
|
if (usingSnapTurn) {
|
||||||
if (primaryJoystickX > 0.7f) {
|
if (primaryJoystickX > 0.7f) {
|
||||||
if (increaseSnap) {
|
if (increaseSnap) {
|
||||||
float turnAngle = vr_turn_mode->integer ? (vr_turn_angle->value / 9.0f)
|
vr.snapTurn -= vr_turn_angle->value;
|
||||||
: vr_turn_angle->value;
|
|
||||||
vr.snapTurn -= turnAngle;
|
|
||||||
|
|
||||||
if (vr_turn_mode->integer == 0) {
|
|
||||||
increaseSnap = false;
|
increaseSnap = false;
|
||||||
}
|
|
||||||
|
|
||||||
if (vr.snapTurn < -180.0f) {
|
if (vr.snapTurn < -180.0f) {
|
||||||
vr.snapTurn += 360.f;
|
vr.snapTurn += 360.f;
|
||||||
}
|
}
|
||||||
|
@ -706,19 +698,14 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG
|
||||||
} else if (primaryJoystickX < 0.3f) {
|
} else if (primaryJoystickX < 0.3f) {
|
||||||
increaseSnap = true;
|
increaseSnap = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int decreaseSnap = true;
|
static int decreaseSnap = true;
|
||||||
|
if (usingSnapTurn) {
|
||||||
if (primaryJoystickX < -0.7f) {
|
if (primaryJoystickX < -0.7f) {
|
||||||
if (decreaseSnap) {
|
if (decreaseSnap) {
|
||||||
|
vr.snapTurn += vr_turn_angle->value;
|
||||||
float turnAngle = vr_turn_mode->integer ? (vr_turn_angle->value / 9.0f)
|
|
||||||
: vr_turn_angle->value;
|
|
||||||
vr.snapTurn += turnAngle;
|
|
||||||
|
|
||||||
//If snap turn configured for less than 10 degrees
|
|
||||||
if (vr_turn_mode->integer == 0) {
|
|
||||||
decreaseSnap = false;
|
decreaseSnap = false;
|
||||||
}
|
|
||||||
|
|
||||||
if (vr.snapTurn > 180.0f) {
|
if (vr.snapTurn > 180.0f) {
|
||||||
vr.snapTurn -= 360.f;
|
vr.snapTurn -= 360.f;
|
||||||
|
@ -727,6 +714,16 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG
|
||||||
} else if (primaryJoystickX > -0.3f) {
|
} else if (primaryJoystickX > -0.3f) {
|
||||||
decreaseSnap = true;
|
decreaseSnap = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!usingSnapTurn && fabs(primaryJoystickX) > 0.1f) //smooth turn
|
||||||
|
{
|
||||||
|
vr.snapTurn -= ((vr_turn_angle->value / 10.0f) *
|
||||||
|
primaryJoystickX);
|
||||||
|
if (vr.snapTurn > 180.0f) {
|
||||||
|
vr.snapTurn -= 360.f;
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (fabs(primaryJoystickX) > 0.5f) {
|
if (fabs(primaryJoystickX) > 0.5f) {
|
||||||
increaseSnap = false;
|
increaseSnap = false;
|
||||||
|
|
|
@ -30,8 +30,8 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
void CG_AdjustFrom640( float *x, float *y, float *w, float *h ) {
|
void CG_AdjustFrom640( float *x, float *y, float *w, float *h ) {
|
||||||
if (cg.drawingHUD && !vr->cin_camera && !vr->using_screen_layer && !vr->scopeengaged)
|
if (cg.drawingHUD && !vr->cin_camera && !vr->using_screen_layer && !vr->scopeengaged)
|
||||||
{
|
{
|
||||||
float screenXScale = 1.0f / (cg.drawingHUD == CG_HUD_SCALED ? 2.5f : 1.25f);
|
float screenXScale = 1.0f / (cg.drawingHUD == CG_HUD_SCALED ? 2.5f : 1.2f);
|
||||||
float screenYScale = 1.0f / (cg.drawingHUD == CG_HUD_SCALED ? 2.5f : 1.25f);
|
float screenYScale = 1.0f / (cg.drawingHUD == CG_HUD_SCALED ? 2.5f : 1.2f);
|
||||||
|
|
||||||
float xoffset = cg.drawingHUD == CG_HUD_SCALED ? -20 : 0;
|
float xoffset = cg.drawingHUD == CG_HUD_SCALED ? -20 : 0;
|
||||||
if (cg.refdef.stereoView == STEREO_LEFT) {
|
if (cg.refdef.stereoView == STEREO_LEFT) {
|
||||||
|
|
|
@ -1968,6 +1968,7 @@ void CG_RunEmplacedWeapon()
|
||||||
|
|
||||||
// don't let the player try and change this
|
// don't let the player try and change this
|
||||||
cg.renderingThirdPerson = qtrue;
|
cg.renderingThirdPerson = qtrue;
|
||||||
|
vr->third_person = false; // don't treat this as a true 3rd person scenario
|
||||||
|
|
||||||
// cg.refdefViewAngles[PITCH] += cg.overrides.thirdPersonPitchOffset? cg.overrides.thirdPersonPitchOffset: cg_thirdPersonPitchOffset.value;
|
// cg.refdefViewAngles[PITCH] += cg.overrides.thirdPersonPitchOffset? cg.overrides.thirdPersonPitchOffset: cg_thirdPersonPitchOffset.value;
|
||||||
// cg.refdefViewAngles[YAW] += cg.overrides.thirdPersonAngle ? cg.overrides.thirdPersonAngle : cg_thirdPersonAngle.value;;
|
// cg.refdefViewAngles[YAW] += cg.overrides.thirdPersonAngle ? cg.overrides.thirdPersonAngle : cg_thirdPersonAngle.value;;
|
||||||
|
@ -2114,10 +2115,13 @@ void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView ) {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
vr->third_person = cg.renderingThirdPerson;
|
||||||
|
|
||||||
if ( cg.zoomMode )
|
if ( cg.zoomMode )
|
||||||
{
|
{
|
||||||
// zoomed characters should never do third person stuff??
|
// zoomed characters should never do third person stuff??
|
||||||
cg.renderingThirdPerson = qfalse;
|
cg.renderingThirdPerson = qfalse;
|
||||||
|
vr->third_person = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
vr->cin_camera = in_camera;
|
vr->cin_camera = in_camera;
|
||||||
|
|
|
@ -712,13 +712,22 @@ void rotateAboutOrigin(float x, float y, float rotation, vec2_t out)
|
||||||
out[1] = cosf(DEG2RAD(-rotation)) * y - sinf(DEG2RAD(-rotation)) * x;
|
out[1] = cosf(DEG2RAD(-rotation)) * y - sinf(DEG2RAD(-rotation)) * x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float getHMDYawForCalc()
|
||||||
|
{
|
||||||
|
if (!vr->third_person) {
|
||||||
|
return vr->hmdorientation[YAW];
|
||||||
|
}
|
||||||
|
return 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
void BG_ConvertFromVR(vec3_t in, vec3_t offset, vec3_t out)
|
void BG_ConvertFromVR(vec3_t in, vec3_t offset, vec3_t out)
|
||||||
{
|
{
|
||||||
vec3_t vrSpace;
|
vec3_t vrSpace;
|
||||||
VectorSet(vrSpace, in[2], in[0], in[1] );
|
VectorSet(vrSpace, in[2], in[0], in[1] );
|
||||||
|
|
||||||
vec2_t r;
|
vec2_t r;
|
||||||
rotateAboutOrigin(vrSpace[0], vrSpace[1], cg.refdefViewAngles[YAW] - vr->hmdorientation[YAW], r);
|
rotateAboutOrigin(vrSpace[0], vrSpace[1],
|
||||||
|
cg.refdefViewAngles[YAW] - getHMDYawForCalc(), r);
|
||||||
|
|
||||||
vrSpace[0] = -r[0];
|
vrSpace[0] = -r[0];
|
||||||
vrSpace[1] = -r[1];
|
vrSpace[1] = -r[1];
|
||||||
|
@ -743,7 +752,7 @@ void BG_CalculateVRPositionInWorld( const vec3_t in_position, vec3_t in_offset,
|
||||||
origin[2] += (in_position[1] + cg_heightAdjust.value) * cg_worldScale.value;
|
origin[2] += (in_position[1] + cg_heightAdjust.value) * cg_worldScale.value;
|
||||||
|
|
||||||
VectorCopy(in_orientation, angles);
|
VectorCopy(in_orientation, angles);
|
||||||
angles[YAW] += (cg.refdefViewAngles[YAW] - vr->hmdorientation[YAW]);
|
angles[YAW] += (cg.refdefViewAngles[YAW] - getHMDYawForCalc());
|
||||||
}
|
}
|
||||||
|
|
||||||
void BG_CalculateVROffHandPosition( vec3_t origin, vec3_t angles )
|
void BG_CalculateVROffHandPosition( vec3_t origin, vec3_t angles )
|
||||||
|
|
|
@ -2782,7 +2782,8 @@ void CG_DrawActive( stereoFrame_t stereoView ) {
|
||||||
|
|
||||||
cg.refdef.worldscale = cg_worldScale.value;
|
cg.refdef.worldscale = cg_worldScale.value;
|
||||||
if (!in_camera &&
|
if (!in_camera &&
|
||||||
!in_misccamera)
|
!in_misccamera &&
|
||||||
|
!cg.renderingThirdPerson)
|
||||||
{
|
{
|
||||||
VectorCopy(vr->hmdorientation, cg.refdef.viewangles);
|
VectorCopy(vr->hmdorientation, cg.refdef.viewangles);
|
||||||
cg.refdef.viewangles[YAW] = vr->clientviewangles[YAW] +
|
cg.refdef.viewangles[YAW] = vr->clientviewangles[YAW] +
|
||||||
|
@ -2790,7 +2791,18 @@ void CG_DrawActive( stereoFrame_t stereoView ) {
|
||||||
AnglesToAxis(cg.refdef.viewangles, cg.refdef.viewaxis);
|
AnglesToAxis(cg.refdef.viewangles, cg.refdef.viewaxis);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((in_camera && vr->immersive_cinematics) || in_turret)
|
if (!in_camera &&
|
||||||
|
!in_misccamera &&
|
||||||
|
cg.renderingThirdPerson)
|
||||||
|
{
|
||||||
|
VectorCopy(vr->hmdorientation, cg.refdef.viewangles);
|
||||||
|
cg.refdef.viewangles[YAW] = vr->clientviewangles[YAW] +
|
||||||
|
(vr->hmdorientation[YAW] - vr->hmdorientation_first[YAW]) +
|
||||||
|
SHORT2ANGLE(cg.snap->ps.delta_angles[YAW]);
|
||||||
|
AnglesToAxis(cg.refdef.viewangles, cg.refdef.viewaxis);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((in_camera && vr->immersive_cinematics) || in_turret || cg.renderingThirdPerson)
|
||||||
{
|
{
|
||||||
BG_ConvertFromVR(vr->hmdposition_offset, cg.refdef.vieworg, cg.refdef.vieworg);
|
BG_ConvertFromVR(vr->hmdposition_offset, cg.refdef.vieworg, cg.refdef.vieworg);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,8 +29,8 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
void CG_AdjustFrom640( float *x, float *y, float *w, float *h ) {
|
void CG_AdjustFrom640( float *x, float *y, float *w, float *h ) {
|
||||||
if (cg.drawingHUD && !vr->cin_camera && !vr->using_screen_layer && !vr->scopeengaged)
|
if (cg.drawingHUD && !vr->cin_camera && !vr->using_screen_layer && !vr->scopeengaged)
|
||||||
{
|
{
|
||||||
float screenXScale = 1.0f / (cg.drawingHUD == CG_HUD_SCALED ? 2.5f : 1.25f);
|
float screenXScale = 1.0f / (cg.drawingHUD == CG_HUD_SCALED ? 2.5f : 1.2f);
|
||||||
float screenYScale = 1.0f / (cg.drawingHUD == CG_HUD_SCALED ? 2.5f : 1.25f);
|
float screenYScale = 1.0f / (cg.drawingHUD == CG_HUD_SCALED ? 2.5f : 1.2f);
|
||||||
|
|
||||||
float xoffset = cg.drawingHUD == CG_HUD_SCALED ? -20 : 0;
|
float xoffset = cg.drawingHUD == CG_HUD_SCALED ? -20 : 0;
|
||||||
if (cg.refdef.stereoView == STEREO_LEFT) {
|
if (cg.refdef.stereoView == STEREO_LEFT) {
|
||||||
|
|
|
@ -1797,6 +1797,7 @@ void CG_RunEmplacedWeapon()
|
||||||
|
|
||||||
// don't let the player try and change this
|
// don't let the player try and change this
|
||||||
cg.renderingThirdPerson = qtrue;
|
cg.renderingThirdPerson = qtrue;
|
||||||
|
vr->third_person = false; // don't treat this as a true 3rd person scenario
|
||||||
|
|
||||||
// cg.refdefViewAngles[PITCH] += cg.overrides.thirdPersonPitchOffset? cg.overrides.thirdPersonPitchOffset: cg_thirdPersonPitchOffset.value;
|
// cg.refdefViewAngles[PITCH] += cg.overrides.thirdPersonPitchOffset? cg.overrides.thirdPersonPitchOffset: cg_thirdPersonPitchOffset.value;
|
||||||
// cg.refdefViewAngles[YAW] += cg.overrides.thirdPersonAngle ? cg.overrides.thirdPersonAngle : cg_thirdPersonAngle.value;;
|
// cg.refdefViewAngles[YAW] += cg.overrides.thirdPersonAngle ? cg.overrides.thirdPersonAngle : cg_thirdPersonAngle.value;;
|
||||||
|
@ -1926,10 +1927,13 @@ wasForceSpeed=isForceSpeed;
|
||||||
(g_entities[0].client &&
|
(g_entities[0].client &&
|
||||||
g_entities[0].client->NPC_class == CLASS_ATST));
|
g_entities[0].client->NPC_class == CLASS_ATST));
|
||||||
|
|
||||||
|
vr->third_person = cg.renderingThirdPerson;
|
||||||
|
|
||||||
if ( cg.zoomMode )
|
if ( cg.zoomMode )
|
||||||
{
|
{
|
||||||
// zoomed characters should never do third person stuff??
|
// zoomed characters should never do third person stuff??
|
||||||
cg.renderingThirdPerson = qfalse;
|
cg.renderingThirdPerson = qfalse;
|
||||||
|
vr->third_person = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
vr->cin_camera = in_camera;
|
vr->cin_camera = in_camera;
|
||||||
|
|
|
@ -653,13 +653,22 @@ void rotateAboutOrigin(float x, float y, float rotation, vec2_t out)
|
||||||
out[1] = cosf(DEG2RAD(-rotation)) * y - sinf(DEG2RAD(-rotation)) * x;
|
out[1] = cosf(DEG2RAD(-rotation)) * y - sinf(DEG2RAD(-rotation)) * x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float getHMDYawForCalc()
|
||||||
|
{
|
||||||
|
if (!vr->third_person) {
|
||||||
|
return vr->hmdorientation[YAW];
|
||||||
|
}
|
||||||
|
return 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
void BG_ConvertFromVR(vec3_t in, vec3_t offset, vec3_t out)
|
void BG_ConvertFromVR(vec3_t in, vec3_t offset, vec3_t out)
|
||||||
{
|
{
|
||||||
vec3_t vrSpace;
|
vec3_t vrSpace;
|
||||||
VectorSet(vrSpace, in[2], in[0], in[1] );
|
VectorSet(vrSpace, in[2], in[0], in[1] );
|
||||||
|
|
||||||
vec2_t r;
|
vec2_t r;
|
||||||
rotateAboutOrigin(vrSpace[0], vrSpace[1], cg.refdefViewAngles[YAW] - vr->hmdorientation[YAW], r);
|
rotateAboutOrigin(vrSpace[0], vrSpace[1],
|
||||||
|
cg.refdefViewAngles[YAW] - getHMDYawForCalc(), r);
|
||||||
|
|
||||||
vrSpace[0] = -r[0];
|
vrSpace[0] = -r[0];
|
||||||
vrSpace[1] = -r[1];
|
vrSpace[1] = -r[1];
|
||||||
|
@ -684,7 +693,7 @@ void BG_CalculateVRPositionInWorld( const vec3_t in_position, vec3_t in_offset,
|
||||||
origin[2] += (in_position[1] + cg_heightAdjust.value) * cg_worldScale.value;
|
origin[2] += (in_position[1] + cg_heightAdjust.value) * cg_worldScale.value;
|
||||||
|
|
||||||
VectorCopy(in_orientation, angles);
|
VectorCopy(in_orientation, angles);
|
||||||
angles[YAW] += (cg.refdefViewAngles[YAW] - vr->hmdorientation[YAW]);
|
angles[YAW] += (cg.refdefViewAngles[YAW] - getHMDYawForCalc());
|
||||||
}
|
}
|
||||||
|
|
||||||
void BG_CalculateVROffHandPosition( vec3_t origin, vec3_t angles )
|
void BG_CalculateVROffHandPosition( vec3_t origin, vec3_t angles )
|
||||||
|
|
Loading…
Reference in a new issue