diff --git a/Code/Sandbox/Editor/GameExporter.cpp b/Code/Sandbox/Editor/GameExporter.cpp index 9039fca70d..8a93dbedce 100644 --- a/Code/Sandbox/Editor/GameExporter.cpp +++ b/Code/Sandbox/Editor/GameExporter.cpp @@ -33,7 +33,6 @@ #include "Util/CryMemFile.h" #include "Objects/ObjectManager.h" -#include "Objects/ObjectPhysicsManager.h" #include "Objects/EntityObject.h" #include "LensFlareEditor/LensFlareManager.h" #include "LensFlareEditor/LensFlareLibrary.h" @@ -192,14 +191,6 @@ bool CGameExporter::Export(unsigned int flags, [[maybe_unused]] EEndian eExportE } } - //////////////////////////////////////////////////////////////////////// - // Inform all objects that an export is about to begin - //////////////////////////////////////////////////////////////////////// - if (exportSuccessful) - { - GetIEditor()->GetObjectManager()->GetPhysicsManager()->PrepareForExport(); - } - //////////////////////////////////////////////////////////////////////// // Export all data to the game //////////////////////////////////////////////////////////////////////// @@ -519,8 +510,6 @@ void CGameExporter::ExportMapInfo(XmlNodeRef& node) CXmlArchive xmlAr; xmlAr.bLoading = false; xmlAr.root = node; - - GetIEditor()->GetObjectManager()->GetPhysicsManager()->SerializeCollisionClasses(xmlAr); } ////////////////////////////////////////////////////////////////////////// diff --git a/Code/Sandbox/Editor/Include/IObjectManager.h b/Code/Sandbox/Editor/Include/IObjectManager.h index bf1bb97db9..c1c09cf753 100644 --- a/Code/Sandbox/Editor/Include/IObjectManager.h +++ b/Code/Sandbox/Editor/Include/IObjectManager.h @@ -24,7 +24,6 @@ class CUsedResources; class CSelectionGroup; class CObjectClassDesc; class CObjectArchive; -class CObjectPhysicsManager; class CViewport; struct HitContext; enum class ImageRotationDegrees; @@ -247,10 +246,6 @@ public: virtual IGizmoManager* GetGizmoManager() = 0; - ////////////////////////////////////////////////////////////////////////// - //! Get acess to object physics manager - virtual CObjectPhysicsManager* GetPhysicsManager() = 0; - ////////////////////////////////////////////////////////////////////////// //! Invalidate visibily settings of objects. virtual void InvalidateVisibleList() = 0; diff --git a/Code/Sandbox/Editor/Objects/ObjectManager.cpp b/Code/Sandbox/Editor/Objects/ObjectManager.cpp index 96d015e2c1..f3f33996da 100644 --- a/Code/Sandbox/Editor/Objects/ObjectManager.cpp +++ b/Code/Sandbox/Editor/Objects/ObjectManager.cpp @@ -25,7 +25,6 @@ #include "Viewport.h" #include "GizmoManager.h" #include "AxisGizmo.h" -#include "ObjectPhysicsManager.h" #include "GameEngine.h" #include "WaitProgress.h" #include "Util/Image.h" @@ -109,7 +108,6 @@ CObjectManager::CObjectManager() , m_pLoadProgress(nullptr) , m_loadedObjects(0) , m_totalObjectsToLoad(0) - , m_pPhysicsManager(new CObjectPhysicsManager()) , m_bExiting(false) , m_isUpdateVisibilityList(false) , m_currentHideCount(CBaseObject::s_invalidHiddenID) @@ -138,7 +136,6 @@ CObjectManager::~CObjectManager() DeleteAllObjects(); delete m_gizmoManager; - delete m_pPhysicsManager; } ////////////////////////////////////////////////////////////////////////// @@ -841,8 +838,6 @@ void CObjectManager::Update() { prevActiveWindow->setFocus(); } - - m_pPhysicsManager->Update(); } ////////////////////////////////////////////////////////////////////////// diff --git a/Code/Sandbox/Editor/Objects/ObjectManager.h b/Code/Sandbox/Editor/Objects/ObjectManager.h index f13616451e..26905c47cd 100644 --- a/Code/Sandbox/Editor/Objects/ObjectManager.h +++ b/Code/Sandbox/Editor/Objects/ObjectManager.h @@ -334,9 +334,6 @@ public: virtual void FindAndRenameProperty2(const char* property2Name, const QString& oldValue, const QString& newValue); virtual void FindAndRenameProperty2If(const char* property2Name, const QString& oldValue, const QString& newValue, const char* otherProperty2Name, const QString& otherValue); - class CObjectPhysicsManager* GetPhysicsManager() - { return m_pPhysicsManager; } - bool IsReloading() const { return m_bInReloading; } void SetSkipUpdate(bool bSkipUpdate) override { m_bSkipObjectUpdate = bSkipUpdate; } @@ -433,8 +430,6 @@ private: int m_totalObjectsToLoad; ////////////////////////////////////////////////////////////////////////// - class CObjectPhysicsManager* m_pPhysicsManager; - ////////////////////////////////////////////////////////////////////////// // Numbering for names. ////////////////////////////////////////////////////////////////////////// diff --git a/Code/Sandbox/Editor/Objects/ObjectPhysicsManager.cpp b/Code/Sandbox/Editor/Objects/ObjectPhysicsManager.cpp deleted file mode 100644 index c3886ad7e8..0000000000 --- a/Code/Sandbox/Editor/Objects/ObjectPhysicsManager.cpp +++ /dev/null @@ -1,191 +0,0 @@ -/* -* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -* its licensors. -* -* For complete copyright and license terms please see the LICENSE at the root of this -* distribution (the "License"). All use of this software is governed by the License, -* or, if provided, by the license below or the license accompanying this file. Do not -* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -#include "EditorDefs.h" - -#include "ObjectPhysicsManager.h" - -// Editor -#include "GameEngine.h" -#include "Commands/CommandManager.h" -#include "Objects/SelectionGroup.h" -#include "Include/IObjectManager.h" - -#include "CryPhysicsDeprecation.h" - -#define MAX_OBJECTS_PHYS_SIMULATION_TIME (5) - -////////////////////////////////////////////////////////////////////////// -CObjectPhysicsManager::CObjectPhysicsManager() -{ - CommandManagerHelper::RegisterCommand(GetIEditor()->GetCommandManager(), - "physics", "simulate_objects", "", "", - AZStd::bind(&CObjectPhysicsManager::Command_SimulateObjects, this)); - CommandManagerHelper::RegisterCommand(GetIEditor()->GetCommandManager(), - "physics", "reset_objects_state", "", "", - AZStd::bind(&CObjectPhysicsManager::Command_ResetPhysicsState, this)); - CommandManagerHelper::RegisterCommand(GetIEditor()->GetCommandManager(), - "physics", "get_objects_state", "", "", - AZStd::bind(&CObjectPhysicsManager::Command_GetPhysicsState, this)); - - m_fStartObjectSimulationTime = 0; - m_bSimulatingObjects = false; - m_wasSimObjects = 0; -} - -////////////////////////////////////////////////////////////////////////// -CObjectPhysicsManager::~CObjectPhysicsManager() -{ - -} - -////////////////////////////////////////////////////////////////////////// -void CObjectPhysicsManager::Command_SimulateObjects() -{ - SimulateSelectedObjectsPositions(); -} - -///////////////////////////////////////////////////////////////////////// -void CObjectPhysicsManager::Command_ResetPhysicsState() -{ - CSelectionGroup* pSelection = GetIEditor()->GetSelection(); - for (int i = 0; i < pSelection->GetCount(); i++) - { - pSelection->GetObject(i)->OnEvent(EVENT_PHYSICS_RESETSTATE); - } -} - -///////////////////////////////////////////////////////////////////////// -void CObjectPhysicsManager::Command_GetPhysicsState() -{ - CSelectionGroup* pSelection = GetIEditor()->GetSelection(); - for (int i = 0; i < pSelection->GetCount(); i++) - { - pSelection->GetObject(i)->OnEvent(EVENT_PHYSICS_GETSTATE); - } -} - -////////////////////////////////////////////////////////////////////////// -void CObjectPhysicsManager::Update() -{ - if (m_bSimulatingObjects) - { - UpdateSimulatingObjects(); - } -} - -////////////////////////////////////////////////////////////////////////// -void CObjectPhysicsManager::SimulateSelectedObjectsPositions() -{ - CSelectionGroup* pSel = GetIEditor()->GetObjectManager()->GetSelection(); - if (pSel->IsEmpty()) - { - return; - } - - if (GetIEditor()->GetGameEngine()->GetSimulationMode()) - { - return; - } - - GetIEditor()->GetGameEngine()->SetSimulationMode(true, true); - - m_simObjects.clear(); - CRY_PHYSICS_REPLACEMENT_ASSERT(); - m_wasSimObjects = m_simObjects.size(); - - m_fStartObjectSimulationTime = GetISystem()->GetITimer()->GetAsyncCurTime(); - m_bSimulatingObjects = true; -} - -////////////////////////////////////////////////////////////////////////// -void CObjectPhysicsManager::UpdateSimulatingObjects() -{ - { - CUndo undo("Simulate"); - CRY_PHYSICS_REPLACEMENT_ASSERT(); - } - - float curTime = GetISystem()->GetITimer()->GetAsyncCurTime(); - float runningTime = (curTime - m_fStartObjectSimulationTime); - - if (m_simObjects.empty() || (runningTime > MAX_OBJECTS_PHYS_SIMULATION_TIME)) - { - m_fStartObjectSimulationTime = 0; - m_bSimulatingObjects = false; - GetIEditor()->GetGameEngine()->SetSimulationMode(false, true); - } -} - -////////////////////////////////////////////////////////////////////////// -void CObjectPhysicsManager::PrepareForExport() -{ - // Clear the collision class set, ready for objects to register - // their collision classes - m_collisionClasses.clear(); - m_collisionClassExportId = 0; - // First collision-class IS always the default one - RegisterCollisionClass(SCollisionClass(0, 0)); -} - -////////////////////////////////////////////////////////////////////////// -bool operator == (const SCollisionClass& lhs, const SCollisionClass& rhs) -{ - return lhs.type == rhs.type && lhs.ignore == rhs.ignore; -} - -////////////////////////////////////////////////////////////////////////// -int CObjectPhysicsManager::RegisterCollisionClass(const SCollisionClass& collclass) -{ - TCollisionClassVector::iterator it = std::find(m_collisionClasses.begin(), m_collisionClasses.end(), collclass); - if (it == m_collisionClasses.end()) - { - m_collisionClasses.push_back(collclass); - return m_collisionClasses.size() - 1; - } - return it - m_collisionClasses.begin(); -} - -////////////////////////////////////////////////////////////////////////// -int CObjectPhysicsManager::GetCollisionClassId(const SCollisionClass& collclass) -{ - TCollisionClassVector::iterator it = std::find(m_collisionClasses.begin(), m_collisionClasses.end(), collclass); - if (it == m_collisionClasses.end()) - { - return 0; - } - return it - m_collisionClasses.begin(); -} - -////////////////////////////////////////////////////////////////////////// -void CObjectPhysicsManager::SerializeCollisionClasses(CXmlArchive& xmlAr) -{ - if (!xmlAr.bLoading) - { - // Storing - CLogFile::WriteLine("Storing Collision Classes ..."); - - XmlNodeRef root = xmlAr.root->newChild("CollisionClasses"); - int count = m_collisionClasses.size(); - for (int i = 0; i < count; i++) - { - SCollisionClass& cc = m_collisionClasses[i]; - XmlNodeRef xmlCC = root->newChild("CollisionClass"); - xmlCC->setAttr("type", cc.type); - xmlCC->setAttr("ignore", cc.ignore); - } - } -} - - - diff --git a/Code/Sandbox/Editor/Objects/ObjectPhysicsManager.h b/Code/Sandbox/Editor/Objects/ObjectPhysicsManager.h deleted file mode 100644 index 7711d93208..0000000000 --- a/Code/Sandbox/Editor/Objects/ObjectPhysicsManager.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -* its licensors. -* -* For complete copyright and license terms please see the LICENSE at the root of this -* distribution (the "License"). All use of this software is governed by the License, -* or, if provided, by the license below or the license accompanying this file. Do not -* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -#ifndef CRYINCLUDE_EDITOR_OBJECTS_OBJECTPHYSICSMANAGER_H -#define CRYINCLUDE_EDITOR_OBJECTS_OBJECTPHYSICSMANAGER_H -#pragma once - - -////////////////////////////////////////////////////////////////////////// -class CObjectPhysicsManager -{ -public: - CObjectPhysicsManager(); - ~CObjectPhysicsManager(); - - void SimulateSelectedObjectsPositions(); - void Update(); - - ////////////////////////////////////////////////////////////////////////// - /// Collision Classes - ////////////////////////////////////////////////////////////////////////// - int RegisterCollisionClass(const SCollisionClass& collclass); - int GetCollisionClassId(const SCollisionClass& collclass); - void SerializeCollisionClasses(CXmlArchive& xmlAr); - - void PrepareForExport(); - -private: - void Command_SimulateObjects(); - void Command_GetPhysicsState(); - void Command_ResetPhysicsState(); - - void UpdateSimulatingObjects(); - - bool m_bSimulatingObjects; - float m_fStartObjectSimulationTime; - int m_wasSimObjects; - std::vector<_smart_ptr > m_simObjects; - - typedef std::vector TCollisionClassVector; - int m_collisionClassExportId; - TCollisionClassVector m_collisionClasses; -}; - - -#endif // CRYINCLUDE_EDITOR_OBJECTS_OBJECTPHYSICSMANAGER_H diff --git a/Code/Sandbox/Editor/editor_lib_files.cmake b/Code/Sandbox/Editor/editor_lib_files.cmake index 4adf501d45..ffbc37170d 100644 --- a/Code/Sandbox/Editor/editor_lib_files.cmake +++ b/Code/Sandbox/Editor/editor_lib_files.cmake @@ -638,8 +638,6 @@ set(FILES Objects/ObjectManager.h Objects/ObjectManagerLegacyUndo.cpp Objects/ObjectManagerLegacyUndo.h - Objects/ObjectPhysicsManager.cpp - Objects/ObjectPhysicsManager.h Objects/DisplayContext.cpp Objects/DisplayContext.h Objects/EntityObject.cpp