BsCmdReparentSO.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #pragma once
  2. #include "BsEditorPrerequisites.h"
  3. #include "BsEditorCommand.h"
  4. #include "BsUndoRedo.h"
  5. namespace BansheeEngine
  6. {
  7. /**
  8. * @brief A command used for undo/redo purposes. It records a scene object
  9. * parent change operations. It allows you to apply the parent change
  10. * or revert the object to its original parent as needed.
  11. */
  12. class CmdReparentSO : public EditorCommand
  13. {
  14. public:
  15. /**
  16. * @brief Creates and executes the command on the provided scene object.
  17. * Automatically registers the command with undo/redo system.
  18. *
  19. * @param sceneObjects Object(s) to change the parent for.
  20. * @param newParent New parent for the provided objects.
  21. * @param description Optional description of what exactly the command does.
  22. */
  23. static void execute(const Vector<HSceneObject>& sceneObjects, const HSceneObject& newParent,
  24. const WString& description = StringUtil::WBLANK);
  25. /**
  26. * @copydoc EditorCommand::commit
  27. */
  28. void commit() override;
  29. /**
  30. * @copydoc EditorCommand::revert
  31. */
  32. void revert() override;
  33. private:
  34. friend class UndoRedo;
  35. CmdReparentSO(const WString& description, const Vector<HSceneObject>& sceneObjects, const HSceneObject& newParent);
  36. Vector<HSceneObject> mSceneObjects;
  37. Vector<HSceneObject> mOldParents;
  38. HSceneObject mNewParent;
  39. };
  40. }