Cry Legacy: the Lessening (#5961)

* Generic Cleanup

Removals:

* Unused cvars,member variables and defines
* Windows media center edition support routines
* CSystem - removed debug_GetCallStackRaw/GetRootWindowMessageHandler/
UnloadDLL/ShutdownModuleLibraries

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* Fix CryMessageBox return values in Windows build

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* Remove named selection group and a few smaller unused functionalities

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* Remove ObjectManager export functionality + 2 deprecated functions

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* Remove object legacy freeze/hide support from ObjectManager

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* Remove ObjectManager duplicate name dection, as well as object renaming

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* Remove ObjectManager serialization and selection callbacks

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* ObjectManager - remove MoveObjects/HitTestObject/EndEditParams and related members/functions

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* Remove a bunch of unused clone related functionality + misc

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* ObjectManager - misc removals

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* ObjectManager - more removals

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* Remove unused object selection/retrieval in ObjectManager and LoadObjects in ObjectLoader

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* CBaseObject - remove unused material layers mask support

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* More CBaseObject cleanups.

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* CBaseObject - remove SubObj functions and IMouseCreateCallback

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* Remove unused procedural floor management, helper scale and tags.

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* CBaseObject - remove more unused methods.

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* Removals in multiple places.

CBaseObject - unused `OBJTYPE_DUMMY` flag removed, member `IsSameClass`
CObjectArchive removed unused methods/members
CObjectManager removed unused `Update` method

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* More removals

IDisplayViewport - HitTestLine/GetGridStep/setHitcontext/
GetConstructionPlane
Unused Cry_Matrix44 template specializations.

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* O3DE.exe Project-Centric "Open Editor" fix (#5852)

* The O3DE.exe Open Editor button now attempts to open the Editor in the
build directory of the project being opened.

If their is no Editor within the build directory of the Project, it uses
the Editor.exe in the current O3DE.exe executable directory if it exists

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Engine .gitignore now ignores the build directory if placed in the
AutomatedTesting project

Previously it was just ignoring a `[Bb]uild` directory if it was
directly within the engine root.
This change matches the behavior of the project templates.

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Renamed the ProjectUtils GetEditorDirectory function to
GetEditorExecutablePath

Added a platform specific implementation for retrieving the path to the
Editor executable in the GetEditorExectuablePath function.

It first attempts to locate the Editor via checking the project build
directory for an Editor executable before falling back to checking the
binary directory of the currently running O3DE executable.

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Correct the MacOS GetEditorExecutablePath to return the Editor path

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>
Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* Adding missing C++20 std::erase implementations (#5735)

There were already implementations for std::erase_if.
This adds the counterpart AZStd::erase versions

resolves #5734

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>
Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* More removals and refactors

`ShowMessage` and `CryMessageBox` return void now
Simplify code in `CSystem::WarningV`
Remove unused `CryGetTicksPerSec`
Remove unused WinBase functionality
Replace `nanosleep` call in WinBase with `std::this_thread::sleep_for`
Remove unused Win32Wrapper routines
Remove unused IFunctorBase.h and IEntityObjectListener.h
Fix VectorAndArray.cpp compilation
Use QMessageBox instead of CryMessageBox in the editor.
Remove empty ArchiveVars platform specific files

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* Fix test code.

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* Remove an unused  function

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* CBaseObject and undo description removals.

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* A bunch of removals

* Remove IRenderNode
* Remove editor's KDTree
* Remove StatObjBus, InstanceStatObjEventBus::ReleaseData is redundant (
same functionality in the only available handler is triggered by
`OnCryEditorCloseScene`)
* Remove CExportManager::AddStatObj/AddMeshes/AddMesh,
IExportManager::ExportSingleStatObj
* Remove CIconManager/IIconManager::GetObject
* Remove CBaseObject::IntersectRayMesh
* Remove IIndexedMesh and related structs.
* Unused IUndoObject::GetDescription and all derived implementations.
* Unused CUndoBaseLibrary/CUndoBaseLibraryManager
* Unused Matrix34_tpl typedefs
* Legacy Xml classes cleanup

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* Remove unused `Vec3ToVector3D` helper

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* fix - remove unused static variable

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

Co-authored-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>
monroegm-disable-blank-issue-2
Artur K 4 years ago committed by GitHub
parent a3835d8545
commit 56904d1799
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -67,30 +67,6 @@ if (editor.EditorToolsApplicationRequestBus(bus.Broadcast, 'GetCurrentLevelName'
if(general.get_num_selected() == 0):
print("clear_selection works")
general.hide_all_objects()
if(general.is_object_hidden(objs_list[1])):
print("hide_all_objects works")
general.unhide_object(objs_list[1])
if not(general.is_object_hidden(objs_list[1])):
print("unhide_object works")
general.hide_object(objs_list[1])
if(general.is_object_hidden(objs_list[1])):
print("hide_object works")
general.unhide_all_objects()
general.freeze_object(objs_list[1])
if(general.is_object_frozen(objs_list[1])):
print("freeze_object works")
general.unfreeze_object(objs_list[1])
position = general.get_position(objs_list[1])
px1, py1, pz1 = fetch_vector3_parts(position)
general.set_position(objs_list[1], px1 + 10, py1 - 4, pz1 + 3)

@ -14,66 +14,6 @@
#include "Include/IBaseLibraryManager.h"
#include <Util/PathUtil.h>
#include <IFileUtil.h>
#include "Undo/IUndoObject.h"
//////////////////////////////////////////////////////////////////////////
// Undo functionality for libraries.
//////////////////////////////////////////////////////////////////////////
class CUndoBaseLibrary
: public IUndoObject
{
public:
CUndoBaseLibrary(CBaseLibrary* pLib, const QString& description, const QString& selectedItem = QString())
: m_pLib(pLib)
, m_description(description)
, m_redo(nullptr)
, m_selectedItem(selectedItem)
{
assert(m_pLib);
m_undo = GetIEditor()->GetSystem()->CreateXmlNode("Undo");
m_pLib->Serialize(m_undo, false);
}
QString GetEditorObjectName() override
{
return m_selectedItem;
}
protected:
int GetSize() override { return sizeof(CUndoBaseLibrary); }
QString GetDescription() override { return m_description; };
void Undo(bool bUndo) override
{
if (bUndo)
{
m_redo = GetIEditor()->GetSystem()->CreateXmlNode("Redo");
m_pLib->Serialize(m_redo, false);
}
m_pLib->Serialize(m_undo, true);
m_pLib->SetModified();
GetIEditor()->Notify(eNotify_OnDataBaseUpdate);
}
void Redo() override
{
m_pLib->Serialize(m_redo, true);
m_pLib->SetModified();
GetIEditor()->Notify(eNotify_OnDataBaseUpdate);
}
private:
QString m_description;
QString m_selectedItem;
_smart_ptr<CBaseLibrary> m_pLib;
XmlNodeRef m_undo;
XmlNodeRef m_redo;
};
//////////////////////////////////////////////////////////////////////////
// CBaseLibrary implementation.

@ -29,7 +29,6 @@ public:
assert(libMgr);
m_itemPath = libItem->GetFullName();
m_description = "Lib item changed: " + m_itemPath;
//serialize the lib item to undo
m_undoCtx.node = GetIEditor()->GetSystem()->CreateXmlNode("Undo");
@ -45,13 +44,8 @@ public:
m_size = sizeof(CUndoBaseLibraryItem);
m_size += static_cast<int>(xmlStr.GetAllocatedMemory());
m_size += m_itemPath.length();
m_size += m_description.length();
}
QString GetEditorObjectName() override
{
return m_itemPath;
}
protected:
int GetSize() override
@ -59,11 +53,6 @@ protected:
return m_size;
}
QString GetDescription() override
{
return m_description;
}
void Undo(bool bUndo) override
{
//find the libItem
@ -111,7 +100,6 @@ protected:
}
private:
QString m_description;
QString m_itemPath;
IDataBaseItem::SerializeContext m_undoCtx; //saved before operation
IDataBaseItem::SerializeContext m_redoCtx; //saved after operation so used for redo

@ -17,120 +17,6 @@
#include "ErrorReport.h"
#include "Undo/IUndoObject.h"
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Undo functionality for Managers, including add library, remove library, and rename library -- Vera, Confetti
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class CUndoBaseLibraryManager
: public IUndoObject
{
public:
CUndoBaseLibraryManager(CBaseLibraryManager* pMngr, const QString& description, const QString& modifiedManager = nullptr)
: m_pMngr(pMngr)
, m_description(description)
, m_editorObject(modifiedManager)
{
assert(m_pMngr);
SerializeTo(m_undos);
}
QString GetEditorObjectName() override
{
return m_editorObject;
}
protected:
int GetSize() override { return sizeof(CUndoBaseLibraryManager); }
QString GetDescription() override { return m_description; };
void Undo(bool bUndo) override
{
if (bUndo)
{
SerializeTo(m_redos);
}
m_pMngr->ClearAll();
UnserializeFrom(m_undos);
GetIEditor()->Notify(eNotify_OnDataBaseUpdate);
}
void Redo() override
{
m_pMngr->ClearAll();
UnserializeFrom(m_redos);
GetIEditor()->Notify(eNotify_OnDataBaseUpdate);
}
private:
struct LibUndoNode
: public _i_reference_target_t
{
LibUndoNode()
{
node = nullptr;
fileName = "";
}
XmlNodeRef node;
QString fileName;
};
static const char* const LIBRARY_TAG;
static const char* const LEVEL_LIBRARY_TAG;
void SerializeTo(std::vector<_smart_ptr<LibUndoNode> >& undos) // Save Library Undo
{
undos.clear();
for (int i = 0; i < m_pMngr->GetLibraryCount(); i++)
{
IDataBaseLibrary* library = m_pMngr->GetLibrary(i);
const char* tag = library->IsLevelLibrary() ? LEVEL_LIBRARY_TAG : LIBRARY_TAG;
XmlNodeRef node = GetIEditor()->GetSystem()->CreateXmlNode(tag);
QString file = library->GetFilename().isEmpty() ? library->GetFilename() : library->GetName();
library->Serialize(node, false);
if (node && !file.isEmpty())
{
_smart_ptr<LibUndoNode> undo = new LibUndoNode();
undo->fileName = file;
undo->node = node;
undos.push_back(undo);
}
}
}
void UnserializeFrom(std::vector<_smart_ptr<LibUndoNode> >& undos) // Load Library Undo
{
for (int i = 0; i < undos.size(); i++)
{
_smart_ptr<LibUndoNode> undo = undos[i];
if (undo->node && !undo->fileName.isEmpty())
{
//AddLibrary adds a .xml to the end of the library path, this will remove the extra for compatibility
undo->fileName.replace(m_pMngr->GetLibsPath().toLower(), "");
undo->fileName.replace(".xml", "");
const bool isLevelLibrary = (strcmp(undo->node->getTag(), LEVEL_LIBRARY_TAG) == 0);
IDataBaseLibrary* library = m_pMngr->AddLibrary(undo->fileName, isLevelLibrary);
library->Serialize(undo->node, true);
}
}
}
QString m_description;
QString m_editorObject;
CBaseLibraryManager* m_pMngr;
std::vector<_smart_ptr<LibUndoNode> > m_undos;
std::vector<_smart_ptr<LibUndoNode> > m_redos;
};
const char* const CUndoBaseLibraryManager::LIBRARY_TAG = "UndoLibrary";
const char* const CUndoBaseLibraryManager::LEVEL_LIBRARY_TAG = "UndoLevelLibrary";
//////////////////////////////////////////////////////////////////////////
// CBaseLibraryManager implementation.
//////////////////////////////////////////////////////////////////////////

@ -82,7 +82,6 @@ protected:
}
int GetSize() override { return sizeof(*this); }
QString GetDescription() override { return "UndoSplineCtrlEx"; };
void Undo(bool bUndo) override
{

@ -33,6 +33,7 @@ AZ_POP_DISABLE_WARNING
#include <QScopedValueRollback>
#include <QClipboard>
#include <QMenuBar>
#include <QMessageBox>
#include <QDialogButtonBox>
// Aws Native SDK
@ -4016,7 +4017,7 @@ void CCryEditApp::OnError(AzFramework::AssetSystem::AssetSystemErrors error)
break;
}
CryMessageBox(errorMessage.c_str(), "Error", MB_OK | MB_ICONERROR | MB_SETFOREGROUND);
QMessageBox::critical(nullptr,"Error",errorMessage.c_str());
}
void CCryEditApp::OnOpenProceduralMaterialEditor()

@ -51,7 +51,6 @@
#include "GameExporter.h"
#include "MainWindow.h"
#include "LevelFileDialog.h"
#include "StatObjBus.h"
#include "Undo/Undo.h"
#include <Atom/RPI.Public/ViewportContext.h>
@ -246,9 +245,6 @@ void CCryEditDoc::DeleteContents()
EBUS_EVENT(AzToolsFramework::EditorEntityContextRequestBus, ResetEditorContext);
// [LY-90904] move this to the EditorVegetationManager component
InstanceStatObjEventBus::Broadcast(&InstanceStatObjEventBus::Events::ReleaseData);
//////////////////////////////////////////////////////////////////////////
// Clear all undo info.
//////////////////////////////////////////////////////////////////////////
@ -308,8 +304,6 @@ void CCryEditDoc::Save(TDocMultiArchive& arrXmlAr)
// Fog settings ///////////////////////////////////////////////////////
SerializeFogSettings((*arrXmlAr[DMAS_GENERAL]));
SerializeNameSelection((*arrXmlAr[DMAS_GENERAL]));
}
}
AfterSave();
@ -455,12 +449,6 @@ void CCryEditDoc::Load(TDocMultiArchive& arrXmlAr, const QString& szFilename)
}
}
if (!isPrefabEnabled)
{
// Name Selection groups
SerializeNameSelection((*arrXmlAr[DMAS_GENERAL]));
}
{
CAutoLogTime logtime("Post Load");
@ -595,16 +583,6 @@ void CCryEditDoc::SerializeFogSettings(CXmlArchive& xmlAr)
}
}
void CCryEditDoc::SerializeNameSelection(CXmlArchive& xmlAr)
{
IObjectManager* pObjManager = GetIEditor()->GetObjectManager();
if (pObjManager)
{
pObjManager->SerializeNameSelection(xmlAr.root, xmlAr.bLoading);
}
}
void CCryEditDoc::SetModifiedModules(EModifiedModule eModifiedModule, bool boSet)
{
if (!boSet)

@ -24,7 +24,6 @@
#include <IEditor.h>
#endif
class CClouds;
struct LightingSettings;
struct IVariable;
struct ICVar;
@ -124,7 +123,6 @@ public: // Create from serialization only
const char* GetTemporaryLevelName() const;
void DeleteTemporaryLevel();
CClouds* GetClouds() { return m_pClouds; }
void SetWaterColor(const QColor& col) { m_waterColor = col; }
QColor GetWaterColor() const { return m_waterColor; }
XmlNodeRef& GetFogTemplate() { return m_fogTemplate; }
@ -163,7 +161,6 @@ protected:
bool LoadEntitiesFromSlice(const QString& sliceFile);
void SerializeFogSettings(CXmlArchive& xmlAr);
virtual void SerializeViewSettings(CXmlArchive& xmlAr);
void SerializeNameSelection(CXmlArchive& xmlAr);
void LogLoadTime(int time) const;
struct TSaveDocContext
@ -195,7 +192,6 @@ protected:
QColor m_waterColor = QColor(0, 0, 255);
XmlNodeRef m_fogTemplate;
XmlNodeRef m_environmentTemplate;
CClouds* m_pClouds;
std::list<IDocListener*> m_listeners;
bool m_bDocumentReady = false;
ICVar* doc_validate_surface_types = nullptr;

@ -97,9 +97,6 @@
#include <QtGui/private/qhighdpiscaling_p.h>
#include <IEntityRenderState.h>
#include <IStatObj.h>
AZ_CVAR(
bool, ed_visibility_logTiming, false, nullptr, AZ::ConsoleFunctorFlags::Null, "Output the timing of the new IVisibilitySystem query");

@ -35,20 +35,8 @@
#include "Resource.h"
#include "Plugins/ComponentEntityEditorPlugin/Objects/ComponentEntityObject.h"
#include <IEntityRenderState.h>
#include <IStatObj.h>
namespace
{
inline Export::Vector3D Vec3ToVector3D(const Vec3& vec)
{
Export::Vector3D ret;
ret.x = vec.x;
ret.y = vec.y;
ret.z = vec.z;
return ret;
}
const float kTangentDelta = 0.01f;
const float kAspectRatio = 1.777778f;
const int kReserveCount = 7; // x,y,z,rot_x,rot_y,rot_z,fov
@ -106,22 +94,22 @@ void Export::CData::Clear()
// CExportManager
CExportManager::CExportManager()
: m_isPrecaching(false)
, m_pBaseObj(nullptr)
, m_FBXBakedExportFPS(0.0f)
, m_fScale(100.0f)
, m_bAnimationExport(false)
, m_pBaseObj(nullptr)
, // this scale is used by CryEngine RC
m_bAnimationExport(false)
m_FBXBakedExportFPS(0.0f)
, m_bExportLocalCoords(false)
, m_bExportOnlyPrimaryCamera(false)
, m_numberOfExportFrames(0)
, m_pivotEntityObject(nullptr)
, m_bBakedKeysSequenceExport(true)
, m_animTimeExportPrimarySequenceCurrentTime(0.0f)
, m_animKeyTimeExport(true)
, m_soundKeyTimeExport(true)
, m_bExportOnlyPrimaryCamera(false)
{
RegisterExporter(new COBJExporter());
RegisterExporter(new COCMExporter());
CExportManager::RegisterExporter(new COBJExporter());
CExportManager::RegisterExporter(new COCMExporter());
}
@ -313,203 +301,6 @@ void CExportManager::AddEntityAnimationData(AZ::EntityId entityId)
ProcessEntityAnimationTrack(entityId, pObj, AnimParamType::Rotation);
}
void CExportManager::AddMesh(Export::CObject* pObj, const IIndexedMesh* pIndMesh, Matrix34A* pTm)
{
if (m_isPrecaching || !pObj)
{
return;
}
pObj->m_MeshHash = reinterpret_cast<size_t>(pIndMesh);
IIndexedMesh::SMeshDescription meshDesc;
pIndMesh->GetMeshDescription(meshDesc);
// if we have subset of meshes we need to duplicate vertices,
// keep transformation of submesh,
// and store new offset for indices
int newOffsetIndex = pObj->GetVertexCount();
if (meshDesc.m_nVertCount)
{
pObj->m_vertices.reserve(meshDesc.m_nVertCount + newOffsetIndex);
pObj->m_normals.reserve(meshDesc.m_nVertCount + newOffsetIndex);
}
for (int v = 0; v < meshDesc.m_nVertCount; ++v)
{
Vec3 n = meshDesc.m_pNorms[v].GetN();
Vec3 tmp = (meshDesc.m_pVerts ? meshDesc.m_pVerts[v] : meshDesc.m_pVertsF16[v].ToVec3());
if (pTm)
{
tmp = pTm->TransformPoint(tmp);
}
pObj->m_vertices.push_back(Vec3ToVector3D(tmp * m_fScale));
pObj->m_normals.push_back(Vec3ToVector3D(n));
}
if (meshDesc.m_nCoorCount)
{
pObj->m_texCoords.reserve(meshDesc.m_nCoorCount + newOffsetIndex);
}
for (int v = 0; v < meshDesc.m_nCoorCount; ++v)
{
Vec2 uv = meshDesc.m_pTexCoord[v].GetUV();
uv.y = 1.0f - uv.y;
pObj->m_texCoords.push_back({uv.x,uv.y});
}
if (pIndMesh->GetSubSetCount() && !(pIndMesh->GetSubSetCount() == 1 && pIndMesh->GetSubSet(0).nNumIndices == 0))
{
for (int i = 0; i < pIndMesh->GetSubSetCount(); ++i)
{
Export::CMesh* pMesh = new Export::CMesh();
const SMeshSubset& sms = pIndMesh->GetSubSet(i);
const vtx_idx* pIndices = &meshDesc.m_pIndices[sms.nFirstIndexId];
int nTris = sms.nNumIndices / 3;
pMesh->m_faces.reserve(nTris);
for (int f = 0; f < nTris; ++f)
{
Export::Face face;
face.idx[0] = *(pIndices++) + newOffsetIndex;
face.idx[1] = *(pIndices++) + newOffsetIndex;
face.idx[2] = *(pIndices++) + newOffsetIndex;
pMesh->m_faces.push_back(face);
}
pObj->m_meshes.push_back(pMesh);
}
}
else
{
Export::CMesh* pMesh = new Export::CMesh();
if (meshDesc.m_nFaceCount == 0 && meshDesc.m_nIndexCount != 0 && meshDesc.m_pIndices != nullptr)
{
const vtx_idx* pIndices = &meshDesc.m_pIndices[0];
int nTris = meshDesc.m_nIndexCount / 3;
pMesh->m_faces.reserve(nTris);
for (int f = 0; f < nTris; ++f)
{
Export::Face face;
face.idx[0] = *(pIndices++) + newOffsetIndex;
face.idx[1] = *(pIndices++) + newOffsetIndex;
face.idx[2] = *(pIndices++) + newOffsetIndex;
pMesh->m_faces.push_back(face);
}
}
else
{
pMesh->m_faces.reserve(meshDesc.m_nFaceCount);
for (int f = 0; f < meshDesc.m_nFaceCount; ++f)
{
Export::Face face;
face.idx[0] = meshDesc.m_pFaces[f].v[0];
face.idx[1] = meshDesc.m_pFaces[f].v[1];
face.idx[2] = meshDesc.m_pFaces[f].v[2];
pMesh->m_faces.push_back(face);
}
}
pObj->m_meshes.push_back(pMesh);
}
}
bool CExportManager::AddStatObj(Export::CObject* pObj, IStatObj* pStatObj, Matrix34A* pTm)
{
IIndexedMesh* pIndMesh = nullptr;
if (pStatObj->GetSubObjectCount())
{
for (int i = 0; i < pStatObj->GetSubObjectCount(); i++)
{
IStatObj::SSubObject* pSubObj = pStatObj->GetSubObject(i);
if (pSubObj && pSubObj->nType == STATIC_SUB_OBJECT_MESH && pSubObj->pStatObj)
{
pIndMesh = nullptr;
if (m_isOccluder)
{
if (pSubObj->pStatObj->GetLodObject(2))
{
pIndMesh = pSubObj->pStatObj->GetLodObject(2)->GetIndexedMesh(true);
}
if (!pIndMesh && pSubObj->pStatObj->GetLodObject(1))
{
pIndMesh = pSubObj->pStatObj->GetLodObject(1)->GetIndexedMesh(true);
}
}
if (!pIndMesh)
{
pIndMesh = pSubObj->pStatObj->GetIndexedMesh(true);
}
if (pIndMesh)
{
AddMesh(pObj, pIndMesh, pTm);
}
}
}
}
if (!pIndMesh)
{
if (m_isOccluder)
{
if (pStatObj->GetLodObject(2))
{
pIndMesh = pStatObj->GetLodObject(2)->GetIndexedMesh(true);
}
if (!pIndMesh && pStatObj->GetLodObject(1))
{
pIndMesh = pStatObj->GetLodObject(1)->GetIndexedMesh(true);
}
}
if (!pIndMesh)
{
pIndMesh = pStatObj->GetIndexedMesh(true);
}
if (pIndMesh)
{
AddMesh(pObj, pIndMesh, pTm);
}
}
return true;
}
bool CExportManager::AddMeshes(Export::CObject* pObj)
{
if (m_pBaseObj->GetType() == OBJTYPE_AZENTITY)
{
CEntityObject* pEntityObject = (CEntityObject*)m_pBaseObj;
IRenderNode* pEngineNode = pEntityObject->GetEngineNode();
if (pEngineNode)
{
if (!m_isPrecaching)
{
for (int i = 0; i < pEngineNode->GetSlotCount(); ++i)
{
Matrix34A tm;
IStatObj* pStatObj = pEngineNode->GetEntityStatObj(i, 0, &tm);
if (pStatObj)
{
Matrix34A objTM = m_pBaseObj->GetWorldTM();
objTM.Invert();
tm = objTM * tm;
AddStatObj(pObj, pStatObj, &tm);
}
}
}
}
}
return true;
}
bool CExportManager::AddObject(CBaseObject* pBaseObj)
{
if (m_isOccluder)
@ -531,7 +322,6 @@ bool CExportManager::AddObject(CBaseObject* pBaseObj)
if (m_isPrecaching)
{
AddMeshes(nullptr);
return true;
}
@ -542,7 +332,6 @@ bool CExportManager::AddObject(CBaseObject* pBaseObj)
m_objectMap[pBaseObj] = int(m_data.m_objects.size() - 1);
AddMeshes(pObj);
m_pBaseObj = nullptr;
return true;
@ -1227,15 +1016,6 @@ bool CExportManager::ImportFromFile(const char* filename)
return bRet;
}
bool CExportManager::ExportSingleStatObj(IStatObj* pStatObj, const char* filename)
{
Export::CObject* pObj = new Export::CObject(Path::GetFileName(filename).toUtf8().data());
AddStatObj(pObj, pStatObj);
m_data.m_objects.push_back(pObj);
ExportToFile(filename, true);
return true;
}
void CExportManager::SaveNodeKeysTimeToXML()
{
CTrackViewSequence* pSequence = GetIEditor()->GetAnimation()->GetSequence();

@ -139,18 +139,11 @@ public:
bool ImportFromFile(const char* filename);
const Export::CData& GetData() const {return m_data; };
//! Exports the stat obj to the obj file specified
//! returns true if succeeded, otherwise false
bool ExportSingleStatObj(IStatObj* pStatObj, const char* filename) override;
void SetBakedKeysSequenceExport(bool bBaked){m_bBakedKeysSequenceExport = bBaked; };
void SaveNodeKeysTimeToXML();
private:
void AddMesh(Export::CObject* pObj, const IIndexedMesh* pIndMesh, Matrix34A* pTm = nullptr);
bool AddStatObj(Export::CObject* pObj, IStatObj* pStatObj, Matrix34A* pTm = nullptr);
bool AddMeshes(Export::CObject* pObj);
bool AddObject(CBaseObject* pBaseObj);
void SolveHierarchy();

@ -157,20 +157,20 @@ struct SSystemUserCallback
}
}
int ShowMessage(const char* text, const char* caption, unsigned int uType) override
void ShowMessage(const char* text, const char* caption, unsigned int uType) override
{
if (CCryEditApp::instance()->IsInAutotestMode())
{
return IDOK;
return;
}
const UINT kMessageBoxButtonMask = 0x000f;
if (!GetIEditor()->IsInGameMode() && (uType == 0 || uType == MB_OK || !(uType & kMessageBoxButtonMask)))
{
static_cast<CEditorImpl*>(GetIEditor())->AddErrorMessage(text, caption);
return IDOK;
return;
}
return CryMessageBox(text, caption, uType);
CryMessageBox(text, caption, uType);
}
void OnSplashScreenDone()

@ -8,17 +8,11 @@
// Description : The game engine for editor
#ifndef CRYINCLUDE_EDITOR_GAMEENGINE_H
#define CRYINCLUDE_EDITOR_GAMEENGINE_H
#pragma once
#if !defined(Q_MOC_RUN)
#include <AzCore/Outcome/Outcome.h>
#include "LogFile.h"
#include "CryListenerSet.h"
#include "Util/ModalWindowDismisser.h"
#endif
@ -159,5 +153,3 @@ private:
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
};
#endif // CRYINCLUDE_EDITOR_GAMEENGINE_H

@ -146,13 +146,11 @@ bool CGameExporter::Export(unsigned int flags, [[maybe_unused]] EEndian eExportE
exportSuccessful = false;
}
if (exportSuccessful)
if (exportSuccessful && m_bAutoExportMode)
{
if (m_bAutoExportMode)
{
// Remove read-only flags.
CrySetFileAttributes(m_levelPak.m_sPath.toUtf8().data(), FILE_ATTRIBUTE_NORMAL);
}
// Remove read-only flags.
auto perms = QFile::permissions(m_levelPak.m_sPath) | QFile::Permission::WriteOwner;
QFile::setPermissions(m_levelPak.m_sPath, perms);
}
//////////////////////////////////////////////////////////////////////////

@ -508,8 +508,6 @@ struct IEditor
virtual CBaseObject* NewObject(const char* typeName, const char* fileName = "", const char* name = "", float x = 0.0f, float y = 0.0f, float z = 0.0f, bool modifyDoc = true) = 0;
//! Delete object
virtual void DeleteObject(CBaseObject* obj) = 0;
//! Clone object
virtual CBaseObject* CloneObject(CBaseObject* obj) = 0;
//! Get current selection group
virtual CSelectionGroup* GetSelection() = 0;
virtual CBaseObject* GetSelectedObject() = 0;

