[LYN-3079] Removed IPickObjectCallback and edit tools that used it.
This commit is contained in:
@@ -1,142 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#include "EditorDefs.h"
|
||||
|
||||
#include "AlignTool.h"
|
||||
|
||||
// Editor
|
||||
#include "Objects/BaseObject.h"
|
||||
#include "Objects/SelectionGroup.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CAlignPickCallback::m_bActive = false;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//! Called when object picked.
|
||||
void CAlignPickCallback::OnPick(CBaseObject* picked)
|
||||
{
|
||||
Matrix34 pickedTM(picked->GetWorldTM());
|
||||
|
||||
AABB pickedAABB;
|
||||
picked->GetBoundBox(pickedAABB);
|
||||
pickedAABB.Move(-pickedTM.GetTranslation());
|
||||
Vec3 pickedPivot = pickedAABB.GetCenter();
|
||||
|
||||
AABB pickedLocalAABB;
|
||||
picked->GetLocalBounds(pickedLocalAABB);
|
||||
|
||||
const Quat& pickedRot = picked->GetRotation();
|
||||
const Vec3& pickedScale = picked->GetScale();
|
||||
const Vec3& pickedPos = picked->GetPos();
|
||||
|
||||
bool bKeepScale = CheckVirtualKey(Qt::Key_Shift);
|
||||
bool bKeepRotation = CheckVirtualKey(Qt::Key_Alt);
|
||||
bool bAlignToBoundBox = CheckVirtualKey(Qt::Key_Control);
|
||||
bool bApplyTransform = !bKeepScale && !bKeepRotation && !bAlignToBoundBox;
|
||||
|
||||
{
|
||||
bool bUndo = !CUndo::IsRecording();
|
||||
if (bUndo)
|
||||
{
|
||||
GetIEditor()->BeginUndo();
|
||||
}
|
||||
|
||||
CSelectionGroup* selGroup = GetIEditor()->GetSelection();
|
||||
selGroup->FilterParents();
|
||||
|
||||
for (int i = 0; i < selGroup->GetFilteredCount(); i++)
|
||||
{
|
||||
CBaseObject* pMovedObj = selGroup->GetFilteredObject(i);
|
||||
|
||||
if (bKeepScale || bKeepRotation || bApplyTransform)
|
||||
{
|
||||
if (bKeepScale && bKeepRotation) // Keep scale and rotation of a moved object
|
||||
{
|
||||
pMovedObj->SetWorldTM(Matrix34::Create(pMovedObj->GetScale(), pMovedObj->GetRotation(), pickedPos), eObjectUpdateFlags_UserInput);
|
||||
}
|
||||
else if (bKeepScale) // Keep only scale of a moved object
|
||||
{
|
||||
pMovedObj->SetWorldTM(Matrix34::Create(pMovedObj->GetScale(), pickedRot, pickedPos), eObjectUpdateFlags_UserInput);
|
||||
}
|
||||
else if (bKeepRotation) // Keep only rotation of a moved object
|
||||
{
|
||||
pMovedObj->SetWorldTM(Matrix34::Create(pickedScale, pMovedObj->GetRotation(), pickedPos), eObjectUpdateFlags_UserInput);
|
||||
}
|
||||
else // Scale, Rotation and Position of a picked object are applied to a moved object.
|
||||
{
|
||||
pMovedObj->SetWorldTM(pickedTM, eObjectUpdateFlags_UserInput);
|
||||
}
|
||||
}
|
||||
else if (bAlignToBoundBox) // align to the bounding box.
|
||||
{
|
||||
if (pickedLocalAABB.GetVolume() == 0.0f)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
AABB movedLocalAABB;
|
||||
pMovedObj->GetLocalBounds(movedLocalAABB);
|
||||
if (fabs(movedLocalAABB.max.x - movedLocalAABB.min.x) < VEC_EPSILON &&
|
||||
fabs(movedLocalAABB.max.y - movedLocalAABB.min.y) < VEC_EPSILON &&
|
||||
fabs(movedLocalAABB.max.z - movedLocalAABB.min.z) < VEC_EPSILON)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const Vec3& movedScale(pMovedObj->GetScale());
|
||||
Matrix34 movedScaleTM = Matrix34::CreateScale(movedScale);
|
||||
AABB movedLocalScaledAABB;
|
||||
movedLocalScaledAABB.min = movedScaleTM.TransformVector(movedLocalAABB.min);
|
||||
movedLocalScaledAABB.max = movedScaleTM.TransformVector(movedLocalAABB.max);
|
||||
|
||||
float fMovedWidth = movedLocalScaledAABB.max.x - movedLocalScaledAABB.min.x;
|
||||
float fMovedHeight = movedLocalScaledAABB.max.z - movedLocalScaledAABB.min.z;
|
||||
float fMovedLength = movedLocalScaledAABB.max.y - movedLocalScaledAABB.min.y;
|
||||
|
||||
Matrix34 pickedScaleTM = Matrix34::CreateScale(picked->GetScale());
|
||||
AABB pickedLocalScaledAABB;
|
||||
pickedLocalScaledAABB.min = pickedScaleTM.TransformVector(pickedLocalAABB.min);
|
||||
pickedLocalScaledAABB.max = pickedScaleTM.TransformVector(pickedLocalAABB.max);
|
||||
float fScaledPickedtWidth = pickedLocalScaledAABB.max.x - pickedLocalScaledAABB.min.x;
|
||||
float fScaledPickedHeight = pickedLocalScaledAABB.max.z - pickedLocalScaledAABB.min.z;
|
||||
float fScaledPickedLength = pickedLocalScaledAABB.max.y - pickedLocalScaledAABB.min.y;
|
||||
|
||||
Vec3 scale((fScaledPickedtWidth / fMovedWidth) * movedScale.x, (fScaledPickedLength / fMovedLength) * movedScale.y, (fScaledPickedHeight / fMovedHeight) * movedScale.z);
|
||||
Matrix34 scaleRotTM = Matrix34::Create(scale, pickedRot, Vec3(0, 0, 0));
|
||||
Vec3 movedPivot = scaleRotTM.TransformVector(movedLocalAABB.GetCenter());
|
||||
|
||||
pMovedObj->SetWorldTM(Matrix34::Create(scale, pickedRot, Vec3(pickedPos + (pickedPivot - movedPivot))), eObjectUpdateFlags_UserInput);
|
||||
}
|
||||
}
|
||||
m_bActive = false;
|
||||
if (bUndo)
|
||||
{
|
||||
GetIEditor()->AcceptUndo("Align To Object");
|
||||
}
|
||||
}
|
||||
delete this;
|
||||
}
|
||||
|
||||
//! Called when pick mode cancelled.
|
||||
void CAlignPickCallback::OnCancelPick()
|
||||
{
|
||||
m_bActive = false;
|
||||
delete this;
|
||||
}
|
||||
|
||||
//! Return true if specified object is pickable.
|
||||
bool CAlignPickCallback::OnPickFilter([[maybe_unused]] CBaseObject* filterObject)
|
||||
{
|
||||
return true;
|
||||
};
|
||||
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_ALIGNTOOL_H
|
||||
#define CRYINCLUDE_EDITOR_ALIGNTOOL_H
|
||||
|
||||
#pragma once
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
class CAlignPickCallback
|
||||
: public IPickObjectCallback
|
||||
{
|
||||
public:
|
||||
CAlignPickCallback() { m_bActive = true; };
|
||||
//! Called when object picked.
|
||||
virtual void OnPick(CBaseObject* picked);
|
||||
//! Called when pick mode cancelled.
|
||||
virtual void OnCancelPick();
|
||||
//! Return true if specified object is pickable.
|
||||
virtual bool OnPickFilter(CBaseObject* filterObject);
|
||||
|
||||
static bool IsActive() { return m_bActive; }
|
||||
|
||||
virtual bool IsNeedSpecificBehaviorForSpaceAcce() { return true; }
|
||||
private:
|
||||
static bool m_bActive;
|
||||
};
|
||||
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_ALIGNTOOL_H
|
||||
@@ -580,7 +580,6 @@ void LevelEditorMenuHandler::PopulateEditMenu(ActionManager::MenuWrapper& editMe
|
||||
|
||||
auto alignMenu = modifyMenu.AddMenu(tr("Align"));
|
||||
alignMenu.AddAction(ID_OBJECTMODIFY_ALIGNTOGRID);
|
||||
alignMenu.AddAction(ID_OBJECTMODIFY_ALIGN);
|
||||
alignMenu.AddAction(ID_MODIFY_ALIGNOBJTOSURF);
|
||||
|
||||
auto constrainMenu = modifyMenu.AddMenu(tr("Constrain"));
|
||||
|
||||
@@ -95,8 +95,6 @@ AZ_POP_DISABLE_WARNING
|
||||
|
||||
#include "Core/QtEditorApplication.h"
|
||||
#include "StringDlg.h"
|
||||
#include "LinkTool.h"
|
||||
#include "AlignTool.h"
|
||||
#include "VoxelAligningTool.h"
|
||||
#include "NewLevelDialog.h"
|
||||
#include "GridSettingsDialog.h"
|
||||
@@ -400,8 +398,6 @@ void CCryEditApp::RegisterActionHandlers()
|
||||
ON_COMMAND(ID_EDITMODE_MOVE, OnEditmodeMove)
|
||||
ON_COMMAND(ID_EDITMODE_ROTATE, OnEditmodeRotate)
|
||||
ON_COMMAND(ID_EDITMODE_SCALE, OnEditmodeScale)
|
||||
ON_COMMAND(ID_EDITTOOL_LINK, OnEditToolLink)
|
||||
ON_COMMAND(ID_EDITTOOL_UNLINK, OnEditToolUnlink)
|
||||
ON_COMMAND(ID_EDITMODE_SELECT, OnEditmodeSelect)
|
||||
ON_COMMAND(ID_EDIT_ESCAPE, OnEditEscape)
|
||||
ON_COMMAND(ID_OBJECTMODIFY_SETAREA, OnObjectSetArea)
|
||||
@@ -421,7 +417,6 @@ void CCryEditApp::RegisterActionHandlers()
|
||||
ON_COMMAND(ID_SELECTION_SAVE, OnSelectionSave)
|
||||
ON_COMMAND(ID_IMPORT_ASSET, OnOpenAssetImporter)
|
||||
ON_COMMAND(ID_SELECTION_LOAD, OnSelectionLoad)
|
||||
ON_COMMAND(ID_OBJECTMODIFY_ALIGN, OnAlignObject)
|
||||
ON_COMMAND(ID_MODIFY_ALIGNOBJTOSURF, OnAlignToVoxel)
|
||||
ON_COMMAND(ID_OBJECTMODIFY_ALIGNTOGRID, OnAlignToGrid)
|
||||
ON_COMMAND(ID_LOCK_SELECTION, OnLockSelection)
|
||||
@@ -2896,51 +2891,6 @@ void CCryEditApp::OnEditmodeScale()
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CCryEditApp::OnEditToolLink()
|
||||
{
|
||||
// TODO: Add your command handler code here
|
||||
if (qobject_cast<CLinkTool*>(GetIEditor()->GetEditTool()))
|
||||
{
|
||||
GetIEditor()->SetEditTool(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
GetIEditor()->SetEditTool(new CLinkTool());
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CCryEditApp::OnUpdateEditToolLink(QAction* action)
|
||||
{
|
||||
if (!GetIEditor()->GetDocument())
|
||||
{
|
||||
action->setEnabled(false);
|
||||
return;
|
||||
}
|
||||
action->setEnabled(GetIEditor()->GetDocument()->IsDocumentReady());
|
||||
CEditTool* pEditTool = GetIEditor()->GetEditTool();
|
||||
action->setChecked(qobject_cast<CLinkTool*>(pEditTool) != nullptr);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CCryEditApp::OnEditToolUnlink()
|
||||
{
|
||||
CUndo undo("Unlink Object(s)");
|
||||
CSelectionGroup* pSelection = GetIEditor()->GetObjectManager()->GetSelection();
|
||||
for (int i = 0; i < pSelection->GetCount(); i++)
|
||||
{
|
||||
CBaseObject* pBaseObj = pSelection->GetObject(i);
|
||||
pBaseObj->DetachThis();
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CCryEditApp::OnUpdateEditToolUnlink(QAction* action)
|
||||
{
|
||||
action->setEnabled(false);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CCryEditApp::OnEditmodeSelect()
|
||||
{
|
||||
@@ -3510,14 +3460,6 @@ void CCryEditApp::OnUpdateSelected(QAction* action)
|
||||
action->setEnabled(!GetIEditor()->GetSelection()->IsEmpty());
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CCryEditApp::OnAlignObject()
|
||||
{
|
||||
// Align pick callback will release itself.
|
||||
CAlignPickCallback* alignCallback = new CAlignPickCallback;
|
||||
GetIEditor()->PickObject(alignCallback, 0, "Align to Object");
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CCryEditApp::OnAlignToGrid()
|
||||
{
|
||||
@@ -3538,15 +3480,6 @@ void CCryEditApp::OnAlignToGrid()
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CCryEditApp::OnUpdateAlignObject(QAction* action)
|
||||
{
|
||||
Q_ASSERT(action->isCheckable());
|
||||
action->setChecked(CAlignPickCallback::IsActive());
|
||||
|
||||
action->setEnabled(!GetIEditor()->GetSelection()->IsEmpty());
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CCryEditApp::OnAlignToVoxel()
|
||||
{
|
||||
|
||||
@@ -224,10 +224,6 @@ public:
|
||||
void OnEditmodeMove();
|
||||
void OnEditmodeRotate();
|
||||
void OnEditmodeScale();
|
||||
void OnEditToolLink();
|
||||
void OnUpdateEditToolLink(QAction* action);
|
||||
void OnEditToolUnlink();
|
||||
void OnUpdateEditToolUnlink(QAction* action);
|
||||
void OnEditmodeSelect();
|
||||
void OnEditEscape();
|
||||
void OnObjectSetArea();
|
||||
@@ -256,10 +252,8 @@ public:
|
||||
void OnOpenAssetImporter();
|
||||
void OnSelectionLoad();
|
||||
void OnUpdateSelected(QAction* action);
|
||||
void OnAlignObject();
|
||||
void OnAlignToVoxel();
|
||||
void OnAlignToGrid();
|
||||
void OnUpdateAlignObject(QAction* action);
|
||||
void OnUpdateAlignToVoxel(QAction* action);
|
||||
void OnLockSelection();
|
||||
void OnEditLevelData();
|
||||
|
||||
@@ -391,21 +391,6 @@ enum EModifiedModule
|
||||
eModifiedAll = -1
|
||||
};
|
||||
|
||||
//! Callback class passed to PickObject.
|
||||
struct IPickObjectCallback
|
||||
{
|
||||
virtual ~IPickObjectCallback() = default;
|
||||
|
||||
//! Called when object picked.
|
||||
virtual void OnPick(CBaseObject* picked) = 0;
|
||||
//! Called when pick mode cancelled.
|
||||
virtual void OnCancelPick() = 0;
|
||||
//! Return true if specified object is pickable.
|
||||
virtual bool OnPickFilter([[maybe_unused]] CBaseObject* filterObject) { return true; };
|
||||
//! If need a specific behavior when holding space, return true or if not, return false.
|
||||
virtual bool IsNeedSpecificBehaviorForSpaceAcce() { return false; }
|
||||
};
|
||||
|
||||
//! Class provided by editor for various registration functions.
|
||||
struct CRegistrationContext
|
||||
{
|
||||
@@ -570,20 +555,6 @@ struct IEditor
|
||||
//! Get access to object manager.
|
||||
virtual struct IObjectManager* GetObjectManager() = 0;
|
||||
virtual CSettingsManager* GetSettingsManager() = 0;
|
||||
//! Set pick object mode.
|
||||
//! When object picked callback will be called, with OnPick
|
||||
//! If pick operation is canceled Cancel will be called
|
||||
//! @param targetClass specifies objects of which class are supposed to be picked
|
||||
//! @param bMultipick if true pick tool will pick multiple object
|
||||
virtual void PickObject(
|
||||
IPickObjectCallback* callback,
|
||||
const QMetaObject* targetClass = 0,
|
||||
const char* statusText = 0,
|
||||
bool bMultipick = false) = 0;
|
||||
//! Cancel current pick operation
|
||||
virtual void CancelPick() = 0;
|
||||
//! Return true if editor now in object picking mode
|
||||
virtual bool IsPicking() = 0;
|
||||
//! Get DB manager that own items of specified type.
|
||||
virtual IDataBaseManager* GetDBItemManager(EDataBaseItemType itemType) = 0;
|
||||
//! Get Manager of Materials.
|
||||
|
||||
@@ -65,7 +65,6 @@ AZ_POP_DISABLE_WARNING
|
||||
#include "UIEnumsDatabase.h"
|
||||
#include "Util/Ruler.h"
|
||||
#include "RenderHelpers/AxisHelper.h"
|
||||
#include "PickObjectTool.h"
|
||||
#include "Settings.h"
|
||||
#include "Include/IObjectManager.h"
|
||||
#include "Include/ISourceControl.h"
|
||||
@@ -170,7 +169,6 @@ CEditorImpl::CEditorImpl()
|
||||
, m_pShaderEnum(nullptr)
|
||||
, m_pIconManager(nullptr)
|
||||
, m_bSelectionLocked(true)
|
||||
, m_pPickTool(nullptr)
|
||||
, m_pAxisGizmo(nullptr)
|
||||
, m_pGameEngine(nullptr)
|
||||
, m_pAnimationContext(nullptr)
|
||||
@@ -794,11 +792,6 @@ void CEditorImpl::SetEditTool(CEditTool* tool, bool bStopCurrentTool)
|
||||
m_pEditTool->BeginEditParams(this, 0);
|
||||
}
|
||||
|
||||
// Make sure pick is aborted.
|
||||
if (tool != m_pPickTool)
|
||||
{
|
||||
m_pPickTool = nullptr;
|
||||
}
|
||||
Notify(eNotify_OnEditToolChange);
|
||||
}
|
||||
|
||||
@@ -1069,34 +1062,6 @@ bool CEditorImpl::IsSelectionLocked()
|
||||
return m_bSelectionLocked;
|
||||
}
|
||||
|
||||
void CEditorImpl::PickObject(IPickObjectCallback* callback, const QMetaObject* targetClass, const char* statusText, bool bMultipick)
|
||||
{
|
||||
m_pPickTool = new CPickObjectTool(callback, targetClass);
|
||||
|
||||
static_cast<CPickObjectTool*>(m_pPickTool.get())->SetMultiplePicks(bMultipick);
|
||||
if (statusText)
|
||||
{
|
||||
m_pPickTool.get()->SetStatusText(statusText);
|
||||
}
|
||||
|
||||
SetEditTool(m_pPickTool);
|
||||
}
|
||||
|
||||
void CEditorImpl::CancelPick()
|
||||
{
|
||||
SetEditTool(0);
|
||||
m_pPickTool = 0;
|
||||
}
|
||||
|
||||
bool CEditorImpl::IsPicking()
|
||||
{
|
||||
if (GetEditTool() == m_pPickTool && m_pPickTool != 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
CViewManager* CEditorImpl::GetViewManager()
|
||||
{
|
||||
return m_pViewManager;
|
||||
|
||||
@@ -181,10 +181,7 @@ public:
|
||||
void SelectObject(CBaseObject* obj);
|
||||
void LockSelection(bool bLock);
|
||||
bool IsSelectionLocked();
|
||||
void PickObject(IPickObjectCallback* callback, const QMetaObject* targetClass = 0, const char* statusText = 0, bool bMultipick = false);
|
||||
|
||||
void CancelPick();
|
||||
bool IsPicking();
|
||||
IDataBaseManager* GetDBItemManager(EDataBaseItemType itemType);
|
||||
CMaterialManager* GetMaterialManager() { return m_pMaterialManager; }
|
||||
CMusicManager* GetMusicManager() { return m_pMusicManager; };
|
||||
@@ -409,7 +406,6 @@ protected:
|
||||
QString m_primaryCDFolder;
|
||||
QString m_userFolder;
|
||||
bool m_bSelectionLocked;
|
||||
_smart_ptr<CEditTool> m_pPickTool;
|
||||
class CAxisGizmo* m_pAxisGizmo;
|
||||
CGameEngine* m_pGameEngine;
|
||||
CAnimationContext* m_pAnimationContext;
|
||||
|
||||
@@ -90,9 +90,6 @@ public:
|
||||
MOCK_METHOD0(IsSelectionLocked, bool());
|
||||
MOCK_METHOD0(GetObjectManager, struct IObjectManager* ());
|
||||
MOCK_METHOD0(GetSettingsManager, CSettingsManager* ());
|
||||
MOCK_METHOD4(PickObject, void(IPickObjectCallback*,const QMetaObject*,const char* ,bool bMultipick));
|
||||
MOCK_METHOD0(CancelPick, void());
|
||||
MOCK_METHOD0(IsPicking, bool());
|
||||
MOCK_METHOD1(GetDBItemManager, IDataBaseManager* (EDataBaseItemType));
|
||||
MOCK_METHOD0(GetMaterialManager, CMaterialManager* ());
|
||||
MOCK_METHOD0(GetMaterialManagerLibrary, IBaseLibraryManager* ());
|
||||
|
||||
@@ -1,286 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#include "EditorDefs.h"
|
||||
|
||||
#include "LinkTool.h"
|
||||
|
||||
// Editor
|
||||
#include "Viewport.h"
|
||||
#include "Objects/EntityObject.h"
|
||||
#include "Objects/SelectionGroup.h"
|
||||
#include <Plugins/ComponentEntityEditorPlugin/Objects/ComponentEntityObject.h>
|
||||
|
||||
// AzCore
|
||||
#include <AzCore/Component/Entity.h>
|
||||
|
||||
#ifdef LoadCursor
|
||||
#undef LoadCursor
|
||||
#endif
|
||||
|
||||
namespace
|
||||
{
|
||||
const float kGeomCacheNodePivotSizeScale = 0.0025f;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
CLinkTool::CLinkTool()
|
||||
: m_nodeName(nullptr)
|
||||
, m_pGeomCacheRenderNode(nullptr)
|
||||
{
|
||||
m_pChild = NULL;
|
||||
SetStatusText("Click on object and drag a link to a new parent");
|
||||
|
||||
m_hLinkCursor = CMFCUtils::LoadCursor(IDC_POINTER_LINK);
|
||||
m_hLinkNowCursor = CMFCUtils::LoadCursor(IDC_POINTER_LINKNOW);
|
||||
m_hCurrCursor = &m_hLinkCursor;
|
||||
AZ::EntitySystemBus::Handler::BusConnect();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
CLinkTool::~CLinkTool()
|
||||
{
|
||||
AZ::EntitySystemBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CLinkTool::LinkObject(CBaseObject* pChild, CBaseObject* pParent)
|
||||
{
|
||||
if (pChild == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (ChildIsValid(pParent, pChild))
|
||||
{
|
||||
CUndo undo("Link Object");
|
||||
|
||||
if (qobject_cast<CEntityObject*>(pChild))
|
||||
{
|
||||
static_cast<CEntityObject*>(pChild)->SetAttachTarget("");
|
||||
static_cast<CEntityObject*>(pChild)->SetAttachType(CEntityObject::eAT_Pivot);
|
||||
}
|
||||
|
||||
pParent->AttachChild(pChild, true);
|
||||
|
||||
QString str;
|
||||
str = tr("%1 attached to %2").arg(pChild->GetName(), pParent->GetName());
|
||||
SetStatusText(str);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetStatusText("Error: Cyclic linking or already linked.");
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CLinkTool::LinkSelectedToParent(CBaseObject* pParent)
|
||||
{
|
||||
if (pParent)
|
||||
{
|
||||
if (IsRelevant(pParent))
|
||||
{
|
||||
CSelectionGroup* pSel = GetIEditor()->GetSelection();
|
||||
if (!pSel->GetCount())
|
||||
{
|
||||
return;
|
||||
}
|
||||
CUndo undo("Link Object(s)");
|
||||
for (int i = 0; i < pSel->GetCount(); i++)
|
||||
{
|
||||
CBaseObject* pChild = pSel->GetObject(i);
|
||||
if (pChild == pParent)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
LinkObject(pChild, pParent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CLinkTool::MouseCallback(CViewport* view, EMouseEvent event, QPoint& point, [[maybe_unused]] int flags)
|
||||
{
|
||||
view->SetCursorString("");
|
||||
|
||||
m_hCurrCursor = &m_hLinkCursor;
|
||||
if (event == eMouseLDown)
|
||||
{
|
||||
HitContext hitInfo;
|
||||
view->HitTest(point, hitInfo);
|
||||
CBaseObject* obj = hitInfo.object;
|
||||
if (obj)
|
||||
{
|
||||
if (IsRelevant(obj))
|
||||
{
|
||||
m_StartDrag = obj->GetWorldPos();
|
||||
m_pChild = obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (event == eMouseLUp)
|
||||
{
|
||||
HitContext hitInfo;
|
||||
view->HitTest(point, hitInfo);
|
||||
CBaseObject* obj = hitInfo.object;
|
||||
if (obj)
|
||||
{
|
||||
if (IsRelevant(obj))
|
||||
{
|
||||
CSelectionGroup* pSelectionGroup = GetIEditor()->GetSelection();
|
||||
int nGroupCount = pSelectionGroup->GetCount();
|
||||
if (pSelectionGroup && nGroupCount > 1)
|
||||
{
|
||||
LinkSelectedToParent(obj);
|
||||
}
|
||||
if (!pSelectionGroup || nGroupCount <= 1 || !pSelectionGroup->IsContainObject(m_pChild))
|
||||
{
|
||||
LinkObject(m_pChild, obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
m_pChild = NULL;
|
||||
}
|
||||
else if (event == eMouseMove)
|
||||
{
|
||||
m_EndDrag = view->ViewToWorld(point);
|
||||
m_nodeName = nullptr;
|
||||
m_pGeomCacheRenderNode = nullptr;
|
||||
|
||||
HitContext hitInfo;
|
||||
if (view->HitTest(point, hitInfo))
|
||||
{
|
||||
m_EndDrag = hitInfo.raySrc + hitInfo.rayDir * hitInfo.dist;
|
||||
}
|
||||
|
||||
CBaseObject* obj = hitInfo.object;
|
||||
if (obj)
|
||||
{
|
||||
if (IsRelevant(obj))
|
||||
{
|
||||
QString name = obj->GetName();
|
||||
if (hitInfo.name)
|
||||
{
|
||||
name += QString("\n ") + hitInfo.name;
|
||||
}
|
||||
|
||||
// Set Cursors.
|
||||
view->SetCursorString(name);
|
||||
if (m_pChild)
|
||||
{
|
||||
if (ChildIsValid(obj, m_pChild))
|
||||
{
|
||||
m_hCurrCursor = &m_hLinkNowCursor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CLinkTool::OnKeyDown([[maybe_unused]] CViewport* view, uint32 nChar, [[maybe_unused]] uint32 nRepCnt, [[maybe_unused]] uint32 nFlags)
|
||||
{
|
||||
if (nChar == VK_ESCAPE)
|
||||
{
|
||||
// Cancel selection.
|
||||
GetIEditor()->SetEditTool(nullptr);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CLinkTool::Display(DisplayContext& dc)
|
||||
{
|
||||
if (m_pChild && m_EndDrag != Vec3(ZERO))
|
||||
{
|
||||
ColorF lineColor = (m_hCurrCursor == &m_hLinkNowCursor) ? ColorF(0, 1, 0) : ColorF(1, 0, 0);
|
||||
dc.DrawLine(m_StartDrag, m_EndDrag, lineColor, lineColor);
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CLinkTool::OnEntityDestruction(const AZ::EntityId& entityId)
|
||||
{
|
||||
if (m_pChild && (m_pChild->GetType() == OBJTYPE_AZENTITY))
|
||||
{
|
||||
CComponentEntityObject* childComponentEntity = static_cast<CComponentEntityObject*>(m_pChild);
|
||||
AZ::EntityId childEntityId = childComponentEntity->GetAssociatedEntityId();
|
||||
if(entityId == childEntityId)
|
||||
{
|
||||
GetIEditor()->SetEditTool(nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CLinkTool::ChildIsValid(CBaseObject* pParent, CBaseObject* pChild, int nDir)
|
||||
{
|
||||
if (!pParent)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!pChild)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (pParent == pChild)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Legacy entities and AZ entities shouldn't be linked.
|
||||
if ((pParent->GetType() == OBJTYPE_AZENTITY) != (pChild->GetType() == OBJTYPE_AZENTITY))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
CBaseObject* pObj;
|
||||
if (nDir & 1)
|
||||
{
|
||||
pObj = pChild->GetParent();
|
||||
if (pObj)
|
||||
{
|
||||
if (!ChildIsValid(pParent, pObj, 1))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (nDir & 2)
|
||||
{
|
||||
for (int i = 0; i < pChild->GetChildCount(); i++)
|
||||
{
|
||||
pObj = pChild->GetChild(i);
|
||||
if (pObj)
|
||||
{
|
||||
if (!ChildIsValid(pParent, pObj, 2))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CLinkTool::OnSetCursor(CViewport* vp)
|
||||
{
|
||||
vp->SetCursor(*m_hCurrCursor);
|
||||
return true;
|
||||
}
|
||||
|
||||
#include <moc_LinkTool.cpp>
|
||||
@@ -1,85 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
// Description : Definition of CLinkTool, tool used to link objects.
|
||||
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_LINKTOOL_H
|
||||
#define CRYINCLUDE_EDITOR_LINKTOOL_H
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include <AzCore/Component/EntityBus.h>
|
||||
#include "EditTool.h"
|
||||
#include "Include/IObjectManager.h"
|
||||
#endif
|
||||
|
||||
class CEntityObject;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
class CLinkTool
|
||||
: public CEditTool
|
||||
, public IObjectSelectCallback
|
||||
, private AZ::EntitySystemBus::Handler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Q_INVOKABLE CLinkTool(); // IPickObjectCallback *callback,CRuntimeClass *targetClass=NULL );
|
||||
|
||||
// Ovverides from CEditTool
|
||||
bool MouseCallback(CViewport* view, EMouseEvent event, QPoint& point, int flags);
|
||||
|
||||
virtual void BeginEditParams([[maybe_unused]] IEditor* ie, [[maybe_unused]] int flags) {};
|
||||
virtual void EndEditParams() {};
|
||||
|
||||
virtual void Display(DisplayContext& dc);
|
||||
virtual bool OnKeyDown(CViewport* view, uint32 nChar, uint32 nRepCnt, uint32 nFlags);
|
||||
virtual bool OnKeyUp([[maybe_unused]] CViewport* view, [[maybe_unused]] uint32 nChar, [[maybe_unused]] uint32 nRepCnt, [[maybe_unused]] uint32 nFlags) { return false; };
|
||||
|
||||
virtual bool OnSelectObject([[maybe_unused]] CBaseObject* obj) {return false; }
|
||||
virtual bool CanSelectObject([[maybe_unused]] CBaseObject* obj) { return true; };
|
||||
|
||||
virtual bool OnSetCursor(CViewport* vp);
|
||||
|
||||
void LinkSelectedToParent(CBaseObject* pParent);
|
||||
|
||||
protected:
|
||||
virtual ~CLinkTool();
|
||||
// Delete itself.
|
||||
void DeleteThis() { delete this; };
|
||||
|
||||
private:
|
||||
bool IsRelevant([[maybe_unused]] CBaseObject* obj) { return true; }
|
||||
bool ChildIsValid(CBaseObject* pParent, CBaseObject* pChild, int nDir = 3);
|
||||
void LinkObject(CBaseObject* pChild, CBaseObject* pParent);
|
||||
void LinkToNode(CEntityObject* pChild, CEntityObject* pParent, const char* nodeName);
|
||||
|
||||
// AZ::EntitySystemBus::Handler
|
||||
void OnEntityDestruction(const AZ::EntityId& entityId) override;
|
||||
|
||||
|
||||
CBaseObject* m_pChild;
|
||||
Vec3 m_StartDrag;
|
||||
Vec3 m_EndDrag;
|
||||
|
||||
QCursor m_hLinkCursor;
|
||||
QCursor m_hLinkNowCursor;
|
||||
QCursor* m_hCurrCursor;
|
||||
|
||||
const char* m_nodeName;
|
||||
IGeomCacheRenderNode* m_pGeomCacheRenderNode;
|
||||
};
|
||||
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_LINKTOOL_H
|
||||
@@ -1104,15 +1104,6 @@ void MainWindow::InitActions()
|
||||
.RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdateSelected)
|
||||
.SetIcon(Style::icon("Align_to_grid"))
|
||||
.SetApplyHoverEffect();
|
||||
am->AddAction(ID_OBJECTMODIFY_ALIGN, tr("Align to object")).SetCheckable(true)
|
||||
#if AZ_TRAIT_OS_PLATFORM_APPLE
|
||||
.SetStatusTip(tr(u8"\u2318: Align an object to a bounding box, \u2325 : Keep Rotation of the moved object, Shift : Keep Scale of the moved object"))
|
||||
#else
|
||||
.SetStatusTip(tr("Ctrl: Align an object to a bounding box, Alt : Keep Rotation of the moved object, Shift : Keep Scale of the moved object"))
|
||||
#endif
|
||||
.RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdateAlignObject)
|
||||
.SetIcon(Style::icon("Align_to_Object"))
|
||||
.SetApplyHoverEffect();
|
||||
am->AddAction(ID_MODIFY_ALIGNOBJTOSURF, tr("Align object to surface (Hold CTRL)")).SetCheckable(true)
|
||||
.SetToolTip(tr("Align object to surface (Hold CTRL)"))
|
||||
.RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdateAlignToVoxel)
|
||||
@@ -1449,15 +1440,6 @@ void MainWindow::InitActions()
|
||||
.SetApplyHoverEffect();
|
||||
|
||||
// Edit Mode Toolbar Actions
|
||||
am->AddAction(ID_EDITTOOL_LINK, tr("Link an object to parent"))
|
||||
.SetIcon(Style::icon("add_link"))
|
||||
.SetApplyHoverEffect()
|
||||
.SetCheckable(true)
|
||||
.RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdateEditToolLink);
|
||||
am->AddAction(ID_EDITTOOL_UNLINK, tr("Unlink all selected objects"))
|
||||
.SetIcon(Style::icon("remove_link"))
|
||||
.SetApplyHoverEffect()
|
||||
.RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdateEditToolUnlink);
|
||||
am->AddAction(IDC_SELECTION_MASK, tr("Selected Object Types"));
|
||||
am->AddAction(ID_REF_COORDS_SYS, tr("Reference coordinate system"))
|
||||
.SetShortcut(tr("Ctrl+W"))
|
||||
|
||||
@@ -1,173 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#include "EditorDefs.h"
|
||||
|
||||
#include "PickObjectTool.h"
|
||||
|
||||
// Editor
|
||||
#include "Viewport.h"
|
||||
#include "Include/HitContext.h"
|
||||
#include "Objects/BaseObject.h"
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
CPickObjectTool::CPickObjectTool(IPickObjectCallback* callback, const QMetaObject* targetClass)
|
||||
{
|
||||
assert(callback != 0);
|
||||
m_callback = callback;
|
||||
m_targetClass = targetClass;
|
||||
m_bMultiPick = false;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
CPickObjectTool::~CPickObjectTool()
|
||||
{
|
||||
GetIEditor()->GetObjectManager()->SetSelectCallback(0);
|
||||
//m_prevSelectCallback = 0;
|
||||
if (m_callback)
|
||||
{
|
||||
m_callback->OnCancelPick();
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CPickObjectTool::BeginEditParams([[maybe_unused]] IEditor* ie, [[maybe_unused]] int flags)
|
||||
{
|
||||
QString str = "Pick object";
|
||||
if (m_targetClass)
|
||||
{
|
||||
str = tr("Pick %1 object").arg(m_targetClass->className());
|
||||
}
|
||||
SetStatusText(str);
|
||||
|
||||
//m_prevSelectCallback =
|
||||
GetIEditor()->GetObjectManager()->SetSelectCallback(this);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CPickObjectTool::MouseCallback(CViewport* view, EMouseEvent event, QPoint& point, [[maybe_unused]] int flags)
|
||||
{
|
||||
if (event == eMouseLDown)
|
||||
{
|
||||
HitContext hitInfo;
|
||||
view->HitTest(point, hitInfo);
|
||||
CBaseObject* obj = hitInfo.object;
|
||||
if (obj)
|
||||
{
|
||||
if (IsRelevant(obj))
|
||||
{
|
||||
if (m_callback)
|
||||
{
|
||||
// Can pick this one.
|
||||
m_callback->OnPick(obj);
|
||||
}
|
||||
if (!m_bMultiPick)
|
||||
{
|
||||
m_callback = 0;
|
||||
GetIEditor()->SetEditTool(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (event == eMouseMove)
|
||||
{
|
||||
HitContext hitInfo;
|
||||
view->HitTest(point, hitInfo);
|
||||
CBaseObject* obj = hitInfo.object;
|
||||
if (obj)
|
||||
{
|
||||
if (IsRelevant(obj))
|
||||
{
|
||||
// Set Cursors.
|
||||
view->SetCurrentCursor(STD_CURSOR_HIT, obj->GetName());
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CPickObjectTool::OnSelectObject(CBaseObject* obj)
|
||||
{
|
||||
if (IsRelevant(obj))
|
||||
{
|
||||
// Can pick this one.
|
||||
if (m_callback)
|
||||
{
|
||||
m_callback->OnPick(obj);
|
||||
m_callback = 0;
|
||||
}
|
||||
if (!m_bMultiPick)
|
||||
{
|
||||
GetIEditor()->SetEditTool(0);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CPickObjectTool::CanSelectObject(CBaseObject* obj)
|
||||
{
|
||||
return IsRelevant(obj);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CPickObjectTool::OnKeyDown([[maybe_unused]] CViewport* view, uint32 nChar, [[maybe_unused]] uint32 nRepCnt, [[maybe_unused]] uint32 nFlags)
|
||||
{
|
||||
if (nChar == VK_ESCAPE)
|
||||
{
|
||||
// Cancel selection.
|
||||
GetIEditor()->SetEditTool(0);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CPickObjectTool::IsRelevant(CBaseObject* obj)
|
||||
{
|
||||
assert(obj != 0);
|
||||
if (obj == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!m_callback)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_targetClass)
|
||||
{
|
||||
return m_callback->OnPickFilter(obj);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (obj->metaObject() == m_targetClass || m_targetClass->cast(obj))
|
||||
{
|
||||
return m_callback->OnPickFilter(obj);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CPickObjectTool::IsNeedSpecificBehaviorForSpaceAcce()
|
||||
{
|
||||
if (m_callback && m_callback->IsNeedSpecificBehaviorForSpaceAcce())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#include <moc_PickObjectTool.cpp>
|
||||
@@ -1,76 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
// Description : Definition of PickObjectTool, tool used to pick objects.
|
||||
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_PICKOBJECTTOOL_H
|
||||
#define CRYINCLUDE_EDITOR_PICKOBJECTTOOL_H
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include "EditTool.h"
|
||||
#include "IObjectManager.h"
|
||||
#endif
|
||||
|
||||
#pragma once
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
class CPickObjectTool
|
||||
: public CEditTool
|
||||
, public IObjectSelectCallback
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CPickObjectTool(IPickObjectCallback* callback, const QMetaObject* targetClass = NULL);
|
||||
|
||||
//! If set to true, pick tool will not stop picking after first pick.
|
||||
void SetMultiplePicks(bool bEnable) { m_bMultiPick = bEnable; };
|
||||
|
||||
// Ovverides from CEditTool
|
||||
bool MouseCallback(CViewport* view, EMouseEvent event, QPoint& point, int flags);
|
||||
|
||||
virtual void BeginEditParams(IEditor* ie, int flags);
|
||||
virtual void EndEditParams() {};
|
||||
|
||||
virtual void Display([[maybe_unused]] DisplayContext& dc) {};
|
||||
virtual bool OnKeyDown(CViewport* view, uint32 nChar, uint32 nRepCnt, uint32 nFlags);
|
||||
virtual bool OnKeyUp([[maybe_unused]] CViewport* view, [[maybe_unused]] uint32 nChar, [[maybe_unused]] uint32 nRepCnt, [[maybe_unused]] uint32 nFlags) { return false; };
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// IObjectSelectCallback
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
virtual bool OnSelectObject(CBaseObject* obj);
|
||||
virtual bool CanSelectObject(CBaseObject* obj);
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
virtual bool IsNeedSpecificBehaviorForSpaceAcce();
|
||||
|
||||
protected:
|
||||
virtual ~CPickObjectTool();
|
||||
// Delete itself.
|
||||
void DeleteThis() { delete this; };
|
||||
|
||||
private:
|
||||
bool IsRelevant(CBaseObject* obj);
|
||||
|
||||
//! Object that requested pick.
|
||||
IPickObjectCallback* m_callback;
|
||||
|
||||
//! If target class specified, will pick only objects that belongs to that runtime class.
|
||||
const QMetaObject* m_targetClass;
|
||||
|
||||
bool m_bMultiPick;
|
||||
};
|
||||
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_PICKOBJECTTOOL_H
|
||||
@@ -181,8 +181,6 @@
|
||||
#define ID_TV_STOP 33568
|
||||
#define ID_TV_PAUSE 33569
|
||||
#define ID_ADDNODE 33570
|
||||
#define ID_EDITTOOL_LINK 33571
|
||||
#define ID_EDITTOOL_UNLINK 33572
|
||||
#define ID_ADDSCENETRACK 33573
|
||||
#define ID_FIND 33574
|
||||
#define ID_SNAP_TO_GRID 33575
|
||||
@@ -214,7 +212,6 @@
|
||||
#define ID_TV_JUMPSTART 33601
|
||||
#define ID_TV_PREVKEY 33602
|
||||
#define ID_TV_NEXTKEY 33603
|
||||
#define ID_OBJECTMODIFY_ALIGN 33604
|
||||
#define ID_PLAY_LOOP 33607
|
||||
#define ID_TERRAIN 33611
|
||||
#define ID_OBJECTMODIFY_ALIGNTOGRID 33619
|
||||
|
||||
@@ -585,13 +585,6 @@ AmazonToolbar ToolbarManager::GetEditModeToolbar() const
|
||||
t.AddAction(ID_TOOLBAR_WIDGET_UNDO, ORIGINAL_TOOLBAR_VERSION);
|
||||
t.AddAction(ID_TOOLBAR_WIDGET_REDO, ORIGINAL_TOOLBAR_VERSION);
|
||||
|
||||
if (!GetIEditor()->IsNewViewportInteractionModelEnabled())
|
||||
{
|
||||
t.AddAction(ID_TOOLBAR_SEPARATOR, ORIGINAL_TOOLBAR_VERSION);
|
||||
t.AddAction(ID_EDITTOOL_LINK, ORIGINAL_TOOLBAR_VERSION);
|
||||
t.AddAction(ID_EDITTOOL_UNLINK, ORIGINAL_TOOLBAR_VERSION);
|
||||
}
|
||||
|
||||
t.AddAction(ID_TOOLBAR_SEPARATOR, ORIGINAL_TOOLBAR_VERSION);
|
||||
|
||||
if (!GetIEditor()->IsNewViewportInteractionModelEnabled())
|
||||
@@ -630,7 +623,6 @@ AmazonToolbar ToolbarManager::GetObjectToolbar() const
|
||||
AmazonToolbar t = AmazonToolbar("Object", QObject::tr("Object Toolbar"));
|
||||
t.SetMainToolbar(true);
|
||||
t.AddAction(ID_GOTO_SELECTED, ORIGINAL_TOOLBAR_VERSION);
|
||||
t.AddAction(ID_OBJECTMODIFY_ALIGN, ORIGINAL_TOOLBAR_VERSION);
|
||||
t.AddAction(ID_OBJECTMODIFY_ALIGNTOGRID, ORIGINAL_TOOLBAR_VERSION);
|
||||
t.AddAction(ID_OBJECTMODIFY_SETHEIGHT, ORIGINAL_TOOLBAR_VERSION);
|
||||
t.AddAction(ID_MODIFY_ALIGNOBJTOSURF, ORIGINAL_TOOLBAR_VERSION);
|
||||
|
||||
@@ -533,8 +533,6 @@ set(FILES
|
||||
Dialogs/PythonScriptsDialog.ui
|
||||
Dialogs/Generic/UserOptions.cpp
|
||||
Dialogs/Generic/UserOptions.h
|
||||
AlignTool.cpp
|
||||
AlignTool.h
|
||||
ObjectCloneTool.cpp
|
||||
ObjectCloneTool.h
|
||||
EditMode/SubObjectSelectionReferenceFrameCalculator.cpp
|
||||
@@ -545,10 +543,6 @@ set(FILES
|
||||
RotateTool.h
|
||||
EditTool.cpp
|
||||
EditTool.h
|
||||
LinkTool.cpp
|
||||
LinkTool.h
|
||||
PickObjectTool.cpp
|
||||
PickObjectTool.h
|
||||
VoxelAligningTool.cpp
|
||||
VoxelAligningTool.h
|
||||
Export/ExportManager.cpp
|
||||
|
||||
Reference in New Issue
Block a user