merge from main
This commit is contained in:
@@ -86,7 +86,6 @@ inline Vec3 SnapToSize(Vec3 v, double size)
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
Q2DViewport::Q2DViewport(QWidget* parent)
|
||||
: QtViewport(parent)
|
||||
, m_renderer(nullptr)
|
||||
{
|
||||
// Scroll offset equals origin
|
||||
m_rcSelect.setRect(0, 0, 0, 0);
|
||||
@@ -528,15 +527,6 @@ void Q2DViewport::paintEvent([[maybe_unused]] QPaintEvent* event)
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
int Q2DViewport::OnCreate()
|
||||
{
|
||||
m_renderer = GetIEditor()->GetRenderer();
|
||||
assert (m_renderer != NULL);
|
||||
if (m_renderer)
|
||||
{
|
||||
WIN_HWND previousContext = m_renderer->GetCurrentContextHWND();
|
||||
m_renderer->CreateContext(renderOverlayHWND());
|
||||
m_renderer->SetCurrentContext(previousContext);
|
||||
}
|
||||
|
||||
// Calculate the View transformation matrix.
|
||||
CalculateViewTM();
|
||||
|
||||
@@ -641,123 +631,11 @@ void Q2DViewport::OnTitleMenu(QMenu* menu)
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Q2DViewport::OnDestroy()
|
||||
{
|
||||
if (m_renderer)
|
||||
{
|
||||
m_renderer->DeleteContext(renderOverlayHWND());
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Q2DViewport::Render()
|
||||
{
|
||||
if (GetIEditor()->IsInGameMode())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_renderer)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isVisible())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!GetIEditor()->GetDocument()->IsDocumentReady())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_renderer->IsStereoEnabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
FUNCTION_PROFILER(GetIEditor()->GetSystem(), PROFILE_EDITOR);
|
||||
|
||||
QRect rc = rect();
|
||||
if (rc.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CalculateViewTM();
|
||||
|
||||
// Render
|
||||
WIN_HWND priorContext = m_renderer->GetCurrentContextHWND();
|
||||
|
||||
m_renderer->SetCurrentContext(renderOverlayHWND());
|
||||
m_renderer->BeginFrame();
|
||||
m_renderer->ChangeViewport(0, 0, rc.right(), rc.bottom(), true);
|
||||
|
||||
CScopedWireFrameMode scopedWireFrame(m_renderer, R_SOLID_MODE);
|
||||
auto colorf = Rgb2ColorF(m_colorBackground);
|
||||
m_renderer->ClearTargetsLater(FRT_CLEAR, colorf);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// 2D Mode.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
if (rc.right() != 0 && rc.bottom() != 0)
|
||||
{
|
||||
TransformationMatrices backupSceneMatrices;
|
||||
|
||||
m_renderer->Set2DMode(rc.right(), rc.bottom(), backupSceneMatrices);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Draw viewport elements here.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Calc world bounding box for objects rendering.
|
||||
m_displayBounds = GetWorldBounds(QPoint(0, 0), QPoint(rc.width(), rc.height()));
|
||||
|
||||
// Draw all objects.
|
||||
DisplayContext& dc = m_displayContext;
|
||||
dc.settings = GetIEditor()->GetDisplaySettings();
|
||||
dc.view = this;
|
||||
dc.renderer = m_renderer;
|
||||
dc.engine = GetIEditor()->Get3DEngine();
|
||||
dc.flags = DISPLAY_2D;
|
||||
dc.box = m_displayBounds;
|
||||
dc.camera = &GetIEditor()->GetSystem()->GetViewCamera();
|
||||
|
||||
if (!dc.settings->IsDisplayLabels() || !dc.settings->IsDisplayHelpers())
|
||||
{
|
||||
dc.flags |= DISPLAY_HIDENAMES;
|
||||
}
|
||||
if (dc.settings->IsDisplayLinks() && dc.settings->IsDisplayHelpers())
|
||||
{
|
||||
dc.flags |= DISPLAY_LINKS;
|
||||
}
|
||||
if (m_bDegradateQuality)
|
||||
{
|
||||
dc.flags |= DISPLAY_DEGRADATED;
|
||||
}
|
||||
|
||||
SRenderingPassInfo passInfo = SRenderingPassInfo::CreateGeneralPassRenderingInfo(GetIEditor()->GetSystem()->GetViewCamera());
|
||||
|
||||
m_renderer->BeginSpawningGeneratingRendItemJobs(passInfo.ThreadID());
|
||||
m_renderer->BeginSpawningShadowGeneratingRendItemJobs(passInfo.ThreadID());
|
||||
m_renderer->EF_StartEf(passInfo);
|
||||
|
||||
dc.SetState(e_Mode3D | e_AlphaBlended | e_FillModeSolid | e_CullModeBack | e_DepthWriteOff | e_DepthTestOn);
|
||||
Draw(dc);
|
||||
|
||||
m_renderer->EF_EndEf3D(SHDF_STREAM_SYNC, -1, -1, passInfo);
|
||||
|
||||
m_renderer->EF_RenderTextMessages();
|
||||
|
||||
// Return back from 2D mode.
|
||||
m_renderer->Unset2DMode(backupSceneMatrices);
|
||||
|
||||
m_renderer->RenderDebug(false);
|
||||
|
||||
ProcessRenderLisneters(m_displayContext);
|
||||
|
||||
m_renderer->EndFrame();
|
||||
}
|
||||
|
||||
GetIEditor()->GetRenderer()->SetCurrentContext(priorContext);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -782,9 +660,7 @@ void Q2DViewport::Draw(DisplayContext& dc)
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Q2DViewport::DrawGrid(DisplayContext& dc, bool bNoXNumbers)
|
||||
{
|
||||
CGrid* pGrid = GetIEditor()->GetViewManager()->GetGrid();
|
||||
float gridSize = pGrid->size;
|
||||
|
||||
float gridSize = 1.0f;
|
||||
if (gridSize < 0.00001f)
|
||||
{
|
||||
return;
|
||||
@@ -815,8 +691,6 @@ void Q2DViewport::DrawGrid(DisplayContext& dc, bool bNoXNumbers)
|
||||
pixelsPerGrid = gridSize * fScale;
|
||||
while (pixelsPerGrid <= 5 && griditers++ < 20)
|
||||
{
|
||||
m_fGridZoom *= pGrid->majorLine;
|
||||
gridSize = gridSize * pGrid->majorLine;
|
||||
pixelsPerGrid = gridSize * fScale;
|
||||
}
|
||||
}
|
||||
@@ -865,7 +739,7 @@ void Q2DViewport::DrawGrid(DisplayContext& dc, bool bNoXNumbers)
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Draw Major grid lines.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
gridSize = gridSize * pGrid->majorLine;
|
||||
gridSize = gridSize * 1.0f;
|
||||
|
||||
if (m_bAutoAdjustGrids)
|
||||
{
|
||||
|
||||
@@ -159,7 +159,6 @@ protected:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Variables.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
IRenderer* m_renderer;
|
||||
|
||||
//! XY/XZ/YZ mode of this 2D viewport.
|
||||
EViewportType m_viewType;
|
||||
|
||||
@@ -169,6 +169,13 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename Fn>
|
||||
ActionWrapper& RegisterUpdateCallback(Fn&& fn)
|
||||
{
|
||||
m_actionManager->RegisterUpdateCallback(m_action->data().toInt(), AZStd::forward<Fn>(fn));
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
friend ActionManager;
|
||||
friend DynamicMenu;
|
||||
@@ -315,11 +322,17 @@ public:
|
||||
void DetachOverride() override;
|
||||
|
||||
template<typename T>
|
||||
void RegisterUpdateCallback(int id, T* object, void (T::* method)(QAction*))
|
||||
void RegisterUpdateCallback(int id, T* object, void (T::*method)(QAction*))
|
||||
{
|
||||
Q_ASSERT(m_actions.contains(id));
|
||||
auto f = std::bind(method, object, m_actions.value(id));
|
||||
m_updateCallbacks[id] = f;
|
||||
m_updateCallbacks[id] = [action = m_actions.value(id), object, method] { AZStd::invoke(method, object, action); };
|
||||
}
|
||||
|
||||
template<typename Fn>
|
||||
void RegisterUpdateCallback(int id, Fn&& fn)
|
||||
{
|
||||
Q_ASSERT(m_actions.contains(id));
|
||||
m_updateCallbacks[id] = [action = m_actions.value(id), fn] { fn(action); };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
||||
@@ -1,287 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#include "EditorDefs.h"
|
||||
|
||||
#include "AlembicCompileDialog.h"
|
||||
|
||||
// Qt
|
||||
#include <QPushButton>
|
||||
|
||||
// AzCore
|
||||
#include <Pak/CryPakUtils.h>
|
||||
|
||||
// Editor
|
||||
#include "Util/PathUtil.h"
|
||||
#include "Util/EditorUtils.h"
|
||||
|
||||
|
||||
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
#include <Alembic/ui_AlembicCompileDialog.h>
|
||||
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
|
||||
CAlembicCompileDialog::CAlembicCompileDialog(const XmlNodeRef config)
|
||||
: m_ui(new Ui::AlembicCompileDialog)
|
||||
{
|
||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
m_ui->setupUi(this);
|
||||
m_config = LoadConfig("", config);
|
||||
|
||||
OnInitDialog();
|
||||
|
||||
connect(m_ui->m_yUpRadio, &QRadioButton::clicked, this, &CAlembicCompileDialog::OnRadioYUp);
|
||||
connect(m_ui->m_zUpRadio, &QRadioButton::clicked, this, &CAlembicCompileDialog::OnRadioZUp);
|
||||
connect(m_ui->m_playbackFromMemoryCheckBox, &QCheckBox::clicked, this, &CAlembicCompileDialog::OnPlaybackFromMemory);
|
||||
connect(m_ui->m_blockCompressionFormatCombo, &QComboBox::currentTextChanged, this, &CAlembicCompileDialog::OnBlockCompressionSelected);
|
||||
connect(m_ui->m_meshPredictionCheckBox, &QCheckBox::clicked, this, &CAlembicCompileDialog::OnMeshPredictionCheckBox);
|
||||
connect(m_ui->m_useBFramesCheckBox, &QCheckBox::clicked, this, &CAlembicCompileDialog::OnUseBFramesCheckBox);
|
||||
connect(m_ui->m_indexFrameDistanceEdit, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &CAlembicCompileDialog::OnIndexFrameDistanceChanged);
|
||||
connect(m_ui->m_positionPrecisionEdit, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &CAlembicCompileDialog::OnPositionPrecisionChanged);
|
||||
connect(m_ui->m_uvMaxEdit, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), this, &CAlembicCompileDialog::OnUVmaxChanged);
|
||||
connect(m_ui->m_presetComboBox, &QComboBox::currentTextChanged, this, &CAlembicCompileDialog::OnPresetSelected);
|
||||
}
|
||||
|
||||
CAlembicCompileDialog::~CAlembicCompileDialog()
|
||||
{
|
||||
}
|
||||
|
||||
void CAlembicCompileDialog::OnInitDialog()
|
||||
{
|
||||
// custom 'Ok' and 'Cancel' text for this dialog
|
||||
m_ui->buttonBox->button(QDialogButtonBox::Ok)->setText("Recompile .cax File");
|
||||
m_ui->buttonBox->button(QDialogButtonBox::Cancel)->setText("Use Existing .cax File");
|
||||
|
||||
m_ui->m_blockCompressionFormatCombo->addItem(QStringLiteral("store"));
|
||||
m_ui->m_blockCompressionFormatCombo->addItem(QStringLiteral("deflate"));
|
||||
m_ui->m_blockCompressionFormatCombo->addItem(QStringLiteral("lz4hc"));
|
||||
m_ui->m_blockCompressionFormatCombo->addItem(QStringLiteral("zstd"));
|
||||
AZStd::vector<AZStd::string> presetFiles;
|
||||
const char* const filePattern = "*.cbc";
|
||||
|
||||
SDirectoryEnumeratorHelper dirHelper;
|
||||
|
||||
dirHelper.ScanDirectoryRecursive(gEnv->pCryPak, "@engroot@/", "Editor/Presets/GeomCache", filePattern, presetFiles);
|
||||
|
||||
for (auto iter = presetFiles.begin(); iter != presetFiles.end(); ++iter)
|
||||
{
|
||||
const auto& file = *iter;
|
||||
const AZStd::string filePath = "@engroot@/" + file;
|
||||
m_presets.push_back(LoadConfig(Path::GetFileName(file.c_str()), XmlHelpers::LoadXmlFromFile(filePath.c_str())));
|
||||
m_ui->m_presetComboBox->addItem(m_presets.back().m_name);
|
||||
}
|
||||
|
||||
m_ui->m_presetComboBox->addItem(tr("(Custom)"));
|
||||
|
||||
SetFromConfig(m_config);
|
||||
UpdatePresetSelection();
|
||||
UpdateEnabledStates();
|
||||
}
|
||||
|
||||
void CAlembicCompileDialog::SetFromConfig(const SConfig& config)
|
||||
{
|
||||
if (QString::compare(config.m_blockCompressionFormat, QLatin1String("deflate"), Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
m_ui->m_blockCompressionFormatCombo->setCurrentIndex(1);
|
||||
}
|
||||
else if (QString::compare(config.m_blockCompressionFormat, QLatin1String("lz4hc"), Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
m_ui->m_blockCompressionFormatCombo->setCurrentIndex(2);
|
||||
}
|
||||
else if (QString::compare(config.m_blockCompressionFormat, QLatin1String("zstd"), Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
m_ui->m_blockCompressionFormatCombo->setCurrentIndex(3);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->m_blockCompressionFormatCombo->setCurrentIndex(0);
|
||||
}
|
||||
|
||||
if (QString::compare(config.m_upAxis, QLatin1String("Y"), Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
m_ui->m_yUpRadio->setChecked(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->m_zUpRadio->setChecked(true);
|
||||
}
|
||||
|
||||
m_ui->m_playbackFromMemoryCheckBox->setChecked(config.m_playbackFromMemory == QStringLiteral("1"));
|
||||
m_ui->m_meshPredictionCheckBox->setChecked(config.m_meshPrediction == QStringLiteral("1"));
|
||||
m_ui->m_useBFramesCheckBox->setChecked(config.m_useBFrames == QStringLiteral("1"));
|
||||
|
||||
m_ui->m_indexFrameDistanceEdit->setValue(config.m_indexFrameDistance);
|
||||
m_ui->m_positionPrecisionEdit->setValue(aznumeric_cast<int>(config.m_positionPrecision));
|
||||
m_ui->m_uvMaxEdit->setValue(config.m_uvMax);
|
||||
}
|
||||
|
||||
void CAlembicCompileDialog::UpdateEnabledStates()
|
||||
{
|
||||
m_ui->m_meshPredictionCheckBox->setEnabled(false);
|
||||
m_ui->m_useBFramesCheckBox->setEnabled(false);
|
||||
m_ui->m_indexFrameDistanceEdit->setEnabled(false);
|
||||
|
||||
if (QString::compare(m_config.m_blockCompressionFormat, QLatin1String("store"), Qt::CaseInsensitive) != 0)
|
||||
{
|
||||
m_ui->m_meshPredictionCheckBox->setEnabled(true);
|
||||
m_ui->m_useBFramesCheckBox->setEnabled(true);
|
||||
|
||||
m_ui->m_indexFrameDistanceEdit->setEnabled(m_config.m_useBFrames == QStringLiteral("1"));
|
||||
}
|
||||
}
|
||||
|
||||
void CAlembicCompileDialog::UpdatePresetSelection()
|
||||
{
|
||||
for (uint i = 0; i < m_presets.size(); ++i)
|
||||
{
|
||||
if (m_presets[i] == m_config)
|
||||
{
|
||||
m_ui->m_presetComboBox->setCurrentIndex(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
m_ui->m_presetComboBox->setCurrentIndex(m_presets.size());
|
||||
}
|
||||
|
||||
QString CAlembicCompileDialog::GetUpAxis() const
|
||||
{
|
||||
return m_config.m_upAxis;
|
||||
}
|
||||
|
||||
QString CAlembicCompileDialog::GetPlaybackFromMemory() const
|
||||
{
|
||||
return m_config.m_playbackFromMemory;
|
||||
}
|
||||
|
||||
QString CAlembicCompileDialog::GetBlockCompressionFormat() const
|
||||
{
|
||||
return m_config.m_blockCompressionFormat;
|
||||
}
|
||||
|
||||
QString CAlembicCompileDialog::GetMeshPrediction() const
|
||||
{
|
||||
return m_config.m_meshPrediction;
|
||||
}
|
||||
|
||||
QString CAlembicCompileDialog::GetUseBFrames() const
|
||||
{
|
||||
return m_config.m_useBFrames;
|
||||
}
|
||||
|
||||
uint CAlembicCompileDialog::GetIndexFrameDistance() const
|
||||
{
|
||||
return m_config.m_indexFrameDistance;
|
||||
}
|
||||
|
||||
double CAlembicCompileDialog::GetPositionPrecision() const
|
||||
{
|
||||
return m_config.m_positionPrecision;
|
||||
}
|
||||
|
||||
float CAlembicCompileDialog::GetUVmax() const
|
||||
{
|
||||
return m_config.m_uvMax;
|
||||
}
|
||||
|
||||
|
||||
void CAlembicCompileDialog::OnRadioYUp()
|
||||
{
|
||||
m_config.m_upAxis = "Y";
|
||||
UpdatePresetSelection();
|
||||
}
|
||||
|
||||
void CAlembicCompileDialog::OnRadioZUp()
|
||||
{
|
||||
m_config.m_upAxis = "Z";
|
||||
UpdatePresetSelection();
|
||||
}
|
||||
|
||||
void CAlembicCompileDialog::OnPlaybackFromMemory()
|
||||
{
|
||||
m_config.m_playbackFromMemory = m_ui->m_playbackFromMemoryCheckBox->isChecked() ? QStringLiteral("1") : QStringLiteral("0");
|
||||
UpdatePresetSelection();
|
||||
}
|
||||
|
||||
void CAlembicCompileDialog::OnBlockCompressionSelected()
|
||||
{
|
||||
m_config.m_blockCompressionFormat = m_ui->m_blockCompressionFormatCombo->currentText();
|
||||
UpdatePresetSelection();
|
||||
UpdateEnabledStates();
|
||||
}
|
||||
|
||||
void CAlembicCompileDialog::OnMeshPredictionCheckBox()
|
||||
{
|
||||
m_config.m_meshPrediction = m_ui->m_meshPredictionCheckBox->isChecked() ? QStringLiteral("1") : QStringLiteral("0");
|
||||
UpdatePresetSelection();
|
||||
}
|
||||
|
||||
void CAlembicCompileDialog::OnUseBFramesCheckBox()
|
||||
{
|
||||
m_config.m_useBFrames = m_ui->m_useBFramesCheckBox->isChecked() ? QStringLiteral("1") : QStringLiteral("0");
|
||||
UpdatePresetSelection();
|
||||
UpdateEnabledStates();
|
||||
}
|
||||
|
||||
void CAlembicCompileDialog::OnIndexFrameDistanceChanged()
|
||||
{
|
||||
m_config.m_indexFrameDistance = m_ui->m_indexFrameDistanceEdit->value();
|
||||
UpdatePresetSelection();
|
||||
}
|
||||
|
||||
void CAlembicCompileDialog::OnPositionPrecisionChanged()
|
||||
{
|
||||
m_config.m_positionPrecision = m_ui->m_positionPrecisionEdit->value();
|
||||
UpdatePresetSelection();
|
||||
}
|
||||
|
||||
void CAlembicCompileDialog::OnUVmaxChanged()
|
||||
{
|
||||
m_config.m_uvMax = aznumeric_cast<float>(m_ui->m_uvMaxEdit->value());
|
||||
UpdatePresetSelection();
|
||||
}
|
||||
|
||||
void CAlembicCompileDialog::OnPresetSelected()
|
||||
{
|
||||
uint presetIndex = m_ui->m_presetComboBox->currentIndex();
|
||||
if (presetIndex < m_presets.size())
|
||||
{
|
||||
m_config = m_presets[presetIndex];
|
||||
SetFromConfig(m_config);
|
||||
}
|
||||
|
||||
m_ui->m_presetComboBox->setCurrentIndex(presetIndex);
|
||||
UpdateEnabledStates();
|
||||
}
|
||||
|
||||
CAlembicCompileDialog::SConfig CAlembicCompileDialog::LoadConfig(const QString& fileName, XmlNodeRef xml) const
|
||||
{
|
||||
SConfig config;
|
||||
config.m_name = fileName;
|
||||
|
||||
if (xml)
|
||||
{
|
||||
config.m_name = xml->getAttr("Name");
|
||||
config.m_blockCompressionFormat = xml->getAttr("BlockCompressionFormat");
|
||||
config.m_upAxis = xml->getAttr("UpAxis");
|
||||
config.m_playbackFromMemory = xml->getAttr("PlaybackFromMemory");
|
||||
config.m_meshPrediction = xml->getAttr("MeshPrediction");
|
||||
config.m_useBFrames = xml->getAttr("UseBFrames");
|
||||
xml->getAttr("IndexFrameDistance", config.m_indexFrameDistance);
|
||||
xml->getAttr("PositionPrecision", config.m_positionPrecision);
|
||||
xml->getAttr("UVmax", config.m_uvMax);
|
||||
}
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
#include <Alembic/moc_AlembicCompileDialog.cpp>
|
||||
@@ -1,107 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_ALEMBIC_ALEMBICCOMPILEDIALOG_H
|
||||
#define CRYINCLUDE_EDITOR_ALEMBIC_ALEMBICCOMPILEDIALOG_H
|
||||
#pragma once
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include <QDialog>
|
||||
|
||||
#include <IXml.h>
|
||||
|
||||
#endif
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class AlembicCompileDialog;
|
||||
}
|
||||
|
||||
class CAlembicCompileDialog
|
||||
: public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CAlembicCompileDialog(const XmlNodeRef config);
|
||||
~CAlembicCompileDialog();
|
||||
|
||||
void OnInitDialog();
|
||||
|
||||
QString GetUpAxis() const;
|
||||
QString GetPlaybackFromMemory() const;
|
||||
QString GetBlockCompressionFormat() const;
|
||||
QString GetMeshPrediction() const;
|
||||
QString GetUseBFrames() const;
|
||||
uint GetIndexFrameDistance() const;
|
||||
double GetPositionPrecision() const;
|
||||
float GetUVmax() const;
|
||||
|
||||
|
||||
private:
|
||||
struct SConfig
|
||||
{
|
||||
SConfig()
|
||||
: m_upAxis("Y")
|
||||
, m_playbackFromMemory("0")
|
||||
, m_blockCompressionFormat("deflate")
|
||||
, m_meshPrediction("1")
|
||||
, m_useBFrames("1")
|
||||
, m_indexFrameDistance(10)
|
||||
, m_positionPrecision(1.0)
|
||||
, m_uvMax(1.0f) {}
|
||||
|
||||
bool operator ==(const SConfig& other) const
|
||||
{
|
||||
return m_blockCompressionFormat == other.m_blockCompressionFormat
|
||||
&& m_upAxis == other.m_upAxis
|
||||
&& m_playbackFromMemory == other.m_playbackFromMemory
|
||||
&& m_meshPrediction == other.m_meshPrediction
|
||||
&& m_useBFrames == other.m_useBFrames
|
||||
&& m_indexFrameDistance == other.m_indexFrameDistance
|
||||
&& m_positionPrecision == other.m_positionPrecision
|
||||
&& m_uvMax == other.m_uvMax;
|
||||
}
|
||||
|
||||
QString m_name;
|
||||
QString m_blockCompressionFormat;
|
||||
QString m_upAxis;
|
||||
QString m_playbackFromMemory;
|
||||
QString m_meshPrediction;
|
||||
QString m_useBFrames;
|
||||
uint m_indexFrameDistance;
|
||||
double m_positionPrecision;
|
||||
float m_uvMax;
|
||||
};
|
||||
|
||||
void SetFromConfig(const SConfig& config);
|
||||
void UpdateEnabledStates();
|
||||
void UpdatePresetSelection();
|
||||
SConfig LoadConfig(const QString& fileName, XmlNodeRef xml) const;
|
||||
|
||||
void OnRadioYUp();
|
||||
void OnRadioZUp();
|
||||
void OnPlaybackFromMemory();
|
||||
void OnBlockCompressionSelected();
|
||||
void OnMeshPredictionCheckBox();
|
||||
void OnUseBFramesCheckBox();
|
||||
void OnIndexFrameDistanceChanged();
|
||||
void OnPositionPrecisionChanged();
|
||||
void OnUVmaxChanged();
|
||||
void OnPresetSelected();
|
||||
|
||||
SConfig m_config;
|
||||
std::vector<SConfig> m_presets;
|
||||
|
||||
QScopedPointer<Ui::AlembicCompileDialog> m_ui;
|
||||
};
|
||||
#endif // CRYINCLUDE_EDITOR_ALEMBIC_ALEMBICCOMPILEDIALOG_H
|
||||
@@ -1,192 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>AlembicCompileDialog</class>
|
||||
<widget class="QDialog" name="AlembicCompileDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>432</width>
|
||||
<height>252</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Compile Alembic File</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Preset</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QComboBox" name="m_presetComboBox"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" rowspan="3">
|
||||
<widget class="QGroupBox" name="groupBox_4">
|
||||
<property name="title">
|
||||
<string>Compression Settings</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Block Compression:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="m_blockCompressionFormatCombo"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Precision (mm):</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QSpinBox" name="m_positionPrecisionEdit">
|
||||
<property name="buttonSymbols">
|
||||
<enum>QAbstractSpinBox::NoButtons</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>UV Max:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="m_meshPredictionCheckBox">
|
||||
<property name="text">
|
||||
<string>Use Mesh Prediction</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="m_useBFramesCheckBox">
|
||||
<property name="text">
|
||||
<string>Use Bi-Directional Prediction</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Index Frame Distance:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="m_indexFrameDistanceEdit">
|
||||
<property name="buttonSymbols">
|
||||
<enum>QAbstractSpinBox::NoButtons</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QDoubleSpinBox" name="m_uvMaxEdit">
|
||||
<property name="buttonSymbols">
|
||||
<enum>QAbstractSpinBox::NoButtons</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Compilation Settings</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="m_yUpRadio">
|
||||
<property name="text">
|
||||
<string>Y-axis up</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="m_zUpRadio">
|
||||
<property name="text">
|
||||
<string>Z-axis up</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QGroupBox" name="groupBox_3">
|
||||
<property name="title">
|
||||
<string>Runtime Settings</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QCheckBox" name="m_playbackFromMemoryCheckBox">
|
||||
<property name="text">
|
||||
<string>Playback from Memory</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="2">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>AlembicCompileDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>AlembicCompileDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
@@ -1,158 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#include "EditorDefs.h"
|
||||
|
||||
#include "AlembicCompiler.h"
|
||||
|
||||
// Editor
|
||||
#include "AlembicCompileDialog.h"
|
||||
#include "Util/EditorUtils.h"
|
||||
#include "Util/FileUtil.h"
|
||||
#include "Util/PathUtil.h"
|
||||
|
||||
// AzCore
|
||||
#include <AzCore/std/string/wildcard.h>
|
||||
|
||||
// AzToolsFramework
|
||||
#include <AzToolsFramework/AssetBrowser/AssetBrowserEntry.h>
|
||||
|
||||
|
||||
|
||||
namespace Internal
|
||||
{
|
||||
// Attempt to add the file to source control if it is available
|
||||
bool TryAddFileToSourceControl(const QString& filename)
|
||||
{
|
||||
if (!CFileUtil::CheckoutFile(filename.toUtf8().data(), nullptr))
|
||||
{
|
||||
CryWarning(VALIDATOR_MODULE_EDITOR, VALIDATOR_ERROR, "Failed to add file %s to the source control provider", filename.toUtf8().constData());
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
} // namespace Internal
|
||||
|
||||
CAlembicCompiler::CAlembicCompiler()
|
||||
{
|
||||
AzToolsFramework::AssetBrowser::AssetBrowserInteractionNotificationBus::Handler::BusConnect();
|
||||
}
|
||||
|
||||
CAlembicCompiler::~CAlembicCompiler()
|
||||
{
|
||||
AzToolsFramework::AssetBrowser::AssetBrowserInteractionNotificationBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
bool CAlembicCompiler::CompileAlembic(const QString& fullPath)
|
||||
{
|
||||
bool compileConfigFileSaved = false;
|
||||
const QString configPath = Path::ReplaceExtension(fullPath, "cbc");
|
||||
XmlNodeRef config = XmlHelpers::LoadXmlFromFile(configPath.toUtf8().data());
|
||||
|
||||
CAlembicCompileDialog dialog(config);
|
||||
|
||||
if (dialog.exec() == QDialog::Accepted)
|
||||
{
|
||||
bool configChanged = false;
|
||||
const QString upAxis = dialog.GetUpAxis();
|
||||
const QString playbackFromMemory = dialog.GetPlaybackFromMemory();
|
||||
const QString blockCompressionFormat = dialog.GetBlockCompressionFormat();
|
||||
const QString meshPrediction = dialog.GetMeshPrediction();
|
||||
const QString useBFrames = dialog.GetUseBFrames();
|
||||
const uint indexFrameDistance = dialog.GetIndexFrameDistance();
|
||||
const double positionPrecision = dialog.GetPositionPrecision();
|
||||
const float uvMax = dialog.GetUVmax();
|
||||
|
||||
if (!config)
|
||||
{
|
||||
CryLog("Build configuration file not found, writing new one");
|
||||
config = XmlHelpers::CreateXmlNode("CacheBuildConfiguration");
|
||||
configChanged = true;
|
||||
}
|
||||
|
||||
if (strcmp(config->getAttr("UpAxis"), upAxis.toUtf8().data()) != 0)
|
||||
{
|
||||
config->setAttr("UpAxis", upAxis.toUtf8().data());
|
||||
configChanged = true;
|
||||
}
|
||||
if (strcmp(config->getAttr("MeshPrediction"), meshPrediction.toUtf8().data()) != 0)
|
||||
{
|
||||
config->setAttr("MeshPrediction", meshPrediction.toUtf8().data());
|
||||
configChanged = true;
|
||||
}
|
||||
if (strcmp(config->getAttr("UseBFrames"), useBFrames.toUtf8().data()) != 0)
|
||||
{
|
||||
config->setAttr("UseBFrames", useBFrames.toUtf8().data());
|
||||
configChanged = true;
|
||||
}
|
||||
if (atoi(config->getAttr("IndexFrameDistance")) != indexFrameDistance)
|
||||
{
|
||||
config->setAttr("IndexFrameDistance", indexFrameDistance);
|
||||
configChanged = true;
|
||||
}
|
||||
if (strcmp(config->getAttr("BlockCompressionFormat"), blockCompressionFormat.toUtf8().data()) != 0)
|
||||
{
|
||||
config->setAttr("BlockCompressionFormat", blockCompressionFormat.toUtf8().data());
|
||||
configChanged = true;
|
||||
}
|
||||
if (strcmp(config->getAttr("PlaybackFromMemory"), playbackFromMemory.toUtf8().data()) != 0)
|
||||
{
|
||||
config->setAttr("PlaybackFromMemory", playbackFromMemory.toUtf8().data());
|
||||
configChanged = true;
|
||||
}
|
||||
if (atof(config->getAttr("PositionPrecision")) != positionPrecision)
|
||||
{
|
||||
config->setAttr("PositionPrecision", positionPrecision);
|
||||
configChanged = true;
|
||||
}
|
||||
if (atof(config->getAttr("UVmax")) != uvMax)
|
||||
{
|
||||
config->setAttr("UVmax", uvMax);
|
||||
configChanged = true;
|
||||
}
|
||||
|
||||
if (configChanged)
|
||||
{
|
||||
compileConfigFileSaved = XmlHelpers::SaveXmlNode(GetIEditor()->GetFileUtil(), config, configPath.toUtf8().data());
|
||||
if (compileConfigFileSaved)
|
||||
{
|
||||
// If we just created the file above, or the cbc file was not previously managed, attempt to add it to perforce now.
|
||||
// Note that XmlHelpers::SaveXmlNode will prompt the user to checkout or overwrite the file
|
||||
Internal::TryAddFileToSourceControl(configPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return compileConfigFileSaved;
|
||||
}
|
||||
|
||||
void CAlembicCompiler::AddSourceFileOpeners(const char* fullSourceFileName, [[maybe_unused]] const AZ::Uuid& sourceUUID, AzToolsFramework::AssetBrowser::SourceFileOpenerList& openers)
|
||||
{
|
||||
using namespace AzToolsFramework;
|
||||
using namespace AzToolsFramework::AssetBrowser;
|
||||
|
||||
if (AZStd::wildcard_match("*.abc", fullSourceFileName))
|
||||
{
|
||||
auto alembicCallback = [this]([[maybe_unused]] const char* fullSourceFileNameInCall, const AZ::Uuid& sourceUUIDInCall)
|
||||
{
|
||||
const SourceAssetBrowserEntry* fullDetails = SourceAssetBrowserEntry::GetSourceByUuid(sourceUUIDInCall);
|
||||
if (fullDetails)
|
||||
{
|
||||
CompileAlembic(fullDetails->GetRelativePath().c_str());
|
||||
}
|
||||
};
|
||||
|
||||
openers.push_back({ "O3DE_AlembicCompiler", "Open In Alembic Compiler...", QIcon(), alembicCallback });
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzToolsFramework/AssetBrowser/AssetBrowserBus.h>
|
||||
|
||||
class CAlembicCompiler
|
||||
: public AzToolsFramework::AssetBrowser::AssetBrowserInteractionNotificationBus::Handler
|
||||
{
|
||||
public:
|
||||
CAlembicCompiler();
|
||||
~CAlembicCompiler();
|
||||
|
||||
bool CompileAlembic(const QString& fullPath);
|
||||
|
||||
protected:
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// AzToolsFramework::AssetBrowser::AssetBrowserInteractionNotificationBus::Handler
|
||||
void AddSourceFileOpeners(const char* fullSourceFileName, const AZ::Uuid& sourceUUID, AzToolsFramework::AssetBrowser::SourceFileOpenerList& openers) override;
|
||||
};
|
||||
@@ -35,4 +35,4 @@ namespace EditorAnimationBones
|
||||
}
|
||||
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_ANIMATION_ANIMATIONBIPEDBONENAMES_H
|
||||
#endif // CRYINCLUDE_EDITOR_ANIMATION_ANIMATIONBIPEDBONENAMES_H
|
||||
|
||||
@@ -36,4 +36,4 @@ namespace AssetDatabase
|
||||
|
||||
AzToolsFramework::AssetDatabase::AssetDatabaseConnection* m_assetDatabaseConnection = nullptr;
|
||||
};
|
||||
}//namespace AssetDatabase
|
||||
}//namespace AssetDatabase
|
||||
|
||||
@@ -50,8 +50,6 @@
|
||||
#include "Include/IObjectManager.h"
|
||||
#include "CryEditDoc.h"
|
||||
#include "QtViewPaneManager.h"
|
||||
#include "AzAssetBrowser/Preview/LegacyPreviewerFactory.h"
|
||||
|
||||
|
||||
namespace AzAssetBrowserRequestHandlerPrivate
|
||||
{
|
||||
@@ -230,18 +228,15 @@ namespace AzAssetBrowserRequestHandlerPrivate
|
||||
}
|
||||
|
||||
AzAssetBrowserRequestHandler::AzAssetBrowserRequestHandler()
|
||||
: m_previewerFactory(aznew LegacyPreviewerFactory)
|
||||
{
|
||||
using namespace AzToolsFramework::AssetBrowser;
|
||||
|
||||
AssetBrowserInteractionNotificationBus::Handler::BusConnect();
|
||||
AzQtComponents::DragAndDropEventsBus::Handler::BusConnect(AzQtComponents::DragAndDropContexts::EditorViewport);
|
||||
AzToolsFramework::AssetBrowser::PreviewerRequestBus::Handler::BusConnect();
|
||||
}
|
||||
|
||||
AzAssetBrowserRequestHandler::~AzAssetBrowserRequestHandler()
|
||||
{
|
||||
AzToolsFramework::AssetBrowser::PreviewerRequestBus::Handler::BusDisconnect();
|
||||
AzToolsFramework::AssetBrowser::AssetBrowserInteractionNotificationBus::Handler::BusDisconnect();
|
||||
AzQtComponents::DragAndDropEventsBus::Handler::BusDisconnect();
|
||||
}
|
||||
@@ -527,15 +522,6 @@ void AzAssetBrowserRequestHandler::Drop(QDropEvent* event, AzQtComponents::DragA
|
||||
}
|
||||
}
|
||||
|
||||
const AzToolsFramework::AssetBrowser::PreviewerFactory* AzAssetBrowserRequestHandler::GetPreviewerFactory(const AzToolsFramework::AssetBrowser::AssetBrowserEntry* entry) const
|
||||
{
|
||||
if (m_previewerFactory->IsEntrySupported(entry))
|
||||
{
|
||||
return m_previewerFactory.get();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void AzAssetBrowserRequestHandler::AddSourceFileOpeners(const char* fullSourceFileName, const AZ::Uuid& sourceUUID, AzToolsFramework::AssetBrowser::SourceFileOpenerList& openers)
|
||||
{
|
||||
using namespace AzToolsFramework;
|
||||
|
||||
@@ -37,12 +37,9 @@ namespace AzToolsFramework
|
||||
}
|
||||
}
|
||||
|
||||
class LegacyPreviewerFactory;
|
||||
|
||||
class AzAssetBrowserRequestHandler
|
||||
: protected AzToolsFramework::AssetBrowser::AssetBrowserInteractionNotificationBus::Handler
|
||||
, protected AzQtComponents::DragAndDropEventsBus::Handler
|
||||
, protected AzToolsFramework::AssetBrowser::PreviewerRequestBus::Handler
|
||||
{
|
||||
public:
|
||||
AzAssetBrowserRequestHandler();
|
||||
@@ -66,16 +63,8 @@ protected:
|
||||
void DragLeave(QDragLeaveEvent* event) override;
|
||||
void Drop(QDropEvent* event, AzQtComponents::DragAndDropContextBase& context) override;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// PreviewerRequestBus::Handler
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
const AzToolsFramework::AssetBrowser::PreviewerFactory* GetPreviewerFactory(const AzToolsFramework::AssetBrowser::AssetBrowserEntry* entry) const override;
|
||||
|
||||
bool CanAcceptDragAndDropEvent(
|
||||
QDropEvent* event, AzQtComponents::DragAndDropContextBase& context,
|
||||
AZStd::optional<AZStd::vector<const AzToolsFramework::AssetBrowser::SourceAssetBrowserEntry*>*> outSources = AZStd::nullopt,
|
||||
AZStd::optional<AZStd::vector<const AzToolsFramework::AssetBrowser::ProductAssetBrowserEntry*>*> outProducts = AZStd::nullopt) const;
|
||||
|
||||
private:
|
||||
AZStd::unique_ptr<const LegacyPreviewerFactory> m_previewerFactory;
|
||||
};
|
||||
|
||||
@@ -1,409 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "EditorDefs.h"
|
||||
|
||||
#include "LegacyPreviewer.h"
|
||||
|
||||
// AzToolsFramework
|
||||
#include <AzToolsFramework/AssetBrowser/AssetBrowserBus.h>
|
||||
#include <AzToolsFramework/AssetBrowser/AssetBrowserEntry.h>
|
||||
#include <AzToolsFramework/AssetBrowser/EBusFindAssetTypeByName.h>
|
||||
|
||||
// Editor
|
||||
#include "Util/Image.h"
|
||||
#include "Util/ImageUtil.h"
|
||||
|
||||
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
#include <AzAssetBrowser/Preview/ui_LegacyPreviewer.h>
|
||||
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
|
||||
|
||||
static const int s_CharWidth = 6;
|
||||
const QString LegacyPreviewer::Name{ QStringLiteral("LegacyPreviewer") };
|
||||
|
||||
LegacyPreviewer::LegacyPreviewer(QWidget* parent)
|
||||
: Previewer(parent)
|
||||
, m_ui(new Ui::LegacyPreviewerClass())
|
||||
, m_textureType(TextureType::RGB)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->m_comboBoxRGB->addItems(QStringList() << "RGB" << "RGBA" << "Alpha");
|
||||
m_ui->m_previewCtrl->SetAspectRatio(4.0f / 3.0f);
|
||||
connect(m_ui->m_comboBoxRGB, static_cast<void(QComboBox::*)(int)>(&QComboBox::activated), this,
|
||||
[=](int index)
|
||||
{
|
||||
m_textureType = static_cast<TextureType>(index);
|
||||
UpdateTextureType();
|
||||
});
|
||||
Clear();
|
||||
}
|
||||
|
||||
LegacyPreviewer::~LegacyPreviewer()
|
||||
{
|
||||
}
|
||||
|
||||
void LegacyPreviewer::Clear() const
|
||||
{
|
||||
m_ui->m_previewCtrl->ReleaseObject();
|
||||
m_ui->m_modelPreviewWidget->hide();
|
||||
m_ui->m_texturePreviewWidget->hide();
|
||||
m_ui->m_fileInfoCtrl->hide();
|
||||
}
|
||||
|
||||
void LegacyPreviewer::Display(const AzToolsFramework::AssetBrowser::AssetBrowserEntry* entry)
|
||||
{
|
||||
using namespace AzToolsFramework::AssetBrowser;
|
||||
|
||||
if (!entry)
|
||||
{
|
||||
Clear();
|
||||
return;
|
||||
}
|
||||
|
||||
switch (entry->GetEntryType())
|
||||
{
|
||||
case AssetBrowserEntry::AssetEntryType::Source:
|
||||
{
|
||||
const SourceAssetBrowserEntry* sourceEntry = azrtti_cast<const SourceAssetBrowserEntry*>(entry);
|
||||
DisplaySource(sourceEntry);
|
||||
break;
|
||||
}
|
||||
case AssetBrowserEntry::AssetEntryType::Product:
|
||||
DisplayProduct(static_cast<const ProductAssetBrowserEntry*>(entry));
|
||||
break;
|
||||
default:
|
||||
Clear();
|
||||
}
|
||||
}
|
||||
|
||||
const QString& LegacyPreviewer::GetName() const
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
|
||||
void LegacyPreviewer::resizeEvent(QResizeEvent* /*event*/)
|
||||
{
|
||||
m_ui->m_fileInfoCtrl->setText(WordWrap(m_fileinfo, m_ui->m_fileInfoCtrl->width() / s_CharWidth));
|
||||
}
|
||||
|
||||
bool LegacyPreviewer::DisplayProduct(const AzToolsFramework::AssetBrowser::ProductAssetBrowserEntry* product)
|
||||
{
|
||||
m_ui->m_fileInfoCtrl->show();
|
||||
|
||||
m_fileinfo = QString::fromUtf8(product->GetName().c_str());
|
||||
|
||||
m_fileinfo += GetFileSize(product->GetRelativePath().c_str());
|
||||
|
||||
EBusFindAssetTypeByName meshAssetTypeResult("Static Mesh");
|
||||
AZ::AssetTypeInfoBus::BroadcastResult(meshAssetTypeResult, &AZ::AssetTypeInfo::GetAssetType);
|
||||
|
||||
QString filename(product->GetRelativePath().c_str());
|
||||
|
||||
// Find item.
|
||||
if (product->GetAssetType() == meshAssetTypeResult.GetAssetType())
|
||||
{
|
||||
m_ui->m_modelPreviewWidget->show();
|
||||
m_ui->m_texturePreviewWidget->hide();
|
||||
m_ui->m_previewCtrl->LoadFile(filename);
|
||||
|
||||
int nVertexCount = m_ui->m_previewCtrl->GetVertexCount();
|
||||
int nFaceCount = m_ui->m_previewCtrl->GetFaceCount();
|
||||
int nMaxLod = m_ui->m_previewCtrl->GetMaxLod();
|
||||
int nMtls = m_ui->m_previewCtrl->GetMtlCount();
|
||||
if (nFaceCount > 0)
|
||||
{
|
||||
m_fileinfo += tr("\r\n%1 Faces\r\n%2 Verts\r\n%3 MaxLod\r\n%4 Materials").arg(nFaceCount).arg(nVertexCount).arg(nMaxLod).arg(nMtls);
|
||||
}
|
||||
m_ui->m_fileInfoCtrl->setText(WordWrap(m_fileinfo, m_ui->m_fileInfoCtrl->width() / s_CharWidth));
|
||||
updateGeometry();
|
||||
return true;
|
||||
}
|
||||
|
||||
EBusFindAssetTypeByName textureAssetTypeResult("Texture");
|
||||
AZ::AssetTypeInfoBus::BroadcastResult(textureAssetTypeResult, &AZ::AssetTypeInfo::GetAssetType);
|
||||
|
||||
if (product->GetAssetType() == textureAssetTypeResult.GetAssetType())
|
||||
{
|
||||
// Get full product file path
|
||||
const char* assetCachePath = AZ::IO::FileIOBase::GetInstance()->GetAlias("@assets@");
|
||||
AZStd::string productFullPath;
|
||||
AzFramework::StringFunc::Path::Join(assetCachePath, product->GetRelativePath().c_str(), productFullPath);
|
||||
if (AZ::IO::FileIOBase::GetInstance()->Exists(productFullPath.c_str()))
|
||||
{
|
||||
// Try to display it in modern dds image loader, if no one exists, use the legacy image loader
|
||||
bool foundPixmap = DisplayTextureProductModern(productFullPath.c_str());
|
||||
return foundPixmap ? foundPixmap : DisplayTextureLegacy(productFullPath.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
// If we cannot find the product file, means it's not treated as an asset, display its source
|
||||
return DisplayTextureLegacy(product->GetFullPath().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
Clear();
|
||||
return false;
|
||||
}
|
||||
|
||||
void LegacyPreviewer::DisplaySource(const AzToolsFramework::AssetBrowser::SourceAssetBrowserEntry* source)
|
||||
{
|
||||
using namespace AzToolsFramework::AssetBrowser;
|
||||
|
||||
EBusFindAssetTypeByName textureAssetType("Texture");
|
||||
AZ::AssetTypeInfoBus::BroadcastResult(textureAssetType, &AZ::AssetTypeInfo::GetAssetType);
|
||||
|
||||
if (source->GetPrimaryAssetType() == textureAssetType.GetAssetType())
|
||||
{
|
||||
m_ui->m_fileInfoCtrl->show();
|
||||
m_fileinfo = QString::fromUtf8(source->GetName().c_str());
|
||||
m_fileinfo += GetFileSize(source->GetFullPath().c_str());
|
||||
const char* fullSourcePath = source->GetFullPath().c_str();
|
||||
// If it's a source dds file, try to display it using modern way
|
||||
if (AzFramework::StringFunc::Path::IsExtension(fullSourcePath, "dds", false))
|
||||
{
|
||||
if (DisplayTextureProductModern(fullSourcePath))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
DisplayTextureLegacy(source->GetFullPath().c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
AZStd::vector<const ProductAssetBrowserEntry*> products;
|
||||
source->GetChildrenRecursively<ProductAssetBrowserEntry>(products);
|
||||
if (products.empty())
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
for (auto* product : products)
|
||||
{
|
||||
if (DisplayProduct(product))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QString LegacyPreviewer::GetFileSize(const char* path)
|
||||
{
|
||||
QString fileSizeStr;
|
||||
AZ::u64 fileSizeResult = 0;
|
||||
if (AZ::IO::FileIOBase::GetInstance()->Size(path, fileSizeResult))
|
||||
{
|
||||
static double kb = 1024.0f;
|
||||
static double mb = kb * 1024.0;
|
||||
static double gb = mb * 1024.0;
|
||||
|
||||
static QString byteStr = "B";
|
||||
static QString kbStr = "KB";
|
||||
static QString mbStr = "MB";
|
||||
static QString gbStr = "GB";
|
||||
|
||||
#if AZ_TRAIT_OS_PLATFORM_APPLE
|
||||
kb = 1000.0;
|
||||
mb = kb * 1000.0;
|
||||
gb = mb * 1000.0;
|
||||
|
||||
kbStr = "kB";
|
||||
mbStr = "mB";
|
||||
gbStr = "gB";
|
||||
#endif // AZ_TRAIT_OS_PLATFORM_APPLE
|
||||
|
||||
if (fileSizeResult < kb)
|
||||
{
|
||||
fileSizeStr += tr("\r\nFile Size: %1%2").arg(QString::number(fileSizeResult), byteStr);
|
||||
}
|
||||
else if (fileSizeResult < mb)
|
||||
{
|
||||
double size = fileSizeResult / kb;
|
||||
fileSizeStr += tr("\r\nFile Size: %1%2").arg(QString::number(size, 'f', 2), kbStr);
|
||||
}
|
||||
else if (fileSizeResult < gb)
|
||||
{
|
||||
double size = fileSizeResult / mb;
|
||||
fileSizeStr += tr("\r\nFile Size: %1%2").arg(QString::number(size, 'f', 2), mbStr);
|
||||
}
|
||||
else
|
||||
{
|
||||
double size = fileSizeResult / gb;
|
||||
fileSizeStr += tr("\r\nFile Size: %1%2").arg(QString::number(size, 'f', 2), gbStr);
|
||||
}
|
||||
}
|
||||
return fileSizeStr;
|
||||
}
|
||||
|
||||
bool LegacyPreviewer::DisplayTextureLegacy(const char* fullImagePath)
|
||||
{
|
||||
m_ui->m_modelPreviewWidget->hide();
|
||||
m_ui->m_texturePreviewWidget->show();
|
||||
|
||||
bool foundPixmap = false;
|
||||
if (!AZ::IO::FileIOBase::GetInstance()->IsDirectory(fullImagePath))
|
||||
{
|
||||
QString strLoadFilename = QString(fullImagePath);
|
||||
if (CImageUtil::LoadImage(strLoadFilename, m_previewImageSource))
|
||||
{
|
||||
m_fileinfo += QStringLiteral("\r\n%1x%2\r\n%3")
|
||||
.arg(m_previewImageSource.GetWidth())
|
||||
.arg(m_previewImageSource.GetHeight())
|
||||
.arg(m_previewImageSource.GetFormatDescription());
|
||||
|
||||
m_fileinfoAlphaTexture = m_fileinfo;
|
||||
UpdateTextureType();
|
||||
foundPixmap = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundPixmap)
|
||||
{
|
||||
m_ui->m_previewImageCtrl->setPixmap(QPixmap());
|
||||
m_ui->m_fileInfoCtrl->setText(WordWrap(m_fileinfo, m_ui->m_fileInfoCtrl->width() / s_CharWidth));
|
||||
}
|
||||
|
||||
updateGeometry();
|
||||
|
||||
return foundPixmap;
|
||||
}
|
||||
|
||||
bool LegacyPreviewer::DisplayTextureProductModern(const char* fullProductImagePath)
|
||||
{
|
||||
m_ui->m_modelPreviewWidget->hide();
|
||||
m_ui->m_texturePreviewWidget->show();
|
||||
|
||||
bool foundPixmap = false;
|
||||
QImage previewImage;
|
||||
AZStd::string productInfo;
|
||||
AZStd::string productAlphaInfo;
|
||||
AzToolsFramework::AssetBrowser::AssetBrowserTexturePreviewRequestsBus::BroadcastResult(foundPixmap, &AzToolsFramework::AssetBrowser::AssetBrowserTexturePreviewRequests::GetProductTexturePreview, fullProductImagePath, previewImage, productInfo, productAlphaInfo);
|
||||
|
||||
if (foundPixmap)
|
||||
{
|
||||
QPixmap pix = QPixmap::fromImage(previewImage);
|
||||
m_ui->m_previewImageCtrl->setPixmap(pix);
|
||||
m_ui->m_previewImageCtrl->updateGeometry();
|
||||
CImageUtil::QImageToImage(previewImage, m_previewImageSource);
|
||||
|
||||
m_fileinfo += QStringLiteral("\r\n%1x%2\r\n%3")
|
||||
.arg(m_previewImageSource.GetWidth())
|
||||
.arg(m_previewImageSource.GetHeight())
|
||||
.arg(m_previewImageSource.GetFormatDescription());
|
||||
|
||||
m_fileinfoAlphaTexture = m_fileinfo;
|
||||
|
||||
m_fileinfo += QString(productInfo.c_str());
|
||||
if (productAlphaInfo.empty())
|
||||
{
|
||||
// If there is no separate info for alpha, use the image info
|
||||
m_fileinfoAlphaTexture += QString(productInfo.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
m_fileinfoAlphaTexture += QString(productAlphaInfo.c_str());
|
||||
}
|
||||
|
||||
|
||||
UpdateTextureType();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->m_previewImageCtrl->setPixmap(QPixmap());
|
||||
m_ui->m_fileInfoCtrl->setText(WordWrap(m_fileinfo, m_ui->m_fileInfoCtrl->width() / s_CharWidth));
|
||||
}
|
||||
|
||||
updateGeometry();
|
||||
return foundPixmap;
|
||||
}
|
||||
|
||||
void LegacyPreviewer::UpdateTextureType()
|
||||
{
|
||||
m_previewImageUpdated.Copy(m_previewImageSource);
|
||||
|
||||
switch (m_textureType)
|
||||
{
|
||||
case TextureType::RGB:
|
||||
{
|
||||
m_previewImageUpdated.SwapRedAndBlue();
|
||||
m_previewImageUpdated.FillAlpha();
|
||||
break;
|
||||
}
|
||||
case TextureType::RGBA:
|
||||
{
|
||||
m_previewImageUpdated.SwapRedAndBlue();
|
||||
break;
|
||||
}
|
||||
case TextureType::Alpha:
|
||||
{
|
||||
for (int h = 0; h < m_previewImageUpdated.GetHeight(); h++)
|
||||
{
|
||||
for (int w = 0; w < m_previewImageUpdated.GetWidth(); w++)
|
||||
{
|
||||
int a = m_previewImageUpdated.ValueAt(w, h) >> 24;
|
||||
m_previewImageUpdated.ValueAt(w, h) = RGB(a, a, a) | 0xFF000000;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
// note that Qt will not deep copy the data, so WE MUST KEEP THE IMAGE DATA AROUND!
|
||||
QPixmap qtPixmap = QPixmap::fromImage(
|
||||
QImage(reinterpret_cast<uchar*>(m_previewImageUpdated.GetData()), m_previewImageUpdated.GetWidth(), m_previewImageUpdated.GetHeight(), QImage::Format_ARGB32));
|
||||
m_ui->m_previewImageCtrl->setPixmap(qtPixmap);
|
||||
m_ui->m_fileInfoCtrl->setText(WordWrap(m_textureType == TextureType::Alpha? m_fileinfoAlphaTexture: m_fileinfo, m_ui->m_fileInfoCtrl->width() / s_CharWidth));
|
||||
m_ui->m_previewImageCtrl->updateGeometry();
|
||||
}
|
||||
|
||||
bool LegacyPreviewer::FileInfoCompare(const FileInfo& f1, const FileInfo& f2)
|
||||
{
|
||||
if ((f1.attrib & _A_SUBDIR) && !(f2.attrib & _A_SUBDIR))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (!(f1.attrib & _A_SUBDIR) && (f2.attrib & _A_SUBDIR))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return QString::compare(f1.filename, f2.filename, Qt::CaseInsensitive) < 0;
|
||||
}
|
||||
|
||||
QString LegacyPreviewer::WordWrap(const QString& string, int maxLength)
|
||||
{
|
||||
QString result;
|
||||
int length = 0;
|
||||
|
||||
for (auto c : string)
|
||||
{
|
||||
if (c == '\n')
|
||||
{
|
||||
length = 0;
|
||||
}
|
||||
else if (length > maxLength)
|
||||
{
|
||||
result.append('\n');
|
||||
length = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
length++;
|
||||
}
|
||||
result.append(c);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
#include <AzAssetBrowser/Preview/moc_LegacyPreviewer.cpp>
|
||||
@@ -1,100 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include <Editor/Util/Image.h>
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
#include <AzToolsFramework/AssetBrowser/Previewer/Previewer.h>
|
||||
|
||||
#include <QWidget>
|
||||
#include <QScopedPointer>
|
||||
#endif
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class LegacyPreviewerClass;
|
||||
}
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
namespace AssetBrowser
|
||||
{
|
||||
class ProductAssetBrowserEntry;
|
||||
class SourceAssetBrowserEntry;
|
||||
class AssetBrowserEntry;
|
||||
}
|
||||
}
|
||||
|
||||
class QResizeEvent;
|
||||
|
||||
class LegacyPreviewer
|
||||
: public AzToolsFramework::AssetBrowser::Previewer
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(LegacyPreviewer, AZ::SystemAllocator, 0);
|
||||
|
||||
explicit LegacyPreviewer(QWidget* parent = nullptr);
|
||||
~LegacyPreviewer();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// AzToolsFramework::AssetBrowser::Previewer
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Clear() const override;
|
||||
void Display(const AzToolsFramework::AssetBrowser::AssetBrowserEntry* entry) override;
|
||||
const QString& GetName() const override;
|
||||
|
||||
static const QString Name;
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent * event) override;
|
||||
|
||||
private:
|
||||
struct FileInfo
|
||||
{
|
||||
QString filename;
|
||||
unsigned attrib;
|
||||
time_t time_create; /* -1 for FAT file systems */
|
||||
time_t time_access; /* -1 for FAT file systems */
|
||||
time_t time_write;
|
||||
_fsize_t size;
|
||||
};
|
||||
|
||||
enum class TextureType
|
||||
{
|
||||
RGB,
|
||||
RGBA,
|
||||
Alpha
|
||||
};
|
||||
|
||||
QScopedPointer<Ui::LegacyPreviewerClass> m_ui;
|
||||
CImageEx m_previewImageSource;
|
||||
CImageEx m_previewImageUpdated;
|
||||
TextureType m_textureType;
|
||||
QString m_fileinfo;
|
||||
QString m_fileinfoAlphaTexture;
|
||||
|
||||
bool DisplayProduct(const AzToolsFramework::AssetBrowser::ProductAssetBrowserEntry* product);
|
||||
void DisplaySource(const AzToolsFramework::AssetBrowser::SourceAssetBrowserEntry* source);
|
||||
|
||||
QString GetFileSize(const char* path);
|
||||
|
||||
bool DisplayTextureLegacy(const char* fullImagePath);
|
||||
bool DisplayTextureProductModern(const char* fullProductImagePath);
|
||||
|
||||
void UpdateTextureType();
|
||||
|
||||
static bool FileInfoCompare(const FileInfo& f1, const FileInfo& f2);
|
||||
//! QLabel word wrap does not break long words such as filenames, so manual word wrap needed
|
||||
static QString WordWrap(const QString& string, int maxLength);
|
||||
};
|
||||
@@ -1,176 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>LegacyPreviewerClass</class>
|
||||
<widget class="QWidget" name="LegacyPreviewerClass">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>148</width>
|
||||
<height>282</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Preview</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QWidget" name="m_texturePreviewWidget" native="true">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="m_horizontalLayout">
|
||||
<item>
|
||||
<spacer name="m_horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="m_comboBoxRGB">
|
||||
<property name="currentText">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="AzToolsFramework::AspectRatioAwarePixmapWidget" name="m_previewImageCtrl" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="m_modelPreviewWidget" native="true">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="CPreviewModelCtrl" name="m_previewCtrl" native="true"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="m_fileInfoCtrl">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Ignored" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::AutoText</enum>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="m_verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>CPreviewModelCtrl</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>Controls/PreviewModelCtrl.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>AzToolsFramework::AspectRatioAwarePixmapWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>AzToolsFramework/UI/UICore/AspectRatioAwarePixmapWidget.hxx</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "EditorDefs.h"
|
||||
|
||||
#include "LegacyPreviewerFactory.h"
|
||||
|
||||
// AzToolsFramework
|
||||
#include <AzToolsFramework/AssetBrowser/AssetBrowserEntry.h> // for AssetBrowserEntry::AssetEntryType
|
||||
#include <AzToolsFramework/AssetBrowser/EBusFindAssetTypeByName.h> // for EBusFindAssetTypeByName
|
||||
|
||||
// Editor
|
||||
#include "LegacyPreviewer.h"
|
||||
|
||||
|
||||
AzToolsFramework::AssetBrowser::Previewer* LegacyPreviewerFactory::CreatePreviewer(QWidget* parent) const
|
||||
{
|
||||
return new LegacyPreviewer(parent);
|
||||
}
|
||||
|
||||
bool LegacyPreviewerFactory::IsEntrySupported(const AzToolsFramework::AssetBrowser::AssetBrowserEntry* entry) const
|
||||
{
|
||||
using namespace AzToolsFramework::AssetBrowser;
|
||||
|
||||
EBusFindAssetTypeByName meshAssetTypeResult("Static Mesh");
|
||||
AZ::AssetTypeInfoBus::BroadcastResult(meshAssetTypeResult, &AZ::AssetTypeInfo::GetAssetType);
|
||||
EBusFindAssetTypeByName textureAssetTypeResult("Texture");
|
||||
AZ::AssetTypeInfoBus::BroadcastResult(textureAssetTypeResult, &AZ::AssetTypeInfo::GetAssetType);
|
||||
|
||||
switch (entry->GetEntryType())
|
||||
{
|
||||
case AssetBrowserEntry::AssetEntryType::Source:
|
||||
{
|
||||
const auto* source = azrtti_cast < const SourceAssetBrowserEntry * > (entry);
|
||||
if (source->GetPrimaryAssetType() == textureAssetTypeResult.GetAssetType())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
AZStd::vector < const ProductAssetBrowserEntry * > products;
|
||||
source->GetChildrenRecursively < ProductAssetBrowserEntry > (products);
|
||||
for (auto* product : products)
|
||||
{
|
||||
if (product->GetAssetType() == textureAssetTypeResult.GetAssetType() ||
|
||||
product->GetAssetType() == meshAssetTypeResult.GetAssetType())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case AssetBrowserEntry::AssetEntryType::Product:
|
||||
const auto* product = azrtti_cast < const ProductAssetBrowserEntry * > (entry);
|
||||
return product->GetAssetType() == textureAssetTypeResult.GetAssetType() ||
|
||||
product->GetAssetType() == meshAssetTypeResult.GetAssetType();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const QString& LegacyPreviewerFactory::GetName() const
|
||||
{
|
||||
return LegacyPreviewer::Name;
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
#include <AzToolsFramework/AssetBrowser/Previewer/PreviewerFactory.h>
|
||||
|
||||
class QString;
|
||||
|
||||
class LegacyPreviewerFactory final
|
||||
: public AzToolsFramework::AssetBrowser::PreviewerFactory
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(LegacyPreviewerFactory, AZ::SystemAllocator, 0);
|
||||
|
||||
LegacyPreviewerFactory() = default;
|
||||
~LegacyPreviewerFactory() = default;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// AzToolsFramework::AssetBrowser::PreviewerFactory
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
AzToolsFramework::AssetBrowser::Previewer* CreatePreviewer(QWidget* parent = nullptr) const override;
|
||||
bool IsEntrySupported(const AzToolsFramework::AssetBrowser::AssetBrowserEntry* entry) const override;
|
||||
const QString& GetName() const override;
|
||||
};
|
||||
@@ -1,629 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#include "EditorDefs.h"
|
||||
|
||||
#include "BackgroundScheduleManager.h"
|
||||
|
||||
namespace BackgroundScheduleManager
|
||||
{
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
CScheduleItem::CScheduleItem(const char* szName)
|
||||
: m_name(szName)
|
||||
, m_refCount(1)
|
||||
, m_state(eScheduleItemState_Pending)
|
||||
{
|
||||
}
|
||||
|
||||
CScheduleItem::~CScheduleItem()
|
||||
{
|
||||
CRY_ASSERT(m_refCount == 0);
|
||||
|
||||
for (TWorkItems::const_iterator it = m_workItems.begin();
|
||||
it != m_workItems.end(); ++it)
|
||||
{
|
||||
(*it)->Release();
|
||||
}
|
||||
}
|
||||
|
||||
const char* CScheduleItem::GetDescription() const
|
||||
{
|
||||
return m_name.c_str();
|
||||
}
|
||||
|
||||
EScheduleItemState CScheduleItem::GetState() const
|
||||
{
|
||||
return m_state;
|
||||
}
|
||||
|
||||
const float CScheduleItem::GetProgress() const
|
||||
{
|
||||
if (m_workItems.empty())
|
||||
{
|
||||
return 1.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
float totalProgress = 0.0f;
|
||||
|
||||
for (TWorkItems::const_iterator it = m_workItems.begin();
|
||||
it != m_workItems.end(); ++it)
|
||||
{
|
||||
totalProgress += (*it)->GetProgress();
|
||||
}
|
||||
|
||||
return totalProgress / (float)m_workItems.size();
|
||||
}
|
||||
}
|
||||
|
||||
const uint32 CScheduleItem::GetNumWorkItems() const
|
||||
{
|
||||
return m_workItems.size();
|
||||
}
|
||||
|
||||
IBackgroundScheduleItemWork* CScheduleItem::GetWorkItem(const uint32 index) const
|
||||
{
|
||||
return m_workItems[index];
|
||||
}
|
||||
|
||||
void CScheduleItem::AddWorkItem(IBackgroundScheduleItemWork* pWork)
|
||||
{
|
||||
// cannot add new work items when item has finished or failed
|
||||
if (m_state == eScheduleItemState_Failed || m_state == eScheduleItemState_Completed)
|
||||
{
|
||||
CryFatalError("Cannot add new work items when item has finished or failed");
|
||||
return;
|
||||
}
|
||||
|
||||
// add to the work list
|
||||
if (m_state == eScheduleItemState_Processing)
|
||||
{
|
||||
m_addedWorkItems.push_back(pWork);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_workItems.push_back(pWork);
|
||||
}
|
||||
}
|
||||
|
||||
void CScheduleItem::AddRef()
|
||||
{
|
||||
CryInterlockedIncrement(&m_refCount);
|
||||
}
|
||||
|
||||
void CScheduleItem::Release()
|
||||
{
|
||||
const int nCount = CryInterlockedDecrement(&m_refCount);
|
||||
assert(nCount >= 0);
|
||||
if (nCount == 0)
|
||||
{
|
||||
delete this;
|
||||
}
|
||||
else if (nCount < 0)
|
||||
{
|
||||
assert(0);
|
||||
CryFatalError("Deleting Reference Counted Object Twice");
|
||||
}
|
||||
}
|
||||
|
||||
void CScheduleItem::RequestStop()
|
||||
{
|
||||
if (m_state == eScheduleItemState_Pending)
|
||||
{
|
||||
// we can stop right away :)
|
||||
m_state = eScheduleItemState_Failed;
|
||||
}
|
||||
else if (m_state == eScheduleItemState_Processing)
|
||||
{
|
||||
m_state = eScheduleItemState_Stopping;
|
||||
|
||||
// signal all pending work to stop
|
||||
uint32 curIndex = 0;
|
||||
while (curIndex < m_processedWorkItems.size())
|
||||
{
|
||||
IBackgroundScheduleItemWork* pWork = m_processedWorkItems[curIndex];
|
||||
if (pWork->OnStop())
|
||||
{
|
||||
// if the work was stopped remove it from list
|
||||
m_processedWorkItems.erase(m_processedWorkItems.begin() + curIndex);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
// this work item cannot be stopped this frame
|
||||
curIndex += 1;
|
||||
}
|
||||
}
|
||||
|
||||
// if all pending work has been stopped we can assume the failed state
|
||||
if (m_processedWorkItems.empty())
|
||||
{
|
||||
m_state = eScheduleItemState_Failed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EScheduleWorkItemStatus CScheduleItem::Update()
|
||||
{
|
||||
EScheduleWorkItemStatus retStatus = eScheduleWorkItemStatus_NotFinished;
|
||||
|
||||
switch (m_state)
|
||||
{
|
||||
// finial state - work failed
|
||||
case eScheduleItemState_Failed:
|
||||
{
|
||||
retStatus = eScheduleWorkItemStatus_Failed;
|
||||
break;
|
||||
}
|
||||
|
||||
// final state - work completed
|
||||
case eScheduleItemState_Completed:
|
||||
{
|
||||
retStatus = eScheduleWorkItemStatus_Finished;
|
||||
break;
|
||||
}
|
||||
|
||||
// first update, start all the work items
|
||||
case eScheduleItemState_Pending:
|
||||
{
|
||||
// start all of the tasks
|
||||
bool bHasFailedStarts = false;
|
||||
for (TWorkItems::const_iterator it = m_workItems.begin();
|
||||
it != m_workItems.end(); ++it)
|
||||
{
|
||||
IBackgroundScheduleItemWork* pWork = (*it);
|
||||
|
||||
if (pWork->OnStart())
|
||||
{
|
||||
m_processedWorkItems.push_back(pWork);
|
||||
}
|
||||
else
|
||||
{
|
||||
bHasFailedStarts = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (bHasFailedStarts)
|
||||
{
|
||||
m_state = eScheduleItemState_Stopping;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_state = eScheduleItemState_Processing;
|
||||
/* FALLS THROUGHT TO PROCESSING STATE */
|
||||
}
|
||||
}
|
||||
|
||||
// work processing state
|
||||
case eScheduleItemState_Processing:
|
||||
{
|
||||
// process new work items that were added while the schedule was created
|
||||
if (!m_addedWorkItems.empty())
|
||||
{
|
||||
for (TWorkItems::const_iterator it = m_addedWorkItems.begin();
|
||||
it != m_addedWorkItems.end(); ++it)
|
||||
{
|
||||
IBackgroundScheduleItemWork* pWork = (*it);
|
||||
pWork->OnStart();
|
||||
m_processedWorkItems.push_back(pWork);
|
||||
m_workItems.push_back(pWork);
|
||||
}
|
||||
|
||||
m_addedWorkItems.clear();
|
||||
}
|
||||
|
||||
// update work items
|
||||
bool bHasFailedItems = false;
|
||||
TWorkItems completedItems;
|
||||
for (TWorkItems::const_iterator it = m_processedWorkItems.begin();
|
||||
it != m_processedWorkItems.end(); ++it)
|
||||
{
|
||||
IBackgroundScheduleItemWork* pWork = (*it);
|
||||
|
||||
// update given work item
|
||||
const EScheduleWorkItemStatus status = pWork->OnUpdate();
|
||||
if (status == eScheduleWorkItemStatus_Finished)
|
||||
{
|
||||
completedItems.push_back(pWork);
|
||||
continue;
|
||||
}
|
||||
|
||||
// item failed - we need to stop other tasks
|
||||
if (status == eScheduleWorkItemStatus_Failed)
|
||||
{
|
||||
bHasFailedItems = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// cleanup completed items
|
||||
for (TWorkItems::iterator it = completedItems.begin();
|
||||
it != completedItems.end(); ++it)
|
||||
{
|
||||
IBackgroundScheduleItemWork* pWork = (*it);
|
||||
TWorkItems::iterator jt = std::find(m_processedWorkItems.begin(), m_processedWorkItems.end(), pWork);
|
||||
m_processedWorkItems.erase(jt);
|
||||
}
|
||||
|
||||
if (!bHasFailedItems)
|
||||
{
|
||||
// all work has finished
|
||||
if (m_processedWorkItems.empty())
|
||||
{
|
||||
retStatus = eScheduleWorkItemStatus_Finished;
|
||||
m_state = eScheduleItemState_Completed;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
// some of the items failed
|
||||
m_state = eScheduleItemState_Stopping;
|
||||
/* FALL THROUGH TO STOPPING STATE */
|
||||
}
|
||||
}
|
||||
|
||||
// We are stopping failed work
|
||||
case eScheduleItemState_Stopping:
|
||||
{
|
||||
uint32 curIndex = 0;
|
||||
while (curIndex < m_processedWorkItems.size())
|
||||
{
|
||||
IBackgroundScheduleItemWork* pWork = m_processedWorkItems[curIndex];
|
||||
if (pWork->OnStop())
|
||||
{
|
||||
// if the work was stopped remove it from list
|
||||
m_processedWorkItems.erase(m_processedWorkItems.begin() + curIndex);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
// this work item cannot be stopped this frame
|
||||
curIndex += 1;
|
||||
}
|
||||
}
|
||||
|
||||
// if all pending work has been stopped we can assume the failed state
|
||||
if (m_processedWorkItems.empty())
|
||||
{
|
||||
m_state = eScheduleItemState_Failed;
|
||||
return eScheduleWorkItemStatus_Failed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return retStatus;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
CSchedule::CSchedule(const char* szName)
|
||||
: m_name(szName)
|
||||
, m_refCount(1)
|
||||
, m_bCanceled(false)
|
||||
, m_currentItem(0)
|
||||
, m_state(eScheduleState_Pending)
|
||||
{
|
||||
}
|
||||
|
||||
CSchedule::~CSchedule()
|
||||
{
|
||||
CRY_ASSERT(m_refCount == 0);
|
||||
|
||||
for (TItems::const_iterator it = m_items.begin();
|
||||
it != m_items.end(); ++it)
|
||||
{
|
||||
CScheduleItem* pItem = *it;
|
||||
SAFE_RELEASE(pItem);
|
||||
}
|
||||
|
||||
m_items.clear();
|
||||
}
|
||||
|
||||
const char* CSchedule::GetDescription() const
|
||||
{
|
||||
return m_name.c_str();
|
||||
}
|
||||
|
||||
float CSchedule::GetProgress() const
|
||||
{
|
||||
if (m_currentItem >= m_items.size())
|
||||
{
|
||||
return 1.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
const float itemProgress = 1.0f / (float)(m_items.size());
|
||||
const IBackgroundScheduleItem* pItem = m_items[m_currentItem];
|
||||
return (m_currentItem + pItem->GetProgress()) * itemProgress;
|
||||
}
|
||||
}
|
||||
|
||||
IBackgroundScheduleItem* CSchedule::GetProcessedItem() const
|
||||
{
|
||||
if (m_currentItem >= m_items.size())
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
IBackgroundScheduleItem* pItem = m_items[m_currentItem];
|
||||
return pItem;
|
||||
}
|
||||
}
|
||||
|
||||
const uint32 CSchedule::GetNumItems() const
|
||||
{
|
||||
return m_items.size();
|
||||
}
|
||||
|
||||
IBackgroundScheduleItem* CSchedule::GetItem(const uint32 index) const
|
||||
{
|
||||
return m_items[index];
|
||||
}
|
||||
|
||||
EScheduleState CSchedule::GetState() const
|
||||
{
|
||||
return m_state;
|
||||
}
|
||||
|
||||
void CSchedule::Cancel()
|
||||
{
|
||||
m_bCanceled = true;
|
||||
}
|
||||
|
||||
bool CSchedule::IsCanceled() const
|
||||
{
|
||||
return m_bCanceled;
|
||||
}
|
||||
|
||||
void CSchedule::AddItem(IBackgroundScheduleItem* pItem)
|
||||
{
|
||||
if (NULL == pItem)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// we can add items only in the "pending" state
|
||||
if (pItem->GetState() != eScheduleItemState_Pending)
|
||||
{
|
||||
CryFatalError("Schedule items can be added to schedule only before their work starts");
|
||||
return;
|
||||
}
|
||||
|
||||
// item has no jobs, do not add
|
||||
if (pItem->GetNumWorkItems() == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_items.push_back(static_cast<CScheduleItem*>(pItem));
|
||||
pItem->AddRef();
|
||||
}
|
||||
|
||||
void CSchedule::AddRef()
|
||||
{
|
||||
CryInterlockedIncrement(&m_refCount);
|
||||
}
|
||||
|
||||
void CSchedule::Release()
|
||||
{
|
||||
const int nCount = CryInterlockedDecrement(&m_refCount);
|
||||
assert(nCount >= 0);
|
||||
if (nCount == 0)
|
||||
{
|
||||
delete this;
|
||||
}
|
||||
else if (nCount < 0)
|
||||
{
|
||||
assert(0);
|
||||
CryFatalError("Deleting Reference Counted Object Twice");
|
||||
}
|
||||
}
|
||||
|
||||
EScheduleWorkItemStatus CSchedule::Update()
|
||||
{
|
||||
EScheduleWorkItemStatus retStatus = eScheduleWorkItemStatus_NotFinished;
|
||||
|
||||
// we have a cancel request
|
||||
if (m_bCanceled)
|
||||
{
|
||||
CryLog("Schedule '%s' was canceled", GetDescription());
|
||||
|
||||
if (m_state == eScheduleState_Processing && m_currentItem < m_items.size())
|
||||
{
|
||||
// stop the current item
|
||||
CScheduleItem* pItem = m_items[m_currentItem];
|
||||
pItem->RequestStop();
|
||||
m_state = eSccheduleState_Stopping;
|
||||
}
|
||||
else if (m_state != eScheduleState_Completed)
|
||||
{
|
||||
m_state = eScheduleState_Failed;
|
||||
return eScheduleWorkItemStatus_Failed;
|
||||
}
|
||||
}
|
||||
|
||||
// process internal state machine
|
||||
switch (m_state)
|
||||
{
|
||||
// final state - work failed
|
||||
case eScheduleState_Failed:
|
||||
{
|
||||
retStatus = eScheduleWorkItemStatus_Failed;
|
||||
break;
|
||||
}
|
||||
|
||||
// final state - work completed
|
||||
case eScheduleState_Completed:
|
||||
{
|
||||
retStatus = eScheduleWorkItemStatus_Finished;
|
||||
break;
|
||||
}
|
||||
|
||||
// stopping current task
|
||||
case eSccheduleState_Stopping:
|
||||
{
|
||||
if (m_currentItem < m_items.size())
|
||||
{
|
||||
CScheduleItem* pItem = m_items[m_currentItem];
|
||||
if (pItem->Update() != eScheduleWorkItemStatus_NotFinished)
|
||||
{
|
||||
// task was finally stopped
|
||||
m_state = eScheduleState_Failed;
|
||||
retStatus = eScheduleWorkItemStatus_Failed;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// first update, switch to processing
|
||||
case eScheduleState_Pending:
|
||||
{
|
||||
m_state = eScheduleState_Processing;
|
||||
m_currentItem = 0;
|
||||
/* FALLS THROUGHT */
|
||||
}
|
||||
|
||||
// if we were in the processing phase inform the current schedule item to stop all it's work
|
||||
case eScheduleState_Processing:
|
||||
{
|
||||
// update schedule items
|
||||
while (m_currentItem < m_items.size())
|
||||
{
|
||||
CScheduleItem* pItem = m_items[m_currentItem];
|
||||
|
||||
const EScheduleWorkItemStatus itemStatus = pItem->Update();
|
||||
if (itemStatus == eScheduleWorkItemStatus_Finished)
|
||||
{
|
||||
m_currentItem += 1;
|
||||
continue;
|
||||
}
|
||||
else if (itemStatus == eScheduleWorkItemStatus_Failed)
|
||||
{
|
||||
m_state = eScheduleState_Failed;
|
||||
retStatus = eScheduleWorkItemStatus_Failed;
|
||||
gEnv->pLog->LogWarning("Schedule '%s' failed on item '%s'.", GetDescription(), pItem->GetDescription());
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// all items updated
|
||||
if (m_currentItem >= m_items.size())
|
||||
{
|
||||
// empty schedule, complete in one tick
|
||||
m_state = eScheduleState_Completed;
|
||||
retStatus = eScheduleWorkItemStatus_Finished;
|
||||
CryLog("Schedule '%s' completed", GetDescription());
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return retStatus;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
CScheduleManager::CScheduleManager()
|
||||
{
|
||||
GetIEditor()->RegisterNotifyListener(this);
|
||||
}
|
||||
|
||||
CScheduleManager::~CScheduleManager()
|
||||
{
|
||||
GetIEditor()->UnregisterNotifyListener(this);
|
||||
|
||||
for (TSchedules::const_iterator it = m_schedules.begin();
|
||||
it != m_schedules.end(); ++it)
|
||||
{
|
||||
CSchedule* pSchedule = *it;
|
||||
SAFE_RELEASE(pSchedule);
|
||||
}
|
||||
|
||||
m_schedules.clear();
|
||||
}
|
||||
|
||||
IBackgroundSchedule* CScheduleManager::CreateSchedule(const char* szName)
|
||||
{
|
||||
return new CSchedule(szName);
|
||||
}
|
||||
|
||||
IBackgroundScheduleItem* CScheduleManager::CreateScheduleItem(const char* szName)
|
||||
{
|
||||
return new CScheduleItem(szName);
|
||||
}
|
||||
|
||||
void CScheduleManager::SubmitSchedule(IBackgroundSchedule* pSchedule)
|
||||
{
|
||||
if (NULL != pSchedule)
|
||||
{
|
||||
if (pSchedule->GetState() != eScheduleState_Pending)
|
||||
{
|
||||
CryFatalError("Only schedules with pending state can be submitted");
|
||||
return;
|
||||
}
|
||||
|
||||
pSchedule->AddRef();
|
||||
m_schedules.push_back(static_cast<CSchedule*>(pSchedule));
|
||||
}
|
||||
}
|
||||
|
||||
const uint32 CScheduleManager::GetNumSchedules() const
|
||||
{
|
||||
return m_schedules.size();
|
||||
}
|
||||
|
||||
IBackgroundSchedule* CScheduleManager::GetSchedule(const uint32 index) const
|
||||
{
|
||||
return m_schedules[index];
|
||||
}
|
||||
|
||||
void CScheduleManager::Update()
|
||||
{
|
||||
while (!m_schedules.empty())
|
||||
{
|
||||
CSchedule* pSchedule = m_schedules[0];
|
||||
|
||||
const EScheduleWorkItemStatus status = pSchedule->Update();
|
||||
if (status == eScheduleWorkItemStatus_NotFinished)
|
||||
{
|
||||
// we need more work next frame
|
||||
break;
|
||||
}
|
||||
|
||||
// schedule has finished, remove current reference
|
||||
m_schedules.erase(m_schedules.begin());
|
||||
SAFE_RELEASE(pSchedule);
|
||||
}
|
||||
}
|
||||
|
||||
void CScheduleManager::OnEditorNotifyEvent(EEditorNotifyEvent ev)
|
||||
{
|
||||
switch (ev)
|
||||
{
|
||||
case eNotify_OnQuit:
|
||||
GetIEditor()->UnregisterNotifyListener(this);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
} // BackgroundScheduleManager
|
||||
@@ -1,117 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_BACKGROUNDSCHEDULEMANAGER_H
|
||||
#define CRYINCLUDE_EDITOR_BACKGROUNDSCHEDULEMANAGER_H
|
||||
#pragma once
|
||||
|
||||
#include "Include/IBackgroundScheduleManager.h"
|
||||
|
||||
namespace BackgroundScheduleManager
|
||||
{
|
||||
class CScheduleItem
|
||||
: public IBackgroundScheduleItem
|
||||
{
|
||||
private:
|
||||
std::string m_name;
|
||||
volatile int m_refCount;
|
||||
|
||||
EScheduleItemState m_state;
|
||||
|
||||
typedef std::vector<IBackgroundScheduleItemWork*> TWorkItems;
|
||||
TWorkItems m_workItems;
|
||||
TWorkItems m_addedWorkItems;
|
||||
TWorkItems m_processedWorkItems;
|
||||
|
||||
public:
|
||||
CScheduleItem(const char* szName);
|
||||
virtual ~CScheduleItem();
|
||||
|
||||
// IBackgroundScheduleItem interface
|
||||
virtual const char* GetDescription() const;
|
||||
virtual EScheduleItemState GetState() const;
|
||||
virtual const float GetProgress() const;
|
||||
virtual const uint32 GetNumWorkItems() const;
|
||||
virtual IBackgroundScheduleItemWork* GetWorkItem(const uint32 index) const;
|
||||
virtual void AddWorkItem(IBackgroundScheduleItemWork* pWork);
|
||||
virtual void AddRef();
|
||||
virtual void Release();
|
||||
|
||||
// Update schedule item
|
||||
EScheduleWorkItemStatus Update();
|
||||
|
||||
// Request to stop work in this item
|
||||
void RequestStop();
|
||||
};
|
||||
|
||||
class CSchedule
|
||||
: public IBackgroundSchedule
|
||||
{
|
||||
private:
|
||||
std::string m_name;
|
||||
volatile int m_refCount;
|
||||
bool m_bCanceled;
|
||||
|
||||
EScheduleState m_state;
|
||||
|
||||
typedef std::vector<CScheduleItem*> TItems;
|
||||
TItems m_items;
|
||||
|
||||
uint32 m_currentItem;
|
||||
|
||||
public:
|
||||
CSchedule(const char* szName);
|
||||
virtual ~CSchedule();
|
||||
|
||||
// IBackgroundSchedule interface
|
||||
virtual const char* GetDescription() const;
|
||||
virtual float GetProgress() const;
|
||||
virtual IBackgroundScheduleItem* GetProcessedItem() const;
|
||||
virtual const uint32 GetNumItems() const;
|
||||
virtual IBackgroundScheduleItem* GetItem(const uint32 index) const;
|
||||
virtual EScheduleState GetState() const;
|
||||
virtual void Cancel();
|
||||
virtual bool IsCanceled() const;
|
||||
virtual void AddItem(IBackgroundScheduleItem* pItem);
|
||||
virtual void AddRef();
|
||||
virtual void Release();
|
||||
|
||||
// Update schedule item
|
||||
EScheduleWorkItemStatus Update();
|
||||
};
|
||||
|
||||
class CScheduleManager
|
||||
: public IBackgroundScheduleManager
|
||||
, public IEditorNotifyListener
|
||||
{
|
||||
private:
|
||||
typedef std::vector<CSchedule*> TSchedules;
|
||||
TSchedules m_schedules;
|
||||
|
||||
public:
|
||||
CScheduleManager();
|
||||
virtual ~CScheduleManager();
|
||||
|
||||
// IBackgroundScheduleManager interface
|
||||
virtual IBackgroundSchedule* CreateSchedule(const char* szName);
|
||||
virtual IBackgroundScheduleItem* CreateScheduleItem(const char* szName);
|
||||
virtual void SubmitSchedule(IBackgroundSchedule* pSchedule);
|
||||
virtual const uint32 GetNumSchedules() const;
|
||||
virtual IBackgroundSchedule* GetSchedule(const uint32 index) const;
|
||||
virtual void Update();
|
||||
|
||||
// IEditorNotifyListener interface implementation
|
||||
virtual void OnEditorNotifyEvent(EEditorNotifyEvent ev) override;
|
||||
};
|
||||
}
|
||||
#endif // CRYINCLUDE_EDITOR_BACKGROUNDSCHEDULEMANAGER_H
|
||||
@@ -1,410 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#include "EditorDefs.h"
|
||||
|
||||
#include "BackgroundTaskManager.h"
|
||||
|
||||
namespace BackgroundTaskManager
|
||||
{
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
CTaskManager::CThread::CThread(class CTaskManager* pManager, CQueue* pQueue)
|
||||
: m_pManager(pManager)
|
||||
, m_pQueue(pQueue)
|
||||
{
|
||||
start();
|
||||
}
|
||||
|
||||
CTaskManager::CThread::~CThread()
|
||||
{
|
||||
}
|
||||
|
||||
void CTaskManager::CThread::WaitForThread()
|
||||
{
|
||||
wait();
|
||||
}
|
||||
|
||||
void CTaskManager::CThread::run()
|
||||
{
|
||||
CryThreadSetName(-1, "BackgroundTaskThread");
|
||||
|
||||
while (!m_pManager->IsStopped())
|
||||
{
|
||||
STaskHandle taskHandle;
|
||||
|
||||
// This blocks on Semaphore waiting for task from queue
|
||||
m_pQueue->PopTask(taskHandle);
|
||||
|
||||
// Should not happen but it's a stupid way to crash :)
|
||||
if (NULL == taskHandle.pTask)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (taskHandle.pTask->IsCanceled())
|
||||
{
|
||||
// Task was canceled before we got here
|
||||
m_pManager->AddCompletedTask(taskHandle, eTaskResult_Canceled);
|
||||
}
|
||||
else
|
||||
{
|
||||
const ETaskResult state = taskHandle.pTask->Work();
|
||||
|
||||
if (state == eTaskResult_Resume)
|
||||
{
|
||||
// Put it back into queue, so more important task can take over.
|
||||
m_pManager->AddTask(taskHandle);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Finish task
|
||||
m_pManager->AddCompletedTask(taskHandle, state);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
CTaskManager::CQueue::CQueue()
|
||||
: m_semaphore(INT_MAX, 0) // no good maximum value, assume worst case
|
||||
{
|
||||
}
|
||||
|
||||
void CTaskManager::CQueue::AddTask(const STaskHandle& taskHandle)
|
||||
{
|
||||
{
|
||||
CryAutoLock<CryMutex> lock(m_lock);
|
||||
|
||||
// TODO: use heap?
|
||||
m_pendingTasks.insert(m_pendingTasks.begin(), taskHandle);
|
||||
std::stable_sort(m_pendingTasks.begin(), m_pendingTasks.end());
|
||||
}
|
||||
|
||||
taskHandle.pTask->SetState(eTaskState_Pending);
|
||||
|
||||
// release internal semaphore so threads can pick up the work
|
||||
m_semaphore.Release();
|
||||
}
|
||||
|
||||
void CTaskManager::CQueue::PopTask(STaskHandle& outTaskHandle)
|
||||
{
|
||||
// wait for job
|
||||
m_semaphore.Acquire();
|
||||
|
||||
{
|
||||
CryAutoLock<CryMutex> lock(m_lock);
|
||||
|
||||
if (m_pendingTasks.empty())
|
||||
{
|
||||
outTaskHandle.pTask = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
outTaskHandle = m_pendingTasks.back();
|
||||
outTaskHandle.pTask->SetState(eTaskState_Working);
|
||||
m_pendingTasks.pop_back();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CTaskManager::CQueue::ReleaseSemaphore()
|
||||
{
|
||||
m_semaphore.Release();
|
||||
}
|
||||
|
||||
void CTaskManager::CQueue::Clear()
|
||||
{
|
||||
CryAutoLock<CryMutex> lock(m_lock);
|
||||
for (uint i = 0; i < m_pendingTasks.size(); ++i)
|
||||
{
|
||||
m_pendingTasks[i].pTask->Release();
|
||||
}
|
||||
|
||||
m_pendingTasks.clear();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
CTaskManager::CTaskManager()
|
||||
: m_bStop(false)
|
||||
, m_nextTaskID(1)
|
||||
, m_listeners(1)
|
||||
{
|
||||
GetIEditor()->RegisterNotifyListener(this);
|
||||
}
|
||||
|
||||
CTaskManager::~CTaskManager()
|
||||
{
|
||||
if (!m_bStop)
|
||||
{
|
||||
Stop();
|
||||
}
|
||||
}
|
||||
|
||||
void CTaskManager::Start(const uint32 threadCount /*=kDefaultThreadCount*/)
|
||||
{
|
||||
m_bStop = false;
|
||||
|
||||
if (m_pThreads.empty())
|
||||
{
|
||||
// Always create one IO thread
|
||||
{
|
||||
CThread* pThread = new CThread(this, &m_pendingTasks[ eTaskThreadMask_IO ]);
|
||||
m_pThreads.push_back(pThread);
|
||||
}
|
||||
|
||||
// We also need at least one generic thread
|
||||
const uint32 numGenericThreads = max<uint32>(threadCount, 1);
|
||||
for (uint32 i = 0; i < numGenericThreads; ++i)
|
||||
{
|
||||
CThread* pThread = new CThread(this, &m_pendingTasks[ eTaskThreadMask_Any ]);
|
||||
m_pThreads.push_back(pThread);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CTaskManager::StartScheduledTasks()
|
||||
{
|
||||
CryAutoLock<CryMutex> lock(m_tasksLock);
|
||||
|
||||
if (!m_scheduledTasks.empty())
|
||||
{
|
||||
const unsigned int time = GetTickCount();
|
||||
while (!m_scheduledTasks.empty())
|
||||
{
|
||||
const int delta = (int)(time - m_scheduledTasks[0].time);
|
||||
if (delta > 0)
|
||||
{
|
||||
// the soonest task on the list is still in the future, no point in looking at the next entries in the list
|
||||
break;
|
||||
}
|
||||
|
||||
// promote the scheduled task to be a full task
|
||||
AddTask(m_scheduledTasks[0].handle);
|
||||
|
||||
// We held a reference to the task on list, release it
|
||||
m_scheduledTasks[0].handle.pTask->Release();
|
||||
|
||||
m_scheduledTasks.erase(m_scheduledTasks.begin());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CTaskManager::Stop()
|
||||
{
|
||||
if (!m_bStop)
|
||||
{
|
||||
m_bStop = true;
|
||||
GetIEditor()->UnregisterNotifyListener(this);
|
||||
|
||||
// clear queues - no new tasks will be processed
|
||||
for (uint32 i = 0; i < eTaskThreadMask_COUNT; ++i)
|
||||
{
|
||||
m_pendingTasks[i].Clear();
|
||||
}
|
||||
|
||||
// kick all the threads to allow them to quit
|
||||
for (uint32 j = 0; j < m_pThreads.size(); ++j)
|
||||
{
|
||||
for (uint32 i = 0; i < eTaskThreadMask_COUNT; ++i)
|
||||
{
|
||||
m_pendingTasks[i].ReleaseSemaphore();
|
||||
}
|
||||
}
|
||||
|
||||
// Stop threads
|
||||
for (TWorkerThreads::iterator it = m_pThreads.begin();
|
||||
it != m_pThreads.end(); ++it)
|
||||
{
|
||||
(*it)->WaitForThread();
|
||||
delete *it;
|
||||
}
|
||||
|
||||
m_pThreads.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void CTaskManager::AddListener(IBackgroundTaskManagerListener* pListener, const char* name)
|
||||
{
|
||||
m_listeners.Add(pListener, name);
|
||||
}
|
||||
|
||||
void CTaskManager::RemoveListener(IBackgroundTaskManagerListener* pListener)
|
||||
{
|
||||
m_listeners.Remove(pListener);
|
||||
}
|
||||
|
||||
void CTaskManager::AddTask(IBackgroundTask* pTask, ETaskPriority priority, ETaskThreadMask threadMask)
|
||||
{
|
||||
MAKE_SURE(pTask != 0, return );
|
||||
|
||||
// keep an extra reference to the task in the manager
|
||||
pTask->AddRef();
|
||||
|
||||
STaskHandle handle;
|
||||
handle.id = CryInterlockedIncrement(&m_nextTaskID);
|
||||
handle.priority = priority;
|
||||
handle.threadMask = threadMask;
|
||||
handle.pTask = pTask;
|
||||
|
||||
AddTask(handle);
|
||||
|
||||
for (TListeners::Notifier notifier(m_listeners); notifier.IsValid(); notifier.Next())
|
||||
{
|
||||
notifier->OnBackgroundTaskAdded(pTask->Description());
|
||||
}
|
||||
}
|
||||
|
||||
void CTaskManager::ScheduleTask(IBackgroundTask* pTask, ETaskPriority priority, int delayMilliseconds, ETaskThreadMask threadMask)
|
||||
{
|
||||
MAKE_SURE(delayMilliseconds >= 0, return );
|
||||
MAKE_SURE(pTask != 0, return );
|
||||
|
||||
// keep an extra reference to the task in the manager
|
||||
pTask->AddRef();
|
||||
|
||||
SScheduledTask task;
|
||||
task.time = GetTickCount() + delayMilliseconds;
|
||||
task.handle.pTask = pTask;
|
||||
task.handle.id = CryInterlockedIncrement(&m_nextTaskID);
|
||||
task.handle.threadMask = threadMask;
|
||||
task.handle.priority = priority;
|
||||
|
||||
{
|
||||
CryAutoLock<CryMutex> lock(m_tasksLock);
|
||||
m_scheduledTasks.push_back(task);
|
||||
}
|
||||
|
||||
for (TListeners::Notifier notifier(m_listeners); notifier.IsValid(); notifier.Next())
|
||||
{
|
||||
notifier->OnBackgroundTaskAdded(pTask->Description());
|
||||
}
|
||||
}
|
||||
|
||||
void CTaskManager::AddTask(const STaskHandle& handle)
|
||||
{
|
||||
MAKE_SURE(handle.pTask != 0, return );
|
||||
MAKE_SURE(handle.id != 0, return );
|
||||
|
||||
// add task to appropriate queue (every thread mask has it's own queue)
|
||||
m_pendingTasks[handle.threadMask].AddTask(handle);
|
||||
}
|
||||
|
||||
void CTaskManager::AddCompletedTask(const STaskHandle& handle, ETaskResult resultState)
|
||||
{
|
||||
CryAutoLock<CryMutex> lock(m_tasksLock);
|
||||
|
||||
CRY_ASSERT(handle.pTask->GetState() == eTaskState_Working);
|
||||
CRY_ASSERT(resultState != eTaskResult_Resume);
|
||||
|
||||
// Update task state
|
||||
switch (resultState)
|
||||
{
|
||||
case eTaskResult_Canceled:
|
||||
{
|
||||
handle.pTask->SetState(eTaskState_Canceled);
|
||||
break;
|
||||
}
|
||||
|
||||
case eTaskResult_Completed:
|
||||
{
|
||||
handle.pTask->SetState(eTaskState_Completed);
|
||||
break;
|
||||
}
|
||||
|
||||
case eTaskResult_Failed:
|
||||
{
|
||||
handle.pTask->SetState(eTaskState_Failed);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// add to the list of completed tasks (for calling the Finalize)
|
||||
// TODO: some of the tasks do not require Finalize() and they could be released here instead of the main thread
|
||||
SCompletedTask info;
|
||||
info.pTask = handle.pTask;
|
||||
info.id = handle.id;
|
||||
info.state = resultState;
|
||||
m_completedTasks.push_back(info);
|
||||
}
|
||||
|
||||
void CTaskManager::Update()
|
||||
{
|
||||
std::vector<SCompletedTask> completedTasks;
|
||||
{
|
||||
CryAutoLock<CryMutex> lock(m_tasksLock);
|
||||
m_completedTasks.swap(completedTasks);
|
||||
}
|
||||
|
||||
// call finalize for the completed tasks
|
||||
for (size_t i = 0; i < completedTasks.size(); ++i)
|
||||
{
|
||||
SCompletedTask& handle = completedTasks[i];
|
||||
|
||||
if (NULL != handle.pTask)
|
||||
{
|
||||
string description = handle.pTask->Description(); // copy string as the description is used after pTask is destroyed
|
||||
|
||||
if (handle.state == eTaskResult_Completed)
|
||||
{
|
||||
if (description && description[0] != '\0')
|
||||
{
|
||||
gEnv->pLog->Log("Task Completed: %s", description.c_str());
|
||||
}
|
||||
}
|
||||
else if (handle.state == eTaskResult_Failed)
|
||||
{
|
||||
if (description && description[0] != '\0' && !handle.pTask->FailReported())
|
||||
{
|
||||
gEnv->pLog->LogError("Task Failed: %s ", description.c_str());
|
||||
|
||||
const char* errorMessage = handle.pTask->ErrorMessage();
|
||||
if (errorMessage && errorMessage[0] != '\0')
|
||||
{
|
||||
gEnv->pLog->LogError("\tReason: [%s]", errorMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
handle.pTask->Finalize();
|
||||
|
||||
// release the internal (task manager) reference.
|
||||
// Tthis is usually the last reference to the task so it gets deleted here.
|
||||
handle.pTask->Release();
|
||||
|
||||
for (TListeners::Notifier notifier(m_listeners); notifier.IsValid(); notifier.Next())
|
||||
{
|
||||
notifier->OnBackgroundTaskCompleted(handle.state, description.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CTaskManager::OnEditorNotifyEvent(EEditorNotifyEvent ev)
|
||||
{
|
||||
switch (ev)
|
||||
{
|
||||
case eNotify_OnInit:
|
||||
Start();
|
||||
break;
|
||||
case eNotify_OnIdleUpdate:
|
||||
Update();
|
||||
break;
|
||||
case eNotify_OnQuit:
|
||||
Stop();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,161 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_BACKGROUNDTASKMANAGER_H
|
||||
#define CRYINCLUDE_EDITOR_BACKGROUNDTASKMANAGER_H
|
||||
#pragma once
|
||||
|
||||
#include "Include/IBackgroundTaskManager.h"
|
||||
#include "CryListenerSet.h"
|
||||
|
||||
#include <QThread>
|
||||
|
||||
namespace BackgroundTaskManager
|
||||
{
|
||||
typedef int TTaskID;
|
||||
|
||||
struct STaskHandle
|
||||
{
|
||||
ETaskPriority priority;
|
||||
ETaskThreadMask threadMask;
|
||||
TTaskID id;
|
||||
IBackgroundTask* pTask;
|
||||
|
||||
bool operator<(const STaskHandle& rhs) const
|
||||
{
|
||||
if (priority < rhs.priority)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (priority > rhs.priority)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return id < rhs.id;
|
||||
}
|
||||
};
|
||||
|
||||
struct SCompletedTask
|
||||
{
|
||||
ETaskResult state;
|
||||
TTaskID id;
|
||||
ETaskThreadMask threadMask;
|
||||
IBackgroundTask* pTask;
|
||||
};
|
||||
|
||||
struct SScheduledTask
|
||||
{
|
||||
unsigned int time;
|
||||
STaskHandle handle;
|
||||
};
|
||||
|
||||
class CTaskManager
|
||||
: public IBackgroundTaskManager
|
||||
, public IEditorNotifyListener
|
||||
{
|
||||
public:
|
||||
CTaskManager();
|
||||
~CTaskManager();
|
||||
|
||||
// IBackgroundTaskManager interface implementation
|
||||
virtual void AddTask(IBackgroundTask* pTask, ETaskPriority priority, ETaskThreadMask threadMask) override;
|
||||
virtual void ScheduleTask(IBackgroundTask* pTask, ETaskPriority priority, int delayMilliseconds, ETaskThreadMask threadMask) override;
|
||||
void AddListener(IBackgroundTaskManagerListener* pListener, const char* name) override;
|
||||
void RemoveListener(IBackgroundTaskManagerListener* pListener) override;
|
||||
|
||||
private:
|
||||
// IEditorNotifyListener interface implementation
|
||||
virtual void OnEditorNotifyEvent(EEditorNotifyEvent ev) override;
|
||||
|
||||
void Start(const uint32 threadCount = kDefaultThreadCount);
|
||||
void Stop();
|
||||
void StartScheduledTasks();
|
||||
void AddTask(const STaskHandle& outTask);
|
||||
void AddCompletedTask(const STaskHandle& outTask, ETaskResult resultState);
|
||||
void Update();
|
||||
|
||||
inline bool IsStopped() const
|
||||
{
|
||||
return m_bStop;
|
||||
}
|
||||
|
||||
private:
|
||||
// Internal queue (per thread mask)
|
||||
class CQueue
|
||||
{
|
||||
public:
|
||||
CQueue();
|
||||
|
||||
// Add task to list
|
||||
void AddTask(const STaskHandle& taskHandle);
|
||||
|
||||
// Pop task from list
|
||||
void PopTask(STaskHandle& outTaskHandle);
|
||||
|
||||
// Release thread semaphore without adding a task
|
||||
void ReleaseSemaphore();
|
||||
|
||||
// Remove all pending tasks
|
||||
void Clear();
|
||||
|
||||
private:
|
||||
CrySemaphore m_semaphore;
|
||||
std::vector<STaskHandle> m_pendingTasks;
|
||||
CryMutex m_lock;
|
||||
};
|
||||
|
||||
// Worker thread class implementation
|
||||
class CThread : public QThread
|
||||
{
|
||||
public:
|
||||
CThread(CTaskManager* pManager, CQueue* pQueue);
|
||||
~CThread();
|
||||
|
||||
void WaitForThread();
|
||||
|
||||
private:
|
||||
void run() override;
|
||||
|
||||
private:
|
||||
CTaskManager* m_pManager;
|
||||
CQueue* m_pQueue;
|
||||
};
|
||||
|
||||
private:
|
||||
static const uint32 kMaxThreadCloseWaitTime = 10000; // ms
|
||||
static const uint32 kDefaultThreadCount = 4; // good enough for LiveCreate (main user right now), do not set to less than 2
|
||||
|
||||
CQueue m_pendingTasks[ eTaskThreadMask_COUNT ];
|
||||
|
||||
// Task scheduled for execution in the future
|
||||
std::vector<SScheduledTask> m_scheduledTasks;
|
||||
|
||||
// Completed tasks (waiting for the "finalize" call)
|
||||
std::vector<SCompletedTask> m_completedTasks;
|
||||
|
||||
volatile TTaskID m_nextTaskID;
|
||||
|
||||
typedef std::vector<CThread*> TWorkerThreads;
|
||||
TWorkerThreads m_pThreads;
|
||||
|
||||
CryMutex m_tasksLock;
|
||||
bool m_bStop;
|
||||
|
||||
typedef CListenerSet<IBackgroundTaskManagerListener*> TListeners;
|
||||
TListeners m_listeners;
|
||||
};
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_BACKGROUNDTASKMANAGER_H
|
||||
@@ -826,9 +826,6 @@ void CBaseLibraryManager::OnEditorNotifyEvent(EEditorNotifyEvent event)
|
||||
SetSelectedItem(0);
|
||||
ClearAll();
|
||||
break;
|
||||
case eNotify_OnMissionChange:
|
||||
SetSelectedItem(0);
|
||||
break;
|
||||
case eNotify_OnCloseScene:
|
||||
SetSelectedItem(0);
|
||||
ClearAll();
|
||||
|
||||
@@ -112,19 +112,18 @@ ly_add_target(
|
||||
3rdParty::zlib
|
||||
3rdParty::AWSNativeSDK::STS
|
||||
Legacy::CryCommon
|
||||
Legacy::CryCommon.EngineSettings.Static
|
||||
Legacy::EditorCommon
|
||||
AZ::AzCore
|
||||
AZ::AzToolsFramework
|
||||
Gem::LmbrCentral.Static
|
||||
Legacy::NewsShared
|
||||
AZ::AWSNativeSDKInit
|
||||
Legacy::CryCommonTools
|
||||
AZ::AtomCore
|
||||
Gem::Atom_RPI.Edit
|
||||
Gem::Atom_RPI.Public
|
||||
Gem::Atom_Feature_Common.Static
|
||||
Gem::AtomToolsFramework.Static
|
||||
Gem::AtomViewportDisplayInfo
|
||||
${additional_dependencies}
|
||||
PUBLIC
|
||||
3rdParty::AWSNativeSDK::Core
|
||||
@@ -245,7 +244,6 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
|
||||
AZ::AzToolsFramework
|
||||
Legacy::EditorLib
|
||||
Gem::LmbrCentral
|
||||
Legacy::CryCommonTools
|
||||
)
|
||||
ly_add_googletest(
|
||||
NAME Legacy::EditorLib.Tests
|
||||
|
||||
@@ -31,4 +31,4 @@ public:
|
||||
|
||||
};
|
||||
|
||||
using CommandManagerRequestBus = AZ::EBus<CommandManagerRequests>;
|
||||
using CommandManagerRequestBus = AZ::EBus<CommandManagerRequests>;
|
||||
|
||||
@@ -136,4 +136,4 @@ void CControlMRU::OnCalcDynamicSize(DWORD dwMode)
|
||||
m_dwHideFlags = 0;
|
||||
SetEnabled(FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
// AzQtComponents
|
||||
#include <AzQtComponents/Components/StyledLineEdit.h>
|
||||
#include <AzQtComponents/Components/StyleManager.h>
|
||||
#include <AzQtComponents/Components/Widgets/LineEdit.h>
|
||||
#include <AzQtComponents/Components/Widgets/ScrollBar.h>
|
||||
#include <AzQtComponents/Components/Widgets/SliderCombo.h>
|
||||
|
||||
@@ -314,7 +315,10 @@ CConsoleSCB::CConsoleSCB(QWidget* parent)
|
||||
setMinimumHeight(120);
|
||||
|
||||
ui->findBar->setVisible(false);
|
||||
|
||||
ui->lineEditFind->setPlaceholderText(QObject::tr("Search..."));
|
||||
ui->lineEditFind->setClearButtonEnabled(true);
|
||||
AzQtComponents::LineEdit::applySearchStyle(ui->lineEditFind);
|
||||
|
||||
// Setup the color table for the default (light) theme
|
||||
m_colorTable << QColor(0, 0, 0)
|
||||
<< QColor(0, 0, 0)
|
||||
|
||||
@@ -1,821 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#include "EditorDefs.h"
|
||||
|
||||
#include "CurveEditorCtrl.h"
|
||||
|
||||
// Qt
|
||||
#include <QPainter>
|
||||
#include <QPainterPath>
|
||||
|
||||
namespace CurveEditor
|
||||
{
|
||||
const int kHandleSize = 6;
|
||||
const int kHandleSizeHalf = kHandleSize / 2;
|
||||
const int kDefaultPadding = 10;
|
||||
const int kInfoFontSize = 7;
|
||||
const int kGrid = 4;
|
||||
const QColor kColor_SelectCross(132, 132, 132);
|
||||
const QColor kColor_DisabledCross(90, 90, 90);
|
||||
const QColor kColor_MiddleLines(80, 80, 80);
|
||||
const QColor kColor_Background(41, 41, 41);
|
||||
const QColor kColor_Disabled(60, 60, 60);
|
||||
const QColor kColor_PaddingBorder(128, 128, 128);
|
||||
const QColor kColor_Text(128, 128, 128);
|
||||
const QColor kColor_TextCrtPos(187, 187, 187);
|
||||
const QColor kColor_Curve(255, 0, 0);
|
||||
const QColor kColor_SelHandle(200, 200, 200);
|
||||
const QColor kColor_NormalHandle(30, 30, 30);
|
||||
const QColor kColor_HandleLight(60, 60, 60);
|
||||
const QColor kColor_HandleShadow(0, 0, 0);
|
||||
const QColor kColor_MarkLines(0, 255, 0);
|
||||
}
|
||||
|
||||
|
||||
CCurveEditorCtrl::CCurveEditorCtrl(QWidget* parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
m_domainMinX = 0.0f;
|
||||
m_domainMinY = 0.0f;
|
||||
m_domainMaxX = 1.0f;
|
||||
m_domainMaxY = 1.0f;
|
||||
m_bMouseDown = m_bDragging = false;
|
||||
m_bAllowMouse = true;
|
||||
m_padding = CurveEditor::kDefaultPadding;
|
||||
m_flags = eFlag_ShowVerticalRuler
|
||||
| eFlag_ShowHorizontalRuler
|
||||
| eFlag_ShowVerticalRulerText
|
||||
| eFlag_ShowHorizontalRulerText
|
||||
| eFlag_ShowPaddingBorder
|
||||
| eFlag_ShowMovingPointAxis
|
||||
| eFlag_ShowPointHandles;
|
||||
m_gridSplits.set(CurveEditor::kGrid, CurveEditor::kGrid);
|
||||
m_fntInfo.setFamily("Arial");
|
||||
m_fntInfo.setPointSize(CurveEditor::kInfoFontSize);
|
||||
m_bHovered = false;
|
||||
m_selCrossPen = QPen(CurveEditor::kColor_SelectCross);
|
||||
|
||||
GenerateDefaultCurve();
|
||||
}
|
||||
|
||||
CCurveEditorCtrl::~CCurveEditorCtrl()
|
||||
{
|
||||
}
|
||||
|
||||
void CCurveEditorCtrl::SetFlags(UINT aFlags)
|
||||
{
|
||||
m_flags = aFlags;
|
||||
}
|
||||
|
||||
UINT CCurveEditorCtrl::GetFlags() const
|
||||
{
|
||||
return m_flags;
|
||||
}
|
||||
|
||||
bool CCurveEditorCtrl::SetDomainBounds(float aMinX, float aMinY, float aMaxX, float aMaxY)
|
||||
{
|
||||
assert(aMinX < aMaxX);
|
||||
assert(aMinY < aMaxY);
|
||||
|
||||
if (aMinX >= aMaxX)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (aMinY >= aMaxY)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
m_domainMinX = aMinX;
|
||||
m_domainMinY = aMinY;
|
||||
m_domainMaxX = aMaxX;
|
||||
m_domainMaxY = aMaxY;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CCurveEditorCtrl::GetDomainBounds(float& rMinX, float& rMinY, float& rMaxX, float& rMaxY) const
|
||||
{
|
||||
rMinX = m_domainMinX;
|
||||
rMinY = m_domainMinY;
|
||||
rMaxX = m_domainMaxX;
|
||||
rMaxY = m_domainMaxY;
|
||||
}
|
||||
|
||||
void CCurveEditorCtrl::SetGrid(UINT aHorizontalSplits, UINT aVerticalSplits, const QStringList& labelsX, const QStringList& labelsY)
|
||||
{
|
||||
assert(aHorizontalSplits);
|
||||
assert(aVerticalSplits);
|
||||
|
||||
if (!aHorizontalSplits)
|
||||
{
|
||||
// defaults
|
||||
aHorizontalSplits = 2;
|
||||
}
|
||||
|
||||
if (!aVerticalSplits)
|
||||
{
|
||||
// defaults
|
||||
aVerticalSplits = 2;
|
||||
}
|
||||
|
||||
m_gridSplits.x = aHorizontalSplits;
|
||||
m_gridSplits.y = aVerticalSplits;
|
||||
|
||||
if (!labelsX.isEmpty())
|
||||
{
|
||||
m_labelsX = labelsX;
|
||||
}
|
||||
|
||||
if (!labelsY.isEmpty())
|
||||
{
|
||||
m_labelsY = labelsY;
|
||||
}
|
||||
}
|
||||
|
||||
QPoint CCurveEditorCtrl::ProjectPoint(float x, float y)
|
||||
{
|
||||
QPoint pt;
|
||||
|
||||
pt.setX(m_padding + (width() - m_padding * 2) * (x - m_domainMinX) / (m_domainMaxX - m_domainMinX));
|
||||
pt.setY(m_padding + (height() - m_padding * 2) * (1.0f - (y - m_domainMinY) / (m_domainMaxY - m_domainMinY)));
|
||||
|
||||
return pt;
|
||||
}
|
||||
|
||||
Vec2 CCurveEditorCtrl::UnprojectPoint(const QPoint& pt)
|
||||
{
|
||||
Vec2 vec;
|
||||
int y = height() - pt.y();
|
||||
float dx = (width() - m_padding * 2);
|
||||
float dy = (height() - m_padding * 2);
|
||||
const float kEpsilon = 0.00000001f;
|
||||
|
||||
if (fabs(dx) <= kEpsilon)
|
||||
{
|
||||
dx = 1.0f;
|
||||
}
|
||||
|
||||
if (fabs(dy) <= kEpsilon)
|
||||
{
|
||||
dy = 1.0f;
|
||||
}
|
||||
|
||||
vec.x = m_domainMinX + (float)(pt.x() - m_padding) / dx * (m_domainMaxX - m_domainMinX);
|
||||
vec.y = m_domainMinY + (float)(y - m_padding) / dy * (m_domainMaxY - m_domainMinY);
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
void CCurveEditorCtrl::SetControlPointCount(UINT aCount)
|
||||
{
|
||||
m_points.resize(aCount);
|
||||
m_projectedPoints.clear();
|
||||
}
|
||||
|
||||
UINT CCurveEditorCtrl::GetControlPointCount() const
|
||||
{
|
||||
return m_points.size();
|
||||
}
|
||||
|
||||
void CCurveEditorCtrl::AddControlPoint(const Vec2& rPosition)
|
||||
{
|
||||
m_points.push_back(CurvePoint(rPosition.x, rPosition.y));
|
||||
}
|
||||
|
||||
void CCurveEditorCtrl::ClearControlPoints()
|
||||
{
|
||||
m_points.clear();
|
||||
}
|
||||
|
||||
void CCurveEditorCtrl::SetControlPoint(UINT aIndex, const Vec2& rPosition)
|
||||
{
|
||||
assert(aIndex < m_points.size());
|
||||
|
||||
if (aIndex >= m_points.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_points[aIndex].pos = rPosition;
|
||||
}
|
||||
|
||||
void CCurveEditorCtrl::SetControlPointTangents(UINT aIndex, const Vec2& rLeft, const Vec2& rRight)
|
||||
{
|
||||
assert(aIndex < m_points.size());
|
||||
|
||||
if (aIndex >= m_points.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_points[aIndex].tanA = rLeft;
|
||||
m_points[aIndex].tanB = rRight;
|
||||
}
|
||||
|
||||
void CCurveEditorCtrl::GetControlPoint(UINT aIndex, Vec2& rOutPosition) const
|
||||
{
|
||||
assert(aIndex < m_points.size());
|
||||
|
||||
if (aIndex >= m_points.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
rOutPosition = m_points[aIndex].pos;
|
||||
}
|
||||
|
||||
void CCurveEditorCtrl::GetControlPointTangents(UINT aIndex, Vec2& rOutLeft, Vec2& rOutRight) const
|
||||
{
|
||||
assert(aIndex < m_points.size());
|
||||
|
||||
if (aIndex >= m_points.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
rOutLeft = m_points[aIndex].tanA;
|
||||
rOutRight = m_points[aIndex].tanB;
|
||||
}
|
||||
|
||||
void CCurveEditorCtrl::paintEvent(QPaintEvent* event)
|
||||
{
|
||||
QWidget::paintEvent(event);
|
||||
|
||||
QPainter dc(this);
|
||||
|
||||
QRect rc = geometry();
|
||||
QString str;
|
||||
QRect textSize;
|
||||
|
||||
dc.setFont(m_fntInfo);
|
||||
QFontMetrics fntMetrics(m_fntInfo);
|
||||
|
||||
if (m_flags & eFlag_Disabled)
|
||||
{
|
||||
// If disabled, just draw a blank square.
|
||||
dc.fillRect(rc, CurveEditor::kColor_Disabled);
|
||||
|
||||
dc.setPen(CurveEditor::kColor_DisabledCross);
|
||||
dc.drawLine(0, 0, rc.width(), rc.height());
|
||||
|
||||
dc.drawLine(rc.width(), 0, 0, rc.height());
|
||||
return;
|
||||
}
|
||||
|
||||
dc.fillRect(rc, CurveEditor::kColor_Background);
|
||||
|
||||
dc.setPen(CurveEditor::kColor_MiddleLines);
|
||||
|
||||
if (m_flags & eFlag_ShowVerticalRuler)
|
||||
{
|
||||
float y = m_domainMinY;
|
||||
float grid = (m_domainMaxY - m_domainMinY) / m_gridSplits.y;
|
||||
QPoint p;
|
||||
|
||||
for (int i = 0; i <= m_gridSplits.y; ++i)
|
||||
{
|
||||
p = ProjectPoint(0, y);
|
||||
dc.drawLine(m_padding, p.y(), rc.width() - m_padding, p.y());
|
||||
|
||||
if (m_flags & eFlag_ShowVerticalRulerText)
|
||||
{
|
||||
if (m_labelsY.empty())
|
||||
{
|
||||
str.asprintf("%0.2f", y);
|
||||
}
|
||||
else
|
||||
{
|
||||
str = m_labelsY[i];
|
||||
}
|
||||
textSize = fntMetrics.tightBoundingRect(str);
|
||||
dc.drawText(2, p.y(), str);
|
||||
}
|
||||
|
||||
y += grid;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_flags & eFlag_ShowHorizontalRuler)
|
||||
{
|
||||
float x = m_domainMinX;
|
||||
float grid = (m_domainMaxX - m_domainMinX) / m_gridSplits.x;
|
||||
QPoint p;
|
||||
|
||||
for (int i = 0; i <= m_gridSplits.x; ++i)
|
||||
{
|
||||
p = ProjectPoint(x, 0);
|
||||
dc.drawLine(p.x(), m_padding, p.x(), rc.height() - m_padding);
|
||||
|
||||
if (m_flags & eFlag_ShowHorizontalRulerText)
|
||||
{
|
||||
if (m_labelsX.empty())
|
||||
{
|
||||
str.asprintf("%0.2f", x);
|
||||
}
|
||||
else
|
||||
{
|
||||
str = m_labelsX[i];
|
||||
}
|
||||
textSize = fntMetrics.tightBoundingRect(str);
|
||||
|
||||
p.setX(p.x() + 2);
|
||||
|
||||
if (p.x() + textSize.width() > width())
|
||||
{
|
||||
p.setX(width() - textSize.width());
|
||||
}
|
||||
|
||||
dc.drawText(p.x(), height() - m_padding + textSize.height() + 2, str);
|
||||
}
|
||||
|
||||
x += grid;
|
||||
}
|
||||
}
|
||||
|
||||
dc.setPen(CurveEditor::kColor_MarkLines);
|
||||
|
||||
if (m_flags & eFlag_ShowVerticalRuler)
|
||||
{
|
||||
QPoint p;
|
||||
for (size_t i = 0; i < m_marksY.size(); ++i)
|
||||
{
|
||||
float v = m_marksY[i];
|
||||
if (v < m_domainMinY || v > m_domainMaxY)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
p = ProjectPoint(0, v);
|
||||
dc.drawLine(m_padding, p.y(), width() - m_padding, p.y());
|
||||
}
|
||||
}
|
||||
|
||||
if (m_flags & eFlag_ShowHorizontalRuler)
|
||||
{
|
||||
QPoint p;
|
||||
for (size_t i = 0; i < m_marksX.size(); ++i)
|
||||
{
|
||||
float v = m_marksX[i];
|
||||
if (v < m_domainMinX || v > m_domainMaxX)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
p = ProjectPoint(v, 0);
|
||||
dc.drawLine(p.x(), m_padding, p.x(), height() - m_padding);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_flags & eFlag_ShowPaddingBorder)
|
||||
{
|
||||
dc.setPen(CurveEditor::kColor_PaddingBorder);
|
||||
dc.drawRect(m_padding, m_padding, width() - m_padding * 2, height() - m_padding * 2);
|
||||
}
|
||||
|
||||
if (m_bDragging
|
||||
&& !m_selectedIndices.empty()
|
||||
&& (m_flags & eFlag_ShowMovingPointAxis))
|
||||
{
|
||||
const Vec2& crtPos = m_points[m_selectedIndices[0]].pos;
|
||||
|
||||
dc.setBrush(CurveEditor::kColor_TextCrtPos);
|
||||
str.asprintf("(%0.2f,%0.2f)", crtPos.x, crtPos.y);
|
||||
textSize = fntMetrics.tightBoundingRect(str);
|
||||
const int kOffsetFromPointer = 5;
|
||||
QPoint txtPos(m_lastMousePoint.x() + kOffsetFromPointer, m_lastMousePoint.y() + kOffsetFromPointer);
|
||||
|
||||
if (txtPos.x() + textSize.width() > width())
|
||||
{
|
||||
txtPos.setX(width() - textSize.width());
|
||||
}
|
||||
|
||||
if (txtPos.y() + textSize.height() > height())
|
||||
{
|
||||
txtPos.setY(height() - textSize.height());
|
||||
}
|
||||
|
||||
dc.drawText(txtPos, str);
|
||||
}
|
||||
|
||||
ComputeTangents();
|
||||
UpdateProjectedPoints();
|
||||
|
||||
// for curve debug, tangents poly, don't delete
|
||||
// dc.setPen(Qt::black);
|
||||
// dc.drawPolyline(m_projectedPoints.data(), m_projectedPoints.size());
|
||||
|
||||
dc.setPen(CurveEditor::kColor_Curve);
|
||||
|
||||
// curve
|
||||
QPainterPath bezierPath;
|
||||
bezierPath.moveTo(m_projectedPoints[0]);
|
||||
for (int i = 1; i < m_projectedPoints.size(); i += 3)
|
||||
{
|
||||
bezierPath.cubicTo(m_projectedPoints[i], m_projectedPoints[i + 1], m_projectedPoints[i + 2]);
|
||||
}
|
||||
dc.drawPath(bezierPath);
|
||||
|
||||
// curve control point handles
|
||||
if (m_flags & eFlag_ShowPointHandles)
|
||||
{
|
||||
for (size_t i = 0; i < m_points.size(); ++i)
|
||||
{
|
||||
QPoint ptProj = ProjectPoint(m_points[i].pos.x, m_points[i].pos.y);
|
||||
QRect rcHandle(0, 0, CurveEditor::kHandleSize, CurveEditor::kHandleSize);
|
||||
rcHandle.moveCenter(ptProj);
|
||||
|
||||
std::vector<int>::iterator iter =
|
||||
std::find(m_selectedIndices.begin(), m_selectedIndices.end(), i);
|
||||
|
||||
bool bSelected = (iter != m_selectedIndices.end());
|
||||
|
||||
if (bSelected && m_bDragging)
|
||||
{
|
||||
dc.setPen(m_selCrossPen);
|
||||
dc.drawLine(0, ptProj.y(), width(), ptProj.y());
|
||||
dc.drawLine(ptProj.x(), 0, ptProj.x(), height());
|
||||
}
|
||||
|
||||
dc.fillRect(rcHandle, bSelected
|
||||
? CurveEditor::kColor_SelHandle
|
||||
: CurveEditor::kColor_NormalHandle);
|
||||
|
||||
dc.setPen(CurveEditor::kColor_HandleLight);
|
||||
dc.drawLine(ptProj.x() - CurveEditor::kHandleSizeHalf, ptProj.y() - CurveEditor::kHandleSizeHalf,
|
||||
ptProj.x() - CurveEditor::kHandleSizeHalf, ptProj.y() + CurveEditor::kHandleSizeHalf);
|
||||
dc.drawLine(ptProj.x() - CurveEditor::kHandleSizeHalf, ptProj.y() + CurveEditor::kHandleSizeHalf,
|
||||
ptProj.x() + CurveEditor::kHandleSizeHalf, ptProj.y() + CurveEditor::kHandleSizeHalf);
|
||||
dc.setPen(CurveEditor::kColor_HandleShadow);
|
||||
dc.drawLine(ptProj.x() + CurveEditor::kHandleSizeHalf, ptProj.y() + CurveEditor::kHandleSizeHalf,
|
||||
ptProj.x() + CurveEditor::kHandleSizeHalf, ptProj.y() - CurveEditor::kHandleSizeHalf);
|
||||
dc.drawLine(ptProj.x() + CurveEditor::kHandleSizeHalf, ptProj.y() - CurveEditor::kHandleSizeHalf,
|
||||
ptProj.x() - CurveEditor::kHandleSizeHalf, ptProj.y() - CurveEditor::kHandleSizeHalf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CCurveEditorCtrl::ComputeTangents()
|
||||
{
|
||||
for (size_t i = 0; i < m_points.size(); ++i)
|
||||
{
|
||||
m_points[i].tanA = m_points[i].pos;
|
||||
m_points[i].tanB = m_points[i].pos;
|
||||
}
|
||||
|
||||
int maxIndex = m_points.size() - 1;
|
||||
|
||||
for (size_t i = 0; i < m_points.size(); ++i)
|
||||
{
|
||||
if (i > maxIndex)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
Vec2& p2 = m_points[i].pos;
|
||||
Vec2& back = m_points[i].tanA;
|
||||
Vec2& forw = m_points[i].tanB;
|
||||
const float kEpsilon = 0.000001f;
|
||||
|
||||
// first point
|
||||
if (i == 0)
|
||||
{
|
||||
back = p2;
|
||||
|
||||
if (maxIndex == 1)
|
||||
{
|
||||
Vec2& p3 = m_points[i + 1].pos;
|
||||
forw = p2 + (p3 - p2) / 3.0f;
|
||||
}
|
||||
else if (maxIndex > 0)
|
||||
{
|
||||
Vec2& p3 = m_points[i + 1].pos;
|
||||
Vec2& pb3 = m_points[i + 1].tanA;
|
||||
|
||||
float lenOsn = (pb3 - p2).GetLength();
|
||||
float lenb = (p3 - p2).GetLength();
|
||||
|
||||
if (lenOsn > kEpsilon && lenb > kEpsilon)
|
||||
{
|
||||
forw = p2 + (pb3 - p2) / (lenOsn / lenb * 3.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
forw = p2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (i == maxIndex)
|
||||
{
|
||||
forw = p2;
|
||||
|
||||
if (i > 0)
|
||||
{
|
||||
Vec2& p1 = m_points[i - 1].pos;
|
||||
Vec2& pf1 = m_points[i - 1].tanB;
|
||||
|
||||
float lenOsn = (pf1 - p2).GetLength();
|
||||
float lenf = (p1 - p2).GetLength();
|
||||
|
||||
if (lenOsn > kEpsilon && lenf > kEpsilon)
|
||||
{
|
||||
back = p2 + (pf1 - p2) / (lenOsn / lenf * 3.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
back = p2;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (i >= 1 && i <= maxIndex - 1)
|
||||
{
|
||||
Vec2& p1 = m_points[i - 1].pos;
|
||||
Vec2& p3 = m_points[i + 1].pos;
|
||||
|
||||
float lenOsn = (p3 - p1).GetLength();
|
||||
float lenb = (p1 - p2).GetLength();
|
||||
float lenf = (p3 - p2).GetLength();
|
||||
|
||||
if (lenOsn > kEpsilon
|
||||
&& lenf > kEpsilon
|
||||
&& lenb > kEpsilon)
|
||||
{
|
||||
back = p2 + (p1 - p3) * (lenb / lenOsn / 3.0f);
|
||||
forw = p2 + (p3 - p1) * (lenf / lenOsn / 3.0f);
|
||||
}
|
||||
}
|
||||
|
||||
ClampToDomain(back);
|
||||
ClampToDomain(forw);
|
||||
}
|
||||
|
||||
// fix tangents in relation of one to another
|
||||
for (size_t i = 0; i < m_points.size(); ++i)
|
||||
{
|
||||
Vec2& p = m_points[i].pos;
|
||||
Vec2& tanA = m_points[i].tanA;
|
||||
Vec2& tanB = m_points[i].tanB;
|
||||
|
||||
if (i < m_points.size() - 1)
|
||||
{
|
||||
if (tanB.x > m_points[i + 1].tanA.x)
|
||||
{
|
||||
tanB.x = (m_points[i + 1].pos.x + p.x) * 0.5f;
|
||||
}
|
||||
}
|
||||
if (i > 0)
|
||||
{
|
||||
if (tanA.x < m_points[i - 1].tanB.x)
|
||||
{
|
||||
tanA.x = (m_points[i - 1].pos.x + p.x) * 0.5f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CCurveEditorCtrl::UpdateProjectedPoints()
|
||||
{
|
||||
m_projectedPoints.resize(m_points.size() * 3 - 2);
|
||||
|
||||
int numPts = 0;
|
||||
|
||||
for (size_t i = 0; i < m_points.size(); ++i)
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
m_projectedPoints[numPts++] = ProjectPoint(m_points[i].pos.x, m_points[i].pos.y);
|
||||
m_projectedPoints[numPts++] = ProjectPoint(m_points[i].tanB.x, m_points[i].tanB.y);
|
||||
}
|
||||
else if (i == m_points.size() - 1)
|
||||
{
|
||||
m_projectedPoints[numPts++] = ProjectPoint(m_points[i].tanA.x, m_points[i].tanA.y);
|
||||
m_projectedPoints[numPts++] = ProjectPoint(m_points[i].pos.x, m_points[i].pos.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_projectedPoints[numPts++] = ProjectPoint(m_points[i].tanA.x, m_points[i].tanA.y);
|
||||
m_projectedPoints[numPts++] = ProjectPoint(m_points[i].pos.x, m_points[i].pos.y);
|
||||
m_projectedPoints[numPts++] = ProjectPoint(m_points[i].tanB.x, m_points[i].tanB.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CCurveEditorCtrl::ClampToDomain(Vec2& rVec)
|
||||
{
|
||||
if (rVec.x < m_domainMinX)
|
||||
{
|
||||
rVec.x = m_domainMinX;
|
||||
}
|
||||
else if (rVec.x > m_domainMaxX)
|
||||
{
|
||||
rVec.x = m_domainMaxX;
|
||||
}
|
||||
|
||||
if (rVec.y < m_domainMinY)
|
||||
{
|
||||
rVec.y = m_domainMinY;
|
||||
}
|
||||
else if (rVec.y > m_domainMaxY)
|
||||
{
|
||||
rVec.y = m_domainMaxY;
|
||||
}
|
||||
}
|
||||
|
||||
void CCurveEditorCtrl::GenerateDefaultCurve()
|
||||
{
|
||||
m_points.clear();
|
||||
m_domainMinX = 0.0f;
|
||||
m_domainMinY = 0.0f;
|
||||
m_domainMaxX = 1.0f;
|
||||
m_domainMaxY = 1.0f;
|
||||
m_points.push_back(CurvePoint(0.00f, 0.00f));
|
||||
m_points.push_back(CurvePoint(0.25f, 0.25f));
|
||||
m_points.push_back(CurvePoint(0.50f, 0.50f));
|
||||
m_points.push_back(CurvePoint(0.75f, 0.75f));
|
||||
m_points.push_back(CurvePoint(1.00f, 1.00f));
|
||||
}
|
||||
|
||||
void CCurveEditorCtrl::mousePressEvent(QMouseEvent* event)
|
||||
{
|
||||
QWidget::mousePressEvent(event);
|
||||
if (event->button() != Qt::LeftButton)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const QPoint point = event->pos();
|
||||
if (m_bAllowMouse)
|
||||
{
|
||||
bool bSimpleSelect = !(event->modifiers() & Qt::ShiftModifier) && !(event->modifiers() & Qt::ControlModifier);
|
||||
|
||||
if (bSimpleSelect)
|
||||
{
|
||||
m_selectedIndices.clear();
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < m_points.size(); ++i)
|
||||
{
|
||||
QPoint ptProj = ProjectPoint(m_points[i].pos.x, m_points[i].pos.y);
|
||||
|
||||
QRect rcHandle(0, 0, CurveEditor::kHandleSize, CurveEditor::kHandleSize);
|
||||
rcHandle.moveCenter(ptProj);
|
||||
|
||||
if (rcHandle.contains(point))
|
||||
{
|
||||
if (bSimpleSelect)
|
||||
{
|
||||
m_selectedIndices.push_back(i);
|
||||
break;
|
||||
}
|
||||
|
||||
if (event->modifiers() & Qt::ShiftModifier)
|
||||
{
|
||||
m_selectedIndices.push_back(i);
|
||||
}
|
||||
else if (event->modifiers() & Qt::ControlModifier)
|
||||
{
|
||||
std::vector<int>::iterator iter =
|
||||
std::find(m_selectedIndices.begin(), m_selectedIndices.end(), i);
|
||||
|
||||
if (iter == m_selectedIndices.end())
|
||||
{
|
||||
m_selectedIndices.push_back(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_selectedIndices.erase(iter);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_bMouseDown = true;
|
||||
m_lastMousePoint = point;
|
||||
}
|
||||
|
||||
grabMouse();
|
||||
update();
|
||||
}
|
||||
|
||||
void CCurveEditorCtrl::mouseReleaseEvent(QMouseEvent* event)
|
||||
{
|
||||
QWidget::mouseReleaseEvent(event);
|
||||
if (event->button() != Qt::LeftButton)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_bMouseDown = false;
|
||||
m_bDragging = false;
|
||||
m_selectedIndices.clear();
|
||||
|
||||
releaseMouse();
|
||||
update();
|
||||
}
|
||||
|
||||
void CCurveEditorCtrl::mouseMoveEvent(QMouseEvent* event)
|
||||
{
|
||||
if (m_bMouseDown && !m_bDragging)
|
||||
{
|
||||
m_bDragging = true;
|
||||
}
|
||||
|
||||
m_bHovered = true;
|
||||
if (m_flags & eFlag_ShowCursorAlways)
|
||||
{
|
||||
m_bHovered = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_bHovered = false;
|
||||
|
||||
for (size_t i = 0; i < m_points.size(); ++i)
|
||||
{
|
||||
QPoint ptProj = ProjectPoint(m_points[i].pos.x, m_points[i].pos.y);
|
||||
QRect rcHandle(0, 0, CurveEditor::kHandleSize, CurveEditor::kHandleSize);
|
||||
rcHandle.moveCenter(ptProj);
|
||||
|
||||
if (rcHandle.contains(event->pos()))
|
||||
{
|
||||
m_bHovered = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (m_bDragging)
|
||||
{
|
||||
Vec2 v1 = UnprojectPoint(m_lastMousePoint);
|
||||
Vec2 v2 = UnprojectPoint(event->pos());
|
||||
Vec2 v = v1 - v2;
|
||||
|
||||
for (size_t i = 0; i < m_selectedIndices.size(); ++i)
|
||||
{
|
||||
int index = m_selectedIndices[i];
|
||||
CurvePoint& cpt = m_points[index];
|
||||
|
||||
// do not move first and last points on X
|
||||
if (index > 0 && index < m_points.size() - 1)
|
||||
{
|
||||
cpt.pos.x -= v.x;
|
||||
}
|
||||
|
||||
cpt.pos.y -= v.y;
|
||||
|
||||
// lets check if the point is overlapping its neighbours
|
||||
if (index > 0 && (index - 1) > 0)
|
||||
{
|
||||
if (cpt.pos.x < m_points[index - 1].pos.x)
|
||||
{
|
||||
CurvePoint p = m_points[index];
|
||||
|
||||
// swap!
|
||||
m_points[index] = m_points[index - 1];
|
||||
m_points[index - 1] = p;
|
||||
m_selectedIndices[i] = index - 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (index < m_points.size() - 1 && (index + 1) < m_points.size() - 1)
|
||||
{
|
||||
if (cpt.pos.x > m_points[index + 1].pos.x)
|
||||
{
|
||||
CurvePoint p = m_points[index];
|
||||
|
||||
// swap!
|
||||
m_points[index] = m_points[index + 1];
|
||||
m_points[index + 1] = p;
|
||||
m_selectedIndices[i] = index + 1;
|
||||
}
|
||||
}
|
||||
|
||||
ClampToDomain(cpt.pos);
|
||||
}
|
||||
|
||||
update();
|
||||
m_lastMousePoint = event->pos();
|
||||
}
|
||||
|
||||
QWidget::mouseMoveEvent(event);
|
||||
}
|
||||
|
||||
void CCurveEditorCtrl::MarkX(float value)
|
||||
{
|
||||
m_marksX.push_back(value);
|
||||
}
|
||||
|
||||
void CCurveEditorCtrl::MarkY(float value)
|
||||
{
|
||||
m_marksY.push_back(value);
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_CONTROLS_CURVEEDITORCTRL_H
|
||||
#define CRYINCLUDE_EDITOR_CONTROLS_CURVEEDITORCTRL_H
|
||||
#pragma once
|
||||
#include "Util/GdiUtil.h"
|
||||
#include <QWidget>
|
||||
#include <QPen>
|
||||
|
||||
|
||||
class CCurveEditorCtrl
|
||||
: public QWidget
|
||||
{
|
||||
public:
|
||||
enum EFlags
|
||||
{
|
||||
eFlag_ShowVerticalRuler = (1 << 0),
|
||||
eFlag_ShowHorizontalRuler = (1 << 1),
|
||||
eFlag_ShowVerticalRulerText = (1 << 2),
|
||||
eFlag_ShowHorizontalRulerText = (1 << 3),
|
||||
eFlag_ShowPaddingBorder = (1 << 4),
|
||||
eFlag_ShowMovingPointAxis = (1 << 5),
|
||||
eFlag_ShowPointHandles = (1 << 6),
|
||||
eFlag_ShowCursorAlways = (1 << 7),
|
||||
eFlag_Disabled = (1 << 8) // special case, when disabling preview window.
|
||||
};
|
||||
|
||||
CCurveEditorCtrl(QWidget* parent);
|
||||
virtual ~CCurveEditorCtrl();
|
||||
|
||||
void SetFlags(UINT aFlags);
|
||||
UINT GetFlags() const;
|
||||
void SetMouseEnable(bool bEnable = true) { m_bAllowMouse = bEnable; }
|
||||
bool GetMouseEnable() const {return m_bAllowMouse; }
|
||||
bool SetDomainBounds(float aMinX, float aMinY, float aMaxX, float aMaxY);
|
||||
void GetDomainBounds(float& rMinX, float& rMinY, float& rMaxX, float& rMaxY) const;
|
||||
// labelsX/labelsY must be null (to use default labels)
|
||||
// or contain aHorizontalSplits+1/aVerticalSplits+1 items.
|
||||
void SetGrid(UINT aHorizontalSplits, UINT aVerticalSplits, const QStringList& labelsX = QStringList(), const QStringList& labelsY = QStringList());
|
||||
void SetPadding(float padding) { m_padding = padding; }
|
||||
void MarkX(float value);
|
||||
void MarkY(float value);
|
||||
void AddControlPoint(const Vec2& rPosition);
|
||||
void ClearControlPoints();
|
||||
void SetControlPointCount(UINT aCount);
|
||||
UINT GetControlPointCount() const;
|
||||
void SetControlPoint(UINT aIndex, const Vec2& rPosition);
|
||||
void SetControlPointTangents(UINT aIndex, const Vec2& rLeft, const Vec2& rRight);
|
||||
void GetControlPoint(UINT aIndex, Vec2& rOutPosition) const;
|
||||
void GetControlPointTangents(UINT aIndex, Vec2& rOutLeft, Vec2& rOutRight) const;
|
||||
QPoint ProjectPoint(float x, float y);
|
||||
Vec2 UnprojectPoint(const QPoint& pt);
|
||||
void UpdateProjectedPoints();
|
||||
|
||||
protected:
|
||||
struct CurvePoint
|
||||
{
|
||||
CurvePoint(float aX = 0.0f, float aY = 0.0f)
|
||||
{
|
||||
pos.x = aX;
|
||||
pos.y = aY;
|
||||
}
|
||||
|
||||
Vec2 pos;
|
||||
Vec2 tanA, tanB;
|
||||
};
|
||||
|
||||
void ComputeTangents();
|
||||
void ClampToDomain(Vec2& rVec);
|
||||
void GenerateDefaultCurve();
|
||||
|
||||
void paintEvent(QPaintEvent* event) override;
|
||||
|
||||
std::vector<CurvePoint> m_points;
|
||||
std::vector<QPoint> m_projectedPoints;
|
||||
float m_domainMinX;
|
||||
float m_domainMinY;
|
||||
float m_domainMaxX;
|
||||
float m_domainMaxY;
|
||||
Vec2 m_gridSplits;
|
||||
int m_padding;
|
||||
bool m_bMouseDown, m_bDragging, m_bAllowMouse;
|
||||
bool m_bHovered;
|
||||
QPoint m_lastMousePoint;
|
||||
std::vector<int> m_selectedIndices;
|
||||
QFont m_fntInfo;
|
||||
QPen m_pen, m_selCrossPen;
|
||||
UINT m_flags;
|
||||
QStringList m_labelsX;
|
||||
QStringList m_labelsY;
|
||||
std::vector<float> m_marksX;
|
||||
std::vector<float> m_marksY;
|
||||
|
||||
void mousePressEvent(QMouseEvent* event) override;
|
||||
void mouseReleaseEvent(QMouseEvent* event) override;
|
||||
void mouseMoveEvent(QMouseEvent* event) override;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_CONTROLS_CURVEEDITORCTRL_H
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,204 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_CONTROLS_PREVIEWMODELCTRL_H
|
||||
#define CRYINCLUDE_EDITOR_CONTROLS_PREVIEWMODELCTRL_H
|
||||
#pragma once
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include <QString>
|
||||
#include <QPoint>
|
||||
#include <QWidget>
|
||||
|
||||
#include <IStatObj.h>
|
||||
|
||||
#include <Editor/Material/Material.h>
|
||||
|
||||
#endif
|
||||
|
||||
struct IRenderNode;
|
||||
class CImageEx;
|
||||
|
||||
class CPreviewModelCtrl
|
||||
: public QWidget
|
||||
, public IEditorNotifyListener
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CPreviewModelCtrl(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
|
||||
|
||||
QSize minimumSizeHint() const override;
|
||||
|
||||
public:
|
||||
void LoadFile(const QString& modelFile, bool changeCamera = true);
|
||||
Vec3 GetSize() const { return m_size; };
|
||||
QString GetLoadedFile() const { return m_loadedFile; }
|
||||
|
||||
void SetEntity(IRenderNode* entity);
|
||||
void SetObject(IStatObj* pObject);
|
||||
IStatObj* GetObject() { return m_pObj; }
|
||||
void SetCameraLookAt(float fRadiusScale, const Vec3& dir = Vec3(0, 1, 0));
|
||||
void SetCameraRadius(float fRadius);
|
||||
CCamera& GetCamera();
|
||||
void SetGrid(bool bEnable) { m_bGrid = bEnable; }
|
||||
void SetAxis(bool bEnable, bool forParticleEditor = false) { m_bAxis = bEnable; m_bAxisParticleEditor = forParticleEditor; }
|
||||
void SetRotation(bool bEnable);
|
||||
void SetClearColor(const ColorF& color);
|
||||
void SetBackgroundTexture(const QString& textureFilename);
|
||||
void UseBackLight(bool bEnable);
|
||||
bool UseBackLight() const { return m_bUseBacklight; }
|
||||
void SetShowNormals(bool bShow) { m_bShowNormals = bShow; }
|
||||
void SetShowPhysics(bool bShow) { m_bShowPhysics = bShow; }
|
||||
void SetShowRenderInfo(bool bShow) { m_bShowRenderInfo = bShow; }
|
||||
|
||||
void EnableUpdate(bool bEnable);
|
||||
bool IsUpdateEnabled() const { return m_bUpdate; }
|
||||
void Update(bool bForceUpdate = false);
|
||||
void ProcessKeys();
|
||||
|
||||
// this turns on and off aspect-ratio-maintaining. Use it when the widget is free to resize itself.
|
||||
void SetAspectRatio(float newAspectRatio);
|
||||
int heightForWidth(int w) const override;
|
||||
bool hasHeightForWidth() const override;
|
||||
|
||||
void SetMaterial(CMaterial* pMaterial);
|
||||
CMaterial* GetMaterial();
|
||||
|
||||
void GetImageOffscreen(CImageEx& image, const QSize& customSize = QSize(0, 0));
|
||||
|
||||
void GetCameraTM(Matrix34& cameraTM);
|
||||
void SetCameraTM(const Matrix34& cameraTM);
|
||||
|
||||
// Place camera so that whole object fits on screen.
|
||||
void FitToScreen();
|
||||
|
||||
// Get information about the preview model.
|
||||
int GetFaceCount();
|
||||
int GetVertexCount();
|
||||
int GetMaxLod();
|
||||
int GetMtlCount();
|
||||
|
||||
void SetShowObject(bool bShowObject) {m_bShowObject = bShowObject; }
|
||||
bool GetShowObject() {return m_bShowObject; }
|
||||
|
||||
void SetAmbient(ColorF amb) { m_ambientColor = amb; }
|
||||
void SetAmbientMultiplier(f32 multiplier) { m_ambientMultiplier = multiplier; }
|
||||
|
||||
typedef void (* CameraChangeCallback)(void* m_userData, CPreviewModelCtrl* m_currentCamera);
|
||||
void SetCameraChangeCallback(CameraChangeCallback callback, void* userData) { m_cameraChangeCallback = callback, m_pCameraChangeUserData = userData; }
|
||||
|
||||
void EnableMaterialPrecaching(bool bPrecacheMaterial) { m_bPrecacheMaterial = bPrecacheMaterial; }
|
||||
void EnableWireframeRendering(bool bDrawWireframe) { m_bDrawWireFrame = bDrawWireframe; }
|
||||
|
||||
public:
|
||||
~CPreviewModelCtrl();
|
||||
|
||||
bool CreateContext();
|
||||
void ReleaseObject();
|
||||
void DeleteRenderContex();
|
||||
|
||||
protected:
|
||||
void OnCreate();
|
||||
void OnDestroy();
|
||||
void OnLButtonDown(QPoint point);
|
||||
void OnLButtonUp(QPoint point);
|
||||
void OnMButtonDown(QPoint point);
|
||||
void OnMButtonUp(QPoint point);
|
||||
void OnRButtonUp(QPoint point);
|
||||
void OnRButtonDown(QPoint point);
|
||||
|
||||
QPaintEngine* paintEngine() const override;
|
||||
void showEvent(QShowEvent* event) override;
|
||||
void paintEvent(QPaintEvent* event) override;
|
||||
void timerEvent(QTimerEvent* event) override;
|
||||
void mouseMoveEvent(QMouseEvent* event) override;
|
||||
void mousePressEvent(QMouseEvent* event) override;
|
||||
void mouseReleaseEvent(QMouseEvent* event) override;
|
||||
void wheelEvent(QWheelEvent* event) override;
|
||||
|
||||
virtual void OnEditorNotifyEvent(EEditorNotifyEvent event);
|
||||
|
||||
protected:
|
||||
virtual bool Render();
|
||||
virtual void SetCamera(CCamera& cam);
|
||||
|
||||
virtual void RenderObject(_smart_ptr<IMaterial> pMaterial, SRenderingPassInfo& passInfo);
|
||||
|
||||
HWND m_hWnd;
|
||||
CCamera m_camera;
|
||||
float m_fov;
|
||||
|
||||
struct SPreviousContext;
|
||||
std::vector<SPreviousContext> m_previousContexts;
|
||||
|
||||
void SetOrbitAngles(const Ang3& ang);
|
||||
void DrawGrid();
|
||||
void DrawBackground();
|
||||
_smart_ptr<IMaterial> GetCurrentMaterial();
|
||||
|
||||
_smart_ptr<IStatObj> m_pObj;
|
||||
|
||||
IRenderer* m_pRenderer;
|
||||
bool m_bContextCreated;
|
||||
|
||||
Vec3 m_size;
|
||||
Vec3 m_pos;
|
||||
int m_nTimer;
|
||||
bool m_useAspectRatio = false;
|
||||
float m_aspectRatio = 1.0f;
|
||||
|
||||
QString m_loadedFile;
|
||||
std::vector<CDLight> m_lights;
|
||||
|
||||
AABB m_aabb;
|
||||
Vec3 m_cameraTarget;
|
||||
float m_cameraRadius;
|
||||
Vec3 m_cameraAngles;
|
||||
bool m_bInRotateMode;
|
||||
bool m_bInMoveMode;
|
||||
bool m_bInPanMode;
|
||||
QPoint m_mousePosition;
|
||||
QPoint m_previousMousePosition;
|
||||
IRenderNode* m_pEntity;
|
||||
bool m_bHaveAnythingToRender;
|
||||
bool m_bGrid;
|
||||
bool m_bAxis;
|
||||
bool m_bAxisParticleEditor;
|
||||
bool m_bUpdate;
|
||||
bool m_bRotate;
|
||||
float m_rotateAngle;
|
||||
ColorF m_clearColor;
|
||||
ColorF m_ambientColor;
|
||||
f32 m_ambientMultiplier;
|
||||
bool m_bUseBacklight;
|
||||
bool m_bShowObject;
|
||||
bool m_bPrecacheMaterial;
|
||||
bool m_bDrawWireFrame;
|
||||
bool m_bShowNormals;
|
||||
bool m_bShowPhysics;
|
||||
bool m_bShowRenderInfo;
|
||||
int m_backgroundTextureId;
|
||||
float m_tileX;
|
||||
float m_tileY;
|
||||
float m_tileSizeX;
|
||||
float m_tileSizeY;
|
||||
_smart_ptr<CMaterial> m_pCurrentMaterial;
|
||||
CameraChangeCallback m_cameraChangeCallback;
|
||||
void* m_pCameraChangeUserData;
|
||||
|
||||
protected:
|
||||
void StorePreviousContext();
|
||||
void SetCurrentContext();
|
||||
void RestorePreviousContext();
|
||||
};
|
||||
#endif // CRYINCLUDE_EDITOR_CONTROLS_PREVIEWMODELCTRL_H
|
||||
@@ -28,15 +28,12 @@ void RegisterReflectedVarHandlers()
|
||||
registered = true;
|
||||
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew AnimationPropertyWidgetHandler());
|
||||
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew FileResourceSelectorWidgetHandler());
|
||||
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew ShaderPropertyHandler());
|
||||
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew MaterialPropertyHandler());
|
||||
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew ReverbPresetPropertyHandler());
|
||||
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew SequencePropertyHandler());
|
||||
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew SequenceIdPropertyHandler());
|
||||
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew LocalStringPropertyHandler());
|
||||
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew LightAnimationPropertyHandler());
|
||||
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew UserPopupWidgetHandler());
|
||||
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew LensFlareHandler());
|
||||
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew ColorCurveHandler());
|
||||
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew FloatCurveHandler());
|
||||
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew MotionPropertyWidgetHandler());
|
||||
|
||||
@@ -26,8 +26,6 @@
|
||||
#include <CryCommon/ILocalizationManager.h>
|
||||
|
||||
// Editor
|
||||
#include "ShadersDialog.h"
|
||||
#include "Material/MaterialManager.h"
|
||||
#include "SelectLightAnimationDialog.h"
|
||||
#include "SelectSequenceDialog.h"
|
||||
#include "SelectEAXPresetDlg.h"
|
||||
@@ -79,38 +77,6 @@ void GenericPopupPropertyEditor::SetPropertyType(PropertyType type)
|
||||
m_propertyType = type;
|
||||
}
|
||||
|
||||
void ShaderPropertyEditor::onEditClicked()
|
||||
{
|
||||
CShadersDialog cShaders(GetValue());
|
||||
if (cShaders.exec() == QDialog::Accepted)
|
||||
{
|
||||
SetValue(cShaders.GetSelection());
|
||||
}
|
||||
|
||||
}
|
||||
void MaterialPropertyEditor::onEditClicked()
|
||||
{
|
||||
QString name = GetValue();
|
||||
IDataBaseItem *pItem = GetIEditor()->GetMaterialManager()->FindItemByName(name);
|
||||
GetIEditor()->OpenMaterialLibrary(pItem);
|
||||
}
|
||||
|
||||
void MaterialPropertyEditor::onButton2Clicked()
|
||||
{
|
||||
// Open material browser dialog.
|
||||
IDataBaseItem *pItem = GetIEditor()->GetMaterialManager()->GetSelectedItem();
|
||||
if (pItem)
|
||||
{
|
||||
QString value = pItem->GetName();
|
||||
value.replace('\\', '/');
|
||||
if (value.length() >= MAX_PATH)
|
||||
value = value.left(MAX_PATH);
|
||||
SetValue(value);
|
||||
}
|
||||
else
|
||||
SetValue(QString());
|
||||
}
|
||||
|
||||
void ReverbPresetPropertyEditor::onEditClicked()
|
||||
{
|
||||
CSelectEAXPresetDlg PresetDlg(this);
|
||||
|
||||
@@ -100,25 +100,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class ShaderPropertyEditor
|
||||
: public GenericPopupPropertyEditor
|
||||
{
|
||||
public:
|
||||
ShaderPropertyEditor(QWidget* pParent = nullptr)
|
||||
: GenericPopupPropertyEditor(pParent){}
|
||||
void onEditClicked() override;
|
||||
};
|
||||
|
||||
class MaterialPropertyEditor
|
||||
: public GenericPopupPropertyEditor
|
||||
{
|
||||
public:
|
||||
MaterialPropertyEditor(QWidget* pParent = nullptr)
|
||||
: GenericPopupPropertyEditor(pParent, true){}
|
||||
void onEditClicked() override;
|
||||
void onButton2Clicked() override;
|
||||
};
|
||||
|
||||
class ReverbPresetPropertyEditor
|
||||
: public GenericPopupPropertyEditor
|
||||
{
|
||||
@@ -178,8 +159,6 @@ public:
|
||||
// So we use our own
|
||||
#define CONST_AZ_CRC(name, value) AZ::u32(value)
|
||||
|
||||
using ShaderPropertyHandler = GenericPopupWidgetHandler<ShaderPropertyEditor, CONST_AZ_CRC("ePropertyShader", 0xc40932f1)>;
|
||||
using MaterialPropertyHandler = GenericPopupWidgetHandler<MaterialPropertyEditor, CONST_AZ_CRC("ePropertyMaterial", 0xf324dffa)>;
|
||||
using ReverbPresetPropertyHandler = GenericPopupWidgetHandler<ReverbPresetPropertyEditor, CONST_AZ_CRC("ePropertyReverbPreset", 0x51469f38)>;
|
||||
using MissionObjPropertyHandler = GenericPopupWidgetHandler<MissionObjPropertyEditor, CONST_AZ_CRC("ePropertyMissionObj", 0x4a2d0dc8)>;
|
||||
using SequencePropertyHandler = GenericPopupWidgetHandler<SequencePropertyEditor, CONST_AZ_CRC("ePropertySequence", 0xdd1c7d44)>;
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
// Editor
|
||||
#include "GenericSelectItemDialog.h"
|
||||
#include "QtViewPaneManager.h"
|
||||
#include "LensFlareEditor/LensFlareEditor.h"
|
||||
|
||||
|
||||
UserPropertyEditor::UserPropertyEditor(QWidget *pParent /*= nullptr*/)
|
||||
@@ -147,79 +146,6 @@ bool UserPopupWidgetHandler::ReadValuesIntoGUI(size_t index, UserPropertyEditor*
|
||||
|
||||
#include <Controls/ReflectedPropertyControl/moc_PropertyMiscCtrl.cpp>
|
||||
|
||||
LensFlarePropertyWidget::LensFlarePropertyWidget(QWidget *pParent /*= nullptr*/)
|
||||
:QWidget(pParent)
|
||||
{
|
||||
m_valueEdit = new QLineEdit;
|
||||
|
||||
QToolButton *mainButton = new QToolButton;
|
||||
mainButton->setText("D");
|
||||
connect(mainButton, &QToolButton::clicked, this, &LensFlarePropertyWidget::OnEditClicked);
|
||||
connect(m_valueEdit, &QLineEdit::editingFinished, m_valueEdit, [this] () {emit ValueChanged(m_valueEdit->text());});
|
||||
|
||||
QHBoxLayout *mainLayout = new QHBoxLayout(this);
|
||||
mainLayout->addWidget(m_valueEdit, 1);
|
||||
mainLayout->addWidget(mainButton);
|
||||
mainLayout->setContentsMargins(1, 1, 1, 1);
|
||||
}
|
||||
|
||||
void LensFlarePropertyWidget::SetValue(const QString &value)
|
||||
{
|
||||
m_valueEdit->setText(value);
|
||||
}
|
||||
|
||||
QString LensFlarePropertyWidget::GetValue() const
|
||||
{
|
||||
return m_valueEdit->text();
|
||||
}
|
||||
|
||||
void LensFlarePropertyWidget::OnEditClicked()
|
||||
{
|
||||
const QtViewPane *lensFlarePane = GetIEditor()->OpenView(CLensFlareEditor::s_pLensFlareEditorClassName);
|
||||
if (!lensFlarePane)
|
||||
return;
|
||||
|
||||
CLensFlareEditor *editor = FindViewPane<CLensFlareEditor>(QtUtil::ToQString(CLensFlareEditor::s_pLensFlareEditorClassName));
|
||||
if (editor)
|
||||
QTimer::singleShot(0, editor, SLOT(OnUpdateTreeCtrl()));
|
||||
}
|
||||
|
||||
QWidget* LensFlareHandler::CreateGUI(QWidget *pParent)
|
||||
{
|
||||
LensFlarePropertyWidget* newCtrl = aznew LensFlarePropertyWidget(pParent);
|
||||
connect(newCtrl, &LensFlarePropertyWidget::ValueChanged, newCtrl, [newCtrl]()
|
||||
{
|
||||
EBUS_EVENT(AzToolsFramework::PropertyEditorGUIMessages::Bus, RequestWrite, newCtrl);
|
||||
});
|
||||
|
||||
return newCtrl;
|
||||
}
|
||||
|
||||
void LensFlareHandler::ConsumeAttribute(LensFlarePropertyWidget* GUI, AZ::u32 attrib, AzToolsFramework::PropertyAttributeReader* attrValue, const char* debugName)
|
||||
{
|
||||
Q_UNUSED(GUI); Q_UNUSED(attrib); Q_UNUSED(attrValue); Q_UNUSED(debugName);
|
||||
}
|
||||
|
||||
void LensFlareHandler::WriteGUIValuesIntoProperty(size_t index, LensFlarePropertyWidget* GUI, property_t& instance, AzToolsFramework::InstanceDataNode* node)
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(node);
|
||||
CReflectedVarGenericProperty val = instance;
|
||||
val.m_value = GUI->GetValue().toUtf8().data();
|
||||
instance = static_cast<property_t>(val);
|
||||
}
|
||||
|
||||
bool LensFlareHandler::ReadValuesIntoGUI(size_t index, LensFlarePropertyWidget* GUI, const property_t& instance, AzToolsFramework::InstanceDataNode* node)
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(node);
|
||||
CReflectedVarGenericProperty val = instance;
|
||||
GUI->SetValue(val.m_value.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
QWidget* FloatCurveHandler::CreateGUI(QWidget *pParent)
|
||||
{
|
||||
CSplineCtrl *cSpline = new CSplineCtrl(pParent);
|
||||
|
||||
@@ -70,39 +70,6 @@ public:
|
||||
|
||||
};
|
||||
|
||||
|
||||
class LensFlarePropertyWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(LensFlarePropertyWidget, AZ::SystemAllocator, 0);
|
||||
LensFlarePropertyWidget(QWidget *pParent = nullptr);
|
||||
|
||||
void SetValue(const QString &value);
|
||||
QString GetValue() const;
|
||||
|
||||
void OnEditClicked();
|
||||
|
||||
signals:
|
||||
void ValueChanged(const QString &value);
|
||||
|
||||
private:
|
||||
QLineEdit *m_valueEdit;
|
||||
};
|
||||
|
||||
class LensFlareHandler : public QObject, public AzToolsFramework::PropertyHandler < CReflectedVarGenericProperty, LensFlarePropertyWidget>
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(LensFlareHandler, AZ::SystemAllocator, 0);
|
||||
bool IsDefaultHandler() const override { return false; }
|
||||
QWidget* CreateGUI(QWidget *pParent) override;
|
||||
|
||||
AZ::u32 GetHandlerName(void) const override { return AZ_CRC("ePropertyFlare", 0x5ce803df); }
|
||||
void ConsumeAttribute(LensFlarePropertyWidget* GUI, AZ::u32 attrib, AzToolsFramework::PropertyAttributeReader* attrValue, const char* debugName) override;
|
||||
void WriteGUIValuesIntoProperty(size_t index, LensFlarePropertyWidget* GUI, property_t& instance, AzToolsFramework::InstanceDataNode* node) override;
|
||||
bool ReadValuesIntoGUI(size_t index, LensFlarePropertyWidget* GUI, const property_t& instance, AzToolsFramework::InstanceDataNode* node) override;
|
||||
};
|
||||
|
||||
class FloatCurveHandler : public QObject, public AzToolsFramework::PropertyHandler < CReflectedVarSpline, CSplineCtrl>
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -1,187 +1,64 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates, or
|
||||
* a third party where indicated.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates, or
|
||||
* a third party where indicated.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "EditorDefs.h"
|
||||
|
||||
#include "PropertyMotionCtrl.h"
|
||||
|
||||
// Qt
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QToolButton>
|
||||
|
||||
// AzToolsFramework
|
||||
#include <AzToolsFramework/AssetBrowser/AssetSelectionModel.h>
|
||||
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
|
||||
#include <AzToolsFramework/AssetBrowser/AssetSelectionModel.h>
|
||||
|
||||
|
||||
MotionPropertyCtrl::MotionPropertyCtrl(QWidget *pParent)
|
||||
: QWidget(pParent)
|
||||
QWidget* MotionPropertyWidgetHandler::CreateGUI(QWidget* pParent)
|
||||
{
|
||||
m_motionLabel = new QLabel;
|
||||
|
||||
m_pBrowseButton = new QToolButton;
|
||||
m_pBrowseButton->setIcon(QIcon(":/reflectedPropertyCtrl/img/file_browse.png"));
|
||||
m_pApplyButton = new QToolButton;
|
||||
m_pApplyButton->setIcon(QIcon(":/reflectedPropertyCtrl/img/apply.png"));
|
||||
|
||||
m_pApplyButton->setFocusPolicy(Qt::StrongFocus);
|
||||
m_pBrowseButton->setFocusPolicy(Qt::StrongFocus);
|
||||
|
||||
QHBoxLayout *pLayout = new QHBoxLayout(this);
|
||||
pLayout->setContentsMargins(0, 0, 0, 0);
|
||||
pLayout->addWidget(m_motionLabel, 1);
|
||||
pLayout->addWidget(m_pBrowseButton);
|
||||
pLayout->addWidget(m_pApplyButton);
|
||||
|
||||
connect(m_pBrowseButton, &QAbstractButton::clicked, this, &MotionPropertyCtrl::OnBrowseClicked);
|
||||
connect(m_pApplyButton, &QAbstractButton::clicked, this, &MotionPropertyCtrl::OnApplyClicked);
|
||||
};
|
||||
|
||||
MotionPropertyCtrl::~MotionPropertyCtrl()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void MotionPropertyCtrl::SetValue(const CReflectedVarMotion &motion)
|
||||
{
|
||||
m_motion = motion;
|
||||
SetLabelText(motion.m_motion);
|
||||
}
|
||||
|
||||
CReflectedVarMotion MotionPropertyCtrl::value() const
|
||||
{
|
||||
return m_motion;
|
||||
}
|
||||
|
||||
void MotionPropertyCtrl::OnBrowseClicked()
|
||||
{
|
||||
|
||||
static AZ::Data::AssetType emotionFXMotionAssetType("{00494B8E-7578-4BA2-8B28-272E90680787}"); // from MotionAsset.h in EMotionFX Gem
|
||||
|
||||
// Request the AssetBrowser Dialog and set a type filter
|
||||
AssetSelectionModel selection = AssetSelectionModel::AssetTypeSelection(emotionFXMotionAssetType);
|
||||
selection.SetSelectedAssetId(m_motion.m_assetId);
|
||||
AzToolsFramework::EditorRequests::Bus::Broadcast(&AzToolsFramework::EditorRequests::BrowseForAssets, selection);
|
||||
if (selection.IsValid())
|
||||
{
|
||||
auto product = azrtti_cast<const ProductAssetBrowserEntry*>(selection.GetResult());
|
||||
if (product != nullptr)
|
||||
{
|
||||
m_motion.m_motion = product->GetRelativePath();
|
||||
m_motion.m_assetId = product->GetAssetId();
|
||||
SetLabelText(m_motion.m_motion);
|
||||
emit ValueChanged(m_motion);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Might be able to delete this function
|
||||
void MotionPropertyCtrl::OnApplyClicked()
|
||||
{
|
||||
#if 0
|
||||
CUIEnumerations &roGeneralProxy = CUIEnumerations::GetUIEnumerationsInstance();
|
||||
QStringList cSelectedMotions;
|
||||
size_t nTotalMotions(0);
|
||||
size_t nCurrentMotion(0);
|
||||
|
||||
QString combinedString = GetIEditor()->GetResourceSelectorHost()->GetGlobalSelection("motion");
|
||||
SplitString(combinedString, cSelectedMotions, ',');
|
||||
|
||||
nTotalMotions = cSelectedMotions.size();
|
||||
for (nCurrentMotion = 0; nCurrentMotion < nTotalMotions; ++nCurrentMotion)
|
||||
{
|
||||
QString& rstrCurrentAnimAction = cSelectedMotions[nCurrentMotion];
|
||||
if (!rstrCurrentAnimAction.isEmpty())
|
||||
{
|
||||
m_motion.m_motion = rstrCurrentAnimAction.toLatin1().data();
|
||||
SetLabelText(m_motion.m_motion);
|
||||
emit ValueChanged(m_motion);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
QWidget* MotionPropertyCtrl::GetFirstInTabOrder()
|
||||
{
|
||||
return m_pBrowseButton;
|
||||
}
|
||||
QWidget* MotionPropertyCtrl::GetLastInTabOrder()
|
||||
{
|
||||
return m_pApplyButton;
|
||||
}
|
||||
|
||||
void MotionPropertyCtrl::UpdateTabOrder()
|
||||
{
|
||||
setTabOrder(m_pBrowseButton, m_pApplyButton);
|
||||
}
|
||||
|
||||
void MotionPropertyCtrl::SetLabelText(const AZStd::string& motion)
|
||||
{
|
||||
if (!motion.empty())
|
||||
{
|
||||
AZStd::string filename;
|
||||
if (AzFramework::StringFunc::Path::GetFileName(motion.c_str(), filename))
|
||||
{
|
||||
m_motionLabel->setText(filename.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
m_motionLabel->setText(motion.c_str());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_motionLabel->setText("");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QWidget* MotionPropertyWidgetHandler::CreateGUI(QWidget *pParent)
|
||||
{
|
||||
MotionPropertyCtrl* newCtrl = aznew MotionPropertyCtrl(pParent);
|
||||
connect(newCtrl, &MotionPropertyCtrl::ValueChanged, newCtrl, [newCtrl]()
|
||||
{
|
||||
EBUS_EVENT(AzToolsFramework::PropertyEditorGUIMessages::Bus, RequestWrite, newCtrl);
|
||||
});
|
||||
AzToolsFramework::PropertyAssetCtrl* newCtrl = aznew AzToolsFramework::PropertyAssetCtrl(pParent);
|
||||
connect(
|
||||
newCtrl, &AzToolsFramework::PropertyAssetCtrl::OnAssetIDChanged, this, [newCtrl]([[maybe_unused]] AZ::Data::AssetId newAssetId) {
|
||||
EBUS_EVENT(AzToolsFramework::PropertyEditorGUIMessages::Bus, RequestWrite, newCtrl);
|
||||
AzToolsFramework::PropertyEditorGUIMessages::Bus::Broadcast(
|
||||
&AzToolsFramework::PropertyEditorGUIMessages::Bus::Handler::OnEditingFinished, newCtrl);
|
||||
});
|
||||
return newCtrl;
|
||||
}
|
||||
|
||||
|
||||
void MotionPropertyWidgetHandler::ConsumeAttribute(MotionPropertyCtrl* GUI, AZ::u32 attrib, AzToolsFramework::PropertyAttributeReader* attrValue, const char* debugName)
|
||||
void MotionPropertyWidgetHandler::ConsumeAttribute(
|
||||
[[maybe_unused]] AzToolsFramework::PropertyAssetCtrl* GUI, [[maybe_unused]] AZ::u32 attrib,
|
||||
[[maybe_unused]] AzToolsFramework::PropertyAttributeReader* attrValue, [[maybe_unused]] const char* debugName)
|
||||
{
|
||||
Q_UNUSED(GUI);
|
||||
Q_UNUSED(attrib);
|
||||
Q_UNUSED(attrValue);
|
||||
Q_UNUSED(debugName);
|
||||
}
|
||||
|
||||
void MotionPropertyWidgetHandler::WriteGUIValuesIntoProperty(size_t index, MotionPropertyCtrl* GUI, property_t& instance, AzToolsFramework::InstanceDataNode* node)
|
||||
void MotionPropertyWidgetHandler::WriteGUIValuesIntoProperty(
|
||||
[[maybe_unused]] size_t index, [[maybe_unused]] AzToolsFramework::PropertyAssetCtrl* GUI, property_t& instance,
|
||||
[[maybe_unused]] AzToolsFramework::InstanceDataNode* node)
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(node);
|
||||
CReflectedVarMotion val = GUI->value();
|
||||
CReflectedVarMotion val;
|
||||
val.m_motion = GUI->GetCurrentAssetHint();
|
||||
val.m_assetId = GUI->GetSelectedAssetID();
|
||||
instance = static_cast<property_t>(val);
|
||||
}
|
||||
|
||||
bool MotionPropertyWidgetHandler::ReadValuesIntoGUI(size_t index, MotionPropertyCtrl* GUI, const property_t& instance, AzToolsFramework::InstanceDataNode* node)
|
||||
bool MotionPropertyWidgetHandler::ReadValuesIntoGUI(
|
||||
[[maybe_unused]] size_t index, [[maybe_unused]] AzToolsFramework::PropertyAssetCtrl* GUI, const property_t& instance,
|
||||
[[maybe_unused]] AzToolsFramework::InstanceDataNode* node)
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(node);
|
||||
CReflectedVarMotion val = instance;
|
||||
GUI->SetValue(val);
|
||||
static const AZ::Data::AssetType emotionFXMotionAssetType(
|
||||
"{00494B8E-7578-4BA2-8B28-272E90680787}"); // from MotionAsset.h in EMotionFX Gem
|
||||
|
||||
GUI->blockSignals(true);
|
||||
GUI->SetSelectedAssetID(instance.m_assetId);
|
||||
GUI->SetCurrentAssetType(emotionFXMotionAssetType);
|
||||
GUI->blockSignals(false);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
#include <Controls/ReflectedPropertyControl/moc_PropertyMotionCtrl.cpp>
|
||||
|
||||
|
||||
@@ -1,92 +1,67 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_UTILS_PROPERTYMOTIONCTRL_H
|
||||
#define CRYINCLUDE_EDITOR_UTILS_PROPERTYMOTIONCTRL_H
|
||||
#pragma once
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include <AzCore/base.h>
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
#include "ReflectedVar.h"
|
||||
#include <QWidget>
|
||||
#include <QPointer>
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
#include <AzCore/base.h>
|
||||
#include <AzToolsFramework/UI/PropertyEditor/PropertyAssetCtrl.hxx>
|
||||
#include <AzToolsFramework/UI/PropertyEditor/PropertyEditorAPI.h>
|
||||
|
||||
#include <QPointer>
|
||||
#include <QWidget>
|
||||
#endif
|
||||
|
||||
class QToolButton;
|
||||
class QLabel;
|
||||
class QHBoxLayout;
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
class PropertyAssetCtrl;
|
||||
}
|
||||
|
||||
class MotionPropertyCtrl
|
||||
: public QWidget
|
||||
class MotionPropertyWidgetHandler : QObject,
|
||||
public AzToolsFramework::PropertyHandler<CReflectedVarMotion, AzToolsFramework::PropertyAssetCtrl>
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(MotionPropertyCtrl, AZ::SystemAllocator, 0);
|
||||
|
||||
MotionPropertyCtrl(QWidget* pParent = nullptr);
|
||||
virtual ~MotionPropertyCtrl();
|
||||
|
||||
CReflectedVarMotion value() const;
|
||||
|
||||
QWidget* GetFirstInTabOrder();
|
||||
QWidget* GetLastInTabOrder();
|
||||
void UpdateTabOrder();
|
||||
|
||||
signals:
|
||||
void ValueChanged(CReflectedVarMotion value);
|
||||
|
||||
public slots:
|
||||
void SetValue(const CReflectedVarMotion& motion);
|
||||
|
||||
protected slots:
|
||||
void OnBrowseClicked();
|
||||
void OnApplyClicked();
|
||||
|
||||
private:
|
||||
void SetLabelText(const AZStd::string& motion);
|
||||
|
||||
QToolButton* m_pBrowseButton;
|
||||
QToolButton* m_pApplyButton;
|
||||
QLabel* m_motionLabel;
|
||||
|
||||
CReflectedVarMotion m_motion;
|
||||
};
|
||||
|
||||
class MotionPropertyWidgetHandler
|
||||
: QObject
|
||||
, public AzToolsFramework::PropertyHandler < CReflectedVarMotion, MotionPropertyCtrl >
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(MotionPropertyWidgetHandler, AZ::SystemAllocator, 0);
|
||||
|
||||
virtual AZ::u32 GetHandlerName(void) const override { return AZ_CRC("Motion", 0xf5fea1e8); }
|
||||
virtual bool IsDefaultHandler() const override { return true; }
|
||||
virtual QWidget* GetFirstInTabOrder(MotionPropertyCtrl* widget) override { return widget->GetFirstInTabOrder(); }
|
||||
virtual QWidget* GetLastInTabOrder(MotionPropertyCtrl* widget) override { return widget->GetLastInTabOrder(); }
|
||||
virtual void UpdateWidgetInternalTabbing(MotionPropertyCtrl* widget) override { widget->UpdateTabOrder(); }
|
||||
virtual AZ::u32 GetHandlerName(void) const override
|
||||
{
|
||||
return AZ_CRC("Motion", 0xf5fea1e8);
|
||||
}
|
||||
|
||||
virtual bool IsDefaultHandler() const override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual QWidget* GetFirstInTabOrder(AzToolsFramework::PropertyAssetCtrl* widget) override
|
||||
{
|
||||
return widget->GetFirstInTabOrder();
|
||||
}
|
||||
|
||||
virtual QWidget* GetLastInTabOrder(AzToolsFramework::PropertyAssetCtrl* widget) override
|
||||
{
|
||||
return widget->GetLastInTabOrder();
|
||||
}
|
||||
|
||||
virtual void UpdateWidgetInternalTabbing(AzToolsFramework::PropertyAssetCtrl* widget) override
|
||||
{
|
||||
widget->UpdateTabOrder();
|
||||
}
|
||||
|
||||
virtual QWidget* CreateGUI(QWidget* pParent) override;
|
||||
virtual void ConsumeAttribute(MotionPropertyCtrl* GUI, AZ::u32 attrib, AzToolsFramework::PropertyAttributeReader* attrValue, const char* debugName) override;
|
||||
virtual void WriteGUIValuesIntoProperty(size_t index, MotionPropertyCtrl* GUI, property_t& instance, AzToolsFramework::InstanceDataNode* node) override;
|
||||
virtual bool ReadValuesIntoGUI(size_t index, MotionPropertyCtrl* GUI, const property_t& instance, AzToolsFramework::InstanceDataNode* node) override;
|
||||
virtual void ConsumeAttribute(
|
||||
AzToolsFramework::PropertyAssetCtrl* GUI, AZ::u32 attrib, AzToolsFramework::PropertyAttributeReader* attrValue,
|
||||
const char* debugName) override;
|
||||
virtual void WriteGUIValuesIntoProperty(
|
||||
size_t index, AzToolsFramework::PropertyAssetCtrl* GUI, property_t& instance, AzToolsFramework::InstanceDataNode* node) override;
|
||||
virtual bool ReadValuesIntoGUI(
|
||||
size_t index, AzToolsFramework::PropertyAssetCtrl* GUI, const property_t& instance,
|
||||
AzToolsFramework::InstanceDataNode* node) override;
|
||||
};
|
||||
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_UTILS_PROPERTYMOTIONCTRL_H
|
||||
|
||||
@@ -111,14 +111,12 @@ private:
|
||||
{
|
||||
case ePropertyTexture:
|
||||
case ePropertyModel:
|
||||
case ePropertyMaterial:
|
||||
newPath.replace("\\\\", "/");
|
||||
}
|
||||
switch (m_propertyType)
|
||||
{
|
||||
case ePropertyTexture:
|
||||
case ePropertyModel:
|
||||
case ePropertyMaterial:
|
||||
case ePropertyFile:
|
||||
if (newPath.size() > MAX_PATH)
|
||||
{
|
||||
|
||||
@@ -361,16 +361,6 @@ void ReflectedPropertyControl::CreateItems(XmlNodeRef node, CVarBlockPtr& outBlo
|
||||
textureVar->Set(textureName);
|
||||
}
|
||||
}
|
||||
else if (!azstricmp(type, "material"))
|
||||
{
|
||||
CSmartVariable<QString> materialVar;
|
||||
AddVariable(group, materialVar, child->getTag(), humanReadableName.toUtf8().data(), strDescription.toUtf8().data(), func, pUserData, IVariable::DT_MATERIAL);
|
||||
const char* materialName;
|
||||
if (child->getAttr("value", &materialName))
|
||||
{
|
||||
materialVar->Set(materialName);
|
||||
}
|
||||
}
|
||||
else if (!azstricmp(type, "color"))
|
||||
{
|
||||
CSmartVariable<Vec3> colorVar;
|
||||
|
||||
@@ -268,8 +268,6 @@ void ReflectedPropertyItem::SetVariable(IVariable *var)
|
||||
case ePropertyUser:
|
||||
m_reflectedVarAdapter = new ReflectedVarUserAdapter;
|
||||
break;
|
||||
case ePropertyShader:
|
||||
case ePropertyMaterial:
|
||||
case ePropertyEquip:
|
||||
case ePropertyReverbPreset:
|
||||
case ePropertyGameToken:
|
||||
@@ -279,7 +277,6 @@ void ReflectedPropertyItem::SetVariable(IVariable *var)
|
||||
case ePropertyLocalString:
|
||||
case ePropertyLightAnimation:
|
||||
case ePropertyParticleName:
|
||||
case ePropertyFlare:
|
||||
m_reflectedVarAdapter = new ReflectedVarGenericPropertyAdapter(desc.m_type);
|
||||
break;
|
||||
case ePropertyTexture:
|
||||
@@ -577,7 +574,6 @@ void ReflectedPropertyItem::SetValue(const QString& sValue, bool bRecordUndo, bo
|
||||
|
||||
case ePropertyTexture:
|
||||
case ePropertyModel:
|
||||
case ePropertyMaterial:
|
||||
value.replace('\\', '/');
|
||||
break;
|
||||
}
|
||||
@@ -587,7 +583,6 @@ void ReflectedPropertyItem::SetValue(const QString& sValue, bool bRecordUndo, bo
|
||||
{
|
||||
case ePropertyTexture:
|
||||
case ePropertyModel:
|
||||
case ePropertyMaterial:
|
||||
case ePropertyFile:
|
||||
if (value.length() >= MAX_PATH)
|
||||
{
|
||||
|
||||
@@ -286,8 +286,6 @@ AZ::u32 CReflectedVarGenericProperty::handler()
|
||||
{
|
||||
case ePropertyShader:
|
||||
return AZ_CRC("ePropertyShader", 0xc40932f1);
|
||||
case ePropertyMaterial:
|
||||
return AZ_CRC("ePropertyMaterial", 0xf324dffa);
|
||||
case ePropertyEquip:
|
||||
return AZ_CRC("ePropertyEquip", 0x66ffd290);
|
||||
case ePropertyReverbPreset:
|
||||
@@ -308,8 +306,6 @@ AZ::u32 CReflectedVarGenericProperty::handler()
|
||||
return AZ_CRC("ePropertyLightAnimation", 0x277097da);
|
||||
case ePropertyParticleName:
|
||||
return AZ_CRC("ePropertyParticleName", 0xf44c7133);
|
||||
case ePropertyFlare:
|
||||
return AZ_CRC("ePropertyFlare", 0x5ce803df);
|
||||
default:
|
||||
AZ_Assert(false, "No property handlers defined for the property type");
|
||||
return AZ_CRC("Default", 0xe35e00df);
|
||||
|
||||
@@ -455,8 +455,6 @@ void ReflectedVarGenericPropertyAdapter::SyncReflectedVarToIVar(IVariable *pVari
|
||||
{
|
||||
QString value;
|
||||
pVariable->Get(value);
|
||||
if (m_reflectedVar->m_propertyType == ePropertyMaterial)
|
||||
value.replace('\\', '/');
|
||||
|
||||
m_reflectedVar->m_value = value.toUtf8().data();
|
||||
}
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
// Description : implementation file
|
||||
|
||||
|
||||
#include "EditorDefs.h"
|
||||
|
||||
#include "TimeOfDaySlider.h"
|
||||
|
||||
QString TimeOfDaySlider::hoverValueText(int sliderValue) const
|
||||
{
|
||||
return QString::fromLatin1("%1:%2").arg(static_cast<int>(sliderValue / 60)).arg(sliderValue % 60, 2, 10, QLatin1Char('0'));
|
||||
}
|
||||
|
||||
#include <Controls/moc_TimeOfDaySlider.cpp>
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_TIMEOFDAYSLIDER_H
|
||||
#define CRYINCLUDE_EDITOR_TIMEOFDAYSLIDER_H
|
||||
#pragma once
|
||||
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include <AzQtComponents/Components/Widgets/Slider.h>
|
||||
#endif
|
||||
|
||||
class TimeOfDaySlider
|
||||
: public AzQtComponents::SliderInt
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
using AzQtComponents::SliderInt::SliderInt;
|
||||
|
||||
protected:
|
||||
QString hoverValueText(int sliderValue) const override;
|
||||
};
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_TIMEOFDAYSLIDER_H
|
||||
@@ -23,7 +23,6 @@
|
||||
#include "Objects/SelectionGroup.h"
|
||||
#include "ViewManager.h"
|
||||
|
||||
#include <AzFramework/API/AtomActiveInterface.h>
|
||||
#include <AzCore/Interface/Interface.h>
|
||||
|
||||
// Qt
|
||||
@@ -458,8 +457,6 @@ QMenu* LevelEditorMenuHandler::CreateFileMenu()
|
||||
|
||||
void LevelEditorMenuHandler::PopulateEditMenu(ActionManager::MenuWrapper& editMenu)
|
||||
{
|
||||
const bool newViewportInteractionModelEnabled = GetIEditor()->IsNewViewportInteractionModelEnabled();
|
||||
|
||||
// Undo
|
||||
editMenu.AddAction(ID_UNDO);
|
||||
|
||||
@@ -496,47 +493,28 @@ void LevelEditorMenuHandler::PopulateEditMenu(ActionManager::MenuWrapper& editMe
|
||||
// Select All
|
||||
editMenu.AddAction(ID_EDIT_SELECTALL);
|
||||
|
||||
// Deselect All
|
||||
if (!newViewportInteractionModelEnabled)
|
||||
{
|
||||
editMenu.AddAction(ID_EDIT_SELECTNONE);
|
||||
}
|
||||
|
||||
// Invert Selection
|
||||
editMenu.AddAction(ID_EDIT_INVERTSELECTION);
|
||||
|
||||
editMenu.AddSeparator();
|
||||
|
||||
// New Viewport Interaction Model actions/shortcuts
|
||||
if (newViewportInteractionModelEnabled)
|
||||
{
|
||||
editMenu.AddAction(ID_EDIT_PIVOT);
|
||||
editMenu.AddAction(ID_EDIT_RESET);
|
||||
editMenu.AddAction(ID_EDIT_RESET_MANIPULATOR);
|
||||
editMenu.AddAction(ID_EDIT_RESET_LOCAL);
|
||||
editMenu.AddAction(ID_EDIT_RESET_WORLD);
|
||||
}
|
||||
editMenu.AddAction(ID_EDIT_PIVOT);
|
||||
editMenu.AddAction(ID_EDIT_RESET);
|
||||
editMenu.AddAction(ID_EDIT_RESET_MANIPULATOR);
|
||||
editMenu.AddAction(ID_EDIT_RESET_LOCAL);
|
||||
editMenu.AddAction(ID_EDIT_RESET_WORLD);
|
||||
|
||||
// Hide Selection
|
||||
editMenu.AddAction(ID_EDIT_HIDE);
|
||||
|
||||
if (!newViewportInteractionModelEnabled)
|
||||
{
|
||||
// Show Selection
|
||||
auto showSelectionMenu = editMenu.Get()->addAction(tr("Show Selection"));
|
||||
connect(showSelectionMenu, &QAction::triggered, this, [this]() { ToggleSelection(false); });
|
||||
|
||||
// Show Last Hidden
|
||||
editMenu.AddAction(ID_EDIT_SHOW_LAST_HIDDEN);
|
||||
}
|
||||
|
||||
// Unhide All
|
||||
editMenu.AddAction(ID_EDIT_UNHIDEALL);
|
||||
|
||||
/*
|
||||
* The following block of code is part of the feature "Isolation Mode" and is temporarily
|
||||
* disabled for 1.10 release.
|
||||
* Jira: https://jira.agscollab.com/browse/LY-49532
|
||||
* Jira: LY-49532
|
||||
|
||||
// Isolate Selected
|
||||
QAction* isolateSelectedAction = editMenu->addAction(tr("Isolate Selected"));
|
||||
@@ -572,31 +550,10 @@ void LevelEditorMenuHandler::PopulateEditMenu(ActionManager::MenuWrapper& editMe
|
||||
// Modify Menu
|
||||
auto modifyMenu = editMenu.AddMenu(tr("&Modify"));
|
||||
|
||||
if (!newViewportInteractionModelEnabled)
|
||||
{
|
||||
modifyMenu.AddAction(ID_MODIFY_LINK);
|
||||
modifyMenu.AddAction(ID_MODIFY_UNLINK);
|
||||
modifyMenu.AddSeparator();
|
||||
}
|
||||
|
||||
auto snapMenu = modifyMenu.AddMenu(tr("Snap"));
|
||||
|
||||
if (!newViewportInteractionModelEnabled)
|
||||
{
|
||||
snapMenu.AddAction(ID_SNAP_TO_GRID);
|
||||
}
|
||||
|
||||
snapMenu.AddAction(ID_SNAPANGLE);
|
||||
|
||||
if (!newViewportInteractionModelEnabled)
|
||||
{
|
||||
auto fastRotateMenu = modifyMenu.AddMenu(tr("Fast Rotate"));
|
||||
fastRotateMenu.AddAction(ID_ROTATESELECTION_XAXIS);
|
||||
fastRotateMenu.AddAction(ID_ROTATESELECTION_YAXIS);
|
||||
fastRotateMenu.AddAction(ID_ROTATESELECTION_ZAXIS);
|
||||
fastRotateMenu.AddAction(ID_ROTATESELECTION_ROTATEANGLE);
|
||||
}
|
||||
|
||||
auto transformModeMenu = modifyMenu.AddMenu(tr("Transform Mode"));
|
||||
transformModeMenu.AddAction(ID_EDITMODE_MOVE);
|
||||
transformModeMenu.AddAction(ID_EDITMODE_ROTATE);
|
||||
@@ -604,21 +561,6 @@ void LevelEditorMenuHandler::PopulateEditMenu(ActionManager::MenuWrapper& editMe
|
||||
|
||||
editMenu.AddSeparator();
|
||||
|
||||
// Lock Selection
|
||||
editMenu.AddAction(ID_EDIT_FREEZE);
|
||||
|
||||
// NEWMENUS: NEEDS IMPLEMENTATION
|
||||
//// Unlock Selection
|
||||
//auto unlockSelectionMenu = editMenu.Get()->addAction(tr("Unlock Selection"));
|
||||
|
||||
//// Unlock Last Locked
|
||||
//auto unlockLastLockedMenu = editMenu.Get()->addAction(tr("Unlock Last Locked"));
|
||||
|
||||
// Unlock All
|
||||
editMenu.AddAction(ID_EDIT_UNFREEZEALL);
|
||||
|
||||
editMenu.AddSeparator();
|
||||
|
||||
// Editor Settings
|
||||
auto editorSettingsMenu = editMenu.AddMenu(tr("Editor Settings"));
|
||||
|
||||
@@ -725,12 +667,6 @@ QMenu* LevelEditorMenuHandler::CreateGameMenu()
|
||||
|
||||
gameMenu.AddSeparator();
|
||||
|
||||
if (!GetIEditor()->IsNewViewportInteractionModelEnabled())
|
||||
{
|
||||
gameMenu.AddAction(ID_TERRAIN_VEGETATION);
|
||||
gameMenu.AddSeparator();
|
||||
}
|
||||
|
||||
CreateDebuggingSubMenu(gameMenu);
|
||||
|
||||
return gameMenu;
|
||||
@@ -793,15 +729,6 @@ QMenu* LevelEditorMenuHandler::CreateViewMenu()
|
||||
viewportViewsMenuWrapper.AddAction(ID_WIREFRAME);
|
||||
viewportViewsMenuWrapper.AddSeparator();
|
||||
|
||||
if (!GetIEditor()->IsNewViewportInteractionModelEnabled())
|
||||
{
|
||||
// Ruler
|
||||
viewportViewsMenuWrapper.AddAction(ID_RULER);
|
||||
}
|
||||
|
||||
viewportViewsMenuWrapper.AddAction(ID_VIEW_GRIDSETTINGS);
|
||||
viewportViewsMenuWrapper.AddSeparator();
|
||||
|
||||
if (CViewManager::IsMultiViewportEnabled())
|
||||
{
|
||||
viewportViewsMenuWrapper.AddAction(ID_VIEW_CONFIGURELAYOUT);
|
||||
@@ -1234,22 +1161,6 @@ void LevelEditorMenuHandler::ClearAll()
|
||||
UpdateMRUFiles();
|
||||
}
|
||||
|
||||
void LevelEditorMenuHandler::ToggleSelection(bool hide)
|
||||
{
|
||||
CCryEditApp::instance()->OnToggleSelection(hide);
|
||||
}
|
||||
|
||||
// Used for showing last hidden objects
|
||||
void LevelEditorMenuHandler::ShowLastHidden()
|
||||
{
|
||||
CSelectionGroup* sel = GetIEditor()->GetSelection();
|
||||
if (!sel->IsEmpty())
|
||||
{
|
||||
CUndo undo("Show Last Hidden");
|
||||
GetIEditor()->GetObjectManager()->ShowLastHiddenObject();
|
||||
}
|
||||
}
|
||||
|
||||
// Used for disabling "Open Recent" menu option
|
||||
void LevelEditorMenuHandler::OnUpdateOpenRecent()
|
||||
{
|
||||
|
||||
@@ -78,8 +78,6 @@ private:
|
||||
void UpdateMRUFiles();
|
||||
|
||||
void ClearAll();
|
||||
void ToggleSelection(bool hide);
|
||||
void ShowLastHidden();
|
||||
void OnUpdateOpenRecent();
|
||||
|
||||
void OnUpdateMacrosMenu();
|
||||
|
||||
+35
-972
File diff suppressed because it is too large
Load Diff
@@ -116,7 +116,6 @@ public:
|
||||
static CCryEditApp* instance();
|
||||
|
||||
bool GetRootEnginePath(QDir& rootEnginePath) const;
|
||||
void OnToggleSelection(bool hide);
|
||||
bool CreateLevel(bool& wasCreateLevelOperationCancelled);
|
||||
void LoadFile(QString fileName);
|
||||
void ForceNextIdleProcessing() { m_bForceProcessIdle = true; }
|
||||
@@ -210,44 +209,29 @@ public:
|
||||
void OnExportSelectedObjects();
|
||||
void OnEditHold();
|
||||
void OnEditFetch();
|
||||
void OnGeneratorsStaticobjects();
|
||||
void OnFileExportToGameNoSurfaceTexture();
|
||||
void OnViewSwitchToGame();
|
||||
void OnViewDeploy();
|
||||
void OnEditSelectAll();
|
||||
void OnEditSelectNone();
|
||||
void OnEditDelete();
|
||||
void DeleteSelectedEntities(bool includeDescendants);
|
||||
void OnMoveObject();
|
||||
void OnRenameObj();
|
||||
void OnSetHeight();
|
||||
void OnEditmodeMove();
|
||||
void OnEditmodeRotate();
|
||||
void OnEditmodeScale();
|
||||
void OnObjectSetArea();
|
||||
void OnObjectSetHeight();
|
||||
void OnUpdateEditmodeMove(QAction* action);
|
||||
void OnUpdateEditmodeRotate(QAction* action);
|
||||
void OnUpdateEditmodeScale(QAction* action);
|
||||
void OnObjectmodifyFreeze();
|
||||
void OnObjectmodifyUnfreeze();
|
||||
void OnUndo();
|
||||
void OnSelectionSave();
|
||||
void OnOpenAssetImporter();
|
||||
void OnSelectionLoad();
|
||||
void OnUpdateSelected(QAction* action);
|
||||
void OnLockSelection();
|
||||
void OnEditLevelData();
|
||||
void OnFileEditLogFile();
|
||||
void OnFileResaveSlices();
|
||||
void OnFileEditEditorini();
|
||||
void OnPreferences();
|
||||
void OnReloadTextures();
|
||||
void OnReloadGeometry();
|
||||
void OnRedo();
|
||||
void OnUpdateRedo(QAction* action);
|
||||
void OnUpdateUndo(QAction* action);
|
||||
void OnGenerateCgfThumbnails();
|
||||
void OnSwitchPhysics();
|
||||
void OnSwitchPhysicsUpdate(QAction* action);
|
||||
void OnSyncPlayer();
|
||||
@@ -299,12 +283,6 @@ private:
|
||||
//! Test mode is a special mode enabled when Editor ran with /test command line.
|
||||
//! In this mode editor starts up, but exit immediately after all initialization.
|
||||
bool m_bTestMode = false;
|
||||
bool m_bPrecacheShaderList = false;
|
||||
bool m_bPrecacheShaders = false;
|
||||
bool m_bPrecacheShadersLevels = false;
|
||||
bool m_bMergeShaders = false;
|
||||
bool m_bStatsShaderList = false;
|
||||
bool m_bStatsShaders = false;
|
||||
//! In this mode editor will load specified cry file, export t, and then close.
|
||||
bool m_bExportMode = false;
|
||||
QString m_exportFile;
|
||||
@@ -386,17 +364,8 @@ private:
|
||||
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
friend struct PythonTestOutputHandler;
|
||||
|
||||
void OnEditHide();
|
||||
void OnUpdateEditHide(QAction* action);
|
||||
void OnEditShowLastHidden();
|
||||
void OnEditUnhideall();
|
||||
void OnEditFreeze();
|
||||
void OnUpdateEditFreeze(QAction* action);
|
||||
void OnEditUnfreezeall();
|
||||
void OnSnap();
|
||||
void OnWireframe();
|
||||
void OnUpdateWireframe(QAction* action);
|
||||
void OnViewGridsettings();
|
||||
void OnViewConfigureLayout();
|
||||
|
||||
// Tag Locations.
|
||||
@@ -431,28 +400,14 @@ private:
|
||||
void OnToolsScriptHelp();
|
||||
void OnViewCycle2dviewport();
|
||||
void OnDisplayGotoPosition();
|
||||
void OnSnapangle();
|
||||
void OnUpdateSnapangle(QAction* action);
|
||||
void OnRuler();
|
||||
void OnUpdateRuler(QAction* action);
|
||||
void OnRotateselectionXaxis();
|
||||
void OnRotateselectionYaxis();
|
||||
void OnRotateselectionZaxis();
|
||||
void OnRotateselectionRotateangle();
|
||||
void OnEditRenameobject();
|
||||
void OnChangemovespeedIncrease();
|
||||
void OnChangemovespeedDecrease();
|
||||
void OnChangemovespeedChangestep();
|
||||
void OnMaterialAssigncurrent();
|
||||
void OnMaterialResettodefault();
|
||||
void OnMaterialGetmaterial();
|
||||
void OnFileSavelevelresources();
|
||||
void OnClearRegistryData();
|
||||
void OnValidatelevel();
|
||||
void OnValidateObjectPositions();
|
||||
void OnToolsPreferences();
|
||||
void OnGraphicsSettings();
|
||||
void OnEditInvertselection();
|
||||
void OnSwitchToDefaultCamera();
|
||||
void OnUpdateSwitchToDefaultCamera(QAction* action);
|
||||
void OnSwitchToSequenceCamera();
|
||||
@@ -461,13 +416,10 @@ private:
|
||||
void OnUpdateSwitchToSelectedCamera(QAction* action);
|
||||
void OnSwitchcameraNext();
|
||||
void OnOpenProceduralMaterialEditor();
|
||||
void OnOpenMaterialEditor();
|
||||
void OnOpenAssetBrowserView();
|
||||
void OnOpenTrackView();
|
||||
void OnOpenAudioControlsEditor();
|
||||
void OnOpenUICanvasEditor();
|
||||
void OnGotoViewportSearch();
|
||||
void OnTimeOfDay();
|
||||
void OnChangeGameSpec(UINT nID);
|
||||
void SetGameSpecCheck(ESystemConfigSpec spec, ESystemConfigPlatform platform, int &nCheck, bool &enable);
|
||||
void OnUpdateGameSpec(QAction* action);
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
// AzFramework
|
||||
#include <AzFramework/Archive/IArchive.h>
|
||||
#include <AzFramework/API/ApplicationAPI.h>
|
||||
#include <AzFramework/API/AtomActiveInterface.h>
|
||||
|
||||
// AzToolsFramework
|
||||
#include <AzToolsFramework/Slice/SliceUtilities.h>
|
||||
@@ -43,7 +42,6 @@
|
||||
#include "Settings.h"
|
||||
|
||||
#include "PluginManager.h"
|
||||
#include "Mission.h"
|
||||
#include "ViewManager.h"
|
||||
#include "DisplaySettings.h"
|
||||
#include "GameEngine.h"
|
||||
@@ -51,20 +49,19 @@
|
||||
#include "CryEdit.h"
|
||||
#include "ActionManager.h"
|
||||
#include "Include/IObjectManager.h"
|
||||
#include "Material/MaterialManager.h"
|
||||
#include "LensFlareEditor/LensFlareManager.h"
|
||||
#include "ErrorReportDialog.h"
|
||||
#include "SurfaceTypeValidator.h"
|
||||
#include "ShaderCache.h"
|
||||
#include "Util/AutoLogTime.h"
|
||||
#include "CheckOutDialog.h"
|
||||
#include "GameExporter.h"
|
||||
#include "MainWindow.h"
|
||||
#include "ITimeOfDay.h"
|
||||
#include "LevelFileDialog.h"
|
||||
#include "StatObjBus.h"
|
||||
|
||||
// LmbrCentral
|
||||
#include <ModernViewportCameraController.h>
|
||||
#include <Atom/RPI.Public/ViewportContext.h>
|
||||
#include <Atom/RPI.Public/ViewportContextBus.h>
|
||||
#include <LmbrCentral/Rendering/EditorLightComponentBus.h> // for LmbrCentral::EditorLightComponentRequestBus
|
||||
|
||||
|
||||
@@ -83,7 +80,7 @@ static const char* kHoldFolder = "$tmp_hold"; // conform to the ignored file typ
|
||||
static const char* kSaveBackupFolder = "_savebackup";
|
||||
static const char* kResizeTempFolder = "$tmp_resize"; // conform to the ignored file types $tmp[0-9]*_ regex
|
||||
|
||||
static const char* kBackupOrTempFolders[] =
|
||||
static const char* kBackupOrTempFolders[] =
|
||||
{
|
||||
kAutoBackupFolder,
|
||||
kHoldFolder,
|
||||
@@ -123,7 +120,6 @@ CCryEditDoc::CCryEditDoc()
|
||||
// The right way would require us to save to the level folder the export status of the
|
||||
// level.
|
||||
, m_boLevelExported(true)
|
||||
, m_mission(NULL)
|
||||
, m_modified(false)
|
||||
, m_envProbeHeight(200.0f)
|
||||
, m_envProbeSliceRelativePath("EngineAssets/Slices/DefaultLevelSetup.slice")
|
||||
@@ -146,7 +142,6 @@ CCryEditDoc::CCryEditDoc()
|
||||
m_environmentTemplate = XmlHelpers::CreateXmlNode("Environment");
|
||||
}
|
||||
|
||||
m_pLevelShaderCache = new CLevelShaderCache;
|
||||
m_bDocumentReady = false;
|
||||
GetIEditor()->SetDocument(this);
|
||||
CLogFile::WriteLine("Document created");
|
||||
@@ -158,9 +153,6 @@ CCryEditDoc::CCryEditDoc()
|
||||
CCryEditDoc::~CCryEditDoc()
|
||||
{
|
||||
GetIEditor()->SetDocument(nullptr);
|
||||
ClearMissions();
|
||||
|
||||
delete m_pLevelShaderCache;
|
||||
|
||||
CLogFile::WriteLine("Document destroyed");
|
||||
|
||||
@@ -255,17 +247,6 @@ bool CCryEditDoc::Save()
|
||||
return OnSaveDocument(GetActivePathName());
|
||||
}
|
||||
|
||||
void CCryEditDoc::ChangeMission()
|
||||
{
|
||||
GetIEditor()->Notify(eNotify_OnMissionChange);
|
||||
|
||||
// Notify listeners.
|
||||
for (std::list<IDocListener*>::iterator it = m_listeners.begin(); it != m_listeners.end(); ++it)
|
||||
{
|
||||
(*it)->OnMissionChange();
|
||||
}
|
||||
}
|
||||
|
||||
void CCryEditDoc::DeleteContents()
|
||||
{
|
||||
m_hasErrors = false;
|
||||
@@ -295,10 +276,6 @@ void CCryEditDoc::DeleteContents()
|
||||
// Delete all objects from Object Manager.
|
||||
GetIEditor()->GetObjectManager()->DeleteAllObjects();
|
||||
|
||||
ClearMissions();
|
||||
|
||||
GetIEditor()->GetGameEngine()->ResetResources();
|
||||
|
||||
// Load scripts data
|
||||
SetModifiedFlag(FALSE);
|
||||
SetModifiedModules(eModifiedNothing);
|
||||
@@ -341,7 +318,6 @@ void CCryEditDoc::Save(TDocMultiArchive& arrXmlAr)
|
||||
if (!isPrefabEnabled)
|
||||
{
|
||||
CAutoDocNotReady autoDocNotReady;
|
||||
QString currentMissionName;
|
||||
|
||||
if (arrXmlAr[DMAS_GENERAL] != NULL)
|
||||
{
|
||||
@@ -356,14 +332,7 @@ void CCryEditDoc::Save(TDocMultiArchive& arrXmlAr)
|
||||
|
||||
// Fog settings ///////////////////////////////////////////////////////
|
||||
SerializeFogSettings((*arrXmlAr[DMAS_GENERAL]));
|
||||
// Serialize Missions //////////////////////////////////////////////////
|
||||
SerializeMissions(arrXmlAr, currentMissionName, false);
|
||||
//! Serialize material manager.
|
||||
GetIEditor()->GetMaterialManager()->Serialize((*arrXmlAr[DMAS_GENERAL]).root, (*arrXmlAr[DMAS_GENERAL]).bLoading);
|
||||
//! Serialize LensFlare manager.
|
||||
GetIEditor()->GetLensFlareManager()->Serialize((*arrXmlAr[DMAS_GENERAL]).root, (*arrXmlAr[DMAS_GENERAL]).bLoading);
|
||||
|
||||
SerializeShaderCache((*arrXmlAr[DMAS_GENERAL_NAMED_DATA]));
|
||||
SerializeNameSelection((*arrXmlAr[DMAS_GENERAL]));
|
||||
}
|
||||
}
|
||||
@@ -408,7 +377,6 @@ void CCryEditDoc::Load(TDocMultiArchive& arrXmlAr, const QString& szFilename)
|
||||
HEAP_CHECK
|
||||
|
||||
CLogFile::FormatLine("Loading from %s...", szFilename.toUtf8().data());
|
||||
QString currentMissionName;
|
||||
QString szLevelPath = Path::GetPath(szFilename);
|
||||
|
||||
{
|
||||
@@ -486,27 +454,9 @@ void CCryEditDoc::Load(TDocMultiArchive& arrXmlAr, const QString& szFilename)
|
||||
Audio::AudioSystemRequestBus::Broadcast(&Audio::AudioSystemRequestBus::Events::PushRequestBlocking, oAudioRequestData);
|
||||
}
|
||||
|
||||
HEAP_CHECK
|
||||
|
||||
if (!isPrefabEnabled)
|
||||
{
|
||||
// multiple missions are no longer supported, only load the current mission (last used)
|
||||
SerializeMissions(arrXmlAr, currentMissionName, false);
|
||||
}
|
||||
|
||||
HEAP_CHECK
|
||||
|
||||
if (GetIEditor()->Get3DEngine())
|
||||
{
|
||||
if (!isPrefabEnabled)
|
||||
{
|
||||
GetIEditor()->Get3DEngine()->LoadCompiledOctreeForEditor();
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
CAutoLogTime logtime("Game Engine level load");
|
||||
GetIEditor()->GetGameEngine()->LoadLevel(currentMissionName, true, true);
|
||||
GetIEditor()->GetGameEngine()->LoadLevel(true, true);
|
||||
}
|
||||
|
||||
if (!isPrefabEnabled)
|
||||
@@ -516,22 +466,6 @@ void CCryEditDoc::Load(TDocMultiArchive& arrXmlAr, const QString& szFilename)
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
(*arrXmlAr[DMAS_GENERAL]).root->getAttr("WaterColor", m_waterColor);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Load materials.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
{
|
||||
CAutoLogTime logtime("Load MaterialManager");
|
||||
GetIEditor()->GetMaterialManager()->Serialize((*arrXmlAr[DMAS_GENERAL]).root, (*arrXmlAr[DMAS_GENERAL]).bLoading);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Load LensFlares.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
{
|
||||
CAutoLogTime logtime("Load Flares");
|
||||
GetIEditor()->GetLensFlareManager()->Serialize((*arrXmlAr[DMAS_GENERAL]).root, (*arrXmlAr[DMAS_GENERAL]).bLoading);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Load View Settings
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -543,32 +477,10 @@ void CCryEditDoc::Load(TDocMultiArchive& arrXmlAr, const QString& szFilename)
|
||||
SerializeFogSettings((*arrXmlAr[DMAS_GENERAL]));
|
||||
}
|
||||
|
||||
{
|
||||
QByteArray str;
|
||||
str = tr("Activating Mission %1").arg(currentMissionName).toUtf8();
|
||||
|
||||
CAutoLogTime logtime(str.data());
|
||||
|
||||
// Select current mission.
|
||||
m_mission = FindMission(currentMissionName);
|
||||
|
||||
if (m_mission)
|
||||
{
|
||||
SyncCurrentMissionContent(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
GetCurrentMission();
|
||||
}
|
||||
}
|
||||
|
||||
ForceSkyUpdate();
|
||||
|
||||
if (!isPrefabEnabled)
|
||||
{
|
||||
// Serialize Shader Cache.
|
||||
CAutoLogTime logtime("Load Level Shader Cache");
|
||||
SerializeShaderCache((*arrXmlAr[DMAS_GENERAL_NAMED_DATA]));
|
||||
}
|
||||
|
||||
{
|
||||
@@ -667,22 +579,13 @@ void CCryEditDoc::SerializeViewSettings(CXmlArchive& xmlAr)
|
||||
view->getAttr(viewerAnglesName.toUtf8().constData(), va);
|
||||
}
|
||||
|
||||
CViewport* pVP = GetIEditor()->GetViewManager()->GetView(i);
|
||||
Matrix34 tm = Matrix34::CreateRotationXYZ(va);
|
||||
tm.SetTranslation(vp);
|
||||
|
||||
if (pVP)
|
||||
auto viewportContextManager = AZ::Interface<AZ::RPI::ViewportContextRequestsInterface>::Get();
|
||||
if (auto viewportContext = viewportContextManager->GetViewportContextById(i))
|
||||
{
|
||||
Matrix34 tm = Matrix34::CreateRotationXYZ(va);
|
||||
tm.SetTranslation(vp);
|
||||
pVP->SetViewTM(tm);
|
||||
}
|
||||
|
||||
// Load grid.
|
||||
auto gridName = QString("Grid%1").arg(useOldViewFormat ? "" : QString::number(i));
|
||||
XmlNodeRef gridNode = xmlAr.root->newChild(gridName.toUtf8().constData());
|
||||
|
||||
if (gridNode)
|
||||
{
|
||||
GetIEditor()->GetViewManager()->GetGrid()->Serialize(gridNode, xmlAr.bLoading);
|
||||
viewportContext->SetCameraTransform(LYTransformToAZTransform(tm));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -709,11 +612,6 @@ void CCryEditDoc::SerializeViewSettings(CXmlArchive& xmlAr)
|
||||
auto viewerAnglesName = QString("ViewerAngles%1").arg(i);
|
||||
view->setAttr(viewerAnglesName.toUtf8().constData(), angles);
|
||||
}
|
||||
|
||||
// Save grid.
|
||||
auto gridName = QString("Grid%1").arg(i);
|
||||
XmlNodeRef gridNode = xmlAr.root->newChild(gridName.toUtf8().constData());
|
||||
GetIEditor()->GetViewManager()->GetGrid()->Serialize(gridNode, xmlAr.bLoading);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -749,127 +647,6 @@ void CCryEditDoc::SerializeFogSettings(CXmlArchive& xmlAr)
|
||||
}
|
||||
}
|
||||
|
||||
void CCryEditDoc::SerializeMissions(TDocMultiArchive& arrXmlAr, QString& currentMissionName, bool bPartsInXml)
|
||||
{
|
||||
bool bLoading = IsLoadingXmlArArray(arrXmlAr);
|
||||
|
||||
if (bLoading)
|
||||
{
|
||||
// Loading
|
||||
CLogFile::WriteLine("Loading missions...");
|
||||
// Clear old layers
|
||||
ClearMissions();
|
||||
// Load shared objects and layers.
|
||||
XmlNodeRef objectsNode = arrXmlAr[DMAS_GENERAL]->root->findChild("Objects");
|
||||
XmlNodeRef objectLayersNode = arrXmlAr[DMAS_GENERAL]->root->findChild("ObjectLayers");
|
||||
// Load the layer count
|
||||
XmlNodeRef node = arrXmlAr[DMAS_GENERAL]->root->findChild("Missions");
|
||||
|
||||
if (!node)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QString current;
|
||||
node->getAttr("Current", current);
|
||||
currentMissionName = current;
|
||||
|
||||
// Read all node
|
||||
for (int i = 0; i < node->getChildCount(); i++)
|
||||
{
|
||||
CXmlArchive ar(*arrXmlAr[DMAS_GENERAL]);
|
||||
ar.root = node->getChild(i);
|
||||
CMission* mission = new CMission(this);
|
||||
mission->Serialize(ar);
|
||||
if (bPartsInXml)
|
||||
{
|
||||
mission->SerializeTimeOfDay(*arrXmlAr[DMAS_TIME_OF_DAY]);
|
||||
mission->SerializeEnvironment(*arrXmlAr[DMAS_ENVIRONMENT]);
|
||||
}
|
||||
else
|
||||
{
|
||||
mission->LoadParts();
|
||||
}
|
||||
|
||||
// Timur[9/11/2002] For backward compatibility with shared objects
|
||||
if (objectsNode)
|
||||
{
|
||||
mission->AddObjectsNode(objectsNode);
|
||||
}
|
||||
if (objectLayersNode)
|
||||
{
|
||||
mission->SetLayersNode(objectLayersNode);
|
||||
}
|
||||
|
||||
AddMission(mission);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Storing
|
||||
CLogFile::WriteLine("Storing missions...");
|
||||
// Save contents of current mission.
|
||||
SyncCurrentMissionContent(false);
|
||||
|
||||
XmlNodeRef node = arrXmlAr[DMAS_GENERAL]->root->newChild("Missions");
|
||||
|
||||
//! Store current mission name.
|
||||
currentMissionName = GetCurrentMission()->GetName();
|
||||
node->setAttr("Current", currentMissionName.toUtf8().data());
|
||||
|
||||
// Write all surface types.
|
||||
for (int i = 0; i < m_missions.size(); i++)
|
||||
{
|
||||
CXmlArchive ar(*arrXmlAr[DMAS_GENERAL]);
|
||||
ar.root = node->newChild("Mission");
|
||||
m_missions[i]->Serialize(ar, false);
|
||||
if (bPartsInXml)
|
||||
{
|
||||
m_missions[i]->SerializeTimeOfDay(*arrXmlAr[DMAS_TIME_OF_DAY]);
|
||||
m_missions[i]->SerializeEnvironment(*arrXmlAr[DMAS_ENVIRONMENT]);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_missions[i]->SaveParts();
|
||||
}
|
||||
}
|
||||
CLogFile::WriteString("Done");
|
||||
}
|
||||
}
|
||||
|
||||
void CCryEditDoc::SerializeShaderCache(CXmlArchive& xmlAr)
|
||||
{
|
||||
if (xmlAr.bLoading)
|
||||
{
|
||||
void* pData = 0;
|
||||
int nSize = 0;
|
||||
|
||||
if (xmlAr.pNamedData->GetDataBlock("ShaderCache", pData, nSize))
|
||||
{
|
||||
if (nSize <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QByteArray str(nSize + 1, 0);
|
||||
memcpy(str.data(), pData, nSize);
|
||||
str[nSize] = 0;
|
||||
m_pLevelShaderCache->LoadBuffer(str);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QString buf;
|
||||
|
||||
m_pLevelShaderCache->SaveBuffer(buf);
|
||||
|
||||
if (!buf.isEmpty())
|
||||
{
|
||||
xmlAr.pNamedData->AddDataBlock("ShaderCache", buf.toUtf8().data(), buf.toUtf8().count());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CCryEditDoc::SerializeNameSelection(CXmlArchive& xmlAr)
|
||||
{
|
||||
IObjectManager* pObjManager = GetIEditor()->GetObjectManager();
|
||||
@@ -1164,7 +941,7 @@ bool CCryEditDoc::OnSaveDocument(const QString& lpszPathName)
|
||||
{
|
||||
DoSaveDocument(lpszPathName, context);
|
||||
saveSuccess = AfterSaveDocument(lpszPathName, context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return saveSuccess;
|
||||
@@ -1436,7 +1213,7 @@ bool CCryEditDoc::SaveLevel(const QString& filename)
|
||||
// Save AZ entities to the editor level.
|
||||
|
||||
bool contentsAllSaved = false; // abort level save if anything within it fails
|
||||
|
||||
|
||||
auto tempFilenameStrData = tempSaveFile.toStdString();
|
||||
auto filenameStrData = fullPathName.toStdString();
|
||||
|
||||
@@ -1458,7 +1235,7 @@ bool CCryEditDoc::SaveLevel(const QString& filename)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
AZStd::vector<AZ::Entity*> editorEntities;
|
||||
AzToolsFramework::EditorEntityContextRequestBus::Broadcast(
|
||||
&AzToolsFramework::EditorEntityContextRequestBus::Events::GetLooseEditorEntities,
|
||||
@@ -1815,7 +1592,7 @@ bool CCryEditDoc::LoadLevel(TDocMultiArchive& arrXmlAr, const QString& absoluteC
|
||||
AzFramework::ApplicationRequests::Bus::BroadcastResult(isPrefabEnabled, &AzFramework::ApplicationRequests::IsPrefabSystemEnabled);
|
||||
|
||||
auto pIPak = GetIEditor()->GetSystem()->GetIPak();
|
||||
|
||||
|
||||
QString folderPath = QFileInfo(absoluteCryFilePath).absolutePath();
|
||||
|
||||
OnStartLevelResourceList();
|
||||
@@ -2108,58 +1885,6 @@ void CCryEditDoc::SaveAutoBackup(bool bForce)
|
||||
isInProgress = false;
|
||||
}
|
||||
|
||||
|
||||
CMission* CCryEditDoc::GetCurrentMission(bool bSkipLoadingAIWhenSyncingContent /* = false */)
|
||||
{
|
||||
if (m_mission)
|
||||
{
|
||||
return m_mission;
|
||||
}
|
||||
|
||||
if (!m_missions.empty())
|
||||
{
|
||||
// Choose first available mission.
|
||||
SetCurrentMission(m_missions[0]);
|
||||
return m_mission;
|
||||
}
|
||||
|
||||
// Create initial mission.
|
||||
m_mission = new CMission(this);
|
||||
m_mission->SetName("Mission0");
|
||||
AddMission(m_mission);
|
||||
m_mission->SyncContent(true, false, bSkipLoadingAIWhenSyncingContent);
|
||||
return m_mission;
|
||||
}
|
||||
|
||||
void CCryEditDoc::SetCurrentMission(CMission* mission)
|
||||
{
|
||||
if (mission != m_mission)
|
||||
{
|
||||
QWaitCursor wait;
|
||||
|
||||
if (m_mission)
|
||||
{
|
||||
m_mission->SyncContent(false, false);
|
||||
}
|
||||
|
||||
m_mission = mission;
|
||||
m_mission->SyncContent(true, false);
|
||||
|
||||
GetIEditor()->GetGameEngine()->LoadMission(m_mission->GetName());
|
||||
}
|
||||
}
|
||||
|
||||
void CCryEditDoc::ClearMissions()
|
||||
{
|
||||
for (int i = 0; i < m_missions.size(); i++)
|
||||
{
|
||||
delete m_missions[i];
|
||||
}
|
||||
|
||||
m_missions.clear();
|
||||
m_mission = 0;
|
||||
}
|
||||
|
||||
bool CCryEditDoc::IsLevelExported() const
|
||||
{
|
||||
return m_boLevelExported;
|
||||
@@ -2170,37 +1895,6 @@ void CCryEditDoc::SetLevelExported(bool boExported)
|
||||
m_boLevelExported = boExported;
|
||||
}
|
||||
|
||||
CMission* CCryEditDoc::FindMission(const QString& name) const
|
||||
{
|
||||
for (int i = 0; i < m_missions.size(); i++)
|
||||
{
|
||||
if (QString::compare(name, m_missions[i]->GetName(), Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
return m_missions[i];
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CCryEditDoc::AddMission(CMission* mission)
|
||||
{
|
||||
assert(std::find(m_missions.begin(), m_missions.end(), mission) == m_missions.end());
|
||||
m_missions.push_back(mission);
|
||||
GetIEditor()->Notify(eNotify_OnInvalidateControls);
|
||||
}
|
||||
|
||||
void CCryEditDoc::RemoveMission(CMission* mission)
|
||||
{
|
||||
// if deleting current mission.
|
||||
if (mission == m_mission)
|
||||
{
|
||||
m_mission = 0;
|
||||
}
|
||||
|
||||
m_missions.erase(std::find(m_missions.begin(), m_missions.end(), mission));
|
||||
GetIEditor()->Notify(eNotify_OnInvalidateControls);
|
||||
}
|
||||
|
||||
void CCryEditDoc::RegisterListener(IDocListener* listener)
|
||||
{
|
||||
if (listener == nullptr)
|
||||
@@ -2306,19 +2000,6 @@ void CCryEditDoc::OnStartLevelResourceList()
|
||||
gEnv->pCryPak->GetResourceList(AZ::IO::IArchive::RFOM_Level)->Clear();
|
||||
}
|
||||
|
||||
void CCryEditDoc::ForceSkyUpdate()
|
||||
{
|
||||
ITimeOfDay* pTimeOfDay = gEnv->p3DEngine ? gEnv->p3DEngine->GetTimeOfDay() : nullptr;
|
||||
CMission* pCurMission = GetIEditor()->GetDocument()->GetCurrentMission();
|
||||
|
||||
if (pTimeOfDay && pCurMission)
|
||||
{
|
||||
pTimeOfDay->SetTime(pCurMission->GetTime(), gSettings.bForceSkyUpdate);
|
||||
pCurMission->SetTime(pCurMission->GetTime());
|
||||
GetIEditor()->Notify(eNotify_OnTimeOfDayChange);
|
||||
}
|
||||
}
|
||||
|
||||
BOOL CCryEditDoc::DoFileSave()
|
||||
{
|
||||
if (GetEditMode() == CCryEditDoc::DocumentEditingMode::LevelEdit)
|
||||
@@ -2380,26 +2061,11 @@ void CCryEditDoc::InitEmptyLevel(int /*resolution*/, int /*unitSize*/, bool /*bU
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
if (!GetIEditor()->IsInPreviewMode())
|
||||
{
|
||||
// Make new mission.
|
||||
GetIEditor()->ReloadTemplates();
|
||||
m_environmentTemplate = GetIEditor()->FindTemplate("Environment");
|
||||
|
||||
GetCurrentMission(true); // true = skip loading the AI in case the content needs to get synchronized (otherwise it would attempt to load AI stuff from the previously loaded level (!) which might give confusing warnings)
|
||||
GetIEditor()->GetGameEngine()->SetMissionName(GetCurrentMission()->GetName());
|
||||
GetIEditor()->GetGameEngine()->SetLevelCreated(true);
|
||||
GetIEditor()->GetGameEngine()->ReloadEnvironment();
|
||||
GetIEditor()->GetGameEngine()->SetLevelCreated(false);
|
||||
|
||||
// Default time of day.
|
||||
XmlNodeRef root = GetISystem()->LoadXmlFromFile("@engroot@/Editor/default_time_of_day.xml");
|
||||
if (root)
|
||||
{
|
||||
ITimeOfDay* pTimeOfDay = gEnv->p3DEngine ? gEnv->p3DEngine->GetTimeOfDay() : nullptr;
|
||||
if (pTimeOfDay)
|
||||
{
|
||||
pTimeOfDay->Serialize(root, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
@@ -2425,44 +2091,9 @@ void CCryEditDoc::InitEmptyLevel(int /*resolution*/, int /*unitSize*/, bool /*bU
|
||||
GetIEditor()->SetStatusText("Ready");
|
||||
}
|
||||
|
||||
void CCryEditDoc::CreateDefaultLevelAssets(int resolution, int unitSize)
|
||||
void CCryEditDoc::CreateDefaultLevelAssets([[maybe_unused]] int resolution, [[maybe_unused]] int unitSize)
|
||||
{
|
||||
if (AZ::Interface<AzFramework::AtomActiveInterface>::Get())
|
||||
{
|
||||
AzToolsFramework::EditorLevelNotificationBus::Broadcast(&AzToolsFramework::EditorLevelNotificationBus::Events::OnNewLevelCreated);
|
||||
}
|
||||
else
|
||||
{
|
||||
bool isPrefabSystemEnabled = false;
|
||||
AzFramework::ApplicationRequests::Bus::BroadcastResult(
|
||||
isPrefabSystemEnabled, &AzFramework::ApplicationRequests::IsPrefabSystemEnabled);
|
||||
|
||||
if (!isPrefabSystemEnabled)
|
||||
{
|
||||
AZ::Data::AssetCatalogRequestBus::BroadcastResult(
|
||||
m_envProbeSliceAssetId, &AZ::Data::AssetCatalogRequests::GetAssetIdByPath, m_envProbeSliceRelativePath,
|
||||
azrtti_typeid<AZ::SliceAsset>(), false);
|
||||
|
||||
if (m_envProbeSliceAssetId.IsValid())
|
||||
{
|
||||
AZ::Data::Asset<AZ::Data::AssetData> asset = AZ::Data::AssetManager::Instance().FindOrCreateAsset<AZ::SliceAsset>(
|
||||
m_envProbeSliceAssetId, AZ::Data::AssetLoadBehavior::Default);
|
||||
if (asset)
|
||||
{
|
||||
m_terrainSize = resolution * unitSize;
|
||||
const float halfTerrainSize = m_terrainSize / 2.0f;
|
||||
|
||||
AZ::Transform worldTransform = AZ::Transform::CreateIdentity();
|
||||
worldTransform = AZ::Transform::CreateTranslation(AZ::Vector3(halfTerrainSize, halfTerrainSize, m_envProbeHeight / 2));
|
||||
|
||||
AzToolsFramework::SliceEditorEntityOwnershipServiceNotificationBus::Handler::BusConnect();
|
||||
GetIEditor()->SuspendUndo();
|
||||
AzToolsFramework::SliceEditorEntityOwnershipServiceRequestBus::Broadcast(
|
||||
&AzToolsFramework::SliceEditorEntityOwnershipServiceRequests::InstantiateEditorSlice, asset, worldTransform);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
AzToolsFramework::EditorLevelNotificationBus::Broadcast(&AzToolsFramework::EditorLevelNotificationBus::Events::OnNewLevelCreated);
|
||||
}
|
||||
|
||||
void CCryEditDoc::OnEnvironmentPropertyChanged(IVariable* pVar)
|
||||
@@ -2522,8 +2153,6 @@ void CCryEditDoc::OnEnvironmentPropertyChanged(IVariable* pVar)
|
||||
pVar->Get(value);
|
||||
childNode->setAttr("value", value.toUtf8().data());
|
||||
}
|
||||
|
||||
GetIEditor()->GetGameEngine()->ReloadEnvironment();
|
||||
}
|
||||
|
||||
QString CCryEditDoc::GetCryIndexPath(const LPCTSTR levelFilePath)
|
||||
@@ -2576,12 +2205,6 @@ void CCryEditDoc::ReleaseXmlArchiveArray(TDocMultiArchive& arrXmlAr)
|
||||
SAFE_DELETE(arrXmlAr[0]);
|
||||
}
|
||||
|
||||
|
||||
void CCryEditDoc::SyncCurrentMissionContent(bool bRetrieve)
|
||||
{
|
||||
GetCurrentMission()->SyncContent(bRetrieve, false);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// AzToolsFramework::EditorEntityContextNotificationBus interface implementation
|
||||
void CCryEditDoc::OnSliceInstantiated(const AZ::Data::AssetId& sliceAssetId, AZ::SliceComponent::SliceInstanceAddress& sliceAddress, const AzFramework::SliceInstantiationTicket& /*ticket*/)
|
||||
@@ -2613,7 +2236,7 @@ void CCryEditDoc::OnSliceInstantiated(const AZ::Data::AssetId& sliceAssetId, AZ:
|
||||
sliceAddress.SetReference(nullptr);
|
||||
SetModifiedFlag(true);
|
||||
SetModifiedModules(eModifiedEntities);
|
||||
|
||||
|
||||
AzToolsFramework::SliceEditorEntityOwnershipServiceNotificationBus::Handler::BusDisconnect();
|
||||
|
||||
//save after level default slice fully instantiated
|
||||
|
||||
@@ -22,8 +22,6 @@
|
||||
#include <TimeValue.h>
|
||||
#endif
|
||||
|
||||
class CMission;
|
||||
class CLevelShaderCache;
|
||||
class CClouds;
|
||||
struct LightingSettings;
|
||||
struct IVariable;
|
||||
@@ -124,19 +122,6 @@ public: // Create from serialization only
|
||||
const char* GetTemporaryLevelName() const;
|
||||
void DeleteTemporaryLevel();
|
||||
|
||||
void ChangeMission();
|
||||
//! Return currently active Mission.
|
||||
CMission* GetCurrentMission(bool bSkipLoadingAIWhenSyncingContent = false);
|
||||
//! Get number of missions on Map.
|
||||
int GetMissionCount() const { return m_missions.size(); }
|
||||
//! Get Mission by index.
|
||||
CMission* GetMission(int index) const { return m_missions[index]; }
|
||||
//! Find Mission by name.
|
||||
CMission* FindMission(const QString& name) const;
|
||||
//! Makes specified mission current.
|
||||
void SetCurrentMission(CMission* mission);
|
||||
|
||||
CLevelShaderCache* GetShaderCache() { return m_pLevelShaderCache; }
|
||||
CClouds* GetClouds() { return m_pClouds; }
|
||||
void SetWaterColor(const QColor& col) { m_waterColor = col; }
|
||||
QColor GetWaterColor() { return m_waterColor; }
|
||||
@@ -167,7 +152,6 @@ protected:
|
||||
|
||||
virtual void Load(TDocMultiArchive& arrXmlAr, const QString& szFilename);
|
||||
virtual void StartStreamingLoad(){}
|
||||
virtual void SyncCurrentMissionContent(bool bRetrieve);
|
||||
|
||||
void Save(CXmlArchive& xmlAr);
|
||||
void Load(CXmlArchive& xmlAr, const QString& szFilename);
|
||||
@@ -179,14 +163,7 @@ protected:
|
||||
bool LoadEntitiesFromSlice(const QString& sliceFile);
|
||||
void SerializeFogSettings(CXmlArchive& xmlAr);
|
||||
virtual void SerializeViewSettings(CXmlArchive& xmlAr);
|
||||
void SerializeMissions(TDocMultiArchive& arrXmlAr, QString& currentMission, bool bPartsInXml);
|
||||
void SerializeShaderCache(CXmlArchive& xmlAr);
|
||||
void SerializeNameSelection(CXmlArchive& xmlAr);
|
||||
void ForceSkyUpdate();
|
||||
//! Add new mission to map.
|
||||
void AddMission(CMission* mission);
|
||||
//! Remove existing mission from map.
|
||||
void RemoveMission(CMission* mission);
|
||||
void LogLoadTime(int time);
|
||||
|
||||
struct TSaveDocContext
|
||||
@@ -200,10 +177,8 @@ protected:
|
||||
|
||||
virtual bool OnSaveDocument(const QString& lpszPathName);
|
||||
virtual void OnFileSaveAs();
|
||||
void LoadTemplates();
|
||||
//! called immediately after saving the level.
|
||||
void AfterSave();
|
||||
void ClearMissions();
|
||||
void RegisterConsoleVariables();
|
||||
void OnStartLevelResourceList();
|
||||
static void OnValidateSurfaceTypesChanged(ICVar*);
|
||||
@@ -220,12 +195,9 @@ protected:
|
||||
QColor m_waterColor;
|
||||
XmlNodeRef m_fogTemplate;
|
||||
XmlNodeRef m_environmentTemplate;
|
||||
CMission* m_mission;
|
||||
CClouds* m_pClouds;
|
||||
std::vector<CMission*> m_missions;
|
||||
std::list<IDocListener*> m_listeners;
|
||||
bool m_bDocumentReady;
|
||||
CLevelShaderCache* m_pLevelShaderCache;
|
||||
ICVar* doc_validate_surface_types;
|
||||
int m_modifiedModuleFlags;
|
||||
bool m_boLevelExported;
|
||||
|
||||
@@ -27,6 +27,7 @@ AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
|
||||
#define MIN_RES 64
|
||||
#define MAX_RES 8192
|
||||
|
||||
CCustomResolutionDlg::CCustomResolutionDlg(int w, int h, QWidget* pParent /*=NULL*/)
|
||||
: QDialog(pParent)
|
||||
@@ -46,18 +47,17 @@ CCustomResolutionDlg::~CCustomResolutionDlg()
|
||||
|
||||
void CCustomResolutionDlg::OnInitDialog()
|
||||
{
|
||||
int maxRes = GetIEditor()->GetRenderer()->GetMaxSquareRasterDimension();
|
||||
m_ui->m_width->setRange(MIN_RES, maxRes);
|
||||
m_ui->m_width->setRange(MIN_RES, MAX_RES);
|
||||
m_ui->m_width->setValue(m_wDefault);
|
||||
|
||||
m_ui->m_height->setRange(MIN_RES, maxRes);
|
||||
m_ui->m_height->setRange(MIN_RES, MAX_RES);
|
||||
m_ui->m_height->setValue(m_hDefault);
|
||||
|
||||
QString maxDimensionString;
|
||||
QTextStream(&maxDimensionString)
|
||||
<< "Maximum Dimension: " << maxRes << Qt::endl
|
||||
<< "Maximum Dimension: " << MAX_RES << Qt::endl
|
||||
<< Qt::endl
|
||||
<< "Note: Dimensions over 4K may be" << Qt::endl
|
||||
<< "Note: Dimensions over 8K may be" << Qt::endl
|
||||
<< "unstable depending on hardware.";
|
||||
|
||||
m_ui->m_maxDimension->setText(maxDimensionString);
|
||||
|
||||
@@ -60,4 +60,4 @@ private:
|
||||
QStringList BuildModels(QWidget* parent);
|
||||
};
|
||||
|
||||
#endif //CRYINCLUDE_EDITOR_CUSTOMIZE_KEYBOARD_DIALOG_H
|
||||
#endif //CRYINCLUDE_EDITOR_CUSTOMIZE_KEYBOARD_DIALOG_H
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,250 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#pragma once
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Crytek Engine Source File.
|
||||
// Copyright (C), Crytek Studios, 2011.
|
||||
// -------------------------------------------------------------------------
|
||||
// File name: DatabaseFrameWnd.h
|
||||
// Created: 10/Dec/2012 by Jaesik.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef CRYINCLUDE_EDITOR_DATABASEFRAMEWND_H
|
||||
#define CRYINCLUDE_EDITOR_DATABASEFRAMEWND_H
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include <AzToolsFramework/AssetBrowser/AssetSelectionModel.h>
|
||||
#include <AzQtComponents/Components/DockMainWindow.h>
|
||||
#include "Undo/IUndoManagerListener.h"
|
||||
#include "BaseLibrary.h"
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QAbstractItemModel>
|
||||
#include <QAbstractListModel>
|
||||
#include <QScopedPointer>
|
||||
#endif
|
||||
|
||||
class QComboBox;
|
||||
class QTreeView;
|
||||
class QMimeData;
|
||||
|
||||
class CBaseLibraryItem;
|
||||
class CBaseLibraryManager;
|
||||
|
||||
class LibraryListModel;
|
||||
class LibraryItemTreeModel;
|
||||
|
||||
namespace Ui {
|
||||
class DatabaseFrameWnd;
|
||||
}
|
||||
|
||||
class CDatabaseFrameWnd
|
||||
: public AzQtComponents::DockMainWindow
|
||||
, public IEditorNotifyListener
|
||||
, public IUndoManagerListener
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CDatabaseFrameWnd(CBaseLibraryManager* pItemManager, QWidget* pParent = nullptr);
|
||||
virtual ~CDatabaseFrameWnd();
|
||||
|
||||
enum SortRecursionType
|
||||
{
|
||||
SORT_RECURSION_NONE = 1,
|
||||
SORT_RECURSION_ITEM = 2,
|
||||
SORT_RECURSION_FULL = 9999
|
||||
};
|
||||
|
||||
virtual void ReloadLibs();
|
||||
virtual void ReloadItems();
|
||||
virtual void SelectLibrary(const QString& library, bool bForceSelect = false);
|
||||
virtual void SelectLibrary(CBaseLibrary* pItem, bool bForceSelect = false);
|
||||
virtual void SelectItem(CBaseLibraryItem* item, bool bForceReload = false);
|
||||
|
||||
virtual CBaseLibrary* FindLibrary(const QString& libraryName);
|
||||
virtual CBaseLibrary* NewLibrary(const QString& libraryName);
|
||||
virtual void DeleteLibrary(CBaseLibrary* pLibrary);
|
||||
virtual void DeleteItem(CBaseLibraryItem* pItem);
|
||||
|
||||
virtual void ReleasePreviewControl(){}
|
||||
|
||||
virtual bool SetItemName(CBaseLibraryItem* item, const QString& groupName, const QString& itemName);
|
||||
|
||||
void DoesItemExist(const QString& itemName, bool& bOutExist) const;
|
||||
void DoesGroupExist(const QString& groupName, bool& bOutExist) const;
|
||||
|
||||
virtual void OnEditorNotifyEvent(EEditorNotifyEvent event) override;
|
||||
|
||||
void SignalNumUndoRedo(const unsigned int& numUndo, const unsigned int& numRedo) override;
|
||||
|
||||
QString GetSelectedLibraryName() const;
|
||||
|
||||
virtual const char* GetClassName() = 0;
|
||||
|
||||
protected:
|
||||
int GetComboBoxIndex(CBaseLibrary* pLibrary);
|
||||
|
||||
virtual void OnInitDialog() = 0;
|
||||
|
||||
void showEvent(QShowEvent* event) override;
|
||||
|
||||
void OnUndo();
|
||||
void OnRedo();
|
||||
|
||||
virtual void OnAddLibrary();
|
||||
virtual void OnRemoveLibrary();
|
||||
virtual void OnAddItem();
|
||||
virtual void OnRemoveItem();
|
||||
virtual void OnRenameItem();
|
||||
virtual void OnChangedLibrary();
|
||||
virtual void OnExportLibrary();
|
||||
virtual void OnSave();
|
||||
virtual void OnReloadLib();
|
||||
virtual void OnLoadLibrary();
|
||||
|
||||
void OnSelChangedItemTree(const QModelIndex& index);
|
||||
bool eventFilter(QObject* watched, QEvent* event);
|
||||
|
||||
virtual void OnCopy() = 0;
|
||||
virtual void OnPaste() = 0;
|
||||
virtual void OnCut();
|
||||
virtual void OnClone();
|
||||
|
||||
void InitTreeCtrl();
|
||||
|
||||
virtual AssetSelectionModel GetAssetSelectionModel() const = 0;
|
||||
|
||||
void LoadLibrary();
|
||||
|
||||
QString MakeValidName(const QString& candidateName, AZStd::function<void(const QString&, bool&)> cb) const;
|
||||
|
||||
virtual QTreeView* GetTreeCtrl() = 0;
|
||||
virtual const QTreeView* GetTreeCtrl() const = 0;
|
||||
|
||||
private:
|
||||
LibraryListModel* m_pLibraryListModel;
|
||||
QComboBox* m_pLibraryListComboBox;
|
||||
|
||||
bool m_bLibsLoaded;
|
||||
|
||||
protected:
|
||||
LibraryItemTreeModel* m_pLibraryItemTreeModel;
|
||||
|
||||
//! Selected library.
|
||||
_smart_ptr<CBaseLibrary> m_pLibrary;
|
||||
|
||||
//! Last selected Item. (kept here for compatibility reasons)
|
||||
// See comments on m_cpoSelectedLibraryItems for more details.
|
||||
_smart_ptr<CBaseLibraryItem> m_pCurrentItem;
|
||||
|
||||
// A set containing all the currently selected items
|
||||
// (it's disabled for MOST, but not ALL cases).
|
||||
// This should be the new standard way of storing selections as
|
||||
// opposed to the former mean, it allows us to store multiple selections.
|
||||
// The migration to this new style should be done according to the needs
|
||||
// for multiple selection.
|
||||
std::set<CBaseLibraryItem*> m_cpoSelectedLibraryItems;
|
||||
|
||||
//! Pointer to item manager.
|
||||
CBaseLibraryManager* m_pItemManager;
|
||||
SortRecursionType m_sortRecursionType;
|
||||
QString m_selectedGroup;
|
||||
|
||||
QScopedPointer<Ui::DatabaseFrameWnd> ui;
|
||||
|
||||
bool m_initialized;
|
||||
};
|
||||
|
||||
class LibraryListModel
|
||||
: public QAbstractListModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
LibraryListModel(CBaseLibraryManager* itemManager, QObject* pParent = nullptr);
|
||||
|
||||
int rowCount(const QModelIndex& parent = {}) const override;
|
||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
|
||||
|
||||
void Reload();
|
||||
|
||||
void clear();
|
||||
|
||||
private:
|
||||
void LibraryModified(bool bModified);
|
||||
|
||||
CBaseLibraryManager* m_pItemManager;
|
||||
};
|
||||
|
||||
class LibraryItemTreeModel
|
||||
: public QAbstractItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
using Group = std::pair<QString, std::vector<CBaseLibraryItem*> >;
|
||||
|
||||
public:
|
||||
LibraryItemTreeModel(CDatabaseFrameWnd* pParent);
|
||||
|
||||
QModelIndex parent(const QModelIndex& index) const override;
|
||||
QModelIndex index(int row, int column, const QModelIndex& parent = {}) const override;
|
||||
QModelIndex index(CBaseLibraryItem* pItem) const;
|
||||
|
||||
int rowCount(const QModelIndex& parent) const override;
|
||||
int columnCount(const QModelIndex& parent) const override;
|
||||
|
||||
Qt::ItemFlags flags(const QModelIndex& index) const override;
|
||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
|
||||
bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
|
||||
|
||||
bool removeRows(int row, int count, const QModelIndex& parent = {}) override;
|
||||
|
||||
QStringList mimeTypes() const override;
|
||||
bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent) override;
|
||||
QMimeData* mimeData(const QModelIndexList& indexes) const override;
|
||||
|
||||
Qt::DropActions supportedDragActions() const override;
|
||||
Qt::DropActions supportedDropActions() const override;
|
||||
|
||||
void Clear();
|
||||
|
||||
void Reload(CBaseLibrary* library);
|
||||
|
||||
void Add(CBaseLibraryItem* item);
|
||||
bool Remove(CBaseLibraryItem* item);
|
||||
|
||||
void Rename(CBaseLibraryItem* item, const QString& groupName, const QString& shortName);
|
||||
|
||||
std::vector<CBaseLibraryItem*> ChildItems(const QModelIndex& index) const;
|
||||
|
||||
QString GetFullName(const QModelIndex& index) const;
|
||||
|
||||
QModelIndex FindLibraryItemByFullName(const QString& fullName) const;
|
||||
bool DoesGroupExist(const QString& groupName) const;
|
||||
|
||||
signals:
|
||||
void itemRenamed(CBaseLibraryItem* item, const QString& prevFullName);
|
||||
|
||||
protected:
|
||||
void RenameItem(CBaseLibraryItem* item, const QString& fullName);
|
||||
QString MakeValidName(const Group& group, const QString& baseName) const;
|
||||
bool MoveItem(CBaseLibraryItem* item, const QModelIndex& parent);
|
||||
|
||||
CDatabaseFrameWnd* m_dialog;
|
||||
|
||||
std::map<QString, std::shared_ptr<Group> > m_groups;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(CBaseLibrary*)
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_DATABASEFRAMEWND_H
|
||||
@@ -1,35 +0,0 @@
|
||||
<RCC>
|
||||
<qresource prefix="/DatabaseFrameWnd">
|
||||
<file alias="db_library_bar_00.png">res/db_library_bar_00.png</file>
|
||||
<file alias="db_library_bar_01.png">res/db_library_bar_01.png</file>
|
||||
<file alias="db_library_bar_02.png">res/db_library_bar_02.png</file>
|
||||
<file alias="db_library_bar_03.png">res/db_library_bar_03.png</file>
|
||||
<file alias="db_library_bar_04.png">res/db_library_bar_04.png</file>
|
||||
<file alias="db_library_bar_05.png">res/db_library_bar_05.png</file>
|
||||
<file alias="db_standart_00.png">res/db_standart_00.png</file>
|
||||
<file alias="db_standart_01.png">res/db_standart_01.png</file>
|
||||
<file alias="db_standart_02.png">res/db_standart_02.png</file>
|
||||
<file alias="db_standart_03.png">res/db_standart_03.png</file>
|
||||
<file alias="db_library_item_bar_00.png">res/db_library_item_bar_00.png</file>
|
||||
<file alias="db_library_item_bar_01.png">res/db_library_item_bar_01.png</file>
|
||||
<file alias="db_library_item_bar_02.png">res/db_library_item_bar_02.png</file>
|
||||
<file alias="db_library_item_bar_03.png">res/db_library_item_bar_03.png</file>
|
||||
<file alias="db_library_item_bar_04.png">res/db_library_item_bar_04.png</file>
|
||||
<file alias="db_library_item_bar_05.png">res/db_library_item_bar_05.png</file>
|
||||
<file alias="db_library_open.svg">res/db_library_open.svg</file>
|
||||
<file alias="db_library_save.svg">res/db_library_save.svg</file>
|
||||
<file alias="db_library_add.svg">res/db_library_add.svg</file>
|
||||
<file alias="db_library_delete.svg">res/db_library_delete.svg</file>
|
||||
<file alias="db_library_refresh.svg">res/db_library_refresh.svg</file>
|
||||
<file alias="db_library_undo.svg">res/db_library_undo.svg</file>
|
||||
<file alias="db_library_redo.svg">res/db_library_redo.svg</file>
|
||||
<file alias="db_library_copy.svg">res/db_library_copy.svg</file>
|
||||
<file alias="db_library_paste.svg">res/db_library_paste.svg</file>
|
||||
<file alias="db_library_additem.svg">res/db_library_additem.svg</file>
|
||||
<file alias="db_library_cloneitem.svg">res/db_library_cloneitem.svg</file>
|
||||
<file alias="db_library_removeitem.svg">res/db_library_removeitem.svg</file>
|
||||
<file alias="db_library_assignitem.svg">res/db_library_assignitem.svg</file>
|
||||
<file alias="db_library_getproperties.svg">res/db_library_getproperties.svg</file>
|
||||
<file alias="db_library_reload.svg">res/db_library_reload.svg</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
@@ -1,279 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>DatabaseFrameWnd</class>
|
||||
<widget class="QMainWindow" name="DatabaseFrameWnd">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>633</width>
|
||||
<height>42</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QToolBar" name="m_toolBar">
|
||||
<property name="windowTitle">
|
||||
<string>Lens Flare Toolbar</string>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="floatable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<addaction name="actionDBLoadLib"/>
|
||||
<addaction name="actionDBSave"/>
|
||||
<addaction name="actionDBAddLib"/>
|
||||
<addaction name="actionDBDelLib"/>
|
||||
<addaction name="actionDBReloadLib"/>
|
||||
</widget>
|
||||
<widget class="QToolBar" name="m_toolBar2">
|
||||
<property name="windowTitle">
|
||||
<string>StandartToolBar</string>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="floatable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<addaction name="actionUndo"/>
|
||||
<addaction name="actionRedo"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionDBCopy"/>
|
||||
<addaction name="actionDBPaste"/>
|
||||
</widget>
|
||||
<widget class="QToolBar" name="m_toolBar3">
|
||||
<property name="windowTitle">
|
||||
<string>ItemToolBar</string>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="floatable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<addaction name="actionDBAdd"/>
|
||||
<addaction name="actionDBClone"/>
|
||||
<addaction name="actionDBRemove"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionDBAssignToSelection"/>
|
||||
<addaction name="actionDBGetFromSelection"/>
|
||||
<addaction name="actionDBReload"/>
|
||||
</widget>
|
||||
<action name="actionDBLoadLib">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/DatabaseFrameWnd/db_library_open.svg</normaloff>:/DatabaseFrameWnd/db_library_open.svg</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Load Library</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Load Library</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDBSave">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/DatabaseFrameWnd/db_library_save.svg</normaloff>:/DatabaseFrameWnd/db_library_save.svg</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save Modified Libraries</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Save Modified Libraries</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDBAddLib">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/DatabaseFrameWnd/db_library_add.svg</normaloff>:/DatabaseFrameWnd/db_library_add.svg</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add Library</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Add Library</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDBDelLib">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/DatabaseFrameWnd/db_library_delete.svg</normaloff>:/DatabaseFrameWnd/db_library_delete.svg</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Remove Library</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Remove Library</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDBReloadLib">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/DatabaseFrameWnd/db_library_refresh.svg</normaloff>:/DatabaseFrameWnd/db_library_refresh.svg</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Reload Library</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Reload Library</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionUndo">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/DatabaseFrameWnd/db_library_undo.svg</normaloff>:/DatabaseFrameWnd/db_library_undo.svg</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Undo last operation</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Undo</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionRedo">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/DatabaseFrameWnd/db_library_redo.svg</normaloff>:/DatabaseFrameWnd/db_library_redo.svg</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Redo last undo operation</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Redo</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDBCopy">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/DatabaseFrameWnd/db_library_copy.svg</normaloff>:/DatabaseFrameWnd/db_library_copy.svg</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Copy Item</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Copy Item</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDBPaste">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/DatabaseFrameWnd/db_library_paste.svg</normaloff>:/DatabaseFrameWnd/db_library_paste.svg</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Paste Item</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Paste Item</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDBAdd">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/DatabaseFrameWnd/db_library_additem.svg</normaloff>:/DatabaseFrameWnd/db_library_additem.svg</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add New Item</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Add New Item</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDBClone">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/DatabaseFrameWnd/db_library_cloneitem.svg</normaloff>:/DatabaseFrameWnd/db_library_cloneitem.svg</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Clone Library Item</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Clone Library Item</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDBRemove">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/DatabaseFrameWnd/db_library_removeitem.svg</normaloff>:/DatabaseFrameWnd/db_library_removeitem.svg</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Remove Item</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Remove Item</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDBAssignToSelection">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/DatabaseFrameWnd/db_library_assignitem.svg</normaloff>:/DatabaseFrameWnd/db_library_assignitem.svg</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Assign Item to Selected Objects</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Assign Item to Selected Objects</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDBGetFromSelection">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/DatabaseFrameWnd/db_library_getproperties.svg</normaloff>:/DatabaseFrameWnd/db_library_getproperties.svg</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Get Properties From Selection</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Get Properties From Selection</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDBReload">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/DatabaseFrameWnd/db_library_reload.svg</normaloff>:/DatabaseFrameWnd/db_library_reload.svg</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Reload Item</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Reload Item</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#include "EditorDefs.h"
|
||||
|
||||
#include "DuplicatedObjectsHandlerDlg.h"
|
||||
|
||||
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
#include <Dialogs/ui_DuplicatedObjectsHandlerDlg.h>
|
||||
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
|
||||
|
||||
CDuplicatedObjectsHandlerDlg::CDuplicatedObjectsHandlerDlg(const QString& msg, QWidget* pParent)
|
||||
: QDialog(pParent)
|
||||
, m_ui(new Ui::DuplicatedObjectsHandlerDlg)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
m_ui->textBrowser->setPlainText(msg);
|
||||
|
||||
connect(m_ui->buttonOverride, &QPushButton::clicked, this, &CDuplicatedObjectsHandlerDlg::OnBnClickedOverrideBtn);
|
||||
connect(m_ui->buttonCreateCopies, &QPushButton::clicked, this, &CDuplicatedObjectsHandlerDlg::OnBnClickedCreateCopiesBtn);
|
||||
}
|
||||
|
||||
CDuplicatedObjectsHandlerDlg::~CDuplicatedObjectsHandlerDlg()
|
||||
{
|
||||
}
|
||||
|
||||
void CDuplicatedObjectsHandlerDlg::OnBnClickedOverrideBtn()
|
||||
{
|
||||
m_result = eResult_Override;
|
||||
accept();
|
||||
}
|
||||
|
||||
void CDuplicatedObjectsHandlerDlg::OnBnClickedCreateCopiesBtn()
|
||||
{
|
||||
m_result = eResult_CreateCopies;
|
||||
accept();
|
||||
}
|
||||
|
||||
#include <Dialogs/moc_DuplicatedObjectsHandlerDlg.cpp>
|
||||
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_DIALOGS_DUPLICATEDOBJECTSHANDLERDLG_H
|
||||
#define CRYINCLUDE_EDITOR_DIALOGS_DUPLICATEDOBJECTSHANDLERDLG_H
|
||||
#pragma once
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include <QDialog>
|
||||
#endif
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class DuplicatedObjectsHandlerDlg;
|
||||
}
|
||||
|
||||
class CDuplicatedObjectsHandlerDlg
|
||||
: public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CDuplicatedObjectsHandlerDlg(const QString& msg, QWidget* pParent = nullptr);
|
||||
virtual ~CDuplicatedObjectsHandlerDlg();
|
||||
|
||||
enum EResult
|
||||
{
|
||||
eResult_None,
|
||||
eResult_Override,
|
||||
eResult_CreateCopies
|
||||
};
|
||||
|
||||
EResult GetResult() const
|
||||
{
|
||||
return m_result;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
EResult m_result;
|
||||
|
||||
void OnBnClickedOverrideBtn();
|
||||
void OnBnClickedCreateCopiesBtn();
|
||||
|
||||
QScopedPointer<Ui::DuplicatedObjectsHandlerDlg> m_ui;
|
||||
};
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_DIALOGS_DUPLICATEDOBJECTSHANDLERDLG_H
|
||||
@@ -1,83 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>DuplicatedObjectsHandlerDlg</class>
|
||||
<widget class="QDialog" name="DuplicatedObjectsHandlerDlg">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>474</width>
|
||||
<height>204</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Duplicated Objects Dialog</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTextBrowser" name="textBrowser">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonOverride">
|
||||
<property name="text">
|
||||
<string>Override</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonCreateCopies">
|
||||
<property name="text">
|
||||
<string>Create Copies</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>pushButton</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>DuplicatedObjectsHandlerDlg</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>258</x>
|
||||
<y>183</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>190</x>
|
||||
<y>184</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
@@ -71,24 +71,8 @@ CPythonScriptsDialog::CPythonScriptsDialog(QWidget* parent)
|
||||
AzQtComponents::LineEdit::applySearchStyle(ui->searchField);
|
||||
|
||||
QStringList scriptFolders;
|
||||
|
||||
const auto editorEnvStr = gSettings.strEditorEnv.toLocal8Bit();
|
||||
AZStd::string editorScriptsPath = AZStd::string::format("@engroot@/%s", editorEnvStr.constData());
|
||||
XmlNodeRef envNode = XmlHelpers::LoadXmlFromFile(editorScriptsPath.c_str());
|
||||
if (envNode)
|
||||
{
|
||||
QString scriptPath;
|
||||
int childrenCount = envNode->getChildCount();
|
||||
for (int idx = 0; idx < childrenCount; ++idx)
|
||||
{
|
||||
XmlNodeRef child = envNode->getChild(idx);
|
||||
if (child->haveAttr("scriptPath"))
|
||||
{
|
||||
scriptPath = child->getAttr("scriptPath");
|
||||
scriptFolders.push_back(scriptPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
auto engineScriptPath = AZ::IO::FixedMaxPath(AZ::Utils::GetEnginePath()) / "Assets" / "Editor" / "Scripts";
|
||||
scriptFolders.push_back(engineScriptPath.c_str());
|
||||
|
||||
AZ::IO::FixedMaxPathString projectPath = AZ::Utils::GetProjectPath();
|
||||
ScanFolderForScripts(QString("%1/Editor/Scripts").arg(projectPath.c_str()), scriptFolders);
|
||||
|
||||
@@ -1,218 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
#include "EditorDefs.h"
|
||||
|
||||
#include "NewEntityDialog.h"
|
||||
|
||||
// Qt
|
||||
#include <QPushButton>
|
||||
#include <QToolTip>
|
||||
#include <QMessageBox>
|
||||
|
||||
// Editor
|
||||
#include "Dialogs/QT/ui_NewEntityDialog.h"
|
||||
|
||||
|
||||
NewEntityDialog::NewEntityDialog(QWidget* parent)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui::NewEntityDialog)
|
||||
{
|
||||
entityNameValidator = new EntityNameValidator(this);
|
||||
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->entityName->setFocus();
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||
connect(ui->entityName, SIGNAL(textChanged(QString)), this, SLOT(ValidateInput()));
|
||||
connect(ui->categoryName, SIGNAL(textChanged(QString)), this, SLOT(ValidateInput()));
|
||||
|
||||
SetCategoryCompleterPath((Path::GetEditingGameDataFolder() + "/Scripts/Entities").c_str());
|
||||
SetNameValidatorPath((Path::GetEditingGameDataFolder() + "/Entities").c_str());
|
||||
}
|
||||
|
||||
NewEntityDialog::~NewEntityDialog()
|
||||
{
|
||||
SAFE_DELETE(entityNameValidator);
|
||||
SAFE_DELETE(folderNameCompleter);
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void NewEntityDialog::SetCategoryCompleterPath(CryStringT<char> path)
|
||||
{
|
||||
SAFE_DELETE(folderNameCompleter);
|
||||
|
||||
QDirIterator directoryIt(QString::fromLocal8Bit(path.c_str(), path.length()), QDir::NoDotAndDotDot | QDir::AllDirs, QDirIterator::Subdirectories);
|
||||
baseDir = directoryIt.path() + "/";
|
||||
|
||||
QStringList dirs;
|
||||
while (directoryIt.hasNext())
|
||||
{
|
||||
QString dir = directoryIt.next().remove(baseDir);
|
||||
dirs.append(dir);
|
||||
}
|
||||
|
||||
folderNameCompleter = new QCompleter(dirs);
|
||||
folderNameCompleter->setCompletionMode(QCompleter::UnfilteredPopupCompletion);
|
||||
folderNameCompleter->setCaseSensitivity(Qt::CaseInsensitive);
|
||||
ui->categoryName->setCompleter(folderNameCompleter);
|
||||
}
|
||||
|
||||
void NewEntityDialog::SetNameValidatorPath(CryStringT<char> path)
|
||||
{
|
||||
QDir dir(QString::fromLocal8Bit(path.c_str(), path.length()));
|
||||
nameBaseDir = dir.path() + "/";
|
||||
}
|
||||
|
||||
void NewEntityDialog::ValidateInput()
|
||||
{
|
||||
int cursorPos = ui->entityName->cursorPosition();
|
||||
QString text = ui->entityName->text();
|
||||
bool validText = entityNameValidator->validate(text, cursorPos);
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(validText);
|
||||
}
|
||||
|
||||
void NewEntityDialog::accept()
|
||||
{
|
||||
if (ui->categoryName->text().isEmpty()
|
||||
&& QMessageBox::question(this, "Are you sure?", "Create entity without category?", QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes)
|
||||
{
|
||||
return;
|
||||
}
|
||||
const char* devRoot = gEnv->pFileIO->GetAlias("@engroot@");
|
||||
QString devRootPath(devRoot);
|
||||
QFile entTemplateFile(devRootPath + "/Editor/NewEntityTemplate.ent_template");
|
||||
QFile luaTemplateFile(devRootPath + "/Editor/NewEntityTemplate.lua_template");
|
||||
QFile entDestFile(nameBaseDir + ui->entityName->text() + ".ent");
|
||||
QFile luaDestFile(baseDir + ui->categoryName->text() + "/" + ui->entityName->text() + ".lua");
|
||||
|
||||
if (!entTemplateFile.exists() || !luaTemplateFile.exists())
|
||||
{
|
||||
QMessageBox::critical(this, tr("Missing Template Files"), tr("In order to create default entities the NewEntityTemplate.lua and NewEntityTemplate.ent template files must exist in the Templates folder!"));
|
||||
return;
|
||||
}
|
||||
|
||||
//generate the .ent file
|
||||
QDir pathMaker(nameBaseDir);
|
||||
pathMaker.mkpath(pathMaker.path());
|
||||
QString entFileString;
|
||||
if (!entTemplateFile.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||
{
|
||||
AZ_Warning("Editor", false, "Enable to open template file for ent : %s", entTemplateFile.fileName().toUtf8().constData());
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
entFileString = entTemplateFile.readAll();
|
||||
entTemplateFile.close();
|
||||
}
|
||||
|
||||
entFileString.replace(QString("[CATEGORY_NAME]"), ui->categoryName->text());
|
||||
entFileString.replace(QString("[ENTITY_NAME]"), ui->entityName->text());
|
||||
if (!entDestFile.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
{
|
||||
AZ_Warning("Editor", false, "Enable to open destination file for ent : %s", entDestFile.fileName().toUtf8().constData());
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
entDestFile.write(entFileString.toUtf8());
|
||||
entDestFile.close();
|
||||
}
|
||||
|
||||
//generate the .lua file
|
||||
pathMaker.setPath(baseDir);
|
||||
pathMaker.mkpath(ui->categoryName->text() + "/");
|
||||
|
||||
QString luaFileString;
|
||||
if (!luaTemplateFile.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||
{
|
||||
AZ_Warning("Editor", false, "Enable to open template file for lua : %s", luaTemplateFile.fileName().toUtf8().constData());
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
luaFileString = luaTemplateFile.readAll();
|
||||
luaTemplateFile.close();
|
||||
}
|
||||
|
||||
luaFileString.replace(QString("[ENTITY_NAME]"), ui->entityName->text());
|
||||
if (!luaDestFile.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
{
|
||||
AZ_Warning("Editor", false, "Enable to open destination file for lua : %s", luaDestFile.fileName().toUtf8().constData());
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
luaDestFile.write(luaFileString.toUtf8());
|
||||
luaDestFile.close();
|
||||
}
|
||||
|
||||
|
||||
if (ui->openLuaCB->isChecked())
|
||||
{
|
||||
CFileUtil::EditTextFile(luaDestFile.fileName().toLocal8Bit().data());
|
||||
}
|
||||
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
QValidator::State NewEntityDialog::EntityNameValidator::validate(QString& input, [[maybe_unused]] int& pos) const
|
||||
{
|
||||
if (!m_Parent)
|
||||
{
|
||||
return Invalid;
|
||||
}
|
||||
|
||||
if (input.isEmpty())
|
||||
{
|
||||
return Invalid;
|
||||
}
|
||||
|
||||
if (input.contains("/"))
|
||||
{
|
||||
return Invalid;
|
||||
}
|
||||
|
||||
QString fileBaseName = m_Parent->ui->entityName->text();
|
||||
|
||||
// Characters
|
||||
const char* notAllowedChars = ",^@=+{}[]~!?:&*\"|#%<>$\"'();`' ";
|
||||
for (const char* c = notAllowedChars; *c; c++)
|
||||
{
|
||||
if (fileBaseName.contains(QLatin1Char(*c)))
|
||||
{
|
||||
const QChar qc = QLatin1Char(*c);
|
||||
if (qc.isSpace())
|
||||
{
|
||||
QToolTip::showText(m_Parent->ui->entityName->mapToGlobal(QPoint()), tr("Name may not contain white space."), m_Parent->ui->entityName, m_Parent->ui->entityName->rect(), 2000);
|
||||
}
|
||||
else
|
||||
{
|
||||
QToolTip::showText(m_Parent->ui->entityName->mapToGlobal(QPoint()), tr("Invalid character \"%1\".").arg(qc), m_Parent->ui->entityName, m_Parent->ui->entityName->rect(), 2000);
|
||||
}
|
||||
return Invalid;
|
||||
}
|
||||
}
|
||||
|
||||
QString filename(m_Parent->nameBaseDir + m_Parent->ui->entityName->text() + ".ent");
|
||||
QFile newFile(filename);
|
||||
|
||||
if (newFile.exists())
|
||||
{
|
||||
QToolTip::showText(m_Parent->ui->entityName->mapToGlobal(QPoint()), tr("Filename already exists!"), m_Parent->ui->entityName, m_Parent->ui->entityName->rect(), 2000);
|
||||
return Invalid;
|
||||
}
|
||||
|
||||
return Acceptable;
|
||||
}
|
||||
|
||||
#include <Dialogs/QT/moc_NewEntityDialog.cpp>
|
||||
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
#ifndef NEWENTITYDIALOG_H
|
||||
#define NEWENTITYDIALOG_H
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include <QDialog>
|
||||
#include <QCompleter>
|
||||
#include <QDirIterator>
|
||||
#include <QStringListModel>
|
||||
#include <QValidator>
|
||||
#include <QEvent>
|
||||
#include <QLineEdit>
|
||||
#endif
|
||||
|
||||
namespace Ui {
|
||||
class NewEntityDialog;
|
||||
}
|
||||
|
||||
class NewEntityDialog
|
||||
: public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit NewEntityDialog(QWidget* parent = 0);
|
||||
~NewEntityDialog();
|
||||
|
||||
private:
|
||||
Ui::NewEntityDialog* ui;
|
||||
QString baseDir = "";
|
||||
QString nameBaseDir = "";
|
||||
QCompleter* folderNameCompleter = NULL;
|
||||
|
||||
void SetCategoryCompleterPath(CryStringT<char> path);
|
||||
void SetNameValidatorPath(CryStringT<char> path);
|
||||
|
||||
virtual void accept();
|
||||
|
||||
class EntityNameValidator
|
||||
: public QValidator
|
||||
{
|
||||
public:
|
||||
explicit EntityNameValidator(NewEntityDialog* parent = 0)
|
||||
: QValidator(parent)
|
||||
, m_Parent(parent)
|
||||
{
|
||||
}
|
||||
virtual State validate(QString& input, int& pos) const;
|
||||
|
||||
NewEntityDialog* m_Parent;
|
||||
};
|
||||
|
||||
EntityNameValidator* entityNameValidator;
|
||||
|
||||
public slots:
|
||||
void ValidateInput();
|
||||
};
|
||||
|
||||
#endif // NEWENTITYDIALOG_H
|
||||
@@ -1,161 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>NewEntityDialog</class>
|
||||
<widget class="QDialog" name="NewEntityDialog">
|
||||
<property name="windowModality">
|
||||
<enum>Qt::WindowModal</enum>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>111</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::PreventContextMenu</enum>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>New Entity</string>
|
||||
</property>
|
||||
<property name="sizeGripEnabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="modal">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>70</y>
|
||||
<width>341</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="entityName">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>110</x>
|
||||
<y>10</y>
|
||||
<width>281</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>71</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Entity Name:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>entityName</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>40</y>
|
||||
<width>91</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Entity Category:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>categoryName</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="categoryName">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>110</x>
|
||||
<y>40</y>
|
||||
<width>281</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="openLuaCB">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>80</y>
|
||||
<width>141</width>
|
||||
<height>17</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Open Lua After Creating</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>entityName</tabstop>
|
||||
<tabstop>categoryName</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>NewEntityDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>NewEntityDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
@@ -22,7 +22,6 @@
|
||||
|
||||
// Editor
|
||||
#include "Settings.h"
|
||||
#include "Material/MaterialManager.h"
|
||||
|
||||
|
||||
|
||||
@@ -87,11 +86,6 @@ void CDisplaySettings::PostInitApply()
|
||||
void CDisplaySettings::SetRenderFlags(int flags)
|
||||
{
|
||||
m_renderFlags = flags;
|
||||
|
||||
if (!GetIEditor()->Get3DEngine())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -112,30 +106,6 @@ void CDisplaySettings::SetDebugFlags(int flags)
|
||||
//SetCVarInt( "sys_enable_budgetmonitoring",(m_debugFlags&DBG_BUDGET_MONITORING) ? 4:0 );
|
||||
|
||||
//SetCVarInt( "Profile",(m_debugFlags&DBG_FRAMEPROFILE) ? 1:0 );
|
||||
|
||||
if (CMaterialManager* pMaterialManager = GetIEditor()->GetMaterialManager())
|
||||
{
|
||||
int mask = pMaterialManager->GetHighlightMask();
|
||||
if (m_debugFlags & DBG_HIGHLIGHT_BREAKABLE)
|
||||
{
|
||||
mask |= eHighlight_Breakable;
|
||||
}
|
||||
else
|
||||
{
|
||||
mask &= ~eHighlight_Breakable;
|
||||
}
|
||||
|
||||
if (m_debugFlags & DBG_HIGHLIGHT_MISSING_SURFACE_TYPE)
|
||||
{
|
||||
mask |= eHighlight_NoSurfaceType;
|
||||
}
|
||||
else
|
||||
{
|
||||
mask &= ~eHighlight_NoSurfaceType;
|
||||
}
|
||||
|
||||
pMaterialManager->SetHighlightMask(mask);
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -1 +1 @@
|
||||
IDI_ICON1 ICON DISCARDABLE "res\\o3de_editor.ico"
|
||||
IDI_ICON1 ICON DISCARDABLE "res\\o3de_editor.ico"
|
||||
|
||||
@@ -132,7 +132,6 @@
|
||||
#include <IRenderer.h>
|
||||
#include <CryFile.h>
|
||||
#include <ISystem.h>
|
||||
#include <I3DEngine.h>
|
||||
#include <IIndexedMesh.h>
|
||||
#include <ITimer.h>
|
||||
#include <IXml.h>
|
||||
|
||||
@@ -35,9 +35,6 @@ void CEditorFileMonitor::OnEditorNotifyEvent(EEditorNotifyEvent ev)
|
||||
{
|
||||
if (ev == eNotify_OnInit)
|
||||
{
|
||||
// Setup file change monitoring
|
||||
gEnv->pSystem->SetIFileChangeMonitor(this);
|
||||
|
||||
// We don't want the file monitor to be enabled while
|
||||
// in console mode...
|
||||
if (!GetIEditor()->IsInConsolewMode())
|
||||
@@ -49,7 +46,6 @@ void CEditorFileMonitor::OnEditorNotifyEvent(EEditorNotifyEvent ev)
|
||||
}
|
||||
else if (ev == eNotify_OnQuit)
|
||||
{
|
||||
gEnv->pSystem->SetIFileChangeMonitor(NULL);
|
||||
CFileChangeMonitor::Instance()->StopMonitor();
|
||||
GetIEditor()->UnregisterNotifyListener(this);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
#define CRYINCLUDE_EDITOR_EDITORFILEMONITOR_H
|
||||
#pragma once
|
||||
#include "Include/IEditorFileMonitor.h"
|
||||
#include "IFileChangeMonitor.h"
|
||||
#include "Util/FileChangeMonitor.h"
|
||||
|
||||
class CEditorFileMonitor
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
#include "EditorPanelUtils.h"
|
||||
|
||||
#include <AzCore/Utils/Utils.h>
|
||||
|
||||
// Qt
|
||||
#include <QInputDialog>
|
||||
#include <QFileDialog>
|
||||
@@ -147,7 +149,8 @@ public:
|
||||
|
||||
virtual void HotKey_Export() override
|
||||
{
|
||||
QString filepath = QFileDialog::getSaveFileName(nullptr, "Select shortcut configuration to load", "Editor/Plugins/ParticleEditorPlugin/settings", "HotKey Config Files (*.hkxml)");
|
||||
auto settingDir = AZ::IO::FixedMaxPath(AZ::Utils::GetEnginePath()) / "Editor" / "Plugins" / "ParticleEditorPlugin" / "settings";
|
||||
QString filepath = QFileDialog::getSaveFileName(nullptr, "Select shortcut configuration to load", settingDir.c_str(), "HotKey Config Files (*.hkxml)");
|
||||
QFile file(filepath);
|
||||
if (!file.open(QIODevice::WriteOnly))
|
||||
{
|
||||
|
||||
@@ -73,4 +73,4 @@ private:
|
||||
QPixmap m_unSelectedPixmap;
|
||||
EditorPreferencesTreeWidgetItem* m_currentPageItem;
|
||||
QString m_filter;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -21,14 +21,12 @@
|
||||
#include <AzToolsFramework/UI/UICore/WidgetHelpers.h>
|
||||
#include <AzToolsFramework/Thumbnails/ThumbnailerComponent.h>
|
||||
#include <AzToolsFramework/AssetBrowser/AssetBrowserComponent.h>
|
||||
#include <AzToolsFramework/MaterialBrowser/MaterialBrowserComponent.h>
|
||||
|
||||
// Editor
|
||||
#include "MainWindow.h"
|
||||
#include "CryEdit.h"
|
||||
#include "DisplaySettingsPythonFuncs.h"
|
||||
#include "GameEngine.h"
|
||||
#include "Material/MaterialPythonFuncs.h"
|
||||
#include "PythonEditorFuncs.h"
|
||||
#include "TrackView/TrackViewPythonFuncs.h"
|
||||
#include "Include/IObjectManager.h"
|
||||
@@ -65,7 +63,6 @@ namespace EditorInternal
|
||||
RegisterComponentDescriptor(AzToolsFramework::DisplaySettingsPythonFuncsHandler::CreateDescriptor());
|
||||
RegisterComponentDescriptor(AzToolsFramework::MainWindowEditorFuncsHandler::CreateDescriptor());
|
||||
RegisterComponentDescriptor(AzToolsFramework::ObjectManagerFuncsHandler::CreateDescriptor());
|
||||
RegisterComponentDescriptor(AzToolsFramework::MaterialPythonFuncsHandler::CreateDescriptor());
|
||||
RegisterComponentDescriptor(AzToolsFramework::PythonEditorComponent::CreateDescriptor());
|
||||
RegisterComponentDescriptor(AzToolsFramework::PythonEditorFuncsHandler::CreateDescriptor());
|
||||
RegisterComponentDescriptor(AzToolsFramework::DisplaySettingsComponent::CreateDescriptor());
|
||||
@@ -81,7 +78,6 @@ namespace EditorInternal
|
||||
|
||||
components.emplace_back(azrtti_typeid<AzToolsFramework::Thumbnailer::ThumbnailerComponent>());
|
||||
components.emplace_back(azrtti_typeid<AzToolsFramework::AssetBrowser::AssetBrowserComponent>());
|
||||
components.emplace_back(azrtti_typeid<AzToolsFramework::MaterialBrowser::MaterialBrowserComponent>());
|
||||
|
||||
// Add new Bus-based Python Bindings
|
||||
components.emplace_back(azrtti_typeid<AzToolsFramework::DisplaySettingsComponent>());
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <EditorViewportSettings.h>
|
||||
|
||||
#include <AzCore/Casting/numeric_cast.h>
|
||||
#include <AzCore/Settings/SettingsRegistry.h>
|
||||
#include <AzCore/std/string/string_view.h>
|
||||
|
||||
namespace SandboxEditor
|
||||
{
|
||||
constexpr AZStd::string_view GridSnappingSetting = "/Amazon/Preferences/Editor/GridSnapping";
|
||||
constexpr AZStd::string_view GridSizeSetting = "/Amazon/Preferences/Editor/GridSize";
|
||||
constexpr AZStd::string_view AngleSnappingSetting = "/Amazon/Preferences/Editor/AngleSnapping";
|
||||
constexpr AZStd::string_view AngleSizeSetting = "/Amazon/Preferences/Editor/AngleSize";
|
||||
constexpr AZStd::string_view ShowGridSetting = "/Amazon/Preferences/Editor/ShowGrid";
|
||||
|
||||
bool GridSnappingEnabled()
|
||||
{
|
||||
bool enabled = false;
|
||||
if (auto* registry = AZ::SettingsRegistry::Get())
|
||||
{
|
||||
registry->Get(enabled, GridSnappingSetting);
|
||||
}
|
||||
return enabled;
|
||||
}
|
||||
|
||||
float GridSnappingSize()
|
||||
{
|
||||
double gridSize = 0.1;
|
||||
if (auto* registry = AZ::SettingsRegistry::Get())
|
||||
{
|
||||
registry->Get(gridSize, GridSizeSetting);
|
||||
}
|
||||
return aznumeric_cast<float>(gridSize);
|
||||
}
|
||||
|
||||
bool AngleSnappingEnabled()
|
||||
{
|
||||
bool enabled = false;
|
||||
if (auto* registry = AZ::SettingsRegistry::Get())
|
||||
{
|
||||
registry->Get(enabled, AngleSnappingSetting);
|
||||
}
|
||||
return enabled;
|
||||
}
|
||||
|
||||
float AngleSnappingSize()
|
||||
{
|
||||
double angleSize = 5.0;
|
||||
if (auto* registry = AZ::SettingsRegistry::Get())
|
||||
{
|
||||
registry->Get(angleSize, AngleSizeSetting);
|
||||
}
|
||||
return aznumeric_cast<float>(angleSize);
|
||||
}
|
||||
|
||||
bool ShowingGrid()
|
||||
{
|
||||
bool enabled = false;
|
||||
if (auto* registry = AZ::SettingsRegistry::Get())
|
||||
{
|
||||
registry->Get(enabled, ShowGridSetting);
|
||||
}
|
||||
return enabled;
|
||||
}
|
||||
|
||||
void SetGridSnapping(const bool enabled)
|
||||
{
|
||||
if (auto* registry = AZ::SettingsRegistry::Get())
|
||||
{
|
||||
registry->Set(GridSnappingSetting, enabled);
|
||||
}
|
||||
}
|
||||
|
||||
void SetGridSnappingSize(const float size)
|
||||
{
|
||||
if (auto* registry = AZ::SettingsRegistry::Get())
|
||||
{
|
||||
registry->Set(GridSizeSetting, size);
|
||||
}
|
||||
}
|
||||
|
||||
void SetAngleSnapping(const bool enabled)
|
||||
{
|
||||
if (auto* registry = AZ::SettingsRegistry::Get())
|
||||
{
|
||||
registry->Set(AngleSnappingSetting, enabled);
|
||||
}
|
||||
}
|
||||
|
||||
void SetAngleSnappingSize(const float size)
|
||||
{
|
||||
if (auto* registry = AZ::SettingsRegistry::Get())
|
||||
{
|
||||
registry->Set(AngleSizeSetting, size);
|
||||
}
|
||||
}
|
||||
|
||||
void SetShowingGrid(const bool showing)
|
||||
{
|
||||
if (auto* registry = AZ::SettingsRegistry::Get())
|
||||
{
|
||||
registry->Set(ShowGridSetting, showing);
|
||||
}
|
||||
}
|
||||
} // namespace SandboxEditor
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <SandboxAPI.h>
|
||||
|
||||
namespace SandboxEditor
|
||||
{
|
||||
SANDBOX_API bool GridSnappingEnabled();
|
||||
|
||||
SANDBOX_API float GridSnappingSize();
|
||||
|
||||
SANDBOX_API bool AngleSnappingEnabled();
|
||||
|
||||
SANDBOX_API float AngleSnappingSize();
|
||||
|
||||
SANDBOX_API bool ShowingGrid();
|
||||
|
||||
SANDBOX_API void SetGridSnapping(bool enabled);
|
||||
|
||||
SANDBOX_API void SetGridSnappingSize(float size);
|
||||
|
||||
SANDBOX_API void SetAngleSnapping(bool enabled);
|
||||
|
||||
SANDBOX_API void SetAngleSnappingSize(float size);
|
||||
|
||||
SANDBOX_API void SetShowingGrid(bool showing);
|
||||
|
||||
//! Return if the new editor camera system is enabled or not.
|
||||
//! @note This is implemented in EditorViewportWidget.cpp
|
||||
SANDBOX_API bool UsingNewCameraSystem();
|
||||
} // namespace SandboxEditor
|
||||
@@ -40,7 +40,6 @@
|
||||
# include <AzFramework/Input/Buses/Notifications/RawInputNotificationBus_Platform.h>
|
||||
#endif // defined(AZ_PLATFORM_WINDOWS)
|
||||
#include <AzFramework/Input/Devices/Mouse/InputDeviceMouse.h> // for AzFramework::InputDeviceMouse
|
||||
#include <AzFramework/API/AtomActiveInterface.h>
|
||||
#include <AzFramework/Viewport/ViewportControllerList.h>
|
||||
|
||||
// AzQtComponents
|
||||
@@ -50,12 +49,12 @@
|
||||
#include <AzToolsFramework/API/ComponentEntityObjectBus.h>
|
||||
#include <AzToolsFramework/Manipulators/ManipulatorManager.h>
|
||||
#include <AzToolsFramework/ViewportSelection/EditorInteractionSystemViewportSelectionRequestBus.h>
|
||||
#include <AzToolsFramework/ViewportSelection/EditorTransformComponentSelectionRequestBus.h>
|
||||
|
||||
// AtomToolsFramework
|
||||
#include <AtomToolsFramework/Viewport/RenderViewportWidget.h>
|
||||
|
||||
// CryCommon
|
||||
#include <CryCommon/I3DEngine.h>
|
||||
#include <CryCommon/HMDBus.h>
|
||||
|
||||
// AzFramework
|
||||
@@ -77,6 +76,7 @@
|
||||
#include "ViewportManipulatorController.h"
|
||||
#include "LegacyViewportCameraController.h"
|
||||
#include "ModernViewportCameraController.h"
|
||||
#include "EditorViewportSettings.h"
|
||||
|
||||
#include "ViewPane.h"
|
||||
#include "CustomResolutionDlg.h"
|
||||
@@ -98,12 +98,33 @@
|
||||
|
||||
#include <QtGui/private/qhighdpiscaling_p.h>
|
||||
|
||||
#include <IEntityRenderState.h>
|
||||
#include <IPhysics.h>
|
||||
#include <IStatObj.h>
|
||||
|
||||
AZ_CVAR(
|
||||
bool, ed_visibility_logTiming, false, nullptr, AZ::ConsoleFunctorFlags::Null,
|
||||
"Output the timing of the new IVisibilitySystem query");
|
||||
bool, ed_visibility_logTiming, false, nullptr, AZ::ConsoleFunctorFlags::Null, "Output the timing of the new IVisibilitySystem query");
|
||||
AZ_CVAR(bool, ed_useNewCameraSystem, false, nullptr, AZ::ConsoleFunctorFlags::Null, "Use the new Editor camera system");
|
||||
|
||||
namespace SandboxEditor
|
||||
{
|
||||
bool UsingNewCameraSystem()
|
||||
{
|
||||
return ed_useNewCameraSystem;
|
||||
}
|
||||
} // namespace SandboxEditor
|
||||
|
||||
EditorViewportWidget* EditorViewportWidget::m_pPrimaryViewport = nullptr;
|
||||
|
||||
namespace AzFramework
|
||||
{
|
||||
extern InputChannelId CameraFreeLookButton;
|
||||
extern InputChannelId CameraFreePanButton;
|
||||
extern InputChannelId CameraOrbitLookButton;
|
||||
extern InputChannelId CameraOrbitDollyButton;
|
||||
extern InputChannelId CameraOrbitPanButton;
|
||||
} // namespace AzFramework
|
||||
|
||||
#if AZ_TRAIT_OS_PLATFORM_APPLE
|
||||
void StopFixedCursorMode();
|
||||
void StartFixedCursorMode(QObject *viewport);
|
||||
@@ -112,9 +133,17 @@ void StartFixedCursorMode(QObject *viewport);
|
||||
#define RENDER_MESH_TEST_DISTANCE (0.2f)
|
||||
#define CURSOR_FONT_HEIGHT 8.0f
|
||||
|
||||
AZ_CVAR(
|
||||
bool, ed_useNewCameraSystem, false, nullptr, AZ::ConsoleFunctorFlags::Null,
|
||||
"Use the new Editor camera system (the Atom-native Editor viewport (experimental) must also be enabled)");
|
||||
//! Viewport settings for the EditorViewportWidget
|
||||
struct EditorViewportSettings : public AzToolsFramework::ViewportInteraction::ViewportSettings
|
||||
{
|
||||
bool GridSnappingEnabled() const override;
|
||||
float GridSize() const override;
|
||||
bool ShowGrid() const override;
|
||||
bool AngleSnappingEnabled() const override;
|
||||
float AngleStep() const override;
|
||||
};
|
||||
|
||||
static const EditorViewportSettings g_EditorViewportSettings;
|
||||
|
||||
namespace AZ::ViewportHelpers
|
||||
{
|
||||
@@ -230,10 +259,6 @@ EditorViewportWidget::~EditorViewportWidget()
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
int EditorViewportWidget::OnCreate()
|
||||
{
|
||||
m_renderer = GetIEditor()->GetRenderer();
|
||||
m_engine = GetIEditor()->Get3DEngine();
|
||||
assert(m_engine);
|
||||
|
||||
CreateRenderContext();
|
||||
|
||||
return 0;
|
||||
@@ -255,11 +280,6 @@ void EditorViewportWidget::resizeEvent(QResizeEvent* event)
|
||||
|
||||
gEnv->pSystem->GetISystemEventDispatcher()->OnSystemEvent(ESYSTEM_EVENT_RESIZE, width(), height());
|
||||
|
||||
if (gEnv->pRenderer)
|
||||
{
|
||||
gEnv->pRenderer->EF_DisableTemporalEffects();
|
||||
}
|
||||
|
||||
// We queue the window resize event because the render overlay may be hidden.
|
||||
// If the render overlay is not visible, the native window that is backing it will
|
||||
// also be hidden, and it will not resize until it becomes visible.
|
||||
@@ -325,8 +345,8 @@ AzToolsFramework::ViewportInteraction::MousePick EditorViewportWidget::BuildMous
|
||||
using namespace AzToolsFramework::ViewportInteraction;
|
||||
|
||||
MousePick mousePick;
|
||||
mousePick.m_screenCoordinates = AzFramework::ScreenPoint(point.x(), point.y());
|
||||
const auto& ray = m_renderViewport->ViewportScreenToWorldRay(point);
|
||||
mousePick.m_screenCoordinates = ScreenPointFromQPoint(point);
|
||||
const auto& ray = m_renderViewport->ViewportScreenToWorldRay(mousePick.m_screenCoordinates);
|
||||
if (ray.has_value())
|
||||
{
|
||||
mousePick.m_rayOrigin = ray.value().origin;
|
||||
@@ -427,7 +447,7 @@ void EditorViewportWidget::Update()
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_engine || m_rcClient.isEmpty() || GetIEditor()->IsInMatEditMode())
|
||||
if (m_rcClient.isEmpty() || GetIEditor()->IsInMatEditMode())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -437,9 +457,21 @@ void EditorViewportWidget::Update()
|
||||
return;
|
||||
}
|
||||
|
||||
static bool sentOnWindowCreated = false;
|
||||
if (!sentOnWindowCreated && windowHandle()->isActive())
|
||||
{
|
||||
sentOnWindowCreated = true;
|
||||
AzFramework::WindowSystemNotificationBus::Broadcast(
|
||||
&AzFramework::WindowSystemNotificationBus::Handler::OnWindowCreated,
|
||||
reinterpret_cast<AzFramework::NativeWindowHandle>(winId()));
|
||||
}
|
||||
|
||||
m_updatingCameraPosition = true;
|
||||
auto transform = LYTransformToAZTransform(m_Camera.GetMatrix());
|
||||
m_renderViewport->GetViewportContext()->SetCameraTransform(transform);
|
||||
if (!ed_useNewCameraSystem)
|
||||
{
|
||||
m_renderViewport->GetViewportContext()->SetCameraTransform(LYTransformToAZTransform(m_Camera.GetMatrix()));
|
||||
}
|
||||
|
||||
AZ::Matrix4x4 clipMatrix;
|
||||
AZ::MakePerspectiveFovMatrixRH(
|
||||
clipMatrix,
|
||||
@@ -525,9 +557,6 @@ void EditorViewportWidget::Update()
|
||||
// Render
|
||||
{
|
||||
// TODO: Move out this logic to a controller and refactor to work with Atom
|
||||
// m_renderer->SetClearColor(Vec3(0.4f, 0.4f, 0.4f));
|
||||
// 3D engine stats
|
||||
GetIEditor()->GetSystem()->RenderBegin();
|
||||
|
||||
OnRender();
|
||||
|
||||
@@ -552,8 +581,6 @@ void EditorViewportWidget::Update()
|
||||
}
|
||||
}
|
||||
|
||||
GetIEditor()->GetSystem()->RenderEnd(m_bRenderStats);
|
||||
|
||||
gEnv->pSystem->SetViewCamera(CurCamera);
|
||||
}
|
||||
|
||||
@@ -646,9 +673,6 @@ CBaseObject* EditorViewportWidget::GetCameraObject() const
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void EditorViewportWidget::OnEditorNotifyEvent(EEditorNotifyEvent event)
|
||||
{
|
||||
static ICVar* outputToHMD = gEnv->pConsole->GetCVar("output_to_hmd");
|
||||
AZ_Assert(outputToHMD, "cvar output_to_hmd is undeclared");
|
||||
|
||||
switch (event)
|
||||
{
|
||||
case eNotify_OnBeginGameMode:
|
||||
@@ -670,7 +694,6 @@ void EditorViewportWidget::OnEditorNotifyEvent(EEditorNotifyEvent event)
|
||||
if (deviceInfo)
|
||||
{
|
||||
// Note: This may also need to adjust the viewport size
|
||||
outputToHMD->Set(1);
|
||||
SetActiveWindow();
|
||||
SetFocus();
|
||||
SetSelected(true);
|
||||
@@ -690,10 +713,6 @@ void EditorViewportWidget::OnEditorNotifyEvent(EEditorNotifyEvent event)
|
||||
if (GetIEditor()->GetViewManager()->GetGameViewport() == this)
|
||||
{
|
||||
SetCurrentCursor(STD_CURSOR_DEFAULT);
|
||||
if (gSettings.bEnableGameModeVR)
|
||||
{
|
||||
outputToHMD->Set(0);
|
||||
}
|
||||
m_bInRotateMode = false;
|
||||
m_bInMoveMode = false;
|
||||
m_bInOrbitMode = false;
|
||||
@@ -793,8 +812,6 @@ void EditorViewportWidget::OnRender()
|
||||
// This is necessary so that automated editor tests using the null renderer to test systems like dynamic vegetation
|
||||
// are still able to manipulate the current logical camera position, even if nothing is rendered.
|
||||
GetIEditor()->GetSystem()->SetViewCamera(m_Camera);
|
||||
GetIEditor()->GetRenderer()->SetCamera(gEnv->pSystem->GetViewCamera());
|
||||
m_engine->RenderWorld(0, SRenderingPassInfo::CreateGeneralPassRenderingInfo(m_Camera), __FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -886,8 +903,7 @@ void EditorViewportWidget::OnBeginPrepareRender()
|
||||
fov = 2 * atanf((h * tan(fov / 2)) / maxTargetHeight);
|
||||
}
|
||||
}
|
||||
|
||||
m_Camera.SetFrustum(w, h, fov, fNearZ, gEnv->p3DEngine->GetMaxViewDistance());
|
||||
m_Camera.SetFrustum(w, h, fov, fNearZ);
|
||||
}
|
||||
|
||||
GetIEditor()->GetSystem()->SetViewCamera(m_Camera);
|
||||
@@ -1109,40 +1125,14 @@ AzFramework::CameraState EditorViewportWidget::GetCameraState()
|
||||
return m_renderViewport->GetCameraState();
|
||||
}
|
||||
|
||||
bool EditorViewportWidget::GridSnappingEnabled()
|
||||
{
|
||||
return GetViewManager()->GetGrid()->IsEnabled();
|
||||
}
|
||||
|
||||
float EditorViewportWidget::GridSize()
|
||||
{
|
||||
const CGrid* grid = GetViewManager()->GetGrid();
|
||||
return grid->scale * grid->size;
|
||||
}
|
||||
|
||||
bool EditorViewportWidget::ShowGrid()
|
||||
{
|
||||
return gSettings.viewports.bShowGridGuide;
|
||||
}
|
||||
|
||||
bool EditorViewportWidget::AngleSnappingEnabled()
|
||||
{
|
||||
return GetViewManager()->GetGrid()->IsAngleSnapEnabled();
|
||||
}
|
||||
|
||||
float EditorViewportWidget::AngleStep()
|
||||
{
|
||||
return GetViewManager()->GetGrid()->GetAngleSnap();
|
||||
}
|
||||
|
||||
AZ::Vector3 EditorViewportWidget::PickTerrain(const QPoint& point)
|
||||
AZ::Vector3 EditorViewportWidget::PickTerrain(const AzFramework::ScreenPoint& point)
|
||||
{
|
||||
FUNCTION_PROFILER(GetIEditor()->GetSystem(), PROFILE_EDITOR);
|
||||
|
||||
return LYVec3ToAZVec3(ViewToWorld(point, nullptr, true));
|
||||
return LYVec3ToAZVec3(ViewToWorld(AzToolsFramework::ViewportInteraction::QPointFromScreenPoint(point), nullptr, true));
|
||||
}
|
||||
|
||||
AZ::EntityId EditorViewportWidget::PickEntity(const QPoint& point)
|
||||
AZ::EntityId EditorViewportWidget::PickEntity(const AzFramework::ScreenPoint& point)
|
||||
{
|
||||
FUNCTION_PROFILER(GetIEditor()->GetSystem(), PROFILE_EDITOR);
|
||||
|
||||
@@ -1151,7 +1141,7 @@ AZ::EntityId EditorViewportWidget::PickEntity(const QPoint& point)
|
||||
AZ::EntityId entityId;
|
||||
HitContext hitInfo;
|
||||
hitInfo.view = this;
|
||||
if (HitTest(point, hitInfo))
|
||||
if (HitTest(AzToolsFramework::ViewportInteraction::QPointFromScreenPoint(point), hitInfo))
|
||||
{
|
||||
if (hitInfo.object && (hitInfo.object->GetType() == OBJTYPE_AZENTITY))
|
||||
{
|
||||
@@ -1177,7 +1167,7 @@ void EditorViewportWidget::FindVisibleEntities(AZStd::vector<AZ::EntityId>& visi
|
||||
visibleEntitiesOut.assign(m_entityVisibilityQuery.Begin(), m_entityVisibilityQuery.End());
|
||||
}
|
||||
|
||||
QPoint EditorViewportWidget::ViewportWorldToScreen(const AZ::Vector3& worldPosition)
|
||||
AzFramework::ScreenPoint EditorViewportWidget::ViewportWorldToScreen(const AZ::Vector3& worldPosition)
|
||||
{
|
||||
return m_renderViewport->ViewportWorldToScreen(worldPosition);
|
||||
}
|
||||
@@ -1218,13 +1208,18 @@ void EditorViewportWidget::SetViewportId(int id)
|
||||
CViewport::SetViewportId(id);
|
||||
|
||||
// Now that we have an ID, we can initialize our viewport.
|
||||
m_renderViewport = new AtomToolsFramework::RenderViewportWidget(id, this);
|
||||
m_defaultViewportContextName = m_renderViewport->GetViewportContext()->GetName();
|
||||
m_renderViewport = new AtomToolsFramework::RenderViewportWidget(this, false);
|
||||
if (!m_renderViewport->InitializeViewportContext(id))
|
||||
{
|
||||
AZ_Warning("EditorViewportWidget", false, "Failed to initialize RenderViewportWidget's ViewportContext");
|
||||
return;
|
||||
}
|
||||
auto viewportContext = m_renderViewport->GetViewportContext();
|
||||
m_defaultViewportContextName = viewportContext->GetName();
|
||||
QBoxLayout* layout = new QBoxLayout(QBoxLayout::Direction::TopToBottom, this);
|
||||
layout->setContentsMargins(QMargins());
|
||||
layout->addWidget(m_renderViewport);
|
||||
|
||||
auto viewportContext = m_renderViewport->GetViewportContext();
|
||||
viewportContext->ConnectViewMatrixChangedHandler(m_cameraViewMatrixChangeHandler);
|
||||
viewportContext->ConnectProjectionMatrixChangedHandler(m_cameraProjectionMatrixChangeHandler);
|
||||
|
||||
@@ -1232,13 +1227,62 @@ void EditorViewportWidget::SetViewportId(int id)
|
||||
|
||||
if (ed_useNewCameraSystem)
|
||||
{
|
||||
m_renderViewport->GetControllerList()->Add(AZStd::make_shared<SandboxEditor::ModernViewportCameraController>());
|
||||
AzFramework::ReloadCameraKeyBindings();
|
||||
|
||||
auto controller = AZStd::make_shared<SandboxEditor::ModernViewportCameraController>();
|
||||
controller->SetCameraListBuilderCallback([](AzFramework::Cameras& cameras)
|
||||
{
|
||||
auto firstPersonRotateCamera = AZStd::make_shared<AzFramework::RotateCameraInput>(AzFramework::CameraFreeLookButton);
|
||||
auto firstPersonPanCamera =
|
||||
AZStd::make_shared<AzFramework::PanCameraInput>(AzFramework::CameraFreePanButton, AzFramework::LookPan);
|
||||
auto firstPersonTranslateCamera = AZStd::make_shared<AzFramework::TranslateCameraInput>(AzFramework::LookTranslation);
|
||||
auto firstPersonWheelCamera = AZStd::make_shared<AzFramework::ScrollTranslationCameraInput>();
|
||||
|
||||
auto orbitCamera = AZStd::make_shared<AzFramework::OrbitCameraInput>();
|
||||
orbitCamera->SetLookAtFn([]() -> AZStd::optional<AZ::Vector3> {
|
||||
AZStd::optional<AZ::Transform> manipulatorTransform;
|
||||
AzToolsFramework::EditorTransformComponentSelectionRequestBus::EventResult(
|
||||
manipulatorTransform, AzToolsFramework::GetEntityContextId(),
|
||||
&AzToolsFramework::EditorTransformComponentSelectionRequestBus::Events::GetManipulatorTransform);
|
||||
|
||||
if (manipulatorTransform)
|
||||
{
|
||||
return manipulatorTransform->GetTranslation();
|
||||
}
|
||||
|
||||
return {};
|
||||
});
|
||||
|
||||
auto orbitRotateCamera = AZStd::make_shared<AzFramework::RotateCameraInput>(AzFramework::CameraOrbitLookButton);
|
||||
auto orbitTranslateCamera = AZStd::make_shared<AzFramework::TranslateCameraInput>(AzFramework::OrbitTranslation);
|
||||
auto orbitDollyWheelCamera = AZStd::make_shared<AzFramework::OrbitDollyScrollCameraInput>();
|
||||
auto orbitDollyMoveCamera =
|
||||
AZStd::make_shared<AzFramework::OrbitDollyCursorMoveCameraInput>(AzFramework::CameraOrbitDollyButton);
|
||||
auto orbitPanCamera =
|
||||
AZStd::make_shared<AzFramework::PanCameraInput>(AzFramework::CameraOrbitPanButton, AzFramework::OrbitPan);
|
||||
|
||||
orbitCamera->m_orbitCameras.AddCamera(orbitRotateCamera);
|
||||
orbitCamera->m_orbitCameras.AddCamera(orbitTranslateCamera);
|
||||
orbitCamera->m_orbitCameras.AddCamera(orbitDollyWheelCamera);
|
||||
orbitCamera->m_orbitCameras.AddCamera(orbitDollyMoveCamera);
|
||||
orbitCamera->m_orbitCameras.AddCamera(orbitPanCamera);
|
||||
|
||||
cameras.AddCamera(firstPersonRotateCamera);
|
||||
cameras.AddCamera(firstPersonPanCamera);
|
||||
cameras.AddCamera(firstPersonTranslateCamera);
|
||||
cameras.AddCamera(firstPersonWheelCamera);
|
||||
cameras.AddCamera(orbitCamera);
|
||||
});
|
||||
|
||||
m_renderViewport->GetControllerList()->Add(controller);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_renderViewport->GetControllerList()->Add(AZStd::make_shared<SandboxEditor::LegacyViewportCameraController>());
|
||||
}
|
||||
|
||||
m_renderViewport->SetViewportSettings(&g_EditorViewportSettings);
|
||||
|
||||
UpdateScene();
|
||||
|
||||
if (m_pPrimaryViewport == this)
|
||||
@@ -1303,26 +1347,8 @@ namespace AZ::ViewportHelpers
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void EditorViewportWidget::OnTitleMenu(QMenu* menu)
|
||||
{
|
||||
const int nWireframe = gEnv->pConsole->GetCVar("r_wireframe")->GetIVal();
|
||||
QAction* action = menu->addAction(tr("Wireframe"));
|
||||
connect(action, &QAction::triggered, action, []()
|
||||
{
|
||||
ICVar* piVar(gEnv->pConsole->GetCVar("r_wireframe"));
|
||||
int nRenderMode = piVar->GetIVal();
|
||||
if (nRenderMode != R_WIREFRAME_MODE)
|
||||
{
|
||||
piVar->Set(R_WIREFRAME_MODE);
|
||||
}
|
||||
else
|
||||
{
|
||||
piVar->Set(R_SOLID_MODE);
|
||||
}
|
||||
});
|
||||
action->setCheckable(true);
|
||||
action->setChecked(nWireframe == R_WIREFRAME_MODE);
|
||||
|
||||
const bool bDisplayLabels = GetIEditor()->GetDisplaySettings()->IsDisplayLabels();
|
||||
action = menu->addAction(tr("Labels"));
|
||||
QAction* action = menu->addAction(tr("Labels"));
|
||||
connect(action, &QAction::triggered, this, [bDisplayLabels] {GetIEditor()->GetDisplaySettings()->DisplayLabels(!bDisplayLabels);
|
||||
});
|
||||
action->setCheckable(true);
|
||||
@@ -1500,10 +1526,10 @@ bool EditorViewportWidget::AddCameraMenuItems(QMenu* menu)
|
||||
}
|
||||
|
||||
action = customCameraMenu->addAction(tr("Look through entity"));
|
||||
AzToolsFramework::EntityIdList selectedEntityList;
|
||||
AzToolsFramework::ToolsApplicationRequests::Bus::BroadcastResult(selectedEntityList, &AzToolsFramework::ToolsApplicationRequests::GetSelectedEntities);
|
||||
action->setCheckable(selectedEntityList.size() > 0 || m_viewSourceType == ViewSourceType::AZ_Entity);
|
||||
action->setEnabled(selectedEntityList.size() > 0 || m_viewSourceType == ViewSourceType::AZ_Entity);
|
||||
bool areAnyEntitiesSelected = false;
|
||||
AzToolsFramework::ToolsApplicationRequestBus::BroadcastResult(areAnyEntitiesSelected, &AzToolsFramework::ToolsApplicationRequests::AreAnyEntitiesSelected);
|
||||
action->setCheckable(areAnyEntitiesSelected || m_viewSourceType == ViewSourceType::AZ_Entity);
|
||||
action->setEnabled(areAnyEntitiesSelected || m_viewSourceType == ViewSourceType::AZ_Entity);
|
||||
action->setChecked(m_viewSourceType == ViewSourceType::AZ_Entity);
|
||||
connect(action, &QAction::triggered, this, [this](bool isChecked)
|
||||
{
|
||||
@@ -1554,7 +1580,6 @@ void EditorViewportWidget::ToggleCameraObject()
|
||||
{
|
||||
if (m_viewSourceType == ViewSourceType::SequenceCamera)
|
||||
{
|
||||
gEnv->p3DEngine->GetPostEffectBaseGroup()->SetParam("Dof_Active", 0.0f);
|
||||
ResetToViewSourceType(ViewSourceType::LegacyCamera);
|
||||
}
|
||||
else
|
||||
@@ -1624,8 +1649,8 @@ void EditorViewportWidget::keyPressEvent(QKeyEvent* event)
|
||||
QCoreApplication::sendEvent(GetIEditor()->GetEditorMainWindow(), event);
|
||||
}
|
||||
|
||||
// NOTE: we keep track of keypresses and releases explicitly because the OS/Qt will insert a slight delay between sending
|
||||
// keyevents when the key is held down. This is standard, but makes responding to key events for game style input silly
|
||||
// NOTE: we keep track of key presses and releases explicitly because the OS/Qt will insert a slight delay between sending
|
||||
// key events when the key is held down. This is standard, but makes responding to key events for game style input silly
|
||||
// because we want the movement to be butter smooth.
|
||||
if (!event->isAutoRepeat())
|
||||
{
|
||||
@@ -1805,11 +1830,6 @@ void EditorViewportWidget::SetViewTM(const Matrix34& viewTM, bool bMoveOnly)
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void EditorViewportWidget::RenderSelectedRegion()
|
||||
{
|
||||
if (!m_engine)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
AABB box;
|
||||
GetIEditor()->GetSelectedRegion(box);
|
||||
if (box.IsEmpty())
|
||||
@@ -2004,7 +2024,7 @@ Vec3 EditorViewportWidget::WorldToView3D(const Vec3& wp, [[maybe_unused]] int nF
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
QPoint EditorViewportWidget::WorldToView(const Vec3& wp) const
|
||||
{
|
||||
return m_renderViewport->ViewportWorldToScreen(LYVec3ToAZVec3(wp));
|
||||
return AzToolsFramework::ViewportInteraction::QPointFromScreenPoint(m_renderViewport->ViewportWorldToScreen(LYVec3ToAZVec3(wp)));
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
QPoint EditorViewportWidget::WorldToViewParticleEditor(const Vec3& wp, int width, int height) const
|
||||
@@ -2026,7 +2046,8 @@ QPoint EditorViewportWidget::WorldToViewParticleEditor(const Vec3& wp, int width
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
Vec3 EditorViewportWidget::ViewToWorld(const QPoint& vp, bool* collideWithTerrain, bool onlyTerrain, bool bSkipVegetation, bool bTestRenderMesh, bool* collideWithObject) const
|
||||
Vec3 EditorViewportWidget::ViewToWorld(
|
||||
const QPoint& vp, bool* collideWithTerrain, bool onlyTerrain, bool bSkipVegetation, bool bTestRenderMesh, bool* collideWithObject) const
|
||||
{
|
||||
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::Editor);
|
||||
|
||||
@@ -2037,7 +2058,7 @@ Vec3 EditorViewportWidget::ViewToWorld(const QPoint& vp, bool* collideWithTerrai
|
||||
AZ_UNUSED(bSkipVegetation)
|
||||
AZ_UNUSED(collideWithObject)
|
||||
|
||||
auto ray = m_renderViewport->ViewportScreenToWorldRay(vp);
|
||||
auto ray = m_renderViewport->ViewportScreenToWorldRay(AzToolsFramework::ViewportInteraction::ScreenPointFromQPoint(vp));
|
||||
if (!ray.has_value())
|
||||
{
|
||||
return Vec3(0, 0, 0);
|
||||
@@ -2138,23 +2159,29 @@ bool EditorViewportWidget::AdjustObjectPosition(const ray_hit& hit, Vec3& outNor
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool EditorViewportWidget::RayRenderMeshIntersection(IRenderMesh* pRenderMesh, const Vec3& vInPos, const Vec3& vInDir, Vec3& vOutPos, Vec3& vOutNormal) const
|
||||
{
|
||||
SRayHitInfo hitInfo;
|
||||
AZ_UNUSED(pRenderMesh);
|
||||
AZ_UNUSED(vInPos);
|
||||
AZ_UNUSED(vInDir);
|
||||
AZ_UNUSED(vOutPos);
|
||||
AZ_UNUSED(vOutNormal);
|
||||
return false;
|
||||
/*SRayHitInfo hitInfo;
|
||||
hitInfo.bUseCache = false;
|
||||
hitInfo.bInFirstHit = false;
|
||||
hitInfo.inRay.origin = vInPos;
|
||||
hitInfo.inRay.direction = vInDir.GetNormalized();
|
||||
hitInfo.inReferencePoint = vInPos;
|
||||
hitInfo.fMaxHitDistance = 0;
|
||||
bool bRes = GetIEditor()->Get3DEngine()->RenderMeshRayIntersection(pRenderMesh, hitInfo, nullptr);
|
||||
bool bRes = ???->RenderMeshRayIntersection(pRenderMesh, hitInfo, nullptr);
|
||||
vOutPos = hitInfo.vHitPos;
|
||||
vOutNormal = hitInfo.vHitNormal;
|
||||
return bRes;
|
||||
return bRes;*/
|
||||
}
|
||||
|
||||
void EditorViewportWidget::UnProjectFromScreen(float sx, float sy, float sz, float* px, float* py, float* pz) const
|
||||
{
|
||||
AZ::Vector3 wp;
|
||||
wp = m_renderViewport->ViewportScreenToWorld({(int)sx, m_rcClient.bottom() - ((int)sy)}, sz).value_or(wp);
|
||||
wp = m_renderViewport->ViewportScreenToWorld(AzFramework::ScreenPoint{(int)sx, m_rcClient.bottom() - ((int)sy)}, sz).value_or(wp);
|
||||
*px = wp.GetX();
|
||||
*py = wp.GetY();
|
||||
*pz = wp.GetZ();
|
||||
@@ -2162,9 +2189,9 @@ void EditorViewportWidget::UnProjectFromScreen(float sx, float sy, float sz, flo
|
||||
|
||||
void EditorViewportWidget::ProjectToScreen(float ptx, float pty, float ptz, float* sx, float* sy, float* sz) const
|
||||
{
|
||||
QPoint screenPosition = m_renderViewport->ViewportWorldToScreen(AZ::Vector3{ptx, pty, ptz});
|
||||
*sx = screenPosition.x();
|
||||
*sy = screenPosition.y();
|
||||
AzFramework::ScreenPoint screenPosition = m_renderViewport->ViewportWorldToScreen(AZ::Vector3{ptx, pty, ptz});
|
||||
*sx = screenPosition.m_x;
|
||||
*sy = screenPosition.m_y;
|
||||
*sz = 0.f;
|
||||
}
|
||||
|
||||
@@ -2419,7 +2446,6 @@ void EditorViewportWidget::SetDefaultCamera()
|
||||
return;
|
||||
}
|
||||
ResetToViewSourceType(ViewSourceType::None);
|
||||
gEnv->p3DEngine->GetPostEffectBaseGroup()->SetParam("Dof_Active", 0.0f);
|
||||
GetViewManager()->SetCameraObjectId(m_cameraObjectId);
|
||||
SetName(m_defaultViewName);
|
||||
SetViewTM(m_defaultViewTM);
|
||||
@@ -2602,8 +2628,7 @@ bool EditorViewportWidget::GetActiveCameraPosition(AZ::Vector3& cameraPos)
|
||||
{
|
||||
if (GetIEditor()->IsInGameMode())
|
||||
{
|
||||
const Vec3 camPos = m_engine->GetRenderingCamera().GetPosition();
|
||||
cameraPos = LYVec3ToAZVec3(camPos);
|
||||
cameraPos = m_renderViewport->GetViewportContext()->GetCameraTransform().GetTranslation();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2815,14 +2840,16 @@ void EditorViewportWidget::RestoreViewportAfterGameMode()
|
||||
|
||||
void EditorViewportWidget::UpdateScene()
|
||||
{
|
||||
AZStd::vector<AzFramework::Scene*> scenes;
|
||||
AzFramework::SceneSystemRequestBus::BroadcastResult(scenes, &AzFramework::SceneSystemRequests::GetAllScenes);
|
||||
if (scenes.size() > 0)
|
||||
auto sceneSystem = AzFramework::SceneSystemInterface::Get();
|
||||
if (sceneSystem)
|
||||
{
|
||||
AZ::RPI::SceneNotificationBus::Handler::BusDisconnect();
|
||||
auto scene = scenes[0];
|
||||
m_renderViewport->SetScene(scene);
|
||||
AZ::RPI::SceneNotificationBus::Handler::BusConnect(m_renderViewport->GetViewportContext()->GetRenderScene()->GetId());
|
||||
AZStd::shared_ptr<AzFramework::Scene> mainScene = sceneSystem->GetScene(AzFramework::Scene::MainSceneName);
|
||||
if (mainScene)
|
||||
{
|
||||
AZ::RPI::SceneNotificationBus::Handler::BusDisconnect();
|
||||
m_renderViewport->SetScene(mainScene);
|
||||
AZ::RPI::SceneNotificationBus::Handler::BusConnect(m_renderViewport->GetViewportContext()->GetRenderScene()->GetId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2875,4 +2902,29 @@ void EditorViewportWidget::SetAsActiveViewport()
|
||||
}
|
||||
}
|
||||
|
||||
bool EditorViewportSettings::GridSnappingEnabled() const
|
||||
{
|
||||
return SandboxEditor::GridSnappingEnabled();
|
||||
}
|
||||
|
||||
float EditorViewportSettings::GridSize() const
|
||||
{
|
||||
return SandboxEditor::GridSnappingSize();
|
||||
}
|
||||
|
||||
bool EditorViewportSettings::ShowGrid() const
|
||||
{
|
||||
return SandboxEditor::ShowingGrid();
|
||||
}
|
||||
|
||||
bool EditorViewportSettings::AngleSnappingEnabled() const
|
||||
{
|
||||
return SandboxEditor::AngleSnappingEnabled();
|
||||
}
|
||||
|
||||
float EditorViewportSettings::AngleStep() const
|
||||
{
|
||||
return SandboxEditor::AngleSnappingSize();
|
||||
}
|
||||
|
||||
#include <moc_EditorViewportWidget.cpp>
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
#include <AzCore/Component/EntityId.h>
|
||||
#include <AzCore/std/optional.h>
|
||||
#include <AzFramework/Input/Buses/Requests/InputSystemCursorRequestBus.h>
|
||||
#include <AzFramework/Scene/SceneSystemBus.h>
|
||||
#include <AzFramework/Scene/SceneSystemInterface.h>
|
||||
#include <AzFramework/Asset/AssetCatalogBus.h>
|
||||
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
|
||||
#include <AzToolsFramework/API/EditorCameraBus.h>
|
||||
@@ -189,22 +189,16 @@ public:
|
||||
virtual void OnStartPlayInEditor();
|
||||
virtual void OnStopPlayInEditor();
|
||||
|
||||
// AzToolsFramework::ViewportInteractionRequestBus
|
||||
AzFramework::CameraState GetCameraState();
|
||||
bool GridSnappingEnabled();
|
||||
float GridSize();
|
||||
bool ShowGrid();
|
||||
bool AngleSnappingEnabled();
|
||||
float AngleStep();
|
||||
QPoint ViewportWorldToScreen(const AZ::Vector3& worldPosition);
|
||||
AzFramework::ScreenPoint ViewportWorldToScreen(const AZ::Vector3& worldPosition);
|
||||
|
||||
// AzToolsFramework::ViewportFreezeRequestBus
|
||||
bool IsViewportInputFrozen() override;
|
||||
void FreezeViewportInput(bool freeze) override;
|
||||
|
||||
// AzToolsFramework::MainEditorViewportInteractionRequestBus
|
||||
AZ::EntityId PickEntity(const QPoint& point) override;
|
||||
AZ::Vector3 PickTerrain(const QPoint& point) override;
|
||||
AZ::EntityId PickEntity(const AzFramework::ScreenPoint& point) override;
|
||||
AZ::Vector3 PickTerrain(const AzFramework::ScreenPoint& point) override;
|
||||
float TerrainHeight(const AZ::Vector2& position) override;
|
||||
void FindVisibleEntities(AZStd::vector<AZ::EntityId>& visibleEntitiesOut) override;
|
||||
bool ShowingWorldSpace() override;
|
||||
@@ -234,11 +228,8 @@ public:
|
||||
QPoint ViewportToWidget(const QPoint& point) const;
|
||||
QSize WidgetToViewport(const QSize& size) const;
|
||||
|
||||
/// Take raw input and create a final mouse interaction.
|
||||
/// @attention Do not map **point** from widget to viewport explicitly,
|
||||
/// this is handled internally by BuildMouseInteraction - just pass directly.
|
||||
AzToolsFramework::ViewportInteraction::MouseInteraction BuildMouseInteraction(
|
||||
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, const QPoint& point);
|
||||
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, const QPoint& point) override;
|
||||
|
||||
void SetPlayerPos()
|
||||
{
|
||||
@@ -398,9 +389,6 @@ protected:
|
||||
};
|
||||
void ResetToViewSourceType(const ViewSourceType& viewSourType);
|
||||
|
||||
//! Assigned renderer.
|
||||
IRenderer* m_renderer = nullptr;
|
||||
I3DEngine* m_engine = nullptr;
|
||||
bool m_bRenderContextCreated = false;
|
||||
bool m_bInRotateMode = false;
|
||||
bool m_bInMoveMode = false;
|
||||
@@ -487,10 +475,6 @@ protected:
|
||||
OBB m_GroundOBB;
|
||||
Vec3 m_GroundOBBPos;
|
||||
|
||||
//-------------------------------------------
|
||||
// Render options.
|
||||
bool m_bRenderStats = true;
|
||||
|
||||
// Index of camera objects.
|
||||
mutable GUID m_cameraObjectId;
|
||||
mutable AZ::EntityId m_viewEntityId;
|
||||
@@ -563,8 +547,7 @@ private:
|
||||
void PushDisableRendering();
|
||||
void PopDisableRendering();
|
||||
bool IsRenderingDisabled() const;
|
||||
AzToolsFramework::ViewportInteraction::MousePick BuildMousePickInternal(
|
||||
const QPoint& point) const;
|
||||
AzToolsFramework::ViewportInteraction::MousePick BuildMousePickInternal(const QPoint& point) const;
|
||||
|
||||
void RestoreViewportAfterGameMode();
|
||||
void UpdateCameraFromViewportContext();
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#include "EditorDefs.h"
|
||||
|
||||
#include "EnvironmentPanel.h"
|
||||
|
||||
// Editor
|
||||
#include "GameEngine.h"
|
||||
#include "CryEditDoc.h"
|
||||
|
||||
// Cry3DEngine
|
||||
#include <Cry3DEngine/Environment/OceanEnvironmentBus.h>
|
||||
|
||||
|
||||
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
#include <ui_EnvironmentPanel.h>
|
||||
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CEnvironmentPanel dialog
|
||||
|
||||
CEnvironmentPanel::CEnvironmentPanel(QWidget* pParent /*=nullptr*/)
|
||||
: QWidget(pParent)
|
||||
, ui(new Ui::CEnvironmentPanel)
|
||||
{
|
||||
XmlNodeRef node = GetIEditor()->GetDocument()->GetEnvironmentTemplate();
|
||||
|
||||
// is the feature toggle enabled?
|
||||
bool bHasOceanFeature = false;
|
||||
AZ::OceanFeatureToggleBus::BroadcastResult(bHasOceanFeature, &AZ::OceanFeatureToggleBus::Events::OceanComponentEnabled);
|
||||
if (bHasOceanFeature)
|
||||
{
|
||||
node->findChild("Ocean")->setAttr("hidden", true);
|
||||
node->findChild("OceanAnimation")->setAttr("hidden", true);
|
||||
}
|
||||
|
||||
m_onSetCallback = AZStd::bind(&CCryEditDoc::OnEnvironmentPropertyChanged, GetIEditor()->GetDocument(), AZStd::placeholders::_1);
|
||||
|
||||
ui->setupUi(this);
|
||||
ui->m_wndProps->Setup();
|
||||
ui->m_wndProps->CreateItems(node, m_varBlock, &m_onSetCallback, true);
|
||||
ui->m_wndProps->RebuildCtrl(false);
|
||||
ui->m_wndProps->ExpandAll();
|
||||
connect(ui->APPLYBTN, &QPushButton::clicked, this, &CEnvironmentPanel::OnBnClickedApply);
|
||||
}
|
||||
|
||||
CEnvironmentPanel::~CEnvironmentPanel()
|
||||
{
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CEnvironmentPanel::OnBnClickedApply()
|
||||
{
|
||||
GetIEditor()->GetGameEngine()->ReloadEnvironment();
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_ENVIRONMENTPANEL_H
|
||||
#define CRYINCLUDE_EDITOR_ENVIRONMENTPANEL_H
|
||||
|
||||
#pragma once
|
||||
// EnvironmentPanel.h : header file
|
||||
//
|
||||
|
||||
#include "Util/Variable.h"
|
||||
|
||||
#include <QWidget>
|
||||
#include <QScopedPointer>
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CEnvironmentPanel dialog
|
||||
namespace Ui {
|
||||
class CEnvironmentPanel;
|
||||
}
|
||||
|
||||
class CEnvironmentPanel
|
||||
: public QWidget
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
CEnvironmentPanel(QWidget* pParent = nullptr); // standard constructor
|
||||
~CEnvironmentPanel();
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
CVarBlockPtr m_varBlock;
|
||||
|
||||
public:
|
||||
void OnBnClickedApply();
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::CEnvironmentPanel> ui;
|
||||
|
||||
IVariable::OnSetCallback m_onSetCallback;
|
||||
};
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_ENVIRONMENTPANEL_H
|
||||
@@ -1,56 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CEnvironmentPanel</class>
|
||||
<widget class="QWidget" name="CEnvironmentPanel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>264</width>
|
||||
<height>259</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="ReflectedPropertyControl" name="m_wndProps" native="true">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>200</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QPushButton" name="APPLYBTN">
|
||||
<property name="text">
|
||||
<string>Apply</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>162</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>ReflectedPropertyControl</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>Controls/ReflectedPropertyControl/ReflectedPropertyCtrl.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -19,7 +19,6 @@
|
||||
#pragma once
|
||||
|
||||
// forward declarations.
|
||||
class CMaterial;
|
||||
class CParticleItem;
|
||||
|
||||
#include "BaseLibraryItem.h"
|
||||
|
||||
@@ -519,11 +519,6 @@ void CErrorReportDialog::OnReportItemDblClick(const QModelIndex& index)
|
||||
}
|
||||
bDone = true;
|
||||
}
|
||||
if (pError && pError->pItem != NULL)
|
||||
{
|
||||
GetIEditor()->OpenMaterialLibrary(pError->pItem);
|
||||
bDone = true;
|
||||
}
|
||||
|
||||
if (!bDone && pError && GetIEditor()->GetActiveView())
|
||||
{
|
||||
@@ -581,11 +576,6 @@ void CErrorReportDialog::OnReportHyperlink(const QModelIndex& index)
|
||||
GetIEditor()->SelectObject(pError->pObject);
|
||||
bDone = true;
|
||||
}
|
||||
if (pError && pError->pItem != NULL)
|
||||
{
|
||||
GetIEditor()->OpenMaterialLibrary(pError->pItem);
|
||||
bDone = true;
|
||||
}
|
||||
|
||||
if (!bDone && pError && GetIEditor()->GetActiveView())
|
||||
{
|
||||
|
||||
@@ -22,8 +22,6 @@
|
||||
#include <Maestro/Types/AnimParamType.h>
|
||||
|
||||
// Editor
|
||||
#include "Geometry/EdGeometry.h"
|
||||
#include "Material/Material.h"
|
||||
#include "ViewManager.h"
|
||||
#include "OBJExporter.h"
|
||||
#include "OCMExporter.h"
|
||||
@@ -42,6 +40,9 @@
|
||||
#include "Resource.h"
|
||||
#include "Plugins/ComponentEntityEditorPlugin/Objects/ComponentEntityObject.h"
|
||||
|
||||
#include <IEntityRenderState.h>
|
||||
#include <IStatObj.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
void SetTexture(Export::TPath& outName, IRenderShaderResources* pRes, int nSlot)
|
||||
@@ -79,47 +80,6 @@ Export::CMesh::CMesh()
|
||||
}
|
||||
|
||||
|
||||
void Export::CMesh::SetMaterial(CMaterial* pMtl, CBaseObject* pBaseObj)
|
||||
{
|
||||
if (!pMtl)
|
||||
{
|
||||
cry_strcpy(material.name, pBaseObj->GetName().toUtf8().data());
|
||||
return;
|
||||
}
|
||||
|
||||
cry_strcpy(material.name, pMtl->GetFullName().toUtf8().data());
|
||||
|
||||
_smart_ptr<IMaterial> matInfo = pMtl->GetMatInfo();
|
||||
IRenderShaderResources* pRes = matInfo->GetShaderItem().m_pShaderResources;
|
||||
if (!pRes)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ColorF difColor = pRes->GetColorValue(EFTT_DIFFUSE);
|
||||
material.diffuse.r = difColor.r;
|
||||
material.diffuse.g = difColor.g;
|
||||
material.diffuse.b = difColor.b;
|
||||
material.diffuse.a = difColor.a;
|
||||
|
||||
ColorF specColor = pRes->GetColorValue(EFTT_SPECULAR);
|
||||
material.specular.r = specColor.r;
|
||||
material.specular.g = specColor.g;
|
||||
material.specular.b = specColor.b;
|
||||
material.specular.a = specColor.a;
|
||||
|
||||
material.opacity = pRes->GetStrengthValue(EFTT_OPACITY);
|
||||
material.smoothness = pRes->GetStrengthValue(EFTT_SMOOTHNESS);
|
||||
|
||||
SetTexture(material.mapDiffuse, pRes, EFTT_DIFFUSE);
|
||||
SetTexture(material.mapSpecular, pRes, EFTT_SPECULAR);
|
||||
SetTexture(material.mapOpacity, pRes, EFTT_OPACITY);
|
||||
SetTexture(material.mapNormals, pRes, EFTT_NORMALS);
|
||||
SetTexture(material.mapDecal, pRes, EFTT_DECAL_OVERLAY);
|
||||
SetTexture(material.mapDisplacement, pRes, EFTT_HEIGHT);
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
// CObject
|
||||
Export::CObject::CObject(const char* pName)
|
||||
@@ -416,18 +376,6 @@ void CExportManager::AddMesh(Export::CObject* pObj, const IIndexedMesh* pIndMesh
|
||||
pObj->m_texCoords.push_back(tc);
|
||||
}
|
||||
|
||||
CMaterial* pMtl = 0;
|
||||
|
||||
if (m_pBaseObj)
|
||||
{
|
||||
pMtl = m_pBaseObj->GetRenderMaterial();
|
||||
}
|
||||
|
||||
if (pMtl)
|
||||
{
|
||||
pObj->SetMaterialName(pMtl->GetFullName().toUtf8().data());
|
||||
}
|
||||
|
||||
if (pIndMesh->GetSubSetCount() && !(pIndMesh->GetSubSetCount() == 1 && pIndMesh->GetSubSet(0).nNumIndices == 0))
|
||||
{
|
||||
for (int i = 0; i < pIndMesh->GetSubSetCount(); ++i)
|
||||
@@ -447,23 +395,6 @@ void CExportManager::AddMesh(Export::CObject* pObj, const IIndexedMesh* pIndMesh
|
||||
pMesh->m_faces.push_back(face);
|
||||
}
|
||||
|
||||
if (pMtl)
|
||||
{
|
||||
if (pMtl->IsMultiSubMaterial())
|
||||
{
|
||||
CMaterial* pSubMtl = 0;
|
||||
if (sms.nMatID < pMtl->GetSubMaterialCount())
|
||||
{
|
||||
pSubMtl = pMtl->GetSubMaterial(sms.nMatID);
|
||||
}
|
||||
pMesh->SetMaterial(pSubMtl, m_pBaseObj);
|
||||
}
|
||||
else
|
||||
{
|
||||
pMesh->SetMaterial(pMtl, m_pBaseObj);
|
||||
}
|
||||
}
|
||||
|
||||
pObj->m_meshes.push_back(pMesh);
|
||||
}
|
||||
}
|
||||
@@ -497,10 +428,6 @@ void CExportManager::AddMesh(Export::CObject* pObj, const IIndexedMesh* pIndMesh
|
||||
}
|
||||
}
|
||||
|
||||
if (m_pBaseObj && pMtl)
|
||||
{
|
||||
pMesh->SetMaterial(pMtl, m_pBaseObj);
|
||||
}
|
||||
pObj->m_meshes.push_back(pMesh);
|
||||
}
|
||||
}
|
||||
@@ -569,53 +496,6 @@ bool CExportManager::AddStatObj(Export::CObject* pObj, IStatObj* pStatObj, Matri
|
||||
|
||||
bool CExportManager::AddMeshes(Export::CObject* pObj)
|
||||
{
|
||||
CEdGeometry* pEdGeom = m_pBaseObj->GetGeometry();
|
||||
IIndexedMesh* pIndMesh = 0;
|
||||
|
||||
if (pEdGeom)
|
||||
{
|
||||
size_t idx = 0;
|
||||
size_t nextIdx = 0;
|
||||
do
|
||||
{
|
||||
pIndMesh = 0;
|
||||
if (m_isOccluder)
|
||||
{
|
||||
if (pEdGeom->GetIStatObj() && pEdGeom->GetIStatObj()->GetLodObject(2))
|
||||
{
|
||||
pIndMesh = pEdGeom->GetIStatObj()->GetLodObject(2)->GetIndexedMesh(true);
|
||||
}
|
||||
if (!pIndMesh && pEdGeom->GetIStatObj() && pEdGeom->GetIStatObj()->GetLodObject(1))
|
||||
{
|
||||
pIndMesh = pEdGeom->GetIStatObj()->GetLodObject(1)->GetIndexedMesh(true);
|
||||
}
|
||||
}
|
||||
|
||||
if (!pIndMesh)
|
||||
{
|
||||
pIndMesh = pEdGeom->GetIndexedMesh(idx);
|
||||
nextIdx++;
|
||||
}
|
||||
|
||||
if (!pIndMesh)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
Matrix34 tm;
|
||||
pEdGeom->GetTM(&tm, idx);
|
||||
Matrix34A objTM = tm;
|
||||
AddMesh(pObj, pIndMesh, &objTM);
|
||||
idx = nextIdx;
|
||||
}
|
||||
while (pIndMesh && idx);
|
||||
|
||||
if (idx > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_pBaseObj->GetType() == OBJTYPE_AZENTITY)
|
||||
{
|
||||
CEntityObject* pEntityObject = (CEntityObject*)m_pBaseObj;
|
||||
@@ -623,11 +503,7 @@ bool CExportManager::AddMeshes(Export::CObject* pObj)
|
||||
|
||||
if (pEngineNode)
|
||||
{
|
||||
if (m_isPrecaching)
|
||||
{
|
||||
GetIEditor()->Get3DEngine()->PrecacheRenderNode(pEngineNode, 0);
|
||||
}
|
||||
else
|
||||
if (!m_isPrecaching)
|
||||
{
|
||||
for (int i = 0; i < pEngineNode->GetSlotCount(); ++i)
|
||||
{
|
||||
@@ -1166,35 +1042,6 @@ bool CExportManager::AddSelectedEntityObjects()
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool CExportManager::AddSelectedObjects()
|
||||
{
|
||||
CSelectionGroup* pSelection = GetIEditor()->GetSelection();
|
||||
|
||||
int numObjects = pSelection->GetCount();
|
||||
if (numObjects > m_data.m_objects.size())
|
||||
{
|
||||
m_data.m_objects.reserve(numObjects + 1); // +1 for terrain
|
||||
}
|
||||
// First run pipeline to precache geometry
|
||||
m_isPrecaching = true;
|
||||
for (int i = 0; i < numObjects; i++)
|
||||
{
|
||||
AddObject(pSelection->GetObject(i));
|
||||
}
|
||||
|
||||
GetIEditor()->Get3DEngine()->ProposeContentPrecache();
|
||||
|
||||
// Repeat pipeline to collect geometry
|
||||
m_isPrecaching = false;
|
||||
for (int i = 0; i < numObjects; i++)
|
||||
{
|
||||
AddObject(pSelection->GetObject(i));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CExportManager::AddSelectedRegionObjects()
|
||||
{
|
||||
AABB box;
|
||||
@@ -1219,8 +1066,6 @@ bool CExportManager::AddSelectedRegionObjects()
|
||||
AddObject(objects[i]);
|
||||
}
|
||||
|
||||
GetIEditor()->Get3DEngine()->ProposeContentPrecache();
|
||||
|
||||
// Repeat pipeline to collect geometry
|
||||
m_isPrecaching = false;
|
||||
for (size_t i = 0; i < numObjects; ++i)
|
||||
@@ -1260,7 +1105,7 @@ bool CExportManager::ExportToFile(const char* filename, bool bClearDataAfterExpo
|
||||
}
|
||||
|
||||
|
||||
bool CExportManager::Export(const char* defaultName, const char* defaultExt, const char* defaultPath, bool isSelectedObjects, bool isSelectedRegionObjects, bool isOccluder, bool bAnimationExport)
|
||||
bool CExportManager::Export(const char* defaultName, const char* defaultExt, const char* defaultPath, [[maybe_unused]] bool isSelectedObjects, bool isSelectedRegionObjects, bool isOccluder, bool bAnimationExport)
|
||||
{
|
||||
m_bAnimationExport = bAnimationExport;
|
||||
|
||||
@@ -1304,10 +1149,6 @@ bool CExportManager::Export(const char* defaultName, const char* defaultExt, con
|
||||
if (m_bAnimationExport || CFileUtil::SelectSaveFile(filters, defaultExt, defaultPath, newFilename))
|
||||
{
|
||||
WaitCursor wait;
|
||||
if (isSelectedObjects)
|
||||
{
|
||||
AddSelectedObjects();
|
||||
}
|
||||
if (isSelectedRegionObjects)
|
||||
{
|
||||
AddSelectedRegionObjects();
|
||||
|
||||
@@ -43,8 +43,6 @@ namespace Export
|
||||
virtual int GetFaceCount() const { return m_faces.size(); }
|
||||
virtual const Face* GetFaceBuffer() const { return m_faces.size() ? &m_faces[0] : 0; }
|
||||
|
||||
void SetMaterial(CMaterial* pMtl, CBaseObject* pBaseObj);
|
||||
|
||||
private:
|
||||
std::vector<Face> m_faces;
|
||||
|
||||
@@ -130,10 +128,6 @@ public:
|
||||
bool Export(const char* defaultName, const char* defaultExt = "", const char* defaultPath = "", bool isSelectedObjects = true,
|
||||
bool isSelectedRegionObjects = false, bool isOccluder = false, bool bAnimationExport = false);
|
||||
|
||||
//! Add to Export Data geometry from selected objects
|
||||
//! return true if succeed, otherwise false
|
||||
bool AddSelectedObjects();
|
||||
|
||||
bool AddSelectedEntityObjects();
|
||||
|
||||
//! Add to Export Data geometry from objects inside selected region volume
|
||||
|
||||
@@ -34,15 +34,10 @@
|
||||
// Editor
|
||||
#include "IEditorImpl.h"
|
||||
#include "CryEditDoc.h"
|
||||
#include "Geometry/EdMesh.h"
|
||||
#include "Mission.h"
|
||||
#include "Settings.h"
|
||||
|
||||
// CryCommon
|
||||
#include <CryCommon/I3DEngine.h>
|
||||
#include <CryCommon/INavigationSystem.h>
|
||||
#include <CryCommon/IDeferredCollisionEvent.h>
|
||||
#include <CryCommon/ITimeOfDay.h>
|
||||
#include <CryCommon/LyShine/ILyShine.h>
|
||||
#include <CryCommon/MainThreadRenderRequestBus.h>
|
||||
|
||||
@@ -50,7 +45,6 @@
|
||||
#include "CryEdit.h"
|
||||
|
||||
#include "ViewManager.h"
|
||||
#include "Util/Ruler.h"
|
||||
#include "AnimationContext.h"
|
||||
#include "UndoViewPosition.h"
|
||||
#include "UndoViewRotation.h"
|
||||
@@ -283,7 +277,6 @@ AZ_POP_DISABLE_WARNING
|
||||
AZ::Interface<IEditorCameraController>::Unregister(this);
|
||||
GetIEditor()->UnregisterNotifyListener(this);
|
||||
m_pISystem->GetIMovieSystem()->SetCallback(NULL);
|
||||
CEdMesh::ReleaseAll();
|
||||
|
||||
if (m_gameDll)
|
||||
{
|
||||
@@ -391,7 +384,6 @@ void CGameEngine::SetCurrentViewRotation(const AZ::Vector3& rotation)
|
||||
AZ::Outcome<void, AZStd::string> CGameEngine::Init(
|
||||
bool bPreviewMode,
|
||||
bool bTestMode,
|
||||
bool bShaderCacheGen,
|
||||
const char* sInCmdLine,
|
||||
IInitializeUIInfo* logo,
|
||||
HWND hwndForInputSystem)
|
||||
@@ -428,12 +420,10 @@ AZ::Outcome<void, AZStd::string> CGameEngine::Init(
|
||||
#else
|
||||
sip.hWnd = hwndForInputSystem;
|
||||
#endif
|
||||
sip.hWndForInputSystem = hwndForInputSystem;
|
||||
|
||||
sip.pLogCallback = &m_logFile;
|
||||
sip.sLogFileName = "@log@/Editor.log";
|
||||
sip.pUserCallback = m_pSystemUserCallback;
|
||||
sip.pValidator = GetIEditor()->GetErrorReport(); // Assign validator from Editor.
|
||||
|
||||
if (sInCmdLine)
|
||||
{
|
||||
@@ -449,10 +439,6 @@ AZ::Outcome<void, AZStd::string> CGameEngine::Init(
|
||||
m_modalWindowDismisser = AZStd::make_unique<ModalWindowDismisser>();
|
||||
}
|
||||
|
||||
if (bShaderCacheGen)
|
||||
{
|
||||
sip.bSkipFont = true;
|
||||
}
|
||||
AssetProcessConnectionStatus apConnectionStatus;
|
||||
|
||||
m_pISystem = pfnCreateSystemInterface(sip);
|
||||
@@ -493,13 +479,6 @@ AZ::Outcome<void, AZStd::string> CGameEngine::Init(
|
||||
|
||||
SetEditorCoreEnvironment(gEnv);
|
||||
|
||||
if (gEnv
|
||||
&& gEnv->p3DEngine
|
||||
&& gEnv->p3DEngine->GetTimeOfDay())
|
||||
{
|
||||
gEnv->p3DEngine->GetTimeOfDay()->BeginEditMode();
|
||||
}
|
||||
|
||||
if (gEnv && gEnv->pMovieSystem)
|
||||
{
|
||||
gEnv->pMovieSystem->EnablePhysicsEvents(m_bSimulationMode);
|
||||
@@ -522,7 +501,6 @@ AZ::Outcome<void, AZStd::string> CGameEngine::Init(
|
||||
|
||||
bool CGameEngine::InitGame(const char*)
|
||||
{
|
||||
// in editor we do it later, bExecuteCommandLine was set to false
|
||||
m_pISystem->ExecuteCommandLine();
|
||||
|
||||
return true;
|
||||
@@ -549,26 +527,14 @@ void CGameEngine::SetLevelPath(const QString& path)
|
||||
{
|
||||
m_levelExtension = defaultExtension;
|
||||
}
|
||||
|
||||
if (gEnv->p3DEngine)
|
||||
{
|
||||
gEnv->p3DEngine->SetLevelPath(m_levelPath.toUtf8().data());
|
||||
}
|
||||
}
|
||||
|
||||
void CGameEngine::SetMissionName(const QString& mission)
|
||||
{
|
||||
m_missionName = mission;
|
||||
}
|
||||
|
||||
bool CGameEngine::LoadLevel(
|
||||
const QString& mission,
|
||||
[[maybe_unused]] bool bDeleteAIGraph,
|
||||
bool bReleaseResources)
|
||||
{
|
||||
LOADING_TIME_PROFILE_SECTION(GetIEditor()->GetSystem());
|
||||
m_bLevelLoaded = false;
|
||||
m_missionName = mission;
|
||||
CLogFile::FormatLine("Loading map '%s' into engine...", m_levelPath.toUtf8().data());
|
||||
// Switch the current directory back to the Primary CD folder first.
|
||||
// The engine might have trouble to find some files when the current
|
||||
@@ -607,30 +573,17 @@ bool CGameEngine::LoadLevel(
|
||||
|
||||
}
|
||||
|
||||
// Load level in 3d engine.
|
||||
if (gEnv->p3DEngine && !gEnv->p3DEngine->InitLevelForEditor(m_levelPath.toUtf8().data(), m_missionName.toUtf8().data()))
|
||||
{
|
||||
CLogFile::WriteLine("ERROR: Can't load level !");
|
||||
QMessageBox::critical(QApplication::activeWindow(), QString(), QObject::tr("ERROR: Can't load level !"));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Audio: notify audio of level loading start?
|
||||
GetIEditor()->GetObjectManager()->SendEvent(EVENT_REFRESH);
|
||||
|
||||
m_bLevelLoaded = true;
|
||||
|
||||
if (!bReleaseResources)
|
||||
{
|
||||
ReloadEnvironment();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CGameEngine::ReloadLevel()
|
||||
{
|
||||
if (!LoadLevel(GetMissionName(), false, false))
|
||||
if (!LoadLevel(false, false))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -638,61 +591,8 @@ bool CGameEngine::ReloadLevel()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CGameEngine::LoadMission(const QString& mission)
|
||||
{
|
||||
if (!IsLevelLoaded())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mission != m_missionName)
|
||||
{
|
||||
m_missionName = mission;
|
||||
gEnv->p3DEngine->LoadMissionDataFromXMLNode(m_missionName.toUtf8().data());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CGameEngine::ReloadEnvironment()
|
||||
{
|
||||
if (!gEnv->p3DEngine)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!IsLevelLoaded() && !m_bJustCreated)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!GetIEditor()->GetDocument())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
XmlNodeRef env = XmlHelpers::CreateXmlNode("Environment");
|
||||
CXmlTemplate::SetValues(GetIEditor()->GetDocument()->GetEnvironmentTemplate(), env);
|
||||
|
||||
// Notify mission that environment may be changed.
|
||||
GetIEditor()->GetDocument()->GetCurrentMission()->OnEnvironmentChange();
|
||||
|
||||
QString xmlStr = QString::fromLatin1(env->getXML());
|
||||
|
||||
// Reload level data in engine.
|
||||
gEnv->p3DEngine->LoadEnvironmentSettingsFromXML(env);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CGameEngine::SwitchToInGame()
|
||||
{
|
||||
if (gEnv->p3DEngine)
|
||||
{
|
||||
gEnv->p3DEngine->DisablePostEffects();
|
||||
gEnv->p3DEngine->ResetPostEffects();
|
||||
}
|
||||
|
||||
auto streamer = AZ::Interface<AZ::IO::IStreamer>::Get();
|
||||
if (streamer)
|
||||
{
|
||||
@@ -705,26 +605,9 @@ void CGameEngine::SwitchToInGame()
|
||||
|
||||
GetIEditor()->Notify(eNotify_OnBeginGameMode);
|
||||
|
||||
m_pISystem->SetThreadState(ESubsys_Physics, false);
|
||||
|
||||
if (gEnv->p3DEngine)
|
||||
{
|
||||
gEnv->p3DEngine->ResetParticlesAndDecals();
|
||||
}
|
||||
|
||||
m_pISystem->GetIMovieSystem()->EnablePhysicsEvents(true);
|
||||
m_bInGameMode = true;
|
||||
|
||||
CRuler* pRuler = GetIEditor()->GetRuler();
|
||||
if (pRuler)
|
||||
{
|
||||
pRuler->SetActive(false);
|
||||
}
|
||||
|
||||
if (gEnv->p3DEngine)
|
||||
{
|
||||
gEnv->p3DEngine->GetTimeOfDay()->EndEditMode();
|
||||
}
|
||||
gEnv->pSystem->GetViewCamera().SetMatrix(m_playerViewTM);
|
||||
|
||||
// Disable accelerators.
|
||||
@@ -758,26 +641,9 @@ void CGameEngine::SwitchToInEditor()
|
||||
}
|
||||
m_pISystem->GetIMovieSystem()->Reset(false, false);
|
||||
|
||||
m_pISystem->SetThreadState(ESubsys_Physics, false);
|
||||
|
||||
if (gEnv->p3DEngine)
|
||||
{
|
||||
// Reset 3d engine effects
|
||||
gEnv->p3DEngine->DisablePostEffects();
|
||||
gEnv->p3DEngine->ResetPostEffects();
|
||||
gEnv->p3DEngine->ResetParticlesAndDecals();
|
||||
}
|
||||
|
||||
CViewport* pGameViewport = GetIEditor()->GetViewManager()->GetGameViewport();
|
||||
|
||||
m_pISystem->GetIMovieSystem()->EnablePhysicsEvents(m_bSimulationMode);
|
||||
if (gEnv->p3DEngine)
|
||||
{
|
||||
gEnv->p3DEngine->GetTimeOfDay()->BeginEditMode();
|
||||
|
||||
// this has to be done before the RemoveSink() call, or else some entities may not be removed
|
||||
gEnv->p3DEngine->GetDeferredPhysicsEventManager()->ClearDeferredEvents();
|
||||
}
|
||||
|
||||
// Enable accelerators.
|
||||
GetIEditor()->EnableAcceleratos(true);
|
||||
@@ -865,7 +731,6 @@ void CGameEngine::SetGameMode(bool bInGame)
|
||||
|
||||
// Ignore updates while changing in and out of game mode
|
||||
m_bIgnoreUpdates = true;
|
||||
LockResources();
|
||||
|
||||
// Switching modes will destroy the current AzFramework::EntityConext which may contain
|
||||
// data the queued events hold on to, so execute all queued events before switching.
|
||||
@@ -891,7 +756,6 @@ void CGameEngine::SetGameMode(bool bInGame)
|
||||
|
||||
GetISystem()->GetISystemEventDispatcher()->OnSystemEvent(ESYSTEM_EVENT_EDITOR_GAME_MODE_CHANGED, bInGame, 0);
|
||||
|
||||
UnlockResources();
|
||||
m_bIgnoreUpdates = false;
|
||||
|
||||
GetISystem()->GetISystemEventDispatcher()->OnSystemEvent(ESYSTEM_EVENT_GAME_MODE_SWITCH_END, bInGame, 0);
|
||||
@@ -906,19 +770,8 @@ void CGameEngine::SetSimulationMode(bool enabled, bool bOnlyPhysics)
|
||||
|
||||
m_pISystem->GetIMovieSystem()->EnablePhysicsEvents(enabled);
|
||||
|
||||
if (!bOnlyPhysics)
|
||||
{
|
||||
LockResources();
|
||||
}
|
||||
|
||||
if (enabled)
|
||||
{
|
||||
CRuler* pRuler = GetIEditor()->GetRuler();
|
||||
if (pRuler)
|
||||
{
|
||||
pRuler->SetActive(false);
|
||||
}
|
||||
|
||||
GetIEditor()->Notify(eNotify_OnBeginSimulationMode);
|
||||
}
|
||||
else
|
||||
@@ -931,39 +784,14 @@ void CGameEngine::SetSimulationMode(bool enabled, bool bOnlyPhysics)
|
||||
// Enables engine to know about simulation mode.
|
||||
gEnv->SetIsEditorSimulationMode(enabled);
|
||||
|
||||
m_pISystem->SetThreadState(ESubsys_Physics, false);
|
||||
|
||||
if (m_bSimulationMode)
|
||||
{
|
||||
if (!bOnlyPhysics)
|
||||
{
|
||||
if (m_pISystem->GetI3DEngine())
|
||||
{
|
||||
m_pISystem->GetI3DEngine()->ResetPostEffects();
|
||||
}
|
||||
|
||||
GetIEditor()->SetConsoleVar("ai_ignoreplayer", 1);
|
||||
//GetIEditor()->SetConsoleVar( "ai_soundperception",0 );
|
||||
}
|
||||
|
||||
// [Anton] the order of the next 3 calls changed, since, EVENT_INGAME loads physics state (if any),
|
||||
// and Reset should be called before it
|
||||
GetIEditor()->GetObjectManager()->SendEvent(EVENT_INGAME);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!bOnlyPhysics)
|
||||
{
|
||||
GetIEditor()->SetConsoleVar("ai_ignoreplayer", 0);
|
||||
//GetIEditor()->SetConsoleVar( "ai_soundperception",1 );
|
||||
|
||||
if (m_pISystem->GetI3DEngine())
|
||||
{
|
||||
m_pISystem->GetI3DEngine()->ResetPostEffects();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
GetIEditor()->GetObjectManager()->SendEvent(EVENT_OUTOFGAME);
|
||||
}
|
||||
|
||||
@@ -983,23 +811,9 @@ void CGameEngine::SetSimulationMode(bool enabled, bool bOnlyPhysics)
|
||||
AzToolsFramework::EditorEntityContextRequestBus::Broadcast(&AzToolsFramework::EditorEntityContextRequestBus::Events::StartPlayInEditor);
|
||||
}
|
||||
|
||||
if (!bOnlyPhysics)
|
||||
{
|
||||
UnlockResources();
|
||||
}
|
||||
|
||||
AzFramework::InputChannelRequestBus::Broadcast(&AzFramework::InputChannelRequests::ResetState);
|
||||
}
|
||||
|
||||
void CGameEngine::ResetResources()
|
||||
{
|
||||
if (gEnv->p3DEngine)
|
||||
{
|
||||
gEnv->p3DEngine->UnloadLevel();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CGameEngine::SetPlayerViewMatrix(const Matrix34& tm, [[maybe_unused]] bool bEyePos)
|
||||
{
|
||||
m_playerViewTM = tm;
|
||||
@@ -1080,22 +894,6 @@ void CGameEngine::Update()
|
||||
// [marco] check current sound and vis areas for music etc.
|
||||
// but if in game mode, 'cos is already done in the above call to game->update()
|
||||
unsigned int updateFlags = ESYSUPDATE_EDITOR;
|
||||
|
||||
CRuler* pRuler = GetIEditor()->GetRuler();
|
||||
const bool bRulerNeedsUpdate = (pRuler && pRuler->HasQueuedPaths());
|
||||
|
||||
if (!m_bSimulationMode)
|
||||
{
|
||||
updateFlags |= ESYSUPDATE_IGNORE_PHYSICS;
|
||||
}
|
||||
|
||||
bool bUpdateAIPhysics = GetSimulationMode();
|
||||
|
||||
if (bUpdateAIPhysics)
|
||||
{
|
||||
updateFlags |= ESYSUPDATE_EDITOR_AI_PHYSICS;
|
||||
}
|
||||
|
||||
GetIEditor()->GetAnimation()->Update();
|
||||
GetIEditor()->GetSystem()->UpdatePreTickBus(updateFlags);
|
||||
componentApplication->Tick(gEnv->pTimer->GetFrameTime(ITimer::ETIMER_GAME));
|
||||
@@ -1107,24 +905,6 @@ void CGameEngine::OnEditorNotifyEvent(EEditorNotifyEvent event)
|
||||
{
|
||||
switch (event)
|
||||
{
|
||||
case eNotify_OnBeginNewScene:
|
||||
case eNotify_OnBeginSceneOpen:
|
||||
{
|
||||
ResetResources();
|
||||
}
|
||||
break;
|
||||
case eNotify_OnEndSceneOpen:
|
||||
case eNotify_OnEndTerrainRebuild:
|
||||
{
|
||||
}
|
||||
case eNotify_OnEndNewScene: // intentional fall-through?
|
||||
{
|
||||
if (gEnv->p3DEngine)
|
||||
{
|
||||
gEnv->p3DEngine->PostLoadLevel();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case eNotify_OnSplashScreenDestroyed:
|
||||
{
|
||||
if (m_pSystemUserCallback != NULL)
|
||||
@@ -1136,22 +916,6 @@ void CGameEngine::OnEditorNotifyEvent(EEditorNotifyEvent event)
|
||||
}
|
||||
}
|
||||
|
||||
void CGameEngine::LockResources()
|
||||
{
|
||||
if (gEnv->p3DEngine)
|
||||
{
|
||||
gEnv->p3DEngine->LockCGFResources();
|
||||
}
|
||||
}
|
||||
|
||||
void CGameEngine::UnlockResources()
|
||||
{
|
||||
if (gEnv->p3DEngine)
|
||||
{
|
||||
gEnv->p3DEngine->UnlockCGFResources();
|
||||
}
|
||||
}
|
||||
|
||||
void CGameEngine::OnTerrainModified(const Vec2& modPosition, float modAreaRadius, bool fullTerrain)
|
||||
{
|
||||
INavigationSystem* pNavigationSystem = nullptr; // INavigationSystem will be converted to an AZInterface (LY-111343)
|
||||
|
||||
@@ -79,7 +79,6 @@ public:
|
||||
AZ::Outcome<void, AZStd::string> Init(
|
||||
bool bPreviewMode,
|
||||
bool bTestMode,
|
||||
bool bShaderCacheGen,
|
||||
const char* sCmdLine,
|
||||
IInitializeUIInfo* logo,
|
||||
HWND hwndForInputSystem);
|
||||
@@ -89,15 +88,10 @@ public:
|
||||
//! Load new terrain level into 3d engine.
|
||||
//! Also load AI triangulation for this level.
|
||||
bool LoadLevel(
|
||||
const QString& mission,
|
||||
bool bDeleteAIGraph,
|
||||
bool bReleaseResources);
|
||||
//!* Reload level if it was already loaded.
|
||||
bool ReloadLevel();
|
||||
//! Load new mission.
|
||||
bool LoadMission(const QString& mission);
|
||||
//! Reload environment settings in currently loaded level.
|
||||
bool ReloadEnvironment();
|
||||
//! Request to switch In/Out of game mode on next update.
|
||||
//! The switch will happen when no sub systems are currently being updated.
|
||||
//! @param inGame When true editor switch to game mode.
|
||||
@@ -111,14 +105,10 @@ public:
|
||||
bool IsLevelLoaded() const { return m_bLevelLoaded; };
|
||||
//! Assign new level path name.
|
||||
void SetLevelPath(const QString& path);
|
||||
//! Assign new current mission name.
|
||||
void SetMissionName(const QString& mission);
|
||||
//! Return name of currently loaded level.
|
||||
const QString& GetLevelName() const { return m_levelName; };
|
||||
//! Return extension of currently loaded level.
|
||||
const QString& GetLevelExtension() const { return m_levelExtension; };
|
||||
//! Return name of currently active mission.
|
||||
const QString& GetMissionName() const { return m_missionName; };
|
||||
//! Get fully specified level path.
|
||||
const QString& GetLevelPath() const { return m_levelPath; };
|
||||
//! Query if engine is in game mode.
|
||||
@@ -142,9 +132,6 @@ public:
|
||||
//! Called every frame.
|
||||
void Update();
|
||||
virtual void OnEditorNotifyEvent(EEditorNotifyEvent event);
|
||||
void LockResources();
|
||||
void UnlockResources();
|
||||
void ResetResources();
|
||||
void OnTerrainModified(const Vec2& modPosition, float modAreaRadius, bool fullTerrain);
|
||||
void OnAreaModified(const AABB& modifiedArea);
|
||||
|
||||
@@ -179,7 +166,6 @@ private:
|
||||
CLogFile m_logFile;
|
||||
QString m_levelName;
|
||||
QString m_levelExtension;
|
||||
QString m_missionName;
|
||||
QString m_levelPath;
|
||||
QString m_MOD;
|
||||
bool m_bLevelLoaded;
|
||||
|
||||
@@ -24,20 +24,12 @@
|
||||
#include "GameExporter.h"
|
||||
#include "GameEngine.h"
|
||||
#include "CryEditDoc.h"
|
||||
#include "Mission.h"
|
||||
#include "ShaderCache.h"
|
||||
#include "UsedResources.h"
|
||||
#include "Material/MaterialManager.h"
|
||||
#include "Material/MaterialLibrary.h"
|
||||
#include "WaitProgress.h"
|
||||
#include "Util/CryMemFile.h"
|
||||
#include "Objects/ObjectManager.h"
|
||||
|
||||
#include "Objects/ObjectPhysicsManager.h"
|
||||
#include "Objects/EntityObject.h"
|
||||
#include "LensFlareEditor/LensFlareManager.h"
|
||||
#include "LensFlareEditor/LensFlareLibrary.h"
|
||||
#include "LensFlareEditor/LensFlareItem.h"
|
||||
|
||||
#include <AzFramework/Terrain/TerrainDataRequestBus.h>
|
||||
|
||||
@@ -137,10 +129,6 @@ bool CGameExporter::Export(unsigned int flags, [[maybe_unused]] EEndian eExportE
|
||||
m_levelPath = Path::RemoveBackslash(sLevelPath);
|
||||
QString rootLevelPath = Path::AddSlash(pGameEngine->GetLevelPath());
|
||||
|
||||
// Make sure we unload any unused CGFs before exporting so that they don't end up in
|
||||
// the level data.
|
||||
pEditor->Get3DEngine()->FreeUnusedCGFResources();
|
||||
|
||||
CCryEditDoc* pDocument = pEditor->GetDocument();
|
||||
|
||||
if (flags & eExp_Fast)
|
||||
@@ -189,21 +177,11 @@ bool CGameExporter::Export(unsigned int flags, [[maybe_unused]] EEndian eExportE
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Inform all objects that an export is about to begin
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
if (exportSuccessful)
|
||||
{
|
||||
GetIEditor()->GetObjectManager()->GetPhysicsManager()->PrepareForExport();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Export all data to the game
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
if (exportSuccessful)
|
||||
{
|
||||
ExportVisAreas(sLevelPath.toUtf8().data(), eExportEndian);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Exporting map setttings
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
@@ -216,10 +194,8 @@ bool CGameExporter::Export(unsigned int flags, [[maybe_unused]] EEndian eExportE
|
||||
|
||||
ExportLevelInfo(sLevelPath);
|
||||
|
||||
ExportLevelLensFlares(sLevelPath);
|
||||
ExportLevelResourceList(sLevelPath);
|
||||
ExportLevelUsedResourceList(sLevelPath);
|
||||
ExportLevelShaderCache(sLevelPath);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// End Exporting Game data.
|
||||
@@ -266,47 +242,6 @@ bool CGameExporter::Export(unsigned int flags, [[maybe_unused]] EEndian eExportE
|
||||
return exportSuccessful;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CGameExporter::ExportVisAreas(const char* pszGamePath, EEndian eExportEndian)
|
||||
{
|
||||
char szFileOutputPath[_MAX_PATH];
|
||||
|
||||
// export visareas
|
||||
IEditor* pEditor = GetIEditor();
|
||||
|
||||
// remove old files
|
||||
sprintf_s(szFileOutputPath, "%s%s", pszGamePath, COMPILED_VISAREA_MAP_FILE_NAME);
|
||||
m_levelPak.m_pakFile.RemoveFile(szFileOutputPath);
|
||||
|
||||
SHotUpdateInfo exportInfo;
|
||||
I3DEngine* p3DEngine = pEditor->Get3DEngine();
|
||||
|
||||
if (eExportEndian == GetPlatformEndian()) // skip second export, this data is common for PC and consoles
|
||||
{
|
||||
std::vector<struct IStatObj*>* pTempBrushTable = NULL;
|
||||
std::vector<_smart_ptr<IMaterial>>* pTempMatsTable = NULL;
|
||||
std::vector<struct IStatInstGroup*>* pTempVegGroupTable = NULL;
|
||||
|
||||
// export visareas
|
||||
CLogFile::WriteLine("Exporting indoors...");
|
||||
pEditor->SetStatusText("Exporting indoors...");
|
||||
if (IVisAreaManager* pVisAreaManager = p3DEngine->GetIVisAreaManager())
|
||||
{
|
||||
if (int nSize = pVisAreaManager->GetCompiledDataSize())
|
||||
{ // get visareas data from 3dengine and save it into file
|
||||
uint8* pData = new uint8[nSize];
|
||||
pVisAreaManager->GetCompiledData(pData, nSize, &pTempBrushTable, &pTempMatsTable, &pTempVegGroupTable, eExportEndian);
|
||||
sprintf_s(szFileOutputPath, "%s%s", pszGamePath, COMPILED_VISAREA_MAP_FILE_NAME);
|
||||
CCryMemFile visareasCompiledFile;
|
||||
visareasCompiledFile.Write(pData, nSize);
|
||||
m_levelPak.m_pakFile.UpdateFile(szFileOutputPath, visareasCompiledFile);
|
||||
delete[] pData;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CGameExporter::ExportOcclusionMesh(const char* pszGamePath)
|
||||
{
|
||||
@@ -331,7 +266,7 @@ void CGameExporter::ExportOcclusionMesh(const char* pszGamePath)
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CGameExporter::ExportLevelData(const QString& path, bool bExportMission)
|
||||
void CGameExporter::ExportLevelData(const QString& path, bool /*bExportMission*/)
|
||||
{
|
||||
IEditor* pEditor = GetIEditor();
|
||||
pEditor->SetStatusText(QObject::tr("Exporting LevelData.xml..."));
|
||||
@@ -344,51 +279,6 @@ void CGameExporter::ExportLevelData(const QString& path, bool bExportMission)
|
||||
XmlNodeRef rootAction = XmlHelpers::CreateXmlNode("LevelDataAction");
|
||||
rootAction->setAttr("SandboxVersion", versionString);
|
||||
|
||||
ExportMapInfo(root);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Export materials.
|
||||
ExportMaterials(root, path);
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CCryEditDoc* pDocument = pEditor->GetDocument();
|
||||
CMission* pCurrentMission = 0;
|
||||
|
||||
if (bExportMission)
|
||||
{
|
||||
pCurrentMission = pDocument->GetCurrentMission();
|
||||
// Save contents of current mission.
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Export missions tag.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
XmlNodeRef missionsNode = rootAction->newChild("Missions");
|
||||
QString missionFileName;
|
||||
QString currentMissionFileName;
|
||||
I3DEngine* p3DEngine = pEditor->Get3DEngine();
|
||||
for (int i = 0; i < pDocument->GetMissionCount(); i++)
|
||||
{
|
||||
CMission* pMission = pDocument->GetMission(i);
|
||||
|
||||
QString name = pMission->GetName();
|
||||
name.replace(' ', '_');
|
||||
missionFileName = QStringLiteral("Mission_%1.xml").arg(name);
|
||||
|
||||
XmlNodeRef missionDescNode = missionsNode->newChild("Mission");
|
||||
missionDescNode->setAttr("Name", pMission->GetName().toUtf8().data());
|
||||
missionDescNode->setAttr("File", missionFileName.toUtf8().data());
|
||||
missionDescNode->setAttr("CGFCount", p3DEngine->GetLoadedObjectCount());
|
||||
|
||||
int nProgressBarRange = m_numExportedMaterials / 10 + p3DEngine->GetLoadedObjectCount();
|
||||
missionDescNode->setAttr("ProgressBarRange", nProgressBarRange);
|
||||
|
||||
if (pMission == pCurrentMission)
|
||||
{
|
||||
currentMissionFileName = missionFileName;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Save Level Data XML
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -404,36 +294,15 @@ void CGameExporter::ExportLevelData(const QString& path, bool bExportMission)
|
||||
fileAction.Write(xmlDataAction.c_str(), xmlDataAction.length());
|
||||
m_levelPak.m_pakFile.UpdateFile(levelDataActionFile.toUtf8().data(), fileAction);
|
||||
|
||||
if (bExportMission)
|
||||
AZStd::vector<char> entitySaveBuffer;
|
||||
AZ::IO::ByteContainerStream<AZStd::vector<char> > entitySaveStream(&entitySaveBuffer);
|
||||
bool savedEntities = false;
|
||||
EBUS_EVENT_RESULT(savedEntities, AzToolsFramework::EditorEntityContextRequestBus, SaveToStreamForGame, entitySaveStream, AZ::DataStream::ST_BINARY);
|
||||
if (savedEntities)
|
||||
{
|
||||
XmlNodeRef objectsNode = NULL;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Export current mission file.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
XmlNodeRef missionNode = rootAction->createNode("Mission");
|
||||
pCurrentMission->Export(missionNode, objectsNode);
|
||||
|
||||
missionNode->setAttr("CGFCount", p3DEngine->GetLoadedObjectCount());
|
||||
|
||||
//if (!CFileUtil::OverwriteFile( path+currentMissionFileName ))
|
||||
// return;
|
||||
|
||||
AZStd::vector<char> entitySaveBuffer;
|
||||
AZ::IO::ByteContainerStream<AZStd::vector<char> > entitySaveStream(&entitySaveBuffer);
|
||||
bool savedEntities = false;
|
||||
EBUS_EVENT_RESULT(savedEntities, AzToolsFramework::EditorEntityContextRequestBus, SaveToStreamForGame, entitySaveStream, AZ::DataStream::ST_BINARY);
|
||||
if (savedEntities)
|
||||
{
|
||||
QString entitiesFile;
|
||||
entitiesFile = QStringLiteral("%1%2.entities_xml").arg(path, pCurrentMission ? pCurrentMission->GetName() : "");
|
||||
m_levelPak.m_pakFile.UpdateFile(entitiesFile.toUtf8().data(), entitySaveBuffer.begin(), entitySaveBuffer.size());
|
||||
}
|
||||
|
||||
_smart_ptr<IXmlStringData> pXmlStrData = missionNode->getXMLData(5000000);
|
||||
|
||||
CCryMemFile fileMission;
|
||||
fileMission.Write(pXmlStrData->GetString(), pXmlStrData->GetStringLength());
|
||||
m_levelPak.m_pakFile.UpdateFile((path + currentMissionFileName).toUtf8().data(), fileMission);
|
||||
QString entitiesFile;
|
||||
entitiesFile = QStringLiteral("%1%2.entities_xml").arg(path, "Mission0");
|
||||
m_levelPak.m_pakFile.UpdateFile(entitiesFile.toUtf8().data(), entitySaveBuffer.begin(), entitySaveBuffer.size());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -457,18 +326,6 @@ void CGameExporter::ExportLevelInfo(const QString& path)
|
||||
const int compiledHeightmapSize = static_cast<int>(terrainAabb.GetXExtent() / terrainGridResolution.GetX());
|
||||
root->setAttr("HeightmapSize", compiledHeightmapSize);
|
||||
|
||||
// Save all missions in this level.
|
||||
XmlNodeRef missionsNode = root->newChild("Missions");
|
||||
int numMissions = pEditor->GetDocument()->GetMissionCount();
|
||||
for (int i = 0; i < numMissions; i++)
|
||||
{
|
||||
CMission* pMission = pEditor->GetDocument()->GetMission(i);
|
||||
XmlNodeRef missionNode = missionsNode->newChild("Mission");
|
||||
missionNode->setAttr("Name", pMission->GetName().toUtf8().data());
|
||||
missionNode->setAttr("Description", pMission->GetDescription().toUtf8().data());
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Save LevelInfo file.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -480,138 +337,6 @@ void CGameExporter::ExportLevelInfo(const QString& path)
|
||||
m_levelPak.m_pakFile.UpdateFile(filename.toUtf8().data(), file);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CGameExporter::ExportMapInfo(XmlNodeRef& node)
|
||||
{
|
||||
XmlNodeRef info = node->newChild("LevelInfo");
|
||||
|
||||
IEditor* pEditor = GetIEditor();
|
||||
info->setAttr("Name", QFileInfo(pEditor->GetDocument()->GetTitle()).completeBaseName());
|
||||
|
||||
auto terrain = AzFramework::Terrain::TerrainDataRequestBus::FindFirstHandler();
|
||||
const AZ::Aabb terrainAabb = terrain ? terrain->GetTerrainAabb() : AZ::Aabb::CreateFromPoint(AZ::Vector3::CreateZero());
|
||||
const AZ::Vector2 terrainGridResolution = terrain ? terrain->GetTerrainGridResolution() : AZ::Vector2::CreateOne();
|
||||
|
||||
const int terrainSizeInMeters = static_cast<int>(terrainAabb.GetXExtent());
|
||||
const int terrainUnitSizeInMeters = static_cast<int>(terrainGridResolution.GetX());
|
||||
info->setAttr("HeightmapSize", terrainSizeInMeters / terrainUnitSizeInMeters);
|
||||
info->setAttr("HeightmapUnitSize", terrainUnitSizeInMeters);
|
||||
//! Default Max Height value.
|
||||
constexpr int HEIGHTMAP_MAX_HEIGHT = 150; //This is the default max height in CHeightmap
|
||||
info->setAttr("HeightmapMaxHeight", HEIGHTMAP_MAX_HEIGHT);
|
||||
info->setAttr("WaterLevel", pEditor->Get3DEngine()->GetWaterLevel());
|
||||
|
||||
// Serialize surface types.
|
||||
CXmlArchive xmlAr;
|
||||
xmlAr.bLoading = false;
|
||||
xmlAr.root = node;
|
||||
|
||||
GetIEditor()->GetObjectManager()->GetPhysicsManager()->SerializeCollisionClasses(xmlAr);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CGameExporter::ExportMaterials(XmlNodeRef& levelDataNode, const QString& path)
|
||||
{
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Export materials manager.
|
||||
CMaterialManager* pManager = GetIEditor()->GetMaterialManager();
|
||||
pManager->Export(levelDataNode);
|
||||
|
||||
QString filename = Path::Make(path, MATERIAL_LEVEL_LIBRARY_FILE);
|
||||
|
||||
bool bHaveItems = true;
|
||||
|
||||
int numMtls = 0;
|
||||
|
||||
XmlNodeRef nodeMaterials = XmlHelpers::CreateXmlNode("MaterialsLibrary");
|
||||
// Export Materials local level library.
|
||||
for (int i = 0; i < pManager->GetLibraryCount(); i++)
|
||||
{
|
||||
XmlNodeRef nodeLib = nodeMaterials->newChild("Library");
|
||||
CMaterialLibrary* pLib = (CMaterialLibrary*)pManager->GetLibrary(i);
|
||||
if (pLib->GetItemCount() > 0)
|
||||
{
|
||||
bHaveItems = false;
|
||||
// Export this library.
|
||||
numMtls += pManager->ExportLib(pLib, nodeLib);
|
||||
}
|
||||
}
|
||||
if (!bHaveItems)
|
||||
{
|
||||
XmlString xmlData = nodeMaterials->getXML();
|
||||
|
||||
CCryMemFile file;
|
||||
file.Write(xmlData.c_str(), xmlData.length());
|
||||
m_levelPak.m_pakFile.UpdateFile(filename.toUtf8().data(), file);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_levelPak.m_pakFile.RemoveFile(filename.toUtf8().data());
|
||||
}
|
||||
m_numExportedMaterials = numMtls;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CGameExporter::ExportLevelLensFlares(const QString& path)
|
||||
{
|
||||
GetIEditor()->SetStatusText(QObject::tr("Exporting Lens Flares..."));
|
||||
std::vector<CBaseObject*> objects;
|
||||
GetIEditor()->GetObjectManager()->FindObjectsOfType(&CEntityObject::staticMetaObject, objects);
|
||||
std::set<QString> flareNameSet;
|
||||
for (int i = 0, iObjectSize(objects.size()); i < iObjectSize; ++i)
|
||||
{
|
||||
CEntityObject* pEntity = (CEntityObject*)objects[i];
|
||||
if (!pEntity->IsLight())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
QString flareName = pEntity->GetEntityPropertyString(CEntityObject::s_LensFlarePropertyName);
|
||||
if (flareName.isEmpty() || flareName == "@root")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
flareNameSet.insert(flareName);
|
||||
}
|
||||
|
||||
XmlNodeRef pRootNode = GetIEditor()->GetSystem()->CreateXmlNode("LensFlareList");
|
||||
pRootNode->setAttr("Version", FLARE_EXPORT_FILE_VERSION);
|
||||
|
||||
CLensFlareManager* pLensManager = GetIEditor()->GetLensFlareManager();
|
||||
|
||||
if (CLensFlareLibrary* pLevelLib = (CLensFlareLibrary*)pLensManager->GetLevelLibrary())
|
||||
{
|
||||
for (int i = 0; i < pLevelLib->GetItemCount(); i++)
|
||||
{
|
||||
CLensFlareItem* pItem = (CLensFlareItem*)pLevelLib->GetItem(i);
|
||||
|
||||
if (flareNameSet.find(pItem->GetFullName()) == flareNameSet.end())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
CBaseLibraryItem::SerializeContext ctx(pItem->CreateXmlData(), false);
|
||||
pRootNode->addChild(ctx.node);
|
||||
pItem->Serialize(ctx);
|
||||
flareNameSet.erase(pItem->GetFullName());
|
||||
}
|
||||
}
|
||||
|
||||
std::set<QString>::iterator iFlareNameSet = flareNameSet.begin();
|
||||
for (; iFlareNameSet != flareNameSet.end(); ++iFlareNameSet)
|
||||
{
|
||||
QString flareName = *iFlareNameSet;
|
||||
XmlNodeRef pFlareNode = GetIEditor()->GetSystem()->CreateXmlNode("LensFlare");
|
||||
pFlareNode->setAttr("name", flareName.toUtf8().data());
|
||||
pRootNode->addChild(pFlareNode);
|
||||
}
|
||||
|
||||
CCryMemFile lensFlareNames;
|
||||
lensFlareNames.Write(pRootNode->getXMLData()->GetString(), pRootNode->getXMLData()->GetStringLength());
|
||||
|
||||
QString exportPathName = path + FLARE_EXPORT_FILE;
|
||||
m_levelPak.m_pakFile.UpdateFile(exportPathName.toUtf8().data(), lensFlareNames);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CGameExporter::ExportLevelResourceList(const QString& path)
|
||||
{
|
||||
@@ -652,18 +377,6 @@ void CGameExporter::ExportLevelUsedResourceList(const QString& path)
|
||||
m_levelPak.m_pakFile.UpdateFile(resFile.toUtf8().data(), memFile, true);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CGameExporter::ExportLevelShaderCache(const QString& path)
|
||||
{
|
||||
QString buf;
|
||||
GetIEditor()->GetDocument()->GetShaderCache()->SaveBuffer(buf);
|
||||
CCryMemFile memFile;
|
||||
memFile.Write(buf.toUtf8().data(), buf.toUtf8().length());
|
||||
|
||||
QString filename = Path::Make(path, SHADER_LIST_FILE);
|
||||
m_levelPak.m_pakFile.UpdateFile(filename.toUtf8().data(), memFile, true);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CGameExporter::ExportFileList(const QString& path, const QString& levelName)
|
||||
{
|
||||
|
||||
@@ -91,16 +91,10 @@ private:
|
||||
void ExportLevelData(const QString& path, bool bExportMission = true);
|
||||
void ExportLevelInfo(const QString& path);
|
||||
|
||||
void ExportVisAreas(const char* pszGamePath, EEndian eExportEndian);
|
||||
void ExportOcclusionMesh(const char* pszGamePath);
|
||||
void ExportMapInfo(XmlNodeRef& node);
|
||||
|
||||
void ExportLevelLensFlares(const QString& path);
|
||||
void ExportLevelResourceList(const QString& path);
|
||||
void ExportLevelUsedResourceList(const QString& path);
|
||||
void ExportLevelShaderCache(const QString& path);
|
||||
void ExportMaterials(XmlNodeRef& levelDataNode, const QString& path);
|
||||
void ExportGameData(const QString& path);
|
||||
void ExportFileList(const QString& path, const QString& levelName);
|
||||
|
||||
void Error(const QString& error);
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
// Editor
|
||||
#include "UsedResources.h"
|
||||
#include "GameEngine.h"
|
||||
#include "Material/MaterialManager.h"
|
||||
#include "Include/IObjectManager.h"
|
||||
#include "WaitProgress.h"
|
||||
|
||||
@@ -51,7 +50,7 @@ void CGameResourcesExporter::ChooseDirectory()
|
||||
void CGameResourcesExporter::GatherAllLoadedResources()
|
||||
{
|
||||
m_files.clear();
|
||||
m_files.reserve(100000); // count from GetResourceList, GetFilesFromObjects, GetFilesFromMaterials ... is unknown
|
||||
m_files.reserve(100000); // count from GetResourceList, GetFilesFromObjects ... is unknown
|
||||
|
||||
auto pResList = gEnv->pCryPak->GetResourceList(AZ::IO::IArchive::RFOM_Level);
|
||||
{
|
||||
@@ -62,7 +61,6 @@ void CGameResourcesExporter::GatherAllLoadedResources()
|
||||
}
|
||||
|
||||
GetFilesFromObjects();
|
||||
GetFilesFromMaterials();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -158,12 +156,3 @@ void CGameResourcesExporter::GetFilesFromObjects()
|
||||
|
||||
Append(m_files, rs.files);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CGameResourcesExporter::GetFilesFromMaterials()
|
||||
{
|
||||
CUsedResources rs;
|
||||
GetIEditor()->GetMaterialManager()->GatherUsedResources(rs);
|
||||
Append(m_files, rs.files);
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,6 @@ private:
|
||||
void GetFilesFromObjects();
|
||||
void GetFilesFromVarBlock(CVarBlock* pVB);
|
||||
void GetFilesFromVariable(IVariable* pVar);
|
||||
void GetFilesFromMaterials();
|
||||
};
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_GAMERESOURCESEXPORTER_H
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#include "EditorDefs.h"
|
||||
|
||||
#include "EdGeometry.h"
|
||||
@@ -1,84 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_GEOMETRY_EDGEOMETRY_H
|
||||
#define CRYINCLUDE_EDITOR_GEOMETRY_EDGEOMETRY_H
|
||||
#pragma once
|
||||
|
||||
struct IIndexedMesh;
|
||||
struct DisplayContext;
|
||||
struct HitContext;
|
||||
struct SSubObjSelectionModifyContext;
|
||||
class CObjectArchive;
|
||||
|
||||
// Basic supported geometry types.
|
||||
enum EEdGeometryType
|
||||
{
|
||||
GEOM_TYPE_MESH = 0, // Mesh geometry.
|
||||
GEOM_TYPE_BRUSH, // Solid brush geometry.
|
||||
GEOM_TYPE_PATCH, // Bezier patch surface geometry.
|
||||
GEOM_TYPE_NURB, // Nurbs surface geometry.
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Description:
|
||||
// CEdGeometry is a base class for all supported editable geometries.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
class CRYEDIT_API CEdGeometry
|
||||
: public CRefCountBase
|
||||
{
|
||||
public:
|
||||
CEdGeometry() {};
|
||||
|
||||
// Query the type of the geometry mesh.
|
||||
virtual EEdGeometryType GetType() const = 0;
|
||||
|
||||
// Serialize geometry.
|
||||
virtual void Serialize(CObjectArchive& ar) = 0;
|
||||
|
||||
// Return geometry axis aligned bounding box.
|
||||
virtual void GetBounds(AABB& box) = 0;
|
||||
|
||||
// Clones Geometry, returns exact copy of the original geometry.
|
||||
virtual CEdGeometry* Clone() = 0;
|
||||
|
||||
// Access to the indexed mesh.
|
||||
// Return false if geometry can not be represented by an indexed mesh.
|
||||
virtual IIndexedMesh* GetIndexedMesh(size_t idx = 0) = 0;
|
||||
virtual IStatObj* GetIStatObj() const = 0;
|
||||
virtual void GetTM(Matrix34* pTM, size_t idx = 0) = 0;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Advanced geometry interface for SubObject selection and modification.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
virtual void SetModified(bool bModified = true) = 0;
|
||||
virtual bool IsModified() const = 0;
|
||||
virtual bool StartSubObjSelection(const Matrix34& nodeWorldTM, int elemType, int nFlags) = 0;
|
||||
virtual void EndSubObjSelection() = 0;
|
||||
|
||||
// Display geometry for sub object selection.
|
||||
virtual void Display(DisplayContext& dc) = 0;
|
||||
|
||||
// Sub geometry hit testing and selection.
|
||||
virtual bool HitTest(HitContext& hit) = 0;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
virtual void ModifySelection(SSubObjSelectionModifyContext& modCtx, bool isUndo = true) = 0;
|
||||
// Called when selection modification is accepted.
|
||||
virtual void AcceptModifySelection() = 0;
|
||||
|
||||
protected:
|
||||
~CEdGeometry() {};
|
||||
};
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_GEOMETRY_EDGEOMETRY_H
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,194 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
// Description : Editor structure that wraps access to IStatObj
|
||||
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_GEOMETRY_EDMESH_H
|
||||
#define CRYINCLUDE_EDITOR_GEOMETRY_EDMESH_H
|
||||
#pragma once
|
||||
|
||||
#include "EdGeometry.h"
|
||||
#include "Objects/SubObjSelection.h"
|
||||
#include "TriMesh.h"
|
||||
|
||||
// Flags that can be set on CEdMesh.
|
||||
enum CEdMeshFlags
|
||||
{
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Description:
|
||||
// CEdMesh is a Geometry kind representing simple mesh.
|
||||
// Holds IStatObj interface from the 3D Engine.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
class CRYEDIT_API CEdMesh
|
||||
: public CEdGeometry
|
||||
{
|
||||
public:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// CEdGeometry implementation.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
virtual EEdGeometryType GetType() const { return GEOM_TYPE_MESH; };
|
||||
virtual void Serialize(CObjectArchive& ar);
|
||||
|
||||
virtual void GetBounds(AABB& box);
|
||||
virtual CEdGeometry* Clone();
|
||||
virtual IIndexedMesh* GetIndexedMesh(size_t idx = 0);
|
||||
virtual void GetTM(Matrix34* pTM, size_t idx = 0);
|
||||
virtual void SetModified(bool bModified = true);
|
||||
virtual bool IsModified() const { return m_bModified; };
|
||||
virtual bool StartSubObjSelection(const Matrix34& nodeWorldTM, int elemType, int nFlags);
|
||||
virtual void EndSubObjSelection();
|
||||
virtual void Display(DisplayContext& dc);
|
||||
virtual bool HitTest(HitContext& hit);
|
||||
bool GetSelectionReferenceFrame(Matrix34& refFrame);
|
||||
virtual void ModifySelection(SSubObjSelectionModifyContext& modCtx, bool isUndo = true);
|
||||
virtual void AcceptModifySelection();
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
~CEdMesh();
|
||||
|
||||
// Return filename of mesh.
|
||||
const QString& GetFilename() const { return m_filename; };
|
||||
void SetFilename(const QString& filename);
|
||||
|
||||
//! Reload geometry of mesh.
|
||||
void ReloadGeometry();
|
||||
void AddUser();
|
||||
void RemoveUser();
|
||||
int GetUserCount() const { return m_nUserCount; };
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetFlags(int nFlags) { m_nFlags = nFlags; };
|
||||
int GetFlags() { return m_nFlags; }
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//! Access stored IStatObj.
|
||||
IStatObj* GetIStatObj() const { return m_pStatObj; }
|
||||
|
||||
//! Returns true if filename and geomname refer to the same object as this one.
|
||||
bool IsSameObject(const char* filename);
|
||||
|
||||
//! RenderMesh.
|
||||
void Render(SRendParams& rp, const SRenderingPassInfo& passInfo);
|
||||
|
||||
//! Make new CEdMesh, if same IStatObj loaded, and CEdMesh for this IStatObj is allocated.
|
||||
//! This instance of CEdMesh will be returned.
|
||||
static CEdMesh* LoadMesh(const char* filename);
|
||||
|
||||
// Creates a new mesh not from a file.
|
||||
// Create a new StatObj and IndexedMesh.
|
||||
static CEdMesh* CreateMesh(const char* name);
|
||||
|
||||
//! Reload all geometries.
|
||||
static void ReloadAllGeometries();
|
||||
static void ReleaseAll();
|
||||
|
||||
//! Check if default object was loaded.
|
||||
bool IsDefaultObject();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Copy EdMesh data to the specified mesh.
|
||||
void CopyToMesh(CTriMesh& toMesh, int nCopyFlags);
|
||||
// Copy EdMesh data from the specified mesh.
|
||||
void CopyFromMesh(CTriMesh& fromMesh, int nCopyFlags, bool bUndo);
|
||||
|
||||
// Retrieve mesh class.
|
||||
CTriMesh* GetMesh();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void InvalidateMesh();
|
||||
void SetWorldTM(const Matrix34& worldTM);
|
||||
|
||||
// Save mesh into the file.
|
||||
// Optionally can provide pointer to the pak file where to save files into.
|
||||
void SaveToCGF(const char* sFilename, CPakFile* pPakFile = NULL, _smart_ptr<IMaterial> pMaterial = NULL);
|
||||
|
||||
// Draw debug representation of this mesh.
|
||||
void DebugDraw(const SGeometryDebugDrawInfo& info, float fExtrdueScale = 0.01f);
|
||||
|
||||
private:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
CEdMesh(IStatObj* pGeom);
|
||||
CEdMesh();
|
||||
void UpdateSubObjCache();
|
||||
void UpdateIndexedMeshFromCache(bool bFast);
|
||||
void OnSelectionChange();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
struct SSubObjHitTestEnvironment
|
||||
{
|
||||
Vec3 vWSCameraPos;
|
||||
Vec3 vWSCameraVector;
|
||||
Vec3 vOSCameraVector;
|
||||
|
||||
bool bHitTestNearest;
|
||||
bool bHitTestSelected;
|
||||
bool bSelectOnHit;
|
||||
bool bAdd;
|
||||
bool bRemove;
|
||||
bool bSelectValue;
|
||||
bool bHighlightOnly;
|
||||
bool bIgnoreBackfacing;
|
||||
};
|
||||
struct SSubObjHitTestResult
|
||||
{
|
||||
CTriMesh::EStream stream; // To What stream of the TriMesh this result apply.
|
||||
MeshElementsArray elems; // List of hit elements.
|
||||
float minDistance; // Minimal distance to the hit.
|
||||
SSubObjHitTestResult() { minDistance = FLT_MAX; }
|
||||
};
|
||||
bool HitTestVertex(HitContext& hit, SSubObjHitTestEnvironment& env, SSubObjHitTestResult& result);
|
||||
bool HitTestEdge(HitContext& hit, SSubObjHitTestEnvironment& env, SSubObjHitTestResult& result);
|
||||
bool HitTestFace(HitContext& hit, SSubObjHitTestEnvironment& env, SSubObjHitTestResult& result);
|
||||
|
||||
// Return`s true if selection changed.
|
||||
bool SelectSubObjElements(SSubObjHitTestEnvironment& env, SSubObjHitTestResult& result);
|
||||
bool IsHitTestResultSelected(SSubObjHitTestResult& result);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//! CGF filename.
|
||||
QString m_filename;
|
||||
IStatObj* m_pStatObj;
|
||||
int m_nUserCount;
|
||||
int m_nFlags;
|
||||
|
||||
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
typedef std::map<QString, CEdMesh*, stl::less_stricmp<QString> > MeshMap;
|
||||
static MeshMap m_meshMap;
|
||||
|
||||
// This cache is created when sub object selection is needed.
|
||||
struct SubObjCache
|
||||
{
|
||||
// Cache of data in geometry.
|
||||
// World space mesh.
|
||||
CTriMesh* pTriMesh;
|
||||
Matrix34 worldTM;
|
||||
Matrix34 invWorldTM;
|
||||
CBitArray m_tempBitArray;
|
||||
bool bNoDisplay;
|
||||
|
||||
SubObjCache()
|
||||
: pTriMesh(0)
|
||||
, bNoDisplay(false) {};
|
||||
};
|
||||
SubObjCache* m_pSubObjCache;
|
||||
bool m_bModified;
|
||||
|
||||
std::vector<IIndexedMesh*> m_tempIndexedMeshes;
|
||||
std::vector<Matrix34> m_tempMatrices;
|
||||
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
};
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_GEOMETRY_EDMESH_H
|
||||
@@ -106,8 +106,7 @@ void CGotoPositionDlg::OnChangeEdit()
|
||||
{
|
||||
const int lengthInSw = 8;
|
||||
const int strNum = 6;
|
||||
TArray< float > pos(strNum);
|
||||
pos.Set(0);
|
||||
AZStd::vector<float> pos(strNum);
|
||||
|
||||
m_sPos = m_ui->m_posEdit->text();
|
||||
const QStringList parts = m_sPos.split(QRegularExpression("[\\s,;\\t]"), Qt::SkipEmptyParts);
|
||||
|
||||
@@ -779,36 +779,6 @@ bool GraphicsSettingsDialog::CVarChanged(AZStd::any val, const char* cvarName, i
|
||||
m_cVarTracker[cvarName].fileVals[specLevel].editedValue = val;
|
||||
}
|
||||
|
||||
// If changing cvar from the platform cfg file currently running, set cvar
|
||||
if (GetISystem()->GetConfigPlatform() == m_currentPlatform && GetISystem()->GetConfigSpec() == specLevel + 1)
|
||||
{
|
||||
if (ICVar* cvar = gEnv->pConsole->GetCVar(cvarName))
|
||||
{
|
||||
int type = cvar->GetType();
|
||||
if (type == CVAR_INT)
|
||||
{
|
||||
int newValue;
|
||||
if (AZStd::any_numeric_cast<int>(&val, newValue))
|
||||
{
|
||||
cvar->Set(newValue);
|
||||
}
|
||||
}
|
||||
else if (type == CVAR_FLOAT)
|
||||
{
|
||||
float newValue;
|
||||
if (AZStd::any_numeric_cast<float>(&val, newValue))
|
||||
{
|
||||
cvar->Set(newValue);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AZStd::string* currValue = AZStd::any_cast<AZStd::string>(&val);
|
||||
cvar->Set(currValue->c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Checking if the newly edited value is equal to the overwritten value
|
||||
cvarInfo = AZStd::make_pair(azcvarName, m_cVarTracker[cvarName]);
|
||||
if (CheckCVarStatesForDiff(&cvarInfo, specLevel, EDITED_OVERWRITTEN_COMPARE))
|
||||
|
||||
@@ -1,171 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#include "EditorDefs.h"
|
||||
|
||||
#include "Grid.h"
|
||||
|
||||
// Editor
|
||||
#include "Settings.h"
|
||||
#include "Objects/SelectionGroup.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
CGrid::CGrid()
|
||||
{
|
||||
scale = 1;
|
||||
size = 1;
|
||||
majorLine = 16;
|
||||
bEnabled = true;
|
||||
rotationAngles = Ang3(0.0f, 0.0f, 0.0f);
|
||||
translation = Vec3(0.0f, 0.0f, 0.0f);
|
||||
|
||||
bAngleSnapEnabled = true;
|
||||
angleSnap = 5;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
Vec3 CGrid::Snap(const Vec3& vec) const
|
||||
{
|
||||
if (!bEnabled || size < 0.001)
|
||||
{
|
||||
return vec;
|
||||
}
|
||||
Vec3 snapped;
|
||||
snapped.x = floor((vec.x / size) / scale + 0.5) * size * scale;
|
||||
snapped.y = floor((vec.y / size) / scale + 0.5) * size * scale;
|
||||
snapped.z = floor((vec.z / size) / scale + 0.5) * size * scale;
|
||||
return snapped;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
Vec3 CGrid::Snap(const Vec3& vec, double fZoom) const
|
||||
{
|
||||
if (!bEnabled || size < 0.001f)
|
||||
{
|
||||
return vec;
|
||||
}
|
||||
|
||||
Matrix34 tm = GetMatrix();
|
||||
|
||||
double zoomscale = scale * fZoom;
|
||||
Vec3 snapped;
|
||||
|
||||
Matrix34 invtm = tm.GetInverted();
|
||||
|
||||
snapped = invtm * vec;
|
||||
|
||||
snapped.x = floor((snapped.x / size) / zoomscale + 0.5) * size * zoomscale;
|
||||
snapped.y = floor((snapped.y / size) / zoomscale + 0.5) * size * zoomscale;
|
||||
snapped.z = floor((snapped.z / size) / zoomscale + 0.5) * size * zoomscale;
|
||||
|
||||
snapped = tm * snapped;
|
||||
|
||||
return snapped;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
double CGrid::SnapAngle(double angle) const
|
||||
{
|
||||
if (!bAngleSnapEnabled)
|
||||
{
|
||||
return angle;
|
||||
}
|
||||
return floor(angle / angleSnap + 0.5) * angleSnap;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
Ang3 CGrid::SnapAngle(const Ang3& vec) const
|
||||
{
|
||||
if (!bAngleSnapEnabled)
|
||||
{
|
||||
return vec;
|
||||
}
|
||||
Ang3 snapped;
|
||||
snapped.x = floor(vec.x / angleSnap + 0.5) * angleSnap;
|
||||
snapped.y = floor(vec.y / angleSnap + 0.5) * angleSnap;
|
||||
snapped.z = floor(vec.z / angleSnap + 0.5) * angleSnap;
|
||||
return snapped;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CGrid::Serialize(XmlNodeRef& xmlNode, bool bLoading)
|
||||
{
|
||||
if (bLoading)
|
||||
{
|
||||
// Loading.
|
||||
xmlNode->getAttr("Size", size);
|
||||
xmlNode->getAttr("Scale", scale);
|
||||
xmlNode->getAttr("Enabled", bEnabled);
|
||||
xmlNode->getAttr("MajorSize", majorLine);
|
||||
xmlNode->getAttr("AngleSnap", angleSnap);
|
||||
xmlNode->getAttr("AngleSnapEnabled", bAngleSnapEnabled);
|
||||
if (size < 0.01)
|
||||
{
|
||||
size = 0.01;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Saving.
|
||||
xmlNode->setAttr("Size", size);
|
||||
xmlNode->setAttr("Scale", scale);
|
||||
xmlNode->setAttr("Enabled", bEnabled);
|
||||
xmlNode->setAttr("MajorSize", majorLine);
|
||||
xmlNode->setAttr("AngleSnap", angleSnap);
|
||||
xmlNode->setAttr("AngleSnapEnabled", bAngleSnapEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
Matrix34 CGrid::GetMatrix() const
|
||||
{
|
||||
Matrix34 tm;
|
||||
|
||||
if (gSettings.snap.bGridUserDefined)
|
||||
{
|
||||
Ang3 angles = Ang3(rotationAngles.x * gf_PI / 180.0, rotationAngles.y * gf_PI / 180.0, rotationAngles.z * gf_PI / 180.0);
|
||||
|
||||
tm = Matrix33::CreateRotationXYZ(angles);
|
||||
|
||||
if (gSettings.snap.bGridGetFromSelected)
|
||||
{
|
||||
CSelectionGroup* sel = GetIEditor()->GetSelection();
|
||||
if (sel->GetCount() > 0)
|
||||
{
|
||||
CBaseObject* obj = sel->GetObject(0);
|
||||
tm = obj->GetWorldTM();
|
||||
tm.OrthonormalizeFast();
|
||||
tm.SetTranslation(Vec3(0, 0, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (GetIEditor()->GetReferenceCoordSys() == COORDS_LOCAL)
|
||||
{
|
||||
tm.SetIdentity();
|
||||
|
||||
CSelectionGroup* sel = GetIEditor()->GetSelection();
|
||||
if (sel->GetCount() > 0)
|
||||
{
|
||||
CBaseObject* obj = sel->GetObject(0);
|
||||
tm = obj->GetWorldTM();
|
||||
tm.OrthonormalizeFast();
|
||||
tm.SetTranslation(Vec3(0, 0, 0));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
tm.SetIdentity();
|
||||
}
|
||||
|
||||
return tm;
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_GRID_H
|
||||
#define CRYINCLUDE_EDITOR_GRID_H
|
||||
|
||||
#pragma once
|
||||
|
||||
/** Definition of grid used in 2D viewports.
|
||||
*/
|
||||
class SANDBOX_API CGrid
|
||||
{
|
||||
public:
|
||||
//! Resolution of grid, it must be multiply of 2.
|
||||
double size;
|
||||
//! Draw major lines every Nth grid line.
|
||||
int majorLine;
|
||||
//! True if grid enabled.
|
||||
bool bEnabled;
|
||||
//! Meters per grid unit.
|
||||
double scale;
|
||||
|
||||
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
Ang3 rotationAngles;
|
||||
Vec3 translation;
|
||||
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
|
||||
//! If snap to angle.
|
||||
bool bAngleSnapEnabled;
|
||||
double angleSnap;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
CGrid();
|
||||
|
||||
//! Snap vector to this grid.
|
||||
Vec3 Snap(const Vec3& vec) const;
|
||||
Vec3 Snap(const Vec3& vec, double fZoom) const;
|
||||
|
||||
//! Snap angle to current angle snapping value.
|
||||
double SnapAngle(double angle) const;
|
||||
//! Snap angle to current angle snapping value.
|
||||
Ang3 SnapAngle(const Ang3& angle) const;
|
||||
|
||||
//! Enable or disable grid.
|
||||
void Enable(bool enable) { bEnabled = enable; }
|
||||
//! Check if grid enabled.
|
||||
bool IsEnabled() const { return bEnabled; }
|
||||
|
||||
//! Enables or disable angle snapping.
|
||||
void EnableAngleSnap(bool enable) { bAngleSnapEnabled = enable; };
|
||||
|
||||
//! Return if snapping of angle is enabled.
|
||||
bool IsAngleSnapEnabled() const { return bAngleSnapEnabled; };
|
||||
//! Returns ammount of snapping for angle in degrees.
|
||||
double GetAngleSnap() const { return angleSnap; };
|
||||
|
||||
void Serialize(XmlNodeRef& xmlNode, bool bLoading);
|
||||
|
||||
//! Get transformation matrix of gird.
|
||||
Matrix34 GetMatrix() const;
|
||||
};
|
||||
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_GRID_H
|
||||
@@ -1,204 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#include "EditorDefs.h"
|
||||
|
||||
#include "GridSettingsDialog.h"
|
||||
|
||||
// Editor
|
||||
#include "Settings.h"
|
||||
#include "Objects/SelectionGroup.h"
|
||||
#include "ViewManager.h"
|
||||
|
||||
|
||||
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
#include <ui_GridSettingsDialog.h>
|
||||
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
|
||||
// CGridSettingsDialog dialog
|
||||
|
||||
CGridSettingsDialog::CGridSettingsDialog(QWidget* pParent /*=NULL*/)
|
||||
: QDialog(pParent)
|
||||
, ui(new Ui::CGridSettingsDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
setWindowTitle(tr("Grid/Snap Settings"));
|
||||
|
||||
OnInitDialog();
|
||||
|
||||
connect(ui->m_userDefined, &QCheckBox::clicked, this, &CGridSettingsDialog::OnBnUserDefined);
|
||||
connect(ui->m_getFromObject, &QCheckBox::clicked, this, &CGridSettingsDialog::OnBnGetFromObject);
|
||||
connect(ui->m_getAnglesFromObject, &QPushButton::clicked, this, &CGridSettingsDialog::OnBnGetAngles);
|
||||
connect(ui->m_getTranslationFromObject, &QPushButton::clicked, this, &CGridSettingsDialog::OnBnGetTranslation);
|
||||
|
||||
auto doubleSpinBoxValueChanged = static_cast<void(QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged);
|
||||
|
||||
connect(ui->m_angleX, doubleSpinBoxValueChanged, this, &CGridSettingsDialog::OnValueUpdate);
|
||||
connect(ui->m_angleY, doubleSpinBoxValueChanged, this, &CGridSettingsDialog::OnValueUpdate);
|
||||
connect(ui->m_angleZ, doubleSpinBoxValueChanged, this, &CGridSettingsDialog::OnValueUpdate);
|
||||
|
||||
connect(ui->m_gridSize, doubleSpinBoxValueChanged, this, &CGridSettingsDialog::OnValueUpdate);
|
||||
connect(ui->m_gridScale, doubleSpinBoxValueChanged, this, &CGridSettingsDialog::OnValueUpdate);
|
||||
connect(ui->m_CPSize, doubleSpinBoxValueChanged, this, &CGridSettingsDialog::OnValueUpdate);
|
||||
|
||||
connect(ui->m_displayCP, &QCheckBox::clicked, this, &CGridSettingsDialog::OnValueUpdate);
|
||||
connect(ui->m_getFromObject, &QCheckBox::clicked, this, &CGridSettingsDialog::OnValueUpdate);
|
||||
|
||||
connect(ui->m_buttonBox, &QDialogButtonBox::accepted, this, &CGridSettingsDialog::accept);
|
||||
connect(ui->m_buttonBox, &QDialogButtonBox::rejected, this, &CGridSettingsDialog::reject);
|
||||
}
|
||||
|
||||
CGridSettingsDialog::~CGridSettingsDialog()
|
||||
{
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CGridSettingsDialog::OnInitDialog()
|
||||
{
|
||||
CGrid* pGrid = GetIEditor()->GetViewManager()->GetGrid();
|
||||
|
||||
ui->m_userDefined->setChecked(gSettings.snap.bGridUserDefined);
|
||||
ui->m_getFromObject->setChecked(gSettings.snap.bGridGetFromSelected);
|
||||
|
||||
ui->m_angleX->setValue(pGrid->rotationAngles.x);
|
||||
ui->m_angleY->setValue(pGrid->rotationAngles.y);
|
||||
ui->m_angleZ->setValue(pGrid->rotationAngles.z);
|
||||
|
||||
ui->m_translationX->setValue(pGrid->translation.x);
|
||||
ui->m_translationY->setValue(pGrid->translation.y);
|
||||
ui->m_translationZ->setValue(pGrid->translation.z);
|
||||
|
||||
ui->m_gridSize->setValue(pGrid->size);
|
||||
ui->m_gridScale->setValue(pGrid->scale);
|
||||
ui->m_snapToGrid->setChecked(pGrid->IsEnabled());
|
||||
|
||||
ui->m_angleSnap->setChecked(pGrid->IsAngleSnapEnabled());
|
||||
ui->m_angleSnapScale->setValue(pGrid->GetAngleSnap());
|
||||
ui->m_displayCP->setChecked(gSettings.snap.constructPlaneDisplay);
|
||||
|
||||
ui->m_CPSize->setValue(gSettings.snap.constructPlaneSize);
|
||||
ui->m_displaySnapMarker->setChecked(gSettings.snap.markerDisplay);
|
||||
ui->m_snapMarkerSize->setValue(gSettings.snap.markerSize);
|
||||
|
||||
ui->m_snapMarkerColor->SetColor(gSettings.snap.markerColor);
|
||||
|
||||
EnableGridPropertyControls(gSettings.snap.bGridUserDefined, gSettings.snap.bGridGetFromSelected);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CGridSettingsDialog::accept()
|
||||
{
|
||||
UpdateValues();
|
||||
gSettings.Save();
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
void CGridSettingsDialog::OnBnUserDefined()
|
||||
{
|
||||
EnableGridPropertyControls(ui->m_userDefined->isChecked(), ui->m_getFromObject->isChecked());
|
||||
OnValueUpdate();
|
||||
}
|
||||
|
||||
void CGridSettingsDialog::OnBnGetFromObject()
|
||||
{
|
||||
EnableGridPropertyControls(ui->m_userDefined->isChecked(), ui->m_getFromObject->isChecked());
|
||||
}
|
||||
|
||||
void CGridSettingsDialog::OnBnGetAngles()
|
||||
{
|
||||
CSelectionGroup* sel = GetIEditor()->GetSelection();
|
||||
if (sel->GetCount() > 0)
|
||||
{
|
||||
CBaseObject* obj = sel->GetObject(0);
|
||||
Matrix34 tm = obj->GetWorldTM();
|
||||
AffineParts ap;
|
||||
ap.SpectralDecompose(tm);
|
||||
|
||||
Vec3 rotation = Vec3(RAD2DEG(Ang3::GetAnglesXYZ(Matrix33(ap.rot))));
|
||||
|
||||
ui->m_angleX->setValue(rotation.x);
|
||||
ui->m_angleY->setValue(rotation.y);
|
||||
ui->m_angleZ->setValue(rotation.z);
|
||||
}
|
||||
}
|
||||
|
||||
void CGridSettingsDialog::OnBnGetTranslation()
|
||||
{
|
||||
CSelectionGroup* sel = GetIEditor()->GetSelection();
|
||||
if (sel->GetCount() > 0)
|
||||
{
|
||||
CBaseObject* obj = sel->GetObject(0);
|
||||
Matrix34 tm = obj->GetWorldTM();
|
||||
Vec3 translation = tm.GetTranslation();
|
||||
|
||||
ui->m_translationX->setValue(translation.x);
|
||||
ui->m_translationY->setValue(translation.y);
|
||||
ui->m_translationZ->setValue(translation.z);
|
||||
}
|
||||
}
|
||||
|
||||
void CGridSettingsDialog::EnableGridPropertyControls(const bool isUserDefined, const bool isGetFromObject)
|
||||
{
|
||||
ui->m_getFromObject->setEnabled(isUserDefined == true);
|
||||
|
||||
ui->m_angleX->setEnabled(isUserDefined == true && isGetFromObject == false);
|
||||
ui->m_angleY->setEnabled(isUserDefined == true && isGetFromObject == false);
|
||||
ui->m_angleZ->setEnabled(isUserDefined == true && isGetFromObject == false);
|
||||
ui->m_translationX->setEnabled(isUserDefined == true && isGetFromObject == false);
|
||||
ui->m_translationY->setEnabled(isUserDefined == true && isGetFromObject == false);
|
||||
ui->m_translationZ->setEnabled(isUserDefined == true && isGetFromObject == false);
|
||||
ui->m_getAnglesFromObject->setEnabled(isUserDefined == true && isGetFromObject == false);
|
||||
ui->m_getTranslationFromObject->setEnabled(isUserDefined == true && isGetFromObject == false);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CGridSettingsDialog::UpdateValues()
|
||||
{
|
||||
CGrid* pGrid = GetIEditor()->GetViewManager()->GetGrid();
|
||||
|
||||
pGrid->Enable(ui->m_snapToGrid->isChecked());
|
||||
pGrid->size = ui->m_gridSize->value();
|
||||
pGrid->scale = ui->m_gridScale->value();
|
||||
|
||||
gSettings.snap.bGridUserDefined = ui->m_userDefined->isChecked();
|
||||
gSettings.snap.bGridGetFromSelected = ui->m_getFromObject->isChecked();
|
||||
pGrid->rotationAngles.x = ui->m_angleX->value();
|
||||
pGrid->rotationAngles.y = ui->m_angleY->value();
|
||||
pGrid->rotationAngles.z = ui->m_angleZ->value();
|
||||
pGrid->translation.x = ui->m_translationX->value();
|
||||
pGrid->translation.y = ui->m_translationY->value();
|
||||
pGrid->translation.z = ui->m_translationZ->value();
|
||||
|
||||
pGrid->bAngleSnapEnabled = ui->m_angleSnap->isChecked();
|
||||
pGrid->angleSnap = ui->m_angleSnapScale->value();
|
||||
|
||||
gSettings.snap.constructPlaneDisplay = ui->m_displayCP->isChecked();
|
||||
gSettings.snap.constructPlaneSize = ui->m_CPSize->value();
|
||||
|
||||
gSettings.snap.markerDisplay = ui->m_displaySnapMarker->isChecked();
|
||||
gSettings.snap.markerSize = ui->m_snapMarkerSize->value();
|
||||
gSettings.snap.markerColor = ui->m_snapMarkerColor->Color();
|
||||
|
||||
NotificationBus::Broadcast(&Notifications::OnGridValuesUpdated);
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CGridSettingsDialog::OnValueUpdate()
|
||||
{
|
||||
UpdateValues();
|
||||
GetIEditor()->UpdateViews(eRedrawViewports);
|
||||
}
|
||||
|
||||
#include <moc_GridSettingsDialog.cpp>
|
||||
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_GRIDSETTINGSDIALOG_H
|
||||
#define CRYINCLUDE_EDITOR_GRIDSETTINGSDIALOG_H
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include <QDialog>
|
||||
#include <AzCore/EBus/EBus.h>
|
||||
#endif
|
||||
|
||||
// CGridSettingsDialog dialog
|
||||
|
||||
namespace Ui {
|
||||
class CGridSettingsDialog;
|
||||
}
|
||||
|
||||
class CGridSettingsDialog
|
||||
: public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
class Notifications
|
||||
: public AZ::EBusTraits
|
||||
{
|
||||
public:
|
||||
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
|
||||
|
||||
virtual void OnGridValuesUpdated() {}
|
||||
};
|
||||
|
||||
using NotificationBus = AZ::EBus<Notifications>;
|
||||
|
||||
CGridSettingsDialog(QWidget* pParent = nullptr); // standard constructor
|
||||
virtual ~CGridSettingsDialog();
|
||||
|
||||
private slots:
|
||||
void accept() override;
|
||||
void OnBnUserDefined();
|
||||
void OnBnGetFromObject();
|
||||
void OnBnGetAngles();
|
||||
void OnBnGetTranslation();
|
||||
void OnValueUpdate();
|
||||
|
||||
private:
|
||||
void EnableGridPropertyControls(const bool isUserDefined, const bool isGetFromObject);
|
||||
|
||||
void OnInitDialog();
|
||||
void UpdateValues();
|
||||
|
||||
QScopedPointer<Ui::CGridSettingsDialog> ui;
|
||||
};
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_GRIDSETTINGSDIALOG_H
|
||||
@@ -1,505 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CGridSettingsDialog</class>
|
||||
<widget class="QDialog" name="CGridSettingsDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>307</width>
|
||||
<height>707</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="group1">
|
||||
<property name="title">
|
||||
<string>Grid</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="1" colspan="2">
|
||||
<widget class="QCheckBox" name="m_snapToGrid">
|
||||
<property name="text">
|
||||
<string>Snap to Grid</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label1">
|
||||
<property name="text">
|
||||
<string>Grid Lines Every:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QDoubleSpinBox" name="m_gridSize">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>0.010000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>1024.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.010000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QLabel" name="label2">
|
||||
<property name="text">
|
||||
<string>units</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label3">
|
||||
<property name="text">
|
||||
<string>Units Per Meter:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QDoubleSpinBox" name="m_gridScale">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>0.010000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>1024.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.010000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QLabel" name="label4">
|
||||
<property name="text">
|
||||
<string>meters</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1" colspan="2">
|
||||
<widget class="QCheckBox" name="m_userDefined">
|
||||
<property name="text">
|
||||
<string>User Defined Grid</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="3">
|
||||
<widget class="QCheckBox" name="m_getFromObject">
|
||||
<property name="text">
|
||||
<string>Get Angles And Trans. From Selected</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label5">
|
||||
<property name="text">
|
||||
<string>Rotation by X:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QDoubleSpinBox" name="m_angleX">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-180.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>180.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.010000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="2">
|
||||
<widget class="QLabel" name="label6">
|
||||
<property name="text">
|
||||
<string>degrees</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="label7">
|
||||
<property name="text">
|
||||
<string>Rotation by Y:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QDoubleSpinBox" name="m_angleY">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-180.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>180.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.010000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="2">
|
||||
<widget class="QLabel" name="label8">
|
||||
<property name="text">
|
||||
<string>degrees</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="label9">
|
||||
<property name="text">
|
||||
<string>Rotation by Z:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<widget class="QDoubleSpinBox" name="m_angleZ">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-180.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>180.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.010000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="2">
|
||||
<widget class="QLabel" name="label10">
|
||||
<property name="text">
|
||||
<string>degrees</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="QLabel" name="label11">
|
||||
<property name="text">
|
||||
<string>Translation by X:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1">
|
||||
<widget class="QDoubleSpinBox" name="m_translationX">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.010000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="0">
|
||||
<widget class="QLabel" name="label12">
|
||||
<property name="text">
|
||||
<string>Translation by Y:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="1">
|
||||
<widget class="QDoubleSpinBox" name="m_translationY">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.010000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="0">
|
||||
<widget class="QLabel" name="label13">
|
||||
<property name="text">
|
||||
<string>Translation by Z:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="1">
|
||||
<widget class="QDoubleSpinBox" name="m_translationZ">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.010000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="0" colspan="3">
|
||||
<widget class="QPushButton" name="m_getAnglesFromObject">
|
||||
<property name="text">
|
||||
<string>Get Angles From Selected</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="12" column="0" colspan="3">
|
||||
<widget class="QPushButton" name="m_getTranslationFromObject">
|
||||
<property name="text">
|
||||
<string>Get Translation From Selected</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="group2">
|
||||
<property name="title">
|
||||
<string>Angle Snapping</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="1" column="2">
|
||||
<widget class="QSpinBox" name="m_angleSnapScale">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QLabel" name="label14">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>80</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>degrees</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2" colspan="2">
|
||||
<widget class="QCheckBox" name="m_angleSnap">
|
||||
<property name="text">
|
||||
<string>Angle Snap</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="label15">
|
||||
<property name="text">
|
||||
<string>Angle Snap:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="group3">
|
||||
<property name="title">
|
||||
<string>Construction Plane</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="label16">
|
||||
<property name="text">
|
||||
<string>Size:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="m_displayCP">
|
||||
<property name="text">
|
||||
<string>Display</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QDoubleSpinBox" name="m_CPSize">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.010000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Minimum</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>80</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
<zorder>m_displayCP</zorder>
|
||||
<zorder>m_CPSize</zorder>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="group4">
|
||||
<property name="title">
|
||||
<string>Snap Marker</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="3">
|
||||
<widget class="QDoubleSpinBox" name="m_snapMarkerSize">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.010000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="m_displaySnapMarker">
|
||||
<property name="text">
|
||||
<string>Display</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<widget class="ColorButton" name="m_snapMarkerColor">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>80</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Color</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="label17">
|
||||
<property name="text">
|
||||
<string>Size:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="m_buttonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>ColorButton</class>
|
||||
<extends>QToolButton</extends>
|
||||
<header location="global">QtUI/ColorButton.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -46,11 +46,8 @@ class CGameEngine;
|
||||
struct IIconManager;
|
||||
class CToolBoxManager;
|
||||
class CClassFactory;
|
||||
class CMaterialManager;
|
||||
class CMusicManager;
|
||||
class CMaterail;
|
||||
struct IEditorParticleManager;
|
||||
class CLensFlareManager;
|
||||
class CEAXPresetManager;
|
||||
class CErrorReport;
|
||||
class CBaseLibraryItem;
|
||||
@@ -69,7 +66,6 @@ class CDialog;
|
||||
#if defined(AZ_PLATFORM_WINDOWS)
|
||||
class C3DConnexionDriver;
|
||||
#endif
|
||||
class CRuler;
|
||||
class CSettingsManager;
|
||||
struct IExportManager;
|
||||
class CDisplaySettings;
|
||||
@@ -88,7 +84,6 @@ namespace WinWidget
|
||||
}
|
||||
|
||||
struct ISystem;
|
||||
struct I3DEngine;
|
||||
struct IRenderer;
|
||||
struct AABB;
|
||||
struct IEventLoopHook;
|
||||
@@ -140,7 +135,6 @@ enum EEditorNotifyEvent
|
||||
eNotify_OnEndLayerExport, // Sent after a layer have been exported.
|
||||
eNotify_OnCloseScene, // Send when the document is about to close.
|
||||
eNotify_OnSceneClosed, // Send when the document is closed.
|
||||
eNotify_OnMissionChange, // Send when the current mission changes.
|
||||
eNotify_OnBeginLoad, // Sent when the document is start to load.
|
||||
eNotify_OnEndLoad, // Sent when the document loading is finished
|
||||
|
||||
@@ -183,8 +177,6 @@ enum EEditorNotifyEvent
|
||||
|
||||
eNotify_OnDisplayRenderUpdate, // Sent when editor finish terrain texture generation.
|
||||
|
||||
eNotify_OnTimeOfDayChange, // Time of day parameters where modified.
|
||||
|
||||
eNotify_OnDataBaseUpdate, // DataBase Library was modified.
|
||||
|
||||
eNotify_OnLayerImportBegin, //layer import was started
|
||||
@@ -244,8 +236,6 @@ struct IDocListener
|
||||
virtual void OnLoadDocument() = 0;
|
||||
//! Called when document is being closed.
|
||||
virtual void OnCloseDocument() = 0;
|
||||
//! Called when mission changes.
|
||||
virtual void OnMissionChange() = 0;
|
||||
};
|
||||
|
||||
//! Derive from this class if you want to register for getting global editor notifications.
|
||||
@@ -434,8 +424,6 @@ struct IEditor
|
||||
virtual void DeleteThis() = 0;
|
||||
//! Access to Editor ISystem interface.
|
||||
virtual ISystem* GetSystem() = 0;
|
||||
virtual I3DEngine* Get3DEngine() = 0;
|
||||
virtual IRenderer* GetRenderer() = 0;
|
||||
//! Access to class factory.
|
||||
virtual IEditorClassFactory* GetClassFactory() = 0;
|
||||
//! Access to commands manager.
|
||||
@@ -545,8 +533,6 @@ struct IEditor
|
||||
virtual CSettingsManager* GetSettingsManager() = 0;
|
||||
//! Get DB manager that own items of specified type.
|
||||
virtual IDataBaseManager* GetDBItemManager(EDataBaseItemType itemType) = 0;
|
||||
//! Get Manager of Materials.
|
||||
virtual CMaterialManager* GetMaterialManager() = 0;
|
||||
virtual IBaseLibraryManager* GetMaterialManagerLibrary() = 0; // Vladimir@conffx
|
||||
virtual IEditorMaterialManager* GetIEditorMaterialManager() = 0; // Vladimir@Conffx
|
||||
//! Returns IconManager.
|
||||
@@ -555,8 +541,6 @@ struct IEditor
|
||||
virtual IEditorPanelUtils* GetEditorPanelUtils() = 0;
|
||||
//! Get Music Manager.
|
||||
virtual CMusicManager* GetMusicManager() = 0;
|
||||
//! Get Lens Flare Manager.
|
||||
virtual CLensFlareManager* GetLensFlareManager() = 0;
|
||||
virtual float GetTerrainElevation(float x, float y) = 0;
|
||||
virtual Editor::EditorQtApplication* GetEditorQtApplication() = 0;
|
||||
virtual const QColor& GetColorByName(const QString& name) = 0;
|
||||
@@ -566,7 +550,6 @@ struct IEditor
|
||||
virtual class CViewManager* GetViewManager() = 0;
|
||||
virtual class CViewport* GetActiveView() = 0;
|
||||
virtual void SetActiveView(CViewport* viewport) = 0;
|
||||
virtual struct IBackgroundTaskManager* GetBackgroundTaskManager() = 0;
|
||||
virtual struct IEditorFileMonitor* GetFileMonitor() = 0;
|
||||
|
||||
// These are needed for Qt integration:
|
||||
@@ -603,8 +586,6 @@ struct IEditor
|
||||
virtual void SetSelectedRegion(const AABB& box) = 0;
|
||||
//! Get currently selected region.
|
||||
virtual void GetSelectedRegion(AABB& box) = 0;
|
||||
//! Get current ruler
|
||||
virtual CRuler* GetRuler() = 0;
|
||||
|
||||
virtual void SetOperationMode(EOperationMode mode) = 0;
|
||||
virtual EOperationMode GetOperationMode() = 0;
|
||||
@@ -632,9 +613,6 @@ struct IEditor
|
||||
virtual RefCoordSys GetReferenceCoordSys() = 0;
|
||||
virtual XmlNodeRef FindTemplate(const QString& templateName) = 0;
|
||||
virtual void AddTemplate(const QString& templateName, XmlNodeRef& tmpl) = 0;
|
||||
//! Open material library and select specified item.
|
||||
//! If parameter is NULL current selection in material library does not change.
|
||||
virtual void OpenMaterialLibrary(IDataBaseItem* pItem = NULL) = 0;
|
||||
|
||||
virtual const QtViewPane* OpenView(QString sViewClassName, bool reuseOpen = true) = 0;
|
||||
virtual QWidget* FindView(QString viewClassName) = 0;
|
||||
@@ -652,7 +630,6 @@ struct IEditor
|
||||
//! Returns true if selection is made and false if selection is canceled.
|
||||
virtual bool SelectColor(QColor& color, QWidget* parent = 0) = 0;
|
||||
//! Get shader enumerator.
|
||||
virtual class CShaderEnum* GetShaderEnum() = 0;
|
||||
virtual class CUndoManager* GetUndoManager() = 0;
|
||||
//! Begin operation requiring undo
|
||||
//! Undo manager enters holding state.
|
||||
@@ -742,15 +719,12 @@ struct IEditor
|
||||
virtual ESystemConfigPlatform GetEditorConfigPlatform() const = 0;
|
||||
virtual void ReloadTemplates() = 0;
|
||||
virtual IResourceSelectorHost* GetResourceSelectorHost() = 0;
|
||||
virtual struct IBackgroundScheduleManager* GetBackgroundScheduleManager() = 0;
|
||||
virtual void ShowStatusText(bool bEnable) = 0;
|
||||
|
||||
// Provides a way to extend the context menu of an object. The function gets called every time the menu is opened.
|
||||
typedef AZStd::function<void(QMenu*, const CBaseObject*)> TContextMenuExtensionFunc;
|
||||
virtual void RegisterObjectContextMenuExtension(TContextMenuExtensionFunc func) = 0;
|
||||
|
||||
virtual void SetCurrentMissionTime(float time) = 0;
|
||||
|
||||
virtual SSystemGlobalEnvironment* GetEnv() = 0;
|
||||
virtual IImageUtil* GetImageUtil() = 0; // Vladimir@conffx
|
||||
virtual SEditorSettings* GetEditorSettings() = 0;
|
||||
@@ -762,8 +736,6 @@ struct IEditor
|
||||
|
||||
// reloads the plugins
|
||||
virtual void LoadPlugins() = 0;
|
||||
|
||||
virtual bool IsNewViewportInteractionModelEnabled() const = 0;
|
||||
};
|
||||
|
||||
//! Callback used by editor when initializing for info in UI dialogs
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user