@ -397,11 +397,6 @@ void CEditorImpl::Update()
// Make sure this is not called recursively
m_bUpdates = false;
//@FIXME: Restore this latter.
//if (GetGameEngine() && GetGameEngine()->IsLevelLoaded())
{
m_pObjectManager->Update();
}
if (IsInPreviewMode())
{
SetModifiedFlag(false);
@ -687,13 +682,6 @@ void CEditorImpl::DeleteObject(CBaseObject* obj)
GetObjectManager()->DeleteObject(obj);
}
CBaseObject* CEditorImpl::CloneObject(CBaseObject* obj)
{
SetModifiedFlag();
GetIEditor()->SetModifiedModule(eModifiedBrushes);
return GetObjectManager()->CloneObject(obj);
}
CBaseObject* CEditorImpl::GetSelectedObject()
{
if (m_pObjectManager->GetSelection()->GetCount() != 1)

@ -141,7 +141,6 @@ public:
const SGizmoParameters& GetGlobalGizmoParameters() override;
CBaseObject* NewObject(const char* typeName, const char* fileName = "", const char* name = "", float x = 0.0f, float y = 0.0f, float z = 0.0f, bool modifyDoc = true) override;
void DeleteObject(CBaseObject* obj) override;
CBaseObject* CloneObject(CBaseObject* obj) override;
IObjectManager* GetObjectManager() override;
// This will return a null pointer if CrySystem is not loaded before
// Global Sandbox Settings are loaded from the registry before CrySystem

@ -21,8 +21,6 @@
#include "Util/Image.h"
#include "Util/ImageUtil.h"
#include <IStatObj.h>
#define HELPER_MATERIAL "Objects/Helper"
namespace
@ -38,7 +36,6 @@ namespace
CIconManager::CIconManager()
{
ZeroStruct(m_icons);
ZeroStruct(m_objects);
}
//////////////////////////////////////////////////////////////////////////
@ -61,13 +58,7 @@ void CIconManager::Done()
void CIconManager::Reset()
{
// Do not unload objects. but clears them.
int i;
for (i = 0; i < sizeof(m_objects) / sizeof(m_objects[0]); i++)
{
delete m_objects[i];
m_objects[i] = nullptr;
}
for (i = 0; i < eIcon_COUNT; i++)
for (int i = 0; i < eIcon_COUNT; i++)
{
m_icons[i] = 0;
}
@ -110,12 +101,6 @@ int CIconManager::GetIconTexture(EIcon icon)
return m_icons[icon];
}
//////////////////////////////////////////////////////////////////////////
IStatObj* CIconManager::GetObject(EStatObject)
{
return nullptr;
}
//////////////////////////////////////////////////////////////////////////
QImage* CIconManager::GetIconBitmap(const char* filename, bool& bHaveAlpha, uint32 effects /*=0*/)
{

@ -8,11 +8,6 @@
// Description : Manages Textures used by Icon.
#ifndef CRYINCLUDE_EDITOR_ICONMANAGER_H
#define CRYINCLUDE_EDITOR_ICONMANAGER_H
#pragma once
#include "Include/IIconManager.h" // for IIconManager
@ -31,7 +26,7 @@ class CIconManager
public:
// Construction
CIconManager();
~CIconManager();
~CIconManager() override;
void Init();
void Done();
@ -41,8 +36,6 @@ public:
// Operations
virtual int GetIconTexture(EIcon icon);
virtual IStatObj* GetObject(EStatObject object);
virtual int GetIconTexture(const char* iconName);
//////////////////////////////////////////////////////////////////////////
@ -61,7 +54,6 @@ public:
private:
StdMap<QString, int> m_textures;
IStatObj* m_objects[eStatObject_COUNT];
int m_icons[eIcon_COUNT];
//////////////////////////////////////////////////////////////////////////
@ -70,5 +62,3 @@ private:
typedef std::map<QString, QImage*> IconsMap;
IconsMap m_iconBitmapsMap;
};
#endif // CRYINCLUDE_EDITOR_ICONMANAGER_H

@ -6,9 +6,6 @@
*
*/
#ifndef CRYINCLUDE_EDITOR_INCLUDE_IDISPLAYVIEWPORT_H
#define CRYINCLUDE_EDITOR_INCLUDE_IDISPLAYVIEWPORT_H
#pragma once
struct DisplayContext;
@ -22,7 +19,6 @@ struct IDisplayViewport
{
virtual void Update() = 0;
virtual float GetScreenScaleFactor(const Vec3& position) const = 0;
virtual bool HitTestLine(const Vec3& lineP1, const Vec3& lineP2, const QPoint& hitpoint, int pixelRadius, float* pToCameraDistance = 0) const = 0;
/**
* Gets the distance of the point on screen to the line defined by the two points, converted to screenspace.
@ -48,12 +44,9 @@ struct IDisplayViewport
virtual Vec3 WorldToView3D(const Vec3& worldPoint, int flags = 0) const = 0;
virtual Vec3 ViewToWorld(const QPoint& vp, bool* collideWithTerrain = nullptr, bool onlyTerrain = false, bool bSkipVegetation = false, bool bTestRenderMesh = false, bool* collideWithObject = nullptr) const = 0;
virtual void ViewToWorldRay(const QPoint& vp, Vec3& raySrc, Vec3& rayDir) const = 0;
virtual float GetGridStep() const = 0;
virtual void setRay(QPoint& vp, Vec3& raySrc, Vec3& rayDir) = 0;
virtual void setHitcontext(QPoint& vp, Vec3& raySrc, Vec3& rayDir) = 0;
virtual float GetAspectRatio() const = 0;
virtual const ::Plane* GetConstructionPlane() const = 0;
virtual bool IsBoundsVisible(const AABB& box) const = 0;
@ -62,5 +55,3 @@ struct IDisplayViewport
virtual CViewport *asCViewport() { return nullptr; }
};
#endif // CRYINCLUDE_EDITOR_INCLUDE_IDISPLAYVIEWPORT_H

@ -8,14 +8,9 @@
// Description : Export geometry interfaces
#ifndef CRYINCLUDE_EDITOR_INCLUDE_IEXPORTMANAGER_H
#define CRYINCLUDE_EDITOR_INCLUDE_IEXPORTMANAGER_H
#pragma once
#define EXP_NAMESIZE 32
struct IStatObj;
enum class AnimParamType;
namespace Export
@ -178,18 +173,10 @@ struct IExporter
virtual void Release() = 0;
};
// IExportManager: interface to export manager
struct IExportManager
{
//! Register exporter
//! return true if succeed, otherwise false
virtual bool RegisterExporter(IExporter* pExporter) = 0;
virtual bool ExportSingleStatObj(IStatObj* pStatObj, const char* filename) = 0;
};
#endif // CRYINCLUDE_EDITOR_INCLUDE_IEXPORTMANAGER_H

@ -6,12 +6,8 @@
*
*/
#ifndef CRYINCLUDE_EDITOR_INCLUDE_IICONMANAGER_H
#define CRYINCLUDE_EDITOR_INCLUDE_IICONMANAGER_H
#pragma once
struct IStatObj;
struct IMaterial;
class CBitmap;
@ -56,12 +52,9 @@ enum EIconEffect
struct IIconManager
{
virtual ~IIconManager() = default;
virtual IStatObj* GetObject(EStatObject object) = 0;
virtual int GetIconTexture(EIcon icon) = 0;
virtual int GetIconTexture(const char* iconName) = 0;
virtual QImage* GetIconBitmap(const char* filename, bool& haveAlpha, uint32 effects = 0) = 0;
// Register an Icon for the specific command
virtual void RegisterCommandIcon([[maybe_unused]] const char* filename, [[maybe_unused]] int nCommandId) {}
};
#endif // CRYINCLUDE_EDITOR_INCLUDE_IICONMANAGER_H

@ -5,10 +5,6 @@
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#ifndef CRYINCLUDE_EDITOR_INCLUDE_IOBJECTMANAGER_H
#define CRYINCLUDE_EDITOR_INCLUDE_IOBJECTMANAGER_H
#pragma once
#include <AzCore/PlatformIncl.h>
@ -29,32 +25,15 @@ class CObjectArchive;
class CViewport;
struct HitContext;
enum class ImageRotationDegrees;
struct IStatObj;
class CBaseObject;
class XmlNodeRef;
#include "ObjectEvent.h"
enum SerializeFlags
{
SERIALIZE_ALL = 0,
SERIALIZE_ONLY_SHARED = 1,
SERIALIZE_ONLY_NOTSHARED = 2,
};
//////////////////////////////////////////////////////////////////////////
typedef std::vector<CBaseObject*> CBaseObjectsArray;
typedef std::pair< bool(CALLBACK*)(CBaseObject const&, void*), void* > BaseObjectFilterFunctor;
struct IObjectSelectCallback
{
//! Called when object is selected.
//! Return true if selection should proceed, or false to abort object selection.
virtual bool OnSelectObject(CBaseObject* obj) = 0;
//! Return true if object can be selected.
virtual bool CanSelectObject(CBaseObject* obj) = 0;
};
//////////////////////////////////////////////////////////////////////////
//
// Interface to access editor objects scene graph.
@ -78,10 +57,6 @@ public:
virtual void DeleteObject(CBaseObject* obj) = 0;
virtual void DeleteSelection(CSelectionGroup* pSelection) = 0;
virtual void DeleteAllObjects() = 0;
virtual CBaseObject* CloneObject(CBaseObject* obj) = 0;
virtual void BeginEditParams(CBaseObject* obj, int flags) = 0;
virtual void EndEditParams(int flags = 0) = 0;
//! Get number of objects manager by ObjectManager (not contain sub objects of groups).
virtual int GetObjectCount() const = 0;
@ -90,27 +65,9 @@ public:
//! @param layer if 0 get objects for all layers, or layer to get objects from.
virtual void GetObjects(CBaseObjectsArray& objects) const = 0;
//! Get array of objects that pass the filter.
//! @param filter The filter functor, return true if you want to get the certain obj, return false if want to skip it.
virtual void GetObjects(CBaseObjectsArray& objects, BaseObjectFilterFunctor const& filter) const = 0;
//! Display objects on specified display context.
virtual void Display(DisplayContext& dc) = 0;
//! Called when selecting without selection helpers - this is needed since
//! the visible object cache is normally not updated when not displaying helpers.
virtual void ForceUpdateVisibleObjectCache(DisplayContext& dc) = 0;
//! Check intersection with objects.
//! Find intersection with nearest to ray origin object hit by ray.
//! If distance tollerance is specified certain relaxation applied on collision test.
//! @return true if hit any object, and fills hitInfo structure.
virtual bool HitTest(HitContext& hitInfo) = 0;
//! Check intersection with an object.
//! @return true if hit, and fills hitInfo structure.
virtual bool HitTestObject(CBaseObject* obj, HitContext& hc) = 0;
//! Gets a radius to be used for hit tests on the axis helpers, like the transform gizmo.
//! @return the axis helper hit radius.
virtual int GetAxisHelperHitRadius() const = 0;
@ -137,59 +94,18 @@ public:
//! Find objects which intersect with a given AABB.
virtual void FindObjectsInAABB(const AABB& aabb, std::vector<CBaseObject*>& result) const = 0;
//////////////////////////////////////////////////////////////////////////
// Operations on objects.
//////////////////////////////////////////////////////////////////////////
//! Makes object visible or invisible.
virtual void HideObject(CBaseObject* obj, bool hide) = 0;
//! Shows the last hidden object based on hidden ID
virtual void ShowLastHiddenObject() = 0;
//! Freeze object, making it unselectable.
virtual void FreezeObject(CBaseObject* obj, bool freeze) = 0;
//! Unhide all hidden objects.
virtual void UnhideAll() = 0;
//! Unfreeze all frozen objects.
virtual void UnfreezeAll() = 0;
//////////////////////////////////////////////////////////////////////////
// Object Selection.
//////////////////////////////////////////////////////////////////////////
virtual bool SelectObject(CBaseObject* obj, bool bUseMask = true) = 0;
virtual void UnselectObject(CBaseObject* obj) = 0;
//! Select objects within specified distance from given position.
//! Return number of selected objects.
virtual int SelectObjects(const AABB& box, bool bUnselect = false) = 0;
virtual void SelectEntities(std::set<CEntityObject*>& s) = 0;
virtual int MoveObjects(const AABB& box, const Vec3& offset, ImageRotationDegrees rotation, bool bIsCopy = false) = 0;
//! Selects/Unselects all objects within 2d rectangle in given viewport.
virtual void SelectObjectsInRect(CViewport* view, const QRect& rect, bool bSelect) = 0;
virtual void FindObjectsInRect(CViewport* view, const QRect& rect, std::vector<GUID>& guids) = 0;
//! Clear default selection set.
//! @Return number of objects removed from selection.
virtual int ClearSelection() = 0;
//! Deselect all current selected objects and selects object that were unselected.
//! @Return number of selected objects.
virtual int InvertSelection() = 0;
//! Get current selection.
virtual CSelectionGroup* GetSelection() const = 0;
//! Get named selection.
virtual CSelectionGroup* GetSelection(const QString& name) const = 0;
// Get selection group names
virtual void GetNameSelectionStrings(QStringList& names) = 0;
//! Change name of current selection group.
//! And store it in list.
virtual void NameSelection(const QString& name) = 0;
//! Set one of name selections as current selection.
virtual void SetSelection(const QString& name) = 0;
//! Removes one of named selections.
virtual void RemoveSelection(const QString& name) = 0;
//! Delete all objects in current selection group.
virtual void DeleteSelection() = 0;
@ -198,54 +114,11 @@ public:
virtual QString GenerateUniqueObjectName(const QString& typeName) = 0;
//! Register object name in object manager, needed for generating uniq names.
virtual void RegisterObjectName(const QString& name) = 0;
//! Enable/Disable generating of unique object names (Enabled by default).
//! Return previous value.
virtual bool EnableUniqObjectNames(bool bEnable) = 0;
//! Find object class by name.
virtual CObjectClassDesc* FindClass(const QString& className) = 0;
virtual void GetClassCategories(QStringList& categories) = 0;
virtual void GetClassCategoryToolClassNamePairs(std::vector< std::pair<QString, QString> >& categoryToolClassNamePairs) = 0;
virtual void GetClassTypes(const QString& category, QStringList& types) = 0;
//! Export objects to xml.
//! When onlyShared is true ony objects with shared flags exported, overwise only not shared object exported.
virtual void Export(const QString& levelPath, XmlNodeRef& rootNode, bool onlyShared) = 0;
//! Export only entities to xml.
virtual void ExportEntities(XmlNodeRef& rootNode) = 0;
//! Serialize Objects in manager to specified XML Node.
//! @param flags Can be one of SerializeFlags.
virtual void Serialize(XmlNodeRef& rootNode, bool bLoading, int flags = SERIALIZE_ALL) = 0;
virtual void SerializeNameSelection(XmlNodeRef& rootNode, bool bLoading) = 0;
//! Load objects from object archive.
//! @param bSelect if set newly loaded object will be selected.
virtual void LoadObjects(CObjectArchive& ar, bool bSelect) = 0;
virtual void ChangeObjectId(REFGUID oldId, REFGUID newId) = 0;
virtual bool IsDuplicateObjectName(const QString& newName) const = 0;
virtual void ShowDuplicationMsgWarning(CBaseObject* obj, const QString& newName, bool bShowMsgBox) const = 0;
virtual void ChangeObjectName(CBaseObject* obj, const QString& newName) = 0;
//! while loading PreFabs we need to force this IDs
//! to force always the same IDs, on each load.
//! needed for RAM-maps assignments
virtual uint32 ForceID() const = 0;
virtual void ForceID(uint32 FID) = 0;
//! Convert object of one type to object of another type.
//! Original object is deleted.
virtual bool ConvertToType(CBaseObject* pObject, const QString& typeName) = 0;
//! Set new selection callback.
//! @return previous selection callback.
virtual IObjectSelectCallback* SetSelectCallback(IObjectSelectCallback* callback) = 0;
// Enables/Disables creating of game objects.
virtual void SetCreateGameObject(bool enable) = 0;
//! Return true if objects loaded from xml should immidiatly create game objects associated with them.
virtual bool IsCreateGameObjects() const = 0;
virtual IGizmoManager* GetGizmoManager() = 0;
@ -253,34 +126,9 @@ public:
//! Invalidate visibily settings of objects.
virtual void InvalidateVisibleList() = 0;
//////////////////////////////////////////////////////////////////////////
// ObjectManager notification Callbacks.
//////////////////////////////////////////////////////////////////////////
virtual void AddObjectEventListener(EventListener* listener) = 0;
virtual void RemoveObjectEventListener(EventListener* listener) = 0;
//////////////////////////////////////////////////////////////////////////
// Used to indicate starting and ending of objects loading.
//////////////////////////////////////////////////////////////////////////
virtual void StartObjectsLoading(int numObjects) = 0;
virtual void EndObjectsLoading() = 0;
//////////////////////////////////////////////////////////////////////////
// Gathers all resources used by all objects.
virtual void GatherUsedResources(CUsedResources& resources) = 0;
virtual bool IsLightClass(CBaseObject* pObject) = 0;
virtual void FindAndRenameProperty2(const char* property2Name, const QString& oldValue, const QString& newValue) = 0;
virtual void FindAndRenameProperty2If(const char* property2Name, const QString& oldValue, const QString& newValue, const char* otherProperty2Name, const QString& otherValue) = 0;
virtual bool IsReloading() const = 0;
// Set bSkipUpdate to true if you want to skip update objects on the idle loop.
virtual void SetSkipUpdate(bool bSkipUpdate) = 0;
virtual void SetExportingLevel(bool bExporting) = 0;
virtual bool IsExportingLevelInprogress() const = 0;
};
#endif // CRYINCLUDE_EDITOR_INCLUDE_IOBJECTMANAGER_H

@ -14,7 +14,6 @@
//! Standart objects types.
enum ObjectType
{
OBJTYPE_DUMMY = 1 << 20,
OBJTYPE_AZENTITY = 1 << 21,
};

@ -63,16 +63,6 @@ namespace ObjectManagerPythonBindingsUnitTests
EXPECT_TRUE(behaviorContext->m_methods.find("get_selection_center") != behaviorContext->m_methods.end());
EXPECT_TRUE(behaviorContext->m_methods.find("get_selection_aabb") != behaviorContext->m_methods.end());
EXPECT_TRUE(behaviorContext->m_methods.find("hide_object") != behaviorContext->m_methods.end());
EXPECT_TRUE(behaviorContext->m_methods.find("is_object_hidden") != behaviorContext->m_methods.end());
EXPECT_TRUE(behaviorContext->m_methods.find("unhide_object") != behaviorContext->m_methods.end());
EXPECT_TRUE(behaviorContext->m_methods.find("hide_all_objects") != behaviorContext->m_methods.end());
EXPECT_TRUE(behaviorContext->m_methods.find("unhide_all_objects") != behaviorContext->m_methods.end());
EXPECT_TRUE(behaviorContext->m_methods.find("freeze_object") != behaviorContext->m_methods.end());
EXPECT_TRUE(behaviorContext->m_methods.find("is_object_frozen") != behaviorContext->m_methods.end());
EXPECT_TRUE(behaviorContext->m_methods.find("unfreeze_object") != behaviorContext->m_methods.end());
EXPECT_TRUE(behaviorContext->m_methods.find("delete_object") != behaviorContext->m_methods.end());
EXPECT_TRUE(behaviorContext->m_methods.find("delete_selected") != behaviorContext->m_methods.end());

@ -576,7 +576,6 @@ void MainWindow::closeEvent(QCloseEvent* event)
}
// Close all edit panels.
GetIEditor()->ClearSelection();
GetIEditor()->GetObjectManager()->EndEditParams();
// force clean up of all deferred deletes, so that we don't have any issues with windows from plugins not being deleted yet
qApp->sendPostedEvents(nullptr, QEvent::DeferredDelete);

