Merge branch 'main' into LY-113714

This commit is contained in:
sphrose
2021-05-11 08:06:16 +01:00
702 changed files with 11113 additions and 66385 deletions
-14
View File
@@ -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,10 +631,6 @@ void Q2DViewport::OnTitleMenu(QMenu* menu)
//////////////////////////////////////////////////////////////////////////
void Q2DViewport::OnDestroy()
{
if (m_renderer)
{
m_renderer->DeleteContext(renderOverlayHWND());
}
}
//////////////////////////////////////////////////////////////////////////
-1
View File
@@ -159,7 +159,6 @@ protected:
//////////////////////////////////////////////////////////////////////////
// Variables.
//////////////////////////////////////////////////////////////////////////
IRenderer* m_renderer;
//! XY/XZ/YZ mode of this 2D viewport.
EViewportType m_viewType;
+16 -3
View File
@@ -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>
+5 -1
View File
@@ -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)
@@ -28,7 +28,6 @@ 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 ReverbPresetPropertyHandler());
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew SequencePropertyHandler());
EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, aznew SequenceIdPropertyHandler());
@@ -26,7 +26,6 @@
#include <CryCommon/ILocalizationManager.h>
// Editor
#include "ShadersDialog.h"
#include "SelectLightAnimationDialog.h"
#include "SelectSequenceDialog.h"
#include "SelectEAXPresetDlg.h"
@@ -78,16 +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 ReverbPresetPropertyEditor::onEditClicked()
{
CSelectEAXPresetDlg PresetDlg(this);
@@ -100,15 +100,6 @@ public:
}
};
class ShaderPropertyEditor
: public GenericPopupPropertyEditor
{
public:
ShaderPropertyEditor(QWidget* pParent = nullptr)
: GenericPopupPropertyEditor(pParent){}
void onEditClicked() override;
};
class ReverbPresetPropertyEditor
: public GenericPopupPropertyEditor
{
@@ -168,7 +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 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)>;
@@ -268,7 +268,6 @@ void ReflectedPropertyItem::SetVariable(IVariable *var)
case ePropertyUser:
m_reflectedVarAdapter = new ReflectedVarUserAdapter;
break;
case ePropertyShader:
case ePropertyEquip:
case ePropertyReverbPreset:
case ePropertyGameToken:
@@ -514,7 +514,7 @@ void LevelEditorMenuHandler::PopulateEditMenu(ActionManager::MenuWrapper& editMe
/*
* 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"));
+2 -96
View File
@@ -132,7 +132,6 @@ AZ_POP_DISABLE_WARNING
#include "Util/AutoDirectoryRestoreFileDialog.h"
#include "Util/EditorAutoLevelLoadTest.h"
#include "Util/Ruler.h"
#include "Util/IndexedFiles.h"
#include "AboutDialog.h"
#include <AzToolsFramework/PythonTerminal/ScriptHelpDialog.h>
@@ -390,7 +389,6 @@ void CCryEditApp::RegisterActionHandlers()
ON_COMMAND(ID_PREFERENCES, OnPreferences)
ON_COMMAND(ID_REDO, OnRedo)
ON_COMMAND(ID_TOOLBAR_WIDGET_REDO, OnRedo)
ON_COMMAND(ID_RELOAD_TEXTURES, OnReloadTextures)
ON_COMMAND(ID_FILE_OPEN_LEVEL, OnOpenLevel)
#ifdef ENABLE_SLICE_EDITOR
ON_COMMAND(ID_FILE_NEW_SLICE, OnCreateSlice)
@@ -400,8 +398,6 @@ void CCryEditApp::RegisterActionHandlers()
ON_COMMAND(ID_GAME_SYNCPLAYER, OnSyncPlayer)
ON_COMMAND(ID_RESOURCES_REDUCEWORKINGSET, OnResourcesReduceworkingset)
ON_COMMAND(ID_SNAP_TO_GRID, OnSnap)
ON_COMMAND(ID_WIREFRAME, OnWireframe)
ON_COMMAND(ID_VIEW_GRIDSETTINGS, OnViewGridsettings)
@@ -444,7 +440,6 @@ void CCryEditApp::RegisterActionHandlers()
ON_COMMAND(ID_VIEW_CYCLE2DVIEWPORT, OnViewCycle2dviewport)
#endif
ON_COMMAND(ID_DISPLAY_GOTOPOSITION, OnDisplayGotoPosition)
ON_COMMAND(ID_SNAPANGLE, OnSnapangle)
ON_COMMAND(ID_CHANGEMOVESPEED_INCREASE, OnChangemovespeedIncrease)
ON_COMMAND(ID_CHANGEMOVESPEED_DECREASE, OnChangemovespeedDecrease)
ON_COMMAND(ID_CHANGEMOVESPEED_CHANGESTEP, OnChangemovespeedChangestep)
@@ -527,12 +522,6 @@ public:
bool m_bExportTexture = false;
bool m_bMatEditMode = false;
bool m_bPrecacheShaders = false;
bool m_bPrecacheShadersLevels = false;
bool m_bPrecacheShaderList = false;
bool m_bStatsShaders = false;
bool m_bStatsShaderList = false;
bool m_bMergeShaders = false;
bool m_bConsoleMode = false;
bool m_bNullRenderer = false;
@@ -574,12 +563,6 @@ public:
{ "exportTexture", m_bExportTexture },
{ "test", m_bTest },
{ "auto_level_load", m_bAutoLoadLevel },
{ "PrecacheShaders", m_bPrecacheShaders },
{ "PrecacheShadersLevels", m_bPrecacheShadersLevels },
{ "PrecacheShaderList", m_bPrecacheShaderList },
{ "StatsShaders", m_bStatsShaders },
{ "StatsShaderList", m_bStatsShaderList },
{ "MergeShaders", m_bMergeShaders },
{ "MatEdit", m_bMatEditMode },
{ "BatchMode", m_bConsoleMode },
{ "NullRenderer", m_bNullRenderer },
@@ -1024,26 +1007,12 @@ void CCryEditApp::OutputStartupMessage(QString str)
//////////////////////////////////////////////////////////////////////////
void CCryEditApp::InitFromCommandLine(CEditCommandLineInfo& cmdInfo)
{
//! Setup flags from command line
if (cmdInfo.m_bPrecacheShaders || cmdInfo.m_bPrecacheShadersLevels || cmdInfo.m_bMergeShaders
|| cmdInfo.m_bPrecacheShaderList || cmdInfo.m_bStatsShaderList || cmdInfo.m_bStatsShaders)
{
m_bPreviewMode = true;
m_bConsoleMode = true;
m_bTestMode = true;
}
m_bConsoleMode |= cmdInfo.m_bConsoleMode;
inEditorBatchMode = AZ::Environment::CreateVariable<bool>("InEditorBatchMode", m_bConsoleMode);
m_bTestMode |= cmdInfo.m_bTest;
m_bSkipWelcomeScreenDialog = cmdInfo.m_bSkipWelcomeScreenDialog || !cmdInfo.m_execFile.isEmpty() || !cmdInfo.m_execLineCmd.isEmpty() || cmdInfo.m_bAutotestMode;
m_bPrecacheShaderList = cmdInfo.m_bPrecacheShaderList;
m_bStatsShaderList = cmdInfo.m_bStatsShaderList;
m_bStatsShaders = cmdInfo.m_bStatsShaders;
m_bPrecacheShaders = cmdInfo.m_bPrecacheShaders;
m_bPrecacheShadersLevels = cmdInfo.m_bPrecacheShadersLevels;
m_bMergeShaders = cmdInfo.m_bMergeShaders;
m_bExportMode = cmdInfo.m_bExport;
m_bRunPythonTestScript = cmdInfo.m_bRunPythonTestScript;
m_bRunPythonScript = cmdInfo.m_bRunPythonScript || cmdInfo.m_bRunPythonTestScript;
@@ -1079,11 +1048,9 @@ void CCryEditApp::InitFromCommandLine(CEditCommandLineInfo& cmdInfo)
/////////////////////////////////////////////////////////////////////////////
AZ::Outcome<void, AZStd::string> CCryEditApp::InitGameSystem(HWND hwndForInputSystem)
{
bool bShaderCacheGen = m_bPrecacheShaderList | m_bPrecacheShaders | m_bPrecacheShadersLevels;
CGameEngine* pGameEngine = new CGameEngine;
AZ::Outcome<void, AZStd::string> initOutcome = pGameEngine->Init(m_bPreviewMode, m_bTestMode, bShaderCacheGen, qApp->arguments().join(" ").toUtf8().data(), g_pInitializeUIInfo, hwndForInputSystem);
AZ::Outcome<void, AZStd::string> initOutcome = pGameEngine->Init(m_bPreviewMode, m_bTestMode, qApp->arguments().join(" ").toUtf8().data(), g_pInitializeUIInfo, hwndForInputSystem);
if (!initOutcome.IsSuccess())
{
return initOutcome;
@@ -1124,8 +1091,7 @@ BOOL CCryEditApp::CheckIfAlreadyRunning()
}
}
// Shader pre-caching may start multiple editor copies
if (!FirstInstance(bForceNewInstance) && !m_bPrecacheShaderList)
if (!FirstInstance(bForceNewInstance))
{
return false;
}
@@ -1347,37 +1313,6 @@ void CCryEditApp::InitLevel(const CEditCommandLineInfo& cmdInfo)
/////////////////////////////////////////////////////////////////////////////
BOOL CCryEditApp::InitConsole()
{
if (m_bPrecacheShaderList)
{
GetIEditor()->GetSystem()->GetIConsole()->ExecuteString("r_PrecacheShaderList");
return false;
}
else if (m_bStatsShaderList)
{
GetIEditor()->GetSystem()->GetIConsole()->ExecuteString("r_StatsShaderList");
return false;
}
else if (m_bStatsShaders)
{
GetIEditor()->GetSystem()->GetIConsole()->ExecuteString("r_StatsShaders");
return false;
}
else if (m_bPrecacheShaders)
{
GetIEditor()->GetSystem()->GetIConsole()->ExecuteString("r_PrecacheShaders");
return false;
}
else if (m_bPrecacheShadersLevels)
{
GetIEditor()->GetSystem()->GetIConsole()->ExecuteString("r_PrecacheShadersLevels");
return false;
}
else if (m_bMergeShaders)
{
GetIEditor()->GetSystem()->GetIConsole()->ExecuteString("r_MergeShaders");
return false;
}
// Execute command from cmdline -exec_line if applicable
if (!m_execLineCmd.isEmpty())
{
@@ -2930,14 +2865,6 @@ void CCryEditApp::OnPreferences()
*/
}
void CCryEditApp::OnReloadTextures()
{
QWaitCursor wait;
CLogFile::WriteLine("Reloading Static objects textures and shaders.");
GetIEditor()->GetObjectManager()->SendEvent(EVENT_RELOAD_TEXTURES);
GetIEditor()->GetRenderer()->EF_ReloadTextures();
}
//////////////////////////////////////////////////////////////////////////
void CCryEditApp::OnUndo()
{
@@ -3493,14 +3420,6 @@ void CCryEditApp::OnResourcesReduceworkingset()
#endif
}
//////////////////////////////////////////////////////////////////////////
void CCryEditApp::OnSnap()
{
// Switch current snap to grid state.
bool bGridEnabled = gSettings.pGrid->IsEnabled();
gSettings.pGrid->Enable(!bGridEnabled);
}
void CCryEditApp::OnWireframe()
{
int nWireframe(R_SOLID_MODE);
@@ -3749,19 +3668,6 @@ void CCryEditApp::OnDisplayGotoPosition()
dlg.exec();
}
//////////////////////////////////////////////////////////////////////////
void CCryEditApp::OnSnapangle()
{
gSettings.pGrid->EnableAngleSnap(!gSettings.pGrid->IsAngleSnapEnabled());
}
//////////////////////////////////////////////////////////////////////////
void CCryEditApp::OnUpdateSnapangle(QAction* action)
{
Q_ASSERT(action->isCheckable());
action->setChecked(gSettings.pGrid->IsAngleSnapEnabled());
}
//////////////////////////////////////////////////////////////////////////
void CCryEditApp::OnChangemovespeedIncrease()
{
-10
View File
@@ -229,7 +229,6 @@ public:
void OnFileResaveSlices();
void OnFileEditEditorini();
void OnPreferences();
void OnReloadTextures();
void OnRedo();
void OnUpdateRedo(QAction* action);
void OnUpdateUndo(QAction* action);
@@ -284,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;
@@ -371,7 +364,6 @@ private:
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
friend struct PythonTestOutputHandler;
void OnSnap();
void OnWireframe();
void OnUpdateWireframe(QAction* action);
void OnViewGridsettings();
@@ -409,8 +401,6 @@ private:
void OnToolsScriptHelp();
void OnViewCycle2dviewport();
void OnDisplayGotoPosition();
void OnSnapangle();
void OnUpdateSnapangle(QAction* action);
void OnChangemovespeedIncrease();
void OnChangemovespeedDecrease();
void OnChangemovespeedChangestep();
-39
View File
@@ -51,7 +51,6 @@
#include "Include/IObjectManager.h"
#include "ErrorReportDialog.h"
#include "SurfaceTypeValidator.h"
#include "ShaderCache.h"
#include "Util/AutoLogTime.h"
#include "CheckOutDialog.h"
#include "GameExporter.h"
@@ -143,7 +142,6 @@ CCryEditDoc::CCryEditDoc()
m_environmentTemplate = XmlHelpers::CreateXmlNode("Environment");
}
m_pLevelShaderCache = new CLevelShaderCache;
m_bDocumentReady = false;
GetIEditor()->SetDocument(this);
CLogFile::WriteLine("Document created");
@@ -156,8 +154,6 @@ CCryEditDoc::~CCryEditDoc()
{
GetIEditor()->SetDocument(nullptr);
delete m_pLevelShaderCache;
CLogFile::WriteLine("Document destroyed");
AzToolsFramework::SliceEditorEntityOwnershipServiceNotificationBus::Handler::BusDisconnect();
@@ -337,7 +333,6 @@ void CCryEditDoc::Save(TDocMultiArchive& arrXmlAr)
// Fog settings ///////////////////////////////////////////////////////
SerializeFogSettings((*arrXmlAr[DMAS_GENERAL]));
SerializeShaderCache((*arrXmlAr[DMAS_GENERAL_NAMED_DATA]));
SerializeNameSelection((*arrXmlAr[DMAS_GENERAL]));
}
}
@@ -486,7 +481,6 @@ void CCryEditDoc::Load(TDocMultiArchive& arrXmlAr, const QString& szFilename)
{
// Serialize Shader Cache.
CAutoLogTime logtime("Load Level Shader Cache");
SerializeShaderCache((*arrXmlAr[DMAS_GENERAL_NAMED_DATA]));
}
{
@@ -668,39 +662,6 @@ void CCryEditDoc::SerializeFogSettings(CXmlArchive& xmlAr)
}
}
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();
-4
View File
@@ -22,7 +22,6 @@
#include <TimeValue.h>
#endif
class CLevelShaderCache;
class CClouds;
struct LightingSettings;
struct IVariable;
@@ -123,7 +122,6 @@ public: // Create from serialization only
const char* GetTemporaryLevelName() const;
void DeleteTemporaryLevel();
CLevelShaderCache* GetShaderCache() { return m_pLevelShaderCache; }
CClouds* GetClouds() { return m_pClouds; }
void SetWaterColor(const QColor& col) { m_waterColor = col; }
QColor GetWaterColor() { return m_waterColor; }
@@ -165,7 +163,6 @@ protected:
bool LoadEntitiesFromSlice(const QString& sliceFile);
void SerializeFogSettings(CXmlArchive& xmlAr);
virtual void SerializeViewSettings(CXmlArchive& xmlAr);
void SerializeShaderCache(CXmlArchive& xmlAr);
void SerializeNameSelection(CXmlArchive& xmlAr);
void LogLoadTime(int time);
@@ -201,7 +198,6 @@ protected:
CClouds* m_pClouds;
std::list<IDocListener*> m_listeners;
bool m_bDocumentReady;
CLevelShaderCache* m_pLevelShaderCache;
ICVar* doc_validate_surface_types;
int m_modifiedModuleFlags;
bool m_boLevelExported;
@@ -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);
}
-1
View File
@@ -15,7 +15,6 @@
#define CRYINCLUDE_EDITOR_EDITORFILEMONITOR_H
#pragma once
#include "Include/IEditorFileMonitor.h"
#include "IFileChangeMonitor.h"
#include "Util/FileChangeMonitor.h"
class CEditorFileMonitor
@@ -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 Editor
{
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 Editor
@@ -0,0 +1,38 @@
/*
* 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 <EditorCoreAPI.h>
namespace Editor
{
EDITOR_CORE_API bool GridSnappingEnabled();
EDITOR_CORE_API float GridSnappingSize();
EDITOR_CORE_API bool AngleSnappingEnabled();
EDITOR_CORE_API float AngleSnappingSize();
EDITOR_CORE_API bool ShowingGrid();
EDITOR_CORE_API void SetGridSnapping(bool enabled);
EDITOR_CORE_API void SetGridSnappingSize(float size);
EDITOR_CORE_API void SetAngleSnapping(bool enabled);
EDITOR_CORE_API void SetAngleSnappingSize(float size);
EDITOR_CORE_API void SetShowingGrid(bool showing);
} // namespace Editor
+19 -17
View File
@@ -75,6 +75,7 @@
#include "ViewportManipulatorController.h"
#include "LegacyViewportCameraController.h"
#include "ModernViewportCameraController.h"
#include "EditorViewportSettings.h"
#include "ViewPane.h"
#include "CustomResolutionDlg.h"
@@ -127,6 +128,18 @@ 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
{
static const char TextCantCreateCameraNoLevel[] = "Cannot create camera when no level is loaded.";
@@ -170,7 +183,6 @@ EditorViewportWidget::EditorViewportWidget(const QString& name, QWidget* parent)
, m_camFOV(gSettings.viewports.fDefaultFov)
, m_defaultViewName(name)
, m_renderViewport(nullptr) //m_renderViewport is initialized later, in SetViewportId
, m_editorViewportSettings(this)
{
// need this to be set in order to allow for language switching on Windows
setAttribute(Qt::WA_InputMethodEnabled);
@@ -791,10 +803,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);
if (GetIEditor()->GetRenderer())
{
GetIEditor()->GetRenderer()->SetCamera(gEnv->pSystem->GetViewCamera());
}
return;
}
@@ -1250,7 +1258,7 @@ void EditorViewportWidget::SetViewportId(int id)
m_renderViewport->GetControllerList()->Add(AZStd::make_shared<SandboxEditor::LegacyViewportCameraController>());
}
m_renderViewport->SetViewportSettings(&m_editorViewportSettings);
m_renderViewport->SetViewportSettings(&g_EditorViewportSettings);
UpdateScene();
@@ -2871,35 +2879,29 @@ void EditorViewportWidget::SetAsActiveViewport()
}
}
EditorViewportSettings::EditorViewportSettings(const EditorViewportWidget* editorViewportWidget)
: m_editorViewportWidget(editorViewportWidget)
{
}
bool EditorViewportSettings::GridSnappingEnabled() const
{
return m_editorViewportWidget->GetViewManager()->GetGrid()->IsEnabled();
return Editor::GridSnappingEnabled();
}
float EditorViewportSettings::GridSize() const
{
const CGrid* grid = m_editorViewportWidget->GetViewManager()->GetGrid();
return grid->scale * grid->size;
return Editor::GridSnappingSize();
}
bool EditorViewportSettings::ShowGrid() const
{
return gSettings.viewports.bShowGridGuide;
return Editor::ShowingGrid();
}
bool EditorViewportSettings::AngleSnappingEnabled() const
{
return m_editorViewportWidget->GetViewManager()->GetGrid()->IsAngleSnapEnabled();
return Editor::AngleSnappingEnabled();
}
float EditorViewportSettings::AngleStep() const
{
return m_editorViewportWidget->GetViewManager()->GetGrid()->GetAngleSnap();
return Editor::AngleSnappingSize();
}
#include <moc_EditorViewportWidget.cpp>
@@ -65,23 +65,6 @@ namespace AzToolsFramework
class ManipulatorManager;
}
class EditorViewportWidget;
//! Viewport settings for the EditorViewportWidget
struct EditorViewportSettings : public AzToolsFramework::ViewportInteraction::ViewportSettings
{
explicit EditorViewportSettings(const EditorViewportWidget* editorViewportWidget);
bool GridSnappingEnabled() const override;
float GridSize() const override;
bool ShowGrid() const override;
bool AngleSnappingEnabled() const override;
float AngleStep() const override;
private:
const EditorViewportWidget* m_editorViewportWidget = nullptr;
};
// EditorViewportWidget window
AZ_PUSH_DISABLE_DLL_EXPORT_BASECLASS_WARNING
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
@@ -607,7 +590,5 @@ private:
AZ::Name m_defaultViewportContextName;
EditorViewportSettings m_editorViewportSettings;
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
};
-22
View File
@@ -38,7 +38,6 @@
// CryCommon
#include <CryCommon/INavigationSystem.h>
#include <CryCommon/IDeferredCollisionEvent.h>
#include <CryCommon/LyShine/ILyShine.h>
#include <CryCommon/MainThreadRenderRequestBus.h>
@@ -46,7 +45,6 @@
#include "CryEdit.h"
#include "ViewManager.h"
#include "Util/Ruler.h"
#include "AnimationContext.h"
#include "UndoViewPosition.h"
#include "UndoViewRotation.h"
@@ -386,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)
@@ -444,10 +441,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);
@@ -620,12 +613,6 @@ void CGameEngine::SwitchToInGame()
m_pISystem->GetIMovieSystem()->EnablePhysicsEvents(true);
m_bInGameMode = true;
CRuler* pRuler = GetIEditor()->GetRuler();
if (pRuler)
{
pRuler->SetActive(false);
}
gEnv->pSystem->GetViewCamera().SetMatrix(m_playerViewTM);
// Disable accelerators.
@@ -792,12 +779,6 @@ void CGameEngine::SetSimulationMode(bool enabled, bool bOnlyPhysics)
if (enabled)
{
CRuler* pRuler = GetIEditor()->GetRuler();
if (pRuler)
{
pRuler->SetActive(false);
}
GetIEditor()->Notify(eNotify_OnBeginSimulationMode);
}
else
@@ -923,9 +904,6 @@ void CGameEngine::Update()
// 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;
-1
View File
@@ -79,7 +79,6 @@ public:
AZ::Outcome<void, AZStd::string> Init(
bool bPreviewMode,
bool bTestMode,
bool bShaderCacheGen,
const char* sCmdLine,
IInitializeUIInfo* logo,
HWND hwndForInputSystem);
+11 -14
View File
@@ -24,7 +24,6 @@
#include "GameExporter.h"
#include "GameEngine.h"
#include "CryEditDoc.h"
#include "ShaderCache.h"
#include "UsedResources.h"
#include "WaitProgress.h"
#include "Util/CryMemFile.h"
@@ -197,7 +196,6 @@ bool CGameExporter::Export(unsigned int flags, [[maybe_unused]] EEndian eExportE
ExportLevelResourceList(sLevelPath);
ExportLevelUsedResourceList(sLevelPath);
ExportLevelShaderCache(sLevelPath);
//////////////////////////////////////////////////////////////////////////
// End Exporting Game data.
@@ -295,6 +293,17 @@ void CGameExporter::ExportLevelData(const QString& path, bool /*bExportMission*/
CCryMemFile fileAction;
fileAction.Write(xmlDataAction.c_str(), xmlDataAction.length());
m_levelPak.m_pakFile.UpdateFile(levelDataActionFile.toUtf8().data(), fileAction);
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, "Mission0");
m_levelPak.m_pakFile.UpdateFile(entitiesFile.toUtf8().data(), entitySaveBuffer.begin(), entitySaveBuffer.size());
}
}
//////////////////////////////////////////////////////////////////////////
@@ -368,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)
{
-2
View File
@@ -95,8 +95,6 @@ private:
void ExportLevelResourceList(const QString& path);
void ExportLevelUsedResourceList(const QString& path);
void ExportLevelShaderCache(const QString& path);
void ExportGameData(const QString& path);
void ExportFileList(const QString& path, const QString& levelName);
void Error(const QString& error);
-5
View File
@@ -66,7 +66,6 @@ class CDialog;
#if defined(AZ_PLATFORM_WINDOWS)
class C3DConnexionDriver;
#endif
class CRuler;
class CSettingsManager;
struct IExportManager;
class CDisplaySettings;
@@ -425,7 +424,6 @@ struct IEditor
virtual void DeleteThis() = 0;
//! Access to Editor ISystem interface.
virtual ISystem* GetSystem() = 0;
virtual IRenderer* GetRenderer() = 0;
//! Access to class factory.
virtual IEditorClassFactory* GetClassFactory() = 0;
//! Access to commands manager.
@@ -589,8 +587,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;
@@ -635,7 +631,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.
-24
View File
@@ -49,7 +49,6 @@ AZ_POP_DISABLE_WARNING
#include "Objects/GizmoManager.h"
#include "Objects/AxisGizmo.h"
#include "DisplaySettings.h"
#include "ShaderEnum.h"
#include "KeyboardCustomizationSettings.h"
#include "Export/ExportManager.h"
#include "LevelIndependentFileMan.h"
@@ -60,7 +59,6 @@ AZ_POP_DISABLE_WARNING
#include "MainWindow.h"
#include "Alembic/AlembicCompiler.h"
#include "UIEnumsDatabase.h"
#include "Util/Ruler.h"
#include "RenderHelpers/AxisHelper.h"
#include "Settings.h"
#include "Include/IObjectManager.h"
@@ -134,7 +132,6 @@ CEditorImpl::CEditorImpl()
, m_bUpdates(true)
, m_bTerrainAxisIgnoreObjects(false)
, m_pDisplaySettings(nullptr)
, m_pShaderEnum(nullptr)
, m_pIconManager(nullptr)
, m_bSelectionLocked(true)
, m_pAxisGizmo(nullptr)
@@ -149,7 +146,6 @@ CEditorImpl::CEditorImpl()
, m_pSourceControl(nullptr)
, m_pSelectionTreeManager(nullptr)
, m_pUIEnumsDatabase(nullptr)
, m_pRuler(nullptr)
, m_pConsoleSync(nullptr)
, m_pSettingsManager(nullptr)
, m_pLevelIndependentFileMan(nullptr)
@@ -185,7 +181,6 @@ CEditorImpl::CEditorImpl()
m_pBackgroundScheduleManager.reset(new BackgroundScheduleManager::CScheduleManager);
m_pUIEnumsDatabase = new CUIEnumsDatabase;
m_pDisplaySettings = new CDisplaySettings;
m_pShaderEnum = new CShaderEnum;
m_pDisplaySettings->LoadRegistry();
m_pPluginManager = new CPluginManager;
@@ -202,7 +197,6 @@ CEditorImpl::CEditorImpl()
m_pImageUtil = new CImageUtil_impl();
m_pResourceSelectorHost.reset(CreateResourceSelectorHost());
m_pRuler = new CRuler;
m_selectedRegion.min = Vec3(0, 0, 0);
m_selectedRegion.max = Vec3(0, 0, 0);
DetectVersion();
@@ -335,8 +329,6 @@ CEditorImpl::~CEditorImpl()
}
SAFE_DELETE(m_pDisplaySettings)
SAFE_DELETE(m_pRuler)
SAFE_DELETE(m_pShaderEnum)
SAFE_DELETE(m_pToolBoxManager)
SAFE_DELETE(m_pCommandManager)
SAFE_DELETE(m_pClassFactory)
@@ -419,7 +411,6 @@ void CEditorImpl::Update()
m_bUpdates = false;
FUNCTION_PROFILER(GetSystem(), PROFILE_EDITOR);
m_pRuler->Update();
//@FIXME: Restore this latter.
//if (GetGameEngine() && GetGameEngine()->IsLevelLoaded())
@@ -440,15 +431,6 @@ ISystem* CEditorImpl::GetSystem()
return m_pSystem;
}
IRenderer* CEditorImpl::GetRenderer()
{
if (gEnv)
{
return gEnv->pRenderer;
}
return nullptr;
}
IEditorClassFactory* CEditorImpl::GetClassFactory()
{
return m_pClassFactory;
@@ -1182,11 +1164,6 @@ void CEditorImpl::AddTemplate(const QString& templateName, XmlNodeRef& tmpl)
m_templateRegistry.AddTemplate(templateName, tmpl);
}
CShaderEnum* CEditorImpl::GetShaderEnum()
{
return m_pShaderEnum;
}
bool CEditorImpl::ExecuteConsoleApp(const QString& CommandLine, QString& OutputText, [[maybe_unused]] bool bNoTimeOut, bool bShowWindow)
{
CLogFile::FormatLine("Executing console application '%s'", CommandLine.toUtf8().data());
@@ -1569,7 +1546,6 @@ void CEditorImpl::ReduceMemory()
GetIEditor()->GetUndoManager()->ClearRedoStack();
GetIEditor()->GetUndoManager()->ClearUndoStack();
GetIEditor()->GetObjectManager()->SendEvent(EVENT_FREE_GAME_DATA);
gEnv->pRenderer->FreeResources(FRR_TEXTURES);
#if defined(AZ_PLATFORM_WINDOWS)
HANDLE hHeap = GetProcessHeap();
-7
View File
@@ -53,7 +53,6 @@ class CAlembicCompiler;
struct IBackgroundTaskManager;
struct IBackgroundScheduleManager;
struct IEditorFileMonitor;
class CShaderEnum;
class CVegetationMap;
@@ -116,7 +115,6 @@ public:
bool IsInitialized() const{ return m_bInitialized; }
bool SaveDocument();
ISystem* GetSystem();
IRenderer* GetRenderer();
void WriteToConsole(const char* string) { CLogFile::WriteLine(string); };
void WriteToConsole(const QString& string) { CLogFile::WriteLine(string); };
// Change the message in the status bar
@@ -215,7 +213,6 @@ public:
void SetMarkerPosition(const Vec3& pos) { m_marker = pos; };
void SetSelectedRegion(const AABB& box);
void GetSelectedRegion(AABB& box);
CRuler* GetRuler() { return m_pRuler; }
bool AddToolbarItem(uint8 iId, IUIEvent* pIHandler);
void SetDataModified();
void SetOperationMode(EOperationMode mode);
@@ -256,7 +253,6 @@ public:
SFileVersion GetFileVersion() { return m_fileVersion; };
SFileVersion GetProductVersion() { return m_productVersion; };
//! Get shader enumerator.
CShaderEnum* GetShaderEnum();
CUndoManager* GetUndoManager() { return m_pUndoManager; };
void BeginUndo();
void RestoreUndo(bool undo);
@@ -365,7 +361,6 @@ protected:
SFileVersion m_productVersion;
CXmlTemplateRegistry m_templateRegistry;
CDisplaySettings* m_pDisplaySettings;
CShaderEnum* m_pShaderEnum;
CIconManager* m_pIconManager;
std::unique_ptr<SGizmoParameters> m_pGizmoParameters;
QString m_primaryCDFolder;
@@ -390,8 +385,6 @@ protected:
CSelectionTreeManager* m_pSelectionTreeManager;
CUIEnumsDatabase* m_pUIEnumsDatabase;
//! Currently used ruler
CRuler* m_pRuler;
//! CConsole Synchronization
CConsoleSynchronization* m_pConsoleSync;
//! Editor Settings Manager
@@ -15,9 +15,43 @@
#define CRYINCLUDE_EDITOR_INCLUDE_IEDITORFILEMONITOR_H
#pragma once
#include <IFileChangeMonitor.h>
struct IFileChangeListener
{
enum EChangeType
{
//! error or unknown change type
eChangeType_Unknown,
//! the file was created
eChangeType_Created,
//! the file was deleted
eChangeType_Deleted,
//! the file was modified (size changed,write)
eChangeType_Modified,
//! this is the old name of a renamed file
eChangeType_RenamedOldName,
//! this is the new name of a renamed file
eChangeType_RenamedNewName
};
struct IFileChangeListener;
virtual ~IFileChangeListener() = default;
virtual void OnFileChange(const char* sFilename, EChangeType eType) = 0;
};
struct IFileChangeMonitor
{
virtual ~IFileChangeMonitor() = default;
// <interfuscator:shuffle>
// Register the path of a file or directory to monitor
// Path is relative to game directory, e.g. "Libs/WoundSystem/" or "Libs/WoundSystem/HitLocations.xml"
virtual bool RegisterListener(IFileChangeListener* pListener, const char* sMonitorItem) = 0;
// This function can be used to monitor files of specific type, e.g.
// RegisterListener(pListener, "Animations", "caf")
virtual bool RegisterListener(IFileChangeListener* pListener, const char* sFolder, const char* sExtension) = 0;
virtual bool UnregisterListener(IFileChangeListener* pListener) = 0;
// </interfuscator:shuffle>
};
struct IEditorFileMonitor
: public IFileChangeMonitor
@@ -33,7 +33,6 @@ enum ObjectEvent
EVENT_DBLCLICK, //!< Signals that object have been double clicked.
EVENT_KEEP_HEIGHT, //!< Signals that object must preserve its height over changed terrain.
EVENT_RELOAD_ENTITY,//!< Signals that entities scripts must be reloaded.
EVENT_RELOAD_TEXTURES,//!< Signals that all possible textures in objects should be reloaded.
EVENT_RELOAD_GEOM, //!< Signals that all possible geometries should be reloaded.
EVENT_UNLOAD_GEOM, //!< Signals that all possible geometries should be unloaded.
EVENT_MISSION_CHANGE, //!< Signals that mission have been changed.
@@ -32,7 +32,6 @@ public:
public:
MOCK_METHOD0(DeleteThis, void());
MOCK_METHOD0(GetSystem, ISystem*());
MOCK_METHOD0(GetRenderer, IRenderer* ());
MOCK_METHOD0(GetClassFactory, IEditorClassFactory* ());
MOCK_METHOD0(GetCommandManager, CEditorCommandManager*());
MOCK_METHOD0(GetICommandManager, ICommandManager* ());
@@ -117,7 +116,6 @@ public:
MOCK_METHOD1(SetMarkerPosition, void(const Vec3&));
MOCK_METHOD1(SetSelectedRegion, void(const AABB& box));
MOCK_METHOD1(GetSelectedRegion, void(AABB& box));
MOCK_METHOD0(GetRuler, CRuler* ());
MOCK_METHOD1(SetOperationMode, void(EOperationMode ));
MOCK_METHOD0(GetOperationMode, EOperationMode());
MOCK_METHOD1(ShowTransformManipulator, ITransformManipulator* (bool));
@@ -140,7 +138,6 @@ public:
MOCK_METHOD1(OpenWinWidget, QWidget* (WinWidgetId ));
MOCK_CONST_METHOD0(GetWinWidgetManager, WinWidget::WinWidgetManager* ());
MOCK_METHOD2(SelectColor, bool(QColor &, QWidget *));
MOCK_METHOD0(GetShaderEnum, class CShaderEnum* ());
MOCK_METHOD0(GetUndoManager, class CUndoManager* ());
MOCK_METHOD0(BeginUndo, void());
MOCK_METHOD1(RestoreUndo, void(bool));
+16 -8
View File
@@ -78,6 +78,7 @@ AZ_POP_DISABLE_WARNING
#include "Core/QtEditorApplication.h"
#include "UndoDropDown.h"
#include "CVarMenu.h"
#include "EditorViewportSettings.h"
#include "KeyboardCustomizationSettings.h"
#include "CustomizeKeyboardDialog.h"
@@ -915,13 +916,22 @@ void MainWindow::InitActions()
.SetToolTip(tr("Snap to grid (G)"))
.SetStatusTip(tr("Toggles snap to grid"))
.SetCheckable(true)
.RegisterUpdateCallback(this, &MainWindow::OnUpdateSnapToGrid);
.RegisterUpdateCallback([](QAction* action) {
Q_ASSERT(action->isCheckable());
action->setChecked(Editor::GridSnappingEnabled());
})
.Connect(&QAction::triggered, []() { Editor::SetGridSnapping(!Editor::GridSnappingEnabled()); });
am->AddAction(ID_SNAPANGLE, tr("Snap angle"))
.SetIcon(Style::icon("Angle"))
.SetApplyHoverEffect()
.SetStatusTip(tr("Snap angle"))
.SetCheckable(true)
.RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdateSnapangle);
.RegisterUpdateCallback([](QAction* action) {
Q_ASSERT(action->isCheckable());
action->setChecked(Editor::AngleSnappingEnabled());
})
.Connect(&QAction::triggered, []() { Editor::SetAngleSnapping(!Editor::AngleSnappingEnabled()); });
// Display actions
am->AddAction(ID_WIREFRAME, tr("&Wireframe"))
@@ -1075,8 +1085,6 @@ void MainWindow::InitActions()
.RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdateSelected);
// Tools actions
am->AddAction(ID_RELOAD_TEXTURES, tr("Reload Textures/Shaders"))
.SetStatusTip(tr("Reload all textures."));
am->AddAction(ID_TOOLS_ENABLEFILECHANGEMONITORING, tr("Enable File Change Monitoring"));
am->AddAction(ID_CLEAR_REGISTRY, tr("Clear Registry Data"))
.SetStatusTip(tr("Clear Registry Data"));
@@ -1434,12 +1442,12 @@ QWidget* MainWindow::CreateSnapToGridWidget()
{
SnapToWidget::SetValueCallback setCallback = [](double snapStep)
{
GetIEditor()->GetViewManager()->GetGrid()->size = snapStep;
Editor::SetGridSnappingSize(snapStep);
};
SnapToWidget::GetValueCallback getCallback = []()
{
return GetIEditor()->GetViewManager()->GetGrid()->size;
return Editor::GridSnappingSize();
};
return new SnapToWidget(m_actionManager->GetAction(ID_SNAP_TO_GRID), setCallback, getCallback);
@@ -1449,12 +1457,12 @@ QWidget* MainWindow::CreateSnapToAngleWidget()
{
SnapToWidget::SetValueCallback setCallback = [](double snapAngle)
{
GetIEditor()->GetViewManager()->GetGrid()->angleSnap = snapAngle;
Editor::SetAngleSnappingSize(snapAngle);
};
SnapToWidget::GetValueCallback getCallback = []()
{
return GetIEditor()->GetViewManager()->GetGrid()->angleSnap;
return Editor::AngleSnappingSize();
};
return new SnapToWidget(m_actionManager->GetAction(ID_SNAPANGLE), setCallback, getCallback);
+1 -305
View File
@@ -894,314 +894,10 @@ void CBaseObject::DrawDefault(DisplayContext& dc, const QColor& labelColor)
}
//////////////////////////////////////////////////////////////////////////
void CBaseObject::DrawDimensions(DisplayContext& dc, AABB* pMergedBoundBox)
void CBaseObject::DrawDimensions(DisplayContext&, AABB*)
{
if (HasMeasurementAxis() && GetIEditor()->GetDisplaySettings()->IsDisplayDimensionFigures())
{
AABB localBoundBox;
GetLocalBounds(localBoundBox);
DrawDimensionsImpl(dc, localBoundBox, pMergedBoundBox);
}
}
//////////////////////////////////////////////////////////////////////////
void CBaseObject::DrawDimensionsImpl(DisplayContext& dc, const AABB& localBoundBox, AABB* pMergedBoundBox)
{
AABB boundBox;
Matrix34 rotatedTM;
bool bHave2Axis(false);
float xLength(0);
float yLength(0);
float zLength(0);
if (pMergedBoundBox)
{
rotatedTM = Matrix34::CreateIdentity();
boundBox = *pMergedBoundBox;
xLength = boundBox.max.x - boundBox.min.x;
zLength = boundBox.max.z - boundBox.min.z;
yLength = boundBox.max.y - boundBox.min.y;
}
else
{
rotatedTM = GetWorldRotTM();
Matrix34 scaledTranslatedTM = GetWorldScaleTM();
scaledTranslatedTM.SetTranslation(GetWorldPos());
boundBox.SetTransformedAABB(scaledTranslatedTM, localBoundBox);
IVariable* pVarXLength(NULL);
IVariable* pVarYLength(NULL);
IVariable* pVarZLength(NULL);
IVariable* pVarDimX(NULL);
IVariable* pVarDimY(NULL);
IVariable* pVarDimZ(NULL);
CVarBlock* pVarBlock(GetVarBlock());
if (pVarBlock)
{
pVarXLength = pVarBlock->FindVariable("Width");
pVarYLength = pVarBlock->FindVariable("Length");
pVarZLength = pVarBlock->FindVariable("Height");
pVarDimX = pVarBlock->FindVariable("DimX");
pVarDimY = pVarBlock->FindVariable("DimY");
pVarDimZ = pVarBlock->FindVariable("DimZ");
}
xLength = boundBox.max.x - boundBox.min.x;
zLength = boundBox.max.z - boundBox.min.z;
yLength = boundBox.max.y - boundBox.min.y;
if (pVarDimX && pVarDimY && pVarDimZ)
{
pVarDimX->Get(xLength);
pVarDimZ->Get(zLength);
pVarDimY->Get(yLength);
xLength *= m_scale.x;
zLength *= m_scale.z;
yLength *= m_scale.y;
}
else if (pVarXLength && pVarYLength && pVarZLength)
{
// A case of an area box.
pVarXLength->Get(xLength);
pVarZLength->Get(zLength);
pVarYLength->Get(yLength);
xLength *= m_scale.x;
zLength *= m_scale.z;
yLength *= m_scale.y;
}
else if (!pVarXLength && !pVarYLength && pVarZLength)
{
// A case of an area shape.
pVarZLength->Get(zLength);
zLength *= m_scale.z;
}
}
const float kMinimumLimitation(0.4f);
if (xLength < kMinimumLimitation && yLength < kMinimumLimitation && zLength < kMinimumLimitation)
{
return;
}
const float kEpsilon(0.001f);
bHave2Axis = fabs(zLength) < kEpsilon;
Vec3 basePoints[] = {
Vec3(boundBox.min.x, boundBox.min.y, boundBox.min.z),
Vec3(boundBox.min.x, boundBox.max.y, boundBox.min.z),
Vec3(boundBox.max.x, boundBox.max.y, boundBox.min.z),
Vec3(boundBox.max.x, boundBox.min.y, boundBox.min.z),
Vec3(boundBox.min.x, boundBox.min.y, boundBox.max.z),
Vec3(boundBox.min.x, boundBox.max.y, boundBox.max.z),
Vec3(boundBox.max.x, boundBox.max.y, boundBox.max.z),
Vec3(boundBox.max.x, boundBox.min.y, boundBox.max.z)
};
const int kElementSize(sizeof(basePoints) / sizeof(*basePoints));
Vec3 axisDirections[kElementSize] = { Vec3(1, 1, 1), Vec3(1, -1, 1), Vec3(-1, -1, 1), Vec3(-1, 1, 1), Vec3(1, 1, -1), Vec3(1, -1, -1), Vec3(-1, -1, -1), Vec3(-1, 1, -1) };
int nLoopCount = bHave2Axis ? (kElementSize / 2) : kElementSize;
if (bHave2Axis)
{
for (int i = 0; i < nLoopCount; ++i)
{
basePoints[i].z = 0.5f * (boundBox.min.z + boundBox.max.z);
}
}
// Find out the nearest base point of a bounding box from a camera position and use it as a pivot.
const CCamera& camera = gEnv->pRenderer->GetCamera();
Vec3 cameraPos(camera.GetPosition());
Vec3 pivot(rotatedTM.TransformVector(basePoints[0] - GetWorldPos()) + GetWorldPos());
float fNearestDist = (cameraPos - pivot).GetLength();
int nNearestAxisIndex(0);
bool bPrevVisible(camera.IsPointVisible(pivot));
for (int i = 1; i < nLoopCount; ++i)
{
Vec3 candidatePivot(rotatedTM.TransformVector(basePoints[i] - GetWorldPos()) + GetWorldPos());
float candidateLength = (candidatePivot - cameraPos).GetLength();
bool bVisible = camera.IsPointVisible(candidatePivot);
if (bVisible)
{
if (!bPrevVisible || candidateLength < fNearestDist)
{
fNearestDist = candidateLength;
pivot = candidatePivot;
nNearestAxisIndex = i;
}
bPrevVisible = bVisible;
}
}
float fScale = dc.view->GetScreenScaleFactor(pivot);
float fArrowScale = fScale * 0.04f;
Vec3 vX(xLength, 0, 0);
Vec3 vY(0, yLength, 0);
Vec3 vZ(0, 0, zLength);
vX = vX * axisDirections[nNearestAxisIndex].x;
vY = vY * axisDirections[nNearestAxisIndex].y;
vZ = vZ * axisDirections[nNearestAxisIndex].z;
vX = rotatedTM.TransformVector(vX);
vY = rotatedTM.TransformVector(vY);
vZ = rotatedTM.TransformVector(vZ);
const float kArrowPivotOffset = 0.1f;
pivot = pivot + (-(vX + vY + vZ)).GetNormalized() * kArrowPivotOffset;
Vec3 centerPt(boundBox.GetCenter());
// Display texts of width, height and depth
float fTextScale(1.3f);
dc.SetColor(QColor(200, 200, 200));
QString str;
const float kBrightness(0.35f);
const ColorF kXColor(1.0f, kBrightness, kBrightness, 0.9f);
const ColorF kYColor(kBrightness, 1.0f, kBrightness, 0.9f);
const ColorF kZColor(kBrightness, kBrightness, 1.0f, 0.9f);
const ColorF TextBoxColor(0, 0, 0, 0.75f);
ColorB backupcolor = dc.GetColor();
uint32 backupstate = dc.GetState();
int backupThickness = dc.GetLineWidth();
dc.SetState(backupstate | e_DepthTestOff);
Vec3 vNX = vX.GetNormalized();
Vec3 vNY = vY.GetNormalized();
Vec3 vNZ = vZ.GetNormalized();
const float kMinimumOffset(0.20f);
const float kMaximumOffset(30.0f);
float fMaximumOffset[3] = { kMaximumOffset, kMaximumOffset, kMaximumOffset };
if (xLength > kMaximumOffset * 0.5f)
{
fMaximumOffset[0] = xLength * 3.0f;
}
if (yLength > kMaximumOffset * 0.5f)
{
fMaximumOffset[1] = yLength * 3.0f;
}
if (zLength > kMaximumOffset * 0.5f)
{
fMaximumOffset[2] = zLength * 3.0f;
}
Vec3 textPos[3] = {pivot, pivot, pivot};
Vec3 textMinPos[3] = { pivot + vNX * kMinimumOffset, pivot + vNY * kMinimumOffset, pivot + vNZ * kMinimumOffset };
Vec3 textCenterPos[3] = { pivot + vX * 0.5f, pivot + vY * 0.5f, pivot + vZ * 0.5f };
Vec3 textMaxPos[3] = { pivot + vNX * fMaximumOffset[0], pivot + vNY * fMaximumOffset[1], pivot + vNZ * fMaximumOffset[2] };
const Vec3& cameraDir(camera.GetViewdir());
for (int i = 0; i < 3; ++i)
{
Vec3 d = (textMaxPos[i] - cameraPos).GetNormalized();
float fCameraDir = d.Dot(cameraDir);
if (fCameraDir < 0)
{
fCameraDir = 0;
}
textPos[i] = textMinPos[i] + (textCenterPos[i] - textPos[i]) * fCameraDir;
}
str = QString::number(xLength, 'f', 3);
DrawTextOn2DBox(dc, textPos[0], str.toUtf8().data(), fTextScale, kXColor, TextBoxColor);
if (!bHave2Axis)
{
str = QString::number(zLength, 'f', 3);
DrawTextOn2DBox(dc, textPos[2], str.toUtf8().data(), fTextScale, kZColor, TextBoxColor);
}
str = QString::number(yLength, 'f', 3);
DrawTextOn2DBox(dc, textPos[1], str.toUtf8().data(), fTextScale, kYColor, TextBoxColor);
dc.SetState(backupstate | e_DepthTestOn);
dc.SetLineWidth(4);
// Draw arrows of each axis.
dc.SetColor(kXColor);
dc.DrawArrow(pivot, pivot + vX, fArrowScale, true);
if (!bHave2Axis)
{
dc.SetColor(kZColor);
dc.DrawArrow(pivot, pivot + vZ, fArrowScale, true);
}
dc.SetColor(kYColor);
dc.DrawArrow(pivot, pivot + vY, fArrowScale, true);
dc.SetState(backupstate);
dc.SetColor(backupcolor);
dc.SetLineWidth(backupThickness);
}
//////////////////////////////////////////////////////////////////////////
void CBaseObject::DrawTextOn2DBox(DisplayContext& dc, const Vec3& pos, const char* text, float textScale, const ColorF& TextColor, const ColorF& TextBackColor)
{
Vec3 worldPos = dc.ToWorldSpacePosition(pos);
int vx, vy, vw, vh;
gEnv->pRenderer->GetViewport(&vx, &vy, &vw, &vh);
const CCamera& camera = gEnv->pRenderer->GetCamera();
Vec3 screenPos;
camera.Project(worldPos, screenPos, Vec2i(0, 0), Vec2i(0, 0));
//! Font size information doesn't seem to exist so the proper size is used
int textlen = strlen(text);
float fontsize = 7.5f;
float textwidth = fontsize * textlen;
float textheight = 16.0f;
screenPos.x = screenPos.x - textwidth * 0.5f;
Vec3 textregion[4] = {
Vec3(screenPos.x, screenPos.y, screenPos.z),
Vec3(screenPos.x + textwidth, screenPos.y, screenPos.z),
Vec3(screenPos.x + textwidth, screenPos.y + textheight, screenPos.z),
Vec3(screenPos.x, screenPos.y + textheight, screenPos.z)
};
Vec3 textworldreign[4];
Matrix34 dcInvTm = dc.GetMatrix().GetInverted();
Matrix44A mProj, mView;
mathMatrixPerspectiveFov(&mProj, camera.GetFov(), camera.GetProjRatio(), camera.GetNearPlane(), camera.GetFarPlane());
mathMatrixLookAt(&mView, camera.GetPosition(), camera.GetPosition() + camera.GetViewdir(), Vec3(0, 0, 1));
Matrix44A mInvViewProj = (mView * mProj).GetInverted();
for (int i = 0; i < 4; ++i)
{
Vec4 projectedpos = Vec4((textregion[i].x - vx) / vw * 2.0f - 1.0f,
-((textregion[i].y - vy) / vh) * 2.0f + 1.0f,
textregion[i].z,
1.0f);
Vec4 wp = projectedpos * mInvViewProj;
wp.x /= wp.w;
wp.y /= wp.w;
wp.z /= wp.w;
textworldreign[i] = dcInvTm.TransformPoint(Vec3(wp.x, wp.y, wp.z));
}
ColorB backupcolor = dc.GetColor();
uint32 backupstate = dc.GetState();
dc.SetColor(TextBackColor);
dc.SetDrawInFrontMode(true);
dc.DrawQuad(textworldreign[3], textworldreign[2], textworldreign[1], textworldreign[0]);
dc.SetColor(TextColor);
dc.DrawTextLabel(pos, textScale, text);
dc.SetDrawInFrontMode(false);
dc.SetColor(backupcolor);
dc.SetState(backupstate);
}
//////////////////////////////////////////////////////////////////////////
void CBaseObject::DrawSelectionHelper(DisplayContext& dc, const Vec3& pos, const QColor& labelColor, [[maybe_unused]] float alpha)
{
-5
View File
@@ -604,9 +604,6 @@ public:
virtual IStatObj* GetIStatObj() { return NULL; }
//! Display length of each axis.
void DrawDimensionsImpl(DisplayContext& dc, const AABB& localBoundBox, AABB* pMergedBoundBox = NULL);
// Invalidates cached transformation matrix.
// nWhyFlags - Flags that indicate the reason for matrix invalidation.
virtual void InvalidateTM(int nWhyFlags);
@@ -678,8 +675,6 @@ protected:
virtual void DrawTextureIcon(DisplayContext& dc, const Vec3& pos, float alpha = 1.0f);
//! Draw warning icons
virtual void DrawWarningIcons(DisplayContext& dc, const Vec3& pos);
//! Display text with a 3d world coordinate.
void DrawTextOn2DBox(DisplayContext& dc, const Vec3& pos, const char* text, float textScale, const ColorF& TextColor, const ColorF& TextBackColor);
//! Check if dimension's figures can be displayed before draw them.
virtual void DrawDimensions(DisplayContext& dc, AABB* pMergedBoundBox = NULL);
@@ -227,7 +227,6 @@ struct SANDBOX_API DisplayContext
void DrawTextLabel(const Vec3& pos, float size, const char* text, const bool bCenter = false, int srcOffsetX = 0, int scrOffsetY = 0);
void Draw2dTextLabel(float x, float y, float size, const char* text, bool bCenter = false);
void DrawTextOn2DBox(const Vec3& pos, const char* text, float textScale, const ColorF& TextColor, const ColorF& TextBackColor);
void SetLineWidth(float width);
//! Is given bbox visible in this display context.
@@ -37,7 +37,7 @@ DisplayContext::DisplayContext()
m_currentMatrix = 0;
m_matrixStack[m_currentMatrix].SetIdentity();
pRenderAuxGeom = gEnv->pRenderer ? gEnv->pRenderer->GetIRenderAuxGeom() : nullptr;
pRenderAuxGeom = nullptr; // ToDo: Remove DisplayContext or update to work with Atom: LYN-3670
m_thickness = 0;
m_width = 0;
@@ -1105,85 +1105,6 @@ void DisplayContext::Draw2dTextLabel(float x, float y, float size, const char* t
renderer->Draw2dLabel(x, y, size, col, bCenter, "%s", text);
}
void DisplayContext::DrawTextOn2DBox(const Vec3& pos, const char* text, float textScale, const ColorF& TextColor, const ColorF& TextBackColor)
{
Vec3 worldPos = ToWorldSpacePosition(pos);
int vx, vy, vw, vh;
gEnv->pRenderer->GetViewport(&vx, &vy, &vw, &vh);
uint32 backupstate = GetState();
SetState(backupstate | e_DepthTestOff);
const CCamera& renderCamera = gEnv->pRenderer->GetCamera();
Vec3 screenPos;
renderCamera.Project(worldPos, screenPos, Vec2i(0, 0), Vec2i(0, 0));
//! Font size information doesn't seem to exist so the proper size is used
int textlen = strlen(text);
float fontsize = 7.5f * textScale;
float textwidth = fontsize * textlen;
float textheight = 16.0f * textScale;
screenPos.x = screenPos.x - (textwidth * 0.5f);
Vec3 textregion[4] = {
Vec3(screenPos.x, screenPos.y, screenPos.z),
Vec3(screenPos.x + textwidth, screenPos.y, screenPos.z),
Vec3(screenPos.x + textwidth, screenPos.y + textheight, screenPos.z),
Vec3(screenPos.x, screenPos.y + textheight, screenPos.z)
};
Vec3 textworldreign[4];
Matrix34 dcInvTm = GetMatrix().GetInverted();
Matrix44A mProj, mView;
mathMatrixPerspectiveFov(&mProj, renderCamera.GetFov(), renderCamera.GetProjRatio(), renderCamera.GetNearPlane(), renderCamera.GetFarPlane());
mathMatrixLookAt(&mView, renderCamera.GetPosition(), renderCamera.GetPosition() + renderCamera.GetViewdir(), Vec3(0, 0, 1));
Matrix44A mInvViewProj = (mView * mProj).GetInverted();
if (vw == 0)
{
vw = 1;
}
if (vh == 0)
{
vh = 1;
}
for (int i = 0; i < 4; ++i)
{
Vec4 projectedpos = Vec4((textregion[i].x - vx) / vw * 2.0f - 1.0f,
-((textregion[i].y - vy) / vh) * 2.0f + 1.0f,
textregion[i].z,
1.0f);
Vec4 wp = projectedpos * mInvViewProj;
if (wp.w == 0.0f)
{
wp.w = 0.0001f;
}
wp.x /= wp.w;
wp.y /= wp.w;
wp.z /= wp.w;
textworldreign[i] = dcInvTm.TransformPoint(Vec3(wp.x, wp.y, wp.z));
}
ColorB backupcolor = GetColor();
SetColor(TextBackColor);
SetDrawInFrontMode(true);
DrawQuad(textworldreign[3], textworldreign[2], textworldreign[1], textworldreign[0]);
SetColor(TextColor);
DrawTextLabel(pos, textScale, text);
SetDrawInFrontMode(false);
SetColor(backupcolor);
SetState(backupstate);
}
//////////////////////////////////////////////////////////////////////////
void DisplayContext::SetLineWidth(float width)
{
+3 -3
View File
@@ -31,7 +31,6 @@
#include "ViewManager.h"
#include "StringDlg.h"
#include "GenericSelectItemDialog.h"
#include "Util/Ruler.h"
#include "Objects/BaseObject.h"
#include "Commands/CommandManager.h"
@@ -608,8 +607,9 @@ namespace
}
else
{
float color[] = {r, g, b, a};
gEnv->pRenderer->Draw2dLabel(x, y, size, color, false, pLabel);
// ToDo: Remove function or update to work with Atom? LYN-3672
// float color[] = {r, g, b, a};
// ???->Draw2dLabel(x, y, size, color, false, pLabel);
}
}
-1
View File
@@ -99,7 +99,6 @@
#define ID_FILE_SAVELEVELRESOURCES 32942
#define ID_VALIDATELEVEL 32943
#define ID_TERRAIN_RESIZE 32944
#define ID_RELOAD_TEXTURES 32952
#define ID_TERRAIN_COLLISION 32960
#define ID_TOOL_FIRST 32972
#define ID_EDIT_UNFREEZE 32973
-183
View File
@@ -1,183 +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 "ShaderCache.h"
// Editor
#include "GameEngine.h"
//////////////////////////////////////////////////////////////////////////
bool CLevelShaderCache::Reload()
{
return Load(m_filename.toUtf8().data());
}
//////////////////////////////////////////////////////////////////////////
bool CLevelShaderCache::Load(const char* filename)
{
FILE* f = nullptr;
azfopen(&f, filename, "rt");
if (!f)
{
return false;
}
int nNumLines = 0;
m_entries.clear();
m_filename = filename;
char str[65535];
while (fgets(str, sizeof(str), f) != NULL)
{
if (str[0] == '<')
{
m_entries.insert(str);
nNumLines++;
}
}
fclose(f);
if (nNumLines == m_entries.size())
{
m_bModified = false;
}
else
{
m_bModified = true;
}
return true;
}
//////////////////////////////////////////////////////////////////////////
bool CLevelShaderCache::LoadBuffer(const QString& textBuffer, bool bClearOld)
{
const char* separators = "\r\n,";
int nNumLines = 0;
if (bClearOld)
{
m_entries.clear();
}
m_filename = "";
for (auto resToken : textBuffer.split(QRegularExpression(QStringLiteral("[%1]").arg(separators)), Qt::SkipEmptyParts))
{
if (!resToken.isEmpty() && resToken[0] == '<')
{
m_entries.insert(resToken);
nNumLines++;
}
}
if (nNumLines == m_entries.size() && !bClearOld)
{
m_bModified = false;
}
else
{
m_bModified = true;
}
int numShaders = m_entries.size();
CLogFile::FormatLine("%d shader combination loaded for level %s", numShaders, GetIEditor()->GetGameEngine()->GetLevelPath().toUtf8().data());
return true;
}
//////////////////////////////////////////////////////////////////////////
bool CLevelShaderCache::Save()
{
if (m_filename.isEmpty())
{
return false;
}
Update();
FILE* f = nullptr;
azfopen(&f, m_filename.toUtf8().data(), "wt");
if (f)
{
for (Entries::iterator it = m_entries.begin(); it != m_entries.end(); ++it)
{
fputs(it->toLatin1().data(), f);
}
fclose(f);
}
m_bModified = false;
return true;
}
//////////////////////////////////////////////////////////////////////////
bool CLevelShaderCache::SaveBuffer(QString& textBuffer)
{
Update();
textBuffer.reserve(m_entries.size() * 1024);
for (Entries::iterator it = m_entries.begin(); it != m_entries.end(); ++it)
{
textBuffer += (*it);
textBuffer += "\n";
}
m_bModified = false;
return true;
}
//////////////////////////////////////////////////////////////////////////
void CLevelShaderCache::Update()
{
IRenderer* pRenderer = gEnv->pRenderer;
if (pRenderer)
{
QString buf;
char* str = NULL;
pRenderer->EF_Query(EFQ_GetShaderCombinations, str);
if (str)
{
buf = str;
pRenderer->EF_Query(EFQ_DeleteMemoryArrayPtr, str);
}
LoadBuffer(buf, true);
}
}
//////////////////////////////////////////////////////////////////////////
void CLevelShaderCache::Clear()
{
m_entries.clear();
m_bModified = true;
}
//////////////////////////////////////////////////////////////////////////
void CLevelShaderCache::ActivateShaders()
{
bool bPreload = false;
ICVar* pSysPreload = gEnv->pConsole->GetCVar("sys_preload");
if (pSysPreload && pSysPreload->GetIVal() != 0)
{
bPreload = true;
}
if (bPreload)
{
QString textBuffer;
textBuffer.reserve(m_entries.size() * 1024);
for (Entries::iterator it = m_entries.begin(); it != m_entries.end(); ++it)
{
textBuffer += (*it);
textBuffer += "\n";
}
gEnv->pRenderer->EF_Query(EFQ_SetShaderCombinations, textBuffer);
}
}
-45
View File
@@ -1,45 +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_SHADERCACHE_H
#define CRYINCLUDE_EDITOR_SHADERCACHE_H
#pragma once
//////////////////////////////////////////////////////////////////////////
class CLevelShaderCache
{
public:
CLevelShaderCache()
{
m_bModified = false;
}
bool Load(const char* filename);
bool LoadBuffer(const QString& textBuffer, bool bClearOld = true);
bool SaveBuffer(QString& textBuffer);
bool Save();
bool Reload();
void Clear();
void Update();
void ActivateShaders();
private:
//////////////////////////////////////////////////////////////////////////
bool m_bModified;
QString m_filename;
typedef std::set<QString> Entries;
Entries m_entries;
};
#endif // CRYINCLUDE_EDITOR_SHADERCACHE_H
-125
View File
@@ -1,125 +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 : Enumerate Installed Shaders.
#include "EditorDefs.h"
#include "ShaderEnum.h"
//////////////////////////////////////////////////////////////////////////
CShaderEnum::CShaderEnum()
{
m_bEnumerated = false;
}
CShaderEnum::~CShaderEnum()
{
}
inline bool ShaderLess(const CShaderEnum::ShaderDesc& s1, const CShaderEnum::ShaderDesc& s2)
{
return QString::compare(s1.name, s2.name, Qt::CaseInsensitive) < 0;
}
/*
struct StringLess {
bool operator()( const CString &s1,const CString &s2 )
{
return _stricmp( s1,s2 ) < 0;
}
};
*/
//! Enum shaders.
int CShaderEnum::EnumShaders()
{
IRenderer* renderer = GetIEditor()->GetSystem()->GetIRenderer();
if (!renderer)
{
return 0;
}
m_bEnumerated = true;
m_shaders.clear();
m_shaders.reserve(100);
//! Enumerate Shaders.
int nNumShaders = 0;
string* files = renderer->EF_GetShaderNames(nNumShaders);
for (int i = 0; i < nNumShaders; i++)
{
ShaderDesc sd;
sd.name = files[i].c_str();
sd.file = files[i].c_str();
if (!sd.name.isEmpty())
{
// Capitalize first character of the string.
sd.name[0] = sd.name[0].toUpper();
}
m_shaders.push_back(sd);
}
XmlNodeRef root = GetISystem()->GetXmlUtils()->LoadXmlFromFile("Materials/ShaderList.xml");
if (root)
{
for (int i = 0; i < root->getChildCount(); ++i)
{
XmlNodeRef ChildNode = root->getChild(i);
const char* pTagName = ChildNode->getTag();
if (!_stricmp(pTagName, "Shader"))
{
QString name;
if (ChildNode->getAttr("name", name) && !name.isEmpty())
{
// make sure there is no duplication
bool isUnique = true;
for (std::vector<ShaderDesc>::iterator pSD = m_shaders.begin(); pSD != m_shaders.end(); ++pSD)
{
if (!QString::compare((*pSD).file, name, Qt::CaseInsensitive))
{
isUnique = false;
break;
}
}
if (isUnique)
{
ShaderDesc sd;
sd.name = name;
sd.file = name.toLower();
m_shaders.push_back(sd);
}
}
}
}
}
std::sort(m_shaders.begin(), m_shaders.end(), ShaderLess);
return m_shaders.size();
}
int CShaderEnum::GetShaderCount() const
{
return m_shaders.size();
}
QString CShaderEnum::GetShader(int i) const
{
return m_shaders[i].name;
}
QString CShaderEnum::GetShaderFile(int i) const
{
return m_shaders[i].file;
}
-60
View File
@@ -1,60 +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 : Enumerate Installed Shaders.
#ifndef CRYINCLUDE_EDITOR_SHADERENUM_H
#define CRYINCLUDE_EDITOR_SHADERENUM_H
#pragma once
/*!
* CShaderEnum class enumerates shaders installed on system.
* It scans all effector files, and gather from them all defined effectors.
*/
class CShaderEnum
{
public:
struct ShaderDesc
{
QString name;
QString file;
};
CShaderEnum();
virtual ~CShaderEnum();
//! Enumerate shaders installed on system.
//! @return Number of enumerated shaders.
virtual int EnumShaders();
//! Get number of shaders in system.
//! @return Number of installed shaders.
virtual int GetShaderCount() const;
//! Get name of shader by index.
//! index must be between 0 and number returned by EnumShaders.
//! @return Name of shader.
virtual QString GetShader(int i) const;
virtual QString GetShaderFile(int i) const;
private:
bool m_bEnumerated;
//! Array of shader names.
std::vector<ShaderDesc> m_shaders;
};
#endif // CRYINCLUDE_EDITOR_SHADERENUM_H
-150
View File
@@ -1,150 +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 "ShadersDialog.h"
// Qt
#include <QStringListModel>
// Editor
#include "ShaderEnum.h"
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
#include <ui_ShadersDialog.h>
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
/////////////////////////////////////////////////////////////////////////////
// CShadersDialog dialog
CShadersDialog::CShadersDialog(const QString& selection, QWidget* pParent /*=NULL*/)
: QDialog(pParent)
, m_shadersModel(new QStringListModel(this))
, ui(new Ui::CShadersDialog)
, m_selection(selection)
{
ui->setupUi(this);
ui->m_shaders->setModel(m_shadersModel);
OnInitDialog();
connect(ui->m_shaders->selectionModel(), &QItemSelectionModel::selectionChanged, this, &CShadersDialog::OnSelchangeShaders);
connect(ui->m_shaders, &QListView::doubleClicked, this, &CShadersDialog::OnDblclkShaders);
connect(ui->m_shaderText, &QTextEdit::textChanged, this, &CShadersDialog::OnEnChangeText);
connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
connect(ui->m_saveButton, &QPushButton::clicked, this, &CShadersDialog::OnBnClickedSave);
connect(ui->m_editButton, &QPushButton::clicked, this, &CShadersDialog::OnBnClickedEdit);
}
CShadersDialog::~CShadersDialog()
{
}
void CShadersDialog::OnSelchangeShaders()
{
// When shader changes.
// Edit shader file.
auto index = ui->m_shaders->currentIndex();
if (index.isValid())
{
QString file = GetIEditor()->GetShaderEnum()->GetShaderFile(index.row());
file.replace('/', '\\');
ui->m_shaderText->LoadFile(file);
// Just loaded file.. Not savable.
ui->m_saveButton->setEnabled(false);
QString shaderName = QStringLiteral("'%1'").arg(index.data().toString());
if (ui->m_shaderText->find(shaderName))
{
auto cursor = ui->m_shaderText->textCursor();
cursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor, shaderName.size());
}
m_selection = index.data().toString();
}
}
void CShadersDialog::OnInitDialog()
{
QWaitCursor wait;
// Fill with shaders.
CShaderEnum* shaderEnum = GetIEditor()->GetShaderEnum();
int numShaders = shaderEnum->EnumShaders();
QStringList shaders;
for (int i = 0; i < numShaders; i++)
{
shaders.append(shaderEnum->GetShader(i));
}
m_shadersModel->setStringList(shaders);
/*
if (numShaders > 0)
{
int i = m_shaders.FindString(m_sel);
if (i != LB_ERR)
m_shaders.SetCurSel( i );
}
*/
}
void CShadersDialog::OnDblclkShaders()
{
// Same as IDOK.
accept();
}
void CShadersDialog::OnBnClickedEdit()
{
// Edit shader file.
auto index = ui->m_shaders->currentIndex();
if (index.isValid())
{
CShaderEnum* shaderEnum = GetIEditor()->GetShaderEnum();
QString file = shaderEnum->GetShaderFile(index.row());
CFileUtil::EditTextFile(file.toUtf8().data(), IFileUtil::FILE_TYPE_SHADER);
}
}
//////////////////////////////////////////////////////////////////////////
void CShadersDialog::OnBnClickedSave()
{
if (ui->m_shaderText->IsModified())
{
ui->m_shaderText->SaveFile(ui->m_shaderText->GetFilename());
if (ui->m_shaderText->IsModified())
{
ui->m_saveButton->setEnabled(true);
}
else
{
ui->m_saveButton->setEnabled(false);
}
}
}
//////////////////////////////////////////////////////////////////////////
void CShadersDialog::OnEnChangeText()
{
// File can be saved.
ui->m_saveButton->setEnabled(true);
}
#include <moc_ShadersDialog.cpp>
-62
View File
@@ -1,62 +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_SHADERSDIALOG_H
#define CRYINCLUDE_EDITOR_SHADERSDIALOG_H
#pragma once
// ShadersDialog.h : header file
//
#if !defined(Q_MOC_RUN)
#include <QDialog>
#endif
class QStringListModel;
namespace Ui {
class CShadersDialog;
}
/////////////////////////////////////////////////////////////////////////////
// CShadersDialog dialog
class CShadersDialog
: public QDialog
{
Q_OBJECT
// Construction
public:
CShadersDialog(const QString& selection, QWidget* pParent = nullptr); // standard constructor
~CShadersDialog();
QString m_selection;
QString GetSelection() { return m_selection; };
protected:
void OnSelchangeShaders();
virtual void OnInitDialog();
void OnDblclkShaders();
public:
void OnBnClickedEdit();
void OnBnClickedSave();
void OnEnChangeText();
QStringListModel* m_shadersModel;
QScopedPointer<Ui::CShadersDialog> ui;
};
#endif // CRYINCLUDE_EDITOR_SHADERSDIALOG_H
-118
View File
@@ -1,118 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CShadersDialog</class>
<widget class="QDialog" name="CShadersDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>615</width>
<height>458</height>
</rect>
</property>
<property name="windowTitle">
<string>Select Shader</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Select Shader</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
<item>
<widget class="QListView" name="m_shaders"/>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Shader Script</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
<item>
<widget class="CTextEditorCtrl" name="m_shaderText">
<property name="text" stdset="0">
<string/>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="m_line">
<property name="frameShape">
<enum>QFrame::HLine</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,1,0,0">
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<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="m_saveButton">
<property name="text">
<string>Save</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="m_editButton">
<property name="text">
<string>External Edit</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>CTextEditorCtrl</class>
<extends>QTextEdit</extends>
<header>Controls/TextEditorCtrl.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
+4 -3
View File
@@ -150,7 +150,7 @@ void QTopRendererWnd::UpdateContent(int flags)
}
//////////////////////////////////////////////////////////////////////////
void QTopRendererWnd::Draw(DisplayContext& dc)
void QTopRendererWnd::Draw([[maybe_unused]] DisplayContext& dc)
{
FUNCTION_PROFILER(GetIEditor()->GetSystem(), PROFILE_EDITOR);
@@ -165,7 +165,8 @@ void QTopRendererWnd::Draw(DisplayContext& dc)
////////////////////////////////////////////////////////////////////////
// Render the 2D map
////////////////////////////////////////////////////////////////////////
if (!m_terrainTextureId)
// ToDo: Remove TopRendererWnd or update to work with Atom: LYN-3671
/*if (!m_terrainTextureId)
{
//GL_BGRA_EXT
if (m_terrainTexture.IsValid())
@@ -238,7 +239,7 @@ void QTopRendererWnd::Draw(DisplayContext& dc)
dc.DepthTestOn();
Q2DViewport::Draw(dc);
Q2DViewport::Draw(dc);*/
}
//////////////////////////////////////////////////////////////////////////
@@ -643,7 +643,7 @@ void CSequenceBatchRenderDialog::OnResolutionSelected()
CCustomResolutionDlg resDlg(defaultW, defaultH, this);
if (resDlg.exec() == QDialog::Accepted)
{
const int maxRes = GetIEditor()->GetRenderer()->GetMaxSquareRasterDimension();
const int maxRes = 8192;
m_customResW = min(resDlg.GetWidth(), maxRes);
m_customResH = min(resDlg.GetHeight(), maxRes);
const QString resText = QString(customResFormat).arg(m_customResW).arg(m_customResH);
-769
View File
@@ -1,769 +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 "ArcBall.h"
bool CArcBall3D::ArcControl(const Matrix34& reference, const Ray& ray, uint32 mouseleft)
{
RotControl <<= 1;
if (mouseleft)
{
RotControl |= 1;
}
Quat WObjectRotation = Quat(reference * Matrix34(ObjectRotation));
Matrix34 WMat = reference * Matrix34(Matrix33(DragRotation * ObjectRotation), sphere.center);
Sphere WSphere(WMat.GetTranslation(), sphere.radius);
Mouse_CutFlag = 0;
Vec3 Mouse_CutOn3DSphere(0, 0, 0);
Mouse_CutOnUnitSphere = Vec3(ZERO);
Mouse_CutFlag = Intersect::Ray_SphereFirst(ray, WSphere, Mouse_CutOn3DSphere);
if (Mouse_CutFlag)
{
Mouse_CutOnUnitSphere = WObjectRotation.GetInverted() * (Mouse_CutOn3DSphere - WSphere.center).GetNormalized();
}
if (RotControl & 3)
{
if (Mouse_CutFlag)
{
if ((RotControl & 3) == 0x01)
{
Mouse_CutFlagStart = 1;
LineStart3D = Mouse_CutOnUnitSphere;
AxisSnap = 0;
Matrix33 bym33;
//get the distance to the axis
f32 xdist = fabsf(Mouse_CutOnUnitSphere.x);
f32 ydist = fabsf(Mouse_CutOnUnitSphere.y);
f32 zdist = fabsf(Mouse_CutOnUnitSphere.z);
//if to close to an axis-crossing, disable axis choosing
if ((xdist < CrossDist) && (zdist < CrossDist))
{
xdist = 1.0f;
ydist = 1.0f;
zdist = 1.0f;
}
if ((xdist < CrossDist) && (ydist < CrossDist))
{
xdist = 1.0f;
ydist = 1.0f;
zdist = 1.0f;
}
if ((ydist < CrossDist) && (zdist < CrossDist))
{
xdist = 1.0f;
ydist = 1.0f;
zdist = 1.0f;
}
//check snap with YZ-plane
if (xdist < AxisDist)
{
bym33.SetIdentity();
if ((LineStart3D.x) || (LineStart3D.z))
{
Vec3 n = Vec3(LineStart3D.x, 0, LineStart3D.z).GetNormalized();
bym33.SetRotationY(acos_tpl(fabsf(n.z)));
}
Vec3 SnapLineStart3D = bym33 * Vec3(fabsf(LineStart3D.x), LineStart3D.y, -fabsf(LineStart3D.z));
if (LineStart3D.z > 0.0f)
{
SnapLineStart3D.z = -SnapLineStart3D.z;
}
LineStart3D = SnapLineStart3D;
AxisSnap = 1;
}
//check snap with XZ-plane
if (ydist < AxisDist)
{
bym33.SetIdentity();
if ((LineStart3D.y) || (LineStart3D.z))
{
Vec3 bn_xz = Vec3(0, LineStart3D.y, LineStart3D.z).GetNormalized();
bym33.SetRotationX(-acos_tpl(fabsf(bn_xz.z)));
}
Vec3 SnapLineStart3D = bym33 * Vec3((LineStart3D.x), fabsf(LineStart3D.y), -fabsf(LineStart3D.z));
if (LineStart3D.z > 0.0f)
{
SnapLineStart3D.z = -SnapLineStart3D.z;
}
LineStart3D = SnapLineStart3D;
AxisSnap = 2;
}
//check snap with XY-plane
if (zdist < AxisDist)
{
bym33.SetIdentity();
if ((LineStart3D.x) || (LineStart3D.z))
{
Vec3 bn_xz = Vec3(LineStart3D.x, 0, LineStart3D.z).GetNormalized();
bym33.SetRotationY(-acos_tpl(fabsf(bn_xz.x)));
}
Vec3 SnapLineStart3D = bym33 * Vec3(fabsf(LineStart3D.x), LineStart3D.y, -fabsf(LineStart3D.z));
if (LineStart3D.x < 0.0f)
{
SnapLineStart3D.x = -SnapLineStart3D.x;
}
LineStart3D = SnapLineStart3D;
AxisSnap = 3;
}
}
if ((RotControl & 3) == 0x03)
{
ArcRotation();
}
if ((RotControl & 3) == 0x02)
{
ObjectRotation = (DragRotation * ObjectRotation).GetNormalized();
DragRotation.SetIdentity();
Mouse_CutFlagStart = 0;
LineStart3D = Vec3(0, -1, 0);
AxisSnap = 0;
return true;
}
}
else
{
Vec3 ClostestPointOnLine;
IntersectSphereLineSegment(WSphere, ray.origin, ray.origin + ray.direction * 1000.0f, ClostestPointOnLine);
Mouse_CutOn3DSphere = ((ClostestPointOnLine - WSphere.center).GetNormalized() * WSphere.radius) + WSphere.center;
Mouse_CutOnUnitSphere = WObjectRotation.GetInverted() * (Mouse_CutOn3DSphere - WSphere.center).GetNormalized();
if ((RotControl & 3) == 0x01)
{
LineStart3D = Mouse_CutOnUnitSphere;
Mouse_CutFlagStart = 0;
AxisSnap = 0;
}
if ((RotControl & 3) == 0x03)
{
ArcRotation();
}
if ((RotControl & 3) == 0x02)
{
ObjectRotation = (DragRotation * ObjectRotation).GetNormalized();
DragRotation.SetIdentity();
Mouse_CutFlagStart = 0;
LineStart3D = Vec3(0, -1, 0);
AxisSnap = 0;
return true;
}
}
}
return false;
}
void CArcBall3D::ArcRotation()
{
Vec3 rv;
f32 gradius = 0;
f32 distance_YZ = 0;
f32 bias = 0;
f32 cosine = 0;
Vec3 XYVector;
DragRotation.SetIdentity();
//first we calculate an ordinary drag-quaternion
cosine = (LineStart3D | Mouse_CutOnUnitSphere);
if (fabsf(cosine) < 0.99999f)
{
DragRotation.SetRotationAA(acos_tpl(cosine), (LineStart3D % Mouse_CutOnUnitSphere).GetNormalized());
}
if (AxisSnap == 1)
{
//m_ButtonArcRotate an UpVector with our drag-quaternion
rv = (DragRotation) * Vec3(0, -1, 0);
DragRotation.SetIdentity();
//project rotated UpVector into XY_Plane (this is a simple y_axis rotation)
Matrix33 ym33;
ym33.SetIdentity();
if ((rv.x) || (rv.z))
{
Vec3 n_xz = Vec3(rv.x, 0, rv.z).GetNormalized();
ym33.SetRotationY(-acos_tpl(fabsf(n_xz.z)));
}
XYVector = ym33 * Vec3(-fabsf(rv.x), rv.y, -fabsf(rv.z));
//find the rotation direction around z-axis
if (rv.z > 0)
{
XYVector.z = -XYVector.z;
}
//calculate the xy-constrained quaternion
cosine = (Vec3(0, -1, 0) | XYVector);
if (fabsf(cosine) < 0.99999f)
{
gradius = Vec3(rv.x, 0, rv.z).GetLength();
distance_YZ = fabsf(rv.z);
bias = distance_YZ / gradius;
DragRotation.SetRotationAA(acos_tpl(cosine) * bias, (Vec3(0, -1, 0) % XYVector).GetNormalized());
}
}
if (AxisSnap == 2)
{
//m_ButtonArcRotate an UpVector with our DRAG-QUATERNION
rv = DragRotation * Vec3(-1, 0, 0);
DragRotation.SetIdentity();
//project rotated UpVector into XY_Plane (this is a simple x_axis rotation)
Matrix33 ym33;
ym33.SetIdentity();
if ((rv.y) || (rv.z))
{
Vec3 n_xz = Vec3(0, rv.y, rv.z).GetNormalized();
ym33.SetRotationX(-acos_tpl(fabsf(n_xz.z)));
}
XYVector = ym33 * Vec3((rv.x), fabsf(rv.y), -fabsf(rv.z));
//find the rotation direction around y-axis
if (rv.z > 0)
{
XYVector.z = -XYVector.z;
}
//calculate the xz-constrained quaternion
cosine = (Vec3(-1, 0, 0) | XYVector);
if (fabsf(cosine) < 0.99999f)
{
gradius = Vec3(0, rv.y, rv.z).GetLength();
distance_YZ = fabsf(rv.z);
bias = distance_YZ / gradius;
DragRotation.SetRotationAA(acos_tpl(cosine) * bias, (Vec3(-1, 0, 0) % XYVector).GetNormalized());
}
}
if (AxisSnap == 3)
{
//m_ButtonArcRotate an UpVector with our DRAG-QUATERNION
rv = DragRotation * Vec3(0, -1, 0);
DragRotation.SetIdentity();
//project rotated UpVector into XY_Plane (this is a simple y_axis rotation)
Matrix33 ym33;
ym33.SetIdentity();
if ((rv.x) || (rv.z))
{
Vec3 n_xz = Vec3(rv.x, 0, rv.z).GetNormalized();
ym33.SetRotationY(-acos_tpl(fabsf(n_xz.x)));
}
XYVector = ym33 * Vec3(fabsf(rv.x), rv.y, -fabsf(rv.z));
//find the rotation direction around z-axis
if (rv.x < 0)
{
XYVector.x = -XYVector.x;
}
//calculate the xy-constrained quaternion
cosine = (Vec3(0, -1, 0) | XYVector);
if (fabsf(cosine) < 0.99999f)
{
gradius = Vec3(rv.x, 0, rv.z).GetLength();
distance_YZ = fabsf(rv.x);
bias = distance_YZ / gradius;
DragRotation.SetRotationAA(acos_tpl(cosine) * bias, (Vec3(0, -1, 0) % XYVector).GetNormalized());
}
}
//BINGO!!!! the final drag quaternion
DragRotation = ObjectRotation * DragRotation * ObjectRotation.GetInverted();
}
uint32 CArcBall3D::IntersectSphereLineSegment(const Sphere& sphere, const Vec3& LineStart, const Vec3& LineEnd, Vec3& I)
{
//this is the code to produce a real z-rotation!
Vec3 LineDir = (LineEnd - LineStart).GetNormalized();
Vec3 ShereCenterDir = (sphere.center - LineStart).GetNormalized();
f32 LengthToSphereCenter = (sphere.center - LineStart).GetLength();
f32 cosine = (ShereCenterDir | LineDir);
//this vector is perpendicular to the vector "ShereCenterDir"
Vec3 PerpVector = LengthToSphereCenter / cosine * LineDir + LineStart;
Vec3 PerpVectorOnSphere = ((PerpVector - sphere.center).GetNormalized() * sphere.radius) + sphere.center;
I = PerpVectorOnSphere;
{
//find closest point on Lineseg
Vec3 LineDir2 = (LineEnd - LineStart).GetNormalized();
f32 proj = LineDir2 | (sphere.center - LineStart);
I = LineDir2 * proj + LineStart;
}
return 0;
}
void CArcBall3D::DrawSphere(const Matrix34& reference, const CCamera& cam, IRenderAuxGeom* pRenderer)
{
f32 thicknessX = 1.0f;
f32 thicknessY = 1.0f;
f32 thicknessZ = 1.0f;
uint32 start;
Vec3 Vertices3D[64 * 32];
Vec3 sVertices3D[64 * 32];
Vec3 tVertices3D[64 * 32];
uint32 c;
Matrix34 WMat = reference * Matrix34(Matrix33(DragRotation * ObjectRotation), sphere.center);
Quat WObjectRotation = Quat(reference * Matrix34(ObjectRotation));
Quat WRotation = Quat(reference * Matrix34(DragRotation * ObjectRotation));
Sphere WSphere(WMat.GetTranslation(), sphere.radius);
SAuxGeomRenderFlags renderFlags(e_Def3DPublicRenderflags);
renderFlags.SetDepthWriteFlag(e_DepthWriteOff);
renderFlags.SetFillMode(e_FillModeSolid);
//------------------------------------------------------------------------------------------------------
uint32 s = 0;
uint32 t = 0;
Vec3 CamPos = cam.GetPosition();
renderFlags.SetAlphaBlendMode(e_AlphaAdditive);
pRenderer->SetRenderFlags(renderFlags);
pRenderer->DrawSphere(WSphere.center, WSphere.radius, RGBA8(0x3f, 0x3f, 0x3f, 0x00));
ColorB col;
f32 xdist = fabsf(Mouse_CutOnUnitSphere.x);
f32 ydist = fabsf(Mouse_CutOnUnitSphere.y);
f32 zdist = fabsf(Mouse_CutOnUnitSphere.z);
if ((xdist < CrossDist) && (zdist < CrossDist))
{
xdist = 1.0f;
ydist = 1.0f;
zdist = 1.0f;
}
if ((xdist < CrossDist) && (ydist < CrossDist))
{
xdist = 1.0f;
ydist = 1.0f;
zdist = 1.0f;
}
if ((ydist < CrossDist) && (zdist < CrossDist))
{
xdist = 1.0f;
ydist = 1.0f;
zdist = 1.0f;
}
//----------------------------------------------------------------------------------
// draw circle around X-axis
//----------------------------------------------------------------------------------
thicknessX = 1.0f;
if (AxisSnap == 0)
{
if (Mouse_CutFlag)
{
if (xdist < AxisDist)
{
thicknessX = 5.0f;
}
}
}
else if (AxisSnap == 1)
{
thicknessX = 5.0f;
}
c = 0;
for (f32 cz = 0; cz < (gf_PI * 2); cz = cz + (2 * gf_PI / 256.0f), ++c)
{
Vertices3D[c] = WMat * (Vec3(0, -cosf(cz), sinf(cz)) * WSphere.radius);
}
assert(c == 0x100);
for (start = 0; start < c; ++start)
{
Vec3 p0 = Vertices3D[(start + 0) & 0xff];
f32 dot0 = (p0 - CamPos) | (p0 - WSphere.center);
Vec3 p1 = Vertices3D[(start + 1) & 0xff];
f32 dot1 = (p1 - CamPos) | (p1 - WSphere.center);
if ((dot0 < 0) && !(dot1 < 0))
{
break;
}
}
s = 0;
t = 0;
start = (start + 1) & 0xff;
for (uint32 i = 0; i < c; ++i)
{
Vec3 p = Vertices3D[start];
f32 dot = (p - CamPos) | (p - WSphere.center);
if (dot < 0)
{
sVertices3D[s] = p;
s++;
}
else
{
tVertices3D[t] = p;
t++;
}
start = (start + 1) & 0xff;
}
renderFlags.SetAlphaBlendMode(e_AlphaNone);
pRenderer->SetRenderFlags(renderFlags);
if (s > 2)
{
pRenderer->DrawPolyline(sVertices3D, s, 0, RGBA8(0xff, 0x12, 0x12, 0x00), thicknessX);
}
renderFlags.SetAlphaBlendMode(e_AlphaAdditive);
pRenderer->SetRenderFlags(renderFlags);
if (t > 2)
{
pRenderer->DrawPolyline(tVertices3D, t, 0, RGBA8(0x1f, 0x07, 0x07, 0x00), thicknessX);
}
//----------------------------------------------------------------------------------
// draw circle around Y-axis
//----------------------------------------------------------------------------------
thicknessY = 1.0f;
if (AxisSnap == 0)
{
if (Mouse_CutFlag)
{
if (ydist < AxisDist)
{
thicknessY = 5.0f;
}
}
}
else if (AxisSnap == 2)
{
thicknessY = 5.0f;
}
c = 0;
for (f32 cz = 0; cz < (gf_PI * 2); cz = cz + (2 * gf_PI / 256.0f), ++c)
{
Vertices3D[c] = WMat * (Vec3(-cosf(cz), 0, sinf(cz)) * WSphere.radius);
}
assert(c == 0x100);
for (start = 0; start < c; ++start)
{
Vec3 p0 = Vertices3D[(start + 0) & 0xff];
f32 dot0 = (p0 - CamPos) | (p0 - WSphere.center);
Vec3 p1 = Vertices3D[(start + 1) & 0xff];
f32 dot1 = (p1 - CamPos) | (p1 - WSphere.center);
if ((dot0 < 0) && !(dot1 < 0))
{
break;
}
}
s = 0;
t = 0;
start = (start + 1) & 0xff;
for (uint32 i = 0; i < c; ++i)
{
Vec3 p = Vertices3D[start];
f32 dot = (p - CamPos) | (p - WSphere.center);
if (dot < 0)
{
sVertices3D[s] = p;
s++;
}
else
{
tVertices3D[t] = p;
t++;
}
start = (start + 1) & 0xff;
}
renderFlags.SetAlphaBlendMode(e_AlphaNone);
pRenderer->SetRenderFlags(renderFlags);
if (s > 2)
{
pRenderer->DrawPolyline(sVertices3D, s, 0, RGBA8(0x12, 0xff, 0x12, 0x00), thicknessY);
}
renderFlags.SetAlphaBlendMode(e_AlphaAdditive);
pRenderer->SetRenderFlags(renderFlags);
if (t > 2)
{
pRenderer->DrawPolyline(tVertices3D, t, 0, RGBA8(0x07, 0x1f, 0x07, 0x00), thicknessY);
}
//----------------------------------------------------------------------------------
// draw circle around Z-axis
//----------------------------------------------------------------------------------
thicknessZ = 1.0f;
if (AxisSnap == 0)
{
if (Mouse_CutFlag)
{
if (zdist < AxisDist)
{
thicknessZ = 5.0f;
}
}
}
else if (AxisSnap == 3)
{
thicknessZ = 5.0f;
}
c = 0;
for (f32 cz = 0; cz < (gf_PI * 2); cz = cz + (2 * gf_PI / 256.0f), ++c)
{
Vertices3D[c] = WMat * (Vec3(sinf(cz), -cosf(cz), 0) * WSphere.radius);
}
assert(c == 0x100);
for (start = 0; start < c; ++start)
{
Vec3 p0 = Vertices3D[(start + 0) & 0xff];
f32 dot0 = (p0 - CamPos) | (p0 - WSphere.center);
Vec3 p1 = Vertices3D[(start + 1) & 0xff];
f32 dot1 = (p1 - CamPos) | (p1 - WSphere.center);
if ((dot0 < 0) && !(dot1 < 0))
{
break;
}
}
s = 0;
t = 0;
start = (start + 1) & 0xff;
for (uint32 i = 0; i < c; ++i)
{
Vec3 p = Vertices3D[start];
f32 dot = (p - CamPos) | (p - WSphere.center);
if (dot < 0)
{
sVertices3D[s] = p;
s++;
}
else
{
tVertices3D[t] = p;
t++;
}
start = (start + 1) & 0xff;
}
renderFlags.SetAlphaBlendMode(e_AlphaNone);
pRenderer->SetRenderFlags(renderFlags);
if (s > 2)
{
pRenderer->DrawPolyline(sVertices3D, s, 0, RGBA8(0x12, 0x12, 0xff, 0x00), thicknessZ);
}
renderFlags.SetAlphaBlendMode(e_AlphaAdditive);
pRenderer->SetRenderFlags(renderFlags);
if (t > 2)
{
pRenderer->DrawPolyline(tVertices3D, t, 0, RGBA8(0x07, 0x07, 0x1f, 0x00), thicknessZ);
}
uint32 v;
Vec3 VBuffer[1000];
ColorB CBuffer[1000];
if ((RotControl & 3) == 3)
{
Vec3 Blue = WObjectRotation * LineStart3D;
Vec3 Red = WObjectRotation * Mouse_CutOnUnitSphere;
VBuffer[0] = Vec3(0, 0, 0);
CBuffer[0] = RGBA8(0x00, 0x00, 0x00, 0x00);
VBuffer[1] = Blue;
CBuffer[1] = RGBA8(0x00, 0x00, 0xff, 0x00);
VBuffer[102] = Red;
CBuffer[102] = RGBA8(0xff, 0x00, 0x00, 0x00);
for (v = 0; v < 100; ++v)
{
f32 t0 = (1.0f / 101.0f * v) + 1.0f / 101.0f;
VBuffer[v + 2] = Vec3::CreateSlerp(Blue, Red, t0);
f32 t1 = (1.0f / 101.0f * v);
CBuffer[v + 2].b = uint8((1.0f - t1) * CBuffer[1].b + t1 * CBuffer[102].b);
CBuffer[v + 2].g = uint8((1.0f - t1) * CBuffer[1].g + t1 * CBuffer[102].g);
CBuffer[v + 2].r = uint8((1.0f - t1) * CBuffer[1].r + t1 * CBuffer[102].r);
}
for (v = 0; v < 103; ++v)
{
VBuffer[v] = VBuffer[v] * WSphere.radius + WSphere.center;
}
if (AxisSnap == 0)
{
SAuxGeomRenderFlags renderFlags2(e_Def3DPublicRenderflags);
renderFlags2.SetFillMode(e_FillModeSolid);
renderFlags2.SetAlphaBlendMode(e_AlphaAdditive);
pRenderer->SetRenderFlags(renderFlags2);
for (v = 0; v < 100; ++v)
{
pRenderer->DrawTriangle(VBuffer[0], CBuffer[0], VBuffer[v + 1], CBuffer[v + 1], VBuffer[v + 2], CBuffer[v + 2]);
pRenderer->DrawTriangle(VBuffer[0], CBuffer[0], VBuffer[v + 2], CBuffer[v + 2], VBuffer[v + 1], CBuffer[v + 1]);
}
}
}
if (AxisSnap)
{
//project vector into the xy-plane
VBuffer[0] = Vec3(0, 0, 0);
CBuffer[0] = RGBA8(0x00, 0x00, 0x00, 0x00);
VBuffer[1] = WObjectRotation * LineStart3D;
CBuffer[1] = RGBA8(0x12, 0x1f, 0x12, 0x00);
VBuffer[102] = WRotation * LineStart3D;
CBuffer[102] = RGBA8(0x22, 0x7f, 0x22, 0x00);
ColorB c0 = CBuffer[1];
ColorB c1 = CBuffer[102];
for (v = 0; v < 100; ++v)
{
f32 t0 = (1.0f / 101.0f * v) + 1.0f / 101.0f;
VBuffer[v + 2] = Vec3::CreateSlerp(VBuffer[1], VBuffer[102], t0);
f32 t1 = (1.0f / 101.0f * v);
CBuffer[v + 2].r = uint8((1.0f - t1) * c0.r + t1 * c1.r);
CBuffer[v + 2].g = uint8((1.0f - t1) * c0.g + t1 * c1.g);
CBuffer[v + 2].b = uint8((1.0f - t1) * c0.b + t1 * c1.b);
}
for (v = 0; v < 103; ++v)
{
VBuffer[v] = VBuffer[v] * WSphere.radius + WSphere.center;
}
SAuxGeomRenderFlags renderFlags2(e_Def3DPublicRenderflags);
renderFlags2.SetFillMode(e_FillModeSolid);
renderFlags2.SetAlphaBlendMode(e_AlphaAdditive);
pRenderer->SetRenderFlags(renderFlags2);
for (v = 0; v < 100; ++v)
{
pRenderer->DrawTriangle(VBuffer[0], CBuffer[0], VBuffer[v + 1], CBuffer[v + 1], VBuffer[v + 2], CBuffer[v + 2]);
pRenderer->DrawTriangle(VBuffer[0], CBuffer[0], VBuffer[v + 2], CBuffer[v + 2], VBuffer[v + 1], CBuffer[v + 1]);
}
}
renderFlags = e_Def3DPublicRenderflags;
renderFlags.SetFillMode(e_FillModeSolid);
renderFlags.SetAlphaBlendMode(e_AlphaNone);
pRenderer->SetRenderFlags(renderFlags);
#define CROSS (0.25f)
Vec3 rmin = WMat * Vec3(0, 0.0f, 0.0f);
Vec3 rmax = WMat * Vec3(CROSS, 0.0f, 0.0f);
pRenderer->DrawLine(rmin, RGBA8(0xff, 0x00, 0x00, 0x00), rmax, RGBA8(0xff, 0x7f, 0x7f, 0x00), thicknessX);
Vec3 gmin = WMat * Vec3(0.0f, 0, 0.0f);
Vec3 gmax = WMat * Vec3(0.0f, CROSS, 0.0f);
pRenderer->DrawLine(gmin, RGBA8(0x00, 0xff, 0x00, 0x00), gmax, RGBA8(0x7f, 0xff, 0x7f, 0x00), thicknessY);
Vec3 bmin = WMat * Vec3(0.0f, 0.0f, 0);
Vec3 bmax = WMat * Vec3(0.0f, 0.0f, CROSS);
pRenderer->DrawLine(bmin, RGBA8(0x00, 0x00, 0xff, 0x00), bmax, RGBA8(0x7f, 0x7f, 0xff, 0x00), thicknessZ);
renderFlags.SetDepthWriteFlag(e_DepthWriteOn);
pRenderer->SetRenderFlags(renderFlags);
}
-64
View File
@@ -1,64 +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_UTIL_ARCBALL_H
#define CRYINCLUDE_EDITOR_UTIL_ARCBALL_H
#pragma once
#include <Cry_Math.h>
#include <Cry_Color.h>
#define CrossDist (0.05f)
#define AxisDist (0.05f)
class SANDBOX_API CArcBall3D
{
public:
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
uint32 RotControl;
Sphere sphere;
uint32 Mouse_CutFlag;
uint32 Mouse_CutFlagStart;
uint32 AxisSnap;
Vec3 LineStart3D;
Vec3 Mouse_CutOnUnitSphere;
Quat DragRotation;
Quat ObjectRotation;
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
CArcBall3D()
{
InitArcBall();
};
void InitArcBall()
{
RotControl = 0;
sphere(Vec3(ZERO), 0.25f);
Mouse_CutFlag = 0;
Mouse_CutOnUnitSphere(0, 0, 0);
LineStart3D(0, -1, 0);
AxisSnap = 0;
DragRotation.SetIdentity();
ObjectRotation.SetIdentity();
}
//---------------------------------------------------------------
// ArcControl
// Returns true if the rotation has changed
//---------------------------------------------------------------
bool ArcControl(const Matrix34& reference, const Ray& ray, uint32 mouseleft);
void ArcRotation();
void DrawSphere(const Matrix34& reference, const CCamera& cam, struct IRenderAuxGeom* pRenderer);
static uint32 IntersectSphereLineSegment(const Sphere& s, const Vec3& LineStart, const Vec3& LineEnd, Vec3& I);
};
#endif // CRYINCLUDE_EDITOR_UTIL_ARCBALL_H
-251
View File
@@ -1,251 +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 "CubemapUtils.h"
// Qt
#include <QAbstractListModel>
#include <QComboBox>
#include <QDialog>
#include <QLabel>
#include <QDialogButtonBox>
#include <QVBoxLayout>
// AzToolsFramework
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
// Editor
#include "Util/ImageTIF.h"
#include "Objects/BaseObject.h"
#include <IEntityRenderState.h>
class CubemapSizeModel
: public QAbstractListModel
{
public:
CubemapSizeModel(QObject* parent = nullptr)
: QAbstractListModel(parent)
{ }
int rowCount(const QModelIndex& parent = {}) const override
{
return parent.isValid() ? 0 : kNumResolutions;
}
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override
{
if (!index.isValid() || index.row() >= kNumResolutions)
{
return {};
}
switch (role)
{
case Qt::DisplayRole:
case Qt::UserRole:
return 32 << index.row();
}
return {};
}
private:
static const int kNumResolutions = 6;
};
class CubemapSizeDialog
: public QDialog
{
public:
CubemapSizeDialog(QWidget* parent = nullptr)
: QDialog(parent)
, m_model(new CubemapSizeModel(this))
{
setWindowTitle(tr("Enter Cubemap Resolution"));
m_comboBox = new QComboBox;
m_comboBox->setModel(m_model);
m_comboBox->setCurrentIndex(3);
auto horLine = new QLabel;
horLine->setFrameShape(QFrame::HLine);
horLine->setFrameShadow(QFrame::Sunken);
auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
auto layout = new QVBoxLayout;
layout->addWidget(m_comboBox);
layout->addWidget(horLine);
layout->addWidget(buttonBox);
setLayout(layout);
}
int GetValue() const
{
return m_comboBox->currentData().toInt();
}
private:
CubemapSizeModel* m_model;
QComboBox* m_comboBox;
};
///////////////////////////////////////////////////////////////////////////////////
bool CubemapUtils::GenCubemapWithObjectPathAndSize(QString& filename, CBaseObject* pObject, const int size, const bool hideObject)
{
if (!pObject)
{
Warning("Select One Entity to Generate Cubemap");
return false;
}
if (pObject->GetType() != OBJTYPE_AZENTITY)
{
Warning("Only Entities are allowed as a selected object. Please Select Entity objects");
return false;
}
int res = 1;
// Make size power of 2.
for (int i = 0; i < 16; i++)
{
if (res * 2 > size)
{
break;
}
res *= 2;
}
if (res > 4096)
{
Warning("Bad texture resolution.\nMust be power of 2 and less or equal to 4096");
return false;
}
IRenderNode* pRenderNode = pObject->GetEngineNode();
// Hide the object before Cubemap generation (maybe). This is useful for when generating a cubemap at an entity's position, like the player,
// and you don't want their model showing up in the cubemap. But you want to leave the entity alone if it's a light or something that
// has a desired contribution to the cubemap.
bool bIsHidden = false;
if (pRenderNode)
{
bIsHidden = (pRenderNode->GetRndFlags() & ERF_HIDDEN) != 0;
if (hideObject)
{
pRenderNode->SetRndFlags(ERF_HIDDEN, true);
}
}
QString texname = Path::GetFileName(filename);
QString path = Path::GetPath(filename);
// Add _CM suffix if missing
int32 nCMSufixCheck = texname.indexOf("_cm");
texname = Path::Make(path, texname + ((nCMSufixCheck == -1) ? "_cm.tif" : ".tif"));
// Assign this texname to current material.
texname = Path::ToUnixPath(texname);
// Temporary solution to save both dds and tiff hdr cubemap
AABB pObjAABB;
pObject->GetBoundBox(pObjAABB);
Vec3 pObjCenter = pObjAABB.GetCenter();
bool success = GenHDRCubemapTiff(texname, res, pObjCenter);
// restore object's visibility
if (pRenderNode)
{
pRenderNode->SetRndFlags(ERF_HIDDEN, bIsHidden);
}
filename = Path::ToUnixPath(texname);
return success;
}
//////////////////////////////////////////////////////////////////////////
bool CubemapUtils::GenHDRCubemapTiff(const QString& fileName, int nDstSize, Vec3& pos)
{
int nSrcSize = nDstSize * 4; // Render 16x bigger cubemap (4x4) - 16x SSAA
TArray<unsigned short> vecData;
vecData.Reserve(nSrcSize * nSrcSize * 6 * 4);
vecData.SetUse(0);
if (!GetIEditor()->GetRenderer()->EF_RenderEnvironmentCubeHDR(nSrcSize, pos, vecData))
{
assert(0);
return false;
}
assert(vecData.size() == nSrcSize * nSrcSize * 6 * 4);
// todo: such big downsampling should be on gpu
// save data to tiff
// resample the image at the original size
CWordImage img;
img.Allocate(nDstSize * 4 * 6, nDstSize);
size_t srcPitch = nSrcSize * 4;
size_t srcSlideSize = nSrcSize * srcPitch;
size_t dstPitch = nDstSize * 4;
for (int side = 0; side < 6; ++side)
{
for (uint32 y = 0; y < nDstSize; ++y)
{
CryHalf4* pSrcSide = (CryHalf4*)&vecData[side * srcSlideSize];
CryHalf4* pDst = (CryHalf4*)&img.ValueAt(side * dstPitch, y);
for (uint32 x = 0; x < nDstSize; ++x)
{
Vec4 cResampledColor(0.f, 0.f, 0.f, 0.f);
// resample the image at the original size
for (uint32 yres = 0; yres < 4; ++yres)
{
for (uint32 xres = 0; xres < 4; ++xres)
{
const CryHalf4& pSrc = pSrcSide[(y * 4 + yres) * nSrcSize + (x * 4 + xres)];
cResampledColor += Vec4(CryConvertHalfToFloat(pSrc.x), CryConvertHalfToFloat(pSrc.y), CryConvertHalfToFloat(pSrc.z), CryConvertHalfToFloat(pSrc.w));
}
}
cResampledColor /= 16.f;
*pDst++ = CryHalf4(cResampledColor.x, cResampledColor.y, cResampledColor.z, cResampledColor.w);
}
}
}
assert(CryMemory::IsHeapValid());
CImageTIF tif;
const bool res = tif.SaveRAW(fileName, img.GetData(), nDstSize * 6, nDstSize, 2, 4, true, "HDRCubemap_highQ");
assert(res);
return res;
}
//function will recurse all probes and generate a cubemap for each
void CubemapUtils::RegenerateAllEnvironmentProbeCubemaps()
{
EBUS_EVENT(AzToolsFramework::EditorRequests::Bus, GenerateAllCubemaps);
}
-33
View File
@@ -1,33 +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_UTIL_CUBEMAPUTILS_H
#define CRYINCLUDE_EDITOR_UTIL_CUBEMAPUTILS_H
#pragma once
namespace CubemapUtils
{
//! Generate a cubemap
//! \param filename
//! \param pObject The cubemap will be generated at this object's location
//! \param size Texel dimension of the cubemap
//! \param hideObject If true, pObject will be hidden when rendering the cubemap. For example, set this to true if pObject is a model that shouldn't
//! show up in the cubemap, or set to false if pObject is a light or probe that should contribute to the cubemap.
SANDBOX_API bool GenCubemapWithObjectPathAndSize(QString& filename, CBaseObject* pObject, const int size, const bool hideObject);
SANDBOX_API bool GenHDRCubemapTiff(const QString& fileName, int size, Vec3& pos);
SANDBOX_API void RegenerateAllEnvironmentProbeCubemaps();
}
#endif // CRYINCLUDE_EDITOR_UTIL_CUBEMAPUTILS_H
-5
View File
@@ -22,7 +22,6 @@
#include "Util/ImageGif.h"
#include "Util/ImageTIF.h"
#include "Util/ImageHDR.h"
#include "Util/Image_DXTC.h"
//////////////////////////////////////////////////////////////////////////
bool CImageUtil::Save(const QString& strFileName, CImageEx& inImage)
@@ -272,10 +271,6 @@ bool CImageUtil::LoadImage(const QString& fileName, CImageEx& image, bool* pQual
{
return LoadPGM(fileName, image);
}
else if (azstricmp(ext, ".dds") == 0)
{
return CImage_DXTC().Load(fileName.toUtf8().data(), image, pQualityLoss);
}
else if (azstricmp(ext, ".png") == 0)
{
return CImageUtil::Load(fileName, image);
-806
View File
@@ -1,806 +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 "Image_DXTC.h"
// CryCommon
#include <CryCommon/IImage.h>
#include <CryCommon/ImageExtensionHelper.h>
// Editor
#include "Util/Image.h"
#include "BitFiddling.h"
#ifndef MAKEFOURCC
#define MAKEFOURCC(ch0, ch1, ch2, ch3) \
((DWORD)(BYTE)(ch0) | ((DWORD)(BYTE)(ch1) << 8) | \
((DWORD)(BYTE)(ch2) << 16) | ((DWORD)(BYTE)(ch3) << 24))
#endif //defined(MAKEFOURCC)
//////////////////////////////////////////////////////////////////////////
// HDR_UPPERNORM -> factor used when converting from [0,32768] high dynamic range images
// to [0,1] low dynamic range images; 32768 = 2^(2^4-1), 4 exponent bits
// LDR_UPPERNORM -> factor used when converting from [0,1] low dynamic range images
// to 8bit outputs
#define HDR_UPPERNORM 1.0f // factor set to 1.0, to be able to see content in our rather dark HDR images
#define LDR_UPPERNORM 255.0f
static float GammaToLinear(float x)
{
return (x <= 0.04045f) ? x / 12.92f : powf((x + 0.055f) / 1.055f, 2.4f);
}
static float LinearToGamma(float x)
{
return (x <= 0.0031308f) ? x * 12.92f : 1.055f * powf(x, 1.0f / 2.4f) - 0.055f;
}
//////////////////////////////////////////////////////////////////////////
// Squish uses non-standard inline friend templates which Recode cannot parse
#ifndef __RECODE__
AZ_PUSH_DISABLE_WARNING(4819 4828, "-Wunknown-warning-option") // Invalid character not in default code page
#include <squish-ccr/squish.h>
AZ_POP_DISABLE_WARNING
#endif
// number of bytes per block per type
#define BLOCKSIZE_BC1 8
#define BLOCKSIZE_BC2 16
#define BLOCKSIZE_BC3 16
#define BLOCKSIZE_BC4 8
#define BLOCKSIZE_BC5 16
#define BLOCKSIZE_BC6 16
#define BLOCKSIZE_BC7 16
CImage_DXTC::COMPRESSOR_ERROR CImage_DXTC::DecompressTextureBTC(
int width,
int height,
ETEX_Format sourceFormat,
CImage_DXTC::UNCOMPRESSED_FORMAT destinationFormat,
[[maybe_unused]] const int imageFlags,
const void* sourceData,
void* destinationData,
int destinationDataSize,
int destinationPageOffset)
{
// Squish uses non-standard inline friend templates which Recode cannot parse
#ifndef __RECODE__
{
const COMPRESSOR_ERROR result = CheckParameters(
width,
height,
destinationFormat,
sourceData,
destinationData,
destinationDataSize);
if (result != COMPRESSOR_ERROR_NONE)
{
return result;
}
}
int flags = 0;
int offs = 0;
int sourceChannels = 4;
switch (sourceFormat)
{
case eTF_BC1:
sourceChannels = 4;
flags = squish::kBtc1;
break;
case eTF_BC2:
sourceChannels = 4;
flags = squish::kBtc2;
break;
case eTF_BC3:
sourceChannels = 4;
flags = squish::kBtc3;
break;
case eTF_BC4U:
sourceChannels = 1;
flags = squish::kBtc4;
break;
case eTF_BC5U:
sourceChannels = 2;
flags = squish::kBtc5 + squish::kColourMetricUnit;
break;
case eTF_BC6UH:
sourceChannels = 3;
flags = squish::kBtc6;
break;
case eTF_BC7:
sourceChannels = 4;
flags = squish::kBtc7;
break;
case eTF_BC4S:
sourceChannels = 1;
flags = squish::kBtc4 + squish::kSignedInternal + squish::kSignedExternal;
offs = 0x80;
break;
case eTF_BC5S:
sourceChannels = 2;
flags = squish::kBtc5 + squish::kSignedInternal + squish::kSignedExternal + squish::kColourMetricUnit;
offs = 0x80;
break;
case eTF_BC6SH:
sourceChannels = 3;
flags = squish::kBtc6 + squish::kSignedInternal + squish::kSignedExternal;
offs = 0x80;
break;
default:
return COMPRESSOR_ERROR_UNSUPPORTED_SOURCE_FORMAT;
}
squish::sqio::dtp datatype = !IsLimitedHDR(sourceFormat) ? squish::sqio::dtp::DT_U8 : squish::sqio::dtp::DT_F23;
switch (destinationFormat)
{
case FORMAT_ARGB_8888: /*datatype = squish::sqio::dtp::DT_U8;*/
break;
// case FORMAT_ARGB_16161616: datatype = squish::sqio::dtp::DT_U16; break;
// case FORMAT_ARGB_32323232F: datatype = squish::sqio::dtp::DT_F23; break;
default:
return COMPRESSOR_ERROR_UNSUPPORTED_DESTINATION_FORMAT;
}
struct squish::sqio sqio = squish::GetSquishIO(width, height, datatype, flags);
const int blockChannels = 4;
const int blockWidth = 4;
const int blockHeight = 4;
const int pixelStride = blockChannels * sizeof(uint8);
const int rowStride = (destinationPageOffset ? destinationPageOffset : pixelStride * width);
if ((datatype == squish::sqio::dtp::DT_U8) && (destinationFormat == FORMAT_ARGB_8888))
{
const char* src = (const char*)sourceData;
for (int y = 0; y < height; y += blockHeight)
{
uint8* dst = ((uint8*)destinationData) + (y * rowStride);
for (int x = 0; x < width; x += blockWidth)
{
uint8 values[blockHeight][blockWidth][blockChannels] = { { { 0 } } };
// decode
sqio.decoder((uint8*)values, src, sqio.flags);
// transfer
for (int by = 0; by < blockHeight; by += 1)
{
uint8* bdst = ((uint8*)dst) + (by * rowStride);
for (int bx = 0; bx < blockWidth; bx += 1)
{
bdst[bx * pixelStride + 0] = sourceChannels <= 0 ? 0U : (values[by][bx][0] + offs);
bdst[bx * pixelStride + 1] = sourceChannels <= 1 ? bdst[bx * pixelStride + 0] : (values[by][bx][1] + offs);
bdst[bx * pixelStride + 2] = sourceChannels <= 1 ? bdst[bx * pixelStride + 0] : (values[by][bx][2] + offs);
bdst[bx * pixelStride + 3] = sourceChannels <= 3 ? 255U : (values[by][bx][3]);
}
}
dst += blockWidth * pixelStride;
src += sqio.blocksize;
}
}
}
else if ((datatype == squish::sqio::dtp::DT_F23) && (destinationFormat == FORMAT_ARGB_8888))
{
const char* src = (const char*)sourceData;
for (int y = 0; y < height; y += blockHeight)
{
uint8* dst = ((uint8*)destinationData) + (y * rowStride);
for (int x = 0; x < width; x += blockWidth)
{
float values[blockHeight][blockWidth][blockChannels] = { { { 0 } } };
// decode
sqio.decoder((float*)values, src, sqio.flags);
// transfer
for (int by = 0; by < blockHeight; by += 1)
{
uint8* bdst = ((uint8*)dst) + (by * rowStride);
for (int bx = 0; bx < blockWidth; bx += 1)
{
bdst[bx * pixelStride + 0] = sourceChannels <= 0 ? 0U : std::min((uint8)255, (uint8)floorf(values[by][bx][0] * LDR_UPPERNORM / HDR_UPPERNORM + 0.5f));
bdst[bx * pixelStride + 1] = sourceChannels <= 1 ? bdst[bx * pixelStride + 0] : std::min((uint8)255, (uint8)floorf(values[by][bx][1] * LDR_UPPERNORM / HDR_UPPERNORM + 0.5f));
bdst[bx * pixelStride + 2] = sourceChannels <= 1 ? bdst[bx * pixelStride + 0] : std::min((uint8)255, (uint8)floorf(values[by][bx][2] * LDR_UPPERNORM / HDR_UPPERNORM + 0.5f));
bdst[bx * pixelStride + 3] = sourceChannels <= 3 ? 255U : 255U;
}
}
dst += blockWidth * pixelStride;
src += sqio.blocksize;
}
}
}
#endif
return COMPRESSOR_ERROR_NONE;
}
//////////////////////////////////////////////////////////////////////////
CImage_DXTC::CImage_DXTC()
{
}
//////////////////////////////////////////////////////////////////////////
CImage_DXTC::~CImage_DXTC()
{
}
//////////////////////////////////////////////////////////////////////////
bool CImage_DXTC::Load(const char* filename, CImageEx& outImage, bool* pQualityLoss)
{
if (pQualityLoss)
{
*pQualityLoss = false;
}
_smart_ptr<IImageFile> pImage = gEnv->pRenderer->EF_LoadImage(filename, 0);
if (!pImage)
{
return(false);
}
BYTE* pDecompBytes;
ETEX_Format eFormat = pImage->mfGetFormat();
int imageFlags = pImage->mfGet_Flags();
if (eFormat == eTF_Unknown)
{
return false;
}
_smart_ptr<IImageFile> pAlphaImage;
ETEX_Format eAttachedFormat = eTF_Unknown;
if (imageFlags & FIM_HAS_ATTACHED_ALPHA)
{
if (pAlphaImage = gEnv->pRenderer->EF_LoadImage(filename, FIM_ALPHA))
{
eAttachedFormat = pAlphaImage->mfGetFormat();
}
}
const bool bIsSRGB = (imageFlags & FIM_SRGB_READ) != 0;
outImage.SetSRGB(bIsSRGB);
const uint32 imageWidth = pImage->mfGet_width();
const uint32 imageHeight = pImage->mfGet_height();
const uint32 numMips = pImage->mfGet_numMips();
int nHorizontalFaces(1);
int nVerticalFaces(1);
int nTargetPitch(imageWidth * 4);
int nTargetPageSize(nTargetPitch * imageHeight);
int nHorizontalPageOffset(nTargetPitch);
int nVerticalPageOffset(0);
bool boIsCubemap = pImage->mfGet_NumSides() == 6;
if (boIsCubemap)
{
nHorizontalFaces = 3;
nVerticalFaces = 2;
nHorizontalPageOffset = nTargetPitch * nHorizontalFaces;
nVerticalPageOffset = nTargetPageSize * nHorizontalFaces;
}
outImage.Allocate(imageWidth * nHorizontalFaces, imageHeight * nVerticalFaces);
pDecompBytes = (BYTE*)outImage.GetData();
if (!pDecompBytes)
{
Warning("Cannot allocate image %dx%d, Out of memory", imageWidth, imageHeight);
return false;
}
if (pQualityLoss)
{
*pQualityLoss = CImageExtensionHelper::IsQuantized(eFormat);
}
bool bOk = true;
int nCurrentFace(0);
int nCurrentHorizontalFace(0);
int nCurrentVerticalFace(0);
unsigned char* dest(NULL);
const unsigned char* src(NULL);
unsigned char* basedest(NULL);
const unsigned char* basesrc(NULL);
for (nCurrentHorizontalFace = 0; nCurrentHorizontalFace < nHorizontalFaces; ++nCurrentHorizontalFace)
{
basedest = &pDecompBytes[nTargetPitch * nCurrentHorizontalFace]; // Horizontal offset.
for (nCurrentVerticalFace = 0; nCurrentVerticalFace < nVerticalFaces; ++nCurrentVerticalFace, ++nCurrentFace)
{
basedest += nVerticalPageOffset * nCurrentVerticalFace; // Vertical offset.
basesrc = src = pImage->mfGet_image(nCurrentFace);
if (eFormat == eTF_R8G8B8A8 || eFormat == eTF_R8G8B8A8S)
{
for (int y = 0; y < imageHeight; y++)
{
dest = basedest + nHorizontalPageOffset * y; // Pixel position.
for (int x = 0; x < imageWidth; x++)
{
dest[0] = src[0];
dest[1] = src[1];
dest[2] = src[2];
dest[3] = src[3];
dest += 4;
src += 4;
}
}
}
else if (eFormat == eTF_B8G8R8A8)
{
for (int y = 0; y < imageHeight; y++)
{
dest = basedest + nHorizontalPageOffset * y; // Pixel position.
for (int x = 0; x < imageWidth; x++)
{
dest[0] = src[2];
dest[1] = src[1];
dest[2] = src[0];
dest[3] = src[3];
dest += 4;
src += 4;
}
}
}
else if (eFormat == eTF_B8G8R8X8)
{
for (int y = 0; y < imageHeight; y++)
{
dest = basedest + nHorizontalPageOffset * y; // Pixel position.
for (int x = 0; x < imageWidth; x++)
{
dest[0] = src[2];
dest[1] = src[1];
dest[2] = src[0];
dest[3] = 255;
dest += 4;
src += 4;
}
}
}
else if (eFormat == eTF_B8G8R8)
{
for (int y = 0; y < imageHeight; y++)
{
dest = basedest + nHorizontalPageOffset * y; // Pixel position.
for (int x = 0; x < imageWidth; x++)
{
dest[0] = src[2];
dest[1] = src[1];
dest[2] = src[0];
dest[3] = 255;
dest += 4;
src += 3;
}
}
}
else if (eFormat == eTF_L8)
{
for (int y = 0; y < imageHeight; y++)
{
dest = basedest + nHorizontalPageOffset * y; // Pixel position.
for (int x = 0; x < imageWidth; x++)
{
dest[0] = *src;
dest[1] = *src;
dest[2] = *src;
dest[3] = 255;
dest += 4;
src += 1;
}
}
}
else if (eFormat == eTF_A8)
{
for (int y = 0; y < imageHeight; y++)
{
dest = basedest + nHorizontalPageOffset * y; // Pixel position.
for (int x = 0; x < imageWidth; x++)
{
dest[0] = 0;
dest[1] = 0;
dest[2] = 0;
dest[3] = *src;
dest += 4;
src += 1;
}
}
}
else if (eFormat == eTF_A8L8)
{
for (int y = 0; y < imageHeight; y++)
{
dest = basedest + nHorizontalPageOffset * y; // Pixel position.
for (int x = 0; x < imageWidth; x++)
{
dest[0] = src[0];
dest[1] = src[0];
dest[2] = src[0];
dest[3] = src[1];
dest += 4;
src += 2;
}
}
}
else if (eFormat == eTF_R9G9B9E5)
{
const int nSourcePitch = imageWidth * 4;
for (int y = 0; y < imageHeight; y++)
{
src = basesrc + nSourcePitch * y; //Scanline position.
dest = basedest + nHorizontalPageOffset * y; // Pixel position.
for (int x = 0; x < imageWidth; x++)
{
const struct RgbE
{
unsigned int r : 9, g : 9, b : 9, e : 5;
}* srcv = (const struct RgbE*)src;
const float escale = powf(2.0f, int(srcv->e) - 15 - 9) * LDR_UPPERNORM / HDR_UPPERNORM;
dest[0] = std::min((uint8)255, (uint8)floorf(srcv->r * escale + 0.5f));
dest[1] = std::min((uint8)255, (uint8)floorf(srcv->g * escale + 0.5f));
dest[2] = std::min((uint8)255, (uint8)floorf(srcv->b * escale + 0.5f));
dest[3] = 255U;
dest += 4;
src += 4;
}
}
}
else
{
const int pixelCount = imageWidth * imageHeight;
const int outputBufferSize = pixelCount * 4;
const int mipCount = numMips;
const COMPRESSOR_ERROR err = DecompressTextureBTC(imageWidth, imageHeight, eFormat, FORMAT_ARGB_8888, imageFlags, basesrc, basedest, outputBufferSize, nHorizontalPageOffset);
if (err != COMPRESSOR_ERROR_NONE)
{
return false;
}
}
// alpha channel might be attached
if (imageFlags & FIM_HAS_ATTACHED_ALPHA)
{
if (IsBlockCompressed(eAttachedFormat))
{
const byte* const basealpha = pAlphaImage->mfGet_image(0);
const int alphaImageWidth = pAlphaImage->mfGet_width();
const int alphaImageHeight = pAlphaImage->mfGet_height();
const int alphaImageFlags = pAlphaImage->mfGet_Flags();
const int tmpOutputBufferSize = imageWidth * imageHeight * 4;
uint8* tmpOutputBuffer = new uint8[tmpOutputBufferSize];
const COMPRESSOR_ERROR err = DecompressTextureBTC(alphaImageWidth, alphaImageHeight, eAttachedFormat, FORMAT_ARGB_8888, alphaImageFlags, basealpha, tmpOutputBuffer, tmpOutputBufferSize, 0);
if (err != COMPRESSOR_ERROR_NONE)
{
delete []tmpOutputBuffer;
return false;
}
// assuming attached image can have lower res and difference is power of two
const uint32 reducex = IntegerLog2((uint32)(imageWidth / alphaImageWidth));
const uint32 reducey = IntegerLog2((uint32)(imageHeight / alphaImageHeight));
for (int y = 0; y < imageHeight; ++y)
{
dest = basedest + nHorizontalPageOffset * y; // Pixel position.
for (int x = 0; x < imageWidth; ++x)
{
dest[3] = tmpOutputBuffer[((x >> reducex) + (y >> reducey) * alphaImageWidth) * 4];
dest += 4;
}
}
delete []tmpOutputBuffer;
}
else if (eAttachedFormat != eTF_Unknown)
{
const byte* const basealpha = pAlphaImage->mfGet_image(0); // assuming it's A8 format (ensured with assets when loading)
const int alphaImageWidth = pAlphaImage->mfGet_width();
const int alphaImageHeight = pAlphaImage->mfGet_height();
const int alphaImageFlags = pAlphaImage->mfGet_Flags();
// assuming attached image can have lower res and difference is power of two
const uint32 reducex = IntegerLog2((uint32)(imageWidth / alphaImageWidth));
const uint32 reducey = IntegerLog2((uint32)(imageHeight / alphaImageHeight));
for (int y = 0; y < imageHeight; ++y)
{
dest = basedest + nHorizontalPageOffset * y; // Pixel position.
for (int x = 0; x < imageWidth; ++x)
{
dest[3] = basealpha[(x >> reducex) + (y >> reducey) * alphaImageWidth];
dest += 4;
}
}
}
}
}
}
//////////////////////////////////////////////////////////////////////////
// destination range is 8bits
// rescale in linear space
float cScaleR = 1.0f;
float cScaleG = 1.0f;
float cScaleB = 1.0f;
float cScaleA = 1.0f;
float cLowR = 0.0f;
float cLowG = 0.0f;
float cLowB = 0.0f;
float cLowA = 0.0f;
if (imageFlags & FIM_RENORMALIZED_TEXTURE)
{
const ColorF cMinColor = pImage->mfGet_minColor();
const ColorF cMaxColor = pImage->mfGet_maxColor();
// base range after normalization, fe. [0,1] for 8bit images, or [0,2^15] for RGBE/HDR data
float cUprValue = 1.0f;
if ((eFormat == eTF_R9G9B9E5) || (eFormat == eTF_BC6UH) || (eFormat == eTF_BC6SH))
{
cUprValue = cMaxColor.a / HDR_UPPERNORM;
}
// original range before normalization, fe. [0,1.83567]
cScaleR = (cMaxColor.r - cMinColor.r) / cUprValue;
cScaleG = (cMaxColor.g - cMinColor.g) / cUprValue;
cScaleB = (cMaxColor.b - cMinColor.b) / cUprValue;
// original offset before normalization, fe. [0.0001204]
cLowR = cMinColor.r;
cLowG = cMinColor.g;
cLowB = cMinColor.b;
}
if (imageFlags & FIM_HAS_ATTACHED_ALPHA)
{
if (pAlphaImage)
{
const int alphaImageFlags = pAlphaImage->mfGet_Flags();
if (alphaImageFlags & FIM_RENORMALIZED_TEXTURE)
{
const ColorF cMinColor = pAlphaImage->mfGet_minColor();
const ColorF cMaxColor = pAlphaImage->mfGet_maxColor();
// base range after normalization, fe. [0,1] for 8bit images, or [0,2^15] for RGBE/HDR data
float cUprValue = 1.0f;
if ((eFormat == eTF_R9G9B9E5) || (eFormat == eTF_BC6UH) || (eFormat == eTF_BC6SH))
{
cUprValue = cMaxColor.a / HDR_UPPERNORM;
}
// original range before normalization, fe. [0,1.83567]
cScaleA = (cMaxColor.r - cMinColor.r) / cUprValue;
// original offset before normalization, fe. [0.0001204]
cLowA = cMinColor.r;
}
}
}
if (cScaleR != 1.0f || cScaleG != 1.0f || cScaleB != 1.0f || cScaleA != 1.0f ||
cLowR != 0.0f || cLowG != 0.0f || cLowB != 0.0f || cLowA != 0.0f)
{
if ((eFormat == eTF_R9G9B9E5) || (eFormat == eTF_BC6UH) || (eFormat == eTF_BC6SH))
{
imageFlags &= ~FIM_SRGB_READ;
}
if (imageFlags & FIM_SRGB_READ)
{
for (int s = 0; s < (imageWidth * nHorizontalFaces * imageHeight * nVerticalFaces * 4); s += 4)
{
pDecompBytes[s + 0] = std::min((uint8)255, uint8(LinearToGamma(GammaToLinear(pDecompBytes[s + 0] / LDR_UPPERNORM) * cScaleR + cLowR) * LDR_UPPERNORM + 0.5f));
pDecompBytes[s + 1] = std::min((uint8)255, uint8(LinearToGamma(GammaToLinear(pDecompBytes[s + 1] / LDR_UPPERNORM) * cScaleG + cLowG) * LDR_UPPERNORM + 0.5f));
pDecompBytes[s + 2] = std::min((uint8)255, uint8(LinearToGamma(GammaToLinear(pDecompBytes[s + 2] / LDR_UPPERNORM) * cScaleB + cLowB) * LDR_UPPERNORM + 0.5f));
pDecompBytes[s + 3] = std::min((uint8)255, uint8(LinearToGamma(GammaToLinear(pDecompBytes[s + 3] / LDR_UPPERNORM) * cScaleA + cLowA) * LDR_UPPERNORM + 0.5f));
}
}
else
{
for (int s = 0; s < (imageWidth * nHorizontalFaces * imageHeight * nVerticalFaces * 4); s += 4)
{
pDecompBytes[s + 0] = std::min((uint8)255, uint8(pDecompBytes[s + 0] * cScaleR + cLowR * LDR_UPPERNORM + 0.5f));
pDecompBytes[s + 1] = std::min((uint8)255, uint8(pDecompBytes[s + 1] * cScaleG + cLowG * LDR_UPPERNORM + 0.5f));
pDecompBytes[s + 2] = std::min((uint8)255, uint8(pDecompBytes[s + 2] * cScaleB + cLowB * LDR_UPPERNORM + 0.5f));
pDecompBytes[s + 3] = std::min((uint8)255, uint8(pDecompBytes[s + 3] * cScaleA + cLowA * LDR_UPPERNORM + 0.5f));
}
}
}
bool hasAlpha = (eAttachedFormat != eTF_Unknown) /*|| CImageExtensionHelper::HasAlphaForTextureFormat(eFormat)*/;
for (int s = 0; s < (imageWidth * nHorizontalFaces * imageHeight * nVerticalFaces); s += 4)
{
hasAlpha |= (pDecompBytes[s + 3] != 0xFF);
}
//////////////////////////////////////////////////////////////////////////
QString strFormat = NameForTextureFormat(eFormat);
QString mips;
mips = QStringLiteral(" Mips:%1").arg(numMips);
if (eAttachedFormat != eTF_Unknown)
{
strFormat += " + ";
strFormat += NameForTextureFormat(eAttachedFormat);
}
strFormat += mips;
// Check whether it's gamma-corrected or not and add a description accordingly.
if (imageFlags & FIM_SRGB_READ)
{
strFormat += ", SRGB/Gamma corrected";
}
if (imageFlags & FIM_RENORMALIZED_TEXTURE)
{
strFormat += ", Renormalized";
}
if (IsLimitedHDR(eFormat))
{
strFormat += ", HDR";
}
outImage.SetFormatDescription(strFormat);
outImage.SetNumberOfMipMaps(numMips);
outImage.SetHasAlphaChannel(hasAlpha);
outImage.SetIsLimitedHDR(IsLimitedHDR(eFormat));
outImage.SetIsCubemap(boIsCubemap);
outImage.SetFormat(eFormat);
outImage.SetSRGB(imageFlags & FIM_SRGB_READ);
// done reading file
return bOk;
}
//////////////////////////////////////////////////////////////////////////
int CImage_DXTC::TextureDataSize(int nWidth, int nHeight, int nDepth, int nMips, ETEX_Format eTF)
{
if (eTF == eTF_Unknown)
{
return 0;
}
if (nMips <= 0)
{
nMips = 0;
}
int nSize = 0;
int nM = 0;
while (nWidth || nHeight || nDepth)
{
if (!nWidth)
{
nWidth = 1;
}
if (!nHeight)
{
nHeight = 1;
}
if (!nDepth)
{
nDepth = 1;
}
nM++;
int nSingleMipSize;
if (IsBlockCompressed(eTF))
{
int blockSize = CImageExtensionHelper::BytesPerBlock(eTF);
const Vec2i blockDim = CImageExtensionHelper::GetBlockDim(eTF);
nSingleMipSize = ((nWidth + blockDim.x - 1) / blockDim.x) * ((nHeight + blockDim.y - 1) / blockDim.y) * nDepth * blockSize;
}
else
{
nSingleMipSize = nWidth * nHeight * nDepth * CImageExtensionHelper::BytesPerBlock(eTF);
}
nSize += nSingleMipSize;
nWidth >>= 1;
nHeight >>= 1;
nDepth >>= 1;
if (nMips == nM)
{
break;
}
}
//assert (nM == nMips);
return nSize;
}
//////////////////////////////////////////////////////////////////////////
CImage_DXTC::COMPRESSOR_ERROR CImage_DXTC::CheckParameters(
int width,
int height,
CImage_DXTC::UNCOMPRESSED_FORMAT destinationFormat,
const void* sourceData,
void* destinationData,
int destinationDataSize)
{
const int blockWidth = 4;
const int blockHeight = 4;
const int bgraPixelSize = 4 * sizeof(uint8);
const int bgraRowSize = bgraPixelSize * width;
if ((width <= 0) || (height <= 0) || (!sourceData))
{
return COMPRESSOR_ERROR_NO_INPUT_DATA;
}
if ((width % blockWidth) || (height % blockHeight))
{
return COMPRESSOR_ERROR_GENERIC;
}
if ((destinationData == 0) || (destinationDataSize <= 0))
{
return COMPRESSOR_ERROR_NO_OUTPUT_POINTER;
}
if (destinationFormat != FORMAT_ARGB_8888)
{
return COMPRESSOR_ERROR_UNSUPPORTED_DESTINATION_FORMAT;
}
if ((height * bgraRowSize <= 0) || (height * bgraRowSize > destinationDataSize))
{
return COMPRESSOR_ERROR_GENERIC;
}
return COMPRESSOR_ERROR_NONE;
}
-87
View File
@@ -1,87 +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_UTIL_IMAGE_DXTC_H
#define CRYINCLUDE_EDITOR_UTIL_IMAGE_DXTC_H
#pragma once
#include "ImageExtensionHelper.h"
class CImageEx;
class CImage_DXTC
{
// Typedefs
public:
protected:
//////////////////////////////////////////////////////////////////////////
// Extracted from Compressorlib.h on SDKs\CompressATI directory.
// Added here because we are not really using the elements inside
// this header file apart from those definitions as we are currently
// loading the DLL CompressATI2.dll manually as recommended by the rendering
// team.
typedef enum
{
FORMAT_ARGB_8888,
FORMAT_ARGB_TOOBIG
} UNCOMPRESSED_FORMAT;
typedef enum
{
COMPRESSOR_ERROR_NONE,
COMPRESSOR_ERROR_NO_INPUT_DATA,
COMPRESSOR_ERROR_NO_OUTPUT_POINTER,
COMPRESSOR_ERROR_UNSUPPORTED_SOURCE_FORMAT,
COMPRESSOR_ERROR_UNSUPPORTED_DESTINATION_FORMAT,
COMPRESSOR_ERROR_UNABLE_TO_INIT_CODEC,
COMPRESSOR_ERROR_GENERIC
} COMPRESSOR_ERROR;
//////////////////////////////////////////////////////////////////////////
// Methods
public:
CImage_DXTC();
~CImage_DXTC();
// Arguments:
// pQualityLoss - 0 if info is not needed, pointer to the result otherwise - not need to preinitialize
bool Load(const char* filename, CImageEx& outImage, bool* pQualityLoss = 0); // true if success
static inline const char* NameForTextureFormat(ETEX_Format ETF) { return CImageExtensionHelper::NameForTextureFormat(ETF); }
static inline bool IsBlockCompressed(ETEX_Format ETF) { return CImageExtensionHelper::IsBlockCompressed(ETF); }
static inline bool IsLimitedHDR(ETEX_Format ETF) { return CImageExtensionHelper::IsRangeless(ETF); }
int TextureDataSize(int nWidth, int nHeight, int nDepth, int nMips, ETEX_Format eTF);
private:
static COMPRESSOR_ERROR CheckParameters(
int width,
int height,
UNCOMPRESSED_FORMAT destinationFormat,
const void* sourceData,
void* destinationData,
int destinationDataSize);
static COMPRESSOR_ERROR DecompressTextureBTC(
int width,
int height,
ETEX_Format sourceFormat,
UNCOMPRESSED_FORMAT destinationFormat,
const int imageFlags,
const void* sourceData,
void* destinationData,
int destinationDataSize,
int destinationPageOffset);
};
#endif // CRYINCLUDE_EDITOR_UTIL_IMAGE_DXTC_H
-268
View File
@@ -1,268 +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 : Ruler helper for Editor to determine distances
#include "EditorDefs.h"
#include "Ruler.h"
// Editor
#include "Settings.h"
#include "Viewport.h"
#include "Include/HitContext.h"
#include "Include/IObjectManager.h"
#include "Objects/BaseObject.h"
// Qt
#include <QtGui/private/qhighdpiscaling_p.h>
//////////////////////////////////////////////////////////////////////////
CRuler::CRuler()
: m_bActive(false)
, m_MouseOverObject(GUID_NULL)
, m_sphereScale(0.5f)
, m_sphereTrans(0.5f)
{
}
//////////////////////////////////////////////////////////////////////////
CRuler::~CRuler()
{
SetActive(false);
}
//////////////////////////////////////////////////////////////////////////
bool CRuler::HasQueuedPaths() const
{
return false;
}
//////////////////////////////////////////////////////////////////////////
void CRuler::SetActive(bool bActive)
{
if (m_bActive != bActive)
{
m_bActive = bActive;
if (m_bActive)
{
m_sphereScale = gSettings.gizmo.rulerSphereScale;
m_sphereTrans = gSettings.gizmo.rulerSphereTrans;
}
// Reset
m_startPoint.Reset();
m_endPoint.Reset();
CBaseObject* pObject = GetIEditor()->GetObjectManager()->FindObject(m_MouseOverObject);
if (pObject)
{
pObject->SetHighlight(false);
}
m_MouseOverObject = GUID_NULL;
}
}
//////////////////////////////////////////////////////////////////////////
void CRuler::Update()
{
if (!IsActive())
{
return;
}
if (CheckVirtualKey(Qt::Key_Escape))
{
SetActive(false);
return;
}
static const ColorF colours[] =
{
Col_Blue,
Col_Green,
Col_Red,
Col_Yellow,
Col_Magenta,
Col_Black,
};
IRenderer* pRenderer = GetIEditor()->GetSystem()->GetIRenderer();
CRY_ASSERT(pRenderer);
IRenderAuxGeom* pAuxGeom = pRenderer->GetIRenderAuxGeom();
CRY_ASSERT(pAuxGeom);
CViewport* pActiveView = GetIEditor()->GetActiveView();
if (pActiveView)
{
// Draw where cursor currently is
if (!IsObjectSelectMode(pActiveView))
{
QPoint vCursorPoint = QCursor::pos();
pActiveView->ScreenToClient(vCursorPoint);
vCursorPoint = QHighDpi::toNativePixels(vCursorPoint, QGuiApplication::screenAt(vCursorPoint));
Vec3 vCursorWorldPos = pActiveView->SnapToGrid(pActiveView->ViewToWorld(vCursorPoint));
Vec3 vOffset(0.1f, 0.1f, 0.1f);
pAuxGeom->SetRenderFlags(e_Def3DPublicRenderflags | e_AlphaBlended);
pAuxGeom->DrawSphere(vCursorWorldPos, m_sphereScale, ColorF(0.5, 0.5, 0.5, m_sphereTrans));
pAuxGeom->DrawAABB(AABB(vCursorWorldPos - vOffset * m_sphereScale, vCursorWorldPos + vOffset * m_sphereScale), false, ColorF(1.0f, 0.0f, 0.0f, 1.0f), eBBD_Faceted);
}
uint32 x = 12, y = 60;
if (!m_startPoint.IsEmpty())
{
//pAuxGeom->DrawSphere(m_startPoint.GetPos(), 1.0f, ColorB(255,255,255,255));
m_startPoint.Render(pRenderer);
}
if (!m_endPoint.IsEmpty())
{
//pAuxGeom->DrawSphere(m_endPoint.GetPos(), 1.0f, ColorB(255,255,255,255));
m_endPoint.Render(pRenderer);
pAuxGeom->DrawLine(m_startPoint.GetPos(), ColorB(255, 255, 255, 255), m_endPoint.GetPos(), ColorB(255, 255, 255, 255));
string sTempText;
// Compute distance and output results
// TODO: Consider movement speed outputs here as well?
const float fDistance = m_startPoint.GetDistance(m_endPoint);
sTempText.Format("Straight-line distance: %.3f", fDistance);
// Draw mid text
float white[] = {1.0f, 1.0f, 1.0f, 1.0f};
pRenderer->Draw2dLabel(x, y, 2.0f, white, false, sTempText.c_str());
y += 18;
}
}
}
//////////////////////////////////////////////////////////////////////////
bool CRuler::IsObjectSelectMode([[maybe_unused]] CViewport* pView) const
{
const bool bShiftDown = CheckVirtualKey(Qt::Key_Shift);
return (bShiftDown);
}
//////////////////////////////////////////////////////////////////////////
void CRuler::UpdateRulerPoint(CViewport* pView, const QPoint& point, CRulerPoint& rulerPoint, bool bRequestPath)
{
CRY_ASSERT(pView);
const bool bObjectSelect = IsObjectSelectMode(pView);
rulerPoint.SetHelperSettings(m_sphereScale, m_sphereTrans);
// Do entity hit check
if (bObjectSelect)
{
HitContext hitInfo;
pView->HitTest(point, hitInfo);
CBaseObject* pHitObj = hitInfo.object;
rulerPoint.Set(pHitObj);
}
else
{
Vec3 vWorldPoint = pView->SnapToGrid(pView->ViewToWorld(point));
rulerPoint.Set(vWorldPoint);
}
if (bRequestPath)
{
RequestPath();
}
}
//////////////////////////////////////////////////////////////////////////
void CRuler::RequestPath()
{
}
//////////////////////////////////////////////////////////////////////////
bool CRuler::MouseCallback(CViewport* pView, EMouseEvent event, QPoint& point, int flags)
{
bool bResult = IsActive();
if (bResult)
{
switch (event)
{
case eMouseMove:
OnMouseMove(pView, point, flags);
break;
case eMouseLUp:
OnLButtonUp(pView, point, flags);
break;
}
}
return bResult;
}
//////////////////////////////////////////////////////////////////////////
void CRuler::OnMouseMove(CViewport* pView, QPoint& point, [[maybe_unused]] int flags)
{
GUID hitGUID = GUID_NULL;
if (IsObjectSelectMode(pView))
{
// Check for hit entity
HitContext hitInfo;
pView->HitTest(point, hitInfo);
CBaseObject* pHitObj = hitInfo.object;
if (pHitObj)
{
hitGUID = pHitObj->GetId();
}
}
if (hitGUID != m_MouseOverObject)
{
// Kill highlight on old
CBaseObject* pOldObj = GetIEditor()->GetObjectManager()->FindObject(m_MouseOverObject);
if (pOldObj)
{
pOldObj->SetHighlight(false);
}
CBaseObject* pHitObj = GetIEditor()->GetObjectManager()->FindObject(hitGUID);
if (pHitObj)
{
pHitObj->SetHighlight(true);
}
m_MouseOverObject = hitGUID;
}
}
//////////////////////////////////////////////////////////////////////////
void CRuler::OnLButtonUp(CViewport* pView, QPoint& point, [[maybe_unused]] int flags)
{
if (m_startPoint.IsEmpty())
{
UpdateRulerPoint(pView, point, m_startPoint, false);
}
else if (m_endPoint.IsEmpty())
{
UpdateRulerPoint(pView, point, m_endPoint, true);
}
else
{
UpdateRulerPoint(pView, point, m_startPoint, false);
m_endPoint.Reset();
}
}
-69
View File
@@ -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.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
// Description : Ruler helper for Editor to determine distances
#ifndef CRYINCLUDE_EDITOR_UTIL_RULER_H
#define CRYINCLUDE_EDITOR_UTIL_RULER_H
#pragma once
#include "RulerPoint.h"
//! The Ruler utility helps to determine distances between user-specified points
class CRuler
{
public:
CRuler();
~CRuler();
//! Returns if ruler has queued paths in the path agent
bool HasQueuedPaths() const;
//! Activate the ruler
void SetActive(bool bActive);
bool IsActive() const { return m_bActive; }
//! Update
void Update();
//! Mouse callback handling from viewport
bool MouseCallback(CViewport* pView, EMouseEvent event, QPoint& point, int flags);
private:
//! Mouse callback helpers
void OnMouseMove(CViewport* pView, QPoint& point, int flags);
void OnLButtonUp(CViewport* pView, QPoint& point, int flags);
//! Returns world point based on mouse point
void UpdateRulerPoint(CViewport* pView, const QPoint& point, CRulerPoint& rulerPoint, bool bRequestPath);
//! Request a path using the path agent
void RequestPath();
bool IsObjectSelectMode(CViewport* pView) const;
private:
bool m_bActive;
GUID m_MouseOverObject;
// Base point
CRulerPoint m_startPoint;
CRulerPoint m_endPoint;
float m_sphereScale;
float m_sphereTrans;
};
#endif // CRYINCLUDE_EDITOR_UTIL_RULER_H
-216
View File
@@ -1,216 +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 : Ruler helper for Editor to determine distances
#include "EditorDefs.h"
#include "RulerPoint.h"
// Editor
#include "Objects/BaseObject.h"
#include "Include/IObjectManager.h"
//////////////////////////////////////////////////////////////////////////
CRulerPoint::CRulerPoint()
: m_type(eType_Invalid)
, m_vPoint(ZERO)
, m_ObjectGUID(GUID_NULL)
{
Reset();
}
//////////////////////////////////////////////////////////////////////////
CRulerPoint& CRulerPoint::operator =(CRulerPoint const& other)
{
if (this != &other)
{
Reset(); // Manage deselect of current object, etc.
m_type = other.m_type;
m_vPoint = other.m_vPoint;
m_ObjectGUID = other.m_ObjectGUID;
m_sphereScale = other.m_sphereScale;
m_sphereTrans = other.m_sphereTrans;
}
return *this;
}
//////////////////////////////////////////////////////////////////////////
void CRulerPoint::Reset()
{
// Kill highlight of current object
CBaseObject* pObject = GetObject();
if (pObject)
{
pObject->SetHighlight(false);
}
m_type = eType_Invalid;
m_vPoint.zero();
m_ObjectGUID = GUID_NULL;
}
//////////////////////////////////////////////////////////////////////////
void CRulerPoint::Render(IRenderer* pRenderer)
{
CRY_ASSERT(pRenderer);
IRenderAuxGeom* pAuxGeom = pRenderer->GetIRenderAuxGeom();
switch (m_type)
{
case eType_Point:
{
Vec3 vOffset(0.1f, 0.1f, 0.1f);
pAuxGeom->SetRenderFlags(e_Def3DPublicRenderflags | e_AlphaBlended);
pAuxGeom->DrawSphere(m_vPoint, m_sphereScale, ColorF(1, 1, 1, m_sphereTrans));
pAuxGeom->DrawAABB(AABB(m_vPoint - vOffset * m_sphereScale, m_vPoint + vOffset * m_sphereScale), false, ColorF(0.0f, 1.0f, 0.0f, 1.0f), eBBD_Faceted);
}
break;
case eType_Object:
{
CBaseObject* pObject = GetObject();
if (pObject)
{
pObject->SetHighlight(true);
}
}
break;
default:
return; // No extra drawing
}
}
//////////////////////////////////////////////////////////////////////////
void CRulerPoint::Set(const Vec3& vPos)
{
Reset();
m_type = eType_Point;
m_vPoint = vPos;
}
//////////////////////////////////////////////////////////////////////////
void CRulerPoint::Set(CBaseObject* pObject)
{
Reset();
m_type = eType_Object;
m_ObjectGUID = (pObject ? pObject->GetId() : GUID_NULL);
}
//////////////////////////////////////////////////////////////////////////
void CRulerPoint::SetHelperSettings(float scale, float trans)
{
m_sphereScale = scale;
m_sphereTrans = trans;
}
//////////////////////////////////////////////////////////////////////////
bool CRulerPoint::IsEmpty() const
{
bool bResult = true;
switch (m_type)
{
case eType_Invalid:
bResult = true;
break;
case eType_Point:
bResult = m_vPoint.IsZero();
break;
case eType_Object:
bResult = (GetObject() == 0);
break;
}
return bResult;
}
//////////////////////////////////////////////////////////////////////////
Vec3 CRulerPoint::GetPos() const
{
Vec3 vResult(ZERO);
switch (m_type)
{
case eType_Point:
vResult = m_vPoint;
break;
case eType_Object:
{
CBaseObject* pObject = GetObject();
if (pObject)
{
vResult = pObject->GetWorldPos();
}
}
break;
}
return vResult;
}
//////////////////////////////////////////////////////////////////////////
Vec3 CRulerPoint::GetMidPoint(const CRulerPoint& otherPoint) const
{
Vec3 vResult(ZERO);
if (!IsEmpty() && !otherPoint.IsEmpty())
{
vResult = GetPos() + (otherPoint.GetPos() - GetPos()) * 0.5f;
}
else if (!IsEmpty())
{
vResult = GetPos();
}
else
{
vResult = otherPoint.GetPos();
}
return vResult;
}
//////////////////////////////////////////////////////////////////////////
float CRulerPoint::GetDistance(const CRulerPoint& otherPoint) const
{
float fResult = 0.0f;
if (!IsEmpty() && !otherPoint.IsEmpty())
{
fResult = GetPos().GetDistance(otherPoint.GetPos());
}
return fResult;
}
//////////////////////////////////////////////////////////////////////////
CBaseObject* CRulerPoint::GetObject() const
{
CBaseObject* pResult = NULL;
if (m_type == eType_Object)
{
pResult = GetIEditor()->GetObjectManager()->FindObject(m_ObjectGUID);
}
return pResult;
}
-65
View File
@@ -1,65 +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 : Ruler point helper, used by CRuler
#ifndef CRYINCLUDE_EDITOR_UTIL_RULERPOINT_H
#define CRYINCLUDE_EDITOR_UTIL_RULERPOINT_H
#pragma once
class CRuler;
//! Ruler point helper - Defines a point for the ruler
class CRulerPoint
{
public:
CRulerPoint();
CRulerPoint& operator =(CRulerPoint const& other);
void Reset();
void Render(IRenderer* pRenderer);
//! Set helpers
void Set(const Vec3& vPos);
void Set(CBaseObject* pObject);
void SetHelperSettings(float scale, float trans);
//! Returns is point has valid data in it (in use)
bool IsEmpty() const;
//! Helpers to get correct data out
Vec3 GetPos() const;
Vec3 GetMidPoint(const CRulerPoint& otherPoint) const;
float GetDistance(const CRulerPoint& otherPoint) const;
CBaseObject* GetObject() const;
private:
enum EType
{
eType_Invalid,
eType_Point,
eType_Object,
eType_COUNT,
};
EType m_type;
Vec3 m_vPoint;
GUID m_ObjectGUID;
float m_sphereScale;
float m_sphereTrans;
};
#endif // CRYINCLUDE_EDITOR_UTIL_RULERPOINT_H
-21
View File
@@ -643,27 +643,6 @@ void CLayoutViewPane::SetFullscren(bool f)
m_bFullscreen = f;
}
//////////////////////////////////////////////////////////////////////////
void CLayoutViewPane::SetFullscreenViewport(bool b)
{
if (!m_viewport)
{
return;
}
if (b)
{
m_viewport->setParent(0);
GetIEditor()->GetRenderer()->ChangeResolution(800, 600, 32, 80, true, false);
}
else
{
m_viewport->setParent(this);
GetIEditor()->GetRenderer()->ChangeResolution(800, 600, 32, 80, false, false);
}
}
//////////////////////////////////////////////////////////////////////////
void CLayoutViewPane::SetFocusToViewport()
{
-2
View File
@@ -63,8 +63,6 @@ public:
void SetFullscren(bool f);
bool IsFullscreen() const { return m_bFullscreen; }
void SetFullscreenViewport(bool b);
QWidget* GetViewport() { return m_viewport; }
//////////////////////////////////////////////////////////////////////////
-11
View File
@@ -30,7 +30,6 @@
#include "Include/HitContext.h"
#include "Objects/ObjectManager.h"
#include "Util/3DConnexionDriver.h"
#include "Util/Ruler.h"
#include "PluginManager.h"
#include "Include/IRenderListener.h"
#include "GameEngine.h"
@@ -1414,17 +1413,7 @@ bool QtViewport::MouseCallback(EMouseEvent event, const QPoint& point, Qt::Keybo
break;
}
//////////////////////////////////////////////////////////////////////////
// Asks Ruler to handle mouse callback.
CRuler* pRuler = GetIEditor()->GetRuler();
QPoint tempPoint(point.x(), point.y());
if (pRuler)
{
if (pRuler->MouseCallback(this, event, tempPoint, flags))
{
return true;
}
}
//////////////////////////////////////////////////////////////////////////
// Handle viewport manipulators.
+1 -9
View File
@@ -95,8 +95,6 @@ CViewportTitleDlg::~CViewportTitleDlg()
{
GetISystem()->GetISystemEventDispatcher()->RemoveListener(this);
GetIEditor()->UnregisterNotifyListener(this);
ICVar* pDisplayInfo(gEnv->pConsole->GetCVar("r_displayInfo"));
pDisplayInfo->RemoveOnChangeFunctor(m_displayInfoCallbackIndex);
}
//////////////////////////////////////////////////////////////////////////
@@ -158,8 +156,6 @@ void CViewportTitleDlg::OnToggleHelpers()
//////////////////////////////////////////////////////////////////////////
void CViewportTitleDlg::OnToggleDisplayInfo()
{
int currentDisplayInfo = gEnv->pConsole->GetCVar("r_displayInfo")->GetIVal();
gEnv->pConsole->GetCVar("r_displayInfo")->Set(currentDisplayInfo >= 3 ? 0 : currentDisplayInfo + 1);
}
//////////////////////////////////////////////////////////////////////////
@@ -548,12 +544,8 @@ void CViewportTitleDlg::UpdateCustomPresets(const QString& text, QStringList& cu
}
}
void CViewportTitleDlg::OnChangedDisplayInfo([[maybe_unused]] ICVar* pDisplayInfo, QAbstractButton* pDisplayInfoButton)
void CViewportTitleDlg::OnChangedDisplayInfo([[maybe_unused]] ICVar* pDisplayInfo, [[maybe_unused]] QAbstractButton* pDisplayInfoButton)
{
if (pDisplayInfoButton)
{
pDisplayInfoButton->setChecked(gEnv->pConsole->GetCVar("r_displayInfo")->GetIVal());
}
}
bool CViewportTitleDlg::eventFilter(QObject* object, QEvent* event)
@@ -22,6 +22,8 @@ set(FILES
Include/IEditorMaterial.h
Include/IEditorMaterialManager.h
Include/IImageUtil.h
EditorViewportSettings.cpp
EditorViewportSettings.h
Controls/ReflectedPropertyControl/ReflectedPropertyCtrl.qrc
Controls/ReflectedPropertyControl/ReflectedPropertyCtrl.cpp
Controls/ReflectedPropertyControl/ReflectedPropertyCtrl.h
@@ -465,9 +465,6 @@ set(FILES
SelectLightAnimationDialog.h
SelectSequenceDialog.cpp
SelectSequenceDialog.h
ShadersDialog.cpp
ShadersDialog.h
ShadersDialog.ui
StartupLogoDialog.cpp
StartupLogoDialog.h
StartupLogoDialog.ui
@@ -659,10 +656,6 @@ set(FILES
ProcessInfo.cpp
ProcessInfo.h
Report.h
ShaderCache.cpp
ShaderCache.h
ShaderEnum.cpp
ShaderEnum.h
SurfaceTypeValidator.cpp
SurfaceTypeValidator.h
TrackView/AtomOutputFrameCapture.cpp
@@ -751,15 +744,11 @@ set(FILES
SettingsBlock.cpp
SettingsBlock.h
Util/AffineParts.h
Util/ArcBall.cpp
Util/ArcBall.h
Util/AutoLogTime.cpp
Util/AutoLogTime.h
Util/AutoDirectoryRestoreFileDialog.h
Util/AutoDirectoryRestoreFileDialog.cpp
Util/CryMemFile.h
Util/CubemapUtils.cpp
Util/CubemapUtils.h
Util/DynamicArray2D.cpp
Util/DynamicArray2D.h
Util/EditorAutoLevelLoadTest.cpp
@@ -833,17 +822,11 @@ set(FILES
Util/ImageASC.h
Util/ImageBT.cpp
Util/ImageBT.h
Util/Image_DXTC.cpp
Util/Image_DXTC.h
Util/ImageGif.cpp
Util/ImageGif.h
Util/ImageTIF.cpp
Util/ImageTIF.h
Util/Math.h
Util/Ruler.cpp
Util/RulerPoint.cpp
Util/Ruler.h
Util/RulerPoint.h
Util/UIEnumerations.cpp
Util/UIEnumerations.h
WelcomeScreen/WelcomeScreenDialog.h
@@ -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 "ComponentEntityEditorPlugin_precompiled.h"
#include "ComponentEntityDebugPrinter.h"
#include <AzFramework/Entity/GameEntityContextBus.h>
#include <AzToolsFramework/Entity/EditorEntityContextBus.h>
ComponentEntityDebugPrinter::ComponentEntityDebugPrinter()
{
AZ::TickBus::Handler::BusConnect();
}
void ComponentEntityDebugPrinter::OnTick(float /*deltaTime*/, AZ::ScriptTimePoint /*time*/)
{
if (!GetIEditor()->GetRenderer())
{
return;
}
ICVar* displayInfo = GetIEditor()->GetSystem()->GetIConsole()->GetCVar("r_DisplayInfo");
if (!displayInfo || displayInfo->GetIVal() == 0)
{
return;
}
float x = 2.f;
float y = 2.f;
SDrawTextInfo textInfo;
textInfo.xscale = 1.25f;
textInfo.yscale = textInfo.xscale;
textInfo.flags = eDrawText_2D | eDrawText_FixedSize | eDrawText_800x600 | eDrawText_Monospace;
// Figure out whether we're querying the Game or Editor entity context
AzFramework::EntityContextId entityContextId = AzFramework::EntityContextId::CreateNull();
if (GetIEditor()->IsInGameMode())
{
AzFramework::GameEntityContextRequestBus::BroadcastResult(entityContextId, &AzFramework::GameEntityContextRequestBus::Events::GetGameEntityContextId);
}
else
{
AzToolsFramework::EditorEntityContextRequestBus::BroadcastResult(entityContextId, &AzToolsFramework::EditorEntityContextRequestBus::Events::GetEditorEntityContextId);
}
if (entityContextId.IsNull())
{
return;
}
// Print the number of entities in the level
AZ::SliceComponent* rootSlice = nullptr;
AzFramework::SliceEntityOwnershipServiceRequestBus::EventResult(rootSlice, entityContextId,
&AzFramework::SliceEntityOwnershipServiceRequestBus::Events::GetRootSlice);
if (rootSlice)
{
size_t numEntities = rootSlice->GetInstantiatedEntityCount();
if (numEntities > 0)
{
GetIEditor()->GetRenderer()->DrawTextQueued(Vec3(x, y, 0), textInfo, AZStd::string::format("Entities: %zu", numEntities).c_str());
}
}
}
@@ -1,32 +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/Component/TickBus.h>
/**
* Prints debug statistics about Component Entities to screen
*/
class ComponentEntityDebugPrinter
: private AZ::TickBus::Handler
{
public:
AZ_CLASS_ALLOCATOR(ComponentEntityDebugPrinter, AZ::SystemAllocator, 0);
ComponentEntityDebugPrinter();
private:
//////////////////////////////////////////////////////////////////////////
// TickBus
void OnTick(float deltaTime, AZ::ScriptTimePoint time) override;
//////////////////////////////////////////////////////////////////////////
};
@@ -915,14 +915,6 @@ void CComponentEntityObject::Display(DisplayContext& dc)
m_entityId, &AzFramework::EntityDebugDisplayEvents::DisplayEntityViewport,
AzFramework::ViewportInfo{ dc.GetView()->asCViewport()->GetViewportId() },
*debugDisplay);
if (showIcons)
{
if (!displaySelectionHelper && !IsSelected())
{
m_entityIconVisible = DisplayEntityIcon(dc, *debugDisplay);
}
}
}
}
}
@@ -984,38 +976,6 @@ void CComponentEntityObject::OnContextMenu(QMenu* /*pMenu*/)
// Deliberately bypass the base class implementation (CEntityObject::OnContextMenu()).
}
bool CComponentEntityObject::DisplayEntityIcon(
DisplayContext& displayContext, AzFramework::DebugDisplayRequests& debugDisplay)
{
if (!m_hasIcon)
{
return false;
}
const QPoint entityScreenPos = displayContext.GetView()->WorldToView(GetWorldPos());
const Vec3 worldPos = GetWorldPos();
const CCamera& camera = gEnv->pRenderer->GetCamera();
const Vec3 cameraToEntity = (worldPos - camera.GetMatrix().GetTranslation());
const float distSq = cameraToEntity.GetLengthSquared();
if (distSq > square(s_kIconMaxWorldDist))
{
return false;
}
// Draw component icons on top of meshes (no depth testing)
int iconFlags = (int) DisplayContext::ETextureIconFlags::TEXICON_ON_TOP;
SetDrawTextureIconProperties(displayContext, worldPos, 1.0f, iconFlags);
const float iconScale = s_kIconMinScale + (s_kIconMaxScale - s_kIconMinScale) * (1.0f - clamp_tpl(max(0.0f, sqrt_tpl(distSq) - s_kIconCloseDist) / s_kIconFarDist, 0.0f, 1.0f));
const float worldDistToScreenScaleFraction = 0.045f;
const float screenScale = displayContext.GetView()->GetScreenScaleFactor(GetWorldPos()) * worldDistToScreenScaleFraction;
debugDisplay.DrawTextureLabel(m_iconTexture, LYVec3ToAZVec3(worldPos), s_kIconSize * iconScale, s_kIconSize * iconScale, GetTextureIconFlags());
return true;
}
void CComponentEntityObject::SetupEntityIcon()
{
bool hideIconInViewport = false;
@@ -1031,8 +991,9 @@ void CComponentEntityObject::SetupEntityIcon()
{
m_hasIcon = true;
int textureId = GetIEditor()->GetIconManager()->GetIconTexture(m_icon.c_str());
m_iconTexture = GetIEditor()->GetRenderer() ? GetIEditor()->GetRenderer()->EF_GetTextureByID(textureId) : nullptr;
// ToDo: Get from Atom?
// int textureId = GetIEditor()->GetIconManager()->GetIconTexture(m_icon.c_str());
m_iconTexture = nullptr;
}
}
}
@@ -59,7 +59,6 @@
#include <MathConversion.h>
#include "Objects/ComponentEntityObject.h"
#include "ComponentEntityDebugPrinter.h"
#include "ISourceControl.h"
#include "UI/QComponentEntityEditorMainWindow.h"
@@ -72,7 +71,6 @@
#include <Editor/CryEditDoc.h>
#include <Editor/GameEngine.h>
#include <Editor/DisplaySettings.h>
#include <Editor/Util/CubemapUtils.h>
#include <Editor/IconManager.h>
#include <Editor/Settings.h>
#include <Editor/StringDlg.h>
@@ -141,7 +139,6 @@ SandboxIntegrationManager::SandboxIntegrationManager()
, m_startedUndoRecordingNestingLevel(0)
, m_dc(nullptr)
, m_notificationWindowManager(new AzToolsFramework::SliceOverridesNotificationWindowManager())
, m_entityDebugPrinter(aznew ComponentEntityDebugPrinter())
{
// Required to receive events from the Cry Engine undo system
GetIEditor()->GetUndoManager()->AddListener(this);
@@ -1998,92 +1995,6 @@ void SandboxIntegrationManager::BrowseForAssets(AssetSelectionModel& selection)
AssetBrowserComponentRequestBus::Broadcast(&AssetBrowserComponentRequests::PickAssets, selection, GetMainWindow());
}
void SandboxIntegrationManager::GenerateCubemapForEntity(AZ::EntityId entityId, AZStd::string* cubemapOutputPath, bool hideEntity)
{
GenerateCubemapWithIDForEntity(entityId, AZ::Uuid::CreateNull(), cubemapOutputPath, hideEntity, false);
}
void SandboxIntegrationManager::GenerateCubemapWithIDForEntity(AZ::EntityId entityId, AZ::Uuid cubemapId,
AZStd::string* cubemapOutputPath, bool hideEntity, bool hasCubemapId)
{
AZ::u32 resolution = 0;
EBUS_EVENT_ID_RESULT(resolution, entityId, LmbrCentral::EditorLightComponentRequestBus, GetCubemapResolution);
if (resolution > 0)
{
CComponentEntityObject* componentEntity = CComponentEntityObject::FindObjectForEntity(entityId);
if (componentEntity)
{
QString levelfolder = GetIEditor()->GetGameEngine()->GetLevelPath();
QString levelname = Path::GetFile(levelfolder).toLower();
QString fullGameFolder = QString(Path::GetEditingGameDataFolder().c_str());
QString texturename;
if (hasCubemapId)
{
texturename = QStringLiteral("%1_cm.tif").arg(cubemapId.ToString<QString>(false, false));
}
else
{
texturename = QStringLiteral("%1_cm.tif").arg(static_cast<qulonglong>(componentEntity->GetAssociatedEntityId()));
}
texturename = texturename.toLower();
QString fullFolder = Path::SubDirectoryCaseInsensitive(fullGameFolder, {"textures", "cubemaps", levelname});
QString fullFilename = QDir(fullFolder).absoluteFilePath(texturename);
QString relFilename = QDir(fullGameFolder).relativeFilePath(fullFilename);
bool directlyExists = CFileUtil::CreateDirectory(fullFolder.toUtf8().data());
if (!directlyExists)
{
QMessageBox::warning(GetMainWindow(), QObject::tr("Cubemap Generation Failed"), QString(QObject::tr("Failed to create destination path '%1'")).arg(fullFolder));
return;
}
if (CubemapUtils::GenCubemapWithObjectPathAndSize(fullFilename, componentEntity, static_cast<int>(resolution), hideEntity))
{
AZStd::string assetPath = relFilename.toUtf8().data();
AzFramework::StringFunc::Path::ReplaceExtension(assetPath, ".dds");
EBUS_EVENT_ID(entityId, LmbrCentral::EditorLightComponentRequestBus, SetCubemap, assetPath);
if (cubemapOutputPath)
{
*cubemapOutputPath = AZStd::move(assetPath);
}
}
else
{
QMessageBox::warning(GetMainWindow(), QObject::tr("Cubemap Generation Failed"), QObject::tr("Unspecified error"));
}
}
}
}
void SandboxIntegrationManager::GenerateAllCubemaps()
{
AZStd::string cubemapOutputPath;
std::vector<CBaseObject*> results;
results.reserve(128);
GetIEditor()->GetObjectManager()->FindObjectsOfType(OBJTYPE_AZENTITY, results);
for (std::vector<CBaseObject*>::iterator end = results.end(), item = results.begin(); item != end; ++item)
{
CComponentEntityObject* componentEntity = static_cast<CComponentEntityObject*>(*item);
//check if it's customized cubemap, only generate it if it's not.
bool isCustomizedCubemap = true;
EBUS_EVENT_ID_RESULT(isCustomizedCubemap, componentEntity->GetAssociatedEntityId(), LmbrCentral::EditorLightComponentRequestBus, UseCustomizedCubemap);
if (isCustomizedCubemap)
{
continue;
}
GenerateCubemapForEntity(componentEntity->GetAssociatedEntityId(), nullptr, true);
}
}
void SandboxIntegrationManager::SetColor(float r, float g, float b, float a)
{
if (m_dc)
@@ -2575,19 +2486,6 @@ void SandboxIntegrationManager::Draw2dTextLabel(float x, float y, float size, co
}
}
void SandboxIntegrationManager::DrawTextOn2DBox(const AZ::Vector3& pos, const char* text, float textScale, const AZ::Vector4& textColor, const AZ::Vector4& textBackColor)
{
if (m_dc)
{
m_dc->DrawTextOn2DBox(
AZVec3ToLYVec3(pos),
text,
textScale,
ColorF(AZVec3ToLYVec3(textColor.GetAsVector3()), textColor.GetW()),
ColorF(AZVec3ToLYVec3(textBackColor.GetAsVector3()), textBackColor.GetW()));
}
}
void SandboxIntegrationManager::DrawTextureLabel(ITexture* texture, const AZ::Vector3& pos, float sizeX, float sizeY, int texIconFlags)
{
if (m_dc)
@@ -2614,8 +2512,12 @@ void SandboxIntegrationManager::DrawTextureLabel(ITexture* texture, const AZ::Ve
void SandboxIntegrationManager::DrawTextureLabel(int textureId, const AZ::Vector3& pos, float sizeX, float sizeY, int texIconFlags)
{
ITexture* texture = GetIEditor()->GetRenderer()->EF_GetTextureByID(textureId);
DrawTextureLabel(texture, pos, sizeX, sizeY, texIconFlags);
// ToDo: With Atom?
AZ_UNUSED(textureId);
AZ_UNUSED(pos);
AZ_UNUSED(sizeX);
AZ_UNUSED(sizeY);
AZ_UNUSED(texIconFlags);
}
void SandboxIntegrationManager::SetLineWidth(float width)
@@ -143,9 +143,6 @@ private:
QDockWidget* InstanceViewPane(const char* paneName) override;
void CloseViewPane(const char* paneName) override;
void BrowseForAssets(AzToolsFramework::AssetBrowser::AssetSelectionModel& selection) override;
void GenerateAllCubemaps() override;
void GenerateCubemapForEntity(AZ::EntityId entityId, AZStd::string* cubemapOutputPath, bool hideEntity) override;
void GenerateCubemapWithIDForEntity(AZ::EntityId entityId, AZ::Uuid cubemapId, AZStd::string* cubemapOutputPath, bool hideEntity, bool hasCubemapId) override;
void HandleObjectModeSelection(const AZ::Vector2& point, int flags, bool& handled) override;
void UpdateObjectModeCursor(AZ::u32& cursorId, AZStd::string& cursorStr) override;
void CreateEditorRepresentation(AZ::Entity* entity) override;
@@ -249,7 +246,6 @@ private:
void DrawArrow(const AZ::Vector3& src, const AZ::Vector3& trg, float fHeadScale, bool b2SidedArrow) override;
void DrawTextLabel(const AZ::Vector3& pos, float size, const char* text, const bool bCenter, int srcOffsetX, int scrOffsetY) override;
void Draw2dTextLabel(float x, float y, float size, const char* text, bool bCenter) override;
void DrawTextOn2DBox(const AZ::Vector3& pos, const char* text, float textScale, const AZ::Vector4& TextColor, const AZ::Vector4& TextBackColor) override;
void DrawTextureLabel(ITexture* texture, const AZ::Vector3& pos, float sizeX, float sizeY, int texIconFlags) override;
void DrawTextureLabel(int textureId, const AZ::Vector3& pos, float sizeX, float sizeY, int texIconFlags) override;
void SetLineWidth(float width) override;
@@ -365,8 +361,6 @@ private:
DisplayContext* m_dc;
AZStd::unique_ptr<class ComponentEntityDebugPrinter> m_entityDebugPrinter;
AZStd::vector<SliceAssetDeletionErrorInfo> m_sliceAssetDeletionErrorRestoreInfos;
// Tracks new entities that have not yet been saved.
@@ -17,8 +17,6 @@ set(FILES
SandboxIntegration.cpp
ComponentEntityEditorPlugin_precompiled.cpp
ComponentEntityEditorPlugin_precompiled.h
ComponentEntityDebugPrinter.h
ComponentEntityDebugPrinter.cpp
UI/ComponentEntityEditorOutlinerWindow.qrc
UI/QComponentEntityEditorMainWindow.h
UI/QComponentEntityEditorMainWindow.cpp
File diff suppressed because it is too large Load Diff
@@ -1,336 +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_EDITORCOMMON_MANIPSCENE_H
#define CRYINCLUDE_EDITORCOMMON_MANIPSCENE_H
#pragma once
#include <platform.h>
#include <Cry_Geo.h>
#include <Cry_Color.h>
#include "EditorCommonAPI.h"
#include <QObject>
#include "QViewportConsumer.h"
namespace Serialization {
class IArchive;
}
class CAxisHelper;
// Manip is a set of reusable utilities for creating interactive 3d scene that
// can be manipulated with gizmos.
namespace Manip
{
using std::unique_ptr;
using std::set;
using std::vector;
enum EElementCaps
{
CAP_SELECT = 1 << 0,
CAP_HIDE = 1 << 1,
CAP_MOVE = 1 << 2,
CAP_ROTATE = 1 << 3,
CAP_SCALE = 1 << 4,
CAP_DELETE = 1 << 5,
};
enum EElementShape
{
SHAPE_AXES,
SHAPE_BOX
};
enum EElementAction
{
ACTION_NONE,
ACTION_DELETE,
ACTION_HIDE,
ACTION_UNHIDE
};
enum EElementColorGroup
{
ELEMENT_COLOR_PROXY,
ELEMENT_COLOR_CLOTH
};
struct SElementPlacement
{
QuatT transform;
QuatT startTransform;
Vec3 center;
Vec3 size;
SElementPlacement()
: transform(IDENTITY)
, startTransform(IDENTITY)
, size(1.0f, 1.0f, 1.0f)
, center(0.0f, 0.0f, 0.0f)
{}
void Serialize(Serialization::IArchive& ar);
};
typedef uint64 ElementId;
struct SSpaceAndIndex
{
int m_space;
int m_jointCRC32;
int m_attachmentCRC32;
SSpaceAndIndex()
{
m_space = -1;
m_jointCRC32 = -1;
m_attachmentCRC32 = -1;
};
};
struct SElement
{
int id;
union
{
int originalId;
const void* originalHandle;
};
int layer;
SElementPlacement placement;
int caps;
EElementAction action;
EElementShape shape;
EElementColorGroup colorGroup;
SSpaceAndIndex parentSpaceIndex;
SSpaceAndIndex parentOrientationSpaceIndex;
QuatT parentSpaceConcatenation;
int mousePickPriority;
bool hidden;
bool changed;
bool alwaysXRay;
SElement()
: id()
, layer(0)
, originalHandle(0)
, action(ACTION_NONE)
, shape(SHAPE_AXES)
, hidden(false)
, changed(false)
, colorGroup(ELEMENT_COLOR_PROXY)
, mousePickPriority(0)
, alwaysXRay(false)
, parentSpaceIndex()
, parentOrientationSpaceIndex()
, parentSpaceConcatenation(IDENTITY)
{
}
};
typedef std::vector<SElement> SElements;
struct SElementData {};
struct IMouseDragHandler
{
virtual ~IMouseDragHandler() = default;
virtual bool Begin(const SMouseEvent& ev, Vec3 hitPoint) = 0;
virtual void Update(const SMouseEvent& ev) = 0;
virtual void Render([[maybe_unused]] const SRenderContext& rc) {}
virtual void End(const SMouseEvent& ev) = 0;
};
struct SSelectionSet
{
SSelectionSet() {}
SSelectionSet(ElementId id) { items.push_back(id); }
void Clear();
void Add(ElementId elementId)
{
items.erase(std::remove(items.begin(), items.end(), elementId), items.end());
items.push_back(elementId);
std::sort(items.begin(), items.end());
}
void Remove(int elementId);
bool IsEmpty() const{ return items.empty(); }
bool Contains(int id) const{ return std::find(items.begin(), items.end(), id) != items.end(); }
size_t Size() const{ return items.size(); }
bool operator==(const SSelectionSet& rhs) const
{
return items == rhs.items;
}
bool operator!=(const SSelectionSet& rhs) const{ return !operator==(rhs); }
std::vector<ElementId> items;
};
struct ICommand {};
struct IElementTracer
{
virtual bool HitRay(Vec3* intersectionPoint, const Ray& ray, const SElement& element) const = 0;
};
struct IElementDrawer
{
virtual bool Draw(const SElement& element);
};
enum ETransformationSpace
{
SPACE_WORLD,
SPACE_LOCAL
};
enum ETransformationMode
{
MODE_TRANSLATE,
MODE_ROTATE,
MODE_SCALE
};
struct SLookSettings
{
ColorB proxyColor;
ColorB proxySelectionColor;
ColorB proxyHighlightColor;
ColorB clothProxyColor;
ColorB jointColor;
ColorB jointHighlightColor;
ColorB jointSelectionColor;
SLookSettings()
: proxyColor(126, 159, 243, 128)
, proxySelectionColor(255, 255, 255, 128)
, proxyHighlightColor(233, 255, 122, 128)
, clothProxyColor(243, 159, 126, 128)
, jointColor(0, 249, 48, 255)
, jointHighlightColor(255, 248, 0, 128)
, jointSelectionColor(255, 255, 255, 128)
{
}
};
struct ISpaceProvider
{
virtual ~ISpaceProvider() = default;
virtual SSpaceAndIndex FindSpaceIndexByName(int spaceType, const char* name, int parentsUp) const = 0;
virtual QuatT GetTransform(const SSpaceAndIndex& index) const = 0;
};
AZ_PUSH_DISABLE_DLL_EXPORT_BASECLASS_WARNING
class EDITOR_COMMON_API CScene
: public QObject
, public QViewportConsumer
{
AZ_POP_DISABLE_DLL_EXPORT_BASECLASS_WARNING
Q_OBJECT
public:
CScene();
~CScene();
void OnViewportKey(const SKeyEvent& ev) override;
bool ProcessesViewportKey(const QKeySequence& key) override;
void OnViewportMouse(const SMouseEvent& ev) override;
void OnViewportRender(const SRenderContext& rc) override;
void SetTransformationMode(ETransformationMode mode);
ETransformationMode TransformationMode() const;
void SetTransformationSpace(ETransformationSpace space);
ETransformationSpace TransformationSpace() const { return m_transformationSpace; }
void SetVisibleLayerMask(unsigned int layerMask);
unsigned int VisibleLayerMask() const { return m_visibleLayerMask; }
bool IsLayerVisible(int layer) const;
void Clear();
void ClearLayer(int layer);
void AddElement(const SElement& element);
void AddElement(const SElement& element, ElementId id);
void ApplyToAll(EElementAction);
void ApplyToSelection(EElementAction);
void SetSpaceProvider(ISpaceProvider* spaceProvider);
ISpaceProvider* SpaceProvider() const{ return m_spaceProvider; }
QuatT GetParentSpace(const SElement& e) const;
QuatT ElementToWorldSpace(const SElement& e) const;
void WorldSpaceToElement(SElement* e, const QuatT& worldSpaceTransform);
void SetCustomTracer(IElementTracer* tracer);
const SElements& Elements() const{ return m_elements; }
SElements& Elements() { return m_elements; }
void GetSelectedElements(SElements* elements) const;
const SSelectionSet& Selection() const{ return m_selection; }
void SetSelection(const SSelectionSet& selection);
void AddToSelection(const SSelectionSet& selection);
void AddToSelection(ElementId elementId);
bool SelectionCanBeMoved() const;
bool SelectionCanBeRotated() const;
QuatT GetSelectionTransform(ETransformationSpace space) const;
bool SetSelectionTransform(ETransformationSpace space, const QuatT& newTransform);
void Serialize(Serialization::IArchive& ar);
signals:
void SignalUndo();
void SignalRedo();
void SignalPushUndo(const char* description, ICommand* cause);
void SignalElementsChanged(unsigned int layerBits);
void SignalElementContinousChange(unsigned int layerBits);
void SignalPropertiesChanged();
void SignalRenderElements(const SElements& elements, const SRenderContext& rc);
void SignalSelectionChanged();
void SignalManipulationModeChanged();
private:
void UpdateElements(const SElements& elements);
bool SetSelectionTransform(const Matrix34& newMatrix);
Matrix34 GetSelectionTransform() const;
int GetSelectionCaps() const;
Vec3 GetSelectionSize() const;
bool SetSelectionSize(const Vec3& size);
void OnMouseMove(const SMouseEvent& ev);
struct SBlockSelectHandler;
struct SMoveHandler;
struct SRotationHandler;
struct SScalingHandler;
struct STransformBox;
IElementTracer* m_customTracer;
IElementDrawer* m_customDrawer;
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
SSelectionSet m_selection;
unique_ptr<IMouseDragHandler> m_mouseDragHandler;
ISpaceProvider* m_spaceProvider;
unique_ptr<CAxisHelper> m_axisHelper;
SElements m_elements;
std::vector<ElementId> m_lastIdByLayer;
ETransformationMode m_transformationMode;
ETransformationSpace m_transformationSpace;
int m_highlightItem;
unsigned int m_visibleLayerMask;
bool m_showGizmo;
SLookSettings m_lookSettings;
int m_highlightedItem;
QuatT m_temporaryLocalDelta;
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
};
}
#endif // CRYINCLUDE_EDITORCOMMON_MANIPSCENE_H
+5 -203
View File
@@ -145,7 +145,6 @@ QViewport::QViewport(QWidget* parent, StartupMode startupMode)
void QViewport::Startup()
{
m_frameTimer = new QElapsedTimer();
CreateRenderContext();
m_camera.reset(new CCamera());
ResetCamera();
@@ -162,8 +161,6 @@ void QViewport::Startup()
QViewport::~QViewport()
{
DestroyRenderContext();
m_viewportRequests.reset();
}
@@ -180,51 +177,14 @@ void QViewport::UpdateBackgroundColor()
bool QViewport::ScreenToWorldRay(Ray* ray, int x, int y)
{
if (!GetIEditor()->GetEnv()->pRenderer)
{
return false;
}
SetCurrentContext();
Vec3 pos0, pos1;
float wx, wy, wz;
if (!GetIEditor()->GetEnv()->pRenderer->UnProjectFromScreen(float(x), float(m_height - y), 0, &wx, &wy, &wz))
{
RestorePreviousContext();
return false;
}
pos0(wx, wy, wz);
if (!GetIEditor()->GetEnv()->pRenderer->UnProjectFromScreen(float(x), float(m_height - y), 1, &wx, &wy, &wz))
{
RestorePreviousContext();
return false;
}
pos1(wx, wy, wz);
RestorePreviousContext();
Vec3 v = (pos1 - pos0);
v = v.GetNormalized();
ray->origin = pos0;
ray->direction = v;
return true;
AZ_UNUSED(ray);
AZ_UNUSED(x);
AZ_UNUSED(y);
return false;
}
QPoint QViewport::ProjectToScreen(const Vec3& wp)
QPoint QViewport::ProjectToScreen(const Vec3&)
{
float x, y, z;
SetCurrentContext();
GetIEditor()->GetEnv()->pRenderer->ProjectToScreen(wp.x, wp.y, wp.z, &x, &y, &z);
if (_finite(x) || _finite(y))
{
RestorePreviousContext();
return QPoint(int((x / 100.0) * Width()), int((y / 100.0) * Height()));
}
RestorePreviousContext();
return QPoint(0, 0);
}
@@ -245,105 +205,6 @@ int QViewport::Height() const
return rect().height();
}
bool QViewport::CreateRenderContext()
{
if (m_creatingRenderContext || !isVisible())
{
return false;
}
HWND windowHandle = reinterpret_cast<HWND>(QWidget::winId());
if( m_renderContextCreated && windowHandle == m_lastHwnd)
{
// the hwnd has not changed, no need to destroy and recreate context (and swap chain etc)
return false;
}
m_creatingRenderContext = true;
DestroyRenderContext();
if (windowHandle && GetIEditor()->GetEnv()->pRenderer && !m_renderContextCreated)
{
m_renderContextCreated = true;
m_viewportRequests.get()->BusConnect(windowHandle);
AzFramework::WindowSystemNotificationBus::Broadcast(&AzFramework::WindowSystemNotificationBus::Handler::OnWindowCreated, windowHandle);
m_lastHwnd = windowHandle;
StorePreviousContext();
GetIEditor()->GetEnv()->pRenderer->CreateContext(windowHandle);
RestorePreviousContext();
m_creatingRenderContext = false;
return true;
}
m_creatingRenderContext = false;
return false;
}
void QViewport::DestroyRenderContext()
{
if (GetIEditor()->GetEnv()->pRenderer && m_renderContextCreated)
{
HWND windowHandle = reinterpret_cast<HWND>(QWidget::winId());
if (windowHandle != GetIEditor()->GetEnv()->pRenderer->GetHWND())
{
GetIEditor()->GetEnv()->pRenderer->DeleteContext(windowHandle);
}
m_renderContextCreated = false;
AzFramework::WindowNotificationBus::Event(windowHandle, &AzFramework::WindowNotificationBus::Handler::OnWindowClosed);
m_viewportRequests.get()->BusDisconnect();
m_lastHwnd = 0;
}
}
void QViewport::StorePreviousContext()
{
SPreviousContext previous;
previous.width = GetIEditor()->GetEnv()->pRenderer->GetWidth();
previous.height = GetIEditor()->GetEnv()->pRenderer->GetHeight();
previous.window = reinterpret_cast<HWND>(GetIEditor()->GetEnv()->pRenderer->GetCurrentContextHWND());
previous.renderCamera = GetIEditor()->GetEnv()->pRenderer->GetCamera();
previous.systemCamera = GetISystem()->GetViewCamera();
previous.isMainViewport = GetIEditor()->GetEnv()->pRenderer->IsCurrentContextMainVP();
m_previousContexts.push_back(previous);
}
void QViewport::SetCurrentContext()
{
StorePreviousContext();
if (m_camera.get() == 0)
{
return;
}
HWND windowHandle = reinterpret_cast<HWND>(QWidget::winId());
GetIEditor()->GetEnv()->pRenderer->SetCurrentContext(windowHandle);
GetIEditor()->GetEnv()->pRenderer->ChangeViewport(0, 0, m_width, m_height);
GetIEditor()->GetEnv()->pRenderer->SetCamera(*m_camera);
GetIEditor()->GetEnv()->pSystem->SetViewCamera(*m_camera);
}
void QViewport::RestorePreviousContext()
{
if (m_previousContexts.empty())
{
assert(0);
return;
}
SPreviousContext x = m_previousContexts.back();
m_previousContexts.pop_back();
GetIEditor()->GetEnv()->pRenderer->SetCurrentContext(x.window);
GetIEditor()->GetEnv()->pRenderer->ChangeViewport(0, 0, x.width, x.height, x.isMainViewport);
GetIEditor()->GetEnv()->pRenderer->SetCamera(x.renderCamera);
GetIEditor()->GetEnv()->pSystem->SetViewCamera(x.systemCamera);
}
void QViewport::Serialize(IArchive& ar)
{
if (!ar.IsEdit())
@@ -720,45 +581,6 @@ void QViewport::RenderInternal()
{
}
void QViewport::GetImageOffscreen(CImageEx& image, const QSize& customSize)
{
if ((m_width == 0) || (m_height == 0))
{
// This can occur, for example, if the material editor window is sized to zero OR
// if it is docked as a tab in another view pane window and is not the active tab when the editor starts.
image.Allocate(1, 1);
image.Clear();
return;
}
IRenderer* renderer = GetIEditor()->GetRenderer();
renderer->EnableSwapBuffers(false);
RenderInternal();
renderer->EnableSwapBuffers(true);
int w;
int h;
if (customSize.isValid())
{
w = customSize.width();
h = customSize.height();
}
else
{
w = width();
h = height();
}
image.Allocate(w, h);
// the renderer will read the frame buffer of the current render context, so we need to set ours as the current before we execute this command.
SetCurrentContext();
renderer->ReadFrameBufferFast(image.GetData(), w, h);
RestorePreviousContext();
}
void QViewport::SetWindowTitle(const AZStd::string& title)
{
// Do not support the WindowRequestBus changing the editor window title
@@ -1022,12 +844,6 @@ void QViewport::resizeEvent(QResizeEvent* ev)
m_width = cx;
m_height = cy;
// We queue the window resize event in case the windows is hidden.
// If the QWidget is hidden, the native windows does not resize and the
// swapchain may have the incorrect size. We need to wait
// until it's visible to trigger the resize event.
m_resizeWindowEvent = true;
GetIEditor()->GetEnv()->pSystem->GetISystemEventDispatcher()->OnSystemEvent(ESYSTEM_EVENT_RESIZE, cx, cy);
SignalUpdate();
Update();
@@ -1035,18 +851,9 @@ void QViewport::resizeEvent(QResizeEvent* ev)
void QViewport::showEvent(QShowEvent* ev)
{
// force a context create once we're shown
// This must be queued, as the showEvent is sent before the widget is actually shown, not after
QMetaObject::invokeMethod(this, "ForceRebuildRenderContext", Qt::QueuedConnection);
QWidget::showEvent(ev);
}
void QViewport::ForceRebuildRenderContext()
{
CreateRenderContext();
}
void QViewport::moveEvent(QMoveEvent* ev)
{
QWidget::moveEvent(ev);
@@ -1058,11 +865,6 @@ bool QViewport::event(QEvent* ev)
{
bool result = QWidget::event(ev);
if (ev->type() == QEvent::WinIdChange)
{
CreateRenderContext();
}
if (ev->type() == QEvent::ShortcutOverride)
{
// When a shortcut is matched, Qt's event processing sends out a shortcut override event
@@ -104,7 +104,6 @@ public:
int Width() const;
int Height() const;
void SetSize(const QSize& size);
void GetImageOffscreen(CImageEx& image, const QSize& customSize);
// WindowRequestBus::Handler... (handler moved to cpp to resolve link issues in unity builds)
void SetWindowTitle(const AZStd::string& title);
@@ -119,7 +118,6 @@ public slots:
void Update();
protected slots:
void RenderInternal();
void ForceRebuildRenderContext();
signals:
void SignalPreRender(const SRenderContext&);
void SignalRender(const SRenderContext&);
@@ -146,12 +144,6 @@ protected:
private:
struct SPrivate;
bool CreateRenderContext();
void DestroyRenderContext();
void StorePreviousContext();
protected:
void SetCurrentContext();
void RestorePreviousContext();
private:
void UpdateBackgroundColor();
@@ -198,6 +190,4 @@ private:
std::vector<QViewportConsumer*> m_consumers;
AZStd::unique_ptr<QViewportRequests> m_viewportRequests;
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
HWND m_lastHwnd = 0;
bool m_resizeWindowEvent = false;
};
@@ -15,8 +15,6 @@ set(FILES
EditorCommon.rc
EditorCommon.qrc
EditorCommonAPI.h
ManipScene.cpp
ManipScene.h
moc.cpp
QViewportConsumer.h
TimelineContent.h
@@ -13,11 +13,9 @@
#include "EditorCommon_precompiled.h"
#include <QViewport.h>
#include <ManipScene.h>
#include <Timeline.h>
#include <CurveEditor.h>
#include <moc_QViewport.cpp>
#include <moc_ManipScene.cpp>
#include <moc_Timeline.cpp>
#include <moc_CurveEditor.cpp>