History

Resolve conflict

atlante45 committed 13 years ago

Commit 16647e31 parent 08b0afd8 files · +403 −61Browse files

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

Unified · Split

interface/src/Application.cpp+30−12
@@ -73,6 +73,8 @@ using namespace std; · 72 unmodified lines
7373 static char STAR_FILE[] = "https://s3-us-west-1.amazonaws.com/highfidelity/stars.txt";
7474 static char STAR_CACHE_FILE[] = "cachedStars.txt";
7575
76+static const bool TESTING_PARTICLE_SYSTEM = false;
77+
7678 static const int BANDWIDTH_METER_CLICK_MAX_DRAG_LENGTH = 6; // farther dragged clicks are ignored
7779
7880 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
183185 _touchAvgX(0.0f),
184186 _touchAvgY(0.0f),
185187 _isTouchPressed(false),
188+ _yawFromTouch(0.0f),
189+ _pitchFromTouch(0.0f),
186190 _mousePressed(false),
187191 _mouseVoxelScale(1.0f / 1024.0f),
188192 _justEditedVoxel(false),
@@ -969,6 +973,9 @@ void Application::idle() { · 780 unmodified lines
969973 gettimeofday(&check, NULL);
970974
971975 // 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);
972979
973980 double timeSinceLastUpdate = diffclock(&_lastTimeUpdated, &check);
974981 if (timeSinceLastUpdate > IDLE_SIMULATE_MSECS) {
@@ -978,9 +985,6 @@ void Application::idle() { · 3 unmodified lines
978985 // This is necessary because id the idle() call takes longer than the
979986 // interval between idle() calls, the event loop never gets to run,
980987 // and touch events get delayed.
981− sendPostedEvents(NULL, QEvent::TouchBegin);
982− sendPostedEvents(NULL, QEvent::TouchUpdate);
983− sendPostedEvents(NULL, QEvent::TouchEnd);
984988
985989 const float BIGGEST_DELTA_TIME_SECS = 0.25f;
986990 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
19021906 if (_isTouchPressed) {
19031907 float TOUCH_YAW_SCALE = -50.0f;
19041908 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+
19111912 _lastTouchAvgX = _touchAvgX;
19121913 _lastTouchAvgY = _touchAvgY;
19131914 }
@@ -2007,15 +2008,28 @@ void Application::update(float deltaTime) { · 93 unmodified lines
20072008 _audio.setLastVelocity(_myAvatar.getVelocity());
20082009 _audio.eventuallyAnalyzePing();
20092010 #endif
2011+
2012+ if (TESTING_PARTICLE_SYSTEM) {
2013+ _particleSystem.simulate(deltaTime);
2014+ }
20102015 }
20112016
20122017 void Application::updateAvatar(float deltaTime) {
20132018
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+
20142026 // Update my avatar's state from gyros and/or webcam
20152027 _myAvatar.updateFromGyrosAndOrWebcam(_gyroLook->isChecked(),
20162028 glm::vec3(_headCameraPitchYawScale,
20172029 _headCameraPitchYawScale,
2018− _headCameraPitchYawScale));
2030+ _headCameraPitchYawScale),
2031+ _yawFromTouch,
2032+ _pitchFromTouch);
20192033
20202034 if (_serialHeadSensor.isActive()) {
20212035
@@ -2055,8 +2069,8 @@ void Application::updateAvatar(float deltaTime) { · 33 unmodified lines
20552069 float yaw, pitch, roll;
20562070 OculusManager::getEulerAngles(yaw, pitch, roll);
20572071
2058− _myAvatar.getHead().setYaw(yaw);
2059− _myAvatar.getHead().setPitch(pitch);
2072+ _myAvatar.getHead().setYaw(yaw + _yawFromTouch);
2073+ _myAvatar.getHead().setPitch(pitch + _pitchFromTouch);
20602074 _myAvatar.getHead().setRoll(roll);
20612075 }
20622076
@@ -2441,6 +2455,10 @@ void Application::displaySide(Camera& whichCamera) { · 378 unmodified lines
24412455 _myAvatar.render(_lookingInMirror->isChecked(), _renderAvatarBalls->isChecked());
24422456 _myAvatar.setDisplayingLookatVectors(_renderLookatOn->isChecked());
24432457 }
2458+
2459+ if (TESTING_PARTICLE_SYSTEM) {
2460+ _particleSystem.render();
2461+ }
24442462
24452463 // Render the world box
24462464 if (!_lookingInMirror->isChecked() && _renderStatsOn->isChecked()) { render_world_box(); }

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