@ -33,8 +33,6 @@
#include "ViewManager.h"
#include "IEditorImpl.h"
#include "GameEngine.h"
#include <IEntityRenderState.h>
#include <IStatObj.h>
// To use the Andrew's algorithm in order to make convex hull from the points, this header is needed.
#include "Util/GeometryUtil.h"
@ -53,18 +51,16 @@ class CUndoBaseObject
: public IUndoObject
{
public:
CUndoBaseObject(CBaseObject* pObj, const char* undoDescription);
CUndoBaseObject(CBaseObject* pObj);
protected:
int GetSize() override { return sizeof(*this); }
QString GetDescription() override { return m_undoDescription; };
QString GetObjectName() override;
void Undo(bool bUndo) override;
void Redo() override;
protected:
QString m_undoDescription;
GUID m_guid;
XmlNodeRef m_undo;
XmlNodeRef m_redo;
@ -77,11 +73,10 @@ class CUndoBaseObjectMinimal
: public IUndoObject
{
public:
CUndoBaseObjectMinimal(CBaseObject* obj, const char* undoDescription, int flags);
CUndoBaseObjectMinimal(CBaseObject* obj, int flags);
protected:
int GetSize() override { return sizeof(*this); }
QString GetDescription() override { return m_undoDescription; };
QString GetObjectName() override;
void Undo(bool bUndo) override;
@ -101,7 +96,6 @@ private:
void SetTransformsFromState(CBaseObject* pObject, const StateStruct& state, bool bUndo);
GUID m_guid;
QString m_undoDescription;
StateStruct m_undoState;
StateStruct m_redoState;
};
@ -167,7 +161,6 @@ private:
}
int GetSize() override { return sizeof(CUndoAttachBaseObject); }
QString GetDescription() override { return "Attachment Changed"; }
GUID m_attachedObjectGUID;
GUID m_parentObjectGUID;
@ -176,11 +169,10 @@ private:
};
//////////////////////////////////////////////////////////////////////////
CUndoBaseObject::CUndoBaseObject(CBaseObject* obj, const char* undoDescription)
CUndoBaseObject::CUndoBaseObject(CBaseObject* obj)
{
// Stores the current state of this object.
assert(obj != 0);
m_undoDescription = undoDescription;
m_guid = obj->GetId();
m_redo = nullptr;
@ -254,11 +246,10 @@ void CUndoBaseObject::Redo()
}
//////////////////////////////////////////////////////////////////////////
CUndoBaseObjectMinimal::CUndoBaseObjectMinimal(CBaseObject* pObj, const char* undoDescription, [[maybe_unused]] int flags)
CUndoBaseObjectMinimal::CUndoBaseObjectMinimal(CBaseObject* pObj, [[maybe_unused]] int flags)
{
// Stores the current state of this object.
assert(pObj != nullptr);
m_undoDescription = undoDescription;
m_guid = pObj->GetId();
ZeroStruct(m_redoState);
@ -287,7 +278,7 @@ QString CUndoBaseObjectMinimal::GetObjectName()
void CUndoBaseObjectMinimal::Undo(bool bUndo)
{
CBaseObject* pObject = GetIEditor()->GetObjectManager()->FindObject(m_guid);
if (!pObject || pObject->GetType() == OBJTYPE_DUMMY)
if (!pObject)
{
return;
}
@ -316,7 +307,7 @@ void CUndoBaseObjectMinimal::Undo(bool bUndo)
void CUndoBaseObjectMinimal::Redo()
{
CBaseObject* pObject = GetIEditor()->GetObjectManager()->FindObject(m_guid);
if (!pObject || pObject->GetType() == OBJTYPE_DUMMY)
if (!pObject)
{
return;
}
@ -382,7 +373,6 @@ CBaseObject::CBaseObject()
, m_rotate(IDENTITY)
, m_scale(1, 1, 1)
, m_guid(GUID_NULL)
, m_floorNumber(-1)
, m_flags(0)
, m_nTextureIcon(0)
, m_color(QColor(255, 255, 255))
@ -398,11 +388,9 @@ CBaseObject::CBaseObject()
, m_bMatrixInWorldSpace(false)
, m_bMatrixValid(false)
, m_bWorldBoxValid(false)
, m_nMaterialLayersMask(0)
, m_nMinSpec(0)
, m_vDrawIconPos(0, 0, 0)
, m_nIconFlags(0)
, m_hideOrder(CBaseObject::s_invalidHiddenID)
{
m_worldBounds.min.Set(0, 0, 0);
m_worldBounds.max.Set(0, 0, 0);
@ -431,7 +419,6 @@ bool CBaseObject::Init([[maybe_unused]] IEditor* ie, CBaseObject* prev, [[maybe_
SetLocalTM(prev->GetPos(), prev->GetRotation(), prev->GetScale());
SetArea(prev->GetArea());
SetColor(prev->GetColor());
m_nMaterialLayersMask = prev->m_nMaterialLayersMask;
SetMinSpec(prev->GetMinSpec(), false);
// Copy all basic variables.
@ -488,7 +475,7 @@ void CBaseObject::SetName(const QString& name)
return;
}
StoreUndo("Name");
StoreUndo();
// Notification is expensive and not required if this is during construction.
bool notify = (!m_name.isEmpty());
@ -500,7 +487,6 @@ void CBaseObject::SetName(const QString& name)
if (notify)
{
NotifyListeners(ON_RENAME);
static_cast<CObjectManager*>(GetIEditor()->GetObjectManager())->NotifyObjectListeners(this, ON_RENAME);
}
}
@ -529,47 +515,6 @@ const QString& CBaseObject::GetName() const
return m_name;
}
//////////////////////////////////////////////////////////////////////////
QString CBaseObject::GetWarningsText() const
{
QString warnings;
if (gSettings.viewports.bShowScaleWarnings)
{
const EScaleWarningLevel scaleWarningLevel = GetScaleWarningLevel();
if (scaleWarningLevel == eScaleWarningLevel_Rescaled)
{
warnings += "\\n Warning: Object Scale is not 100%.";
}
else if (scaleWarningLevel == eScaleWarningLevel_RescaledNonUniform)
{
warnings += "\\n Warning: Object has non-uniform scale.";
}
}
if (gSettings.viewports.bShowRotationWarnings)
{
const ERotationWarningLevel rotationWarningLevel = GetRotationWarningLevel();
if (rotationWarningLevel == eRotationWarningLevel_Rotated)
{
warnings += "\\n Warning: Object is rotated.";
}
else if (rotationWarningLevel == eRotationWarningLevel_RotatedNonRectangular)
{
warnings += "\\n Warning: Object is rotated non-orthogonally.";
}
}
return warnings;
}
//////////////////////////////////////////////////////////////////////////
bool CBaseObject::IsSameClass(CBaseObject* obj)
{
return GetClassDesc() == obj->GetClassDesc();
}
//////////////////////////////////////////////////////////////////////////
bool CBaseObject::SetPos(const Vec3& pos, int flags)
{
@ -615,7 +560,7 @@ bool CBaseObject::SetPos(const Vec3& pos, int flags)
//////////////////////////////////////////////////////////////////////////
if (!bPositionDelegated && (flags & eObjectUpdateFlags_RestoreUndo) == 0 && (flags & eObjectUpdateFlags_Animated) == 0)
{
StoreUndo("Position", true, flags);
StoreUndo(true, flags);
}
if (!bPositionDelegated)
@ -659,7 +604,7 @@ bool CBaseObject::SetRotation(const Quat& rotate, int flags)
if (!bRotationDelegated && (flags & eObjectUpdateFlags_RestoreUndo) == 0 && (flags & eObjectUpdateFlags_Animated) == 0)
{
StoreUndo("Rotate", true, flags);
StoreUndo(true, flags);
}
if (!bRotationDelegated)
@ -704,7 +649,7 @@ bool CBaseObject::SetScale(const Vec3& scale, int flags)
if (!bScaleDelegated && (flags & eObjectUpdateFlags_RestoreUndo) == 0 && (flags & eObjectUpdateFlags_Animated) == 0)
{
StoreUndo("Scale", true, flags);
StoreUndo(true, flags);
}
if (!bScaleDelegated)
@ -763,7 +708,7 @@ void CBaseObject::ChangeColor(const QColor& color)
return;
}
StoreUndo("Color", true);
StoreUndo(true);
SetColor(color);
SetModified(false);
@ -783,7 +728,7 @@ void CBaseObject::SetArea(float area)
return;
}
StoreUndo("Area", true);
StoreUndo(true);
m_flattenArea = area;
SetModified(false);
@ -1183,47 +1128,6 @@ bool CBaseObject::CanBeDrawn(const DisplayContext& dc, bool& outDisplaySelection
return bResult;
}
//////////////////////////////////////////////////////////////////////////
int CBaseObject::MouseCreateCallback(CViewport* view, EMouseEvent event, QPoint& point, int flags)
{
AZ_PROFILE_FUNCTION(Editor);
if (event == eMouseMove || event == eMouseLDown)
{
Vec3 pos;
if (GetIEditor()->GetAxisConstrains() != AXIS_TERRAIN)
{
pos = view->MapViewToCP(point);
}
else
{
// Snap to terrain.
bool hitTerrain;
pos = view->ViewToWorld(point, &hitTerrain);
if (hitTerrain)
{
pos.z = GetIEditor()->GetTerrainElevation(pos.x, pos.y) + 1.0f;
}
pos = view->SnapToGrid(pos);
}
SetPos(pos);
if (event == eMouseLDown)
{
return MOUSECREATE_OK;
}
}
if (event == eMouseWheel)
{
float angle = 1;
Quat rot = GetRotation();
rot.SetRotationXYZ(Ang3(0.f, 0.f, rot.GetRotZ() + DEG2RAD(flags > 0 ? angle * (-1) : angle)));
SetRotation(rot);
}
return MOUSECREATE_CONTINUE;
}
//////////////////////////////////////////////////////////////////////////
void CBaseObject::OnEvent(ObjectEvent event)
{
@ -1237,18 +1141,13 @@ void CBaseObject::OnEvent(ObjectEvent event)
//////////////////////////////////////////////////////////////////////////
void CBaseObject::SetShared([[maybe_unused]] bool bShared)
{
}
//////////////////////////////////////////////////////////////////////////
void CBaseObject::SetHidden(bool bHidden, uint64 hiddenID, bool bAnimated)
void CBaseObject::SetHidden(bool bHidden, bool bAnimated)
{
if (CheckFlags(OBJFLAG_HIDDEN) != bHidden)
{
if (!bAnimated)
{
StoreUndo("Hide Object");
StoreUndo();
}
if (bHidden)
@ -1260,7 +1159,6 @@ void CBaseObject::SetHidden(bool bHidden, uint64 hiddenID, bool bAnimated)
ClearFlags(OBJFLAG_HIDDEN);
}
m_hideOrder = hiddenID;
UpdateVisibility(!IsHidden());
}
}
@ -1270,7 +1168,7 @@ void CBaseObject::SetFrozen(bool bFrozen)
{
if (CheckFlags(OBJFLAG_FROZEN) != bFrozen)
{
StoreUndo("Freeze Object");
StoreUndo();
if (bFrozen)
{
SetFlags(OBJFLAG_FROZEN);
@ -1356,14 +1254,6 @@ void CBaseObject::Serialize(CObjectArchive& ar)
if (ar.bLoading)
{
// Loading.
if (ar.ShouldResetInternalMembers())
{
m_flags = 0;
m_flattenArea = 0.0f;
m_nMinSpec = 0;
m_scale.Set(1.0f, 1.0f, 1.0f);
}
int flags = 0;
int oldFlags = m_flags;
@ -1403,7 +1293,6 @@ void CBaseObject::Serialize(CObjectArchive& ar)
xmlNode->getAttr("LookAt", lookatId);
xmlNode->getAttr("Material", mtlName);
xmlNode->getAttr("MinSpec", nMinSpec);
xmlNode->getAttr("FloorNumber", m_floorNumber);
if (nMinSpec <= CONFIG_VERYHIGH_SPEC) // Ignore invalid values.
{
@ -1467,18 +1356,6 @@ void CBaseObject::Serialize(CObjectArchive& ar)
SetModified(false);
//////////////////////////////////////////////////////////////////////////
if (ar.bUndo)
{
// If we are selected update UI Panel.
xmlNode->getAttr("HideOrder", m_hideOrder);
}
// We reseted the min spec and deserialized it so set it internally
if (ar.ShouldResetInternalMembers())
{
SetMinSpec(m_nMinSpec);
}
}
else
{
@ -1490,7 +1367,6 @@ void CBaseObject::Serialize(CObjectArchive& ar)
xmlNode->setAttr("Id", m_guid);
xmlNode->setAttr("Name", GetName().toUtf8().data());
xmlNode->setAttr("HideOrder", m_hideOrder);
if (m_parent)
{
@ -1507,8 +1383,6 @@ void CBaseObject::Serialize(CObjectArchive& ar)
xmlNode->setAttr("Pos", GetPos());
}
xmlNode->setAttr("FloorNumber", m_floorNumber);
xmlNode->setAttr("Rotate", m_rotate);
if (!IsEquivalent(GetScale(), Vec3(1, 1, 1), 0))
@ -1601,13 +1475,8 @@ CBaseObject* CBaseObject::FindObject(REFGUID id) const
}
//////////////////////////////////////////////////////////////////////////
void CBaseObject::StoreUndo(const char* UndoDescription, bool minimal, int flags)
void CBaseObject::StoreUndo(bool minimal, int flags)
{
if (m_objType == OBJTYPE_DUMMY)
{
return;
}
// Don't use Sandbox undo for AZ entities, except for the move & scale tools, which rely on it.
const bool isGizmoTool = 0 != (flags & (eObjectUpdateFlags_MoveTool | eObjectUpdateFlags_ScaleTool | eObjectUpdateFlags_UserInput));
if (!isGizmoTool && 0 != (m_flags & OBJFLAG_DONT_SAVE))
@ -1619,28 +1488,18 @@ void CBaseObject::StoreUndo(const char* UndoDescription, bool minimal, int flags
{
if (minimal)
{
CUndo::Record(new CUndoBaseObjectMinimal(this, UndoDescription, flags));
CUndo::Record(new CUndoBaseObjectMinimal(this, flags));
}
else
{
CUndo::Record(new CUndoBaseObject(this, UndoDescription));
CUndo::Record(new CUndoBaseObject(this));
}
}
}
//////////////////////////////////////////////////////////////////////////
bool CBaseObject::IsCreateGameObjects() const
{
return GetObjectManager()->IsCreateGameObjects();
}
//////////////////////////////////////////////////////////////////////////
QString CBaseObject::GetTypeName() const
{
if (m_objType == OBJTYPE_DUMMY)
{
return "";
}
QString className = m_classDesc->ClassName();
QString subClassName = strstr(className.toUtf8().data(), "::");
if (subClassName.isEmpty())
@ -1901,85 +1760,6 @@ bool CBaseObject::HitTestRect(HitContext& hc)
return bHit;
}
//////////////////////////////////////////////////////////////////////////
bool CBaseObject::HitHelperTest(HitContext& hc)
{
return HitHelperAtTest(hc, GetWorldPos());
}
//////////////////////////////////////////////////////////////////////////
bool CBaseObject::HitHelperAtTest(HitContext& hc, const Vec3& pos)
{
AZ_PROFILE_FUNCTION(Editor);
bool bResult = false;
if (m_nTextureIcon && (gSettings.viewports.bShowIcons || gSettings.viewports.bShowSizeBasedIcons) && !hc.bUseSelectionHelpers)
{
int iconSizeX = OBJECT_TEXTURE_ICON_SIZEX;
int iconSizeY = OBJECT_TEXTURE_ICON_SIZEY;
if (gSettings.viewports.bDistanceScaleIcons)
{
float fScreenScale = hc.view->GetScreenScaleFactor(pos);
iconSizeX = static_cast<int>(static_cast<float>(iconSizeX) * OBJECT_TEXTURE_ICON_SCALE / fScreenScale);
iconSizeY = static_cast<int>(static_cast<float>(iconSizeY) * OBJECT_TEXTURE_ICON_SCALE / fScreenScale);
}
// Hit Test icon of this object.
Vec3 testPos = pos;
int y0 = -(iconSizeY / 2);
int y1 = +(iconSizeY / 2);
if (CheckFlags(OBJFLAG_SHOW_ICONONTOP))
{
Vec3 objectPos = GetWorldPos();
AABB box;
GetBoundBox(box);
testPos.z = (pos.z - objectPos.z) + box.max.z;
y0 = -(iconSizeY);
y1 = 0;
}
QPoint pnt = hc.view->WorldToView(testPos);
if (hc.point2d.x() >= pnt.x() - (iconSizeX / 2) && hc.point2d.x() <= pnt.x() + (iconSizeX / 2) &&
hc.point2d.y() >= pnt.y() + y0 && hc.point2d.y() <= pnt.y() + y1)
{
hc.dist = hc.raySrc.GetDistance(testPos) - 0.2f;
hc.iconHit = true;
bResult = true;
}
}
else if (hc.bUseSelectionHelpers)
{
// Check potentially children first
bResult = HitHelperTestForChildObjects(hc);
// If no hit check this object
if (!bResult)
{
// Hit test helper.
Vec3 w = pos - hc.raySrc;
w = hc.rayDir.Cross(w);
float d = w.GetLengthSquared();
static const float screenScaleToRadiusFactor = 0.008f;
const float radius = hc.view->GetScreenScaleFactor(pos) * screenScaleToRadiusFactor;
const float pickDistance = hc.raySrc.GetDistance(pos);
if (d < radius * radius + hc.distanceTolerance && hc.dist >= pickDistance)
{
hc.dist = pickDistance;
hc.object = this;
bResult = true;
}
}
}
return bResult;
}
//////////////////////////////////////////////////////////////////////////
CBaseObject* CBaseObject::GetChild(size_t const i) const
{
@ -1987,47 +1767,6 @@ CBaseObject* CBaseObject::GetChild(size_t const i) const
return m_childs[i];
}
//////////////////////////////////////////////////////////////////////////
bool CBaseObject::IsChildOf(CBaseObject* node)
{
CBaseObject* p = m_parent;
while (p && p != node)
{
p = p->m_parent;
}
if (p == node)
{
return true;
}
return false;
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
void CBaseObject::CloneChildren(CBaseObject* pFromObject)
{
if (pFromObject == nullptr)
{
return;
}
for (size_t i = 0, nChildCount(pFromObject->GetChildCount()); i < nChildCount; ++i)
{
CBaseObject* pFromChildObject = pFromObject->GetChild(i);
CBaseObject* pChildClone = GetObjectManager()->CloneObject(pFromChildObject);
if (pChildClone == nullptr)
{
continue;
}
pChildClone->CloneChildren(pFromChildObject);
AddMember(pChildClone, false);
}
}
//////////////////////////////////////////////////////////////////////////
void CBaseObject::AttachChild(CBaseObject* child, bool bKeepPos)
{
@ -2044,7 +1783,6 @@ void CBaseObject::AttachChild(CBaseObject* child, bool bKeepPos)
return;
}
static_cast<CObjectManager*>(GetObjectManager())->NotifyObjectListeners(child, ON_PREATTACHED);
child->NotifyListeners(bKeepPos ? ON_PREATTACHEDKEEPXFORM : ON_PREATTACHED);
pTransformDelegate = m_pTransformDelegate;
@ -2089,7 +1827,6 @@ void CBaseObject::AttachChild(CBaseObject* child, bool bKeepPos)
m_pTransformDelegate = pTransformDelegate;
child->m_pTransformDelegate = pChildTransformDelegate;
static_cast<CObjectManager*>(GetObjectManager())->NotifyObjectListeners(child, ON_ATTACHED);
child->NotifyListeners(ON_ATTACHED);
NotifyListeners(ON_CHILDATTACHED);
@ -2127,7 +1864,6 @@ void CBaseObject::DetachThis(bool bKeepPos)
{
CScopedSuspendUndo suspendUndo;
static_cast<CObjectManager*>(GetObjectManager())->NotifyObjectListeners(this, ON_PREDETACHED);
NotifyListeners(bKeepPos ? ON_PREDETACHEDKEEPXFORM : ON_PREDETACHED);
pTransformDelegate = m_pTransformDelegate;
@ -2158,7 +1894,6 @@ void CBaseObject::DetachThis(bool bKeepPos)
SetTransformDelegate(pTransformDelegate);
static_cast<CObjectManager*>(GetObjectManager())->NotifyObjectListeners(this, ON_DETACHED);
NotifyListeners(ON_DETACHED);
}
}
@ -2262,12 +1997,6 @@ Matrix34 CBaseObject::GetParentAttachPointWorldTM() const
return Matrix34(IDENTITY);
}
//////////////////////////////////////////////////////////////////////////
bool CBaseObject::IsParentAttachmentValid() const
{
return true;
}
//////////////////////////////////////////////////////////////////////////
void CBaseObject::InvalidateTM([[maybe_unused]] int flags)
{
@ -2418,7 +2147,7 @@ void CBaseObject::SetLookAt(CBaseObject* target)
return;
}
StoreUndo("Change LookAt");
StoreUndo();
if (m_lookat)
{
@ -2543,63 +2272,6 @@ void CBaseObject::Validate(IErrorReport* report)
//////////////////////////////////////////////////////////////////////////
};
//////////////////////////////////////////////////////////////////////////
Ang3 CBaseObject::GetWorldAngles() const
{
if (m_scale == Vec3(1, 1, 1))
{
Quat q = Quat(GetWorldTM());
Ang3 angles = RAD2DEG(Ang3::GetAnglesXYZ(Matrix33(q)));
return angles;
}
else
{
Matrix34 tm = GetWorldTM();
tm.OrthonormalizeFast();
Quat q = Quat(tm);
Ang3 angles = RAD2DEG(Ang3::GetAnglesXYZ(Matrix33(q)));
return angles;
}
};
//////////////////////////////////////////////////////////////////////////
void CBaseObject::PostClone(CBaseObject* pFromObject, CObjectCloneContext& ctx)
{
CBaseObject* pFromParent = pFromObject->GetParent();
if (pFromParent)
{
SetFloorNumber(pFromObject->GetFloorNumber());
CBaseObject* pFromParentInContext = ctx.FindClone(pFromParent);
if (pFromParentInContext)
{
pFromParentInContext->AddMember(this, false);
}
else
{
pFromParent->AddMember(this, false);
}
}
if (pFromObject->ShouldCloneChildren())
{
for (int i = 0; i < pFromObject->GetChildCount(); i++)
{
CBaseObject* pChildObject = pFromObject->GetChild(i);
CBaseObject* pClonedChild = GetObjectManager()->CloneObject(pChildObject);
ctx.AddClone(pChildObject, pClonedChild);
}
for (int i = 0; i < pFromObject->GetChildCount(); i++)
{
CBaseObject* pChildObject = pFromObject->GetChild(i);
CBaseObject* pClonedChild = ctx.FindClone(pChildObject);
if (pClonedChild)
{
pClonedChild->PostClone(pChildObject, ctx);
}
}
}
}
//////////////////////////////////////////////////////////////////////////
void CBaseObject::GatherUsedResources(CUsedResources& resources)
{
@ -2635,79 +2307,6 @@ void CBaseObject::SetMinSpec(uint32 nSpec, bool bSetChildren)
}
}
//////////////////////////////////////////////////////////////////////////
void CBaseObject::OnPropertyChanged(IVariable*)
{
}
//////////////////////////////////////////////////////////////////////////
void CBaseObject::OnMultiSelPropertyChanged(IVariable*)
{
}
//////////////////////////////////////////////////////////////////////////
void CBaseObject::OnMenuShowInAssetBrowser()
{
if (!IsSelected())
{
CUndo undo("Select Object");
GetIEditor()->GetObjectManager()->ClearSelection();
GetIEditor()->SelectObject(this);
}
GetIEditor()->ExecuteCommand("asset_browser.show_viewport_selection");
}
//////////////////////////////////////////////////////////////////////////
void CBaseObject::OnContextMenu(QMenu* menu)
{
if (!menu->isEmpty())
{
menu->addSeparator();
}
CUsedResources resources;
GatherUsedResources(resources);
static_cast<CEditorImpl*>(GetIEditor())->OnObjectContextMenuOpened(menu, this);
}
//////////////////////////////////////////////////////////////////////////
bool CBaseObject::IntersectRayMesh(const Vec3& raySrc, const Vec3& rayDir, SRayHitInfo& outHitInfo) const
{
const float fRenderMeshTestDistance = 0.2f;
IRenderNode* pRenderNode = GetEngineNode();
if (!pRenderNode)
{
return false;
}
Matrix34 worldTM;
IStatObj* pStatObj = pRenderNode->GetEntityStatObj(0, 0, &worldTM);
if (!pStatObj)
{
return false;
}
// transform decal into object space
Matrix34 worldTM_Inverted = worldTM.GetInverted();
Matrix33 worldRot(worldTM_Inverted);
worldRot.Transpose();
// put hit direction into the object space
Vec3 vRayDir = rayDir.GetNormalized() * worldRot;
// put hit position into the object space
Vec3 vHitPos = worldTM_Inverted.TransformPoint(raySrc);
Vec3 vLineP1 = vHitPos - vRayDir * fRenderMeshTestDistance;
memset(&outHitInfo, 0, sizeof(outHitInfo));
outHitInfo.inReferencePoint = vHitPos;
outHitInfo.inRay.origin = vLineP1;
outHitInfo.inRay.direction = vRayDir;
outHitInfo.bInFirstHit = false;
outHitInfo.bUseCache = false;
return pStatObj->RayIntersection(outHitInfo, nullptr);
}
//////////////////////////////////////////////////////////////////////////
EScaleWarningLevel CBaseObject::GetScaleWarningLevel() const
{

@ -35,8 +35,6 @@ struct SSubObjSelectionModifyContext;
struct SRayHitInfo;
class CPopupMenuItem;
class QMenu;
struct IRenderNode;
struct IStatObj;
//////////////////////////////////////////////////////////////////////////
typedef _smart_ptr<CBaseObject> CBaseObjectPtr;
@ -119,15 +117,6 @@ enum ObjectFlags
#define ERF_GET_WRITABLE(flags) (flags)
//////////////////////////////////////////////////////////////////////////
//! This flags passed to CBaseObject::BeginEditParams method.
enum ObjectEditFlags
{
OBJECT_CREATE = 0x001,
OBJECT_EDIT = 0x002,
OBJECT_COLLAPSE_OBJECTPANEL = 0x004
};
//////////////////////////////////////////////////////////////////////////
//! Return values from CBaseObject::MouseCreateCallback method.
enum MouseCreateResult
@ -137,19 +126,6 @@ enum MouseCreateResult
MOUSECREATE_OK, //!< Accept this object.
};
//////////////////////////////////////////////////////////////////////////
// Interface to the object create with the mouse callback.
//////////////////////////////////////////////////////////////////////////
struct IMouseCreateCallback
{
virtual void Release() = 0;
virtual MouseCreateResult OnMouseEvent(CViewport* view, EMouseEvent event, QPoint& point, int flags) = 0;
// Some process of creation need to be able to be displayed such as creation for custom solid.
virtual void Display([[maybe_unused]] DisplayContext& dc){}
// Called after accepting an object to see if new object creation mode should be continued.
virtual bool ContinueCreation() = 0;
};
// Flags used for object interaction
enum EObjectUpdateFlags
{
@ -261,22 +237,11 @@ public:
/** Check if both object are of same class.
*/
virtual bool IsSameClass(CBaseObject* obj);
virtual void SetDefaultType() { m_objType = OBJTYPE_DUMMY; };
virtual ObjectType GetType() const
{
if (m_objType == OBJTYPE_DUMMY)
{
return m_objType;
}
else
{
return m_classDesc->GetObjectType();
}
return m_classDesc->GetObjectType();
};
// const char* GetTypeName() const { return m_classDesc->ClassName(); };
QString GetTypeName() const;
virtual QString GetTypeDescription() const { return m_classDesc->ClassName(); };
//////////////////////////////////////////////////////////////////////////
// Flags.
@ -289,8 +254,6 @@ public:
// Hidden ID
//////////////////////////////////////////////////////////////////////////
static const uint64 s_invalidHiddenID = 0;
uint64 GetHideOrder() const { return m_hideOrder; }
void SetHideOrder(uint64 newID) { m_hideOrder = newID; }
//! Returns true if object hidden.
bool IsHidden() const;
@ -307,26 +270,19 @@ public:
virtual bool IsSelectable() const;
// Return texture icon.
bool HaveTextureIcon() const { return m_nTextureIcon != 0; };
int GetTextureIcon() const { return m_nTextureIcon; }
void SetTextureIcon(int nTexIcon) { m_nTextureIcon = nTexIcon; }
//! Set shared between missions flag.
virtual void SetShared(bool bShared);
//! Set object hidden status.
virtual void SetHidden(bool bHidden, uint64 hiddenId = CBaseObject::s_invalidHiddenID, bool bAnimated = false);
virtual void SetHidden(bool bHidden, bool bAnimated = false);
//! Set object frozen status.
virtual void SetFrozen(bool bFrozen);
//! Set object selected status.
virtual void SetSelected(bool bSelect);
//! Return associated 3DEngine render node
virtual IRenderNode* GetEngineNode() const { return nullptr; };
//! Set object highlighted (Note: not selected)
virtual void SetHighlight(bool bHighlight);
//! Check if object is highlighted.
bool IsHighlighted() const { return CheckFlags(OBJFLAG_HIGHLIGHT); }
//! Check if object can have measurement axises.
virtual bool HasMeasurementAxis() const { return true; }
//! Check if the object is isolated when the editor is in Isolation Mode
virtual bool IsIsolated() const { return false; }
@ -345,8 +301,6 @@ public:
//////////////////////////////////////////////////////////////////////////
//! Get name of object.
const QString& GetName() const;
virtual QString GetComment() const { return QString(); }
virtual QString GetWarningsText() const;
//! Change name of object.
virtual void SetName(const QString& name);
@ -376,10 +330,6 @@ public:
//! Get object scale.
const Vec3 GetScale() const;
virtual bool StartScaling() { return false; }
virtual bool GetUntransformedScale([[maybe_unused]] Vec3& scale) const { return false; }
virtual bool TransformScale([[maybe_unused]] const Vec3& scale) { return false; }
//! Set flatten area.
void SetArea(float area);
float GetArea() const { return m_flattenArea; };
@ -397,8 +347,6 @@ public:
// CHILDS
//////////////////////////////////////////////////////////////////////////
//! Return true if node have childs.
bool HaveChilds() const { return !m_childs.empty(); }
//! Return true if have attached childs.
size_t GetChildCount() const { return m_childs.size(); }
@ -406,10 +354,6 @@ public:
CBaseObject* GetChild(size_t const i) const;
//! Return parent node if exist.
CBaseObject* GetParent() const { return m_parent; };
//! Scans hierarchy up to determine if we child of specified node.
virtual bool IsChildOf(CBaseObject* node);
//! Clone Children
void CloneChildren(CBaseObject* pFromObject);
//! Attach new child node.
//! @param bKeepPos if true Child node will keep its world space position.
virtual void AttachChild(CBaseObject* child, bool bKeepPos = true);
@ -422,8 +366,6 @@ public:
virtual void DetachAll(bool bKeepPos = true);
// Detach this node from parent.
virtual void DetachThis(bool bKeepPos = true);
// Returns the link parent.
virtual CBaseObject* GetLinkParent() const { return GetParent(); }
//////////////////////////////////////////////////////////////////////////
// MATRIX
@ -437,15 +379,11 @@ public:
// Gets matrix of parent attachment point
virtual Matrix34 GetParentAttachPointWorldTM() const;
// Checks if the attachment point is valid
virtual bool IsParentAttachmentValid() const;
//! Set position in world space.
virtual void SetWorldPos(const Vec3& pos, int flags = 0);
//! Get position in world space.
Vec3 GetWorldPos() const { return GetWorldTM().GetTranslation(); };
Ang3 GetWorldAngles() const;
//! Set xform of object given in world space.
virtual void SetWorldTM(const Matrix34& tm, int flags = 0);
@ -460,12 +398,6 @@ public:
// Interface to be implemented in plugins.
//////////////////////////////////////////////////////////////////////////
//! Called when object is being created (use GetMouseCreateCallback for more advanced mouse creation callback).
virtual int MouseCreateCallback(CViewport* view, EMouseEvent event, QPoint& point, int flags);
// Return pointer to the callback object used when creating object by the mouse.
// If this function return nullptr MouseCreateCallback method will be used instead.
virtual IMouseCreateCallback* GetMouseCreateCallback() { return nullptr; };
//! Draw object to specified viewport.
virtual void Display([[maybe_unused]] DisplayContext& disp) {}
@ -477,10 +409,6 @@ public:
//! Return true if was hit.
virtual bool HitTestRect(HitContext& hc);
//! Perform intersection testing of this object based on its icon helper.
//! Return true if was hit.
virtual bool HitHelperTest(HitContext& hc);
//! Get bounding box of object in world coordinate space.
virtual void GetBoundBox(AABB& box);
@ -500,8 +428,6 @@ public:
//! @param bUndo true if loading or saving data for Undo/Redo purposes.
virtual void Serialize(CObjectArchive& ar);
//// Pre load called before serialize after all objects where completly loaded.
//virtual void PreLoad( CObjectArchive &ar ) {};
// Post load called after all objects where completely loaded.
virtual void PostLoad([[maybe_unused]] CObjectArchive& ar) {};
@ -513,9 +439,6 @@ public:
//! Override in derived classes, to handle specific events.
virtual void OnEvent(ObjectEvent event);
//! Generate dynamic context menu for the object
virtual void OnContextMenu(QMenu* menu);
//////////////////////////////////////////////////////////////////////////
// LookAt Target.
//////////////////////////////////////////////////////////////////////////
@ -523,13 +446,11 @@ public:
CBaseObject* GetLookAt() const { return m_lookat; };
//! Returns true if this object is a look-at target.
bool IsLookAtTarget() const;
CBaseObject* GetLookAtSource() const { return m_lookatSource; };
IObjectManager* GetObjectManager() const;
//! Store undo information for this object.
void StoreUndo(const char* undoDescription, bool minimal = false, int flags = 0);
void StoreUndo(bool minimal = false, int flags = 0);
//! Add event listener callback.
void AddEventListener(EventListener* listener);
@ -548,52 +469,21 @@ public:
//! Check if specified object is very similar to this one.
virtual bool IsSimilarObject(CBaseObject* pObject);
//////////////////////////////////////////////////////////////////////////
// Material Layers Mask.
//////////////////////////////////////////////////////////////////////////
virtual void SetMaterialLayersMask(uint32 nLayersMask) { m_nMaterialLayersMask = nLayersMask; }
uint32 GetMaterialLayersMask() const { return m_nMaterialLayersMask; };
//////////////////////////////////////////////////////////////////////////
// Object minimal usage spec (All/Low/Medium/High)
//////////////////////////////////////////////////////////////////////////
uint32 GetMinSpec() const { return m_nMinSpec; }
virtual void SetMinSpec(uint32 nSpec, bool bSetChildren = true);
//////////////////////////////////////////////////////////////////////////
// SubObj selection.
//////////////////////////////////////////////////////////////////////////
// Return true if object support selecting of this sub object element type.
virtual bool StartSubObjSelection([[maybe_unused]] int elemType) { return false; };
virtual void EndSubObjectSelection() {};
virtual void ModifySubObjSelection([[maybe_unused]] SSubObjSelectionModifyContext& modCtx) {};
virtual void AcceptSubObjectModify() {};
//! In This function variables of the object must be initialized.
virtual void InitVariables() {};
//////////////////////////////////////////////////////////////////////////
// Procedural Floor Management.
//////////////////////////////////////////////////////////////////////////
int GetFloorNumber() const { return m_floorNumber; };
void SetFloorNumber(int floorNumber) { m_floorNumber = floorNumber; };
virtual void OnPropertyChanged(IVariable*);
virtual void OnMultiSelPropertyChanged(IVariable*);
//! Draw a reddish highlight indicating its budget usage.
virtual void DrawBudgetUsage(DisplayContext& dc, const QColor& color);
bool IntersectRayMesh(const Vec3& raySrc, const Vec3& rayDir, SRayHitInfo& outHitInfo) const;
virtual void EditTags([[maybe_unused]] bool alwaysTag) {}
virtual bool SupportsEditTags() const { return false; }
bool CanBeHightlighted() const;
bool IsSkipSelectionHelper() const;
virtual IStatObj* GetIStatObj() { return nullptr; }
// Invalidates cached transformation matrix.
// nWhyFlags - Flags that indicate the reason for matrix invalidation.
virtual void InvalidateTM(int nWhyFlags);
@ -612,26 +502,14 @@ protected:
//! Optional file parameter specify initial object or script for this object.
virtual bool Init(IEditor* ie, CBaseObject* prev, const QString& file);
//////////////////////////////////////////////////////////////////////////
//! Must be called after cloning the object on clone of object.
//! This will make sure object references are cloned correctly.
virtual void PostClone(CBaseObject* pFromObject, CObjectCloneContext& ctx);
//! Must be implemented by derived class to create game related objects.
virtual bool CreateGameObject() { return true; };
//! If true, all attached chilren will be cloned when the parent object is cloned.
virtual bool ShouldCloneChildren() const { return true; }
/** Called when object is about to be deleted.
All Game resources should be freed in this function.
All Game resources should be freed in this function.
*/
virtual void Done();
/** Change current id of object.
*/
//virtual void SetId( uint32 objectId ) { m_id = objectId; };
//! Call this to delete an object.
virtual void DeleteThis() = 0;
@ -682,17 +560,11 @@ protected:
// Function can be used by derived classes.
bool HitTestRectBounds(HitContext& hc, const AABB& box);
// Do helper hit testing as specific location.
bool HitHelperAtTest(HitContext& hc, const Vec3& pos);
// Do helper hit testing taking child objects into account (e.g. opened prefab)
virtual bool HitHelperTestForChildObjects([[maybe_unused]] HitContext& hc) { return false; }
CBaseObject* FindObject(REFGUID id) const;
// Returns true if game objects should be created.
bool IsCreateGameObjects() const;
// Helper gizmo functions.
void AddGizmo(CGizmo* gizmo);
void RemoveGizmo(CGizmo* gizmo);
@ -703,14 +575,6 @@ protected:
//! Only used by ObjectManager.
bool IsPotentiallyVisible() const;
//////////////////////////////////////////////////////////////////////////
// May be overridden in derived classes to handle helpers scaling.
//////////////////////////////////////////////////////////////////////////
virtual void SetHelperScale([[maybe_unused]] float scale) {};
virtual float GetHelperScale() { return 1.0f; };
void SetNameInternal(const QString& name) { m_name = name; }
void SetDrawTextureIconProperties(DisplayContext& dc, const Vec3& pos, float alpha = 1.0f, int texIconFlags = 0);
const Vec3& GetTextureIconDrawPos(){ return m_vDrawIconPos; };
int GetTextureIconFlags(){ return m_nIconFlags; };
@ -732,8 +596,6 @@ private:
friend class CObjectArchive;
friend class CSelectionGroup;
void OnMenuShowInAssetBrowser();
//! Set class description for this object,
//! Only called once after creation by ObjectManager.
void SetClassDesc(CObjectClassDesc* classDesc);
@ -741,9 +603,6 @@ private:
EScaleWarningLevel GetScaleWarningLevel() const;
ERotationWarningLevel GetRotationWarningLevel() const;
// auto resolving
void OnMtlResolved(uint32 id, bool success, const char* orgName, const char* newName);
bool IsInSelectionBox() const { return m_bInSelectionBox; }
void SetId(REFGUID guid) { m_guid = guid; }
@ -766,13 +625,10 @@ private:
//! Unique object Id.
GUID m_guid;
// floor number of object if procedural object flag is set
int m_floorNumber;
//! Flags of this object.
int m_flags;
// Id of the texture icon for this object.
//! Id of the texture icon for this object.
int m_nTextureIcon;
//! Display color.
@ -823,13 +679,10 @@ private:
mutable uint32 m_bMatrixValid : 1;
mutable uint32 m_bWorldBoxValid : 1;
uint32 m_bInSelectionBox : 1;
uint32 m_nMaterialLayersMask : 8;
uint32 m_nMinSpec : 8;
Vec3 m_vDrawIconPos;
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
uint64 m_hideOrder;
};
Q_DECLARE_METATYPE(CBaseObject*)

@ -81,11 +81,38 @@ struct SANDBOX_API DisplayContext
// Draw functions
//////////////////////////////////////////////////////////////////////////
//! Set current materialc color.
void SetColor(float r, float g, float b, float a = 1) { m_color4b = ColorB(static_cast<uint8>(r * 255.0f), static_cast<uint8>(g * 255.0f), static_cast<uint8>(b * 255.0f), static_cast<uint8>(a * 255.0f)); };
void SetColor(const Vec3& color, float a = 1) { m_color4b = ColorB(static_cast<uint8>(color.x * 255.0f), static_cast<uint8>(color.y * 255.0f), static_cast<uint8>(color.z * 255.0f), static_cast<uint8>(a * 255.0f)); };
void SetColor(const QColor& rgb, float a) { m_color4b = ColorB(static_cast<uint8>(rgb.red()), static_cast<uint8>(rgb.green()), static_cast<uint8>(rgb.blue()), static_cast<uint8>(a * 255.0f)); };
void SetColor(const QColor& color) { m_color4b = ColorB(static_cast<uint8>(color.red()), static_cast<uint8>(color.green()), static_cast<uint8>(color.blue()), static_cast<uint8>(color.alpha())); };
void SetColor(const ColorB& color) { m_color4b = color; };
void SetColor(float r, float g, float b, float a = 1)
{
m_color4b = ColorB(
static_cast<uint8>(r * 255.0f), static_cast<uint8>(g * 255.0f), static_cast<uint8>(b * 255.0f), static_cast<uint8>(a * 255.0f));
};
void SetColor(const Vec3& color, float a = 1)
{
m_color4b = ColorB(
static_cast<uint8>(color.x * 255.0f), static_cast<uint8>(color.y * 255.0f), static_cast<uint8>(color.z * 255.0f),
static_cast<uint8>(a * 255.0f));
};
void SetColor(const AZ::Vector3& color, float a = 1)
{
m_color4b = ColorB(
static_cast<uint8>(color.GetX() * 255.0f), static_cast<uint8>(color.GetY() * 255.0f), static_cast<uint8>(color.GetZ() * 255.0f),
static_cast<uint8>(a * 255.0f));
};
void SetColor(const QColor& rgb, float a)
{
m_color4b = ColorB(
static_cast<uint8>(rgb.red()), static_cast<uint8>(rgb.green()), static_cast<uint8>(rgb.blue()), static_cast<uint8>(a * 255.0f));
};
void SetColor(const QColor& color)
{
m_color4b = ColorB(
static_cast<uint8>(color.red()), static_cast<uint8>(color.green()), static_cast<uint8>(color.blue()),
static_cast<uint8>(color.alpha()));
};
void SetColor(const ColorB& color)
{
m_color4b = color;
};
void SetAlpha(float a = 1) { m_color4b.a = static_cast<uint8>(a * 255.0f); };
ColorB GetColor() const { return m_color4b; }
@ -108,6 +135,7 @@ struct SANDBOX_API DisplayContext
void DrawTrianglesIndexed(const AZStd::vector<Vec3>& vertices, const AZStd::vector<vtx_idx>& indices, const ColorB& color);
// Draw wireframe box.
void DrawWireBox(const Vec3& min, const Vec3& max);
void DrawWireBox(const AZ::Vector3& min, const AZ::Vector3& max);
// Draw filled box
void DrawSolidBox(const Vec3& min, const Vec3& max);
void DrawSolidOBB(const Vec3& center, const Vec3& axisX, const Vec3& axisY, const Vec3& axisZ, const Vec3& halfExtents);

@ -225,6 +225,12 @@ void DisplayContext::DrawWireBox(const Vec3& min, const Vec3& max)
pRenderAuxGeom->DrawAABB(AABB(min, max), m_matrixStack[m_currentMatrix], false, m_color4b, eBBD_Faceted);
}
void DisplayContext::DrawWireBox(const AZ::Vector3& min, const AZ::Vector3& max)
{
pRenderAuxGeom->DrawAABB(
AABB(Vec3(min.GetX(), min.GetY(), min.GetZ()), Vec3(max.GetX(), max.GetY(), max.GetZ())),
m_matrixStack[m_currentMatrix], false, m_color4b, eBBD_Faceted);
}
//////////////////////////////////////////////////////////////////////////
void DisplayContext::DrawSolidBox(const Vec3& min, const Vec3& max)
{

@ -28,8 +28,7 @@
#include "HitContext.h"
#include "Objects/SelectionGroup.h"
#include <IEntityRenderState.h>
#include <IStatObj.h>
static constexpr int VIEW_DISTANCE_MULTIPLIER_MAX = 100;
//////////////////////////////////////////////////////////////////////////
//! Undo Entity Link
@ -58,7 +57,6 @@ public:
protected:
void Release() override { delete this; };
int GetSize() override { return sizeof(*this); }; // Return size of xml state.
QString GetDescription() override { return "Entity Link"; };
QString GetObjectName() override{ return ""; };
void Undo([[maybe_unused]] bool bUndo) override
@ -139,7 +137,6 @@ private:
}
int GetSize() override { return sizeof(CUndoAttachEntity); }
QString GetDescription() override { return "Attachment Changed"; }
GUID m_attachedEntityGUID;
CEntityObject::EAttachmentType m_attachmentType;
@ -151,8 +148,6 @@ private:
// CBase implementation.
//////////////////////////////////////////////////////////////////////////
float CEntityObject::m_helperScale = 1;
namespace
{
CEntityObject* s_pPropertyPanelEntityObject = nullptr;
@ -163,12 +158,9 @@ namespace
//////////////////////////////////////////////////////////////////////////
CEntityObject::CEntityObject()
: m_listeners(1)
{
m_bLoadFailed = false;
m_visualObject = nullptr;
m_box.min.Set(0, 0, 0);
m_box.max.Set(0, 0, 0);
@ -223,7 +215,7 @@ CEntityObject::CEntityObject()
mv_ratioLOD = 100;
mv_viewDistanceMultiplier = 1.0f;
mv_ratioLOD.SetLimits(0, 255);
mv_viewDistanceMultiplier.SetLimits(0.0f, IRenderNode::VIEW_DISTANCE_MULTIPLIER_MAX);
mv_viewDistanceMultiplier.SetLimits(0.0f, VIEW_DISTANCE_MULTIPLIER_MAX);
m_physicsState = nullptr;
@ -247,7 +239,6 @@ CEntityObject::CEntityObject()
m_onSetCallbacksCache.emplace_back([this](IVariable* var) { OnProjectInAllDirsChange(var); });
m_onSetCallbacksCache.emplace_back([this](IVariable* var) { OnProjectorFOVChange(var); });
m_onSetCallbacksCache.emplace_back([this](IVariable* var) { OnProjectorTextureChange(var); });
m_onSetCallbacksCache.emplace_back([this](IVariable* var) { OnPropertyChange(var); });
m_onSetCallbacksCache.emplace_back([this](IVariable* var) { OnRadiusChange(var); });
}
@ -295,11 +286,6 @@ void CEntityObject::Done()
ReleaseEventTargets();
RemoveAllEntityLinks();
for (CListenerSet<IEntityObjectListener*>::Notifier notifier(m_listeners); notifier.IsValid(); notifier.Next())
{
notifier->OnDone();
}
CBaseObject::Done();
}
@ -365,12 +351,6 @@ void CEntityObject::SetTransformDelegate(ITransformDelegate* pTransformDelegate)
ResetCallbacks();
}
//////////////////////////////////////////////////////////////////////////
bool CEntityObject::IsSameClass(CBaseObject* obj)
{
return (GetClassDesc() == obj->GetClassDesc());
}
//////////////////////////////////////////////////////////////////////////
bool CEntityObject::ConvertFromObject(CBaseObject* object)
{
@ -458,33 +438,10 @@ bool CEntityObject::HitTest(HitContext& hc)
return false;
}
//////////////////////////////////////////////////////////////////////////
bool CEntityObject::HitHelperTest(HitContext& hc)
{
bool bResult = CBaseObject::HitHelperTest(hc);
if (bResult)
{
hc.object = this;
}
return bResult;
}
//////////////////////////////////////////////////////////////////////////
bool CEntityObject::HitTestRect(HitContext& hc)
{
bool bResult = false;
if (m_visualObject && !gSettings.viewports.bShowIcons && !gSettings.viewports.bShowSizeBasedIcons)
{
AABB box;
box.SetTransformedAABB(GetWorldTM(), m_visualObject->GetAABB());
bResult = HitTestRectBounds(hc, box);
}
else
{
bResult = CBaseObject::HitTestRect(hc);
}
bool bResult = CBaseObject::HitTestRect(hc);
if (bResult)
{
@ -494,42 +451,6 @@ bool CEntityObject::HitTestRect(HitContext& hc)
return bResult;
}
//////////////////////////////////////////////////////////////////////////
int CEntityObject::MouseCreateCallback(CViewport* view, EMouseEvent event, QPoint& point, int flags)
{
AZ_PROFILE_FUNCTION(Entity);
if (event == eMouseMove || event == eMouseLDown)
{
Vec3 pos;
// Rise Entity above ground on Bounding box amount.
if (GetIEditor()->GetAxisConstrains() != AXIS_TERRAIN)
{
pos = view->MapViewToCP(point);
}
else
{
// Snap to terrain.
bool hitTerrain;
pos = view->ViewToWorld(point, &hitTerrain);
if (hitTerrain)
{
pos.z = GetIEditor()->GetTerrainElevation(pos.x, pos.y);
pos.z = pos.z - m_box.min.z;
}
pos = view->SnapToGrid(pos);
}
SetPos(pos);
if (event == eMouseLDown)
{
return MOUSECREATE_OK;
}
return MOUSECREATE_CONTINUE;
}
return CBaseObject::MouseCreateCallback(view, event, point, flags);
}
//////////////////////////////////////////////////////////////////////////
IVariable* CEntityObject::FindVariableInSubBlock(CVarBlockPtr& properties, IVariable* pSubBlockVar, const char* pVarName)
{
@ -680,11 +601,6 @@ void CEntityObject::SetName(const QString& name)
CBaseObject::SetName(name);
CListenerSet<IEntityObjectListener*> listeners = m_listeners;
for (CListenerSet<IEntityObjectListener*>::Notifier notifier(listeners); notifier.IsValid(); notifier.Next())
{
notifier->OnNameChanged(name.toUtf8().data());
}
}
//////////////////////////////////////////////////////////////////////////
@ -697,19 +613,6 @@ void CEntityObject::SetSelected(bool bSelect)
UpdateLightProperty();
}
for (CListenerSet<IEntityObjectListener*>::Notifier notifier(m_listeners); notifier.IsValid(); notifier.Next())
{
notifier->OnSelectionChanged(bSelect);
}
}
//////////////////////////////////////////////////////////////////////////
void CEntityObject::OnPropertyChange([[maybe_unused]] IVariable* var)
{
if (s_ignorePropertiesUpdate)
{
return;
}
}
template <typename T>
@ -941,11 +844,9 @@ void CEntityObject::Serialize(CObjectArchive& ar)
m_eventTargets.emplace_back(AZStd::move(et));
if (targetId != GUID_NULL)
{
using namespace AZStd::placeholders;
ar.SetResolveCallback(
this, targetId,
[this](CBaseObject* object, unsigned int index) { ResolveEventTarget(object, index); },
i);
[this,i](CBaseObject* object) { ResolveEventTarget(object, i); });
}
}
}
@ -1154,12 +1055,6 @@ XmlNodeRef CEntityObject::Export([[maybe_unused]] const QString& levelPath, XmlN
objNode->setAttr("MinSpec", ( uint32 )GetMinSpec());
}
uint32 nMtlLayersMask = GetMaterialLayersMask();
if (nMtlLayersMask != 0)
{
objNode->setAttr("MatLayersMask", nMtlLayersMask);
}
if (mv_hiddenInGame)
{
objNode->setAttr("HiddenInGame", true);
@ -1256,11 +1151,6 @@ void CEntityObject::OnEvent(ObjectEvent event)
case EVENT_CONFIG_SPEC_CHANGE:
{
IObjectManager* objMan = GetIEditor()->GetObjectManager();
if (objMan && objMan->IsLightClass(this))
{
OnPropertyChange(nullptr);
}
break;
}
default:
@ -1350,56 +1240,6 @@ QString CEntityObject::GetLightAnimation() const
return "";
}
//////////////////////////////////////////////////////////////////////////
void CEntityObject::PostClone(CBaseObject* pFromObject, CObjectCloneContext& ctx)
{
CBaseObject::PostClone(pFromObject, ctx);
CEntityObject* pFromEntity = ( CEntityObject* )pFromObject;
// Clone event targets.
if (!pFromEntity->m_eventTargets.empty())
{
size_t numTargets = pFromEntity->m_eventTargets.size();
for (size_t i = 0; i < numTargets; i++)
{
CEntityEventTarget& et = pFromEntity->m_eventTargets[i];
CBaseObject* pClonedTarget = ctx.FindClone(et.target);
if (!pClonedTarget)
{
pClonedTarget = et.target; // If target not cloned, link to original target.
}
// Add cloned event.
AddEventTarget(pClonedTarget, et.event, et.sourceEvent, true);
}
}
// Clone links.
if (!pFromEntity->m_links.empty())
{
int numTargets = static_cast<int>(pFromEntity->m_links.size());
for (int i = 0; i < numTargets; i++)
{
CEntityLink& et = pFromEntity->m_links[i];
CBaseObject* pClonedTarget = ctx.FindClone(et.target);
if (!pClonedTarget)
{
pClonedTarget = et.target; // If target not cloned, link to original target.
}
// Add cloned event.
if (pClonedTarget)
{
AddEntityLink(et.name, pClonedTarget->GetId());
}
else
{
AddEntityLink(et.name, GUID_NULL);
}
}
}
}
//////////////////////////////////////////////////////////////////////////
void CEntityObject::ResolveEventTarget(CBaseObject* object, unsigned int index)
{
@ -1554,7 +1394,7 @@ void CEntityObject::OnObjectEvent(CBaseObject* target, int event)
//////////////////////////////////////////////////////////////////////////
int CEntityObject::AddEventTarget(CBaseObject* target, const QString& event, const QString& sourceEvent, [[maybe_unused]] bool bUpdateScript)
{
StoreUndo("Add EventTarget");
StoreUndo();
CEntityEventTarget et;
et.target = target;
et.event = event;
@ -1588,7 +1428,7 @@ void CEntityObject::RemoveEventTarget(int index, [[maybe_unused]] bool bUpdateSc
{
if (index >= 0 && index < m_eventTargets.size())
{
StoreUndo("Remove EventTarget");
StoreUndo();
if (m_eventTargets[index].pLineGizmo)
{
@ -1624,7 +1464,7 @@ int CEntityObject::AddEntityLink(const QString& name, GUID targetEntityId)
}
}
StoreUndo("Add EntityLink");
StoreUndo();
CLineGizmo* pLineGizmo = nullptr;
@ -1672,7 +1512,7 @@ void CEntityObject::RemoveEntityLink(int index)
if (index >= 0 && index < m_links.size())
{
CEntityLink& link = m_links[index];
StoreUndo("Remove EntityLink");
StoreUndo();
if (link.pLineGizmo)
{
@ -1695,7 +1535,7 @@ void CEntityObject::RenameEntityLink(int index, const QString& newName)
{
if (index >= 0 && index < m_links.size())
{
StoreUndo("Rename EntityLink");
StoreUndo();
if (m_links[index].pLineGizmo)
{
@ -1842,18 +1682,6 @@ void CEntityObject::OnLoadFailed()
GetIEditor()->GetErrorReport()->ReportError(err);
}
//////////////////////////////////////////////////////////////////////////
void CEntityObject::SetHelperScale(float scale)
{
m_helperScale = scale;
}
//////////////////////////////////////////////////////////////////////////
float CEntityObject::GetHelperScale()
{
return m_helperScale;
}
//////////////////////////////////////////////////////////////////////////
//! Analyze errors for this object.
void CEntityObject::Validate(IErrorReport* report)
@ -1901,19 +1729,6 @@ bool CEntityObject::IsSimilarObject(CBaseObject* pObject)
return false;
}
//////////////////////////////////////////////////////////////////////////
void CEntityObject::OnContextMenu(QMenu* pMenu)
{
if (!pMenu->isEmpty())
{
pMenu->addSeparator();
}
// Events
CBaseObject::OnContextMenu(pMenu);
}
//////////////////////////////////////////////////////////////////////////
void CEntityObject::PreInitLightProperty()
{
@ -2171,16 +1986,6 @@ void CEntityObject::StoreUndoEntityLink(CSelectionGroup* pGroup)
}
}
void CEntityObject::RegisterListener(IEntityObjectListener* pListener)
{
m_listeners.Add(pListener);
}
void CEntityObject::UnregisterListener(IEntityObjectListener* pListener)
{
m_listeners.Remove(pListener);
}
template <typename T>
T CEntityObject::GetEntityProperty(const char* pName, T defaultvalue) const
{

@ -16,10 +16,7 @@
#include "BaseObject.h"
#include "IMovieSystem.h"
#include "IEntityObjectListener.h"
#include "Gizmo.h"
#include "CryListenerSet.h"
#include "StatObjBus.h"
#include <QObject>
#endif
@ -81,11 +78,6 @@ public:
//////////////////////////////////////////////////////////////////////////
// Overrides from CBaseObject.
//////////////////////////////////////////////////////////////////////////
//! Return type name of Entity.
QString GetTypeDescription() const override { return GetEntityClass(); };
//////////////////////////////////////////////////////////////////////////
bool IsSameClass(CBaseObject* obj) override;
bool Init(IEditor* ie, CBaseObject* prev, const QString& file) override;
void InitVariables() override;
@ -102,16 +94,12 @@ public:
void SetEntityPropertyFloat(const char* name, float value);
void SetEntityPropertyString(const char* name, const QString& value);
int MouseCreateCallback(CViewport* view, EMouseEvent event, QPoint& point, int flags) override;
void OnContextMenu(QMenu* menu) override;
void SetName(const QString& name) override;
void SetSelected(bool bSelect) override;
void GetLocalBounds(AABB& box) override;
bool HitTest(HitContext& hc) override;
bool HitHelperTest(HitContext& hc) override;
bool HitTestRect(HitContext& hc) override;
void UpdateVisibility(bool bVisible) override;
bool ConvertFromObject(CBaseObject* object) override;
@ -139,14 +127,9 @@ public:
EAttachmentType GetAttachType() const { return m_attachmentType; }
QString GetAttachTarget() const { return m_attachmentTarget; }
void SetHelperScale(float scale) override;
float GetHelperScale() override;
void GatherUsedResources(CUsedResources& resources) override;
bool IsSimilarObject(CBaseObject* pObject) override;
bool HasMeasurementAxis() const override { return false; }
bool IsIsolated() const override { return false; }
//////////////////////////////////////////////////////////////////////////
@ -220,20 +203,12 @@ public:
static void StoreUndoEntityLink(CSelectionGroup* pGroup);
void RegisterListener(IEntityObjectListener* pListener);
void UnregisterListener(IEntityObjectListener* pListener);
protected:
template <typename T>
void SetEntityProperty(const char* name, T value);
template <typename T>
T GetEntityProperty(const char* name, T defaultvalue) const;
//////////////////////////////////////////////////////////////////////////
//! Must be called after cloning the object on clone of object.
//! This will make sure object references are cloned correctly.
void PostClone(CBaseObject* pFromObject, CObjectCloneContext& ctx) override;
//! Draw default object items.
void DrawProjectorPyramid(DisplayContext& dc, float dist);
void DrawProjectorFrustum(DisplayContext& dc, Vec2 size, float dist);
@ -242,10 +217,6 @@ protected:
CVarBlock* CloneProperties(CVarBlock* srcProperties);
//////////////////////////////////////////////////////////////////////////
//! Callback called when one of entity properties have been modified.
void OnPropertyChange(IVariable* var);
//////////////////////////////////////////////////////////////////////////
void OnObjectEvent(CBaseObject* target, int event) override;
void ResolveEventTarget(CBaseObject* object, unsigned int index);
@ -327,7 +298,6 @@ protected:
// Used for light entities
float m_projectorFOV;
IStatObj* m_visualObject;
AABB m_box;
//////////////////////////////////////////////////////////////////////////
@ -388,8 +358,6 @@ protected:
XmlNodeRef m_physicsState;
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
static float m_helperScale;
EAttachmentType m_attachmentType;
bool m_bEnableReload;
@ -433,7 +401,6 @@ private:
void ForceVariableUpdate();
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
CListenerSet<IEntityObjectListener*> m_listeners;
std::vector< std::pair<IVariable*, IVariable::OnSetCallback*> > m_callbacks;
AZStd::fixed_vector< IVariable::OnSetCallback, VariableCallbackIndex::Count > m_onSetCallbacksCache;
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING

@ -1,20 +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
*
*/
#pragma once
class IEntityObjectListener
{
public:
virtual ~IEntityObjectListener() = default;
virtual void OnNameChanged(const char* pName) = 0;
virtual void OnSelectionChanged(const bool bSelected) = 0;
virtual void OnDone() = 0;
};

@ -28,19 +28,12 @@ CObjectArchive::CObjectArchive(IObjectManager* objMan, XmlNodeRef xmlRoot, bool
m_nFlags = 0;
node = xmlRoot;
m_pCurrentErrorReport = GetIEditor()->GetErrorReport();
m_pGeometryPak = nullptr;
m_pCurrentObject = nullptr;
m_bNeedResolveObjects = false;
m_bProgressBarEnabled = true;
}
//////////////////////////////////////////////////////////////////////////
CObjectArchive::~CObjectArchive()
{
if (m_pGeometryPak)
{
delete m_pGeometryPak;
}
// Always make sure objects are resolved when loading from archive.
if (bLoading && m_bNeedResolveObjects)
{
@ -74,31 +67,6 @@ void CObjectArchive::SetResolveCallback(CBaseObject* fromObject, REFGUID objectI
}
}
//////////////////////////////////////////////////////////////////////////
void CObjectArchive::SetResolveCallback(CBaseObject* fromObject, REFGUID objectId, ResolveObjRefFunctor2 func, uint32 userData)
{
if (objectId == GUID_NULL)
{
func(0, userData);
return;
}
CBaseObject* object = m_objectManager->FindObject(objectId);
if (object && !(m_nFlags & eObjectLoader_MakeNewIDs))
{
// Object is already resolved. immidiatly call callback.
func(object, userData);
}
else
{
Callback cb;
cb.fromObject = fromObject;
cb.func2 = func;
cb.userData = userData;
m_resolveCallbacks.insert(Callbacks::value_type(objectId, cb));
}
}
//////////////////////////////////////////////////////////////////////////
GUID CObjectArchive::ResolveID(REFGUID id)
{
@ -117,10 +85,7 @@ void CObjectArchive::ResolveObjects()
{
CWaitProgress wait("Loading Objects", false);
if (m_bProgressBarEnabled)
{
wait.Start();
}
wait.Start();
GetIEditor()->SuspendUndo();
//////////////////////////////////////////////////////////////////////////
@ -129,10 +94,7 @@ void CObjectArchive::ResolveObjects()
int numObj = static_cast<int>(m_loadedObjects.size());
for (i = 0; i < numObj; i++)
{
if (m_bProgressBarEnabled)
{
wait.Step((i * 100) / numObj);
}
wait.Step((i * 100) / numObj);
SLoadedObjectInfo& obj = m_loadedObjects[i];
m_pCurrentErrorReport->SetCurrentValidatorObject(obj.pObject);
@ -204,30 +166,20 @@ void CObjectArchive::ResolveObjects()
{
(cb.func1)(object);
}
if (cb.func2)
{
(cb.func2)(object, cb.userData);
}
}
m_resolveCallbacks.clear();
//////////////////////////////////////////////////////////////////////////
{
CWaitProgress wait("Creating Objects", false);
if (m_bProgressBarEnabled)
{
wait.Start();
}
wait.Start();
//////////////////////////////////////////////////////////////////////////
// Serialize All Objects from XML.
//////////////////////////////////////////////////////////////////////////
int numObj = static_cast<int>(m_loadedObjects.size());
for (i = 0; i < numObj; i++)
{
if (m_bProgressBarEnabled)
{
wait.Step((i * 100) / numObj);
}
wait.Step((i * 100) / numObj);
SLoadedObjectInfo& obj = m_loadedObjects[i];
m_pCurrentErrorReport->SetCurrentValidatorObject(obj.pObject);
@ -258,8 +210,6 @@ void CObjectArchive::ResolveObjects()
m_bNeedResolveObjects = false;
m_pCurrentErrorReport->SetCurrentValidatorObject(nullptr);
m_sequenceIdRemap.clear();
m_pendingIds.clear();
}
//////////////////////////////////////////////////////////////////////////
@ -272,7 +222,6 @@ void CObjectArchive::SaveObject(CBaseObject* pObject)
if (m_savedObjects.find(pObject) == m_savedObjects.end())
{
m_pCurrentObject = pObject;
m_savedObjects.insert(pObject);
// If this object was not saved before.
XmlNodeRef objNode = node->newChild("Object");
@ -307,45 +256,6 @@ CBaseObject* CObjectArchive::LoadObject(const XmlNodeRef& objNode, CBaseObject*
return pObject;
}
//////////////////////////////////////////////////////////////////////////
void CObjectArchive::LoadObjects(XmlNodeRef& rootObjectsNode)
{
int numObjects = rootObjectsNode->getChildCount();
for (int i = 0; i < numObjects; i++)
{
XmlNodeRef objNode = rootObjectsNode->getChild(i);
LoadObject(objNode, nullptr);
}
}
//////////////////////////////////////////////////////////////////////////
void CObjectArchive::ReportError(CErrorRecord& err)
{
if (m_pCurrentErrorReport)
{
m_pCurrentErrorReport->ReportError(err);
}
}
//////////////////////////////////////////////////////////////////////////
void CObjectArchive::SetErrorReport(CErrorReport* errReport)
{
if (errReport)
{
m_pCurrentErrorReport = errReport;
}
else
{
m_pCurrentErrorReport = GetIEditor()->GetErrorReport();
}
}
//////////////////////////////////////////////////////////////////////////
void CObjectArchive::ShowErrors()
{
GetIEditor()->GetErrorReport()->Display();
}
//////////////////////////////////////////////////////////////////////////
void CObjectArchive::MakeNewIds(bool bEnable)
{
@ -359,70 +269,8 @@ void CObjectArchive::MakeNewIds(bool bEnable)
}
}
//////////////////////////////////////////////////////////////////////////
void CObjectArchive::SetShouldResetInternalMembers(bool reset)
{
if (reset)
{
m_nFlags |= eObjectLoader_ResetInternalMembers;
}
else
{
m_nFlags &= ~(eObjectLoader_ResetInternalMembers);
}
}
//////////////////////////////////////////////////////////////////////////
void CObjectArchive::RemapID(REFGUID oldId, REFGUID newId)
{
m_IdRemap[oldId] = newId;
}
//////////////////////////////////////////////////////////////////////////
CPakFile* CObjectArchive::GetGeometryPak(const char* sFilename)
{
if (m_pGeometryPak)
{
return m_pGeometryPak;
}
m_pGeometryPak = new CPakFile;
m_pGeometryPak->Open(sFilename);
return m_pGeometryPak;
}
//////////////////////////////////////////////////////////////////////////
CBaseObject* CObjectArchive::GetCurrentObject()
{
return m_pCurrentObject;
}
//////////////////////////////////////////////////////////////////////////
void CObjectArchive::AddSequenceIdMapping(uint32 oldId, uint32 newId)
{
assert(oldId != newId);
assert(GetIEditor()->GetMovieSystem()->FindSequenceById(oldId) || stl::find(m_pendingIds, oldId));
assert(GetIEditor()->GetMovieSystem()->FindSequenceById(newId) == nullptr);
assert(stl::find(m_pendingIds, newId) == false);
m_sequenceIdRemap[oldId] = newId;
m_pendingIds.push_back(newId);
}
//////////////////////////////////////////////////////////////////////////
uint32 CObjectArchive::RemapSequenceId(uint32 id) const
{
std::map<uint32, uint32>::const_iterator itr = m_sequenceIdRemap.find(id);
if (itr == m_sequenceIdRemap.end())
{
return id;
}
else
{
return itr->second;
}
}
//////////////////////////////////////////////////////////////////////////
bool CObjectArchive::IsAmongPendingIds(uint32 id) const
{
return stl::find(m_pendingIds, id);
}

@ -6,18 +6,13 @@
*
*/
#ifndef CRYINCLUDE_EDITOR_OBJECTS_OBJECTLOADER_H
#define CRYINCLUDE_EDITOR_OBJECTS_OBJECTLOADER_H
#pragma once
#include "Util/GuidUtil.h"
#include "ErrorReport.h"
#include <AzCore/std/containers/set.h>
#include <set>
class CPakFile;
class CErrorRecord;
struct IObjectManager;
@ -43,63 +38,27 @@ AZ_POP_DISABLE_DLL_EXPORT_BASECLASS_WARNING
//! Resolve callback with only one parameter of CBaseObject.
typedef AZStd::function<void(CBaseObject*)> ResolveObjRefFunctor1;
//! Resolve callback with two parameters one is pointer to CBaseObject and second use data integer.
typedef AZStd::function<void(CBaseObject*, unsigned int)> ResolveObjRefFunctor2;
/** Register Object id.
@param objectId Original object id from the file.
@param realObjectId Changed object id.
*/
//void RegisterObjectId( int objectId,int realObjectId );
// Return object ID remapped after loading.
GUID ResolveID(REFGUID id);
//! Set object resolve callback, it will be called once object with specified Id is loaded.
void SetResolveCallback(CBaseObject* fromObject, REFGUID objectId, ResolveObjRefFunctor1 func);
//! Set object resolve callback, it will be called once object with specified Id is loaded.
void SetResolveCallback(CBaseObject* fromObject, REFGUID objectId, ResolveObjRefFunctor2 func, uint32 userData);
//! Resolve all object ids and call callbacks on resolved objects.
void ResolveObjects();
// Save object to archive.
void SaveObject(CBaseObject* pObject);
//! Load multiple objects from archive.
void LoadObjects(XmlNodeRef& rootObjectsNode);
//! Load one object from archive.
CBaseObject* LoadObject(const XmlNodeRef& objNode, CBaseObject* pPrevObject = nullptr);
//////////////////////////////////////////////////////////////////////////
int GetLoadedObjectsCount() { return static_cast<int>(m_loadedObjects.size()); }
CBaseObject* GetLoadedObject(int nIndex) const { return m_loadedObjects[nIndex].pObject; }
//! If true new loaded objects will be assigned new GUIDs.
void MakeNewIds(bool bEnable);
//! Remap object ids.
void RemapID(REFGUID oldId, REFGUID newId);
//! Report error during loading.
void ReportError(CErrorRecord& err);
//! Assigner different error report class.
void SetErrorReport(CErrorReport* errReport);
//! Display collected error reports.
void ShowErrors();
void EnableProgressBar(bool bEnable) { m_bProgressBarEnabled = bEnable; };
CPakFile* GetGeometryPak(const char* sFilename);
CBaseObject* GetCurrentObject();
void AddSequenceIdMapping(uint32 oldId, uint32 newId);
uint32 RemapSequenceId(uint32 id) const;
bool IsAmongPendingIds(uint32 id) const;
void SetShouldResetInternalMembers(bool reset);
bool ShouldResetInternalMembers() const { return m_nFlags & eObjectLoader_ResetInternalMembers; }
private:
struct SLoadedObjectInfo
{
@ -110,22 +69,19 @@ private:
bool operator <(const SLoadedObjectInfo& oi) const { return nSortOrder < oi.nSortOrder; }
};
IObjectManager* m_objectManager;
struct Callback
{
ResolveObjRefFunctor1 func1;
ResolveObjRefFunctor2 func2;
uint32 userData;
_smart_ptr<CBaseObject> fromObject;
Callback() { func1 = 0; func2 = 0; userData = 0; };
Callback() { func1 = 0; }
};
typedef std::multimap<GUID, Callback, guid_less_predicate> Callbacks;
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
Callbacks m_resolveCallbacks;
// Set of all saved objects to this archive.
typedef std::set<_smart_ptr<CBaseObject> > ObjectsSet;
typedef AZStd::set<_smart_ptr<CBaseObject> > ObjectsSet;
ObjectsSet m_savedObjects;
//typedef std::multimap<int,_smart_ptr<CBaseObject> > OrderedObjects;
@ -138,20 +94,11 @@ private:
enum EObjectLoaderFlags
{
eObjectLoader_MakeNewIDs = 0x0001, // If true new loaded objects will be assigned new GUIDs.
eObjectLoader_ResetInternalMembers = 0x0004, // In case we are deserializing and we would like to wipe all previous state
};
int m_nFlags;
IErrorReport* m_pCurrentErrorReport;
CPakFile* m_pGeometryPak;
CBaseObject* m_pCurrentObject;
bool m_bNeedResolveObjects;
bool m_bProgressBarEnabled;
// This table is used when there is any collision of ids while importing TrackView sequences.
std::map<uint32, uint32> m_sequenceIdRemap;
std::vector<uint32> m_pendingIds;
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
};
#endif // CRYINCLUDE_EDITOR_OBJECTS_OBJECTLOADER_H

File diff suppressed because it is too large Load Diff

@ -8,10 +8,6 @@
// Description : ObjectManager definition.
#ifndef CRYINCLUDE_EDITOR_OBJECTS_OBJECTMANAGER_H
#define CRYINCLUDE_EDITOR_OBJECTS_OBJECTMANAGER_H
#pragma once
#include "IObjectManager.h"
@ -42,12 +38,10 @@ public:
CObjectManagerLevelIsExporting()
{
AZ::ObjectManagerEventBus::Broadcast(&AZ::ObjectManagerEventBus::Events::OnExportingStarting);
GetIEditor()->GetObjectManager()->SetExportingLevel(true);
}
~CObjectManagerLevelIsExporting()
{
GetIEditor()->GetObjectManager()->SetExportingLevel(false);
AZ::ObjectManagerEventBus::Broadcast(&AZ::ObjectManagerEventBus::Events::OnExportingFinished);
}
};
@ -66,20 +60,12 @@ public:
CObjectManager();
~CObjectManager();
void RegisterObjectClasses();
CBaseObject* NewObject(CObjectClassDesc* cls, CBaseObject* prev = 0, const QString& file = "", const char* newObjectName = nullptr) override;
CBaseObject* NewObject(const QString& typeName, CBaseObject* prev = 0, const QString& file = "", const char* newEntityName = nullptr) override;
void DeleteObject(CBaseObject* obj) override;
void DeleteSelection(CSelectionGroup* pSelection) override;
void DeleteAllObjects() override;
CBaseObject* CloneObject(CBaseObject* obj) override;
void BeginEditParams(CBaseObject* obj, int flags) override;
void EndEditParams(int flags = 0) override;
// Hides all transform manipulators.
void HideTransformManipulators();
//! Get number of objects manager by ObjectManager (not contain sub objects of groups).
int GetObjectCount() const override;
@ -88,30 +74,9 @@ public:
//! @param layer if 0 get objects for all layers, or layer to get objects from.
void GetObjects(CBaseObjectsArray& objects) const override;
//! Get array of objects that pass the filter.
//! @param filter The filter functor, return true if you want to get the certain obj, return false if want to skip it.
void GetObjects(CBaseObjectsArray& objects, BaseObjectFilterFunctor const& filter) const override;
//! Update objects.
void Update();
//! Display objects on display context.
void Display(DisplayContext& dc) override;
//! Called when selecting without selection helpers - this is needed since
//! the visible object cache is normally not updated when not displaying helpers.
void ForceUpdateVisibleObjectCache(DisplayContext& dc) override;
//! Check intersection with objects.
//! Find intersection with nearest to ray origin object hit by ray.
//! If distance tollerance is specified certain relaxation applied on collision test.
//! @return true if hit any object, and fills hitInfo structure.
bool HitTest(HitContext& hitInfo) override;
//! Check intersection with an object.
//! @return true if hit, and fills hitInfo structure.
bool HitTestObject(CBaseObject* obj, HitContext& hc) override;
//! Send event to all objects.
//! Will cause OnEvent handler to be called on all objects.
void SendEvent(ObjectEvent event) override;
@ -134,76 +99,28 @@ public:
//! Find objects which intersect with a given AABB.
void FindObjectsInAABB(const AABB& aabb, std::vector<CBaseObject*>& result) const override;
//////////////////////////////////////////////////////////////////////////
// Operations on objects.
//////////////////////////////////////////////////////////////////////////
//! Makes object visible or invisible.
void HideObject(CBaseObject* obj, bool hide) override;
//! Shows the last hidden object based on hidden ID
void ShowLastHiddenObject() override;
//! Freeze object, making it unselectable.
void FreezeObject(CBaseObject* obj, bool freeze) override;
//! Unhide all hidden objects.
void UnhideAll() override;
//! Unfreeze all frozen objects.
void UnfreezeAll() override;
//////////////////////////////////////////////////////////////////////////
// Object Selection.
//////////////////////////////////////////////////////////////////////////
bool SelectObject(CBaseObject* obj, bool bUseMask = true) override;
void UnselectObject(CBaseObject* obj) override;
//! Select objects within specified distance from given position.
//! Return number of selected objects.
int SelectObjects(const AABB& box, bool bUnselect = false) override;
void SelectEntities(std::set<CEntityObject*>& s) override;
int MoveObjects(const AABB& box, const Vec3& offset, ImageRotationDegrees rotation, bool bIsCopy = false) override;
//! Selects/Unselects all objects within 2d rectangle in given viewport.
void SelectObjectsInRect(CViewport* view, const QRect& rect, bool bSelect) override;
void FindObjectsInRect(CViewport* view, const QRect& rect, std::vector<GUID>& guids) override;
//! Clear default selection set.
//! @Return number of objects removed from selection.
int ClearSelection() override;
//! Deselect all current selected objects and selects object that were unselected.
//! @Return number of selected objects.
int InvertSelection() override;
//! Get current selection.
CSelectionGroup* GetSelection() const override { return m_currSelection; };
//! Get named selection.
CSelectionGroup* GetSelection(const QString& name) const override;
// Get selection group names
void GetNameSelectionStrings(QStringList& names) override;
//! Change name of current selection group.
//! And store it in list.
void NameSelection(const QString& name) override;
//! Set one of name selections as current selection.
void SetSelection(const QString& name) override;
void RemoveSelection(const QString& name) override;
bool IsObjectDeletionAllowed(CBaseObject* pObject);
//! Delete all objects in selection group.
void DeleteSelection() override;
uint32 ForceID() const override{return m_ForceID; }
void ForceID(uint32 FID) override{m_ForceID = FID; }
//! Generates uniq name base on type name of object.
QString GenerateUniqueObjectName(const QString& typeName) override;
//! Register object name in object manager, needed for generating uniq names.
void RegisterObjectName(const QString& name) override;
//! Decrease name number and remove if it was last in object manager, needed for generating uniq names.
void UpdateRegisterObjectName(const QString& name);
//! Enable/Disable generating of unique object names (Enabled by default).
//! Return previous value.
bool EnableUniqObjectNames(bool bEnable) override;
//! Register XML template of runtime class.
void RegisterClassTemplate(const XmlNodeRef& templ);
@ -215,52 +132,10 @@ public:
//! Find object class by name.
CObjectClassDesc* FindClass(const QString& className) override;
void GetClassCategories(QStringList& categories) override;
void GetClassCategoryToolClassNamePairs(std::vector< std::pair<QString, QString> >& categoryToolClassNamePairs) override;
void GetClassTypes(const QString& category, QStringList& types) override;
//! Export objects to xml.
//! When onlyShared is true ony objects with shared flags exported, overwise only not shared object exported.
void Export(const QString& levelPath, XmlNodeRef& rootNode, bool onlyShared) override;
void ExportEntities(XmlNodeRef& rootNode) override;
//! Serialize Objects in manager to specified XML Node.
//! @param flags Can be one of SerializeFlags.
void Serialize(XmlNodeRef& rootNode, bool bLoading, int flags = SERIALIZE_ALL) override;
void SerializeNameSelection(XmlNodeRef& rootNode, bool bLoading) override;
//! Load objects from object archive.
//! @param bSelect if set newly loaded object will be selected.
void LoadObjects(CObjectArchive& ar, bool bSelect) override;
//! Delete from Object manager all objects without SHARED flag.
void DeleteNotSharedObjects();
//! Delete from Object manager all objects with SHARED flag.
void DeleteSharedObjects();
bool AddObject(CBaseObject* obj);
void RemoveObject(CBaseObject* obj);
void ChangeObjectId(REFGUID oldId, REFGUID newId) override;
bool IsDuplicateObjectName(const QString& newName) const override
{
return FindObject(newName) ? true : false;
}
void ShowDuplicationMsgWarning(CBaseObject* obj, const QString& newName, bool bShowMsgBox) const override;
void ChangeObjectName(CBaseObject* obj, const QString& newName) override;
//! Convert object of one type to object of another type.
//! Original object is deleted.
bool ConvertToType(CBaseObject* pObject, const QString& typeName) override;
//! Set new selection callback.
//! @return previous selection callback.
IObjectSelectCallback* SetSelectCallback(IObjectSelectCallback* callback) override;
// Enables/Disables creating of game objects.
void SetCreateGameObject(bool enable) override { m_createGameObjects = enable; };
//! Return true if objects loaded from xml should immidiatly create game objects associated with them.
bool IsCreateGameObjects() const override { return m_createGameObjects; };
//////////////////////////////////////////////////////////////////////////
//! Get access to gizmo manager.
@ -270,33 +145,12 @@ public:
//! Invalidate visibily settings of objects.
void InvalidateVisibleList() override;
//////////////////////////////////////////////////////////////////////////
// ObjectManager notification Callbacks.
//////////////////////////////////////////////////////////////////////////
void AddObjectEventListener(EventListener* listener) override;
void RemoveObjectEventListener(EventListener* listener) override;
//////////////////////////////////////////////////////////////////////////
// Used to indicate starting and ending of objects loading.
//////////////////////////////////////////////////////////////////////////
void StartObjectsLoading(int numObjects) override;
void EndObjectsLoading() override;
//////////////////////////////////////////////////////////////////////////
// Gathers all resources used by all objects.
void GatherUsedResources(CUsedResources& resources) override;
bool IsLightClass(CBaseObject* pObject) override;
virtual void FindAndRenameProperty2(const char* property2Name, const QString& oldValue, const QString& newValue) override;
virtual void FindAndRenameProperty2If(const char* property2Name, const QString& oldValue, const QString& newValue, const char* otherProperty2Name, const QString& otherValue) override;
bool IsReloading() const override { return m_bInReloading; }
void SetSkipUpdate(bool bSkipUpdate) override { m_bSkipObjectUpdate = bSkipUpdate; }
void SetExportingLevel(bool bExporting) override { m_bLevelExporting = bExporting; }
bool IsExportingLevelInprogress() const override { return m_bLevelExporting; }
int GetAxisHelperHitRadius() const override { return m_axisHelperHitRadius; }
private:
@ -317,29 +171,12 @@ private:
void SelectCurrent();
void SetObjectSelected(CBaseObject* pObject, bool bSelect);
// Recursive functions potentially taking into child objects into account
void SelectObjectInRect(CBaseObject* pObj, CViewport* view, HitContext hc, bool bSelect);
void HitTestObjectAgainstRect(CBaseObject* pObj, CViewport* view, HitContext hc, std::vector<GUID>& guids);
void SaveRegistry();
void LoadRegistry();
void NotifyObjectListeners(CBaseObject* pObject, CBaseObject::EObjectListenerEvent event);
void FindDisplayableObjects(DisplayContext& dc, bool bDisplay);
private:
typedef std::map<GUID, CBaseObjectPtr, guid_less_predicate> Objects;
typedef AZStd::map<GUID, CBaseObjectPtr, guid_less_predicate> Objects;
Objects m_objects;
typedef std::unordered_map<AZ::u32, CBaseObjectPtr> ObjectsByNameCrc;
typedef AZStd::unordered_map<AZ::u32, CBaseObjectPtr> ObjectsByNameCrc;
ObjectsByNameCrc m_objectsByName;
typedef std::map<QString, CSelectionGroup*> TNameSelectionMap;
TNameSelectionMap m_selections;
//! Used for forcing IDs of "GetEditorObjectID" of PreFabs, as they used to have random IDs on each load
uint32 m_ForceID;
//! Array of currently visible objects.
TBaseObjects m_visibleObjects;
@ -349,16 +186,11 @@ private:
unsigned int m_lastComputedVisibility = 0; // when the object manager itself last updated visibility (since it also has a cache)
int m_lastHideMask = 0;
float m_maxObjectViewDistRatio;
//////////////////////////////////////////////////////////////////////////
// Selection.
//! Current selection group.
CSelectionGroup* m_currSelection;
int m_nLastSelCount;
bool m_bSelectionChanged;
IObjectSelectCallback* m_selectCallback;
bool m_bLoadingObjects;
// True while performing a select or deselect operation on more than one object.
// Prevents individual undo/redo commands for every object, allowing bulk undo/redo
@ -367,20 +199,9 @@ private:
//! Default selection.
CSelectionGroup m_defaultSelection;
CBaseObjectPtr m_currEditObject;
bool m_bSingleSelection;
bool m_createGameObjects;
bool m_bGenUniqObjectNames;
// Object manager also handles Gizmo manager.
CGizmoManager* m_gizmoManager;
//////////////////////////////////////////////////////////////////////////
// Loading progress.
CWaitProgress* m_pLoadProgress;
int m_loadedObjects;
int m_totalObjectsToLoad;
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
@ -389,10 +210,6 @@ private:
typedef std::map<QString, std::set<uint16>, stl::less_stricmp<QString> > NameNumbersMap;
NameNumbersMap m_nameNumbersMap;
//////////////////////////////////////////////////////////////////////////
// Listeners.
std::list<EventListener*> m_objectEventListeners;
bool m_bExiting;
std::unordered_set<CEntityObject*> m_animatedAttachedEntities;
@ -401,10 +218,6 @@ private:
uint64 m_currentHideCount;
bool m_bInReloading;
bool m_bSkipObjectUpdate;
bool m_bLevelExporting;
int m_axisHelperHitRadius = 20;
};
@ -426,4 +239,3 @@ namespace AzToolsFramework
} // namespace AzToolsFramework
#endif // CRYINCLUDE_EDITOR_OBJECTS_OBJECTMANAGER_H

@ -24,12 +24,11 @@ public:
CUndoBaseObjectNew(CBaseObject* object);
protected:
virtual int GetSize() override { return sizeof(*this); }; // Return size of xml state.
virtual QString GetDescription() override { return "New BaseObject"; };
virtual QString GetObjectName() override { return m_object->GetName(); };
int GetSize() override { return sizeof(*this); } // Return size of xml state.
QString GetObjectName() override { return m_object->GetName(); }
virtual void Undo(bool bUndo) override;
virtual void Redo() override;
void Undo(bool bUndo) override;
void Redo() override;
private:
CBaseObjectPtr m_object;
@ -47,12 +46,11 @@ public:
CUndoBaseObjectDelete(CBaseObject* object);
protected:
virtual int GetSize() override { return sizeof(*this); }; // Return size of xml state.
virtual QString GetDescription() override { return "Delete BaseObject"; };
virtual QString GetObjectName() override { return m_object->GetName(); };
int GetSize() override { return sizeof(*this); } // Return size of xml state.
QString GetObjectName() override { return m_object->GetName(); }
virtual void Undo(bool bUndo) override;
virtual void Redo() override;
void Undo(bool bUndo) override;
void Redo() override;
private:
CBaseObjectPtr m_object;
@ -73,20 +71,19 @@ public:
* This Undo command can be used for either Legacy or Component Entities, though for
* performance reasons Component Entities are typically undone using CUndoBaseObjectBulkSelect
*
* @param pObj The object to perform the undo/redo operation on.
* @param object The object to perform the undo/redo operation on.
* @param isSelect This is true if you are trying to undo a select operation, and false if
* trying to undo a deselect operation
*/
CUndoBaseObjectSelect(CBaseObject* object, bool isSelect);
protected:
virtual void Release() override { delete this; };
virtual int GetSize() override { return sizeof(*this); }; // Return size of xml state.
virtual QString GetDescription() override { return "Select Object"; };
virtual QString GetObjectName() override;
void Release() override { delete this; }
int GetSize() override { return sizeof(*this); } // Return size of xml state.
QString GetObjectName() override;
virtual void Undo(bool bUndo) override;
virtual void Redo() override;
void Undo(bool bUndo) override;
void Redo() override;
private:
GUID m_guid;
@ -116,7 +113,6 @@ public:
protected:
int GetSize() override { return sizeof(*this); } // Return size of xml state.
QString GetDescription() override { return QObject::tr("Select Objects"); }
/*
* Deselects the objects
@ -153,7 +149,6 @@ public:
protected:
int GetSize() override { return sizeof(*this); } // Return size of xml state.
QString GetDescription() override { return QObject::tr("Select Objects"); }
void Undo(bool bUndo) override;

@ -18,8 +18,6 @@
#include "ViewManager.h"
#include "Include/IObjectManager.h"
#include <IStatObj.h>
//////////////////////////////////////////////////////////////////////////
CSelectionGroup::CSelectionGroup()
: m_ref(1)
@ -226,7 +224,6 @@ void CSelectionGroup::Move(const Vec3& offset, EMoveSelectionFlag moveFlag, [[ma
m_bVertexSnapped = false;
FilterParents();
Vec3 newPos;
bool bValidFollowGeometryMode(true);
if (point.x() == -1 || point.y() == -1)
@ -234,8 +231,6 @@ void CSelectionGroup::Move(const Vec3& offset, EMoveSelectionFlag moveFlag, [[ma
bValidFollowGeometryMode = false;
}
SRayHitInfo pickedInfo;
if (moveFlag == eMS_FollowGeometryPosNorm)
{
if (m_LastestMoveSelectionFlag != eMS_FollowGeometryPosNorm)
@ -249,6 +244,8 @@ void CSelectionGroup::Move(const Vec3& offset, EMoveSelectionFlag moveFlag, [[ma
}
m_LastestMoveSelectionFlag = moveFlag;
Vec3 zeroPickedInfo_vHitNormal;
Vec3 zeroPickedInfo_vHitPos;
for (int i = 0; i < GetFilteredCount(); i++)
{
@ -264,16 +261,15 @@ void CSelectionGroup::Move(const Vec3& offset, EMoveSelectionFlag moveFlag, [[ma
Vec3 zaxis = m_LastestMovedObjectRot * Vec3(0, 0, 1);
zaxis.Normalize();
Quat nq;
nq.SetRotationV0V1(zaxis, pickedInfo.vHitNormal);
obj->SetPos(pickedInfo.vHitPos);
nq.SetRotationV0V1(zaxis, zeroPickedInfo_vHitNormal);
obj->SetPos(zeroPickedInfo_vHitPos);
obj->SetRotation(nq * m_LastestMovedObjectRot);
continue;
}
Matrix34 wtm = obj->GetWorldTM();
const Matrix34 &wtm = obj->GetWorldTM();
Vec3 wp = wtm.GetTranslation();
newPos = wp + offset;
Vec3 newPos = wp + offset;
if (moveFlag == eMS_FollowTerrain)
{
// Make sure object keeps it height.
@ -465,17 +461,6 @@ void CSelectionGroup::SetScale(const Vec3& scale, int referenceCoordSys)
Scale(relScale, referenceCoordSys);
}
void CSelectionGroup::StartScaling()
{
for (int i = 0; i < GetFilteredCount(); i++)
{
CBaseObject* obj = GetFilteredObject(i);
obj->StartScaling();
}
}
//////////////////////////////////////////////////////////////////////////
void CSelectionGroup::Align()
{
@ -533,45 +518,6 @@ void CSelectionGroup::ResetTransformation()
}
}
//////////////////////////////////////////////////////////////////////////
void CSelectionGroup::Clone(CSelectionGroup& newGroup)
{
IObjectManager* pObjMan = GetIEditor()->GetObjectManager();
assert(pObjMan);
int i;
CObjectCloneContext cloneContext;
FilterParents();
//////////////////////////////////////////////////////////////////////////
// Clone every object.
for (i = 0; i < GetFilteredCount(); i++)
{
CBaseObject* pFromObject = GetFilteredObject(i);
CBaseObject* newObj = pObjMan->CloneObject(pFromObject);
if (!newObj) // can be null, e.g. sequence can't be cloned
{
continue;
}
cloneContext.AddClone(pFromObject, newObj);
newGroup.AddObject(newObj);
}
//////////////////////////////////////////////////////////////////////////
// Only after everything was cloned, call PostClone on all cloned objects.
for (i = 0; i < newGroup.GetCount(); ++i)
{
CBaseObject* pFromObject = GetFilteredObject(i);
CBaseObject* pClonedObject = newGroup.GetObject(i);
if (pClonedObject)
{
pClonedObject->PostClone(pFromObject, cloneContext);
}
}
}
//////////////////////////////////////////////////////////////////////////
void CSelectionGroup::SendEvent(ObjectEvent event)
{

@ -98,7 +98,6 @@ public:
//! Resets rotation and scale to identity and (1.0f, 1.0f, 1.0f)
void ResetTransformation();
//! Scale objects in selection by given scale.
void StartScaling();
void Scale(const Vec3& scale, int referenceCoordSys);
void SetScale(const Vec3& scale, int referenceCoordSys);
//! Align objects in selection to surface normal
@ -106,11 +105,6 @@ public:
//! Very special method to move contents of a voxel.
void MoveContent(const Vec3& offset);
//////////////////////////////////////////////////////////////////////////
//! Clone objects in this group and add cloned objects to new selection group.
//! Only topmost parent objects will be added to this selection group.
void Clone(CSelectionGroup& newGroup);
// Send event to all objects in selection group.
void SendEvent(ObjectEvent event);

@ -14,6 +14,7 @@
// Editor
#include "Include/IViewPane.h"
#include <QMessageBox>
CClassFactory* CClassFactory::s_pInstance = nullptr;
CAutoRegisterClassHelper* CAutoRegisterClassHelper::s_pFirst = nullptr;
@ -79,7 +80,7 @@ void CClassFactory::RegisterClass(IClassDesc* pClassDesc)
existingUUIDString,
findByGuid->second->ClassName().toUtf8().data());
CryMessageBox(errorMessageBuffer, "Invalid class registration - Duplicate UUID", MB_OK);
QMessageBox::critical(nullptr,"Invalid class registration - Duplicate UUID",QString::fromLatin1(errorMessageBuffer));
return;
}
@ -107,7 +108,7 @@ void CClassFactory::RegisterClass(IClassDesc* pClassDesc)
newUUIDString,
existingUUIDString);
CryMessageBox(errorMessageBuffer, "Invalid class registration - Duplicate Class Name", MB_OK);
QMessageBox::critical(nullptr, "Invalid class registration - Duplicate Class Name", QString::fromLatin1(errorMessageBuffer));
return;
}

@ -36,7 +36,6 @@
#include <AzToolsFramework/ToolsComponents/EditorSelectionAccentSystemComponent.h>
#include <AzToolsFramework/ToolsComponents/EditorEntityIconComponentBus.h>
#include <AzToolsFramework/Undo/UndoCacheInterface.h>
#include <LmbrCentral/Rendering/RenderNodeBus.h>
#include <IDisplayViewport.h>
#include <CryCommon/Cry_GeoIntersect.h>
@ -48,14 +47,12 @@
/**
* Scalars for icon drawing behavior.
*/
static const int s_kIconSize = 36; /// Icon display size (in pixels)
CComponentEntityObject::CComponentEntityObject()
: m_hasIcon(false)
: m_accentType(AzToolsFramework::EntityAccentType::None)
, m_hasIcon(false)
, m_entityIconVisible(false)
, m_iconOnlyHitTest(false)
, m_drawAccents(true)
, m_accentType(AzToolsFramework::EntityAccentType::None)
, m_isIsolated(false)
, m_iconTexture(nullptr)
{
@ -243,7 +240,7 @@ void CComponentEntityObject::SetSelected(bool bSelect)
}
bool anySelected = false;
AzToolsFramework::ToolsApplicationRequestBus::BroadcastResult(anySelected, &AzToolsFramework::ToolsApplicationRequests::AreAnyEntitiesSelected);
if (!anySelected)
@ -266,18 +263,6 @@ void CComponentEntityObject::SetHighlight(bool bHighlight)
}
}
IRenderNode* CComponentEntityObject::GetEngineNode() const
{
// It's possible for AZ::Entities to have multiple IRenderNodes.
// However, the editor currently expects a single IRenderNode per "editor object".
// Therefore, return the highest priority handler.
if (auto* renderNodeHandler = LmbrCentral::RenderNodeRequestBus::FindFirstHandler(m_entityId))
{
return renderNodeHandler->GetRenderNode();
}
return nullptr;
}
void CComponentEntityObject::OnEntityNameChanged(const AZStd::string& name)
{
if (m_nameReentryGuard)
@ -331,14 +316,6 @@ void CComponentEntityObject::DetachThis(bool /*bKeepPos*/)
}
}
CBaseObject* CComponentEntityObject::GetLinkParent() const
{
AZ::EntityId parentId;
EBUS_EVENT_ID_RESULT(parentId, m_entityId, AZ::TransformBus, GetParentId);
return CComponentEntityObject::FindObjectForEntity(parentId);
}
bool CComponentEntityObject::IsFrozen() const
{
return CheckFlags(OBJFLAG_FROZEN);
@ -358,16 +335,6 @@ void CComponentEntityObject::OnEntityLockChanged(bool locked)
CEntityObject::SetFrozen(locked);
}
void CComponentEntityObject::SetHidden(
bool bHidden, [[maybe_unused]] uint64 hiddenId /*=CBaseObject::s_invalidHiddenID*/, [[maybe_unused]] bool bAnimated /*=false*/)
{
if (m_visibilityFlagReentryGuard)
{
EditorActionScope flagChange(m_visibilityFlagReentryGuard);
AzToolsFramework::SetEntityVisibility(m_entityId, !bHidden);
}
}
void CComponentEntityObject::OnEntityVisibilityChanged(bool visible)
{
CEntityObject::SetHidden(!visible);
@ -612,66 +579,6 @@ void CComponentEntityObject::OnTransformChanged([[maybe_unused]] const AZ::Trans
}
}
int CComponentEntityObject::MouseCreateCallback(CViewport* view, EMouseEvent event, QPoint& point, int flags)
{
if (event == eMouseMove || event == eMouseLDown)
{
Vec3 pos;
if (GetIEditor()->GetAxisConstrains() != AXIS_TERRAIN)
{
pos = view->MapViewToCP(point);
}
else
{
// Snap to terrain.
bool hitTerrain;
pos = view->ViewToWorld(point, &hitTerrain);
if (hitTerrain)
{
pos.z = GetIEditor()->GetTerrainElevation(pos.x, pos.y);
}
pos = view->SnapToGrid(pos);
}
pos = view->SnapToGrid(pos);
SetPos(pos);
if (event == eMouseLDown)
{
return MOUSECREATE_OK;
}
return MOUSECREATE_CONTINUE;
}
return CBaseObject::MouseCreateCallback(view, event, point, flags);
}
bool CComponentEntityObject::HitHelperTest(HitContext& hc)
{
bool hit = CEntityObject::HitHelperTest(hc);
if (!hit && m_entityId.IsValid())
{
// Pick against icon in screen space.
if (IsEntityIconVisible())
{
const QPoint entityScreenPos = hc.view->WorldToView(GetWorldPos());
const float screenPosX = static_cast<float>(entityScreenPos.x());
const float screenPosY = static_cast<float>(entityScreenPos.y());
const float iconRange = static_cast<float>(s_kIconSize / 2);
if ((hc.point2d.x() >= screenPosX - iconRange && hc.point2d.x() <= screenPosX + iconRange)
&& (hc.point2d.y() >= screenPosY - iconRange && hc.point2d.y() <= screenPosY + iconRange))
{
hc.dist = hc.raySrc.GetDistance(GetWorldPos());
hc.iconHit = true;
return true;
}
}
}
return hit;
}
bool CComponentEntityObject::HitTest(HitContext& hc)
{
AZ_PROFILE_FUNCTION(Entity);
@ -907,11 +814,6 @@ void CComponentEntityObject::DrawDefault(DisplayContext& dc, const QColor& label
DrawAccent(dc);
}
IStatObj* CComponentEntityObject::GetIStatObj()
{
return nullptr;
}
bool CComponentEntityObject::IsIsolated() const
{
return m_isIsolated;
@ -952,11 +854,6 @@ void CComponentEntityObject::SetWorldPos(const Vec3& pos, int flags)
CEntityObject::SetWorldPos(pos, flags);
}
void CComponentEntityObject::OnContextMenu(QMenu* /*pMenu*/)
{
// Deliberately bypass the base class implementation (CEntityObject::OnContextMenu()).
}
void CComponentEntityObject::SetupEntityIcon()
{
bool hideIconInViewport = false;

@ -56,27 +56,21 @@ public:
bool SetScale(const Vec3& scale, int flags) override;
void InvalidateTM(int nWhyFlags) override;
void Display(DisplayContext& disp) override;
void OnContextMenu(QMenu* pMenu) override;
int MouseCreateCallback(CViewport* view, EMouseEvent event, QPoint& point, int flags) override;
bool HitHelperTest(HitContext& hc) override;
bool HitTest(HitContext& hc) override;
void GetLocalBounds(AABB& box) override;
void GetBoundBox(AABB& box) override;
void SetName(const QString& name) override;
bool IsFrozen() const override;
void SetFrozen(bool bFrozen) override;
void SetHidden(bool bHidden, uint64 hiddenId = CBaseObject::s_invalidHiddenID, bool bAnimated = false) override;
void SetSelected(bool bSelect) override;
void SetHighlight(bool bHighlight) override;
IRenderNode* GetEngineNode() const override;
void AttachChild(CBaseObject* child, bool bKeepPos = true) override;
void DetachAll(bool bKeepPos = true) override;
void DetachThis(bool bKeepPos = true) override;
CBaseObject* GetLinkParent() const override;
XmlNodeRef Export(const QString& levelPath, XmlNodeRef& xmlNode) override;
void DeleteEntity() override;
void DrawDefault(DisplayContext& dc, const QColor& labelColor = QColor(255, 255, 255)) override;
IStatObj* GetIStatObj() override;
bool IsIsolated() const override;
bool IsSelected() const override;
bool IsSelectable() const override;
@ -88,12 +82,6 @@ public:
// Component entity highlighting (accenting) is taken care of elsewhere
void DrawHighlight(DisplayContext& /*dc*/) override {};
// Don't auto-clone children. Cloning happens in groups with reference fixups,
// and individually selected objercts should be cloned as individuals.
bool ShouldCloneChildren() const override { return false; }
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////

@ -447,7 +447,7 @@ void SandboxIntegrationManager::OnEndUndo(const char* label, bool changed)
// Add the undo only after we know it's got a legit change, we can't remove undos from the cry undo system so we do it here instead of OnBeginUndo
if (changed && CUndo::IsRecording())
{
CUndo::Record(new CToolsApplicationUndoLink(label));
CUndo::Record(new CToolsApplicationUndoLink());
}
if (m_startedUndoRecordingNestingLevel)
{

@ -306,8 +306,7 @@ class CToolsApplicationUndoLink
{
public:
CToolsApplicationUndoLink(const char* description)
: m_description(description)
CToolsApplicationUndoLink()
{
}
@ -316,11 +315,6 @@ public:
return 0;
}
QString GetDescription() override
{
return m_description.c_str();
}
void Undo(bool bUndo = true) override
{
// Always run the undo even if the flag was set to false, that just means that undo wasn't expressly desired, but can be used in cases of canceling the current super undo.
@ -354,8 +348,6 @@ public:
w->setFocus(Qt::OtherFocusReason);
}
}
AZStd::string m_description;
};
#endif // CRYINCLUDE_COMPONENTENTITYEDITORPLUGIN_SANDBOXINTEGRATION_H

@ -57,7 +57,6 @@ protected:
}
int GetSize() override { return sizeof(*this); }
QString GetDescription() override { return "UndoTrackViewSplineCtrl"; };
void Undo(bool bUndo) override
{

@ -6,9 +6,6 @@
*
*/
#ifndef CRYINCLUDE_EDITOR_TRACKVIEW_TRACKVIEWUNDO_H
#define CRYINCLUDE_EDITOR_TRACKVIEW_TRACKVIEWUNDO_H
#pragma once
#include "TrackViewTrack.h"
@ -27,11 +24,10 @@ public:
CUndoComponentEntityTrackObject(CTrackViewTrack* track);
protected:
virtual int GetSize() override { return sizeof(*this); }
virtual QString GetDescription() override { return "Undo Component Entity Track Modify"; };
int GetSize() override { return sizeof(*this); }
virtual void Undo(bool bUndo) override;
virtual void Redo() override;
void Undo(bool bUndo) override;
void Redo() override;
private:
@ -50,5 +46,3 @@ private:
CTrackViewTrackMemento m_undo;
CTrackViewTrackMemento m_redo;
};
#endif // CRYINCLUDE_EDITOR_TRACKVIEW_TRACKVIEWUNDO_H

@ -8,10 +8,6 @@
// Description : Interface for implementation of IUndo objects.
#ifndef CRYINCLUDE_EDITOR_UNDO_IUNDOOBJECT_H
#define CRYINCLUDE_EDITOR_UNDO_IUNDOOBJECT_H
#pragma once
#include <QString>
@ -26,8 +22,6 @@ struct IUndoObject
virtual void Release() { delete this; };
//! Return size of this Undo object.
virtual int GetSize() = 0;
//! Return description of this Undo object.
virtual QString GetDescription() = 0;
//! Undo this object.
//! @param bUndo If true this operation called in response to Undo operation.
@ -37,14 +31,5 @@ struct IUndoObject
virtual void Redo() = 0;
// Returns the name of undo object
virtual QString GetObjectName(){ return QString(); };
// Returns the name of related editor object.
// Ex: For a undo action which would modify value for var "Emitter Strength" of emitter "Level.example",
// this function will return emitter name "Level.example" - Vera, Confetti
virtual QString GetEditorObjectName() { return QString(); };
virtual bool IsChanged([[maybe_unused]] unsigned int& compareValue) const { return false; }
virtual QString GetObjectName(){ return QString(); }
};
#endif // CRYINCLUDE_EDITOR_UNDO_IUNDOOBJECT_H

@ -1,572 +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 "KDTree.h"
#include <IStatObj.h>
class KDTreeNode
{
public:
KDTreeNode()
{
pChildren[0] = nullptr;
pChildren[1] = nullptr;
pVertexIndices = nullptr;
}
~KDTreeNode()
{
if (!IsLeaf())
{
if (pChildren[0])
{
delete pChildren[0];
}
if (pChildren[1])
{
delete pChildren[1];
}
}
else if (GetVertexBufferSize() > 1)
{
if (pVertexIndices)
{
delete [] pVertexIndices;
}
}
}
uint32 GetVertexBufferSize() const
{
return nVertexIndexBufferSize;
}
float GetSplitPos() const
{
return splitPos;
}
void SetSplitPos(float pos)
{
splitPos = pos;
}
CKDTree::ESplitAxis GetSplitAxis() const
{
if (splitAxis == 0)
{
return CKDTree::eSA_X;
}
if (splitAxis == 1)
{
return CKDTree::eSA_Y;
}
if (splitAxis == 2)
{
return CKDTree::eSA_Z;
}
return CKDTree::eSA_Invalid;
}
void SetSplitAxis(const CKDTree::ESplitAxis& axis)
{
splitAxis = axis;
}
bool IsLeaf() const
{
return pChildren[0] == nullptr && pChildren[1] == nullptr;
}
KDTreeNode* GetChild(uint32 nIndex) const
{
if (nIndex > 1)
{
return nullptr;
}
return pChildren[nIndex];
}
void SetChild(uint32 nIndex, KDTreeNode* pNode)
{
if (nIndex > 1)
{
return;
}
if (pChildren[nIndex])
{
delete pChildren[nIndex];
}
pChildren[nIndex] = pNode;
}
const AABB& GetBoundBox()
{
return boundbox;
}
void SetBoundBox(const AABB& aabb)
{
boundbox = aabb;
}
void SetVertexIndexBuffer(std::vector<uint32>& vertexInfos)
{
nVertexIndexBufferSize = (uint32)vertexInfos.size();
if (nVertexIndexBufferSize == 0)
{
return;
}
if (nVertexIndexBufferSize == 1)
{
oneIndex = vertexInfos[0];
}
else
{
pVertexIndices = new uint32[nVertexIndexBufferSize];
memcpy(pVertexIndices, &vertexInfos[0], sizeof(uint32) * nVertexIndexBufferSize);
}
}
uint32 GetVertexIndex(uint32 nIndex) const
{
if (GetVertexBufferSize() == 1)
{
return oneIndex & 0x00FFFFFF;
}
return pVertexIndices[nIndex] & 0x00FFFFFF;
}
uint32 GetObjIndex(uint32 nIndex) const
{
if (GetVertexBufferSize() == 1)
{
return (oneIndex & 0xFF000000) >> 24;
}
return (pVertexIndices[nIndex] & 0xFF000000) >> 24;
}
private:
union
{
float splitPos; // Interior
uint32 oneIndex; // Leaf
uint32* pVertexIndices; // Leaf : high 8bits - object index, low 24bits - vertex index
};
union
{
uint32 splitAxis; // Interior
uint32 nVertexIndexBufferSize; // Leaf
};
AABB boundbox; // Both
KDTreeNode* pChildren[2]; // Interior
};
CKDTree::ESplitAxis SearchForBestSplitAxis(const AABB& aabb)
{
float xsize = aabb.max.x - aabb.min.x;
float ysize = aabb.max.y - aabb.min.y;
float zsize = aabb.max.z - aabb.min.z;
CKDTree::ESplitAxis axis;
if (xsize > ysize && xsize > zsize)
{
axis = CKDTree::eSA_X;
}
else if (ysize > zsize && ysize > xsize)
{
axis = CKDTree::eSA_Y;
}
else
{
axis = CKDTree::eSA_Z;
}
return axis;
}
bool SearchForBestSplitPos(CKDTree::ESplitAxis axis, const std::vector<CKDTree::SStatObj>& statObjList, std::vector<uint32>& indices, float& outBestSplitPos)
{
if (axis != CKDTree::eSA_X && axis != CKDTree::eSA_Y && axis != CKDTree::eSA_Z)
{
return false;
}
outBestSplitPos = 0;
int nSizeOfIndices = static_cast<int>(indices.size());
for (int i = 0; i < nSizeOfIndices; ++i)
{
int nObjIndex = (indices[i] & 0xFF000000) >> 24;
int nVertexIndex = (indices[i] & 0xFFFFFF);
const CKDTree::SStatObj* pObj = &statObjList[nObjIndex];
const IIndexedMesh* pMesh = pObj->pStatObj->GetIndexedMesh();
if (pMesh == nullptr)
{
continue;
}
IIndexedMesh::SMeshDescription meshDesc;
pMesh->GetMeshDescription(meshDesc);
if (meshDesc.m_pVerts)
{
outBestSplitPos += pObj->tm.TransformPoint(meshDesc.m_pVerts[nVertexIndex])[axis];
}
else if (meshDesc.m_pVertsF16)
{
outBestSplitPos += pObj->tm.TransformPoint(meshDesc.m_pVertsF16[nVertexIndex].ToVec3())[axis];
}
}
outBestSplitPos /= nSizeOfIndices;
return true;
}
struct SSplitInfo
{
AABB aboveBoundbox;
std::vector<uint32> aboveIndices;
AABB belowBoundbox;
std::vector<uint32> belowIndices;
};
bool SplitNode(const std::vector<CKDTree::SStatObj>& statObjList, const AABB& boundbox, const std::vector<uint32>& indices, CKDTree::ESplitAxis splitAxis, float splitPos, SSplitInfo& outInfo)
{
if (splitAxis != CKDTree::eSA_X && splitAxis != CKDTree::eSA_Y && splitAxis != CKDTree::eSA_Z)
{
return false;
}
outInfo.aboveBoundbox = boundbox;
outInfo.belowBoundbox = boundbox;
outInfo.aboveBoundbox.max[splitAxis] = splitPos;
outInfo.belowBoundbox.min[splitAxis] = splitPos;
uint32 iIndexSize = (uint32)indices.size();
outInfo.aboveIndices.reserve(iIndexSize);
outInfo.belowIndices.reserve(iIndexSize);
for (uint32 i = 0; i < iIndexSize; ++i)
{
int nObjIndex = (indices[i] & 0xFF000000) >> 24;
int nVertexIndex = indices[i] & 0xFFFFFF;
const CKDTree::SStatObj* pObj = &statObjList[nObjIndex];
const IIndexedMesh* pMesh = pObj->pStatObj->GetIndexedMesh();
if (pMesh == nullptr)
{
return false;
}
IIndexedMesh::SMeshDescription meshDesc;
pMesh->GetMeshDescription(meshDesc);
Vec3 vPos;
if (meshDesc.m_pVerts)
{
vPos = pObj->tm.TransformPoint(meshDesc.m_pVerts[nVertexIndex]);
}
else if (meshDesc.m_pVertsF16)
{
vPos = pObj->tm.TransformPoint(meshDesc.m_pVertsF16[nVertexIndex].ToVec3());
}
else
{
continue;
}
if (vPos[splitAxis] < splitPos)
{
outInfo.aboveIndices.push_back(indices[i]);
assert(outInfo.aboveBoundbox.IsContainPoint(vPos));
}
else
{
outInfo.belowIndices.push_back(indices[i]);
assert(outInfo.belowBoundbox.IsContainPoint(vPos));
}
}
return true;
}
CKDTree::CKDTree()
{
m_pRootNode = nullptr;
}
CKDTree::~CKDTree()
{
if (m_pRootNode)
{
delete m_pRootNode;
}
}
bool CKDTree::Build(IStatObj* pStatObj)
{
if (pStatObj == nullptr)
{
return false;
}
m_StatObjectList.clear();
if (pStatObj->GetIndexedMesh(true))
{
SStatObj rootObj;
rootObj.tm.SetIdentity();
rootObj.pStatObj = pStatObj;
m_StatObjectList.push_back(rootObj);
}
ConstructStatObjList(pStatObj, Matrix34::CreateIdentity());
AABB entireBoundBox;
entireBoundBox.Reset();
std::vector<uint32> indices;
for (int i = 0, iStatObjSize = static_cast<uint32>(m_StatObjectList.size()); i < iStatObjSize; ++i)
{
IIndexedMesh* pMesh = m_StatObjectList[i].pStatObj->GetIndexedMesh(true);
if (pMesh == nullptr)
{
continue;
}
IIndexedMesh::SMeshDescription meshDesc;
pMesh->GetMeshDescription(meshDesc);
for (int k = 0; k < meshDesc.m_nVertCount; ++k)
{
entireBoundBox.Add(m_StatObjectList[i].tm.TransformPoint(meshDesc.m_pVerts[k]));
indices.push_back((i << 24) | k);
}
}
if (m_pRootNode)
{
delete m_pRootNode;
}
m_pRootNode = new KDTreeNode;
BuildRecursively(m_pRootNode, entireBoundBox, indices);
return true;
}
void CKDTree::BuildRecursively(KDTreeNode* pNode, const AABB& boundbox, std::vector<uint32>& indices) const
{
pNode->SetBoundBox(boundbox);
if (indices.size() <= s_MinimumVertexSizeInLeafNode)
{
pNode->SetVertexIndexBuffer(indices);
return;
}
ESplitAxis splitAxis = SearchForBestSplitAxis(boundbox);
float splitPos(0);
SearchForBestSplitPos(splitAxis, m_StatObjectList, indices, splitPos);
pNode->SetSplitAxis(splitAxis);
pNode->SetSplitPos(splitPos);
SSplitInfo splitInfo;
if (!SplitNode(m_StatObjectList, boundbox, indices, splitAxis, splitPos, splitInfo))
{
return;
}
if (splitInfo.aboveIndices.empty() || splitInfo.belowIndices.empty())
{
pNode->SetVertexIndexBuffer(indices);
return;
}
KDTreeNode* pChild0 = new KDTreeNode;
KDTreeNode* pChild1 = new KDTreeNode;
pNode->SetChild(0, pChild0);
pNode->SetChild(1, pChild1);
BuildRecursively(pChild0, splitInfo.aboveBoundbox, splitInfo.aboveIndices);
BuildRecursively(pChild1, splitInfo.belowBoundbox, splitInfo.belowIndices);
}
void CKDTree::ConstructStatObjList(IStatObj* pStatObj, const Matrix34& matParent)
{
if (pStatObj == nullptr)
{
return;
}
for (int i = 0, nChildObjSize(pStatObj->GetSubObjectCount()); i < nChildObjSize; ++i)
{
IStatObj::SSubObject* pSubObj = pStatObj->GetSubObject(i);
SStatObj s;
s.tm = matParent * pSubObj->localTM;
if (pSubObj->pStatObj && pSubObj->pStatObj->GetIndexedMesh(true))
{
s.pStatObj = pSubObj->pStatObj;
m_StatObjectList.push_back(s);
}
ConstructStatObjList(pSubObj->pStatObj, s.tm);
}
}
bool CKDTree::FindNearestVertex(const Vec3& raySrc, const Vec3& rayDir, float vVertexBoxSize, const Vec3& localCameraPos, Vec3& outPos, Vec3& vOutHitPosOnCube) const
{
return FindNearestVertexRecursively(m_pRootNode, raySrc, rayDir, vVertexBoxSize, localCameraPos, outPos, vOutHitPosOnCube);
}
AABB GetNodeBoundBox(KDTreeNode* pNode, float vVertexBoxSize, const Vec3& localCameraPos)
{
AABB nodeAABB = pNode->GetBoundBox();
float fScreenFactorMin = localCameraPos.GetDistance(nodeAABB.min);
Vec3 vBoundBoxMin(fScreenFactorMin * vVertexBoxSize, fScreenFactorMin * vVertexBoxSize, fScreenFactorMin * vVertexBoxSize);
float fScreenFactorMax = localCameraPos.GetDistance(nodeAABB.max);
Vec3 vBoundBoxMax(fScreenFactorMax * vVertexBoxSize, fScreenFactorMax * vVertexBoxSize, fScreenFactorMax * vVertexBoxSize);
nodeAABB.min -= vBoundBoxMin;
nodeAABB.max += vBoundBoxMax;
return nodeAABB;
}
bool CKDTree::FindNearestVertexRecursively(KDTreeNode* pNode, const Vec3& raySrc, const Vec3& rayDir, float vVertexBoxSize, const Vec3& localCameraPos, Vec3& outPos, Vec3& vOutHitPosOnCube) const
{
if (!pNode)
{
return false;
}
Vec3 vHitPos;
AABB nodeAABB = GetNodeBoundBox(pNode, vVertexBoxSize, localCameraPos);
if (!pNode->GetBoundBox().IsContainPoint(raySrc) && !Intersect::Ray_AABB(raySrc, rayDir, nodeAABB, vHitPos))
{
return false;
}
if (pNode->IsLeaf())
{
if (m_StatObjectList.empty())
{
return false;
}
uint32 nVBuffSize = pNode->GetVertexBufferSize();
if (nVBuffSize == 0)
{
return false;
}
float fNearestDist = 3e10f;
for (uint32 i = 0; i < nVBuffSize; ++i)
{
uint32 nVertexIndex = pNode->GetVertexIndex(i);
uint32 nObjIndex = pNode->GetObjIndex(i);
assert(nObjIndex < m_StatObjectList.size());
const SStatObj* pStatObjInfo = &(m_StatObjectList[nObjIndex]);
IIndexedMesh* pMesh = m_StatObjectList[nObjIndex].pStatObj->GetIndexedMesh();
if (pMesh == nullptr)
{
continue;
}
IIndexedMesh::SMeshDescription meshDesc;
pMesh->GetMeshDescription(meshDesc);
Vec3 vCandidatePos(0, 0, 0);
if (meshDesc.m_pVerts)
{
vCandidatePos = pStatObjInfo->tm.TransformPoint(meshDesc.m_pVerts[nVertexIndex]);
}
else if (meshDesc.m_pVertsF16)
{
vCandidatePos = pStatObjInfo->tm.TransformPoint(meshDesc.m_pVertsF16[nVertexIndex].ToVec3());
}
else
{
continue;
}
float fScreenFactor = localCameraPos.GetDistance(vCandidatePos);
Vec3 vBoundBox(fScreenFactor * vVertexBoxSize, fScreenFactor * vVertexBoxSize, fScreenFactor * vVertexBoxSize);
Vec3 vHitPosOnCube;
if (Intersect::Ray_AABB(raySrc, rayDir, AABB(vCandidatePos - vBoundBox, vCandidatePos + vBoundBox), vHitPosOnCube))
{
float fDist = vHitPosOnCube.GetDistance(raySrc);
if (fDist < fNearestDist)
{
fNearestDist = fDist;
outPos = vCandidatePos;
vOutHitPosOnCube = vHitPosOnCube;
}
}
}
if (fNearestDist < 3e10f)
{
return true;
}
return false;
}
Vec3 vNearestPos0, vNearestPos0OnCube;
Vec3 vNearestPos1, vNearestPos1OnCube;
bool bFoundChild0 = FindNearestVertexRecursively(pNode->GetChild(0), raySrc, rayDir, vVertexBoxSize, localCameraPos, vNearestPos0, vNearestPos0OnCube);
bool bFoundChild1 = FindNearestVertexRecursively(pNode->GetChild(1), raySrc, rayDir, vVertexBoxSize, localCameraPos, vNearestPos1, vNearestPos1OnCube);
if (bFoundChild0 && bFoundChild1)
{
float fDist0 = raySrc.GetDistance(vNearestPos0OnCube);
float fDist1 = raySrc.GetDistance(vNearestPos1OnCube);
if (fDist0 < fDist1)
{
outPos = vNearestPos0;
vOutHitPosOnCube = vNearestPos0OnCube;
}
else
{
outPos = vNearestPos1;
vOutHitPosOnCube = vNearestPos1OnCube;
}
}
else if (bFoundChild0 && !bFoundChild1)
{
outPos = vNearestPos0;
vOutHitPosOnCube = vNearestPos0OnCube;
}
else if (!bFoundChild0 && bFoundChild1)
{
outPos = vNearestPos1;
vOutHitPosOnCube = vNearestPos1OnCube;
}
return bFoundChild0 || bFoundChild1;
}
void CKDTree::GetPenetratedBoxes(const Vec3& raySrc, const Vec3& rayDir, std::vector<AABB>& outBoxes)
{
GetPenetratedBoxesRecursively(m_pRootNode, raySrc, rayDir, outBoxes);
}
void CKDTree::GetPenetratedBoxesRecursively(KDTreeNode* pNode, const Vec3& raySrc, const Vec3& rayDir, std::vector<AABB>& outBoxes)
{
Vec3 vHitPos;
if (!pNode || (!pNode->GetBoundBox().IsContainPoint(raySrc) && !Intersect::Ray_AABB(raySrc, rayDir, pNode->GetBoundBox(), vHitPos)))
{
return;
}
outBoxes.push_back(pNode->GetBoundBox());
GetPenetratedBoxesRecursively(pNode->GetChild(0), raySrc, rayDir, outBoxes);
GetPenetratedBoxesRecursively(pNode->GetChild(1), raySrc, rayDir, outBoxes);
}

@ -1,57 +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_UTIL_KDTREE_H
#define CRYINCLUDE_EDITOR_UTIL_KDTREE_H
#pragma once
struct IStatObj;
class KDTreeNode;
class CKDTree
{
public:
CKDTree();
~CKDTree();
bool Build(IStatObj* pStatObj);
bool FindNearestVertex(const Vec3& raySrc, const Vec3& rayDir, float vVertexBoxSize, const Vec3& localCameraPos, Vec3& outPos, Vec3& vOutHitPosOnCube) const;
void GetPenetratedBoxes(const Vec3& raySrc, const Vec3& rayDir, std::vector<AABB>& outBoxes);
enum ESplitAxis
{
eSA_X = 0,
eSA_Y,
eSA_Z,
eSA_Invalid
};
struct SStatObj
{
Matrix34 tm;
IStatObj* pStatObj;
};
private:
void BuildRecursively(KDTreeNode* pNode, const AABB& boundbox, std::vector<uint32>& indices) const;
bool FindNearestVertexRecursively(KDTreeNode* pNode, const Vec3& raySrc, const Vec3& rayDir, float vVertexBoxSize, const Vec3& localCameraPos, Vec3& outPos, Vec3& vOutHitPosOnCube) const;
void GetPenetratedBoxesRecursively(KDTreeNode* pNode, const Vec3& raySrc, const Vec3& rayDir, std::vector<AABB>& outBoxes);
void ConstructStatObjList(IStatObj* pStatObj, const Matrix34& matParent);
static const int s_MinimumVertexSizeInLeafNode = 4;
private:
KDTreeNode* m_pRootNode;
std::vector<SStatObj> m_StatObjectList;
};
#endif // CRYINCLUDE_EDITOR_UTIL_KDTREE_H

@ -16,102 +16,6 @@
//////////////////////////////////////////////////////////////////////////
// CXmlArchive
bool CXmlArchive::Load(const QString& file)
{
bLoading = true;
char filename[AZ_MAX_PATH_LEN] = { 0 };
AZ::IO::FileIOBase::GetInstance()->ResolvePath(file.toUtf8().data(), filename, AZ_MAX_PATH_LEN);
QFile cFile(filename);
if (!cFile.open(QFile::ReadOnly))
{
CLogFile::FormatLine("Warning: Loading of %s failed", filename);
return false;
}
CArchive ar(&cFile, CArchive::load);
QString str;
ar >> str;
root = XmlHelpers::LoadXmlFromBuffer(str.toUtf8().data(), str.toUtf8().length());
if (!root)
{
// If we didn't extract valid XML, attempt to check the header to see if we're dealing with an improperly serialized archive
// When deserializing QStrings, we use readStringLength in EditorUtils, which mimics MFC's decoding.
// In this encoding, the length is first read as an unsigned 8-bit value, if that is 0xFF then the next two bytes are read
// If the 16 bit uint is 0xFFFF, then the next four bytes are read, etc. up to a final 64 bit value.
// In 1.09, there was a bug in which we'd serialize out the 32-bit length improperly like so:
// 0xFF 0xFF 0x00 <4 byte proper length>
// Note that the header could also historically start with 0xFF 0xFF 0xFE to indicate wide strings prior to the length data
// but we don't have to deal with that here as the broken version of the code never prepended this
cFile.seek(0);
quint8 len8;
ar >> len8;
quint16 len16;
ar >> len16;
// Possible bad header, attempt to read 32 bit length.
if (len8 == 0xff && len16 == 0xff)
{
// This version of operator<< only serialized out UTF8 strings up to 32 bits of length, no need to 64-bit check or do wchar.
quint32 len32;
ar >> len32;
str = QString::fromUtf8(cFile.read(len32));
root = XmlHelpers::LoadXmlFromBuffer(str.toUtf8().data(), str.toUtf8().length());
}
if (!root)
{
CLogFile::FormatLine("Warning: Loading of %s failed", filename);
return false;
}
}
const bool loaded = pNamedData->Serialize(ar);
if (!loaded)
{
CLogFile::FormatLine("Error: Can't load xml file: '%s'! File corrupted. Binary file possibly was corrupted by Source Control if it was marked like text format.", filename);
return false;
}
return true;
}
//////////////////////////////////////////////////////////////////////////
void CXmlArchive::Save(const QString& file)
{
char filename[AZ_MAX_PATH_LEN] = { 0 };
AZ::IO::FileIOBase::GetInstance()->ResolvePath(file.toUtf8().data(), filename, AZ_MAX_PATH_LEN);
bLoading = false;
if (!root)
{
return;
}
QFile cFile(filename);
// Open the file for writing, create it if needed
if (!cFile.open(QFile::WriteOnly))
{
CLogFile::FormatLine("Warning: Saving of %s failed", filename);
return;
}
// Create the archive object
CArchive ar(&cFile, CArchive::store);
_smart_ptr<IXmlStringData> pXmlStrData = root->getXMLData(5000000);
// Need convert to QString for CArchive::operator<<
QString str = pXmlStrData->GetString();
ar << str;
pNamedData->Serialize(ar);
}
//////////////////////////////////////////////////////////////////////////
bool CXmlArchive::SaveToPak([[maybe_unused]] const QString& levelPath, CPakFile& pakFile)

@ -60,9 +60,6 @@ public:
return *this;
}
bool Load(const QString& file);
void Save(const QString& file);
//! Save XML Archive to pak file.
//! @return true if saved.
bool SaveToPak(const QString& levelPath, CPakFile& pakFile);

@ -1062,11 +1062,6 @@ Vec3 QtViewport::SnapToGrid(const Vec3& vec)
return vec;
}
float QtViewport::GetGridStep() const
{
return 0.0f;
}
//////////////////////////////////////////////////////////////////////////
void QtViewport::BeginUndo()
{
@ -1121,30 +1116,6 @@ bool QtViewport::IsBoundsVisible([[maybe_unused]] const AABB& box) const
return true;
}
//////////////////////////////////////////////////////////////////////////
bool QtViewport::HitTestLine(const Vec3& lineP1, const Vec3& lineP2, const QPoint& hitpoint, int pixelRadius, float* pToCameraDistance) const
{
float dist = GetDistanceToLine(lineP1, lineP2, hitpoint);
if (dist <= pixelRadius)
{
if (pToCameraDistance)
{
Vec3 raySrc, rayDir;
ViewToWorldRay(hitpoint, raySrc, rayDir);
Vec3 rayTrg = raySrc + rayDir * 10000.0f;
Vec3 pa, pb;
float mua, mub;
LineLineIntersect(lineP1, lineP2, raySrc, rayTrg, pa, pb, mua, mub);
*pToCameraDistance = mub;
}
return true;
}
return false;
}
//////////////////////////////////////////////////////////////////////////
float QtViewport::GetDistanceToLine(const Vec3& lineP1, const Vec3& lineP2, const QPoint& point) const
{
@ -1349,6 +1320,7 @@ float QtViewport::GetFOV() const
{
return gSettings.viewports.fDefaultFov;
}
//////////////////////////////////////////////////////////////////////////
void QtViewport::setRay(QPoint& vp, Vec3& raySrc, Vec3& rayDir)
{
@ -1356,12 +1328,5 @@ void QtViewport::setRay(QPoint& vp, Vec3& raySrc, Vec3& rayDir)
m_raySrc = raySrc;
m_rayDir = rayDir;
}
////////////////////////////////////////////////////////////////////////
void QtViewport::setHitcontext(QPoint& vp, Vec3& raySrc, Vec3& rayDir)
{
vp = m_vp;
raySrc = m_raySrc;
rayDir = m_rayDir;
}
#include <moc_Viewport.cpp>

@ -397,7 +397,6 @@ public:
//! Snap any given 3D world position to grid lines if snap is enabled.
Vec3 SnapToGrid(const Vec3& vec) override;
float GetGridStep() const override;
//! Returns the screen scale factor for a point given in world coordinates.
//! This factor gives the width in world-space units at the point's distance of the viewport.
@ -434,19 +433,12 @@ public:
//! Performs hit testing of 2d point in view to find which object hit.
bool HitTest(const QPoint& point, HitContext& hitInfo) override;
//! Do 2D hit testing of line in world space.
// pToCameraDistance is an optional output parameter in which distance from the camera to the line is returned.
bool HitTestLine(const Vec3& lineP1, const Vec3& lineP2, const QPoint& hitpoint, int pixelRadius, float* pToCameraDistance = 0) const override;
float GetDistanceToLine(const Vec3& lineP1, const Vec3& lineP2, const QPoint& point) const override;
// Access to the member m_bAdvancedSelectMode so interested modules can know its value.
bool GetAdvancedSelectModeFlag() override;
void GetPerpendicularAxis(EAxis* pAxis, bool* pIs2D) const override;
const ::Plane* GetConstructionPlane() const override { return &m_constructionPlane; }
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//! Set construction plane from given position construction matrix refrence coord system and axis settings.
@ -502,7 +494,7 @@ public:
void ReleaseMouse() override { m_mouseCaptured = false; QWidget::releaseMouse(); }
void setRay(QPoint& vp, Vec3& raySrc, Vec3& rayDir) override;
void setHitcontext(QPoint& vp, Vec3& raySrc, Vec3& rayDir) override;
QPoint m_vp;
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
Vec3 m_raySrc;

@ -488,7 +488,6 @@ set(FILES
UndoViewPosition.h
UndoViewRotation.h
Util/GeometryUtil.h
Util/KDTree.h
WipFeaturesDlg.h
WipFeaturesDlg.ui
WipFeaturesDlg.qrc
@ -499,7 +498,6 @@ set(FILES
Objects/ClassDesc.cpp
Objects/ClassDesc.h
Objects/DisplayContextShared.inl
Objects/IEntityObjectListener.h
Objects/SelectionGroup.cpp
Objects/SelectionGroup.h
Objects/SubObjSelection.cpp
@ -710,7 +708,6 @@ set(FILES
Util/GuidUtil.cpp
Util/GuidUtil.h
Util/IObservable.h
Util/KDTree.cpp
Util/Mailer.h
Util/NamedData.cpp
Util/NamedData.h

@ -53,10 +53,8 @@
// Compiler traits ...
#define AZ_TRAIT_COMPILER_DEFINE_AZSWNPRINTF_AS_SWPRINTF 1
#define AZ_TRAIT_COMPILER_DEFINE_FS_ERRNO_TYPE 1
#define AZ_TRAIT_COMPILER_DEFINE_FS_STAT_TYPE 0
#define AZ_TRAIT_COMPILER_DEFINE_GETCURRENTPROCESSID 1
#define AZ_TRAIT_COMPILER_DEFINE_REFGUID 0
#define AZ_TRAIT_COMPILER_DEFINE_SASSERTDATA_TYPE 1
#define AZ_TRAIT_COMPILER_DEFINE_WCSICMP 1
#define AZ_TRAIT_COMPILER_INT64_T_IS_LONG 1
#define AZ_TRAIT_COMPILER_OPTIMIZE_MISSING_DEFAULT_SWITCH_CASE 0

@ -53,10 +53,8 @@
// Compiler traits ...
#define AZ_TRAIT_COMPILER_DEFINE_AZSWNPRINTF_AS_SWPRINTF 1
#define AZ_TRAIT_COMPILER_DEFINE_FS_ERRNO_TYPE 1
#define AZ_TRAIT_COMPILER_DEFINE_FS_STAT_TYPE 0
#define AZ_TRAIT_COMPILER_DEFINE_GETCURRENTPROCESSID 1
#define AZ_TRAIT_COMPILER_DEFINE_REFGUID 1
#define AZ_TRAIT_COMPILER_DEFINE_SASSERTDATA_TYPE 1
#define AZ_TRAIT_COMPILER_DEFINE_WCSICMP 0
#define AZ_TRAIT_COMPILER_INT64_T_IS_LONG 1
#define AZ_TRAIT_COMPILER_OPTIMIZE_MISSING_DEFAULT_SWITCH_CASE 1

@ -53,10 +53,8 @@
// Compiler traits ...
#define AZ_TRAIT_COMPILER_DEFINE_AZSWNPRINTF_AS_SWPRINTF 1
#define AZ_TRAIT_COMPILER_DEFINE_FS_ERRNO_TYPE 1
#define AZ_TRAIT_COMPILER_DEFINE_FS_STAT_TYPE 1
#define AZ_TRAIT_COMPILER_DEFINE_GETCURRENTPROCESSID 1
#define AZ_TRAIT_COMPILER_DEFINE_REFGUID 1
#define AZ_TRAIT_COMPILER_DEFINE_SASSERTDATA_TYPE 1
#define AZ_TRAIT_COMPILER_DEFINE_WCSICMP 0
#define AZ_TRAIT_COMPILER_INT64_T_IS_LONG 0
#define AZ_TRAIT_COMPILER_OPTIMIZE_MISSING_DEFAULT_SWITCH_CASE 1

@ -53,10 +53,8 @@
// Compiler traits ...
#define AZ_TRAIT_COMPILER_DEFINE_AZSWNPRINTF_AS_SWPRINTF 0
#define AZ_TRAIT_COMPILER_DEFINE_FS_ERRNO_TYPE 0
#define AZ_TRAIT_COMPILER_DEFINE_FS_STAT_TYPE 0
#define AZ_TRAIT_COMPILER_DEFINE_GETCURRENTPROCESSID 0
#define AZ_TRAIT_COMPILER_DEFINE_REFGUID 0
#define AZ_TRAIT_COMPILER_DEFINE_SASSERTDATA_TYPE 0
#define AZ_TRAIT_COMPILER_DEFINE_WCSICMP 0
#define AZ_TRAIT_COMPILER_INT64_T_IS_LONG 0
#define AZ_TRAIT_COMPILER_OPTIMIZE_MISSING_DEFAULT_SWITCH_CASE 1

@ -53,10 +53,8 @@
// Compiler traits ...
#define AZ_TRAIT_COMPILER_DEFINE_AZSWNPRINTF_AS_SWPRINTF 1
#define AZ_TRAIT_COMPILER_DEFINE_FS_ERRNO_TYPE 1
#define AZ_TRAIT_COMPILER_DEFINE_FS_STAT_TYPE 1
#define AZ_TRAIT_COMPILER_DEFINE_GETCURRENTPROCESSID 1
#define AZ_TRAIT_COMPILER_DEFINE_REFGUID 1
#define AZ_TRAIT_COMPILER_DEFINE_SASSERTDATA_TYPE 1
#define AZ_TRAIT_COMPILER_DEFINE_WCSICMP 0
#define AZ_TRAIT_COMPILER_INT64_T_IS_LONG 0
#define AZ_TRAIT_COMPILER_OPTIMIZE_MISSING_DEFAULT_SWITCH_CASE 1

@ -46,11 +46,6 @@ namespace AZ::IO
"If set to 0, tells Archive to try to open the file on the file system first othewise check mounted paks.\n"
"If set to 1, tells Archive to try to open the file in pak first, then go to file system.\n"
"If set to 2, tells the Archive to only open files from the pak");
AZ_CVAR(int, sys_PakMessageInvalidFileAccess, ArchiveVars{}.nMessageInvalidFileAccess, nullptr, AZ::ConsoleFunctorFlags::Null,
"Message Box synchronous file access when in game");
AZ_CVAR(int, sys_PakWarnOnPakAccessFailures, ArchiveVars{}.nWarnOnPakAccessFails, nullptr, AZ::ConsoleFunctorFlags::Null,
"If 1, access failure for Paks is treated as a warning, if zero it is only a log message.");
AZ_CVAR(int, sys_report_files_not_found_in_paks, 0, nullptr, AZ::ConsoleFunctorFlags::Null,
"Reports when files are searched for in paks and not found. 1 = log, 2 = warning, 3 = error");
AZ_CVAR(int32_t, az_archive_verbosity, 0, nullptr, AZ::ConsoleFunctorFlags::Null,

@ -9,8 +9,6 @@
#pragma once
#include <AzFramework/Archive/ArchiveVars_Platform.h>
namespace AZ::IO
{
enum class FileSearchPriority
@ -39,25 +37,10 @@ namespace AZ::IO
#else
inline static constexpr bool IsReleaseConfig{};
#endif
int nReadSlice{};
int nSaveTotalResourceList{};
int nSaveFastloadResourceList{};
int nSaveMenuCommonResourceList{};
int nSaveLevelResourceList{};
int nValidateFileHashes{ IsReleaseConfig ? 0 : 1 };
int nUncachedStreamReads{ 1 };
int nInMemoryPerPakSizeLimit{ 6 }; // Limits in MB
int nTotalInMemoryPakSizeLimit{ 30 };
int nLoadCache{};
int nLoadModePaks{};
int nStreamCache{ STREAM_CACHE_DEFAULT };
FileSearchPriority m_fileSearchPriority{ GetDefaultFileSearchPriority()};
int nMessageInvalidFileAccess{};
int nLogInvalidFileAccess{ IsReleaseConfig ? 0 : 1 };
int nDisableNonLevelRelatedPaks{ 1 };
int nWarnOnPakAccessFails{ 1 }; // Whether to treat failed pak access as a warning or log message
int nSetLogLevel{ 3 };
int nLogAllFileAccess{};
};
}

@ -1,11 +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
*
*/
#pragma once
#define STREAM_CACHE_DEFAULT 0

@ -1,10 +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
*
*/
#pragma once
#include <AzFramework/Archive/ArchiveVars_Android.h>

@ -27,8 +27,6 @@ set(FILES
AzFramework/Input/User/LocalUserId_Platform.h
../Common/Default/AzFramework/Input/User/LocalUserId_Default.h
AzFramework/Input/Devices/VirtualKeyboard/InputDeviceVirtualKeyboard_Android.cpp
AzFramework/Archive/ArchiveVars_Platform.h
AzFramework/Archive/ArchiveVars_Android.h
AzFramework/Process/ProcessCommon.h
AzFramework/Process/ProcessWatcher_Android.cpp
AzFramework/Process/ProcessCommunicator_Android.cpp

@ -1,11 +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
*
*/
#pragma once
#define STREAM_CACHE_DEFAULT 0

@ -1,10 +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
*
*/
#pragma once
#include <AzFramework/Archive/ArchiveVars_Linux.h>

@ -28,6 +28,4 @@ set(FILES
AzFramework/Input/User/LocalUserId_Platform.h
../Common/Default/AzFramework/Input/User/LocalUserId_Default.h
../Common/Unimplemented/AzFramework/Input/Devices/VirtualKeyboard/InputDeviceVirtualKeyboard_Unimplemented.cpp
AzFramework/Archive/ArchiveVars_Platform.h
AzFramework/Archive/ArchiveVars_Linux.h
)

@ -1,11 +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
*
*/
#pragma once
#define STREAM_CACHE_DEFAULT 0

@ -1,10 +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
*
*/
#pragma once
#include <AzFramework/Archive/ArchiveVars_Mac.h>

@ -30,8 +30,6 @@ set(FILES
AzFramework/Input/User/LocalUserId_Platform.h
../Common/Default/AzFramework/Input/User/LocalUserId_Default.h
../Common/Unimplemented/AzFramework/Input/Devices/VirtualKeyboard/InputDeviceVirtualKeyboard_Unimplemented.cpp
AzFramework/Archive/ArchiveVars_Platform.h
AzFramework/Archive/ArchiveVars_Mac.h
../Common/Apple/AzFramework/Utils/SystemUtilsApple.h
../Common/Apple/AzFramework/Utils/SystemUtilsApple.mm
)

@ -1,10 +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
*
*/
#pragma once
#include <AzFramework/Archive/ArchiveVars_Windows.h>

@ -1,11 +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
*
*/
#pragma once
#define STREAM_CACHE_DEFAULT 0

@ -32,6 +32,4 @@ set(FILES
AzFramework/Input/User/LocalUserId_Platform.h
../Common/Default/AzFramework/Input/User/LocalUserId_Default.h
../Common/Unimplemented/AzFramework/Input/Devices/VirtualKeyboard/InputDeviceVirtualKeyboard_Unimplemented.cpp
AzFramework/Archive/ArchiveVars_Platform.h
AzFramework/Archive/ArchiveVars_Windows.h
)

@ -1,10 +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
*
*/
#pragma once
#include <AzFramework/Archive/ArchiveVars_iOS.h>

@ -1,11 +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
*
*/
#pragma once
#define STREAM_CACHE_DEFAULT 0

@ -27,8 +27,6 @@ set(FILES
AzFramework/Input/User/LocalUserId_Platform.h
../Common/Default/AzFramework/Input/User/LocalUserId_Default.h
../Common/Apple/AzFramework/Input/Devices/VirtualKeyboard/InputDeviceVirtualKeyboard_Apple.mm
AzFramework/Archive/ArchiveVars_Platform.h
AzFramework/Archive/ArchiveVars_iOS.h
AzFramework/Process/ProcessCommon.h
AzFramework/Process/ProcessWatcher_iOS.cpp
AzFramework/Process/ProcessCommunicator_iOS.cpp

@ -10,6 +10,7 @@
#include <AzCore/base.h>
#include <AzCore/EBus/EBus.h>
#include <AzCore/Math/Vector2.h>
class CVegetationMap;
struct CVegetationInstance;

@ -141,11 +141,6 @@ typedef uint8 byte;
#endif
#ifndef SAFE_RELEASE_FORCE
#define SAFE_RELEASE_FORCE(p) { if (p) { (p)->ReleaseForce(); (p) = NULL; } \
}
#endif
#define MAKEWORD(a, b) ((WORD)(((BYTE)((DWORD_PTR)(a) & 0xff)) | ((WORD)((BYTE)((DWORD_PTR)(b) & 0xff))) << 8))
#define MAKELONG(a, b) ((LONG)(((WORD)((DWORD_PTR)(a) & 0xffff)) | ((DWORD)((WORD)((DWORD_PTR)(b) & 0xffff))) << 16))
#define LOWORD(l) ((WORD)((DWORD_PTR)(l) & 0xffff))
@ -472,22 +467,6 @@ inline int64 CryGetTicks()
return counter.QuadPart;
}
inline int64 CryGetTicksPerSec()
{
LARGE_INTEGER li;
QueryPerformanceFrequency(&li);
return li.QuadPart;
}
/*
inline uint32 GetTickCount()
{
LARGE_INTEGER count, freq;
QueryPerformanceCounter(&count);
QueryPerformanceFrequency(&freq);
return uint32(count.QuadPart * 1000 / freq.QuadPart);
}
*/
#ifdef _RELEASE
#define __debugbreak()
#else

@ -799,11 +799,6 @@ struct Matrix34_tpl
///////////////////////////////////////////////////////////////////////////////
typedef Matrix34_tpl<f32> Matrix34; //always 32 bit
#if AZ_COMPILER_MSVC
typedef __declspec(align(16)) Matrix34_tpl<f32> Matrix34A;
#elif AZ_COMPILER_CLANG
typedef Matrix34_tpl<f32> __attribute__((aligned(16))) Matrix34A;
#endif
//----------------------------------------------------------------------------------
//----------------------------------------------------------------------------------

@ -276,30 +276,6 @@ struct Matrix44_tpl
m32 = m.m32;
m33 = m.m33;
}
//CONSTRUCTOR for identical types which converts between double/float
//Matrix44 m=m44r;
//Matrix44r m=m44;
template<class F1>
ILINE Matrix44_tpl<F>(const Matrix44_tpl<F1>&m)
{
assert(m.IsValid());
m00 = F(m.m00);
m01 = F(m.m01);
m02 = F(m.m02);
m03 = F(m.m03);
m10 = F(m.m10);
m11 = F(m.m11);
m12 = F(m.m12);
m13 = F(m.m13);
m20 = F(m.m20);
m21 = F(m.m21);
m22 = F(m.m22);
m23 = F(m.m23);
m30 = F(m.m30);
m31 = F(m.m31);
m32 = F(m.m32);
m33 = F(m.m33);
}
//---------------------------------------------------------------------
@ -662,13 +638,6 @@ struct Matrix44_tpl
///////////////////////////////////////////////////////////////////////////////
typedef Matrix44_tpl<f32> Matrix44; //always 32 bit
typedef Matrix44_tpl<f64> Matrix44d; //always 64 bit
typedef Matrix44_tpl<real> Matrix44r; //variable float precision. depending on the target system it can be between 32, 64 or 80 bit
#if AZ_COMPILER_MSVC
typedef __declspec(align(16)) Matrix44_tpl<f32> Matrix44A;
#elif AZ_COMPILER_CLANG
typedef Matrix44_tpl<f32> __attribute__((aligned(16))) Matrix44A;
#endif
//----------------------------------------------------------------------------------
//----------------------------------------------------------------------------------

@ -1,26 +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
*
*/
#pragma once
#include <CryCommon/Cry_Matrix34.h>
struct IStatObj;
struct IRenderNode
{
// Gives access to object components.
IStatObj* GetEntityStatObj(unsigned int = 0, unsigned int = 0, Matrix34* = nullptr, bool = false) {
return nullptr;
}
int GetSlotCount() const { return 1; }
// Max view distance settings.
static constexpr int VIEW_DISTANCE_MULTIPLIER_MAX = 100;
};

@ -1,54 +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
*
*/
// Description : Base header for multi DLL functors.
#ifndef CRYINCLUDE_CRYCOMMON_IFUNCTORBASE_H
#define CRYINCLUDE_CRYCOMMON_IFUNCTORBASE_H
#pragma once
#include <AzCore/std/parallel/atomic.h>
// Base class for functor storage.
// Not intended for direct usage.
class IFunctorBase
{
public:
IFunctorBase()
: m_nReferences(0){}
virtual ~IFunctorBase(){};
virtual void Call() = 0;
void AddRef()
{
m_nReferences.fetch_add(1, AZStd::memory_order_acq_rel);
}
void Release()
{
if (m_nReferences.fetch_sub(1, AZStd::memory_order_acq_rel) == 1)
{
delete this;
}
}
protected:
AZStd::atomic_int m_nReferences;
};
// Base Template for specialization.
// Not intended for direct usage.
template<typename tType>
class TFunctor
: public IFunctorBase
{
};
#endif // CRYINCLUDE_CRYCOMMON_IFUNCTORBASE_H

@ -10,7 +10,6 @@
#pragma once
#include "Cry_Color.h"
#include <VertexFormats.h>
#include <Vertex.h>
// Description:
@ -53,119 +52,3 @@ public:
a = othera;
}
};
// Description:
// Defines a single triangle face in the CMesh topology.
struct SMeshFace
{
int v[3]; // indices to vertex, normals and optionally tangent basis arrays
unsigned char nSubset; // index to mesh subsets array.
};
// Description:
// 3D Normal Vector used by CMesh.
struct SMeshNormal
{
SMeshNormal() {}
private:
Vec3 Normal;
public:
explicit SMeshNormal(const Vec3& othern)
{
Normal = othern;
}
Vec3 GetN() const { return Normal; }
};
// Subset of mesh is a continuous range of vertices and indices that share same material.
struct SMeshSubset
{
Vec3 vCenter;
float fRadius;
float fTexelDensity;
int nFirstIndexId;
int nNumIndices;
int nFirstVertId;
int nNumVerts;
int nMatID; // Material Sub-object id.
int nMatFlags; // Special Material flags.
int nPhysicalizeType; // Type of physicalization for this subset.
AZ::Vertex::Format vertexFormat;
SMeshSubset()
: vCenter(0, 0, 0)
, fRadius(0)
, fTexelDensity(0)
, nFirstIndexId(0)
, nNumIndices(0)
, nFirstVertId(0)
, nNumVerts(0)
, nMatID(0)
, nMatFlags(0)
, nPhysicalizeType(0x1000)
, vertexFormat(eVF_P3S_C4B_T2S)
{
}
};
// Description:
// Editable mesh interface.
// IndexedMesh can be created directly or loaded from CGF file, before rendering it is converted into IRenderMesh.
// IStatObj is used to host IIndexedMesh, and corresponding IRenderMesh.
struct IIndexedMesh
{
/*! Structure used for read-only access to mesh data. Used by GetMesh() function */
struct SMeshDescription
{
const SMeshFace* m_pFaces; // pointer to array of faces
const Vec3* m_pVerts; // pointer to array of vertices in f32 format
const Vec3f16* m_pVertsF16; // pointer to array of vertices in f16 format
const SMeshNormal* m_pNorms; // pointer to array of normals
const SMeshColor* m_pColor; // pointer to array of vertex colors
const SMeshTexCoord* m_pTexCoord; // pointer to array of texture coordinates
const vtx_idx* m_pIndices; // pointer to array of indices
int m_nFaceCount; // number of elements m_pFaces array
int m_nVertCount; // number of elements in m_pVerts, m_pNorms and m_pColor arrays
int m_nCoorCount; // number of elements in m_pTexCoord array
int m_nIndexCount; // number of elements in m_pIndices array
};
virtual ~IIndexedMesh() {}
// Release indexed mesh.
virtual void Release() = 0;
//! Gives read-only access to mesh data
virtual void GetMeshDescription(SMeshDescription& meshDesc) const = 0;
//! Return number of allocated faces
virtual int GetFaceCount() const = 0;
//! Return number of allocated vertices, normals and colors
virtual int GetVertexCount() const = 0;
/*! Reallocates vertices, normals and colors. Calling this function invalidates SMeshDescription pointers */
virtual void SetVertexCount(int nNewCount) = 0;
//! Return number of allocated texture coordinates
virtual int GetTexCoordCount() const = 0;
// Get number of indices in the mesh.
virtual int GetIndexCount() const = 0;
//////////////////////////////////////////////////////////////////////////
// Subset access.
//////////////////////////////////////////////////////////////////////////
virtual int GetSubSetCount() const = 0;
virtual const SMeshSubset& GetSubSet(int nIndex) const = 0;
};

@ -1,110 +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
*
*/
#pragma once
#include "Cry_Math.h"
#include "Cry_Geo.h"
#include "IMaterial.h"
// General forward declaration.
struct SRenderingPassInfo;
//////////////////////////////////////////////////////////////////////////
// Type of static sub object.
//////////////////////////////////////////////////////////////////////////
enum EStaticSubObjectType
{
STATIC_SUB_OBJECT_MESH, // This simple geometry part of the multi-sub object geometry.
STATIC_SUB_OBJECT_HELPER_MESH, // Special helper mesh, not rendered usually, used for broken pieces.
};
// used for on-CPU voxelization
struct SRayHitInfo
{
SRayHitInfo()
{
memset(this, 0, sizeof(*this));
}
//////////////////////////////////////////////////////////////////////////
// Input parameters.
Vec3 inReferencePoint;
Ray inRay;
//////////////////////////////////////////////////////////////////////////
// Output parameters.
Vec3 vHitPos;
Vec3 vHitNormal;
// More inputs
bool bInFirstHit;
bool bUseCache;
};
// Summary:
// Interface to hold static object data
struct IStatObj
{
//////////////////////////////////////////////////////////////////////////
// SubObject
//////////////////////////////////////////////////////////////////////////
struct SSubObject
{
EStaticSubObjectType nType;
Matrix34 localTM; // Local transformation matrix, relative to parent.
IStatObj* pStatObj; // Static object for sub part of CGF.
};
//////////////////////////////////////////////////////////////////////////
virtual ~IStatObj() {}
// Description:
// Provide access to the faces, vertices, texture coordinates, normals and
// colors of the object used later for CRenderMesh construction.
// Return Value:
//
// Summary:
// Get the object source geometry
virtual struct IIndexedMesh* GetIndexedMesh(bool bCreateIfNone = false) = 0;
// Summary:
// Get the bounding box
// Arguments:
// Mins - Position of the bottom left close corner of the bounding box
// Maxs - Position of the top right far corner of the bounding box
virtual AABB GetAABB() = 0;
// Description:
// Returns the LOD object, if present.
// Arguments:
// nLodLevel - Level of the LOD
// bReturnNearest - if true will return nearest available LOD to nLodLevel.
// Return Value:
// A static object with the desired LOD. The value NULL will be return if there isn't any LOD object for the level requested.
// Summary:
// Get the LOD object
virtual IStatObj* GetLodObject(int nLodLevel, bool bReturnNearest = false) = 0;
// Summary:
// Returns a pointer to the object
// Return Value:
// A pointer to the current object, which is simply done like this "return this;"
virtual struct IStatObj* GetIStatObj() { return this; }
//////////////////////////////////////////////////////////////////////////
// Interface to the Sub Objects.
//////////////////////////////////////////////////////////////////////////
// Summary:
// Retrieve number of sub-objects.
virtual int GetSubObjectCount() const = 0;
// Summary:
// Retrieve sub object by index, where 0 <= nIndex < GetSubObjectCount()
virtual SSubObject* GetSubObject(int nIndex) = 0;
// Intersect ray with static object.
// Ray must be in object local space.
virtual bool RayIntersection(SRayHitInfo& hitInfo, IMaterial* pCustomMtl = nullptr) = 0;
};

@ -427,7 +427,7 @@ struct ISystemUserCallback
// Description:
// Show message by provider.
virtual int ShowMessage(const char* text, const char* caption, unsigned int uType) { return CryMessageBox(text, caption, uType); }
virtual void ShowMessage(const char* text, const char* caption, unsigned int uType) { CryMessageBox(text, caption, uType); }
// </interfuscator:shuffle>
@ -811,14 +811,13 @@ struct ISystem
// Description:
// Report message by provider or by using CryMessageBox.
// Doesn't terminate the execution.
virtual int ShowMessage(const char* text, const char* caption, unsigned int uType) = 0;
virtual void ShowMessage(const char* text, const char* caption, unsigned int uType) = 0;
// Summary:
// Compare specified verbosity level to the one currently set.
virtual bool CheckLogVerbosity(int verbosity) = 0;
// return the related subsystem interface
virtual ILevelSystem* GetILevelSystem() = 0;
virtual ICmdLine* GetICmdLine() = 0;
virtual ILog* GetILog() = 0;
@ -829,13 +828,6 @@ struct ISystem
virtual IRemoteConsole* GetIRemoteConsole() = 0;
virtual ISystemEventDispatcher* GetISystemEventDispatcher() = 0;
// Arguments:
// bValue - Set to true when running on a cheat protected server or a client that is connected to it (not used in singleplayer).
virtual void SetForceNonDevMode(bool bValue) = 0;
// Return Value:
// True when running on a cheat protected server or a client that is connected to it (not used in singleplayer).
virtual bool GetForceNonDevMode() const = 0;
virtual bool WasInDevMode() const = 0;
virtual bool IsDevMode() const = 0;
//////////////////////////////////////////////////////////////////////////
@ -860,18 +852,6 @@ struct ISystem
// When ignore update sets to true, system will ignore and updates and render calls.
virtual void IgnoreUpdates(bool bIgnore) = 0;
// Summary:
// Sets the active process
// Arguments:
// process - A pointer to a class that implement the IProcess interface.
virtual void SetIProcess(IProcess* process) = 0;
// Summary:
// Gets the active process.
// Return Value:
// A pointer to the current active process.
virtual IProcess* GetIProcess() = 0;
// Return Value:
// True if system running in Test mode.
virtual bool IsTestMode() const = 0;
@ -911,8 +891,6 @@ struct ISystem
// pCallback - 0 means normal LoadConfigVar behaviour is used
virtual void LoadConfiguration(const char* sFilename, ILoadConfigurationEntrySink* pSink = 0, bool warnIfMissing = true) = 0;
virtual ESystemConfigSpec GetMaxConfigSpec() const = 0;
//////////////////////////////////////////////////////////////////////////
// Summary:
@ -937,10 +915,6 @@ struct ISystem
// Retrieves the perlin noise singleton instance.
virtual CPNoise3* GetNoiseGen() = 0;
// Summary:
// Retrieves system update counter.
virtual uint64 GetUpdateCounter() = 0;
//////////////////////////////////////////////////////////////////////////
// Error callback handling
@ -973,13 +947,6 @@ struct ISystem
virtual void SetAssertVisible(bool bAssertVisble) = 0;
//////////////////////////////////////////////////////////////////////////
// Summary:
// Enable/Disable drawing the console
virtual void SetConsoleDrawEnabled(bool enabled) = 0;
// Enable/Disable drawing the UI
virtual void SetUIDrawEnabled(bool enabled) = 0;
// Summary:
// Get the index of the currently running O3DE application. (0 = first instance, 1 = second instance, etc)
virtual int GetApplicationInstance() = 0;
@ -1027,12 +994,6 @@ struct ISystem
virtual bool IsSavingResourceList() const = 0;
#endif
// Summary:
// Gets the root window message handler function
// The returned pointer is platform-specific:
// For Windows OS, the pointer is of type WNDPROC
virtual void* GetRootWindowMessageHandler() = 0;
// Summary:
// Register a IWindowMessageHandler that will be informed about window messages
// The delivered messages are platform-specific
@ -1042,10 +1003,6 @@ struct ISystem
// Unregister an IWindowMessageHandler that was previously registered using RegisterWindowMessageHandler
virtual void UnregisterWindowMessageHandler(IWindowMessageHandler* pHandler) = 0;
// Create an instance of a Local File IO object (which reads directly off the local filesystem, instead of,
// for example, reading from the network or a pack or USB or such.
virtual std::shared_ptr<AZ::IO::FileIOBase> CreateLocalFileIO() = 0;
////////////////////////////////////////////////////////////////////////////////////////////////
// EBus interface used to listen for cry system notifications
class CrySystemNotifications : public AZ::EBusTraits

@ -87,7 +87,7 @@ class XmlString
public:
XmlString() {};
XmlString(const char* str)
: AZStd::string(str) {};
: AZStd::string(str) {}
size_t GetAllocatedMemory() const
{
@ -243,15 +243,6 @@ public:
// Removes child node.
virtual void removeChild(const XmlNodeRef& node) = 0;
// Summary:
// Inserts child node.
virtual void insertChild(int nIndex, const XmlNodeRef& node) = 0;
// Summary:
// Replaces a specified child with the passed one
// Not supported by all node implementations
virtual void replaceChild(int nIndex, const XmlNodeRef& fromNode) = 0;
// Summary:
// Removes all child nodes.
virtual void removeAllChilds() = 0;
@ -283,13 +274,6 @@ public:
// Sets content of this node.
virtual void setContent(const char* str) = 0;
// Summary:
// Deep clone of this and all child xml nodes.
virtual XmlNodeRef clone() = 0;
// Summary:
// Returns line number for XML tag.
virtual int getLine() const = 0;
// Summary:
// Set line number in xml.
virtual void setLine(int line) = 0;
@ -385,20 +369,6 @@ public:
}
#endif
// Summary:
// Copies children to this node from a given node.
// Children are reference copied (shallow copy) and the children's parent is NOT set to this
// node, but left with its original parent (which is still the parent)
virtual void shareChildren(const XmlNodeRef& fromNode) = 0;
// Summary:
// Removes child node at known position.
virtual void deleteChildAt(int nIndex) = 0;
// Summary:
// Returns XML of this node and sub nodes into tmpBuffer without XML checks (much faster)
virtual XmlString getXMLUnsafe(int level, [[maybe_unused]] char* tmpBuffer, [[maybe_unused]] uint32 sizeOfTmpBuffer) const { return getXML(level); }
// Notes:
// Save in small memory chunks.
virtual bool saveToFile(const char* fileName, size_t chunkSizeBytes, AZ::IO::HandleType fileHandle = AZ::IO::InvalidHandle) = 0;
@ -413,28 +383,22 @@ public:
bool getAttr(const char* key, long& value) const
{
int v;
if (getAttr(key, v))
{
value = static_cast<long>(v);
return true;
}
else
if (!getAttr(key, v))
{
return false;
}
value = static_cast<long>(v);
return true;
}
bool getAttr(const char* key, unsigned long& value) const
{
int v;
if (getAttr(key, v))
{
value = static_cast<unsigned long>(v);
return true;
}
else
if (!getAttr(key, v))
{
return false;
}
value = static_cast<unsigned long>(v);
return true;
}
void setAttr(const char* key, unsigned long value) { setAttr(key, (unsigned int)value); };
void setAttr(const char* key, long value) { setAttr(key, (int)value); };
@ -442,54 +406,42 @@ public:
bool getAttr(const char* key, unsigned short& value) const
{
int v;
if (getAttr(key, v))
{
value = static_cast<unsigned short>(v);
return true;
}
else
if (!getAttr(key, v))
{
return false;
}
value = static_cast<unsigned short>(v);
return true;
}
bool getAttr(const char* key, unsigned char& value) const
{
int v;
if (getAttr(key, v))
{
value = static_cast<unsigned char>(v);
return true;
}
else
if (!getAttr(key, v))
{
return false;
}
value = static_cast<unsigned char>(v);
return true;
}
bool getAttr(const char* key, short& value) const
{
int v;
if (getAttr(key, v))
{
value = static_cast<short>(v);
return true;
}
else
if (!getAttr(key, v))
{
return false;
}
value = static_cast<short>(v);
return true;
}
bool getAttr(const char* key, char& value) const
{
int v;
if (getAttr(key, v))
{
value = static_cast<char>(v);
return true;
}
else
if (!getAttr(key, v))
{
return false;
}
value = static_cast<char>(v);
return true;
}
//##@}

@ -102,11 +102,6 @@ typedef float FLOAT;
#endif
#ifndef SAFE_RELEASE_FORCE
#define SAFE_RELEASE_FORCE(p) { if (p) { (p)->ReleaseForce(); (p) = NULL; } \
}
#endif
#define MAKEWORD(a, b) ((WORD)(((BYTE)((DWORD_PTR)(a) & 0xff)) | ((WORD)((BYTE)((DWORD_PTR)(b) & 0xff))) << 8))
#define MAKELONG(a, b) ((LONG)(((WORD)((DWORD_PTR)(a) & 0xffff)) | ((DWORD)((WORD)((DWORD_PTR)(b) & 0xffff))) << 16))
#define LOWORD(l) ((WORD)((DWORD_PTR)(l) & 0xffff))
@ -462,13 +457,6 @@ inline int64 CryGetTicks()
return counter.QuadPart;
}
inline int64 CryGetTicksPerSec()
{
LARGE_INTEGER li;
QueryPerformanceFrequency(&li);
return li.QuadPart;
}
#endif //__cplusplus
inline int _CrtCheckMemory() { return 1; };

