Fixes crouching

This commit is contained in:
Simon 2020-05-18 23:32:09 +01:00
parent 9ba23bd449
commit 4071417a7d
4 changed files with 30 additions and 22 deletions

View file

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.drbeef.questzdoom"
android:versionCode="14"
android:versionName="0.7.0" android:installLocation="auto" >
android:versionCode="15"
android:versionName="0.7.1" android:installLocation="auto" >
<!-- Tell the system this app requires OpenGL ES 3.1. -->
<uses-feature android:glEsVersion="0x00030001" android:required="true"/>

View file

@ -123,14 +123,17 @@ namespace s3d
LSVec3 eyeOffset(tmp[0], tmp[1], tmp[2]);
// In vr, the real world floor level is at y==0
// In Doom, the virtual player foot level is viewheight below the current viewpoint (on the Z axis)
// We want to align those two heights here
const player_t & player = players[consoleplayer];
double vh = player.viewheight; // Doom thinks this is where you are
//bit of a hack, assume player is at "normal" height when not crouching
if (player.crouching == 0)
{
playerHeight = player.viewheight; // Doom thinks this is where you are
}
double pixelstretch = level.info ? level.info->pixelstretch : 1.2;
double hh = ((hmdPosition[1] + vr_height_adjust) * vr_vunits_per_meter) / pixelstretch; // HMD is actually here
eyeOffset[2] += hh - vh;
eyeOffset[2] += hh - playerHeight;
outViewShift[0] = eyeOffset[0];
outViewShift[1] = eyeOffset[1];
@ -252,11 +255,6 @@ namespace s3d
QzDoom_GetScreenRes(&sceneWidth, &sceneHeight);
}
void OculusQuestMode::getTracking(ovrTracking2 *_tracking) const
{
*_tracking = tracking;
}
/* virtual */
// AdjustViewports() is called from within FLGRenderer::SetOutputViewport(...)
void OculusQuestMode::AdjustViewports() const
@ -295,9 +293,16 @@ namespace s3d
AActor* playermo = player->mo;
DVector3 pos = playermo->InterpolatedPosition(r_viewpoint.TicFrac);
//bit of a hack, assume player is at "normal" height when not crouching
static double height = 0;
if (player->crouching == 0)
{
height = player->viewheight; // Doom thinks this is where you are
}
mat->loadIdentity();
mat->translate(pos.X, pos.Z, pos.Y);
mat->translate(pos.X, pos.Z + (player->viewheight - height), pos.Y);
mat->scale(vr_vunits_per_meter, vr_vunits_per_meter, -vr_vunits_per_meter);
@ -475,9 +480,16 @@ namespace s3d
player->mo->AttackPitch = -weaponangles[PITCH];
player->mo->AttackAngle = -90 + (doomYaw - hmdorientation[YAW]) + weaponangles[YAW];
//bit of a hack, assume player is at "normal" height when not crouching
static double height = 0;
if (player->crouching == 0)
{
height = player->viewheight; // Doom thinks this is where you are
}
player->mo->AttackPos.X = player->mo->X() - (weaponoffset[0] * vr_vunits_per_meter);
player->mo->AttackPos.Y = player->mo->Y() - (weaponoffset[2] * vr_vunits_per_meter);
player->mo->AttackPos.Z = player->mo->Z() + (((hmdPosition[1] + weaponoffset[1] + vr_height_adjust) * vr_vunits_per_meter) / pixelstretch);
player->mo->AttackPos.Z = player->mo->Z() + (((hmdPosition[1] + weaponoffset[1] + vr_height_adjust) * vr_vunits_per_meter) / pixelstretch) + (player->viewheight - height);
player->mo->AttackDir = MapAttackDir;
}
@ -595,14 +607,11 @@ namespace s3d
if (gamestate == GS_LEVEL && !getMenuState())
{
doomYaw += hmdYawDeltaDegrees;
}
//Set all the render angles - including roll
{
//Always update roll (as the game tic cmd doesn't support roll
GLRenderer->mAngles.Roll = roll;
GLRenderer->mAngles.Pitch = pitch;
}
{
double viewYaw = doomYaw;
while (viewYaw <= -180.0)
viewYaw += 360.0;

View file

@ -57,6 +57,7 @@ public:
protected:
mutable uint32_t framebuffer;
int eye;
mutable double playerHeight;
VSMatrix getHUDProjection() const;
@ -83,8 +84,6 @@ public:
virtual bool RenderPlayerSpritesInScene() const { return true; }
virtual bool GetTeleportLocation(DVector3 &out) const override;
void getTracking(ovrTracking2 *tracking) const;
protected:
OculusQuestMode();

View file

@ -41,7 +41,7 @@ const char *GetVersionString();
/** Lots of different version numbers **/
#define VERSIONSTR "DrBeef's QuestZDoom-0.7.0 (LZDoom 3.83a)"
#define VERSIONSTR "DrBeef's QuestZDoom-0.7.1 (LZDoom 3.83a)"
// The version as seen in the Windows resource
#define RC_FILEVERSION 3,83,1