From b22032e40a3557c63bc5f2b527c73259b7546a92 Mon Sep 17 00:00:00 2001 From: Chris Galvan Date: Fri, 18 Feb 2022 07:51:10 -0600 Subject: [PATCH] Removed legacy Editor LevelInfo class Signed-off-by: Chris Galvan --- Code/Editor/CryEdit.cpp | 10 -- Code/Editor/CryEdit.h | 1 - Code/Editor/LevelInfo.cpp | 178 ----------------------------- Code/Editor/LevelInfo.h | 30 ----- Code/Editor/MainWindow.cpp | 3 - Code/Editor/Resource.h | 2 - Code/Editor/editor_lib_files.cmake | 2 - 7 files changed, 226 deletions(-) delete mode 100644 Code/Editor/LevelInfo.cpp delete mode 100644 Code/Editor/LevelInfo.h diff --git a/Code/Editor/CryEdit.cpp b/Code/Editor/CryEdit.cpp index bf624d996e..0a7cc3b27a 100644 --- a/Code/Editor/CryEdit.cpp +++ b/Code/Editor/CryEdit.cpp @@ -104,7 +104,6 @@ AZ_POP_DISABLE_WARNING #include "WaitProgress.h" #include "ToolBox.h" -#include "LevelInfo.h" #include "EditorPreferencesDialog.h" #include "AnimationContext.h" @@ -422,7 +421,6 @@ void CCryEditApp::RegisterActionHandlers() ON_COMMAND(ID_DISPLAY_GOTOPOSITION, OnDisplayGotoPosition) ON_COMMAND(ID_FILE_SAVELEVELRESOURCES, OnFileSavelevelresources) ON_COMMAND(ID_CLEAR_REGISTRY, OnClearRegistryData) - ON_COMMAND(ID_VALIDATELEVEL, OnValidatelevel) ON_COMMAND(ID_TOOLS_PREFERENCES, OnToolsPreferences) ON_COMMAND(ID_SWITCHCAMERA_DEFAULTCAMERA, OnSwitchToDefaultCamera) ON_COMMAND(ID_SWITCHCAMERA_SEQUENCECAMERA, OnSwitchToSequenceCamera) @@ -3644,14 +3642,6 @@ void CCryEditApp::OnClearRegistryData() } } -////////////////////////////////////////////////////////////////////////// -void CCryEditApp::OnValidatelevel() -{ - // TODO: Add your command handler code here - CLevelInfo levelInfo; - levelInfo.Validate(); -} - ////////////////////////////////////////////////////////////////////////// void CCryEditApp::OnToolsPreferences() { diff --git a/Code/Editor/CryEdit.h b/Code/Editor/CryEdit.h index f472639dcd..2ed916a922 100644 --- a/Code/Editor/CryEdit.h +++ b/Code/Editor/CryEdit.h @@ -399,7 +399,6 @@ private: void OnDisplayGotoPosition(); void OnFileSavelevelresources(); void OnClearRegistryData(); - void OnValidatelevel(); void OnToolsPreferences(); void OnSwitchToDefaultCamera(); void OnUpdateSwitchToDefaultCamera(QAction* action); diff --git a/Code/Editor/LevelInfo.cpp b/Code/Editor/LevelInfo.cpp deleted file mode 100644 index 5ad7a6593d..0000000000 --- a/Code/Editor/LevelInfo.cpp +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - - -#include "EditorDefs.h" - -#include "LevelInfo.h" - -// Qt -#include - -// Editor -#include "Util/fastlib.h" - -#include - -#include "QtUI/WaitCursor.h" // for WaitCursor -#include "Include/IErrorReport.h" -#include "Include/IObjectManager.h" -#include "Objects/BaseObject.h" -#include "UsedResources.h" -#include "ErrorReport.h" - - -////////////////////////////////////////////////////////////////////////// -CLevelInfo::CLevelInfo() -{ - m_pReport = GetIEditor()->GetErrorReport(); -} - -////////////////////////////////////////////////////////////////////////// -void CLevelInfo::SaveLevelResources([[maybe_unused]] const QString& toPath) -{ -} - -////////////////////////////////////////////////////////////////////////// -void CLevelInfo::Validate() -{ - m_pReport->Clear(); - m_pReport->SetImmediateMode(false); - m_pReport->SetShowErrors(true); - - int nTotalErrors(0); - int nCurrentError(0); - - // Here we are appending the current level load errors to the general errors. - // Actually we are inserting them before all others, but this is not important :-). - IErrorReport* poLastLoadedLevelErrorReport = GetIEditor()->GetLastLoadedLevelErrorReport(); - if (poLastLoadedLevelErrorReport) - { - nTotalErrors = poLastLoadedLevelErrorReport->GetErrorCount(); - for (nCurrentError = 0; nCurrentError < nTotalErrors; ++nCurrentError) - { - m_pReport->ReportError(poLastLoadedLevelErrorReport->GetError(nCurrentError)); - } - } - - // Validate level. - ValidateObjects(); - - if (m_pReport->GetErrorCount() == 0) - { - QMessageBox::information(QApplication::activeWindow(), QString(), QObject::tr("No Errors Found")); - } - else - { - m_pReport->Display(); - } -} - -////////////////////////////////////////////////////////////////////////// -void CLevelInfo::ValidateObjects() -{ - WaitCursor cursor; - - // Validate all objects - CBaseObjectsArray objects; - GetIEditor()->GetObjectManager()->GetObjects(objects); - - int i; - - CLogFile::WriteLine("Validating Objects..."); - for (i = 0; i < objects.size(); i++) - { - CBaseObject* pObject = objects[i]; - - m_pReport->SetCurrentValidatorObject(pObject); - - pObject->Validate(m_pReport); - - m_pReport->SetCurrentValidatorObject(nullptr); - } - - CLogFile::WriteLine("Validating Duplicate Objects..."); - ////////////////////////////////////////////////////////////////////////// - // Find duplicate objects, Same objects with same transform. - // Use simple grid to speed up the check. - ////////////////////////////////////////////////////////////////////////// - int gridSize = 256; - - AZ::Aabb terrainAabb = AZ::Aabb::CreateFromPoint(AZ::Vector3::CreateZero()); - AzFramework::Terrain::TerrainDataRequestBus::BroadcastResult(terrainAabb, &AzFramework::Terrain::TerrainDataRequests::GetTerrainAabb); - float worldSize = terrainAabb.GetXExtent(); - - float fGridToWorld = worldSize / gridSize; - - // Put all objects into parition grid. - std::vector > grid; - grid.resize(gridSize * gridSize); - // Put objects to grid. - for (i = 0; i < objects.size(); i++) - { - CBaseObject* pObject = objects[i]; - Vec3 pos = pObject->GetWorldPos(); - int px = ftoi(pos.x / fGridToWorld); - int py = ftoi(pos.y / fGridToWorld); - if (px < 0) - { - px = 0; - } - if (py < 0) - { - py = 0; - } - if (px >= gridSize) - { - px = gridSize - 1; - } - if (py >= gridSize) - { - py = gridSize - 1; - } - grid[py * gridSize + px].push_back(pObject); - } - - std::list::iterator it1, it2; - // Check objects in grid. - for (i = 0; i < gridSize * gridSize; i++) - { - std::list::iterator first = grid[i].begin(); - std::list::iterator last = grid[i].end(); - for (it1 = first; it1 != last; ++it1) - { - for (it2 = first; it2 != it1; ++it2) - { - // Check if same object. - CBaseObject* p1 = *it1; - CBaseObject* p2 = *it2; - if (p1 != p2 && p1->GetClassDesc() == p2->GetClassDesc()) - { - // Same class. - Quat q1 = p1->GetRotation(); - Quat q2 = p2->GetRotation(); - if (p1->GetWorldPos() == p2->GetWorldPos() && q1.w == q2.w && IsEquivalent(q1.v, q2.v, 0) && p1->GetScale() == p2->GetScale()) - { - // Same transformation - // Check if objects are really same. - if (p1->IsSimilarObject(p2)) - { - // Report duplicate objects. - CErrorRecord err; - err.error = QObject::tr("Found multiple objects in the same location (class %1): %2 and %3") - .arg(p1->GetClassDesc()->ClassName(), p1->GetName(), p2->GetName()); - err.pObject = p1; - err.severity = CErrorRecord::ESEVERITY_ERROR; - m_pReport->ReportError(err); - } - } - } - } - } - } -} diff --git a/Code/Editor/LevelInfo.h b/Code/Editor/LevelInfo.h deleted file mode 100644 index ec1c498c70..0000000000 --- a/Code/Editor/LevelInfo.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - - -#ifndef CRYINCLUDE_EDITOR_LEVELINFO_H -#define CRYINCLUDE_EDITOR_LEVELINFO_H -#pragma once - -/*! CLevelInfo provides methods for getting information about current level. - */ -class CLevelInfo -{ -public: - CLevelInfo(); - void Validate(); - - void SaveLevelResources(const QString& toPath); - -private: - void ValidateObjects(); - - IErrorReport* m_pReport; -}; - -#endif // CRYINCLUDE_EDITOR_LEVELINFO_H diff --git a/Code/Editor/MainWindow.cpp b/Code/Editor/MainWindow.cpp index a1f054b57f..88c37f0eb0 100644 --- a/Code/Editor/MainWindow.cpp +++ b/Code/Editor/MainWindow.cpp @@ -1011,9 +1011,6 @@ void MainWindow::InitActions() am->AddAction(ID_TOOLS_ENABLEFILECHANGEMONITORING, tr("Enable File Change Monitoring")); am->AddAction(ID_CLEAR_REGISTRY, tr("Clear Registry Data")) .SetStatusTip(tr("Clear Registry Data")); - am->AddAction(ID_VALIDATELEVEL, tr("&Check Level for Errors")) - .SetStatusTip(tr("Validate Level")); - am->AddAction(ID_TOOLS_VALIDATEOBJECTPOSITIONS, tr("Check Object Positions")); QAction* saveLevelStatsAction = am->AddAction(ID_TOOLS_LOGMEMORYUSAGE, tr("Save Level Statistics")) .SetStatusTip(tr("Logs Editor memory usage.")); diff --git a/Code/Editor/Resource.h b/Code/Editor/Resource.h index ef72bfc9be..1ffc137ab7 100644 --- a/Code/Editor/Resource.h +++ b/Code/Editor/Resource.h @@ -86,7 +86,6 @@ #define ID_PHYSICS_RESETPHYSICSSTATE 32938 #define ID_GAME_SYNCPLAYER 32941 #define ID_FILE_SAVELEVELRESOURCES 32942 -#define ID_VALIDATELEVEL 32943 #define ID_TERRAIN_RESIZE 32944 #define ID_TERRAIN_COLLISION 32960 #define ID_TOOL_FIRST 32972 @@ -236,7 +235,6 @@ #define ID_SNAP_TO_GRID_RANGE_END 34106 #define ID_TOOLS_EXPORT_SHORTCUTS 34138 #define ID_TOOLS_IMPORT_SHORTCUTS 34139 -#define ID_TOOLS_VALIDATEOBJECTPOSITIONS 34143 #define ID_TOOLS_BATCH_RENDER 34151 #define ID_TOOLS_SCRIPTHELP 34152 #define ID_TV_MODE_OPENCURVEEDITOR 34153 diff --git a/Code/Editor/editor_lib_files.cmake b/Code/Editor/editor_lib_files.cmake index 53cfe243b1..1100fdc868 100644 --- a/Code/Editor/editor_lib_files.cmake +++ b/Code/Editor/editor_lib_files.cmake @@ -532,8 +532,6 @@ set(FILES ErrorReport.h IconManager.cpp IconManager.h - LevelInfo.cpp - LevelInfo.h ProcessInfo.cpp ProcessInfo.h TrackView/AtomOutputFrameCapture.cpp