@ -5,10 +5,6 @@
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#ifndef CRYINCLUDE_CRYCOMMON_LINUX_WIN32WRAPPER_H
#define CRYINCLUDE_CRYCOMMON_LINUX_WIN32WRAPPER_H
#pragma once
#include <CryAssert.h>
@ -326,57 +322,6 @@ inline uint32 GetTickCount()
#define _strlwr_s(BUF, SIZE) strlwr(BUF)
#define _strups strupr
typedef struct __finddata64_t
{
//!< atributes set by find request
unsigned int attrib; //!< attributes, only directory and readonly flag actually set
int64 time_create; //!< creation time, cannot parse under linux, last modification time is used instead (game does nowhere makes decision based on this values)
int64 time_access; //!< last access time
int64 time_write; //!< last modification time
int64 size; //!< file size (for a directory it will be the block size)
char name[256]; //!< file/directory name
private:
int m_LastIndex; //!< last index for findnext
char m_DirectoryName[260]; //!< directory name, needed when getting file attributes on the fly
char m_ToMatch[260]; //!< pattern to match with
DIR* m_Dir; //!< directory handle
std::vector<AZStd::string> m_Entries; //!< all file entries in the current directories
public:
inline __finddata64_t()
: attrib(0)
, time_create(0)
, time_access(0)
, time_write(0)
, size(0)
, m_LastIndex(-1)
, m_Dir(NULL)
{
memset(name, '0', 256);
}
~__finddata64_t();
//!< copies and retrieves the data for an actual match (to not waste any effort retrioeving data for unused files)
void CopyFoundData(const char* rMatchedFileName);
public:
//!< global _findfirst64 function using struct above, can't be a member function due to required semantic match
friend intptr_t _findfirst64(const char* pFileName, __finddata64_t* pFindData);
//!< global _findnext64 function using struct above, can't be a member function due to required semantic match
friend int _findnext64(intptr_t last, __finddata64_t* pFindData);
}__finddata64_t;
typedef struct _finddata_t
: public __finddata64_t
{}_finddata_t;//!< need inheritance since in many places it get used as struct _finddata_t
extern int _findnext64(intptr_t last, __finddata64_t* pFindData);
extern intptr_t _findfirst64(const char* pFileName, __finddata64_t* pFindData);
extern DWORD GetFileAttributesW(LPCWSTR lpFileName);
extern const bool GetFilenameNoCase(const char* file, char*);
extern BOOL GetUserName(LPSTR lpBuffer, LPDWORD nSize);
//error code stuff
@ -646,8 +591,3 @@ inline unsigned long long _byteswap_uint64(unsigned long long input)
((input & 0x000000000000ff00ull) << 40) |
((input & 0x00000000000000ffull) << 56));
}
#endif // CRYINCLUDE_CRYCOMMON_LINUX_WIN32WRAPPER_H
// vim:ts=2

