Positional Tracking

Made positional tracking consistent regardless of framerate
This commit is contained in:
Simon 2020-09-13 10:36:58 +01:00
parent b1d017108b
commit e096223048
3 changed files with 11 additions and 2 deletions

View file

@ -26,6 +26,8 @@ extern "C" {
#define ALOGV(...)
#endif
#define TIC_RATE 60
float playerHeight;
float playerYaw;

View file

@ -109,7 +109,7 @@ ovrLayerCylinder2 BuildCylinderLayer( ovrRenderer * cylinderRenderer,
const float density = 4500.0f;
const float rotateYaw = 0.0f;
const float radius = 6.0f;
const ovrVector3f translation = { 0.0f, 0.0f, -5.0f };
const ovrVector3f translation = { 0.0f, 0.0f, -6.0f };
ovrMatrix4f cylinderTransform =
CylinderModelMatrix( textureWidth, textureHeight, translation,

View file

@ -406,10 +406,17 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
//Right-hand specific stuff
{
//Adjust positional factor for this sample based on how long the last frame took, it should
//approximately even out the positional movement on a per frame basis (especially when fps is much lower than 60)
//NOTE: it'll never be above ~60fps since we use com_fixedTic of "-1"
static float lastSampleTime = 0;
float sampleTime = Sys_Milliseconds();
float vr_positional_factor = 2400.0f * ((1000.0f / TIC_RATE) / (sampleTime-lastSampleTime));
lastSampleTime = sampleTime;
//This section corrects for the fact that the controller actually controls direction of movement, but we want to move relative to the direction the
//player is facing for positional tracking
vec2_t v;
float vr_positional_factor = 2500;
rotateAboutOrigin(-pVRClientInfo->hmdposition_delta[0] * vr_positional_factor,
pVRClientInfo->hmdposition_delta[2] * vr_positional_factor, - pVRClientInfo->hmdorientation[YAW], v);
positional_movementSideways = v[0];