| 123456789101112131415161718192021222324252627282930313233343536373839 |
- //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
- //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
- #include "UndoRedo/BsCmdCreateSO.h"
- #include "Scene/BsSceneObject.h"
- namespace bs
- {
- CmdCreateSO::CmdCreateSO(const String& description, const String& name, UINT32 flags)
- :EditorCommand(description), mName(name), mFlags(flags)
- { }
- HSceneObject CmdCreateSO::execute(const String& name, UINT32 flags, const String& description)
- {
- // Register command and commit it
- CmdCreateSO* command = new (bs_alloc<CmdCreateSO>()) CmdCreateSO(description, name, flags);
- SPtr<CmdCreateSO> commandPtr = bs_shared_ptr(command);
- UndoRedo::instance().registerCommand(commandPtr);
- commandPtr->commit();
- return commandPtr->mSceneObject;
- }
- void CmdCreateSO::commit()
- {
- mSceneObject = SceneObject::create(mName, mFlags);
- }
- void CmdCreateSO::revert()
- {
- if (mSceneObject == nullptr)
- return;
- if (!mSceneObject.isDestroyed())
- mSceneObject->destroy(true);
- mSceneObject = nullptr;
- }
- }
|