@ -52,7 +52,7 @@ public:
void Warning([[maybe_unused]] EValidatorModule module, [[maybe_unused]] EValidatorSeverity severity, [[maybe_unused]] int flags, [[maybe_unused]] const char* file, [[maybe_unused]] const char* format, ...) override {}
MOCK_METHOD3(ShowMessage,
int(const char* text, const char* caption, unsigned int uType));
void(const char* text, const char* caption, unsigned int uType));
MOCK_METHOD1(CheckLogVerbosity,
bool(int verbosity));
MOCK_METHOD0(GetILevelSystem,
@ -75,12 +75,6 @@ public:
IRemoteConsole * ());
MOCK_METHOD0(GetISystemEventDispatcher,
ISystemEventDispatcher * ());
MOCK_METHOD1(SetForceNonDevMode,
void(bool bValue));
MOCK_CONST_METHOD0(GetForceNonDevMode,
bool());
MOCK_CONST_METHOD0(WasInDevMode,
bool());
MOCK_CONST_METHOD0(IsDevMode,
bool());
MOCK_METHOD3(CreateXmlNode,
@ -93,10 +87,6 @@ public:
IXmlUtils * ());
MOCK_METHOD1(IgnoreUpdates,
void(bool bIgnore));
MOCK_METHOD1(SetIProcess,
void(IProcess * process));
MOCK_METHOD0(GetIProcess,
IProcess * ());
MOCK_CONST_METHOD0(IsTestMode,
bool());
MOCK_METHOD3(SetFrameProfiler,
@ -115,8 +105,6 @@ public:
MOCK_METHOD3(LoadConfiguration,
void(const char*, ILoadConfigurationEntrySink*, bool));
MOCK_CONST_METHOD0(GetMaxConfigSpec,
ESystemConfigSpec());
MOCK_CONST_METHOD0(GetConfigPlatform,
ESystemConfigPlatform());
MOCK_METHOD1(SetConfigPlatform,
@ -127,8 +115,6 @@ public:
ILocalizationManager * ());
MOCK_METHOD0(GetNoiseGen,
CPNoise3 * ());
MOCK_METHOD0(GetUpdateCounter,
uint64());
MOCK_METHOD1(RegisterErrorObserver,
bool(IErrorObserver * errorObserver));
MOCK_METHOD1(UnregisterErrorObserver,
@ -139,10 +125,6 @@ public:
bool());
MOCK_METHOD1(SetAssertVisible,
void(bool bAssertVisble));
MOCK_METHOD1(SetConsoleDrawEnabled,
void(bool enabled));
MOCK_METHOD1(SetUIDrawEnabled,
void(bool enabled));
MOCK_METHOD0(GetApplicationInstance,
int());
MOCK_METHOD1(GetApplicationLogInstance,
@ -167,14 +149,10 @@ public:
bool());
#endif
MOCK_METHOD0(GetRootWindowMessageHandler,
void*());
MOCK_METHOD1(RegisterWindowMessageHandler,
void(IWindowMessageHandler * pHandler));
MOCK_METHOD1(UnregisterWindowMessageHandler,
void(IWindowMessageHandler * pHandler));
MOCK_METHOD0(CreateLocalFileIO,
std::shared_ptr<AZ::IO::FileIOBase>());
MOCK_METHOD2(ForceMaxFps, void(bool, int));
};

