History

Merge branch 'master' of https://github.com/highfidelity/hifi into local_voxels

Atlante45 committed 12 years ago

Commit f1ce0342 parents ef9ff0f 5c0ec0f140 files · +1208 −1986Browse files

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

Unified · Split

interface/src/Application.cpp+18−180
@@ -140,8 +140,6 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 139 unmodified lines
140140 _touchAvgY(0.0f),
141141 _isTouchPressed(false),
142142 _mousePressed(false),
143− _isHoverVoxel(false),
144− _isHighlightVoxel(false),
145143 _chatEntryOn(false),
146144 _audio(&_audioScope, STARTUP_JITTER_SAMPLES),
147145 _enableProcessVoxelsThread(true),
@@ -364,6 +362,8 @@ Application::~Application() { · 216 unmodified lines
364362 _myAvatar = NULL;
365363
366364 delete _glWidget;
365+
366+ AccountManager::getInstance().destroy();
367367 }
368368
369369 void Application::restoreSizeAndPosition() {
@@ -746,9 +746,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 376 unmodified lines
746746 break;
747747
748748 case Qt::Key_S:
749− if (isShifted && !isMeta) {
750− _voxels.collectStatsForTreesAndVBOs();
751− } else if (isShifted && isMeta) {
749+ if (isShifted && isMeta) {
752750 Menu::getInstance()->triggerOption(MenuOption::SuppressShortTimings);
753751 } else if (!isShifted && isMeta) {
754752 takeSnapshot();
@@ -1035,11 +1033,6 @@ void Application::mousePressEvent(QMouseEvent* event) { · 280 unmodified lines
10351033 return;
10361034 }
10371035
1038− if (!_isHoverVoxel || _myAvatar->getLookAtTargetAvatar()) {
1039− // disable for now
1040− // _pieMenu.mousePressEvent(_mouseX, _mouseY);
1041− }
1042−
10431036 } else if (event->button() == Qt::RightButton) {
10441037 // right click items here
10451038 }
@@ -1159,7 +1152,7 @@ void Application::dropEvent(QDropEvent *event) { · 113 unmodified lines
11591152 }
11601153
11611154 SnapshotMetaData* snapshotData = Snapshot::parseSnapshotData(snapshotPath);
1162− if (snapshotData != NULL) {
1155+ if (snapshotData) {
11631156 if (!snapshotData->getDomain().isEmpty()) {
11641157 Menu::getInstance()->goToDomain(snapshotData->getDomain());
11651158 }
@@ -1294,7 +1287,7 @@ void Application::removeVoxel(glm::vec3 position, · 128 unmodified lines
12941287 _voxelEditSender.sendVoxelEditMessage(PacketTypeVoxelErase, voxel);
12951288
12961289 // delete it locally to see the effect immediately (and in case no voxel server is present)
1297− _voxels.deleteVoxelAt(voxel.x, voxel.y, voxel.z, voxel.s);
1290+ _voxels.getTree()->deleteVoxelAt(voxel.x, voxel.y, voxel.z, voxel.s);
12981291 }
12991292
13001293
@@ -1316,8 +1309,7 @@ void Application::makeVoxel(glm::vec3 position, · 15 unmodified lines
13161309 _voxelEditSender.sendVoxelEditMessage(message, voxel);
13171310
13181311 // create the voxel locally so it appears immediately
1319−
1320− _voxels.createVoxel(voxel.x, voxel.y, voxel.z, voxel.s,
1312+ _voxels.getTree()->createVoxel(voxel.x, voxel.y, voxel.z, voxel.s,
13211313 voxel.red, voxel.green, voxel.blue,
13221314 isDestructive);
13231315 }
@@ -1376,10 +1368,11 @@ void Application::exportVoxels(const VoxelDetail& sourceVoxel) { · 52 unmodified lines
13761368 tr("Sparse Voxel Octree Files (*.svo)"));
13771369 QByteArray fileNameAscii = fileNameString.toLocal8Bit();
13781370 const char* fileName = fileNameAscii.data();
1379− VoxelTreeElement* selectedNode = _voxels.getVoxelAt(sourceVoxel.x, sourceVoxel.y, sourceVoxel.z, sourceVoxel.s);
1371+
1372+ VoxelTreeElement* selectedNode = _voxels.getTree()->getVoxelAt(sourceVoxel.x, sourceVoxel.y, sourceVoxel.z, sourceVoxel.s);
13801373 if (selectedNode) {
13811374 VoxelTree exportTree;
1382− _voxels.copySubTreeIntoNewTree(selectedNode, &exportTree, true);
1375+ getVoxelTree()->copySubTreeIntoNewTree(selectedNode, &exportTree, true);
13831376 exportTree.writeToSVOFile(fileName);
13841377 }
13851378
@@ -1421,9 +1414,10 @@ void Application::copyVoxels(const VoxelDetail& sourceVoxel) { · 35 unmodified lines
14211414 }
14221415
14231416 // then copy onto it if there is something to copy
1424− VoxelTreeElement* selectedNode = _voxels.getVoxelAt(sourceVoxel.x, sourceVoxel.y, sourceVoxel.z, sourceVoxel.s);
1417+ VoxelTreeElement* selectedNode = _voxels.getTree()->getVoxelAt(sourceVoxel.x, sourceVoxel.y, sourceVoxel.z, sourceVoxel.s);
14251418 if (selectedNode) {
1426− _voxels.copySubTreeIntoNewTree(selectedNode, &_sharedVoxelSystem, true);
1419+ getVoxelTree()->copySubTreeIntoNewTree(selectedNode, _sharedVoxelSystem.getTree(), true);
1420+ _sharedVoxelSystem.forceRedrawEntireTree();
14271421 }
14281422 }
14291423
@@ -1445,7 +1439,7 @@ void Application::pasteVoxelsToOctalCode(const unsigned char* octalCodeDestinati · 15 unmodified lines
14451439
14461440 void Application::pasteVoxels(const VoxelDetail& sourceVoxel) {
14471441 unsigned char* calculatedOctCode = NULL;
1448− VoxelTreeElement* selectedNode = _voxels.getVoxelAt(sourceVoxel.x, sourceVoxel.y, sourceVoxel.z, sourceVoxel.s);
1442+ VoxelTreeElement* selectedNode = _voxels.getTree()->getVoxelAt(sourceVoxel.x, sourceVoxel.y, sourceVoxel.z, sourceVoxel.s);
14491443
14501444 // we only need the selected voxel to get the newBaseOctCode, which we can actually calculate from the
14511445 // voxel size/position details. If we don't have an actual selectedNode then use the mouseVoxel to create a
@@ -1465,7 +1459,7 @@ void Application::pasteVoxels(const VoxelDetail& sourceVoxel) { · 13 unmodified lines
14651459 }
14661460
14671461 void Application::nudgeVoxelsByVector(const VoxelDetail& sourceVoxel, const glm::vec3& nudgeVec) {
1468− VoxelTreeElement* nodeToNudge = _voxels.getVoxelAt(sourceVoxel.x, sourceVoxel.y, sourceVoxel.z, sourceVoxel.s);
1462+ VoxelTreeElement* nodeToNudge = _voxels.getTree()->getVoxelAt(sourceVoxel.x, sourceVoxel.y, sourceVoxel.z, sourceVoxel.s);
14691463 if (nodeToNudge) {
14701464 _voxels.getTree()->nudgeSubTree(nodeToNudge, nudgeVec, _voxelEditSender);
14711465 }
@@ -1623,20 +1617,6 @@ bool Application::isLookingAtMyAvatar(Avatar* avatar) { · 151 unmodified lines
16231617 return false;
16241618 }
16251619
1626−void Application::renderHighlightVoxel(VoxelDetail voxel) {
1627− glDisable(GL_LIGHTING);
1628− glPushMatrix();
1629− glScalef(TREE_SCALE, TREE_SCALE, TREE_SCALE);
1630− const float EDGE_EXPAND = 1.02f;
1631− glColor3ub(voxel.red + 128, voxel.green + 128, voxel.blue + 128);
1632− glTranslatef(voxel.x + voxel.s * 0.5f,
1633− voxel.y + voxel.s * 0.5f,
1634− voxel.z + voxel.s * 0.5f);
1635− glLineWidth(2.0f);
1636− glutWireCube(voxel.s * EDGE_EXPAND);
1637− glPopMatrix();
1638−}
1639−
16401620 void Application::updateMouseRay() {
16411621
16421622 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
@@ -1707,9 +1687,6 @@ void Application::updateMyAvatarLookAtPosition() { · 64 unmodified lines
17071687 if (_myAvatar->getLookAtTargetAvatar()) {
17081688 distance = glm::distance(_mouseRayOrigin,
17091689 static_cast<Avatar*>(_myAvatar->getLookAtTargetAvatar())->getHead()->calculateAverageEyePosition());
1710−
1711− } else if (_isHoverVoxel) {
1712− distance = glm::distance(_mouseRayOrigin, getMouseVoxelWorldCoordinates(_hoverVoxel));
17131690 }
17141691 const float FIXED_MIN_EYE_DISTANCE = 0.3f;
17151692 float minEyeDistance = FIXED_MIN_EYE_DISTANCE + (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON ? 0.0f :
@@ -1740,17 +1717,6 @@ void Application::updateMyAvatarLookAtPosition() { · 24 unmodified lines
17401717 _myAvatar->getHead()->setLookAtPosition(lookAtSpot);
17411718 }
17421719
1743−void Application::updateHoverVoxels(float deltaTime, float& distance, BoxFace& face) {
1744−
1745− bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
1746− PerformanceWarning warn(showWarnings, "Application::updateHoverVoxels()");
1747−
1748− if (!_mousePressed) {
1749− PerformanceWarning warn(showWarnings, "Application::updateHoverVoxels() _voxels.findRayIntersection()");
1750− _isHoverVoxel = _voxels.findRayIntersection(_mouseRayOrigin, _mouseRayDirection, _hoverVoxel, distance, face);
1751− }
1752−}
1753−
17541720 void Application::updateHandAndTouch(float deltaTime) {
17551721 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
17561722 PerformanceWarning warn(showWarnings, "Application::updateHandAndTouch()");
@@ -1899,11 +1865,6 @@ void Application::update(float deltaTime) { · 142 unmodified lines
18991865 _myAvatar->updateLookAtTargetAvatar();
19001866 updateMyAvatarLookAtPosition();
19011867
1902− // Find the voxel we are hovering over, and respond if clicked
1903− float distance;
1904− BoxFace face;
1905−
1906− updateHoverVoxels(deltaTime, distance, face); // clicking on voxels and making sounds
19071868 updateHandAndTouch(deltaTime); // Update state for touch sensors
19081869 updateLeap(deltaTime); // Leap finger-sensing device
19091870 updateSixense(deltaTime); // Razer Hydra controllers
@@ -1988,7 +1949,7 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType, Node · 78 unmodified lines
19881949
19891950 foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) {
19901951 // only send to the NodeTypes that are serverType
1991− if (node->getActiveSocket() != NULL && node->getType() == serverType) {
1952+ if (node->getActiveSocket() && node->getType() == serverType) {
19921953 totalServers++;
19931954
19941955 // get the server bounds for this server
@@ -2048,7 +2009,7 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType, Node · 53 unmodified lines
20482009
20492010 foreach (const SharedNodePointer& node, nodeList->getNodeHash()) {
20502011 // only send to the NodeTypes that are serverType
2051− if (node->getActiveSocket() != NULL && node->getType() == serverType) {
2012+ if (node->getActiveSocket() && node->getType() == serverType) {
20522013
20532014
20542015 // get the server bounds for this server
@@ -2410,11 +2371,6 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 355 unmodified lines
24102371
24112372 // restore default, white specular
24122373 glMaterialfv(GL_FRONT, GL_SPECULAR, WHITE_SPECULAR_COLOR);
2413−
2414− // Render the highlighted voxel
2415− if (_isHighlightVoxel) {
2416− renderHighlightVoxel(_highlightVoxel);
2417− }
24182374 }
24192375
24202376 bool forceRenderMyHead = (whichCamera.getInterpolatedMode() == CAMERA_MODE_MIRROR);
@@ -2476,7 +2432,7 @@ void Application::computeOffAxisFrustum(float& left, float& right, float& bottom · 55 unmodified lines
24762432 _viewFrustum.computeOffAxisFrustum(left, right, bottom, top, nearVal, farVal, nearClipPlane, farClipPlane);
24772433 }
24782434
2479−const float WHITE_TEXT[] = { 0.93, 0.93, 0.93 };
2435+const float WHITE_TEXT[] = { 0.93f, 0.93f, 0.93f };
24802436
24812437 void Application::displayOverlay() {
24822438 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "Application::displayOverlay()");
@@ -2525,15 +2481,6 @@ void Application::displayOverlay() { · 42 unmodified lines
25252481 }
25262482 }
25272483
2528− // testing rendering coverage map
2529− if (Menu::getInstance()->isOptionChecked(MenuOption::CoverageMapV2)) {
2530− renderCoverageMapV2();
2531− }
2532−
2533− if (Menu::getInstance()->isOptionChecked(MenuOption::CoverageMap)) {
2534− renderCoverageMap();
2535− }
2536−
25372484 // Show chat entry field
25382485 if (_chatEntryOn) {
25392486 _chatEntry.render(_glWidget->width(), _glWidget->height());
@@ -2975,115 +2922,6 @@ glm::vec2 Application::getScaledScreenPoint(glm::vec2 projectedPoint) { · 435 unmodified lines
29752922 return screenPoint;
29762923 }
29772924
2978−// render the coverage map on screen
2979−void Application::renderCoverageMapV2() {
2980− glDisable(GL_LIGHTING);
2981− glLineWidth(2.0);
2982− glBegin(GL_LINES);
2983− glColor3f(0,1,1);
2984−
2985− renderCoverageMapsV2Recursively(&_voxels.myCoverageMapV2);
2986−
2987− glEnd();
2988− glEnable(GL_LIGHTING);
2989−}
2990−
2991−void Application::renderCoverageMapsV2Recursively(CoverageMapV2* map) {
2992− // render ourselves...
2993− if (map->isCovered()) {
2994− BoundingBox box = map->getBoundingBox();
2995−
2996− glm::vec2 firstPoint = getScaledScreenPoint(box.getVertex(0));
2997− glm::vec2 lastPoint(firstPoint);
2998−
2999− for (int i = 1; i < box.getVertexCount(); i++) {
3000− glm::vec2 thisPoint = getScaledScreenPoint(box.getVertex(i));
3001−
3002− glVertex2f(lastPoint.x, lastPoint.y);
3003− glVertex2f(thisPoint.x, thisPoint.y);
3004− lastPoint = thisPoint;
3005− }
3006−
3007− glVertex2f(lastPoint.x, lastPoint.y);
3008− glVertex2f(firstPoint.x, firstPoint.y);
3009− } else {
3010− // iterate our children and call render on them.
3011− for (int i = 0; i < CoverageMapV2::NUMBER_OF_CHILDREN; i++) {
3012− CoverageMapV2* childMap = map->getChild(i);
3013− if (childMap) {
3014− renderCoverageMapsV2Recursively(childMap);
3015− }
3016− }
3017− }
3018−}
3019−
3020−// render the coverage map on screen
3021−void Application::renderCoverageMap() {
3022−
3023− glDisable(GL_LIGHTING);
3024− glLineWidth(2.0);
3025− glBegin(GL_LINES);
3026− glColor3f(0,0,1);
3027−
3028− renderCoverageMapsRecursively(&_voxels.myCoverageMap);
3029−
3030− glEnd();
3031− glEnable(GL_LIGHTING);
3032−}
3033−
3034−void Application::renderCoverageMapsRecursively(CoverageMap* map) {
3035− for (int i = 0; i < map->getPolygonCount(); i++) {
3036−
3037− OctreeProjectedPolygon* polygon = map->getPolygon(i);
3038−
3039− if (polygon->getProjectionType() == (PROJECTION_RIGHT | PROJECTION_NEAR | PROJECTION_BOTTOM)) {
3040− glColor3f(.5,0,0); // dark red
3041− } else if (polygon->getProjectionType() == (PROJECTION_NEAR | PROJECTION_RIGHT)) {
3042− glColor3f(.5,.5,0); // dark yellow
3043− } else if (polygon->getProjectionType() == (PROJECTION_NEAR | PROJECTION_LEFT)) {
3044− glColor3f(.5,.5,.5); // gray
3045− } else if (polygon->getProjectionType() == (PROJECTION_NEAR | PROJECTION_LEFT | PROJECTION_BOTTOM)) {
3046− glColor3f(.5,0,.5); // dark magenta
3047− } else if (polygon->getProjectionType() == (PROJECTION_NEAR | PROJECTION_BOTTOM)) {
3048− glColor3f(.75,0,0); // red
3049− } else if (polygon->getProjectionType() == (PROJECTION_NEAR | PROJECTION_TOP)) {
3050− glColor3f(1,0,1); // magenta
3051− } else if (polygon->getProjectionType() == (PROJECTION_NEAR | PROJECTION_LEFT | PROJECTION_TOP)) {
3052− glColor3f(0,0,1); // Blue
3053− } else if (polygon->getProjectionType() == (PROJECTION_NEAR | PROJECTION_RIGHT | PROJECTION_TOP)) {
3054− glColor3f(0,1,0); // green
3055− } else if (polygon->getProjectionType() == (PROJECTION_NEAR)) {
3056− glColor3f(1,1,0); // yellow
3057− } else if (polygon->getProjectionType() == (PROJECTION_FAR | PROJECTION_RIGHT | PROJECTION_BOTTOM)) {
3058− glColor3f(0,.5,.5); // dark cyan
3059− } else {
3060− glColor3f(1,0,0);
3061− }
3062−
3063− glm::vec2 firstPoint = getScaledScreenPoint(polygon->getVertex(0));
3064− glm::vec2 lastPoint(firstPoint);
3065−
3066− for (int i = 1; i < polygon->getVertexCount(); i++) {
3067− glm::vec2 thisPoint = getScaledScreenPoint(polygon->getVertex(i));
3068−
3069− glVertex2f(lastPoint.x, lastPoint.y);
3070− glVertex2f(thisPoint.x, thisPoint.y);
3071− lastPoint = thisPoint;
3072− }
3073−
3074− glVertex2f(lastPoint.x, lastPoint.y);
3075− glVertex2f(firstPoint.x, firstPoint.y);
3076− }
3077−
3078− // iterate our children and call render on them.
3079− for (int i = 0; i < CoverageMapV2::NUMBER_OF_CHILDREN; i++) {
3080− CoverageMap* childMap = map->getChild(i);
3081− if (childMap) {
3082− renderCoverageMapsRecursively(childMap);
3083− }
3084− }
3085−}
3086−
30872925 void Application::renderRearViewMirror(const QRect& region, bool billboard) {
30882926 bool eyeRelativeCamera = false;
30892927 if (billboard) {
@@ -3333,7 +3171,7 @@ void Application::deleteVoxelAt(const VoxelDetail& voxel) { · 243 unmodified lines
33333171 _voxelEditSender.sendVoxelEditMessage(PacketTypeVoxelErase, voxel);
33343172
33353173 // delete it locally to see the effect immediately (and in case no voxel server is present)
3336− _voxels.deleteVoxelAt(voxel.x, voxel.y, voxel.z, voxel.s);
3174+ _voxels.getTree()->deleteVoxelAt(voxel.x, voxel.y, voxel.z, voxel.s);
33373175 }
33383176 }
33393177

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