History

Merge branch 'master' of https://github.com/worklist/hifi into 19494

stojce committed 12 years ago

Commit 1ac583e2 parents 75ad4fd d743df925 files · +1102 −274Browse files

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

Unified · Split

interface/src/Application.cpp+16−80
@@ -137,7 +137,6 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 136 unmodified lines
137137 _isTouchPressed(false),
138138 _mousePressed(false),
139139 _isHoverVoxel(false),
140− _isHoverVoxelSounding(false),
141140 _mouseVoxelScale(1.0f / 1024.0f),
142141 _mouseVoxelScaleInitialized(false),
143142 _justEditedVoxel(false),
@@ -1216,7 +1215,7 @@ void Application::mouseMoveEvent(QMouseEvent* event) { · 1072 unmodified lines
12161215 return;
12171216 }
12181217 if (_isHoverVoxel) {
1219− _myAvatar->orbit(getMouseVoxelWorldCoordinates(_hoverVoxel), deltaX, deltaY);
1218+ //_myAvatar->orbit(getMouseVoxelWorldCoordinates(_hoverVoxel), deltaX, deltaY);
12201219 return;
12211220 }
12221221 }
@@ -1236,11 +1235,6 @@ void Application::mouseMoveEvent(QMouseEvent* event) { · 13 unmodified lines
12361235 }
12371236 }
12381237
1239−const bool MAKE_SOUND_ON_VOXEL_HOVER = false;
1240−const bool MAKE_SOUND_ON_VOXEL_CLICK = true;
1241−const float HOVER_VOXEL_FREQUENCY = 7040.f;
1242−const float HOVER_VOXEL_DECAY = 0.999f;
1243−
12441238 void Application::mousePressEvent(QMouseEvent* event) {
12451239 _controllerScriptingInterface.emitMousePressEvent(event); // send events to any registered scripts
12461240
@@ -1280,37 +1274,6 @@ void Application::mousePressEvent(QMouseEvent* event) { · 33 unmodified lines
12801274 pasteVoxels();
12811275 }
12821276
1283− if (!Menu::getInstance()->isOptionChecked(MenuOption::VoxelDeleteMode) &&
1284− MAKE_SOUND_ON_VOXEL_CLICK && _isHoverVoxel && !_isHoverVoxelSounding) {
1285− _hoverVoxelOriginalColor[0] = _hoverVoxel.red;
1286− _hoverVoxelOriginalColor[1] = _hoverVoxel.green;
1287− _hoverVoxelOriginalColor[2] = _hoverVoxel.blue;
1288− _hoverVoxelOriginalColor[3] = 1;
1289− const float RED_CLICK_FREQUENCY = 1000.f;
1290− const float GREEN_CLICK_FREQUENCY = 1250.f;
1291− const float BLUE_CLICK_FREQUENCY = 1330.f;
1292− const float MIDDLE_A_FREQUENCY = 440.f;
1293− float frequency = MIDDLE_A_FREQUENCY +
1294− (_hoverVoxel.red / 255.f * RED_CLICK_FREQUENCY +
1295− _hoverVoxel.green / 255.f * GREEN_CLICK_FREQUENCY +
1296− _hoverVoxel.blue / 255.f * BLUE_CLICK_FREQUENCY) / 3.f;
1297−
1298− _audio.startCollisionSound(1.0, frequency, 0.0, HOVER_VOXEL_DECAY, false);
1299− _isHoverVoxelSounding = true;
1300−
1301− const float PERCENTAGE_TO_MOVE_TOWARD = 0.90f;
1302− glm::vec3 newTarget = getMouseVoxelWorldCoordinates(_hoverVoxel);
1303− glm::vec3 myPosition = _myAvatar->getPosition();
1304−
1305− // If there is not an action tool set (add, delete, color), move to this voxel
1306− if (Menu::getInstance()->isOptionChecked(MenuOption::ClickToFly) &&
1307− !(Menu::getInstance()->isOptionChecked(MenuOption::VoxelAddMode) ||
1308− Menu::getInstance()->isOptionChecked(MenuOption::VoxelDeleteMode) ||
1309− Menu::getInstance()->isOptionChecked(MenuOption::VoxelColorMode))) {
1310− _myAvatar->setMoveTarget(myPosition + (newTarget - myPosition) * PERCENTAGE_TO_MOVE_TOWARD);
1311− }
1312− }
1313−
13141277 } else if (event->button() == Qt::RightButton && Menu::getInstance()->isVoxelModeActionChecked()) {
13151278 deleteVoxelUnderCursor();
13161279 }
@@ -1341,7 +1304,9 @@ void Application::mouseReleaseEvent(QMouseEvent* event) { · 24 unmodified lines
13411304 }
13421305
13431306 void Application::touchUpdateEvent(QTouchEvent* event) {
1344− _controllerScriptingInterface.emitTouchUpdateEvent(event); // send events to any registered scripts
1307+ TouchEvent thisEvent(*event, _lastTouchEvent);
1308+ _controllerScriptingInterface.emitTouchUpdateEvent(thisEvent); // send events to any registered scripts
1309+ _lastTouchEvent = thisEvent;
13451310
13461311 // if one of our scripts have asked to capture this event, then stop processing it
13471312 if (_controllerScriptingInterface.isTouchCaptured()) {
@@ -1372,8 +1337,10 @@ void Application::touchUpdateEvent(QTouchEvent* event) { · 24 unmodified lines
13721337 }
13731338
13741339 void Application::touchBeginEvent(QTouchEvent* event) {
1375− _controllerScriptingInterface.emitTouchBeginEvent(event); // send events to any registered scripts
1340+ TouchEvent thisEvent(*event); // on touch begin, we don't compare to last event
1341+ _controllerScriptingInterface.emitTouchBeginEvent(thisEvent); // send events to any registered scripts
13761342
1343+ _lastTouchEvent = thisEvent; // and we reset our last event to this event before we call our update
13771344 touchUpdateEvent(event);
13781345
13791346 // if one of our scripts have asked to capture this event, then stop processing it
@@ -1388,7 +1355,9 @@ void Application::touchBeginEvent(QTouchEvent* event) { · 8 unmodified lines
13881355 }
13891356
13901357 void Application::touchEndEvent(QTouchEvent* event) {
1391− _controllerScriptingInterface.emitTouchEndEvent(event); // send events to any registered scripts
1358+ TouchEvent thisEvent(*event, _lastTouchEvent);
1359+ _controllerScriptingInterface.emitTouchEndEvent(thisEvent); // send events to any registered scripts
1360+ _lastTouchEvent = thisEvent;
13921361
13931362 // if one of our scripts have asked to capture this event, then stop processing it
13941363 if (_controllerScriptingInterface.isTouchCaptured()) {
@@ -1875,6 +1844,9 @@ void Application::init() { · 480 unmodified lines
18751844 _audio.setJitterBufferSamples(Menu::getInstance()->getAudioJitterBufferSamples());
18761845 }
18771846 qDebug("Loaded settings");
1847+
1848+ // fire off an immediate domain-server check in now that settings are loaded
1849+ NodeList::getInstance()->sendDomainServerCheckIn();
18781850
18791851 // Set up VoxelSystem after loading preferences so we can get the desired max voxel count
18801852 _voxels.setMaxVoxels(Menu::getInstance()->getMaxVoxels());
@@ -2056,45 +2028,9 @@ void Application::updateHoverVoxels(float deltaTime, float& distance, BoxFace& f · 175 unmodified lines
20562028 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
20572029 PerformanceWarning warn(showWarnings, "Application::updateHoverVoxels()");
20582030
2059− // If we have clicked on a voxel, update it's color
2060− if (_isHoverVoxelSounding) {
2061− VoxelTreeElement* hoveredNode = _voxels.getVoxelAt(_hoverVoxel.x, _hoverVoxel.y, _hoverVoxel.z, _hoverVoxel.s);
2062− if (hoveredNode) {
2063− float bright = _audio.getCollisionSoundMagnitude();
2064− nodeColor clickColor = { 255 * bright + _hoverVoxelOriginalColor[0] * (1.f - bright),
2065− _hoverVoxelOriginalColor[1] * (1.f - bright),
2066− _hoverVoxelOriginalColor[2] * (1.f - bright), 1 };
2067− hoveredNode->setColor(clickColor);
2068− if (bright < 0.01f) {
2069− hoveredNode->setColor(_hoverVoxelOriginalColor);
2070− _isHoverVoxelSounding = false;
2071− }
2072− } else {
2073− // Voxel is not found, clear all
2074− _isHoverVoxelSounding = false;
2075− _isHoverVoxel = false;
2076− }
2077− } else {
2078− // Check for a new hover voxel
2079− glm::vec4 oldVoxel(_hoverVoxel.x, _hoverVoxel.y, _hoverVoxel.z, _hoverVoxel.s);
2080− // only do this work if MAKE_SOUND_ON_VOXEL_HOVER or MAKE_SOUND_ON_VOXEL_CLICK is enabled,
2081− // and make sure the tree is not already busy... because otherwise you'll have to wait.
2082− if (!_mousePressed) {
2083− {
2084− PerformanceWarning warn(showWarnings, "Application::updateHoverVoxels() _voxels.findRayIntersection()");
2085− _isHoverVoxel = _voxels.findRayIntersection(_mouseRayOrigin, _mouseRayDirection, _hoverVoxel, distance, face);
2086− }
2087− if (MAKE_SOUND_ON_VOXEL_HOVER && _isHoverVoxel &&
2088− glm::vec4(_hoverVoxel.x, _hoverVoxel.y, _hoverVoxel.z, _hoverVoxel.s) != oldVoxel) {
2089−
2090− _hoverVoxelOriginalColor[0] = _hoverVoxel.red;
2091− _hoverVoxelOriginalColor[1] = _hoverVoxel.green;
2092− _hoverVoxelOriginalColor[2] = _hoverVoxel.blue;
2093− _hoverVoxelOriginalColor[3] = 1;
2094− _audio.startCollisionSound(1.0, HOVER_VOXEL_FREQUENCY * _hoverVoxel.s * TREE_SCALE, 0.0, HOVER_VOXEL_DECAY, false);
2095− _isHoverVoxelSounding = true;
2096− }
2097− }
2031+ if (!_mousePressed) {
2032+ PerformanceWarning warn(showWarnings, "Application::updateHoverVoxels() _voxels.findRayIntersection()");
2033+ _isHoverVoxel = _voxels.findRayIntersection(_mouseRayOrigin, _mouseRayDirection, _hoverVoxel, distance, face);
20982034 }
20992035 }
21002036

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