Removed legacy Editor LevelInfo class

Signed-off-by: Chris Galvan <chgalvan@amazon.com>
development
Chris Galvan 4 years ago
parent fdb9c053ce
commit b22032e40a

@ -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()
{

@ -399,7 +399,6 @@ private:
void OnDisplayGotoPosition();
void OnFileSavelevelresources();
void OnClearRegistryData();
void OnValidatelevel();
void OnToolsPreferences();
void OnSwitchToDefaultCamera();
void OnUpdateSwitchToDefaultCamera(QAction* action);

@ -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 <QMessageBox>
// Editor
#include "Util/fastlib.h"
#include <AzFramework/Terrain/TerrainDataRequestBus.h>
#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<std::list<CBaseObject*> > 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<CBaseObject*>::iterator it1, it2;
// Check objects in grid.
for (i = 0; i < gridSize * gridSize; i++)
{
std::list<CBaseObject*>::iterator first = grid[i].begin();
std::list<CBaseObject*>::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);
}
}
}
}
}
}
}

@ -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

@ -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."));

@ -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

@ -532,8 +532,6 @@ set(FILES
ErrorReport.h
IconManager.cpp
IconManager.h
LevelInfo.cpp
LevelInfo.h
ProcessInfo.cpp
ProcessInfo.h
TrackView/AtomOutputFrameCapture.cpp

Loading…
Cancel
Save