Selaa lähdekoodia

feat: remove object manager python reflection and tests

Signed-off-by: Michael Pollind <[email protected]>
Michael Pollind 1 vuosi sitten
vanhempi
commit
d50d0afeee

+ 0 - 8
AutomatedTesting/Gem/PythonTests/EditorPythonBindings/TestSuite_Periodic.py

@@ -107,11 +107,3 @@ class TestAutomation_EditorTools(EditorTestSuite):
 
     class Editor_WaitCommands_Works(EditorBatchedTest):
         from .tests import Editor_WaitCommands_Works as test_module
-
[email protected]_periodic
[email protected]("launcher_platform", ['windows_editor'])
[email protected]("project", ["AutomatedTesting"])
-class TestAutomation_EditorSingleTests:# (EditorTestSuite):
-
-    class Editor_ObjectManagerCommands_Works(EditorSingleTest):
-        from .tests import Editor_ObjectManagerCommands_Works as test_module

+ 0 - 69
AutomatedTesting/Gem/PythonTests/EditorPythonBindings/tests/Editor_ObjectManagerCommands_Works.py

@@ -1,69 +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
-"""
-import os, sys
-sys.path.append(os.path.dirname(__file__))
-from Editor_TestClass import BaseClass
-
-def Editor_ObjectManagerCommands_Works(BaseClass):
-    # Description: 
-    # Tests a portion of the Python API from ObjectManager.cpp while the Editor is running
-
-    @staticmethod
-    def test():
-        import azlmbr.bus as bus
-        import azlmbr.editor as editor
-        import azlmbr.legacy.general as general
-
-        currentLevelName = editor.EditorToolsApplicationRequestBus(bus.Broadcast, 'GetCurrentLevelName')
-        BaseClass.check_result(currentLevelName == 'TestDependenciesLevel', "Not TestDependenciesLevel level")
-    
-        objs_list = general.get_all_objects()
-        BaseClass.check_result(len(objs_list) > 0, "get_all_objects works")
-
-        def fetch_vector3_parts(vec3):
-            x = vec3.get_property('x')
-            y = vec3.get_property('y')
-            z = vec3.get_property('z')
-            return (x, y, z)
-    
-        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)
-        new_position = general.get_position(objs_list[1])
-        px2, py2, pz2 = fetch_vector3_parts(new_position)
-    
-        BaseClass.check_result((px2 > px1) and (py2 < py1) and (pz2 > pz1), "position setter/getter works")
-    
-        rotation = general.get_rotation(objs_list[1])
-        rx1, ry1, rz1 = fetch_vector3_parts(rotation)
-        general.set_rotation(objs_list[1], rx1 + 10, ry1 - 4, rz1 + 3)
-        new_rotation = general.get_rotation(objs_list[1])
-        rx2, ry2, rz2 = fetch_vector3_parts(new_rotation)
-    
-        BaseClass.check_result((rx2 > rx1) and (ry2 < ry1) and (rz2 > rz1), "rotation setter/getter works")
-    
-        scale = general.get_scale(objs_list[1])
-        sx1, sy1, sz1 = fetch_vector3_parts(scale)
-        general.set_scale(objs_list[1], sx1 + 10, sy1 + 4, sz1 + 3)
-        new_scale = general.get_scale(objs_list[1])
-        sx2, sy2, sz2 = fetch_vector3_parts(new_scale)
-    
-        BaseClass.check_result((sx2 > sx1) and (sy2 > sy1) and (sz2 > sz1), "scale setter/getter works")
-    
-        general.delete_object(objs_list[0])
-        new_objs_list = general.get_all_objects()
-    
-        BaseClass.check_result((len(new_objs_list) < len(objs_list)), "delete_object works")
-    
-        general.rename_object(objs_list[1], "some_test_name")
-        new_objs_list = general.get_all_objects()
-    
-        BaseClass.check_result("some_test_name" in new_objs_list, "rename_object works")
-
-if __name__ == "__main__":
-    tester = Editor_ObjectManagerCommands_Works()
-    tester.test_case(tester.test, level="TestDependenciesLevel")

+ 2 - 3
Code/Editor/EditorToolsApplication.cpp

@@ -71,7 +71,6 @@ namespace EditorInternal
         RegisterComponentDescriptor(AzToolsFramework::CryEditDocFuncsHandler::CreateDescriptor());
         RegisterComponentDescriptor(AzToolsFramework::DisplaySettingsPythonFuncsHandler::CreateDescriptor());
         RegisterComponentDescriptor(AzToolsFramework::MainWindowEditorFuncsHandler::CreateDescriptor());
-        RegisterComponentDescriptor(AzToolsFramework::ObjectManagerFuncsHandler::CreateDescriptor());
         RegisterComponentDescriptor(AzToolsFramework::PythonEditorComponent::CreateDescriptor());
         RegisterComponentDescriptor(AzToolsFramework::PythonEditorFuncsHandler::CreateDescriptor());
         RegisterComponentDescriptor(AzToolsFramework::DisplaySettingsComponent::CreateDescriptor());
@@ -124,7 +123,7 @@ namespace EditorInternal
     }
 
     void EditorToolsApplication::QueryApplicationType(AZ::ApplicationTypeQuery& appType) const
-    { 
+    {
         appType.m_maskValue = AZ::ApplicationTypeQuery::Masks::Editor | AZ::ApplicationTypeQuery::Masks::Tool;
     };
 
@@ -212,7 +211,7 @@ namespace EditorInternal
                 return false;
             }
         }
-        
+
         auto previousDocument = GetIEditor()->GetDocument();
         QString previousPathName = (previousDocument != nullptr) ? previousDocument->GetLevelPathName() : "";
         auto newDocument = CCryEditApp::instance()->OpenDocumentFile(levelPath.c_str(), true, COpenSameLevelOptions::ReopenLevelIfSame);

+ 0 - 70
Code/Editor/Lib/Tests/test_ObjectManagerPythonBindings.cpp

@@ -1,70 +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 <AzTest/AzTest.h>
-#include <Util/EditorUtils.h>
-#include <AzCore/base.h>
-#include <AzCore/Memory/SystemAllocator.h>
-#include <AzCore/Debug/TraceMessageBus.h>
-#include <AzToolsFramework/API/ToolsApplicationAPI.h>
-#include <AzCore/UnitTest/TestTypes.h>
-#include <AzCore/UserSettings/UserSettingsComponent.h>
-
-#include <AzToolsFramework/Application/ToolsApplication.h>
-#include <Objects/ObjectManager.h>
-#include <AzCore/RTTI/BehaviorContext.h>
-
-namespace ObjectManagerPythonBindingsUnitTests
-{
-
-    class ObjectManagerPythonBindingsFixture
-        : public ::UnitTest::LeakDetectionFixture
-    {
-    public:
-        AzToolsFramework::ToolsApplication m_app;
-
-        void SetUp() override
-        {
-            AzFramework::Application::Descriptor appDesc;
-            AZ::ComponentApplication::StartupParameters startupParameters;
-            startupParameters.m_loadSettingsRegistry = false;
-            m_app.Start(appDesc, startupParameters);
-            // Without this, the user settings component would attempt to save on finalize/shutdown. Since the file is
-            // shared across the whole engine, if multiple tests are run in parallel, the saving could cause a crash 
-            // in the unit tests.
-            AZ::UserSettingsComponentRequestBus::Broadcast(&AZ::UserSettingsComponentRequests::DisableSaveOnFinalize);
-            m_app.RegisterComponentDescriptor(AzToolsFramework::ObjectManagerFuncsHandler::CreateDescriptor());
-        }
-
-        void TearDown() override
-        {
-            m_app.Stop();
-        }
-    };
-
-    TEST_F(ObjectManagerPythonBindingsFixture, ObjectManagerEditorCommands_ApiExists)
-    {
-        AZ::BehaviorContext* behaviorContext = m_app.GetBehaviorContext();
-        ASSERT_TRUE(behaviorContext);
-
-        EXPECT_TRUE(behaviorContext->m_methods.find("get_all_objects") != behaviorContext->m_methods.end());
-
-        EXPECT_TRUE(behaviorContext->m_methods.find("delete_object") != behaviorContext->m_methods.end());
-
-        EXPECT_TRUE(behaviorContext->m_methods.find("get_position") != behaviorContext->m_methods.end());
-        EXPECT_TRUE(behaviorContext->m_methods.find("set_position") != behaviorContext->m_methods.end());
-
-        EXPECT_TRUE(behaviorContext->m_methods.find("get_rotation") != behaviorContext->m_methods.end());
-        EXPECT_TRUE(behaviorContext->m_methods.find("set_rotation") != behaviorContext->m_methods.end());
-
-        EXPECT_TRUE(behaviorContext->m_methods.find("get_scale") != behaviorContext->m_methods.end());
-        EXPECT_TRUE(behaviorContext->m_methods.find("set_scale") != behaviorContext->m_methods.end());
-
-        EXPECT_TRUE(behaviorContext->m_methods.find("rename_object") != behaviorContext->m_methods.end());
-    }
-}

+ 0 - 158
Code/Editor/Objects/ObjectManager.cpp

@@ -790,161 +790,3 @@ void CObjectManager::GatherUsedResources(CUsedResources& resources)
     }
 }
 
-//////////////////////////////////////////////////////////////////////////
-namespace
-{
-    AZStd::vector<AZStd::string> PyGetAllObjects()
-    {
-        IObjectManager* pObjMgr = GetIEditor()->GetObjectManager();
-        CBaseObjectsArray objects;
-        pObjMgr->GetObjects(objects);
-        int count = pObjMgr->GetObjectCount();
-        AZStd::vector<AZStd::string> result;
-        for (int i = 0; i < count; ++i)
-        {
-            result.push_back(objects[i]->GetName().toUtf8().data());
-        }
-
-        return result;
-    }
-
-    void PyDeleteObject(const char* objName)
-    {
-        CUndo undo("Delete Object");
-
-        CBaseObject* pObject = GetIEditor()->GetObjectManager()->FindObject(objName);
-        if (pObject)
-        {
-            GetIEditor()->GetObjectManager()->DeleteObject(pObject);
-        }
-    }
-
-    int PyClearSelection()
-    {
-        int numSel = 0;
-        AzToolsFramework::ToolsApplicationRequestBus::BroadcastResult(
-            numSel, &AzToolsFramework::ToolsApplicationRequests::GetSelectedEntitiesCount);
-
-        AzToolsFramework::ToolsApplicationRequestBus::Broadcast(
-            &AzToolsFramework::ToolsApplicationRequests::SetSelectedEntities, AzToolsFramework::EntityIdList());
-
-        return numSel;
-    }
-
-    AZ::Vector3 PyGetObjectPosition(const char* pName)
-    {
-        CBaseObject* pObject = GetIEditor()->GetObjectManager()->FindObject(pName);
-        if (!pObject)
-        {
-            throw std::logic_error((QString("\"") + pName + "\" is an invalid object.").toUtf8().data());
-        }
-        Vec3 position = pObject->GetPos();
-        return AZ::Vector3(position.x, position.y, position.z);
-    }
-
-    void PySetObjectPosition(const char* pName, float fValueX, float fValueY, float fValueZ)
-    {
-        CBaseObject* pObject = GetIEditor()->GetObjectManager()->FindObject(pName);
-        if (!pObject)
-        {
-            throw std::logic_error((QString("\"") + pName + "\" is an invalid object.").toUtf8().data());
-        }
-        CUndo undo("Set Object Base Position");
-        pObject->SetPos(Vec3(fValueX, fValueY, fValueZ));
-    }
-
-    AZ::Vector3 PyGetObjectRotation(const char* pName)
-    {
-        CBaseObject* pObject = GetIEditor()->GetObjectManager()->FindObject(pName);
-        if (!pObject)
-        {
-            throw std::logic_error((QString("\"") + pName + "\" is an invalid object.").toUtf8().data());
-        }
-        Ang3 ang = RAD2DEG(Ang3(pObject->GetRotation()));
-        return AZ::Vector3(ang.x, ang.y, ang.z);
-    }
-
-    void PySetObjectRotation(const char* pName, float fValueX, float fValueY, float fValueZ)
-    {
-        CBaseObject* pObject = GetIEditor()->GetObjectManager()->FindObject(pName);
-        if (!pObject)
-        {
-            throw std::logic_error((QString("\"") + pName + "\" is an invalid object.").toUtf8().data());
-        }
-        CUndo undo("Set Object Rotation");
-        pObject->SetRotation(Quat(DEG2RAD(Ang3(fValueX, fValueY, fValueZ))));
-    }
-
-    AZ::Vector3 PyGetObjectScale(const char* pName)
-    {
-        CBaseObject* pObject = GetIEditor()->GetObjectManager()->FindObject(pName);
-        if (!pObject)
-        {
-            throw std::logic_error((QString("\"") + pName + "\" is an invalid object.").toUtf8().data());
-        }
-        Vec3 scaleVec3 = pObject->GetScale();
-        return AZ::Vector3(scaleVec3.x, scaleVec3.y, scaleVec3.z);
-    }
-
-    void PySetObjectScale(const char* pName, float fValueX, float fValueY, float fValueZ)
-    {
-        CBaseObject* pObject = GetIEditor()->GetObjectManager()->FindObject(pName);
-        if (!pObject)
-        {
-            throw std::logic_error((QString("\"") + pName + "\" is an invalid object.").toUtf8().data());
-        }
-        CUndo undo("Set Object Scale");
-        pObject->SetScale(Vec3(fValueX, fValueY, fValueZ));
-    }
-
-    void PyRenameObject(const char* pOldName, const char* pNewName)
-    {
-        CBaseObject* pObject = GetIEditor()->GetObjectManager()->FindObject(pOldName);
-        if (!pObject)
-        {
-            throw std::runtime_error("Could not find object");
-        }
-
-        if (strcmp(pNewName, "") == 0 || GetIEditor()->GetObjectManager()->FindObject(pNewName))
-        {
-            throw std::runtime_error("Invalid object name.");
-        }
-
-        CUndo undo("Rename object");
-        pObject->SetName(pNewName);
-    }
-}
-
-namespace AzToolsFramework
-{
-    void ObjectManagerFuncsHandler::Reflect(AZ::ReflectContext* context)
-    {
-        if (auto behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
-        {
-            // this will put these methods into the 'azlmbr.legacy.general' module
-            auto addLegacyGeneral = [](AZ::BehaviorContext::GlobalMethodBuilder methodBuilder)
-            {
-                methodBuilder->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation)
-                    ->Attribute(AZ::Script::Attributes::Category, "Legacy/Editor")
-                    ->Attribute(AZ::Script::Attributes::Module, "legacy.general");
-            };
-            addLegacyGeneral(behaviorContext->Method("get_all_objects", PyGetAllObjects, nullptr, "Gets the list of names of all objects in the whole level."));
-
-            addLegacyGeneral(behaviorContext->Method("clear_selection", PyClearSelection, nullptr, "Clears selection."));
-            addLegacyGeneral(behaviorContext->Method("delete_object", PyDeleteObject, nullptr, "Deletes a specified object."));
-
-            addLegacyGeneral(behaviorContext->Method("get_position", PyGetObjectPosition, nullptr, "Gets the position of an object."));
-            addLegacyGeneral(behaviorContext->Method("set_position", PySetObjectPosition, nullptr, "Sets the position of an object."));
-
-            addLegacyGeneral(behaviorContext->Method("get_rotation", PyGetObjectRotation, nullptr, "Gets the rotation of an object."));
-            addLegacyGeneral(behaviorContext->Method("set_rotation", PySetObjectRotation, nullptr, "Sets the rotation of an object."));
-
-            addLegacyGeneral(behaviorContext->Method("get_scale", PyGetObjectScale, nullptr, "Gets the scale of an object."));
-            addLegacyGeneral(behaviorContext->Method("set_scale", PySetObjectScale, nullptr, "Sets the scale of an object."));
-
-            addLegacyGeneral(behaviorContext->Method("rename_object", PyRenameObject, nullptr, "Renames object with oldObjectName to newObjectName."));
-
-
-        }
-    }
-} // namespace AzToolsFramework

+ 0 - 1
Code/Editor/editor_lib_test_files.cmake

@@ -14,7 +14,6 @@ set(FILES
     Lib/Tests/test_EditorUtils.cpp
     Lib/Tests/test_Main.cpp
     Lib/Tests/test_MainWindowPythonBindings.cpp
-    Lib/Tests/test_ObjectManagerPythonBindings.cpp
     Lib/Tests/test_TrackViewPythonBindings.cpp
     Lib/Tests/test_ViewPanePythonBindings.cpp
     Lib/Tests/test_ViewportTitleDlgPythonBindings.cpp