Integrating latest 47acbe8

This commit is contained in:
alexpete
2021-03-25 13:57:57 -07:00
parent 448c549698
commit 75dc720198
10312 changed files with 2711566 additions and 671451 deletions
-7
View File
@@ -412,13 +412,6 @@ void ActionManager::AddAction(QAction* action)
{
widget->addAction(action);
}
// This is to prevent icons being shown in the main menu.
// Currently, the goal is to show icons in the toolbar but not in the main menu,
// and the code that handles showing icon in the LevelEditorMenuHandler.cpp
// has been removed. This fix is a short term solution as in the future
// we need to add custom different icons on the menus.
action->setIconVisibleInMenu(false);
}
void ActionManager::RemoveAction(QAction* action)
@@ -28,6 +28,7 @@
#include <AzFramework/Asset/GenericAssetHandler.h>
// AzToolsFramework
#include <AzToolsFramework/AssetBrowser/AssetBrowserSourceDropBus.h>
#include <AzToolsFramework/AssetBrowser/Entries/ProductAssetBrowserEntry.h>
#include <AzToolsFramework/AssetBrowser/Entries/SourceAssetBrowserEntry.h>
#include <AzToolsFramework/AssetEditor/AssetEditorBus.h>
@@ -375,7 +376,12 @@ void AzAssetBrowserRequestHandler::AddContextMenuActions(QWidget* caller, QMenu*
}
}
bool AzAssetBrowserRequestHandler::CanAcceptDragAndDropEvent(QDropEvent* event, AzQtComponents::DragAndDropContextBase& context) const
bool AzAssetBrowserRequestHandler::CanAcceptDragAndDropEvent(
QDropEvent* event,
AzQtComponents::DragAndDropContextBase& context,
AZStd::optional<AZStd::vector<const AzToolsFramework::AssetBrowser::SourceAssetBrowserEntry*>*> outSources,
AZStd::optional<AZStd::vector<const AzToolsFramework::AssetBrowser::ProductAssetBrowserEntry*>*> outProducts
) const
{
using namespace AzQtComponents;
using namespace AzToolsFramework;
@@ -389,19 +395,46 @@ bool AzAssetBrowserRequestHandler::CanAcceptDragAndDropEvent(QDropEvent* event,
return false;
}
// is it something we know how to spawn?
bool canSpawn = false;
bool canAcceptEvent = false;
AzToolsFramework::AssetBrowser::AssetBrowserEntry::ForEachEntryInMimeData<ProductAssetBrowserEntry>(event->mimeData(),
[&](const AzToolsFramework::AssetBrowser::ProductAssetBrowserEntry* product)
{
if (CanSpawnEntityForProduct(product))
// Detects Source Asset Entries whose extensions are handled by a system
AzToolsFramework::AssetBrowser::AssetBrowserEntry::ForEachEntryInMimeData<SourceAssetBrowserEntry>(
event->mimeData(), [&](const AzToolsFramework::AssetBrowser::SourceAssetBrowserEntry* source) {
if (AssetBrowser::AssetBrowserSourceDropBus::HasHandlers(source->GetExtension()))
{
canSpawn = true;
if (outSources.has_value())
{
outSources.value()->push_back(source);
}
canAcceptEvent = true;
}
});
return canSpawn;
// Detects Product Assets that are dragged directly, or child Products of other entry types.
AzToolsFramework::AssetBrowser::AssetBrowserEntry::ForEachEntryInMimeData<ProductAssetBrowserEntry>(
event->mimeData(), [&](const AzToolsFramework::AssetBrowser::ProductAssetBrowserEntry* product)
{
// Skip if this product is a child of a source file that is handled
if (outSources.has_value() && !outSources.value()->empty())
{
auto parent = azrtti_cast<const SourceAssetBrowserEntry*>(product->GetParent());
if (parent != nullptr && AZStd::find(outSources.value()->begin(), outSources.value()->end(), parent) != outSources.value()->end())
{
return;
}
}
if (CanSpawnEntityForProduct(product))
{
if (outProducts.has_value())
{
outProducts.value()->push_back(product);
}
canAcceptEvent = true;
}
});
return canAcceptEvent;
}
void AzAssetBrowserRequestHandler::DragEnter(QDragEnterEvent* event, AzQtComponents::DragAndDropContextBase& context)
@@ -434,11 +467,14 @@ void AzAssetBrowserRequestHandler::Drop(QDropEvent* event, AzQtComponents::DragA
using namespace AzQtComponents;
using namespace AzAssetBrowserRequestHandlerPrivate;
// ALWAYS CHECK - you are not the only one connected to this bus, and someone else may have already
// handled the event or accepted the drop - it might not contain types relevant to you.
// you still get informed about the drop event in case you did some stuff in your gui and need to clean it up.
if (!CanAcceptDragAndDropEvent(event, context))
AZStd::vector<const SourceAssetBrowserEntry*> sources;
AZStd::vector<const ProductAssetBrowserEntry*> products;
if (!CanAcceptDragAndDropEvent(event, context, &sources, &products))
{
// ALWAYS CHECK - you are not the only one connected to this bus, and someone else may have already
// handled the event or accepted the drop - it might not contain types relevant to you.
// you still get informed about the drop event in case you did some stuff in your gui and need to clean it up.
return;
}
@@ -448,21 +484,32 @@ void AzAssetBrowserRequestHandler::Drop(QDropEvent* event, AzQtComponents::DragA
event->setDropAction(Qt::CopyAction);
event->setAccepted(true);
// spawn entities!
EntityIdList spawnedEntities;
AzFramework::SliceInstantiationTicket spawnTicket;
// make a scoped undo that covers the ENTIRE operation.
// Make a scoped undo that covers the ENTIRE operation.
ScopedUndoBatch undo("Create entities from asset");
AssetBrowserEntry::ForEachEntryInMimeData<ProductAssetBrowserEntry>(event->mimeData(),
[&](const ProductAssetBrowserEntry* product)
// Handle sources
for (const SourceAssetBrowserEntry* source : sources)
{
AssetBrowser::AssetBrowserSourceDropBus::Event(
source->GetExtension(),
&AssetBrowser::AssetBrowserSourceDropEvents::HandleSourceFileType,
source->GetFullPath(),
AZ::EntityId(),
viewportDragContext->m_hitLocation
);
}
// Handle products
for (const ProductAssetBrowserEntry* product : products)
{
if (CanSpawnEntityForProduct(product))
{
if (CanSpawnEntityForProduct(product))
{
SpawnEntityAtPoint(product, viewportDragContext, spawnedEntities, spawnTicket);
}
});
SpawnEntityAtPoint(product, viewportDragContext, spawnedEntities, spawnTicket);
}
}
// Select the new entity (and deselect others).
if (!spawnedEntities.empty())
@@ -32,6 +32,8 @@ namespace AzToolsFramework
{
class AssetBrowserEntry;
class PreviewerFactory;
class ProductAssetBrowserEntry;
class SourceAssetBrowserEntry;
}
}
@@ -69,7 +71,10 @@ protected:
//////////////////////////////////////////////////////////////////////////
const AzToolsFramework::AssetBrowser::PreviewerFactory* GetPreviewerFactory(const AzToolsFramework::AssetBrowser::AssetBrowserEntry* entry) const override;
bool CanAcceptDragAndDropEvent(QDropEvent* event, AzQtComponents::DragAndDropContextBase& context) const;
bool CanAcceptDragAndDropEvent(
QDropEvent* event, AzQtComponents::DragAndDropContextBase& context,
AZStd::optional<AZStd::vector<const AzToolsFramework::AssetBrowser::SourceAssetBrowserEntry*>*> outSources = AZStd::nullopt,
AZStd::optional<AZStd::vector<const AzToolsFramework::AssetBrowser::ProductAssetBrowserEntry*>*> outProducts = AZStd::nullopt) const;
private:
AZStd::unique_ptr<const LegacyPreviewerFactory> m_previewerFactory;
+7 -6
View File
@@ -120,17 +120,17 @@ ly_add_target(
Legacy::NewsShared
AZ::AWSNativeSDKInit
Legacy::CryCommonTools
AZ::AtomCore
Gem::Atom_RPI.Edit
Gem::Atom_RPI.Public
Gem::Atom_Feature_Common.Static
Gem::AtomToolsFramework.Static
${additional_dependencies}
PUBLIC
3rdParty::AWSNativeSDK::Core
3rdParty::Qt::Network
Legacy::EditorCore
)
ly_add_source_properties(
SOURCES IEditorImpl.cpp
PROPERTY COMPILE_DEFINITIONS
VALUES LY_METRICS_BUILD_TIME=${LY_METRICS_BUILD_TIME}
)
ly_add_source_properties(
SOURCES CryEdit.cpp
PROPERTY COMPILE_DEFINITIONS
@@ -169,10 +169,11 @@ ly_add_target(
Platform/${PAL_PLATFORM_NAME}/editor_${PAL_PLATFORM_NAME_LOWERCASE}.cmake
BUILD_DEPENDENCIES
PRIVATE
Legacy::EditorLib
3rdParty::Qt::Core
Legacy::CryCommon
RUNTIME_DEPENDENCIES
Legacy::CrySystem
Legacy::EditorLib
)
ly_add_translations(
TARGETS Editor
@@ -148,7 +148,7 @@ bool CEditorCommandManager::RegisterUICommand(
const char* name,
const char* description,
const char* example,
const Functor0& functor,
const AZStd::function<void()>& functor,
const CCommand0::SUIInfo& uiInfo)
{
bool ok = CommandManagerHelper::RegisterCommand(this, module, name, description, example, functor);
@@ -49,7 +49,7 @@ public:
const char* name,
const char* description,
const char* example,
const Functor0& functor,
const AZStd::function<void()>& functor,
const CCommand0::SUIInfo& uiInfo);
bool AttachUIInfo(const char* fullCmdName, const CCommand0::SUIInfo& uiInfo);
bool GetUIInfo(const string& module, const string& name, CCommand0::SUIInfo& uiInfo) const;
@@ -112,10 +112,10 @@ private:
static CAutoRegisterCommandHelper* s_pLast;
};
#define REGISTER_EDITOR_COMMAND(functionPtr, moduleName, functionName, description, example) \
#define REGISTER_EDITOR_COMMAND(boundFunction, moduleName, functionName, description, example) \
void RegisterCommand##moduleName##functionName(CEditorCommandManager & cmdMgr) \
{ \
CommandManagerHelper::RegisterCommand(&cmdMgr, #moduleName, #functionName, description, example, functor(functionPtr)); \
CommandManagerHelper::RegisterCommand(&cmdMgr, #moduleName, #functionName, description, example, boundFunction); \
} \
CAutoRegisterCommandHelper g_AutoRegCmdHelper##moduleName##functionName(RegisterCommand##moduleName##functionName)
@@ -67,7 +67,7 @@ public:
void SetZoom(float fZoom);
void SetOrigin(float fOffset);
typedef Functor1<CColorGradientCtrl*> UpdateCallback;
typedef AZStd::function<void(CColorGradientCtrl*)> UpdateCallback;
void SetUpdateCallback(const UpdateCallback& cb) { m_updateCallback = cb; };
void SetNoTimeMarker(bool noTimeMarker);
@@ -180,7 +180,7 @@ void ConsoleLineEdit::keyPressEvent(QKeyEvent* ev)
{
m_historyIndex = m_history.size();
}
// Do not add the same string if it is the top of the stack, but allow duplicate entries otherwise
if (m_history.isEmpty() || m_history.back() != str)
{
@@ -528,7 +528,7 @@ static CString mfc_popup_helper(HWND hwnd, int x, int y)
if (!gPropertiesDlg->m_hWnd)
{
gPropertiesDlg->Create(CPropertiesDialog::IDD, AfxGetMainWnd());
gPropertiesDlg->SetUpdateCallback(functor(OnConsoleVariableUpdated));
gPropertiesDlg->SetUpdateCallback(AZStd::bind(OnConsoleVariableUpdated, AZStd::placeholders::_1));
}
gPropertiesDlg->ShowWindow(SW_SHOW);
gPropertiesDlg->BringWindowToTop();
@@ -1,12 +1,12 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates, or
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates, or
* a third party where indicated.
*
* 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,
* 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.
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
@@ -169,7 +169,7 @@ void LensFlarePropertyWidget::SetValue(const QString &value)
}
QString LensFlarePropertyWidget::GetValue() const
{
{
return m_valueEdit->text();
}
@@ -223,7 +223,7 @@ bool LensFlareHandler::ReadValuesIntoGUI(size_t index, LensFlarePropertyWidget*
QWidget* FloatCurveHandler::CreateGUI(QWidget *pParent)
{
CSplineCtrl *cSpline = new CSplineCtrl(pParent);
cSpline->SetUpdateCallback(functor(*this, &FloatCurveHandler::OnSplineChange));
cSpline->SetUpdateCallback(AZStd::bind(&FloatCurveHandler::OnSplineChange, this, AZStd::placeholders::_1));
cSpline->SetTimeRange(0, 1);
cSpline->SetValueRange(0, 1);
cSpline->SetGrid(12, 12);
@@ -35,7 +35,7 @@ void ReflectedPropertiesPanel::DeleteVars()
}
//////////////////////////////////////////////////////////////////////////
void ReflectedPropertiesPanel::SetVarBlock(class CVarBlock* vb, const ReflectedPropertyControl::UpdateVarCallback& updCallback, const char* category)
void ReflectedPropertiesPanel::SetVarBlock(class CVarBlock* vb, ReflectedPropertyControl::UpdateVarCallback* updCallback, const char* category)
{
assert(vb);
@@ -45,7 +45,7 @@ void ReflectedPropertiesPanel::SetVarBlock(class CVarBlock* vb, const ReflectedP
m_varBlock = vb;
AddVarBlock(m_varBlock, category);
SetUpdateCallback(functor(*this, &ReflectedPropertiesPanel::OnPropertyChanged));
SetUpdateCallback(AZStd::bind(&ReflectedPropertiesPanel::OnPropertyChanged, this, AZStd::placeholders::_1));
// When new object set all previous callbacks freed.
m_updateCallbacks.clear();
@@ -56,7 +56,7 @@ void ReflectedPropertiesPanel::SetVarBlock(class CVarBlock* vb, const ReflectedP
}
//////////////////////////////////////////////////////////////////////////
void ReflectedPropertiesPanel::AddVars(CVarBlock* vb, const ReflectedPropertyControl::UpdateVarCallback& updCallback, const char* category)
void ReflectedPropertiesPanel::AddVars(CVarBlock* vb, ReflectedPropertyControl::UpdateVarCallback* updCallback, const char* category)
{
assert(vb);
@@ -73,7 +73,7 @@ void ReflectedPropertiesPanel::AddVars(CVarBlock* vb, const ReflectedPropertyCon
if (bNewBlock)
{
SetUpdateCallback(functor(*this, &ReflectedPropertiesPanel::OnPropertyChanged));
SetUpdateCallback(AZStd::bind(&ReflectedPropertiesPanel::OnPropertyChanged, this, AZStd::placeholders::_1));
// When new object set all previous callbacks freed.
m_updateCallbacks.clear();
@@ -87,10 +87,10 @@ void ReflectedPropertiesPanel::AddVars(CVarBlock* vb, const ReflectedPropertyCon
void ReflectedPropertiesPanel::OnPropertyChanged(IVariable* pVar)
{
std::list<ReflectedPropertyControl::UpdateVarCallback>::iterator iter;
std::list<ReflectedPropertyControl::UpdateVarCallback*>::iterator iter;
for (iter = m_updateCallbacks.begin(); iter != m_updateCallbacks.end(); ++iter)
{
(*iter)(pVar);
(*iter)->operator()(pVar);
}
}
@@ -31,9 +31,9 @@ public:
ReflectedPropertiesPanel(QWidget* pParent = nullptr); // standard constructor
void DeleteVars();
void AddVars(class CVarBlock* vb, const ReflectedPropertyControl::UpdateVarCallback& func = nullptr, const char* category = nullptr);
void AddVars(class CVarBlock* vb, ReflectedPropertyControl::UpdateVarCallback* func = nullptr, const char* category = nullptr);
void SetVarBlock(class CVarBlock* vb, const ReflectedPropertyControl::UpdateVarCallback& func = nullptr, const char* category = nullptr);
void SetVarBlock(class CVarBlock* vb, ReflectedPropertyControl::UpdateVarCallback* func = nullptr, const char* category = nullptr);
protected:
void OnPropertyChanged(IVariable* pVar);
@@ -42,7 +42,7 @@ protected:
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
TSmartPtr<CVarBlock> m_varBlock;
std::list<ReflectedPropertyControl::UpdateVarCallback> m_updateCallbacks;
std::list<ReflectedPropertyControl::UpdateVarCallback*> m_updateCallbacks;
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
};
@@ -1,12 +1,12 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates, or
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates, or
* a third party where indicated.
*
* 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,
* 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.
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
@@ -15,7 +15,7 @@
#include "ReflectedPropertyCtrl.h"
// Qt
#include <QScopedValueRollback>
#include <QScopedValueRollback>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QLabel>
@@ -27,7 +27,7 @@
#include <AzToolsFramework/UI/PropertyEditor/ComponentEditorHeader.hxx>
#include <AzToolsFramework/UI/PropertyEditor/ReflectedPropertyEditor.hxx>
#include <AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.hxx>
#include <AzToolsFramework/UI/SearchWidget/SearchCriteriaWidget.hxx>
#include <AzToolsFramework/UI/SearchWidget/SearchCriteriaWidget.hxx>
#include <AzToolsFramework/Editor/EditorSettingsAPIBus.h>
// Editor
@@ -98,7 +98,7 @@ QSize ReflectedPropertyControl::sizeHint() const
ReflectedPropertyItem* ReflectedPropertyControl::AddVarBlock(CVarBlock *varBlock, const char *szCategory /*= nullptr*/)
{
AZ_Assert(m_initialized, "ReflectedPropertyControl not initialized. Setup must be called first.");
if (!varBlock)
return nullptr;
@@ -112,7 +112,7 @@ ReflectedPropertyItem* ReflectedPropertyControl::AddVarBlock(CVarBlock *varBlock
m_editor->AddInstance(m_rootContainer.get());
}
AZStd::vector<IVariable*> variables(varBlock->GetNumVariables());
//Copy variables into vector
@@ -171,7 +171,7 @@ ReflectedPropertyItem* ReflectedPropertyControl::AddVarBlock(CVarBlock *varBlock
}
//////////////////////////////////////////////////////////////////////////
static void AddVariable(CVariableBase& varArray, CVariableBase& var, const char* varName, const char* humanVarName, const char* description, IVariable::OnSetCallback func, void* pUserData, char dataType = IVariable::DT_SIMPLE)
static void AddVariable(CVariableBase& varArray, CVariableBase& var, const char* varName, const char* humanVarName, const char* description, IVariable::OnSetCallback* func, void* pUserData, char dataType = IVariable::DT_SIMPLE)
{
if (varName)
{
@@ -200,7 +200,7 @@ void ReflectedPropertyControl::CreateItems(XmlNodeRef node)
CreateItems(node, out, nullptr);
}
void ReflectedPropertyControl::CreateItems(XmlNodeRef node, CVarBlockPtr& outBlockPtr, IVariable::OnSetCallback func, bool splitCamelCaseIntoWords)
void ReflectedPropertyControl::CreateItems(XmlNodeRef node, CVarBlockPtr& outBlockPtr, IVariable::OnSetCallback* func, bool splitCamelCaseIntoWords)
{
SelectItem(0);
@@ -456,7 +456,7 @@ int ReflectedPropertyControl::GetContentHeight() const
}
void ReflectedPropertyControl::AddCustomPopupMenuPopup(const QString& text, const Functor1<int>& handler, const QStringList& items)
void ReflectedPropertyControl::AddCustomPopupMenuPopup(const QString& text, const AZStd::function<void(int)>& handler, const QStringList& items)
{
m_customPopupMenuPopups.push_back(SCustomPopupMenu(text, handler, items));
}
@@ -709,7 +709,7 @@ void ReflectedPropertyControl::OnItemChange(ReflectedPropertyItem *item, bool de
}
if (m_updateObjectFunc != 0 && m_bEnableCallback)
{
// KDAB: This callback has same signature as DoUpdateCallback. I think the only reason there are 2 is because some
// KDAB: This callback has same signature as DoUpdateCallback. I think the only reason there are 2 is because some
// EntityObject registers callback and some derived objects want to register their own callback. the normal UpdateCallback
// can only be registered for item at a time so the original authors added a 2nd callback function, so we ported it this way.
// This can probably get cleaned up to only on callback function with multiple receivers.
@@ -949,7 +949,7 @@ void ReflectedPropertyControl::EnableUpdateCallback(bool bEnable)
void ReflectedPropertyControl::SetGrayed([[maybe_unused]] bool grayed)
{
//KDAB_PROPERTYCTRL_PORT_TODO
//control should be grayed out but not disabled?
//control should be grayed out but not disabled?
}
void ReflectedPropertyControl::SetReadOnly(bool readonly)
@@ -46,7 +46,7 @@ AZ_POP_DISABLE_DLL_EXPORT_BASECLASS_WARNING
Q_OBJECT
public:
//! For alternative undo.
typedef Functor1<IVariable*> UndoCallback;
typedef AZStd::function<void(IVariable*)> UndoCallback;
explicit ReflectedPropertyControl(QWidget* parent = nullptr, Qt::WindowFlags windowFlags = Qt::WindowFlags());
@@ -55,7 +55,7 @@ public:
ReflectedPropertyItem* AddVarBlock(CVarBlock* varBlock, const char* szCategory = nullptr);
void CreateItems(XmlNodeRef node);
void CreateItems(XmlNodeRef node, CVarBlockPtr& varBlock, IVariable::OnSetCallback func, bool splitCamelCaseIntoWords = false);
void CreateItems(XmlNodeRef node, CVarBlockPtr& varBlock, IVariable::OnSetCallback* func, bool splitCamelCaseIntoWords = false);
// Replace category item contents with the specified var block.
virtual void ReplaceVarBlock(IVariable* categoryItem, CVarBlock* varBlock);
@@ -68,11 +68,11 @@ public:
bool FindVariable(IVariable* categoryItem) const;
//! When item change, this callback fired variable that changed.
typedef Functor1<IVariable*> UpdateVarCallback;
typedef AZStd::function<void(IVariable*)> UpdateVarCallback;
//! When item change, update object.
typedef Functor1<IVariable*> UpdateObjectCallback;
typedef AZStd::function<void(IVariable*)> UpdateObjectCallback;
//! When selection changes, this callback fired variable that changed.
typedef Functor1<IVariable*> SelChangeCallback;
typedef AZStd::function<void(IVariable*)> SelChangeCallback;
/** Set update callback to be used for this property window.
*/
@@ -166,19 +166,19 @@ public:
struct SCustomPopupItem
{
typedef Functor0 Callback;
typedef AZStd::function<void()> Callback;
QString m_text;
Callback m_callback;
SCustomPopupItem(const QString& text, const Functor0& callback)
SCustomPopupItem(const QString& text, const Callback& callback)
: m_text(text)
, m_callback(callback) {}
};
struct SCustomPopupMenu
{
typedef Functor1<int> Callback;
typedef AZStd::function<void(int)> Callback;
QString m_text;
Callback m_callback;
@@ -190,7 +190,7 @@ public:
, m_subMenuText(subMenuText) {}
};
void AddCustomPopupMenuPopup(const QString& text, const Functor1<int>& handler, const QStringList& items);
void AddCustomPopupMenuPopup(const QString& text, const AZStd::function<void(int)>& handler, const QStringList& items);
void RemoveCustomPopupMenuPopup(const QString& text);
void AddCustomPopupMenuItem(const QString& text, const SCustomPopupItem::Callback handler);
@@ -1,12 +1,12 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates, or
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates, or
* a third party where indicated.
*
* 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,
* 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.
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
@@ -28,10 +28,10 @@ const float ReflectedPropertyItem::s_DefaultNumStepIncrements = 500.0f;
//A ReflectedVarAdapter for holding IVariableContainers
//The extra ReflectedVarAdapter is the extra case of a container (has children) but also has a value itself.
//An example is an IVariable array whose type is forced to IVariable::DT_TEXTURE. The base Ivariable has a texture,
//The extra ReflectedVarAdapter is the extra case of a container (has children) but also has a value itself.
//An example is an IVariable array whose type is forced to IVariable::DT_TEXTURE. The base Ivariable has a texture,
//but it also has children that are parameters of the texture. The ReflectedPropertyEditor does not support this case
//so we work around by adding the base property to the list of children and showing the value of the base property
//so we work around by adding the base property to the list of children and showing the value of the base property
//in the container value space instead of "X Elements"
static ColorF StringToColor(const QString &value)
@@ -92,7 +92,7 @@ public:
UpdateCommon(m_item->GetVariable(), varBlock);
}
void SyncReflectedVarToIVar(IVariable *pVariable) override
void SyncReflectedVarToIVar(IVariable *pVariable) override
{
if (m_extraVariableAdapter)
{
@@ -102,7 +102,7 @@ public:
}
};
void SyncIVarToReflectedVar(IVariable *pVariable) override
void SyncIVarToReflectedVar(IVariable *pVariable) override
{
if (m_extraVariableAdapter)
{
@@ -175,6 +175,9 @@ ReflectedPropertyItem::ReflectedPropertyItem(ReflectedPropertyControl *control,
m_modified = false;
if (parent)
parent->AddChild(this);
m_onSetCallback = AZStd::bind(&ReflectedPropertyItem::OnVariableChange, this, AZStd::placeholders::_1);
m_onSetEnumCallback = AZStd::bind(&ReflectedPropertyItem::OnVariableEnumChange, this, AZStd::placeholders::_1);
}
ReflectedPropertyItem::~ReflectedPropertyItem()
@@ -193,7 +196,7 @@ void ReflectedPropertyItem::SetVariable(IVariable *var)
if (var == m_pVariable)
{
// Early exit optimization if setting the same var as the current var.
// A common use case, in Track View for example, is to re-use the save var for a property when switching to a new
// A common use case, in Track View for example, is to re-use the save var for a property when switching to a new
// instance of the same variable. The visible display of the value is often handled by invalidating the property,
// but the non-visible attributes, i.e. the range values, are usually set using this method. Thus we reset the ranges
// explicitly here when the Ivariable var is the same
@@ -210,8 +213,8 @@ void ReflectedPropertyItem::SetVariable(IVariable *var)
m_pVariable = pInputVar;
assert(m_pVariable != NULL);
m_pVariable->AddOnSetCallback(functor(*this, &ReflectedPropertyItem::OnVariableChange));
m_pVariable->AddOnSetEnumCallback(functor(*this, &ReflectedPropertyItem::OnVariableEnumChange));
m_pVariable->AddOnSetCallback(&m_onSetCallback);
m_pVariable->AddOnSetEnumCallback(&m_onSetEnumCallback);
// Fetch base parameter description
Prop::Description desc(m_pVariable);
@@ -230,14 +233,14 @@ void ReflectedPropertyItem::SetVariable(IVariable *var)
break;
case ePropertyFloat:
case ePropertyAngle:
//if the Description has a valid global enumDB lookup, edit as an enum, otherwise use normal float editor
//if the Description has a valid global enumDB lookup, edit as an enum, otherwise use normal float editor
if (desc.m_pEnumDBItem)
m_reflectedVarAdapter = new ReflectedVarDBEnumAdapter;
else
m_reflectedVarAdapter = new ReflectedVarFloatAdapter;
break;
case ePropertyInt:
//if the Description has a valid global enumDB lookup, edit as an enum, otherwise use normal int editor
//if the Description has a valid global enumDB lookup, edit as an enum, otherwise use normal int editor
if (desc.m_pEnumDBItem)
m_reflectedVarAdapter = new ReflectedVarDBEnumAdapter;
else
@@ -247,7 +250,7 @@ void ReflectedPropertyItem::SetVariable(IVariable *var)
m_reflectedVarAdapter = new ReflectedVarBoolAdapter;
break;
case ePropertyString:
//if the Description has a valid global enumDB lookup, edit as an enum, otherwise use normal string editor
//if the Description has a valid global enumDB lookup, edit as an enum, otherwise use normal string editor
if (desc.m_pEnumDBItem)
m_reflectedVarAdapter = new ReflectedVarDBEnumAdapter;
else
@@ -301,7 +304,7 @@ void ReflectedPropertyItem::SetVariable(IVariable *var)
default:
break;
}
const bool hasChildren = (m_pVariable->GetNumVariables() > 0 || desc.m_type == ePropertyTable || m_pVariable->GetType() == IVariable::ARRAY);
//const bool isNotContainerType = (m_pVariable->GetType() != IVariable::ARRAY && desc.m_type != ePropertyTable && desc.m_type != ePropertyInvalid);
if (hasChildren )
@@ -309,7 +312,7 @@ void ReflectedPropertyItem::SetVariable(IVariable *var)
m_reflectedVarContainerAdapter = new ReflectedVarContainerAdapter(this, m_propertyCtrl, m_reflectedVarAdapter);
m_reflectedVarAdapter = m_reflectedVarContainerAdapter;
}
if (m_reflectedVarAdapter)
{
m_reflectedVarAdapter->SetVariable(m_pVariable);
@@ -474,8 +477,8 @@ void ReflectedPropertyItem::ReleaseVariable()
if (m_pVariable)
{
// Unwire all from variable.
m_pVariable->RemoveOnSetCallback(functor(*this, &ReflectedPropertyItem::OnVariableChange));
m_pVariable->RemoveOnSetEnumCallback(functor(*this, &ReflectedPropertyItem::OnVariableEnumChange));
m_pVariable->RemoveOnSetCallback(&m_onSetCallback);
m_pVariable->RemoveOnSetEnumCallback(&m_onSetEnumCallback);
}
m_pVariable = 0;
delete m_reflectedVarAdapter;
@@ -619,7 +622,7 @@ void ReflectedPropertyItem::SetValue(const QString& sValue, bool bRecordUndo, bo
{
m_pVariable->SetForceModified(true);
}
switch (m_type)
{
case ePropertyColor:
@@ -162,6 +162,11 @@ AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
QString m_strNoScriptDefault;
QString m_strScriptDefault;
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
IVariable::OnSetCallback m_onSetCallback;
IVariable::OnSetEnumCallback m_onSetEnumCallback;
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
};
typedef _smart_ptr<ReflectedPropertyItem> ReflectedPropertyItemPtr;
+1 -1
View File
@@ -70,7 +70,7 @@ public:
void SetTimelineCtrl(TimelineWidget* pTimelineCtrl);
void UpdateToolTip();
typedef Functor1<CSplineCtrl*> UpdateCallback;
typedef AZStd::function<void(CSplineCtrl*)> UpdateCallback;
void SetUpdateCallback(UpdateCallback cb) { m_updateCallback = cb; };
Q_SIGNALS:
@@ -21,6 +21,7 @@
#include "ToolBox.h"
#include "Include/IObjectManager.h"
#include "Objects/SelectionGroup.h"
#include "ViewManager.h"
#include <AzFramework/API/AtomActiveInterface.h>
#include <AzCore/Interface/Interface.h>
@@ -765,7 +766,7 @@ QMenu* LevelEditorMenuHandler::CreateViewMenu()
viewMenu.AddAction(ID_OPEN_QUICK_ACCESS_BAR);
// Layouts
if (!AZ::Interface<AzFramework::AtomActiveInterface>::Get()) // Only supports 1 viewport for now.
if (CViewManager::IsMultiViewportEnabled()) // Only supports 1 viewport for now.
{
// Disable Layouts menu
m_layoutsMenu = viewMenu.AddMenu(tr("Layouts"));
@@ -804,7 +805,7 @@ QMenu* LevelEditorMenuHandler::CreateViewMenu()
viewportViewsMenuWrapper.AddAction(ID_VIEW_GRIDSETTINGS);
viewportViewsMenuWrapper.AddSeparator();
if (!AZ::Interface<AzFramework::AtomActiveInterface>::Get()) // Only supports 1 viewport for now.
if (CViewManager::IsMultiViewportEnabled())
{
viewportViewsMenuWrapper.AddAction(ID_VIEW_CONFIGURELAYOUT);
}
@@ -410,10 +410,9 @@ namespace Editor
}
}
// Ensure that the Windows WM_INPUT messages get passed through to the AzFramework input system,
// but only while in game mode so we don't accumulate raw input events before we start actually
// ticking the input devices, otherwise the queued events will get sent when entering game mode.
if (msg->message == WM_INPUT && GetIEditor()->IsInGameMode())
// Ensure that the Windows WM_INPUT messages get passed through to the AzFramework input system.
// These events are now consumed both in and out of game mode.
if (msg->message == WM_INPUT)
{
UINT rawInputSize;
const UINT rawInputHeaderSize = sizeof(RAWINPUTHEADER);
+19 -1
View File
@@ -5584,13 +5584,19 @@ extern "C"
#pragma comment(lib, "Shell32.lib")
#endif
int SANDBOX_API CryEditMain(int argc, char* argv[])
extern "C" int AZ_DLL_EXPORT CryEditMain(int argc, char* argv[])
{
AZ_Assert(!AZ::AllocatorInstance<AZ::LegacyAllocator>::IsReady(), "Expected allocator to not be initialized, hunt down the static that is initializing it");
AZ::AllocatorInstance<AZ::LegacyAllocator>::Create();
AZ_Assert(!AZ::AllocatorInstance<CryStringAllocator>::IsReady(), "Expected allocator to not be initialized, hunt down the static that is initializing it");
AZ::AllocatorInstance<CryStringAllocator>::Create();
// ensure the EditorEventsBus context gets created inside EditorLib
[[maybe_unused]] const auto& editorEventsContext = AzToolsFramework::EditorEvents::Bus::GetOrCreateContext();
// connect relevant buses to global settings
gSettings.Connect();
CCryEditApp* theApp = new CCryEditApp();
// this does some magic to set the current directory...
{
@@ -5680,7 +5686,19 @@ int SANDBOX_API CryEditMain(int argc, char* argv[])
delete theApp;
gSettings.Disconnect();
return ret;
}
extern "C" AZ_DLL_EXPORT void InitializeDynamicModule(void* env)
{
AZ::Environment::Attach(static_cast<AZ::EnvironmentInstance>(env));
}
extern "C" AZ_DLL_EXPORT void UninitializeDynamicModule()
{
AZ::Environment::Detach();
}
#include <moc_CryEdit.cpp>
+4 -1
View File
@@ -168,7 +168,7 @@ public:
//! \param args Space separated list of arguments to pass to the process on start.
void StartProcessDetached(const char* process, const char* args);
//! Launches the Lua Editor/Debugger (Woodpecker)
//! Launches the Lua Editor/Debugger
//! \param files A space separated list of aliased paths
void OpenLUAEditor(const char* files);
@@ -601,4 +601,7 @@ namespace AzToolsFramework
} // namespace AzToolsFramework
extern "C" AZ_DLL_EXPORT void InitializeDynamicModule(void* env);
extern "C" AZ_DLL_EXPORT void UninitializeDynamicModule();
#endif // CRYINCLUDE_EDITOR_CRYEDIT_H
+7 -3
View File
@@ -470,6 +470,7 @@ void CCryEditDoc::Load(TDocMultiArchive& arrXmlAr, const QString& szFilename)
HEAP_CHECK
if (GetIEditor()->Get3DEngine())
{
CAutoLogTime logtime("Load Terrain");
bool terrainLoaded = GetIEditor()->Get3DEngine()->LoadCompiledOctreeForEditor();
@@ -2183,7 +2184,7 @@ void CCryEditDoc::OnStartLevelResourceList()
void CCryEditDoc::ForceSkyUpdate()
{
ITimeOfDay* pTimeOfDay = gEnv->p3DEngine->GetTimeOfDay();
ITimeOfDay* pTimeOfDay = gEnv->p3DEngine ? gEnv->p3DEngine->GetTimeOfDay() : nullptr;
CMission* pCurMission = GetIEditor()->GetDocument()->GetCurrentMission();
if (pTimeOfDay && pCurMission)
@@ -2269,8 +2270,11 @@ void CCryEditDoc::InitEmptyLevel(int /*resolution*/, int /*unitSize*/, bool /*bU
XmlNodeRef root = GetISystem()->LoadXmlFromFile("@engroot@/Editor/default_time_of_day.xml");
if (root)
{
ITimeOfDay* pTimeOfDay = gEnv->p3DEngine->GetTimeOfDay();
pTimeOfDay->Serialize(root, true);
ITimeOfDay* pTimeOfDay = gEnv->p3DEngine ? gEnv->p3DEngine->GetTimeOfDay() : nullptr;
if (pTimeOfDay)
{
pTimeOfDay->Serialize(root, true);
}
}
}
-2
View File
@@ -541,8 +541,6 @@ namespace AzToolsFramework
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation);
behaviorContext->EnumProperty<ESystemConfigPlatform::CONFIG_IOS>("SystemConfigPlatform_Ios")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation);
behaviorContext->EnumProperty<ESystemConfigPlatform::CONFIG_XENIA>("SystemConfigPlatform_Xenia")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation);
behaviorContext->EnumProperty<ESystemConfigPlatform::CONFIG_PROVO>("SystemConfigPlatform_Provo")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation);
}
+1 -1
View File
@@ -662,7 +662,7 @@ void CDatabaseFrameWnd::DoesItemExist(const QString& itemName, bool& bOutExist)
bOutExist = false;
}
QString CDatabaseFrameWnd::MakeValidName(const QString& candidateName, Functor2<const QString&, bool&> FuncForCheck) const
QString CDatabaseFrameWnd::MakeValidName(const QString& candidateName, AZStd::function<void(const QString&, bool&)> FuncForCheck) const
{
bool bCheck = false;
FuncForCheck(candidateName, bCheck);
+1 -1
View File
@@ -126,7 +126,7 @@ protected:
void LoadLibrary();
QString MakeValidName(const QString& candidateName, Functor2<const QString&, bool&> cb) const;
QString MakeValidName(const QString& candidateName, AZStd::function<void(const QString&, bool&)> cb) const;
virtual QTreeView* GetTreeCtrl() = 0;
virtual const QTreeView* GetTreeCtrl() const = 0;
-2
View File
@@ -137,7 +137,6 @@
#include <ITimer.h>
#include <IXml.h>
#include <IMovieSystem.h>
#include <functor.h>
//////////////////////////////////////////////////////////////////////////
// Commonly used Editor includes.
@@ -155,7 +154,6 @@
// Utility classes.
#include "Util/bitarray.h"
#include "Util/FunctorMulticaster.h"
#include "Util/RefCountBase.h"
#include "Util/TRefCountBase.h"
#include "Util/MemoryBlock.h"
@@ -46,7 +46,7 @@ void CEditorPreferencesPage_General::Reflect(AZ::SerializeContext& serialize)
->Field("ShowNews", &GeneralSettings::m_bShowNews)
->Field("EnableSceneInspector", &GeneralSettings::m_enableSceneInspector)
->Field("RestoreViewportCamera", &GeneralSettings::m_restoreViewportCamera)
;
->Field("PrefabSystem", &GeneralSettings::m_enablePrefabSystem);
serialize.Class<Messaging>()
->Version(2)
@@ -101,7 +101,7 @@ void CEditorPreferencesPage_General::Reflect(AZ::SerializeContext& serialize)
->DataElement(AZ::Edit::UIHandlers::CheckBox, &GeneralSettings::m_stylusMode, "Stylus Mode", "Stylus Mode for tablets and other pointing devices")
->DataElement(AZ::Edit::UIHandlers::CheckBox, &GeneralSettings::m_restoreViewportCamera, EditorPreferencesGeneralRestoreViewportCameraSettingName, "Keep the original editor viewport transform when exiting game mode.")
->DataElement(AZ::Edit::UIHandlers::CheckBox, &GeneralSettings::m_enableSceneInspector, "Enable Scene Inspector (EXPERIMENTAL)", "Enable the option to inspect the internal data loaded from scene files like .fbx. This is an experimental feature. Restart the Scene Settings if the option is not visible under the Help menu.")
;
->DataElement(AZ::Edit::UIHandlers::CheckBox, &GeneralSettings::m_enablePrefabSystem, "Enable Prefab System (EXPERIMENTAL)", "Enable this option to preview Lumberyard's new prefab system. Enabling this setting removes slice support for level entities; you will need to restart the Editor for the change to take effect.");
editContext->Class<Messaging>("Messaging", "")
->DataElement(AZ::Edit::UIHandlers::CheckBox, &Messaging::m_showDashboard, "Show Welcome to Lumberyard at startup", "Show Welcome to Lumberyard at startup")
@@ -172,6 +172,8 @@ void CEditorPreferencesPage_General::OnApply()
gSettings.restoreViewportCamera = m_generalSettings.m_restoreViewportCamera;
gSettings.enableSceneInspector = m_generalSettings.m_enableSceneInspector;
gSettings.prefabSystem = m_generalSettings.m_enablePrefabSystem;
if (static_cast<int>(m_generalSettings.m_toolbarIconSize) != gSettings.gui.nToolbarIconSize)
{
gSettings.gui.nToolbarIconSize = static_cast<int>(m_generalSettings.m_toolbarIconSize);
@@ -193,6 +195,16 @@ void CEditorPreferencesPage_General::OnApply()
//slices
gSettings.sliceSettings.dynamicByDefault = m_sliceSettings.m_slicesDynamicByDefault;
// if the user enabled/disabled the prefab context - notify them that a restart
// is required in order to see the effect of the change
if (gSettings.prefabSystem != m_generalSettings.m_enablePrefabSystemInitialValue)
{
QMessageBox::warning(
AzToolsFramework::GetActiveWindow(), QObject::tr("Restart required"),
QObject::tr("Restart the Editor in order for the Prefab/Slice system changes to take effect.")
);
}
}
void CEditorPreferencesPage_General::InitializeSettings()
@@ -207,6 +219,8 @@ void CEditorPreferencesPage_General::InitializeSettings()
m_generalSettings.m_stylusMode = gSettings.stylusMode;
m_generalSettings.m_restoreViewportCamera = gSettings.restoreViewportCamera;
m_generalSettings.m_enableSceneInspector = gSettings.enableSceneInspector;
m_generalSettings.m_enablePrefabSystem = gSettings.prefabSystem;
m_generalSettings.m_enablePrefabSystemInitialValue = gSettings.prefabSystem;
m_generalSettings.m_toolbarIconSize = static_cast<AzQtComponents::ToolBar::ToolBarIconSize>(gSettings.gui.nToolbarIconSize);
@@ -58,6 +58,10 @@ private:
bool m_restoreViewportCamera;
bool m_bShowNews;
bool m_enableSceneInspector;
bool m_enablePrefabSystem;
// Only used to tell if the user has changed this value since it requires a restart
bool m_enablePrefabSystemInitialValue;
};
struct Messaging
File diff suppressed because it is too large Load Diff
+639
View File
@@ -0,0 +1,639 @@
/*
* 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.
#pragma once
// RenderViewport.h : header file
//
#if !defined(Q_MOC_RUN)
#include <Cry_Camera.h>
#include <QSet>
#include "Viewport.h"
#include "Objects/DisplayContext.h"
#include "Undo/Undo.h"
#include "Util/PredefinedAspectRatios.h"
#include <AzCore/Component/EntityId.h>
#include <AzCore/std/optional.h>
#include <AzFramework/Input/Buses/Requests/InputSystemCursorRequestBus.h>
#include <AzFramework/Scene/SceneSystemBus.h>
#include <AzFramework/Asset/AssetCatalogBus.h>
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
#include <AzToolsFramework/API/EditorCameraBus.h>
#include <AzToolsFramework/Entity/EditorEntityContextBus.h>
#include <AzToolsFramework/Viewport/ViewportMessages.h>
#include <MathConversion.h>
#include <Atom/RPI.Public/ViewportContext.h>
#endif
#include <AzFramework/Windowing/WindowBus.h>
#include <AzFramework/Visibility/EntityVisibilityQuery.h>
// forward declarations.
class CBaseObject;
class QMenu;
class QKeyEvent;
struct ray_hit;
struct IRenderMesh;
struct IVariable;
namespace AZ::ViewportHelpers
{
class EditorEntityNotifications;
} //namespace AZ::ViewportHelpers
namespace AtomToolsFramework
{
class RenderViewportWidget;
}
namespace AzToolsFramework
{
class ManipulatorManager;
}
// EditorViewportWidget window
AZ_PUSH_DISABLE_DLL_EXPORT_BASECLASS_WARNING
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
class SANDBOX_API EditorViewportWidget
: public QtViewport
, public IEditorNotifyListener
, public IUndoManagerListener
, public Camera::EditorCameraRequestBus::Handler
, public AzFramework::InputSystemCursorConstraintRequestBus::Handler
, public AzToolsFramework::ViewportInteraction::ViewportFreezeRequestBus::Handler
, public AzToolsFramework::ViewportInteraction::MainEditorViewportInteractionRequestBus::Handler
, public AzFramework::AssetCatalogEventBus::Handler
{
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
AZ_POP_DISABLE_DLL_EXPORT_BASECLASS_WARNING
Q_OBJECT
public:
struct SResolution
{
SResolution()
: width(0)
, height(0)
{
}
SResolution(int w, int h)
: width(w)
, height(h)
{
}
int width;
int height;
};
public:
EditorViewportWidget(const QString& name, QWidget* parent = nullptr);
static const GUID& GetClassID()
{
return QtViewport::GetClassID<EditorViewportWidget>();
}
/** Get type of this viewport.
*/
virtual EViewportType GetType() const { return ET_ViewportCamera; }
virtual void SetType([[maybe_unused]] EViewportType type) { assert(type == ET_ViewportCamera); };
virtual ~EditorViewportWidget();
Q_INVOKABLE void InjectFakeMouseMove(int deltaX, int deltaY, Qt::MouseButtons buttons);
// Replacement for still used CRenderer methods
void UnProjectFromScreen(float sx, float sy, float sz, float* px, float* py, float* pz) const;
void ProjectToScreen(float ptx, float pty, float ptz, float* sx, float* sy, float* sz) const;
public:
virtual void Update();
virtual void ResetContent();
virtual void UpdateContent(int flags);
void OnTitleMenu(QMenu* menu) override;
void SetCamera(const CCamera& camera);
const CCamera& GetCamera() const { return m_Camera; };
virtual void SetViewTM(const Matrix34& tm)
{
if (m_viewSourceType == ViewSourceType::None)
{
m_defaultViewTM = tm;
}
SetViewTM(tm, false);
}
//! Map world space position to viewport position.
virtual QPoint WorldToView(const Vec3& wp) const;
virtual QPoint WorldToViewParticleEditor(const Vec3& wp, int width, int height) const;
virtual Vec3 WorldToView3D(const Vec3& wp, int nFlags = 0) const;
//! Map viewport position to world space position.
virtual Vec3 ViewToWorld(const QPoint& vp, bool* collideWithTerrain = nullptr, bool onlyTerrain = false, bool bSkipVegetation = false, bool bTestRenderMesh = false, bool* collideWithObject = nullptr) const override;
virtual void ViewToWorldRay(const QPoint& vp, Vec3& raySrc, Vec3& rayDir) const override;
virtual Vec3 ViewToWorldNormal(const QPoint& vp, bool onlyTerrain, bool bTestRenderMesh = false) override;
virtual float GetScreenScaleFactor(const Vec3& worldPoint) const;
virtual float GetScreenScaleFactor(const CCamera& camera, const Vec3& object_position);
virtual float GetAspectRatio() const;
virtual bool HitTest(const QPoint& point, HitContext& hitInfo);
virtual bool IsBoundsVisible(const AABB& box) const;
virtual void CenterOnSelection();
virtual void CenterOnAABB(const AABB& aabb);
void CenterOnSliceInstance() override;
void focusOutEvent(QFocusEvent* event) override;
void keyPressEvent(QKeyEvent* event) override;
void SetFOV(float fov);
float GetFOV() const;
void SetDefaultCamera();
bool IsDefaultCamera() const;
void SetSequenceCamera();
bool IsSequenceCamera() const { return m_viewSourceType == ViewSourceType::SequenceCamera; }
void SetSelectedCamera();
bool IsSelectedCamera() const;
void SetComponentCamera(const AZ::EntityId& entityId);
void SetEntityAsCamera(const AZ::EntityId& entityId, bool lockCameraMovement = false);
void SetFirstComponentCamera();
void SetViewEntity(const AZ::EntityId& cameraEntityId, bool lockCameraMovement = false);
void PostCameraSet();
// This switches the active camera to the next one in the list of (default, all custom cams).
void CycleCamera();
// Camera::EditorCameraRequestBus
void SetViewFromEntityPerspective(const AZ::EntityId& entityId) override;
void SetViewAndMovementLockFromEntityPerspective(const AZ::EntityId& entityId, bool lockCameraMovement) override;
AZ::EntityId GetCurrentViewEntityId() override { return m_viewEntityId; }
bool GetActiveCameraPosition(AZ::Vector3& cameraPos) override;
// AzToolsFramework::EditorEntityContextNotificationBus (handler moved to cpp to resolve link issues in unity builds)
virtual void OnStartPlayInEditor();
virtual void OnStopPlayInEditor();
// AzToolsFramework::EditorEvents::Bus (handler moved to cpp to resolve link issues in unity builds)
// We use this to determine when the viewport context menu is being displayed so we can exit move mode
void PopulateEditorGlobalContextMenu(QMenu* /*menu*/, const AZ::Vector2& /*point*/, int /*flags*/);
// AzToolsFramework::ViewportInteractionRequestBus
AzFramework::CameraState GetCameraState();
bool GridSnappingEnabled();
float GridSize();
bool ShowGrid();
bool AngleSnappingEnabled();
float AngleStep();
QPoint ViewportWorldToScreen(const AZ::Vector3& worldPosition);
// AzToolsFramework::ViewportFreezeRequestBus
bool IsViewportInputFrozen() override;
void FreezeViewportInput(bool freeze) override;
// AzToolsFramework::MainEditorViewportInteractionRequestBus
AZ::EntityId PickEntity(const QPoint& point) override;
AZ::Vector3 PickTerrain(const QPoint& point) override;
float TerrainHeight(const AZ::Vector2& position) override;
void FindVisibleEntities(AZStd::vector<AZ::EntityId>& visibleEntitiesOut) override;
bool ShowingWorldSpace() override;
QWidget* GetWidgetForViewportContextMenu() override;
void BeginWidgetContext() override;
void EndWidgetContext() override;
// CViewport...
void SetViewportId(int id) override;
void ConnectViewportInteractionRequestBus();
void DisconnectViewportInteractionRequestBus();
void LockCameraMovement(bool bLock) { m_bLockCameraMovement = bLock; }
bool IsCameraMovementLocked() const { return m_bLockCameraMovement; }
void EnableCameraObjectMove(bool bMove) { m_bMoveCameraObject = bMove; }
bool IsCameraObjectMove() const { return m_bMoveCameraObject; }
void SetPlayerControl(uint32 i) { m_PlayerControl = i; };
uint32 GetPlayerControl() { return m_PlayerControl; };
const DisplayContext& GetDisplayContext() const { return m_displayContext; }
CBaseObject* GetCameraObject() const;
QPoint WidgetToViewport(const QPoint& point) const;
QPoint ViewportToWidget(const QPoint& point) const;
QSize WidgetToViewport(const QSize& size) const;
/// Take raw input and create a final mouse interaction.
/// @attention Do not map **point** from widget to viewport explicitly,
/// this is handled internally by BuildMouseInteraction - just pass directly.
AzToolsFramework::ViewportInteraction::MouseInteraction BuildMouseInteraction(
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, const QPoint& point);
void SetPlayerPos()
{
Matrix34 m = GetViewTM();
m.SetTranslation(m.GetTranslation() - m_PhysicalLocation.t);
SetViewTM(m);
m_AverageFrameTime = 0.14f;
m_PhysicalLocation.SetIdentity();
m_LocalEntityMat.SetIdentity();
m_PrevLocalEntityMat.SetIdentity();
m_absCameraHigh = 2.0f;
m_absCameraPos = Vec3(0, 3, 2);
m_absCameraPosVP = Vec3(0, -3, 1.5);
m_absCurrentSlope = 0.0f;
m_absLookDirectionXY = Vec2(0, 1);
m_LookAt = Vec3(ZERO);
m_LookAtRate = Vec3(ZERO);
m_vCamPos = Vec3(ZERO);
m_vCamPosRate = Vec3(ZERO);
m_relCameraRotX = 0;
m_relCameraRotZ = 0;
uint32 numSample6 = m_arrAnimatedCharacterPath.size();
for (uint32 i = 0; i < numSample6; i++)
{
m_arrAnimatedCharacterPath[i] = Vec3(ZERO);
}
numSample6 = m_arrSmoothEntityPath.size();
for (uint32 i = 0; i < numSample6; i++)
{
m_arrSmoothEntityPath[i] = Vec3(ZERO);
}
uint32 numSample7 = m_arrRunStrafeSmoothing.size();
for (uint32 i = 0; i < numSample7; i++)
{
m_arrRunStrafeSmoothing[i] = 0;
}
m_vWorldDesiredBodyDirection = Vec2(0, 1);
m_vWorldDesiredBodyDirectionSmooth = Vec2(0, 1);
m_vWorldDesiredBodyDirectionSmoothRate = Vec2(0, 1);
m_vWorldDesiredBodyDirection2 = Vec2(0, 1);
m_vWorldDesiredMoveDirection = Vec2(0, 1);
m_vWorldDesiredMoveDirectionSmooth = Vec2(0, 1);
m_vWorldDesiredMoveDirectionSmoothRate = Vec2(0, 1);
m_vLocalDesiredMoveDirection = Vec2(0, 1);
m_vLocalDesiredMoveDirectionSmooth = Vec2(0, 1);
m_vLocalDesiredMoveDirectionSmoothRate = Vec2(0, 1);
m_vWorldAimBodyDirection = Vec2(0, 1);
m_MoveSpeedMSec = 5.0f;
m_key_W = 0;
m_keyrcr_W = 0;
m_key_S = 0;
m_keyrcr_S = 0;
m_key_A = 0;
m_keyrcr_A = 0;
m_key_D = 0;
m_keyrcr_D = 0;
m_key_SPACE = 0;
m_keyrcr_SPACE = 0;
m_ControllMode = 0;
m_State = -1;
m_Stance = 1; //combat
m_udGround = 0.0f;
m_lrGround = 0.0f;
AABB aabb = AABB(Vec3(-40.0f, -40.0f, -0.25f), Vec3(+40.0f, +40.0f, +0.0f));
m_GroundOBB = OBB::CreateOBBfromAABB(Matrix33(IDENTITY), aabb);
m_GroundOBBPos = Vec3(0, 0, -0.01f);
};
static EditorViewportWidget* GetPrimaryViewport();
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
CCamera m_Camera;
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
protected:
struct SScopedCurrentContext;
void SetViewTM(const Matrix34& tm, bool bMoveOnly);
virtual float GetCameraMoveSpeed() const;
virtual float GetCameraRotateSpeed() const;
virtual bool GetCameraInvertYRotation() const;
virtual float GetCameraInvertPan() const;
// Called to render stuff.
virtual void OnRender();
virtual void OnEditorNotifyEvent(EEditorNotifyEvent event);
//! Get currently active camera object.
void ToggleCameraObject();
void RenderConstructionPlane();
void RenderSnapMarker();
void RenderCursorString();
void RenderSnappingGrid();
void RenderAll();
void DrawAxis();
void DrawBackground();
void InitDisplayContext();
struct SPreviousContext
{
CCamera rendererCamera;
HWND window;
int width;
int height;
bool mainViewport;
};
SPreviousContext m_preWidgetContext;
// Create an auto-sized render context that is sized based on the Editor's current
// viewport.
SPreviousContext SetCurrentContext() const;
SPreviousContext SetCurrentContext(int newWidth, int newHeight) const;
void RestorePreviousContext(const SPreviousContext& x) const;
void PreWidgetRendering() override;
void PostWidgetRendering() override;
// Update the safe frame, safe action, safe title, and borders rectangles based on
// viewport size and target aspect ratio.
void UpdateSafeFrame();
// Draw safe frame, safe action, safe title rectangles and borders.
void RenderSafeFrame();
// Draw one of the safe frame rectangles with the desired color.
void RenderSafeFrame(const QRect& frame, float r, float g, float b, float a);
// Draw the selection rectangle.
void RenderSelectionRectangle();
// Draw a selected region if it has been selected
void RenderSelectedRegion();
virtual bool CreateRenderContext();
virtual void DestroyRenderContext();
void OnMenuCommandChangeAspectRatio(unsigned int commandId);
bool AdjustObjectPosition(const ray_hit& hit, Vec3& outNormal, Vec3& outPos) const;
bool RayRenderMeshIntersection(IRenderMesh* pRenderMesh, const Vec3& vInPos, const Vec3& vInDir, Vec3& vOutPos, Vec3& vOutNormal) const;
bool AddCameraMenuItems(QMenu* menu);
void ResizeView(int width, int height);
void OnCameraFOVVariableChanged(IVariable* var);
void HideCursor();
void ShowCursor();
bool IsKeyDown(Qt::Key key) const;
enum class ViewSourceType
{
None,
SequenceCamera,
LegacyCamera,
CameraComponent,
AZ_Entity,
ViewSourceTypesCount,
};
void ResetToViewSourceType(const ViewSourceType& viewSourType);
//! Assigned renderer.
IRenderer* m_renderer = nullptr;
I3DEngine* m_engine = nullptr;
bool m_bRenderContextCreated = false;
bool m_bInRotateMode = false;
bool m_bInMoveMode = false;
bool m_bInOrbitMode = false;
bool m_bInZoomMode = false;
QPoint m_mousePos = QPoint(0, 0);
QPoint m_prevMousePos = QPoint(0, 0); // for tablets, you can't use SetCursorPos and need to remember the prior point and delta with that.
float m_moveSpeed = 1;
float m_orbitDistance = 10.0f;
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
Vec3 m_orbitTarget;
//-------------------------------------------
//--- player-control in CharEdit ---
//-------------------------------------------
f32 m_MoveSpeedMSec;
uint32 m_key_W, m_keyrcr_W;
uint32 m_key_S, m_keyrcr_S;
uint32 m_key_A, m_keyrcr_A;
uint32 m_key_D, m_keyrcr_D;
uint32 m_key_SPACE, m_keyrcr_SPACE;
uint32 m_ControllMode;
int32 m_Stance;
int32 m_State;
f32 m_AverageFrameTime;
uint32 m_PlayerControl = 0;
f32 m_absCameraHigh;
Vec3 m_absCameraPos;
Vec3 m_absCameraPosVP;
f32 m_absCurrentSlope; //in radiants
Vec2 m_absLookDirectionXY;
Vec3 m_LookAt;
Vec3 m_LookAtRate;
Vec3 m_vCamPos;
Vec3 m_vCamPosRate;
float m_camFOV;
f32 m_relCameraRotX;
f32 m_relCameraRotZ;
QuatTS m_PhysicalLocation;
Matrix34 m_AnimatedCharacterMat;
Matrix34 m_LocalEntityMat; //this is used for data-driven animations where the character is running on the spot
Matrix34 m_PrevLocalEntityMat;
std::vector<Vec3> m_arrVerticesHF;
std::vector<vtx_idx> m_arrIndicesHF;
std::vector<Vec3> m_arrAnimatedCharacterPath;
std::vector<Vec3> m_arrSmoothEntityPath;
std::vector<f32> m_arrRunStrafeSmoothing;
Vec2 m_vWorldDesiredBodyDirection;
Vec2 m_vWorldDesiredBodyDirectionSmooth;
Vec2 m_vWorldDesiredBodyDirectionSmoothRate;
Vec2 m_vWorldDesiredBodyDirection2;
Vec2 m_vWorldDesiredMoveDirection;
Vec2 m_vWorldDesiredMoveDirectionSmooth;
Vec2 m_vWorldDesiredMoveDirectionSmoothRate;
Vec2 m_vLocalDesiredMoveDirection;
Vec2 m_vLocalDesiredMoveDirectionSmooth;
Vec2 m_vLocalDesiredMoveDirectionSmoothRate;
Vec2 m_vWorldAimBodyDirection;
f32 m_udGround;
f32 m_lrGround;
OBB m_GroundOBB;
Vec3 m_GroundOBBPos;
//-------------------------------------------
// Render options.
bool m_bRenderStats = true;
// Index of camera objects.
mutable GUID m_cameraObjectId;
mutable AZ::EntityId m_viewEntityId;
mutable ViewSourceType m_viewSourceType = ViewSourceType::None;
AZ::EntityId m_viewEntityIdCachedForEditMode;
Matrix34 m_preGameModeViewTM;
uint m_disableRenderingCount = 0;
bool m_bLockCameraMovement;
bool m_bUpdateViewport = false;
bool m_bMoveCameraObject = true;
enum class KeyPressedState
{
AllUp,
PressedThisFrame,
PressedInPreviousFrame,
};
KeyPressedState m_pressedKeyState = KeyPressedState::AllUp;
Matrix34 m_defaultViewTM;
const QString m_defaultViewName;
DisplayContext m_displayContext;
bool m_isOnPaint = false;
static EditorViewportWidget* m_pPrimaryViewport;
QRect m_safeFrame;
QRect m_safeAction;
QRect m_safeTitle;
CPredefinedAspectRatios m_predefinedAspectRatios;
IVariable* m_pCameraFOVVariable = nullptr;
bool m_bCursorHidden = false;
void OnMenuResolutionCustom();
void OnMenuCreateCameraEntityFromCurrentView();
void OnMenuSelectCurrentCamera();
int OnCreate();
void resizeEvent(QResizeEvent* event) override;
void paintEvent(QPaintEvent* event) override;
void mousePressEvent(QMouseEvent* event) override;
// From a series of input primitives, compose a complete mouse interaction.
AzToolsFramework::ViewportInteraction::MouseInteraction BuildMouseInteractionInternal(
AzToolsFramework::ViewportInteraction::MouseButtons buttons,
AzToolsFramework::ViewportInteraction::KeyboardModifiers modifiers,
const AzToolsFramework::ViewportInteraction::MousePick& mousePick) const;
// Given a point in the viewport, return the pick ray into the scene.
// note: The argument passed to parameter **point**, originating
// from a Qt event, must first be passed to WidgetToViewport before being
// passed to BuildMousePick.
AzToolsFramework::ViewportInteraction::MousePick BuildMousePick(const QPoint& point);
bool event(QEvent* event) override;
void OnDestroy();
bool CheckRespondToInput() const;
// AzFramework::InputSystemCursorConstraintRequestBus
void* GetSystemCursorConstraintWindow() const override { return renderOverlayHWND(); }
void BuildDragDropContext(AzQtComponents::ViewportDragContext& context, const QPoint& pt) override;
private:
void PushDisableRendering();
void PopDisableRendering();
bool IsRenderingDisabled() const;
AzToolsFramework::ViewportInteraction::MousePick BuildMousePickInternal(
const QPoint& point) const;
void RestoreViewportAfterGameMode();
void UpdateCameraFromViewportContext();
double WidgetToViewportFactor() const
{
#if defined(AZ_PLATFORM_WINDOWS)
// Needed for high DPI mode on windows
return devicePixelRatioF();
#else
return 1.0f;
#endif
}
void BeginUndoTransaction() override;
void EndUndoTransaction() override;
void UpdateCurrentMousePos(const QPoint& newPosition);
void UpdateScene();
AzFramework::EntityVisibilityQuery m_entityVisibilityQuery;
SPreviousContext m_previousContext;
QSet<int> m_keyDown;
bool m_freezeViewportInput = false;
size_t m_cameraSetForWidgetRenderingCount = 0; ///< How many calls to PreWidgetRendering happened before
///< subsequent calls to PostWidetRendering.
AZStd::shared_ptr<AzToolsFramework::ManipulatorManager> m_manipulatorManager;
// Used to prevent circular set camera events
bool m_ignoreSetViewFromEntityPerspective = false;
bool m_windowResizedEvent = false;
AZStd::unique_ptr<AZ::ViewportHelpers::EditorEntityNotifications> m_editorEntityNotifications;
AtomToolsFramework::RenderViewportWidget* m_renderViewport = nullptr;
bool m_updatingCameraPosition = false;
AZ::RPI::ViewportContext::MatrixChangedEvent::Handler m_cameraViewMatrixChangeHandler;
AZ::RPI::ViewportContext::MatrixChangedEvent::Handler m_cameraProjectionMatrixChangeHandler;
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
};
+5 -3
View File
@@ -42,12 +42,14 @@ CEnvironmentPanel::CEnvironmentPanel(QWidget* pParent /*=nullptr*/)
if (bHasOceanFeature)
{
node->findChild("Ocean")->setAttr("hidden", true);
node->findChild("OceanAnimation")->setAttr("hidden", true);
node->findChild("OceanAnimation")->setAttr("hidden", true);
}
m_onSetCallback = AZStd::bind(&CCryEditDoc::OnEnvironmentPropertyChanged, GetIEditor()->GetDocument(), AZStd::placeholders::_1);
ui->setupUi(this);
ui->m_wndProps->Setup();
ui->m_wndProps->CreateItems(node, m_varBlock, functor(*GetIEditor()->GetDocument(), &CCryEditDoc::OnEnvironmentPropertyChanged), true);
ui->m_wndProps->CreateItems(node, m_varBlock, &m_onSetCallback, true);
ui->m_wndProps->RebuildCtrl(false);
ui->m_wndProps->ExpandAll();
connect(ui->APPLYBTN, &QPushButton::clicked, this, &CEnvironmentPanel::OnBnClickedApply);
+2
View File
@@ -46,6 +46,8 @@ public:
private:
QScopedPointer<Ui::CEnvironmentPanel> ui;
IVariable::OnSetCallback m_onSetCallback;
};
#endif // CRYINCLUDE_EDITOR_ENVIRONMENTPANEL_H
+21 -46
View File
@@ -639,14 +639,13 @@ bool CGameEngine::LoadLevel(
if (physicsEntityGridSize <= 0)
{
ICVar* pCvar = m_pISystem->GetIConsole()->GetCVar("e_PhysEntityGridSizeDefault");
AZ_Assert(pCvar, "The CVAR e_PhysEntityGridSizeDefault is not defined");
physicsEntityGridSize = pCvar->GetIVal();
physicsEntityGridSize = pCvar ? pCvar->GetIVal() : 4096;
}
}
// Load level in 3d engine.
if (!gEnv->p3DEngine->InitLevelForEditor(m_levelPath.toUtf8().data(), m_missionName.toUtf8().data()))
if (gEnv->p3DEngine && !gEnv->p3DEngine->InitLevelForEditor(m_levelPath.toUtf8().data(), m_missionName.toUtf8().data()))
{
CLogFile::WriteLine("ERROR: Can't load level !");
QMessageBox::critical(QApplication::activeWindow(), QString(), QObject::tr("ERROR: Can't load level !"));
@@ -761,7 +760,10 @@ void CGameEngine::SwitchToInGame()
pRuler->SetActive(false);
}
gEnv->p3DEngine->GetTimeOfDay()->EndEditMode();
if (gEnv->p3DEngine)
{
gEnv->p3DEngine->GetTimeOfDay()->EndEditMode();
}
gEnv->pSystem->GetViewCamera().SetMatrix(m_playerViewTM);
// Disable accelerators.
@@ -808,10 +810,13 @@ void CGameEngine::SwitchToInEditor()
CViewport* pGameViewport = GetIEditor()->GetViewManager()->GetGameViewport();
m_pISystem->GetIMovieSystem()->EnablePhysicsEvents(m_bSimulationMode);
gEnv->p3DEngine->GetTimeOfDay()->BeginEditMode();
if (gEnv->p3DEngine)
{
gEnv->p3DEngine->GetTimeOfDay()->BeginEditMode();
// this has to be done before the RemoveSink() call, or else some entities may not be removed
gEnv->p3DEngine->GetDeferredPhysicsEventManager()->ClearDeferredEvents();
// this has to be done before the RemoveSink() call, or else some entities may not be removed
gEnv->p3DEngine->GetDeferredPhysicsEventManager()->ClearDeferredEvents();
}
// Enable accelerators.
GetIEditor()->EnableAcceleratos(true);
@@ -1097,40 +1102,6 @@ void CGameEngine::Update()
if (m_bInGameMode)
{
CViewport* pRenderViewport = GetIEditor()->GetViewManager()->GetGameViewport();
// if we're in editor mode, match the width, height and Fov, but alter no other parameters
if (pRenderViewport)
{
int width = 640;
int height = 480;
pRenderViewport->GetDimensions(&width, &height);
// Check for custom width and height cvars in use by Track View.
// The backbuffer size maybe have been changed, so we need to make sure the viewport
// is setup with the correct aspect ratio here so the captured output will look correct.
ICVar* cVar = gEnv->pConsole->GetCVar("TrackViewRenderOutputCapturing");
if (cVar && cVar->GetIVal() != 0)
{
const int customWidth = gEnv->pConsole->GetCVar("r_CustomResWidth")->GetIVal();
const int customHeight = gEnv->pConsole->GetCVar("r_CustomResHeight")->GetIVal();
if (customWidth != 0 && customHeight != 0)
{
IEditor* editor = GetIEditor();
AZ_Assert(editor, "Expected valid Editor");
IRenderer* renderer = editor->GetRenderer();
AZ_Assert(renderer, "Expected valid Renderer");
int maxRes = renderer->GetMaxSquareRasterDimension();
width = clamp_tpl(customWidth, 32, maxRes);
height = clamp_tpl(customHeight, 32, maxRes);
}
}
CCamera& cam = gEnv->pSystem->GetViewCamera();
cam.SetFrustum(width, height, pRenderViewport->GetFOV(), cam.GetNearPlane(), cam.GetFarPlane(), cam.GetPixelAspectRatio());
}
if (gEnv->pSystem)
{
gEnv->pSystem->UpdatePreTickBus();
@@ -1138,10 +1109,8 @@ void CGameEngine::Update()
gEnv->pSystem->UpdatePostTickBus();
}
// TODO: still necessary after AVI recording removal?
if (pRenderViewport)
if (CViewport* pRenderViewport = GetIEditor()->GetViewManager()->GetGameViewport())
{
// Make sure we at least try to update game viewport (Needed for AVI recording).
pRenderViewport->Update();
}
}
@@ -1208,12 +1177,18 @@ void CGameEngine::OnEditorNotifyEvent(EEditorNotifyEvent event)
void CGameEngine::LockResources()
{
gEnv->p3DEngine->LockCGFResources();
if (gEnv->p3DEngine)
{
gEnv->p3DEngine->LockCGFResources();
}
}
void CGameEngine::UnlockResources()
{
gEnv->p3DEngine->UnlockCGFResources();
if (gEnv->p3DEngine)
{
gEnv->p3DEngine->UnlockCGFResources();
}
}
void CGameEngine::OnTerrainModified(const Vec2& modPosition, float modAreaRadius, bool fullTerrain)
+44 -16
View File
@@ -196,6 +196,8 @@ bool CGameExporter::Export(unsigned int flags, [[maybe_unused]] EEndian eExportE
////////////////////////////////////////////////////////////////////////
if (exportSuccessful)
{
ExportVisAreas(sLevelPath.toUtf8().data(), eExportEndian);
////////////////////////////////////////////////////////////////////////
// Exporting map setttings
////////////////////////////////////////////////////////////////////////
@@ -223,9 +225,6 @@ bool CGameExporter::Export(unsigned int flags, [[maybe_unused]] EEndian eExportE
pEditor->SetStatusText(QObject::tr("Ready"));
// Disabled, for now. (inside EncryptPakFile)
EncryptPakFile(m_levelPak.m_sPath);
// Reopen this pak file.
if (!OpenLevelPack(m_levelPak, true))
{
@@ -262,6 +261,48 @@ bool CGameExporter::Export(unsigned int flags, [[maybe_unused]] EEndian eExportE
}
//////////////////////////////////////////////////////////////////////////
void CGameExporter::ExportVisAreas(const char* pszGamePath, EEndian eExportEndian)
{
char szFileOutputPath[_MAX_PATH];
// export visareas
IEditor* pEditor = GetIEditor();
// remove old files
sprintf_s(szFileOutputPath, "%s%s", pszGamePath, COMPILED_VISAREA_MAP_FILE_NAME);
m_levelPak.m_pakFile.RemoveFile(szFileOutputPath);
SHotUpdateInfo* pExportInfo = NULL;
SHotUpdateInfo exportInfo;
I3DEngine* p3DEngine = pEditor->Get3DEngine();
if (eExportEndian == GetPlatformEndian()) // skip second export, this data is common for PC and consoles
{
std::vector<struct IStatObj*>* pTempBrushTable = NULL;
std::vector<_smart_ptr<IMaterial>>* pTempMatsTable = NULL;
std::vector<struct IStatInstGroup*>* pTempVegGroupTable = NULL;
// export visareas
CLogFile::WriteLine("Exporting indoors...");
pEditor->SetStatusText("Exporting indoors...");
if (IVisAreaManager* pVisAreaManager = p3DEngine->GetIVisAreaManager())
{
if (int nSize = pVisAreaManager->GetCompiledDataSize())
{ // get visareas data from 3dengine and save it into file
uint8* pData = new uint8[nSize];
pVisAreaManager->GetCompiledData(pData, nSize, &pTempBrushTable, &pTempMatsTable, &pTempVegGroupTable, eExportEndian);
sprintf_s(szFileOutputPath, "%s%s", pszGamePath, COMPILED_VISAREA_MAP_FILE_NAME);
CCryMemFile visareasCompiledFile;
visareasCompiledFile.Write(pData, nSize);
m_levelPak.m_pakFile.UpdateFile(szFileOutputPath, visareasCompiledFile);
delete[] pData;
}
}
}
}
//////////////////////////////////////////////////////////////////////////
void CGameExporter::ExportOcclusionMesh(const char* pszGamePath)
{
@@ -464,19 +505,6 @@ void CGameExporter::ExportMapInfo(XmlNodeRef& node)
GetIEditor()->GetObjectManager()->GetPhysicsManager()->SerializeCollisionClasses(xmlAr);
}
void CGameExporter::EncryptPakFile([[maybe_unused]] QString& rPakFilename)
{
// Disabled, for now. (inside EncryptPakFile)
#if 0
CString args;
args.Format("/zip_encrypt=1 \"%s\"", rPakFilename.GetBuffer());
Log("Encrypting PAK: %s", rPakFilename.GetBuffer());
// Will need porting to QProcess when EncryptPakFile is enabled again
::ShellExecute(AfxGetMainWnd()->GetSafeHwnd(), "open", "Bin32\\rc\\rc.exe", args, "", SW_HIDE);
#endif
}
//////////////////////////////////////////////////////////////////////////
void CGameExporter::ExportMaterials(XmlNodeRef& levelDataNode, const QString& path)
{
+1 -1
View File
@@ -62,7 +62,6 @@ public:
CGameExporter();
~CGameExporter();
static const char* GetLevelPakFilename() { return "level.pak"; }
static void EncryptPakFile(QString& rPakFilename);
SGameExporterSettings& GetSettings() { return m_settings; }
SLevelPakHelper& GetLevelPack() { return m_levelPak; }
@@ -80,6 +79,7 @@ private:
void ExportLevelData(const QString& path, bool bExportMission = true);
void ExportLevelInfo(const QString& path);
void ExportVisAreas(const char* pszGamePath, EEndian eExportEndian);
void ExportOcclusionMesh(const char* pszGamePath);
void ExportMapInfo(XmlNodeRef& node);
+14 -12
View File
@@ -16,13 +16,12 @@
#pragma once
#ifdef PLUGIN_EXPORTS
#define PLUGIN_API DLL_EXPORT
#define PLUGIN_API DLL_EXPORT
#else
#define PLUGIN_API DLL_IMPORT
#define PLUGIN_API DLL_IMPORT
#endif
#include <ISystem.h>
#include <functor.h>
#include "Include/SandboxAPI.h"
#include "Util/UndoUtil.h"
#include <CryVersion.h>
@@ -258,7 +257,9 @@ struct IEditorNotifyListener
bool m_bIsRegistered;
IEditorNotifyListener()
: m_bIsRegistered(false) {}
: m_bIsRegistered(false)
{
}
virtual ~IEditorNotifyListener()
{
if (m_bIsRegistered)
@@ -351,10 +352,10 @@ enum EMouseEvent
//! Viewports update flags
enum UpdateConentFlags
{
eUpdateHeightmap = 0x01,
eUpdateStatObj = 0x02,
eUpdateObjects = 0x04, //! Update objects in viewport.
eRedrawViewports = 0x08 //! Just redraw viewports..
eUpdateHeightmap = 0x01,
eUpdateStatObj = 0x02,
eUpdateObjects = 0x04, //! Update objects in viewport.
eRedrawViewports = 0x08 //! Just redraw viewports..
};
enum MouseCallbackFlags
@@ -404,7 +405,7 @@ struct IPickObjectCallback
//! 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; }
virtual bool IsNeedSpecificBehaviorForSpaceAcce() { return false; }
};
//! Class provided by editor for various registration functions.
@@ -551,7 +552,7 @@ struct IEditor
virtual SFileVersion GetProductVersion() = 0;
//! Retrieve pointer to game engine instance
virtual CGameEngine* GetGameEngine() = 0;
virtual CDisplaySettings* GetDisplaySettings() = 0;
virtual CDisplaySettings* GetDisplaySettings() = 0;
virtual const SGizmoParameters& GetGlobalGizmoParameters() = 0;
//! Create new object
virtual CBaseObject* NewObject(const char* typeName, const char* fileName = "", const char* name = "", float x = 0.0f, float y = 0.0f, float z = 0.0f, bool modifyDoc = true) = 0;
@@ -705,7 +706,7 @@ struct IEditor
//! Opens standard color selection dialog.
//! Initialized with the color specified in color parameter.
//! Returns true if selection is made and false if selection is canceled.
virtual bool SelectColor(QColor &color, QWidget *parent = 0) = 0;
virtual bool SelectColor(QColor& color, QWidget* parent = 0) = 0;
//! Get shader enumerator.
virtual class CShaderEnum* GetShaderEnum() = 0;
virtual class CUndoManager* GetUndoManager() = 0;
@@ -801,7 +802,7 @@ struct IEditor
virtual void ShowStatusText(bool bEnable) = 0;
// Provides a way to extend the context menu of an object. The function gets called every time the menu is opened.
typedef Functor2<QMenu*, const CBaseObject*> TContextMenuExtensionFunc;
typedef AZStd::function<void(QMenu*, const CBaseObject*)> TContextMenuExtensionFunc;
virtual void RegisterObjectContextMenuExtension(TContextMenuExtensionFunc func) = 0;
virtual void SetCurrentMissionTime(float time) = 0;
@@ -819,6 +820,7 @@ struct IEditor
virtual void LoadPlugins() = 0;
virtual bool IsNewViewportInteractionModelEnabled() const = 0;
virtual bool IsPrefabSystemEnabled() const = 0;
};
//! Callback used by editor when initializing for info in UI dialogs
+8
View File
@@ -213,6 +213,9 @@ CEditorImpl::CEditorImpl()
SetPrimaryCDFolder();
gSettings.Load();
// retrieve this after the settings have been loaded
m_isPrefabSystemEnabled = gSettings.prefabSystem;
m_pErrorReport = new CErrorReport;
m_pClassFactory = CClassFactory::Instance();
m_pCommandManager = new CEditorCommandManager;
@@ -2095,6 +2098,11 @@ bool CEditorImpl::IsNewViewportInteractionModelEnabled() const
return m_isNewViewportInteractionModelEnabled;
}
bool CEditorImpl::IsPrefabSystemEnabled() const
{
return m_isPrefabSystemEnabled;
}
void CEditorImpl::OnStartPlayInEditor()
{
if (SelectionContainsComponentEntities())
+2
View File
@@ -361,6 +361,7 @@ public:
void DestroyQMimeData(QMimeData* data) const override;
bool IsNewViewportInteractionModelEnabled() const override;
bool IsPrefabSystemEnabled() const override;
protected:
@@ -478,5 +479,6 @@ protected:
static const char* m_crashLogFileName;
bool m_isNewViewportInteractionModelEnabled = true;
bool m_isPrefabSystemEnabled = false;
};
+1 -1
View File
@@ -117,7 +117,7 @@ int CIconManager::GetIconTexture(const char* iconName)
if (AZ::Interface<AzFramework::AtomActiveInterface>::Get())
{
ITexture* texture = GetIEditor()->GetRenderer()->EF_LoadTexture(iconName);
ITexture* texture = GetIEditor()->GetRenderer() ? GetIEditor()->GetRenderer()->EF_LoadTexture(iconName) : nullptr;
if (texture)
{
id = texture->GetTextureID();
+35 -36
View File
@@ -20,7 +20,6 @@
#include <QString>
#include "functor.h"
#include "Util/EditorUtils.h"
inline string ToString(const QString& s)
@@ -144,7 +143,7 @@ class CCommand0
public:
CCommand0(const string& module, const string& name,
const string& description, const string& example,
const Functor0& functor)
const AZStd::function<void()>& functor)
: CCommand(module, name, description, example)
, m_functor(functor) {}
@@ -175,7 +174,7 @@ public:
protected:
friend class CEditorCommandManager;
Functor0 m_functor;
AZStd::function<void()> m_functor;
SUIInfo m_uiInfo;
};
@@ -186,13 +185,13 @@ class CCommand0wRet
public:
CCommand0wRet(const string& module, const string& name,
const string& description, const string& example,
const Functor0wRet<RT>& functor);
const AZStd::function<RT()>& functor);
QString Execute(const CArgs& args);
protected:
friend class CEditorCommandManager;
Functor0wRet<RT> m_functor;
AZStd::function<RT()> m_functor;
};
template <LIST(1, typename P)>
@@ -202,13 +201,13 @@ class CCommand1
public:
CCommand1(const string& module, const string& name,
const string& description, const string& example,
const Functor1<LIST(1, P)>& functor);
const AZStd::function<void(LIST(1, P))>& functor);
QString Execute(const CArgs& args);
protected:
friend class CEditorCommandManager;
Functor1<LIST(1, P)> m_functor;
AZStd::function<void(LIST(1, P))> m_functor;
};
template <LIST(1, typename P), typename RT>
@@ -218,13 +217,13 @@ class CCommand1wRet
public:
CCommand1wRet(const string& module, const string& name,
const string& description, const string& example,
const Functor1wRet<LIST(1, P), RT>& functor);
const AZStd::function<RT(LIST(1, P))>& functor);
QString Execute(const CArgs& args);
protected:
friend class CEditorCommandManager;
Functor1wRet<LIST(1, P), RT> m_functor;
AZStd::function<RT(LIST(1, P))> m_functor;
};
template <LIST(2, typename P)>
@@ -234,13 +233,13 @@ class CCommand2
public:
CCommand2(const string& module, const string& name,
const string& description, const string& example,
const Functor2<LIST(2, P)>& functor);
const AZStd::function<void(LIST(2, P))>& functor);
QString Execute(const CArgs& args);
protected:
friend class CEditorCommandManager;
Functor2<LIST(2, P)> m_functor;
AZStd::function<void(LIST(2, P))> m_functor;
};
template <LIST(2, typename P), typename RT>
@@ -250,13 +249,13 @@ class CCommand2wRet
public:
CCommand2wRet(const string& module, const string& name,
const string& description, const string& example,
const Functor2wRet<LIST(2, P), RT>& functor);
const AZStd::function<RT(LIST(2, P))>& functor);
QString Execute(const CArgs& args);
protected:
friend class CEditorCommandManager;
Functor2wRet<LIST(2, P), RT> m_functor;
AZStd::function<RT(LIST(2, P))> m_functor;
};
template <LIST(3, typename P)>
@@ -266,13 +265,13 @@ class CCommand3
public:
CCommand3(const string& module, const string& name,
const string& description, const string& example,
const Functor3<LIST(3, P)>& functor);
const AZStd::function<void(LIST(3, P))>& functor);
QString Execute(const CArgs& args);
protected:
friend class CEditorCommandManager;
Functor3<LIST(3, P)> m_functor;
AZStd::function<void(LIST(3, P))> m_functor;
};
template <LIST(3, typename P), typename RT>
@@ -282,13 +281,13 @@ class CCommand3wRet
public:
CCommand3wRet(const string& module, const string& name,
const string& description, const string& example,
const Functor3wRet<LIST(3, P), RT>& functor);
const AZStd::function<RT(LIST(3, P))>& functor);
QString Execute(const CArgs& args);
protected:
friend class CEditorCommandManager;
Functor3wRet<LIST(3, P), RT> m_functor;
AZStd::function<RT(LIST(3, P))> m_functor;
};
template <LIST(4, typename P)>
@@ -298,13 +297,13 @@ class CCommand4
public:
CCommand4(const string& module, const string& name,
const string& description, const string& example,
const Functor4<LIST(4, P)>& functor);
const AZStd::function<void(LIST(4, P))>& functor);
QString Execute(const CArgs& args);
protected:
friend class CEditorCommandManager;
Functor4<LIST(4, P)> m_functor;
AZStd::function<void(LIST(4, P))> m_functor;
};
template <LIST(4, typename P), typename RT>
@@ -314,13 +313,13 @@ class CCommand4wRet
public:
CCommand4wRet(const string& module, const string& name,
const string& description, const string& example,
const Functor4wRet<LIST(4, P), RT>& functor);
const AZStd::function<RT(LIST(4, P))>& functor);
QString Execute(const CArgs& args);
protected:
friend class CEditorCommandManager;
Functor4wRet<LIST(4, P), RT> m_functor;
AZStd::function<RT(LIST(4, P))> m_functor;
};
template <LIST(5, typename P)>
@@ -330,13 +329,13 @@ class CCommand5
public:
CCommand5(const string& module, const string& name,
const string& description, const string& example,
const Functor5<LIST(5, P)>& functor);
const AZStd::function<void(LIST(5, P))>& functor);
QString Execute(const CArgs& args);
protected:
friend class CEditorCommandManager;
Functor5<LIST(5, P)> m_functor;
AZStd::function<void(LIST(5, P))> m_functor;
};
template <LIST(6, typename P)>
@@ -346,13 +345,13 @@ class CCommand6
public:
CCommand6(const string& module, const string& name,
const string& description, const string& example,
const Functor6<LIST(6, P)>& functor);
const AZStd::function<void(LIST(6, P))>& functor);
QString Execute(const CArgs& args);
protected:
friend class CEditorCommandManager;
Functor6<LIST(6, P)> m_functor;
AZStd::function<void(LIST(6, P))> m_functor;
};
//////////////////////////////////////////////////////////////////////////
@@ -360,7 +359,7 @@ protected:
template <typename RT>
CCommand0wRet<RT>::CCommand0wRet(const string& module, const string& name,
const string& description, const string& example,
const Functor0wRet<RT>& functor)
const AZStd::function<RT()>& functor)
: CCommand(module, name, description, example)
, m_functor(functor)
{
@@ -380,7 +379,7 @@ QString CCommand0wRet<RT>::Execute(const CCommand::CArgs& args)
template <LIST(1, typename P)>
CCommand1<LIST(1, P)>::CCommand1(const string& module, const string& name,
const string& description, const string& example,
const Functor1<LIST(1, P)>& functor)
const AZStd::function<void(LIST(1, P))>& functor)
: CCommand(module, name, description, example)
, m_functor(functor)
{
@@ -417,7 +416,7 @@ QString CCommand1<LIST(1, P)>::Execute(const CCommand::CArgs& args)
template <LIST(1, typename P), typename RT>
CCommand1wRet<LIST(1, P), RT>::CCommand1wRet(const string& module, const string& name,
const string& description, const string& example,
const Functor1wRet<LIST(1, P), RT>& functor)
const AZStd::function<RT(LIST(1, P))>& functor)
: CCommand(module, name, description, example)
, m_functor(functor)
{
@@ -455,7 +454,7 @@ QString CCommand1wRet<LIST(1, P), RT>::Execute(const CCommand::CArgs& args)
template <LIST(2, typename P)>
CCommand2<LIST(2, P)>::CCommand2(const string& module, const string& name,
const string& description, const string& example,
const Functor2<LIST(2, P)>& functor)
const AZStd::function<void(LIST(2, P))>& functor)
: CCommand(module, name, description, example)
, m_functor(functor)
{
@@ -494,7 +493,7 @@ QString CCommand2<LIST(2, P)>::Execute(const CCommand::CArgs& args)
template <LIST(2, typename P), typename RT>
CCommand2wRet<LIST(2, P), RT>::CCommand2wRet(const string& module, const string& name,
const string& description, const string& example,
const Functor2wRet<LIST(2, P), RT>& functor)
const AZStd::function<RT(LIST(2, P))>& functor)
: CCommand(module, name, description, example)
, m_functor(functor)
{
@@ -534,7 +533,7 @@ QString CCommand2wRet<LIST(2, P), RT>::Execute(const CCommand::CArgs& args)
template <LIST(3, typename P)>
CCommand3<LIST(3, P)>::CCommand3(const string& module, const string& name,
const string& description, const string& example,
const Functor3<LIST(3, P)>& functor)
const AZStd::function<void(LIST(3, P))>& functor)
: CCommand(module, name, description, example)
, m_functor(functor)
{
@@ -575,7 +574,7 @@ QString CCommand3<LIST(3, P)>::Execute(const CCommand::CArgs& args)
template <LIST(3, typename P), typename RT>
CCommand3wRet<LIST(3, P), RT>::CCommand3wRet(const string& module, const string& name,
const string& description, const string& example,
const Functor3wRet<LIST(3, P), RT>& functor)
const AZStd::function<RT(LIST(3, P))>& functor)
: CCommand(module, name, description, example)
, m_functor(functor)
{
@@ -617,7 +616,7 @@ QString CCommand3wRet<LIST(3, P), RT>::Execute(const CCommand::CArgs& args)
template <LIST(4, typename P)>
CCommand4<LIST(4, P)>::CCommand4(const string& module, const string& name,
const string& description, const string& example,
const Functor4<LIST(4, P)>& functor)
const AZStd::function<void(LIST(4, P))>& functor)
: CCommand(module, name, description, example)
, m_functor(functor)
{
@@ -661,7 +660,7 @@ QString CCommand4<LIST(4, P)>::Execute(const CCommand::CArgs& args)
template <LIST(4, typename P), typename RT>
CCommand4wRet<LIST(4, P), RT>::CCommand4wRet(const string& module, const string& name,
const string& description, const string& example,
const Functor4wRet<LIST(4, P), RT>& functor)
const AZStd::function<RT(LIST(4, P))>& functor)
: CCommand(module, name, description, example)
, m_functor(functor)
{
@@ -706,7 +705,7 @@ QString CCommand4wRet<LIST(4, P), RT>::Execute(const CCommand::CArgs& args)
template <LIST(5, typename P)>
CCommand5<LIST(5, P)>::CCommand5(const string& module, const string& name,
const string& description, const string& example,
const Functor5<LIST(5, P)>& functor)
const AZStd::function<void(LIST(5, P))>& functor)
: CCommand(module, name, description, example)
, m_functor(functor)
{
@@ -752,7 +751,7 @@ QString CCommand5<LIST(5, P)>::Execute(const CCommand::CArgs& args)
template <LIST(6, typename P)>
CCommand6<LIST(6, P)>::CCommand6(const string& module, const string& name,
const string& description, const string& example,
const Functor6<LIST(6, P)>& functor)
const AZStd::function<void(LIST(6, P))>& functor)
: CCommand(module, name, description, example)
, m_functor(functor)
{
@@ -151,7 +151,7 @@ struct IAssetItemDatabase
typedef std::vector<SAssetField> TAssetFields;
typedef std::map < QString/*field name*/, SAssetField > TAssetFieldFiltersMap;
typedef std::map < QString/*asset filename*/, IAssetItem* > TFilenameAssetMap;
typedef Functor1wRet<const IAssetItem*, bool> MetaDataChangeListener;
typedef AZStd::function<bool(const IAssetItem*)> MetaDataChangeListener;
// Description:
// Refresh the database by scanning the folders/paks for files, does not load the files, only filename and filesize are fetched
+37 -38
View File
@@ -15,7 +15,6 @@
#define CRYINCLUDE_EDITOR_INCLUDE_ICOMMANDMANAGER_H
#pragma once
#include "Command.h"
#include "functor.h"
typedef void (* TPfnDeleter)(void*);
@@ -23,7 +22,7 @@ class ICommandManager
{
public:
virtual ~ICommandManager() = default;
virtual bool AddCommand(CCommand* pCommand, TPfnDeleter deleter = nullptr) = 0;
virtual bool UnregisterCommand(const char* module, const char* name) = 0;
virtual bool AttachUIInfo(const char* fullCmdName, const CCommand0::SUIInfo& uiInfo) = 0;
@@ -37,51 +36,51 @@ namespace CommandManagerHelper
{
bool RegisterCommand(ICommandManager* pCmdMgr, const char* module, const char* name,
const char* description, const char* example,
const Functor0& functor);
const AZStd::function<void()>& functor);
template <typename RT>
bool RegisterCommand(ICommandManager* pCmdMgr, const char* module, const char* name,
const char* description, const char* example,
const Functor0wRet<RT>& functor);
const AZStd::function<RT()>& functor);
template <LIST(1, typename P)>
bool RegisterCommand(ICommandManager* pCmdMgr, const char* module, const char* name,
const char* description, const char* example,
const Functor1<LIST(1, P)>& functor);
const AZStd::function<void(LIST(1, P))>& functor);
template <LIST(1, typename P), typename RT>
bool RegisterCommand(ICommandManager* pCmdMgr, const char* module, const char* name,
const char* description, const char* example,
const Functor1wRet<LIST(1, P), RT>& functor);
const AZStd::function<RT(LIST(1, P))>& functor);
template <LIST(2, typename P)>
bool RegisterCommand(ICommandManager* pCmdMgr, const char* module, const char* name,
const char* description, const char* example,
const Functor2<LIST(2, P)>& functor);
const AZStd::function<void(LIST(2, P))>& functor);
template <LIST(2, typename P), typename RT>
bool RegisterCommand(ICommandManager* pCmdMgr, const char* module, const char* name,
const char* description, const char* example,
const Functor2wRet<LIST(2, P), RT>& functor);
const AZStd::function<RT(LIST(2, P))>& functor);
template <LIST(3, typename P)>
bool RegisterCommand(ICommandManager* pCmdMgr, const char* module, const char* name,
const char* description, const char* example,
const Functor3<LIST(3, P)>& functor);
const AZStd::function<void(LIST(3, P))>& functor);
template <LIST(3, typename P), typename RT>
bool RegisterCommand(ICommandManager* pCmdMgr, const char* module, const char* name,
const char* description, const char* example,
const Functor3wRet<LIST(3, P), RT>& functor);
const AZStd::function<RT(LIST(3, P))>& functor);
template <LIST(4, typename P)>
bool RegisterCommand(ICommandManager* pCmdMgr, const char* module, const char* name,
const char* description, const char* example,
const Functor4<LIST(4, P)>& functor);
const AZStd::function<void(LIST(4, P))>& functor);
template <LIST(4, typename P), typename RT>
bool RegisterCommand(ICommandManager* pCmdMgr, const char* module, const char* name,
const char* description, const char* example,
const Functor4wRet<LIST(4, P), RT>& functor);
const AZStd::function<RT(LIST(4, P))>& functor);
template <LIST(5, typename P)>
bool RegisterCommand(ICommandManager* pCmdMgr, const char* module, const char* name,
const char* description, const char* example,
const Functor5<LIST(5, P)>& functor);
const AZStd::function<void(LIST(5, P))>& functor);
template <LIST(6, typename P)>
bool RegisterCommand(ICommandManager* pCmdMgr, const char* module, const char* name,
const char* description, const char* example,
const Functor6<LIST(6, P)>& functor);
const AZStd::function<void(LIST(6, P))>& functor);
namespace Private
{
@@ -117,96 +116,96 @@ bool CommandManagerHelper::Private::RegisterCommand(ICommandManager* pCmdMgr,
inline
bool CommandManagerHelper::RegisterCommand(ICommandManager* pCmdMgr, const char* module, const char* name,
const char* description, const char* example,
const Functor0& functor)
const AZStd::function<void()>& functor)
{
return Private::RegisterCommand<Functor0, CCommand0>(pCmdMgr, module, name, description, example, functor);
return Private::RegisterCommand<AZStd::function<void()>, CCommand0>(pCmdMgr, module, name, description, example, functor);
}
template <typename RT>
bool CommandManagerHelper::RegisterCommand(ICommandManager* pCmdMgr, const char* module, const char* name,
const char* description, const char* example,
const Functor0wRet<RT>& functor)
const AZStd::function<RT()>& functor)
{
return Private::RegisterCommand<Functor0wRet<RT>, CCommand0wRet<RT> >(pCmdMgr, module, name, description, example, functor);
return Private::RegisterCommand<AZStd::function<RT()>, CCommand0wRet<RT> >(pCmdMgr, module, name, description, example, functor);
}
template <LIST(1, typename P)>
bool CommandManagerHelper::RegisterCommand(ICommandManager* pCmdMgr, const char* module, const char* name,
const char* description, const char* example,
const Functor1<LIST(1, P)>& functor)
const AZStd::function<void(LIST(1, P))>& functor)
{
return Private::RegisterCommand<Functor1<LIST(1, P)>, CCommand1<LIST(1, P)> >(pCmdMgr, module, name, description, example, functor);
return Private::RegisterCommand<AZStd::function<void(LIST(1, P))>, CCommand1<LIST(1, P)> >(pCmdMgr, module, name, description, example, functor);
}
template <LIST(1, typename P), typename RT>
bool CommandManagerHelper::RegisterCommand(ICommandManager* pCmdMgr, const char* module, const char* name,
const char* description, const char* example,
const Functor1wRet<LIST(1, P), RT>& functor)
const AZStd::function<RT(LIST(1, P))>& functor)
{
return Private::RegisterCommand<Functor1wRet<LIST(1, P), RT>, CCommand1wRet<LIST(1, P), RT> >(pCmdMgr, module, name, description, example, functor);
return Private::RegisterCommand<AZStd::function<RT(LIST(1, P))>, CCommand1wRet<LIST(1, P), RT> >(pCmdMgr, module, name, description, example, functor);
}
template <LIST(2, typename P)>
bool CommandManagerHelper::RegisterCommand(ICommandManager* pCmdMgr, const char* module, const char* name,
const char* description, const char* example,
const Functor2<LIST(2, P)>& functor)
const AZStd::function<void(LIST(2, P))>& functor)
{
return Private::RegisterCommand<Functor2<LIST(2, P)>, CCommand2<LIST(2, P)> >(pCmdMgr, module, name, description, example, functor);
return Private::RegisterCommand<AZStd::function<void(LIST(2, P))>, CCommand2<LIST(2, P)> >(pCmdMgr, module, name, description, example, functor);
}
template <LIST(2, typename P), typename RT>
bool CommandManagerHelper::RegisterCommand(ICommandManager* pCmdMgr, const char* module, const char* name,
const char* description, const char* example,
const Functor2wRet<LIST(2, P), RT>& functor)
const AZStd::function<RT(LIST(2, P))>& functor)
{
return Private::RegisterCommand<Functor2wRet<LIST(2, P), RT>, CCommand2wRet<LIST(2, P), RT> >(pCmdMgr, module, name, description, example, functor);
return Private::RegisterCommand<AZStd::function<RT(LIST(2, P))>, CCommand2wRet<LIST(2, P), RT> >(pCmdMgr, module, name, description, example, functor);
}
template <LIST(3, typename P)>
bool CommandManagerHelper::RegisterCommand(ICommandManager* pCmdMgr, const char* module, const char* name,
const char* description, const char* example,
const Functor3<LIST(3, P)>& functor)
const AZStd::function<void(LIST(3, P))>& functor)
{
return Private::RegisterCommand<Functor3<LIST(3, P)>, CCommand3<LIST(3, P)> >(pCmdMgr, module, name, description, example, functor);
return Private::RegisterCommand<AZStd::function<void(LIST(3, P))>, CCommand3<LIST(3, P)> >(pCmdMgr, module, name, description, example, functor);
}
template <LIST(3, typename P), typename RT>
bool CommandManagerHelper::RegisterCommand(ICommandManager* pCmdMgr, const char* module, const char* name,
const char* description, const char* example,
const Functor3wRet<LIST(3, P), RT>& functor)
const AZStd::function<RT(LIST(3, P))>& functor)
{
return Private::RegisterCommand<Functor3wRet<LIST(3, P), RT>, CCommand3wRet<LIST(3, P), RT> >(pCmdMgr, module, name, description, example, functor);
return Private::RegisterCommand<AZStd::function<RT(LIST(3, P))>, CCommand3wRet<LIST(3, P), RT> >(pCmdMgr, module, name, description, example, functor);
}
template <LIST(4, typename P)>
bool CommandManagerHelper::RegisterCommand(ICommandManager* pCmdMgr, const char* module, const char* name,
const char* description, const char* example,
const Functor4<LIST(4, P)>& functor)
const AZStd::function<void(LIST(4, P))>& functor)
{
return Private::RegisterCommand<Functor4<LIST(4, P)>, CCommand4<LIST(4, P)> >(pCmdMgr, module, name, description, example, functor);
return Private::RegisterCommand<AZStd::function<void(LIST(4, P))>, CCommand4<LIST(4, P)> >(pCmdMgr, module, name, description, example, functor);
}
template <LIST(4, typename P), typename RT>
bool CommandManagerHelper::RegisterCommand(ICommandManager* pCmdMgr, const char* module, const char* name,
const char* description, const char* example,
const Functor4wRet<LIST(4, P), RT>& functor)
const AZStd::function<RT(LIST(4, P))>& functor)
{
return Private::RegisterCommand<Functor4wRet<LIST(4, P), RT>, CCommand4wRet<LIST(4, P), RT> >(pCmdMgr, module, name, description, example, functor);
return Private::RegisterCommand<AZStd::function<RT(LIST(4, P))>, CCommand4wRet<LIST(4, P), RT> >(pCmdMgr, module, name, description, example, functor);
}
template <LIST(5, typename P)>
bool CommandManagerHelper::RegisterCommand(ICommandManager* pCmdMgr, const char* module, const char* name,
const char* description, const char* example,
const Functor5<LIST(5, P)>& functor)
const AZStd::function<void(LIST(5, P))>& functor)
{
return Private::RegisterCommand<Functor5<LIST(5, P)>, CCommand5<LIST(5, P)> >(pCmdMgr, module, name, description, example, functor);
return Private::RegisterCommand<AZStd::function<void(LIST(5, P))>, CCommand5<LIST(5, P)> >(pCmdMgr, module, name, description, example, functor);
}
template <LIST(6, typename P)>
bool CommandManagerHelper::RegisterCommand(ICommandManager* pCmdMgr, const char* module, const char* name,
const char* description, const char* example,
const Functor6<LIST(6, P)>& functor)
const AZStd::function<void(LIST(6, P))>& functor)
{
return Private::RegisterCommand<Functor6<LIST(6, P)>, CCommand6<LIST(6, P)> >(pCmdMgr, module, name, description, example, functor);
return Private::RegisterCommand<AZStd::function<void(LIST(6, P))>, CCommand6<LIST(6, P)> >(pCmdMgr, module, name, description, example, functor);
}
#endif // CRYINCLUDE_EDITOR_INCLUDE_ICOMMANDMANAGER_H
+6 -3
View File
@@ -63,7 +63,10 @@ public:
virtual ~IObjectManager() = default;
//! This callback will be called on response to object event.
typedef Functor2<CBaseObject*, int> EventCallback;
struct EventListener
{
virtual void OnObjectEvent(CBaseObject*, int) = 0;
};
virtual CBaseObject* NewObject(CObjectClassDesc* cls, CBaseObject* prev = 0, const QString& file = "", const char* newObjectName = nullptr) = 0;
virtual CBaseObject* NewObject(const QString& typeName, CBaseObject* prev = 0, const QString& file = "", const char* newObjectName = nullptr) = 0;
@@ -257,8 +260,8 @@ public:
//////////////////////////////////////////////////////////////////////////
// ObjectManager notification Callbacks.
//////////////////////////////////////////////////////////////////////////
virtual void AddObjectEventListener(const EventCallback& cb) = 0;
virtual void RemoveObjectEventListener(const EventCallback& cb) = 0;
virtual void AddObjectEventListener(EventListener* listener) = 0;
virtual void RemoveObjectEventListener(EventListener* listener) = 0;
//////////////////////////////////////////////////////////////////////////
// Used to indicate starting and ending of objects loading.
+4 -1
View File
@@ -146,13 +146,16 @@ CInfoBar::CInfoBar(QWidget* parent)
ui->m_moveSpeed->setValidator(new QDoubleValidator(m_minSpeed, m_maxSpeed, m_numDecimals, ui->m_moveSpeed));
// Save off the move speed here since setting up the combo box can cause it to update values in the background.
float cameraMoveSpeed = gSettings.cameraMoveSpeed;
// Populate the presets in the ComboBox
for (float presetValue : m_speedPresetValues)
{
ui->m_moveSpeed->addItem(QString().setNum(presetValue, 'f', m_numDecimals), presetValue);
}
SetSpeedComboBox(gSettings.cameraMoveSpeed);
SetSpeedComboBox(cameraMoveSpeed);
ui->m_moveSpeed->setInsertPolicy(QComboBox::NoInsert);
+2 -1
View File
@@ -31,6 +31,7 @@
#include "MainWindow.h"
#include "ViewPane.h"
#include "QtViewPaneManager.h"
#include "ViewManager.h"
#include <AzQtComponents/Components/Style.h>
@@ -426,7 +427,7 @@ void CLayoutWnd::CreateLayout(EViewLayout layout, bool bBindViewports, EViewport
m_maximizedView->setVisible(false);
m_maximizedView->SetFullscren(true);
if (AZ::Interface<AzFramework::AtomActiveInterface>::Get()) // Only supports 1 viewport for now.
if (!CViewManager::IsMultiViewportEnabled())
{
m_viewType[0] = ViewportTypeToClassName(defaultView);
if (bBindViewports)
@@ -0,0 +1,507 @@
/*
* 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.
*
*/
#include "LegacyViewportCameraController.h"
#include <AzFramework/Input/Devices/Mouse/InputDeviceMouse.h>
#include <AzFramework/Input/Devices/Keyboard/InputDeviceKeyboard.h>
#include <AzToolsFramework/Viewport/ViewportMessages.h>
#include <Atom/RPI.Public/ViewportContextBus.h>
#include <Atom/RPI.Public/ViewportContext.h>
#include <IViewSystem.h>
#include <ISystem.h>
#include "CryCommon/MathConversion.h"
#include "SandboxAPI.h"
#include "Settings.h"
namespace SandboxEditor
{
LegacyViewportCameraControllerInstance::LegacyViewportCameraControllerInstance(AzFramework::ViewportId viewportId)
: AzFramework::MultiViewportControllerInstanceInterface(viewportId)
{
}
bool LegacyViewportCameraControllerInstance::JustAltHeld() const
{
return (m_modifiers ^ Qt::AltModifier) == 0;
}
bool LegacyViewportCameraControllerInstance::NoModifierHeld() const
{
return !m_modifiers;
}
bool LegacyViewportCameraControllerInstance::AllowDolly() const
{
return JustAltHeld();
}
bool LegacyViewportCameraControllerInstance::AllowOrbit() const
{
return JustAltHeld();
}
bool LegacyViewportCameraControllerInstance::AllowPan() const
{
// begin pan with alt (inverted movement) or no modifiers
return JustAltHeld() || NoModifierHeld();
}
bool LegacyViewportCameraControllerInstance::InvertPan() const
{
return JustAltHeld();
}
AZ::RPI::ViewportContextPtr LegacyViewportCameraControllerInstance::GetViewportContext()
{
// This could be cached, if needed
auto viewportContextManager = AZ::Interface<AZ::RPI::ViewportContextRequestsInterface>::Get();
if (!viewportContextManager)
{
return {};
}
return viewportContextManager->GetViewportContextById(GetViewportId());
}
bool LegacyViewportCameraControllerInstance::HandleMouseMove(const QPoint& currentMousePos, const QPoint& previousMousePos)
{
if (previousMousePos == currentMousePos)
{
return false;
}
auto viewportContext = GetViewportContext();
if (!viewportContext)
{
return false;
}
float speedScale = gSettings.cameraMoveSpeed;
if (m_modifiers & Qt::Key_Control)
{
speedScale *= gSettings.cameraFastMoveSpeed;
}
if ((m_inRotateMode && m_inMoveMode) || m_inZoomMode)
{
Matrix34 m = AZTransformToLYTransform(viewportContext->GetCameraTransform());
Vec3 ydir = m.GetColumn1().GetNormalized();
Vec3 pos = m.GetTranslation();
const float posDelta = 0.2f * (previousMousePos.y() - currentMousePos.y()) * speedScale;
pos = pos - ydir * posDelta;
m_orbitDistance = m_orbitDistance + posDelta;
m_orbitDistance = fabs(m_orbitDistance);
m.SetTranslation(pos);
viewportContext->SetCameraTransform(LYTransformToAZTransform(m));
return true;
}
else if (m_inRotateMode)
{
Ang3 angles(-currentMousePos.y() + previousMousePos.y(), 0, -currentMousePos.x() + previousMousePos.x());
angles = angles * 0.002f * gSettings.cameraRotateSpeed;
if (gSettings.invertYRotation)
{
angles.x = -angles.x;
}
Matrix34 camtm = AZTransformToLYTransform(viewportContext->GetCameraTransform());
Ang3 ypr = CCamera::CreateAnglesYPR(Matrix33(camtm));
ypr.x += angles.z;
ypr.y += angles.x;
ypr.y = AZStd::clamp(ypr.y, -1.5f, 1.5f); // to keep rotation in reasonable range
ypr.z = 0; // to have camera always upward
camtm = Matrix34(CCamera::CreateOrientationYPR(ypr), camtm.GetTranslation());
viewportContext->SetCameraTransform(LYTransformToAZTransform(camtm));
return true;
}
else if (m_inMoveMode)
{
// Slide.
Matrix34 m = AZTransformToLYTransform(viewportContext->GetCameraTransform());
Vec3 xdir = m.GetColumn0().GetNormalized();
Vec3 zdir = m.GetColumn2().GetNormalized();
if (InvertPan())
{
xdir = -xdir;
zdir = -zdir;
}
Vec3 pos = m.GetTranslation();
pos += 0.1f * xdir * (currentMousePos.x() - previousMousePos.x()) * speedScale + 0.1f * zdir * (previousMousePos.y() - currentMousePos.y()) * speedScale;
m.SetTranslation(pos);
AZ::Transform transform = viewportContext->GetCameraTransform();
transform.SetTranslation(LYVec3ToAZVec3(pos));
viewportContext->SetCameraTransform(transform);
return true;
}
else if (m_inOrbitMode)
{
Ang3 angles(-currentMousePos.y() + previousMousePos.y(), 0, -currentMousePos.x() + previousMousePos.x());
angles = angles * 0.002f * gSettings.cameraRotateSpeed;
if (gSettings.invertPan)
{
angles.z = -angles.z;
}
Matrix34 m = AZTransformToLYTransform(viewportContext->GetCameraTransform());
Ang3 ypr = CCamera::CreateAnglesYPR(Matrix33(m));
ypr.x += angles.z;
ypr.y = AZStd::clamp(ypr.y, -1.5f, 1.5f); // to keep rotation in reasonable range
ypr.y += angles.x;
Matrix33 rotateTM = CCamera::CreateOrientationYPR(ypr);
Vec3 src = m.GetTranslation();
Vec3 trg(m_orbitTarget.GetX(), m_orbitTarget.GetY(), m_orbitTarget.GetZ());
float fCameraRadius = (trg - src).GetLength();
// Calc new source.
src = trg - rotateTM * Vec3(0, 1, 0) * fCameraRadius;
Matrix34 camTM = rotateTM;
camTM.SetTranslation(src);
viewportContext->SetCameraTransform(LYTransformToAZTransform(camTM));
return true;
}
return false;
}
bool LegacyViewportCameraControllerInstance::HandleMouseWheel(float zDelta)
{
auto viewportContext = GetViewportContext();
if (!viewportContext)
{
return false;
}
Matrix34 m = AZTransformToLYTransform(viewportContext->GetCameraTransform());
const Vec3 ydir = m.GetColumn1().GetNormalized();
Vec3 pos = m.GetTranslation();
const float posDelta = 0.01f * zDelta * gSettings.wheelZoomSpeed;
pos += ydir * posDelta;
m_orbitDistance = m_orbitDistance - posDelta;
m_orbitDistance = fabs(m_orbitDistance);
m.SetTranslation(pos);
viewportContext->SetCameraTransform(LYTransformToAZTransform(m));
return true;
}
bool LegacyViewportCameraControllerInstance::IsKeyDown(Qt::Key key) const
{
return m_pressedKeys.contains(key);
}
Qt::Key LegacyViewportCameraControllerInstance::GetKeyboardKey(const AzFramework::InputChannel& inputChannel)
{
using Key = AzFramework::InputDeviceKeyboard::Key;
const auto& id = inputChannel.GetInputChannelId();
if (id == Key::AlphanumericW)
{
return Qt::Key_W;
}
else if (id == Key::AlphanumericA)
{
return Qt::Key_A;
}
else if (id == Key::AlphanumericS)
{
return Qt::Key_S;
}
else if (id == Key::AlphanumericD)
{
return Qt::Key_D;
}
else if (id == Key::AlphanumericQ)
{
return Qt::Key_Q;
}
else if (id == Key::AlphanumericE)
{
return Qt::Key_E;
}
else if (id == Key::NavigationArrowUp)
{
return Qt::Key_Up;
}
else if (id == Key::NavigationArrowUp)
{
return Qt::Key_Down;
}
else if (id == Key::NavigationArrowUp)
{
return Qt::Key_Left;
}
else if (id == Key::NavigationArrowUp)
{
return Qt::Key_Right;
}
return Qt::Key_unknown;
}
Qt::KeyboardModifier LegacyViewportCameraControllerInstance::GetKeyboardModifier(const AzFramework::InputChannel& inputChannel)
{
using Key = AzFramework::InputDeviceKeyboard::Key;
const auto& id = inputChannel.GetInputChannelId();
if (id == Key::ModifierAltL || id == Key::ModifierAltR)
{
return Qt::KeyboardModifier::AltModifier;
}
if (id == Key::ModifierCtrlL || id == Key::ModifierCtrlR)
{
return Qt::KeyboardModifier::ControlModifier;
}
if (id == Key::ModifierShiftL || id == Key::ModifierShiftR)
{
return Qt::KeyboardModifier::ShiftModifier;
}
return Qt::KeyboardModifier::NoModifier;
}
bool LegacyViewportCameraControllerInstance::HandleInputChannelEvent(const AzFramework::ViewportControllerInputEvent& event)
{
using AzFramework::InputChannel;
using MouseButton = AzFramework::InputDeviceMouse::Button;
const auto& id = event.m_inputChannel.GetInputChannelId();
const auto& state = event.m_inputChannel.GetState();
bool shouldCaptureCursor = m_capturingCursor;
bool shouldConsumeEvent = false;
if (id == AzFramework::InputDeviceMouse::SystemCursorPosition)
{
QPoint screenPosition = QPoint();
bool result = false;
AzToolsFramework::ViewportInteraction::ViewportMouseCursorRequestBus::Event(
GetViewportId(),
[this, &result](AzToolsFramework::ViewportInteraction::ViewportMouseCursorRequests* mouseRequests)
{
auto previousMousePosition = mouseRequests->PreviousViewportCursorScreenPosition();
if (previousMousePosition.has_value())
{
result = HandleMouseMove(mouseRequests->ViewportCursorScreenPosition(), previousMousePosition.value());
}
});
return result;
}
else if (id == MouseButton::Left)
{
if (state == InputChannel::State::Began)
{
if (AllowOrbit())
{
AzFramework::CameraState cameraState;
AzToolsFramework::ViewportInteraction::ViewportInteractionRequestBus::EventResult(
cameraState, event.m_viewportId,
&AzToolsFramework::ViewportInteraction::ViewportInteractionRequestBus::Events::GetCameraState);
m_inOrbitMode = true;
m_orbitTarget = cameraState.m_position + cameraState.m_forward * m_orbitDistance;
shouldConsumeEvent = true;
shouldCaptureCursor = true;
}
}
else if (state == InputChannel::State::Ended)
{
m_inOrbitMode = false;
shouldCaptureCursor = false;
}
}
else if (id == MouseButton::Right)
{
if (state == InputChannel::State::Began)
{
if (AllowDolly())
{
m_inZoomMode = true;
}
else
{
m_inRotateMode = true;
}
shouldConsumeEvent = true;
shouldCaptureCursor = true;
}
else if (state == InputChannel::State::Ended)
{
m_inZoomMode = false;
m_inRotateMode = false;
shouldCaptureCursor = false;
}
}
else if (id == MouseButton::Middle)
{
if (state == InputChannel::State::Began)
{
if (AllowPan())
{
m_inMoveMode = true;
shouldConsumeEvent = true;
shouldCaptureCursor = true;
}
}
else if (state == InputChannel::State::Ended)
{
m_inMoveMode = false;
shouldCaptureCursor = false;
}
}
else if (auto modifier = GetKeyboardModifier(event.m_inputChannel); modifier != Qt::KeyboardModifier::NoModifier)
{
if (state == InputChannel::State::Ended)
{
m_modifiers &= ~modifier;
}
else
{
m_modifiers |= modifier;
}
}
else if (id == AzFramework::InputDeviceMouse::Movement::Z)
{
if (state == InputChannel::State::Began || state == InputChannel::State::Updated)
{
shouldConsumeEvent = HandleMouseWheel(event.m_inputChannel.GetValue());
}
}
else if (auto key = GetKeyboardKey(event.m_inputChannel); key != Qt::Key_unknown)
{
if (state == InputChannel::State::Ended)
{
m_pressedKeys.erase(key);
}
else
{
m_pressedKeys.insert(key);
shouldConsumeEvent = true;
}
}
if (m_capturingCursor != shouldCaptureCursor)
{
if (shouldCaptureCursor)
{
AzToolsFramework::ViewportInteraction::ViewportMouseCursorRequestBus::Event(
GetViewportId(),
&AzToolsFramework::ViewportInteraction::ViewportMouseCursorRequestBus::Events::BeginCursorCapture
);
}
else
{
AzToolsFramework::ViewportInteraction::ViewportMouseCursorRequestBus::Event(
GetViewportId(),
&AzToolsFramework::ViewportInteraction::ViewportMouseCursorRequestBus::Events::EndCursorCapture
);
}
m_capturingCursor = shouldCaptureCursor;
}
return shouldConsumeEvent;
}
void LegacyViewportCameraControllerInstance::UpdateViewport(const AzFramework::ViewportControllerUpdateEvent& event)
{
auto viewportContext = GetViewportContext();
if (!viewportContext)
{
return;
}
AZ::Transform transform = viewportContext->GetCameraTransform();
AZ::Vector3 xdir = transform.GetBasisX();
AZ::Vector3 ydir = transform.GetBasisY();
AZ::Vector3 zdir = transform.GetBasisZ();
AZ::Vector3 pos = transform.GetTranslation();
float speedScale = AZStd::GetMin(30.0f * event.m_deltaTime.count(), 20.0f);
// Use the global modifier keys instead of our keymap. It's more reliable.
const bool shiftPressed = m_modifiers & Qt::ShiftModifier;
const bool controlPressed = m_modifiers & Qt::ControlModifier;
speedScale *= gSettings.cameraMoveSpeed;
if (controlPressed)
{
return;
}
if (shiftPressed)
{
speedScale *= gSettings.cameraFastMoveSpeed;
}
bool cameraMoved = false;
if (IsKeyDown(Qt::Key_Up) || IsKeyDown(Qt::Key_W))
{
// move forward
cameraMoved = true;
pos = pos + (speedScale * m_moveSpeed * ydir);
}
if (IsKeyDown(Qt::Key_Down) || IsKeyDown(Qt::Key_S))
{
// move backward
cameraMoved = true;
pos = pos - (speedScale * m_moveSpeed * ydir);
}
if (IsKeyDown(Qt::Key_Left) || IsKeyDown(Qt::Key_A))
{
// move left
cameraMoved = true;
pos = pos - (speedScale * m_moveSpeed * xdir);
}
if (IsKeyDown(Qt::Key_Right) || IsKeyDown(Qt::Key_D))
{
// move right
cameraMoved = true;
pos = pos + (speedScale * m_moveSpeed * xdir);
}
if (IsKeyDown(Qt::Key_E))
{
// move Up
cameraMoved = true;
pos = pos + (speedScale * m_moveSpeed * zdir);
}
if (IsKeyDown(Qt::Key_Q))
{
// move down
cameraMoved = true;
pos = pos - (speedScale * m_moveSpeed * zdir);
}
if (cameraMoved)
{
transform.SetTranslation(pos);
viewportContext->SetCameraTransform(transform);
}
}
} //namespace SandboxEditor
@@ -0,0 +1,65 @@
/*
* 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.
*
*/
#pragma once
#include <AzFramework/Viewport/ViewportId.h>
#include <AzFramework/Viewport/MultiViewportController.h>
#include <AzCore/Math/Vector3.h>
#include <Atom/RPI.Public/Base.h>
#include <QtCore/qnamespace.h>
#include <QPoint>
namespace SandboxEditor
{
class LegacyViewportCameraControllerInstance final
: public AzFramework::MultiViewportControllerInstanceInterface
{
public:
explicit LegacyViewportCameraControllerInstance(AzFramework::ViewportId viewport);
bool HandleInputChannelEvent(const AzFramework::ViewportControllerInputEvent& event) override;
void UpdateViewport(const AzFramework::ViewportControllerUpdateEvent& event) override;
private:
bool JustAltHeld() const;
bool NoModifierHeld() const;
bool AllowDolly() const;
bool AllowOrbit() const;
bool AllowPan() const;
bool InvertPan() const;
static Qt::KeyboardModifier GetKeyboardModifier(const AzFramework::InputChannel& inputChannel);
static Qt::Key GetKeyboardKey(const AzFramework::InputChannel& inputChannel);
AZ::RPI::ViewportContextPtr GetViewportContext();
bool HandleMouseMove(const QPoint& currentMousePos, const QPoint& previousMousePos);
bool HandleMouseWheel(float zDelta);
bool IsKeyDown(Qt::Key key) const;
bool m_inRotateMode = false;
bool m_inMoveMode = false;
bool m_inOrbitMode = false;
bool m_inZoomMode = false;
float m_orbitDistance = 10.f;
float m_moveSpeed = 1.f;
AZ::Vector3 m_orbitTarget = {};
unsigned int m_modifiers = {};
AZStd::unordered_set<Qt::Key> m_pressedKeys;
bool m_capturingCursor = false;
};
using LegacyViewportCameraController = AzFramework::MultiViewportController<LegacyViewportCameraControllerInstance>;
} //namespace SandboxEditor
@@ -107,7 +107,7 @@ CLensFlareEditor::CLensFlareEditor(QWidget* pParent)
m_pLensFlareElementTree->RegisterListener(m_pLensFlareView);
m_pWndProps->ExpandAll();
m_pWndProps->SetUpdateCallback(functor(*this, &CLensFlareEditor::OnUpdateProperties));
m_pWndProps->SetUpdateCallback(AZStd::bind(&CLensFlareEditor::OnUpdateProperties, this, AZStd::placeholders::_1));
m_pWndProps->SetCallbackOnNonModified(false);
connect(ui->actionDBAdd, &QAction::triggered, this, &CLensFlareEditor::OnAddItem);
@@ -428,7 +428,8 @@ void CLensFlareEditor::Paste(const QModelIndex& hSelectedTreeItem, XmlNodeRef no
if (bShouldCreateNewGroup)
{
targetGroupName = MakeValidName("NewGroup", functor(*this, &CDatabaseFrameWnd::DoesGroupExist));
using namespace AZStd::placeholders;
targetGroupName = MakeValidName("NewGroup", AZStd::bind(&CDatabaseFrameWnd::DoesGroupExist, this, _1, _2));
}
else
{
@@ -493,7 +494,8 @@ void CLensFlareEditor::Paste(const QModelIndex& hSelectedTreeItem, XmlNodeRef no
}
QString candidateName = targetGroupName + QString(".") + sourceName;
QString validName = MakeValidName(candidateName, functor(*this, &CDatabaseFrameWnd::DoesItemExist));
QString validName = MakeValidName(candidateName,
AZStd::bind(&CDatabaseFrameWnd::DoesItemExist, this, AZStd::placeholders::_1, AZStd::placeholders::_2));
QString validShortName = LensFlareUtil::GetShortName(validName);
pNewItem = AddNewLensFlareItem(targetGroupName, validShortName);
assert(pNewItem);
@@ -1141,7 +1143,8 @@ void CLensFlareEditor::AddNewItemByAtomicOptics(const QModelIndex& hSelectedItem
}
FlareInfoArray::Props flareProps = FlareInfoArray::Get();
QString itemName = MakeValidName(groupName + QString(".") + flareProps.p[flareType].name, functor(*this, &CDatabaseFrameWnd::DoesItemExist));
QString itemName = MakeValidName(groupName + QString(".") + flareProps.p[flareType].name,
AZStd::bind(&CDatabaseFrameWnd::DoesItemExist, this, AZStd::placeholders::_1, AZStd::placeholders::_2));
CLensFlareItem* pNewItem = AddNewLensFlareItem(groupName, LensFlareUtil::GetShortName(itemName));
if (pNewItem)
@@ -224,21 +224,51 @@ void CLensFlareElement::UpdateLights()
void CLensFlareElement::UpdateProperty(IOpticsElementBasePtr pOptics)
{
std::vector<IVariable::OnSetCallback> funcs;
std::vector<IVariable::OnSetCallback*> funcs;
if (GetLensFlareTree())
if (CLensFlareElementTree* lensFlareTree = GetLensFlareTree(); lensFlareTree)
{
funcs.push_back(functor(*GetLensFlareTree(), &CLensFlareElementTree::OnInternalVariableChange));
auto callbackItr = m_callbackCache.find(lensFlareTree);
if (callbackItr == m_callbackCache.end())
{
IVariable::OnSetCallback callback =
AZStd::bind(&CLensFlareElementTree::OnInternalVariableChange, lensFlareTree, AZStd::placeholders::_1);
auto result = m_callbackCache.insert(AZStd::make_pair(lensFlareTree, callback));
callbackItr = result.first;
}
funcs.push_back(&(callbackItr->second));
}
if (GetLensFlareView())
if (CLensFlareView* lensFlareView = GetLensFlareView(); lensFlareView)
{
funcs.push_back(functor(*GetLensFlareView(), &CLensFlareView::OnInternalVariableChange));
auto callbackItr = m_callbackCache.find(lensFlareView);
if (callbackItr == m_callbackCache.end())
{
IVariable::OnSetCallback callback =
AZStd::bind(&CLensFlareView::OnInternalVariableChange, lensFlareView, AZStd::placeholders::_1);
auto result = m_callbackCache.insert(AZStd::make_pair(lensFlareView, callback));
callbackItr = result.first;
}
funcs.push_back(&(callbackItr->second));
}
if (GetLensFlareLibrary())
if (CLensFlareLibrary* lensFlareLibrary = GetLensFlareLibrary(); lensFlareLibrary)
{
funcs.push_back(functor(*GetLensFlareLibrary(), &CLensFlareLibrary::OnInternalVariableChange));
auto callbackItr = m_callbackCache.find(lensFlareLibrary);
if (callbackItr == m_callbackCache.end())
{
IVariable::OnSetCallback callback =
AZStd::bind(&CLensFlareLibrary::OnInternalVariableChange, lensFlareLibrary, AZStd::placeholders::_1);
auto result = m_callbackCache.insert(AZStd::make_pair(lensFlareLibrary, callback));
callbackItr = result.first;
}
funcs.push_back(&(callbackItr->second));
}
LensFlareUtil::SetVariablesTemplateFromOptics(pOptics, m_vars, funcs);
@@ -100,5 +100,7 @@ private:
CLensFlareElement* m_pParent;
LensFlareElementList m_children;
AZStd::map<void*, IVariable::OnSetCallback> m_callbackCache;
};
#endif // CRYINCLUDE_EDITOR_LENSFLAREEDITOR_LENSFLAREELEMENT_H
@@ -83,13 +83,13 @@ LensFlareLightEntityModel::LensFlareLightEntityModel(QObject* pParent)
: QAbstractListModel(pParent)
{
CLensFlareEditor::GetLensFlareEditor()->RegisterLensFlareItemChangeListener(this);
GetIEditor()->GetObjectManager()->AddObjectEventListener(functor(*this, &LensFlareLightEntityModel::OnObjectEvent));
GetIEditor()->GetObjectManager()->AddObjectEventListener(this);
}
LensFlareLightEntityModel::~LensFlareLightEntityModel()
{
CLensFlareEditor::GetLensFlareEditor()->UnregisterLensFlareItemChangeListener(this);
GetIEditor()->GetObjectManager()->RemoveObjectEventListener(functor(*this, &LensFlareLightEntityModel::OnObjectEvent));
GetIEditor()->GetObjectManager()->RemoveObjectEventListener(this);
}
void LensFlareLightEntityModel::OnLensFlareChangeItem(CLensFlareItem* pLensFlareItem)
@@ -20,6 +20,7 @@
#include <QScopedPointer>
#include <QTreeWidget>
#include "IObjectManager.h" // for IObjectManager::EventListener
#include "Objects/EntityObject.h"
#endif
@@ -46,6 +47,7 @@ protected:
class LensFlareLightEntityModel
: public QAbstractListModel
, public ILensFlareChangeItemListener
, public IObjectManager::EventListener
{
Q_OBJECT
@@ -60,7 +62,7 @@ public:
void OnLensFlareChangeItem(CLensFlareItem* pLensFlareItem);
protected:
void OnObjectEvent(CBaseObject* pObject, int nEvent);
void OnObjectEvent(CBaseObject* pObject, int nEvent) override;
bool AddLightEntity(CEntityObject* pEntity);
@@ -171,7 +171,7 @@ namespace LensFlareUtil
return true;
}
void SetVariablesTemplateFromOptics(IOpticsElementBasePtr pOptics, CVarBlockPtr& pRootVar, std::vector<IVariable::OnSetCallback>& funcs)
void SetVariablesTemplateFromOptics(IOpticsElementBasePtr pOptics, CVarBlockPtr& pRootVar, std::vector<IVariable::OnSetCallback*>& funcs)
{
if (pOptics == NULL)
{
@@ -355,7 +355,7 @@ namespace LensFlareUtil
IOpticsElementBasePtr CreateOptics(IOpticsElementBasePtr pOptics, bool bForceTypeToGroup = false);
bool FillOpticsFromXML(IOpticsElementBasePtr pOptics, const XmlNodeRef& xmlNode);
bool CreateXmlData(IOpticsElementBasePtr pOptics, XmlNodeRef& pOutNode);
void SetVariablesTemplateFromOptics(IOpticsElementBasePtr pOptics, CVarBlockPtr& pRootVar, std::vector<IVariable::OnSetCallback>& funcs);
void SetVariablesTemplateFromOptics(IOpticsElementBasePtr pOptics, CVarBlockPtr& pRootVar, std::vector<IVariable::OnSetCallback*>& funcs);
void SetVariablesTemplateFromOptics(IOpticsElementBasePtr pOptics, CVarBlockPtr& pRootVar);
void CopyOptics(IOpticsElementBasePtr pSrcOptics, IOpticsElementBasePtr pDestOptics, bool bReculsiveCopy = true);
void OutputOpticsDebug(IOpticsElementBasePtr pOptics);
@@ -212,6 +212,7 @@ public:
MOCK_METHOD0(UnloadPlugins, void());
MOCK_METHOD0(LoadPlugins, void());
MOCK_CONST_METHOD0(IsNewViewportInteractionModelEnabled, bool());
MOCK_CONST_METHOD0(IsPrefabSystemEnabled, bool());
MOCK_METHOD1(GetSearchPath, QString(EEditorPathName));
MOCK_METHOD0(GetEditorPanelUtils, IEditorPanelUtils* ());
+10 -11
View File
@@ -613,6 +613,8 @@ void MainWindow::Initialize()
AzToolsFramework::Ticker* ticker = new AzToolsFramework::Ticker(this);
ticker->Start();
connect(ticker, &AzToolsFramework::Ticker::Tick, this, &MainWindow::SystemTick);
AzToolsFramework::EditorEventsBus::Broadcast(&AzToolsFramework::EditorEvents::NotifyMainWindowInitialized, this);
}
void MainWindow::InitStatusBar()
@@ -637,6 +639,8 @@ void MainWindow::closeEvent(QCloseEvent* event)
{
auto cryEdit = CCryEditApp::instance();
gSettings.Save();
AzFramework::SystemCursorState currentCursorState;
bool isInGameMode = false;
if (GetIEditor()->IsInGameMode())
@@ -849,9 +853,6 @@ void MainWindow::InitActions()
am->AddAction(ID_GAME_IOS_ENABLELOWSPEC, tr("Low")).SetCheckable(true)
.RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdateGameSpec);
#if defined(AZ_TOOLS_EXPAND_FOR_RESTRICTED_PLATFORMS)
#if defined(TOOLS_SUPPORT_XENIA)
#include AZ_RESTRICTED_FILE_EXPLICIT(MainWindow_cpp, xenia)
#endif
#if defined(TOOLS_SUPPORT_JASPER)
#include AZ_RESTRICTED_FILE_EXPLICIT(MainWindow_cpp, jasper)
#endif
@@ -891,14 +892,12 @@ void MainWindow::InitActions()
.SetReserved()
.SetStatusTip(tr("Undo last operation"))
//.SetMenu(new QMenu("FIXME"))
.SetIcon(Style::icon("undo"))
.SetApplyHoverEffect()
.RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdateUndo);
am->AddAction(ID_REDO, tr("&Redo"))
.SetShortcut(AzQtComponents::RedoKeySequence)
.SetReserved()
//.SetMenu(new QMenu("FIXME"))
.SetIcon(Style::icon("Redo"))
.SetApplyHoverEffect()
.SetStatusTip(tr("Redo last undo operation"))
.RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdateRedo);
@@ -1242,7 +1241,7 @@ void MainWindow::InitActions()
.SetShortcut(tr("Ctrl+F12"))
.SetToolTip(tr("Location 12 (Ctrl+F12)"));
if (!AZ::Interface<AzFramework::AtomActiveInterface>::Get())
if (CViewManager::IsMultiViewportEnabled())
{
am->AddAction(ID_VIEW_CONFIGURELAYOUT, tr("Configure Layout..."));
}
@@ -1267,7 +1266,6 @@ void MainWindow::InitActions()
.SetShortcut(tr("Ctrl+G"))
.SetToolTip(tr("Play Game (Ctrl+G)"))
.SetStatusTip(tr("Activate the game input mode"))
.SetIcon(Style::icon("Play"))
.SetApplyHoverEffect()
.SetCheckable(true)
.RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdatePlayGame);
@@ -1310,7 +1308,7 @@ void MainWindow::InitActions()
am->AddAction(ID_VALIDATELEVEL, tr("&Check Level for Errors"))
.SetStatusTip(tr("Validate Level"));
am->AddAction(ID_TOOLS_VALIDATEOBJECTPOSITIONS, tr("Check Object Positions"));
QAction* saveLevelStatsAction =
QAction* saveLevelStatsAction =
am->AddAction(ID_TOOLS_LOGMEMORYUSAGE, tr("Save Level Statistics"))
.SetStatusTip(tr("Logs Editor memory usage."));
if( saveLevelStatsAction && AZ::Interface<AzFramework::AtomActiveInterface>::Get())
@@ -1337,7 +1335,7 @@ void MainWindow::InitActions()
.SetToolTip(tr("Show &Quick Access Bar (Ctrl+Alt+Space)"));
// Disable layouts menu
if (!AZ::Interface<AzFramework::AtomActiveInterface>::Get())
if (CViewManager::IsMultiViewportEnabled())
{
am->AddAction(ID_VIEW_LAYOUTS, tr("Layouts"));
@@ -1967,7 +1965,8 @@ void MainWindow::RegisterStdViewClasses()
//CLightmapCompilerDialog::RegisterViewClass();
// Notify that views can now be registered
EBUS_EVENT(AzToolsFramework::EditorEvents::Bus, NotifyRegisterViews);
AzToolsFramework::EditorEvents::Bus::Broadcast(
&AzToolsFramework::EditorEvents::Bus::Events::NotifyRegisterViews);
}
void MainWindow::OnCustomizeToolbar()
@@ -2356,7 +2355,7 @@ void MainWindow::RegisterOpenWndCommands()
cmdUI.tooltip = (QString("Open ") + className).toUtf8().data();
cmdUI.iconFilename = className.toUtf8().data();
GetIEditor()->GetCommandManager()->RegisterUICommand("editor", openCommandName.toUtf8().data(),
"", "", functor(*pCmd, &CEditorOpenViewCommand::Execute), cmdUI);
"", "", AZStd::bind(&CEditorOpenViewCommand::Execute, pCmd), cmdUI);
GetIEditor()->GetCommandManager()->GetUIInfo("editor", openCommandName.toUtf8().data(), cmdUI);
}
}
@@ -1342,7 +1342,7 @@ CMaterialDialog::CMaterialDialog(QWidget* parent /* = 0 */)
GetIEditor()->RegisterNotifyListener(this);
m_pMatManager->AddListener(this);
m_propsCtrl->SetUndoCallback(functor(*this, &CMaterialDialog::OnUndo));
m_propsCtrl->SetUndoCallback(AZStd::bind(&CMaterialDialog::OnUndo, this, AZStd::placeholders::_1));
m_propsCtrl->SetStoreUndoByItems(false);
// KDAB_TODO: hack until we have proper signal coming from the IEDitor
@@ -1899,7 +1899,7 @@ void CMaterialDialog::SelectItem(CBaseLibraryItem* item, bool bForceReload)
UpdateShaderParamsUI(mtl);
//////////////////////////////////////////////////////////////////////////
m_propsCtrl->SetUpdateCallback(functor(*this, &CMaterialDialog::OnUpdateProperties));
m_propsCtrl->SetUpdateCallback(AZStd::bind(&CMaterialDialog::OnUpdateProperties, this, AZStd::placeholders::_1));
m_propsCtrl->EnableUpdateCallback(true);
if (mtl->IsDummy())
@@ -586,7 +586,7 @@ CMaterial* CMaterialManager::LoadMaterialWithFullSourcePath(const QString& relat
//////////////////////////////////////////////////////////////////////////
CMaterial* CMaterialManager::LoadMaterialInternal(const QString &materialNameClear, const QString &fullSourcePath, const QString &relativeFilePath, bool makeIfNotFound)
{
{
// Note: We are loading from source files here, not from compiled assets, so there is no need to query the asset system for compilation status, etc.
// Load material with this name if not yet loaded.
@@ -650,7 +650,7 @@ void CMaterialManager::AddSourceFileOpeners(const char* fullSourceFileName, [[ma
if (AZStd::wildcard_match("*.mtl", fullSourceFileName))
{
// we can handle these!
// we can handle these!
auto materialCallback = [this](const char* fullSourceFileNameInCall, const AZ::Uuid& sourceUUIDInCall)
{
const SourceAssetBrowserEntry* fullDetails = SourceAssetBrowserEntry::GetSourceByUuid(sourceUUIDInCall);
@@ -867,7 +867,7 @@ void CMaterialManager::OnCreateMaterial(_smart_ptr<IMaterial> pMatInfo)
AddForHighlighting(pMaterial);
}
else
else
{
// If the material already exists, re-set its values from the engine material that was just re-loaded
existingMaterial->SetFromMatInfo(pMatInfo);
@@ -1031,12 +1031,12 @@ void CMaterialManager::RemoveMaterialFromDisk(const char * fileName)
//////////////////////////////////////////////////////////////////////////
void CMaterialManager::RegisterCommands(CRegistrationContext& regCtx)
{
CommandManagerHelper::RegisterCommand(regCtx.pCommandManager, "material", "duplicate", "", "", functor(*this, &CMaterialManager::Command_Duplicate));
CommandManagerHelper::RegisterCommand(regCtx.pCommandManager, "material", "merge", "", "", functor(*this, &CMaterialManager::Command_Merge));
CommandManagerHelper::RegisterCommand(regCtx.pCommandManager, "material", "delete", "", "", functor(*this, &CMaterialManager::Command_Delete));
CommandManagerHelper::RegisterCommand(regCtx.pCommandManager, "material", "assign_to_selection", "", "", functor(*this, &CMaterialManager::Command_AssignToSelection));
CommandManagerHelper::RegisterCommand(regCtx.pCommandManager, "material", "select_assigned_objects", "", "", functor(*this, &CMaterialManager::Command_SelectAssignedObjects));
CommandManagerHelper::RegisterCommand(regCtx.pCommandManager, "material", "select_from_object", "", "", functor(*this, &CMaterialManager::Command_SelectFromObject));
CommandManagerHelper::RegisterCommand(regCtx.pCommandManager, "material", "duplicate", "", "", AZStd::bind(&CMaterialManager::Command_Duplicate, this));
CommandManagerHelper::RegisterCommand(regCtx.pCommandManager, "material", "merge", "", "", AZStd::bind(&CMaterialManager::Command_Merge, this));
CommandManagerHelper::RegisterCommand(regCtx.pCommandManager, "material", "delete", "", "", AZStd::bind(&CMaterialManager::Command_Delete, this));
CommandManagerHelper::RegisterCommand(regCtx.pCommandManager, "material", "assign_to_selection", "", "", AZStd::bind(&CMaterialManager::Command_AssignToSelection, this));
CommandManagerHelper::RegisterCommand(regCtx.pCommandManager, "material", "select_assigned_objects", "", "", AZStd::bind(&CMaterialManager::Command_SelectAssignedObjects, this));
CommandManagerHelper::RegisterCommand(regCtx.pCommandManager, "material", "select_from_object", "", "", AZStd::bind(&CMaterialManager::Command_SelectFromObject, this));
}
//////////////////////////////////////////////////////////////////////////
@@ -1802,7 +1802,7 @@ void CMaterialManager::QueueSourceControlTick()
};
AZ::SystemTickBus::QueueFunction(tickFunction);
// Stop further queues as TickSourceControl will queue itself
// Stop further queues as TickSourceControl will queue itself
// until there are no more paths in the buffer to process
m_sourceControlFunctionQueued = true;
}
@@ -1860,7 +1860,7 @@ void CMaterialManager::StartDccMaterialSaveThread()
}
///////////////////////////////////////////////////////////////////////////
// Will save all the .dccmtl file paths in the buffer to source .mtl
// Will save all the .dccmtl file paths in the buffer to source .mtl
// Runs on a separate thread so as not to stall the main thread
void CMaterialManager::DccMaterialSaveThreadFunc()
{
@@ -1887,7 +1887,7 @@ void CMaterialManager::DccMaterialSaveThreadFunc()
m_dccMaterialSaveBuffer.clear();
}
// Save all the buffered .dccmtl files
// Save all the buffered .dccmtl files
for (AZStd::string& fileName : dccMaterialPaths)
{
SaveDccMaterial(fileName);
@@ -1987,9 +1987,9 @@ void CMaterialManager::OnCatalogAssetChanged(const AZ::Data::AssetId& assetId)
{
AZ::Data::AssetInfo assetInfo;
EBUS_EVENT_RESULT(assetInfo, AZ::Data::AssetCatalogRequestBus, GetAssetInfoById, assetId);
if (assetInfo.m_assetType != m_dccMaterialAssetType)
{
{
// Ignore types that aren't .dccmtl
return;
}
@@ -2007,7 +2007,7 @@ void CMaterialManager::AddDccMaterialPath(const AZStd::string relativeDccMateria
// Lock access to the buffer
AZStd::lock_guard<AZStd::mutex> lock(m_sourceControlBufferMutex);
// Add file path
m_sourceControlBuffer.push_back(relativeDccMaterialPath);
@@ -73,7 +73,7 @@ AZ_POP_DISABLE_DLL_EXPORT_BASECLASS_WARNING
public:
//! Notification callback.
typedef Functor0 NotifyCallback;
typedef AZStd::function<void()> NotifyCallback;
CMaterialManager(CRegistrationContext& regCtx);
~CMaterialManager();
+6 -3
View File
@@ -184,6 +184,9 @@ void CMission::Export(XmlNodeRef& root, XmlNodeRef& objectsNode)
//objects->setTag( "Objects" );
//root->addChild( objects );
XmlNodeRef envNode = m_environment->clone();
root->addChild(envNode);
m_timeOfDay->setAttr("Time", m_time);
root->addChild(m_timeOfDay);
@@ -262,10 +265,10 @@ void CMission::SyncContent(bool bRetrieve, bool bIgnoreObjects, [[maybe_unused]]
if (GetIEditor()->Get3DEngine())
{
m_numCGFObjects = GetIEditor()->Get3DEngine()->GetLoadedObjectCount();
}
// Load time of day.
GetIEditor()->Get3DEngine()->GetTimeOfDay()->Serialize(m_timeOfDay, true);
// Load time of day.
GetIEditor()->Get3DEngine()->GetTimeOfDay()->Serialize(m_timeOfDay, true);
}
}
else
{
+15 -9
View File
@@ -92,11 +92,17 @@ CModelViewport::CModelViewport(const char* settingsPath, QWidget* parent)
m_arrRunStrafeSmoothing.resize(0x100);
SetPlayerPos();
// cache all the variable callbacks, must match order of enum defined in header
m_onSetCallbacksCache.push_back(AZStd::bind(&CModelViewport::OnCharPhysics, this, AZStd::placeholders::_1));
m_onSetCallbacksCache.push_back(AZStd::bind(&CModelViewport::OnLightColor, this, AZStd::placeholders::_1));
m_onSetCallbacksCache.push_back(AZStd::bind(&CModelViewport::OnLightMultiplier, this, AZStd::placeholders::_1));
m_onSetCallbacksCache.push_back(AZStd::bind(&CModelViewport::OnShowShaders, this, AZStd::placeholders::_1));
//--------------------------------------------------
// Register variables.
//--------------------------------------------------
m_vars.AddVariable(mv_showPhysics, "Display Physics");
m_vars.AddVariable(mv_useCharPhysics, "Use Character Physics", functor(*this, &CModelViewport::OnCharPhysics));
m_vars.AddVariable(mv_useCharPhysics, "Use Character Physics", &m_onSetCallbacksCache[VariableCallbackIndex::OnCharPhysics]);
mv_useCharPhysics = true;
m_vars.AddVariable(mv_showGrid, "ShowGrid");
mv_showGrid = true;
@@ -113,14 +119,14 @@ CModelViewport::CModelViewport(const char* settingsPath, QWidget* parent)
mv_lighting = true;
m_vars.AddVariable(mv_animateLights, "AnimLights");
m_vars.AddVariable(mv_backgroundColor, "BackgroundColor", functor(*this, &CModelViewport::OnLightColor), IVariable::DT_COLOR);
m_vars.AddVariable(mv_objectAmbientColor, "ObjectAmbient", functor(*this, &CModelViewport::OnLightColor), IVariable::DT_COLOR);
m_vars.AddVariable(mv_backgroundColor, "BackgroundColor", &m_onSetCallbacksCache[VariableCallbackIndex::OnLightColor], IVariable::DT_COLOR);
m_vars.AddVariable(mv_objectAmbientColor, "ObjectAmbient", &m_onSetCallbacksCache[VariableCallbackIndex::OnLightColor], IVariable::DT_COLOR);
m_vars.AddVariable(mv_lightDiffuseColor, "LightDiffuse", functor(*this, &CModelViewport::OnLightColor), IVariable::DT_COLOR);
m_vars.AddVariable(mv_lightMultiplier, "Light Multiplier", functor(*this, &CModelViewport::OnLightMultiplier), IVariable::DT_SIMPLE);
m_vars.AddVariable(mv_lightSpecMultiplier, "Light Specular Multiplier", functor(*this, &CModelViewport::OnLightMultiplier), IVariable::DT_SIMPLE);
m_vars.AddVariable(mv_lightRadius, "Light Radius", functor(*this, &CModelViewport::OnLightMultiplier), IVariable::DT_SIMPLE);
m_vars.AddVariable(mv_lightOrbit, "Light Orbit", functor(*this, &CModelViewport::OnLightMultiplier), IVariable::DT_SIMPLE);
m_vars.AddVariable(mv_lightDiffuseColor, "LightDiffuse", &m_onSetCallbacksCache[VariableCallbackIndex::OnLightColor], IVariable::DT_COLOR);
m_vars.AddVariable(mv_lightMultiplier, "Light Multiplier", &m_onSetCallbacksCache[VariableCallbackIndex::OnLightMultiplier], IVariable::DT_SIMPLE);
m_vars.AddVariable(mv_lightSpecMultiplier, "Light Specular Multiplier", &m_onSetCallbacksCache[VariableCallbackIndex::OnLightMultiplier], IVariable::DT_SIMPLE);
m_vars.AddVariable(mv_lightRadius, "Light Radius", &m_onSetCallbacksCache[VariableCallbackIndex::OnLightMultiplier], IVariable::DT_SIMPLE);
m_vars.AddVariable(mv_lightOrbit, "Light Orbit", &m_onSetCallbacksCache[VariableCallbackIndex::OnLightMultiplier], IVariable::DT_SIMPLE);
m_vars.AddVariable(mv_showWireframe1, "ShowWireframe1");
m_vars.AddVariable(mv_showWireframe2, "ShowWireframe2");
@@ -141,7 +147,7 @@ CModelViewport::CModelViewport(const char* settingsPath, QWidget* parent)
m_vars.AddVariable(mv_forceLODNum, "ForceLODNum");
mv_forceLODNum = 0;
mv_forceLODNum.SetLimits(0, 10);
m_vars.AddVariable(mv_showShaders, "ShowShaders", functor(*this, &CModelViewport::OnShowShaders));
m_vars.AddVariable(mv_showShaders, "ShowShaders", &m_onSetCallbacksCache[VariableCallbackIndex::OnShowShaders]);
m_vars.AddVariable(mv_AttachCamera, "AttachCamera");
m_vars.AddVariable(mv_fov, "FOV");
+18
View File
@@ -245,6 +245,24 @@ protected:
void OnDestroy();
void mouseDoubleClickEvent(QMouseEvent* event) override;
private:
struct VariableCallbackIndex
{
enum : unsigned char
{
OnCharPhysics = 0,
OnLightColor,
OnLightMultiplier,
OnShowShaders,
// must be at the end
Count,
};
};
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
AZStd::fixed_vector< IVariable::OnSetCallback, VariableCallbackIndex::Count > m_onSetCallbacksCache;
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
};
#endif // CRYINCLUDE_EDITOR_MODELVIEWPORT_H
+2 -2
View File
@@ -43,7 +43,7 @@ CAxisGizmo::CAxisGizmo(CBaseObject* object)
SetFlags(EGIZMO_SELECTABLE | EGIZMO_TRANSFORM_MANIPULATOR);
m_axisGizmoCount++;
m_object->AddEventListener(functor(*this, &CAxisGizmo::OnObjectEvent));
m_object->AddEventListener(this);
m_localTM.SetIdentity();
m_parentTM.SetIdentity();
@@ -72,7 +72,7 @@ CAxisGizmo::~CAxisGizmo()
{
if (m_object)
{
m_object->RemoveEventListener(functor(*this, &CAxisGizmo::OnObjectEvent));
m_object->RemoveEventListener(this);
}
m_axisGizmoCount--;
}
+2 -1
View File
@@ -29,6 +29,7 @@ class CAxisHelperExtended;
class SANDBOX_API CAxisGizmo
: public CGizmo
, public ITransformManipulator
, public CBaseObject::EventListener
{
public:
CAxisGizmo();
@@ -68,7 +69,7 @@ public:
CBaseObjectPtr GetBaseObject() const override { return m_object; }
private:
void OnObjectEvent(CBaseObject* object, int event);
void OnObjectEvent(CBaseObject* object, int event) override;
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
CBaseObjectPtr m_object;
+12 -16
View File
@@ -1845,8 +1845,8 @@ void CBaseObject::Serialize(CObjectArchive& ar)
//////////////////////////////////////////////////////////////////////////
SetMaterial(mtlName);
ar.SetResolveCallback(this, parentId, functor(*this, &CBaseObject::ResolveParent));
ar.SetResolveCallback(this, lookatId, functor(*this, &CBaseObject::SetLookAt));
ar.SetResolveCallback(this, parentId, AZStd::bind(&CBaseObject::ResolveParent, this, AZStd::placeholders::_1 ));
ar.SetResolveCallback(this, lookatId, AZStd::bind(&CBaseObject::SetLookAt, this, AZStd::placeholders::_1));
InvalidateTM(0);
SetModified(false);
@@ -2883,26 +2883,26 @@ bool CBaseObject::IsLookAtTarget() const
}
//////////////////////////////////////////////////////////////////////////
void CBaseObject::AddEventListener(const EventCallback& cb)
void CBaseObject::AddEventListener(EventListener* listener)
{
if (find(m_eventListeners.begin(), m_eventListeners.end(), cb) == m_eventListeners.end())
if (find(m_eventListeners.begin(), m_eventListeners.end(), listener) == m_eventListeners.end())
{
m_eventListeners.push_back(cb);
m_eventListeners.push_back(listener);
}
}
//////////////////////////////////////////////////////////////////////////
void CBaseObject::RemoveEventListener(const EventCallback& cb)
void CBaseObject::RemoveEventListener(EventListener* listener)
{
std::vector<EventCallback>::iterator cbFound = find(m_eventListeners.begin(), m_eventListeners.end(), cb);
if (cbFound != m_eventListeners.end())
std::vector<EventListener*>::iterator listenerFound = find(m_eventListeners.begin(), m_eventListeners.end(), listener);
if (listenerFound != m_eventListeners.end())
{
(*cbFound) = EventCallback();
(*listenerFound) = nullptr;
}
}
//////////////////////////////////////////////////////////////////////////
bool IsBaseObjectEventCallbackNULL(const CBaseObject::EventCallback& cb) { return cb.getFunc() == NULL; }
bool IsBaseObjectEventCallbackNULL(CBaseObject::EventListener* listener) { return listener == nullptr; }
//////////////////////////////////////////////////////////////////////////
void CBaseObject::NotifyListeners(EObjectListenerEvent event)
@@ -2910,15 +2910,14 @@ void CBaseObject::NotifyListeners(EObjectListenerEvent event)
for (auto it = m_eventListeners.begin(); it != m_eventListeners.end(); ++it)
{
// Call listener callback.
if ((*it).getFunc() != NULL)
if (*it)
{
(*it)(this, event);
(*it)->OnObjectEvent(this, event);
}
}
m_eventListeners.erase(remove_if(m_eventListeners.begin(), m_eventListeners.end(), IsBaseObjectEventCallbackNULL), std::end(m_eventListeners));
}
//////////////////////////////////////////////////////////////////////////
bool CBaseObject::ConvertFromObject(CBaseObject* object)
{
@@ -3169,9 +3168,6 @@ void CBaseObject::OnContextMenu(QMenu* menu)
GatherUsedResources(resources);
static_cast<CEditorImpl*>(GetIEditor())->OnObjectContextMenuOpened(menu, this);
//TODO: to be re-added when AssetBrowser is loading fast
//menu->Add("Show in Asset Browser", functor(*this, &CBaseObject::OnMenuShowInAssetBrowser)).Enable(!resources.files.empty());
}
//////////////////////////////////////////////////////////////////////////
+8 -5
View File
@@ -236,7 +236,7 @@ class SANDBOX_API CBaseObject
{
Q_OBJECT
public:
//! Events sent by object to listeners in EventCallback.
//! Events sent by object to EventListeners
enum EObjectListenerEvent
{
ON_DELETE = 0,// Sent after object was deleted from object manager.
@@ -260,7 +260,10 @@ public:
};
//! This callback will be called if object is deleted.
typedef Functor2<CBaseObject*, int> EventCallback;
struct EventListener
{
virtual void OnObjectEvent(CBaseObject*, int) = 0;
};
//! Childs structure.
typedef std::vector<_smart_ptr<CBaseObject> > Childs;
@@ -547,9 +550,9 @@ public:
void StoreUndo(const char* undoDescription, bool minimal = false, int flags = 0);
//! Add event listener callback.
void AddEventListener(const EventCallback& cb);
void AddEventListener(EventListener* listener);
//! Remove event listener callback.
void RemoveEventListener(const EventCallback& cb);
void RemoveEventListener(EventListener* listener);
//////////////////////////////////////////////////////////////////////////
//! Material handling for this base object.
@@ -868,7 +871,7 @@ private:
//////////////////////////////////////////////////////////////////////////
// Listeners.
std::vector<EventCallback> m_eventListeners;
std::vector<EventListener*> m_eventListeners;
//////////////////////////////////////////////////////////////////////////
// Flags and bit masks.
@@ -40,7 +40,7 @@ DisplayContext::DisplayContext()
m_currentMatrix = 0;
m_matrixStack[m_currentMatrix].SetIdentity();
pRenderAuxGeom = gEnv->pRenderer->GetIRenderAuxGeom();
pRenderAuxGeom = gEnv->pRenderer ? gEnv->pRenderer->GetIRenderAuxGeom() : nullptr;
m_thickness = 0;
m_width = 0;
+53 -31
View File
@@ -238,6 +238,27 @@ CEntityObject::CEntityObject()
m_physicsState = 0;
m_attachmentType = eAT_Pivot;
// cache all the variable callbacks, must match order of enum defined in header
m_onSetCallbacksCache.push_back(AZStd::bind(&CEntityObject::OnAreaHeightChange, this, AZStd::placeholders::_1));
m_onSetCallbacksCache.push_back(AZStd::bind(&CEntityObject::OnAreaLightChange, this, AZStd::placeholders::_1));
m_onSetCallbacksCache.push_back(AZStd::bind(&CEntityObject::OnAreaLightSizeChange, this, AZStd::placeholders::_1));
m_onSetCallbacksCache.push_back(AZStd::bind(&CEntityObject::OnAreaWidthChange, this, AZStd::placeholders::_1));
m_onSetCallbacksCache.push_back(AZStd::bind(&CEntityObject::OnBoxHeightChange, this, AZStd::placeholders::_1));
m_onSetCallbacksCache.push_back(AZStd::bind(&CEntityObject::OnBoxLengthChange, this, AZStd::placeholders::_1));
m_onSetCallbacksCache.push_back(AZStd::bind(&CEntityObject::OnBoxProjectionChange, this, AZStd::placeholders::_1));
m_onSetCallbacksCache.push_back(AZStd::bind(&CEntityObject::OnBoxSizeXChange, this, AZStd::placeholders::_1));
m_onSetCallbacksCache.push_back(AZStd::bind(&CEntityObject::OnBoxSizeYChange, this, AZStd::placeholders::_1));
m_onSetCallbacksCache.push_back(AZStd::bind(&CEntityObject::OnBoxSizeZChange, this, AZStd::placeholders::_1));
m_onSetCallbacksCache.push_back(AZStd::bind(&CEntityObject::OnBoxWidthChange, this, AZStd::placeholders::_1));
m_onSetCallbacksCache.push_back(AZStd::bind(&CEntityObject::OnColorChange, this, AZStd::placeholders::_1));
m_onSetCallbacksCache.push_back(AZStd::bind(&CEntityObject::OnInnerRadiusChange, this, AZStd::placeholders::_1));
m_onSetCallbacksCache.push_back(AZStd::bind(&CEntityObject::OnOuterRadiusChange, this, AZStd::placeholders::_1));
m_onSetCallbacksCache.push_back(AZStd::bind(&CEntityObject::OnProjectInAllDirsChange, this, AZStd::placeholders::_1));
m_onSetCallbacksCache.push_back(AZStd::bind(&CEntityObject::OnProjectorFOVChange, this, AZStd::placeholders::_1));
m_onSetCallbacksCache.push_back(AZStd::bind(&CEntityObject::OnProjectorTextureChange, this, AZStd::placeholders::_1));
m_onSetCallbacksCache.push_back(AZStd::bind(&CEntityObject::OnPropertyChange, this, AZStd::placeholders::_1));
m_onSetCallbacksCache.push_back(AZStd::bind(&CEntityObject::OnRadiusChange, this, AZStd::placeholders::_1));
}
CEntityObject::~CEntityObject()
@@ -930,7 +951,8 @@ void CEntityObject::Serialize(CObjectArchive& ar)
m_eventTargets.push_back(et);
if (targetId != GUID_NULL)
{
ar.SetResolveCallback(this, targetId, functor(*this, &CEntityObject::ResolveEventTarget), i);
using namespace AZStd::placeholders;
ar.SetResolveCallback(this, targetId, AZStd::bind(&CEntityObject::ResolveEventTarget, this, _1, _2), i);
}
}
}
@@ -1410,7 +1432,7 @@ void CEntityObject::ResolveEventTarget(CBaseObject* object, unsigned int index)
assert(index >= 0 && index < m_eventTargets.size());
if (object)
{
object->AddEventListener(functor(*this, &CEntityObject::OnEventTargetEvent));
object->AddEventListener(this);
}
m_eventTargets[index].target = object;
@@ -1522,7 +1544,7 @@ void CEntityObject::SaveLink(XmlNodeRef xmlNode)
}
//////////////////////////////////////////////////////////////////////////
void CEntityObject::OnEventTargetEvent(CBaseObject* target, int event)
void CEntityObject::OnObjectEvent(CBaseObject* target, int event)
{
// When event target is deleted.
if (event == CBaseObject::ON_DELETE)
@@ -1566,7 +1588,7 @@ int CEntityObject::AddEventTarget(CBaseObject* target, const QString& event, con
// Assign event target.
if (et.target)
{
et.target->AddEventListener(functor(*this, &CEntityObject::OnEventTargetEvent));
et.target->AddEventListener(this);
}
if (target)
@@ -1600,7 +1622,7 @@ void CEntityObject::RemoveEventTarget(int index, [[maybe_unused]] bool bUpdateSc
if (m_eventTargets[index].target)
{
m_eventTargets[index].target->RemoveEventListener(functor(*this, &CEntityObject::OnEventTargetEvent));
m_eventTargets[index].target->RemoveEventListener(this);
}
m_eventTargets.erase(m_eventTargets.begin() + index);
@@ -1634,7 +1656,7 @@ int CEntityObject::AddEntityLink(const QString& name, GUID targetEntityId)
// Assign event target.
if (target)
{
target->AddEventListener(functor(*this, &CEntityObject::OnEventTargetEvent));
target->AddEventListener(this);
// Make line gizmo.
pLineGizmo = new CLineGizmo;
@@ -1684,7 +1706,7 @@ void CEntityObject::RemoveEntityLink(int index)
if (link.target)
{
link.target->RemoveEventListener(functor(*this, &CEntityObject::OnEventTargetEvent));
link.target->RemoveEventListener(this);
link.target->EntityUnlinked(link.name, GetId());
}
m_links.erase(m_links.begin() + index);
@@ -2188,7 +2210,7 @@ void CEntityObject::ResetCallbacks()
if (var && (var->GetType() == IVariable::FLOAT || var->GetType() == IVariable::INT))
{
var->Get(m_proximityRadius);
SetVariableCallback(var, functor(*this, &CEntityObject::OnRadiusChange));
SetVariableCallback(var, &m_onSetCallbacksCache[VariableCallbackIndex::OnRadiusChange]);
}
else
{
@@ -2196,7 +2218,7 @@ void CEntityObject::ResetCallbacks()
if (var && (var->GetType() == IVariable::FLOAT || var->GetType() == IVariable::INT))
{
var->Get(m_proximityRadius);
SetVariableCallback(var, functor(*this, &CEntityObject::OnRadiusChange));
SetVariableCallback(var, &m_onSetCallbacksCache[VariableCallbackIndex::OnRadiusChange]);
}
}
@@ -2204,39 +2226,39 @@ void CEntityObject::ResetCallbacks()
if (var && (var->GetType() == IVariable::FLOAT || var->GetType() == IVariable::INT))
{
var->Get(m_innerRadius);
SetVariableCallback(var, functor(*this, &CEntityObject::OnInnerRadiusChange));
SetVariableCallback(var, &m_onSetCallbacksCache[VariableCallbackIndex::OnInnerRadiusChange]);
}
var = pProperties->FindVariable("OuterRadius", false);
if (var && (var->GetType() == IVariable::FLOAT || var->GetType() == IVariable::INT))
{
var->Get(m_outerRadius);
SetVariableCallback(var, functor(*this, &CEntityObject::OnOuterRadiusChange));
SetVariableCallback(var, &m_onSetCallbacksCache[VariableCallbackIndex::OnOuterRadiusChange]);
}
var = pProperties->FindVariable("BoxSizeX", false);
if (var && (var->GetType() == IVariable::FLOAT || var->GetType() == IVariable::INT))
{
var->Get(m_boxSizeX);
SetVariableCallback(var, functor(*this, &CEntityObject::OnBoxSizeXChange));
SetVariableCallback(var, &m_onSetCallbacksCache[VariableCallbackIndex::OnBoxSizeXChange]);
}
var = pProperties->FindVariable("BoxSizeY", false);
if (var && (var->GetType() == IVariable::FLOAT || var->GetType() == IVariable::INT))
{
var->Get(m_boxSizeY);
SetVariableCallback(var, functor(*this, &CEntityObject::OnBoxSizeYChange));
SetVariableCallback(var, &m_onSetCallbacksCache[VariableCallbackIndex::OnBoxSizeYChange]);
}
var = pProperties->FindVariable("BoxSizeZ", false);
if (var && (var->GetType() == IVariable::FLOAT || var->GetType() == IVariable::INT))
{
var->Get(m_boxSizeZ);
SetVariableCallback(var, functor(*this, &CEntityObject::OnBoxSizeZChange));
SetVariableCallback(var, &m_onSetCallbacksCache[VariableCallbackIndex::OnBoxSizeZChange]);
}
var = pProperties->FindVariable("fAttenuationBulbSize");
if (var && (var->GetType() == IVariable::FLOAT || var->GetType() == IVariable::INT))
{
var->Get(m_fAreaLightSize);
SetVariableCallback(var, functor(*this, &CEntityObject::OnAreaLightSizeChange));
SetVariableCallback(var, &m_onSetCallbacksCache[VariableCallbackIndex::OnAreaLightSizeChange]);
}
IVariable* pProjector = pProperties->FindVariable("Projector");
@@ -2246,7 +2268,7 @@ void CEntityObject::ResetCallbacks()
if (var && (var->GetType() == IVariable::FLOAT || var->GetType() == IVariable::INT))
{
var->Get(m_projectorFOV);
SetVariableCallback(var, functor(*this, &CEntityObject::OnProjectorFOVChange));
SetVariableCallback(var, &m_onSetCallbacksCache[VariableCallbackIndex::OnProjectorFOVChange]);
}
var = pProjector->FindVariable("bProjectInAllDirs");
if (var && var->GetType() == IVariable::BOOL)
@@ -2254,7 +2276,7 @@ void CEntityObject::ResetCallbacks()
int value;
var->Get(value);
m_bProjectInAllDirs = value;
SetVariableCallback(var, functor(*this, &CEntityObject::OnProjectInAllDirsChange));
SetVariableCallback(var, &m_onSetCallbacksCache[VariableCallbackIndex::OnProjectInAllDirsChange]);
}
var = pProjector->FindVariable("texture_Texture");
if (var && var->GetType() == IVariable::STRING)
@@ -2262,7 +2284,7 @@ void CEntityObject::ResetCallbacks()
QString projectorTexture;
var->Get(projectorTexture);
m_bProjectorHasTexture = !projectorTexture.isEmpty();
SetVariableCallback(var, functor(*this, &CEntityObject::OnProjectorTextureChange));
SetVariableCallback(var, &m_onSetCallbacksCache[VariableCallbackIndex::OnProjectorTextureChange]);
}
}
@@ -2282,7 +2304,7 @@ void CEntityObject::ResetCallbacks()
if (name == "clrDiffuse")
{
pChild->Get(m_lightColor);
SetVariableCallback(pChild, functor(*this, &CEntityObject::OnColorChange));
SetVariableCallback(pChild, &m_onSetCallbacksCache[VariableCallbackIndex::OnColorChange]);
break;
}
}
@@ -2297,19 +2319,19 @@ void CEntityObject::ResetCallbacks()
int value;
var->Get(value);
m_bAreaLight = value;
SetVariableCallback(var, functor(*this, &CEntityObject::OnAreaLightChange));
SetVariableCallback(var, &m_onSetCallbacksCache[VariableCallbackIndex::OnAreaLightChange]);
}
var = pType->FindVariable("fPlaneWidth");
if (var && (var->GetType() == IVariable::FLOAT || var->GetType() == IVariable::INT))
{
var->Get(m_fAreaWidth);
SetVariableCallback(var, functor(*this, &CEntityObject::OnAreaWidthChange));
SetVariableCallback(var, &m_onSetCallbacksCache[VariableCallbackIndex::OnAreaWidthChange]);
}
var = pType->FindVariable("fPlaneHeight");
if (var && (var->GetType() == IVariable::FLOAT || var->GetType() == IVariable::INT))
{
var->Get(m_fAreaHeight);
SetVariableCallback(var, functor(*this, &CEntityObject::OnAreaHeightChange));
SetVariableCallback(var, &m_onSetCallbacksCache[VariableCallbackIndex::OnAreaHeightChange]);
}
}
@@ -2322,40 +2344,40 @@ void CEntityObject::ResetCallbacks()
int value;
var->Get(value);
m_bBoxProjectedCM = value;
SetVariableCallback(var, functor(*this, &CEntityObject::OnBoxProjectionChange));
SetVariableCallback(var, &m_onSetCallbacksCache[VariableCallbackIndex::OnBoxProjectionChange]);
}
var = pProjection->FindVariable("fBoxWidth");
if (var && (var->GetType() == IVariable::FLOAT || var->GetType() == IVariable::INT))
{
var->Get(m_fBoxWidth);
SetVariableCallback(var, functor(*this, &CEntityObject::OnBoxWidthChange));
SetVariableCallback(var, &m_onSetCallbacksCache[VariableCallbackIndex::OnBoxWidthChange]);
}
var = pProjection->FindVariable("fBoxHeight");
if (var && (var->GetType() == IVariable::FLOAT || var->GetType() == IVariable::INT))
{
var->Get(m_fBoxHeight);
SetVariableCallback(var, functor(*this, &CEntityObject::OnBoxHeightChange));
SetVariableCallback(var, &m_onSetCallbacksCache[VariableCallbackIndex::OnBoxHeightChange]);
}
var = pProjection->FindVariable("fBoxLength");
if (var && (var->GetType() == IVariable::FLOAT || var->GetType() == IVariable::INT))
{
var->Get(m_fBoxLength);
SetVariableCallback(var, functor(*this, &CEntityObject::OnBoxLengthChange));
SetVariableCallback(var, &m_onSetCallbacksCache[VariableCallbackIndex::OnBoxLengthChange]);
}
}
// Each property must have callback to our OnPropertyChange.
pProperties->AddOnSetCallback(functor(*this, &CEntityObject::OnPropertyChange));
pProperties->AddOnSetCallback(&m_onSetCallbacksCache[VariableCallbackIndex::OnPropertyChange]);
}
if (pProperties2)
{
pProperties2->AddOnSetCallback(functor(*this, &CEntityObject::OnPropertyChange));
pProperties2->AddOnSetCallback(&m_onSetCallbacksCache[VariableCallbackIndex::OnPropertyChange]);
}
}
//////////////////////////////////////////////////////////////////////////
void CEntityObject::SetVariableCallback(IVariable* pVar, IVariable::OnSetCallback func)
void CEntityObject::SetVariableCallback(IVariable* pVar, IVariable::OnSetCallback* func)
{
pVar->AddOnSetCallback(func);
m_callbacks.push_back(std::make_pair(pVar, func));
@@ -2366,12 +2388,12 @@ void CEntityObject::ClearCallbacks()
{
if (m_pProperties)
{
m_pProperties->RemoveOnSetCallback(functor(*this, &CEntityObject::OnPropertyChange));
m_pProperties->RemoveOnSetCallback(&m_onSetCallbacksCache[VariableCallbackIndex::OnPropertyChange]);
}
if (m_pProperties2)
{
m_pProperties2->RemoveOnSetCallback(functor(*this, &CEntityObject::OnPropertyChange));
m_pProperties2->RemoveOnSetCallback(&m_onSetCallbacksCache[VariableCallbackIndex::OnPropertyChange]);
}
for (auto iter = m_callbacks.begin(); iter != m_callbacks.end(); ++iter)
+34 -3
View File
@@ -76,6 +76,7 @@ AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
*/
class CRYEDIT_API CEntityObject
: public CBaseObject
, public CBaseObject::EventListener
{
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
AZ_POP_DISABLE_DLL_EXPORT_BASECLASS_WARNING
@@ -267,7 +268,7 @@ protected:
void OnPropertyChange(IVariable* var);
//////////////////////////////////////////////////////////////////////////
virtual void OnEventTargetEvent(CBaseObject* target, int event);
void OnObjectEvent(CBaseObject* target, int event) override;
void ResolveEventTarget(CBaseObject* object, unsigned int index);
void ReleaseEventTargets();
@@ -424,15 +425,45 @@ protected:
QString m_attachmentTarget;
private:
struct VariableCallbackIndex
{
enum : unsigned char
{
OnAreaHeightChange = 0,
OnAreaLightChange,
OnAreaLightSizeChange,
OnAreaWidthChange,
OnBoxHeightChange,
OnBoxLengthChange,
OnBoxProjectionChange,
OnBoxSizeXChange,
OnBoxSizeYChange,
OnBoxSizeZChange,
OnBoxWidthChange,
OnColorChange,
OnInnerRadiusChange,
OnOuterRadiusChange,
OnProjectInAllDirsChange,
OnProjectorFOVChange,
OnProjectorTextureChange,
OnPropertyChange,
OnRadiusChange,
// must be at the end
Count,
};
};
void ResetCallbacks();
void SetVariableCallback(IVariable* pVar, IVariable::OnSetCallback func);
void SetVariableCallback(IVariable* pVar, IVariable::OnSetCallback* func);
void ClearCallbacks();
void ForceVariableUpdate();
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
CListenerSet<IEntityObjectListener*> m_listeners;
std::vector< std::pair<IVariable*, IVariable::OnSetCallback> > m_callbacks;
std::vector< std::pair<IVariable*, IVariable::OnSetCallback*> > m_callbacks;
AZStd::fixed_vector< IVariable::OnSetCallback, VariableCallbackIndex::Count > m_onSetCallbacksCache;
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
};
+4 -4
View File
@@ -35,11 +35,11 @@ CLineGizmo::~CLineGizmo()
{
if (m_object[0])
{
m_object[0]->RemoveEventListener(functor(*this, &CLineGizmo::OnObjectEvent));
m_object[0]->RemoveEventListener(this);
}
if (m_object[1])
{
m_object[1]->RemoveEventListener(functor(*this, &CLineGizmo::OnObjectEvent));
m_object[1]->RemoveEventListener(this);
}
m_object[0] = 0;
m_object[1] = 0;
@@ -54,8 +54,8 @@ void CLineGizmo::SetObjects(CBaseObject* pObject1, CBaseObject* pObject2, const
m_object[1] = pObject2;
m_boneName = boneName;
m_object[0]->AddEventListener(functor(*this, &CLineGizmo::OnObjectEvent));
m_object[1]->AddEventListener(functor(*this, &CLineGizmo::OnObjectEvent));
m_object[0]->AddEventListener(this);
m_object[1]->AddEventListener(this);
CalcBounds();
}
+2 -1
View File
@@ -25,6 +25,7 @@ struct DisplayContext;
*/
class CLineGizmo
: public CGizmo
, public CBaseObject::EventListener
{
public:
CLineGizmo();
@@ -43,7 +44,7 @@ public:
void SetColor(const Vec3& color1, const Vec3& color2, float alpha1 = 1.0f, float alpha2 = 1.0f);
private:
void OnObjectEvent(CBaseObject* object, int event);
void OnObjectEvent(CBaseObject* object, int event) override;
void CalcBounds();
CBaseObjectPtr m_object[2];
+2 -2
View File
@@ -44,9 +44,9 @@ AZ_POP_DISABLE_DLL_EXPORT_BASECLASS_WARNING
~CObjectArchive();
//! Resolve callback with only one parameter of CBaseObject.
typedef Functor1<CBaseObject*> ResolveObjRefFunctor1;
typedef AZStd::function<void(CBaseObject*)> ResolveObjRefFunctor1;
//! Resolve callback with two parameters one is pointer to CBaseObject and second use data integer.
typedef Functor2<CBaseObject*, unsigned int> ResolveObjRefFunctor2;
typedef AZStd::function<void(CBaseObject*, unsigned int)> ResolveObjRefFunctor2;
/** Register Object id.
@param objectId Original object id from the file.
+13 -13
View File
@@ -986,7 +986,7 @@ void CObjectManager::UnselectObject(CBaseObject* obj)
{
SetObjectSelected(obj, false);
}
m_currSelection->RemoveObject(obj);
}
@@ -1141,7 +1141,7 @@ int CObjectManager::ClearSelection()
GetIEditor()->RecordUndo(new CUndoBaseObjectClearSelection(*m_currSelection));
}
// Handle legacy entities separately so the selection group can be cleared safely.
// Handle legacy entities separately so the selection group can be cleared safely.
// This prevents every AzEntity from being removed one by one from a vector.
m_currSelection->RemoveAllExceptLegacySet();
@@ -1163,7 +1163,7 @@ int CObjectManager::ClearSelection()
// Unselect all component entities as one bulk operation instead of individually
AzToolsFramework::ToolsApplicationRequestBus::Broadcast(
&AzToolsFramework::ToolsApplicationRequests::SetSelectedEntities,
&AzToolsFramework::ToolsApplicationRequests::SetSelectedEntities,
AzToolsFramework::EntityIdList());
m_processingBulkSelect = false;
@@ -1927,7 +1927,7 @@ void CObjectManager::SelectObjectsInRect(CViewport* view, const QRect& rect, boo
CBaseObjectsCache* displayedViewObjects = view->GetVisibleObjectsCache();
int numVis = displayedViewObjects->GetObjectCount();
// Tracking the previous selection allows proper undo/redo functionality of additional
// Tracking the previous selection allows proper undo/redo functionality of additional
// selections (CTRL + drag select)
AZStd::unordered_set<const CBaseObject*> previousSelection;
@@ -1944,7 +1944,7 @@ void CObjectManager::SelectObjectsInRect(CViewport* view, const QRect& rect, boo
// This will update m_currSelection
SelectObjectInRect(object, view, hc, bSelect);
// Legacy undo/redo does not go through the Ebus system and must be done individually
// Legacy undo/redo does not go through the Ebus system and must be done individually
if (isUndoRecording && object->GetType() != OBJTYPE_AZENTITY)
{
GetIEditor()->RecordUndo(new CUndoBaseObjectSelect(object, true));
@@ -2517,27 +2517,27 @@ void CObjectManager::HideTransformManipulators()
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
void CObjectManager::AddObjectEventListener(const EventCallback& cb)
void CObjectManager::AddObjectEventListener(EventListener* listener)
{
stl::push_back_unique(m_objectEventListeners, cb);
stl::push_back_unique(m_objectEventListeners, listener);
}
//////////////////////////////////////////////////////////////////////////
void CObjectManager::RemoveObjectEventListener(const EventCallback& cb)
void CObjectManager::RemoveObjectEventListener(EventListener* listener)
{
stl::find_and_erase(m_objectEventListeners, cb);
stl::find_and_erase(m_objectEventListeners, listener);
}
//////////////////////////////////////////////////////////////////////////
void CObjectManager::NotifyObjectListeners(CBaseObject* pObject, CBaseObject::EObjectListenerEvent event)
{
std::list<EventCallback>::iterator next;
for (std::list<EventCallback>::iterator it = m_objectEventListeners.begin(); it != m_objectEventListeners.end(); it = next)
std::list<EventListener*>::iterator next;
for (std::list<EventListener*>::iterator it = m_objectEventListeners.begin(); it != m_objectEventListeners.end(); it = next)
{
next = it;
++next;
// Call listener callback.
(*it)(pObject, event);
(*it)->OnObjectEvent(pObject, event);
}
}
@@ -3004,7 +3004,7 @@ namespace
aabb.min.x,
aabb.min.y,
aabb.min.z
),
),
AZ::Vector3(
aabb.max.x,
aabb.max.y,
+3 -3
View File
@@ -315,8 +315,8 @@ public:
//////////////////////////////////////////////////////////////////////////
// ObjectManager notification Callbacks.
//////////////////////////////////////////////////////////////////////////
void AddObjectEventListener(const EventCallback& cb);
void RemoveObjectEventListener(const EventCallback& cb);
void AddObjectEventListener(EventListener* listener);
void RemoveObjectEventListener(EventListener* listener);
//////////////////////////////////////////////////////////////////////////
// Used to indicate starting and ending of objects loading.
@@ -445,7 +445,7 @@ private:
//////////////////////////////////////////////////////////////////////////
// Listeners.
std::list<EventCallback> m_objectEventListeners;
std::list<EventListener*> m_objectEventListeners;
bool m_bExiting;
@@ -30,13 +30,13 @@ CObjectPhysicsManager::CObjectPhysicsManager()
{
CommandManagerHelper::RegisterCommand(GetIEditor()->GetCommandManager(),
"physics", "simulate_objects", "", "",
functor(*this, &CObjectPhysicsManager::Command_SimulateObjects));
AZStd::bind(&CObjectPhysicsManager::Command_SimulateObjects, this));
CommandManagerHelper::RegisterCommand(GetIEditor()->GetCommandManager(),
"physics", "reset_objects_state", "", "",
functor(*this, &CObjectPhysicsManager::Command_ResetPhysicsState));
AZStd::bind(&CObjectPhysicsManager::Command_ResetPhysicsState, this));
CommandManagerHelper::RegisterCommand(GetIEditor()->GetCommandManager(),
"physics", "get_objects_state", "", "",
functor(*this, &CObjectPhysicsManager::Command_GetPhysicsState));
AZStd::bind(&CObjectPhysicsManager::Command_GetPhysicsState, this));
m_fStartObjectSimulationTime = 0;
m_bSimulatingObjects = false;
@@ -9,5 +9,5 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
set (PAL_TRAIT_BUILD_EDITOR_APPLICATION_TYPE EXECUTABLE)
set (PAL_TRAIT_BUILD_EDITOR_APPLICATION_TYPE APPLICATION)
@@ -9,17 +9,17 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
# ly_add_bundle_resources(
# TARGET Editor
# FILES
# ${CMAKE_SOURCE_DIR}/Code/Tools/RC/Config/rc/xmlfilter.txt
# ${CMAKE_SOURCE_DIR}/Code/Tools/RC/Config/rc/rc.ini
# )
ly_add_bundle_resources(
TARGET Editor
FILES
${CMAKE_SOURCE_DIR}/Code/Tools/RC/Config/rc/xmlfilter.txt
${CMAKE_SOURCE_DIR}/Code/Tools/RC/Config/rc/rc.ini
)
# Set resources directory for app icons
target_sources(Editor PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/res/Images.xcassets)
# set_target_properties(Editor PROPERTIES
# MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/gui_info.plist
# RESOURCE ${CMAKE_CURRENT_SOURCE_DIR}/res/Images.xcassets
# XCODE_ATTRIBUTE_ASSETCATALOG_COMPILER_APPICON_NAME EditorAppIcon
# )
target_sources(Editor PRIVATE ${CMAKE_CURRENT_LIST_DIR}/Images.xcassets)
set_target_properties(Editor PROPERTIES
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_LIST_DIR}/gui_info.plist
RESOURCE ${CMAKE_CURRENT_LIST_DIR}/Images.xcassets
XCODE_ATTRIBUTE_ASSETCATALOG_COMPILER_APPICON_NAME EditorAppIcon
)

Some files were not shown because too many files have changed in this diff Show More