Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Reset user position in NoAPI when leaving immersive mode #1404

Merged
merged 1 commit into from
Jul 22, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions app/src/noapi/cpp/DeviceDelegateNoAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,9 @@ struct DeviceDelegateNoAPI::State {
vrb::Matrix headingMatrix;
vrb::Matrix pitchMatrix;
vrb::Vector position;
vrb::Vector cachedStandalonePosition;
bool clicked;
GLsizei glWidth, glHeight;
float near, far;
vrb::Matrix reorientMatrix;
State()
: renderMode(device::RenderMode::StandAlone)
, heading(0.0f)
Expand All @@ -67,7 +65,6 @@ struct DeviceDelegateNoAPI::State {
, glHeight(0)
, near(0.1f)
, far(1000.0f)
, reorientMatrix(vrb::Matrix::Identity())
{
}

Expand Down Expand Up @@ -115,17 +112,17 @@ DeviceDelegateNoAPI::SetRenderMode(const device::RenderMode aMode) {
if (aMode == m.renderMode) {
return;
}
m.renderMode = aMode;
if (ValidateMethodID(sEnv, sActivity, sSetRenderMode, __FUNCTION__)) {
sEnv->CallVoidMethod(sActivity, sSetRenderMode, (aMode == device::RenderMode::Immersive ? 1 : 0));
CheckJNIException(sEnv, __FUNCTION__);
}
if (aMode != device::RenderMode::StandAlone) {
m.cachedStandalonePosition = m.position;
m.position = vrb::Vector();
} else {
m.position = m.cachedStandalonePosition;
// recenter when leaving immersive mode.
MoveAxis(0.0f, 0.0f, 0.0f);
}
m.renderMode = aMode;
}

device::RenderMode
Expand Down Expand Up @@ -159,12 +156,13 @@ DeviceDelegateNoAPI::GetHeadTransform() const {

const vrb::Matrix&
DeviceDelegateNoAPI::GetReorientTransform() const {
return m.reorientMatrix;
static vrb::Matrix identity(vrb::Matrix::Identity());
return identity;
}

void
DeviceDelegateNoAPI::SetReorientTransform(const vrb::Matrix& aMatrix) {
m.reorientMatrix = aMatrix;
// Ignore reorient transform
}

void
Expand Down Expand Up @@ -303,7 +301,7 @@ DeviceDelegateNoAPI::MoveAxis(const float aX, const float aY, const float aZ) {
if (m.renderMode == device::RenderMode::Immersive) {
m.position = vrb::Vector();
} else {
m.position = GetHomePosition();;
m.position = GetHomePosition();
}
m.heading = 0.0f;
m.pitch = 0.0f;
Expand Down