Showing the changes to interface/src/Application.cpp (1 of 8 files). Show all
Unified · Split
| @@ -73,6 +73,8 @@ using namespace std; · 72 unmodified lines | ||
| 73 | 73 | static char STAR_FILE[] = "https://s3-us-west-1.amazonaws.com/highfidelity/stars.txt"; |
| 74 | 74 | static char STAR_CACHE_FILE[] = "cachedStars.txt"; |
| 75 | 75 | |
| 76 | +static const bool TESTING_PARTICLE_SYSTEM = false; | |
| 77 | + | |
| 76 | 78 | static const int BANDWIDTH_METER_CLICK_MAX_DRAG_LENGTH = 6; // farther dragged clicks are ignored |
| 77 | 79 | |
| 78 | 80 | const glm::vec3 START_LOCATION(4.f, 0.f, 5.f); // Where one's own node begins in the world |
| @@ -183,6 +185,8 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 104 unmodified lines | ||
| 183 | 185 | _touchAvgX(0.0f), |
| 184 | 186 | _touchAvgY(0.0f), |
| 185 | 187 | _isTouchPressed(false), |
| 188 | + _yawFromTouch(0.0f), | |
| 189 | + _pitchFromTouch(0.0f), | |
| 186 | 190 | _mousePressed(false), |
| 187 | 191 | _mouseVoxelScale(1.0f / 1024.0f), |
| 188 | 192 | _justEditedVoxel(false), |
| @@ -969,6 +973,9 @@ void Application::idle() { · 780 unmodified lines | ||
| 969 | 973 | gettimeofday(&check, NULL); |
| 970 | 974 | |
| 971 | 975 | // Only run simulation code if more than IDLE_SIMULATE_MSECS have passed since last time we ran |
| 976 | + sendPostedEvents(NULL, QEvent::TouchBegin); | |
| 977 | + sendPostedEvents(NULL, QEvent::TouchUpdate); | |
| 978 | + sendPostedEvents(NULL, QEvent::TouchEnd); | |
| 972 | 979 | |
| 973 | 980 | double timeSinceLastUpdate = diffclock(&_lastTimeUpdated, &check); |
| 974 | 981 | if (timeSinceLastUpdate > IDLE_SIMULATE_MSECS) { |
| @@ -978,9 +985,6 @@ void Application::idle() { · 3 unmodified lines | ||
| 978 | 985 | // This is necessary because id the idle() call takes longer than the |
| 979 | 986 | // interval between idle() calls, the event loop never gets to run, |
| 980 | 987 | // and touch events get delayed. |
| 981 | − sendPostedEvents(NULL, QEvent::TouchBegin); | |
| 982 | − sendPostedEvents(NULL, QEvent::TouchUpdate); | |
| 983 | − sendPostedEvents(NULL, QEvent::TouchEnd); | |
| 984 | 988 | |
| 985 | 989 | const float BIGGEST_DELTA_TIME_SECS = 0.25f; |
| 986 | 990 | update(glm::clamp((float)timeSinceLastUpdate / 1000.f, 0.f, BIGGEST_DELTA_TIME_SECS)); |
| @@ -1902,12 +1906,9 @@ void Application::update(float deltaTime) { · 915 unmodified lines | ||
| 1902 | 1906 | if (_isTouchPressed) { |
| 1903 | 1907 | float TOUCH_YAW_SCALE = -50.0f; |
| 1904 | 1908 | 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); | |
| 1909 | + _yawFromTouch += ((_touchAvgX - _lastTouchAvgX) * TOUCH_YAW_SCALE * deltaTime); | |
| 1910 | + _pitchFromTouch += ((_touchAvgY - _lastTouchAvgY) * TOUCH_PITCH_SCALE * deltaTime); | |
| 1911 | + | |
| 1911 | 1912 | _lastTouchAvgX = _touchAvgX; |
| 1912 | 1913 | _lastTouchAvgY = _touchAvgY; |
| 1913 | 1914 | } |
| @@ -2007,15 +2008,28 @@ void Application::update(float deltaTime) { · 93 unmodified lines | ||
| 2007 | 2008 | _audio.setLastVelocity(_myAvatar.getVelocity()); |
| 2008 | 2009 | _audio.eventuallyAnalyzePing(); |
| 2009 | 2010 | #endif |
| 2011 | + | |
| 2012 | + if (TESTING_PARTICLE_SYSTEM) { | |
| 2013 | + _particleSystem.simulate(deltaTime); | |
| 2014 | + } | |
| 2010 | 2015 | } |
| 2011 | 2016 | |
| 2012 | 2017 | void Application::updateAvatar(float deltaTime) { |
| 2013 | 2018 | |
| 2019 | + // When head is rotated via touch/mouse look, slowly turn body to follow | |
| 2020 | + const float BODY_FOLLOW_HEAD_RATE = 0.5f; | |
| 2021 | + // update body yaw by body yaw delta | |
| 2022 | + _myAvatar.setOrientation(_myAvatar.getOrientation() | |
| 2023 | + * glm::quat(glm::vec3(0, _yawFromTouch * deltaTime * BODY_FOLLOW_HEAD_RATE, 0) * deltaTime)); | |
| 2024 | + _yawFromTouch -= _yawFromTouch * deltaTime * BODY_FOLLOW_HEAD_RATE; | |
| 2025 | + | |
| 2014 | 2026 | // Update my avatar's state from gyros and/or webcam |
| 2015 | 2027 | _myAvatar.updateFromGyrosAndOrWebcam(_gyroLook->isChecked(), |
| 2016 | 2028 | glm::vec3(_headCameraPitchYawScale, |
| 2017 | 2029 | _headCameraPitchYawScale, |
| 2018 | − _headCameraPitchYawScale)); | |
| 2030 | + _headCameraPitchYawScale), | |
| 2031 | + _yawFromTouch, | |
| 2032 | + _pitchFromTouch); | |
| 2019 | 2033 | |
| 2020 | 2034 | if (_serialHeadSensor.isActive()) { |
| 2021 | 2035 | |
| @@ -2055,8 +2069,8 @@ void Application::updateAvatar(float deltaTime) { · 33 unmodified lines | ||
| 2055 | 2069 | float yaw, pitch, roll; |
| 2056 | 2070 | OculusManager::getEulerAngles(yaw, pitch, roll); |
| 2057 | 2071 | |
| 2058 | − _myAvatar.getHead().setYaw(yaw); | |
| 2059 | − _myAvatar.getHead().setPitch(pitch); | |
| 2072 | + _myAvatar.getHead().setYaw(yaw + _yawFromTouch); | |
| 2073 | + _myAvatar.getHead().setPitch(pitch + _pitchFromTouch); | |
| 2060 | 2074 | _myAvatar.getHead().setRoll(roll); |
| 2061 | 2075 | } |
| 2062 | 2076 | |
| @@ -2441,6 +2455,10 @@ void Application::displaySide(Camera& whichCamera) { · 378 unmodified lines | ||
| 2441 | 2455 | _myAvatar.render(_lookingInMirror->isChecked(), _renderAvatarBalls->isChecked()); |
| 2442 | 2456 | _myAvatar.setDisplayingLookatVectors(_renderLookatOn->isChecked()); |
| 2443 | 2457 | } |
| 2458 | + | |
| 2459 | + if (TESTING_PARTICLE_SYSTEM) { | |
| 2460 | + _particleSystem.render(); | |
| 2461 | + } | |
| 2444 | 2462 | |
| 2445 | 2463 | // Render the world box |
| 2446 | 2464 | if (!_lookingInMirror->isChecked() && _renderStatsOn->isChecked()) { render_world_box(); } |