QWidget *VegetableSettingsPage::createPage(QWidget *parent) { m_page = new QWidget(parent); m_ui.setupUi(m_page); QSettings *settings = Core::ICore::instance()->settings(); settings->beginGroup(Constants::OBJECT_VIEWER_SECTION); m_ui.tileBankLineEdit->setText(settings->value(Constants::VEGET_TILE_BANK, "").toString()); m_ui.tileFarBankLineEdit->setText(settings->value(Constants::VEGET_TILE_FAR_BANK, "").toString()); m_ui.vegetTextureLineEdit->setText(settings->value(Constants::VEGET_TEXTURE, "").toString()); m_ui.coarseLineEdit->setText(settings->value(Constants::COARSE_MESH_TEXTURE, "").toString()); m_ui.zonesListWidget->addItems(settings->value(Constants::VEGET_LANDSCAPE_ZONES).toStringList()); settings->endGroup(); connect(m_ui.tileBankToolButton, SIGNAL(clicked()), this, SLOT(setTileBank())); connect(m_ui.tileFarBankToolButton, SIGNAL(clicked()), this, SLOT(setTileFarBank())); connect(m_ui.vegetTexToolButton, SIGNAL(clicked()), this, SLOT(setTextureVegetable())); connect(m_ui.coarseToolButton, SIGNAL(clicked()), this, SLOT(setCoarseMeshTexture())); connect(m_ui.addZoneToolButton, SIGNAL(clicked()), this, SLOT(addZone())); connect(m_ui.removeZoneToolButton, SIGNAL(clicked()), this, SLOT(removeZone())); connect(m_ui.clearButton, SIGNAL(clicked()), m_ui.zonesListWidget, SLOT(clear())); return m_page; }
void SearchStructure::removeHiddenSurfaces( int threshold, size_t& removedZones, size_t& removedSurfaces) { removedZones = 0; removedSurfaces = 0; bool invertRemoval = (threshold < 0); threshold = glm::abs(threshold); std::vector<bool> removeSurface(_searchSurfaces.size()); for(int i=0; i < _searchSurfaces.size(); ++i) { bool remove = _searchSurfaces[i].hitCount .load(std::memory_order_relaxed) < threshold; if(invertRemoval) remove = !remove; if(remove) ++removedSurfaces; removeSurface[i] = remove; } std::vector<bool> removeZone(_searchZones.size()); for(int i=_searchZones.size()-1; i >= 0; --i) { SearchZone& zone = _searchZones[i]; bool remove = true; for(size_t z=i+1; z < zone.endZone; ++z) remove = remove && removeZone[z]; for(size_t s=zone.begSurf; s < zone.endSurf; ++s) remove = remove && removeSurface[s]; if(remove)++removedZones; removeZone[i] = remove; } std::vector<SearchZone> newZones; std::vector<SearchSurface> newSurfs; size_t cumZoneRemove = 0; size_t cumSurfRemove = 0; for(int i=0; i < _searchZones.size(); ++i) { SearchZone zone = _searchZones[i]; if(removeZone[i]) { ++cumZoneRemove; cumSurfRemove += zone.endSurf - zone.begSurf; } else { size_t preCumSurfRemove = cumSurfRemove; for(size_t s=zone.begSurf; s < zone.endSurf; ++s) { if(removeSurface[s]) ++cumSurfRemove; else newSurfs.push_back(_searchSurfaces[s]); } zone.begSurf -= preCumSurfRemove; zone.endSurf -= cumSurfRemove; size_t remZoneCount = 0; for(size_t z=i+1; z < zone.endZone; ++z) { if(removeZone[z]) ++remZoneCount; } zone.endZone -= (cumZoneRemove + remZoneCount); newZones.push_back(zone); } } std::swap(_searchZones, newZones); std::swap(_searchSurfaces, newSurfs); _isOptimized = true; }