History

Gyros and touch look now work at same time

Philip Rosedale committed 13 years ago

Commit 6609a851 parent 670de734 files · +25 −14Browse files

Showing the changes to interface/src/Application.cpp (1 of 4 files). Show all

Unified · Split

interface/src/Application.cpp+11−10
@@ -183,6 +183,8 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 182 unmodified lines
183 _touchAvgX(0.0f),183 _touchAvgX(0.0f),
184 _touchAvgY(0.0f),184 _touchAvgY(0.0f),
185 _isTouchPressed(false),185 _isTouchPressed(false),
186 _yawFromTouch(0.0f),
187 _pitchFromTouch(0.0f),
186 _mousePressed(false),188 _mousePressed(false),
187 _mouseVoxelScale(1.0f / 1024.0f),189 _mouseVoxelScale(1.0f / 1024.0f),
188 _justEditedVoxel(false),190 _justEditedVoxel(false),
@@ -969,6 +971,9 @@ void Application::idle() { · 780 unmodified lines
969 gettimeofday(&check, NULL);971 gettimeofday(&check, NULL);
970 972
971 // Only run simulation code if more than IDLE_SIMULATE_MSECS have passed since last time we ran973 // Only run simulation code if more than IDLE_SIMULATE_MSECS have passed since last time we ran
974 sendPostedEvents(NULL, QEvent::TouchBegin);
975 sendPostedEvents(NULL, QEvent::TouchUpdate);
976 sendPostedEvents(NULL, QEvent::TouchEnd);
972 977
973 double timeSinceLastUpdate = diffclock(&_lastTimeUpdated, &check);978 double timeSinceLastUpdate = diffclock(&_lastTimeUpdated, &check);
974 if (timeSinceLastUpdate > IDLE_SIMULATE_MSECS) {979 if (timeSinceLastUpdate > IDLE_SIMULATE_MSECS) {
@@ -978,9 +983,6 @@ void Application::idle() { · 3 unmodified lines
978 // This is necessary because id the idle() call takes longer than the983 // This is necessary because id the idle() call takes longer than the
979 // interval between idle() calls, the event loop never gets to run,984 // interval between idle() calls, the event loop never gets to run,
980 // and touch events get delayed.985 // and touch events get delayed.
981 sendPostedEvents(NULL, QEvent::TouchBegin);
982 sendPostedEvents(NULL, QEvent::TouchUpdate);
983 sendPostedEvents(NULL, QEvent::TouchEnd);
984 986
985 const float BIGGEST_DELTA_TIME_SECS = 0.25f;987 const float BIGGEST_DELTA_TIME_SECS = 0.25f;
986 update(glm::clamp((float)timeSinceLastUpdate / 1000.f, 0.f, BIGGEST_DELTA_TIME_SECS));988 update(glm::clamp((float)timeSinceLastUpdate / 1000.f, 0.f, BIGGEST_DELTA_TIME_SECS));
@@ -1902,12 +1904,9 @@ void Application::update(float deltaTime) { · 915 unmodified lines
1902 if (_isTouchPressed) {1904 if (_isTouchPressed) {
1903 float TOUCH_YAW_SCALE = -50.0f;1905 float TOUCH_YAW_SCALE = -50.0f;
1904 float TOUCH_PITCH_SCALE = -50.0f;1906 float TOUCH_PITCH_SCALE = -50.0f;
1905 _myAvatar.getHead().addYaw((_touchAvgX - _lastTouchAvgX)1907 _yawFromTouch += ((_touchAvgX - _lastTouchAvgX) * TOUCH_YAW_SCALE * deltaTime);
1906 * TOUCH_YAW_SCALE1908 _pitchFromTouch += ((_touchAvgY - _lastTouchAvgY) * TOUCH_PITCH_SCALE * deltaTime);
1907 * deltaTime);1909
1908 _myAvatar.getHead().addPitch((_touchAvgY - _lastTouchAvgY)
1909 * TOUCH_PITCH_SCALE
1910 * deltaTime);
1911 _lastTouchAvgX = _touchAvgX;1910 _lastTouchAvgX = _touchAvgX;
1912 _lastTouchAvgY = _touchAvgY;1911 _lastTouchAvgY = _touchAvgY;
1913 }1912 }
@@ -2015,7 +2014,9 @@ void Application::updateAvatar(float deltaTime) { · 101 unmodified lines
2015 _myAvatar.updateFromGyrosAndOrWebcam(_gyroLook->isChecked(),2014 _myAvatar.updateFromGyrosAndOrWebcam(_gyroLook->isChecked(),
2016 glm::vec3(_headCameraPitchYawScale,2015 glm::vec3(_headCameraPitchYawScale,
2017 _headCameraPitchYawScale,2016 _headCameraPitchYawScale,
2018 _headCameraPitchYawScale));2017 _headCameraPitchYawScale),
2018 _yawFromTouch,
2019 _pitchFromTouch);
2019 2020
2020 if (_serialHeadSensor.isActive()) {2021 if (_serialHeadSensor.isActive()) {
2021 2022

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t