Showing the changes to interface/src/Application.cpp (1 of 14 files). Show all
Unified · Split
| @@ -82,7 +82,6 @@ const int STARTUP_JITTER_SAMPLES = PACKET_LENGTH_SAMPLES_PER_CHANNEL / 2; · 81 unmodified lines | ||
| 82 | 82 | // Startup optimistically with small jitter buffer that |
| 83 | 83 | // will start playback on the second received audio packet. |
| 84 | 84 | |
| 85 | −static const float CLIPBOARD_TREE_SCALE = 1.0f; | |
| 86 | 85 | |
| 87 | 86 | void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString &message) { |
| 88 | 87 | fprintf(stdout, "%s", message.toLocal8Bit().constData()); |
| @@ -97,7 +96,6 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 8 unmodified lines | ||
| 97 | 96 | _frameCount(0), |
| 98 | 97 | _fps(120.0f), |
| 99 | 98 | _justStarted(true), |
| 100 | − _clipboard(CLIPBOARD_TREE_SCALE), | |
| 101 | 99 | _voxelImporter(_window), |
| 102 | 100 | _wantToKillLocalVoxels(false), |
| 103 | 101 | _audioScope(256, 200, true), |
| @@ -238,6 +236,8 @@ Application::~Application() { · 134 unmodified lines | ||
| 238 | 236 | NodeList::getInstance()->removeHook(&_voxels); |
| 239 | 237 | NodeList::getInstance()->removeHook(this); |
| 240 | 238 | |
| 239 | + _sharedVoxelSystem.changeTree(new VoxelTree); | |
| 240 | + | |
| 241 | 241 | delete Menu::getInstance(); |
| 242 | 242 | |
| 243 | 243 | delete _oculusProgram; |
| @@ -1215,15 +1215,6 @@ void Application::exportVoxels() { · 971 unmodified lines | ||
| 1215 | 1215 | void Application::importVoxels() { |
| 1216 | 1216 | if (_voxelImporter.exec()) { |
| 1217 | 1217 | qDebug("[DEBUG] Import succedded.\n"); |
| 1218 | − | |
| 1219 | − if (_voxelImporter.getImportIntoClipboard()) { | |
| 1220 | − _clipboard.killLocalVoxels(); | |
| 1221 | − _voxelImporter.getVoxelSystem()->copySubTreeIntoNewTree( | |
| 1222 | − _voxelImporter.getVoxelSystem()->getVoxelAt(0, 0, 0, 1), | |
| 1223 | − &_clipboard, | |
| 1224 | − true); | |
| 1225 | − _voxelImporter.reset(); | |
| 1226 | − } | |
| 1227 | 1218 | } else { |
| 1228 | 1219 | qDebug("[DEBUG] Import failed.\n"); |
| 1229 | 1220 | } |
| @@ -1238,13 +1229,17 @@ void Application::cutVoxels() { · 8 unmodified lines | ||
| 1238 | 1229 | } |
| 1239 | 1230 | |
| 1240 | 1231 | void Application::copyVoxels() { |
| 1232 | + // switch to and clear the clipboard first... | |
| 1233 | + _sharedVoxelSystem.killLocalVoxels(); | |
| 1234 | + if (_sharedVoxelSystem.getTree() != &_clipboard) { | |
| 1235 | + _clipboard.eraseAllVoxels(); | |
| 1236 | + _sharedVoxelSystem.changeTree(&_clipboard); | |
| 1237 | + } | |
| 1238 | + | |
| 1239 | + // then copy onto it if there is something to copy | |
| 1241 | 1240 | VoxelNode* selectedNode = _voxels.getVoxelAt(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z, _mouseVoxel.s); |
| 1242 | 1241 | if (selectedNode) { |
| 1243 | − // clear the clipboard first... | |
| 1244 | − _clipboard.killLocalVoxels(); | |
| 1245 | − | |
| 1246 | − // then copy onto it | |
| 1247 | − _voxels.copySubTreeIntoNewTree(selectedNode, &_clipboard, true); | |
| 1242 | + _voxels.copySubTreeIntoNewTree(selectedNode, &_sharedVoxelSystem, true); | |
| 1248 | 1243 | } |
| 1249 | 1244 | } |
| 1250 | 1245 | |
| @@ -1265,12 +1260,13 @@ void Application::pasteVoxels() { · 14 unmodified lines | ||
| 1265 | 1260 | args.newBaseOctCode = calculatedOctCode = pointToVoxel(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z, _mouseVoxel.s); |
| 1266 | 1261 | } |
| 1267 | 1262 | |
| 1268 | − if (_voxelImporter.getImportWaiting()) { | |
| 1269 | − _voxelImporter.getVoxelSystem()->recurseTreeWithOperation(sendVoxelsOperation, &args); | |
| 1270 | − _voxelImporter.reset(); | |
| 1271 | − } else { | |
| 1272 | − _clipboard.recurseTreeWithOperation(sendVoxelsOperation, &args); | |
| 1263 | + _sharedVoxelSystem.getTree()->recurseTreeWithOperation(sendVoxelsOperation, &args); | |
| 1264 | + | |
| 1265 | + if (_sharedVoxelSystem.getTree() != &_clipboard) { | |
| 1266 | + _sharedVoxelSystem.killLocalVoxels(); | |
| 1267 | + _sharedVoxelSystem.changeTree(&_clipboard); | |
| 1273 | 1268 | } |
| 1269 | + | |
| 1274 | 1270 | _voxelEditSender.flushQueue(); |
| 1275 | 1271 | |
| 1276 | 1272 | if (calculatedOctCode) { |
| @@ -1312,10 +1308,21 @@ void Application::initDisplay() { · 35 unmodified lines | ||
| 1312 | 1308 | |
| 1313 | 1309 | void Application::init() { |
| 1314 | 1310 | _voxels.init(); |
| 1315 | − _clipboard.init(); | |
| 1316 | − _clipboardViewFrustum.setKeyholeRadius(1000.0f); | |
| 1317 | − _clipboardViewFrustum.calculate(); | |
| 1318 | − _clipboard.setViewFrustum(&_clipboardViewFrustum); | |
| 1311 | + _sharedVoxelSystemViewFrustum.setPosition(glm::vec3(TREE_SCALE / 2.0f, | |
| 1312 | + TREE_SCALE / 2.0f, | |
| 1313 | + 3.0f * TREE_SCALE / 2.0f)); | |
| 1314 | + _sharedVoxelSystemViewFrustum.setNearClip(TREE_SCALE / 2.0f); | |
| 1315 | + _sharedVoxelSystemViewFrustum.setFarClip(3.0f * TREE_SCALE / 2.0f); | |
| 1316 | + _sharedVoxelSystemViewFrustum.setFieldOfView(90); | |
| 1317 | + _sharedVoxelSystemViewFrustum.setOrientation(glm::quat()); | |
| 1318 | + _sharedVoxelSystemViewFrustum.calculate(); | |
| 1319 | + _sharedVoxelSystem.setViewFrustum(&_sharedVoxelSystemViewFrustum); | |
| 1320 | + _sharedVoxelSystem.init(); | |
| 1321 | + VoxelTree* tmpTree = _sharedVoxelSystem.getTree(); | |
| 1322 | + _sharedVoxelSystem.changeTree(&_clipboard); | |
| 1323 | + delete tmpTree; | |
| 1324 | + | |
| 1325 | + _voxelImporter.init(); | |
| 1319 | 1326 | |
| 1320 | 1327 | _environment.init(); |
| 1321 | 1328 | |
| @@ -1326,6 +1333,7 @@ void Application::init() { · 4 unmodified lines | ||
| 1326 | 1333 | |
| 1327 | 1334 | _headMouseX = _mouseX = _glWidget->width() / 2; |
| 1328 | 1335 | _headMouseY = _mouseY = _glWidget->height() / 2; |
| 1336 | + QCursor::setPos(_headMouseX, _headMouseY); | |
| 1329 | 1337 | |
| 1330 | 1338 | _myAvatar.init(); |
| 1331 | 1339 | _myAvatar.setPosition(START_LOCATION); |
| @@ -1333,7 +1341,6 @@ void Application::init() { · 1 unmodified line | ||
| 1333 | 1341 | _myCamera.setModeShiftRate(1.0f); |
| 1334 | 1342 | _myAvatar.setDisplayingLookatVectors(false); |
| 1335 | 1343 | |
| 1336 | − QCursor::setPos(_headMouseX, _headMouseY); | |
| 1337 | 1344 | |
| 1338 | 1345 | OculusManager::connect(); |
| 1339 | 1346 | if (OculusManager::isConnected()) { |
| @@ -2233,15 +2240,11 @@ void Application::displaySide(Camera& whichCamera) { · 893 unmodified lines | ||
| 2233 | 2240 | glTranslatef(_mouseVoxel.x * TREE_SCALE, |
| 2234 | 2241 | _mouseVoxel.y * TREE_SCALE, |
| 2235 | 2242 | _mouseVoxel.z * TREE_SCALE); |
| 2236 | − glScalef(_mouseVoxel.s * TREE_SCALE, | |
| 2237 | − _mouseVoxel.s * TREE_SCALE, | |
| 2238 | − _mouseVoxel.s * TREE_SCALE); | |
| 2243 | + glScalef(_mouseVoxel.s, | |
| 2244 | + _mouseVoxel.s, | |
| 2245 | + _mouseVoxel.s); | |
| 2239 | 2246 | |
| 2240 | − if (_voxelImporter.getImportWaiting()) { | |
| 2241 | − _voxelImporter.getVoxelSystem()->render(true); | |
| 2242 | − } else { | |
| 2243 | − _clipboard.render(true); | |
| 2244 | − } | |
| 2247 | + _sharedVoxelSystem.render(true); | |
| 2245 | 2248 | glPopMatrix(); |
| 2246 | 2249 | } |
| 2247 | 2250 | |