diff --git a/src/Editor/CharacterEditor/CCharacterEditor.cpp b/src/Editor/CharacterEditor/CCharacterEditor.cpp index a4c7f0ff..57d4e981 100644 --- a/src/Editor/CharacterEditor/CCharacterEditor.cpp +++ b/src/Editor/CharacterEditor/CCharacterEditor.cpp @@ -7,25 +7,19 @@ #include #include -const CVector3f CCharacterEditor::skDefaultOrbitTarget = CVector3f(0,0,1); -const float CCharacterEditor::skDefaultOrbitDistance = 4.f; +constexpr CVector3f skDefaultOrbitTarget{0, 0, 1}; +constexpr float skDefaultOrbitDistance = 4.f; CCharacterEditor::CCharacterEditor(CAnimSet *pSet, QWidget *parent) : IEditor(parent) - , ui(new Ui::CCharacterEditor) - , mpScene(new CScene()) - , mpSelectedBone(nullptr) - , mBindPose(false) - , mPlayAnim(true) - , mLoopAnim(true) - , mAnimTime(0.f) - , mPlaybackSpeed(1.f) + , ui(std::make_unique()) + , mpScene(std::make_unique()) { ui->setupUi(this); REPLACE_WINDOWTITLE_APPVARS; - mpCharNode = new CCharacterNode(mpScene, -1); - ui->Viewport->SetNode(mpCharNode); + mpCharNode = std::make_unique(mpScene.get(), UINT32_MAX); + ui->Viewport->SetNode(mpCharNode.get()); CCamera& rCamera = ui->Viewport->Camera(); rCamera.SetMoveSpeed(0.5f); @@ -77,12 +71,7 @@ CCharacterEditor::CCharacterEditor(CAnimSet *pSet, QWidget *parent) SetActiveAnimSet(pSet); } -CCharacterEditor::~CCharacterEditor() -{ - delete ui; - delete mpScene; - delete mpCharNode; -} +CCharacterEditor::~CCharacterEditor() = default; void CCharacterEditor::EditorTick(float DeltaTime) { diff --git a/src/Editor/CharacterEditor/CCharacterEditor.h b/src/Editor/CharacterEditor/CCharacterEditor.h index 05045979..aeb0993f 100644 --- a/src/Editor/CharacterEditor/CCharacterEditor.h +++ b/src/Editor/CharacterEditor/CCharacterEditor.h @@ -11,6 +11,8 @@ #include #include +#include + namespace Ui { class CCharacterEditor; } @@ -19,32 +21,28 @@ class CCharacterEditor : public IEditor { Q_OBJECT - Ui::CCharacterEditor *ui; - CScene *mpScene; - CCharacterNode *mpCharNode; - CBone *mpSelectedBone; + std::unique_ptr ui; + std::unique_ptr mpScene; + std::unique_ptr mpCharNode; + CBone *mpSelectedBone = nullptr; CSkeletonHierarchyModel mSkeletonModel; - QComboBox *mpCharComboBox; - QComboBox *mpAnimComboBox; + QComboBox *mpCharComboBox = nullptr; + QComboBox *mpAnimComboBox = nullptr; TResPtr mpSet; - uint32 mCurrentChar; - uint32 mCurrentAnim; - bool mBindPose; + uint32 mCurrentChar = 0; + uint32 mCurrentAnim = 0; + bool mBindPose = false; // Playback Controls - bool mPlayAnim; - bool mLoopAnim; - float mAnimTime; - float mPlaybackSpeed; - - // Constants - static const CVector3f skDefaultOrbitTarget; - static const float skDefaultOrbitDistance; + bool mPlayAnim = true; + bool mLoopAnim = true; + float mAnimTime = 0.0f; + float mPlaybackSpeed = 1.0f; public: - explicit CCharacterEditor(CAnimSet *pSet, QWidget *parent = 0); + explicit CCharacterEditor(CAnimSet *pSet, QWidget *parent = nullptr); ~CCharacterEditor(); void EditorTick(float DeltaTime); void UpdateAnimTime(float DeltaTime);