Increased rotation granularity to 0.01 desgrees

This commit is contained in:
Kung-vr
2019-01-13 10:04:21 +09:00
parent 5956041ebb
commit d0e2c15e7a
2 changed files with 29 additions and 29 deletions
+15 -15
View File
@@ -249,11 +249,11 @@ MyStackViewPage {
Layout.preferredWidth: 40 Layout.preferredWidth: 40
text: "-" text: "-"
onClicked: { onClicked: {
var val = MoveCenterTabController.tempRotation - 45 var val = ( MoveCenterTabController.tempRotation / 100 ) - 45
if (val < -180) { if (val < -180) {
val = val + 360; val = val + 360;
} }
MoveCenterTabController.tempRotation = val MoveCenterTabController.tempRotation = val * 100
} }
} }
@@ -261,15 +261,15 @@ MyStackViewPage {
id: playspaceRotationSlider id: playspaceRotationSlider
from: -180 from: -180
to: 180 to: 180
stepSize: 1 stepSize: 0.01
value: 0 value: 0
Layout.fillWidth: true Layout.fillWidth: true
onPositionChanged: { onPositionChanged: {
var val = this.from + ( this.position * (this.to - this.from)) var val = this.from + ( this.position * (this.to - this.from))
MoveCenterTabController.tempRotation = Math.round(val) MoveCenterTabController.tempRotation = Math.round(val * 100)
} }
onValueChanged: { onValueChanged: {
MoveCenterTabController.tempRotation = Math.round(playspaceRotationSlider.value) MoveCenterTabController.tempRotation = Math.round(playspaceRotationSlider.value * 100)
//playspaceRotationText.text = Math.round(playspaceRotationSlider.value) + "°" //playspaceRotationText.text = Math.round(playspaceRotationSlider.value) + "°"
} }
} }
@@ -279,11 +279,11 @@ MyStackViewPage {
Layout.preferredWidth: 40 Layout.preferredWidth: 40
text: "+" text: "+"
onClicked: { onClicked: {
var val = MoveCenterTabController.tempRotation + 45 var val = ( MoveCenterTabController.tempRotation / 100 ) + 45
if (val > 180) { if (val > 180) {
val = val -360; val = val -360;
} }
MoveCenterTabController.tempRotation = val MoveCenterTabController.tempRotation = val * 100
} }
} }
@@ -291,17 +291,17 @@ MyStackViewPage {
id: playspaceRotationText id: playspaceRotationText
text: "0°" text: "0°"
keyBoardUID: 104 keyBoardUID: 104
Layout.preferredWidth: 100 Layout.preferredWidth: 150
Layout.leftMargin: 10 Layout.leftMargin: 10
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
function onInputEvent(input) { function onInputEvent(input) {
var val = parseInt(input) var val = parseFloat(input)
if (!isNaN(val)) { if (!isNaN(val)) {
val = val % 180 val = val % 180
MoveCenterTabController.tempRotation = val MoveCenterTabController.tempRotation = Math.round(val * 100)
text = MoveCenterTabController.tempRotation + "°" text = ( MoveCenterTabController.tempRotation / 100 ) + "°"
} else { } else {
text = MoveCenterTabController.tempRotation + "°" text = ( MoveCenterTabController.tempRotation / 100 ) + "°"
} }
} }
} }
@@ -446,11 +446,11 @@ MyStackViewPage {
playSpaceMoveZText.text = MoveCenterTabController.offsetZ.toFixed(2) playSpaceMoveZText.text = MoveCenterTabController.offsetZ.toFixed(2)
} }
onRotationChanged: { onRotationChanged: {
playspaceRotationSlider.value = MoveCenterTabController.rotation playspaceRotationSlider.value = ( MoveCenterTabController.rotation / 100 )
} }
onTempRotationChanged: { onTempRotationChanged: {
playspaceRotationSlider.value = MoveCenterTabController.tempRotation playspaceRotationSlider.value = ( MoveCenterTabController.tempRotation / 100 )
playspaceRotationText.text = MoveCenterTabController.tempRotation + "°" playspaceRotationText.text = ( MoveCenterTabController.tempRotation / 100 ) + "°"
} }
onAdjustChaperoneChanged: { onAdjustChaperoneChanged: {
playspaceAdjustChaperoneToggle.checked = MoveCenterTabController.adjustChaperone playspaceAdjustChaperoneToggle.checked = MoveCenterTabController.adjustChaperone
+14 -14
View File
@@ -151,7 +151,7 @@ void MoveCenterTabController::setRotation( int value, bool notify )
{ {
if ( m_rotation != value ) if ( m_rotation != value )
{ {
double angle = ( value - m_rotation ) * 2 * M_PI / 360.0; double angle = ( value - m_rotation ) * M_PI / 18000.0;
// Revert now because we don't commit in RotateUniverseCenter and // Revert now because we don't commit in RotateUniverseCenter and
// AddOffsetToUniverseCenter. We do this so rotation and offset can // AddOffsetToUniverseCenter. We do this so rotation and offset can
@@ -176,7 +176,7 @@ void MoveCenterTabController::setRotation( int value, bool notify )
= { oldHmdPos.m[0][3], oldHmdPos.m[1][3], oldHmdPos.m[2][3] }; = { oldHmdPos.m[0][3], oldHmdPos.m[1][3], oldHmdPos.m[2][3] };
// Convert oldHmdXyz into un-rotated coordinates. // Convert oldHmdXyz into un-rotated coordinates.
double oldAngle = -m_rotation * 2 * M_PI / 360.0; double oldAngle = -m_rotation * M_PI / 18000.0;
rotateCoordinates( oldHmdXyz, oldAngle ); rotateCoordinates( oldHmdXyz, oldAngle );
// Set newHmdXyz to have additional rotation from incoming angle change. // Set newHmdXyz to have additional rotation from incoming angle change.
@@ -204,7 +204,7 @@ void MoveCenterTabController::setRotation( int value, bool notify )
// We use rotated coordinates here because we have already applied // We use rotated coordinates here because we have already applied
// RotateUniverseCenter. This will be the final offset ready to apply, // RotateUniverseCenter. This will be the final offset ready to apply,
// so it must match the current universe axis rotation. // so it must match the current universe axis rotation.
double finalAngle = m_rotation * 2 * M_PI / 360.0; double finalAngle = m_rotation * M_PI / 18000.0;
double finalHmdRotDiff[3] = { hmdRotDiff[0], 0, hmdRotDiff[2] }; double finalHmdRotDiff[3] = { hmdRotDiff[0], 0, hmdRotDiff[2] };
rotateCoordinates( finalHmdRotDiff, finalAngle ); rotateCoordinates( finalHmdRotDiff, finalAngle );
@@ -262,7 +262,7 @@ void MoveCenterTabController::setAdjustChaperone( bool value, bool notify )
m_adjustChaperone = value; m_adjustChaperone = value;
if ( m_trackingUniverse == vr::TrackingUniverseStanding ) if ( m_trackingUniverse == vr::TrackingUniverseStanding )
{ {
double angle = m_rotation * 2 * M_PI / 360.0; double angle = m_rotation * M_PI / 18000.0;
double offsetdir = m_adjustChaperone ? -1.0 : 1.0; double offsetdir = m_adjustChaperone ? -1.0 : 1.0;
double offset[3] = { offsetdir * m_offsetX, double offset[3] = { offsetdir * m_offsetX,
offsetdir * m_offsetY, offsetdir * m_offsetY,
@@ -428,7 +428,7 @@ void MoveCenterTabController::modOffsetX( float value, bool notify )
// TODO ? possible issue with locking position this way // TODO ? possible issue with locking position this way
if ( !m_lockXToggle ) if ( !m_lockXToggle )
{ {
double angle = m_rotation * 2 * M_PI / 360.0; double angle = m_rotation * M_PI / 18000.0;
double offset[3] = { value, 0, 0 }; double offset[3] = { value, 0, 0 };
rotateCoordinates( offset, angle ); rotateCoordinates( offset, angle );
float offsetFloat[3] = { static_cast<float>( offset[0] ), float offsetFloat[3] = { static_cast<float>( offset[0] ),
@@ -467,7 +467,7 @@ void MoveCenterTabController::modOffsetZ( float value, bool notify )
{ {
if ( !m_lockZToggle ) if ( !m_lockZToggle )
{ {
double angle = m_rotation * 2 * M_PI / 360.0; double angle = m_rotation * M_PI / 18000.0;
double offset[3] = { 0, 0, value }; double offset[3] = { 0, 0, value };
rotateCoordinates( offset, angle ); rotateCoordinates( offset, angle );
float offsetFloat[3] = { static_cast<float>( offset[0] ), float offsetFloat[3] = { static_cast<float>( offset[0] ),
@@ -490,7 +490,7 @@ void MoveCenterTabController::reset()
vr::VRChaperoneSetup()->RevertWorkingCopy(); vr::VRChaperoneSetup()->RevertWorkingCopy();
parent->RotateUniverseCenter( parent->RotateUniverseCenter(
vr::TrackingUniverseOrigin( m_trackingUniverse ), vr::TrackingUniverseOrigin( m_trackingUniverse ),
-m_rotation * 2 * M_PI / 360.0, static_cast<float>( -m_rotation * M_PI / 18000.0 ),
m_adjustChaperone, m_adjustChaperone,
false ); false );
float offset[3] = { -m_offsetX, -m_offsetY, -m_offsetZ }; float offset[3] = { -m_offsetX, -m_offsetY, -m_offsetZ };
@@ -660,7 +660,7 @@ void MoveCenterTabController::eventLoopTick(
pose->mDeviceToAbsoluteTracking.m[1][3], pose->mDeviceToAbsoluteTracking.m[1][3],
pose->mDeviceToAbsoluteTracking.m[2][3] }; pose->mDeviceToAbsoluteTracking.m[2][3] };
double angle = m_rotation * 2 * M_PI / 360.0; double angle = m_rotation * M_PI / 18000.0;
rotateCoordinates( relativeControllerPosition, -angle ); rotateCoordinates( relativeControllerPosition, -angle );
float absoluteControllerPosition[] = { float absoluteControllerPosition[] = {
static_cast<float>( relativeControllerPosition[0] ) + m_offsetX, static_cast<float>( relativeControllerPosition[0] ) + m_offsetX,
@@ -758,16 +758,16 @@ void MoveCenterTabController::eventLoopTick(
// TODO: Increase angular granularity beyond 1 degree. // TODO: Increase angular granularity beyond 1 degree.
int newRotationAngleDeg = static_cast<int>( int newRotationAngleDeg = static_cast<int>(
round( handYawDiff * 180.0 / M_PI ) + m_rotation ); round( handYawDiff * 18000.0 / M_PI ) + m_rotation );
// Keep angle within -180 ~ 180 // Keep angle within -18000 ~ 18000
if ( newRotationAngleDeg > 180 ) if ( newRotationAngleDeg > 18000 )
{ {
newRotationAngleDeg -= 360; newRotationAngleDeg -= 36000;
} }
else if ( newRotationAngleDeg < -180 ) else if ( newRotationAngleDeg < -18000 )
{ {
newRotationAngleDeg += 360; newRotationAngleDeg += 36000;
} }
setRotation( newRotationAngleDeg ); setRotation( newRotationAngleDeg );