History

merge

atlante45 committed 13 years ago

Commit fec25d32 parents 13952a6 31a1e3e26 files · +1484 −205Browse files

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

Unified · Split

interface/src/Application.cpp+102−26
@@ -56,6 +56,8 @@ · 55 unmodified lines
5656 #include <PairingHandler.h>
5757 #include <PerfStat.h>
5858
59+#include <VoxelSceneStats.h>
60+
5961 #include "Application.h"
6062 #include "InterfaceConfig.h"
6163 #include "LogDisplay.h"
@@ -174,6 +176,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 112 unmodified lines
174176 _window(new QMainWindow(desktop())),
175177 _glWidget(new GLCanvas()),
176178 _bandwidthDialog(NULL),
179+ _voxelStatsDialog(NULL),
177180 _displayLevels(false),
178181 _frameCount(0),
179182 _fps(120.0f),
@@ -200,6 +203,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 20 unmodified lines
200203 _mouseVoxelScale(1.0f / 1024.0f),
201204 _justEditedVoxel(false),
202205 _isLookingAtOtherAvatar(false),
206+ _lookatIndicatorScale(1.0f),
203207 _paintOn(false),
204208 _dominantColor(0),
205209 _perfStatsOn(false),
@@ -1154,6 +1158,21 @@ void Application::bandwidthDetailsClosed() { · 948 unmodified lines
11541158 delete dlg;
11551159 }
11561160
1161+void Application::voxelStatsDetails() {
1162+ if (!_voxelStatsDialog) {
1163+ _voxelStatsDialog = new VoxelStatsDialog(_glWidget, &_voxelSceneStats);
1164+ connect(_voxelStatsDialog, SIGNAL(closed()), SLOT(voxelStatsDetailsClosed()));
1165+ _voxelStatsDialog->show();
1166+ }
1167+ _voxelStatsDialog->raise();
1168+}
1169+
1170+void Application::voxelStatsDetailsClosed() {
1171+ QDialog* dlg = _voxelStatsDialog;
1172+ _voxelStatsDialog = NULL;
1173+ delete dlg;
1174+}
1175+
11571176 void Application::editPreferences() {
11581177 QDialog dialog(_glWidget);
11591178 dialog.setWindowTitle("Interface Preferences");
@@ -1758,6 +1777,7 @@ void Application::initMenu() { · 598 unmodified lines
17581777 (_bandwidthDisplayOn = toolsMenu->addAction("Bandwidth Display"))->setCheckable(true);
17591778 _bandwidthDisplayOn->setChecked(true);
17601779 toolsMenu->addAction("Bandwidth Details", this, SLOT(bandwidthDetails()));
1780+ toolsMenu->addAction("Voxel Stats Details", this, SLOT(voxelStatsDetails()));
17611781
17621782
17631783 QMenu* voxelMenu = menuBar->addMenu("Voxels");
@@ -1842,6 +1862,11 @@ void Application::initMenu() { · 78 unmodified lines
18421862 (_simulateLeapHand = debugMenu->addAction("Simulate Leap Hand"))->setCheckable(true);
18431863 (_testRaveGlove = debugMenu->addAction("Test RaveGlove"))->setCheckable(true);
18441864
1865+ QMenu* audioDebugMenu = debugMenu->addMenu("Audio Debugging Tools");
1866+ audioDebugMenu->addAction("Listen Mode Normal", this, SLOT(setListenModeNormal()), Qt::CTRL | Qt::Key_1);
1867+ audioDebugMenu->addAction("Listen Mode Point/Radius", this, SLOT(setListenModePoint()), Qt::CTRL | Qt::Key_2);
1868+ audioDebugMenu->addAction("Listen Mode Single Source", this, SLOT(setListenModeSingleSource()), Qt::CTRL | Qt::Key_3);
1869+
18451870 QMenu* settingsMenu = menuBar->addMenu("Settings");
18461871 (_settingsAutosave = settingsMenu->addAction("Autosave"))->setCheckable(true);
18471872 _settingsAutosave->setChecked(true);
@@ -1853,6 +1878,30 @@ void Application::initMenu() { · 5 unmodified lines
18531878 _networkAccessManager = new QNetworkAccessManager(this);
18541879 }
18551880
1881+void Application::setListenModeNormal() {
1882+ _audio.setListenMode(AudioRingBuffer::NORMAL);
1883+}
1884+
1885+void Application::setListenModePoint() {
1886+ _audio.setListenMode(AudioRingBuffer::OMNI_DIRECTIONAL_POINT);
1887+ _audio.setListenRadius(1.0);
1888+}
1889+
1890+void Application::setListenModeSingleSource() {
1891+ _audio.setListenMode(AudioRingBuffer::SELECTED_SOURCES);
1892+ _audio.clearListenSources();
1893+
1894+ glm::vec3 mouseRayOrigin = _myAvatar.getMouseRayOrigin();
1895+ glm::vec3 mouseRayDirection = _myAvatar.getMouseRayDirection();
1896+ glm::vec3 eyePositionIgnored;
1897+ uint16_t nodeID;
1898+
1899+ if (isLookingAtOtherAvatar(mouseRayOrigin, mouseRayDirection, eyePositionIgnored, nodeID)) {
1900+ _audio.addListenSource(nodeID);
1901+ }
1902+}
1903+
1904+
18561905 void Application::updateFrustumRenderModeAction() {
18571906 switch (_frustumDrawingMode) {
18581907 default:
@@ -1941,7 +1990,10 @@ const float MAX_AVATAR_EDIT_VELOCITY = 1.0f; · 82 unmodified lines
19411990 const float MAX_VOXEL_EDIT_DISTANCE = 20.0f;
19421991 const float HEAD_SPHERE_RADIUS = 0.07;
19431992
1944−bool Application::isLookingAtOtherAvatar(glm::vec3& mouseRayOrigin, glm::vec3& mouseRayDirection, glm::vec3& eyePosition) {
1993+
1994+bool Application::isLookingAtOtherAvatar(glm::vec3& mouseRayOrigin, glm::vec3& mouseRayDirection,
1995+ glm::vec3& eyePosition, uint16_t& nodeID) {
1996+
19451997 NodeList* nodeList = NodeList::getInstance();
19461998 for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
19471999 if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) {
@@ -1949,7 +2001,9 @@ bool Application::isLookingAtOtherAvatar(glm::vec3& mouseRayOrigin, glm::vec3& m · 1 unmodified line
19492001 glm::vec3 headPosition = avatar->getHead().getPosition();
19502002 if (rayIntersectsSphere(mouseRayOrigin, mouseRayDirection, headPosition, HEAD_SPHERE_RADIUS)) {
19512003 eyePosition = avatar->getHead().getEyeLevelPosition();
2004+ _lookatIndicatorScale = avatar->getScale();
19522005 _lookatOtherPosition = headPosition;
2006+ nodeID = avatar->getOwningNode()->getNodeID();
19532007 return true;
19542008 }
19552009 }
@@ -1959,11 +2013,13 @@ bool Application::isLookingAtOtherAvatar(glm::vec3& mouseRayOrigin, glm::vec3& m · 3 unmodified lines
19592013
19602014 void Application::renderLookatIndicator(glm::vec3 pointOfInterest, Camera& whichCamera) {
19612015
1962− const float DISTANCE_FROM_HEAD_SPHERE = 0.1f;
2016+ const float DISTANCE_FROM_HEAD_SPHERE = 0.1f * _lookatIndicatorScale;
2017+ const float INDICATOR_RADIUS = 0.1f * _lookatIndicatorScale;
19632018 const float YELLOW[] = { 1.0f, 1.0f, 0.0f };
2019+ const int NUM_SEGMENTS = 30;
19642020 glm::vec3 haloOrigin(pointOfInterest.x, pointOfInterest.y + DISTANCE_FROM_HEAD_SPHERE, pointOfInterest.z);
19652021 glColor3f(YELLOW[0], YELLOW[1], YELLOW[2]);
1966− renderCircle(haloOrigin, 0.1f, glm::vec3(0.0f, 1.0f, 0.0f), 30);
2022+ renderCircle(haloOrigin, INDICATOR_RADIUS, IDENTITY_UP, NUM_SEGMENTS);
19672023 }
19682024
19692025 void Application::update(float deltaTime) {
@@ -1993,7 +2049,9 @@ void Application::update(float deltaTime) { · 23 unmodified lines
19932049
19942050 // Set where I am looking based on my mouse ray (so that other people can see)
19952051 glm::vec3 eyePosition;
1996− if (_isLookingAtOtherAvatar = isLookingAtOtherAvatar(mouseRayOrigin, mouseRayDirection, eyePosition)) {
2052+ uint16_t ignored;
2053+ _isLookingAtOtherAvatar = isLookingAtOtherAvatar(mouseRayOrigin, mouseRayDirection, eyePosition, ignored);
2054+ if (_isLookingAtOtherAvatar) {
19972055 // If the mouse is over another avatar's head...
19982056 glm::vec3 myLookAtFromMouse(eyePosition);
19992057 _myAvatar.getHead().setLookAtPosition(myLookAtFromMouse);
@@ -2010,7 +2068,7 @@ void Application::update(float deltaTime) { · 10 unmodified lines
20102068 glm::vec3 front = orientation * IDENTITY_FRONT;
20112069 glm::vec3 up = orientation * IDENTITY_UP;
20122070 glm::vec3 towardVoxel = getMouseVoxelWorldCoordinates(_mouseVoxelDragging)
2013− - _myAvatar.getCameraPosition(); // is this an error? getCameraPosition dne
2071+ - _myAvatar.getCameraPosition();
20142072 towardVoxel = front * glm::length(towardVoxel);
20152073 glm::vec3 lateralToVoxel = glm::cross(up, glm::normalize(towardVoxel)) * glm::length(towardVoxel);
20162074 _voxelThrust = glm::vec3(0, 0, 0);
@@ -2198,6 +2256,9 @@ void Application::update(float deltaTime) { · 181 unmodified lines
21982256 if (_bandwidthDialog) {
21992257 _bandwidthDialog->update();
22002258 }
2259+ if (_voxelStatsDialog) {
2260+ _voxelStatsDialog->update();
2261+ }
22012262
22022263 // Update audio stats for procedural sounds
22032264 #ifndef _WIN32
@@ -2255,7 +2316,9 @@ void Application::updateAvatar(float deltaTime) { · 51 unmodified lines
22552316 _viewFrustum.computePickRay(MIDPOINT_OF_SCREEN, MIDPOINT_OF_SCREEN, screenCenterRayOrigin, screenCenterRayDirection);
22562317
22572318 glm::vec3 eyePosition;
2258− if (_isLookingAtOtherAvatar = isLookingAtOtherAvatar(screenCenterRayOrigin, screenCenterRayDirection, eyePosition)) {
2319+ uint16_t ignored;
2320+ _isLookingAtOtherAvatar = isLookingAtOtherAvatar(screenCenterRayOrigin, screenCenterRayDirection, eyePosition, ignored);
2321+ if (_isLookingAtOtherAvatar) {
22592322 glm::vec3 myLookAtFromMouse(eyePosition);
22602323 _myAvatar.getHead().setLookAtPosition(myLookAtFromMouse);
22612324 }
@@ -2283,7 +2346,7 @@ void Application::updateAvatar(float deltaTime) { · 21 unmodified lines
22832346 // actually need to calculate the view frustum planes to send these details
22842347 // to the server.
22852348 loadViewFrustum(_myCamera, _viewFrustum);
2286− _myAvatar.setCameraPosition(_viewFrustum.getPosition()); // setCameraPosition() dne
2349+ _myAvatar.setCameraPosition(_viewFrustum.getPosition());
22872350 _myAvatar.setCameraOrientation(_viewFrustum.getOrientation());
22882351 _myAvatar.setCameraFov(_viewFrustum.getFieldOfView());
22892352 _myAvatar.setCameraAspectRatio(_viewFrustum.getAspectRatio());
@@ -2854,27 +2917,19 @@ void Application::displayStats() { · 564 unmodified lines
28542917 drawtext(10, statsVerticalOffset + 230, 0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str());
28552918
28562919 voxelStats.str("");
2857− voxelStats << "Voxels Created: " << _voxels.getVoxelsCreated() / 1000.f << "K (" << _voxels.getVoxelsCreatedPerSecondAverage() / 1000.f
2858− << "Kps) ";
2920+ char* voxelDetails = _voxelSceneStats.getItemValue(VoxelSceneStats::ITEM_VOXELS);
2921+ voxelStats << "Voxels Sent from Server: " << voxelDetails;
28592922 drawtext(10, statsVerticalOffset + 250, 0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str());
2860−
2923+
28612924 voxelStats.str("");
2862− voxelStats << "Voxels Colored: " << _voxels.getVoxelsColored() / 1000.f << "K (" << _voxels.getVoxelsColoredPerSecondAverage() / 1000.f
2863− << "Kps) ";
2925+ voxelDetails = _voxelSceneStats.getItemValue(VoxelSceneStats::ITEM_ELAPSED);
2926+ voxelStats << "Scene Send Time from Server: " << voxelDetails;
28642927 drawtext(10, statsVerticalOffset + 270, 0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str());
2865−
2866− voxelStats.str("");
2867− voxelStats << "Voxel Bits Read: " << _voxels.getVoxelsBytesRead() * 8.f / 1000000.f
2868− << "M (" << _voxels.getVoxelsBytesReadPerSecondAverage() * 8.f / 1000000.f << " Mbps)";
2869− drawtext(10, statsVerticalOffset + 290,0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str());
28702928
28712929 voxelStats.str("");
2872− float voxelsBytesPerColored = _voxels.getVoxelsColored()
2873− ? ((float) _voxels.getVoxelsBytesRead() / _voxels.getVoxelsColored())
2874− : 0;
2875−
2876− voxelStats << "Voxels Bits per Colored: " << voxelsBytesPerColored * 8;
2877− drawtext(10, statsVerticalOffset + 310, 0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str());
2930+ voxelDetails = _voxelSceneStats.getItemValue(VoxelSceneStats::ITEM_ENCODE);
2931+ voxelStats << "Encode Time on Server: " << voxelDetails;
2932+ drawtext(10, statsVerticalOffset + 290, 0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str());
28782933
28792934 Node *avatarMixer = NodeList::getInstance()->soloNodeOfType(NODE_TYPE_AVATAR_MIXER);
28802935 char avatarMixerStats[200];
@@ -3433,16 +3488,37 @@ void* Application::networkReceive(void* args) { · 552 unmodified lines
34333488 case PACKET_TYPE_VOXEL_DATA_MONOCHROME:
34343489 case PACKET_TYPE_Z_COMMAND:
34353490 case PACKET_TYPE_ERASE_VOXEL:
3491+ case PACKET_TYPE_VOXEL_STATS:
34363492 case PACKET_TYPE_ENVIRONMENT_DATA: {
3493+
3494+ unsigned char* messageData = app->_incomingPacket;
3495+ ssize_t messageLength = bytesReceived;
3496+
3497+ // note: PACKET_TYPE_VOXEL_STATS can have PACKET_TYPE_VOXEL_DATA or PACKET_TYPE_VOXEL_DATA_MONOCHROME
3498+ // immediately following them inside the same packet. So, we process the PACKET_TYPE_VOXEL_STATS first
3499+ // then process any remaining bytes as if it was another packet
3500+ if (messageData[0] == PACKET_TYPE_VOXEL_STATS) {
3501+ int statsMessageLength = app->_voxelSceneStats.unpackFromMessage(messageData, messageLength);
3502+ if (messageLength > statsMessageLength) {
3503+ messageData += statsMessageLength;
3504+ messageLength -= statsMessageLength;
3505+ if (!packetVersionMatch(messageData)) {
3506+ break; // bail since piggyback data doesn't match our versioning
3507+ }
3508+ } else {
3509+ break; // bail since no piggyback data
3510+ }
3511+ } // fall through to piggyback message
3512+
34373513 if (app->_renderVoxels->isChecked()) {
34383514 Node* voxelServer = NodeList::getInstance()->soloNodeOfType(NODE_TYPE_VOXEL_SERVER);
34393515 if (voxelServer && socketMatch(voxelServer->getActiveSocket(), &senderAddress)) {
34403516 voxelServer->lock();
34413517
3442− if (app->_incomingPacket[0] == PACKET_TYPE_ENVIRONMENT_DATA) {
3443− app->_environment.parseData(&senderAddress, app->_incomingPacket, bytesReceived);
3518+ if (messageData[0] == PACKET_TYPE_ENVIRONMENT_DATA) {
3519+ app->_environment.parseData(&senderAddress, messageData, messageLength);
34443520 } else {
3445− app->_voxels.parseData(app->_incomingPacket, bytesReceived);
3521+ app->_voxels.parseData(messageData, messageLength);
34463522 }
34473523
34483524 voxelServer->unlock();

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