Merge remote-tracking branch 'origin/development' into sc-editor-asset-redux
Signed-off-by: carlitosan <82187351+carlitosan@users.noreply.github.com>
This commit is contained in:
@@ -234,7 +234,7 @@ void Q2DViewport::UpdateContent(int flags)
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Q2DViewport::OnRButtonDown(Qt::KeyboardModifiers modifiers, const QPoint& point)
|
||||
void Q2DViewport::OnRButtonDown([[maybe_unused]] Qt::KeyboardModifiers modifiers, const QPoint& point)
|
||||
{
|
||||
if (GetIEditor()->IsInGameMode())
|
||||
{
|
||||
@@ -246,9 +246,6 @@ void Q2DViewport::OnRButtonDown(Qt::KeyboardModifiers modifiers, const QPoint& p
|
||||
setFocus();
|
||||
}
|
||||
|
||||
// Check Edit Tool.
|
||||
MouseCallback(eMouseRDown, point, modifiers);
|
||||
|
||||
SetCurrentCursor(STD_CURSOR_MOVE, QString());
|
||||
|
||||
// Save the mouse down position
|
||||
@@ -273,17 +270,8 @@ void Q2DViewport::OnRButtonUp([[maybe_unused]] Qt::KeyboardModifiers modifiers,
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Q2DViewport::OnMButtonDown(Qt::KeyboardModifiers modifiers, const QPoint& point)
|
||||
void Q2DViewport::OnMButtonDown([[maybe_unused]] Qt::KeyboardModifiers modifiers, const QPoint& point)
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// User pressed the middle mouse button
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Check Edit Tool.
|
||||
if (MouseCallback(eMouseMDown, point, modifiers))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Save the mouse down position
|
||||
m_RMouseDownPos = point;
|
||||
|
||||
@@ -300,14 +288,8 @@ void Q2DViewport::OnMButtonDown(Qt::KeyboardModifiers modifiers, const QPoint& p
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Q2DViewport::OnMButtonUp(Qt::KeyboardModifiers modifiers, const QPoint& point)
|
||||
void Q2DViewport::OnMButtonUp([[maybe_unused]] Qt::KeyboardModifiers modifiers, [[maybe_unused]] const QPoint& point)
|
||||
{
|
||||
// Check Edit Tool.
|
||||
if (MouseCallback(eMouseMUp, point, modifiers))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SetViewMode(NothingMode);
|
||||
|
||||
ReleaseMouse();
|
||||
@@ -547,13 +529,6 @@ QPoint Q2DViewport::WorldToView(const Vec3& wp) const
|
||||
QPoint p = QPoint(static_cast<int>(sp.x), static_cast<int>(sp.y));
|
||||
return p;
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
QPoint Q2DViewport::WorldToViewParticleEditor(const Vec3& wp, [[maybe_unused]] int width, [[maybe_unused]] int height) const //Eric@conffx implement for the children class of IDisplayViewport
|
||||
{
|
||||
Vec3 sp = m_screenTM.TransformPoint(wp);
|
||||
QPoint p = QPoint(static_cast<int>(sp.x), static_cast<int>(sp.y));
|
||||
return p;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
Vec3 Q2DViewport::ViewToWorld(const QPoint& vp, [[maybe_unused]] bool* collideWithTerrain, [[maybe_unused]] bool onlyTerrain, [[maybe_unused]] bool bSkipVegetation, [[maybe_unused]] bool bTestRenderMesh, [[maybe_unused]] bool* collideWithObject) const
|
||||
|
||||
@@ -50,8 +50,6 @@ public:
|
||||
//! Map world space position to viewport position.
|
||||
QPoint WorldToView(const Vec3& wp) const override;
|
||||
|
||||
QPoint WorldToViewParticleEditor(const Vec3& wp, int width, int height) const override; //Eric@conffx
|
||||
|
||||
//! Map viewport position to world space position.
|
||||
Vec3 ViewToWorld(const QPoint& vp, bool* collideWithTerrain = nullptr, bool onlyTerrain = false, bool bSkipVegetation = false, bool bTestRenderMesh = false, bool* collideWithObject = nullptr) const override;
|
||||
//! Map viewport position to world space ray from camera.
|
||||
@@ -64,7 +62,6 @@ public:
|
||||
|
||||
// ovverided from CViewport.
|
||||
float GetScreenScaleFactor(const Vec3& worldPoint) const override;
|
||||
float GetScreenScaleFactor([[maybe_unused]] const CCamera& camera, [[maybe_unused]] const Vec3& object_position) override { return 1; } //Eric@conffx
|
||||
|
||||
// Overrided from CViewport.
|
||||
void OnDragSelectRectangle(const QRect &rect, bool bNormalizeRect = false) override;
|
||||
|
||||
@@ -125,7 +125,7 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>General Availability</string>
|
||||
<string>development</string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::AutoText</enum>
|
||||
|
||||
@@ -152,15 +152,6 @@ ActionManager::ActionWrapper& ActionManager::ActionWrapper::SetMenu(DynamicMenu*
|
||||
return *this;
|
||||
}
|
||||
|
||||
ActionManager::ActionWrapper& ActionManager::ActionWrapper::SetApplyHoverEffect()
|
||||
{
|
||||
// Our standard toolbar icons, when hovered on, get a white color effect.
|
||||
// But for this to work we need .pngs that look good with this effect, so this only works with the standard toolbars
|
||||
// and looks very ugly for other toolbars, including toolbars loaded from XML (which just show a white rectangle)
|
||||
m_action->setProperty("IconHasHoverEffect", true);
|
||||
return *this;
|
||||
}
|
||||
|
||||
ActionManager::ActionWrapper& ActionManager::ActionWrapper::SetReserved()
|
||||
{
|
||||
m_action->setProperty("Reserved", true);
|
||||
|
||||
@@ -151,7 +151,6 @@ public:
|
||||
}
|
||||
|
||||
ActionWrapper& SetMenu(DynamicMenu* menu);
|
||||
ActionWrapper& SetApplyHoverEffect();
|
||||
|
||||
operator QAction*() const {
|
||||
return m_action;
|
||||
|
||||
@@ -10,24 +10,21 @@
|
||||
|
||||
#include "AnimationBipedBoneNames.h"
|
||||
|
||||
namespace EditorAnimationBones
|
||||
namespace EditorAnimationBones::Biped
|
||||
{
|
||||
namespace Biped
|
||||
{
|
||||
const char* Pelvis = "Bip01 Pelvis";
|
||||
const char* Head = "Bip01 Head";
|
||||
const char* Weapon = "weapon_bone";
|
||||
const char* Pelvis = "Bip01 Pelvis";
|
||||
const char* Head = "Bip01 Head";
|
||||
const char* Weapon = "weapon_bone";
|
||||
|
||||
const char* LeftEye = "eye_bone_left";
|
||||
const char* RightEye = "eye_bone_right";
|
||||
const char* LeftEye = "eye_bone_left";
|
||||
const char* RightEye = "eye_bone_right";
|
||||
|
||||
const char* Spine[5] = { "Bip01 Spine", "Bip01 Spine1", "Bip01 Spine2", "Bip01 Spine3", "Bip01 Spine4" };
|
||||
const char* Neck[2] = { "Bip01 Neck", "Bip01 Neck1" };
|
||||
const char* Spine[5] = { "Bip01 Spine", "Bip01 Spine1", "Bip01 Spine2", "Bip01 Spine3", "Bip01 Spine4" };
|
||||
const char* Neck[2] = { "Bip01 Neck", "Bip01 Neck1" };
|
||||
|
||||
const char* LeftHeel = "Bip01 L Heel";
|
||||
const char* LeftToe[2] = { "Bip01 L Toe0", "Bip01 L Toe1" };
|
||||
const char* LeftHeel = "Bip01 L Heel";
|
||||
const char* LeftToe[2] = { "Bip01 L Toe0", "Bip01 L Toe1" };
|
||||
|
||||
const char* RightHeel = "Bip01 R Heel";
|
||||
const char* RightToe[2] = { "Bip01 R Toe0", "Bip01 R Toe1" };
|
||||
}
|
||||
}
|
||||
const char* RightHeel = "Bip01 R Heel";
|
||||
const char* RightToe[2] = { "Bip01 R Toe0", "Bip01 R Toe1" };
|
||||
} // namespace EditorAnimationBones::Biped
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
#include "Include/IObjectManager.h"
|
||||
#include "Objects/EntityObject.h"
|
||||
|
||||
#include <AzCore/Time/ITime.h>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Movie Callback.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -499,25 +501,24 @@ void CAnimationContext::Update()
|
||||
return;
|
||||
}
|
||||
|
||||
ITimer* pTimer = GetIEditor()->GetSystem()->GetITimer();
|
||||
const AZ::TimeUs frameDeltaTimeUs = AZ::GetSimulationTickDeltaTimeUs();
|
||||
const float frameDeltaTime = AZ::TimeUsToSeconds(frameDeltaTimeUs);
|
||||
|
||||
if (!m_bAutoRecording)
|
||||
{
|
||||
AnimateActiveSequence();
|
||||
|
||||
float dt = pTimer->GetFrameTime();
|
||||
m_currTime += dt * m_fTimeScale;
|
||||
m_currTime += frameDeltaTime * m_fTimeScale;
|
||||
|
||||
if (!m_recording)
|
||||
{
|
||||
GetIEditor()->GetMovieSystem()->PreUpdate(dt);
|
||||
GetIEditor()->GetMovieSystem()->PostUpdate(dt);
|
||||
GetIEditor()->GetMovieSystem()->PreUpdate(frameDeltaTime);
|
||||
GetIEditor()->GetMovieSystem()->PostUpdate(frameDeltaTime);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
float dt = pTimer->GetFrameTime();
|
||||
m_fRecordingCurrTime += dt * m_fTimeScale;
|
||||
m_fRecordingCurrTime += frameDeltaTime * m_fTimeScale;
|
||||
if (fabs(m_fRecordingCurrTime - m_currTime) > m_fRecordingTimeStep)
|
||||
{
|
||||
m_currTime += m_fRecordingTimeStep;
|
||||
@@ -644,7 +645,9 @@ void CAnimationContext::OnPostRender()
|
||||
{
|
||||
SAnimContext ac;
|
||||
ac.dt = 0;
|
||||
ac.fps = GetIEditor()->GetSystem()->GetITimer()->GetFrameRate();
|
||||
const AZ::TimeUs frameDeltaTimeUs = AZ::GetSimulationTickDeltaTimeUs();
|
||||
const float frameDeltaTime = AZ::TimeUsToSeconds(frameDeltaTimeUs);
|
||||
ac.fps = 1.0f / frameDeltaTime;
|
||||
ac.time = m_currTime;
|
||||
ac.singleFrame = true;
|
||||
ac.forcePlay = true;
|
||||
@@ -797,7 +800,9 @@ void CAnimationContext::AnimateActiveSequence()
|
||||
|
||||
SAnimContext ac;
|
||||
ac.dt = 0;
|
||||
ac.fps = GetIEditor()->GetSystem()->GetITimer()->GetFrameRate();
|
||||
const AZ::TimeUs frameDeltaTimeUs = AZ::GetSimulationTickDeltaTimeUs();
|
||||
const float frameDeltaTime = AZ::TimeUsToSeconds(frameDeltaTimeUs);
|
||||
ac.fps = 1.0f / frameDeltaTime;
|
||||
ac.time = m_currTime;
|
||||
ac.singleFrame = true;
|
||||
ac.forcePlay = true;
|
||||
|
||||
@@ -140,7 +140,7 @@ bool AssetImporterManager::OnBrowseFiles()
|
||||
bool encounteredCrate = false;
|
||||
QStringList invalidFiles;
|
||||
|
||||
for (QString path : fileDialog.selectedFiles())
|
||||
for (const QString& path : fileDialog.selectedFiles())
|
||||
{
|
||||
QString fileName = GetFileName(path);
|
||||
QFileInfo info(path);
|
||||
|
||||
@@ -199,41 +199,6 @@ namespace AzAssetBrowserRequestHandlerPrivate
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Helper utility - determines if the thing being dragged is a FBX from the scene import pipeline
|
||||
// This is important to differentiate.
|
||||
// when someone drags a MTL file directly into the viewport, even from a FBX, we want to spawn it as a decal
|
||||
// but when someone drags a FBX that contains MTL files, we want only to spawn the meshes.
|
||||
// so we have to specifically differentiate here between the mimeData type that contains the source as the root
|
||||
// (dragging the fbx file itself)
|
||||
// and one which contains the actual product at its root.
|
||||
|
||||
bool IsDragOfFBX(const QMimeData* mimeData)
|
||||
{
|
||||
AZStd::vector<AssetBrowserEntry*> entries;
|
||||
if (!AssetBrowserEntry::FromMimeData(mimeData, entries))
|
||||
{
|
||||
// if mimedata does not even contain entries, no point in proceeding.
|
||||
return false;
|
||||
}
|
||||
|
||||
for (auto entry : entries)
|
||||
{
|
||||
if (entry->GetEntryType() != AssetBrowserEntry::AssetEntryType::Source)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
// this is a source file. Is it the filetype we're looking for?
|
||||
if (SourceAssetBrowserEntry* source = azrtti_cast<SourceAssetBrowserEntry*>(entry))
|
||||
{
|
||||
if (AzFramework::StringFunc::Equal(source->GetExtension().c_str(), ".fbx", false))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
AzAssetBrowserRequestHandler::AzAssetBrowserRequestHandler()
|
||||
|
||||
@@ -14,66 +14,6 @@
|
||||
#include "Include/IBaseLibraryManager.h"
|
||||
#include <Util/PathUtil.h>
|
||||
#include <IFileUtil.h>
|
||||
#include "Undo/IUndoObject.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Undo functionality for libraries.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class CUndoBaseLibrary
|
||||
: public IUndoObject
|
||||
{
|
||||
public:
|
||||
CUndoBaseLibrary(CBaseLibrary* pLib, const QString& description, const QString& selectedItem = QString())
|
||||
: m_pLib(pLib)
|
||||
, m_description(description)
|
||||
, m_redo(nullptr)
|
||||
, m_selectedItem(selectedItem)
|
||||
{
|
||||
assert(m_pLib);
|
||||
|
||||
m_undo = GetIEditor()->GetSystem()->CreateXmlNode("Undo");
|
||||
m_pLib->Serialize(m_undo, false);
|
||||
}
|
||||
|
||||
QString GetEditorObjectName() override
|
||||
{
|
||||
return m_selectedItem;
|
||||
}
|
||||
|
||||
protected:
|
||||
int GetSize() override { return sizeof(CUndoBaseLibrary); }
|
||||
QString GetDescription() override { return m_description; };
|
||||
|
||||
void Undo(bool bUndo) override
|
||||
{
|
||||
if (bUndo)
|
||||
{
|
||||
m_redo = GetIEditor()->GetSystem()->CreateXmlNode("Redo");
|
||||
m_pLib->Serialize(m_redo, false);
|
||||
}
|
||||
m_pLib->Serialize(m_undo, true);
|
||||
m_pLib->SetModified();
|
||||
GetIEditor()->Notify(eNotify_OnDataBaseUpdate);
|
||||
}
|
||||
|
||||
void Redo() override
|
||||
{
|
||||
m_pLib->Serialize(m_redo, true);
|
||||
m_pLib->SetModified();
|
||||
GetIEditor()->Notify(eNotify_OnDataBaseUpdate);
|
||||
}
|
||||
|
||||
private:
|
||||
QString m_description;
|
||||
QString m_selectedItem;
|
||||
_smart_ptr<CBaseLibrary> m_pLib;
|
||||
XmlNodeRef m_undo;
|
||||
XmlNodeRef m_redo;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// CBaseLibrary implementation.
|
||||
|
||||
@@ -29,7 +29,6 @@ public:
|
||||
assert(libMgr);
|
||||
|
||||
m_itemPath = libItem->GetFullName();
|
||||
m_description = "Lib item changed: " + m_itemPath;
|
||||
|
||||
//serialize the lib item to undo
|
||||
m_undoCtx.node = GetIEditor()->GetSystem()->CreateXmlNode("Undo");
|
||||
@@ -45,13 +44,8 @@ public:
|
||||
m_size = sizeof(CUndoBaseLibraryItem);
|
||||
m_size += static_cast<int>(xmlStr.GetAllocatedMemory());
|
||||
m_size += m_itemPath.length();
|
||||
m_size += m_description.length();
|
||||
}
|
||||
|
||||
QString GetEditorObjectName() override
|
||||
{
|
||||
return m_itemPath;
|
||||
}
|
||||
|
||||
protected:
|
||||
int GetSize() override
|
||||
@@ -59,11 +53,6 @@ protected:
|
||||
return m_size;
|
||||
}
|
||||
|
||||
QString GetDescription() override
|
||||
{
|
||||
return m_description;
|
||||
}
|
||||
|
||||
void Undo(bool bUndo) override
|
||||
{
|
||||
//find the libItem
|
||||
@@ -111,7 +100,6 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
QString m_description;
|
||||
QString m_itemPath;
|
||||
IDataBaseItem::SerializeContext m_undoCtx; //saved before operation
|
||||
IDataBaseItem::SerializeContext m_redoCtx; //saved after operation so used for redo
|
||||
|
||||
@@ -17,120 +17,6 @@
|
||||
#include "ErrorReport.h"
|
||||
#include "Undo/IUndoObject.h"
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Undo functionality for Managers, including add library, remove library, and rename library -- Vera, Confetti
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class CUndoBaseLibraryManager
|
||||
: public IUndoObject
|
||||
{
|
||||
public:
|
||||
CUndoBaseLibraryManager(CBaseLibraryManager* pMngr, const QString& description, const QString& modifiedManager = nullptr)
|
||||
: m_pMngr(pMngr)
|
||||
, m_description(description)
|
||||
, m_editorObject(modifiedManager)
|
||||
{
|
||||
assert(m_pMngr);
|
||||
SerializeTo(m_undos);
|
||||
}
|
||||
|
||||
QString GetEditorObjectName() override
|
||||
{
|
||||
return m_editorObject;
|
||||
}
|
||||
|
||||
protected:
|
||||
int GetSize() override { return sizeof(CUndoBaseLibraryManager); }
|
||||
QString GetDescription() override { return m_description; };
|
||||
|
||||
void Undo(bool bUndo) override
|
||||
{
|
||||
if (bUndo)
|
||||
{
|
||||
SerializeTo(m_redos);
|
||||
}
|
||||
m_pMngr->ClearAll();
|
||||
UnserializeFrom(m_undos);
|
||||
GetIEditor()->Notify(eNotify_OnDataBaseUpdate);
|
||||
}
|
||||
|
||||
void Redo() override
|
||||
{
|
||||
m_pMngr->ClearAll();
|
||||
UnserializeFrom(m_redos);
|
||||
GetIEditor()->Notify(eNotify_OnDataBaseUpdate);
|
||||
}
|
||||
|
||||
private:
|
||||
struct LibUndoNode
|
||||
: public _i_reference_target_t
|
||||
{
|
||||
LibUndoNode()
|
||||
{
|
||||
node = nullptr;
|
||||
fileName = "";
|
||||
}
|
||||
XmlNodeRef node;
|
||||
QString fileName;
|
||||
};
|
||||
|
||||
static const char* const LIBRARY_TAG;
|
||||
static const char* const LEVEL_LIBRARY_TAG;
|
||||
|
||||
void SerializeTo(std::vector<_smart_ptr<LibUndoNode> >& undos) // Save Library Undo
|
||||
{
|
||||
undos.clear();
|
||||
for (int i = 0; i < m_pMngr->GetLibraryCount(); i++)
|
||||
{
|
||||
IDataBaseLibrary* library = m_pMngr->GetLibrary(i);
|
||||
|
||||
const char* tag = library->IsLevelLibrary() ? LEVEL_LIBRARY_TAG : LIBRARY_TAG;
|
||||
XmlNodeRef node = GetIEditor()->GetSystem()->CreateXmlNode(tag);
|
||||
QString file = library->GetFilename().isEmpty() ? library->GetFilename() : library->GetName();
|
||||
library->Serialize(node, false);
|
||||
if (node && !file.isEmpty())
|
||||
{
|
||||
_smart_ptr<LibUndoNode> undo = new LibUndoNode();
|
||||
undo->fileName = file;
|
||||
undo->node = node;
|
||||
undos.push_back(undo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UnserializeFrom(std::vector<_smart_ptr<LibUndoNode> >& undos) // Load Library Undo
|
||||
{
|
||||
for (int i = 0; i < undos.size(); i++)
|
||||
{
|
||||
_smart_ptr<LibUndoNode> undo = undos[i];
|
||||
if (undo->node && !undo->fileName.isEmpty())
|
||||
{
|
||||
//AddLibrary adds a .xml to the end of the library path, this will remove the extra for compatibility
|
||||
undo->fileName.replace(m_pMngr->GetLibsPath().toLower(), "");
|
||||
undo->fileName.replace(".xml", "");
|
||||
|
||||
const bool isLevelLibrary = (strcmp(undo->node->getTag(), LEVEL_LIBRARY_TAG) == 0);
|
||||
|
||||
IDataBaseLibrary* library = m_pMngr->AddLibrary(undo->fileName, isLevelLibrary);
|
||||
library->Serialize(undo->node, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QString m_description;
|
||||
QString m_editorObject;
|
||||
CBaseLibraryManager* m_pMngr;
|
||||
std::vector<_smart_ptr<LibUndoNode> > m_undos;
|
||||
std::vector<_smart_ptr<LibUndoNode> > m_redos;
|
||||
};
|
||||
|
||||
const char* const CUndoBaseLibraryManager::LIBRARY_TAG = "UndoLibrary";
|
||||
const char* const CUndoBaseLibraryManager::LEVEL_LIBRARY_TAG = "UndoLevelLibrary";
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// CBaseLibraryManager implementation.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -606,11 +492,9 @@ void CBaseLibraryManager::RegisterItem(CBaseLibraryItem* pItem, REFGUID newGuid)
|
||||
|
||||
if (m_bUniqGuidMap)
|
||||
{
|
||||
bool bNewItem = true;
|
||||
REFGUID oldGuid = pItem->GetGUID();
|
||||
if (!GuidUtil::IsEmpty(oldGuid))
|
||||
{
|
||||
bNewItem = false;
|
||||
m_itemsGuidMap.erase(oldGuid);
|
||||
}
|
||||
if (GuidUtil::IsEmpty(newGuid))
|
||||
|
||||
@@ -131,7 +131,7 @@ ly_add_source_properties(
|
||||
PROPERTY COMPILE_DEFINITIONS
|
||||
VALUES
|
||||
O3DE_COPYRIGHT_YEAR=${LY_VERSION_COPYRIGHT_YEAR}
|
||||
LY_BUILD=${LY_VERSION_BUILD_NUMBER}
|
||||
LY_VERSION_BUILD_NUMBER=${LY_VERSION_BUILD_NUMBER}
|
||||
${LY_PAL_TOOLS_DEFINES}
|
||||
)
|
||||
ly_add_source_properties(
|
||||
|
||||
@@ -671,7 +671,7 @@ AzToolsFramework::PropertyRowWidget* ReflectedPropertyControl::FindPropertyRowWi
|
||||
return nullptr;
|
||||
}
|
||||
const AzToolsFramework::ReflectedPropertyEditor::WidgetList& widgets = m_editor->GetWidgets();
|
||||
for (auto instance : widgets)
|
||||
for (const auto& instance : widgets)
|
||||
{
|
||||
if (instance.second->label() == item->GetPropertyName())
|
||||
{
|
||||
|
||||
@@ -82,7 +82,6 @@ protected:
|
||||
}
|
||||
|
||||
int GetSize() override { return sizeof(*this); }
|
||||
QString GetDescription() override { return "UndoSplineCtrlEx"; };
|
||||
|
||||
void Undo(bool bUndo) override
|
||||
{
|
||||
|
||||
+17
-26
@@ -33,6 +33,7 @@ AZ_POP_DISABLE_WARNING
|
||||
#include <QScopedValueRollback>
|
||||
#include <QClipboard>
|
||||
#include <QMenuBar>
|
||||
#include <QMessageBox>
|
||||
#include <QDialogButtonBox>
|
||||
|
||||
// Aws Native SDK
|
||||
@@ -80,7 +81,6 @@ AZ_POP_DISABLE_WARNING
|
||||
#include <AzQtComponents/Utilities/QtPluginPaths.h>
|
||||
|
||||
// CryCommon
|
||||
#include <CryCommon/ITimer.h>
|
||||
#include <CryCommon/ILevelSystem.h>
|
||||
|
||||
// Editor
|
||||
@@ -371,10 +371,8 @@ void CCryEditApp::RegisterActionHandlers()
|
||||
ON_COMMAND(ID_EDIT_FETCH, OnEditFetch)
|
||||
ON_COMMAND(ID_FILE_EXPORTTOGAMENOSURFACETEXTURE, OnFileExportToGameNoSurfaceTexture)
|
||||
ON_COMMAND(ID_VIEW_SWITCHTOGAME, OnViewSwitchToGame)
|
||||
MainWindow::instance()->GetActionManager()->RegisterActionHandler(ID_VIEW_SWITCHTOGAME_FULLSCREEN, [this]() {
|
||||
ed_previewGameInFullscreen_once = true;
|
||||
OnViewSwitchToGame();
|
||||
});
|
||||
ON_COMMAND(ID_VIEW_SWITCHTOGAME_VIEWPORT, OnViewSwitchToGame)
|
||||
ON_COMMAND(ID_VIEW_SWITCHTOGAME_FULLSCREEN, OnViewSwitchToGameFullScreen)
|
||||
ON_COMMAND(ID_MOVE_OBJECT, OnMoveObject)
|
||||
ON_COMMAND(ID_RENAME_OBJ, OnRenameObj)
|
||||
ON_COMMAND(ID_UNDO, OnUndo)
|
||||
@@ -914,13 +912,9 @@ namespace
|
||||
QWidget* g_splashScreen = nullptr;
|
||||
}
|
||||
|
||||
QString FormatVersion(const SFileVersion& v)
|
||||
QString FormatVersion([[maybe_unused]] const SFileVersion& v)
|
||||
{
|
||||
#if defined(LY_BUILD)
|
||||
return QObject::tr("Version %1.%2.%3.%4 - Build %5").arg(v[3]).arg(v[2]).arg(v[1]).arg(v[0]).arg(LY_BUILD);
|
||||
#else
|
||||
return QObject::tr("Version %1.%2.%3.%4").arg(v[3]).arg(v[2]).arg(v[1]).arg(v[0]);
|
||||
#endif
|
||||
return QObject::tr("Version %1").arg(LY_VERSION_BUILD_NUMBER);
|
||||
}
|
||||
|
||||
QString FormatRichTextCopyrightNotice()
|
||||
@@ -1361,16 +1355,6 @@ void CCryEditApp::CompileCriticalAssets() const
|
||||
assetsInQueueNotifcation.BusDisconnect();
|
||||
CCryEditApp::OutputStartupMessage(QString("Asset Processor is now ready."));
|
||||
|
||||
// VERY early on, as soon as we can, request that the asset system make sure the following assets take priority over others,
|
||||
// so that by the time we ask for them there is a greater likelihood that they're already good to go.
|
||||
// these can be loaded later but are still important:
|
||||
AzFramework::AssetSystemRequestBus::Broadcast(&AzFramework::AssetSystem::AssetSystemRequests::EscalateAssetBySearchTerm, "/texturemsg/");
|
||||
AzFramework::AssetSystemRequestBus::Broadcast(&AzFramework::AssetSystem::AssetSystemRequests::EscalateAssetBySearchTerm, "engineassets/materials");
|
||||
AzFramework::AssetSystemRequestBus::Broadcast(&AzFramework::AssetSystem::AssetSystemRequests::EscalateAssetBySearchTerm, "engineassets/geomcaches");
|
||||
AzFramework::AssetSystemRequestBus::Broadcast(&AzFramework::AssetSystem::AssetSystemRequests::EscalateAssetBySearchTerm, "engineassets/objects");
|
||||
|
||||
// some are specifically extra important and will cause issues if missing completely:
|
||||
AzFramework::AssetSystemRequestBus::Broadcast(&AzFramework::AssetSystem::AssetSystemRequests::CompileAssetSync, "engineassets/objects/default.cgf");
|
||||
}
|
||||
|
||||
bool CCryEditApp::ConnectToAssetProcessor() const
|
||||
@@ -2584,6 +2568,12 @@ void CCryEditApp::OnViewSwitchToGame()
|
||||
GetIEditor()->SetInGameMode(inGame);
|
||||
}
|
||||
|
||||
void CCryEditApp::OnViewSwitchToGameFullScreen()
|
||||
{
|
||||
ed_previewGameInFullscreen_once = true;
|
||||
OnViewSwitchToGame();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CCryEditApp::OnExportSelectedObjects()
|
||||
{
|
||||
@@ -3974,9 +3964,8 @@ void CCryEditApp::OpenLUAEditor(const char* files)
|
||||
}
|
||||
}
|
||||
|
||||
const char* engineRoot = nullptr;
|
||||
AzFramework::ApplicationRequests::Bus::BroadcastResult(engineRoot, &AzFramework::ApplicationRequests::GetEngineRoot);
|
||||
AZ_Assert(engineRoot != nullptr, "Unable to communicate to AzFramework::ApplicationRequests::Bus");
|
||||
AZ::IO::FixedMaxPathString engineRoot = AZ::Utils::GetEnginePath();
|
||||
AZ_Assert(!engineRoot.empty(), "Unable to query Engine Path");
|
||||
|
||||
AZStd::string_view exePath;
|
||||
AZ::ComponentApplicationBus::BroadcastResult(exePath, &AZ::ComponentApplicationRequests::GetExecutableFolder);
|
||||
@@ -3995,7 +3984,7 @@ void CCryEditApp::OpenLUAEditor(const char* files)
|
||||
#endif
|
||||
"%s", argumentQuoteString, aznumeric_cast<int>(exePath.size()), exePath.data(), argumentQuoteString);
|
||||
|
||||
AZStd::string processArgs = AZStd::string::format("%s -engine-path \"%s\"", args.c_str(), engineRoot);
|
||||
AZStd::string processArgs = AZStd::string::format("%s -engine-path \"%s\"", args.c_str(), engineRoot.c_str());
|
||||
StartProcessDetached(process.c_str(), processArgs.c_str());
|
||||
}
|
||||
|
||||
@@ -4028,7 +4017,7 @@ void CCryEditApp::OnError(AzFramework::AssetSystem::AssetSystemErrors error)
|
||||
break;
|
||||
}
|
||||
|
||||
CryMessageBox(errorMessage.c_str(), "Error", MB_OK | MB_ICONERROR | MB_SETFOREGROUND);
|
||||
QMessageBox::critical(nullptr,"Error",errorMessage.c_str());
|
||||
}
|
||||
|
||||
void CCryEditApp::OnOpenProceduralMaterialEditor()
|
||||
@@ -4196,6 +4185,8 @@ extern "C" int AZ_DLL_EXPORT CryEditMain(int argc, char* argv[])
|
||||
"\nThis could be because of incorrectly configured components, or missing required gems."
|
||||
"\nSee other errors for more details.");
|
||||
|
||||
AzToolsFramework::EditorEventsBus::Broadcast(&AzToolsFramework::EditorEvents::NotifyEditorInitialized);
|
||||
|
||||
if (didCryEditStart)
|
||||
{
|
||||
app->EnableOnIdle();
|
||||
|
||||
@@ -212,6 +212,7 @@ public:
|
||||
void OnEditFetch();
|
||||
void OnFileExportToGameNoSurfaceTexture();
|
||||
void OnViewSwitchToGame();
|
||||
void OnViewSwitchToGameFullScreen();
|
||||
void OnViewDeploy();
|
||||
void DeleteSelectedEntities(bool includeDescendants);
|
||||
void OnMoveObject();
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <AzCore/Component/TransformBus.h>
|
||||
#include <AzCore/Asset/AssetManager.h>
|
||||
#include <AzCore/Interface/Interface.h>
|
||||
#include <AzCore/Time/ITime.h>
|
||||
#include <AzCore/Utils/Utils.h>
|
||||
#include <MathConversion.h>
|
||||
|
||||
@@ -50,7 +51,6 @@
|
||||
#include "GameExporter.h"
|
||||
#include "MainWindow.h"
|
||||
#include "LevelFileDialog.h"
|
||||
#include "StatObjBus.h"
|
||||
#include "Undo/Undo.h"
|
||||
|
||||
#include <Atom/RPI.Public/ViewportContext.h>
|
||||
@@ -245,9 +245,6 @@ void CCryEditDoc::DeleteContents()
|
||||
|
||||
EBUS_EVENT(AzToolsFramework::EditorEntityContextRequestBus, ResetEditorContext);
|
||||
|
||||
// [LY-90904] move this to the EditorVegetationManager component
|
||||
InstanceStatObjEventBus::Broadcast(&InstanceStatObjEventBus::Events::ReleaseData);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Clear all undo info.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -307,8 +304,6 @@ void CCryEditDoc::Save(TDocMultiArchive& arrXmlAr)
|
||||
|
||||
// Fog settings ///////////////////////////////////////////////////////
|
||||
SerializeFogSettings((*arrXmlAr[DMAS_GENERAL]));
|
||||
|
||||
SerializeNameSelection((*arrXmlAr[DMAS_GENERAL]));
|
||||
}
|
||||
}
|
||||
AfterSave();
|
||||
@@ -454,12 +449,6 @@ void CCryEditDoc::Load(TDocMultiArchive& arrXmlAr, const QString& szFilename)
|
||||
}
|
||||
}
|
||||
|
||||
if (!isPrefabEnabled)
|
||||
{
|
||||
// Name Selection groups
|
||||
SerializeNameSelection((*arrXmlAr[DMAS_GENERAL]));
|
||||
}
|
||||
|
||||
{
|
||||
CAutoLogTime logtime("Post Load");
|
||||
|
||||
@@ -594,16 +583,6 @@ void CCryEditDoc::SerializeFogSettings(CXmlArchive& xmlAr)
|
||||
}
|
||||
}
|
||||
|
||||
void CCryEditDoc::SerializeNameSelection(CXmlArchive& xmlAr)
|
||||
{
|
||||
IObjectManager* pObjManager = GetIEditor()->GetObjectManager();
|
||||
|
||||
if (pObjManager)
|
||||
{
|
||||
pObjManager->SerializeNameSelection(xmlAr.root, xmlAr.bLoading);
|
||||
}
|
||||
}
|
||||
|
||||
void CCryEditDoc::SetModifiedModules(EModifiedModule eModifiedModule, bool boSet)
|
||||
{
|
||||
if (!boSet)
|
||||
@@ -749,7 +728,9 @@ bool CCryEditDoc::OnOpenDocument(const QString& lpszPathName)
|
||||
|
||||
bool CCryEditDoc::BeforeOpenDocument(const QString& lpszPathName, TOpenDocContext& context)
|
||||
{
|
||||
CTimeValue loading_start_time = gEnv->pTimer->GetAsyncTime();
|
||||
const AZ::TimeMs timeMs = AZ::GetRealElapsedTimeMs();
|
||||
const double timeSec = AZ::TimeMsToSecondsDouble(timeMs);
|
||||
const CTimeValue loading_start_time(timeSec);
|
||||
|
||||
bool usePrefabSystemForLevels = false;
|
||||
AzFramework::ApplicationRequests::Bus::BroadcastResult(
|
||||
@@ -790,7 +771,7 @@ bool CCryEditDoc::BeforeOpenDocument(const QString& lpszPathName, TOpenDocContex
|
||||
|
||||
bool CCryEditDoc::DoOpenDocument(TOpenDocContext& context)
|
||||
{
|
||||
CTimeValue& loading_start_time = context.loading_start_time;
|
||||
const CTimeValue& loading_start_time = context.loading_start_time;
|
||||
|
||||
bool isPrefabEnabled = false;
|
||||
AzFramework::ApplicationRequests::Bus::BroadcastResult(isPrefabEnabled, &AzFramework::ApplicationRequests::IsPrefabSystemEnabled);
|
||||
@@ -860,7 +841,9 @@ bool CCryEditDoc::DoOpenDocument(TOpenDocContext& context)
|
||||
|
||||
StartStreamingLoad();
|
||||
|
||||
CTimeValue loading_end_time = gEnv->pTimer->GetAsyncTime();
|
||||
const AZ::TimeMs timeMs = AZ::GetRealElapsedTimeMs();
|
||||
const double timeSec = AZ::TimeMsToSecondsDouble(timeMs);
|
||||
const CTimeValue loading_end_time(timeSec);
|
||||
|
||||
CLogFile::FormatLine("-----------------------------------------------------------");
|
||||
CLogFile::FormatLine("Successfully opened document %s", context.absoluteLevelPath.toUtf8().data());
|
||||
@@ -1123,7 +1106,7 @@ bool CCryEditDoc::SaveLevel(const QString& filename)
|
||||
const QString oldLevelPattern = QDir(oldLevelFolder).absoluteFilePath("*.*");
|
||||
const QString oldLevelName = Path::GetFile(GetLevelPathName());
|
||||
const QString oldLevelXml = Path::ReplaceExtension(oldLevelName, "xml");
|
||||
AZ::IO::ArchiveFileIterator findHandle = pIPak->FindFirst(oldLevelPattern.toUtf8().data(), AZ::IO::IArchive::eFileSearchType_AllowOnDiskAndInZips);
|
||||
AZ::IO::ArchiveFileIterator findHandle = pIPak->FindFirst(oldLevelPattern.toUtf8().data(), AZ::IO::FileSearchLocation::Any);
|
||||
if (findHandle)
|
||||
{
|
||||
do
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
#include <IEditor.h>
|
||||
#endif
|
||||
|
||||
class CClouds;
|
||||
struct LightingSettings;
|
||||
struct IVariable;
|
||||
struct ICVar;
|
||||
@@ -124,7 +123,6 @@ public: // Create from serialization only
|
||||
const char* GetTemporaryLevelName() const;
|
||||
void DeleteTemporaryLevel();
|
||||
|
||||
CClouds* GetClouds() { return m_pClouds; }
|
||||
void SetWaterColor(const QColor& col) { m_waterColor = col; }
|
||||
QColor GetWaterColor() const { return m_waterColor; }
|
||||
XmlNodeRef& GetFogTemplate() { return m_fogTemplate; }
|
||||
@@ -163,7 +161,6 @@ protected:
|
||||
bool LoadEntitiesFromSlice(const QString& sliceFile);
|
||||
void SerializeFogSettings(CXmlArchive& xmlAr);
|
||||
virtual void SerializeViewSettings(CXmlArchive& xmlAr);
|
||||
void SerializeNameSelection(CXmlArchive& xmlAr);
|
||||
void LogLoadTime(int time) const;
|
||||
|
||||
struct TSaveDocContext
|
||||
@@ -195,7 +192,6 @@ protected:
|
||||
QColor m_waterColor = QColor(0, 0, 255);
|
||||
XmlNodeRef m_fogTemplate;
|
||||
XmlNodeRef m_environmentTemplate;
|
||||
CClouds* m_pClouds;
|
||||
std::list<IDocListener*> m_listeners;
|
||||
bool m_bDocumentReady = false;
|
||||
ICVar* doc_validate_surface_types = nullptr;
|
||||
|
||||
@@ -40,10 +40,10 @@ AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
namespace
|
||||
{
|
||||
// File name extension for python files
|
||||
const QString s_kPythonFileNameSpec = "*.py";
|
||||
const QString s_kPythonFileNameSpec("*.py");
|
||||
|
||||
// Tree root element name
|
||||
const QString s_kRootElementName = "Python Scripts";
|
||||
const QString s_kRootElementName("Python Scripts");
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -105,7 +105,6 @@
|
||||
#include <CryFile.h>
|
||||
#include <ISystem.h>
|
||||
#include <IIndexedMesh.h>
|
||||
#include <ITimer.h>
|
||||
#include <IXml.h>
|
||||
#include <IMovieSystem.h>
|
||||
|
||||
|
||||
@@ -145,6 +145,15 @@ namespace SandboxEditor
|
||||
}
|
||||
};
|
||||
|
||||
const auto trackingTransform = [viewportId = m_viewportId]
|
||||
{
|
||||
bool tracking = false;
|
||||
AtomToolsFramework::ModularViewportCameraControllerRequestBus::EventResult(
|
||||
tracking, viewportId, &AtomToolsFramework::ModularViewportCameraControllerRequestBus::Events::IsTrackingTransform);
|
||||
|
||||
return tracking;
|
||||
};
|
||||
|
||||
m_firstPersonRotateCamera = AZStd::make_shared<AzFramework::RotateCameraInput>(SandboxEditor::CameraFreeLookChannelId());
|
||||
|
||||
m_firstPersonRotateCamera->m_rotateSpeedFn = []
|
||||
@@ -152,6 +161,11 @@ namespace SandboxEditor
|
||||
return SandboxEditor::CameraRotateSpeed();
|
||||
};
|
||||
|
||||
m_firstPersonRotateCamera->m_constrainPitch = [trackingTransform]
|
||||
{
|
||||
return !trackingTransform();
|
||||
};
|
||||
|
||||
// default behavior is to hide the cursor but this can be disabled (useful for remote desktop)
|
||||
// note: See CaptureCursorLook in the Settings Registry
|
||||
m_firstPersonRotateCamera->SetActivationBeganFn(hideCursor);
|
||||
@@ -255,6 +269,11 @@ namespace SandboxEditor
|
||||
return SandboxEditor::CameraOrbitYawRotationInverted();
|
||||
};
|
||||
|
||||
m_orbitRotateCamera->m_constrainPitch = [trackingTransform]
|
||||
{
|
||||
return !trackingTransform();
|
||||
};
|
||||
|
||||
m_orbitTranslateCamera = AZStd::make_shared<AzFramework::TranslateCameraInput>(
|
||||
translateCameraInputChannelIds, AzFramework::LookTranslation, AzFramework::TranslateOffsetOrbit);
|
||||
|
||||
@@ -337,12 +356,12 @@ namespace SandboxEditor
|
||||
AZ::TransformBus::EventResult(worldFromLocal, viewEntityId, &AZ::TransformBus::Events::GetWorldTM);
|
||||
|
||||
AtomToolsFramework::ModularViewportCameraControllerRequestBus::Event(
|
||||
m_viewportId, &AtomToolsFramework::ModularViewportCameraControllerRequestBus::Events::SetReferenceFrame, worldFromLocal);
|
||||
m_viewportId, &AtomToolsFramework::ModularViewportCameraControllerRequestBus::Events::StartTrackingTransform, worldFromLocal);
|
||||
}
|
||||
else
|
||||
{
|
||||
AtomToolsFramework::ModularViewportCameraControllerRequestBus::Event(
|
||||
m_viewportId, &AtomToolsFramework::ModularViewportCameraControllerRequestBus::Events::ClearReferenceFrame);
|
||||
m_viewportId, &AtomToolsFramework::ModularViewportCameraControllerRequestBus::Events::StopTrackingTransform);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,6 @@
|
||||
#include <AtomToolsFramework/Viewport/RenderViewportWidget.h>
|
||||
|
||||
// CryCommon
|
||||
#include <CryCommon/HMDBus.h>
|
||||
#include <CryCommon/IRenderAuxGeom.h>
|
||||
|
||||
// AzFramework
|
||||
@@ -98,9 +97,6 @@
|
||||
|
||||
#include <QtGui/private/qhighdpiscaling_p.h>
|
||||
|
||||
#include <IEntityRenderState.h>
|
||||
#include <IStatObj.h>
|
||||
|
||||
AZ_CVAR(
|
||||
bool, ed_visibility_logTiming, false, nullptr, AZ::ConsoleFunctorFlags::Null, "Output the timing of the new IVisibilitySystem query");
|
||||
|
||||
@@ -299,13 +295,9 @@ AzToolsFramework::ViewportInteraction::MousePick EditorViewportWidget::BuildMous
|
||||
{
|
||||
AzToolsFramework::ViewportInteraction::MousePick mousePick;
|
||||
mousePick.m_screenCoordinates = AzToolsFramework::ViewportInteraction::ScreenPointFromQPoint(point);
|
||||
if (const auto& ray = m_renderViewport->ViewportScreenToWorldRay(mousePick.m_screenCoordinates);
|
||||
ray.has_value())
|
||||
{
|
||||
mousePick.m_rayOrigin = ray.value().origin;
|
||||
mousePick.m_rayDirection = ray.value().direction;
|
||||
}
|
||||
|
||||
const auto[origin, direction] = m_renderViewport->ViewportScreenToWorldRay(mousePick.m_screenCoordinates);
|
||||
mousePick.m_rayOrigin = origin;
|
||||
mousePick.m_rayDirection = direction;
|
||||
return mousePick;
|
||||
}
|
||||
|
||||
@@ -480,7 +472,7 @@ void EditorViewportWidget::Update()
|
||||
{
|
||||
auto start = std::chrono::steady_clock::now();
|
||||
|
||||
m_entityVisibilityQuery.UpdateVisibility(GetCameraState());
|
||||
m_entityVisibilityQuery.UpdateVisibility(m_renderViewport->GetCameraState());
|
||||
|
||||
if (ed_visibility_logTiming)
|
||||
{
|
||||
@@ -556,22 +548,6 @@ void EditorViewportWidget::OnEditorNotifyEvent(EEditorNotifyEvent event)
|
||||
// this should only occur for the main viewport and no others.
|
||||
ShowCursor();
|
||||
|
||||
// If the user has selected game mode, enable outputting to any attached HMD and properly size the context
|
||||
// to the resolution specified by the VR device.
|
||||
if (gSettings.bEnableGameModeVR)
|
||||
{
|
||||
const AZ::VR::HMDDeviceInfo* deviceInfo = nullptr;
|
||||
EBUS_EVENT_RESULT(deviceInfo, AZ::VR::HMDDeviceRequestBus, GetDeviceInfo);
|
||||
AZ_Warning("Render Viewport", deviceInfo, "No VR device detected");
|
||||
|
||||
if (deviceInfo)
|
||||
{
|
||||
// Note: This may also need to adjust the viewport size
|
||||
SetActiveWindow();
|
||||
SetFocus();
|
||||
SetSelected(true);
|
||||
}
|
||||
}
|
||||
SetCurrentCursor(STD_CURSOR_GAME);
|
||||
|
||||
if (ShouldPreviewFullscreen())
|
||||
@@ -738,7 +714,7 @@ void EditorViewportWidget::RenderAll()
|
||||
|
||||
m_debugDisplay->DepthTestOff();
|
||||
m_manipulatorManager->DrawManipulators(
|
||||
*m_debugDisplay, GetCameraState(),
|
||||
*m_debugDisplay, m_renderViewport->GetCameraState(),
|
||||
BuildMouseInteractionInternal(
|
||||
AztfVi::MouseButtons(AztfVi::TranslateMouseButtons(QGuiApplication::mouseButtons())), keyboardModifiers,
|
||||
BuildMousePick(WidgetToViewport(mapFromGlobal(QCursor::pos())))));
|
||||
@@ -902,48 +878,11 @@ void EditorViewportWidget::OnMenuSelectCurrentCamera()
|
||||
}
|
||||
}
|
||||
|
||||
AzFramework::CameraState EditorViewportWidget::GetCameraState()
|
||||
{
|
||||
return m_renderViewport->GetCameraState();
|
||||
}
|
||||
|
||||
AZ::Vector3 EditorViewportWidget::PickTerrain(const AzFramework::ScreenPoint& point)
|
||||
{
|
||||
return LYVec3ToAZVec3(ViewToWorld(AzToolsFramework::ViewportInteraction::QPointFromScreenPoint(point), nullptr, true));
|
||||
}
|
||||
|
||||
AZ::EntityId EditorViewportWidget::PickEntity(const AzFramework::ScreenPoint& point)
|
||||
{
|
||||
AZ::EntityId entityId;
|
||||
HitContext hitInfo;
|
||||
hitInfo.view = this;
|
||||
if (HitTest(AzToolsFramework::ViewportInteraction::QPointFromScreenPoint(point), hitInfo))
|
||||
{
|
||||
if (hitInfo.object && (hitInfo.object->GetType() == OBJTYPE_AZENTITY))
|
||||
{
|
||||
auto entityObject = static_cast<CComponentEntityObject*>(hitInfo.object);
|
||||
entityId = entityObject->GetAssociatedEntityId();
|
||||
}
|
||||
}
|
||||
|
||||
return entityId;
|
||||
}
|
||||
|
||||
float EditorViewportWidget::TerrainHeight(const AZ::Vector2& position)
|
||||
{
|
||||
return GetIEditor()->GetTerrainElevation(position.GetX(), position.GetY());
|
||||
}
|
||||
|
||||
void EditorViewportWidget::FindVisibleEntities(AZStd::vector<AZ::EntityId>& visibleEntitiesOut)
|
||||
{
|
||||
visibleEntitiesOut.assign(m_entityVisibilityQuery.Begin(), m_entityVisibilityQuery.End());
|
||||
}
|
||||
|
||||
AzFramework::ScreenPoint EditorViewportWidget::ViewportWorldToScreen(const AZ::Vector3& worldPosition)
|
||||
{
|
||||
return m_renderViewport->ViewportWorldToScreen(worldPosition);
|
||||
}
|
||||
|
||||
QWidget* EditorViewportWidget::GetWidgetForViewportContextMenu()
|
||||
{
|
||||
return this;
|
||||
@@ -1653,16 +1592,15 @@ void EditorViewportWidget::RenderSelectedRegion()
|
||||
Vec3 EditorViewportWidget::WorldToView3D(const Vec3& wp, [[maybe_unused]] int nFlags) const
|
||||
{
|
||||
Vec3 out(0, 0, 0);
|
||||
float x, y, z;
|
||||
float x, y;
|
||||
|
||||
ProjectToScreen(wp.x, wp.y, wp.z, &x, &y, &z);
|
||||
if (_finite(x) && _finite(y) && _finite(z))
|
||||
ProjectToScreen(wp.x, wp.y, wp.z, &x, &y);
|
||||
if (_finite(x) && _finite(y))
|
||||
{
|
||||
out.x = (x / 100) * m_rcClient.width();
|
||||
out.y = (y / 100) * m_rcClient.height();
|
||||
out.x /= static_cast<float>(QHighDpiScaling::factor(windowHandle()->screen()));
|
||||
out.y /= static_cast<float>(QHighDpiScaling::factor(windowHandle()->screen()));
|
||||
out.z = z;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
@@ -1672,24 +1610,6 @@ QPoint EditorViewportWidget::WorldToView(const Vec3& wp) const
|
||||
{
|
||||
return AzToolsFramework::ViewportInteraction::QPointFromScreenPoint(m_renderViewport->ViewportWorldToScreen(LYVec3ToAZVec3(wp)));
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
QPoint EditorViewportWidget::WorldToViewParticleEditor(const Vec3& wp, int width, int height) const
|
||||
{
|
||||
QPoint p;
|
||||
float x, y, z;
|
||||
|
||||
ProjectToScreen(wp.x, wp.y, wp.z, &x, &y, &z);
|
||||
if (_finite(x) || _finite(y))
|
||||
{
|
||||
p.rx() = static_cast<int>((x / 100) * width);
|
||||
p.ry() = static_cast<int>((y / 100) * height);
|
||||
}
|
||||
else
|
||||
{
|
||||
QPoint(0, 0);
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
Vec3 EditorViewportWidget::ViewToWorld(
|
||||
@@ -1705,20 +1625,16 @@ Vec3 EditorViewportWidget::ViewToWorld(
|
||||
AZ_UNUSED(collideWithObject);
|
||||
|
||||
auto ray = m_renderViewport->ViewportScreenToWorldRay(AzToolsFramework::ViewportInteraction::ScreenPointFromQPoint(vp));
|
||||
if (!ray.has_value())
|
||||
{
|
||||
return Vec3(0, 0, 0);
|
||||
}
|
||||
|
||||
const float maxDistance = 10000.f;
|
||||
Vec3 v = AZVec3ToLYVec3(ray.value().direction) * maxDistance;
|
||||
Vec3 v = AZVec3ToLYVec3(ray.direction) * maxDistance;
|
||||
|
||||
if (!_finite(v.x) || !_finite(v.y) || !_finite(v.z))
|
||||
{
|
||||
return Vec3(0, 0, 0);
|
||||
}
|
||||
|
||||
Vec3 colp = AZVec3ToLYVec3(ray.value().origin) + 0.002f * v;
|
||||
Vec3 colp = AZVec3ToLYVec3(ray.origin) + 0.002f * v;
|
||||
|
||||
return colp;
|
||||
}
|
||||
@@ -1757,21 +1673,19 @@ bool EditorViewportWidget::RayRenderMeshIntersection(IRenderMesh* pRenderMesh, c
|
||||
return bRes;*/
|
||||
}
|
||||
|
||||
void EditorViewportWidget::UnProjectFromScreen(float sx, float sy, float sz, float* px, float* py, float* pz) const
|
||||
void EditorViewportWidget::UnProjectFromScreen(float sx, float sy, float* px, float* py, float* pz) const
|
||||
{
|
||||
AZ::Vector3 wp;
|
||||
wp = m_renderViewport->ViewportScreenToWorld(AzFramework::ScreenPoint{(int)sx, m_rcClient.bottom() - ((int)sy)}, sz).value_or(wp);
|
||||
const AZ::Vector3 wp = m_renderViewport->ViewportScreenToWorld(AzFramework::ScreenPoint{(int)sx, m_rcClient.bottom() - ((int)sy)});
|
||||
*px = wp.GetX();
|
||||
*py = wp.GetY();
|
||||
*pz = wp.GetZ();
|
||||
}
|
||||
|
||||
void EditorViewportWidget::ProjectToScreen(float ptx, float pty, float ptz, float* sx, float* sy, float* sz) const
|
||||
void EditorViewportWidget::ProjectToScreen(float ptx, float pty, float ptz, float* sx, float* sy) const
|
||||
{
|
||||
AzFramework::ScreenPoint screenPosition = m_renderViewport->ViewportWorldToScreen(AZ::Vector3{ptx, pty, ptz});
|
||||
*sx = static_cast<float>(screenPosition.m_x);
|
||||
*sy = static_cast<float>(screenPosition.m_y);
|
||||
*sz = 0.f;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -1781,32 +1695,22 @@ void EditorViewportWidget::ViewToWorldRay(const QPoint& vp, Vec3& raySrc, Vec3&
|
||||
|
||||
Vec3 pos0, pos1;
|
||||
float wx, wy, wz;
|
||||
UnProjectFromScreen(static_cast<float>(vp.x()), static_cast<float>(rc.bottom() - vp.y()), 0.0f, &wx, &wy, &wz);
|
||||
if (!_finite(wx) || !_finite(wy) || !_finite(wz))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (fabs(wx) > 1000000 || fabs(wy) > 1000000 || fabs(wz) > 1000000)
|
||||
{
|
||||
return;
|
||||
}
|
||||
pos0(wx, wy, wz);
|
||||
UnProjectFromScreen(static_cast<float>(vp.x()), static_cast<float>(rc.bottom() - vp.y()), 1.0f, &wx, &wy, &wz);
|
||||
if (!_finite(wx) || !_finite(wy) || !_finite(wz))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (fabs(wx) > 1000000 || fabs(wy) > 1000000 || fabs(wz) > 1000000)
|
||||
{
|
||||
return;
|
||||
}
|
||||
pos1(wx, wy, wz);
|
||||
UnProjectFromScreen(static_cast<float>(vp.x()), static_cast<float>(rc.bottom() - vp.y()), &wx, &wy, &wz);
|
||||
|
||||
Vec3 v = (pos1 - pos0);
|
||||
v = v.GetNormalized();
|
||||
if (!_finite(wx) || !_finite(wy) || !_finite(wz))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (fabs(wx) > 1000000 || fabs(wy) > 1000000 || fabs(wz) > 1000000)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
pos0(wx, wy, wz);
|
||||
|
||||
raySrc = pos0;
|
||||
rayDir = v;
|
||||
rayDir = (pos0 - AZVec3ToLYVec3(m_renderViewport->GetCameraState().m_position)).GetNormalized();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -1815,13 +1719,6 @@ float EditorViewportWidget::GetScreenScaleFactor([[maybe_unused]] const Vec3& wo
|
||||
AZ_Error("CryLegacy", false, "EditorViewportWidget::GetScreenScaleFactor not implemented");
|
||||
return 1.f;
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
float EditorViewportWidget::GetScreenScaleFactor(const CCamera& camera, const Vec3& object_position)
|
||||
{
|
||||
Vec3 camPos = camera.GetPosition();
|
||||
float dist = camPos.GetDistance(object_position);
|
||||
return dist;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool EditorViewportWidget::CheckRespondToInput() const
|
||||
@@ -1842,7 +1739,6 @@ bool EditorViewportWidget::CheckRespondToInput() const
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool EditorViewportWidget::HitTest(const QPoint& point, HitContext& hitInfo)
|
||||
{
|
||||
hitInfo.camera = nullptr;
|
||||
hitInfo.pExcludedObject = GetCameraObject();
|
||||
return QtViewport::HitTest(point, hitInfo);
|
||||
}
|
||||
@@ -2216,7 +2112,7 @@ bool EditorViewportWidget::GetActiveCameraState(AzFramework::CameraState& camera
|
||||
{
|
||||
if (m_pPrimaryViewport == this)
|
||||
{
|
||||
cameraState = GetCameraState();
|
||||
cameraState = m_renderViewport->GetCameraState();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2363,10 +2259,10 @@ void* EditorViewportWidget::GetSystemCursorConstraintWindow() const
|
||||
return systemCursorConstrained ? renderOverlayHWND() : nullptr;
|
||||
}
|
||||
|
||||
void EditorViewportWidget::BuildDragDropContext(AzQtComponents::ViewportDragContext& context, const QPoint& pt)
|
||||
void EditorViewportWidget::BuildDragDropContext(
|
||||
AzQtComponents::ViewportDragContext& context, const AzFramework::ViewportId viewportId, const QPoint& point)
|
||||
{
|
||||
const auto scaledPoint = WidgetToViewport(pt);
|
||||
QtViewport::BuildDragDropContext(context, scaledPoint);
|
||||
QtViewport::BuildDragDropContext(context, viewportId, point);
|
||||
}
|
||||
|
||||
void EditorViewportWidget::RestoreViewportAfterGameMode()
|
||||
@@ -2547,12 +2443,6 @@ bool EditorViewportWidget::ShouldPreviewFullscreen() const
|
||||
return false;
|
||||
}
|
||||
|
||||
// Not supported in VR
|
||||
if (gSettings.bEnableGameModeVR)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// If level not loaded, don't preview in fullscreen (preview shouldn't work at all without a level, but it does)
|
||||
if (auto ge = GetIEditor()->GetGameEngine())
|
||||
{
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#pragma once
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include <Cry_Camera.h>
|
||||
|
||||
#include <QSet>
|
||||
|
||||
@@ -166,13 +165,11 @@ private:
|
||||
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, const QPoint& point) override;
|
||||
void SetViewportId(int id) override;
|
||||
QPoint WorldToView(const Vec3& wp) const override;
|
||||
QPoint WorldToViewParticleEditor(const Vec3& wp, int width, int height) const override;
|
||||
Vec3 WorldToView3D(const Vec3& wp, int nFlags = 0) const override;
|
||||
Vec3 ViewToWorld(const QPoint& vp, bool* collideWithTerrain = nullptr, bool onlyTerrain = false, bool bSkipVegetation = false, bool bTestRenderMesh = false, bool* collideWithObject = nullptr) const override;
|
||||
void ViewToWorldRay(const QPoint& vp, Vec3& raySrc, Vec3& rayDir) const override;
|
||||
Vec3 ViewToWorldNormal(const QPoint& vp, bool onlyTerrain, bool bTestRenderMesh = false) override;
|
||||
float GetScreenScaleFactor(const Vec3& worldPoint) const override;
|
||||
float GetScreenScaleFactor(const CCamera& camera, const Vec3& object_position) override;
|
||||
float GetAspectRatio() const override;
|
||||
bool HitTest(const QPoint& point, HitContext& hitInfo) override;
|
||||
bool IsBoundsVisible(const AABB& box) const override;
|
||||
@@ -208,9 +205,6 @@ private:
|
||||
void* GetSystemCursorConstraintWindow() const override;
|
||||
|
||||
// AzToolsFramework::MainEditorViewportInteractionRequestBus overrides ...
|
||||
AZ::EntityId PickEntity(const AzFramework::ScreenPoint& point) override;
|
||||
AZ::Vector3 PickTerrain(const AzFramework::ScreenPoint& point) override;
|
||||
float TerrainHeight(const AZ::Vector2& position) override;
|
||||
bool ShowingWorldSpace() override;
|
||||
QWidget* GetWidgetForViewportContextMenu() override;
|
||||
|
||||
@@ -275,7 +269,8 @@ private:
|
||||
|
||||
bool CheckRespondToInput() const;
|
||||
|
||||
void BuildDragDropContext(AzQtComponents::ViewportDragContext& context, const QPoint& pt) override;
|
||||
void BuildDragDropContext(
|
||||
AzQtComponents::ViewportDragContext& context, AzFramework::ViewportId viewportId, const QPoint& point) override;
|
||||
|
||||
void SetAsActiveViewport();
|
||||
void PushDisableRendering();
|
||||
@@ -296,9 +291,6 @@ private:
|
||||
// This switches the active camera to the next one in the list of (default, all custom cams).
|
||||
void CycleCamera();
|
||||
|
||||
AzFramework::CameraState GetCameraState();
|
||||
AzFramework::ScreenPoint ViewportWorldToScreen(const AZ::Vector3& worldPosition);
|
||||
|
||||
QPoint WidgetToViewport(const QPoint& point) const;
|
||||
QPoint ViewportToWidget(const QPoint& point) const;
|
||||
QSize WidgetToViewport(const QSize& size) const;
|
||||
@@ -306,8 +298,8 @@ private:
|
||||
const DisplayContext& GetDisplayContext() const { return m_displayContext; }
|
||||
CBaseObject* GetCameraObject() const;
|
||||
|
||||
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;
|
||||
void UnProjectFromScreen(float sx, float sy, float* px, float* py, float* pz) const;
|
||||
void ProjectToScreen(float ptx, float pty, float ptz, float* sx, float* sy) const;
|
||||
|
||||
AZ::RPI::ViewPtr GetCurrentAtomView() const;
|
||||
|
||||
|
||||
@@ -35,20 +35,8 @@
|
||||
#include "Resource.h"
|
||||
#include "Plugins/ComponentEntityEditorPlugin/Objects/ComponentEntityObject.h"
|
||||
|
||||
#include <IEntityRenderState.h>
|
||||
#include <IStatObj.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
inline Export::Vector3D Vec3ToVector3D(const Vec3& vec)
|
||||
{
|
||||
Export::Vector3D ret;
|
||||
ret.x = vec.x;
|
||||
ret.y = vec.y;
|
||||
ret.z = vec.z;
|
||||
return ret;
|
||||
}
|
||||
|
||||
const float kTangentDelta = 0.01f;
|
||||
const float kAspectRatio = 1.777778f;
|
||||
const int kReserveCount = 7; // x,y,z,rot_x,rot_y,rot_z,fov
|
||||
@@ -106,22 +94,22 @@ void Export::CData::Clear()
|
||||
// CExportManager
|
||||
CExportManager::CExportManager()
|
||||
: m_isPrecaching(false)
|
||||
, m_pBaseObj(nullptr)
|
||||
, m_FBXBakedExportFPS(0.0f)
|
||||
, m_fScale(100.0f)
|
||||
, m_bAnimationExport(false)
|
||||
, m_pBaseObj(nullptr)
|
||||
, // this scale is used by CryEngine RC
|
||||
m_bAnimationExport(false)
|
||||
m_FBXBakedExportFPS(0.0f)
|
||||
, m_bExportLocalCoords(false)
|
||||
, m_bExportOnlyPrimaryCamera(false)
|
||||
, m_numberOfExportFrames(0)
|
||||
, m_pivotEntityObject(nullptr)
|
||||
, m_bBakedKeysSequenceExport(true)
|
||||
, m_animTimeExportPrimarySequenceCurrentTime(0.0f)
|
||||
, m_animKeyTimeExport(true)
|
||||
, m_soundKeyTimeExport(true)
|
||||
, m_bExportOnlyPrimaryCamera(false)
|
||||
{
|
||||
RegisterExporter(new COBJExporter());
|
||||
RegisterExporter(new COCMExporter());
|
||||
CExportManager::RegisterExporter(new COBJExporter());
|
||||
CExportManager::RegisterExporter(new COCMExporter());
|
||||
}
|
||||
|
||||
|
||||
@@ -313,203 +301,6 @@ void CExportManager::AddEntityAnimationData(AZ::EntityId entityId)
|
||||
ProcessEntityAnimationTrack(entityId, pObj, AnimParamType::Rotation);
|
||||
}
|
||||
|
||||
|
||||
void CExportManager::AddMesh(Export::CObject* pObj, const IIndexedMesh* pIndMesh, Matrix34A* pTm)
|
||||
{
|
||||
if (m_isPrecaching || !pObj)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
pObj->m_MeshHash = reinterpret_cast<size_t>(pIndMesh);
|
||||
IIndexedMesh::SMeshDescription meshDesc;
|
||||
pIndMesh->GetMeshDescription(meshDesc);
|
||||
|
||||
// if we have subset of meshes we need to duplicate vertices,
|
||||
// keep transformation of submesh,
|
||||
// and store new offset for indices
|
||||
int newOffsetIndex = pObj->GetVertexCount();
|
||||
|
||||
if (meshDesc.m_nVertCount)
|
||||
{
|
||||
pObj->m_vertices.reserve(meshDesc.m_nVertCount + newOffsetIndex);
|
||||
pObj->m_normals.reserve(meshDesc.m_nVertCount + newOffsetIndex);
|
||||
}
|
||||
|
||||
for (int v = 0; v < meshDesc.m_nVertCount; ++v)
|
||||
{
|
||||
Vec3 n = meshDesc.m_pNorms[v].GetN();
|
||||
Vec3 tmp = (meshDesc.m_pVerts ? meshDesc.m_pVerts[v] : meshDesc.m_pVertsF16[v].ToVec3());
|
||||
if (pTm)
|
||||
{
|
||||
tmp = pTm->TransformPoint(tmp);
|
||||
}
|
||||
|
||||
pObj->m_vertices.push_back(Vec3ToVector3D(tmp * m_fScale));
|
||||
pObj->m_normals.push_back(Vec3ToVector3D(n));
|
||||
}
|
||||
|
||||
if (meshDesc.m_nCoorCount)
|
||||
{
|
||||
pObj->m_texCoords.reserve(meshDesc.m_nCoorCount + newOffsetIndex);
|
||||
}
|
||||
|
||||
for (int v = 0; v < meshDesc.m_nCoorCount; ++v)
|
||||
{
|
||||
Vec2 uv = meshDesc.m_pTexCoord[v].GetUV();
|
||||
uv.y = 1.0f - uv.y;
|
||||
pObj->m_texCoords.push_back({uv.x,uv.y});
|
||||
}
|
||||
|
||||
if (pIndMesh->GetSubSetCount() && !(pIndMesh->GetSubSetCount() == 1 && pIndMesh->GetSubSet(0).nNumIndices == 0))
|
||||
{
|
||||
for (int i = 0; i < pIndMesh->GetSubSetCount(); ++i)
|
||||
{
|
||||
Export::CMesh* pMesh = new Export::CMesh();
|
||||
|
||||
const SMeshSubset& sms = pIndMesh->GetSubSet(i);
|
||||
const vtx_idx* pIndices = &meshDesc.m_pIndices[sms.nFirstIndexId];
|
||||
int nTris = sms.nNumIndices / 3;
|
||||
pMesh->m_faces.reserve(nTris);
|
||||
for (int f = 0; f < nTris; ++f)
|
||||
{
|
||||
Export::Face face;
|
||||
face.idx[0] = *(pIndices++) + newOffsetIndex;
|
||||
face.idx[1] = *(pIndices++) + newOffsetIndex;
|
||||
face.idx[2] = *(pIndices++) + newOffsetIndex;
|
||||
pMesh->m_faces.push_back(face);
|
||||
}
|
||||
|
||||
pObj->m_meshes.push_back(pMesh);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Export::CMesh* pMesh = new Export::CMesh();
|
||||
if (meshDesc.m_nFaceCount == 0 && meshDesc.m_nIndexCount != 0 && meshDesc.m_pIndices != nullptr)
|
||||
{
|
||||
const vtx_idx* pIndices = &meshDesc.m_pIndices[0];
|
||||
int nTris = meshDesc.m_nIndexCount / 3;
|
||||
pMesh->m_faces.reserve(nTris);
|
||||
for (int f = 0; f < nTris; ++f)
|
||||
{
|
||||
Export::Face face;
|
||||
face.idx[0] = *(pIndices++) + newOffsetIndex;
|
||||
face.idx[1] = *(pIndices++) + newOffsetIndex;
|
||||
face.idx[2] = *(pIndices++) + newOffsetIndex;
|
||||
pMesh->m_faces.push_back(face);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pMesh->m_faces.reserve(meshDesc.m_nFaceCount);
|
||||
for (int f = 0; f < meshDesc.m_nFaceCount; ++f)
|
||||
{
|
||||
Export::Face face;
|
||||
face.idx[0] = meshDesc.m_pFaces[f].v[0];
|
||||
face.idx[1] = meshDesc.m_pFaces[f].v[1];
|
||||
face.idx[2] = meshDesc.m_pFaces[f].v[2];
|
||||
pMesh->m_faces.push_back(face);
|
||||
}
|
||||
}
|
||||
|
||||
pObj->m_meshes.push_back(pMesh);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool CExportManager::AddStatObj(Export::CObject* pObj, IStatObj* pStatObj, Matrix34A* pTm)
|
||||
{
|
||||
IIndexedMesh* pIndMesh = nullptr;
|
||||
|
||||
if (pStatObj->GetSubObjectCount())
|
||||
{
|
||||
for (int i = 0; i < pStatObj->GetSubObjectCount(); i++)
|
||||
{
|
||||
IStatObj::SSubObject* pSubObj = pStatObj->GetSubObject(i);
|
||||
if (pSubObj && pSubObj->nType == STATIC_SUB_OBJECT_MESH && pSubObj->pStatObj)
|
||||
{
|
||||
pIndMesh = nullptr;
|
||||
if (m_isOccluder)
|
||||
{
|
||||
if (pSubObj->pStatObj->GetLodObject(2))
|
||||
{
|
||||
pIndMesh = pSubObj->pStatObj->GetLodObject(2)->GetIndexedMesh(true);
|
||||
}
|
||||
if (!pIndMesh && pSubObj->pStatObj->GetLodObject(1))
|
||||
{
|
||||
pIndMesh = pSubObj->pStatObj->GetLodObject(1)->GetIndexedMesh(true);
|
||||
}
|
||||
}
|
||||
if (!pIndMesh)
|
||||
{
|
||||
pIndMesh = pSubObj->pStatObj->GetIndexedMesh(true);
|
||||
}
|
||||
if (pIndMesh)
|
||||
{
|
||||
AddMesh(pObj, pIndMesh, pTm);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!pIndMesh)
|
||||
{
|
||||
if (m_isOccluder)
|
||||
{
|
||||
if (pStatObj->GetLodObject(2))
|
||||
{
|
||||
pIndMesh = pStatObj->GetLodObject(2)->GetIndexedMesh(true);
|
||||
}
|
||||
if (!pIndMesh && pStatObj->GetLodObject(1))
|
||||
{
|
||||
pIndMesh = pStatObj->GetLodObject(1)->GetIndexedMesh(true);
|
||||
}
|
||||
}
|
||||
if (!pIndMesh)
|
||||
{
|
||||
pIndMesh = pStatObj->GetIndexedMesh(true);
|
||||
}
|
||||
if (pIndMesh)
|
||||
{
|
||||
AddMesh(pObj, pIndMesh, pTm);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CExportManager::AddMeshes(Export::CObject* pObj)
|
||||
{
|
||||
if (m_pBaseObj->GetType() == OBJTYPE_AZENTITY)
|
||||
{
|
||||
CEntityObject* pEntityObject = (CEntityObject*)m_pBaseObj;
|
||||
IRenderNode* pEngineNode = pEntityObject->GetEngineNode();
|
||||
|
||||
if (pEngineNode)
|
||||
{
|
||||
if (!m_isPrecaching)
|
||||
{
|
||||
for (int i = 0; i < pEngineNode->GetSlotCount(); ++i)
|
||||
{
|
||||
Matrix34A tm;
|
||||
IStatObj* pStatObj = pEngineNode->GetEntityStatObj(i, 0, &tm);
|
||||
if (pStatObj)
|
||||
{
|
||||
Matrix34A objTM = m_pBaseObj->GetWorldTM();
|
||||
objTM.Invert();
|
||||
tm = objTM * tm;
|
||||
AddStatObj(pObj, pStatObj, &tm);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool CExportManager::AddObject(CBaseObject* pBaseObj)
|
||||
{
|
||||
if (m_isOccluder)
|
||||
@@ -531,7 +322,6 @@ bool CExportManager::AddObject(CBaseObject* pBaseObj)
|
||||
|
||||
if (m_isPrecaching)
|
||||
{
|
||||
AddMeshes(nullptr);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -542,7 +332,6 @@ bool CExportManager::AddObject(CBaseObject* pBaseObj)
|
||||
|
||||
m_objectMap[pBaseObj] = int(m_data.m_objects.size() - 1);
|
||||
|
||||
AddMeshes(pObj);
|
||||
m_pBaseObj = nullptr;
|
||||
|
||||
return true;
|
||||
@@ -1227,15 +1016,6 @@ bool CExportManager::ImportFromFile(const char* filename)
|
||||
return bRet;
|
||||
}
|
||||
|
||||
bool CExportManager::ExportSingleStatObj(IStatObj* pStatObj, const char* filename)
|
||||
{
|
||||
Export::CObject* pObj = new Export::CObject(Path::GetFileName(filename).toUtf8().data());
|
||||
AddStatObj(pObj, pStatObj);
|
||||
m_data.m_objects.push_back(pObj);
|
||||
ExportToFile(filename, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
void CExportManager::SaveNodeKeysTimeToXML()
|
||||
{
|
||||
CTrackViewSequence* pSequence = GetIEditor()->GetAnimation()->GetSequence();
|
||||
|
||||
@@ -139,18 +139,11 @@ public:
|
||||
bool ImportFromFile(const char* filename);
|
||||
const Export::CData& GetData() const {return m_data; };
|
||||
|
||||
//! Exports the stat obj to the obj file specified
|
||||
//! returns true if succeeded, otherwise false
|
||||
bool ExportSingleStatObj(IStatObj* pStatObj, const char* filename) override;
|
||||
|
||||
void SetBakedKeysSequenceExport(bool bBaked){m_bBakedKeysSequenceExport = bBaked; };
|
||||
|
||||
void SaveNodeKeysTimeToXML();
|
||||
|
||||
private:
|
||||
void AddMesh(Export::CObject* pObj, const IIndexedMesh* pIndMesh, Matrix34A* pTm = nullptr);
|
||||
bool AddStatObj(Export::CObject* pObj, IStatObj* pStatObj, Matrix34A* pTm = nullptr);
|
||||
bool AddMeshes(Export::CObject* pObj);
|
||||
bool AddObject(CBaseObject* pBaseObj);
|
||||
void SolveHierarchy();
|
||||
|
||||
|
||||
@@ -157,20 +157,20 @@ struct SSystemUserCallback
|
||||
}
|
||||
}
|
||||
|
||||
int ShowMessage(const char* text, const char* caption, unsigned int uType) override
|
||||
void ShowMessage(const char* text, const char* caption, unsigned int uType) override
|
||||
{
|
||||
if (CCryEditApp::instance()->IsInAutotestMode())
|
||||
{
|
||||
return IDOK;
|
||||
return;
|
||||
}
|
||||
|
||||
const UINT kMessageBoxButtonMask = 0x000f;
|
||||
if (!GetIEditor()->IsInGameMode() && (uType == 0 || uType == MB_OK || !(uType & kMessageBoxButtonMask)))
|
||||
{
|
||||
static_cast<CEditorImpl*>(GetIEditor())->AddErrorMessage(text, caption);
|
||||
return IDOK;
|
||||
return;
|
||||
}
|
||||
return CryMessageBox(text, caption, uType);
|
||||
CryMessageBox(text, caption, uType);
|
||||
}
|
||||
|
||||
void OnSplashScreenDone()
|
||||
@@ -822,7 +822,7 @@ void CGameEngine::Update()
|
||||
if (gEnv->pSystem)
|
||||
{
|
||||
gEnv->pSystem->UpdatePreTickBus();
|
||||
componentApplication->Tick(gEnv->pTimer->GetFrameTime(ITimer::ETIMER_GAME));
|
||||
componentApplication->Tick();
|
||||
gEnv->pSystem->UpdatePostTickBus();
|
||||
}
|
||||
|
||||
@@ -838,7 +838,7 @@ void CGameEngine::Update()
|
||||
unsigned int updateFlags = ESYSUPDATE_EDITOR;
|
||||
GetIEditor()->GetAnimation()->Update();
|
||||
GetIEditor()->GetSystem()->UpdatePreTickBus(updateFlags);
|
||||
componentApplication->Tick(gEnv->pTimer->GetFrameTime(ITimer::ETIMER_GAME));
|
||||
componentApplication->Tick();
|
||||
GetIEditor()->GetSystem()->UpdatePostTickBus(updateFlags);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,17 +8,11 @@
|
||||
|
||||
|
||||
// Description : The game engine for editor
|
||||
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_GAMEENGINE_H
|
||||
#define CRYINCLUDE_EDITOR_GAMEENGINE_H
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include <AzCore/Outcome/Outcome.h>
|
||||
#include "LogFile.h"
|
||||
#include "CryListenerSet.h"
|
||||
#include "Util/ModalWindowDismisser.h"
|
||||
#endif
|
||||
|
||||
@@ -159,5 +153,3 @@ private:
|
||||
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
};
|
||||
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_GAMEENGINE_H
|
||||
|
||||
@@ -146,13 +146,11 @@ bool CGameExporter::Export(unsigned int flags, [[maybe_unused]] EEndian eExportE
|
||||
exportSuccessful = false;
|
||||
}
|
||||
|
||||
if (exportSuccessful)
|
||||
if (exportSuccessful && m_bAutoExportMode)
|
||||
{
|
||||
if (m_bAutoExportMode)
|
||||
{
|
||||
// Remove read-only flags.
|
||||
CrySetFileAttributes(m_levelPak.m_sPath.toUtf8().data(), FILE_ATTRIBUTE_NORMAL);
|
||||
}
|
||||
// Remove read-only flags.
|
||||
auto perms = QFile::permissions(m_levelPak.m_sPath) | QFile::Permission::WriteOwner;
|
||||
QFile::setPermissions(m_levelPak.m_sPath, perms);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -508,8 +508,6 @@ struct IEditor
|
||||
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;
|
||||
//! Delete object
|
||||
virtual void DeleteObject(CBaseObject* obj) = 0;
|
||||
//! Clone object
|
||||
virtual CBaseObject* CloneObject(CBaseObject* obj) = 0;
|
||||
//! Get current selection group
|
||||
virtual CSelectionGroup* GetSelection() = 0;
|
||||
virtual CBaseObject* GetSelectedObject() = 0;
|
||||
|
||||
@@ -397,11 +397,6 @@ void CEditorImpl::Update()
|
||||
// Make sure this is not called recursively
|
||||
m_bUpdates = false;
|
||||
|
||||
//@FIXME: Restore this latter.
|
||||
//if (GetGameEngine() && GetGameEngine()->IsLevelLoaded())
|
||||
{
|
||||
m_pObjectManager->Update();
|
||||
}
|
||||
if (IsInPreviewMode())
|
||||
{
|
||||
SetModifiedFlag(false);
|
||||
@@ -687,13 +682,6 @@ void CEditorImpl::DeleteObject(CBaseObject* obj)
|
||||
GetObjectManager()->DeleteObject(obj);
|
||||
}
|
||||
|
||||
CBaseObject* CEditorImpl::CloneObject(CBaseObject* obj)
|
||||
{
|
||||
SetModifiedFlag();
|
||||
GetIEditor()->SetModifiedModule(eModifiedBrushes);
|
||||
return GetObjectManager()->CloneObject(obj);
|
||||
}
|
||||
|
||||
CBaseObject* CEditorImpl::GetSelectedObject()
|
||||
{
|
||||
if (m_pObjectManager->GetSelection()->GetCount() != 1)
|
||||
|
||||
@@ -141,7 +141,6 @@ public:
|
||||
const SGizmoParameters& GetGlobalGizmoParameters() override;
|
||||
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) override;
|
||||
void DeleteObject(CBaseObject* obj) override;
|
||||
CBaseObject* CloneObject(CBaseObject* obj) override;
|
||||
IObjectManager* GetObjectManager() override;
|
||||
// This will return a null pointer if CrySystem is not loaded before
|
||||
// Global Sandbox Settings are loaded from the registry before CrySystem
|
||||
|
||||
@@ -21,8 +21,6 @@
|
||||
#include "Util/Image.h"
|
||||
#include "Util/ImageUtil.h"
|
||||
|
||||
#include <IStatObj.h>
|
||||
|
||||
#define HELPER_MATERIAL "Objects/Helper"
|
||||
|
||||
namespace
|
||||
@@ -38,7 +36,6 @@ namespace
|
||||
CIconManager::CIconManager()
|
||||
{
|
||||
ZeroStruct(m_icons);
|
||||
ZeroStruct(m_objects);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -61,13 +58,7 @@ void CIconManager::Done()
|
||||
void CIconManager::Reset()
|
||||
{
|
||||
// Do not unload objects. but clears them.
|
||||
int i;
|
||||
for (i = 0; i < sizeof(m_objects) / sizeof(m_objects[0]); i++)
|
||||
{
|
||||
delete m_objects[i];
|
||||
m_objects[i] = nullptr;
|
||||
}
|
||||
for (i = 0; i < eIcon_COUNT; i++)
|
||||
for (int i = 0; i < eIcon_COUNT; i++)
|
||||
{
|
||||
m_icons[i] = 0;
|
||||
}
|
||||
@@ -110,12 +101,6 @@ int CIconManager::GetIconTexture(EIcon icon)
|
||||
return m_icons[icon];
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
IStatObj* CIconManager::GetObject(EStatObject)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
QImage* CIconManager::GetIconBitmap(const char* filename, bool& bHaveAlpha, uint32 effects /*=0*/)
|
||||
{
|
||||
|
||||
@@ -8,11 +8,6 @@
|
||||
|
||||
|
||||
// Description : Manages Textures used by Icon.
|
||||
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_ICONMANAGER_H
|
||||
#define CRYINCLUDE_EDITOR_ICONMANAGER_H
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Include/IIconManager.h" // for IIconManager
|
||||
@@ -31,7 +26,7 @@ class CIconManager
|
||||
public:
|
||||
// Construction
|
||||
CIconManager();
|
||||
~CIconManager();
|
||||
~CIconManager() override;
|
||||
|
||||
void Init();
|
||||
void Done();
|
||||
@@ -41,8 +36,6 @@ public:
|
||||
|
||||
// Operations
|
||||
virtual int GetIconTexture(EIcon icon);
|
||||
|
||||
virtual IStatObj* GetObject(EStatObject object);
|
||||
virtual int GetIconTexture(const char* iconName);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -61,7 +54,6 @@ public:
|
||||
private:
|
||||
StdMap<QString, int> m_textures;
|
||||
|
||||
IStatObj* m_objects[eStatObject_COUNT];
|
||||
int m_icons[eIcon_COUNT];
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -70,5 +62,3 @@ private:
|
||||
typedef std::map<QString, QImage*> IconsMap;
|
||||
IconsMap m_iconBitmapsMap;
|
||||
};
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_ICONMANAGER_H
|
||||
|
||||
@@ -19,7 +19,6 @@ class CBaseObject;
|
||||
struct IDisplayViewport;
|
||||
class CDeepSelection;
|
||||
struct AABB;
|
||||
class CCamera;
|
||||
|
||||
#include <QRect>
|
||||
#include <platform.h>
|
||||
@@ -68,8 +67,6 @@ struct HitContext
|
||||
QRect rect;
|
||||
//! Optional limiting bounding box for hit testing.
|
||||
AABB* bounds;
|
||||
//! Optional camera for culling perspective viewports.
|
||||
CCamera* camera;
|
||||
|
||||
//! Testing performed in 2D viewport.
|
||||
bool b2DViewport;
|
||||
@@ -120,7 +117,6 @@ struct HitContext
|
||||
rect = QRect();
|
||||
b2DViewport = false;
|
||||
view = 0;
|
||||
camera = 0;
|
||||
point2d = QPoint();
|
||||
axis = 0;
|
||||
distanceTolerance = 0;
|
||||
|
||||
@@ -6,15 +6,11 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_INCLUDE_IDISPLAYVIEWPORT_H
|
||||
#define CRYINCLUDE_EDITOR_INCLUDE_IDISPLAYVIEWPORT_H
|
||||
#pragma once
|
||||
|
||||
struct DisplayContext;
|
||||
class CBaseObjectsCache;
|
||||
class QPoint;
|
||||
class CCamera;
|
||||
struct AABB;
|
||||
class CViewport;
|
||||
|
||||
@@ -23,8 +19,6 @@ struct IDisplayViewport
|
||||
{
|
||||
virtual void Update() = 0;
|
||||
virtual float GetScreenScaleFactor(const Vec3& position) const = 0;
|
||||
virtual float GetScreenScaleFactor(const CCamera& camera, const Vec3& object_position) = 0;
|
||||
virtual bool HitTestLine(const Vec3& lineP1, const Vec3& lineP2, const QPoint& hitpoint, int pixelRadius, float* pToCameraDistance = 0) const = 0;
|
||||
|
||||
/**
|
||||
* Gets the distance of the point on screen to the line defined by the two points, converted to screenspace.
|
||||
@@ -47,16 +41,12 @@ struct IDisplayViewport
|
||||
virtual const Matrix34& GetViewTM() const = 0;
|
||||
virtual const Matrix34& GetScreenTM() const = 0;
|
||||
virtual QPoint WorldToView(const Vec3& worldPoint) const = 0;
|
||||
virtual QPoint WorldToViewParticleEditor(const Vec3& worldPoint, int width, int height) const = 0;
|
||||
virtual Vec3 WorldToView3D(const Vec3& worldPoint, int flags = 0) const = 0;
|
||||
virtual Vec3 ViewToWorld(const QPoint& vp, bool* collideWithTerrain = nullptr, bool onlyTerrain = false, bool bSkipVegetation = false, bool bTestRenderMesh = false, bool* collideWithObject = nullptr) const = 0;
|
||||
virtual void ViewToWorldRay(const QPoint& vp, Vec3& raySrc, Vec3& rayDir) const = 0;
|
||||
virtual float GetGridStep() const = 0;
|
||||
virtual void setRay(QPoint& vp, Vec3& raySrc, Vec3& rayDir) = 0;
|
||||
virtual void setHitcontext(QPoint& vp, Vec3& raySrc, Vec3& rayDir) = 0;
|
||||
|
||||
virtual float GetAspectRatio() const = 0;
|
||||
virtual const ::Plane* GetConstructionPlane() const = 0;
|
||||
|
||||
virtual bool IsBoundsVisible(const AABB& box) const = 0;
|
||||
|
||||
@@ -65,5 +55,3 @@ struct IDisplayViewport
|
||||
|
||||
virtual CViewport *asCViewport() { return nullptr; }
|
||||
};
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_INCLUDE_IDISPLAYVIEWPORT_H
|
||||
|
||||
@@ -9,10 +9,6 @@
|
||||
#define CRYINCLUDE_EDITOR_MATERIAL_IEDITORMATERIALMANAGER_H
|
||||
#pragma once
|
||||
|
||||
#define MATERIAL_FILE_EXT ".mtl"
|
||||
#define DCC_MATERIAL_FILE_EXT ".dccmtl"
|
||||
#define MATERIALS_PATH "materials/"
|
||||
|
||||
#include <Include/IBaseLibraryManager.h>
|
||||
#include <IMaterial.h>
|
||||
|
||||
|
||||
@@ -8,14 +8,9 @@
|
||||
|
||||
|
||||
// Description : Export geometry interfaces
|
||||
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_INCLUDE_IEXPORTMANAGER_H
|
||||
#define CRYINCLUDE_EDITOR_INCLUDE_IEXPORTMANAGER_H
|
||||
#pragma once
|
||||
|
||||
#define EXP_NAMESIZE 32
|
||||
struct IStatObj;
|
||||
enum class AnimParamType;
|
||||
|
||||
namespace Export
|
||||
@@ -178,18 +173,10 @@ struct IExporter
|
||||
virtual void Release() = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
// IExportManager: interface to export manager
|
||||
struct IExportManager
|
||||
{
|
||||
//! Register exporter
|
||||
//! return true if succeed, otherwise false
|
||||
virtual bool RegisterExporter(IExporter* pExporter) = 0;
|
||||
|
||||
virtual bool ExportSingleStatObj(IStatObj* pStatObj, const char* filename) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_INCLUDE_IEXPORTMANAGER_H
|
||||
|
||||
@@ -60,7 +60,6 @@ struct IFileUtil
|
||||
EFILE_TYPE_GEOMETRY,
|
||||
EFILE_TYPE_TEXTURE,
|
||||
EFILE_TYPE_SOUND,
|
||||
EFILE_TYPE_GEOMCACHE,
|
||||
EFILE_TYPE_LAST,
|
||||
};
|
||||
|
||||
@@ -114,9 +113,7 @@ struct IFileUtil
|
||||
|
||||
virtual void ShowInExplorer(const QString& path) = 0;
|
||||
|
||||
virtual bool CompileLuaFile(const char* luaFilename) = 0;
|
||||
virtual bool ExtractFile(QString& file, bool bMsgBoxAskForExtraction = true, const char* pDestinationFilename = nullptr) = 0;
|
||||
virtual void EditTextFile(const char* txtFile, int line = 0, ETextFileType fileType = FILE_TYPE_SCRIPT) = 0;
|
||||
virtual void EditTextureFile(const char* txtureFile, bool bUseGameFolder) = 0;
|
||||
|
||||
//! dcc filename calculation and extraction sub-routines
|
||||
|
||||
@@ -6,12 +6,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_INCLUDE_IICONMANAGER_H
|
||||
#define CRYINCLUDE_EDITOR_INCLUDE_IICONMANAGER_H
|
||||
#pragma once
|
||||
|
||||
struct IStatObj;
|
||||
struct IMaterial;
|
||||
class CBitmap;
|
||||
|
||||
@@ -56,12 +52,9 @@ enum EIconEffect
|
||||
struct IIconManager
|
||||
{
|
||||
virtual ~IIconManager() = default;
|
||||
virtual IStatObj* GetObject(EStatObject object) = 0;
|
||||
virtual int GetIconTexture(EIcon icon) = 0;
|
||||
virtual int GetIconTexture(const char* iconName) = 0;
|
||||
virtual QImage* GetIconBitmap(const char* filename, bool& haveAlpha, uint32 effects = 0) = 0;
|
||||
// Register an Icon for the specific command
|
||||
virtual void RegisterCommandIcon([[maybe_unused]] const char* filename, [[maybe_unused]] int nCommandId) {}
|
||||
};
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_INCLUDE_IICONMANAGER_H
|
||||
|
||||
@@ -5,10 +5,6 @@
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_INCLUDE_IOBJECTMANAGER_H
|
||||
#define CRYINCLUDE_EDITOR_INCLUDE_IOBJECTMANAGER_H
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/PlatformIncl.h>
|
||||
@@ -29,32 +25,15 @@ class CObjectArchive;
|
||||
class CViewport;
|
||||
struct HitContext;
|
||||
enum class ImageRotationDegrees;
|
||||
struct IStatObj;
|
||||
class CBaseObject;
|
||||
class XmlNodeRef;
|
||||
|
||||
#include "ObjectEvent.h"
|
||||
|
||||
enum SerializeFlags
|
||||
{
|
||||
SERIALIZE_ALL = 0,
|
||||
SERIALIZE_ONLY_SHARED = 1,
|
||||
SERIALIZE_ONLY_NOTSHARED = 2,
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
typedef std::vector<CBaseObject*> CBaseObjectsArray;
|
||||
typedef std::pair< bool(CALLBACK*)(CBaseObject const&, void*), void* > BaseObjectFilterFunctor;
|
||||
|
||||
struct IObjectSelectCallback
|
||||
{
|
||||
//! Called when object is selected.
|
||||
//! Return true if selection should proceed, or false to abort object selection.
|
||||
virtual bool OnSelectObject(CBaseObject* obj) = 0;
|
||||
//! Return true if object can be selected.
|
||||
virtual bool CanSelectObject(CBaseObject* obj) = 0;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Interface to access editor objects scene graph.
|
||||
@@ -78,10 +57,6 @@ public:
|
||||
virtual void DeleteObject(CBaseObject* obj) = 0;
|
||||
virtual void DeleteSelection(CSelectionGroup* pSelection) = 0;
|
||||
virtual void DeleteAllObjects() = 0;
|
||||
virtual CBaseObject* CloneObject(CBaseObject* obj) = 0;
|
||||
|
||||
virtual void BeginEditParams(CBaseObject* obj, int flags) = 0;
|
||||
virtual void EndEditParams(int flags = 0) = 0;
|
||||
|
||||
//! Get number of objects manager by ObjectManager (not contain sub objects of groups).
|
||||
virtual int GetObjectCount() const = 0;
|
||||
@@ -90,27 +65,9 @@ public:
|
||||
//! @param layer if 0 get objects for all layers, or layer to get objects from.
|
||||
virtual void GetObjects(CBaseObjectsArray& objects) const = 0;
|
||||
|
||||
//! Get array of objects that pass the filter.
|
||||
//! @param filter The filter functor, return true if you want to get the certain obj, return false if want to skip it.
|
||||
virtual void GetObjects(CBaseObjectsArray& objects, BaseObjectFilterFunctor const& filter) const = 0;
|
||||
|
||||
//! Display objects on specified display context.
|
||||
virtual void Display(DisplayContext& dc) = 0;
|
||||
|
||||
//! Called when selecting without selection helpers - this is needed since
|
||||
//! the visible object cache is normally not updated when not displaying helpers.
|
||||
virtual void ForceUpdateVisibleObjectCache(DisplayContext& dc) = 0;
|
||||
|
||||
//! Check intersection with objects.
|
||||
//! Find intersection with nearest to ray origin object hit by ray.
|
||||
//! If distance tollerance is specified certain relaxation applied on collision test.
|
||||
//! @return true if hit any object, and fills hitInfo structure.
|
||||
virtual bool HitTest(HitContext& hitInfo) = 0;
|
||||
|
||||
//! Check intersection with an object.
|
||||
//! @return true if hit, and fills hitInfo structure.
|
||||
virtual bool HitTestObject(CBaseObject* obj, HitContext& hc) = 0;
|
||||
|
||||
//! Gets a radius to be used for hit tests on the axis helpers, like the transform gizmo.
|
||||
//! @return the axis helper hit radius.
|
||||
virtual int GetAxisHelperHitRadius() const = 0;
|
||||
@@ -137,59 +94,18 @@ public:
|
||||
//! Find objects which intersect with a given AABB.
|
||||
virtual void FindObjectsInAABB(const AABB& aabb, std::vector<CBaseObject*>& result) const = 0;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Operations on objects.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//! Makes object visible or invisible.
|
||||
virtual void HideObject(CBaseObject* obj, bool hide) = 0;
|
||||
//! Shows the last hidden object based on hidden ID
|
||||
virtual void ShowLastHiddenObject() = 0;
|
||||
//! Freeze object, making it unselectable.
|
||||
virtual void FreezeObject(CBaseObject* obj, bool freeze) = 0;
|
||||
//! Unhide all hidden objects.
|
||||
virtual void UnhideAll() = 0;
|
||||
//! Unfreeze all frozen objects.
|
||||
virtual void UnfreezeAll() = 0;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Object Selection.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
virtual bool SelectObject(CBaseObject* obj, bool bUseMask = true) = 0;
|
||||
virtual void UnselectObject(CBaseObject* obj) = 0;
|
||||
|
||||
//! Select objects within specified distance from given position.
|
||||
//! Return number of selected objects.
|
||||
virtual int SelectObjects(const AABB& box, bool bUnselect = false) = 0;
|
||||
|
||||
virtual void SelectEntities(std::set<CEntityObject*>& s) = 0;
|
||||
|
||||
virtual int MoveObjects(const AABB& box, const Vec3& offset, ImageRotationDegrees rotation, bool bIsCopy = false) = 0;
|
||||
|
||||
//! Selects/Unselects all objects within 2d rectangle in given viewport.
|
||||
virtual void SelectObjectsInRect(CViewport* view, const QRect& rect, bool bSelect) = 0;
|
||||
virtual void FindObjectsInRect(CViewport* view, const QRect& rect, std::vector<GUID>& guids) = 0;
|
||||
|
||||
//! Clear default selection set.
|
||||
//! @Return number of objects removed from selection.
|
||||
virtual int ClearSelection() = 0;
|
||||
|
||||
//! Deselect all current selected objects and selects object that were unselected.
|
||||
//! @Return number of selected objects.
|
||||
virtual int InvertSelection() = 0;
|
||||
|
||||
//! Get current selection.
|
||||
virtual CSelectionGroup* GetSelection() const = 0;
|
||||
//! Get named selection.
|
||||
virtual CSelectionGroup* GetSelection(const QString& name) const = 0;
|
||||
// Get selection group names
|
||||
virtual void GetNameSelectionStrings(QStringList& names) = 0;
|
||||
//! Change name of current selection group.
|
||||
//! And store it in list.
|
||||
virtual void NameSelection(const QString& name) = 0;
|
||||
//! Set one of name selections as current selection.
|
||||
virtual void SetSelection(const QString& name) = 0;
|
||||
//! Removes one of named selections.
|
||||
virtual void RemoveSelection(const QString& name) = 0;
|
||||
|
||||
//! Delete all objects in current selection group.
|
||||
virtual void DeleteSelection() = 0;
|
||||
@@ -198,54 +114,11 @@ public:
|
||||
virtual QString GenerateUniqueObjectName(const QString& typeName) = 0;
|
||||
//! Register object name in object manager, needed for generating uniq names.
|
||||
virtual void RegisterObjectName(const QString& name) = 0;
|
||||
//! Enable/Disable generating of unique object names (Enabled by default).
|
||||
//! Return previous value.
|
||||
virtual bool EnableUniqObjectNames(bool bEnable) = 0;
|
||||
|
||||
//! Find object class by name.
|
||||
virtual CObjectClassDesc* FindClass(const QString& className) = 0;
|
||||
virtual void GetClassCategories(QStringList& categories) = 0;
|
||||
virtual void GetClassCategoryToolClassNamePairs(std::vector< std::pair<QString, QString> >& categoryToolClassNamePairs) = 0;
|
||||
virtual void GetClassTypes(const QString& category, QStringList& types) = 0;
|
||||
|
||||
//! Export objects to xml.
|
||||
//! When onlyShared is true ony objects with shared flags exported, overwise only not shared object exported.
|
||||
virtual void Export(const QString& levelPath, XmlNodeRef& rootNode, bool onlyShared) = 0;
|
||||
//! Export only entities to xml.
|
||||
virtual void ExportEntities(XmlNodeRef& rootNode) = 0;
|
||||
|
||||
//! Serialize Objects in manager to specified XML Node.
|
||||
//! @param flags Can be one of SerializeFlags.
|
||||
virtual void Serialize(XmlNodeRef& rootNode, bool bLoading, int flags = SERIALIZE_ALL) = 0;
|
||||
virtual void SerializeNameSelection(XmlNodeRef& rootNode, bool bLoading) = 0;
|
||||
|
||||
//! Load objects from object archive.
|
||||
//! @param bSelect if set newly loaded object will be selected.
|
||||
virtual void LoadObjects(CObjectArchive& ar, bool bSelect) = 0;
|
||||
|
||||
virtual void ChangeObjectId(REFGUID oldId, REFGUID newId) = 0;
|
||||
virtual bool IsDuplicateObjectName(const QString& newName) const = 0;
|
||||
virtual void ShowDuplicationMsgWarning(CBaseObject* obj, const QString& newName, bool bShowMsgBox) const = 0;
|
||||
virtual void ChangeObjectName(CBaseObject* obj, const QString& newName) = 0;
|
||||
|
||||
//! while loading PreFabs we need to force this IDs
|
||||
//! to force always the same IDs, on each load.
|
||||
//! needed for RAM-maps assignments
|
||||
virtual uint32 ForceID() const = 0;
|
||||
virtual void ForceID(uint32 FID) = 0;
|
||||
|
||||
//! Convert object of one type to object of another type.
|
||||
//! Original object is deleted.
|
||||
virtual bool ConvertToType(CBaseObject* pObject, const QString& typeName) = 0;
|
||||
|
||||
//! Set new selection callback.
|
||||
//! @return previous selection callback.
|
||||
virtual IObjectSelectCallback* SetSelectCallback(IObjectSelectCallback* callback) = 0;
|
||||
|
||||
// Enables/Disables creating of game objects.
|
||||
virtual void SetCreateGameObject(bool enable) = 0;
|
||||
//! Return true if objects loaded from xml should immidiatly create game objects associated with them.
|
||||
virtual bool IsCreateGameObjects() const = 0;
|
||||
|
||||
virtual IGizmoManager* GetGizmoManager() = 0;
|
||||
|
||||
@@ -253,34 +126,9 @@ public:
|
||||
//! Invalidate visibily settings of objects.
|
||||
virtual void InvalidateVisibleList() = 0;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// ObjectManager notification Callbacks.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
virtual void AddObjectEventListener(EventListener* listener) = 0;
|
||||
virtual void RemoveObjectEventListener(EventListener* listener) = 0;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Used to indicate starting and ending of objects loading.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
virtual void StartObjectsLoading(int numObjects) = 0;
|
||||
virtual void EndObjectsLoading() = 0;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Gathers all resources used by all objects.
|
||||
virtual void GatherUsedResources(CUsedResources& resources) = 0;
|
||||
|
||||
virtual bool IsLightClass(CBaseObject* pObject) = 0;
|
||||
|
||||
virtual void FindAndRenameProperty2(const char* property2Name, const QString& oldValue, const QString& newValue) = 0;
|
||||
virtual void FindAndRenameProperty2If(const char* property2Name, const QString& oldValue, const QString& newValue, const char* otherProperty2Name, const QString& otherValue) = 0;
|
||||
|
||||
virtual bool IsReloading() const = 0;
|
||||
|
||||
// Set bSkipUpdate to true if you want to skip update objects on the idle loop.
|
||||
virtual void SetSkipUpdate(bool bSkipUpdate) = 0;
|
||||
|
||||
virtual void SetExportingLevel(bool bExporting) = 0;
|
||||
virtual bool IsExportingLevelInprogress() const = 0;
|
||||
};
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_INCLUDE_IOBJECTMANAGER_H
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
//! Standart objects types.
|
||||
enum ObjectType
|
||||
{
|
||||
OBJTYPE_DUMMY = 1 << 20,
|
||||
OBJTYPE_AZENTITY = 1 << 21,
|
||||
};
|
||||
|
||||
|
||||
@@ -487,7 +487,6 @@ bool CLayoutWnd::LoadConfig()
|
||||
|
||||
CreateLayout((EViewLayout)layout, false);
|
||||
|
||||
bool bRebindViewports = false;
|
||||
if (m_splitWnd)
|
||||
{
|
||||
const QString str = settings.value("Viewports").toString();
|
||||
@@ -498,14 +497,12 @@ bool CLayoutWnd::LoadConfig()
|
||||
{
|
||||
break;
|
||||
}
|
||||
bRebindViewports = true;
|
||||
if (!resToken.isEmpty())
|
||||
{
|
||||
m_viewType[nIndex] = resToken;
|
||||
}
|
||||
nIndex++;
|
||||
}
|
||||
;
|
||||
}
|
||||
|
||||
BindViewports();
|
||||
|
||||
@@ -27,7 +27,9 @@ namespace UnitTest
|
||||
AZ::Entity* m_entity = nullptr;
|
||||
AZ::ComponentDescriptor* m_transformComponent = nullptr;
|
||||
|
||||
static const AzFramework::ViewportId TestViewportId;
|
||||
static inline constexpr AzFramework::ViewportId TestViewportId = 2345;
|
||||
static inline constexpr float HalfInterpolateToTransformDuration =
|
||||
AtomToolsFramework::ModularViewportCameraControllerRequests::InterpolateToTransformDuration * 0.5f;
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
@@ -76,8 +78,6 @@ namespace UnitTest
|
||||
}
|
||||
};
|
||||
|
||||
const AzFramework::ViewportId EditorCameraFixture::TestViewportId = AzFramework::ViewportId(1337);
|
||||
|
||||
TEST_F(EditorCameraFixture, ModularViewportCameraControllerReferenceFrameUpdatedWhenViewportEntityisChanged)
|
||||
{
|
||||
// Given
|
||||
@@ -91,8 +91,8 @@ namespace UnitTest
|
||||
&Camera::EditorCameraNotificationBus::Events::OnViewportViewEntityChanged, m_entity->GetId());
|
||||
|
||||
// ensure the viewport updates after the viewport view entity change
|
||||
const float deltaTime = 1.0f / 60.0f;
|
||||
m_controllerList->UpdateViewport({ TestViewportId, AzFramework::FloatSeconds(deltaTime), AZ::ScriptTimePoint() });
|
||||
// note: do a large step to ensure smoothing finishes (e.g. not 1.0f/60.0f)
|
||||
m_controllerList->UpdateViewport({ TestViewportId, AzFramework::FloatSeconds(2.0f), AZ::ScriptTimePoint() });
|
||||
|
||||
// retrieve updated camera transform
|
||||
const AZ::Transform cameraTransform = m_cameraViewportContextView->GetCameraTransform();
|
||||
@@ -102,61 +102,40 @@ namespace UnitTest
|
||||
EXPECT_THAT(cameraTransform, IsClose(entityTransform));
|
||||
}
|
||||
|
||||
TEST_F(EditorCameraFixture, ReferenceFrameRemainsIdentityAfterExternalCameraTransformChangeWhenNotSet)
|
||||
TEST_F(EditorCameraFixture, TrackingTransformIsTrueAfterTransformIsTracked)
|
||||
{
|
||||
// Given
|
||||
m_cameraViewportContextView->SetCameraTransform(AZ::Transform::CreateTranslation(AZ::Vector3(10.0f, 20.0f, 30.0f)));
|
||||
// Given/When
|
||||
const AZ::Transform referenceFrame = AZ::Transform::CreateFromQuaternionAndTranslation(
|
||||
AZ::Quaternion::CreateRotationX(AZ::DegToRad(90.0f)), AZ::Vector3(1.0f, 2.0f, 3.0f));
|
||||
AtomToolsFramework::ModularViewportCameraControllerRequestBus::Event(
|
||||
TestViewportId, &AtomToolsFramework::ModularViewportCameraControllerRequestBus::Events::StartTrackingTransform, referenceFrame);
|
||||
|
||||
// When
|
||||
AZ::Transform referenceFrame = AZ::Transform::CreateTranslation(AZ::Vector3(1.0f, 2.0f, 3.0f));
|
||||
bool trackingTransform = false;
|
||||
AtomToolsFramework::ModularViewportCameraControllerRequestBus::EventResult(
|
||||
referenceFrame, TestViewportId, &AtomToolsFramework::ModularViewportCameraControllerRequestBus::Events::GetReferenceFrame);
|
||||
trackingTransform, TestViewportId, &AtomToolsFramework::ModularViewportCameraControllerRequestBus::Events::IsTrackingTransform);
|
||||
|
||||
// Then
|
||||
// reference frame is still the identity
|
||||
EXPECT_THAT(referenceFrame, IsClose(AZ::Transform::CreateIdentity()));
|
||||
EXPECT_THAT(trackingTransform, ::testing::IsTrue());
|
||||
}
|
||||
|
||||
TEST_F(EditorCameraFixture, ExternalCameraTransformChangeWhenReferenceFrameIsSetUpdatesReferenceFrame)
|
||||
TEST_F(EditorCameraFixture, TrackingTransformIsFalseAfterTransformIsStoppedBeingTracked)
|
||||
{
|
||||
// Given
|
||||
const AZ::Transform referenceFrame = AZ::Transform::CreateFromQuaternionAndTranslation(
|
||||
AZ::Quaternion::CreateRotationX(AZ::DegToRad(90.0f)), AZ::Vector3(1.0f, 2.0f, 3.0f));
|
||||
AtomToolsFramework::ModularViewportCameraControllerRequestBus::Event(
|
||||
TestViewportId, &AtomToolsFramework::ModularViewportCameraControllerRequestBus::Events::SetReferenceFrame, referenceFrame);
|
||||
|
||||
const AZ::Transform nextTransform = AZ::Transform::CreateTranslation(AZ::Vector3(10.0f, 20.0f, 30.0f));
|
||||
m_cameraViewportContextView->SetCameraTransform(nextTransform);
|
||||
|
||||
// When
|
||||
AZ::Transform currentReferenceFrame = AZ::Transform::CreateTranslation(AZ::Vector3(1.0f, 2.0f, 3.0f));
|
||||
AtomToolsFramework::ModularViewportCameraControllerRequestBus::EventResult(
|
||||
currentReferenceFrame, TestViewportId,
|
||||
&AtomToolsFramework::ModularViewportCameraControllerRequestBus::Events::GetReferenceFrame);
|
||||
|
||||
// Then
|
||||
EXPECT_THAT(currentReferenceFrame, IsClose(nextTransform));
|
||||
}
|
||||
|
||||
TEST_F(EditorCameraFixture, ReferenceFrameReturnedToIdentityAfterClear)
|
||||
{
|
||||
// Given
|
||||
const AZ::Transform referenceFrame = AZ::Transform::CreateFromQuaternionAndTranslation(
|
||||
AZ::Quaternion::CreateRotationX(AZ::DegToRad(90.0f)), AZ::Vector3(1.0f, 2.0f, 3.0f));
|
||||
AtomToolsFramework::ModularViewportCameraControllerRequestBus::Event(
|
||||
TestViewportId, &AtomToolsFramework::ModularViewportCameraControllerRequestBus::Events::SetReferenceFrame, referenceFrame);
|
||||
TestViewportId, &AtomToolsFramework::ModularViewportCameraControllerRequestBus::Events::StartTrackingTransform, referenceFrame);
|
||||
|
||||
// When
|
||||
AtomToolsFramework::ModularViewportCameraControllerRequestBus::Event(
|
||||
TestViewportId, &AtomToolsFramework::ModularViewportCameraControllerRequestBus::Events::ClearReferenceFrame);
|
||||
|
||||
AZ::Transform currentReferenceFrame = AZ::Transform::CreateTranslation(AZ::Vector3(1.0f, 2.0f, 3.0f));
|
||||
AtomToolsFramework::ModularViewportCameraControllerRequestBus::EventResult(
|
||||
currentReferenceFrame, TestViewportId,
|
||||
&AtomToolsFramework::ModularViewportCameraControllerRequestBus::Events::GetReferenceFrame);
|
||||
TestViewportId, &AtomToolsFramework::ModularViewportCameraControllerRequestBus::Events::StopTrackingTransform);
|
||||
|
||||
// Then
|
||||
EXPECT_THAT(currentReferenceFrame, IsClose(AZ::Transform::CreateIdentity()));
|
||||
bool trackingTransform = false;
|
||||
AtomToolsFramework::ModularViewportCameraControllerRequestBus::EventResult(
|
||||
trackingTransform, TestViewportId, &AtomToolsFramework::ModularViewportCameraControllerRequestBus::Events::IsTrackingTransform);
|
||||
|
||||
EXPECT_THAT(trackingTransform, ::testing::IsFalse());
|
||||
}
|
||||
|
||||
TEST_F(EditorCameraFixture, InterpolateToTransform)
|
||||
@@ -169,8 +148,10 @@ namespace UnitTest
|
||||
transformToInterpolateTo);
|
||||
|
||||
// simulate interpolation
|
||||
m_controllerList->UpdateViewport({ TestViewportId, AzFramework::FloatSeconds(0.5f), AZ::ScriptTimePoint() });
|
||||
m_controllerList->UpdateViewport({ TestViewportId, AzFramework::FloatSeconds(0.5f), AZ::ScriptTimePoint() });
|
||||
m_controllerList->UpdateViewport(
|
||||
{ TestViewportId, AzFramework::FloatSeconds(HalfInterpolateToTransformDuration), AZ::ScriptTimePoint() });
|
||||
m_controllerList->UpdateViewport(
|
||||
{ TestViewportId, AzFramework::FloatSeconds(HalfInterpolateToTransformDuration), AZ::ScriptTimePoint() });
|
||||
|
||||
const auto finalTransform = m_cameraViewportContextView->GetCameraTransform();
|
||||
|
||||
@@ -184,7 +165,7 @@ namespace UnitTest
|
||||
const AZ::Transform referenceFrame = AZ::Transform::CreateFromQuaternionAndTranslation(
|
||||
AZ::Quaternion::CreateRotationX(AZ::DegToRad(90.0f)), AZ::Vector3(1.0f, 2.0f, 3.0f));
|
||||
AtomToolsFramework::ModularViewportCameraControllerRequestBus::Event(
|
||||
TestViewportId, &AtomToolsFramework::ModularViewportCameraControllerRequestBus::Events::SetReferenceFrame, referenceFrame);
|
||||
TestViewportId, &AtomToolsFramework::ModularViewportCameraControllerRequestBus::Events::StartTrackingTransform, referenceFrame);
|
||||
|
||||
AZ::Transform transformToInterpolateTo = AZ::Transform::CreateFromQuaternionAndTranslation(
|
||||
AZ::Quaternion::CreateRotationZ(AZ::DegToRad(90.0f)), AZ::Vector3(20.0f, 40.0f, 60.0f));
|
||||
@@ -195,18 +176,85 @@ namespace UnitTest
|
||||
transformToInterpolateTo);
|
||||
|
||||
// simulate interpolation
|
||||
m_controllerList->UpdateViewport({ TestViewportId, AzFramework::FloatSeconds(0.5f), AZ::ScriptTimePoint() });
|
||||
m_controllerList->UpdateViewport({ TestViewportId, AzFramework::FloatSeconds(0.5f), AZ::ScriptTimePoint() });
|
||||
|
||||
AZ::Transform currentReferenceFrame = AZ::Transform::CreateTranslation(AZ::Vector3(1.0f, 2.0f, 3.0f));
|
||||
AtomToolsFramework::ModularViewportCameraControllerRequestBus::EventResult(
|
||||
currentReferenceFrame, TestViewportId,
|
||||
&AtomToolsFramework::ModularViewportCameraControllerRequestBus::Events::GetReferenceFrame);
|
||||
m_controllerList->UpdateViewport(
|
||||
{ TestViewportId, AzFramework::FloatSeconds(HalfInterpolateToTransformDuration), AZ::ScriptTimePoint() });
|
||||
m_controllerList->UpdateViewport(
|
||||
{ TestViewportId, AzFramework::FloatSeconds(HalfInterpolateToTransformDuration), AZ::ScriptTimePoint() });
|
||||
|
||||
const auto finalTransform = m_cameraViewportContextView->GetCameraTransform();
|
||||
|
||||
// Then
|
||||
EXPECT_THAT(finalTransform, IsClose(transformToInterpolateTo));
|
||||
EXPECT_THAT(currentReferenceFrame, IsClose(AZ::Transform::CreateIdentity()));
|
||||
}
|
||||
|
||||
TEST_F(EditorCameraFixture, BeginningCameraInterpolationReturnsTrue)
|
||||
{
|
||||
// Given/When
|
||||
bool interpolationBegan = false;
|
||||
AtomToolsFramework::ModularViewportCameraControllerRequestBus::EventResult(
|
||||
interpolationBegan, TestViewportId,
|
||||
&AtomToolsFramework::ModularViewportCameraControllerRequestBus::Events::InterpolateToTransform,
|
||||
AZ::Transform::CreateTranslation(AZ::Vector3(10.0f, 10.0f, 10.0f)));
|
||||
|
||||
// Then
|
||||
EXPECT_THAT(interpolationBegan, ::testing::IsTrue());
|
||||
}
|
||||
|
||||
TEST_F(EditorCameraFixture, CameraInterpolationDoesNotBeginDuringAnExistingInterpolation)
|
||||
{
|
||||
// Given/When
|
||||
bool initialInterpolationBegan = false;
|
||||
AtomToolsFramework::ModularViewportCameraControllerRequestBus::EventResult(
|
||||
initialInterpolationBegan, TestViewportId,
|
||||
&AtomToolsFramework::ModularViewportCameraControllerRequestBus::Events::InterpolateToTransform,
|
||||
AZ::Transform::CreateTranslation(AZ::Vector3(10.0f, 10.0f, 10.0f)));
|
||||
|
||||
m_controllerList->UpdateViewport(
|
||||
{ TestViewportId, AzFramework::FloatSeconds(HalfInterpolateToTransformDuration), AZ::ScriptTimePoint() });
|
||||
|
||||
bool nextInterpolationBegan = true;
|
||||
AtomToolsFramework::ModularViewportCameraControllerRequestBus::EventResult(
|
||||
nextInterpolationBegan, TestViewportId,
|
||||
&AtomToolsFramework::ModularViewportCameraControllerRequestBus::Events::InterpolateToTransform,
|
||||
AZ::Transform::CreateTranslation(AZ::Vector3(10.0f, 10.0f, 10.0f)));
|
||||
|
||||
bool interpolating = false;
|
||||
AtomToolsFramework::ModularViewportCameraControllerRequestBus::EventResult(
|
||||
interpolating, TestViewportId, &AtomToolsFramework::ModularViewportCameraControllerRequestBus::Events::IsInterpolating);
|
||||
|
||||
// Then
|
||||
EXPECT_THAT(initialInterpolationBegan, ::testing::IsTrue());
|
||||
EXPECT_THAT(nextInterpolationBegan, ::testing::IsFalse());
|
||||
EXPECT_THAT(interpolating, ::testing::IsTrue());
|
||||
}
|
||||
|
||||
TEST_F(EditorCameraFixture, CameraInterpolationCanBeginAfterAnInterpolationCompletes)
|
||||
{
|
||||
// Given/When
|
||||
bool initialInterpolationBegan = false;
|
||||
AtomToolsFramework::ModularViewportCameraControllerRequestBus::EventResult(
|
||||
initialInterpolationBegan, TestViewportId,
|
||||
&AtomToolsFramework::ModularViewportCameraControllerRequestBus::Events::InterpolateToTransform,
|
||||
AZ::Transform::CreateTranslation(AZ::Vector3(10.0f, 10.0f, 10.0f)));
|
||||
|
||||
m_controllerList->UpdateViewport(
|
||||
{ TestViewportId,
|
||||
AzFramework::FloatSeconds(AtomToolsFramework::ModularViewportCameraControllerRequests::InterpolateToTransformDuration + 0.5f),
|
||||
AZ::ScriptTimePoint() });
|
||||
|
||||
bool interpolating = true;
|
||||
AtomToolsFramework::ModularViewportCameraControllerRequestBus::EventResult(
|
||||
interpolating, TestViewportId, &AtomToolsFramework::ModularViewportCameraControllerRequestBus::Events::IsInterpolating);
|
||||
|
||||
bool nextInterpolationBegan = false;
|
||||
AtomToolsFramework::ModularViewportCameraControllerRequestBus::EventResult(
|
||||
nextInterpolationBegan, TestViewportId,
|
||||
&AtomToolsFramework::ModularViewportCameraControllerRequestBus::Events::InterpolateToTransform,
|
||||
AZ::Transform::CreateTranslation(AZ::Vector3(10.0f, 10.0f, 10.0f)));
|
||||
|
||||
// Then
|
||||
EXPECT_THAT(initialInterpolationBegan, ::testing::IsTrue());
|
||||
EXPECT_THAT(interpolating, ::testing::IsFalse());
|
||||
EXPECT_THAT(nextInterpolationBegan, ::testing::IsTrue());
|
||||
}
|
||||
} // namespace UnitTest
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
#include <Mocks/ISystemMock.h>
|
||||
#include <Mocks/IConsoleMock.h>
|
||||
#include <Mocks/ILogMock.h>
|
||||
#include <Mocks/ITimerMock.h>
|
||||
#include <Mocks/IConsoleMock.h>
|
||||
#include "IEditorMock.h"
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <AtomToolsFramework/Viewport/ModularViewportCameraController.h>
|
||||
#include <AzCore/Settings/SettingsRegistryImpl.h>
|
||||
#include <AzFramework/Viewport/ViewportControllerList.h>
|
||||
#include <AzToolsFramework/Input/QtEventToAzInputManager.h>
|
||||
#include <AzToolsFramework/Input/QtEventToAzInputMapper.h>
|
||||
#include <AzToolsFramework/UnitTest/AzToolsFrameworkTestHelpers.h>
|
||||
#include <EditorViewportWidget.h>
|
||||
#include <Mocks/MockWindowRequests.h>
|
||||
@@ -74,7 +74,7 @@ namespace UnitTest
|
||||
class ModularViewportCameraControllerFixture : public AllocatorsTestFixture
|
||||
{
|
||||
public:
|
||||
static const AzFramework::ViewportId TestViewportId;
|
||||
static inline constexpr AzFramework::ViewportId TestViewportId = 1234;
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
@@ -146,6 +146,17 @@ namespace UnitTest
|
||||
controller->SetCameraPropsBuilderCallback(
|
||||
[](AzFramework::CameraProps& cameraProps)
|
||||
{
|
||||
// note: rotateSmoothness is also used for roll (not related to camera input directly)
|
||||
cameraProps.m_rotateSmoothnessFn = []
|
||||
{
|
||||
return 5.0f;
|
||||
};
|
||||
|
||||
cameraProps.m_translateSmoothnessFn = []
|
||||
{
|
||||
return 5.0f;
|
||||
};
|
||||
|
||||
cameraProps.m_rotateSmoothingEnabledFn = []
|
||||
{
|
||||
return false;
|
||||
@@ -209,8 +220,6 @@ namespace UnitTest
|
||||
AZStd::unique_ptr<SandboxEditor::EditorModularViewportCameraComposer> m_editorModularViewportCameraComposer;
|
||||
};
|
||||
|
||||
const AzFramework::ViewportId ModularViewportCameraControllerFixture::TestViewportId = AzFramework::ViewportId(0);
|
||||
|
||||
TEST_F(ModularViewportCameraControllerFixture, MouseMovementDoesNotAccumulateExcessiveDriftInModularViewportCameraWithVaryingDeltaTime)
|
||||
{
|
||||
SandboxEditor::SetCameraCaptureCursorForLook(false);
|
||||
@@ -380,6 +389,7 @@ namespace UnitTest
|
||||
m_controllerList->UpdateViewport({ TestViewportId, AzFramework::FloatSeconds(deltaTime), AZ::ScriptTimePoint() });
|
||||
|
||||
QTest::mouseRelease(m_rootWidget.get(), Qt::MouseButton::RightButton, Qt::NoModifier, start + mouseDelta);
|
||||
m_controllerList->UpdateViewport({ TestViewportId, AzFramework::FloatSeconds(deltaTime), AZ::ScriptTimePoint() });
|
||||
|
||||
// update the position of the widget
|
||||
const auto offset = QPoint(500, 500);
|
||||
|
||||
@@ -63,16 +63,6 @@ namespace ObjectManagerPythonBindingsUnitTests
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("get_selection_center") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("get_selection_aabb") != behaviorContext->m_methods.end());
|
||||
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("hide_object") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("is_object_hidden") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("unhide_object") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("hide_all_objects") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("unhide_all_objects") != behaviorContext->m_methods.end());
|
||||
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("freeze_object") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("is_object_frozen") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("unfreeze_object") != behaviorContext->m_methods.end());
|
||||
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("delete_object") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("delete_selected") != behaviorContext->m_methods.end());
|
||||
|
||||
|
||||
@@ -94,6 +94,9 @@ namespace TrackViewPythonBindingsUnitTests
|
||||
|
||||
m_app.Start(appDesc);
|
||||
m_app.RegisterComponentDescriptor(AzToolsFramework::TrackViewComponent::CreateDescriptor());
|
||||
|
||||
// Disable saving global user settings to prevent failure due to detecting file updates
|
||||
AZ::UserSettingsComponentRequestBus::Broadcast(&AZ::UserSettingsComponentRequests::DisableSaveOnFinalize);
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
|
||||
@@ -8,10 +8,11 @@
|
||||
|
||||
#include <AzFramework/Viewport/CameraInput.h>
|
||||
#include <AzFramework/Viewport/ViewportControllerList.h>
|
||||
#include <AzToolsFramework/Input/QtEventToAzInputManager.h>
|
||||
#include <AzToolsFramework/Input/QtEventToAzInputMapper.h>
|
||||
#include <AzToolsFramework/UnitTest/AzToolsFrameworkTestHelpers.h>
|
||||
#include <AzToolsFramework/ViewportSelection/EditorInteractionSystemViewportSelectionRequestBus.h>
|
||||
#include <Editor/ViewportManipulatorController.h>
|
||||
#include <Mocks/MockWindowRequests.h>
|
||||
|
||||
namespace UnitTest
|
||||
{
|
||||
@@ -77,14 +78,15 @@ namespace UnitTest
|
||||
class ViewportManipulatorControllerFixture : public AllocatorsTestFixture
|
||||
{
|
||||
public:
|
||||
static const AzFramework::ViewportId TestViewportId;
|
||||
static inline constexpr AzFramework::ViewportId TestViewportId = 1234;
|
||||
static inline const QSize WidgetSize = QSize(1920, 1080);
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
AllocatorsTestFixture::SetUp();
|
||||
|
||||
m_rootWidget = AZStd::make_unique<QWidget>();
|
||||
m_rootWidget->setFixedSize(QSize(100, 100));
|
||||
m_rootWidget->setFixedSize(WidgetSize);
|
||||
QApplication::setActiveWindow(m_rootWidget.get());
|
||||
|
||||
m_controllerList = AZStd::make_shared<AzFramework::ViewportControllerList>();
|
||||
@@ -111,8 +113,6 @@ namespace UnitTest
|
||||
AZStd::unique_ptr<AzToolsFramework::QtEventToAzInputMapper> m_inputChannelMapper;
|
||||
};
|
||||
|
||||
const AzFramework::ViewportId ViewportManipulatorControllerFixture::TestViewportId = AzFramework::ViewportId(0);
|
||||
|
||||
TEST_F(ViewportManipulatorControllerFixture, AnEventIsNotPropagatedToTheViewportWhenAManipulatorHandlesItFirst)
|
||||
{
|
||||
// forward input events to our controller list
|
||||
@@ -227,4 +227,74 @@ namespace UnitTest
|
||||
// the key was released (cleared)
|
||||
EXPECT_TRUE(endedEvent);
|
||||
}
|
||||
|
||||
TEST_F(ViewportManipulatorControllerFixture, DoubleClickIsNotRegisteredIfMouseDeltaHasMovedMoreThanDeadzoneInClickInterval)
|
||||
{
|
||||
AzFramework::NativeWindowHandle nativeWindowHandle = nullptr;
|
||||
|
||||
// forward input events to our controller list
|
||||
QObject::connect(
|
||||
m_inputChannelMapper.get(), &AzToolsFramework::QtEventToAzInputMapper::InputChannelUpdated, m_rootWidget.get(),
|
||||
[this, nativeWindowHandle](const AzFramework::InputChannel* inputChannel, [[maybe_unused]] QEvent* event)
|
||||
{
|
||||
m_controllerList->HandleInputChannelEvent(
|
||||
AzFramework::ViewportControllerInputEvent{ TestViewportId, nativeWindowHandle, *inputChannel });
|
||||
});
|
||||
|
||||
::testing::NiceMock<MockWindowRequests> mockWindowRequests;
|
||||
mockWindowRequests.Connect(nativeWindowHandle);
|
||||
|
||||
using ::testing::Return;
|
||||
// note: WindowRequests is used internally by ViewportManipulatorController
|
||||
ON_CALL(mockWindowRequests, GetClientAreaSize())
|
||||
.WillByDefault(Return(AzFramework::WindowSize(WidgetSize.width(), WidgetSize.height())));
|
||||
|
||||
EditorInteractionViewportSelectionFake editorInteractionViewportFake;
|
||||
editorInteractionViewportFake.m_internalHandleMouseManipulatorInteraction = [](const MouseInteractionEvent&)
|
||||
{
|
||||
// report the event was not handled (manipulator was not interacted with)
|
||||
return false;
|
||||
};
|
||||
|
||||
bool doubleClickDetected = false;
|
||||
editorInteractionViewportFake.m_internalHandleMouseViewportInteraction =
|
||||
[&doubleClickDetected](const MouseInteractionEvent& mouseInteractionEvent)
|
||||
{
|
||||
// ensure no double click event is detected with the given inputs below
|
||||
if (mouseInteractionEvent.m_mouseEvent == AzToolsFramework::ViewportInteraction::MouseEvent::DoubleClick)
|
||||
{
|
||||
doubleClickDetected = true;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
editorInteractionViewportFake.Connect();
|
||||
|
||||
m_controllerList->Add(AZStd::make_shared<SandboxEditor::ViewportManipulatorController>());
|
||||
|
||||
// simulate a click, move, click
|
||||
MouseMove(m_rootWidget.get(), QPoint(0, 0), QPoint(10, 10));
|
||||
MousePressAndMove(m_rootWidget.get(), QPoint(10, 10), QPoint(0, 0), Qt::MouseButton::LeftButton);
|
||||
QTest::mouseRelease(m_rootWidget.get(), Qt::MouseButton::LeftButton, Qt::KeyboardModifier::NoModifier, QPoint(10, 10));
|
||||
MouseMove(m_rootWidget.get(), QPoint(10, 10), QPoint(20, 20));
|
||||
MousePressAndMove(m_rootWidget.get(), QPoint(20, 20), QPoint(0, 0), Qt::MouseButton::LeftButton);
|
||||
QTest::mouseRelease(m_rootWidget.get(), Qt::MouseButton::LeftButton, Qt::KeyboardModifier::NoModifier, QPoint(20, 20));
|
||||
|
||||
// ensure no double click was detected
|
||||
EXPECT_FALSE(doubleClickDetected);
|
||||
|
||||
// simulate double click (sanity check it still is detected correctly with no movement)
|
||||
MouseMove(m_rootWidget.get(), QPoint(0, 0), QPoint(10, 10));
|
||||
MousePressAndMove(m_rootWidget.get(), QPoint(10, 10), QPoint(0, 0), Qt::MouseButton::LeftButton);
|
||||
QTest::mouseRelease(m_rootWidget.get(), Qt::MouseButton::LeftButton, Qt::KeyboardModifier::NoModifier, QPoint(10, 10));
|
||||
MousePressAndMove(m_rootWidget.get(), QPoint(10, 10), QPoint(0, 0), Qt::MouseButton::LeftButton);
|
||||
QTest::mouseRelease(m_rootWidget.get(), Qt::MouseButton::LeftButton, Qt::KeyboardModifier::NoModifier, QPoint(10, 10));
|
||||
|
||||
// ensure a double click was detected
|
||||
EXPECT_TRUE(doubleClickDetected);
|
||||
|
||||
mockWindowRequests.Disconnect();
|
||||
editorInteractionViewportFake.Disconnect();
|
||||
}
|
||||
} // namespace UnitTest
|
||||
|
||||
+17
-32
@@ -519,7 +519,7 @@ MainWindow* MainWindow::instance()
|
||||
|
||||
void MainWindow::closeEvent(QCloseEvent* event)
|
||||
{
|
||||
gSettings.Save();
|
||||
gSettings.Save(true);
|
||||
|
||||
AzFramework::SystemCursorState currentCursorState;
|
||||
bool isInGameMode = false;
|
||||
@@ -576,7 +576,6 @@ void MainWindow::closeEvent(QCloseEvent* event)
|
||||
}
|
||||
// Close all edit panels.
|
||||
GetIEditor()->ClearSelection();
|
||||
GetIEditor()->GetObjectManager()->EndEditParams();
|
||||
|
||||
// force clean up of all deferred deletes, so that we don't have any issues with windows from plugins not being deleted yet
|
||||
qApp->sendPostedEvents(nullptr, QEvent::DeferredDelete);
|
||||
@@ -708,14 +707,10 @@ void MainWindow::InitActions()
|
||||
.SetShortcut(QKeySequence::Undo)
|
||||
.SetReserved()
|
||||
.SetStatusTip(tr("Undo last operation"))
|
||||
//.SetMenu(new QMenu("FIXME"))
|
||||
.SetApplyHoverEffect()
|
||||
.RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdateUndo);
|
||||
am->AddAction(ID_REDO, tr("&Redo"))
|
||||
.SetShortcut(AzQtComponents::RedoKeySequence)
|
||||
.SetReserved()
|
||||
//.SetMenu(new QMenu("FIXME"))
|
||||
.SetApplyHoverEffect()
|
||||
.SetStatusTip(tr("Redo last undo operation"))
|
||||
.RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdateRedo);
|
||||
|
||||
@@ -731,7 +726,6 @@ void MainWindow::InitActions()
|
||||
// Modify actions
|
||||
am->AddAction(AzToolsFramework::EditModeMove, tr("Move"))
|
||||
.SetIcon(Style::icon("Move"))
|
||||
.SetApplyHoverEffect()
|
||||
.SetShortcut(tr("1"))
|
||||
.SetToolTip(tr("Move (1)"))
|
||||
.SetCheckable(true)
|
||||
@@ -757,7 +751,6 @@ void MainWindow::InitActions()
|
||||
});
|
||||
am->AddAction(AzToolsFramework::EditModeRotate, tr("Rotate"))
|
||||
.SetIcon(Style::icon("Translate"))
|
||||
.SetApplyHoverEffect()
|
||||
.SetShortcut(tr("2"))
|
||||
.SetToolTip(tr("Rotate (2)"))
|
||||
.SetCheckable(true)
|
||||
@@ -783,7 +776,6 @@ void MainWindow::InitActions()
|
||||
});
|
||||
am->AddAction(AzToolsFramework::EditModeScale, tr("Scale"))
|
||||
.SetIcon(Style::icon("Scale"))
|
||||
.SetApplyHoverEffect()
|
||||
.SetShortcut(tr("3"))
|
||||
.SetToolTip(tr("Scale (3)"))
|
||||
.SetCheckable(true)
|
||||
@@ -808,7 +800,6 @@ void MainWindow::InitActions()
|
||||
|
||||
am->AddAction(AzToolsFramework::SnapToGrid, tr("Snap to grid"))
|
||||
.SetIcon(Style::icon("Grid"))
|
||||
.SetApplyHoverEffect()
|
||||
.SetShortcut(tr("G"))
|
||||
.SetToolTip(tr("Snap to grid (G)"))
|
||||
.SetStatusTip(tr("Toggles snap to grid"))
|
||||
@@ -821,7 +812,6 @@ void MainWindow::InitActions()
|
||||
|
||||
am->AddAction(AzToolsFramework::SnapAngle, tr("Snap angle"))
|
||||
.SetIcon(Style::icon("Angle"))
|
||||
.SetApplyHoverEffect()
|
||||
.SetStatusTip(tr("Snap angle"))
|
||||
.SetCheckable(true)
|
||||
.RegisterUpdateCallback([](QAction* action) {
|
||||
@@ -939,29 +929,28 @@ void MainWindow::InitActions()
|
||||
.Connect(&QAction::triggered, this, &MainWindow::OnRefreshAudioSystem);
|
||||
|
||||
// Game actions
|
||||
am->AddAction(ID_VIEW_SWITCHTOGAME, tr("Play &Game"))
|
||||
am->AddAction(ID_VIEW_SWITCHTOGAME, tr("Play Game"))
|
||||
.SetIcon(QIcon(":/stylesheet/img/UI20/toolbar/Play.svg"))
|
||||
.SetToolTip(tr("Play Game"))
|
||||
.SetStatusTip(tr("Activate the game input mode"))
|
||||
.SetCheckable(true)
|
||||
.RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdatePlayGame);
|
||||
am->AddAction(ID_VIEW_SWITCHTOGAME_VIEWPORT, tr("Play Game"))
|
||||
.SetShortcut(tr("Ctrl+G"))
|
||||
.SetToolTip(tr("Play Game (Ctrl+G)"))
|
||||
.SetStatusTip(tr("Activate the game input mode"))
|
||||
.SetApplyHoverEffect()
|
||||
.SetCheckable(true)
|
||||
.RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdatePlayGame);
|
||||
am->AddAction(ID_VIEW_SWITCHTOGAME_FULLSCREEN, tr("Play &Game (Maximized)"))
|
||||
am->AddAction(ID_VIEW_SWITCHTOGAME_FULLSCREEN, tr("Play Game (Maximized)"))
|
||||
.SetShortcut(tr("Ctrl+Shift+G"))
|
||||
.SetStatusTip(tr("Activate the game input mode (maximized)"))
|
||||
.SetIcon(Style::icon("Play"))
|
||||
.SetApplyHoverEffect()
|
||||
.SetCheckable(true);
|
||||
.RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdatePlayGame);
|
||||
am->AddAction(ID_TOOLBAR_WIDGET_PLAYCONSOLE_LABEL, tr("Play Controls"))
|
||||
.SetText(tr("Play Controls"));
|
||||
am->AddAction(ID_SWITCH_PHYSICS, tr("Simulate"))
|
||||
.SetIcon(QIcon(":/stylesheet/img/UI20/toolbar/Simulate_Physics.svg"))
|
||||
.SetShortcut(tr("Ctrl+P"))
|
||||
.SetToolTip(tr("Simulate (Ctrl+P)"))
|
||||
.SetCheckable(true)
|
||||
.SetStatusTip(tr("Enable processing of Physics and AI."))
|
||||
.SetApplyHoverEffect()
|
||||
.SetCheckable(true)
|
||||
.RegisterUpdateCallback(cryEdit, &CCryEditApp::OnSwitchPhysicsUpdate);
|
||||
am->AddAction(ID_GAME_SYNCPLAYER, tr("Move Player and Camera Separately")).SetCheckable(true)
|
||||
@@ -1051,8 +1040,7 @@ void MainWindow::InitActions()
|
||||
|
||||
// Editors Toolbar actions
|
||||
am->AddAction(ID_OPEN_ASSET_BROWSER, tr("Asset browser"))
|
||||
.SetToolTip(tr("Open Asset Browser"))
|
||||
.SetApplyHoverEffect();
|
||||
.SetToolTip(tr("Open Asset Browser"));
|
||||
|
||||
AZ::EBusReduceResult<bool, AZStd::logical_or<bool>> emfxEnabled(false);
|
||||
using AnimationRequestBus = AzToolsFramework::EditorAnimationSystemRequestsBus;
|
||||
@@ -1062,8 +1050,7 @@ void MainWindow::InitActions()
|
||||
{
|
||||
QAction* action = am->AddAction(ID_OPEN_EMOTIONFX_EDITOR, tr("Animation Editor"))
|
||||
.SetToolTip(tr("Open Animation Editor"))
|
||||
.SetIcon(QIcon(":/EMotionFX/EMFX_icon_32x32.png"))
|
||||
.SetApplyHoverEffect();
|
||||
.SetIcon(QIcon(":/EMotionFX/EMFX_icon_32x32.png"));
|
||||
QObject::connect(action, &QAction::triggered, this, []() {
|
||||
QtViewPaneManager::instance()->OpenPane(LyViewPane::AnimationEditor);
|
||||
});
|
||||
@@ -1071,12 +1058,10 @@ void MainWindow::InitActions()
|
||||
|
||||
am->AddAction(ID_OPEN_AUDIO_CONTROLS_BROWSER, tr("Audio Controls Editor"))
|
||||
.SetToolTip(tr("Open Audio Controls Editor"))
|
||||
.SetIcon(Style::icon("Audio"))
|
||||
.SetApplyHoverEffect();
|
||||
.SetIcon(Style::icon("Audio"));
|
||||
|
||||
am->AddAction(ID_OPEN_UICANVASEDITOR, tr(LyViewPane::UiEditor))
|
||||
.SetToolTip(tr("Open UI Editor"))
|
||||
.SetApplyHoverEffect();
|
||||
.SetToolTip(tr("Open UI Editor"));
|
||||
|
||||
// Edit Mode Toolbar Actions
|
||||
am->AddAction(IDC_SELECTION_MASK, tr("Selected Object Types"));
|
||||
@@ -1089,12 +1074,10 @@ void MainWindow::InitActions()
|
||||
// Object Toolbar Actions
|
||||
am->AddAction(ID_GOTO_SELECTED, tr("Go to selected object"))
|
||||
.SetIcon(Style::icon("select_object"))
|
||||
.SetApplyHoverEffect()
|
||||
.Connect(&QAction::triggered, this, &MainWindow::OnGotoSelected);
|
||||
|
||||
// Misc Toolbar Actions
|
||||
am->AddAction(ID_OPEN_SUBSTANCE_EDITOR, tr("Open Substance Editor"))
|
||||
.SetApplyHoverEffect();
|
||||
am->AddAction(ID_OPEN_SUBSTANCE_EDITOR, tr("Open Substance Editor"));
|
||||
}
|
||||
|
||||
void MainWindow::InitToolActionHandlers()
|
||||
@@ -1266,7 +1249,9 @@ void MainWindow::OnGameModeChanged(bool inGameMode)
|
||||
// block signals on the switch to game actions before setting the checked state, as
|
||||
// setting the checked state triggers the action, which will re-enter this function
|
||||
// and result in an infinite loop
|
||||
AZStd::vector<QAction*> actions = { m_actionManager->GetAction(ID_VIEW_SWITCHTOGAME), m_actionManager->GetAction(ID_VIEW_SWITCHTOGAME_FULLSCREEN) };
|
||||
AZStd::vector<QAction*> actions = { m_actionManager->GetAction(ID_VIEW_SWITCHTOGAME_VIEWPORT),
|
||||
m_actionManager->GetAction(ID_VIEW_SWITCHTOGAME_FULLSCREEN),
|
||||
m_actionManager->GetAction(ID_VIEW_SWITCHTOGAME)};
|
||||
for (auto action : actions)
|
||||
{
|
||||
action->blockSignals(true);
|
||||
|
||||
@@ -329,7 +329,6 @@ bool CAxisGizmo::MouseCallback(CViewport* view, EMouseEvent event, QPoint& point
|
||||
hc.b2DViewport = view->GetType() != ET_ViewportCamera;
|
||||
hc.point2d = point;
|
||||
view->ViewToWorldRay(point, hc.raySrc, hc.rayDir);
|
||||
bool bHit = false;
|
||||
if (HitTest(hc))
|
||||
{
|
||||
switch (hc.manipulatorMode)
|
||||
@@ -344,7 +343,6 @@ bool CAxisGizmo::MouseCallback(CViewport* view, EMouseEvent event, QPoint& point
|
||||
view->SetCurrentCursor(STD_CURSOR_SCALE);
|
||||
break;
|
||||
}
|
||||
bHit = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,8 +33,6 @@
|
||||
#include "ViewManager.h"
|
||||
#include "IEditorImpl.h"
|
||||
#include "GameEngine.h"
|
||||
#include <IEntityRenderState.h>
|
||||
#include <IStatObj.h>
|
||||
// To use the Andrew's algorithm in order to make convex hull from the points, this header is needed.
|
||||
#include "Util/GeometryUtil.h"
|
||||
|
||||
@@ -53,18 +51,16 @@ class CUndoBaseObject
|
||||
: public IUndoObject
|
||||
{
|
||||
public:
|
||||
CUndoBaseObject(CBaseObject* pObj, const char* undoDescription);
|
||||
CUndoBaseObject(CBaseObject* pObj);
|
||||
|
||||
protected:
|
||||
int GetSize() override { return sizeof(*this); }
|
||||
QString GetDescription() override { return m_undoDescription; };
|
||||
QString GetObjectName() override;
|
||||
|
||||
void Undo(bool bUndo) override;
|
||||
void Redo() override;
|
||||
|
||||
protected:
|
||||
QString m_undoDescription;
|
||||
GUID m_guid;
|
||||
XmlNodeRef m_undo;
|
||||
XmlNodeRef m_redo;
|
||||
@@ -77,11 +73,10 @@ class CUndoBaseObjectMinimal
|
||||
: public IUndoObject
|
||||
{
|
||||
public:
|
||||
CUndoBaseObjectMinimal(CBaseObject* obj, const char* undoDescription, int flags);
|
||||
CUndoBaseObjectMinimal(CBaseObject* obj, int flags);
|
||||
|
||||
protected:
|
||||
int GetSize() override { return sizeof(*this); }
|
||||
QString GetDescription() override { return m_undoDescription; };
|
||||
QString GetObjectName() override;
|
||||
|
||||
void Undo(bool bUndo) override;
|
||||
@@ -101,7 +96,6 @@ private:
|
||||
void SetTransformsFromState(CBaseObject* pObject, const StateStruct& state, bool bUndo);
|
||||
|
||||
GUID m_guid;
|
||||
QString m_undoDescription;
|
||||
StateStruct m_undoState;
|
||||
StateStruct m_redoState;
|
||||
};
|
||||
@@ -167,7 +161,6 @@ private:
|
||||
}
|
||||
|
||||
int GetSize() override { return sizeof(CUndoAttachBaseObject); }
|
||||
QString GetDescription() override { return "Attachment Changed"; }
|
||||
|
||||
GUID m_attachedObjectGUID;
|
||||
GUID m_parentObjectGUID;
|
||||
@@ -176,11 +169,10 @@ private:
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
CUndoBaseObject::CUndoBaseObject(CBaseObject* obj, const char* undoDescription)
|
||||
CUndoBaseObject::CUndoBaseObject(CBaseObject* obj)
|
||||
{
|
||||
// Stores the current state of this object.
|
||||
assert(obj != 0);
|
||||
m_undoDescription = undoDescription;
|
||||
m_guid = obj->GetId();
|
||||
|
||||
m_redo = nullptr;
|
||||
@@ -254,11 +246,10 @@ void CUndoBaseObject::Redo()
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
CUndoBaseObjectMinimal::CUndoBaseObjectMinimal(CBaseObject* pObj, const char* undoDescription, [[maybe_unused]] int flags)
|
||||
CUndoBaseObjectMinimal::CUndoBaseObjectMinimal(CBaseObject* pObj, [[maybe_unused]] int flags)
|
||||
{
|
||||
// Stores the current state of this object.
|
||||
assert(pObj != nullptr);
|
||||
m_undoDescription = undoDescription;
|
||||
m_guid = pObj->GetId();
|
||||
|
||||
ZeroStruct(m_redoState);
|
||||
@@ -287,7 +278,7 @@ QString CUndoBaseObjectMinimal::GetObjectName()
|
||||
void CUndoBaseObjectMinimal::Undo(bool bUndo)
|
||||
{
|
||||
CBaseObject* pObject = GetIEditor()->GetObjectManager()->FindObject(m_guid);
|
||||
if (!pObject || pObject->GetType() == OBJTYPE_DUMMY)
|
||||
if (!pObject)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -316,7 +307,7 @@ void CUndoBaseObjectMinimal::Undo(bool bUndo)
|
||||
void CUndoBaseObjectMinimal::Redo()
|
||||
{
|
||||
CBaseObject* pObject = GetIEditor()->GetObjectManager()->FindObject(m_guid);
|
||||
if (!pObject || pObject->GetType() == OBJTYPE_DUMMY)
|
||||
if (!pObject)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -382,7 +373,6 @@ CBaseObject::CBaseObject()
|
||||
, m_rotate(IDENTITY)
|
||||
, m_scale(1, 1, 1)
|
||||
, m_guid(GUID_NULL)
|
||||
, m_floorNumber(-1)
|
||||
, m_flags(0)
|
||||
, m_nTextureIcon(0)
|
||||
, m_color(QColor(255, 255, 255))
|
||||
@@ -398,11 +388,9 @@ CBaseObject::CBaseObject()
|
||||
, m_bMatrixInWorldSpace(false)
|
||||
, m_bMatrixValid(false)
|
||||
, m_bWorldBoxValid(false)
|
||||
, m_nMaterialLayersMask(0)
|
||||
, m_nMinSpec(0)
|
||||
, m_vDrawIconPos(0, 0, 0)
|
||||
, m_nIconFlags(0)
|
||||
, m_hideOrder(CBaseObject::s_invalidHiddenID)
|
||||
{
|
||||
m_worldBounds.min.Set(0, 0, 0);
|
||||
m_worldBounds.max.Set(0, 0, 0);
|
||||
@@ -431,7 +419,6 @@ bool CBaseObject::Init([[maybe_unused]] IEditor* ie, CBaseObject* prev, [[maybe_
|
||||
SetLocalTM(prev->GetPos(), prev->GetRotation(), prev->GetScale());
|
||||
SetArea(prev->GetArea());
|
||||
SetColor(prev->GetColor());
|
||||
m_nMaterialLayersMask = prev->m_nMaterialLayersMask;
|
||||
SetMinSpec(prev->GetMinSpec(), false);
|
||||
|
||||
// Copy all basic variables.
|
||||
@@ -488,7 +475,7 @@ void CBaseObject::SetName(const QString& name)
|
||||
return;
|
||||
}
|
||||
|
||||
StoreUndo("Name");
|
||||
StoreUndo();
|
||||
|
||||
// Notification is expensive and not required if this is during construction.
|
||||
bool notify = (!m_name.isEmpty());
|
||||
@@ -500,7 +487,6 @@ void CBaseObject::SetName(const QString& name)
|
||||
if (notify)
|
||||
{
|
||||
NotifyListeners(ON_RENAME);
|
||||
static_cast<CObjectManager*>(GetIEditor()->GetObjectManager())->NotifyObjectListeners(this, ON_RENAME);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -529,47 +515,6 @@ const QString& CBaseObject::GetName() const
|
||||
return m_name;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
QString CBaseObject::GetWarningsText() const
|
||||
{
|
||||
QString warnings;
|
||||
|
||||
if (gSettings.viewports.bShowScaleWarnings)
|
||||
{
|
||||
const EScaleWarningLevel scaleWarningLevel = GetScaleWarningLevel();
|
||||
if (scaleWarningLevel == eScaleWarningLevel_Rescaled)
|
||||
{
|
||||
warnings += "\\n Warning: Object Scale is not 100%.";
|
||||
}
|
||||
else if (scaleWarningLevel == eScaleWarningLevel_RescaledNonUniform)
|
||||
{
|
||||
warnings += "\\n Warning: Object has non-uniform scale.";
|
||||
}
|
||||
}
|
||||
|
||||
if (gSettings.viewports.bShowRotationWarnings)
|
||||
{
|
||||
const ERotationWarningLevel rotationWarningLevel = GetRotationWarningLevel();
|
||||
|
||||
if (rotationWarningLevel == eRotationWarningLevel_Rotated)
|
||||
{
|
||||
warnings += "\\n Warning: Object is rotated.";
|
||||
}
|
||||
else if (rotationWarningLevel == eRotationWarningLevel_RotatedNonRectangular)
|
||||
{
|
||||
warnings += "\\n Warning: Object is rotated non-orthogonally.";
|
||||
}
|
||||
}
|
||||
|
||||
return warnings;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CBaseObject::IsSameClass(CBaseObject* obj)
|
||||
{
|
||||
return GetClassDesc() == obj->GetClassDesc();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CBaseObject::SetPos(const Vec3& pos, int flags)
|
||||
{
|
||||
@@ -615,7 +560,7 @@ bool CBaseObject::SetPos(const Vec3& pos, int flags)
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
if (!bPositionDelegated && (flags & eObjectUpdateFlags_RestoreUndo) == 0 && (flags & eObjectUpdateFlags_Animated) == 0)
|
||||
{
|
||||
StoreUndo("Position", true, flags);
|
||||
StoreUndo(true, flags);
|
||||
}
|
||||
|
||||
if (!bPositionDelegated)
|
||||
@@ -659,7 +604,7 @@ bool CBaseObject::SetRotation(const Quat& rotate, int flags)
|
||||
|
||||
if (!bRotationDelegated && (flags & eObjectUpdateFlags_RestoreUndo) == 0 && (flags & eObjectUpdateFlags_Animated) == 0)
|
||||
{
|
||||
StoreUndo("Rotate", true, flags);
|
||||
StoreUndo(true, flags);
|
||||
}
|
||||
|
||||
if (!bRotationDelegated)
|
||||
@@ -704,7 +649,7 @@ bool CBaseObject::SetScale(const Vec3& scale, int flags)
|
||||
|
||||
if (!bScaleDelegated && (flags & eObjectUpdateFlags_RestoreUndo) == 0 && (flags & eObjectUpdateFlags_Animated) == 0)
|
||||
{
|
||||
StoreUndo("Scale", true, flags);
|
||||
StoreUndo(true, flags);
|
||||
}
|
||||
|
||||
if (!bScaleDelegated)
|
||||
@@ -763,7 +708,7 @@ void CBaseObject::ChangeColor(const QColor& color)
|
||||
return;
|
||||
}
|
||||
|
||||
StoreUndo("Color", true);
|
||||
StoreUndo(true);
|
||||
|
||||
SetColor(color);
|
||||
SetModified(false);
|
||||
@@ -783,7 +728,7 @@ void CBaseObject::SetArea(float area)
|
||||
return;
|
||||
}
|
||||
|
||||
StoreUndo("Area", true);
|
||||
StoreUndo(true);
|
||||
|
||||
m_flattenArea = area;
|
||||
SetModified(false);
|
||||
@@ -953,14 +898,8 @@ void CBaseObject::DrawTextureIcon(DisplayContext& dc, [[maybe_unused]] const Vec
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CBaseObject::DrawWarningIcons(DisplayContext& dc, const Vec3& pos)
|
||||
void CBaseObject::DrawWarningIcons(DisplayContext& dc, const Vec3&)
|
||||
{
|
||||
// Don't draw warning icons if they are beyond draw distance
|
||||
if ((dc.camera->GetPosition() - pos).GetLength() > gSettings.viewports.fWarningIconsDrawDistance)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (gSettings.viewports.bShowIcons || gSettings.viewports.bShowSizeBasedIcons)
|
||||
{
|
||||
const int warningIconSizeX = OBJECT_TEXTURE_ICON_SIZEX / 2;
|
||||
@@ -1010,11 +949,8 @@ void CBaseObject::DrawLabel(DisplayContext& dc, const Vec3& pos, const QColor& l
|
||||
labelColor = QColor(0, 0, 0);
|
||||
}
|
||||
|
||||
float camDist = dc.camera->GetPosition().GetDistance(pos);
|
||||
float maxDist = dc.settings->GetLabelsDistance();
|
||||
if (camDist < dc.settings->GetLabelsDistance() || (dc.flags & DISPLAY_SELECTION_HELPERS))
|
||||
if (dc.flags & DISPLAY_SELECTION_HELPERS)
|
||||
{
|
||||
float range = maxDist / 2.0f;
|
||||
Vec3 c(static_cast<f32>(labelColor.redF()), static_cast<f32>(labelColor.greenF()), static_cast<f32>(labelColor.redF()));
|
||||
if (IsSelected())
|
||||
{
|
||||
@@ -1032,10 +968,6 @@ void CBaseObject::DrawLabel(DisplayContext& dc, const Vec3& pos, const QColor& l
|
||||
col[1] = c.y;
|
||||
col[2] = c.z;
|
||||
}
|
||||
else if (camDist > range)
|
||||
{
|
||||
col[3] = col[3] * (1.0f - (camDist - range) / range);
|
||||
}
|
||||
|
||||
dc.SetColor(col[0], col[1], col[2], col[3] * alpha);
|
||||
dc.DrawTextLabel(pos, size, GetName().toUtf8().data());
|
||||
@@ -1196,74 +1128,6 @@ bool CBaseObject::CanBeDrawn(const DisplayContext& dc, bool& outDisplaySelection
|
||||
return bResult;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CBaseObject::IsInCameraView(const CCamera& camera)
|
||||
{
|
||||
AABB bbox;
|
||||
GetBoundBox(bbox);
|
||||
return (camera.IsAABBVisible_F(AABB(bbox.min, bbox.max)));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
float CBaseObject::GetCameraVisRatio(const CCamera& camera)
|
||||
{
|
||||
AABB bbox;
|
||||
GetBoundBox(bbox);
|
||||
|
||||
static const float defaultVisRatio = 1000.0f;
|
||||
|
||||
const float objectHeightSq = max(1.0f, (bbox.max - bbox.min).GetLengthSquared());
|
||||
const float camdistSq = (bbox.min - camera.GetPosition()).GetLengthSquared();
|
||||
float visRatio = defaultVisRatio;
|
||||
if (camdistSq > FLT_EPSILON)
|
||||
{
|
||||
visRatio = objectHeightSq / camdistSq;
|
||||
}
|
||||
|
||||
return visRatio;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
int CBaseObject::MouseCreateCallback(CViewport* view, EMouseEvent event, QPoint& point, int flags)
|
||||
{
|
||||
AZ_PROFILE_FUNCTION(Editor);
|
||||
|
||||
if (event == eMouseMove || event == eMouseLDown)
|
||||
{
|
||||
Vec3 pos;
|
||||
if (GetIEditor()->GetAxisConstrains() != AXIS_TERRAIN)
|
||||
{
|
||||
pos = view->MapViewToCP(point);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Snap to terrain.
|
||||
bool hitTerrain;
|
||||
pos = view->ViewToWorld(point, &hitTerrain);
|
||||
if (hitTerrain)
|
||||
{
|
||||
pos.z = GetIEditor()->GetTerrainElevation(pos.x, pos.y) + 1.0f;
|
||||
}
|
||||
pos = view->SnapToGrid(pos);
|
||||
}
|
||||
SetPos(pos);
|
||||
|
||||
if (event == eMouseLDown)
|
||||
{
|
||||
return MOUSECREATE_OK;
|
||||
}
|
||||
}
|
||||
|
||||
if (event == eMouseWheel)
|
||||
{
|
||||
float angle = 1;
|
||||
Quat rot = GetRotation();
|
||||
rot.SetRotationXYZ(Ang3(0.f, 0.f, rot.GetRotZ() + DEG2RAD(flags > 0 ? angle * (-1) : angle)));
|
||||
SetRotation(rot);
|
||||
}
|
||||
return MOUSECREATE_CONTINUE;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CBaseObject::OnEvent(ObjectEvent event)
|
||||
{
|
||||
@@ -1277,18 +1141,13 @@ void CBaseObject::OnEvent(ObjectEvent event)
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CBaseObject::SetShared([[maybe_unused]] bool bShared)
|
||||
{
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CBaseObject::SetHidden(bool bHidden, uint64 hiddenID, bool bAnimated)
|
||||
void CBaseObject::SetHidden(bool bHidden, bool bAnimated)
|
||||
{
|
||||
if (CheckFlags(OBJFLAG_HIDDEN) != bHidden)
|
||||
{
|
||||
if (!bAnimated)
|
||||
{
|
||||
StoreUndo("Hide Object");
|
||||
StoreUndo();
|
||||
}
|
||||
|
||||
if (bHidden)
|
||||
@@ -1300,7 +1159,6 @@ void CBaseObject::SetHidden(bool bHidden, uint64 hiddenID, bool bAnimated)
|
||||
ClearFlags(OBJFLAG_HIDDEN);
|
||||
}
|
||||
|
||||
m_hideOrder = hiddenID;
|
||||
UpdateVisibility(!IsHidden());
|
||||
}
|
||||
}
|
||||
@@ -1310,7 +1168,7 @@ void CBaseObject::SetFrozen(bool bFrozen)
|
||||
{
|
||||
if (CheckFlags(OBJFLAG_FROZEN) != bFrozen)
|
||||
{
|
||||
StoreUndo("Freeze Object");
|
||||
StoreUndo();
|
||||
if (bFrozen)
|
||||
{
|
||||
SetFlags(OBJFLAG_FROZEN);
|
||||
@@ -1396,14 +1254,6 @@ void CBaseObject::Serialize(CObjectArchive& ar)
|
||||
if (ar.bLoading)
|
||||
{
|
||||
// Loading.
|
||||
if (ar.ShouldResetInternalMembers())
|
||||
{
|
||||
m_flags = 0;
|
||||
m_flattenArea = 0.0f;
|
||||
m_nMinSpec = 0;
|
||||
m_scale.Set(1.0f, 1.0f, 1.0f);
|
||||
}
|
||||
|
||||
int flags = 0;
|
||||
int oldFlags = m_flags;
|
||||
|
||||
@@ -1443,7 +1293,6 @@ void CBaseObject::Serialize(CObjectArchive& ar)
|
||||
xmlNode->getAttr("LookAt", lookatId);
|
||||
xmlNode->getAttr("Material", mtlName);
|
||||
xmlNode->getAttr("MinSpec", nMinSpec);
|
||||
xmlNode->getAttr("FloorNumber", m_floorNumber);
|
||||
|
||||
if (nMinSpec <= CONFIG_VERYHIGH_SPEC) // Ignore invalid values.
|
||||
{
|
||||
@@ -1507,18 +1356,6 @@ void CBaseObject::Serialize(CObjectArchive& ar)
|
||||
SetModified(false);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
if (ar.bUndo)
|
||||
{
|
||||
// If we are selected update UI Panel.
|
||||
xmlNode->getAttr("HideOrder", m_hideOrder);
|
||||
}
|
||||
|
||||
// We reseted the min spec and deserialized it so set it internally
|
||||
if (ar.ShouldResetInternalMembers())
|
||||
{
|
||||
SetMinSpec(m_nMinSpec);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1530,7 +1367,6 @@ void CBaseObject::Serialize(CObjectArchive& ar)
|
||||
xmlNode->setAttr("Id", m_guid);
|
||||
|
||||
xmlNode->setAttr("Name", GetName().toUtf8().data());
|
||||
xmlNode->setAttr("HideOrder", m_hideOrder);
|
||||
|
||||
if (m_parent)
|
||||
{
|
||||
@@ -1547,8 +1383,6 @@ void CBaseObject::Serialize(CObjectArchive& ar)
|
||||
xmlNode->setAttr("Pos", GetPos());
|
||||
}
|
||||
|
||||
xmlNode->setAttr("FloorNumber", m_floorNumber);
|
||||
|
||||
xmlNode->setAttr("Rotate", m_rotate);
|
||||
|
||||
if (!IsEquivalent(GetScale(), Vec3(1, 1, 1), 0))
|
||||
@@ -1641,13 +1475,8 @@ CBaseObject* CBaseObject::FindObject(REFGUID id) const
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CBaseObject::StoreUndo(const char* UndoDescription, bool minimal, int flags)
|
||||
void CBaseObject::StoreUndo(bool minimal, int flags)
|
||||
{
|
||||
if (m_objType == OBJTYPE_DUMMY)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Don't use Sandbox undo for AZ entities, except for the move & scale tools, which rely on it.
|
||||
const bool isGizmoTool = 0 != (flags & (eObjectUpdateFlags_MoveTool | eObjectUpdateFlags_ScaleTool | eObjectUpdateFlags_UserInput));
|
||||
if (!isGizmoTool && 0 != (m_flags & OBJFLAG_DONT_SAVE))
|
||||
@@ -1659,28 +1488,18 @@ void CBaseObject::StoreUndo(const char* UndoDescription, bool minimal, int flags
|
||||
{
|
||||
if (minimal)
|
||||
{
|
||||
CUndo::Record(new CUndoBaseObjectMinimal(this, UndoDescription, flags));
|
||||
CUndo::Record(new CUndoBaseObjectMinimal(this, flags));
|
||||
}
|
||||
else
|
||||
{
|
||||
CUndo::Record(new CUndoBaseObject(this, UndoDescription));
|
||||
CUndo::Record(new CUndoBaseObject(this));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CBaseObject::IsCreateGameObjects() const
|
||||
{
|
||||
return GetObjectManager()->IsCreateGameObjects();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
QString CBaseObject::GetTypeName() const
|
||||
{
|
||||
if (m_objType == OBJTYPE_DUMMY)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
QString className = m_classDesc->ClassName();
|
||||
QString subClassName = strstr(className.toUtf8().data(), "::");
|
||||
if (subClassName.isEmpty())
|
||||
@@ -1689,7 +1508,7 @@ QString CBaseObject::GetTypeName() const
|
||||
}
|
||||
|
||||
QString name;
|
||||
name.append(className.mid(0, className.length() - subClassName.length()));
|
||||
name.append(className.midRef(0, className.length() - subClassName.length()));
|
||||
return name;
|
||||
}
|
||||
|
||||
@@ -1941,85 +1760,6 @@ bool CBaseObject::HitTestRect(HitContext& hc)
|
||||
return bHit;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CBaseObject::HitHelperTest(HitContext& hc)
|
||||
{
|
||||
return HitHelperAtTest(hc, GetWorldPos());
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CBaseObject::HitHelperAtTest(HitContext& hc, const Vec3& pos)
|
||||
{
|
||||
AZ_PROFILE_FUNCTION(Editor);
|
||||
|
||||
bool bResult = false;
|
||||
|
||||
if (m_nTextureIcon && (gSettings.viewports.bShowIcons || gSettings.viewports.bShowSizeBasedIcons) && !hc.bUseSelectionHelpers)
|
||||
{
|
||||
int iconSizeX = OBJECT_TEXTURE_ICON_SIZEX;
|
||||
int iconSizeY = OBJECT_TEXTURE_ICON_SIZEY;
|
||||
|
||||
if (gSettings.viewports.bDistanceScaleIcons)
|
||||
{
|
||||
float fScreenScale = hc.view->GetScreenScaleFactor(pos);
|
||||
|
||||
iconSizeX = static_cast<int>(static_cast<float>(iconSizeX) * OBJECT_TEXTURE_ICON_SCALE / fScreenScale);
|
||||
iconSizeY = static_cast<int>(static_cast<float>(iconSizeY) * OBJECT_TEXTURE_ICON_SCALE / fScreenScale);
|
||||
}
|
||||
|
||||
// Hit Test icon of this object.
|
||||
Vec3 testPos = pos;
|
||||
int y0 = -(iconSizeY / 2);
|
||||
int y1 = +(iconSizeY / 2);
|
||||
if (CheckFlags(OBJFLAG_SHOW_ICONONTOP))
|
||||
{
|
||||
Vec3 objectPos = GetWorldPos();
|
||||
|
||||
AABB box;
|
||||
GetBoundBox(box);
|
||||
testPos.z = (pos.z - objectPos.z) + box.max.z;
|
||||
y0 = -(iconSizeY);
|
||||
y1 = 0;
|
||||
}
|
||||
QPoint pnt = hc.view->WorldToView(testPos);
|
||||
|
||||
if (hc.point2d.x() >= pnt.x() - (iconSizeX / 2) && hc.point2d.x() <= pnt.x() + (iconSizeX / 2) &&
|
||||
hc.point2d.y() >= pnt.y() + y0 && hc.point2d.y() <= pnt.y() + y1)
|
||||
{
|
||||
hc.dist = hc.raySrc.GetDistance(testPos) - 0.2f;
|
||||
hc.iconHit = true;
|
||||
bResult = true;
|
||||
}
|
||||
}
|
||||
else if (hc.bUseSelectionHelpers)
|
||||
{
|
||||
// Check potentially children first
|
||||
bResult = HitHelperTestForChildObjects(hc);
|
||||
|
||||
// If no hit check this object
|
||||
if (!bResult)
|
||||
{
|
||||
// Hit test helper.
|
||||
Vec3 w = pos - hc.raySrc;
|
||||
w = hc.rayDir.Cross(w);
|
||||
float d = w.GetLengthSquared();
|
||||
|
||||
static const float screenScaleToRadiusFactor = 0.008f;
|
||||
const float radius = hc.view->GetScreenScaleFactor(pos) * screenScaleToRadiusFactor;
|
||||
const float pickDistance = hc.raySrc.GetDistance(pos);
|
||||
if (d < radius * radius + hc.distanceTolerance && hc.dist >= pickDistance)
|
||||
{
|
||||
hc.dist = pickDistance;
|
||||
hc.object = this;
|
||||
bResult = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return bResult;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
CBaseObject* CBaseObject::GetChild(size_t const i) const
|
||||
{
|
||||
@@ -2027,47 +1767,6 @@ CBaseObject* CBaseObject::GetChild(size_t const i) const
|
||||
return m_childs[i];
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CBaseObject::IsChildOf(CBaseObject* node)
|
||||
{
|
||||
CBaseObject* p = m_parent;
|
||||
while (p && p != node)
|
||||
{
|
||||
p = p->m_parent;
|
||||
}
|
||||
if (p == node)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CBaseObject::CloneChildren(CBaseObject* pFromObject)
|
||||
{
|
||||
if (pFromObject == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (size_t i = 0, nChildCount(pFromObject->GetChildCount()); i < nChildCount; ++i)
|
||||
{
|
||||
CBaseObject* pFromChildObject = pFromObject->GetChild(i);
|
||||
|
||||
CBaseObject* pChildClone = GetObjectManager()->CloneObject(pFromChildObject);
|
||||
if (pChildClone == nullptr)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
pChildClone->CloneChildren(pFromChildObject);
|
||||
AddMember(pChildClone, false);
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CBaseObject::AttachChild(CBaseObject* child, bool bKeepPos)
|
||||
{
|
||||
@@ -2084,7 +1783,6 @@ void CBaseObject::AttachChild(CBaseObject* child, bool bKeepPos)
|
||||
return;
|
||||
}
|
||||
|
||||
static_cast<CObjectManager*>(GetObjectManager())->NotifyObjectListeners(child, ON_PREATTACHED);
|
||||
child->NotifyListeners(bKeepPos ? ON_PREATTACHEDKEEPXFORM : ON_PREATTACHED);
|
||||
|
||||
pTransformDelegate = m_pTransformDelegate;
|
||||
@@ -2129,7 +1827,6 @@ void CBaseObject::AttachChild(CBaseObject* child, bool bKeepPos)
|
||||
m_pTransformDelegate = pTransformDelegate;
|
||||
child->m_pTransformDelegate = pChildTransformDelegate;
|
||||
|
||||
static_cast<CObjectManager*>(GetObjectManager())->NotifyObjectListeners(child, ON_ATTACHED);
|
||||
child->NotifyListeners(ON_ATTACHED);
|
||||
|
||||
NotifyListeners(ON_CHILDATTACHED);
|
||||
@@ -2167,7 +1864,6 @@ void CBaseObject::DetachThis(bool bKeepPos)
|
||||
|
||||
{
|
||||
CScopedSuspendUndo suspendUndo;
|
||||
static_cast<CObjectManager*>(GetObjectManager())->NotifyObjectListeners(this, ON_PREDETACHED);
|
||||
NotifyListeners(bKeepPos ? ON_PREDETACHEDKEEPXFORM : ON_PREDETACHED);
|
||||
|
||||
pTransformDelegate = m_pTransformDelegate;
|
||||
@@ -2198,7 +1894,6 @@ void CBaseObject::DetachThis(bool bKeepPos)
|
||||
|
||||
SetTransformDelegate(pTransformDelegate);
|
||||
|
||||
static_cast<CObjectManager*>(GetObjectManager())->NotifyObjectListeners(this, ON_DETACHED);
|
||||
NotifyListeners(ON_DETACHED);
|
||||
}
|
||||
}
|
||||
@@ -2302,12 +1997,6 @@ Matrix34 CBaseObject::GetParentAttachPointWorldTM() const
|
||||
return Matrix34(IDENTITY);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CBaseObject::IsParentAttachmentValid() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CBaseObject::InvalidateTM([[maybe_unused]] int flags)
|
||||
{
|
||||
@@ -2458,7 +2147,7 @@ void CBaseObject::SetLookAt(CBaseObject* target)
|
||||
return;
|
||||
}
|
||||
|
||||
StoreUndo("Change LookAt");
|
||||
StoreUndo();
|
||||
|
||||
if (m_lookat)
|
||||
{
|
||||
@@ -2583,63 +2272,6 @@ void CBaseObject::Validate(IErrorReport* report)
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
Ang3 CBaseObject::GetWorldAngles() const
|
||||
{
|
||||
if (m_scale == Vec3(1, 1, 1))
|
||||
{
|
||||
Quat q = Quat(GetWorldTM());
|
||||
Ang3 angles = RAD2DEG(Ang3::GetAnglesXYZ(Matrix33(q)));
|
||||
return angles;
|
||||
}
|
||||
else
|
||||
{
|
||||
Matrix34 tm = GetWorldTM();
|
||||
tm.OrthonormalizeFast();
|
||||
Quat q = Quat(tm);
|
||||
Ang3 angles = RAD2DEG(Ang3::GetAnglesXYZ(Matrix33(q)));
|
||||
return angles;
|
||||
}
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CBaseObject::PostClone(CBaseObject* pFromObject, CObjectCloneContext& ctx)
|
||||
{
|
||||
CBaseObject* pFromParent = pFromObject->GetParent();
|
||||
if (pFromParent)
|
||||
{
|
||||
SetFloorNumber(pFromObject->GetFloorNumber());
|
||||
|
||||
CBaseObject* pFromParentInContext = ctx.FindClone(pFromParent);
|
||||
if (pFromParentInContext)
|
||||
{
|
||||
pFromParentInContext->AddMember(this, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
pFromParent->AddMember(this, false);
|
||||
}
|
||||
}
|
||||
if (pFromObject->ShouldCloneChildren())
|
||||
{
|
||||
for (int i = 0; i < pFromObject->GetChildCount(); i++)
|
||||
{
|
||||
CBaseObject* pChildObject = pFromObject->GetChild(i);
|
||||
CBaseObject* pClonedChild = GetObjectManager()->CloneObject(pChildObject);
|
||||
ctx.AddClone(pChildObject, pClonedChild);
|
||||
}
|
||||
for (int i = 0; i < pFromObject->GetChildCount(); i++)
|
||||
{
|
||||
CBaseObject* pChildObject = pFromObject->GetChild(i);
|
||||
CBaseObject* pClonedChild = ctx.FindClone(pChildObject);
|
||||
if (pClonedChild)
|
||||
{
|
||||
pClonedChild->PostClone(pChildObject, ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CBaseObject::GatherUsedResources(CUsedResources& resources)
|
||||
{
|
||||
@@ -2675,79 +2307,6 @@ void CBaseObject::SetMinSpec(uint32 nSpec, bool bSetChildren)
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CBaseObject::OnPropertyChanged(IVariable*)
|
||||
{
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CBaseObject::OnMultiSelPropertyChanged(IVariable*)
|
||||
{
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CBaseObject::OnMenuShowInAssetBrowser()
|
||||
{
|
||||
if (!IsSelected())
|
||||
{
|
||||
CUndo undo("Select Object");
|
||||
GetIEditor()->GetObjectManager()->ClearSelection();
|
||||
GetIEditor()->SelectObject(this);
|
||||
}
|
||||
|
||||
GetIEditor()->ExecuteCommand("asset_browser.show_viewport_selection");
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CBaseObject::OnContextMenu(QMenu* menu)
|
||||
{
|
||||
if (!menu->isEmpty())
|
||||
{
|
||||
menu->addSeparator();
|
||||
}
|
||||
CUsedResources resources;
|
||||
GatherUsedResources(resources);
|
||||
|
||||
static_cast<CEditorImpl*>(GetIEditor())->OnObjectContextMenuOpened(menu, this);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CBaseObject::IntersectRayMesh(const Vec3& raySrc, const Vec3& rayDir, SRayHitInfo& outHitInfo) const
|
||||
{
|
||||
const float fRenderMeshTestDistance = 0.2f;
|
||||
IRenderNode* pRenderNode = GetEngineNode();
|
||||
if (!pRenderNode)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Matrix34 worldTM;
|
||||
IStatObj* pStatObj = pRenderNode->GetEntityStatObj(0, 0, &worldTM);
|
||||
if (!pStatObj)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// transform decal into object space
|
||||
Matrix34 worldTM_Inverted = worldTM.GetInverted();
|
||||
Matrix33 worldRot(worldTM_Inverted);
|
||||
worldRot.Transpose();
|
||||
// put hit direction into the object space
|
||||
Vec3 vRayDir = rayDir.GetNormalized() * worldRot;
|
||||
// put hit position into the object space
|
||||
Vec3 vHitPos = worldTM_Inverted.TransformPoint(raySrc);
|
||||
Vec3 vLineP1 = vHitPos - vRayDir * fRenderMeshTestDistance;
|
||||
|
||||
memset(&outHitInfo, 0, sizeof(outHitInfo));
|
||||
outHitInfo.inReferencePoint = vHitPos;
|
||||
outHitInfo.inRay.origin = vLineP1;
|
||||
outHitInfo.inRay.direction = vRayDir;
|
||||
outHitInfo.bInFirstHit = false;
|
||||
outHitInfo.bUseCache = false;
|
||||
|
||||
return pStatObj->RayIntersection(outHitInfo, nullptr);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
EScaleWarningLevel CBaseObject::GetScaleWarningLevel() const
|
||||
{
|
||||
|
||||
@@ -35,8 +35,6 @@ struct SSubObjSelectionModifyContext;
|
||||
struct SRayHitInfo;
|
||||
class CPopupMenuItem;
|
||||
class QMenu;
|
||||
struct IRenderNode;
|
||||
struct IStatObj;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
typedef _smart_ptr<CBaseObject> CBaseObjectPtr;
|
||||
@@ -119,15 +117,6 @@ enum ObjectFlags
|
||||
|
||||
#define ERF_GET_WRITABLE(flags) (flags)
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//! This flags passed to CBaseObject::BeginEditParams method.
|
||||
enum ObjectEditFlags
|
||||
{
|
||||
OBJECT_CREATE = 0x001,
|
||||
OBJECT_EDIT = 0x002,
|
||||
OBJECT_COLLAPSE_OBJECTPANEL = 0x004
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//! Return values from CBaseObject::MouseCreateCallback method.
|
||||
enum MouseCreateResult
|
||||
@@ -137,19 +126,6 @@ enum MouseCreateResult
|
||||
MOUSECREATE_OK, //!< Accept this object.
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Interface to the object create with the mouse callback.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
struct IMouseCreateCallback
|
||||
{
|
||||
virtual void Release() = 0;
|
||||
virtual MouseCreateResult OnMouseEvent(CViewport* view, EMouseEvent event, QPoint& point, int flags) = 0;
|
||||
// Some process of creation need to be able to be displayed such as creation for custom solid.
|
||||
virtual void Display([[maybe_unused]] DisplayContext& dc){}
|
||||
// Called after accepting an object to see if new object creation mode should be continued.
|
||||
virtual bool ContinueCreation() = 0;
|
||||
};
|
||||
|
||||
// Flags used for object interaction
|
||||
enum EObjectUpdateFlags
|
||||
{
|
||||
@@ -261,22 +237,11 @@ public:
|
||||
|
||||
/** Check if both object are of same class.
|
||||
*/
|
||||
virtual bool IsSameClass(CBaseObject* obj);
|
||||
virtual void SetDefaultType() { m_objType = OBJTYPE_DUMMY; };
|
||||
virtual ObjectType GetType() const
|
||||
{
|
||||
if (m_objType == OBJTYPE_DUMMY)
|
||||
{
|
||||
return m_objType;
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_classDesc->GetObjectType();
|
||||
}
|
||||
return m_classDesc->GetObjectType();
|
||||
};
|
||||
// const char* GetTypeName() const { return m_classDesc->ClassName(); };
|
||||
QString GetTypeName() const;
|
||||
virtual QString GetTypeDescription() const { return m_classDesc->ClassName(); };
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Flags.
|
||||
@@ -289,8 +254,6 @@ public:
|
||||
// Hidden ID
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
static const uint64 s_invalidHiddenID = 0;
|
||||
uint64 GetHideOrder() const { return m_hideOrder; }
|
||||
void SetHideOrder(uint64 newID) { m_hideOrder = newID; }
|
||||
|
||||
//! Returns true if object hidden.
|
||||
bool IsHidden() const;
|
||||
@@ -307,26 +270,19 @@ public:
|
||||
virtual bool IsSelectable() const;
|
||||
|
||||
// Return texture icon.
|
||||
bool HaveTextureIcon() const { return m_nTextureIcon != 0; };
|
||||
int GetTextureIcon() const { return m_nTextureIcon; }
|
||||
void SetTextureIcon(int nTexIcon) { m_nTextureIcon = nTexIcon; }
|
||||
|
||||
//! Set shared between missions flag.
|
||||
virtual void SetShared(bool bShared);
|
||||
//! Set object hidden status.
|
||||
virtual void SetHidden(bool bHidden, uint64 hiddenId = CBaseObject::s_invalidHiddenID, bool bAnimated = false);
|
||||
virtual void SetHidden(bool bHidden, bool bAnimated = false);
|
||||
//! Set object frozen status.
|
||||
virtual void SetFrozen(bool bFrozen);
|
||||
//! Set object selected status.
|
||||
virtual void SetSelected(bool bSelect);
|
||||
//! Return associated 3DEngine render node
|
||||
virtual IRenderNode* GetEngineNode() const { return nullptr; };
|
||||
//! Set object highlighted (Note: not selected)
|
||||
virtual void SetHighlight(bool bHighlight);
|
||||
//! Check if object is highlighted.
|
||||
bool IsHighlighted() const { return CheckFlags(OBJFLAG_HIGHLIGHT); }
|
||||
//! Check if object can have measurement axises.
|
||||
virtual bool HasMeasurementAxis() const { return true; }
|
||||
//! Check if the object is isolated when the editor is in Isolation Mode
|
||||
virtual bool IsIsolated() const { return false; }
|
||||
|
||||
@@ -345,8 +301,6 @@ public:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//! Get name of object.
|
||||
const QString& GetName() const;
|
||||
virtual QString GetComment() const { return QString(); }
|
||||
virtual QString GetWarningsText() const;
|
||||
|
||||
//! Change name of object.
|
||||
virtual void SetName(const QString& name);
|
||||
@@ -376,10 +330,6 @@ public:
|
||||
//! Get object scale.
|
||||
const Vec3 GetScale() const;
|
||||
|
||||
virtual bool StartScaling() { return false; }
|
||||
virtual bool GetUntransformedScale([[maybe_unused]] Vec3& scale) const { return false; }
|
||||
virtual bool TransformScale([[maybe_unused]] const Vec3& scale) { return false; }
|
||||
|
||||
//! Set flatten area.
|
||||
void SetArea(float area);
|
||||
float GetArea() const { return m_flattenArea; };
|
||||
@@ -397,8 +347,6 @@ public:
|
||||
// CHILDS
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//! Return true if node have childs.
|
||||
bool HaveChilds() const { return !m_childs.empty(); }
|
||||
//! Return true if have attached childs.
|
||||
size_t GetChildCount() const { return m_childs.size(); }
|
||||
|
||||
@@ -406,10 +354,6 @@ public:
|
||||
CBaseObject* GetChild(size_t const i) const;
|
||||
//! Return parent node if exist.
|
||||
CBaseObject* GetParent() const { return m_parent; };
|
||||
//! Scans hierarchy up to determine if we child of specified node.
|
||||
virtual bool IsChildOf(CBaseObject* node);
|
||||
//! Clone Children
|
||||
void CloneChildren(CBaseObject* pFromObject);
|
||||
//! Attach new child node.
|
||||
//! @param bKeepPos if true Child node will keep its world space position.
|
||||
virtual void AttachChild(CBaseObject* child, bool bKeepPos = true);
|
||||
@@ -422,8 +366,6 @@ public:
|
||||
virtual void DetachAll(bool bKeepPos = true);
|
||||
// Detach this node from parent.
|
||||
virtual void DetachThis(bool bKeepPos = true);
|
||||
// Returns the link parent.
|
||||
virtual CBaseObject* GetLinkParent() const { return GetParent(); }
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// MATRIX
|
||||
@@ -437,15 +379,11 @@ public:
|
||||
// Gets matrix of parent attachment point
|
||||
virtual Matrix34 GetParentAttachPointWorldTM() const;
|
||||
|
||||
// Checks if the attachment point is valid
|
||||
virtual bool IsParentAttachmentValid() const;
|
||||
|
||||
//! Set position in world space.
|
||||
virtual void SetWorldPos(const Vec3& pos, int flags = 0);
|
||||
|
||||
//! Get position in world space.
|
||||
Vec3 GetWorldPos() const { return GetWorldTM().GetTranslation(); };
|
||||
Ang3 GetWorldAngles() const;
|
||||
|
||||
//! Set xform of object given in world space.
|
||||
virtual void SetWorldTM(const Matrix34& tm, int flags = 0);
|
||||
@@ -460,12 +398,6 @@ public:
|
||||
// Interface to be implemented in plugins.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//! Called when object is being created (use GetMouseCreateCallback for more advanced mouse creation callback).
|
||||
virtual int MouseCreateCallback(CViewport* view, EMouseEvent event, QPoint& point, int flags);
|
||||
// Return pointer to the callback object used when creating object by the mouse.
|
||||
// If this function return nullptr MouseCreateCallback method will be used instead.
|
||||
virtual IMouseCreateCallback* GetMouseCreateCallback() { return nullptr; };
|
||||
|
||||
//! Draw object to specified viewport.
|
||||
virtual void Display([[maybe_unused]] DisplayContext& disp) {}
|
||||
|
||||
@@ -477,10 +409,6 @@ public:
|
||||
//! Return true if was hit.
|
||||
virtual bool HitTestRect(HitContext& hc);
|
||||
|
||||
//! Perform intersection testing of this object based on its icon helper.
|
||||
//! Return true if was hit.
|
||||
virtual bool HitHelperTest(HitContext& hc);
|
||||
|
||||
//! Get bounding box of object in world coordinate space.
|
||||
virtual void GetBoundBox(AABB& box);
|
||||
|
||||
@@ -500,8 +428,6 @@ public:
|
||||
//! @param bUndo true if loading or saving data for Undo/Redo purposes.
|
||||
virtual void Serialize(CObjectArchive& ar);
|
||||
|
||||
//// Pre load called before serialize after all objects where completly loaded.
|
||||
//virtual void PreLoad( CObjectArchive &ar ) {};
|
||||
// Post load called after all objects where completely loaded.
|
||||
virtual void PostLoad([[maybe_unused]] CObjectArchive& ar) {};
|
||||
|
||||
@@ -513,9 +439,6 @@ public:
|
||||
//! Override in derived classes, to handle specific events.
|
||||
virtual void OnEvent(ObjectEvent event);
|
||||
|
||||
//! Generate dynamic context menu for the object
|
||||
virtual void OnContextMenu(QMenu* menu);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// LookAt Target.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -523,13 +446,11 @@ public:
|
||||
CBaseObject* GetLookAt() const { return m_lookat; };
|
||||
//! Returns true if this object is a look-at target.
|
||||
bool IsLookAtTarget() const;
|
||||
CBaseObject* GetLookAtSource() const { return m_lookatSource; };
|
||||
|
||||
|
||||
IObjectManager* GetObjectManager() const;
|
||||
|
||||
//! Store undo information for this object.
|
||||
void StoreUndo(const char* undoDescription, bool minimal = false, int flags = 0);
|
||||
void StoreUndo(bool minimal = false, int flags = 0);
|
||||
|
||||
//! Add event listener callback.
|
||||
void AddEventListener(EventListener* listener);
|
||||
@@ -548,52 +469,21 @@ public:
|
||||
//! Check if specified object is very similar to this one.
|
||||
virtual bool IsSimilarObject(CBaseObject* pObject);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Material Layers Mask.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
virtual void SetMaterialLayersMask(uint32 nLayersMask) { m_nMaterialLayersMask = nLayersMask; }
|
||||
uint32 GetMaterialLayersMask() const { return m_nMaterialLayersMask; };
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Object minimal usage spec (All/Low/Medium/High)
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
uint32 GetMinSpec() const { return m_nMinSpec; }
|
||||
virtual void SetMinSpec(uint32 nSpec, bool bSetChildren = true);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// SubObj selection.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Return true if object support selecting of this sub object element type.
|
||||
virtual bool StartSubObjSelection([[maybe_unused]] int elemType) { return false; };
|
||||
virtual void EndSubObjectSelection() {};
|
||||
virtual void ModifySubObjSelection([[maybe_unused]] SSubObjSelectionModifyContext& modCtx) {};
|
||||
virtual void AcceptSubObjectModify() {};
|
||||
|
||||
//! In This function variables of the object must be initialized.
|
||||
virtual void InitVariables() {};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Procedural Floor Management.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
int GetFloorNumber() const { return m_floorNumber; };
|
||||
void SetFloorNumber(int floorNumber) { m_floorNumber = floorNumber; };
|
||||
|
||||
virtual void OnPropertyChanged(IVariable*);
|
||||
virtual void OnMultiSelPropertyChanged(IVariable*);
|
||||
|
||||
//! Draw a reddish highlight indicating its budget usage.
|
||||
virtual void DrawBudgetUsage(DisplayContext& dc, const QColor& color);
|
||||
|
||||
bool IntersectRayMesh(const Vec3& raySrc, const Vec3& rayDir, SRayHitInfo& outHitInfo) const;
|
||||
|
||||
virtual void EditTags([[maybe_unused]] bool alwaysTag) {}
|
||||
virtual bool SupportsEditTags() const { return false; }
|
||||
|
||||
bool CanBeHightlighted() const;
|
||||
bool IsSkipSelectionHelper() const;
|
||||
|
||||
virtual IStatObj* GetIStatObj() { return nullptr; }
|
||||
|
||||
// Invalidates cached transformation matrix.
|
||||
// nWhyFlags - Flags that indicate the reason for matrix invalidation.
|
||||
virtual void InvalidateTM(int nWhyFlags);
|
||||
@@ -612,26 +502,14 @@ protected:
|
||||
//! Optional file parameter specify initial object or script for this object.
|
||||
virtual bool Init(IEditor* ie, CBaseObject* prev, const QString& file);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//! Must be called after cloning the object on clone of object.
|
||||
//! This will make sure object references are cloned correctly.
|
||||
virtual void PostClone(CBaseObject* pFromObject, CObjectCloneContext& ctx);
|
||||
|
||||
//! Must be implemented by derived class to create game related objects.
|
||||
virtual bool CreateGameObject() { return true; };
|
||||
|
||||
//! If true, all attached chilren will be cloned when the parent object is cloned.
|
||||
virtual bool ShouldCloneChildren() const { return true; }
|
||||
|
||||
/** Called when object is about to be deleted.
|
||||
All Game resources should be freed in this function.
|
||||
All Game resources should be freed in this function.
|
||||
*/
|
||||
virtual void Done();
|
||||
|
||||
/** Change current id of object.
|
||||
*/
|
||||
//virtual void SetId( uint32 objectId ) { m_id = objectId; };
|
||||
|
||||
//! Call this to delete an object.
|
||||
virtual void DeleteThis() = 0;
|
||||
|
||||
@@ -674,11 +552,6 @@ protected:
|
||||
//! Returns if the object can be drawn, and if its selection helper should also be drawn.
|
||||
bool CanBeDrawn(const DisplayContext& dc, bool& outDisplaySelectionHelper) const;
|
||||
|
||||
//! Returns if object is in the camera view.
|
||||
virtual bool IsInCameraView(const CCamera& camera);
|
||||
//! Returns vis ratio of object in camera
|
||||
virtual float GetCameraVisRatio(const CCamera& camera);
|
||||
|
||||
// Do basic intersection tests
|
||||
virtual bool IntersectRectBounds(const AABB& bbox);
|
||||
virtual bool IntersectRayBounds(const Ray& ray);
|
||||
@@ -687,17 +560,11 @@ protected:
|
||||
// Function can be used by derived classes.
|
||||
bool HitTestRectBounds(HitContext& hc, const AABB& box);
|
||||
|
||||
// Do helper hit testing as specific location.
|
||||
bool HitHelperAtTest(HitContext& hc, const Vec3& pos);
|
||||
|
||||
// Do helper hit testing taking child objects into account (e.g. opened prefab)
|
||||
virtual bool HitHelperTestForChildObjects([[maybe_unused]] HitContext& hc) { return false; }
|
||||
|
||||
CBaseObject* FindObject(REFGUID id) const;
|
||||
|
||||
// Returns true if game objects should be created.
|
||||
bool IsCreateGameObjects() const;
|
||||
|
||||
// Helper gizmo functions.
|
||||
void AddGizmo(CGizmo* gizmo);
|
||||
void RemoveGizmo(CGizmo* gizmo);
|
||||
@@ -708,14 +575,6 @@ protected:
|
||||
//! Only used by ObjectManager.
|
||||
bool IsPotentiallyVisible() const;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// May be overridden in derived classes to handle helpers scaling.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
virtual void SetHelperScale([[maybe_unused]] float scale) {};
|
||||
virtual float GetHelperScale() { return 1.0f; };
|
||||
|
||||
void SetNameInternal(const QString& name) { m_name = name; }
|
||||
|
||||
void SetDrawTextureIconProperties(DisplayContext& dc, const Vec3& pos, float alpha = 1.0f, int texIconFlags = 0);
|
||||
const Vec3& GetTextureIconDrawPos(){ return m_vDrawIconPos; };
|
||||
int GetTextureIconFlags(){ return m_nIconFlags; };
|
||||
@@ -737,8 +596,6 @@ private:
|
||||
friend class CObjectArchive;
|
||||
friend class CSelectionGroup;
|
||||
|
||||
void OnMenuShowInAssetBrowser();
|
||||
|
||||
//! Set class description for this object,
|
||||
//! Only called once after creation by ObjectManager.
|
||||
void SetClassDesc(CObjectClassDesc* classDesc);
|
||||
@@ -746,9 +603,6 @@ private:
|
||||
EScaleWarningLevel GetScaleWarningLevel() const;
|
||||
ERotationWarningLevel GetRotationWarningLevel() const;
|
||||
|
||||
// auto resolving
|
||||
void OnMtlResolved(uint32 id, bool success, const char* orgName, const char* newName);
|
||||
|
||||
bool IsInSelectionBox() const { return m_bInSelectionBox; }
|
||||
|
||||
void SetId(REFGUID guid) { m_guid = guid; }
|
||||
@@ -771,13 +625,10 @@ private:
|
||||
//! Unique object Id.
|
||||
GUID m_guid;
|
||||
|
||||
// floor number of object if procedural object flag is set
|
||||
int m_floorNumber;
|
||||
|
||||
//! Flags of this object.
|
||||
int m_flags;
|
||||
|
||||
// Id of the texture icon for this object.
|
||||
//! Id of the texture icon for this object.
|
||||
int m_nTextureIcon;
|
||||
|
||||
//! Display color.
|
||||
@@ -828,13 +679,10 @@ private:
|
||||
mutable uint32 m_bMatrixValid : 1;
|
||||
mutable uint32 m_bWorldBoxValid : 1;
|
||||
uint32 m_bInSelectionBox : 1;
|
||||
uint32 m_nMaterialLayersMask : 8;
|
||||
uint32 m_nMinSpec : 8;
|
||||
|
||||
Vec3 m_vDrawIconPos;
|
||||
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
|
||||
uint64 m_hideOrder;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(CBaseObject*)
|
||||
|
||||
@@ -31,7 +31,6 @@ struct IRenderer;
|
||||
struct IRenderAuxGeom;
|
||||
struct IIconManager;
|
||||
class CDisplaySettings;
|
||||
class CCamera;
|
||||
class QPoint;
|
||||
|
||||
enum DisplayFlags
|
||||
@@ -66,7 +65,6 @@ struct SANDBOX_API DisplayContext
|
||||
IDisplayViewport* view;
|
||||
IRenderAuxGeom* pRenderAuxGeom;
|
||||
IIconManager* pIconManager;
|
||||
CCamera* camera;
|
||||
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
AABB box; // Bounding box of volume that need to be repainted.
|
||||
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
@@ -83,11 +81,38 @@ struct SANDBOX_API DisplayContext
|
||||
// Draw functions
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//! Set current materialc color.
|
||||
void SetColor(float r, float g, float b, float a = 1) { m_color4b = ColorB(static_cast<uint8>(r * 255.0f), static_cast<uint8>(g * 255.0f), static_cast<uint8>(b * 255.0f), static_cast<uint8>(a * 255.0f)); };
|
||||
void SetColor(const Vec3& color, float a = 1) { m_color4b = ColorB(static_cast<uint8>(color.x * 255.0f), static_cast<uint8>(color.y * 255.0f), static_cast<uint8>(color.z * 255.0f), static_cast<uint8>(a * 255.0f)); };
|
||||
void SetColor(const QColor& rgb, float a) { m_color4b = ColorB(static_cast<uint8>(rgb.red()), static_cast<uint8>(rgb.green()), static_cast<uint8>(rgb.blue()), static_cast<uint8>(a * 255.0f)); };
|
||||
void SetColor(const QColor& color) { m_color4b = ColorB(static_cast<uint8>(color.red()), static_cast<uint8>(color.green()), static_cast<uint8>(color.blue()), static_cast<uint8>(color.alpha())); };
|
||||
void SetColor(const ColorB& color) { m_color4b = color; };
|
||||
void SetColor(float r, float g, float b, float a = 1)
|
||||
{
|
||||
m_color4b = ColorB(
|
||||
static_cast<uint8>(r * 255.0f), static_cast<uint8>(g * 255.0f), static_cast<uint8>(b * 255.0f), static_cast<uint8>(a * 255.0f));
|
||||
};
|
||||
void SetColor(const Vec3& color, float a = 1)
|
||||
{
|
||||
m_color4b = ColorB(
|
||||
static_cast<uint8>(color.x * 255.0f), static_cast<uint8>(color.y * 255.0f), static_cast<uint8>(color.z * 255.0f),
|
||||
static_cast<uint8>(a * 255.0f));
|
||||
};
|
||||
void SetColor(const AZ::Vector3& color, float a = 1)
|
||||
{
|
||||
m_color4b = ColorB(
|
||||
static_cast<uint8>(color.GetX() * 255.0f), static_cast<uint8>(color.GetY() * 255.0f), static_cast<uint8>(color.GetZ() * 255.0f),
|
||||
static_cast<uint8>(a * 255.0f));
|
||||
};
|
||||
void SetColor(const QColor& rgb, float a)
|
||||
{
|
||||
m_color4b = ColorB(
|
||||
static_cast<uint8>(rgb.red()), static_cast<uint8>(rgb.green()), static_cast<uint8>(rgb.blue()), static_cast<uint8>(a * 255.0f));
|
||||
};
|
||||
void SetColor(const QColor& color)
|
||||
{
|
||||
m_color4b = ColorB(
|
||||
static_cast<uint8>(color.red()), static_cast<uint8>(color.green()), static_cast<uint8>(color.blue()),
|
||||
static_cast<uint8>(color.alpha()));
|
||||
};
|
||||
void SetColor(const ColorB& color)
|
||||
{
|
||||
m_color4b = color;
|
||||
};
|
||||
void SetAlpha(float a = 1) { m_color4b.a = static_cast<uint8>(a * 255.0f); };
|
||||
ColorB GetColor() const { return m_color4b; }
|
||||
|
||||
@@ -110,6 +135,7 @@ struct SANDBOX_API DisplayContext
|
||||
void DrawTrianglesIndexed(const AZStd::vector<Vec3>& vertices, const AZStd::vector<vtx_idx>& indices, const ColorB& color);
|
||||
// Draw wireframe box.
|
||||
void DrawWireBox(const Vec3& min, const Vec3& max);
|
||||
void DrawWireBox(const AZ::Vector3& min, const AZ::Vector3& max);
|
||||
// Draw filled box
|
||||
void DrawSolidBox(const Vec3& min, const Vec3& max);
|
||||
void DrawSolidOBB(const Vec3& center, const Vec3& axisX, const Vec3& axisY, const Vec3& axisZ, const Vec3& halfExtents);
|
||||
|
||||
@@ -225,6 +225,12 @@ void DisplayContext::DrawWireBox(const Vec3& min, const Vec3& max)
|
||||
pRenderAuxGeom->DrawAABB(AABB(min, max), m_matrixStack[m_currentMatrix], false, m_color4b, eBBD_Faceted);
|
||||
}
|
||||
|
||||
void DisplayContext::DrawWireBox(const AZ::Vector3& min, const AZ::Vector3& max)
|
||||
{
|
||||
pRenderAuxGeom->DrawAABB(
|
||||
AABB(Vec3(min.GetX(), min.GetY(), min.GetZ()), Vec3(max.GetX(), max.GetY(), max.GetZ())),
|
||||
m_matrixStack[m_currentMatrix], false, m_color4b, eBBD_Faceted);
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void DisplayContext::DrawSolidBox(const Vec3& min, const Vec3& max)
|
||||
{
|
||||
@@ -1138,10 +1144,6 @@ bool DisplayContext::IsVisible(const AABB& bounds)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return camera->IsAABBVisible_F(AABB(bounds.min, bounds.max));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,8 +28,7 @@
|
||||
#include "HitContext.h"
|
||||
#include "Objects/SelectionGroup.h"
|
||||
|
||||
#include <IEntityRenderState.h>
|
||||
#include <IStatObj.h>
|
||||
static constexpr int VIEW_DISTANCE_MULTIPLIER_MAX = 100;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//! Undo Entity Link
|
||||
@@ -58,7 +57,6 @@ public:
|
||||
protected:
|
||||
void Release() override { delete this; };
|
||||
int GetSize() override { return sizeof(*this); }; // Return size of xml state.
|
||||
QString GetDescription() override { return "Entity Link"; };
|
||||
QString GetObjectName() override{ return ""; };
|
||||
|
||||
void Undo([[maybe_unused]] bool bUndo) override
|
||||
@@ -139,7 +137,6 @@ private:
|
||||
}
|
||||
|
||||
int GetSize() override { return sizeof(CUndoAttachEntity); }
|
||||
QString GetDescription() override { return "Attachment Changed"; }
|
||||
|
||||
GUID m_attachedEntityGUID;
|
||||
CEntityObject::EAttachmentType m_attachmentType;
|
||||
@@ -151,8 +148,6 @@ private:
|
||||
// CBase implementation.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
float CEntityObject::m_helperScale = 1;
|
||||
|
||||
namespace
|
||||
{
|
||||
CEntityObject* s_pPropertyPanelEntityObject = nullptr;
|
||||
@@ -163,12 +158,9 @@ namespace
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
CEntityObject::CEntityObject()
|
||||
: m_listeners(1)
|
||||
{
|
||||
m_bLoadFailed = false;
|
||||
|
||||
m_visualObject = nullptr;
|
||||
|
||||
m_box.min.Set(0, 0, 0);
|
||||
m_box.max.Set(0, 0, 0);
|
||||
|
||||
@@ -223,7 +215,7 @@ CEntityObject::CEntityObject()
|
||||
mv_ratioLOD = 100;
|
||||
mv_viewDistanceMultiplier = 1.0f;
|
||||
mv_ratioLOD.SetLimits(0, 255);
|
||||
mv_viewDistanceMultiplier.SetLimits(0.0f, IRenderNode::VIEW_DISTANCE_MULTIPLIER_MAX);
|
||||
mv_viewDistanceMultiplier.SetLimits(0.0f, VIEW_DISTANCE_MULTIPLIER_MAX);
|
||||
|
||||
m_physicsState = nullptr;
|
||||
|
||||
@@ -247,7 +239,6 @@ CEntityObject::CEntityObject()
|
||||
m_onSetCallbacksCache.emplace_back([this](IVariable* var) { OnProjectInAllDirsChange(var); });
|
||||
m_onSetCallbacksCache.emplace_back([this](IVariable* var) { OnProjectorFOVChange(var); });
|
||||
m_onSetCallbacksCache.emplace_back([this](IVariable* var) { OnProjectorTextureChange(var); });
|
||||
m_onSetCallbacksCache.emplace_back([this](IVariable* var) { OnPropertyChange(var); });
|
||||
m_onSetCallbacksCache.emplace_back([this](IVariable* var) { OnRadiusChange(var); });
|
||||
}
|
||||
|
||||
@@ -295,11 +286,6 @@ void CEntityObject::Done()
|
||||
ReleaseEventTargets();
|
||||
RemoveAllEntityLinks();
|
||||
|
||||
for (CListenerSet<IEntityObjectListener*>::Notifier notifier(m_listeners); notifier.IsValid(); notifier.Next())
|
||||
{
|
||||
notifier->OnDone();
|
||||
}
|
||||
|
||||
CBaseObject::Done();
|
||||
}
|
||||
|
||||
@@ -365,12 +351,6 @@ void CEntityObject::SetTransformDelegate(ITransformDelegate* pTransformDelegate)
|
||||
ResetCallbacks();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CEntityObject::IsSameClass(CBaseObject* obj)
|
||||
{
|
||||
return (GetClassDesc() == obj->GetClassDesc());
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CEntityObject::ConvertFromObject(CBaseObject* object)
|
||||
{
|
||||
@@ -458,33 +438,10 @@ bool CEntityObject::HitTest(HitContext& hc)
|
||||
return false;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CEntityObject::HitHelperTest(HitContext& hc)
|
||||
{
|
||||
bool bResult = CBaseObject::HitHelperTest(hc);
|
||||
if (bResult)
|
||||
{
|
||||
hc.object = this;
|
||||
}
|
||||
|
||||
return bResult;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CEntityObject::HitTestRect(HitContext& hc)
|
||||
{
|
||||
bool bResult = false;
|
||||
|
||||
if (m_visualObject && !gSettings.viewports.bShowIcons && !gSettings.viewports.bShowSizeBasedIcons)
|
||||
{
|
||||
AABB box;
|
||||
box.SetTransformedAABB(GetWorldTM(), m_visualObject->GetAABB());
|
||||
bResult = HitTestRectBounds(hc, box);
|
||||
}
|
||||
else
|
||||
{
|
||||
bResult = CBaseObject::HitTestRect(hc);
|
||||
}
|
||||
bool bResult = CBaseObject::HitTestRect(hc);
|
||||
|
||||
if (bResult)
|
||||
{
|
||||
@@ -494,42 +451,6 @@ bool CEntityObject::HitTestRect(HitContext& hc)
|
||||
return bResult;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
int CEntityObject::MouseCreateCallback(CViewport* view, EMouseEvent event, QPoint& point, int flags)
|
||||
{
|
||||
AZ_PROFILE_FUNCTION(Entity);
|
||||
|
||||
if (event == eMouseMove || event == eMouseLDown)
|
||||
{
|
||||
Vec3 pos;
|
||||
// Rise Entity above ground on Bounding box amount.
|
||||
if (GetIEditor()->GetAxisConstrains() != AXIS_TERRAIN)
|
||||
{
|
||||
pos = view->MapViewToCP(point);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Snap to terrain.
|
||||
bool hitTerrain;
|
||||
pos = view->ViewToWorld(point, &hitTerrain);
|
||||
if (hitTerrain)
|
||||
{
|
||||
pos.z = GetIEditor()->GetTerrainElevation(pos.x, pos.y);
|
||||
pos.z = pos.z - m_box.min.z;
|
||||
}
|
||||
pos = view->SnapToGrid(pos);
|
||||
}
|
||||
SetPos(pos);
|
||||
|
||||
if (event == eMouseLDown)
|
||||
{
|
||||
return MOUSECREATE_OK;
|
||||
}
|
||||
return MOUSECREATE_CONTINUE;
|
||||
}
|
||||
return CBaseObject::MouseCreateCallback(view, event, point, flags);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
IVariable* CEntityObject::FindVariableInSubBlock(CVarBlockPtr& properties, IVariable* pSubBlockVar, const char* pVarName)
|
||||
{
|
||||
@@ -592,11 +513,11 @@ void CEntityObject::AdjustLightProperties(CVarBlockPtr& properties, const char*
|
||||
if (IVariable* pCastShadowVarLegacy = FindVariableInSubBlock(properties, pSubBlockVar, "bCastShadow"))
|
||||
{
|
||||
pCastShadowVarLegacy->SetFlags(pCastShadowVarLegacy->GetFlags() | IVariable::UI_INVISIBLE);
|
||||
|
||||
if (pCastShadowVarLegacy->GetDisplayValue()[0] != '0')
|
||||
const QString zeroPrefix("0");
|
||||
if (!pCastShadowVarLegacy->GetDisplayValue().startsWith(zeroPrefix))
|
||||
{
|
||||
bCastShadowLegacy = true;
|
||||
pCastShadowVarLegacy->SetDisplayValue("0");
|
||||
pCastShadowVarLegacy->SetDisplayValue(zeroPrefix);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -680,11 +601,6 @@ void CEntityObject::SetName(const QString& name)
|
||||
|
||||
CBaseObject::SetName(name);
|
||||
|
||||
CListenerSet<IEntityObjectListener*> listeners = m_listeners;
|
||||
for (CListenerSet<IEntityObjectListener*>::Notifier notifier(listeners); notifier.IsValid(); notifier.Next())
|
||||
{
|
||||
notifier->OnNameChanged(name.toUtf8().data());
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -697,19 +613,6 @@ void CEntityObject::SetSelected(bool bSelect)
|
||||
UpdateLightProperty();
|
||||
}
|
||||
|
||||
for (CListenerSet<IEntityObjectListener*>::Notifier notifier(m_listeners); notifier.IsValid(); notifier.Next())
|
||||
{
|
||||
notifier->OnSelectionChanged(bSelect);
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CEntityObject::OnPropertyChange([[maybe_unused]] IVariable* var)
|
||||
{
|
||||
if (s_ignorePropertiesUpdate)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@@ -941,11 +844,9 @@ void CEntityObject::Serialize(CObjectArchive& ar)
|
||||
m_eventTargets.emplace_back(AZStd::move(et));
|
||||
if (targetId != GUID_NULL)
|
||||
{
|
||||
using namespace AZStd::placeholders;
|
||||
ar.SetResolveCallback(
|
||||
this, targetId,
|
||||
[this](CBaseObject* object, unsigned int index) { ResolveEventTarget(object, index); },
|
||||
i);
|
||||
[this,i](CBaseObject* object) { ResolveEventTarget(object, i); });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -956,11 +857,7 @@ void CEntityObject::Serialize(CObjectArchive& ar)
|
||||
QString attachmentType;
|
||||
xmlNode->getAttr("AttachmentType", attachmentType);
|
||||
|
||||
if (attachmentType == "GeomCacheNode")
|
||||
{
|
||||
m_attachmentType = eAT_GeomCacheNode;
|
||||
}
|
||||
else if (attachmentType == "CharacterBone")
|
||||
if (attachmentType == "CharacterBone")
|
||||
{
|
||||
m_attachmentType = eAT_CharacterBone;
|
||||
}
|
||||
@@ -987,11 +884,7 @@ void CEntityObject::Serialize(CObjectArchive& ar)
|
||||
{
|
||||
if (m_attachmentType != eAT_Pivot)
|
||||
{
|
||||
if (m_attachmentType == eAT_GeomCacheNode)
|
||||
{
|
||||
xmlNode->setAttr("AttachmentType", "GeomCacheNode");
|
||||
}
|
||||
else if (m_attachmentType == eAT_CharacterBone)
|
||||
if (m_attachmentType == eAT_CharacterBone)
|
||||
{
|
||||
xmlNode->setAttr("AttachmentType", "CharacterBone");
|
||||
}
|
||||
@@ -1091,11 +984,7 @@ XmlNodeRef CEntityObject::Export([[maybe_unused]] const QString& levelPath, XmlN
|
||||
objNode->setAttr("ParentId", parentEntity->GetEntityId());
|
||||
if (m_attachmentType != eAT_Pivot)
|
||||
{
|
||||
if (m_attachmentType == eAT_GeomCacheNode)
|
||||
{
|
||||
objNode->setAttr("AttachmentType", "GeomCacheNode");
|
||||
}
|
||||
else if (m_attachmentType == eAT_CharacterBone)
|
||||
if (m_attachmentType == eAT_CharacterBone)
|
||||
{
|
||||
objNode->setAttr("AttachmentType", "CharacterBone");
|
||||
}
|
||||
@@ -1166,12 +1055,6 @@ XmlNodeRef CEntityObject::Export([[maybe_unused]] const QString& levelPath, XmlN
|
||||
objNode->setAttr("MinSpec", ( uint32 )GetMinSpec());
|
||||
}
|
||||
|
||||
uint32 nMtlLayersMask = GetMaterialLayersMask();
|
||||
if (nMtlLayersMask != 0)
|
||||
{
|
||||
objNode->setAttr("MatLayersMask", nMtlLayersMask);
|
||||
}
|
||||
|
||||
if (mv_hiddenInGame)
|
||||
{
|
||||
objNode->setAttr("HiddenInGame", true);
|
||||
@@ -1268,11 +1151,6 @@ void CEntityObject::OnEvent(ObjectEvent event)
|
||||
|
||||
case EVENT_CONFIG_SPEC_CHANGE:
|
||||
{
|
||||
IObjectManager* objMan = GetIEditor()->GetObjectManager();
|
||||
if (objMan && objMan->IsLightClass(this))
|
||||
{
|
||||
OnPropertyChange(nullptr);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@@ -1362,56 +1240,6 @@ QString CEntityObject::GetLightAnimation() const
|
||||
return "";
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CEntityObject::PostClone(CBaseObject* pFromObject, CObjectCloneContext& ctx)
|
||||
{
|
||||
CBaseObject::PostClone(pFromObject, ctx);
|
||||
|
||||
CEntityObject* pFromEntity = ( CEntityObject* )pFromObject;
|
||||
// Clone event targets.
|
||||
if (!pFromEntity->m_eventTargets.empty())
|
||||
{
|
||||
size_t numTargets = pFromEntity->m_eventTargets.size();
|
||||
for (size_t i = 0; i < numTargets; i++)
|
||||
{
|
||||
CEntityEventTarget& et = pFromEntity->m_eventTargets[i];
|
||||
CBaseObject* pClonedTarget = ctx.FindClone(et.target);
|
||||
if (!pClonedTarget)
|
||||
{
|
||||
pClonedTarget = et.target; // If target not cloned, link to original target.
|
||||
}
|
||||
|
||||
// Add cloned event.
|
||||
AddEventTarget(pClonedTarget, et.event, et.sourceEvent, true);
|
||||
}
|
||||
}
|
||||
|
||||
// Clone links.
|
||||
if (!pFromEntity->m_links.empty())
|
||||
{
|
||||
int numTargets = static_cast<int>(pFromEntity->m_links.size());
|
||||
for (int i = 0; i < numTargets; i++)
|
||||
{
|
||||
CEntityLink& et = pFromEntity->m_links[i];
|
||||
CBaseObject* pClonedTarget = ctx.FindClone(et.target);
|
||||
if (!pClonedTarget)
|
||||
{
|
||||
pClonedTarget = et.target; // If target not cloned, link to original target.
|
||||
}
|
||||
|
||||
// Add cloned event.
|
||||
if (pClonedTarget)
|
||||
{
|
||||
AddEntityLink(et.name, pClonedTarget->GetId());
|
||||
}
|
||||
else
|
||||
{
|
||||
AddEntityLink(et.name, GUID_NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CEntityObject::ResolveEventTarget(CBaseObject* object, unsigned int index)
|
||||
{
|
||||
@@ -1566,7 +1394,7 @@ void CEntityObject::OnObjectEvent(CBaseObject* target, int event)
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
int CEntityObject::AddEventTarget(CBaseObject* target, const QString& event, const QString& sourceEvent, [[maybe_unused]] bool bUpdateScript)
|
||||
{
|
||||
StoreUndo("Add EventTarget");
|
||||
StoreUndo();
|
||||
CEntityEventTarget et;
|
||||
et.target = target;
|
||||
et.event = event;
|
||||
@@ -1600,7 +1428,7 @@ void CEntityObject::RemoveEventTarget(int index, [[maybe_unused]] bool bUpdateSc
|
||||
{
|
||||
if (index >= 0 && index < m_eventTargets.size())
|
||||
{
|
||||
StoreUndo("Remove EventTarget");
|
||||
StoreUndo();
|
||||
|
||||
if (m_eventTargets[index].pLineGizmo)
|
||||
{
|
||||
@@ -1636,7 +1464,7 @@ int CEntityObject::AddEntityLink(const QString& name, GUID targetEntityId)
|
||||
}
|
||||
}
|
||||
|
||||
StoreUndo("Add EntityLink");
|
||||
StoreUndo();
|
||||
|
||||
CLineGizmo* pLineGizmo = nullptr;
|
||||
|
||||
@@ -1684,7 +1512,7 @@ void CEntityObject::RemoveEntityLink(int index)
|
||||
if (index >= 0 && index < m_links.size())
|
||||
{
|
||||
CEntityLink& link = m_links[index];
|
||||
StoreUndo("Remove EntityLink");
|
||||
StoreUndo();
|
||||
|
||||
if (link.pLineGizmo)
|
||||
{
|
||||
@@ -1707,7 +1535,7 @@ void CEntityObject::RenameEntityLink(int index, const QString& newName)
|
||||
{
|
||||
if (index >= 0 && index < m_links.size())
|
||||
{
|
||||
StoreUndo("Rename EntityLink");
|
||||
StoreUndo();
|
||||
|
||||
if (m_links[index].pLineGizmo)
|
||||
{
|
||||
@@ -1854,18 +1682,6 @@ void CEntityObject::OnLoadFailed()
|
||||
GetIEditor()->GetErrorReport()->ReportError(err);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CEntityObject::SetHelperScale(float scale)
|
||||
{
|
||||
m_helperScale = scale;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
float CEntityObject::GetHelperScale()
|
||||
{
|
||||
return m_helperScale;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//! Analyze errors for this object.
|
||||
void CEntityObject::Validate(IErrorReport* report)
|
||||
@@ -1913,19 +1729,6 @@ bool CEntityObject::IsSimilarObject(CBaseObject* pObject)
|
||||
return false;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CEntityObject::OnContextMenu(QMenu* pMenu)
|
||||
{
|
||||
if (!pMenu->isEmpty())
|
||||
{
|
||||
pMenu->addSeparator();
|
||||
}
|
||||
|
||||
// Events
|
||||
|
||||
CBaseObject::OnContextMenu(pMenu);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CEntityObject::PreInitLightProperty()
|
||||
{
|
||||
@@ -2183,16 +1986,6 @@ void CEntityObject::StoreUndoEntityLink(CSelectionGroup* pGroup)
|
||||
}
|
||||
}
|
||||
|
||||
void CEntityObject::RegisterListener(IEntityObjectListener* pListener)
|
||||
{
|
||||
m_listeners.Add(pListener);
|
||||
}
|
||||
|
||||
void CEntityObject::UnregisterListener(IEntityObjectListener* pListener)
|
||||
{
|
||||
m_listeners.Remove(pListener);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T CEntityObject::GetEntityProperty(const char* pName, T defaultvalue) const
|
||||
{
|
||||
|
||||
@@ -16,10 +16,7 @@
|
||||
#include "BaseObject.h"
|
||||
|
||||
#include "IMovieSystem.h"
|
||||
#include "IEntityObjectListener.h"
|
||||
#include "Gizmo.h"
|
||||
#include "CryListenerSet.h"
|
||||
#include "StatObjBus.h"
|
||||
|
||||
#include <QObject>
|
||||
#endif
|
||||
@@ -81,11 +78,6 @@ public:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Overrides from CBaseObject.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//! Return type name of Entity.
|
||||
QString GetTypeDescription() const override { return GetEntityClass(); };
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool IsSameClass(CBaseObject* obj) override;
|
||||
|
||||
bool Init(IEditor* ie, CBaseObject* prev, const QString& file) override;
|
||||
void InitVariables() override;
|
||||
@@ -102,16 +94,12 @@ public:
|
||||
void SetEntityPropertyFloat(const char* name, float value);
|
||||
void SetEntityPropertyString(const char* name, const QString& value);
|
||||
|
||||
int MouseCreateCallback(CViewport* view, EMouseEvent event, QPoint& point, int flags) override;
|
||||
void OnContextMenu(QMenu* menu) override;
|
||||
|
||||
void SetName(const QString& name) override;
|
||||
void SetSelected(bool bSelect) override;
|
||||
|
||||
void GetLocalBounds(AABB& box) override;
|
||||
|
||||
bool HitTest(HitContext& hc) override;
|
||||
bool HitHelperTest(HitContext& hc) override;
|
||||
bool HitTestRect(HitContext& hc) override;
|
||||
void UpdateVisibility(bool bVisible) override;
|
||||
bool ConvertFromObject(CBaseObject* object) override;
|
||||
@@ -131,7 +119,6 @@ public:
|
||||
enum EAttachmentType
|
||||
{
|
||||
eAT_Pivot,
|
||||
eAT_GeomCacheNode,
|
||||
eAT_CharacterBone,
|
||||
};
|
||||
|
||||
@@ -140,14 +127,9 @@ public:
|
||||
EAttachmentType GetAttachType() const { return m_attachmentType; }
|
||||
QString GetAttachTarget() const { return m_attachmentTarget; }
|
||||
|
||||
void SetHelperScale(float scale) override;
|
||||
float GetHelperScale() override;
|
||||
|
||||
void GatherUsedResources(CUsedResources& resources) override;
|
||||
bool IsSimilarObject(CBaseObject* pObject) override;
|
||||
|
||||
bool HasMeasurementAxis() const override { return false; }
|
||||
|
||||
bool IsIsolated() const override { return false; }
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -221,20 +203,12 @@ public:
|
||||
|
||||
static void StoreUndoEntityLink(CSelectionGroup* pGroup);
|
||||
|
||||
void RegisterListener(IEntityObjectListener* pListener);
|
||||
void UnregisterListener(IEntityObjectListener* pListener);
|
||||
|
||||
protected:
|
||||
template <typename T>
|
||||
void SetEntityProperty(const char* name, T value);
|
||||
template <typename T>
|
||||
T GetEntityProperty(const char* name, T defaultvalue) const;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//! Must be called after cloning the object on clone of object.
|
||||
//! This will make sure object references are cloned correctly.
|
||||
void PostClone(CBaseObject* pFromObject, CObjectCloneContext& ctx) override;
|
||||
|
||||
//! Draw default object items.
|
||||
void DrawProjectorPyramid(DisplayContext& dc, float dist);
|
||||
void DrawProjectorFrustum(DisplayContext& dc, Vec2 size, float dist);
|
||||
@@ -243,10 +217,6 @@ protected:
|
||||
|
||||
CVarBlock* CloneProperties(CVarBlock* srcProperties);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//! Callback called when one of entity properties have been modified.
|
||||
void OnPropertyChange(IVariable* var);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void OnObjectEvent(CBaseObject* target, int event) override;
|
||||
void ResolveEventTarget(CBaseObject* object, unsigned int index);
|
||||
@@ -328,7 +298,6 @@ protected:
|
||||
// Used for light entities
|
||||
float m_projectorFOV;
|
||||
|
||||
IStatObj* m_visualObject;
|
||||
AABB m_box;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -389,8 +358,6 @@ protected:
|
||||
XmlNodeRef m_physicsState;
|
||||
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
|
||||
static float m_helperScale;
|
||||
|
||||
EAttachmentType m_attachmentType;
|
||||
|
||||
bool m_bEnableReload;
|
||||
@@ -434,7 +401,6 @@ private:
|
||||
void ForceVariableUpdate();
|
||||
|
||||
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
CListenerSet<IEntityObjectListener*> m_listeners;
|
||||
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
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
class IEntityObjectListener
|
||||
{
|
||||
public:
|
||||
virtual ~IEntityObjectListener() = default;
|
||||
|
||||
virtual void OnNameChanged(const char* pName) = 0;
|
||||
virtual void OnSelectionChanged(const bool bSelected) = 0;
|
||||
virtual void OnDone() = 0;
|
||||
};
|
||||
|
||||
@@ -98,16 +98,8 @@ void CLineGizmo::Display(DisplayContext& dc)
|
||||
Vec3 pos = 0.5f * (m_point[0] + m_point[1]);
|
||||
//dc.renderer->DrawLabelEx( p3+Vec3(0,0,0.3f),1.2f,col,true,true,m_name );
|
||||
|
||||
float camDist = dc.camera->GetPosition().GetDistance(pos);
|
||||
float maxDist = dc.settings->GetLabelsDistance();
|
||||
if (camDist < dc.settings->GetLabelsDistance())
|
||||
{
|
||||
float range = maxDist / 2.0f;
|
||||
float col[4] = { m_color[0].r, m_color[0].g, m_color[0].b, m_color[0].a };
|
||||
if (camDist > range)
|
||||
{
|
||||
col[3] = col[3] * (1.0f - (camDist - range) / range);
|
||||
}
|
||||
dc.SetColor(col[0], col[1], col[2], col[3]);
|
||||
dc.DrawTextLabel(pos + Vec3(0, 0, 0.2f), 1.2f, m_name.toUtf8().data());
|
||||
}
|
||||
|
||||
@@ -28,19 +28,12 @@ CObjectArchive::CObjectArchive(IObjectManager* objMan, XmlNodeRef xmlRoot, bool
|
||||
m_nFlags = 0;
|
||||
node = xmlRoot;
|
||||
m_pCurrentErrorReport = GetIEditor()->GetErrorReport();
|
||||
m_pGeometryPak = nullptr;
|
||||
m_pCurrentObject = nullptr;
|
||||
m_bNeedResolveObjects = false;
|
||||
m_bProgressBarEnabled = true;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
CObjectArchive::~CObjectArchive()
|
||||
{
|
||||
if (m_pGeometryPak)
|
||||
{
|
||||
delete m_pGeometryPak;
|
||||
}
|
||||
// Always make sure objects are resolved when loading from archive.
|
||||
if (bLoading && m_bNeedResolveObjects)
|
||||
{
|
||||
@@ -74,31 +67,6 @@ void CObjectArchive::SetResolveCallback(CBaseObject* fromObject, REFGUID objectI
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CObjectArchive::SetResolveCallback(CBaseObject* fromObject, REFGUID objectId, ResolveObjRefFunctor2 func, uint32 userData)
|
||||
{
|
||||
if (objectId == GUID_NULL)
|
||||
{
|
||||
func(0, userData);
|
||||
return;
|
||||
}
|
||||
|
||||
CBaseObject* object = m_objectManager->FindObject(objectId);
|
||||
if (object && !(m_nFlags & eObjectLoader_MakeNewIDs))
|
||||
{
|
||||
// Object is already resolved. immidiatly call callback.
|
||||
func(object, userData);
|
||||
}
|
||||
else
|
||||
{
|
||||
Callback cb;
|
||||
cb.fromObject = fromObject;
|
||||
cb.func2 = func;
|
||||
cb.userData = userData;
|
||||
m_resolveCallbacks.insert(Callbacks::value_type(objectId, cb));
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
GUID CObjectArchive::ResolveID(REFGUID id)
|
||||
{
|
||||
@@ -117,10 +85,7 @@ void CObjectArchive::ResolveObjects()
|
||||
|
||||
{
|
||||
CWaitProgress wait("Loading Objects", false);
|
||||
if (m_bProgressBarEnabled)
|
||||
{
|
||||
wait.Start();
|
||||
}
|
||||
wait.Start();
|
||||
|
||||
GetIEditor()->SuspendUndo();
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -129,10 +94,7 @@ void CObjectArchive::ResolveObjects()
|
||||
int numObj = static_cast<int>(m_loadedObjects.size());
|
||||
for (i = 0; i < numObj; i++)
|
||||
{
|
||||
if (m_bProgressBarEnabled)
|
||||
{
|
||||
wait.Step((i * 100) / numObj);
|
||||
}
|
||||
wait.Step((i * 100) / numObj);
|
||||
|
||||
SLoadedObjectInfo& obj = m_loadedObjects[i];
|
||||
m_pCurrentErrorReport->SetCurrentValidatorObject(obj.pObject);
|
||||
@@ -204,30 +166,20 @@ void CObjectArchive::ResolveObjects()
|
||||
{
|
||||
(cb.func1)(object);
|
||||
}
|
||||
if (cb.func2)
|
||||
{
|
||||
(cb.func2)(object, cb.userData);
|
||||
}
|
||||
}
|
||||
m_resolveCallbacks.clear();
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
{
|
||||
CWaitProgress wait("Creating Objects", false);
|
||||
if (m_bProgressBarEnabled)
|
||||
{
|
||||
wait.Start();
|
||||
}
|
||||
wait.Start();
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Serialize All Objects from XML.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
int numObj = static_cast<int>(m_loadedObjects.size());
|
||||
for (i = 0; i < numObj; i++)
|
||||
{
|
||||
if (m_bProgressBarEnabled)
|
||||
{
|
||||
wait.Step((i * 100) / numObj);
|
||||
}
|
||||
wait.Step((i * 100) / numObj);
|
||||
|
||||
SLoadedObjectInfo& obj = m_loadedObjects[i];
|
||||
m_pCurrentErrorReport->SetCurrentValidatorObject(obj.pObject);
|
||||
@@ -258,8 +210,6 @@ void CObjectArchive::ResolveObjects()
|
||||
|
||||
m_bNeedResolveObjects = false;
|
||||
m_pCurrentErrorReport->SetCurrentValidatorObject(nullptr);
|
||||
m_sequenceIdRemap.clear();
|
||||
m_pendingIds.clear();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -272,7 +222,6 @@ void CObjectArchive::SaveObject(CBaseObject* pObject)
|
||||
|
||||
if (m_savedObjects.find(pObject) == m_savedObjects.end())
|
||||
{
|
||||
m_pCurrentObject = pObject;
|
||||
m_savedObjects.insert(pObject);
|
||||
// If this object was not saved before.
|
||||
XmlNodeRef objNode = node->newChild("Object");
|
||||
@@ -307,45 +256,6 @@ CBaseObject* CObjectArchive::LoadObject(const XmlNodeRef& objNode, CBaseObject*
|
||||
return pObject;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CObjectArchive::LoadObjects(XmlNodeRef& rootObjectsNode)
|
||||
{
|
||||
int numObjects = rootObjectsNode->getChildCount();
|
||||
for (int i = 0; i < numObjects; i++)
|
||||
{
|
||||
XmlNodeRef objNode = rootObjectsNode->getChild(i);
|
||||
LoadObject(objNode, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CObjectArchive::ReportError(CErrorRecord& err)
|
||||
{
|
||||
if (m_pCurrentErrorReport)
|
||||
{
|
||||
m_pCurrentErrorReport->ReportError(err);
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CObjectArchive::SetErrorReport(CErrorReport* errReport)
|
||||
{
|
||||
if (errReport)
|
||||
{
|
||||
m_pCurrentErrorReport = errReport;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pCurrentErrorReport = GetIEditor()->GetErrorReport();
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CObjectArchive::ShowErrors()
|
||||
{
|
||||
GetIEditor()->GetErrorReport()->Display();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CObjectArchive::MakeNewIds(bool bEnable)
|
||||
{
|
||||
@@ -359,70 +269,8 @@ void CObjectArchive::MakeNewIds(bool bEnable)
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CObjectArchive::SetShouldResetInternalMembers(bool reset)
|
||||
{
|
||||
if (reset)
|
||||
{
|
||||
m_nFlags |= eObjectLoader_ResetInternalMembers;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_nFlags &= ~(eObjectLoader_ResetInternalMembers);
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CObjectArchive::RemapID(REFGUID oldId, REFGUID newId)
|
||||
{
|
||||
m_IdRemap[oldId] = newId;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
CPakFile* CObjectArchive::GetGeometryPak(const char* sFilename)
|
||||
{
|
||||
if (m_pGeometryPak)
|
||||
{
|
||||
return m_pGeometryPak;
|
||||
}
|
||||
m_pGeometryPak = new CPakFile;
|
||||
m_pGeometryPak->Open(sFilename);
|
||||
return m_pGeometryPak;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
CBaseObject* CObjectArchive::GetCurrentObject()
|
||||
{
|
||||
return m_pCurrentObject;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CObjectArchive::AddSequenceIdMapping(uint32 oldId, uint32 newId)
|
||||
{
|
||||
assert(oldId != newId);
|
||||
assert(GetIEditor()->GetMovieSystem()->FindSequenceById(oldId) || stl::find(m_pendingIds, oldId));
|
||||
assert(GetIEditor()->GetMovieSystem()->FindSequenceById(newId) == nullptr);
|
||||
assert(stl::find(m_pendingIds, newId) == false);
|
||||
m_sequenceIdRemap[oldId] = newId;
|
||||
m_pendingIds.push_back(newId);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
uint32 CObjectArchive::RemapSequenceId(uint32 id) const
|
||||
{
|
||||
std::map<uint32, uint32>::const_iterator itr = m_sequenceIdRemap.find(id);
|
||||
if (itr == m_sequenceIdRemap.end())
|
||||
{
|
||||
return id;
|
||||
}
|
||||
else
|
||||
{
|
||||
return itr->second;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CObjectArchive::IsAmongPendingIds(uint32 id) const
|
||||
{
|
||||
return stl::find(m_pendingIds, id);
|
||||
}
|
||||
|
||||
@@ -6,18 +6,13 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_OBJECTS_OBJECTLOADER_H
|
||||
#define CRYINCLUDE_EDITOR_OBJECTS_OBJECTLOADER_H
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "Util/GuidUtil.h"
|
||||
#include "ErrorReport.h"
|
||||
#include <AzCore/std/containers/set.h>
|
||||
|
||||
#include <set>
|
||||
|
||||
class CPakFile;
|
||||
class CErrorRecord;
|
||||
struct IObjectManager;
|
||||
|
||||
@@ -43,63 +38,27 @@ AZ_POP_DISABLE_DLL_EXPORT_BASECLASS_WARNING
|
||||
|
||||
//! Resolve callback with only one parameter of CBaseObject.
|
||||
typedef AZStd::function<void(CBaseObject*)> ResolveObjRefFunctor1;
|
||||
//! Resolve callback with two parameters one is pointer to CBaseObject and second use data integer.
|
||||
typedef AZStd::function<void(CBaseObject*, unsigned int)> ResolveObjRefFunctor2;
|
||||
|
||||
/** Register Object id.
|
||||
@param objectId Original object id from the file.
|
||||
@param realObjectId Changed object id.
|
||||
*/
|
||||
//void RegisterObjectId( int objectId,int realObjectId );
|
||||
|
||||
// Return object ID remapped after loading.
|
||||
GUID ResolveID(REFGUID id);
|
||||
|
||||
//! Set object resolve callback, it will be called once object with specified Id is loaded.
|
||||
void SetResolveCallback(CBaseObject* fromObject, REFGUID objectId, ResolveObjRefFunctor1 func);
|
||||
//! Set object resolve callback, it will be called once object with specified Id is loaded.
|
||||
void SetResolveCallback(CBaseObject* fromObject, REFGUID objectId, ResolveObjRefFunctor2 func, uint32 userData);
|
||||
//! Resolve all object ids and call callbacks on resolved objects.
|
||||
void ResolveObjects();
|
||||
|
||||
// Save object to archive.
|
||||
void SaveObject(CBaseObject* pObject);
|
||||
|
||||
//! Load multiple objects from archive.
|
||||
void LoadObjects(XmlNodeRef& rootObjectsNode);
|
||||
|
||||
//! Load one object from archive.
|
||||
CBaseObject* LoadObject(const XmlNodeRef& objNode, CBaseObject* pPrevObject = nullptr);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
int GetLoadedObjectsCount() { return static_cast<int>(m_loadedObjects.size()); }
|
||||
CBaseObject* GetLoadedObject(int nIndex) const { return m_loadedObjects[nIndex].pObject; }
|
||||
|
||||
//! If true new loaded objects will be assigned new GUIDs.
|
||||
void MakeNewIds(bool bEnable);
|
||||
|
||||
//! Remap object ids.
|
||||
void RemapID(REFGUID oldId, REFGUID newId);
|
||||
|
||||
//! Report error during loading.
|
||||
void ReportError(CErrorRecord& err);
|
||||
//! Assigner different error report class.
|
||||
void SetErrorReport(CErrorReport* errReport);
|
||||
//! Display collected error reports.
|
||||
void ShowErrors();
|
||||
|
||||
void EnableProgressBar(bool bEnable) { m_bProgressBarEnabled = bEnable; };
|
||||
|
||||
CPakFile* GetGeometryPak(const char* sFilename);
|
||||
CBaseObject* GetCurrentObject();
|
||||
|
||||
void AddSequenceIdMapping(uint32 oldId, uint32 newId);
|
||||
uint32 RemapSequenceId(uint32 id) const;
|
||||
bool IsAmongPendingIds(uint32 id) const;
|
||||
|
||||
void SetShouldResetInternalMembers(bool reset);
|
||||
bool ShouldResetInternalMembers() const { return m_nFlags & eObjectLoader_ResetInternalMembers; }
|
||||
|
||||
private:
|
||||
struct SLoadedObjectInfo
|
||||
{
|
||||
@@ -110,22 +69,19 @@ private:
|
||||
bool operator <(const SLoadedObjectInfo& oi) const { return nSortOrder < oi.nSortOrder; }
|
||||
};
|
||||
|
||||
|
||||
IObjectManager* m_objectManager;
|
||||
struct Callback
|
||||
{
|
||||
ResolveObjRefFunctor1 func1;
|
||||
ResolveObjRefFunctor2 func2;
|
||||
uint32 userData;
|
||||
_smart_ptr<CBaseObject> fromObject;
|
||||
Callback() { func1 = 0; func2 = 0; userData = 0; };
|
||||
Callback() { func1 = 0; }
|
||||
};
|
||||
typedef std::multimap<GUID, Callback, guid_less_predicate> Callbacks;
|
||||
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
Callbacks m_resolveCallbacks;
|
||||
|
||||
// Set of all saved objects to this archive.
|
||||
typedef std::set<_smart_ptr<CBaseObject> > ObjectsSet;
|
||||
typedef AZStd::set<_smart_ptr<CBaseObject> > ObjectsSet;
|
||||
ObjectsSet m_savedObjects;
|
||||
|
||||
//typedef std::multimap<int,_smart_ptr<CBaseObject> > OrderedObjects;
|
||||
@@ -138,20 +94,11 @@ private:
|
||||
enum EObjectLoaderFlags
|
||||
{
|
||||
eObjectLoader_MakeNewIDs = 0x0001, // If true new loaded objects will be assigned new GUIDs.
|
||||
eObjectLoader_ResetInternalMembers = 0x0004, // In case we are deserializing and we would like to wipe all previous state
|
||||
};
|
||||
int m_nFlags;
|
||||
IErrorReport* m_pCurrentErrorReport;
|
||||
CPakFile* m_pGeometryPak;
|
||||
CBaseObject* m_pCurrentObject;
|
||||
|
||||
bool m_bNeedResolveObjects;
|
||||
bool m_bProgressBarEnabled;
|
||||
|
||||
// This table is used when there is any collision of ids while importing TrackView sequences.
|
||||
std::map<uint32, uint32> m_sequenceIdRemap;
|
||||
std::vector<uint32> m_pendingIds;
|
||||
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
};
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_OBJECTS_OBJECTLOADER_H
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -8,10 +8,6 @@
|
||||
|
||||
|
||||
// Description : ObjectManager definition.
|
||||
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_OBJECTS_OBJECTMANAGER_H
|
||||
#define CRYINCLUDE_EDITOR_OBJECTS_OBJECTMANAGER_H
|
||||
#pragma once
|
||||
|
||||
#include "IObjectManager.h"
|
||||
@@ -42,12 +38,10 @@ public:
|
||||
CObjectManagerLevelIsExporting()
|
||||
{
|
||||
AZ::ObjectManagerEventBus::Broadcast(&AZ::ObjectManagerEventBus::Events::OnExportingStarting);
|
||||
GetIEditor()->GetObjectManager()->SetExportingLevel(true);
|
||||
}
|
||||
|
||||
~CObjectManagerLevelIsExporting()
|
||||
{
|
||||
GetIEditor()->GetObjectManager()->SetExportingLevel(false);
|
||||
AZ::ObjectManagerEventBus::Broadcast(&AZ::ObjectManagerEventBus::Events::OnExportingFinished);
|
||||
}
|
||||
};
|
||||
@@ -66,20 +60,12 @@ public:
|
||||
CObjectManager();
|
||||
~CObjectManager();
|
||||
|
||||
void RegisterObjectClasses();
|
||||
|
||||
CBaseObject* NewObject(CObjectClassDesc* cls, CBaseObject* prev = 0, const QString& file = "", const char* newObjectName = nullptr) override;
|
||||
CBaseObject* NewObject(const QString& typeName, CBaseObject* prev = 0, const QString& file = "", const char* newEntityName = nullptr) override;
|
||||
|
||||
void DeleteObject(CBaseObject* obj) override;
|
||||
void DeleteSelection(CSelectionGroup* pSelection) override;
|
||||
void DeleteAllObjects() override;
|
||||
CBaseObject* CloneObject(CBaseObject* obj) override;
|
||||
|
||||
void BeginEditParams(CBaseObject* obj, int flags) override;
|
||||
void EndEditParams(int flags = 0) override;
|
||||
// Hides all transform manipulators.
|
||||
void HideTransformManipulators();
|
||||
|
||||
//! Get number of objects manager by ObjectManager (not contain sub objects of groups).
|
||||
int GetObjectCount() const override;
|
||||
@@ -88,30 +74,9 @@ public:
|
||||
//! @param layer if 0 get objects for all layers, or layer to get objects from.
|
||||
void GetObjects(CBaseObjectsArray& objects) const override;
|
||||
|
||||
//! Get array of objects that pass the filter.
|
||||
//! @param filter The filter functor, return true if you want to get the certain obj, return false if want to skip it.
|
||||
void GetObjects(CBaseObjectsArray& objects, BaseObjectFilterFunctor const& filter) const override;
|
||||
|
||||
//! Update objects.
|
||||
void Update();
|
||||
|
||||
//! Display objects on display context.
|
||||
void Display(DisplayContext& dc) override;
|
||||
|
||||
//! Called when selecting without selection helpers - this is needed since
|
||||
//! the visible object cache is normally not updated when not displaying helpers.
|
||||
void ForceUpdateVisibleObjectCache(DisplayContext& dc) override;
|
||||
|
||||
//! Check intersection with objects.
|
||||
//! Find intersection with nearest to ray origin object hit by ray.
|
||||
//! If distance tollerance is specified certain relaxation applied on collision test.
|
||||
//! @return true if hit any object, and fills hitInfo structure.
|
||||
bool HitTest(HitContext& hitInfo) override;
|
||||
|
||||
//! Check intersection with an object.
|
||||
//! @return true if hit, and fills hitInfo structure.
|
||||
bool HitTestObject(CBaseObject* obj, HitContext& hc) override;
|
||||
|
||||
//! Send event to all objects.
|
||||
//! Will cause OnEvent handler to be called on all objects.
|
||||
void SendEvent(ObjectEvent event) override;
|
||||
@@ -134,76 +99,28 @@ public:
|
||||
//! Find objects which intersect with a given AABB.
|
||||
void FindObjectsInAABB(const AABB& aabb, std::vector<CBaseObject*>& result) const override;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Operations on objects.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//! Makes object visible or invisible.
|
||||
void HideObject(CBaseObject* obj, bool hide) override;
|
||||
//! Shows the last hidden object based on hidden ID
|
||||
void ShowLastHiddenObject() override;
|
||||
//! Freeze object, making it unselectable.
|
||||
void FreezeObject(CBaseObject* obj, bool freeze) override;
|
||||
//! Unhide all hidden objects.
|
||||
void UnhideAll() override;
|
||||
//! Unfreeze all frozen objects.
|
||||
void UnfreezeAll() override;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Object Selection.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool SelectObject(CBaseObject* obj, bool bUseMask = true) override;
|
||||
void UnselectObject(CBaseObject* obj) override;
|
||||
|
||||
//! Select objects within specified distance from given position.
|
||||
//! Return number of selected objects.
|
||||
int SelectObjects(const AABB& box, bool bUnselect = false) override;
|
||||
|
||||
void SelectEntities(std::set<CEntityObject*>& s) override;
|
||||
|
||||
int MoveObjects(const AABB& box, const Vec3& offset, ImageRotationDegrees rotation, bool bIsCopy = false) override;
|
||||
|
||||
//! Selects/Unselects all objects within 2d rectangle in given viewport.
|
||||
void SelectObjectsInRect(CViewport* view, const QRect& rect, bool bSelect) override;
|
||||
void FindObjectsInRect(CViewport* view, const QRect& rect, std::vector<GUID>& guids) override;
|
||||
|
||||
//! Clear default selection set.
|
||||
//! @Return number of objects removed from selection.
|
||||
int ClearSelection() override;
|
||||
|
||||
//! Deselect all current selected objects and selects object that were unselected.
|
||||
//! @Return number of selected objects.
|
||||
int InvertSelection() override;
|
||||
|
||||
//! Get current selection.
|
||||
CSelectionGroup* GetSelection() const override { return m_currSelection; };
|
||||
//! Get named selection.
|
||||
CSelectionGroup* GetSelection(const QString& name) const override;
|
||||
// Get selection group names
|
||||
void GetNameSelectionStrings(QStringList& names) override;
|
||||
//! Change name of current selection group.
|
||||
//! And store it in list.
|
||||
void NameSelection(const QString& name) override;
|
||||
//! Set one of name selections as current selection.
|
||||
void SetSelection(const QString& name) override;
|
||||
void RemoveSelection(const QString& name) override;
|
||||
|
||||
bool IsObjectDeletionAllowed(CBaseObject* pObject);
|
||||
|
||||
//! Delete all objects in selection group.
|
||||
void DeleteSelection() override;
|
||||
|
||||
uint32 ForceID() const override{return m_ForceID; }
|
||||
void ForceID(uint32 FID) override{m_ForceID = FID; }
|
||||
|
||||
//! Generates uniq name base on type name of object.
|
||||
QString GenerateUniqueObjectName(const QString& typeName) override;
|
||||
//! Register object name in object manager, needed for generating uniq names.
|
||||
void RegisterObjectName(const QString& name) override;
|
||||
//! Decrease name number and remove if it was last in object manager, needed for generating uniq names.
|
||||
void UpdateRegisterObjectName(const QString& name);
|
||||
//! Enable/Disable generating of unique object names (Enabled by default).
|
||||
//! Return previous value.
|
||||
bool EnableUniqObjectNames(bool bEnable) override;
|
||||
|
||||
//! Register XML template of runtime class.
|
||||
void RegisterClassTemplate(const XmlNodeRef& templ);
|
||||
@@ -215,52 +132,10 @@ public:
|
||||
|
||||
//! Find object class by name.
|
||||
CObjectClassDesc* FindClass(const QString& className) override;
|
||||
void GetClassCategories(QStringList& categories) override;
|
||||
void GetClassCategoryToolClassNamePairs(std::vector< std::pair<QString, QString> >& categoryToolClassNamePairs) override;
|
||||
void GetClassTypes(const QString& category, QStringList& types) override;
|
||||
|
||||
//! Export objects to xml.
|
||||
//! When onlyShared is true ony objects with shared flags exported, overwise only not shared object exported.
|
||||
void Export(const QString& levelPath, XmlNodeRef& rootNode, bool onlyShared) override;
|
||||
void ExportEntities(XmlNodeRef& rootNode) override;
|
||||
|
||||
//! Serialize Objects in manager to specified XML Node.
|
||||
//! @param flags Can be one of SerializeFlags.
|
||||
void Serialize(XmlNodeRef& rootNode, bool bLoading, int flags = SERIALIZE_ALL) override;
|
||||
|
||||
void SerializeNameSelection(XmlNodeRef& rootNode, bool bLoading) override;
|
||||
|
||||
//! Load objects from object archive.
|
||||
//! @param bSelect if set newly loaded object will be selected.
|
||||
void LoadObjects(CObjectArchive& ar, bool bSelect) override;
|
||||
|
||||
//! Delete from Object manager all objects without SHARED flag.
|
||||
void DeleteNotSharedObjects();
|
||||
//! Delete from Object manager all objects with SHARED flag.
|
||||
void DeleteSharedObjects();
|
||||
|
||||
bool AddObject(CBaseObject* obj);
|
||||
void RemoveObject(CBaseObject* obj);
|
||||
void ChangeObjectId(REFGUID oldId, REFGUID newId) override;
|
||||
bool IsDuplicateObjectName(const QString& newName) const override
|
||||
{
|
||||
return FindObject(newName) ? true : false;
|
||||
}
|
||||
void ShowDuplicationMsgWarning(CBaseObject* obj, const QString& newName, bool bShowMsgBox) const override;
|
||||
void ChangeObjectName(CBaseObject* obj, const QString& newName) override;
|
||||
|
||||
//! Convert object of one type to object of another type.
|
||||
//! Original object is deleted.
|
||||
bool ConvertToType(CBaseObject* pObject, const QString& typeName) override;
|
||||
|
||||
//! Set new selection callback.
|
||||
//! @return previous selection callback.
|
||||
IObjectSelectCallback* SetSelectCallback(IObjectSelectCallback* callback) override;
|
||||
|
||||
// Enables/Disables creating of game objects.
|
||||
void SetCreateGameObject(bool enable) override { m_createGameObjects = enable; };
|
||||
//! Return true if objects loaded from xml should immidiatly create game objects associated with them.
|
||||
bool IsCreateGameObjects() const override { return m_createGameObjects; };
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//! Get access to gizmo manager.
|
||||
@@ -270,33 +145,12 @@ public:
|
||||
//! Invalidate visibily settings of objects.
|
||||
void InvalidateVisibleList() override;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// ObjectManager notification Callbacks.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void AddObjectEventListener(EventListener* listener) override;
|
||||
void RemoveObjectEventListener(EventListener* listener) override;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Used to indicate starting and ending of objects loading.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void StartObjectsLoading(int numObjects) override;
|
||||
void EndObjectsLoading() override;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Gathers all resources used by all objects.
|
||||
void GatherUsedResources(CUsedResources& resources) override;
|
||||
|
||||
bool IsLightClass(CBaseObject* pObject) override;
|
||||
|
||||
virtual void FindAndRenameProperty2(const char* property2Name, const QString& oldValue, const QString& newValue) override;
|
||||
virtual void FindAndRenameProperty2If(const char* property2Name, const QString& oldValue, const QString& newValue, const char* otherProperty2Name, const QString& otherValue) override;
|
||||
|
||||
bool IsReloading() const override { return m_bInReloading; }
|
||||
void SetSkipUpdate(bool bSkipUpdate) override { m_bSkipObjectUpdate = bSkipUpdate; }
|
||||
|
||||
void SetExportingLevel(bool bExporting) override { m_bLevelExporting = bExporting; }
|
||||
bool IsExportingLevelInprogress() const override { return m_bLevelExporting; }
|
||||
|
||||
int GetAxisHelperHitRadius() const override { return m_axisHelperHitRadius; }
|
||||
|
||||
private:
|
||||
@@ -317,29 +171,12 @@ private:
|
||||
void SelectCurrent();
|
||||
void SetObjectSelected(CBaseObject* pObject, bool bSelect);
|
||||
|
||||
// Recursive functions potentially taking into child objects into account
|
||||
void SelectObjectInRect(CBaseObject* pObj, CViewport* view, HitContext hc, bool bSelect);
|
||||
void HitTestObjectAgainstRect(CBaseObject* pObj, CViewport* view, HitContext hc, std::vector<GUID>& guids);
|
||||
|
||||
void SaveRegistry();
|
||||
void LoadRegistry();
|
||||
|
||||
void NotifyObjectListeners(CBaseObject* pObject, CBaseObject::EObjectListenerEvent event);
|
||||
|
||||
void FindDisplayableObjects(DisplayContext& dc, bool bDisplay);
|
||||
|
||||
private:
|
||||
typedef std::map<GUID, CBaseObjectPtr, guid_less_predicate> Objects;
|
||||
typedef AZStd::map<GUID, CBaseObjectPtr, guid_less_predicate> Objects;
|
||||
Objects m_objects;
|
||||
typedef std::unordered_map<AZ::u32, CBaseObjectPtr> ObjectsByNameCrc;
|
||||
typedef AZStd::unordered_map<AZ::u32, CBaseObjectPtr> ObjectsByNameCrc;
|
||||
ObjectsByNameCrc m_objectsByName;
|
||||
|
||||
typedef std::map<QString, CSelectionGroup*> TNameSelectionMap;
|
||||
TNameSelectionMap m_selections;
|
||||
|
||||
//! Used for forcing IDs of "GetEditorObjectID" of PreFabs, as they used to have random IDs on each load
|
||||
uint32 m_ForceID;
|
||||
|
||||
//! Array of currently visible objects.
|
||||
TBaseObjects m_visibleObjects;
|
||||
|
||||
@@ -349,16 +186,11 @@ private:
|
||||
unsigned int m_lastComputedVisibility = 0; // when the object manager itself last updated visibility (since it also has a cache)
|
||||
int m_lastHideMask = 0;
|
||||
|
||||
float m_maxObjectViewDistRatio;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Selection.
|
||||
//! Current selection group.
|
||||
CSelectionGroup* m_currSelection;
|
||||
int m_nLastSelCount;
|
||||
bool m_bSelectionChanged;
|
||||
IObjectSelectCallback* m_selectCallback;
|
||||
bool m_bLoadingObjects;
|
||||
|
||||
// True while performing a select or deselect operation on more than one object.
|
||||
// Prevents individual undo/redo commands for every object, allowing bulk undo/redo
|
||||
@@ -367,20 +199,9 @@ private:
|
||||
//! Default selection.
|
||||
CSelectionGroup m_defaultSelection;
|
||||
|
||||
CBaseObjectPtr m_currEditObject;
|
||||
bool m_bSingleSelection;
|
||||
|
||||
bool m_createGameObjects;
|
||||
bool m_bGenUniqObjectNames;
|
||||
|
||||
// Object manager also handles Gizmo manager.
|
||||
CGizmoManager* m_gizmoManager;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Loading progress.
|
||||
CWaitProgress* m_pLoadProgress;
|
||||
int m_loadedObjects;
|
||||
int m_totalObjectsToLoad;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -389,10 +210,6 @@ private:
|
||||
typedef std::map<QString, std::set<uint16>, stl::less_stricmp<QString> > NameNumbersMap;
|
||||
NameNumbersMap m_nameNumbersMap;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Listeners.
|
||||
std::list<EventListener*> m_objectEventListeners;
|
||||
|
||||
bool m_bExiting;
|
||||
|
||||
std::unordered_set<CEntityObject*> m_animatedAttachedEntities;
|
||||
@@ -401,10 +218,6 @@ private:
|
||||
|
||||
uint64 m_currentHideCount;
|
||||
|
||||
bool m_bInReloading;
|
||||
bool m_bSkipObjectUpdate;
|
||||
bool m_bLevelExporting;
|
||||
|
||||
int m_axisHelperHitRadius = 20;
|
||||
};
|
||||
|
||||
@@ -426,4 +239,3 @@ namespace AzToolsFramework
|
||||
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_OBJECTS_OBJECTMANAGER_H
|
||||
|
||||
@@ -24,12 +24,11 @@ public:
|
||||
CUndoBaseObjectNew(CBaseObject* object);
|
||||
|
||||
protected:
|
||||
virtual int GetSize() override { return sizeof(*this); }; // Return size of xml state.
|
||||
virtual QString GetDescription() override { return "New BaseObject"; };
|
||||
virtual QString GetObjectName() override { return m_object->GetName(); };
|
||||
int GetSize() override { return sizeof(*this); } // Return size of xml state.
|
||||
QString GetObjectName() override { return m_object->GetName(); }
|
||||
|
||||
virtual void Undo(bool bUndo) override;
|
||||
virtual void Redo() override;
|
||||
void Undo(bool bUndo) override;
|
||||
void Redo() override;
|
||||
|
||||
private:
|
||||
CBaseObjectPtr m_object;
|
||||
@@ -47,12 +46,11 @@ public:
|
||||
CUndoBaseObjectDelete(CBaseObject* object);
|
||||
|
||||
protected:
|
||||
virtual int GetSize() override { return sizeof(*this); }; // Return size of xml state.
|
||||
virtual QString GetDescription() override { return "Delete BaseObject"; };
|
||||
virtual QString GetObjectName() override { return m_object->GetName(); };
|
||||
int GetSize() override { return sizeof(*this); } // Return size of xml state.
|
||||
QString GetObjectName() override { return m_object->GetName(); }
|
||||
|
||||
virtual void Undo(bool bUndo) override;
|
||||
virtual void Redo() override;
|
||||
void Undo(bool bUndo) override;
|
||||
void Redo() override;
|
||||
|
||||
private:
|
||||
CBaseObjectPtr m_object;
|
||||
@@ -73,20 +71,19 @@ public:
|
||||
* This Undo command can be used for either Legacy or Component Entities, though for
|
||||
* performance reasons Component Entities are typically undone using CUndoBaseObjectBulkSelect
|
||||
*
|
||||
* @param pObj The object to perform the undo/redo operation on.
|
||||
* @param object The object to perform the undo/redo operation on.
|
||||
* @param isSelect This is true if you are trying to undo a select operation, and false if
|
||||
* trying to undo a deselect operation
|
||||
*/
|
||||
CUndoBaseObjectSelect(CBaseObject* object, bool isSelect);
|
||||
|
||||
protected:
|
||||
virtual void Release() override { delete this; };
|
||||
virtual int GetSize() override { return sizeof(*this); }; // Return size of xml state.
|
||||
virtual QString GetDescription() override { return "Select Object"; };
|
||||
virtual QString GetObjectName() override;
|
||||
void Release() override { delete this; }
|
||||
int GetSize() override { return sizeof(*this); } // Return size of xml state.
|
||||
QString GetObjectName() override;
|
||||
|
||||
virtual void Undo(bool bUndo) override;
|
||||
virtual void Redo() override;
|
||||
void Undo(bool bUndo) override;
|
||||
void Redo() override;
|
||||
|
||||
private:
|
||||
GUID m_guid;
|
||||
@@ -116,7 +113,6 @@ public:
|
||||
|
||||
protected:
|
||||
int GetSize() override { return sizeof(*this); } // Return size of xml state.
|
||||
QString GetDescription() override { return QObject::tr("Select Objects"); }
|
||||
|
||||
/*
|
||||
* Deselects the objects
|
||||
@@ -153,7 +149,6 @@ public:
|
||||
|
||||
protected:
|
||||
int GetSize() override { return sizeof(*this); } // Return size of xml state.
|
||||
QString GetDescription() override { return QObject::tr("Select Objects"); }
|
||||
|
||||
void Undo(bool bUndo) override;
|
||||
|
||||
|
||||
@@ -18,8 +18,6 @@
|
||||
#include "ViewManager.h"
|
||||
#include "Include/IObjectManager.h"
|
||||
|
||||
#include <IStatObj.h>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
CSelectionGroup::CSelectionGroup()
|
||||
: m_ref(1)
|
||||
@@ -226,7 +224,6 @@ void CSelectionGroup::Move(const Vec3& offset, EMoveSelectionFlag moveFlag, [[ma
|
||||
|
||||
m_bVertexSnapped = false;
|
||||
FilterParents();
|
||||
Vec3 newPos;
|
||||
|
||||
bool bValidFollowGeometryMode(true);
|
||||
if (point.x() == -1 || point.y() == -1)
|
||||
@@ -234,8 +231,6 @@ void CSelectionGroup::Move(const Vec3& offset, EMoveSelectionFlag moveFlag, [[ma
|
||||
bValidFollowGeometryMode = false;
|
||||
}
|
||||
|
||||
SRayHitInfo pickedInfo;
|
||||
|
||||
if (moveFlag == eMS_FollowGeometryPosNorm)
|
||||
{
|
||||
if (m_LastestMoveSelectionFlag != eMS_FollowGeometryPosNorm)
|
||||
@@ -249,6 +244,8 @@ void CSelectionGroup::Move(const Vec3& offset, EMoveSelectionFlag moveFlag, [[ma
|
||||
}
|
||||
|
||||
m_LastestMoveSelectionFlag = moveFlag;
|
||||
Vec3 zeroPickedInfo_vHitNormal;
|
||||
Vec3 zeroPickedInfo_vHitPos;
|
||||
|
||||
for (int i = 0; i < GetFilteredCount(); i++)
|
||||
{
|
||||
@@ -264,16 +261,15 @@ void CSelectionGroup::Move(const Vec3& offset, EMoveSelectionFlag moveFlag, [[ma
|
||||
Vec3 zaxis = m_LastestMovedObjectRot * Vec3(0, 0, 1);
|
||||
zaxis.Normalize();
|
||||
Quat nq;
|
||||
nq.SetRotationV0V1(zaxis, pickedInfo.vHitNormal);
|
||||
obj->SetPos(pickedInfo.vHitPos);
|
||||
nq.SetRotationV0V1(zaxis, zeroPickedInfo_vHitNormal);
|
||||
obj->SetPos(zeroPickedInfo_vHitPos);
|
||||
obj->SetRotation(nq * m_LastestMovedObjectRot);
|
||||
continue;
|
||||
}
|
||||
|
||||
Matrix34 wtm = obj->GetWorldTM();
|
||||
const Matrix34 &wtm = obj->GetWorldTM();
|
||||
Vec3 wp = wtm.GetTranslation();
|
||||
|
||||
newPos = wp + offset;
|
||||
Vec3 newPos = wp + offset;
|
||||
if (moveFlag == eMS_FollowTerrain)
|
||||
{
|
||||
// Make sure object keeps it height.
|
||||
@@ -465,17 +461,6 @@ void CSelectionGroup::SetScale(const Vec3& scale, int referenceCoordSys)
|
||||
Scale(relScale, referenceCoordSys);
|
||||
}
|
||||
|
||||
|
||||
void CSelectionGroup::StartScaling()
|
||||
{
|
||||
for (int i = 0; i < GetFilteredCount(); i++)
|
||||
{
|
||||
CBaseObject* obj = GetFilteredObject(i);
|
||||
obj->StartScaling();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CSelectionGroup::Align()
|
||||
{
|
||||
@@ -533,45 +518,6 @@ void CSelectionGroup::ResetTransformation()
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CSelectionGroup::Clone(CSelectionGroup& newGroup)
|
||||
{
|
||||
IObjectManager* pObjMan = GetIEditor()->GetObjectManager();
|
||||
assert(pObjMan);
|
||||
|
||||
int i;
|
||||
CObjectCloneContext cloneContext;
|
||||
|
||||
FilterParents();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Clone every object.
|
||||
for (i = 0; i < GetFilteredCount(); i++)
|
||||
{
|
||||
CBaseObject* pFromObject = GetFilteredObject(i);
|
||||
CBaseObject* newObj = pObjMan->CloneObject(pFromObject);
|
||||
if (!newObj) // can be null, e.g. sequence can't be cloned
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
cloneContext.AddClone(pFromObject, newObj);
|
||||
newGroup.AddObject(newObj);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Only after everything was cloned, call PostClone on all cloned objects.
|
||||
for (i = 0; i < newGroup.GetCount(); ++i)
|
||||
{
|
||||
CBaseObject* pFromObject = GetFilteredObject(i);
|
||||
CBaseObject* pClonedObject = newGroup.GetObject(i);
|
||||
if (pClonedObject)
|
||||
{
|
||||
pClonedObject->PostClone(pFromObject, cloneContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CSelectionGroup::SendEvent(ObjectEvent event)
|
||||
{
|
||||
|
||||
@@ -98,7 +98,6 @@ public:
|
||||
//! Resets rotation and scale to identity and (1.0f, 1.0f, 1.0f)
|
||||
void ResetTransformation();
|
||||
//! Scale objects in selection by given scale.
|
||||
void StartScaling();
|
||||
void Scale(const Vec3& scale, int referenceCoordSys);
|
||||
void SetScale(const Vec3& scale, int referenceCoordSys);
|
||||
//! Align objects in selection to surface normal
|
||||
@@ -106,11 +105,6 @@ public:
|
||||
//! Very special method to move contents of a voxel.
|
||||
void MoveContent(const Vec3& offset);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//! Clone objects in this group and add cloned objects to new selection group.
|
||||
//! Only topmost parent objects will be added to this selection group.
|
||||
void Clone(CSelectionGroup& newGroup);
|
||||
|
||||
// Send event to all objects in selection group.
|
||||
void SendEvent(ObjectEvent event);
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
// Editor
|
||||
#include "Include/IViewPane.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
CClassFactory* CClassFactory::s_pInstance = nullptr;
|
||||
CAutoRegisterClassHelper* CAutoRegisterClassHelper::s_pFirst = nullptr;
|
||||
@@ -79,7 +80,7 @@ void CClassFactory::RegisterClass(IClassDesc* pClassDesc)
|
||||
existingUUIDString,
|
||||
findByGuid->second->ClassName().toUtf8().data());
|
||||
|
||||
CryMessageBox(errorMessageBuffer, "Invalid class registration - Duplicate UUID", MB_OK);
|
||||
QMessageBox::critical(nullptr,"Invalid class registration - Duplicate UUID",QString::fromLatin1(errorMessageBuffer));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -107,7 +108,7 @@ void CClassFactory::RegisterClass(IClassDesc* pClassDesc)
|
||||
newUUIDString,
|
||||
existingUUIDString);
|
||||
|
||||
CryMessageBox(errorMessageBuffer, "Invalid class registration - Duplicate Class Name", MB_OK);
|
||||
QMessageBox::critical(nullptr, "Invalid class registration - Duplicate Class Name", QString::fromLatin1(errorMessageBuffer));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,6 @@
|
||||
#include <AzToolsFramework/ToolsComponents/EditorSelectionAccentSystemComponent.h>
|
||||
#include <AzToolsFramework/ToolsComponents/EditorEntityIconComponentBus.h>
|
||||
#include <AzToolsFramework/Undo/UndoCacheInterface.h>
|
||||
#include <LmbrCentral/Rendering/RenderNodeBus.h>
|
||||
|
||||
#include <IDisplayViewport.h>
|
||||
#include <CryCommon/Cry_GeoIntersect.h>
|
||||
@@ -48,14 +47,12 @@
|
||||
/**
|
||||
* Scalars for icon drawing behavior.
|
||||
*/
|
||||
static const int s_kIconSize = 36; /// Icon display size (in pixels)
|
||||
|
||||
CComponentEntityObject::CComponentEntityObject()
|
||||
: m_hasIcon(false)
|
||||
: m_accentType(AzToolsFramework::EntityAccentType::None)
|
||||
, m_hasIcon(false)
|
||||
, m_entityIconVisible(false)
|
||||
, m_iconOnlyHitTest(false)
|
||||
, m_drawAccents(true)
|
||||
, m_accentType(AzToolsFramework::EntityAccentType::None)
|
||||
, m_isIsolated(false)
|
||||
, m_iconTexture(nullptr)
|
||||
{
|
||||
@@ -243,7 +240,7 @@ void CComponentEntityObject::SetSelected(bool bSelect)
|
||||
}
|
||||
|
||||
bool anySelected = false;
|
||||
|
||||
|
||||
AzToolsFramework::ToolsApplicationRequestBus::BroadcastResult(anySelected, &AzToolsFramework::ToolsApplicationRequests::AreAnyEntitiesSelected);
|
||||
|
||||
if (!anySelected)
|
||||
@@ -266,18 +263,6 @@ void CComponentEntityObject::SetHighlight(bool bHighlight)
|
||||
}
|
||||
}
|
||||
|
||||
IRenderNode* CComponentEntityObject::GetEngineNode() const
|
||||
{
|
||||
// It's possible for AZ::Entities to have multiple IRenderNodes.
|
||||
// However, the editor currently expects a single IRenderNode per "editor object".
|
||||
// Therefore, return the highest priority handler.
|
||||
if (auto* renderNodeHandler = LmbrCentral::RenderNodeRequestBus::FindFirstHandler(m_entityId))
|
||||
{
|
||||
return renderNodeHandler->GetRenderNode();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void CComponentEntityObject::OnEntityNameChanged(const AZStd::string& name)
|
||||
{
|
||||
if (m_nameReentryGuard)
|
||||
@@ -331,14 +316,6 @@ void CComponentEntityObject::DetachThis(bool /*bKeepPos*/)
|
||||
}
|
||||
}
|
||||
|
||||
CBaseObject* CComponentEntityObject::GetLinkParent() const
|
||||
{
|
||||
AZ::EntityId parentId;
|
||||
EBUS_EVENT_ID_RESULT(parentId, m_entityId, AZ::TransformBus, GetParentId);
|
||||
|
||||
return CComponentEntityObject::FindObjectForEntity(parentId);
|
||||
}
|
||||
|
||||
bool CComponentEntityObject::IsFrozen() const
|
||||
{
|
||||
return CheckFlags(OBJFLAG_FROZEN);
|
||||
@@ -358,16 +335,6 @@ void CComponentEntityObject::OnEntityLockChanged(bool locked)
|
||||
CEntityObject::SetFrozen(locked);
|
||||
}
|
||||
|
||||
void CComponentEntityObject::SetHidden(
|
||||
bool bHidden, [[maybe_unused]] uint64 hiddenId /*=CBaseObject::s_invalidHiddenID*/, [[maybe_unused]] bool bAnimated /*=false*/)
|
||||
{
|
||||
if (m_visibilityFlagReentryGuard)
|
||||
{
|
||||
EditorActionScope flagChange(m_visibilityFlagReentryGuard);
|
||||
AzToolsFramework::SetEntityVisibility(m_entityId, !bHidden);
|
||||
}
|
||||
}
|
||||
|
||||
void CComponentEntityObject::OnEntityVisibilityChanged(bool visible)
|
||||
{
|
||||
CEntityObject::SetHidden(!visible);
|
||||
@@ -612,66 +579,6 @@ void CComponentEntityObject::OnTransformChanged([[maybe_unused]] const AZ::Trans
|
||||
}
|
||||
}
|
||||
|
||||
int CComponentEntityObject::MouseCreateCallback(CViewport* view, EMouseEvent event, QPoint& point, int flags)
|
||||
{
|
||||
if (event == eMouseMove || event == eMouseLDown)
|
||||
{
|
||||
Vec3 pos;
|
||||
if (GetIEditor()->GetAxisConstrains() != AXIS_TERRAIN)
|
||||
{
|
||||
pos = view->MapViewToCP(point);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Snap to terrain.
|
||||
bool hitTerrain;
|
||||
pos = view->ViewToWorld(point, &hitTerrain);
|
||||
if (hitTerrain)
|
||||
{
|
||||
pos.z = GetIEditor()->GetTerrainElevation(pos.x, pos.y);
|
||||
}
|
||||
pos = view->SnapToGrid(pos);
|
||||
}
|
||||
|
||||
pos = view->SnapToGrid(pos);
|
||||
SetPos(pos);
|
||||
|
||||
if (event == eMouseLDown)
|
||||
{
|
||||
return MOUSECREATE_OK;
|
||||
}
|
||||
|
||||
return MOUSECREATE_CONTINUE;
|
||||
}
|
||||
|
||||
return CBaseObject::MouseCreateCallback(view, event, point, flags);
|
||||
}
|
||||
|
||||
bool CComponentEntityObject::HitHelperTest(HitContext& hc)
|
||||
{
|
||||
bool hit = CEntityObject::HitHelperTest(hc);
|
||||
if (!hit && m_entityId.IsValid())
|
||||
{
|
||||
// Pick against icon in screen space.
|
||||
if (IsEntityIconVisible())
|
||||
{
|
||||
const QPoint entityScreenPos = hc.view->WorldToView(GetWorldPos());
|
||||
const float screenPosX = static_cast<float>(entityScreenPos.x());
|
||||
const float screenPosY = static_cast<float>(entityScreenPos.y());
|
||||
const float iconRange = static_cast<float>(s_kIconSize / 2);
|
||||
|
||||
if ((hc.point2d.x() >= screenPosX - iconRange && hc.point2d.x() <= screenPosX + iconRange)
|
||||
&& (hc.point2d.y() >= screenPosY - iconRange && hc.point2d.y() <= screenPosY + iconRange))
|
||||
{
|
||||
hc.dist = hc.raySrc.GetDistance(GetWorldPos());
|
||||
hc.iconHit = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return hit;
|
||||
}
|
||||
|
||||
bool CComponentEntityObject::HitTest(HitContext& hc)
|
||||
{
|
||||
AZ_PROFILE_FUNCTION(Entity);
|
||||
@@ -907,11 +814,6 @@ void CComponentEntityObject::DrawDefault(DisplayContext& dc, const QColor& label
|
||||
DrawAccent(dc);
|
||||
}
|
||||
|
||||
IStatObj* CComponentEntityObject::GetIStatObj()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool CComponentEntityObject::IsIsolated() const
|
||||
{
|
||||
return m_isIsolated;
|
||||
@@ -952,11 +854,6 @@ void CComponentEntityObject::SetWorldPos(const Vec3& pos, int flags)
|
||||
CEntityObject::SetWorldPos(pos, flags);
|
||||
}
|
||||
|
||||
void CComponentEntityObject::OnContextMenu(QMenu* /*pMenu*/)
|
||||
{
|
||||
// Deliberately bypass the base class implementation (CEntityObject::OnContextMenu()).
|
||||
}
|
||||
|
||||
void CComponentEntityObject::SetupEntityIcon()
|
||||
{
|
||||
bool hideIconInViewport = false;
|
||||
|
||||
@@ -56,27 +56,21 @@ public:
|
||||
bool SetScale(const Vec3& scale, int flags) override;
|
||||
void InvalidateTM(int nWhyFlags) override;
|
||||
void Display(DisplayContext& disp) override;
|
||||
void OnContextMenu(QMenu* pMenu) override;
|
||||
int MouseCreateCallback(CViewport* view, EMouseEvent event, QPoint& point, int flags) override;
|
||||
bool HitHelperTest(HitContext& hc) override;
|
||||
bool HitTest(HitContext& hc) override;
|
||||
void GetLocalBounds(AABB& box) override;
|
||||
void GetBoundBox(AABB& box) override;
|
||||
void SetName(const QString& name) override;
|
||||
bool IsFrozen() const override;
|
||||
void SetFrozen(bool bFrozen) override;
|
||||
void SetHidden(bool bHidden, uint64 hiddenId = CBaseObject::s_invalidHiddenID, bool bAnimated = false) override;
|
||||
void SetSelected(bool bSelect) override;
|
||||
void SetHighlight(bool bHighlight) override;
|
||||
IRenderNode* GetEngineNode() const override;
|
||||
void AttachChild(CBaseObject* child, bool bKeepPos = true) override;
|
||||
void DetachAll(bool bKeepPos = true) override;
|
||||
void DetachThis(bool bKeepPos = true) override;
|
||||
CBaseObject* GetLinkParent() const override;
|
||||
XmlNodeRef Export(const QString& levelPath, XmlNodeRef& xmlNode) override;
|
||||
void DeleteEntity() override;
|
||||
void DrawDefault(DisplayContext& dc, const QColor& labelColor = QColor(255, 255, 255)) override;
|
||||
IStatObj* GetIStatObj() override;
|
||||
|
||||
bool IsIsolated() const override;
|
||||
bool IsSelected() const override;
|
||||
bool IsSelectable() const override;
|
||||
@@ -88,12 +82,6 @@ public:
|
||||
// Component entity highlighting (accenting) is taken care of elsewhere
|
||||
void DrawHighlight(DisplayContext& /*dc*/) override {};
|
||||
|
||||
// Don't auto-clone children. Cloning happens in groups with reference fixups,
|
||||
// and individually selected objercts should be cloned as individuals.
|
||||
bool ShouldCloneChildren() const override { return false; }
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include <AzCore/Component/ComponentApplicationBus.h>
|
||||
#include <AzCore/Component/Entity.h>
|
||||
#include <AzCore/Component/TransformBus.h>
|
||||
#include <AzCore/Console/IConsole.h>
|
||||
#include <AzCore/Debug/Profiler.h>
|
||||
#include <AzCore/Math/Transform.h>
|
||||
#include <AzCore/RTTI/AttributeReader.h>
|
||||
@@ -57,6 +56,7 @@
|
||||
#include <AzToolsFramework/UI/PropertyEditor/EntityPropertyEditor.hxx>
|
||||
#include <AzToolsFramework/UI/Layer/NameConflictWarning.hxx>
|
||||
#include <AzToolsFramework/ViewportSelection/EditorHelpers.h>
|
||||
#include <AzToolsFramework/ViewportSelection/EditorSelectionUtil.h>
|
||||
#include <MathConversion.h>
|
||||
|
||||
#include <Atom/RPI.Public/ViewportContext.h>
|
||||
@@ -447,7 +447,7 @@ void SandboxIntegrationManager::OnEndUndo(const char* label, bool changed)
|
||||
// Add the undo only after we know it's got a legit change, we can't remove undos from the cry undo system so we do it here instead of OnBeginUndo
|
||||
if (changed && CUndo::IsRecording())
|
||||
{
|
||||
CUndo::Record(new CToolsApplicationUndoLink(label));
|
||||
CUndo::Record(new CToolsApplicationUndoLink());
|
||||
}
|
||||
if (m_startedUndoRecordingNestingLevel)
|
||||
{
|
||||
@@ -498,13 +498,11 @@ void SandboxIntegrationManager::EntityParentChanged(
|
||||
// before finally being saved, it will result in all of those layers saving, too.
|
||||
AZ::EntityId oldAncestor = oldParentId;
|
||||
|
||||
bool wasNotInLayer = false;
|
||||
AZ::EntityId oldLayer;
|
||||
do
|
||||
{
|
||||
if (!oldAncestor.IsValid())
|
||||
{
|
||||
wasNotInLayer = true;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -530,13 +528,11 @@ void SandboxIntegrationManager::EntityParentChanged(
|
||||
|
||||
AZ::EntityId newAncestor = newParentId;
|
||||
|
||||
bool isGoingToRootScene = false;
|
||||
AZ::EntityId newLayer;
|
||||
do
|
||||
{
|
||||
if (!newAncestor.IsValid())
|
||||
{
|
||||
isGoingToRootScene = true;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1394,13 +1390,13 @@ void SandboxIntegrationManager::ContextMenu_NewEntity()
|
||||
{
|
||||
AZ::Vector3 worldPosition = AZ::Vector3::CreateZero();
|
||||
|
||||
CViewport* view = GetIEditor()->GetViewManager()->GetGameViewport();
|
||||
// If we don't have a viewport active to aid in placement, the object
|
||||
// will be created at the origin.
|
||||
if (view)
|
||||
if (CViewport* view = GetIEditor()->GetViewManager()->GetGameViewport())
|
||||
{
|
||||
const QPoint viewPoint(static_cast<int>(m_contextMenuViewPoint.GetX()), static_cast<int>(m_contextMenuViewPoint.GetY()));
|
||||
worldPosition = view->GetHitLocation(viewPoint);
|
||||
worldPosition = AzToolsFramework::FindClosestPickIntersection(
|
||||
view->GetViewportId(), AzFramework::ScreenPointFromVector2(m_contextMenuViewPoint), AzToolsFramework::EditorPickRayLength,
|
||||
AzToolsFramework::GetDefaultEntityPlacementDistance());
|
||||
}
|
||||
|
||||
CreateNewEntityAtPosition(worldPosition);
|
||||
@@ -1675,6 +1671,12 @@ void SandboxIntegrationManager::GoToEntitiesInViewports(const AzToolsFramework::
|
||||
if (auto viewportContext = viewportContextManager->GetViewportContextById(viewIndex))
|
||||
{
|
||||
const AZ::Transform cameraTransform = viewportContext->GetCameraTransform();
|
||||
// do not attempt to interpolate to where we currently are
|
||||
if (cameraTransform.GetTranslation().IsClose(center))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const AZ::Vector3 forward = (center - cameraTransform.GetTranslation()).GetNormalized();
|
||||
|
||||
// move camera 25% further back than required
|
||||
|
||||
@@ -306,8 +306,7 @@ class CToolsApplicationUndoLink
|
||||
{
|
||||
public:
|
||||
|
||||
CToolsApplicationUndoLink(const char* description)
|
||||
: m_description(description)
|
||||
CToolsApplicationUndoLink()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -316,11 +315,6 @@ public:
|
||||
return 0;
|
||||
}
|
||||
|
||||
QString GetDescription() override
|
||||
{
|
||||
return m_description.c_str();
|
||||
}
|
||||
|
||||
void Undo(bool bUndo = true) override
|
||||
{
|
||||
// Always run the undo even if the flag was set to false, that just means that undo wasn't expressly desired, but can be used in cases of canceling the current super undo.
|
||||
@@ -354,8 +348,6 @@ public:
|
||||
w->setFocus(Qt::OtherFocusReason);
|
||||
}
|
||||
}
|
||||
|
||||
AZStd::string m_description;
|
||||
};
|
||||
|
||||
#endif // CRYINCLUDE_COMPONENTENTITYEDITORPLUGIN_SANDBOXINTEGRATION_H
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
#include <LmbrCentral/Rendering/LensFlareAsset.h>
|
||||
#include <LmbrCentral/Rendering/MeshAsset.h>
|
||||
#include <LmbrCentral/Rendering/MaterialAsset.h>
|
||||
|
||||
#include <AzCore/Memory/Memory.h>
|
||||
#include <AzCore/RTTI/TypeInfo.h>
|
||||
@@ -136,14 +135,6 @@ AssetCatalogModel::AssetCatalogModel(QObject* parent)
|
||||
}
|
||||
}
|
||||
|
||||
// Special cases for SimpleAssets. If these get full-fledged AssetData types, these cases can be removed.
|
||||
QString textureExtensions = LmbrCentral::TextureAsset::GetFileFilter();
|
||||
m_extensionToAssetType.insert(AZStd::make_pair(textureExtensions.replace("*", "").replace(" ", "").toStdString().c_str(), AZStd::vector<AZ::Uuid> { AZ::AzTypeInfo<LmbrCentral::TextureAsset>::Uuid() }));
|
||||
QString materialExtensions = LmbrCentral::MaterialAsset::GetFileFilter();
|
||||
m_extensionToAssetType.insert(AZStd::make_pair(materialExtensions.replace("*", "").replace(" ", "").toStdString().c_str(), AZStd::vector<AZ::Uuid> { AZ::AzTypeInfo<LmbrCentral::MaterialAsset>::Uuid() }));
|
||||
QString dccMaterialExtensions = LmbrCentral::DccMaterialAsset::GetFileFilter();
|
||||
m_extensionToAssetType.insert(AZStd::make_pair(dccMaterialExtensions.replace("*", "").replace(" ", "").toStdString().c_str(), AZStd::vector<AZ::Uuid> { AZ::AzTypeInfo<LmbrCentral::DccMaterialAsset>::Uuid() }));
|
||||
|
||||
AZ::SerializeContext* serializeContext = nullptr;
|
||||
EBUS_EVENT_RESULT(serializeContext, AZ::ComponentApplicationBus, GetSerializeContext);
|
||||
AZ_Assert(serializeContext, "Failed to acquire application serialize context.");
|
||||
|
||||
@@ -2640,7 +2640,7 @@ QSize OutlinerItemDelegate::sizeHint(const QStyleOptionViewItem& option, const Q
|
||||
m_cachedBoundingRectOfTallCharacter = QRect();
|
||||
};
|
||||
|
||||
QTimer::singleShot(0, resetFunction);
|
||||
QTimer::singleShot(0, this, resetFunction);
|
||||
}
|
||||
|
||||
// And add 8 to it gives the outliner roughly the visible spacing we're looking for.
|
||||
|
||||
@@ -121,6 +121,18 @@ namespace
|
||||
SortEntityChildrenRecursively(childId, comparer);
|
||||
}
|
||||
}
|
||||
|
||||
QModelIndex nextIndexForTree(bool direction, OutlinerTreeView *tree, QModelIndex current)
|
||||
{
|
||||
if (direction)
|
||||
{
|
||||
return tree->indexAbove(current);
|
||||
}
|
||||
else
|
||||
{
|
||||
return tree->indexBelow(current);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
OutlinerWidget::OutlinerWidget(QWidget* pParent, Qt::WindowFlags flags)
|
||||
@@ -891,9 +903,7 @@ void OutlinerWidget::DoSelectSliceRootNextToSelection(bool isTraversalUpwards)
|
||||
return;
|
||||
}
|
||||
|
||||
AZStd::function<QModelIndex(QModelIndex)> getNextIdxFunction =
|
||||
AZStd::bind(isTraversalUpwards ? &QTreeView::indexAbove : &QTreeView::indexBelow, treeView, AZStd::placeholders::_1);
|
||||
QModelIndex nextIdx = getNextIdxFunction(currentIdx);
|
||||
QModelIndex nextIdx = nextIndexForTree(isTraversalUpwards,treeView,currentIdx);
|
||||
bool foundSliceRoot = false;
|
||||
|
||||
while (nextIdx.isValid() && !foundSliceRoot)
|
||||
@@ -904,7 +914,7 @@ void OutlinerWidget::DoSelectSliceRootNextToSelection(bool isTraversalUpwards)
|
||||
AzToolsFramework::ToolsApplicationRequestBus::BroadcastResult(
|
||||
foundSliceRoot, &AzToolsFramework::ToolsApplicationRequests::IsSliceRootEntity, currentEntityId);
|
||||
|
||||
nextIdx = getNextIdxFunction(currentIdx);
|
||||
nextIdx = nextIndexForTree(isTraversalUpwards, treeView, currentIdx);
|
||||
}
|
||||
|
||||
if (foundSliceRoot)
|
||||
@@ -934,13 +944,10 @@ void OutlinerWidget::DoSelectEdgeSliceRoot(bool shouldSelectTopMostSlice)
|
||||
}
|
||||
|
||||
QModelIndex currentIdx;
|
||||
AZStd::function<QModelIndex(QModelIndex)> getNextIdxFunction;
|
||||
|
||||
if (shouldSelectTopMostSlice)
|
||||
{
|
||||
currentIdx = itemModel->index(0, OutlinerListModel::ColumnName);
|
||||
|
||||
getNextIdxFunction =
|
||||
AZStd::bind(&QTreeView::indexBelow, treeView, AZStd::placeholders::_1);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -949,9 +956,6 @@ void OutlinerWidget::DoSelectEdgeSliceRoot(bool shouldSelectTopMostSlice)
|
||||
{
|
||||
currentIdx = itemModel->index(itemModel->rowCount(currentIdx) - 1, OutlinerListModel::ColumnName, currentIdx);
|
||||
}
|
||||
|
||||
getNextIdxFunction =
|
||||
AZStd::bind(&QTreeView::indexAbove, treeView, AZStd::placeholders::_1);
|
||||
}
|
||||
|
||||
QModelIndex nextIdx = currentIdx;
|
||||
@@ -964,7 +968,7 @@ void OutlinerWidget::DoSelectEdgeSliceRoot(bool shouldSelectTopMostSlice)
|
||||
|
||||
AzToolsFramework::ToolsApplicationRequestBus::BroadcastResult(
|
||||
foundSliceRoot, &AzToolsFramework::ToolsApplicationRequests::IsSliceRootEntity, currentEntityId);
|
||||
nextIdx = getNextIdxFunction(currentIdx);
|
||||
nextIdx = nextIndexForTree(shouldSelectTopMostSlice,treeView,currentIdx);
|
||||
} while (nextIdx.isValid() && !foundSliceRoot);
|
||||
|
||||
if (foundSliceRoot)
|
||||
@@ -1416,7 +1420,10 @@ void OutlinerWidget::SortContent()
|
||||
}
|
||||
m_entitiesToSort.clear();
|
||||
|
||||
auto comparer = AZStd::bind(&CompareEntitiesForSorting, AZStd::placeholders::_1, AZStd::placeholders::_2, m_sortMode);
|
||||
auto comparer = [sortMode = m_sortMode](AZ::EntityId left, AZ::EntityId right) -> bool
|
||||
{
|
||||
return CompareEntitiesForSorting(left, right, sortMode);
|
||||
};
|
||||
for (const AZ::EntityId& entityId : parentsToSort)
|
||||
{
|
||||
SortEntityChildren(entityId, comparer);
|
||||
@@ -1433,7 +1440,10 @@ void OutlinerWidget::OnSortModeChanged(EntityOutliner::DisplaySortMode sortMode)
|
||||
if (sortMode != EntityOutliner::DisplaySortMode::Manually)
|
||||
{
|
||||
AZ_PROFILE_FUNCTION(AzToolsFramework);
|
||||
auto comparer = AZStd::bind(&CompareEntitiesForSorting, AZStd::placeholders::_1, AZStd::placeholders::_2, sortMode);
|
||||
auto comparer = [sortMode = m_sortMode](AZ::EntityId left, AZ::EntityId right) -> bool
|
||||
{
|
||||
return CompareEntitiesForSorting(left, right, sortMode);
|
||||
};
|
||||
SortEntityChildrenRecursively(AZ::EntityId(), comparer);
|
||||
}
|
||||
|
||||
|
||||
@@ -104,6 +104,7 @@
|
||||
#define ID_FILE_EXPORTTOGAMENOSURFACETEXTURE 33473
|
||||
#define ID_VIEW_SWITCHTOGAME 33477
|
||||
#define ID_VIEW_SWITCHTOGAME_FULLSCREEN 33478
|
||||
#define ID_VIEW_SWITCHTOGAME_VIEWPORT 33479
|
||||
#define ID_MOVE_OBJECT 33481
|
||||
#define ID_RENAME_OBJ 33483
|
||||
#define ID_FETCH 33496
|
||||
|
||||
@@ -112,8 +112,6 @@ SEditorSettings::SEditorSettings()
|
||||
m_showCircularDependencyError = true;
|
||||
bAutoloadLastLevelAtStartup = false;
|
||||
bMuteAudio = false;
|
||||
bEnableGameModeVR = false;
|
||||
|
||||
|
||||
objectHideMask = 0;
|
||||
objectSelectMask = 0xFFFFFFFF; // Initially all selectable.
|
||||
@@ -473,7 +471,7 @@ void SEditorSettings::LoadValue(const char* sSection, const char* sKey, ESystemC
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SEditorSettings::Save()
|
||||
void SEditorSettings::Save(bool isEditorClosing)
|
||||
{
|
||||
QString strStringPlaceholder;
|
||||
|
||||
@@ -640,14 +638,16 @@ void SEditorSettings::Save()
|
||||
// --- Settings Registry values
|
||||
|
||||
// Prefab System UI
|
||||
AzFramework::ApplicationRequests::Bus::Broadcast(
|
||||
&AzFramework::ApplicationRequests::SetPrefabSystemEnabled, prefabSystem);
|
||||
AzFramework::ApplicationRequests::Bus::Broadcast(&AzFramework::ApplicationRequests::SetPrefabSystemEnabled, prefabSystem);
|
||||
|
||||
AzToolsFramework::Prefab::PrefabLoaderInterface* prefabLoaderInterface =
|
||||
AZ::Interface<AzToolsFramework::Prefab::PrefabLoaderInterface>::Get();
|
||||
prefabLoaderInterface->SetSaveAllPrefabsPreference(levelSaveSettings.saveAllPrefabsPreference);
|
||||
|
||||
SaveSettingsRegistryFile();
|
||||
if (!isEditorClosing)
|
||||
{
|
||||
SaveSettingsRegistryFile();
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -267,7 +267,7 @@ struct SANDBOX_API SEditorSettings
|
||||
AZ_POP_DISABLE_DLL_EXPORT_BASECLASS_WARNING
|
||||
SEditorSettings();
|
||||
~SEditorSettings() = default;
|
||||
void Save();
|
||||
void Save(bool isEditorClosing = false);
|
||||
void Load();
|
||||
void LoadCloudSettings();
|
||||
|
||||
@@ -305,7 +305,6 @@ AZ_POP_DISABLE_DLL_EXPORT_BASECLASS_WARNING
|
||||
bool m_showCircularDependencyError;
|
||||
bool bAutoloadLastLevelAtStartup;
|
||||
bool bMuteAudio;
|
||||
bool bEnableGameModeVR;
|
||||
|
||||
//! Speed of camera movement.
|
||||
float cameraMoveSpeed;
|
||||
|
||||
@@ -103,7 +103,7 @@
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>General Availability</string>
|
||||
<string>development</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@@ -590,6 +590,16 @@ AmazonToolbar ToolbarManager::GetObjectToolbar() const
|
||||
return t;
|
||||
}
|
||||
|
||||
QMenu* ToolbarManager::CreatePlayButtonMenu() const
|
||||
{
|
||||
QMenu* playButtonMenu = new QMenu("Play Game");
|
||||
|
||||
playButtonMenu->addAction(m_actionManager->GetAction(ID_VIEW_SWITCHTOGAME_VIEWPORT));
|
||||
playButtonMenu->addAction(m_actionManager->GetAction(ID_VIEW_SWITCHTOGAME_FULLSCREEN));
|
||||
|
||||
return playButtonMenu;
|
||||
}
|
||||
|
||||
AmazonToolbar ToolbarManager::GetPlayConsoleToolbar() const
|
||||
{
|
||||
AmazonToolbar t = AmazonToolbar("PlayConsole", QObject::tr("Play Controls"));
|
||||
@@ -598,8 +608,17 @@ AmazonToolbar ToolbarManager::GetPlayConsoleToolbar() const
|
||||
t.AddAction(ID_TOOLBAR_WIDGET_SPACER_RIGHT, ORIGINAL_TOOLBAR_VERSION);
|
||||
t.AddAction(ID_TOOLBAR_SEPARATOR, ORIGINAL_TOOLBAR_VERSION);
|
||||
t.AddAction(ID_TOOLBAR_WIDGET_PLAYCONSOLE_LABEL, ORIGINAL_TOOLBAR_VERSION);
|
||||
t.AddAction(ID_VIEW_SWITCHTOGAME, TOOLBARS_WITH_PLAY_GAME);
|
||||
t.AddAction(ID_VIEW_SWITCHTOGAME_FULLSCREEN, TOOLBARS_WITH_PLAY_GAME);
|
||||
|
||||
QAction* playAction = m_actionManager->GetAction(ID_VIEW_SWITCHTOGAME);
|
||||
QToolButton* playButton = new QToolButton(t.Toolbar());
|
||||
|
||||
QMenu* menu = CreatePlayButtonMenu();
|
||||
menu->setParent(t.Toolbar());
|
||||
playAction->setMenu(menu);
|
||||
|
||||
playButton->setDefaultAction(playAction);
|
||||
t.AddWidget(playButton, ID_VIEW_SWITCHTOGAME, ORIGINAL_TOOLBAR_VERSION);
|
||||
|
||||
t.AddAction(ID_TOOLBAR_SEPARATOR, ORIGINAL_TOOLBAR_VERSION);
|
||||
t.AddAction(ID_SWITCH_PHYSICS, TOOLBARS_WITH_PLAY_GAME);
|
||||
return t;
|
||||
@@ -728,7 +747,14 @@ void AmazonToolbar::SetActionsOnInternalToolbar(ActionManager* actionManager)
|
||||
{
|
||||
if (actionManager->HasAction(actionId))
|
||||
{
|
||||
m_toolbar->addAction(actionManager->GetAction(actionId));
|
||||
if (actionData.widget != nullptr)
|
||||
{
|
||||
m_toolbar->addWidget(actionData.widget);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_toolbar->addAction(actionManager->GetAction(actionId));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1367,7 +1393,12 @@ void AmazonToolbar::InstantiateToolbar(QMainWindow* mainWindow, ToolbarManager*
|
||||
|
||||
void AmazonToolbar::AddAction(int actionId, int toolbarVersionAdded)
|
||||
{
|
||||
m_actions.push_back({ actionId, toolbarVersionAdded });
|
||||
AddWidget(nullptr, actionId, toolbarVersionAdded);
|
||||
}
|
||||
|
||||
void AmazonToolbar::AddWidget(QWidget* widget, int actionId, int toolbarVersionAdded)
|
||||
{
|
||||
m_actions.push_back({ actionId, toolbarVersionAdded, widget });
|
||||
}
|
||||
|
||||
void AmazonToolbar::Clear()
|
||||
|
||||
@@ -87,6 +87,7 @@ public:
|
||||
const QString& GetTranslatedName() const { return m_translatedName; }
|
||||
|
||||
void AddAction(int actionId, int toolbarVersionAdded = 0);
|
||||
void AddWidget(QWidget* widget, int actionId, int toolbarVersionAdded = 0);
|
||||
|
||||
QToolBar* Toolbar() const { return m_toolbar; }
|
||||
|
||||
@@ -117,6 +118,7 @@ private:
|
||||
{
|
||||
int actionId;
|
||||
int toolbarVersionAdded;
|
||||
QWidget* widget;
|
||||
|
||||
bool operator ==(const AmazonToolbar::ActionData& other) const
|
||||
{
|
||||
@@ -133,7 +135,9 @@ private:
|
||||
class AmazonToolBarExpanderWatcher;
|
||||
|
||||
class ToolbarManager
|
||||
: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ToolbarManager(ActionManager* actionManager, MainWindow* mainWindow);
|
||||
~ToolbarManager();
|
||||
@@ -178,6 +182,8 @@ private:
|
||||
void UpdateAllowedAreas(QToolBar* toolbar);
|
||||
bool IsDirty(const AmazonToolbar& toolbar) const;
|
||||
|
||||
QMenu* CreatePlayButtonMenu() const;
|
||||
|
||||
const AmazonToolbar* FindDefaultToolbar(const QString& toolbarName) const;
|
||||
AmazonToolbar* FindToolbar(const QString& toolbarName);
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <Atom/RPI.Public/Scene.h>
|
||||
#include <Atom/RPI.Public/View.h>
|
||||
#include <Atom/RPI.Reflect/System/RenderPipelineDescriptor.h>
|
||||
#include <PostProcess/PostProcessFeatureProcessor.h>
|
||||
#include <AzCore/Component/TransformBus.h>
|
||||
#include <AzCore/Math/MatrixUtils.h>
|
||||
#include <AzCore/Name/Name.h>
|
||||
@@ -47,18 +48,42 @@ namespace TrackView
|
||||
AZ::Name viewName = AZ::Name("MainCamera");
|
||||
m_view = AZ::RPI::View::CreateView(viewName, AZ::RPI::View::UsageCamera);
|
||||
m_renderPipeline->SetDefaultView(m_view);
|
||||
m_targetView = scene.GetDefaultRenderPipeline()->GetDefaultView();
|
||||
if (AZ::Render::PostProcessFeatureProcessor* fp = scene.GetFeatureProcessor<AZ::Render::PostProcessFeatureProcessor>())
|
||||
{
|
||||
// This will be set again to mimic the active camera in UpdateView
|
||||
fp->SetViewAlias(m_view, m_targetView);
|
||||
}
|
||||
}
|
||||
|
||||
void AtomOutputFrameCapture::DestroyPipeline(AZ::RPI::Scene& scene)
|
||||
{
|
||||
if (AZ::Render::PostProcessFeatureProcessor* fp = scene.GetFeatureProcessor<AZ::Render::PostProcessFeatureProcessor>())
|
||||
{
|
||||
// Remove view alias introduced in CreatePipeline and UpdateView
|
||||
fp->RemoveViewAlias(m_view);
|
||||
}
|
||||
scene.RemoveRenderPipeline(m_renderPipeline->GetId());
|
||||
m_passHierarchy.clear();
|
||||
m_renderPipeline.reset();
|
||||
m_view.reset();
|
||||
m_targetView.reset();
|
||||
}
|
||||
|
||||
void AtomOutputFrameCapture::UpdateView(const AZ::Matrix3x4& cameraTransform, const AZ::Matrix4x4& cameraProjection)
|
||||
void AtomOutputFrameCapture::UpdateView(const AZ::Matrix3x4& cameraTransform, const AZ::Matrix4x4& cameraProjection, const AZ::RPI::ViewPtr targetView)
|
||||
{
|
||||
if (targetView && targetView != m_targetView)
|
||||
{
|
||||
if (AZ::RPI::Scene* scene = SceneFromGameEntityContext())
|
||||
{
|
||||
if (AZ::Render::PostProcessFeatureProcessor* fp = scene->GetFeatureProcessor<AZ::Render::PostProcessFeatureProcessor>())
|
||||
{
|
||||
fp->SetViewAlias(m_view, targetView);
|
||||
m_targetView = targetView;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_view->SetCameraTransform(cameraTransform);
|
||||
m_view->SetViewToClipMatrix(cameraProjection);
|
||||
}
|
||||
|
||||
@@ -39,11 +39,12 @@ namespace TrackView
|
||||
CaptureFinishedCallback captureFinishedCallback);
|
||||
|
||||
//! Update the internal view that is associated with the created pipeline.
|
||||
void UpdateView(const AZ::Matrix3x4& cameraTransform, const AZ::Matrix4x4& cameraProjection);
|
||||
void UpdateView(const AZ::Matrix3x4& cameraTransform, const AZ::Matrix4x4& cameraProjection, const AZ::RPI::ViewPtr targetView = nullptr);
|
||||
|
||||
private:
|
||||
AZ::RPI::RenderPipelinePtr m_renderPipeline; //!< The internal render pipeline.
|
||||
AZ::RPI::ViewPtr m_view; //!< The view associated with the render pipeline.
|
||||
AZ::RPI::ViewPtr m_targetView; //!< The view that this render pipeline will mimic.
|
||||
AZStd::vector<AZStd::string> m_passHierarchy; //!< Pass hierarchy (includes pipelineName and CopyToSwapChain).
|
||||
CaptureFinishedCallback m_captureFinishedCallback; //!< Stored callback called from OnCaptureFinished.
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
#include <AzCore/Component/ComponentApplication.h>
|
||||
#include <AzFramework/Windowing/WindowBus.h>
|
||||
#include <Atom/RPI.Public/ViewProviderBus.h>
|
||||
|
||||
// Qt
|
||||
#include <QAction>
|
||||
@@ -91,9 +92,12 @@ namespace
|
||||
static void UpdateAtomOutputFrameCaptureView(TrackView::AtomOutputFrameCapture& atomOutputFrameCapture, const int width, const int height)
|
||||
{
|
||||
const AZ::EntityId activeCameraEntityId = TrackView::ActiveCameraEntityId();
|
||||
AZ::RPI::ViewPtr view = nullptr;
|
||||
AZ::RPI::ViewProviderBus::EventResult(view, activeCameraEntityId, &AZ::RPI::ViewProvider::GetView);
|
||||
atomOutputFrameCapture.UpdateView(
|
||||
TrackView::TransformFromEntityId(activeCameraEntityId),
|
||||
TrackView::ProjectionFromCameraEntityId(activeCameraEntityId, static_cast<float>(width), static_cast<float>(height)));
|
||||
TrackView::ProjectionFromCameraEntityId(activeCameraEntityId, aznumeric_cast<float>(width), aznumeric_cast<float>(height)),
|
||||
view);
|
||||
}
|
||||
|
||||
CSequenceBatchRenderDialog::CSequenceBatchRenderDialog(float fps, QWidget* pParent /* = nullptr */)
|
||||
|
||||
@@ -108,18 +108,15 @@ void CSoundKeyUIControls::OnUIChange(IVariable* pVar, CTrackViewKeyBundle& selec
|
||||
{
|
||||
ISoundKey soundKey;
|
||||
keyHandle.GetKey(&soundKey);
|
||||
bool bChangedSoundFile = false;
|
||||
|
||||
if (pVar == mv_startTrigger.GetVar())
|
||||
{
|
||||
QString sFilename = mv_startTrigger;
|
||||
bChangedSoundFile = sFilename != soundKey.sStartTrigger.c_str();
|
||||
soundKey.sStartTrigger = sFilename.toUtf8().data();
|
||||
}
|
||||
else if (pVar == mv_stopTrigger.GetVar())
|
||||
{
|
||||
QString sFilename = mv_stopTrigger;
|
||||
bChangedSoundFile = sFilename != soundKey.sStopTrigger.c_str();
|
||||
soundKey.sStopTrigger = sFilename.toUtf8().data();
|
||||
}
|
||||
|
||||
|
||||
@@ -2233,7 +2233,6 @@ void CTrackViewDopeSheetBase::AddKeys(const QPoint& point, const bool bTryAddKey
|
||||
|
||||
if (pTrack && inRange)
|
||||
{
|
||||
bool keyCreated = false;
|
||||
if (bTryAddKeysInGroup && pNode->GetParentNode()) // Add keys in group
|
||||
{
|
||||
CTrackViewTrackBundle tracksInGroup = pNode->GetTracksByParam(pTrack->GetParameterType());
|
||||
@@ -2248,8 +2247,6 @@ void CTrackViewDopeSheetBase::AddKeys(const QPoint& point, const bool bTryAddKey
|
||||
AzToolsFramework::ScopedUndoBatch undoBatch("Create Key");
|
||||
pCurrTrack->CreateKey(keyTime);
|
||||
undoBatch.MarkEntityDirty(sequence->GetSequenceComponentEntityId());
|
||||
|
||||
keyCreated = true;
|
||||
}
|
||||
}
|
||||
else // A compound track
|
||||
@@ -2262,8 +2259,6 @@ void CTrackViewDopeSheetBase::AddKeys(const QPoint& point, const bool bTryAddKey
|
||||
AzToolsFramework::ScopedUndoBatch undoBatch("Create Key");
|
||||
pSubTrack->CreateKey(keyTime);
|
||||
undoBatch.MarkEntityDirty(sequence->GetSequenceComponentEntityId());
|
||||
|
||||
keyCreated = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2276,15 +2271,13 @@ void CTrackViewDopeSheetBase::AddKeys(const QPoint& point, const bool bTryAddKey
|
||||
AzToolsFramework::ScopedUndoBatch undoBatch("Create Key");
|
||||
pTrack->CreateKey(keyTime);
|
||||
undoBatch.MarkEntityDirty(sequence->GetSequenceComponentEntityId());
|
||||
|
||||
keyCreated = true;
|
||||
}
|
||||
}
|
||||
else // A compound track
|
||||
{
|
||||
if (pTrack->GetValueType() == AnimValueType::RGB)
|
||||
{
|
||||
keyCreated = CreateColorKey(pTrack, keyTime);
|
||||
CreateColorKey(pTrack, keyTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2295,7 +2288,6 @@ void CTrackViewDopeSheetBase::AddKeys(const QPoint& point, const bool bTryAddKey
|
||||
if (IsOkToAddKeyHere(pSubTrack, keyTime))
|
||||
{
|
||||
pSubTrack->CreateKey(keyTime);
|
||||
keyCreated = true;
|
||||
}
|
||||
}
|
||||
undoBatch.MarkEntityDirty(sequence->GetSequenceComponentEntityId());
|
||||
@@ -2617,7 +2609,6 @@ void CTrackViewDopeSheetBase::DrawSelectTrack(const Range& timeRange, QPainter*
|
||||
void CTrackViewDopeSheetBase::DrawBoolTrack(const Range& timeRange, QPainter* painter, CTrackViewTrack* pTrack, const QRect& rc)
|
||||
{
|
||||
int x0 = TimeToClient(timeRange.start);
|
||||
float t0 = timeRange.start;
|
||||
|
||||
const QBrush prevBrush = painter->brush();
|
||||
painter->setBrush(m_visibilityBrush);
|
||||
@@ -2648,7 +2639,6 @@ void CTrackViewDopeSheetBase::DrawBoolTrack(const Range& timeRange, QPainter* pa
|
||||
painter->fillRect(QRect(QPoint(x0, rc.top() + 4), QPoint(x, rc.bottom() - 4)), gradient);
|
||||
}
|
||||
|
||||
t0 = time;
|
||||
x0 = x;
|
||||
}
|
||||
int x = TimeToClient(timeRange.end);
|
||||
|
||||
@@ -198,7 +198,6 @@ void CTrackViewKeyPropertiesDlg::OnKeySelectionChanged(CTrackViewSequence* seque
|
||||
|
||||
m_wndProps->setEnabled(false);
|
||||
m_wndTrackProps->setEnabled(false);
|
||||
bool bAssigned = false;
|
||||
if (selectedKeys.GetKeyCount() > 0 && selectedKeys.AreAllKeysOfSameType())
|
||||
{
|
||||
CTrackViewTrack* pTrack = selectedKeys.GetKey(0).GetTrack();
|
||||
@@ -215,12 +214,6 @@ void CTrackViewKeyPropertiesDlg::OnKeySelectionChanged(CTrackViewSequence* seque
|
||||
{
|
||||
AddVars(m_keyControls[i]);
|
||||
}
|
||||
|
||||
if (m_keyControls[i]->OnKeySelectionChange(selectedKeys))
|
||||
{
|
||||
bAssigned = true;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,6 @@ protected:
|
||||
}
|
||||
|
||||
int GetSize() override { return sizeof(*this); }
|
||||
QString GetDescription() override { return "UndoTrackViewSplineCtrl"; };
|
||||
|
||||
void Undo(bool bUndo) override
|
||||
{
|
||||
|
||||
@@ -6,9 +6,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_TRACKVIEW_TRACKVIEWUNDO_H
|
||||
#define CRYINCLUDE_EDITOR_TRACKVIEW_TRACKVIEWUNDO_H
|
||||
#pragma once
|
||||
|
||||
#include "TrackViewTrack.h"
|
||||
@@ -27,11 +24,10 @@ public:
|
||||
CUndoComponentEntityTrackObject(CTrackViewTrack* track);
|
||||
|
||||
protected:
|
||||
virtual int GetSize() override { return sizeof(*this); }
|
||||
virtual QString GetDescription() override { return "Undo Component Entity Track Modify"; };
|
||||
int GetSize() override { return sizeof(*this); }
|
||||
|
||||
virtual void Undo(bool bUndo) override;
|
||||
virtual void Redo() override;
|
||||
void Undo(bool bUndo) override;
|
||||
void Redo() override;
|
||||
|
||||
private:
|
||||
|
||||
@@ -50,5 +46,3 @@ private:
|
||||
CTrackViewTrackMemento m_undo;
|
||||
CTrackViewTrackMemento m_redo;
|
||||
};
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_TRACKVIEW_TRACKVIEWUNDO_H
|
||||
|
||||
@@ -8,10 +8,6 @@
|
||||
|
||||
|
||||
// Description : Interface for implementation of IUndo objects.
|
||||
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_UNDO_IUNDOOBJECT_H
|
||||
#define CRYINCLUDE_EDITOR_UNDO_IUNDOOBJECT_H
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
@@ -26,8 +22,6 @@ struct IUndoObject
|
||||
virtual void Release() { delete this; };
|
||||
//! Return size of this Undo object.
|
||||
virtual int GetSize() = 0;
|
||||
//! Return description of this Undo object.
|
||||
virtual QString GetDescription() = 0;
|
||||
|
||||
//! Undo this object.
|
||||
//! @param bUndo If true this operation called in response to Undo operation.
|
||||
@@ -37,14 +31,5 @@ struct IUndoObject
|
||||
virtual void Redo() = 0;
|
||||
|
||||
// Returns the name of undo object
|
||||
virtual QString GetObjectName(){ return QString(); };
|
||||
|
||||
// Returns the name of related editor object.
|
||||
// Ex: For a undo action which would modify value for var "Emitter Strength" of emitter "Level.example",
|
||||
// this function will return emitter name "Level.example" - Vera, Confetti
|
||||
virtual QString GetEditorObjectName() { return QString(); };
|
||||
|
||||
virtual bool IsChanged([[maybe_unused]] unsigned int& compareValue) const { return false; }
|
||||
virtual QString GetObjectName(){ return QString(); }
|
||||
};
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_UNDO_IUNDOOBJECT_H
|
||||
|
||||
@@ -23,9 +23,9 @@
|
||||
// AzCore
|
||||
#include <AzCore/Component/TickBus.h>
|
||||
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
|
||||
#include <AzCore/Utils/Utils.h>
|
||||
|
||||
// AzFramework
|
||||
#include <AzFramework/API/ApplicationAPI.h>
|
||||
|
||||
// AzQtComponents
|
||||
#include <AzQtComponents/Utilities/DesktopUtilities.h>
|
||||
@@ -54,92 +54,14 @@
|
||||
#include <Shellapi.h>
|
||||
#endif
|
||||
|
||||
bool CFileUtil::s_singleFileDlgPref[IFileUtil::EFILE_TYPE_LAST] = { true, true, true, true, true };
|
||||
bool CFileUtil::s_multiFileDlgPref[IFileUtil::EFILE_TYPE_LAST] = { true, true, true, true, true };
|
||||
bool CFileUtil::s_singleFileDlgPref[IFileUtil::EFILE_TYPE_LAST] = { true, true, true, true };
|
||||
bool CFileUtil::s_multiFileDlgPref[IFileUtil::EFILE_TYPE_LAST] = { true, true, true, true };
|
||||
|
||||
CAutoRestorePrimaryCDRoot::~CAutoRestorePrimaryCDRoot()
|
||||
{
|
||||
QDir::setCurrent(GetIEditor()->GetPrimaryCDFolder());
|
||||
}
|
||||
|
||||
bool CFileUtil::CompileLuaFile(const char* luaFilename)
|
||||
{
|
||||
QString luaFile = luaFilename;
|
||||
|
||||
if (luaFile.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if this file is in Archive.
|
||||
{
|
||||
CCryFile file;
|
||||
if (file.Open(luaFilename, "rb"))
|
||||
{
|
||||
// Check if in pack.
|
||||
if (file.IsInPak())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
luaFile = Path::GamePathToFullPath(luaFilename);
|
||||
|
||||
// First try compiling script and see if it have any errors.
|
||||
QString LuaCompiler;
|
||||
QString CompilerOutput;
|
||||
|
||||
// Create the filepath of the lua compiler
|
||||
QString szExeFileName = qApp->applicationFilePath();
|
||||
QString exePath = Path::GetPath(szExeFileName);
|
||||
|
||||
#if defined(AZ_PLATFORM_WINDOWS)
|
||||
const char* luaCompiler = "LuaCompiler.exe";
|
||||
#else
|
||||
const char* luaCompiler = "lua";
|
||||
#endif
|
||||
LuaCompiler = Path::AddPathSlash(exePath) + luaCompiler + " ";
|
||||
|
||||
AZStd::string path = luaFile.toUtf8().data();
|
||||
EBUS_EVENT(AzFramework::ApplicationRequests::Bus, NormalizePath, path);
|
||||
|
||||
QString finalPath = path.c_str();
|
||||
finalPath = "\"" + finalPath + "\"";
|
||||
|
||||
// Add the name of the Lua file
|
||||
QString cmdLine = LuaCompiler + finalPath;
|
||||
|
||||
// Execute the compiler and capture the output
|
||||
if (!GetIEditor()->ExecuteConsoleApp(cmdLine, CompilerOutput))
|
||||
{
|
||||
QMessageBox::critical(QApplication::activeWindow(), QString(), QObject::tr("Error while executing '%1', make sure the file is in" \
|
||||
" your Primary CD folder !").arg(luaCompiler));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check return string
|
||||
if (!CompilerOutput.isEmpty())
|
||||
{
|
||||
// Errors while compiling file.
|
||||
|
||||
// Show output from Lua compiler
|
||||
if (QMessageBox::critical(QApplication::activeWindow(), QObject::tr("Lua Compiler"),
|
||||
QObject::tr("Error output from Lua compiler:\r\n%1\r\nDo you want to edit the file ?").arg(CompilerOutput), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes)
|
||||
{
|
||||
int line = 0;
|
||||
int index = CompilerOutput.indexOf("at line");
|
||||
if (index >= 0)
|
||||
{
|
||||
azsscanf(CompilerOutput.mid(index).toUtf8().data(), "at line %d", &line);
|
||||
}
|
||||
// Open the Lua file for editing
|
||||
EditTextFile(luaFile.toUtf8().data(), line);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CFileUtil::ExtractFile(QString& file, bool bMsgBoxAskForExtraction, const char* pDestinationFilename)
|
||||
{
|
||||
@@ -205,7 +127,7 @@ void CFileUtil::EditTextFile(const char* txtFile, int line, IFileUtil::ETextFile
|
||||
{
|
||||
QString file = txtFile;
|
||||
|
||||
QString fullPathName = Path::GamePathToFullPath(file);
|
||||
QString fullPathName = Path::GamePathToFullPath(file);
|
||||
ExtractFile(fullPathName);
|
||||
QString cmd(fullPathName);
|
||||
#if defined (AZ_PLATFORM_WINDOWS)
|
||||
@@ -301,64 +223,6 @@ void CFileUtil::EditTextureFile(const char* textureFile, [[maybe_unused]] bool b
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CFileUtil::EditMayaFile(const char* filepath, const bool bExtractFromPak, const bool bUseGameFolder)
|
||||
{
|
||||
QString dosFilepath = PathUtil::ToDosPath(filepath).c_str();
|
||||
if (bExtractFromPak)
|
||||
{
|
||||
ExtractFile(dosFilepath);
|
||||
}
|
||||
|
||||
if (bUseGameFolder)
|
||||
{
|
||||
const QString sGameFolder = Path::GetEditingGameDataFolder().c_str();
|
||||
int nLength = sGameFolder.toUtf8().count();
|
||||
if (azstrnicmp(filepath, sGameFolder.toUtf8().data(), nLength) != 0)
|
||||
{
|
||||
dosFilepath = sGameFolder + '\\' + filepath;
|
||||
}
|
||||
|
||||
dosFilepath = PathUtil::ToDosPath(dosFilepath.toUtf8().data()).c_str();
|
||||
}
|
||||
|
||||
const char* engineRoot;
|
||||
EBUS_EVENT_RESULT(engineRoot, AzFramework::ApplicationRequests::Bus, GetEngineRoot);
|
||||
|
||||
const QString fullPath = QString(engineRoot) + '\\' + dosFilepath;
|
||||
|
||||
if (gSettings.animEditor.isEmpty())
|
||||
{
|
||||
AzQtComponents::ShowFileOnDesktop(fullPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!QProcess::startDetached(gSettings.animEditor, { fullPath }))
|
||||
{
|
||||
CryMessageBox("Can't open the file. You can specify a source editor in Sandbox Preferences or create an association in Windows.", "Cannot open file!", MB_OK | MB_ICONERROR);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CFileUtil::EditFile(const char* filePath, const bool bExtrackFromPak, const bool bUseGameFolder)
|
||||
{
|
||||
QString extension = filePath;
|
||||
extension.remove(0, extension.lastIndexOf('.'));
|
||||
|
||||
if (extension.compare(".ma") == 0)
|
||||
{
|
||||
return EditMayaFile(filePath, bExtrackFromPak, bUseGameFolder);
|
||||
}
|
||||
else if ((extension.compare(".bspace") == 0) || (extension.compare(".comb") == 0))
|
||||
{
|
||||
EditTextFile(filePath, 0, IFileUtil::FILE_TYPE_BSPACE);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CFileUtil::CalculateDccFilename(const QString& assetFilename, QString& dccFilename)
|
||||
|
||||
@@ -25,14 +25,9 @@ public:
|
||||
|
||||
static void ShowInExplorer(const QString& path);
|
||||
|
||||
// Try to compile the given lua file: returns true if compilation succeeded, false on failure.
|
||||
static bool CompileLuaFile(const char* luaFilename);
|
||||
|
||||
static bool ExtractFile(QString& file, bool bMsgBoxAskForExtraction = true, const char* pDestinationFilename = nullptr);
|
||||
static void EditTextFile(const char* txtFile, int line = 0, IFileUtil::ETextFileType fileType = IFileUtil::FILE_TYPE_SCRIPT);
|
||||
static void EditTextureFile(const char* txtureFile, bool bUseGameFolder);
|
||||
static bool EditMayaFile(const char* mayaFile, const bool bExtractFromPak, const bool bUseGameFolder);
|
||||
static bool EditFile(const char* filePath, const bool bExtrackFromPak, const bool bUseGameFolder);
|
||||
|
||||
//! dcc filename calculation and extraction sub-routines
|
||||
static bool CalculateDccFilename(const QString& assetFilename, QString& dccFilename);
|
||||
|
||||
@@ -20,21 +20,11 @@ void CFileUtil_impl::ShowInExplorer(const QString& path)
|
||||
CFileUtil::ShowInExplorer(path);
|
||||
}
|
||||
|
||||
bool CFileUtil_impl::CompileLuaFile(const char* luaFilename)
|
||||
{
|
||||
return CFileUtil::CompileLuaFile(luaFilename);
|
||||
}
|
||||
|
||||
bool CFileUtil_impl::ExtractFile(QString& file, bool bMsgBoxAskForExtraction, const char* pDestinationFilename)
|
||||
{
|
||||
return CFileUtil::ExtractFile(file, bMsgBoxAskForExtraction, pDestinationFilename);
|
||||
}
|
||||
|
||||
void CFileUtil_impl::EditTextFile(const char* txtFile, int line, ETextFileType fileType)
|
||||
{
|
||||
CFileUtil::EditTextFile(txtFile, line, fileType);
|
||||
}
|
||||
|
||||
void CFileUtil_impl::EditTextureFile(const char* txtureFile, bool bUseGameFolder)
|
||||
{
|
||||
CFileUtil::EditTextureFile(txtureFile, bUseGameFolder);
|
||||
|
||||
@@ -36,9 +36,7 @@ public:
|
||||
|
||||
void ShowInExplorer(const QString& path) override;
|
||||
|
||||
bool CompileLuaFile(const char* luaFilename) override;
|
||||
bool ExtractFile(QString& file, bool bMsgBoxAskForExtraction = true, const char* pDestinationFilename = nullptr) override;
|
||||
void EditTextFile(const char* txtFile, int line = 0, ETextFileType fileType = FILE_TYPE_SCRIPT) override;
|
||||
void EditTextureFile(const char* txtureFile, bool bUseGameFolder) override;
|
||||
|
||||
//! dcc filename calculation and extraction sub-routines
|
||||
|
||||
@@ -75,17 +75,16 @@ void CImageEx::ReverseUpDown()
|
||||
}
|
||||
|
||||
uint32* pPixData = GetData();
|
||||
uint32* pReversePix = new uint32[GetWidth() * GetHeight()];
|
||||
|
||||
for (int i = GetHeight() - 1, i2 = 0; i >= 0; i--, i2++)
|
||||
const int height = GetHeight();
|
||||
const int width = GetWidth();
|
||||
for (int i = 0; i < height / 2; i++)
|
||||
{
|
||||
for (int k = 0; k < GetWidth(); k++)
|
||||
for (int j = 0; j < width; j++)
|
||||
{
|
||||
pReversePix[i2 * GetWidth() + k] = pPixData[i * GetWidth() + k];
|
||||
AZStd::swap(pPixData[i * width + j], pPixData[(height - 1 - i) * width + j]);
|
||||
}
|
||||
}
|
||||
|
||||
Attach(pReversePix, GetWidth(), GetHeight());
|
||||
}
|
||||
|
||||
void CImageEx::FillAlpha(unsigned char value)
|
||||
|
||||
@@ -197,11 +197,9 @@ bool CImageGif::Load(const QString& fileName, CImageEx& outImage)
|
||||
return false;
|
||||
}
|
||||
|
||||
int numcols;
|
||||
unsigned char ch, ch1;
|
||||
uint8* ptr1;
|
||||
int i;
|
||||
short transparency = -1;
|
||||
|
||||
TImage<uint8> outImageIndex;
|
||||
|
||||
@@ -246,7 +244,6 @@ bool CImageGif::Load(const QString& fileName, CImageEx& outImage)
|
||||
HasColormap = ((ch & COLORMAPMASK) ? true : false);
|
||||
|
||||
BitsPerPixel = (ch & 7) + 1;
|
||||
numcols = ColorMapSize = 1 << BitsPerPixel;
|
||||
BitMask = ColorMapSize - 1;
|
||||
|
||||
Background = NEXTBYTE; /* background color... not used. */
|
||||
@@ -290,10 +287,6 @@ bool CImageGif::Load(const QString& fileName, CImageEx& outImage)
|
||||
{
|
||||
case GRAPHIC_EXT:
|
||||
ch = NEXTBYTE;
|
||||
if (ptr[0] & 0x1)
|
||||
{
|
||||
transparency = ptr[3]; /* transparent color index */
|
||||
}
|
||||
ptr += ch;
|
||||
break;
|
||||
case PLAINTEXT_EXT:
|
||||
@@ -317,9 +310,6 @@ bool CImageGif::Load(const QString& fileName, CImageEx& outImage)
|
||||
}
|
||||
}
|
||||
|
||||
//if (transparency >= 0)
|
||||
//mfSet_transparency(transparency);
|
||||
|
||||
/* Now read in values from the image descriptor */
|
||||
|
||||
ch = NEXTBYTE;
|
||||
|
||||
@@ -1,572 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "EditorDefs.h"
|
||||
|
||||
#include "KDTree.h"
|
||||
|
||||
#include <IStatObj.h>
|
||||
|
||||
class KDTreeNode
|
||||
{
|
||||
public:
|
||||
KDTreeNode()
|
||||
{
|
||||
pChildren[0] = nullptr;
|
||||
pChildren[1] = nullptr;
|
||||
pVertexIndices = nullptr;
|
||||
}
|
||||
~KDTreeNode()
|
||||
{
|
||||
if (!IsLeaf())
|
||||
{
|
||||
if (pChildren[0])
|
||||
{
|
||||
delete pChildren[0];
|
||||
}
|
||||
if (pChildren[1])
|
||||
{
|
||||
delete pChildren[1];
|
||||
}
|
||||
}
|
||||
else if (GetVertexBufferSize() > 1)
|
||||
{
|
||||
if (pVertexIndices)
|
||||
{
|
||||
delete [] pVertexIndices;
|
||||
}
|
||||
}
|
||||
}
|
||||
uint32 GetVertexBufferSize() const
|
||||
{
|
||||
return nVertexIndexBufferSize;
|
||||
}
|
||||
float GetSplitPos() const
|
||||
{
|
||||
return splitPos;
|
||||
}
|
||||
void SetSplitPos(float pos)
|
||||
{
|
||||
splitPos = pos;
|
||||
}
|
||||
CKDTree::ESplitAxis GetSplitAxis() const
|
||||
{
|
||||
if (splitAxis == 0)
|
||||
{
|
||||
return CKDTree::eSA_X;
|
||||
}
|
||||
if (splitAxis == 1)
|
||||
{
|
||||
return CKDTree::eSA_Y;
|
||||
}
|
||||
if (splitAxis == 2)
|
||||
{
|
||||
return CKDTree::eSA_Z;
|
||||
}
|
||||
return CKDTree::eSA_Invalid;
|
||||
}
|
||||
void SetSplitAxis(const CKDTree::ESplitAxis& axis)
|
||||
{
|
||||
splitAxis = axis;
|
||||
}
|
||||
bool IsLeaf() const
|
||||
{
|
||||
return pChildren[0] == nullptr && pChildren[1] == nullptr;
|
||||
}
|
||||
KDTreeNode* GetChild(uint32 nIndex) const
|
||||
{
|
||||
if (nIndex > 1)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
return pChildren[nIndex];
|
||||
}
|
||||
void SetChild(uint32 nIndex, KDTreeNode* pNode)
|
||||
{
|
||||
if (nIndex > 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (pChildren[nIndex])
|
||||
{
|
||||
delete pChildren[nIndex];
|
||||
}
|
||||
pChildren[nIndex] = pNode;
|
||||
}
|
||||
const AABB& GetBoundBox()
|
||||
{
|
||||
return boundbox;
|
||||
}
|
||||
void SetBoundBox(const AABB& aabb)
|
||||
{
|
||||
boundbox = aabb;
|
||||
}
|
||||
void SetVertexIndexBuffer(std::vector<uint32>& vertexInfos)
|
||||
{
|
||||
nVertexIndexBufferSize = (uint32)vertexInfos.size();
|
||||
if (nVertexIndexBufferSize == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (nVertexIndexBufferSize == 1)
|
||||
{
|
||||
oneIndex = vertexInfos[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
pVertexIndices = new uint32[nVertexIndexBufferSize];
|
||||
memcpy(pVertexIndices, &vertexInfos[0], sizeof(uint32) * nVertexIndexBufferSize);
|
||||
}
|
||||
}
|
||||
uint32 GetVertexIndex(uint32 nIndex) const
|
||||
{
|
||||
if (GetVertexBufferSize() == 1)
|
||||
{
|
||||
return oneIndex & 0x00FFFFFF;
|
||||
}
|
||||
|
||||
return pVertexIndices[nIndex] & 0x00FFFFFF;
|
||||
}
|
||||
uint32 GetObjIndex(uint32 nIndex) const
|
||||
{
|
||||
if (GetVertexBufferSize() == 1)
|
||||
{
|
||||
return (oneIndex & 0xFF000000) >> 24;
|
||||
}
|
||||
|
||||
return (pVertexIndices[nIndex] & 0xFF000000) >> 24;
|
||||
}
|
||||
|
||||
private:
|
||||
union
|
||||
{
|
||||
float splitPos; // Interior
|
||||
uint32 oneIndex; // Leaf
|
||||
uint32* pVertexIndices; // Leaf : high 8bits - object index, low 24bits - vertex index
|
||||
};
|
||||
union
|
||||
{
|
||||
uint32 splitAxis; // Interior
|
||||
uint32 nVertexIndexBufferSize; // Leaf
|
||||
};
|
||||
AABB boundbox; // Both
|
||||
KDTreeNode* pChildren[2]; // Interior
|
||||
};
|
||||
|
||||
CKDTree::ESplitAxis SearchForBestSplitAxis(const AABB& aabb)
|
||||
{
|
||||
float xsize = aabb.max.x - aabb.min.x;
|
||||
float ysize = aabb.max.y - aabb.min.y;
|
||||
float zsize = aabb.max.z - aabb.min.z;
|
||||
|
||||
CKDTree::ESplitAxis axis;
|
||||
if (xsize > ysize && xsize > zsize)
|
||||
{
|
||||
axis = CKDTree::eSA_X;
|
||||
}
|
||||
else if (ysize > zsize && ysize > xsize)
|
||||
{
|
||||
axis = CKDTree::eSA_Y;
|
||||
}
|
||||
else
|
||||
{
|
||||
axis = CKDTree::eSA_Z;
|
||||
}
|
||||
|
||||
return axis;
|
||||
}
|
||||
|
||||
bool SearchForBestSplitPos(CKDTree::ESplitAxis axis, const std::vector<CKDTree::SStatObj>& statObjList, std::vector<uint32>& indices, float& outBestSplitPos)
|
||||
{
|
||||
if (axis != CKDTree::eSA_X && axis != CKDTree::eSA_Y && axis != CKDTree::eSA_Z)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
outBestSplitPos = 0;
|
||||
|
||||
int nSizeOfIndices = static_cast<int>(indices.size());
|
||||
|
||||
for (int i = 0; i < nSizeOfIndices; ++i)
|
||||
{
|
||||
int nObjIndex = (indices[i] & 0xFF000000) >> 24;
|
||||
int nVertexIndex = (indices[i] & 0xFFFFFF);
|
||||
|
||||
const CKDTree::SStatObj* pObj = &statObjList[nObjIndex];
|
||||
|
||||
const IIndexedMesh* pMesh = pObj->pStatObj->GetIndexedMesh();
|
||||
if (pMesh == nullptr)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
IIndexedMesh::SMeshDescription meshDesc;
|
||||
pMesh->GetMeshDescription(meshDesc);
|
||||
|
||||
if (meshDesc.m_pVerts)
|
||||
{
|
||||
outBestSplitPos += pObj->tm.TransformPoint(meshDesc.m_pVerts[nVertexIndex])[axis];
|
||||
}
|
||||
else if (meshDesc.m_pVertsF16)
|
||||
{
|
||||
outBestSplitPos += pObj->tm.TransformPoint(meshDesc.m_pVertsF16[nVertexIndex].ToVec3())[axis];
|
||||
}
|
||||
}
|
||||
|
||||
outBestSplitPos /= nSizeOfIndices;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
struct SSplitInfo
|
||||
{
|
||||
AABB aboveBoundbox;
|
||||
std::vector<uint32> aboveIndices;
|
||||
AABB belowBoundbox;
|
||||
std::vector<uint32> belowIndices;
|
||||
};
|
||||
|
||||
bool SplitNode(const std::vector<CKDTree::SStatObj>& statObjList, const AABB& boundbox, const std::vector<uint32>& indices, CKDTree::ESplitAxis splitAxis, float splitPos, SSplitInfo& outInfo)
|
||||
{
|
||||
if (splitAxis != CKDTree::eSA_X && splitAxis != CKDTree::eSA_Y && splitAxis != CKDTree::eSA_Z)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
outInfo.aboveBoundbox = boundbox;
|
||||
outInfo.belowBoundbox = boundbox;
|
||||
|
||||
outInfo.aboveBoundbox.max[splitAxis] = splitPos;
|
||||
outInfo.belowBoundbox.min[splitAxis] = splitPos;
|
||||
|
||||
uint32 iIndexSize = (uint32)indices.size();
|
||||
outInfo.aboveIndices.reserve(iIndexSize);
|
||||
outInfo.belowIndices.reserve(iIndexSize);
|
||||
|
||||
for (uint32 i = 0; i < iIndexSize; ++i)
|
||||
{
|
||||
int nObjIndex = (indices[i] & 0xFF000000) >> 24;
|
||||
int nVertexIndex = indices[i] & 0xFFFFFF;
|
||||
|
||||
const CKDTree::SStatObj* pObj = &statObjList[nObjIndex];
|
||||
|
||||
const IIndexedMesh* pMesh = pObj->pStatObj->GetIndexedMesh();
|
||||
if (pMesh == nullptr)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
IIndexedMesh::SMeshDescription meshDesc;
|
||||
pMesh->GetMeshDescription(meshDesc);
|
||||
|
||||
Vec3 vPos;
|
||||
if (meshDesc.m_pVerts)
|
||||
{
|
||||
vPos = pObj->tm.TransformPoint(meshDesc.m_pVerts[nVertexIndex]);
|
||||
}
|
||||
else if (meshDesc.m_pVertsF16)
|
||||
{
|
||||
vPos = pObj->tm.TransformPoint(meshDesc.m_pVertsF16[nVertexIndex].ToVec3());
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (vPos[splitAxis] < splitPos)
|
||||
{
|
||||
outInfo.aboveIndices.push_back(indices[i]);
|
||||
assert(outInfo.aboveBoundbox.IsContainPoint(vPos));
|
||||
}
|
||||
else
|
||||
{
|
||||
outInfo.belowIndices.push_back(indices[i]);
|
||||
assert(outInfo.belowBoundbox.IsContainPoint(vPos));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
CKDTree::CKDTree()
|
||||
{
|
||||
m_pRootNode = nullptr;
|
||||
}
|
||||
|
||||
CKDTree::~CKDTree()
|
||||
{
|
||||
if (m_pRootNode)
|
||||
{
|
||||
delete m_pRootNode;
|
||||
}
|
||||
}
|
||||
|
||||
bool CKDTree::Build(IStatObj* pStatObj)
|
||||
{
|
||||
if (pStatObj == nullptr)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
m_StatObjectList.clear();
|
||||
|
||||
if (pStatObj->GetIndexedMesh(true))
|
||||
{
|
||||
SStatObj rootObj;
|
||||
rootObj.tm.SetIdentity();
|
||||
rootObj.pStatObj = pStatObj;
|
||||
m_StatObjectList.push_back(rootObj);
|
||||
}
|
||||
|
||||
ConstructStatObjList(pStatObj, Matrix34::CreateIdentity());
|
||||
|
||||
AABB entireBoundBox;
|
||||
entireBoundBox.Reset();
|
||||
|
||||
std::vector<uint32> indices;
|
||||
for (int i = 0, iStatObjSize = static_cast<uint32>(m_StatObjectList.size()); i < iStatObjSize; ++i)
|
||||
{
|
||||
IIndexedMesh* pMesh = m_StatObjectList[i].pStatObj->GetIndexedMesh(true);
|
||||
if (pMesh == nullptr)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
IIndexedMesh::SMeshDescription meshDesc;
|
||||
pMesh->GetMeshDescription(meshDesc);
|
||||
|
||||
for (int k = 0; k < meshDesc.m_nVertCount; ++k)
|
||||
{
|
||||
entireBoundBox.Add(m_StatObjectList[i].tm.TransformPoint(meshDesc.m_pVerts[k]));
|
||||
indices.push_back((i << 24) | k);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_pRootNode)
|
||||
{
|
||||
delete m_pRootNode;
|
||||
}
|
||||
|
||||
m_pRootNode = new KDTreeNode;
|
||||
BuildRecursively(m_pRootNode, entireBoundBox, indices);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CKDTree::BuildRecursively(KDTreeNode* pNode, const AABB& boundbox, std::vector<uint32>& indices) const
|
||||
{
|
||||
pNode->SetBoundBox(boundbox);
|
||||
|
||||
if (indices.size() <= s_MinimumVertexSizeInLeafNode)
|
||||
{
|
||||
pNode->SetVertexIndexBuffer(indices);
|
||||
return;
|
||||
}
|
||||
|
||||
ESplitAxis splitAxis = SearchForBestSplitAxis(boundbox);
|
||||
float splitPos(0);
|
||||
SearchForBestSplitPos(splitAxis, m_StatObjectList, indices, splitPos);
|
||||
pNode->SetSplitAxis(splitAxis);
|
||||
pNode->SetSplitPos(splitPos);
|
||||
|
||||
SSplitInfo splitInfo;
|
||||
if (!SplitNode(m_StatObjectList, boundbox, indices, splitAxis, splitPos, splitInfo))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (splitInfo.aboveIndices.empty() || splitInfo.belowIndices.empty())
|
||||
{
|
||||
pNode->SetVertexIndexBuffer(indices);
|
||||
return;
|
||||
}
|
||||
|
||||
KDTreeNode* pChild0 = new KDTreeNode;
|
||||
KDTreeNode* pChild1 = new KDTreeNode;
|
||||
|
||||
pNode->SetChild(0, pChild0);
|
||||
pNode->SetChild(1, pChild1);
|
||||
|
||||
BuildRecursively(pChild0, splitInfo.aboveBoundbox, splitInfo.aboveIndices);
|
||||
BuildRecursively(pChild1, splitInfo.belowBoundbox, splitInfo.belowIndices);
|
||||
}
|
||||
|
||||
void CKDTree::ConstructStatObjList(IStatObj* pStatObj, const Matrix34& matParent)
|
||||
{
|
||||
if (pStatObj == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
for (int i = 0, nChildObjSize(pStatObj->GetSubObjectCount()); i < nChildObjSize; ++i)
|
||||
{
|
||||
IStatObj::SSubObject* pSubObj = pStatObj->GetSubObject(i);
|
||||
SStatObj s;
|
||||
s.tm = matParent * pSubObj->localTM;
|
||||
if (pSubObj->pStatObj && pSubObj->pStatObj->GetIndexedMesh(true))
|
||||
{
|
||||
s.pStatObj = pSubObj->pStatObj;
|
||||
m_StatObjectList.push_back(s);
|
||||
}
|
||||
ConstructStatObjList(pSubObj->pStatObj, s.tm);
|
||||
}
|
||||
}
|
||||
|
||||
bool CKDTree::FindNearestVertex(const Vec3& raySrc, const Vec3& rayDir, float vVertexBoxSize, const Vec3& localCameraPos, Vec3& outPos, Vec3& vOutHitPosOnCube) const
|
||||
{
|
||||
return FindNearestVertexRecursively(m_pRootNode, raySrc, rayDir, vVertexBoxSize, localCameraPos, outPos, vOutHitPosOnCube);
|
||||
}
|
||||
|
||||
AABB GetNodeBoundBox(KDTreeNode* pNode, float vVertexBoxSize, const Vec3& localCameraPos)
|
||||
{
|
||||
AABB nodeAABB = pNode->GetBoundBox();
|
||||
float fScreenFactorMin = localCameraPos.GetDistance(nodeAABB.min);
|
||||
Vec3 vBoundBoxMin(fScreenFactorMin * vVertexBoxSize, fScreenFactorMin * vVertexBoxSize, fScreenFactorMin * vVertexBoxSize);
|
||||
float fScreenFactorMax = localCameraPos.GetDistance(nodeAABB.max);
|
||||
Vec3 vBoundBoxMax(fScreenFactorMax * vVertexBoxSize, fScreenFactorMax * vVertexBoxSize, fScreenFactorMax * vVertexBoxSize);
|
||||
nodeAABB.min -= vBoundBoxMin;
|
||||
nodeAABB.max += vBoundBoxMax;
|
||||
return nodeAABB;
|
||||
}
|
||||
|
||||
bool CKDTree::FindNearestVertexRecursively(KDTreeNode* pNode, const Vec3& raySrc, const Vec3& rayDir, float vVertexBoxSize, const Vec3& localCameraPos, Vec3& outPos, Vec3& vOutHitPosOnCube) const
|
||||
{
|
||||
if (!pNode)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Vec3 vHitPos;
|
||||
AABB nodeAABB = GetNodeBoundBox(pNode, vVertexBoxSize, localCameraPos);
|
||||
if (!pNode->GetBoundBox().IsContainPoint(raySrc) && !Intersect::Ray_AABB(raySrc, rayDir, nodeAABB, vHitPos))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (pNode->IsLeaf())
|
||||
{
|
||||
if (m_StatObjectList.empty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32 nVBuffSize = pNode->GetVertexBufferSize();
|
||||
if (nVBuffSize == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
float fNearestDist = 3e10f;
|
||||
|
||||
for (uint32 i = 0; i < nVBuffSize; ++i)
|
||||
{
|
||||
uint32 nVertexIndex = pNode->GetVertexIndex(i);
|
||||
uint32 nObjIndex = pNode->GetObjIndex(i);
|
||||
|
||||
assert(nObjIndex < m_StatObjectList.size());
|
||||
|
||||
const SStatObj* pStatObjInfo = &(m_StatObjectList[nObjIndex]);
|
||||
|
||||
IIndexedMesh* pMesh = m_StatObjectList[nObjIndex].pStatObj->GetIndexedMesh();
|
||||
if (pMesh == nullptr)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
IIndexedMesh::SMeshDescription meshDesc;
|
||||
pMesh->GetMeshDescription(meshDesc);
|
||||
|
||||
Vec3 vCandidatePos(0, 0, 0);
|
||||
if (meshDesc.m_pVerts)
|
||||
{
|
||||
vCandidatePos = pStatObjInfo->tm.TransformPoint(meshDesc.m_pVerts[nVertexIndex]);
|
||||
}
|
||||
else if (meshDesc.m_pVertsF16)
|
||||
{
|
||||
vCandidatePos = pStatObjInfo->tm.TransformPoint(meshDesc.m_pVertsF16[nVertexIndex].ToVec3());
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
float fScreenFactor = localCameraPos.GetDistance(vCandidatePos);
|
||||
Vec3 vBoundBox(fScreenFactor * vVertexBoxSize, fScreenFactor * vVertexBoxSize, fScreenFactor * vVertexBoxSize);
|
||||
|
||||
Vec3 vHitPosOnCube;
|
||||
if (Intersect::Ray_AABB(raySrc, rayDir, AABB(vCandidatePos - vBoundBox, vCandidatePos + vBoundBox), vHitPosOnCube))
|
||||
{
|
||||
float fDist = vHitPosOnCube.GetDistance(raySrc);
|
||||
if (fDist < fNearestDist)
|
||||
{
|
||||
fNearestDist = fDist;
|
||||
outPos = vCandidatePos;
|
||||
vOutHitPosOnCube = vHitPosOnCube;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (fNearestDist < 3e10f)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Vec3 vNearestPos0, vNearestPos0OnCube;
|
||||
Vec3 vNearestPos1, vNearestPos1OnCube;
|
||||
bool bFoundChild0 = FindNearestVertexRecursively(pNode->GetChild(0), raySrc, rayDir, vVertexBoxSize, localCameraPos, vNearestPos0, vNearestPos0OnCube);
|
||||
bool bFoundChild1 = FindNearestVertexRecursively(pNode->GetChild(1), raySrc, rayDir, vVertexBoxSize, localCameraPos, vNearestPos1, vNearestPos1OnCube);
|
||||
|
||||
if (bFoundChild0 && bFoundChild1)
|
||||
{
|
||||
float fDist0 = raySrc.GetDistance(vNearestPos0OnCube);
|
||||
float fDist1 = raySrc.GetDistance(vNearestPos1OnCube);
|
||||
if (fDist0 < fDist1)
|
||||
{
|
||||
outPos = vNearestPos0;
|
||||
vOutHitPosOnCube = vNearestPos0OnCube;
|
||||
}
|
||||
else
|
||||
{
|
||||
outPos = vNearestPos1;
|
||||
vOutHitPosOnCube = vNearestPos1OnCube;
|
||||
}
|
||||
}
|
||||
else if (bFoundChild0 && !bFoundChild1)
|
||||
{
|
||||
outPos = vNearestPos0;
|
||||
vOutHitPosOnCube = vNearestPos0OnCube;
|
||||
}
|
||||
else if (!bFoundChild0 && bFoundChild1)
|
||||
{
|
||||
outPos = vNearestPos1;
|
||||
vOutHitPosOnCube = vNearestPos1OnCube;
|
||||
}
|
||||
|
||||
return bFoundChild0 || bFoundChild1;
|
||||
}
|
||||
|
||||
void CKDTree::GetPenetratedBoxes(const Vec3& raySrc, const Vec3& rayDir, std::vector<AABB>& outBoxes)
|
||||
{
|
||||
GetPenetratedBoxesRecursively(m_pRootNode, raySrc, rayDir, outBoxes);
|
||||
}
|
||||
|
||||
void CKDTree::GetPenetratedBoxesRecursively(KDTreeNode* pNode, const Vec3& raySrc, const Vec3& rayDir, std::vector<AABB>& outBoxes)
|
||||
{
|
||||
Vec3 vHitPos;
|
||||
if (!pNode || (!pNode->GetBoundBox().IsContainPoint(raySrc) && !Intersect::Ray_AABB(raySrc, rayDir, pNode->GetBoundBox(), vHitPos)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
outBoxes.push_back(pNode->GetBoundBox());
|
||||
|
||||
GetPenetratedBoxesRecursively(pNode->GetChild(0), raySrc, rayDir, outBoxes);
|
||||
GetPenetratedBoxesRecursively(pNode->GetChild(1), raySrc, rayDir, outBoxes);
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_UTIL_KDTREE_H
|
||||
#define CRYINCLUDE_EDITOR_UTIL_KDTREE_H
|
||||
#pragma once
|
||||
|
||||
struct IStatObj;
|
||||
|
||||
class KDTreeNode;
|
||||
|
||||
class CKDTree
|
||||
{
|
||||
public:
|
||||
|
||||
CKDTree();
|
||||
~CKDTree();
|
||||
|
||||
bool Build(IStatObj* pStatObj);
|
||||
bool FindNearestVertex(const Vec3& raySrc, const Vec3& rayDir, float vVertexBoxSize, const Vec3& localCameraPos, Vec3& outPos, Vec3& vOutHitPosOnCube) const;
|
||||
void GetPenetratedBoxes(const Vec3& raySrc, const Vec3& rayDir, std::vector<AABB>& outBoxes);
|
||||
|
||||
enum ESplitAxis
|
||||
{
|
||||
eSA_X = 0,
|
||||
eSA_Y,
|
||||
eSA_Z,
|
||||
eSA_Invalid
|
||||
};
|
||||
|
||||
struct SStatObj
|
||||
{
|
||||
Matrix34 tm;
|
||||
IStatObj* pStatObj;
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
void BuildRecursively(KDTreeNode* pNode, const AABB& boundbox, std::vector<uint32>& indices) const;
|
||||
bool FindNearestVertexRecursively(KDTreeNode* pNode, const Vec3& raySrc, const Vec3& rayDir, float vVertexBoxSize, const Vec3& localCameraPos, Vec3& outPos, Vec3& vOutHitPosOnCube) const;
|
||||
void GetPenetratedBoxesRecursively(KDTreeNode* pNode, const Vec3& raySrc, const Vec3& rayDir, std::vector<AABB>& outBoxes);
|
||||
void ConstructStatObjList(IStatObj* pStatObj, const Matrix34& matParent);
|
||||
|
||||
static const int s_MinimumVertexSizeInLeafNode = 4;
|
||||
|
||||
private:
|
||||
|
||||
KDTreeNode* m_pRootNode;
|
||||
std::vector<SStatObj> m_StatObjectList;
|
||||
};
|
||||
#endif // CRYINCLUDE_EDITOR_UTIL_KDTREE_H
|
||||
@@ -14,7 +14,6 @@
|
||||
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
|
||||
#include <AzCore/Utils/Utils.h>
|
||||
#include <AzToolsFramework/API/EditorAssetSystemAPI.h> // for ebus events
|
||||
#include <AzFramework/API/ApplicationAPI.h>
|
||||
#include <AzCore/std/string/conversions.h>
|
||||
#include <AzFramework/IO/LocalFileIO.h>
|
||||
|
||||
@@ -175,9 +174,8 @@ namespace Path
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
QString GetEngineRootPath()
|
||||
{
|
||||
const char* engineRoot;
|
||||
EBUS_EVENT_RESULT(engineRoot, AzFramework::ApplicationRequests::Bus, GetEngineRoot);
|
||||
return QString(engineRoot);
|
||||
const AZ::IO::FixedMaxPathString engineRoot = AZ::Utils::GetEnginePath();
|
||||
return QString::fromUtf8(engineRoot.c_str(), static_cast<int>(engineRoot.size()));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -16,102 +16,6 @@
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// CXmlArchive
|
||||
bool CXmlArchive::Load(const QString& file)
|
||||
{
|
||||
bLoading = true;
|
||||
|
||||
char filename[AZ_MAX_PATH_LEN] = { 0 };
|
||||
AZ::IO::FileIOBase::GetInstance()->ResolvePath(file.toUtf8().data(), filename, AZ_MAX_PATH_LEN);
|
||||
|
||||
QFile cFile(filename);
|
||||
if (!cFile.open(QFile::ReadOnly))
|
||||
{
|
||||
CLogFile::FormatLine("Warning: Loading of %s failed", filename);
|
||||
return false;
|
||||
}
|
||||
CArchive ar(&cFile, CArchive::load);
|
||||
|
||||
QString str;
|
||||
ar >> str;
|
||||
|
||||
root = XmlHelpers::LoadXmlFromBuffer(str.toUtf8().data(), str.toUtf8().length());
|
||||
if (!root)
|
||||
{
|
||||
// If we didn't extract valid XML, attempt to check the header to see if we're dealing with an improperly serialized archive
|
||||
// When deserializing QStrings, we use readStringLength in EditorUtils, which mimics MFC's decoding.
|
||||
// In this encoding, the length is first read as an unsigned 8-bit value, if that is 0xFF then the next two bytes are read
|
||||
// If the 16 bit uint is 0xFFFF, then the next four bytes are read, etc. up to a final 64 bit value.
|
||||
|
||||
// In 1.09, there was a bug in which we'd serialize out the 32-bit length improperly like so:
|
||||
// 0xFF 0xFF 0x00 <4 byte proper length>
|
||||
|
||||
// Note that the header could also historically start with 0xFF 0xFF 0xFE to indicate wide strings prior to the length data
|
||||
// but we don't have to deal with that here as the broken version of the code never prepended this
|
||||
cFile.seek(0);
|
||||
quint8 len8;
|
||||
ar >> len8;
|
||||
|
||||
quint16 len16;
|
||||
ar >> len16;
|
||||
|
||||
// Possible bad header, attempt to read 32 bit length.
|
||||
if (len8 == 0xff && len16 == 0xff)
|
||||
{
|
||||
// This version of operator<< only serialized out UTF8 strings up to 32 bits of length, no need to 64-bit check or do wchar.
|
||||
quint32 len32;
|
||||
ar >> len32;
|
||||
|
||||
str = QString::fromUtf8(cFile.read(len32));
|
||||
root = XmlHelpers::LoadXmlFromBuffer(str.toUtf8().data(), str.toUtf8().length());
|
||||
}
|
||||
|
||||
if (!root)
|
||||
{
|
||||
CLogFile::FormatLine("Warning: Loading of %s failed", filename);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
const bool loaded = pNamedData->Serialize(ar);
|
||||
if (!loaded)
|
||||
{
|
||||
CLogFile::FormatLine("Error: Can't load xml file: '%s'! File corrupted. Binary file possibly was corrupted by Source Control if it was marked like text format.", filename);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CXmlArchive::Save(const QString& file)
|
||||
{
|
||||
char filename[AZ_MAX_PATH_LEN] = { 0 };
|
||||
AZ::IO::FileIOBase::GetInstance()->ResolvePath(file.toUtf8().data(), filename, AZ_MAX_PATH_LEN);
|
||||
|
||||
bLoading = false;
|
||||
if (!root)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QFile cFile(filename);
|
||||
// Open the file for writing, create it if needed
|
||||
if (!cFile.open(QFile::WriteOnly))
|
||||
{
|
||||
CLogFile::FormatLine("Warning: Saving of %s failed", filename);
|
||||
return;
|
||||
}
|
||||
// Create the archive object
|
||||
CArchive ar(&cFile, CArchive::store);
|
||||
|
||||
_smart_ptr<IXmlStringData> pXmlStrData = root->getXMLData(5000000);
|
||||
|
||||
// Need convert to QString for CArchive::operator<<
|
||||
QString str = pXmlStrData->GetString();
|
||||
ar << str;
|
||||
|
||||
pNamedData->Serialize(ar);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CXmlArchive::SaveToPak([[maybe_unused]] const QString& levelPath, CPakFile& pakFile)
|
||||
|
||||
@@ -60,9 +60,6 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool Load(const QString& file);
|
||||
void Save(const QString& file);
|
||||
|
||||
//! Save XML Archive to pak file.
|
||||
//! @return true if saved.
|
||||
bool SaveToPak(const QString& levelPath, CPakFile& pakFile);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user