@ -1,36 +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
*
*/
#pragma once
#include <AzCore/EBus/EBus.h>
#include <AzCore/std/containers/unordered_set.h>
//////////////////////////////////////////////////////////////////////////
//
// EBUS support for triggering necessary updates when IStatObj instances
// caches should be updated when 3D Engine events happen during level loads,
// shutting down the application, and so forth
//
//////////////////////////////////////////////////////////////////////////
class InstanceStatObjEvents
: public AZ::EBusTraits
{
public:
virtual ~InstanceStatObjEvents() = default;
// AZ::EBusTraits
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Multiple;
using MutexType = AZStd::recursive_mutex;
virtual void ReleaseData()
{
}
};
using InstanceStatObjEventBus = AZ::EBus<InstanceStatObjEvents>;

@ -53,21 +53,8 @@
#include <mach/mach_host.h>
#endif
#if defined(ANDROID)
#define FIX_FILENAME_CASE 0 // everything is lower case on android
#elif defined(LINUX) || defined(APPLE)
#define FIX_FILENAME_CASE 1
#endif
#include <sys/time.h>
#if !defined(_RELEASE) || defined(_DEBUG)
#include <set>
unsigned int g_EnableMultipleAssert = 0;//set to something else than 0 if to enable already reported asserts
#endif
#if defined(LINUX) || defined(APPLE)
#include <sys/types.h>
#include <unistd.h>
@ -81,106 +68,11 @@ unsigned int g_EnableMultipleAssert = 0;//set to something else than 0 if to ena
#if AZ_TRAIT_COMPILER_DEFINE_FS_ERRNO_TYPE
typedef int FS_ERRNO_TYPE;
#if AZ_TRAIT_COMPILER_DEFINE_FS_STAT_TYPE
typedef struct stat FS_STAT_TYPE;
#else
typedef struct stat64 FS_STAT_TYPE;
#endif
#include <mutex>
#elif AZ_TRAIT_COMPILER_DEFINE_FS_STAT_TYPE
#error cannot request AZ_TRAIT_COMPILER_DEFINE_FS_STAT_TYPE if AZ_TRAIT_COMPILER_DEFINE_FS_ERRNO_TYPE is zero
#endif
#if AZ_TRAIT_COMPILER_DEFINE_SASSERTDATA_TYPE && (!defined(_RELEASE) || defined(_DEBUG))
struct SAssertData
{
int line;
char fileName[256 - sizeof(int)];
const bool operator==(const SAssertData& crArg) const
{
return crArg.line == line && (strcmp(fileName, crArg.fileName) == 0);
}
const bool operator<(const SAssertData& crArg) const
{
if (line == crArg.line)
{
return strcmp(fileName, crArg.fileName) < 0;
}
else
{
return line < crArg.line;
}
}
SAssertData()
: line(-1){}
SAssertData(const int cLine, const char* cpFile)
: line(cLine)
{
azstrcpy(fileName, AZ_ARRAY_SIZE(fileName), cpFile);
}
SAssertData(const SAssertData& crAssertData)
{
memcpy((void*)this, &crAssertData, sizeof(SAssertData));
}
void operator=(const SAssertData& crAssertData)
{
memcpy((void*)this, &crAssertData, sizeof(SAssertData));
}
};
//#define OUTPUT_ASSERT_TO_FILE
void HandleAssert(const char* cpMessage, const char* cpFunc, const char* cpFile, const int cLine)
{
#if defined(OUTPUT_ASSERT_TO_FILE)
static FILE* pAssertLogFile = nullptr;
if (!pAssertLogFile)
{
azfopen(&pAssertLogFile, "Assert.log", "w+");
}
#endif
bool report = true;
static std::set<SAssertData> assertSet;
SAssertData assertData(cLine, cpFile);
if (!g_EnableMultipleAssert)
{
std::set<SAssertData>::const_iterator it = assertSet.find(assertData);
if (it != assertSet.end())
{
report = false;
}
else
{
assertSet.insert(assertData);
}
}
else
{
assertSet.insert(assertData);
}
if (report)
{
//added function to be able to place a breakpoint here or to print out to other consoles
printf("ASSERT: %s in %s (%s : %d)\n", cpMessage, cpFunc, cpFile, cLine);
#if defined(OUTPUT_ASSERT_TO_FILE)
if (pAssertLogFile)
{
fprintf(pAssertLogFile, "ASSERT: %s in %s (%s : %d)\n", cpMessage, cpFunc, cpFile, cLine);
fflush(pAssertLogFile);
}
#endif
}
}
#endif
bool IsBadReadPtr(void* ptr, unsigned int size)
{
//too complicated to really support it
@ -232,9 +124,9 @@ char* strupr (char* str)
char* ltoa (long i, char* a, int radix)
{
if (a == NULL)
if (a == nullptr)
{
return NULL;
return nullptr;
}
strcpy (a, "0");
if (i && radix > 1 && radix < 37)
@ -369,9 +261,9 @@ void _makepath(char* path, const char* drive, const char* dir, const char* filen
char* _ui64toa(unsigned long long value, char* str, int radix)
{
if (str == 0)
if (str == nullptr)
{
return 0;
return nullptr;
}
char buffer[65];
@ -401,7 +293,7 @@ char* _ui64toa(unsigned long long value, char* str, int radix)
long long _atoi64(const char* str)
{
if (str == 0)
if (str == nullptr)
{
return -1;
}
@ -550,22 +442,6 @@ void _splitpath(const char* inpath, char* drv, char* dir, char* fname, char* ext
}
}
//////////////////////////////////////////////////////////////////////////
int memicmp(LPCSTR s1, LPCSTR s2, DWORD len)
{
int ret = 0;
while (len--)
{
if ((ret = tolower(*s1) - tolower(*s2)))
{
break;
}
s1++;
s2++;
}
return ret;
}
//-----------------------------------------other stuff-------------------------------------------------------------------
void GlobalMemoryStatus(LPMEMORYSTATUS lpmem)
@ -697,7 +573,7 @@ static void NormalizeTimeFields(short* FieldToNormalize, short* CarryField, int
*CarryField = (short) (*CarryField + 1);
}
bool TimeFieldsToTime(PTIME_FIELDS tfTimeFields, PLARGE_INTEGER Time)
static bool TimeFieldsToTime(PTIME_FIELDS tfTimeFields, PLARGE_INTEGER Time)
{
#define SECSPERMIN 60
#define MINSPERHOUR 60
@ -775,119 +651,6 @@ BOOL SystemTimeToFileTime(const SYSTEMTIME* syst, LPFILETIME ft)
return TRUE;
}
void adaptFilenameToLinux(AZStd::string& rAdjustedFilename)
{
//first replace all \\ by /
AZStd::string::size_type loc = 0;
while ((loc = rAdjustedFilename.find("\\", loc)) != AZStd::string::npos)
{
rAdjustedFilename.replace(loc, 1, "/");
}
loc = 0;
//remove /./
while ((loc = rAdjustedFilename.find("/./", loc)) != AZStd::string::npos)
{
rAdjustedFilename.replace(loc, 3, "/");
}
}
void replaceDoublePathFilename(char* szFileName)
{
//replace "\.\" by "\"
AZStd::string s(szFileName);
AZStd::string::size_type loc = 0;
//remove /./
while ((loc = s.find("/./", loc)) != AZStd::string::npos)
{
s.replace(loc, 3, "/");
}
loc = 0;
//remove "\.\"
while ((loc = s.find("\\.\\", loc)) != AZStd::string::npos)
{
s.replace(loc, 3, "\\");
}
azstrcpy((char*)szFileName, AZ_MAX_PATH_LEN, s.c_str());
}
#if FIX_FILENAME_CASE
static bool FixOnePathElement(char* path)
{
if (*path == '\0')
{
return true;
}
if ((path[0] == '/') && (path[1] == '\0'))
{
return true; // root dir always exists.
}
if (strchr(path, '*') || strchr(path, '?'))
{
return true; // wildcard...stop correcting path.
}
struct stat statbuf;
if (stat(path, &statbuf) != -1) // current case exists.
{
return true;
}
char* name = path;
char* ptr = strrchr(path, '/');
if (ptr)
{
name = ptr + 1;
*ptr = '\0';
}
if (*name == '\0') // trailing '/' ?
{
*ptr = '/';
return true;
}
const char* parent;
if (ptr == path)
{
parent = "/";
}
else if (ptr == NULL)
{
parent = ".";
}
else
{
parent = path;
}
DIR* dirp = opendir(parent);
if (ptr)
{
*ptr = '/';
}
if (dirp == NULL)
{
return false;
}
struct dirent* dent;
bool found = false;
while ((dent = readdir(dirp)) != NULL)
{
if (strcasecmp(dent->d_name, name) == 0)
{
azstrcpy(name, AZ_MAX_PATH_LEN, dent->d_name);
found = true;
break;
}
}
closedir(dirp);
return found;
}
#endif
#define Int32x32To64(a, b) ((uint64)((uint64)(a)) * (uint64)((uint64)(b)))
//////////////////////////////////////////////////////////////////////////
@ -904,24 +667,14 @@ threadID GetCurrentThreadId()
}
#endif
#include <chrono>
#include <thread>
//////////////////////////////////////////////////////////////////////////
DWORD Sleep(DWORD dwMilliseconds)
{
#if defined(LINUX) || defined(APPLE)
timespec req;
timespec rem;
memset(&req, 0, sizeof(req));
memset(&rem, 0, sizeof(rem));
time_t sec = (int)(dwMilliseconds / 1000);
req.tv_sec = sec;
req.tv_nsec = (dwMilliseconds - (sec * 1000)) * 1000000L;
if (nanosleep(&req, &rem) == -1)
{
nanosleep(&rem, 0);
}
std::this_thread::sleep_for(std::chrono::milliseconds(dwMilliseconds));
return 0;
#define AZ_RESTRICTED_SECTION_IMPLEMENTED
#elif defined(AZ_RESTRICTED_PLATFORM)
@ -960,7 +713,7 @@ DWORD Sleep(DWORD dwMilliseconds)
}
//////////////////////////////////////////////////////////////////////////
DWORD SleepEx(DWORD dwMilliseconds, BOOL bAlertable)
DWORD SleepEx(DWORD dwMilliseconds, BOOL /*bAlertable*/)
{
//TODO: implement
// CRY_ASSERT_MESSAGE(0, "SleepEx not implemented yet");
@ -1006,7 +759,7 @@ void CrySleep(unsigned int dwMilliseconds)
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
int CryMessageBox(const char* lpText, const char* lpCaption, unsigned int uType)
void CryMessageBox(const char* lpText, const char* lpCaption, [[maybe_unused]] unsigned int uType)
{
#ifdef WIN32
# error WIN32 is defined in WinBase.cpp (it is a non-Windows file)
@ -1087,63 +840,8 @@ int CryMessageBox(const char* lpText, const char* lpCaption, unsigned int uType)
CFRelease(strText);
}
if (kResult == kCFUserNotificationDefaultResponse)
{
switch (uType & 0xf)
{
case MB_OK:
case MB_OKCANCEL:
default:
return IDOK;
case MB_ABORTRETRYIGNORE:
return IDABORT;
case MB_YESNOCANCEL:
case MB_YESNO:
return IDYES;
case MB_RETRYCANCEL:
return IDRETRY;
case MB_CANCELTRYCONTINUE:
return IDCANCEL;
}
}
else if (kResult == kCFUserNotificationAlternateResponse)
{
switch (uType & 0xf)
{
case MB_OKCANCEL:
case MB_RETRYCANCEL:
return IDCANCEL;
case MB_ABORTRETRYIGNORE:
return IDRETRY;
case MB_YESNOCANCEL:
case MB_YESNO:
return IDNO;
case MB_CANCELTRYCONTINUE:
return IDTRYAGAIN;
default:
assert(false);
return IDCANCEL;
}
}
else if (kResult == kCFUserNotificationOtherResponse)
{
switch (uType & 0xf)
{
case MB_ABORTRETRYIGNORE:
return IDIGNORE;
case MB_YESNOCANCEL:
return IDCANCEL;
case MB_CANCELTRYCONTINUE:
return IDCONTINUE;
default:
assert(false);
return IDCANCEL;
}
}
return 0;
#else
printf("Messagebox: cap: %s text:%s\n", lpCaption ? lpCaption : " ", lpText ? lpText : " ");
return 0;
#endif
}
@ -1171,21 +869,6 @@ DLL_EXPORT void OutputDebugString(const char* outputString)
// This code does not have a long life span and will be replaced soon
#if defined(APPLE) || defined(LINUX) || defined(DEFINE_LEGACY_CRY_FILE_OPERATIONS)
typedef DIR* FS_DIR_TYPE;
typedef dirent FS_DIRENT_TYPE;
static const FS_ERRNO_TYPE FS_ENOENT = ENOENT;
static const FS_DIR_TYPE FS_DIR_NULL = NULL;
typedef int FS_ERRNO_TYPE;
#if defined(APPLE)
typedef struct stat FS_STAT_TYPE;
#else
typedef struct stat64 FS_STAT_TYPE;
#endif
#include <mutex>
bool CrySetFileAttributes(const char* lpFileName, uint32 dwFileAttributes)
{
//TODO: implement
@ -1194,190 +877,7 @@ bool CrySetFileAttributes(const char* lpFileName, uint32 dwFileAttributes)
}
ILINE void FS_OPEN(const char* szFileName, int iFlags, int& iFileDesc, mode_t uMode, FS_ERRNO_TYPE& rErr)
{
rErr = ((iFileDesc = open(szFileName, iFlags, uMode)) != -1) ? 0 : errno;
}
ILINE void FS_CLOSE(int iFileDesc, FS_ERRNO_TYPE& rErr)
{
rErr = close(iFileDesc) != -1 ? 0 : errno;
}
ILINE void FS_CLOSE_NOERR(int iFileDesc)
{
close(iFileDesc);
}
ILINE void FS_OPENDIR(const char* szDirName, FS_DIR_TYPE& pDir, FS_ERRNO_TYPE& rErr)
{
rErr = (pDir = opendir(szDirName)) != NULL ? 0 : errno;
}
ILINE void FS_READDIR(FS_DIR_TYPE pDir, FS_DIRENT_TYPE& kEnt, uint64_t& uEntSize, FS_ERRNO_TYPE& rErr)
{
errno = 0; // errno is used to determine if readdir succeeds after
FS_DIRENT_TYPE* pDirent(readdir(pDir));
if (pDirent == NULL)
{
uEntSize = 0;
rErr = (errno == FS_ENOENT) ? 0 : errno;
}
else
{
kEnt = *pDirent;
uEntSize = static_cast<uint64_t>(sizeof(FS_DIRENT_TYPE));
rErr = 0;
}
}
ILINE void FS_STAT(const char* szFileName, FS_STAT_TYPE& kStat, FS_ERRNO_TYPE& rErr)
{
#if defined(APPLE)
rErr = stat(szFileName, &kStat) != -1 ? 0 : errno;
#else
rErr = stat64(szFileName, &kStat) != -1 ? 0 : errno;
#endif
}
ILINE void FS_FSTAT(int iFileDesc, FS_STAT_TYPE& kStat, FS_ERRNO_TYPE& rErr)
{
#if defined(APPLE)
rErr = fstat(iFileDesc, &kStat) != -1 ? 0 : errno;
#else
rErr = fstat64(iFileDesc, &kStat) != -1 ? 0 : errno;
#endif
}
ILINE void FS_CLOSEDIR(FS_DIR_TYPE pDir, FS_ERRNO_TYPE& rErr)
{
errno = 0;
rErr = closedir(pDir) == 0 ? 0 : errno;
}
ILINE void FS_CLOSEDIR_NOERR(FS_DIR_TYPE pDir)
{
closedir(pDir);
}
const bool GetFilenameNoCase
(
const char* file,
char* pAdjustedFilename
)
{
assert(file);
assert(pAdjustedFilename);
azstrcpy(pAdjustedFilename, AZ_MAX_PATH_LEN, file);
// Fix the dirname case.
const int cLen = strlen(file);
for (int i = 0; i < cLen; ++i)
{
if (pAdjustedFilename[i] == '\\')
{
pAdjustedFilename[i] = '/';
}
}
if ((pAdjustedFilename) == (char*)-1)
{
return false;
}
#if !defined(LINUX) && !defined(APPLE) && !defined(DEFINE_SKIP_WILDCARD_CHECK) // fix the parent path anyhow.
char* slash = strrchr(pAdjustedFilename, '/');
char* name = pAdjustedFilename;
if (slash)
{
name = slash + 1;
*slash = 0;
}
// Check for wildcards. We'll always return true if the specified filename is
// a wildcard pattern.
if (strchr(name, '*') || strchr(name, '?'))
{
if (slash)
{
*slash = '/';
}
return true;
}
// Scan for the file.
if (slash)
{
*slash = '/';
}
#endif
#if FIX_FILENAME_CASE
char* path = pAdjustedFilename;
char* sep;
while ((sep = strchr(path, '/')) != NULL)
{
*sep = '\0';
const bool exists = FixOnePathElement(pAdjustedFilename);
*sep = '/';
if (!exists)
{
return false;
}
path = sep + 1;
}
if (!FixOnePathElement(pAdjustedFilename)) // catch last filename.
{
return false;
}
#else
for (char* c = pAdjustedFilename; *c; ++c)
{
*c = tolower(*c);
}
#endif
return true;
}
DWORD GetFileAttributes(LPCWSTR lpFileNameW)
{
AZStd::string lpFileName;
AZStd::to_string(lpFileName, lpFileNameW);
struct stat fileStats;
const int success = stat(lpFileName.c_str(), &fileStats);
if (success == -1)
{
char adjustedFilename[MAX_PATH];
GetFilenameNoCase(lpFileName.c_str(), adjustedFilename);
if (stat(adjustedFilename, &fileStats) == -1)
{
return (DWORD)INVALID_FILE_ATTRIBUTES;
}
}
DWORD ret = 0;
const int acc = (fileStats.st_mode & S_IWRITE);
if (acc != 0)
{
if (S_ISDIR(fileStats.st_mode) != 0)
{
ret |= FILE_ATTRIBUTE_DIRECTORY;
}
}
return (ret == 0) ? FILE_ATTRIBUTE_NORMAL : ret;//return file attribute normal as the default value, must only be set if no other attributes have been found
}
__finddata64_t::~__finddata64_t()
{
if (m_Dir != FS_DIR_NULL)
{
FS_CLOSEDIR_NOERR(m_Dir);
m_Dir = FS_DIR_NULL;
}
}
#endif //defined(APPLE) || defined(LINUX)
#endif // AZ_TRAIT_LEGACY_CRYCOMMON_USE_WINDOWS_STUBS

@ -11,9 +11,7 @@ set(FILES
IAudioSystem.h
ICmdLine.h
IConsole.h
IEntityRenderState.h
IFont.h
IFunctorBase.h
IGem.h
IIndexedMesh.h
ILevelSystem.h
@ -30,8 +28,6 @@ set(FILES
ISerialize.h
IShader.h
ISplines.h
IStatObj.h
StatObjBus.h
ISystem.h
ITexture.h
IValidator.h

@ -249,7 +249,7 @@ ILINE DestinationType alias_cast(SourceType pPtr)
// Mostly used only for debugging!
//////////////////////////////////////////////////////////////////////////
void CrySleep(unsigned int dwMilliseconds);
int CryMessageBox(const char* lpText, const char* lpCaption, unsigned int uType);
void CryMessageBox(const char* lpText, const char* lpCaption, unsigned int uType);
//---------------------------------------------------------------------------
// Useful function to clean the structure.

@ -178,21 +178,21 @@ void CrySleep(unsigned int dwMilliseconds)
}
//////////////////////////////////////////////////////////////////////////
int CryMessageBox([[maybe_unused]] const char* lpText, [[maybe_unused]] const char* lpCaption, [[maybe_unused]] unsigned int uType)
void CryMessageBox([[maybe_unused]] const char* lpText, [[maybe_unused]] const char* lpCaption, [[maybe_unused]] unsigned int uType)
{
#ifdef WIN32
ICVar* const pCVar = gEnv && gEnv->pConsole ? gEnv->pConsole->GetCVar("sys_no_crash_dialog") : NULL;
if ((pCVar && pCVar->GetIVal() != 0) || (gEnv && gEnv->bNoAssertDialog))
{
return 0;
return;
}
AZStd::wstring lpTextW;
AZStd::to_wstring(lpTextW, lpText);
AZStd::wstring lpCaptionW;
AZStd::to_wstring(lpCaptionW, lpCaption);
return MessageBoxW(NULL, lpTextW.c_str(), lpCaptionW.c_str(), uType);
MessageBoxW(NULL, lpTextW.c_str(), lpCaptionW.c_str(), uType);
#else
return 0;
return;
#endif
}
@ -281,12 +281,6 @@ int64 CryGetTicks()
return li.QuadPart;
}
int64 CryGetTicksPerSec()
{
LARGE_INTEGER li;
QueryPerformanceFrequency(&li);
return li.QuadPart;
}
#endif

@ -209,20 +209,7 @@ CSystem::CSystem(SharedEnvironmentInstance* pSharedEnvironment)
m_env.pSharedEnvironment = pSharedEnvironment;
//////////////////////////////////////////////////////////////////////////
m_pIFont = NULL;
m_pIFontUi = NULL;
m_rWidth = NULL;
m_rHeight = NULL;
m_rWidthAndHeightAsFractionOfScreenSize = NULL;
m_rMaxWidth = NULL;
m_rMaxHeight = NULL;
m_rColorBits = NULL;
m_rDepthBits = NULL;
m_cvSSInfo = NULL;
m_rStencilBits = NULL;
m_rFullscreen = NULL;
m_sysNoUpdate = NULL;
m_pProcess = NULL;
m_pCmdLine = NULL;
m_pLevelSystem = NULL;
m_pLocalizationManager = NULL;
@ -230,18 +217,9 @@ CSystem::CSystem(SharedEnvironmentInstance* pSharedEnvironment)
#define AZ_RESTRICTED_SECTION SYSTEM_CPP_SECTION_2
#include AZ_RESTRICTED_FILE(System_cpp)
#endif
m_sys_min_step = 0;
m_sys_max_step = 0;
m_cvAIUpdate = NULL;
m_pUserCallback = NULL;
m_sys_memory_debug = NULL;
m_sysWarnings = NULL;
m_sysKeyboard = NULL;
m_sys_firstlaunch = NULL;
m_sys_enable_budgetmonitoring = NULL;
m_sys_preload = NULL;
// m_sys_filecache = NULL;
m_gpu_particle_physics = NULL;
@ -256,22 +234,11 @@ CSystem::CSystem(SharedEnvironmentInstance* pSharedEnvironment)
m_bNoCrashDialog = false;
m_bNoErrorReportWindow = false;
m_pCVarQuit = NULL;
m_bForceNonDevMode = false;
m_bWasInDevMode = false;
m_bInDevMode = false;
m_bGameFolderWritable = false;
m_bDrawConsole = true;
m_bDrawUI = true;
m_nServerConfigSpec = CONFIG_VERYHIGH_SPEC;
m_nMaxConfigSpec = CONFIG_VERYHIGH_SPEC;
m_bPaused = false;
m_bNoUpdate = false;
m_nUpdateCounter = 0;
m_iApplicationInstance = -1;
@ -293,7 +260,6 @@ CSystem::CSystem(SharedEnvironmentInstance* pSharedEnvironment)
m_bHasRenderedErrorMessage = false;
m_pDataProbe = nullptr;
#if AZ_LEGACY_CRYSYSTEM_TRAIT_USE_MESSAGE_HANDLER
RegisterWindowMessageHandler(this);
#endif
@ -339,48 +305,15 @@ void CSystem::Release()
delete this;
}
//////////////////////////////////////////////////////////////////////////
void CSystem::FreeLib(AZStd::unique_ptr<AZ::DynamicModuleHandle>& hLibModule)
{
if (hLibModule)
{
if (hLibModule->IsLoaded())
{
hLibModule->Unload();
}
hLibModule.release();
}
}
//////////////////////////////////////////////////////////////////////////
IRemoteConsole* CSystem::GetIRemoteConsole()
{
return CRemoteConsole::GetInst();
}
//////////////////////////////////////////////////////////////////////////
void CSystem::SetForceNonDevMode(const bool bValue)
{
m_bForceNonDevMode = bValue;
if (bValue)
{
SetDevMode(false);
}
}
//////////////////////////////////////////////////////////////////////////
bool CSystem::GetForceNonDevMode() const
{
return m_bForceNonDevMode;
}
//////////////////////////////////////////////////////////////////////////
void CSystem::SetDevMode(bool bEnable)
{
if (bEnable)
{
m_bWasInDevMode = true;
}
m_bInDevMode = bEnable;
}
@ -464,31 +397,13 @@ void CSystem::ShutDown()
// Release console variables.
SAFE_RELEASE(m_pCVarQuit);
SAFE_RELEASE(m_rWidth);
SAFE_RELEASE(m_rHeight);
SAFE_RELEASE(m_rWidthAndHeightAsFractionOfScreenSize);
SAFE_RELEASE(m_rMaxWidth);
SAFE_RELEASE(m_rMaxHeight);
SAFE_RELEASE(m_rColorBits);
SAFE_RELEASE(m_rDepthBits);
SAFE_RELEASE(m_cvSSInfo);
SAFE_RELEASE(m_rStencilBits);
SAFE_RELEASE(m_rFullscreen);
SAFE_RELEASE(m_sysWarnings);
SAFE_RELEASE(m_sysKeyboard);
SAFE_RELEASE(m_sys_firstlaunch);
SAFE_RELEASE(m_sys_enable_budgetmonitoring);
#if defined(AZ_RESTRICTED_PLATFORM)
#define AZ_RESTRICTED_SECTION SYSTEM_CPP_SECTION_3
#include AZ_RESTRICTED_FILE(System_cpp)
#endif
SAFE_RELEASE(m_sys_min_step);
SAFE_RELEASE(m_sys_max_step);
SAFE_DELETE(m_pLocalizationManager);
delete m_pCmdLine;
@ -556,14 +471,6 @@ bool CSystem::IsQuitting() const
return wasExitMainLoopRequested;
}
//////////////////////////////////////////////////////////////////////////
void CSystem::SetIProcess(IProcess* process)
{
m_pProcess = process;
//if (m_pProcess)
//m_pProcess->SetPMessage("");
}
//////////////////////////////////////////////////////////////////////////
ISystem* CSystem::GetCrySystem()
{
@ -659,7 +566,6 @@ bool CSystem::UpdatePreTickBus(int updateFlags, int nPauseMode)
AZ_TRACE_METHOD();
m_nUpdateCounter++;
#ifndef EXCLUDE_UPDATE_ON_CONSOLE
if (m_pUserCallback)
{
@ -952,13 +858,16 @@ void CSystem::Warning(EValidatorModule module, EValidatorSeverity severity, int
}
//////////////////////////////////////////////////////////////////////////
int CSystem::ShowMessage(const char* text, const char* caption, unsigned int uType)
void CSystem::ShowMessage(const char* text, const char* caption, unsigned int uType)
{
if (m_pUserCallback)
{
return m_pUserCallback->ShowMessage(text, caption, uType);
m_pUserCallback->ShowMessage(text, caption, uType);
}
else
{
CryMessageBox(text, caption, uType);
}
return CryMessageBox(text, caption, uType);
}
inline const char* ValidatorModuleToString(EValidatorModule module)
@ -1035,22 +944,18 @@ void CSystem::WarningV(EValidatorModule module, EValidatorSeverity severity, int
default:
break;
}
char szBuffer[MAX_WARNING_LENGTH];
vsnprintf_s(szBuffer, sizeof(szBuffer), sizeof(szBuffer) - 1, format, args);
AZStd::fixed_string<MAX_WARNING_LENGTH> fmt;
vsnprintf_s(fmt.data(), MAX_WARNING_LENGTH, MAX_WARNING_LENGTH - 1, format, args);
if (file && *file)
{
AZStd::fixed_string<MAX_WARNING_LENGTH> fmt = szBuffer;
fmt += " [File=";
fmt += file;
fmt += "]";
m_env.pLog->LogWithType(ltype, flags | VALIDATOR_FLAG_SKIP_VALIDATOR, "%s", fmt.c_str());
}
else
{
m_env.pLog->LogWithType(ltype, flags | VALIDATOR_FLAG_SKIP_VALIDATOR, "%s", szBuffer);
}
m_env.pLog->LogWithType(ltype, flags | VALIDATOR_FLAG_SKIP_VALIDATOR, "%s", fmt.c_str());
if (bDbgBreak && g_cvars.sys_error_debugbreak)
{
@ -1135,34 +1040,6 @@ ILocalizationManager* CSystem::GetLocalizationManager()
return m_pLocalizationManager;
}
//////////////////////////////////////////////////////////////////////////
void CSystem::debug_GetCallStackRaw(void** callstack, uint32& callstackLength)
{
memset(callstack, 0, sizeof(void*) * callstackLength);
#if !defined(ANDROID)
callstackLength = 0;
#endif
#if AZ_LEGACY_CRYSYSTEM_TRAIT_CAPTURESTACK
uint32 nNumStackFramesToSkip = 1;
uint32 callstackCapacity = callstackLength;
if (callstackCapacity > 0x40)
{
callstackCapacity = 0x40;
}
callstackLength = RtlCaptureStackBackTrace(nNumStackFramesToSkip, callstackCapacity, callstack, NULL);
#elif defined(AZ_RESTRICTED_PLATFORM)
#define AZ_RESTRICTED_SECTION SYSTEM_CPP_SECTION_7
#include AZ_RESTRICTED_FILE(System_cpp)
#endif
if (callstackLength > 0)
{
std::reverse(callstack, callstack + callstackLength);
}
}
//////////////////////////////////////////////////////////////////////////
void CSystem::ExecuteCommandLine(bool deferred)
{
@ -1201,12 +1078,6 @@ void CSystem::ExecuteCommandLine(bool deferred)
//gEnv->pConsole->ExecuteString("sys_RestoreSpec test*"); // to get useful debugging information about current spec settings to the log file
}
//////////////////////////////////////////////////////////////////////////
ESystemConfigSpec CSystem::GetMaxConfigSpec() const
{
return m_nMaxConfigSpec;
}
//////////////////////////////////////////////////////////////////////////
void CSystem::SetConfigPlatform(const ESystemConfigPlatform platform)
{
@ -1401,23 +1272,6 @@ void CSystem::SetSystemGlobalState(const ESystemGlobalState systemGlobalState)
#endif // if AZ_LOADSCREENCOMPONENT_ENABLED
}
//////////////////////////////////////////////////////////////////////////
void* CSystem::GetRootWindowMessageHandler()
{
#if defined(AZ_RESTRICTED_PLATFORM)
#define AZ_RESTRICTED_SECTION SYSTEM_CPP_SECTION_9
#include AZ_RESTRICTED_FILE(System_cpp)
#endif
#if defined(AZ_RESTRICTED_SECTION_IMPLEMENTED)
#undef AZ_RESTRICTED_SECTION_IMPLEMENTED
#elif defined(WIN32)
return reinterpret_cast<void*>(&WndProc);
#else
CRY_ASSERT(false && "This platform does not support window message handlers");
return NULL;
#endif
}
//////////////////////////////////////////////////////////////////////////
void CSystem::RegisterWindowMessageHandler(IWindowMessageHandler* pHandler)
{
@ -1601,11 +1455,6 @@ bool CSystem::HandleMessage([[maybe_unused]] HWND hWnd, UINT uMsg, WPARAM wParam
#endif
std::shared_ptr<AZ::IO::FileIOBase> CSystem::CreateLocalFileIO()
{
return std::make_shared<AZ::IO::LocalFileIO>();
}
ILevelSystem* CSystem::GetILevelSystem()
{
return m_pLevelSystem;

@ -78,9 +78,6 @@ class CWatchdogThread;
#if defined(WIN32)
#define AZ_LEGACY_CRYSYSTEM_TRAIT_USE_MESSAGE_HANDLER 1
#endif
#if defined(WIN64) || defined(WIN32)
#define AZ_LEGACY_CRYSYSTEM_TRAIT_CAPTURESTACK 1
#endif
//////////////////////////////////////////////////////////////////////////
@ -98,30 +95,12 @@ namespace Audio
struct IAudioSystem;
struct IMusicSystem;
} // namespace Audio
struct IDataProbe;
#define PHSYICS_OBJECT_ENTITY 0
#define MAX_STREAMING_POOL_INDEX 6
#define MAX_THREAD_POOL_INDEX 6
struct SSystemCVars
{
int sys_streaming_requests_grouping_time_period;
int sys_streaming_sleep;
int sys_streaming_memory_budget;
int sys_streaming_max_finalize_per_frame;
float sys_streaming_max_bandwidth;
int sys_streaming_cpu;
int sys_streaming_cpu_worker;
int sys_streaming_debug;
int sys_streaming_resetstats;
int sys_streaming_debug_filter;
float sys_streaming_debug_filter_min_time;
int sys_streaming_use_optical_drive_thread;
ICVar* sys_streaming_debug_filter_file_name;
ICVar* sys_localization_folder;
int sys_streaming_in_blocks;
int sys_float_exceptions;
int sys_no_crash_dialog;
@ -129,33 +108,16 @@ struct SSystemCVars
int sys_dump_aux_threads;
int sys_WER;
int sys_dump_type;
int sys_ai;
int sys_entitysystem;
int sys_trackview;
float sys_update_profile_time;
int sys_limit_phys_thread_count;
int sys_MaxFPS;
float sys_maxTimeStepForMovieSystem;
int sys_force_installtohdd_mode;
int sys_report_files_not_found_in_paks = 0;
#ifdef USE_HTTP_WEBSOCKETS
int sys_simple_http_base_port;
#endif
int sys_asserts;
int sys_error_debugbreak;
int sys_FilesystemCaseSensitivity;
AZ::IO::ArchiveVars archiveVars;
#if defined(WIN32)
int sys_display_threads;
#elif defined(AZ_RESTRICTED_PLATFORM)
#define AZ_RESTRICTED_SECTION SYSTEM_H_SECTION_2
#include AZ_RESTRICTED_FILE(System_h)
#endif
};
extern SSystemCVars g_cvars;
@ -239,9 +201,8 @@ public:
//////////////////////////////////////////////////////////////////////////
// retrieves the perlin noise singleton instance
CPNoise3* GetNoiseGen() override;
uint64 GetUpdateCounter() override { return m_nUpdateCounter; };
void DetectGameFolderAccessRights();
void DetectGameFolderAccessRights();
void ExecuteCommandLine(bool deferred=true) override;
@ -256,9 +217,6 @@ public:
void IgnoreUpdates(bool bIgnore) override { m_bIgnoreUpdates = bIgnore; };
void SetIProcess(IProcess* process) override;
IProcess* GetIProcess() override{ return m_pProcess; }
bool IsTestMode() const override { return m_bTestMode; }
//@}
@ -269,7 +227,7 @@ public:
// Validator Warning.
void WarningV(EValidatorModule module, EValidatorSeverity severity, int flags, const char* file, const char* format, va_list args) override;
void Warning(EValidatorModule module, EValidatorSeverity severity, int flags, const char* file, const char* format, ...) override;
int ShowMessage(const char* text, const char* caption, unsigned int uType) override;
void ShowMessage(const char* text, const char* caption, unsigned int uType) override;
bool CheckLogVerbosity(int verbosity) override;
//! Return pointer to user defined callback.
@ -278,7 +236,6 @@ public:
//////////////////////////////////////////////////////////////////////////
void SaveConfiguration() override;
void LoadConfiguration(const char* sFilename, ILoadConfigurationEntrySink* pSink = nullptr, bool warnIfMissing = true) override;
ESystemConfigSpec GetMaxConfigSpec() const override;
ESystemConfigPlatform GetConfigPlatform() const override;
void SetConfigPlatform(ESystemConfigPlatform platform) override;
//////////////////////////////////////////////////////////////////////////
@ -288,9 +245,6 @@ public:
ILocalizationManager* GetLocalizationManager() override;
void debug_GetCallStack(const char** pFunctions, int& nCount) override;
void debug_LogCallStack(int nMaxFuncs = 32, int nFlags = 0) override;
// Get the current callstack in raw address form (more lightweight than the above functions)
// static as memReplay needs it before CSystem has been setup - expose a ISystem interface to this function if you need it outside CrySystem
static void debug_GetCallStackRaw(void** callstack, uint32& callstackLength);
public:
#if !defined(RELEASE)
@ -300,7 +254,6 @@ public:
#if defined(WIN32)
friend LRESULT WINAPI WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
#endif
void* GetRootWindowMessageHandler() override;
void RegisterWindowMessageHandler(IWindowMessageHandler* pHandler) override;
void UnregisterWindowMessageHandler(IWindowMessageHandler* pHandler) override;
@ -330,8 +283,6 @@ private:
void CreateSystemVars();
void CreateAudioVars();
void FreeLib(AZStd::unique_ptr<AZ::DynamicModuleHandle>& hLibModule);
void QueryVersionInfo();
void LogVersion();
void LogBuildInfo();
@ -341,7 +292,6 @@ private:
static void SystemVersionChanged(ICVar* pCVar);
#endif // #ifndef _RELEASE
bool ReLaunchMediaCenter();
void UpdateAudioSystems();
void AddCVarGroupDirectory(const AZStd::string& sPath) override;
@ -357,14 +307,7 @@ public:
void EnableFloatExceptions(int type);
// interface ISystem -------------------------------------------
virtual IDataProbe* GetIDataProbe() { return m_pDataProbe; };
void SetForceNonDevMode(bool bValue) override;
bool GetForceNonDevMode() const override;
bool WasInDevMode() const override { return m_bWasInDevMode; };
bool IsDevMode() const override { return m_bInDevMode && !GetForceNonDevMode(); }
void SetConsoleDrawEnabled(bool enabled) override { m_bDrawConsole = enabled; }
void SetUIDrawEnabled(bool enabled) override { m_bDrawUI = enabled; }
bool IsDevMode() const override { return m_bInDevMode; }
// -------------------------------------------------------------
@ -373,47 +316,30 @@ public:
ICVar* attachVariable (const char* szVarName, int* pContainer, const char* szComment, int dwFlags = 0);
const CTimeValue& GetLastTickTime() const { return m_lastTickTime; }
const ICVar* GetDedicatedMaxRate() const { return m_svDedicatedMaxRate; }
std::shared_ptr<AZ::IO::FileIOBase> CreateLocalFileIO() override;
private: // ------------------------------------------------------
// System environment.
SSystemGlobalEnvironment m_env;
bool m_bInitializedSuccessfully; //!< true if the system completed all initialization steps
bool m_bRelaunch; //!< relaunching the app or not (true beforerelaunch)
int m_iLoadingMode; //!< Game is loading w/o changing context (0 not, 1 quickloading, 2 full loading)
bool m_bTestMode; //!< If running in testing mode.
bool m_bEditor; //!< If running in Editor.
bool m_bNoCrashDialog;
bool m_bNoErrorReportWindow;
bool m_bPreviewMode; //!< If running in Preview mode.
bool m_bDedicatedServer; //!< If running as Dedicated server.
bool m_bIgnoreUpdates; //!< When set to true will ignore Update and Render calls,
bool m_bForceNonDevMode; //!< true when running on a cheat protected server or a client that is connected to it (not used in singlplayer)
bool m_bWasInDevMode; //!< Set to true if was in dev mode.
bool m_bInDevMode; //!< Set to true if was in dev mode.
bool m_bGameFolderWritable;//!< True when verified that current game folder have write access.
int m_ttMemStatSS; //!< Time to memstat screenshot
bool m_bDrawConsole; //!< Set to true if OK to draw the console.
bool m_bDrawUI; //!< Set to true if OK to draw UI.
//! current active process
IProcess* m_pProcess;
bool m_bInitializedSuccessfully; //!< true if the system completed all initialization steps
bool m_bRelaunch; //!< relaunching the app or not (true beforerelaunch)
int m_iLoadingMode; //!< Game is loading w/o changing context (0 not, 1 quickloading, 2 full loading)
bool m_bTestMode; //!< If running in testing mode.
bool m_bEditor; //!< If running in Editor.
bool m_bNoCrashDialog;
bool m_bNoErrorReportWindow;
bool m_bPreviewMode; //!< If running in Preview mode.
bool m_bDedicatedServer; //!< If running as Dedicated server.
bool m_bIgnoreUpdates; //!< When set to true will ignore Update and Render calls,
bool m_bInDevMode; //!< Set to true if was in dev mode.
bool m_bGameFolderWritable; //!< True when verified that current game folder have write access.
CTimeValue m_lastTickTime;
//! system event dispatcher
ISystemEventDispatcher* m_pSystemEventDispatcher;
//! The default mono-spaced font for internal usage (profiling, debug info, etc.)
IFFont* m_pIFont;
//! The default font for end-user UI interfaces
IFFont* m_pIFontUi;
//! System to manage levels.
ILevelSystem* m_pLevelSystem;
@ -432,12 +358,6 @@ private: // ------------------------------------------------------
// System console variables.
//////////////////////////////////////////////////////////////////////////
// DLL names
ICVar* m_sys_dll_response_system;
#if !defined(_RELEASE)
ICVar* m_sys_resource_cache_folder;
#endif
#if AZ_LOADSCREENCOMPONENT_ENABLED
ICVar* m_game_load_screen_uicanvas_path;
ICVar* m_level_load_screen_uicanvas_path;
@ -451,37 +371,9 @@ private: // ------------------------------------------------------
ICVar* m_level_load_screen_minimum_time{};
#endif // if AZ_LOADSCREENCOMPONENT_ENABLED
ICVar* m_sys_initpreloadpacks;
ICVar* m_sys_menupreloadpacks;
ICVar* m_cvAIUpdate;
ICVar* m_rWidth;
ICVar* m_rHeight;
ICVar* m_rWidthAndHeightAsFractionOfScreenSize;
ICVar* m_rTabletWidthAndHeightAsFractionOfScreenSize;
ICVar* m_rHDRDolby;
ICVar* m_rMaxWidth;
ICVar* m_rMaxHeight;
ICVar* m_rColorBits;
ICVar* m_rDepthBits;
ICVar* m_rStencilBits;
ICVar* m_rFullscreen;
ICVar* m_rFullscreenWindow;
ICVar* m_rFullscreenNativeRes;
ICVar* m_rDisplayInfo;
ICVar* m_rOverscanBordersDrawDebugView;
ICVar* m_sysNoUpdate;
ICVar* m_cvEntitySuppressionLevel;
ICVar* m_pCVarQuit;
ICVar* m_cvMemStats;
ICVar* m_cvMemStatsThreshold;
ICVar* m_cvMemStatsMaxDepth;
ICVar* m_sysKeyboard;
ICVar* m_sysWarnings; //!< might be 0, "sys_warnings" - Treat warning as errors.
ICVar* m_cvSSInfo; //!< might be 0, "sys_SSInfo" 0/1 - get file sourcesafe info
ICVar* m_svDedicatedMaxRate;
ICVar* m_sys_firstlaunch;
ICVar* m_sys_asset_processor;
ICVar* m_sys_load_files_to_memory;
#if defined(AZ_RESTRICTED_PLATFORM)
@ -491,13 +383,6 @@ private: // ------------------------------------------------------
ICVar* m_sys_audio_disable;
ICVar* m_sys_min_step;
ICVar* m_sys_max_step;
ICVar* m_sys_enable_budgetmonitoring;
ICVar* m_sys_memory_debug;
ICVar* m_sys_preload;
// ICVar *m_sys_filecache;
ICVar* m_gpu_particle_physics;
AZStd::string m_sSavedRDriver; //!< to restore the driver when quitting the dedicated server
@ -509,28 +394,20 @@ private: // ------------------------------------------------------
SFileVersion m_fileVersion;
SFileVersion m_productVersion;
SFileVersion m_buildVersion;
IDataProbe* m_pDataProbe;
class CLocalizedStringsManager* m_pLocalizationManager;
ESystemConfigSpec m_nServerConfigSpec;
ESystemConfigSpec m_nMaxConfigSpec;
ESystemConfigPlatform m_ConfigPlatform;
// Pause mode.
bool m_bPaused;
bool m_bNoUpdate;
uint64 m_nUpdateCounter;
bool m_executedCommandLine = false;
AZStd::unique_ptr<AzFramework::MissingAssetLogger> m_missingAssetLogger;
public:
ICVar* m_sys_main_CPU;
ICVar* m_sys_streaming_CPU;
ICVar* m_sys_TaskThread_CPU[MAX_THREAD_POOL_INDEX];
//////////////////////////////////////////////////////////////////////////
// File version.

@ -1193,18 +1193,6 @@ void CSystem::CreateSystemVars()
assert(gEnv);
assert(gEnv->pConsole);
// Register DLL names as cvars before we load them
//
EVarFlags dllFlags = (EVarFlags)0;
m_sys_dll_response_system = REGISTER_STRING("sys_dll_response_system", 0, dllFlags, "Specifies the DLL to load for the dynamic response system");
m_sys_initpreloadpacks = REGISTER_STRING("sys_initpreloadpacks", "", 0, "Specifies the paks for an engine initialization");
m_sys_menupreloadpacks = REGISTER_STRING("sys_menupreloadpacks", 0, 0, "Specifies the paks for a main menu loading");
#ifndef _RELEASE
m_sys_resource_cache_folder = REGISTER_STRING("sys_resource_cache_folder", "Editor\\ResourceCache", 0, "Folder for resource compiled locally. Managed by Sandbox.");
#endif
#if AZ_LOADSCREENCOMPONENT_ENABLED
m_game_load_screen_uicanvas_path = REGISTER_STRING("game_load_screen_uicanvas_path", "", 0, "Game load screen UiCanvas path.");
m_level_load_screen_uicanvas_path = REGISTER_STRING("level_load_screen_uicanvas_path", "", 0, "Level load screen UiCanvas path.");
@ -1220,8 +1208,6 @@ void CSystem::CreateSystemVars()
REGISTER_INT("cvDoVerboseWindowTitle", 0, VF_NULL, "");
m_pCVarQuit = REGISTER_INT("ExitOnQuit", 1, VF_NULL, "");
// Register an AZ Console command to quit the engine.
// The command is available even in Release builds.
static AZ::ConsoleFunctor<void, false> s_functorQuit
@ -1242,52 +1228,14 @@ void CSystem::CreateSystemVars()
REGISTER_STRING_CB("sys_version", "", VF_CHEAT, "Override system file/product version", SystemVersionChanged);
#endif // #ifndef _RELEASE
m_cvAIUpdate = REGISTER_INT("ai_NoUpdate", 0, VF_CHEAT, "Disables AI system update when 1");
m_cvMemStats = REGISTER_INT("MemStats", 0, 0,
"0/x=refresh rate in milliseconds\n"
"Use 1000 to switch on and 0 to switch off\n"
"Usage: MemStats [0..]");
m_cvMemStatsThreshold = REGISTER_INT ("MemStatsThreshold", 32000, VF_NULL, "");
m_cvMemStatsMaxDepth = REGISTER_INT("MemStatsMaxDepth", 4, VF_NULL, "");
attachVariable("sys_PakReadSlice", &g_cvars.archiveVars.nReadSlice, "If non-0, means number of kilobytes to use to read files in portions. Should only be used on Win9x kernels");
attachVariable("sys_PakInMemorySizeLimit", &g_cvars.archiveVars.nInMemoryPerPakSizeLimit, "Individual pak size limit for being loaded into memory (MB)");
attachVariable("sys_PakTotalInMemorySizeLimit", &g_cvars.archiveVars.nTotalInMemoryPakSizeLimit, "Total limit (in MB) for all in memory paks");
attachVariable("sys_PakLoadCache", &g_cvars.archiveVars.nLoadCache, "Load in memory paks from _LoadCache folder");
attachVariable("sys_PakLoadModePaks", &g_cvars.archiveVars.nLoadModePaks, "Load mode switching paks from modes folder");
attachVariable("sys_PakStreamCache", &g_cvars.archiveVars.nStreamCache, "Load in memory paks for faster streaming (cgf_cache.pak,dds_cache.pak)");
attachVariable("sys_PakSaveTotalResourceList", &g_cvars.archiveVars.nSaveTotalResourceList, "Save resource list");
attachVariable("sys_PakSaveLevelResourceList", &g_cvars.archiveVars.nSaveLevelResourceList, "Save resource list when loading level");
attachVariable("sys_PakSaveFastLoadResourceList", &g_cvars.archiveVars.nSaveFastloadResourceList, "Save resource list during initial loading");
attachVariable("sys_PakSaveMenuCommonResourceList", &g_cvars.archiveVars.nSaveMenuCommonResourceList, "Save resource list during front end menu flow");
attachVariable("sys_PakMessageInvalidFileAccess", &g_cvars.archiveVars.nMessageInvalidFileAccess, "Message Box synchronous file access when in game");
attachVariable("sys_PakLogInvalidFileAccess", &g_cvars.archiveVars.nLogInvalidFileAccess, "Log synchronous file access when in game");
#ifndef _RELEASE
attachVariable("sys_PakLogAllFileAccess", &g_cvars.archiveVars.nLogAllFileAccess, "Log all file access allowing you to easily see whether a file has been loaded directly, or which pak file.");
#endif
attachVariable("sys_PakValidateFileHash", &g_cvars.archiveVars.nValidateFileHashes, "Validate file hashes in pak files for collisions");
attachVariable("sys_UncachedStreamReads", &g_cvars.archiveVars.nUncachedStreamReads, "Enable stream reads via an uncached file handle");
attachVariable("sys_PakDisableNonLevelRelatedPaks", &g_cvars.archiveVars.nDisableNonLevelRelatedPaks, "Disables all paks that are not required by specific level; This is used with per level splitted assets.");
attachVariable("sys_PakWarnOnPakAccessFailures", &g_cvars.archiveVars.nWarnOnPakAccessFails, "If 1, access failure for Paks is treated as a warning, if zero it is only a log message.");
static const int fileSystemCaseSensitivityDefault = 0;
REGISTER_CVAR2("sys_FilesystemCaseSensitivity", &g_cvars.sys_FilesystemCaseSensitivity, fileSystemCaseSensitivityDefault, VF_NULL,
"0 - CryPak lowercases all input file names\n"
"1 - CryPak preserves file name casing\n"
"Default is 1");
m_sysNoUpdate = REGISTER_INT("sys_noupdate", 0, VF_CHEAT,
"Toggles updating of system with sys_script_debugger.\n"
"Usage: sys_noupdate [0/1]\n"
"Default is 0 (system updates during debug).");
m_sysWarnings = REGISTER_INT("sys_warnings", 0, 0,
"Toggles printing system warnings.\n"
"Usage: sys_warnings [0/1]\n"
"Default is 0 (off).");
#if defined(_RELEASE) && defined(CONSOLE) && !defined(ENABLE_LW_PROFILERS)
enum
{
@ -1299,10 +1247,6 @@ void CSystem::CreateSystemVars()
e_sysKeyboardDefault = 1
};
#endif
m_sysKeyboard = REGISTER_INT("sys_keyboard", e_sysKeyboardDefault, 0,
"Enables keyboard.\n"
"Usage: sys_keyboard [0/1]\n"
"Default is 1 (on).");
m_svDedicatedMaxRate = REGISTER_FLOAT("sv_DedicatedMaxRate", 30.0f, 0,
"Sets the maximum update rate when running as a dedicated server.\n"
@ -1318,55 +1262,14 @@ void CSystem::CreateSystemVars()
"Usage: sv_DedicatedCPUVariance [5..50]\n"
"Default is 10.");
m_cvSSInfo = REGISTER_INT("sys_SSInfo", 0, 0,
"Show SourceSafe information (Name,Comment,Date) for file errors."
"Usage: sys_SSInfo [0/1]\n"
"Default is 0 (off)");
m_cvEntitySuppressionLevel = REGISTER_INT("e_EntitySuppressionLevel", 0, 0,
"Defines the level at which entities are spawned.\n"
"Entities marked with lower level will not be spawned - 0 means no level.\n"
"Usage: e_EntitySuppressionLevel [0-infinity]\n"
"Default is 0 (off)");
m_sys_firstlaunch = REGISTER_INT("sys_firstlaunch", 0, 0,
"Indicates that the game was run for the first time.");
m_sys_main_CPU = REGISTER_INT("sys_main_CPU", 0, 0,
"Specifies the physical CPU index main will run on");
m_sys_TaskThread_CPU[0] = REGISTER_INT("sys_TaskThread0_CPU", 3, 0,
"Specifies the physical CPU index taskthread0 will run on");
m_sys_TaskThread_CPU[1] = REGISTER_INT("sys_TaskThread1_CPU", 5, 0,
"Specifies the physical CPU index taskthread1 will run on");
m_sys_TaskThread_CPU[2] = REGISTER_INT("sys_TaskThread2_CPU", 4, 0,
"Specifies the physical CPU index taskthread2 will run on");
m_sys_TaskThread_CPU[3] = REGISTER_INT("sys_TaskThread3_CPU", 3, 0,
"Specifies the physical CPU index taskthread3 will run on");
m_sys_TaskThread_CPU[4] = REGISTER_INT("sys_TaskThread4_CPU", 2, 0,
"Specifies the physical CPU index taskthread4 will run on");
m_sys_TaskThread_CPU[5] = REGISTER_INT("sys_TaskThread5_CPU", 1, 0,
"Specifies the physical CPU index taskthread5 will run on");
#if defined(AZ_RESTRICTED_PLATFORM)
#define AZ_RESTRICTED_SECTION SYSTEMINIT_CPP_SECTION_12
#include AZ_RESTRICTED_FILE(SystemInit_cpp)
#endif
m_sys_min_step = REGISTER_FLOAT("sys_min_step", 0.01f, 0,
"Specifies the minimum physics step in a separate thread");
m_sys_max_step = REGISTER_FLOAT("sys_max_step", 0.05f, 0,
"Specifies the maximum physics step in a separate thread");
// used in define MEMORY_DEBUG_POINT()
m_sys_memory_debug = REGISTER_INT("sys_memory_debug", 0, VF_CHEAT,
"Enables to activate low memory situation is specific places in the code (argument defines which place), 0=off");
#if defined(AZ_RESTRICTED_PLATFORM)
#define AZ_RESTRICTED_SECTION SYSTEMINIT_CPP_SECTION_17
#include AZ_RESTRICTED_FILE(SystemInit_cpp)
@ -1377,40 +1280,7 @@ void CSystem::CreateSystemVars()
# define SYS_STREAMING_CPU_DEFAULT_VALUE 1
# define SYS_STREAMING_CPU_WORKER_DEFAULT_VALUE 5
#endif
REGISTER_CVAR2("sys_streaming_CPU", &g_cvars.sys_streaming_cpu, SYS_STREAMING_CPU_DEFAULT_VALUE, VF_NULL, "Specifies the physical CPU file IO thread run on");
REGISTER_CVAR2("sys_streaming_CPU_worker", &g_cvars.sys_streaming_cpu_worker, SYS_STREAMING_CPU_WORKER_DEFAULT_VALUE, VF_NULL, "Specifies the physical CPU file IO worker thread/s run on");
REGISTER_CVAR2("sys_streaming_memory_budget", &g_cvars.sys_streaming_memory_budget, 10 * 1024, VF_NULL, "Temp memory streaming system can use in KB");
REGISTER_CVAR2("sys_streaming_max_finalize_per_frame", &g_cvars.sys_streaming_max_finalize_per_frame, 0, VF_NULL,
"Maximum stream finalizing calls per frame to reduce the CPU impact on main thread (0 to disable)");
REGISTER_CVAR2("sys_streaming_max_bandwidth", &g_cvars.sys_streaming_max_bandwidth, 0, VF_NULL, "Enables capping of max streaming bandwidth in MB/s");
REGISTER_CVAR2("sys_streaming_debug", &g_cvars.sys_streaming_debug, 0, VF_NULL, "Enable streaming debug information\n"
"0=off\n"
"1=Streaming Stats\n"
"2=File IO\n"
"3=Request Order\n"
"4=Write to Log\n"
"5=Stats per extension\n"
);
REGISTER_CVAR2("sys_streaming_requests_grouping_time_period", &g_cvars.sys_streaming_requests_grouping_time_period, 2, VF_NULL, // Vlad: 2 works better than 4 visually, should be be re-tested when streaming pak's activated
"Streaming requests are grouped by request time and then sorted by disk offset");
REGISTER_CVAR2("sys_streaming_debug_filter", &g_cvars.sys_streaming_debug_filter, 0, VF_NULL, "Set streaming debug information filter.\n"
"0=all\n"
"1=Texture\n"
"2=Geometry\n"
"3=Terrain\n"
"4=Animation\n"
"5=Music\n"
"6=Sound\n"
"7=Shader\n"
);
g_cvars.sys_streaming_debug_filter_file_name = REGISTER_STRING("sys_streaming_debug_filter_file_name", "", VF_CHEAT,
"Set streaming debug information filter");
REGISTER_CVAR2("sys_streaming_debug_filter_min_time", &g_cvars.sys_streaming_debug_filter_min_time, 0.f, VF_NULL, "Show only slow items.");
REGISTER_CVAR2("sys_streaming_resetstats", &g_cvars.sys_streaming_resetstats, 0, VF_NULL,
"Reset all the streaming stats");
#define DEFAULT_USE_OPTICAL_DRIVE_THREAD (gEnv->IsDedicated() ? 0 : 1)
REGISTER_CVAR2("sys_streaming_use_optical_drive_thread", &g_cvars.sys_streaming_use_optical_drive_thread, DEFAULT_USE_OPTICAL_DRIVE_THREAD, VF_NULL,
"Allow usage of an extra optical drive thread for faster streaming from 2 medias");
const char* localizeFolder = "Localization";
g_cvars.sys_localization_folder = REGISTER_STRING_CB("sys_localization_folder", localizeFolder, VF_NULL,
@ -1420,9 +1290,6 @@ void CSystem::CreateSystemVars()
"Default: Localization\n",
CSystem::OnLocalizationFolderCVarChanged);
REGISTER_CVAR2("sys_streaming_in_blocks", &g_cvars.sys_streaming_in_blocks, 1, VF_NULL,
"Streaming of large files happens in blocks");
#if (defined(WIN32) || defined(WIN64)) && defined(_DEBUG)
REGISTER_CVAR2("sys_float_exceptions", &g_cvars.sys_float_exceptions, 2, 0, "Use or not use floating point exceptions.");
#else // Float exceptions by default disabled for console builds.
@ -1441,11 +1308,6 @@ void CSystem::CreateSystemVars()
REGISTER_CVAR2("sys_WER", &g_cvars.sys_WER, 0, 0, "Enables Windows Error Reporting");
#endif
#ifdef USE_HTTP_WEBSOCKETS
REGISTER_CVAR2("sys_simple_http_base_port", &g_cvars.sys_simple_http_base_port, 1880, VF_REQUIRE_APP_RESTART,
"sets the base port for the simple http server to run on, defaults to 1880");
#endif
const int DEFAULT_DUMP_TYPE = 2;
REGISTER_CVAR2("sys_dump_type", &g_cvars.sys_dump_type, DEFAULT_DUMP_TYPE, VF_NULL,
@ -1457,8 +1319,6 @@ void CSystem::CreateSystemVars()
);
REGISTER_CVAR2("sys_dump_aux_threads", &g_cvars.sys_dump_aux_threads, 1, VF_NULL, "Dumps callstacks of other threads in case of a crash");
REGISTER_CVAR2("sys_limit_phys_thread_count", &g_cvars.sys_limit_phys_thread_count, 1, VF_NULL, "Limits p_num_threads to physical CPU count - 1");
#if (defined(WIN32) || defined(WIN64)) && defined(_RELEASE)
const int DEFAULT_SYS_MAX_FPS = 0;
#else
@ -1470,11 +1330,8 @@ void CSystem::CreateSystemVars()
REGISTER_CVAR2("sys_maxTimeStepForMovieSystem", &g_cvars.sys_maxTimeStepForMovieSystem, 0.1f, VF_NULL, "Caps the time step for the movie system so that a cut-scene won't be jumped in the case of an extreme stall.");
REGISTER_CVAR2("sys_force_installtohdd_mode", &g_cvars.sys_force_installtohdd_mode, 0, VF_NULL, "Forces install to HDD mode even when doing DVD emulation");
REGISTER_CVAR2("sys_report_files_not_found_in_paks", &g_cvars.sys_report_files_not_found_in_paks, 0, VF_NULL, "Reports when files are searched for in paks and not found. 1 = log, 2 = warning, 3 = error");
m_sys_preload = REGISTER_INT("sys_preload", 0, 0, "Preload Game Resources");
REGISTER_COMMAND("sys_crashtest", CmdCrashTest, VF_CHEAT, "Make the game crash\n"
"0=off\n"
"1=null pointer exception\n"
@ -1513,20 +1370,11 @@ void CSystem::CreateSystemVars()
"To speed up loading from non HD media\n"
"0=off / 1=enabled");
*/
REGISTER_CVAR2("sys_AI", &g_cvars.sys_ai, 1, 0, "Enables AI Update");
REGISTER_CVAR2("sys_entities", &g_cvars.sys_entitysystem, 1, 0, "Enables Entities Update");
REGISTER_CVAR2("sys_trackview", &g_cvars.sys_trackview, 1, 0, "Enables TrackView Update");
//Defines selected language.
REGISTER_STRING_CB("g_language", "", VF_NULL, "Defines which language pak is loaded", CSystem::OnLanguageCVarChanged);
#if defined(WIN32)
REGISTER_CVAR2("sys_display_threads", &g_cvars.sys_display_threads, 0, 0, "Displays Thread info");
#elif defined(AZ_RESTRICTED_PLATFORM)
#define AZ_RESTRICTED_SECTION SYSTEMINIT_CPP_SECTION_13
#include AZ_RESTRICTED_FILE(SystemInit_cpp)
#endif
// adding CVAR to toggle assert verbosity level
const int defaultAssertValue = 1;
REGISTER_CVAR2_CB("sys_asserts", &g_cvars.sys_asserts, defaultAssertValue, VF_CHEAT,

@ -383,45 +383,6 @@ void CSystem::debug_LogCallStack(int nMaxFuncs, [[maybe_unused]] int nFlags)
}
}
//////////////////////////////////////////////////////////////////////////
// Support relaunching for windows media center edition.
//////////////////////////////////////////////////////////////////////////
#if defined(WIN32)
#if (_WIN32_WINNT < 0x0501)
#define SM_MEDIACENTER 87
#endif
bool CSystem::ReLaunchMediaCenter()
{
// Skip if not running on a Media Center
if (GetSystemMetrics(SM_MEDIACENTER) == 0)
{
return false;
}
// Get the path to Media Center
wchar_t szExpandedPath[AZ_MAX_PATH_LEN];
if (!ExpandEnvironmentStringsW(L"%SystemRoot%\\ehome\\ehshell.exe", szExpandedPath, AZ_MAX_PATH_LEN))
{
return false;
}
// Skip if ehshell.exe doesn't exist
if (GetFileAttributesW(szExpandedPath) == 0xFFFFFFFF)
{
return false;
}
// Launch ehshell.exe
INT_PTR result = (INT_PTR)ShellExecuteW(NULL, TEXT("open"), szExpandedPath, NULL, NULL, SW_SHOWNORMAL);
return (result > 32);
}
#else
bool CSystem::ReLaunchMediaCenter()
{
return false;
}
#endif //defined(WIN32)
#if (defined(WIN32) || defined(WIN64))
//////////////////////////////////////////////////////////////////////////
bool CSystem::GetWinGameFolder(char* szMyDocumentsPath, int maxPathSize)

@ -11,20 +11,6 @@
#include "Cry_Color.h"
#include "XMLBinaryNode.h"
//////////////////////////////////////////////////////////////////////////
CBinaryXmlData::CBinaryXmlData()
: pNodes(0)
, pAttributes(0)
, pChildIndices(0)
, pStringData(0)
, pFileContents(0)
, nFileSize(0)
, bOwnsFileContentsMemory(true)
, pBinaryNodes(0)
, nRefCount(0)
{
}
//////////////////////////////////////////////////////////////////////////
CBinaryXmlData::~CBinaryXmlData()
{
@ -32,10 +18,10 @@ CBinaryXmlData::~CBinaryXmlData()
{
delete [] pFileContents;
}
pFileContents = 0;
pFileContents = nullptr;
delete [] pBinaryNodes;
pBinaryNodes = 0;
pBinaryNodes = nullptr;
}
//////////////////////////////////////////////////////////////////////////
@ -56,7 +42,7 @@ XmlNodeRef CBinaryXmlNode::getParent() const
XmlNodeRef CBinaryXmlNode::createNode([[maybe_unused]] const char* tag)
{
assert(0);
return 0;
return nullptr;
}
//////////////////////////////////////////////////////////////////////////
@ -93,7 +79,7 @@ bool CBinaryXmlNode::getAttr(const char* key, const char** value) const
bool CBinaryXmlNode::haveAttr(const char* key) const
{
return (GetValue(key) != 0);
return (GetValue(key) != nullptr);
}
//////////////////////////////////////////////////////////////////////////
@ -113,7 +99,7 @@ bool CBinaryXmlNode::getAttr(const char* key, unsigned int& value) const
const char* svalue = GetValue(key);
if (svalue)
{
value = strtoul(svalue, NULL, 10);
value = strtoul(svalue, nullptr, 10);
return true;
}
return false;
@ -290,7 +276,7 @@ XmlNodeRef CBinaryXmlNode::findChild(const char* tag) const
return m_pData->pBinaryNodes + m_pData->pChildIndices[i];
}
}
return 0;
return nullptr;
}
//! Get XML Node child nodes.

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save