History

Merge pull request #3335 from ZappoMan/virtualEntities

Model Server to Entity Server Refactoring

AndrewMeadows committed 12 years ago

Commit bd55da42 parents f33a334 d08e7ef158 files · +11382 −5677Browse files

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

Unified · Split

interface/src/Application.cpp+78−67
@@ -52,9 +52,9 @@ · 51 unmodified lines
5252
5353 #include <AccountManager.h>
5454 #include <AudioInjector.h>
55+#include <EntityScriptingInterface.h>
5556 #include <LocalVoxelsList.h>
5657 #include <Logging.h>
57−#include <ModelsScriptingInterface.h>
5858 #include <NetworkAccessManager.h>
5959 #include <OctalCode.h>
6060 #include <OctreeSceneStats.h>
@@ -141,8 +141,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 80 unmodified lines
141141 _voxelImporter(),
142142 _importSucceded(false),
143143 _sharedVoxelSystem(TREE_SCALE, DEFAULT_MAX_VOXELS_PER_SYSTEM, &_clipboard),
144− _modelClipboardRenderer(),
145− _modelClipboard(),
144+ _entityClipboardRenderer(),
145+ _entityClipboard(),
146146 _wantToKillLocalVoxels(false),
147147 _viewFrustum(),
148148 _lastQueriedViewFrustum(),
@@ -303,13 +303,13 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 154 unmodified lines
303303
304304 // tell the NodeList instance who to tell the domain server we care about
305305 nodeList->addSetOfNodeTypesToNodeInterestSet(NodeSet() << NodeType::AudioMixer << NodeType::AvatarMixer
306− << NodeType::VoxelServer << NodeType::ParticleServer << NodeType::ModelServer
306+ << NodeType::VoxelServer << NodeType::ParticleServer << NodeType::EntityServer
307307 << NodeType::MetavoxelServer);
308308
309309 // connect to the packet sent signal of the _voxelEditSender and the _particleEditSender
310310 connect(&_voxelEditSender, &VoxelEditPacketSender::packetSent, this, &Application::packetSent);
311311 connect(&_particleEditSender, &ParticleEditPacketSender::packetSent, this, &Application::packetSent);
312− connect(&_modelEditSender, &ModelEditPacketSender::packetSent, this, &Application::packetSent);
312+ connect(&_entityEditSender, &EntityEditPacketSender::packetSent, this, &Application::packetSent);
313313
314314 // move the silentNodeTimer to the _nodeThread
315315 QTimer* silentNodeTimer = new QTimer();
@@ -352,7 +352,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 36 unmodified lines
352352 // Tell our voxel edit sender about our known jurisdictions
353353 _voxelEditSender.setVoxelServerJurisdictions(&_voxelServerJurisdictions);
354354 _particleEditSender.setServerJurisdictions(&_particleServerJurisdictions);
355− _modelEditSender.setServerJurisdictions(&_modelServerJurisdictions);
355+ _entityEditSender.setServerJurisdictions(&_entityServerJurisdictions);
356356
357357 Particle::setVoxelEditPacketSender(&_voxelEditSender);
358358 Particle::setParticleEditPacketSender(&_particleEditSender);
@@ -364,7 +364,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 5 unmodified lines
364364 // probably not the right long term solution. But for now, we're going to do this to
365365 // allow you to move a particle around in your hand
366366 _particleEditSender.setPacketsPerSecond(3000); // super high!!
367− _modelEditSender.setPacketsPerSecond(3000); // super high!!
367+ _entityEditSender.setPacketsPerSecond(3000); // super high!!
368368
369369 // Set the sixense filtering
370370 _sixenseManager.setFilter(Menu::getInstance()->isOptionChecked(MenuOption::FilterSixense));
@@ -454,7 +454,7 @@ Application::~Application() { · 83 unmodified lines
454454 _voxelHideShowThread.terminate();
455455 _voxelEditSender.terminate();
456456 _particleEditSender.terminate();
457− _modelEditSender.terminate();
457+ _entityEditSender.terminate();
458458
459459
460460 VoxelTreeElement::removeDeleteHook(&_voxels); // we don't need to do this processing on shutdown
@@ -549,7 +549,7 @@ void Application::initializeGL() { · 88 unmodified lines
549549 _voxelEditSender.initialize(_enableProcessVoxelsThread);
550550 _voxelHideShowThread.initialize(_enableProcessVoxelsThread);
551551 _particleEditSender.initialize(_enableProcessVoxelsThread);
552− _modelEditSender.initialize(_enableProcessVoxelsThread);
552+ _entityEditSender.initialize(_enableProcessVoxelsThread);
553553
554554 if (_enableProcessVoxelsThread) {
555555 qDebug("Voxel parsing thread created.");
@@ -801,7 +801,7 @@ void Application::controlledBroadcastToNodes(const QByteArray& packet, const Nod · 245 unmodified lines
801801 break;
802802 case NodeType::VoxelServer:
803803 case NodeType::ParticleServer:
804− case NodeType::ModelServer:
804+ case NodeType::EntityServer:
805805 channel = BandwidthMeter::VOXELS;
806806 break;
807807 default:
@@ -1339,7 +1339,7 @@ void Application::dropEvent(QDropEvent *event) { · 531 unmodified lines
13391339 void Application::sendPingPackets() {
13401340 QByteArray pingPacket = NodeList::getInstance()->constructPingPacket();
13411341 controlledBroadcastToNodes(pingPacket, NodeSet()
1342− << NodeType::VoxelServer << NodeType::ParticleServer << NodeType::ModelServer
1342+ << NodeType::VoxelServer << NodeType::ParticleServer << NodeType::EntityServer
13431343 << NodeType::AudioMixer << NodeType::AvatarMixer
13441344 << NodeType::MetavoxelServer);
13451345 }
@@ -1523,22 +1523,21 @@ struct SendVoxelsOperationArgs { · 177 unmodified lines
15231523 const unsigned char* newBaseOctCode;
15241524 };
15251525
1526−bool Application::exportModels(const QString& filename, float x, float y, float z, float scale) {
1527− QVector<ModelItem*> models;
1528− _models.getTree()->findModelsInCube(AACube(glm::vec3(x / (float)TREE_SCALE, y / (float)TREE_SCALE, z / (float)TREE_SCALE), scale / (float)TREE_SCALE), models);
1529− if (models.size() > 0) {
1526+bool Application::exportEntities(const QString& filename, float x, float y, float z, float scale) {
1527+ QVector<EntityItem*> entities;
1528+ _entities.getTree()->findEntities(AACube(glm::vec3(x / (float)TREE_SCALE,
1529+ y / (float)TREE_SCALE, z / (float)TREE_SCALE), scale / (float)TREE_SCALE), entities);
1530+
1531+ if (entities.size() > 0) {
15301532 glm::vec3 root(x, y, z);
1531− ModelTree exportTree;
1533+ EntityTree exportTree;
15321534
1533− for (int i = 0; i < models.size(); i++) {
1534− ModelItemProperties properties;
1535− ModelItemID id = models.at(i)->getModelItemID();
1536− id.isKnownID = false;
1537− properties.copyFromNewModelItem(*models.at(i));
1535+ for (int i = 0; i < entities.size(); i++) {
1536+ EntityItemProperties properties = entities.at(i)->getProperties();
1537+ EntityItemID id = entities.at(i)->getEntityItemID();
15381538 properties.setPosition(properties.getPosition() - root);
1539− exportTree.addModel(id, properties);
1539+ exportTree.addEntity(id, properties);
15401540 }
1541−
15421541 exportTree.writeToSVOFile(filename.toLocal8Bit().constData());
15431542 } else {
15441543 qDebug() << "No models were selected";
@@ -1631,17 +1630,17 @@ void Application::importVoxels() { · 86 unmodified lines
16311630 emit importDone();
16321631 }
16331632
1634−bool Application::importModels(const QString& filename) {
1635− _modelClipboard.eraseAllOctreeElements();
1636− bool success = _modelClipboard.readFromSVOFile(filename.toLocal8Bit().constData());
1633+bool Application::importEntities(const QString& filename) {
1634+ _entityClipboard.eraseAllOctreeElements();
1635+ bool success = _entityClipboard.readFromSVOFile(filename.toLocal8Bit().constData());
16371636 if (success) {
1638− _modelClipboard.reaverageOctreeElements();
1637+ _entityClipboard.reaverageOctreeElements();
16391638 }
16401639 return success;
16411640 }
16421641
1643−void Application::pasteModels(float x, float y, float z) {
1644− _modelClipboard.sendModels(&_modelEditSender, x, y, z);
1642+void Application::pasteEntities(float x, float y, float z) {
1643+ _entityClipboard.sendEntities(&_entityEditSender, _entities.getTree(), x, y, z);
16451644 }
16461645
16471646 void Application::cutVoxels(const VoxelDetail& sourceVoxel) {
@@ -1797,12 +1796,12 @@ void Application::init() { · 149 unmodified lines
17971796 _particles.init();
17981797 _particles.setViewFrustum(getViewFrustum());
17991798
1800− _models.init();
1801− _models.setViewFrustum(getViewFrustum());
1799+ _entities.init();
1800+ _entities.setViewFrustum(getViewFrustum());
18021801
1803− _modelClipboardRenderer.init();
1804− _modelClipboardRenderer.setViewFrustum(getViewFrustum());
1805− _modelClipboardRenderer.setTree(&_modelClipboard);
1802+ _entityClipboardRenderer.init();
1803+ _entityClipboardRenderer.setViewFrustum(getViewFrustum());
1804+ _entityClipboardRenderer.setTree(&_entityClipboard);
18061805
18071806 _metavoxels.init();
18081807
@@ -2032,7 +2031,7 @@ void Application::updateThreads(float deltaTime) { · 223 unmodified lines
20322031 _voxelHideShowThread.threadRoutine();
20332032 _voxelEditSender.threadRoutine();
20342033 _particleEditSender.threadRoutine();
2035− _modelEditSender.threadRoutine();
2034+ _entityEditSender.threadRoutine();
20362035 }
20372036 }
20382037
@@ -2165,8 +2164,8 @@ void Application::update(float deltaTime) { · 126 unmodified lines
21652164 }
21662165
21672166 {
2168− PerformanceTimer perfTimer("models");
2169− _models.update(); // update the models...
2167+ PerformanceTimer perfTimer("entities");
2168+ _entities.update(); // update the models...
21702169 }
21712170
21722171 {
@@ -2210,9 +2209,16 @@ void Application::update(float deltaTime) { · 37 unmodified lines
22102209 // if it's been a while since our last query or the view has significantly changed then send a query, otherwise suppress it
22112210 if (queryIsDue || viewIsDifferentEnough) {
22122211 _lastQueriedTime = now;
2213− queryOctree(NodeType::VoxelServer, PacketTypeVoxelQuery, _voxelServerJurisdictions);
2214− queryOctree(NodeType::ParticleServer, PacketTypeParticleQuery, _particleServerJurisdictions);
2215− queryOctree(NodeType::ModelServer, PacketTypeModelQuery, _modelServerJurisdictions);
2212+
2213+ if (Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) {
2214+ queryOctree(NodeType::VoxelServer, PacketTypeVoxelQuery, _voxelServerJurisdictions);
2215+ }
2216+ if (Menu::getInstance()->isOptionChecked(MenuOption::Particles)) {
2217+ queryOctree(NodeType::ParticleServer, PacketTypeParticleQuery, _particleServerJurisdictions);
2218+ }
2219+ if (Menu::getInstance()->isOptionChecked(MenuOption::Models)) {
2220+ queryOctree(NodeType::EntityServer, PacketTypeEntityQuery, _entityServerJurisdictions);
2221+ }
22162222 _lastQueriedViewFrustum = _viewFrustum;
22172223 }
22182224 }
@@ -2268,7 +2274,7 @@ int Application::sendNackPackets() { · 49 unmodified lines
22682274 if (node->getActiveSocket() &&
22692275 ( node->getType() == NodeType::VoxelServer
22702276 || node->getType() == NodeType::ParticleServer
2271− || node->getType() == NodeType::ModelServer)
2277+ || node->getType() == NodeType::EntityServer)
22722278 ) {
22732279
22742280 QUuid nodeUUID = node->getUUID();
@@ -2335,13 +2341,7 @@ int Application::sendNackPackets() { · 60 unmodified lines
23352341
23362342 void Application::queryOctree(NodeType_t serverType, PacketType packetType, NodeToJurisdictionMap& jurisdictions) {
23372343
2338− // if voxels are disabled, then don't send this at all...
2339− if (!Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) {
2340− return;
2341− }
2342−
23432344 //qDebug() << ">>> inside... queryOctree()... _viewFrustum.getFieldOfView()=" << _viewFrustum.getFieldOfView();
2344−
23452345 bool wantExtraDebugging = getLogger()->extraDebugging();
23462346
23472347 // These will be the same for all servers, so we can set them up once and then reuse for each server we send to.
@@ -2659,9 +2659,20 @@ void Application::updateShadowMap() { · 311 unmodified lines
26592659 glEnable(GL_POLYGON_OFFSET_FILL);
26602660 glPolygonOffset(1.1f, 4.0f); // magic numbers courtesy http://www.eecs.berkeley.edu/~ravir/6160/papers/shadowmaps.ppt
26612661
2662− _avatarManager.renderAvatars(Avatar::SHADOW_RENDER_MODE);
2663− _particles.render(OctreeRenderer::SHADOW_RENDER_MODE);
2664− _models.render(OctreeRenderer::SHADOW_RENDER_MODE);
2662+ {
2663+ PerformanceTimer perfTimer("avatarManager");
2664+ _avatarManager.renderAvatars(Avatar::SHADOW_RENDER_MODE);
2665+ }
2666+
2667+ {
2668+ PerformanceTimer perfTimer("particles");
2669+ _particles.render(OctreeRenderer::SHADOW_RENDER_MODE);
2670+ }
2671+
2672+ {
2673+ PerformanceTimer perfTimer("entities");
2674+ _entities.render(OctreeRenderer::SHADOW_RENDER_MODE);
2675+ }
26652676
26662677 glDisable(GL_POLYGON_OFFSET_FILL);
26672678
@@ -2858,10 +2869,10 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 190 unmodified lines
28582869
28592870 // render models...
28602871 if (Menu::getInstance()->isOptionChecked(MenuOption::Models)) {
2861− PerformanceTimer perfTimer("models");
2872+ PerformanceTimer perfTimer("entities");
28622873 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
2863− "Application::displaySide() ... models...");
2864− _models.render();
2874+ "Application::displaySide() ... entities...");
2875+ _entities.render();
28652876 }
28662877
28672878 // render the ambient occlusion effect if enabled
@@ -3385,7 +3396,7 @@ void Application::domainChanged(const QString& domainHostname) { · 517 unmodified lines
33853396 _particles.clear();
33863397
33873398 // reset the model renderer
3388− _models.clear();
3399+ _entities.clear();
33893400
33903401 // reset the voxels renderer
33913402 _voxels.killLocalVoxels();
@@ -3424,7 +3435,7 @@ void Application::nodeKilled(SharedNodePointer node) { · 32 unmodified lines
34243435
34253436 _voxelEditSender.nodeKilled(node);
34263437 _particleEditSender.nodeKilled(node);
3427− _modelEditSender.nodeKilled(node);
3438+ _entityEditSender.nodeKilled(node);
34283439
34293440 if (node->getType() == NodeType::AudioMixer) {
34303441 QMetaObject::invokeMethod(&_audio, "audioMixerKilled");
@@ -3504,16 +3515,16 @@ void Application::nodeKilled(SharedNodePointer node) { · 73 unmodified lines
35043515 }
35053516 _octreeSceneStatsLock.unlock();
35063517
3507− } else if (node->getType() == NodeType::ModelServer) {
3518+ } else if (node->getType() == NodeType::EntityServer) {
35083519
35093520 QUuid nodeUUID = node->getUUID();
35103521 // see if this is the first we've heard of this node...
3511− _modelServerJurisdictions.lockForRead();
3512− if (_modelServerJurisdictions.find(nodeUUID) != _modelServerJurisdictions.end()) {
3513− unsigned char* rootCode = _modelServerJurisdictions[nodeUUID].getRootOctalCode();
3522+ _entityServerJurisdictions.lockForRead();
3523+ if (_entityServerJurisdictions.find(nodeUUID) != _entityServerJurisdictions.end()) {
3524+ unsigned char* rootCode = _entityServerJurisdictions[nodeUUID].getRootOctalCode();
35143525 VoxelPositionSize rootDetails;
35153526 voxelDetailsForCode(rootCode, rootDetails);
3516− _modelServerJurisdictions.unlock();
3527+ _entityServerJurisdictions.unlock();
35173528
35183529 qDebug("model server going away...... v[%f, %f, %f, %f]",
35193530 rootDetails.x, rootDetails.y, rootDetails.z, rootDetails.s);
@@ -3530,10 +3541,10 @@ void Application::nodeKilled(SharedNodePointer node) { · 10 unmodified lines
35303541 }
35313542
35323543 // If the model server is going away, remove it from our jurisdiction map so we don't send voxels to a dead server
3533− _modelServerJurisdictions.lockForWrite();
3534− _modelServerJurisdictions.erase(_modelServerJurisdictions.find(nodeUUID));
3544+ _entityServerJurisdictions.lockForWrite();
3545+ _entityServerJurisdictions.erase(_entityServerJurisdictions.find(nodeUUID));
35353546 }
3536− _modelServerJurisdictions.unlock();
3547+ _entityServerJurisdictions.unlock();
35373548
35383549 // also clean up scene stats for that server
35393550 _octreeSceneStatsLock.lockForWrite();
@@ -3599,8 +3610,8 @@ int Application::parseOctreeStats(const QByteArray& packet, const SharedNodePoin · 59 unmodified lines
35993610 jurisdiction = &_particleServerJurisdictions;
36003611 serverType = "Particle";
36013612 } else {
3602− jurisdiction = &_modelServerJurisdictions;
3603− serverType = "Model";
3613+ jurisdiction = &_entityServerJurisdictions;
3614+ serverType = "Entity";
36043615 }
36053616
36063617 jurisdiction->lockForRead();
@@ -3709,8 +3720,8 @@ ScriptEngine* Application::loadScript(const QString& scriptName, bool loadScript · 102 unmodified lines
37093720 scriptEngine->getParticlesScriptingInterface()->setPacketSender(&_particleEditSender);
37103721 scriptEngine->getParticlesScriptingInterface()->setParticleTree(_particles.getTree());
37113722
3712− scriptEngine->getModelsScriptingInterface()->setPacketSender(&_modelEditSender);
3713− scriptEngine->getModelsScriptingInterface()->setModelTree(_models.getTree());
3723+ scriptEngine->getEntityScriptingInterface()->setPacketSender(&_entityEditSender);
3724+ scriptEngine->getEntityScriptingInterface()->setEntityTree(_entities.getTree());
37143725
37153726 // model has some custom types
37163727 Model::registerMetaTypes(scriptEngine);

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