History

first major pass at voxelEctomy

ZappoMan committed 11 years ago

Commit 4ea9bbc1 parent 2a129b665 files · +43 −5956Browse files

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

Unified · Split

interface/src/Application.cpp+10−97
@@ -169,7 +169,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 168 unmodified lines
169169 _isTouchPressed(false),
170170 _mousePressed(false),
171171 _audio(),
172− _enableProcessVoxelsThread(true),
172+ _enableProcessOctreeThread(true),
173173 _octreeProcessor(),
174174 _packetsPerSecond(0),
175175 _bytesPerSecond(0),
@@ -311,7 +311,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 135 unmodified lines
311311
312312 // tell the NodeList instance who to tell the domain server we care about
313313 nodeList->addSetOfNodeTypesToNodeInterestSet(NodeSet() << NodeType::AudioMixer << NodeType::AvatarMixer
314− << NodeType::VoxelServer << NodeType::EntityServer
314+ << NodeType::EntityServer
315315 << NodeType::MetavoxelServer);
316316
317317 // connect to the packet sent signal of the _entityEditSender
@@ -539,9 +539,9 @@ void Application::initializeGL() { · 221 unmodified lines
539539 init();
540540 qDebug( "init() complete.");
541541
542− // create thread for parsing of voxel data independent of the main network and rendering threads
543− _octreeProcessor.initialize(_enableProcessVoxelsThread);
544− _entityEditSender.initialize(_enableProcessVoxelsThread);
542+ // create thread for parsing of octee data independent of the main network and rendering threads
543+ _octreeProcessor.initialize(_enableProcessOctreeThread);
544+ _entityEditSender.initialize(_enableProcessOctreeThread);
545545
546546 // call our timer function every second
547547 QTimer* timer = new QTimer(this);
@@ -1731,20 +1731,14 @@ void Application::init() { · 1183 unmodified lines
17311731 _entities.setViewFrustum(getViewFrustum());
17321732
17331733 EntityTree* entityTree = _entities.getTree();
1734− _entityCollisionSystem.init(&_entityEditSender, entityTree, NULL, &_audio, &_avatarManager);
1734+ _entityCollisionSystem.init(&_entityEditSender, entityTree, &_audio, &_avatarManager);
17351735 entityTree->setSimulation(&_entityCollisionSystem);
17361736
1737− // connect the _entityCollisionSystem to our script engine's EntityScriptingInterface
1738− connect(&_entityCollisionSystem, &EntityCollisionSystem::entityCollisionWithVoxel,
1739− ScriptEngine::getEntityScriptingInterface(), &EntityScriptingInterface::entityCollisionWithVoxel);
17401737
17411738 connect(&_entityCollisionSystem, &EntityCollisionSystem::entityCollisionWithEntity,
17421739 ScriptEngine::getEntityScriptingInterface(), &EntityScriptingInterface::entityCollisionWithEntity);
17431740
17441741 // connect the _entityCollisionSystem to our EntityTreeRenderer since that's what handles running entity scripts
1745− connect(&_entityCollisionSystem, &EntityCollisionSystem::entityCollisionWithVoxel,
1746− &_entities, &EntityTreeRenderer::entityCollisionWithVoxel);
1747−
17481742 connect(&_entityCollisionSystem, &EntityCollisionSystem::entityCollisionWithEntity,
17491743 &_entities, &EntityTreeRenderer::entityCollisionWithEntity);
17501744
@@ -1951,10 +1945,8 @@ void Application::updateThreads(float deltaTime) { · 200 unmodified lines
19511945 PerformanceWarning warn(showWarnings, "Application::updateThreads()");
19521946
19531947 // parse voxel packets
1954− if (!_enableProcessVoxelsThread) {
1948+ if (!_enableProcessOctreeThread) {
19551949 _octreeProcessor.threadRoutine();
1956− _voxelHideShowThread.threadRoutine();
1957− _voxelEditSender.threadRoutine();
19581950 _entityEditSender.threadRoutine();
19591951 }
19601952 }
@@ -2134,9 +2126,6 @@ void Application::update(float deltaTime) { · 173 unmodified lines
21342126 if (queryIsDue || viewIsDifferentEnough) {
21352127 _lastQueriedTime = now;
21362128
2137− if (Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) {
2138− queryOctree(NodeType::VoxelServer, PacketTypeVoxelQuery, _voxelServerJurisdictions);
2139− }
21402129 if (Menu::getInstance()->isOptionChecked(MenuOption::Entities)) {
21412130 queryOctree(NodeType::EntityServer, PacketTypeEntityQuery, _entityServerJurisdictions);
21422131 }
@@ -2837,14 +2826,6 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly, RenderAr · 694 unmodified lines
28372826 glColor3f(1,0,0);
28382827 DependencyManager::get<GeometryCache>()->renderSphere(originSphereRadius, 15, 15);
28392828
2840− // Draw voxels
2841− if (Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) {
2842− PerformanceTimer perfTimer("voxels");
2843− PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
2844− "Application::displaySide() ... voxels...");
2845− _voxels.render();
2846− }
2847−
28482829 // also, metavoxels
28492830 if (Menu::getInstance()->isOptionChecked(MenuOption::Metavoxels)) {
28502831 PerformanceTimer perfTimer("metavoxels");
@@ -3308,20 +3289,6 @@ void Application::renderViewFrustum(ViewFrustum& viewFrustum) { · 457 unmodified lines
33083289 }
33093290 }
33103291
3311−void Application::deleteVoxels(const VoxelDetail& voxel) {
3312− deleteVoxelAt(voxel);
3313−}
3314−
3315−void Application::deleteVoxelAt(const VoxelDetail& voxel) {
3316− if (voxel.s != 0) {
3317− // sending delete to the server is sufficient, server will send new version so we see updates soon enough
3318− _voxelEditSender.sendVoxelEditMessage(PacketTypeVoxelErase, voxel);
3319−
3320− // delete it locally to see the effect immediately (and in case no voxel server is present)
3321− _voxels.getTree()->deleteVoxelAt(voxel.x, voxel.y, voxel.z, voxel.s);
3322− }
3323−}
3324−
33253292 void Application::resetSensors() {
33263293 DependencyManager::get<Faceshift>()->reset();
33273294 DependencyManager::get<Visage>()->reset();
@@ -3422,10 +3389,6 @@ void Application::clearDomainOctreeDetails() { · 94 unmodified lines
34223389 _environment.resetToDefault();
34233390
34243391 // reset our node to stats and node to jurisdiction maps... since these must be changing...
3425− _voxelServerJurisdictions.lockForWrite();
3426− _voxelServerJurisdictions.clear();
3427− _voxelServerJurisdictions.unlock();
3428−
34293392 _entityServerJurisdictions.lockForWrite();
34303393 _entityServerJurisdictions.clear();
34313394 _entityServerJurisdictions.unlock();
@@ -3437,8 +3400,6 @@ void Application::clearDomainOctreeDetails() { · 5 unmodified lines
34373400 // reset the model renderer
34383401 _entities.clear();
34393402
3440− // reset the voxels renderer
3441− _voxels.killLocalVoxels();
34423403 }
34433404
34443405 void Application::domainChanged(const QString& domainHostname) {
@@ -3475,51 +3436,13 @@ void Application::nodeKilled(SharedNodePointer node) { · 30 unmodified lines
34753436
34763437 _octreeProcessor.nodeKilled(node);
34773438
3478− _voxelEditSender.nodeKilled(node);
34793439 _entityEditSender.nodeKilled(node);
34803440
34813441 if (node->getType() == NodeType::AudioMixer) {
34823442 QMetaObject::invokeMethod(&_audio, "audioMixerKilled");
34833443 }
34843444
3485− if (node->getType() == NodeType::VoxelServer) {
3486− QUuid nodeUUID = node->getUUID();
3487− // see if this is the first we've heard of this node...
3488− _voxelServerJurisdictions.lockForRead();
3489− if (_voxelServerJurisdictions.find(nodeUUID) != _voxelServerJurisdictions.end()) {
3490− unsigned char* rootCode = _voxelServerJurisdictions[nodeUUID].getRootOctalCode();
3491− VoxelPositionSize rootDetails;
3492− voxelDetailsForCode(rootCode, rootDetails);
3493− _voxelServerJurisdictions.unlock();
3494−
3495− qDebug("voxel server going away...... v[%f, %f, %f, %f]",
3496− rootDetails.x, rootDetails.y, rootDetails.z, rootDetails.s);
3497−
3498− // Add the jurisditionDetails object to the list of "fade outs"
3499− if (!Menu::getInstance()->isOptionChecked(MenuOption::DontFadeOnVoxelServerChanges)) {
3500− VoxelFade fade(VoxelFade::FADE_OUT, NODE_KILLED_RED, NODE_KILLED_GREEN, NODE_KILLED_BLUE);
3501− fade.voxelDetails = rootDetails;
3502− const float slightly_smaller = 0.99f;
3503− fade.voxelDetails.s = fade.voxelDetails.s * slightly_smaller;
3504− _voxelFadesLock.lockForWrite();
3505− _voxelFades.push_back(fade);
3506− _voxelFadesLock.unlock();
3507− }
3508−
3509− // If the voxel server is going away, remove it from our jurisdiction map so we don't send voxels to a dead server
3510− _voxelServerJurisdictions.lockForWrite();
3511− _voxelServerJurisdictions.erase(_voxelServerJurisdictions.find(nodeUUID));
3512− }
3513− _voxelServerJurisdictions.unlock();
3514−
3515− // also clean up scene stats for that server
3516− _octreeSceneStatsLock.lockForWrite();
3517− if (_octreeServerSceneStats.find(nodeUUID) != _octreeServerSceneStats.end()) {
3518− _octreeServerSceneStats.erase(nodeUUID);
3519− }
3520− _octreeSceneStatsLock.unlock();
3521−
3522− } else if (node->getType() == NodeType::EntityServer) {
3445+ if (node->getType() == NodeType::EntityServer) {
35233446
35243447 QUuid nodeUUID = node->getUUID();
35253448 // see if this is the first we've heard of this node...
@@ -3563,7 +3486,7 @@ void Application::nodeKilled(SharedNodePointer node) { · 37 unmodified lines
35633486 }
35643487 }
35653488
3566−void Application::trackIncomingVoxelPacket(const QByteArray& packet, const SharedNodePointer& sendingNode, bool wasStatsPacket) {
3489+void Application::trackIncomingOctreePacket(const QByteArray& packet, const SharedNodePointer& sendingNode, bool wasStatsPacket) {
35673490
35683491 // Attempt to identify the sender from it's address.
35693492 if (sendingNode) {
@@ -3607,10 +3530,7 @@ int Application::parseOctreeStats(const QByteArray& packet, const SharedNodePoin · 37 unmodified lines
36073530 // see if this is the first we've heard of this node...
36083531 NodeToJurisdictionMap* jurisdiction = NULL;
36093532 QString serverType;
3610− if (sendingNode->getType() == NodeType::VoxelServer) {
3611− jurisdiction = &_voxelServerJurisdictions;
3612− serverType = "Voxel";
3613− } else {
3533+ if (sendingNode->getType() == NodeType::EntityServer) {
36143534 jurisdiction = &_entityServerJurisdictions;
36153535 serverType = "Entity";
36163536 }
@@ -3704,9 +3624,6 @@ void joystickFromScriptValue(const QScriptValue &object, Joystick* &out) { · 87 unmodified lines
37043624 void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scriptEngine) {
37053625 // setup the packet senders and jurisdiction listeners of the script engine's scripting interfaces so
37063626 // we can use the same ones from the application.
3707− scriptEngine->getVoxelsScriptingInterface()->setPacketSender(&_voxelEditSender);
3708− scriptEngine->getVoxelsScriptingInterface()->setVoxelTree(_voxels.getTree());
3709− scriptEngine->getVoxelsScriptingInterface()->setUndoStack(&_undoStack);
37103627 scriptEngine->getEntityScriptingInterface()->setPacketSender(&_entityEditSender);
37113628 scriptEngine->getEntityScriptingInterface()->setEntityTree(_entities.getTree());
37123629
@@ -3968,10 +3885,6 @@ void Application::domainSettingsReceived(const QJsonObject& domainSettingsObject · 255 unmodified lines
39683885
39693886 qDebug() << "Voxel costs are" << satoshisPerVoxel << "per voxel and" << satoshisPerMeterCubed << "per meter cubed";
39703887 qDebug() << "Destination wallet UUID for voxel payments is" << voxelWalletUUID;
3971−
3972− _voxelEditSender.setSatoshisPerVoxel(satoshisPerVoxel);
3973− _voxelEditSender.setSatoshisPerMeterCubed(satoshisPerMeterCubed);
3974− _voxelEditSender.setDestinationWalletUUID(voxelWalletUUID);
39753888 }
39763889
39773890 QString Application::getPreviousScriptLocation() {

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