56904d1799
* 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>
156 lines
5.4 KiB
C++
156 lines
5.4 KiB
C++
/*
|
|
* 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 : The game engine for editor
|
|
#pragma once
|
|
|
|
#if !defined(Q_MOC_RUN)
|
|
#include <AzCore/Outcome/Outcome.h>
|
|
#include "LogFile.h"
|
|
#include "Util/ModalWindowDismisser.h"
|
|
#endif
|
|
|
|
class CStartupLogoDialog;
|
|
struct IInitializeUIInfo;
|
|
|
|
#include <AzCore/Interface/Interface.h>
|
|
#include <AzCore/Math/Vector3.h>
|
|
|
|
#include <AzCore/Module/DynamicModuleHandle.h>
|
|
|
|
class ThreadedOnErrorHandler : public QObject
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit ThreadedOnErrorHandler(ISystemUserCallback* callback);
|
|
~ThreadedOnErrorHandler();
|
|
|
|
public slots:
|
|
bool OnError(const char* error);
|
|
|
|
private:
|
|
ISystemUserCallback* m_userCallback;
|
|
};
|
|
|
|
AZ_PUSH_DISABLE_DLL_EXPORT_BASECLASS_WARNING
|
|
//! This class serves as a high-level wrapper for CryEngine game.
|
|
class SANDBOX_API CGameEngine
|
|
: public IEditorNotifyListener
|
|
{
|
|
AZ_POP_DISABLE_DLL_EXPORT_BASECLASS_WARNING
|
|
public:
|
|
CGameEngine();
|
|
~CGameEngine(void);
|
|
//! Initialize System.
|
|
//! @return successful outcome if initialization succeeded. or failed outcome with error message.
|
|
AZ::Outcome<void, AZStd::string> Init(
|
|
bool bPreviewMode,
|
|
bool bTestMode,
|
|
const char* sCmdLine,
|
|
IInitializeUIInfo* logo,
|
|
HWND hwndForInputSystem);
|
|
//! Initialize game.
|
|
//! @return true if initialization succeeded, false otherwise
|
|
bool InitGame(const char* sGameDLL);
|
|
//! Load new terrain level into 3d engine.
|
|
//! Also load AI triangulation for this level.
|
|
bool LoadLevel(
|
|
bool bDeleteAIGraph,
|
|
bool bReleaseResources);
|
|
//!* Reload level if it was already loaded.
|
|
bool ReloadLevel();
|
|
//! Request to switch In/Out of game mode on next update.
|
|
//! The switch will happen when no sub systems are currently being updated.
|
|
//! @param inGame When true editor switch to game mode.
|
|
void RequestSetGameMode(bool inGame);
|
|
//! Switch In/Out of AI and Physics simulation mode.
|
|
//! @param enabled When true editor switch to simulation mode.
|
|
void SetSimulationMode(bool enabled, bool bOnlyPhysics = false);
|
|
//! Get current simulation mode.
|
|
bool GetSimulationMode() const { return m_bSimulationMode; };
|
|
//! Returns true if level is loaded.
|
|
bool IsLevelLoaded() const { return m_bLevelLoaded; };
|
|
//! Assign new level path name.
|
|
void SetLevelPath(const QString& path);
|
|
//! Return name of currently loaded level.
|
|
const QString& GetLevelName() const { return m_levelName; };
|
|
//! Return extension of currently loaded level.
|
|
const QString& GetLevelExtension() const { return m_levelExtension; };
|
|
//! Get fully specified level path.
|
|
const QString& GetLevelPath() const { return m_levelPath; };
|
|
//! Query if engine is in game mode.
|
|
bool IsInGameMode() const { return m_bInGameMode; };
|
|
//! Force level loaded variable to true.
|
|
void SetLevelLoaded(bool bLoaded) { m_bLevelLoaded = bLoaded; }
|
|
//! Force level just created variable to true.
|
|
void SetLevelCreated(bool bJustCreated) { m_bJustCreated = bJustCreated; }
|
|
//! Query ISystem interface.
|
|
ISystem* GetSystem() { return m_pISystem; };
|
|
//! Set player position in game.
|
|
//! @param bEyePos If set then given position is position of player eyes.
|
|
void SetPlayerViewMatrix(const Matrix34& tm, bool bEyePos = true);
|
|
//! When set, player in game will be every frame synchronized with editor camera.
|
|
void SyncPlayerPosition(bool bEnable);
|
|
bool IsSyncPlayerPosition() const { return m_bSyncPlayerPosition; };
|
|
//! Set game's current Mod name.
|
|
void SetCurrentMOD(const char* sMod);
|
|
//! Returns game's current Mod name.
|
|
QString GetCurrentMOD() const;
|
|
//! Called every frame.
|
|
void Update();
|
|
virtual void OnEditorNotifyEvent(EEditorNotifyEvent event);
|
|
void OnTerrainModified(const Vec2& modPosition, float modAreaRadius, bool fullTerrain);
|
|
void OnAreaModified(const AABB& modifiedArea);
|
|
|
|
void ExecuteQueuedEvents();
|
|
|
|
//! mutex used by other threads to lock up the PAK modification,
|
|
//! so only one thread can modify the PAK at once
|
|
static AZStd::recursive_mutex& GetPakModifyMutex()
|
|
{
|
|
//! mutex used to halt copy process while the export to game
|
|
//! or other pak operation is done in the main thread
|
|
static AZStd::recursive_mutex s_pakModifyMutex;
|
|
return s_pakModifyMutex;
|
|
}
|
|
|
|
private:
|
|
void SetGameMode(bool inGame);
|
|
void SwitchToInGame();
|
|
void SwitchToInEditor();
|
|
static void HandleQuitRequest(IConsoleCmdArgs*);
|
|
|
|
CLogFile m_logFile;
|
|
QString m_levelName;
|
|
QString m_levelExtension;
|
|
QString m_levelPath;
|
|
QString m_MOD;
|
|
bool m_bLevelLoaded;
|
|
bool m_bInGameMode;
|
|
bool m_bSimulationMode;
|
|
bool m_bSyncPlayerPosition;
|
|
bool m_bJustCreated;
|
|
bool m_bIgnoreUpdates;
|
|
ISystem* m_pISystem;
|
|
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
|
Matrix34 m_playerViewTM;
|
|
struct SSystemUserCallback* m_pSystemUserCallback;
|
|
AZStd::unique_ptr<AZ::DynamicModuleHandle> m_hSystemHandle;
|
|
enum EPendingGameMode
|
|
{
|
|
ePGM_NotPending,
|
|
ePGM_SwitchToInGame,
|
|
ePGM_SwitchToInEditor,
|
|
};
|
|
EPendingGameMode m_ePendingGameMode;
|
|
AZStd::unique_ptr<class ModalWindowDismisser> m_modalWindowDismisser;
|
|
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
|
};
|
|
|