BsCmdUtility.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsEditorPrerequisites.h"
  5. namespace BansheeEngine
  6. {
  7. /** @addtogroup UndoRedo
  8. * @{
  9. */
  10. /** Contains various utility methods and structures used by EditorCommand%s. */
  11. class CmdUtility
  12. {
  13. public:
  14. /**
  15. * Contains stored information about stored scene object instance data, including all of its children and
  16. * components.
  17. *
  18. * @note
  19. * When object is serialized it will receive new instance data (as if it was a new object). But we want to restore
  20. * the original object completely (including any references other objects might have to it) so we need store the
  21. * instance data.
  22. */
  23. struct SceneObjProxy
  24. {
  25. GameObjectInstanceDataPtr instanceData;
  26. Vector<GameObjectInstanceDataPtr> componentInstanceData;
  27. Vector<SceneObjProxy> children;
  28. };
  29. /**
  30. * Parses the scene object hierarchy and components and generates a hierarchy of instance data required to restore
  31. * the object identities.
  32. */
  33. static SceneObjProxy createProxy(const HSceneObject& sceneObject);
  34. /**
  35. * Restores original object instance data from the provided scene object proxy that was previously generated using
  36. * createProxy().
  37. *
  38. * @param[in] restored New instance of the object.
  39. * @param[in] proxy Proxy data containing the original object instance data we want to restore.
  40. */
  41. static void restoreIds(const HSceneObject& restored, SceneObjProxy& proxy);
  42. };
  43. /** @} */
  44. }