History

merge

atlante45 committed 13 years ago

Commit b8c18be2 parents 5da525f f0bb42a14 files · +192 −151Browse files

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

Unified · Split

interface/src/Application.cpp+37−34
@@ -82,7 +82,6 @@ const int STARTUP_JITTER_SAMPLES = PACKET_LENGTH_SAMPLES_PER_CHANNEL / 2; · 81 unmodified lines
8282 // Startup optimistically with small jitter buffer that
8383 // will start playback on the second received audio packet.
8484
85−static const float CLIPBOARD_TREE_SCALE = 1.0f;
8685
8786 void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString &message) {
8887 fprintf(stdout, "%s", message.toLocal8Bit().constData());
@@ -97,7 +96,6 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 8 unmodified lines
9796 _frameCount(0),
9897 _fps(120.0f),
9998 _justStarted(true),
100− _clipboard(CLIPBOARD_TREE_SCALE),
10199 _voxelImporter(_window),
102100 _wantToKillLocalVoxels(false),
103101 _audioScope(256, 200, true),
@@ -238,6 +236,8 @@ Application::~Application() { · 134 unmodified lines
238236 NodeList::getInstance()->removeHook(&_voxels);
239237 NodeList::getInstance()->removeHook(this);
240238
239+ _sharedVoxelSystem.changeTree(new VoxelTree);
240+
241241 delete Menu::getInstance();
242242
243243 delete _oculusProgram;
@@ -1215,15 +1215,6 @@ void Application::exportVoxels() { · 971 unmodified lines
12151215 void Application::importVoxels() {
12161216 if (_voxelImporter.exec()) {
12171217 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− }
12271218 } else {
12281219 qDebug("[DEBUG] Import failed.\n");
12291220 }
@@ -1238,13 +1229,17 @@ void Application::cutVoxels() { · 8 unmodified lines
12381229 }
12391230
12401231 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
12411240 VoxelNode* selectedNode = _voxels.getVoxelAt(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z, _mouseVoxel.s);
12421241 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);
12481243 }
12491244 }
12501245
@@ -1265,12 +1260,13 @@ void Application::pasteVoxels() { · 14 unmodified lines
12651260 args.newBaseOctCode = calculatedOctCode = pointToVoxel(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z, _mouseVoxel.s);
12661261 }
12671262
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);
12731268 }
1269+
12741270 _voxelEditSender.flushQueue();
12751271
12761272 if (calculatedOctCode) {
@@ -1312,10 +1308,21 @@ void Application::initDisplay() { · 35 unmodified lines
13121308
13131309 void Application::init() {
13141310 _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();
13191326
13201327 _environment.init();
13211328
@@ -1326,6 +1333,7 @@ void Application::init() { · 4 unmodified lines
13261333
13271334 _headMouseX = _mouseX = _glWidget->width() / 2;
13281335 _headMouseY = _mouseY = _glWidget->height() / 2;
1336+ QCursor::setPos(_headMouseX, _headMouseY);
13291337
13301338 _myAvatar.init();
13311339 _myAvatar.setPosition(START_LOCATION);
@@ -1333,7 +1341,6 @@ void Application::init() { · 1 unmodified line
13331341 _myCamera.setModeShiftRate(1.0f);
13341342 _myAvatar.setDisplayingLookatVectors(false);
13351343
1336− QCursor::setPos(_headMouseX, _headMouseY);
13371344
13381345 OculusManager::connect();
13391346 if (OculusManager::isConnected()) {
@@ -2233,15 +2240,11 @@ void Application::displaySide(Camera& whichCamera) { · 893 unmodified lines
22332240 glTranslatef(_mouseVoxel.x * TREE_SCALE,
22342241 _mouseVoxel.y * TREE_SCALE,
22352242 _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);
22392246
2240− if (_voxelImporter.getImportWaiting()) {
2241− _voxelImporter.getVoxelSystem()->render(true);
2242− } else {
2243− _clipboard.render(true);
2244− }
2247+ _sharedVoxelSystem.render(true);
22452248 glPopMatrix();
22462249 }
22472250

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