Showing the changes to interface/src/Application.cpp (1 of 25 files). Show all
Unified · Split
| @@ -137,7 +137,6 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 136 unmodified lines | ||
| 137 | 137 | _isTouchPressed(false), |
| 138 | 138 | _mousePressed(false), |
| 139 | 139 | _isHoverVoxel(false), |
| 140 | − _isHoverVoxelSounding(false), | |
| 141 | 140 | _mouseVoxelScale(1.0f / 1024.0f), |
| 142 | 141 | _mouseVoxelScaleInitialized(false), |
| 143 | 142 | _justEditedVoxel(false), |
| @@ -1216,7 +1215,7 @@ void Application::mouseMoveEvent(QMouseEvent* event) { · 1072 unmodified lines | ||
| 1216 | 1215 | return; |
| 1217 | 1216 | } |
| 1218 | 1217 | if (_isHoverVoxel) { |
| 1219 | − _myAvatar->orbit(getMouseVoxelWorldCoordinates(_hoverVoxel), deltaX, deltaY); | |
| 1218 | + //_myAvatar->orbit(getMouseVoxelWorldCoordinates(_hoverVoxel), deltaX, deltaY); | |
| 1220 | 1219 | return; |
| 1221 | 1220 | } |
| 1222 | 1221 | } |
| @@ -1236,11 +1235,6 @@ void Application::mouseMoveEvent(QMouseEvent* event) { · 13 unmodified lines | ||
| 1236 | 1235 | } |
| 1237 | 1236 | } |
| 1238 | 1237 | |
| 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 | − | |
| 1244 | 1238 | void Application::mousePressEvent(QMouseEvent* event) { |
| 1245 | 1239 | _controllerScriptingInterface.emitMousePressEvent(event); // send events to any registered scripts |
| 1246 | 1240 | |
| @@ -1280,37 +1274,6 @@ void Application::mousePressEvent(QMouseEvent* event) { · 33 unmodified lines | ||
| 1280 | 1274 | pasteVoxels(); |
| 1281 | 1275 | } |
| 1282 | 1276 | |
| 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 | − | |
| 1314 | 1277 | } else if (event->button() == Qt::RightButton && Menu::getInstance()->isVoxelModeActionChecked()) { |
| 1315 | 1278 | deleteVoxelUnderCursor(); |
| 1316 | 1279 | } |
| @@ -1341,7 +1304,9 @@ void Application::mouseReleaseEvent(QMouseEvent* event) { · 24 unmodified lines | ||
| 1341 | 1304 | } |
| 1342 | 1305 | |
| 1343 | 1306 | 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; | |
| 1345 | 1310 | |
| 1346 | 1311 | // if one of our scripts have asked to capture this event, then stop processing it |
| 1347 | 1312 | if (_controllerScriptingInterface.isTouchCaptured()) { |
| @@ -1372,8 +1337,10 @@ void Application::touchUpdateEvent(QTouchEvent* event) { · 24 unmodified lines | ||
| 1372 | 1337 | } |
| 1373 | 1338 | |
| 1374 | 1339 | 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 | |
| 1376 | 1342 | |
| 1343 | + _lastTouchEvent = thisEvent; // and we reset our last event to this event before we call our update | |
| 1377 | 1344 | touchUpdateEvent(event); |
| 1378 | 1345 | |
| 1379 | 1346 | // 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 | ||
| 1388 | 1355 | } |
| 1389 | 1356 | |
| 1390 | 1357 | 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; | |
| 1392 | 1361 | |
| 1393 | 1362 | // if one of our scripts have asked to capture this event, then stop processing it |
| 1394 | 1363 | if (_controllerScriptingInterface.isTouchCaptured()) { |
| @@ -1875,6 +1844,9 @@ void Application::init() { · 480 unmodified lines | ||
| 1875 | 1844 | _audio.setJitterBufferSamples(Menu::getInstance()->getAudioJitterBufferSamples()); |
| 1876 | 1845 | } |
| 1877 | 1846 | qDebug("Loaded settings"); |
| 1847 | + | |
| 1848 | + // fire off an immediate domain-server check in now that settings are loaded | |
| 1849 | + NodeList::getInstance()->sendDomainServerCheckIn(); | |
| 1878 | 1850 | |
| 1879 | 1851 | // Set up VoxelSystem after loading preferences so we can get the desired max voxel count |
| 1880 | 1852 | _voxels.setMaxVoxels(Menu::getInstance()->getMaxVoxels()); |
| @@ -2056,45 +2028,9 @@ void Application::updateHoverVoxels(float deltaTime, float& distance, BoxFace& f · 175 unmodified lines | ||
| 2056 | 2028 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 2057 | 2029 | PerformanceWarning warn(showWarnings, "Application::updateHoverVoxels()"); |
| 2058 | 2030 | |
| 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); | |
| 2098 | 2034 | } |
| 2099 | 2035 | } |
| 2100 | 2036 | |