From 3df9ceda032f50400327ac9c42d016bf2a2743e4 Mon Sep 17 00:00:00 2001 From: unelsson Date: Sat, 2 Oct 2021 14:58:47 +0300 Subject: [PATCH] Remove measurement code --- apps/opencs/view/render/terrainselection.cpp | 66 -------------------- apps/opencs/view/render/terrainselection.hpp | 8 --- 2 files changed, 74 deletions(-) diff --git a/apps/opencs/view/render/terrainselection.cpp b/apps/opencs/view/render/terrainselection.cpp index dd1b982337..8b855fc91b 100644 --- a/apps/opencs/view/render/terrainselection.cpp +++ b/apps/opencs/view/render/terrainselection.cpp @@ -96,7 +96,6 @@ void CSVRender::TerrainSelection::update() void CSVRender::TerrainSelection::drawShapeSelection(const osg::ref_ptr vertices) { - resetMeasurements(); if (!mSelection.empty()) { for (std::pair &localPos : mSelection) @@ -129,12 +128,10 @@ void CSVRender::TerrainSelection::drawShapeSelection(const osg::ref_ptr vertices) { - resetMeasurements(); if (!mSelection.empty()) { const int landHeightsNudge = (ESM::Land::REAL_SIZE / ESM::Land::LAND_SIZE) / (ESM::Land::LAND_SIZE - 1); // Does this work with all land size configurations? @@ -203,7 +200,6 @@ void CSVRender::TerrainSelection::drawTextureSelection(const osg::ref_ptr>& localPositions, bool toggleInProgress, SelectionMethod selectionMethod) @@ -329,7 +325,6 @@ bool CSVRender::TerrainSelection::isLandLoaded(const std::string& cellId) int CSVRender::TerrainSelection::calculateLandHeight(int x, int y) // global vertex coordinates { - auto start = std::chrono::high_resolution_clock::now(); int cellX = std::floor(static_cast(x) / (ESM::Land::LAND_SIZE - 1)); int cellY = std::floor(static_cast(y) / (ESM::Land::LAND_SIZE - 1)); int localX = x - cellX * (ESM::Land::LAND_SIZE - 1); @@ -347,69 +342,8 @@ int CSVRender::TerrainSelection::calculateLandHeight(int x, int y) // global ver CSMDoc::Document& document = mWorldspaceWidget->getDocument(); std::string cellId = CSMWorld::CellCoordinates::generateId(cellX, cellY); const ESM::Land::LandData* landData = document.getData().getLand().getRecord(cellId).get().getLandData(ESM::Land::DATA_VHGT); - auto stop = std::chrono::high_resolution_clock::now(); - int duration = std::chrono::duration_cast(stop - start).count(); - mDurationsA += duration; - mDurationsAMeasurements++; return landData->mHeights[localY*ESM::Land::LAND_SIZE + localX]; } - auto stop = std::chrono::high_resolution_clock::now(); - int duration = std::chrono::duration_cast(stop - start).count(); - mDurationsB += duration; - mDurationsBMeasurements++; return landHeight; } - -/*int CSVRender::TerrainSelection::OldCalculateLandHeight(int x, int y) // global vertex coordinates -{ - auto start = std::chrono::high_resolution_clock::now(); - int cellX = std::floor(static_cast(x) / (ESM::Land::LAND_SIZE - 1)); - int cellY = std::floor(static_cast(y) / (ESM::Land::LAND_SIZE - 1)); - int localX = x - cellX * (ESM::Land::LAND_SIZE - 1); - int localY = y - cellY * (ESM::Land::LAND_SIZE - 1); - - CSMWorld::CellCoordinates coords (cellX, cellY); - - float landHeight = 0.f; - if (CSVRender::Cell* cell = dynamic_cast(mWorldspaceWidget->getCell(coords))) - { - landHeight = cell->getSumOfAlteredAndTrueHeight(cellX, cellY, localX, localY); - } - else if (isLandLoaded(CSMWorld::CellCoordinates::generateId(cellX, cellY))) - { - CSMDoc::Document& document = mWorldspaceWidget->getDocument(); - CSMWorld::IdTable& landTable = dynamic_cast ( *document.getData().getTableModel (CSMWorld::UniversalId::Type_Land)); - std::string cellId = CSMWorld::CellCoordinates::generateId(cellX, cellY); - int landshapeColumn = landTable.findColumnIndex(CSMWorld::Columns::ColumnId_LandHeightsIndex); - const CSMWorld::LandHeightsColumn::DataType mPointer = landTable.data(landTable.getModelIndex(cellId, landshapeColumn)).value(); - auto stop = std::chrono::high_resolution_clock::now(); - int duration = std::chrono::duration_cast(stop - start).count(); - mDurationsA += duration; - mDurationsAMeasurements++; - return mPointer[localY*ESM::Land::LAND_SIZE + localX]; - } - auto stop = std::chrono::high_resolution_clock::now(); - int duration = std::chrono::duration_cast(stop - start).count(); - mDurationsB += duration; - mDurationsBMeasurements++; - return landHeight; -}*/ - - -void CSVRender::TerrainSelection::resetMeasurements() -{ - mDurationsA = 0; - mDurationsB = 0; - mDurationsAMeasurements = 0; - mDurationsBMeasurements = 0; -} - -void CSVRender::TerrainSelection::printMeasurements() -{ - if (mDurationsAMeasurements != 0) - Log(Debug::Warning) << "A (total) " << mDurationsA << "(avg) " << mDurationsA / mDurationsAMeasurements << "(meas.) " << mDurationsAMeasurements; - - if (mDurationsBMeasurements != 0) - Log(Debug::Warning) << "B (total) " << mDurationsB << "(avg) " << mDurationsB / mDurationsBMeasurements << "(meas.) " << mDurationsBMeasurements; -} diff --git a/apps/opencs/view/render/terrainselection.hpp b/apps/opencs/view/render/terrainselection.hpp index c8c7bc7aab..868c3aea42 100644 --- a/apps/opencs/view/render/terrainselection.hpp +++ b/apps/opencs/view/render/terrainselection.hpp @@ -64,10 +64,6 @@ namespace CSVRender private: - void resetMeasurements(); - - void printMeasurements(); - void handleSelection(const std::vector>& localPositions, bool toggleInProgress, SelectionMethod selectionMethod); bool noCell(const std::string& cellId); @@ -87,10 +83,6 @@ namespace CSVRender std::vector> mTemporarySelection; // Used during toggle to compare the most recent drag operation bool mDraggedOperationFlag; //true during drag operation, false when click-operation TerrainSelectionType mSelectionType; - int mDurationsA; - int mDurationsB; - int mDurationsAMeasurements; - int mDurationsBMeasurements; }; }