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
183183 _touchAvgX(0.0f),
184184 _touchAvgY(0.0f),
185185 _isTouchPressed(false),
186+ _yawFromTouch(0.0f),
187+ _pitchFromTouch(0.0f),
186188 _mousePressed(false),
187189 _mouseVoxelScale(1.0f / 1024.0f),
188190 _justEditedVoxel(false),
@@ -969,6 +971,9 @@ void Application::idle() { · 780 unmodified lines
969971 gettimeofday(&check, NULL);
970972
971973 // 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);
972977
973978 double timeSinceLastUpdate = diffclock(&_lastTimeUpdated, &check);
974979 if (timeSinceLastUpdate > IDLE_SIMULATE_MSECS) {
@@ -978,9 +983,6 @@ void Application::idle() { · 3 unmodified lines
978983 // This is necessary because id the idle() call takes longer than the
979984 // interval between idle() calls, the event loop never gets to run,
980985 // and touch events get delayed.
981− sendPostedEvents(NULL, QEvent::TouchBegin);
982− sendPostedEvents(NULL, QEvent::TouchUpdate);
983− sendPostedEvents(NULL, QEvent::TouchEnd);
984986
985987 const float BIGGEST_DELTA_TIME_SECS = 0.25f;
986988 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
19021904 if (_isTouchPressed) {
19031905 float TOUCH_YAW_SCALE = -50.0f;
19041906 float TOUCH_PITCH_SCALE = -50.0f;
1905− _myAvatar.getHead().addYaw((_touchAvgX - _lastTouchAvgX)
1906− * TOUCH_YAW_SCALE
1907− * deltaTime);
1908− _myAvatar.getHead().addPitch((_touchAvgY - _lastTouchAvgY)
1909− * TOUCH_PITCH_SCALE
1910− * deltaTime);
1907+ _yawFromTouch += ((_touchAvgX - _lastTouchAvgX) * TOUCH_YAW_SCALE * deltaTime);
1908+ _pitchFromTouch += ((_touchAvgY - _lastTouchAvgY) * TOUCH_PITCH_SCALE * deltaTime);
1909+
19111910 _lastTouchAvgX = _touchAvgX;
19121911 _lastTouchAvgY = _touchAvgY;
19131912 }
@@ -2015,7 +2014,9 @@ void Application::updateAvatar(float deltaTime) { · 101 unmodified lines
20152014 _myAvatar.updateFromGyrosAndOrWebcam(_gyroLook->isChecked(),
20162015 glm::vec3(_headCameraPitchYawScale,
20172016 _headCameraPitchYawScale,
2018− _headCameraPitchYawScale));
2017+ _headCameraPitchYawScale),
2018+ _yawFromTouch,
2019+ _pitchFromTouch);
20192020
20202021 if (_serialHeadSensor.isActive()) {
20212022

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