//********************************** Banshee Engine (www.banshee3d.com) **************************************************// //**************** Copyright (c) 2016 Marko Pintera (marko.pintera@gmail.com). All rights reserved. **********************// #pragma once #include "BsEditorPrerequisites.h" #include "UndoRedo/BsEditorCommand.h" #include "UndoRedo/BsUndoRedo.h" namespace bs { /** @addtogroup UndoRedo * @{ */ /** * A command used for undo/redo purposes. It records a scene object parent change operations. It allows you to apply * the parent change or revert the object to its original parent as needed. */ class BS_ED_EXPORT CmdReparentSO final : public EditorCommand { public: /** * Creates and executes the command on the provided scene object(s). Automatically registers the command with * undo/redo system. * * @param[in] sceneObjects Object(s) to change the parent for. * @param[in] newParent New parent for the provided objects. * @param[in] description Optional description of what exactly the command does. */ static void execute(const Vector& sceneObjects, const HSceneObject& newParent, const String& description = StringUtil::BLANK); /** * Creates and executes the command on the provided scene object. Automatically registers the command with * undo/redo system. * * @param[in] sceneObject Object to change the parent for. * @param[in] newParent New parent for the provided objects. * @param[in] description Optional description of what exactly the command does. */ static void execute(HSceneObject& sceneObject, const HSceneObject& newParent, const String& description = StringUtil::BLANK); /** @copydoc EditorCommand::commit */ void commit() override; /** @copydoc EditorCommand::revert */ void revert() override; private: friend class UndoRedo; CmdReparentSO(const String& description, const Vector& sceneObjects, const HSceneObject& newParent); Vector mSceneObjects; Vector mOldParents; HSceneObject mNewParent; }; /** @} */ }