Merge branch 'main' into LYN-1767-AB
This commit is contained in:
@@ -1,5 +0,0 @@
|
||||
#Ignore these directories
|
||||
SDKs
|
||||
|
||||
#ignore these files
|
||||
*.user
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -674,9 +660,7 @@ void Q2DViewport::Draw(DisplayContext& dc)
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Q2DViewport::DrawGrid(DisplayContext& dc, bool bNoXNumbers)
|
||||
{
|
||||
CGrid* pGrid = GetIEditor()->GetViewManager()->GetGrid();
|
||||
float gridSize = pGrid->size;
|
||||
|
||||
float gridSize = 1.0f;
|
||||
if (gridSize < 0.00001f)
|
||||
{
|
||||
return;
|
||||
@@ -707,8 +691,6 @@ void Q2DViewport::DrawGrid(DisplayContext& dc, bool bNoXNumbers)
|
||||
pixelsPerGrid = gridSize * fScale;
|
||||
while (pixelsPerGrid <= 5 && griditers++ < 20)
|
||||
{
|
||||
m_fGridZoom *= pGrid->majorLine;
|
||||
gridSize = gridSize * pGrid->majorLine;
|
||||
pixelsPerGrid = gridSize * fScale;
|
||||
}
|
||||
}
|
||||
@@ -757,7 +739,7 @@ void Q2DViewport::DrawGrid(DisplayContext& dc, bool bNoXNumbers)
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Draw Major grid lines.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
gridSize = gridSize * pGrid->majorLine;
|
||||
gridSize = gridSize * 1.0f;
|
||||
|
||||
if (m_bAutoAdjustGrids)
|
||||
{
|
||||
|
||||
@@ -159,7 +159,6 @@ protected:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Variables.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
IRenderer* m_renderer;
|
||||
|
||||
//! XY/XZ/YZ mode of this 2D viewport.
|
||||
EViewportType m_viewType;
|
||||
|
||||
@@ -169,6 +169,13 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename Fn>
|
||||
ActionWrapper& RegisterUpdateCallback(Fn&& fn)
|
||||
{
|
||||
m_actionManager->RegisterUpdateCallback(m_action->data().toInt(), AZStd::forward<Fn>(fn));
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
friend ActionManager;
|
||||
friend DynamicMenu;
|
||||
@@ -315,11 +322,17 @@ public:
|
||||
void DetachOverride() override;
|
||||
|
||||
template<typename T>
|
||||
void RegisterUpdateCallback(int id, T* object, void (T::* method)(QAction*))
|
||||
void RegisterUpdateCallback(int id, T* object, void (T::*method)(QAction*))
|
||||
{
|
||||
Q_ASSERT(m_actions.contains(id));
|
||||
auto f = std::bind(method, object, m_actions.value(id));
|
||||
m_updateCallbacks[id] = f;
|
||||
m_updateCallbacks[id] = [action = m_actions.value(id), object, method] { AZStd::invoke(method, object, action); };
|
||||
}
|
||||
|
||||
template<typename Fn>
|
||||
void RegisterUpdateCallback(int id, Fn&& fn)
|
||||
{
|
||||
Q_ASSERT(m_actions.contains(id));
|
||||
m_updateCallbacks[id] = [action = m_actions.value(id), fn] { fn(action); };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
||||
@@ -1,629 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#include "EditorDefs.h"
|
||||
|
||||
#include "BackgroundScheduleManager.h"
|
||||
|
||||
namespace BackgroundScheduleManager
|
||||
{
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
CScheduleItem::CScheduleItem(const char* szName)
|
||||
: m_name(szName)
|
||||
, m_refCount(1)
|
||||
, m_state(eScheduleItemState_Pending)
|
||||
{
|
||||
}
|
||||
|
||||
CScheduleItem::~CScheduleItem()
|
||||
{
|
||||
CRY_ASSERT(m_refCount == 0);
|
||||
|
||||
for (TWorkItems::const_iterator it = m_workItems.begin();
|
||||
it != m_workItems.end(); ++it)
|
||||
{
|
||||
(*it)->Release();
|
||||
}
|
||||
}
|
||||
|
||||
const char* CScheduleItem::GetDescription() const
|
||||
{
|
||||
return m_name.c_str();
|
||||
}
|
||||
|
||||
EScheduleItemState CScheduleItem::GetState() const
|
||||
{
|
||||
return m_state;
|
||||
}
|
||||
|
||||
const float CScheduleItem::GetProgress() const
|
||||
{
|
||||
if (m_workItems.empty())
|
||||
{
|
||||
return 1.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
float totalProgress = 0.0f;
|
||||
|
||||
for (TWorkItems::const_iterator it = m_workItems.begin();
|
||||
it != m_workItems.end(); ++it)
|
||||
{
|
||||
totalProgress += (*it)->GetProgress();
|
||||
}
|
||||
|
||||
return totalProgress / (float)m_workItems.size();
|
||||
}
|
||||
}
|
||||
|
||||
const uint32 CScheduleItem::GetNumWorkItems() const
|
||||
{
|
||||
return m_workItems.size();
|
||||
}
|
||||
|
||||
IBackgroundScheduleItemWork* CScheduleItem::GetWorkItem(const uint32 index) const
|
||||
{
|
||||
return m_workItems[index];
|
||||
}
|
||||
|
||||
void CScheduleItem::AddWorkItem(IBackgroundScheduleItemWork* pWork)
|
||||
{
|
||||
// cannot add new work items when item has finished or failed
|
||||
if (m_state == eScheduleItemState_Failed || m_state == eScheduleItemState_Completed)
|
||||
{
|
||||
CryFatalError("Cannot add new work items when item has finished or failed");
|
||||
return;
|
||||
}
|
||||
|
||||
// add to the work list
|
||||
if (m_state == eScheduleItemState_Processing)
|
||||
{
|
||||
m_addedWorkItems.push_back(pWork);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_workItems.push_back(pWork);
|
||||
}
|
||||
}
|
||||
|
||||
void CScheduleItem::AddRef()
|
||||
{
|
||||
CryInterlockedIncrement(&m_refCount);
|
||||
}
|
||||
|
||||
void CScheduleItem::Release()
|
||||
{
|
||||
const int nCount = CryInterlockedDecrement(&m_refCount);
|
||||
assert(nCount >= 0);
|
||||
if (nCount == 0)
|
||||
{
|
||||
delete this;
|
||||
}
|
||||
else if (nCount < 0)
|
||||
{
|
||||
assert(0);
|
||||
CryFatalError("Deleting Reference Counted Object Twice");
|
||||
}
|
||||
}
|
||||
|
||||
void CScheduleItem::RequestStop()
|
||||
{
|
||||
if (m_state == eScheduleItemState_Pending)
|
||||
{
|
||||
// we can stop right away :)
|
||||
m_state = eScheduleItemState_Failed;
|
||||
}
|
||||
else if (m_state == eScheduleItemState_Processing)
|
||||
{
|
||||
m_state = eScheduleItemState_Stopping;
|
||||
|
||||
// signal all pending work to stop
|
||||
uint32 curIndex = 0;
|
||||
while (curIndex < m_processedWorkItems.size())
|
||||
{
|
||||
IBackgroundScheduleItemWork* pWork = m_processedWorkItems[curIndex];
|
||||
if (pWork->OnStop())
|
||||
{
|
||||
// if the work was stopped remove it from list
|
||||
m_processedWorkItems.erase(m_processedWorkItems.begin() + curIndex);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
// this work item cannot be stopped this frame
|
||||
curIndex += 1;
|
||||
}
|
||||
}
|
||||
|
||||
// if all pending work has been stopped we can assume the failed state
|
||||
if (m_processedWorkItems.empty())
|
||||
{
|
||||
m_state = eScheduleItemState_Failed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EScheduleWorkItemStatus CScheduleItem::Update()
|
||||
{
|
||||
EScheduleWorkItemStatus retStatus = eScheduleWorkItemStatus_NotFinished;
|
||||
|
||||
switch (m_state)
|
||||
{
|
||||
// finial state - work failed
|
||||
case eScheduleItemState_Failed:
|
||||
{
|
||||
retStatus = eScheduleWorkItemStatus_Failed;
|
||||
break;
|
||||
}
|
||||
|
||||
// final state - work completed
|
||||
case eScheduleItemState_Completed:
|
||||
{
|
||||
retStatus = eScheduleWorkItemStatus_Finished;
|
||||
break;
|
||||
}
|
||||
|
||||
// first update, start all the work items
|
||||
case eScheduleItemState_Pending:
|
||||
{
|
||||
// start all of the tasks
|
||||
bool bHasFailedStarts = false;
|
||||
for (TWorkItems::const_iterator it = m_workItems.begin();
|
||||
it != m_workItems.end(); ++it)
|
||||
{
|
||||
IBackgroundScheduleItemWork* pWork = (*it);
|
||||
|
||||
if (pWork->OnStart())
|
||||
{
|
||||
m_processedWorkItems.push_back(pWork);
|
||||
}
|
||||
else
|
||||
{
|
||||
bHasFailedStarts = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (bHasFailedStarts)
|
||||
{
|
||||
m_state = eScheduleItemState_Stopping;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_state = eScheduleItemState_Processing;
|
||||
/* FALLS THROUGHT TO PROCESSING STATE */
|
||||
}
|
||||
}
|
||||
|
||||
// work processing state
|
||||
case eScheduleItemState_Processing:
|
||||
{
|
||||
// process new work items that were added while the schedule was created
|
||||
if (!m_addedWorkItems.empty())
|
||||
{
|
||||
for (TWorkItems::const_iterator it = m_addedWorkItems.begin();
|
||||
it != m_addedWorkItems.end(); ++it)
|
||||
{
|
||||
IBackgroundScheduleItemWork* pWork = (*it);
|
||||
pWork->OnStart();
|
||||
m_processedWorkItems.push_back(pWork);
|
||||
m_workItems.push_back(pWork);
|
||||
}
|
||||
|
||||
m_addedWorkItems.clear();
|
||||
}
|
||||
|
||||
// update work items
|
||||
bool bHasFailedItems = false;
|
||||
TWorkItems completedItems;
|
||||
for (TWorkItems::const_iterator it = m_processedWorkItems.begin();
|
||||
it != m_processedWorkItems.end(); ++it)
|
||||
{
|
||||
IBackgroundScheduleItemWork* pWork = (*it);
|
||||
|
||||
// update given work item
|
||||
const EScheduleWorkItemStatus status = pWork->OnUpdate();
|
||||
if (status == eScheduleWorkItemStatus_Finished)
|
||||
{
|
||||
completedItems.push_back(pWork);
|
||||
continue;
|
||||
}
|
||||
|
||||
// item failed - we need to stop other tasks
|
||||
if (status == eScheduleWorkItemStatus_Failed)
|
||||
{
|
||||
bHasFailedItems = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// cleanup completed items
|
||||
for (TWorkItems::iterator it = completedItems.begin();
|
||||
it != completedItems.end(); ++it)
|
||||
{
|
||||
IBackgroundScheduleItemWork* pWork = (*it);
|
||||
TWorkItems::iterator jt = std::find(m_processedWorkItems.begin(), m_processedWorkItems.end(), pWork);
|
||||
m_processedWorkItems.erase(jt);
|
||||
}
|
||||
|
||||
if (!bHasFailedItems)
|
||||
{
|
||||
// all work has finished
|
||||
if (m_processedWorkItems.empty())
|
||||
{
|
||||
retStatus = eScheduleWorkItemStatus_Finished;
|
||||
m_state = eScheduleItemState_Completed;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
// some of the items failed
|
||||
m_state = eScheduleItemState_Stopping;
|
||||
/* FALL THROUGH TO STOPPING STATE */
|
||||
}
|
||||
}
|
||||
|
||||
// We are stopping failed work
|
||||
case eScheduleItemState_Stopping:
|
||||
{
|
||||
uint32 curIndex = 0;
|
||||
while (curIndex < m_processedWorkItems.size())
|
||||
{
|
||||
IBackgroundScheduleItemWork* pWork = m_processedWorkItems[curIndex];
|
||||
if (pWork->OnStop())
|
||||
{
|
||||
// if the work was stopped remove it from list
|
||||
m_processedWorkItems.erase(m_processedWorkItems.begin() + curIndex);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
// this work item cannot be stopped this frame
|
||||
curIndex += 1;
|
||||
}
|
||||
}
|
||||
|
||||
// if all pending work has been stopped we can assume the failed state
|
||||
if (m_processedWorkItems.empty())
|
||||
{
|
||||
m_state = eScheduleItemState_Failed;
|
||||
return eScheduleWorkItemStatus_Failed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return retStatus;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
CSchedule::CSchedule(const char* szName)
|
||||
: m_name(szName)
|
||||
, m_refCount(1)
|
||||
, m_bCanceled(false)
|
||||
, m_currentItem(0)
|
||||
, m_state(eScheduleState_Pending)
|
||||
{
|
||||
}
|
||||
|
||||
CSchedule::~CSchedule()
|
||||
{
|
||||
CRY_ASSERT(m_refCount == 0);
|
||||
|
||||
for (TItems::const_iterator it = m_items.begin();
|
||||
it != m_items.end(); ++it)
|
||||
{
|
||||
CScheduleItem* pItem = *it;
|
||||
SAFE_RELEASE(pItem);
|
||||
}
|
||||
|
||||
m_items.clear();
|
||||
}
|
||||
|
||||
const char* CSchedule::GetDescription() const
|
||||
{
|
||||
return m_name.c_str();
|
||||
}
|
||||
|
||||
float CSchedule::GetProgress() const
|
||||
{
|
||||
if (m_currentItem >= m_items.size())
|
||||
{
|
||||
return 1.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
const float itemProgress = 1.0f / (float)(m_items.size());
|
||||
const IBackgroundScheduleItem* pItem = m_items[m_currentItem];
|
||||
return (m_currentItem + pItem->GetProgress()) * itemProgress;
|
||||
}
|
||||
}
|
||||
|
||||
IBackgroundScheduleItem* CSchedule::GetProcessedItem() const
|
||||
{
|
||||
if (m_currentItem >= m_items.size())
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
IBackgroundScheduleItem* pItem = m_items[m_currentItem];
|
||||
return pItem;
|
||||
}
|
||||
}
|
||||
|
||||
const uint32 CSchedule::GetNumItems() const
|
||||
{
|
||||
return m_items.size();
|
||||
}
|
||||
|
||||
IBackgroundScheduleItem* CSchedule::GetItem(const uint32 index) const
|
||||
{
|
||||
return m_items[index];
|
||||
}
|
||||
|
||||
EScheduleState CSchedule::GetState() const
|
||||
{
|
||||
return m_state;
|
||||
}
|
||||
|
||||
void CSchedule::Cancel()
|
||||
{
|
||||
m_bCanceled = true;
|
||||
}
|
||||
|
||||
bool CSchedule::IsCanceled() const
|
||||
{
|
||||
return m_bCanceled;
|
||||
}
|
||||
|
||||
void CSchedule::AddItem(IBackgroundScheduleItem* pItem)
|
||||
{
|
||||
if (NULL == pItem)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// we can add items only in the "pending" state
|
||||
if (pItem->GetState() != eScheduleItemState_Pending)
|
||||
{
|
||||
CryFatalError("Schedule items can be added to schedule only before their work starts");
|
||||
return;
|
||||
}
|
||||
|
||||
// item has no jobs, do not add
|
||||
if (pItem->GetNumWorkItems() == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_items.push_back(static_cast<CScheduleItem*>(pItem));
|
||||
pItem->AddRef();
|
||||
}
|
||||
|
||||
void CSchedule::AddRef()
|
||||
{
|
||||
CryInterlockedIncrement(&m_refCount);
|
||||
}
|
||||
|
||||
void CSchedule::Release()
|
||||
{
|
||||
const int nCount = CryInterlockedDecrement(&m_refCount);
|
||||
assert(nCount >= 0);
|
||||
if (nCount == 0)
|
||||
{
|
||||
delete this;
|
||||
}
|
||||
else if (nCount < 0)
|
||||
{
|
||||
assert(0);
|
||||
CryFatalError("Deleting Reference Counted Object Twice");
|
||||
}
|
||||
}
|
||||
|
||||
EScheduleWorkItemStatus CSchedule::Update()
|
||||
{
|
||||
EScheduleWorkItemStatus retStatus = eScheduleWorkItemStatus_NotFinished;
|
||||
|
||||
// we have a cancel request
|
||||
if (m_bCanceled)
|
||||
{
|
||||
CryLog("Schedule '%s' was canceled", GetDescription());
|
||||
|
||||
if (m_state == eScheduleState_Processing && m_currentItem < m_items.size())
|
||||
{
|
||||
// stop the current item
|
||||
CScheduleItem* pItem = m_items[m_currentItem];
|
||||
pItem->RequestStop();
|
||||
m_state = eSccheduleState_Stopping;
|
||||
}
|
||||
else if (m_state != eScheduleState_Completed)
|
||||
{
|
||||
m_state = eScheduleState_Failed;
|
||||
return eScheduleWorkItemStatus_Failed;
|
||||
}
|
||||
}
|
||||
|
||||
// process internal state machine
|
||||
switch (m_state)
|
||||
{
|
||||
// final state - work failed
|
||||
case eScheduleState_Failed:
|
||||
{
|
||||
retStatus = eScheduleWorkItemStatus_Failed;
|
||||
break;
|
||||
}
|
||||
|
||||
// final state - work completed
|
||||
case eScheduleState_Completed:
|
||||
{
|
||||
retStatus = eScheduleWorkItemStatus_Finished;
|
||||
break;
|
||||
}
|
||||
|
||||
// stopping current task
|
||||
case eSccheduleState_Stopping:
|
||||
{
|
||||
if (m_currentItem < m_items.size())
|
||||
{
|
||||
CScheduleItem* pItem = m_items[m_currentItem];
|
||||
if (pItem->Update() != eScheduleWorkItemStatus_NotFinished)
|
||||
{
|
||||
// task was finally stopped
|
||||
m_state = eScheduleState_Failed;
|
||||
retStatus = eScheduleWorkItemStatus_Failed;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// first update, switch to processing
|
||||
case eScheduleState_Pending:
|
||||
{
|
||||
m_state = eScheduleState_Processing;
|
||||
m_currentItem = 0;
|
||||
/* FALLS THROUGHT */
|
||||
}
|
||||
|
||||
// if we were in the processing phase inform the current schedule item to stop all it's work
|
||||
case eScheduleState_Processing:
|
||||
{
|
||||
// update schedule items
|
||||
while (m_currentItem < m_items.size())
|
||||
{
|
||||
CScheduleItem* pItem = m_items[m_currentItem];
|
||||
|
||||
const EScheduleWorkItemStatus itemStatus = pItem->Update();
|
||||
if (itemStatus == eScheduleWorkItemStatus_Finished)
|
||||
{
|
||||
m_currentItem += 1;
|
||||
continue;
|
||||
}
|
||||
else if (itemStatus == eScheduleWorkItemStatus_Failed)
|
||||
{
|
||||
m_state = eScheduleState_Failed;
|
||||
retStatus = eScheduleWorkItemStatus_Failed;
|
||||
gEnv->pLog->LogWarning("Schedule '%s' failed on item '%s'.", GetDescription(), pItem->GetDescription());
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// all items updated
|
||||
if (m_currentItem >= m_items.size())
|
||||
{
|
||||
// empty schedule, complete in one tick
|
||||
m_state = eScheduleState_Completed;
|
||||
retStatus = eScheduleWorkItemStatus_Finished;
|
||||
CryLog("Schedule '%s' completed", GetDescription());
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return retStatus;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
CScheduleManager::CScheduleManager()
|
||||
{
|
||||
GetIEditor()->RegisterNotifyListener(this);
|
||||
}
|
||||
|
||||
CScheduleManager::~CScheduleManager()
|
||||
{
|
||||
GetIEditor()->UnregisterNotifyListener(this);
|
||||
|
||||
for (TSchedules::const_iterator it = m_schedules.begin();
|
||||
it != m_schedules.end(); ++it)
|
||||
{
|
||||
CSchedule* pSchedule = *it;
|
||||
SAFE_RELEASE(pSchedule);
|
||||
}
|
||||
|
||||
m_schedules.clear();
|
||||
}
|
||||
|
||||
IBackgroundSchedule* CScheduleManager::CreateSchedule(const char* szName)
|
||||
{
|
||||
return new CSchedule(szName);
|
||||
}
|
||||
|
||||
IBackgroundScheduleItem* CScheduleManager::CreateScheduleItem(const char* szName)
|
||||
{
|
||||
return new CScheduleItem(szName);
|
||||
}
|
||||
|
||||
void CScheduleManager::SubmitSchedule(IBackgroundSchedule* pSchedule)
|
||||
{
|
||||
if (NULL != pSchedule)
|
||||
{
|
||||
if (pSchedule->GetState() != eScheduleState_Pending)
|
||||
{
|
||||
CryFatalError("Only schedules with pending state can be submitted");
|
||||
return;
|
||||
}
|
||||
|
||||
pSchedule->AddRef();
|
||||
m_schedules.push_back(static_cast<CSchedule*>(pSchedule));
|
||||
}
|
||||
}
|
||||
|
||||
const uint32 CScheduleManager::GetNumSchedules() const
|
||||
{
|
||||
return m_schedules.size();
|
||||
}
|
||||
|
||||
IBackgroundSchedule* CScheduleManager::GetSchedule(const uint32 index) const
|
||||
{
|
||||
return m_schedules[index];
|
||||
}
|
||||
|
||||
void CScheduleManager::Update()
|
||||
{
|
||||
while (!m_schedules.empty())
|
||||
{
|
||||
CSchedule* pSchedule = m_schedules[0];
|
||||
|
||||
const EScheduleWorkItemStatus status = pSchedule->Update();
|
||||
if (status == eScheduleWorkItemStatus_NotFinished)
|
||||
{
|
||||
// we need more work next frame
|
||||
break;
|
||||
}
|
||||
|
||||
// schedule has finished, remove current reference
|
||||
m_schedules.erase(m_schedules.begin());
|
||||
SAFE_RELEASE(pSchedule);
|
||||
}
|
||||
}
|
||||
|
||||
void CScheduleManager::OnEditorNotifyEvent(EEditorNotifyEvent ev)
|
||||
{
|
||||
switch (ev)
|
||||
{
|
||||
case eNotify_OnQuit:
|
||||
GetIEditor()->UnregisterNotifyListener(this);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
} // BackgroundScheduleManager
|
||||
@@ -1,117 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_BACKGROUNDSCHEDULEMANAGER_H
|
||||
#define CRYINCLUDE_EDITOR_BACKGROUNDSCHEDULEMANAGER_H
|
||||
#pragma once
|
||||
|
||||
#include "Include/IBackgroundScheduleManager.h"
|
||||
|
||||
namespace BackgroundScheduleManager
|
||||
{
|
||||
class CScheduleItem
|
||||
: public IBackgroundScheduleItem
|
||||
{
|
||||
private:
|
||||
std::string m_name;
|
||||
volatile int m_refCount;
|
||||
|
||||
EScheduleItemState m_state;
|
||||
|
||||
typedef std::vector<IBackgroundScheduleItemWork*> TWorkItems;
|
||||
TWorkItems m_workItems;
|
||||
TWorkItems m_addedWorkItems;
|
||||
TWorkItems m_processedWorkItems;
|
||||
|
||||
public:
|
||||
CScheduleItem(const char* szName);
|
||||
virtual ~CScheduleItem();
|
||||
|
||||
// IBackgroundScheduleItem interface
|
||||
virtual const char* GetDescription() const;
|
||||
virtual EScheduleItemState GetState() const;
|
||||
virtual const float GetProgress() const;
|
||||
virtual const uint32 GetNumWorkItems() const;
|
||||
virtual IBackgroundScheduleItemWork* GetWorkItem(const uint32 index) const;
|
||||
virtual void AddWorkItem(IBackgroundScheduleItemWork* pWork);
|
||||
virtual void AddRef();
|
||||
virtual void Release();
|
||||
|
||||
// Update schedule item
|
||||
EScheduleWorkItemStatus Update();
|
||||
|
||||
// Request to stop work in this item
|
||||
void RequestStop();
|
||||
};
|
||||
|
||||
class CSchedule
|
||||
: public IBackgroundSchedule
|
||||
{
|
||||
private:
|
||||
std::string m_name;
|
||||
volatile int m_refCount;
|
||||
bool m_bCanceled;
|
||||
|
||||
EScheduleState m_state;
|
||||
|
||||
typedef std::vector<CScheduleItem*> TItems;
|
||||
TItems m_items;
|
||||
|
||||
uint32 m_currentItem;
|
||||
|
||||
public:
|
||||
CSchedule(const char* szName);
|
||||
virtual ~CSchedule();
|
||||
|
||||
// IBackgroundSchedule interface
|
||||
virtual const char* GetDescription() const;
|
||||
virtual float GetProgress() const;
|
||||
virtual IBackgroundScheduleItem* GetProcessedItem() const;
|
||||
virtual const uint32 GetNumItems() const;
|
||||
virtual IBackgroundScheduleItem* GetItem(const uint32 index) const;
|
||||
virtual EScheduleState GetState() const;
|
||||
virtual void Cancel();
|
||||
virtual bool IsCanceled() const;
|
||||
virtual void AddItem(IBackgroundScheduleItem* pItem);
|
||||
virtual void AddRef();
|
||||
virtual void Release();
|
||||
|
||||
// Update schedule item
|
||||
EScheduleWorkItemStatus Update();
|
||||
};
|
||||
|
||||
class CScheduleManager
|
||||
: public IBackgroundScheduleManager
|
||||
, public IEditorNotifyListener
|
||||
{
|
||||
private:
|
||||
typedef std::vector<CSchedule*> TSchedules;
|
||||
TSchedules m_schedules;
|
||||
|
||||
public:
|
||||
CScheduleManager();
|
||||
virtual ~CScheduleManager();
|
||||
|
||||
// IBackgroundScheduleManager interface
|
||||
virtual IBackgroundSchedule* CreateSchedule(const char* szName);
|
||||
virtual IBackgroundScheduleItem* CreateScheduleItem(const char* szName);
|
||||
virtual void SubmitSchedule(IBackgroundSchedule* pSchedule);
|
||||
virtual const uint32 GetNumSchedules() const;
|
||||
virtual IBackgroundSchedule* GetSchedule(const uint32 index) const;
|
||||
virtual void Update();
|
||||
|
||||
// IEditorNotifyListener interface implementation
|
||||
virtual void OnEditorNotifyEvent(EEditorNotifyEvent ev) override;
|
||||
};
|
||||
}
|
||||
#endif // CRYINCLUDE_EDITOR_BACKGROUNDSCHEDULEMANAGER_H
|
||||
@@ -1,410 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#include "EditorDefs.h"
|
||||
|
||||
#include "BackgroundTaskManager.h"
|
||||
|
||||
namespace BackgroundTaskManager
|
||||
{
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
CTaskManager::CThread::CThread(class CTaskManager* pManager, CQueue* pQueue)
|
||||
: m_pManager(pManager)
|
||||
, m_pQueue(pQueue)
|
||||
{
|
||||
start();
|
||||
}
|
||||
|
||||
CTaskManager::CThread::~CThread()
|
||||
{
|
||||
}
|
||||
|
||||
void CTaskManager::CThread::WaitForThread()
|
||||
{
|
||||
wait();
|
||||
}
|
||||
|
||||
void CTaskManager::CThread::run()
|
||||
{
|
||||
CryThreadSetName(-1, "BackgroundTaskThread");
|
||||
|
||||
while (!m_pManager->IsStopped())
|
||||
{
|
||||
STaskHandle taskHandle;
|
||||
|
||||
// This blocks on Semaphore waiting for task from queue
|
||||
m_pQueue->PopTask(taskHandle);
|
||||
|
||||
// Should not happen but it's a stupid way to crash :)
|
||||
if (NULL == taskHandle.pTask)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (taskHandle.pTask->IsCanceled())
|
||||
{
|
||||
// Task was canceled before we got here
|
||||
m_pManager->AddCompletedTask(taskHandle, eTaskResult_Canceled);
|
||||
}
|
||||
else
|
||||
{
|
||||
const ETaskResult state = taskHandle.pTask->Work();
|
||||
|
||||
if (state == eTaskResult_Resume)
|
||||
{
|
||||
// Put it back into queue, so more important task can take over.
|
||||
m_pManager->AddTask(taskHandle);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Finish task
|
||||
m_pManager->AddCompletedTask(taskHandle, state);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
CTaskManager::CQueue::CQueue()
|
||||
: m_semaphore(INT_MAX, 0) // no good maximum value, assume worst case
|
||||
{
|
||||
}
|
||||
|
||||
void CTaskManager::CQueue::AddTask(const STaskHandle& taskHandle)
|
||||
{
|
||||
{
|
||||
CryAutoLock<CryMutex> lock(m_lock);
|
||||
|
||||
// TODO: use heap?
|
||||
m_pendingTasks.insert(m_pendingTasks.begin(), taskHandle);
|
||||
std::stable_sort(m_pendingTasks.begin(), m_pendingTasks.end());
|
||||
}
|
||||
|
||||
taskHandle.pTask->SetState(eTaskState_Pending);
|
||||
|
||||
// release internal semaphore so threads can pick up the work
|
||||
m_semaphore.Release();
|
||||
}
|
||||
|
||||
void CTaskManager::CQueue::PopTask(STaskHandle& outTaskHandle)
|
||||
{
|
||||
// wait for job
|
||||
m_semaphore.Acquire();
|
||||
|
||||
{
|
||||
CryAutoLock<CryMutex> lock(m_lock);
|
||||
|
||||
if (m_pendingTasks.empty())
|
||||
{
|
||||
outTaskHandle.pTask = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
outTaskHandle = m_pendingTasks.back();
|
||||
outTaskHandle.pTask->SetState(eTaskState_Working);
|
||||
m_pendingTasks.pop_back();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CTaskManager::CQueue::ReleaseSemaphore()
|
||||
{
|
||||
m_semaphore.Release();
|
||||
}
|
||||
|
||||
void CTaskManager::CQueue::Clear()
|
||||
{
|
||||
CryAutoLock<CryMutex> lock(m_lock);
|
||||
for (uint i = 0; i < m_pendingTasks.size(); ++i)
|
||||
{
|
||||
m_pendingTasks[i].pTask->Release();
|
||||
}
|
||||
|
||||
m_pendingTasks.clear();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
CTaskManager::CTaskManager()
|
||||
: m_bStop(false)
|
||||
, m_nextTaskID(1)
|
||||
, m_listeners(1)
|
||||
{
|
||||
GetIEditor()->RegisterNotifyListener(this);
|
||||
}
|
||||
|
||||
CTaskManager::~CTaskManager()
|
||||
{
|
||||
if (!m_bStop)
|
||||
{
|
||||
Stop();
|
||||
}
|
||||
}
|
||||
|
||||
void CTaskManager::Start(const uint32 threadCount /*=kDefaultThreadCount*/)
|
||||
{
|
||||
m_bStop = false;
|
||||
|
||||
if (m_pThreads.empty())
|
||||
{
|
||||
// Always create one IO thread
|
||||
{
|
||||
CThread* pThread = new CThread(this, &m_pendingTasks[ eTaskThreadMask_IO ]);
|
||||
m_pThreads.push_back(pThread);
|
||||
}
|
||||
|
||||
// We also need at least one generic thread
|
||||
const uint32 numGenericThreads = max<uint32>(threadCount, 1);
|
||||
for (uint32 i = 0; i < numGenericThreads; ++i)
|
||||
{
|
||||
CThread* pThread = new CThread(this, &m_pendingTasks[ eTaskThreadMask_Any ]);
|
||||
m_pThreads.push_back(pThread);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CTaskManager::StartScheduledTasks()
|
||||
{
|
||||
CryAutoLock<CryMutex> lock(m_tasksLock);
|
||||
|
||||
if (!m_scheduledTasks.empty())
|
||||
{
|
||||
const unsigned int time = GetTickCount();
|
||||
while (!m_scheduledTasks.empty())
|
||||
{
|
||||
const int delta = (int)(time - m_scheduledTasks[0].time);
|
||||
if (delta > 0)
|
||||
{
|
||||
// the soonest task on the list is still in the future, no point in looking at the next entries in the list
|
||||
break;
|
||||
}
|
||||
|
||||
// promote the scheduled task to be a full task
|
||||
AddTask(m_scheduledTasks[0].handle);
|
||||
|
||||
// We held a reference to the task on list, release it
|
||||
m_scheduledTasks[0].handle.pTask->Release();
|
||||
|
||||
m_scheduledTasks.erase(m_scheduledTasks.begin());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CTaskManager::Stop()
|
||||
{
|
||||
if (!m_bStop)
|
||||
{
|
||||
m_bStop = true;
|
||||
GetIEditor()->UnregisterNotifyListener(this);
|
||||
|
||||
// clear queues - no new tasks will be processed
|
||||
for (uint32 i = 0; i < eTaskThreadMask_COUNT; ++i)
|
||||
{
|
||||
m_pendingTasks[i].Clear();
|
||||
}
|
||||
|
||||
// kick all the threads to allow them to quit
|
||||
for (uint32 j = 0; j < m_pThreads.size(); ++j)
|
||||
{
|
||||
for (uint32 i = 0; i < eTaskThreadMask_COUNT; ++i)
|
||||
{
|
||||
m_pendingTasks[i].ReleaseSemaphore();
|
||||
}
|
||||
}
|
||||
|
||||
// Stop threads
|
||||
for (TWorkerThreads::iterator it = m_pThreads.begin();
|
||||
it != m_pThreads.end(); ++it)
|
||||
{
|
||||
(*it)->WaitForThread();
|
||||
delete *it;
|
||||
}
|
||||
|
||||
m_pThreads.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void CTaskManager::AddListener(IBackgroundTaskManagerListener* pListener, const char* name)
|
||||
{
|
||||
m_listeners.Add(pListener, name);
|
||||
}
|
||||
|
||||
void CTaskManager::RemoveListener(IBackgroundTaskManagerListener* pListener)
|
||||
{
|
||||
m_listeners.Remove(pListener);
|
||||
}
|
||||
|
||||
void CTaskManager::AddTask(IBackgroundTask* pTask, ETaskPriority priority, ETaskThreadMask threadMask)
|
||||
{
|
||||
MAKE_SURE(pTask != 0, return );
|
||||
|
||||
// keep an extra reference to the task in the manager
|
||||
pTask->AddRef();
|
||||
|
||||
STaskHandle handle;
|
||||
handle.id = CryInterlockedIncrement(&m_nextTaskID);
|
||||
handle.priority = priority;
|
||||
handle.threadMask = threadMask;
|
||||
handle.pTask = pTask;
|
||||
|
||||
AddTask(handle);
|
||||
|
||||
for (TListeners::Notifier notifier(m_listeners); notifier.IsValid(); notifier.Next())
|
||||
{
|
||||
notifier->OnBackgroundTaskAdded(pTask->Description());
|
||||
}
|
||||
}
|
||||
|
||||
void CTaskManager::ScheduleTask(IBackgroundTask* pTask, ETaskPriority priority, int delayMilliseconds, ETaskThreadMask threadMask)
|
||||
{
|
||||
MAKE_SURE(delayMilliseconds >= 0, return );
|
||||
MAKE_SURE(pTask != 0, return );
|
||||
|
||||
// keep an extra reference to the task in the manager
|
||||
pTask->AddRef();
|
||||
|
||||
SScheduledTask task;
|
||||
task.time = GetTickCount() + delayMilliseconds;
|
||||
task.handle.pTask = pTask;
|
||||
task.handle.id = CryInterlockedIncrement(&m_nextTaskID);
|
||||
task.handle.threadMask = threadMask;
|
||||
task.handle.priority = priority;
|
||||
|
||||
{
|
||||
CryAutoLock<CryMutex> lock(m_tasksLock);
|
||||
m_scheduledTasks.push_back(task);
|
||||
}
|
||||
|
||||
for (TListeners::Notifier notifier(m_listeners); notifier.IsValid(); notifier.Next())
|
||||
{
|
||||
notifier->OnBackgroundTaskAdded(pTask->Description());
|
||||
}
|
||||
}
|
||||
|
||||
void CTaskManager::AddTask(const STaskHandle& handle)
|
||||
{
|
||||
MAKE_SURE(handle.pTask != 0, return );
|
||||
MAKE_SURE(handle.id != 0, return );
|
||||
|
||||
// add task to appropriate queue (every thread mask has it's own queue)
|
||||
m_pendingTasks[handle.threadMask].AddTask(handle);
|
||||
}
|
||||
|
||||
void CTaskManager::AddCompletedTask(const STaskHandle& handle, ETaskResult resultState)
|
||||
{
|
||||
CryAutoLock<CryMutex> lock(m_tasksLock);
|
||||
|
||||
CRY_ASSERT(handle.pTask->GetState() == eTaskState_Working);
|
||||
CRY_ASSERT(resultState != eTaskResult_Resume);
|
||||
|
||||
// Update task state
|
||||
switch (resultState)
|
||||
{
|
||||
case eTaskResult_Canceled:
|
||||
{
|
||||
handle.pTask->SetState(eTaskState_Canceled);
|
||||
break;
|
||||
}
|
||||
|
||||
case eTaskResult_Completed:
|
||||
{
|
||||
handle.pTask->SetState(eTaskState_Completed);
|
||||
break;
|
||||
}
|
||||
|
||||
case eTaskResult_Failed:
|
||||
{
|
||||
handle.pTask->SetState(eTaskState_Failed);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// add to the list of completed tasks (for calling the Finalize)
|
||||
// TODO: some of the tasks do not require Finalize() and they could be released here instead of the main thread
|
||||
SCompletedTask info;
|
||||
info.pTask = handle.pTask;
|
||||
info.id = handle.id;
|
||||
info.state = resultState;
|
||||
m_completedTasks.push_back(info);
|
||||
}
|
||||
|
||||
void CTaskManager::Update()
|
||||
{
|
||||
std::vector<SCompletedTask> completedTasks;
|
||||
{
|
||||
CryAutoLock<CryMutex> lock(m_tasksLock);
|
||||
m_completedTasks.swap(completedTasks);
|
||||
}
|
||||
|
||||
// call finalize for the completed tasks
|
||||
for (size_t i = 0; i < completedTasks.size(); ++i)
|
||||
{
|
||||
SCompletedTask& handle = completedTasks[i];
|
||||
|
||||
if (NULL != handle.pTask)
|
||||
{
|
||||
string description = handle.pTask->Description(); // copy string as the description is used after pTask is destroyed
|
||||
|
||||
if (handle.state == eTaskResult_Completed)
|
||||
{
|
||||
if (description && description[0] != '\0')
|
||||
{
|
||||
gEnv->pLog->Log("Task Completed: %s", description.c_str());
|
||||
}
|
||||
}
|
||||
else if (handle.state == eTaskResult_Failed)
|
||||
{
|
||||
if (description && description[0] != '\0' && !handle.pTask->FailReported())
|
||||
{
|
||||
gEnv->pLog->LogError("Task Failed: %s ", description.c_str());
|
||||
|
||||
const char* errorMessage = handle.pTask->ErrorMessage();
|
||||
if (errorMessage && errorMessage[0] != '\0')
|
||||
{
|
||||
gEnv->pLog->LogError("\tReason: [%s]", errorMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
handle.pTask->Finalize();
|
||||
|
||||
// release the internal (task manager) reference.
|
||||
// Tthis is usually the last reference to the task so it gets deleted here.
|
||||
handle.pTask->Release();
|
||||
|
||||
for (TListeners::Notifier notifier(m_listeners); notifier.IsValid(); notifier.Next())
|
||||
{
|
||||
notifier->OnBackgroundTaskCompleted(handle.state, description.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CTaskManager::OnEditorNotifyEvent(EEditorNotifyEvent ev)
|
||||
{
|
||||
switch (ev)
|
||||
{
|
||||
case eNotify_OnInit:
|
||||
Start();
|
||||
break;
|
||||
case eNotify_OnIdleUpdate:
|
||||
Update();
|
||||
break;
|
||||
case eNotify_OnQuit:
|
||||
Stop();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,161 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_BACKGROUNDTASKMANAGER_H
|
||||
#define CRYINCLUDE_EDITOR_BACKGROUNDTASKMANAGER_H
|
||||
#pragma once
|
||||
|
||||
#include "Include/IBackgroundTaskManager.h"
|
||||
#include "CryListenerSet.h"
|
||||
|
||||
#include <QThread>
|
||||
|
||||
namespace BackgroundTaskManager
|
||||
{
|
||||
typedef int TTaskID;
|
||||
|
||||
struct STaskHandle
|
||||
{
|
||||
ETaskPriority priority;
|
||||
ETaskThreadMask threadMask;
|
||||
TTaskID id;
|
||||
IBackgroundTask* pTask;
|
||||
|
||||
bool operator<(const STaskHandle& rhs) const
|
||||
{
|
||||
if (priority < rhs.priority)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (priority > rhs.priority)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return id < rhs.id;
|
||||
}
|
||||
};
|
||||
|
||||
struct SCompletedTask
|
||||
{
|
||||
ETaskResult state;
|
||||
TTaskID id;
|
||||
ETaskThreadMask threadMask;
|
||||
IBackgroundTask* pTask;
|
||||
};
|
||||
|
||||
struct SScheduledTask
|
||||
{
|
||||
unsigned int time;
|
||||
STaskHandle handle;
|
||||
};
|
||||
|
||||
class CTaskManager
|
||||
: public IBackgroundTaskManager
|
||||
, public IEditorNotifyListener
|
||||
{
|
||||
public:
|
||||
CTaskManager();
|
||||
~CTaskManager();
|
||||
|
||||
// IBackgroundTaskManager interface implementation
|
||||
virtual void AddTask(IBackgroundTask* pTask, ETaskPriority priority, ETaskThreadMask threadMask) override;
|
||||
virtual void ScheduleTask(IBackgroundTask* pTask, ETaskPriority priority, int delayMilliseconds, ETaskThreadMask threadMask) override;
|
||||
void AddListener(IBackgroundTaskManagerListener* pListener, const char* name) override;
|
||||
void RemoveListener(IBackgroundTaskManagerListener* pListener) override;
|
||||
|
||||
private:
|
||||
// IEditorNotifyListener interface implementation
|
||||
virtual void OnEditorNotifyEvent(EEditorNotifyEvent ev) override;
|
||||
|
||||
void Start(const uint32 threadCount = kDefaultThreadCount);
|
||||
void Stop();
|
||||
void StartScheduledTasks();
|
||||
void AddTask(const STaskHandle& outTask);
|
||||
void AddCompletedTask(const STaskHandle& outTask, ETaskResult resultState);
|
||||
void Update();
|
||||
|
||||
inline bool IsStopped() const
|
||||
{
|
||||
return m_bStop;
|
||||
}
|
||||
|
||||
private:
|
||||
// Internal queue (per thread mask)
|
||||
class CQueue
|
||||
{
|
||||
public:
|
||||
CQueue();
|
||||
|
||||
// Add task to list
|
||||
void AddTask(const STaskHandle& taskHandle);
|
||||
|
||||
// Pop task from list
|
||||
void PopTask(STaskHandle& outTaskHandle);
|
||||
|
||||
// Release thread semaphore without adding a task
|
||||
void ReleaseSemaphore();
|
||||
|
||||
// Remove all pending tasks
|
||||
void Clear();
|
||||
|
||||
private:
|
||||
CrySemaphore m_semaphore;
|
||||
std::vector<STaskHandle> m_pendingTasks;
|
||||
CryMutex m_lock;
|
||||
};
|
||||
|
||||
// Worker thread class implementation
|
||||
class CThread : public QThread
|
||||
{
|
||||
public:
|
||||
CThread(CTaskManager* pManager, CQueue* pQueue);
|
||||
~CThread();
|
||||
|
||||
void WaitForThread();
|
||||
|
||||
private:
|
||||
void run() override;
|
||||
|
||||
private:
|
||||
CTaskManager* m_pManager;
|
||||
CQueue* m_pQueue;
|
||||
};
|
||||
|
||||
private:
|
||||
static const uint32 kMaxThreadCloseWaitTime = 10000; // ms
|
||||
static const uint32 kDefaultThreadCount = 4; // good enough for LiveCreate (main user right now), do not set to less than 2
|
||||
|
||||
CQueue m_pendingTasks[ eTaskThreadMask_COUNT ];
|
||||
|
||||
// Task scheduled for execution in the future
|
||||
std::vector<SScheduledTask> m_scheduledTasks;
|
||||
|
||||
// Completed tasks (waiting for the "finalize" call)
|
||||
std::vector<SCompletedTask> m_completedTasks;
|
||||
|
||||
volatile TTaskID m_nextTaskID;
|
||||
|
||||
typedef std::vector<CThread*> TWorkerThreads;
|
||||
TWorkerThreads m_pThreads;
|
||||
|
||||
CryMutex m_tasksLock;
|
||||
bool m_bStop;
|
||||
|
||||
typedef CListenerSet<IBackgroundTaskManagerListener*> TListeners;
|
||||
TListeners m_listeners;
|
||||
};
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_BACKGROUNDTASKMANAGER_H
|
||||
@@ -112,14 +112,12 @@ ly_add_target(
|
||||
3rdParty::zlib
|
||||
3rdParty::AWSNativeSDK::STS
|
||||
Legacy::CryCommon
|
||||
Legacy::CryCommon.EngineSettings.Static
|
||||
Legacy::EditorCommon
|
||||
AZ::AzCore
|
||||
AZ::AzToolsFramework
|
||||
Gem::LmbrCentral.Static
|
||||
Legacy::NewsShared
|
||||
AZ::AWSNativeSDKInit
|
||||
Legacy::CryCommonTools
|
||||
AZ::AtomCore
|
||||
Gem::Atom_RPI.Edit
|
||||
Gem::Atom_RPI.Public
|
||||
@@ -245,7 +243,6 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
|
||||
AZ::AzToolsFramework
|
||||
Legacy::EditorLib
|
||||
Gem::LmbrCentral
|
||||
Legacy::CryCommonTools
|
||||
)
|
||||
ly_add_googletest(
|
||||
NAME Legacy::EditorLib.Tests
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
// AzQtComponents
|
||||
#include <AzQtComponents/Components/StyledLineEdit.h>
|
||||
#include <AzQtComponents/Components/StyleManager.h>
|
||||
#include <AzQtComponents/Components/Widgets/LineEdit.h>
|
||||
#include <AzQtComponents/Components/Widgets/ScrollBar.h>
|
||||
#include <AzQtComponents/Components/Widgets/SliderCombo.h>
|
||||
|
||||
@@ -314,7 +315,10 @@ CConsoleSCB::CConsoleSCB(QWidget* parent)
|
||||
setMinimumHeight(120);
|
||||
|
||||
ui->findBar->setVisible(false);
|
||||
|
||||
ui->lineEditFind->setPlaceholderText(QObject::tr("Search..."));
|
||||
ui->lineEditFind->setClearButtonEnabled(true);
|
||||
AzQtComponents::LineEdit::applySearchStyle(ui->lineEditFind);
|
||||
|
||||
// Setup the color table for the default (light) theme
|
||||
m_colorTable << QColor(0, 0, 0)
|
||||
<< QColor(0, 0, 0)
|
||||
|
||||
@@ -1,821 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#include "EditorDefs.h"
|
||||
|
||||
#include "CurveEditorCtrl.h"
|
||||
|
||||
// Qt
|
||||
#include <QPainter>
|
||||
#include <QPainterPath>
|
||||
|
||||
namespace CurveEditor
|
||||
{
|
||||
const int kHandleSize = 6;
|
||||
const int kHandleSizeHalf = kHandleSize / 2;
|
||||
const int kDefaultPadding = 10;
|
||||
const int kInfoFontSize = 7;
|
||||
const int kGrid = 4;
|
||||
const QColor kColor_SelectCross(132, 132, 132);
|
||||
const QColor kColor_DisabledCross(90, 90, 90);
|
||||
const QColor kColor_MiddleLines(80, 80, 80);
|
||||
const QColor kColor_Background(41, 41, 41);
|
||||
const QColor kColor_Disabled(60, 60, 60);
|
||||
const QColor kColor_PaddingBorder(128, 128, 128);
|
||||
const QColor kColor_Text(128, 128, 128);
|
||||
const QColor kColor_TextCrtPos(187, 187, 187);
|
||||
const QColor kColor_Curve(255, 0, 0);
|
||||
const QColor kColor_SelHandle(200, 200, 200);
|
||||
const QColor kColor_NormalHandle(30, 30, 30);
|
||||
const QColor kColor_HandleLight(60, 60, 60);
|
||||
const QColor kColor_HandleShadow(0, 0, 0);
|
||||
const QColor kColor_MarkLines(0, 255, 0);
|
||||
}
|
||||
|
||||
|
||||
CCurveEditorCtrl::CCurveEditorCtrl(QWidget* parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
m_domainMinX = 0.0f;
|
||||
m_domainMinY = 0.0f;
|
||||
m_domainMaxX = 1.0f;
|
||||
m_domainMaxY = 1.0f;
|
||||
m_bMouseDown = m_bDragging = false;
|
||||
m_bAllowMouse = true;
|
||||
m_padding = CurveEditor::kDefaultPadding;
|
||||
m_flags = eFlag_ShowVerticalRuler
|
||||
| eFlag_ShowHorizontalRuler
|
||||
| eFlag_ShowVerticalRulerText
|
||||
| eFlag_ShowHorizontalRulerText
|
||||
| eFlag_ShowPaddingBorder
|
||||
| eFlag_ShowMovingPointAxis
|
||||
| eFlag_ShowPointHandles;
|
||||
m_gridSplits.set(CurveEditor::kGrid, CurveEditor::kGrid);
|
||||
m_fntInfo.setFamily("Arial");
|
||||
m_fntInfo.setPointSize(CurveEditor::kInfoFontSize);
|
||||
m_bHovered = false;
|
||||
m_selCrossPen = QPen(CurveEditor::kColor_SelectCross);
|
||||
|
||||
GenerateDefaultCurve();
|
||||
}
|
||||
|
||||
CCurveEditorCtrl::~CCurveEditorCtrl()
|
||||
{
|
||||
}
|
||||
|
||||
void CCurveEditorCtrl::SetFlags(UINT aFlags)
|
||||
{
|
||||
m_flags = aFlags;
|
||||
}
|
||||
|
||||
UINT CCurveEditorCtrl::GetFlags() const
|
||||
{
|
||||
return m_flags;
|
||||
}
|
||||
|
||||
bool CCurveEditorCtrl::SetDomainBounds(float aMinX, float aMinY, float aMaxX, float aMaxY)
|
||||
{
|
||||
assert(aMinX < aMaxX);
|
||||
assert(aMinY < aMaxY);
|
||||
|
||||
if (aMinX >= aMaxX)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (aMinY >= aMaxY)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
m_domainMinX = aMinX;
|
||||
m_domainMinY = aMinY;
|
||||
m_domainMaxX = aMaxX;
|
||||
m_domainMaxY = aMaxY;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CCurveEditorCtrl::GetDomainBounds(float& rMinX, float& rMinY, float& rMaxX, float& rMaxY) const
|
||||
{
|
||||
rMinX = m_domainMinX;
|
||||
rMinY = m_domainMinY;
|
||||
rMaxX = m_domainMaxX;
|
||||
rMaxY = m_domainMaxY;
|
||||
}
|
||||
|
||||
void CCurveEditorCtrl::SetGrid(UINT aHorizontalSplits, UINT aVerticalSplits, const QStringList& labelsX, const QStringList& labelsY)
|
||||
{
|
||||
assert(aHorizontalSplits);
|
||||
assert(aVerticalSplits);
|
||||
|
||||
if (!aHorizontalSplits)
|
||||
{
|
||||
// defaults
|
||||
aHorizontalSplits = 2;
|
||||
}
|
||||
|
||||
if (!aVerticalSplits)
|
||||
{
|
||||
// defaults
|
||||
aVerticalSplits = 2;
|
||||
}
|
||||
|
||||
m_gridSplits.x = aHorizontalSplits;
|
||||
m_gridSplits.y = aVerticalSplits;
|
||||
|
||||
if (!labelsX.isEmpty())
|
||||
{
|
||||
m_labelsX = labelsX;
|
||||
}
|
||||
|
||||
if (!labelsY.isEmpty())
|
||||
{
|
||||
m_labelsY = labelsY;
|
||||
}
|
||||
}
|
||||
|
||||
QPoint CCurveEditorCtrl::ProjectPoint(float x, float y)
|
||||
{
|
||||
QPoint pt;
|
||||
|
||||
pt.setX(m_padding + (width() - m_padding * 2) * (x - m_domainMinX) / (m_domainMaxX - m_domainMinX));
|
||||
pt.setY(m_padding + (height() - m_padding * 2) * (1.0f - (y - m_domainMinY) / (m_domainMaxY - m_domainMinY)));
|
||||
|
||||
return pt;
|
||||
}
|
||||
|
||||
Vec2 CCurveEditorCtrl::UnprojectPoint(const QPoint& pt)
|
||||
{
|
||||
Vec2 vec;
|
||||
int y = height() - pt.y();
|
||||
float dx = (width() - m_padding * 2);
|
||||
float dy = (height() - m_padding * 2);
|
||||
const float kEpsilon = 0.00000001f;
|
||||
|
||||
if (fabs(dx) <= kEpsilon)
|
||||
{
|
||||
dx = 1.0f;
|
||||
}
|
||||
|
||||
if (fabs(dy) <= kEpsilon)
|
||||
{
|
||||
dy = 1.0f;
|
||||
}
|
||||
|
||||
vec.x = m_domainMinX + (float)(pt.x() - m_padding) / dx * (m_domainMaxX - m_domainMinX);
|
||||
vec.y = m_domainMinY + (float)(y - m_padding) / dy * (m_domainMaxY - m_domainMinY);
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
void CCurveEditorCtrl::SetControlPointCount(UINT aCount)
|
||||
{
|
||||
m_points.resize(aCount);
|
||||
m_projectedPoints.clear();
|
||||
}
|
||||
|
||||
UINT CCurveEditorCtrl::GetControlPointCount() const
|
||||
{
|
||||
return m_points.size();
|
||||
}
|
||||
|
||||
void CCurveEditorCtrl::AddControlPoint(const Vec2& rPosition)
|
||||
{
|
||||
m_points.push_back(CurvePoint(rPosition.x, rPosition.y));
|
||||
}
|
||||
|
||||
void CCurveEditorCtrl::ClearControlPoints()
|
||||
{
|
||||
m_points.clear();
|
||||
}
|
||||
|
||||
void CCurveEditorCtrl::SetControlPoint(UINT aIndex, const Vec2& rPosition)
|
||||
{
|
||||
assert(aIndex < m_points.size());
|
||||
|
||||
if (aIndex >= m_points.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_points[aIndex].pos = rPosition;
|
||||
}
|
||||
|
||||
void CCurveEditorCtrl::SetControlPointTangents(UINT aIndex, const Vec2& rLeft, const Vec2& rRight)
|
||||
{
|
||||
assert(aIndex < m_points.size());
|
||||
|
||||
if (aIndex >= m_points.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_points[aIndex].tanA = rLeft;
|
||||
m_points[aIndex].tanB = rRight;
|
||||
}
|
||||
|
||||
void CCurveEditorCtrl::GetControlPoint(UINT aIndex, Vec2& rOutPosition) const
|
||||
{
|
||||
assert(aIndex < m_points.size());
|
||||
|
||||
if (aIndex >= m_points.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
rOutPosition = m_points[aIndex].pos;
|
||||
}
|
||||
|
||||
void CCurveEditorCtrl::GetControlPointTangents(UINT aIndex, Vec2& rOutLeft, Vec2& rOutRight) const
|
||||
{
|
||||
assert(aIndex < m_points.size());
|
||||
|
||||
if (aIndex >= m_points.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
rOutLeft = m_points[aIndex].tanA;
|
||||
rOutRight = m_points[aIndex].tanB;
|
||||
}
|
||||
|
||||
void CCurveEditorCtrl::paintEvent(QPaintEvent* event)
|
||||
{
|
||||
QWidget::paintEvent(event);
|
||||
|
||||
QPainter dc(this);
|
||||
|
||||
QRect rc = geometry();
|
||||
QString str;
|
||||
QRect textSize;
|
||||
|
||||
dc.setFont(m_fntInfo);
|
||||
QFontMetrics fntMetrics(m_fntInfo);
|
||||
|
||||
if (m_flags & eFlag_Disabled)
|
||||
{
|
||||
// If disabled, just draw a blank square.
|
||||
dc.fillRect(rc, CurveEditor::kColor_Disabled);
|
||||
|
||||
dc.setPen(CurveEditor::kColor_DisabledCross);
|
||||
dc.drawLine(0, 0, rc.width(), rc.height());
|
||||
|
||||
dc.drawLine(rc.width(), 0, 0, rc.height());
|
||||
return;
|
||||
}
|
||||
|
||||
dc.fillRect(rc, CurveEditor::kColor_Background);
|
||||
|
||||
dc.setPen(CurveEditor::kColor_MiddleLines);
|
||||
|
||||
if (m_flags & eFlag_ShowVerticalRuler)
|
||||
{
|
||||
float y = m_domainMinY;
|
||||
float grid = (m_domainMaxY - m_domainMinY) / m_gridSplits.y;
|
||||
QPoint p;
|
||||
|
||||
for (int i = 0; i <= m_gridSplits.y; ++i)
|
||||
{
|
||||
p = ProjectPoint(0, y);
|
||||
dc.drawLine(m_padding, p.y(), rc.width() - m_padding, p.y());
|
||||
|
||||
if (m_flags & eFlag_ShowVerticalRulerText)
|
||||
{
|
||||
if (m_labelsY.empty())
|
||||
{
|
||||
str.asprintf("%0.2f", y);
|
||||
}
|
||||
else
|
||||
{
|
||||
str = m_labelsY[i];
|
||||
}
|
||||
textSize = fntMetrics.tightBoundingRect(str);
|
||||
dc.drawText(2, p.y(), str);
|
||||
}
|
||||
|
||||
y += grid;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_flags & eFlag_ShowHorizontalRuler)
|
||||
{
|
||||
float x = m_domainMinX;
|
||||
float grid = (m_domainMaxX - m_domainMinX) / m_gridSplits.x;
|
||||
QPoint p;
|
||||
|
||||
for (int i = 0; i <= m_gridSplits.x; ++i)
|
||||
{
|
||||
p = ProjectPoint(x, 0);
|
||||
dc.drawLine(p.x(), m_padding, p.x(), rc.height() - m_padding);
|
||||
|
||||
if (m_flags & eFlag_ShowHorizontalRulerText)
|
||||
{
|
||||
if (m_labelsX.empty())
|
||||
{
|
||||
str.asprintf("%0.2f", x);
|
||||
}
|
||||
else
|
||||
{
|
||||
str = m_labelsX[i];
|
||||
}
|
||||
textSize = fntMetrics.tightBoundingRect(str);
|
||||
|
||||
p.setX(p.x() + 2);
|
||||
|
||||
if (p.x() + textSize.width() > width())
|
||||
{
|
||||
p.setX(width() - textSize.width());
|
||||
}
|
||||
|
||||
dc.drawText(p.x(), height() - m_padding + textSize.height() + 2, str);
|
||||
}
|
||||
|
||||
x += grid;
|
||||
}
|
||||
}
|
||||
|
||||
dc.setPen(CurveEditor::kColor_MarkLines);
|
||||
|
||||
if (m_flags & eFlag_ShowVerticalRuler)
|
||||
{
|
||||
QPoint p;
|
||||
for (size_t i = 0; i < m_marksY.size(); ++i)
|
||||
{
|
||||
float v = m_marksY[i];
|
||||
if (v < m_domainMinY || v > m_domainMaxY)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
p = ProjectPoint(0, v);
|
||||
dc.drawLine(m_padding, p.y(), width() - m_padding, p.y());
|
||||
}
|
||||
}
|
||||
|
||||
if (m_flags & eFlag_ShowHorizontalRuler)
|
||||
{
|
||||
QPoint p;
|
||||
for (size_t i = 0; i < m_marksX.size(); ++i)
|
||||
{
|
||||
float v = m_marksX[i];
|
||||
if (v < m_domainMinX || v > m_domainMaxX)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
p = ProjectPoint(v, 0);
|
||||
dc.drawLine(p.x(), m_padding, p.x(), height() - m_padding);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_flags & eFlag_ShowPaddingBorder)
|
||||
{
|
||||
dc.setPen(CurveEditor::kColor_PaddingBorder);
|
||||
dc.drawRect(m_padding, m_padding, width() - m_padding * 2, height() - m_padding * 2);
|
||||
}
|
||||
|
||||
if (m_bDragging
|
||||
&& !m_selectedIndices.empty()
|
||||
&& (m_flags & eFlag_ShowMovingPointAxis))
|
||||
{
|
||||
const Vec2& crtPos = m_points[m_selectedIndices[0]].pos;
|
||||
|
||||
dc.setBrush(CurveEditor::kColor_TextCrtPos);
|
||||
str.asprintf("(%0.2f,%0.2f)", crtPos.x, crtPos.y);
|
||||
textSize = fntMetrics.tightBoundingRect(str);
|
||||
const int kOffsetFromPointer = 5;
|
||||
QPoint txtPos(m_lastMousePoint.x() + kOffsetFromPointer, m_lastMousePoint.y() + kOffsetFromPointer);
|
||||
|
||||
if (txtPos.x() + textSize.width() > width())
|
||||
{
|
||||
txtPos.setX(width() - textSize.width());
|
||||
}
|
||||
|
||||
if (txtPos.y() + textSize.height() > height())
|
||||
{
|
||||
txtPos.setY(height() - textSize.height());
|
||||
}
|
||||
|
||||
dc.drawText(txtPos, str);
|
||||
}
|
||||
|
||||
ComputeTangents();
|
||||
UpdateProjectedPoints();
|
||||
|
||||
// for curve debug, tangents poly, don't delete
|
||||
// dc.setPen(Qt::black);
|
||||
// dc.drawPolyline(m_projectedPoints.data(), m_projectedPoints.size());
|
||||
|
||||
dc.setPen(CurveEditor::kColor_Curve);
|
||||
|
||||
// curve
|
||||
QPainterPath bezierPath;
|
||||
bezierPath.moveTo(m_projectedPoints[0]);
|
||||
for (int i = 1; i < m_projectedPoints.size(); i += 3)
|
||||
{
|
||||
bezierPath.cubicTo(m_projectedPoints[i], m_projectedPoints[i + 1], m_projectedPoints[i + 2]);
|
||||
}
|
||||
dc.drawPath(bezierPath);
|
||||
|
||||
// curve control point handles
|
||||
if (m_flags & eFlag_ShowPointHandles)
|
||||
{
|
||||
for (size_t i = 0; i < m_points.size(); ++i)
|
||||
{
|
||||
QPoint ptProj = ProjectPoint(m_points[i].pos.x, m_points[i].pos.y);
|
||||
QRect rcHandle(0, 0, CurveEditor::kHandleSize, CurveEditor::kHandleSize);
|
||||
rcHandle.moveCenter(ptProj);
|
||||
|
||||
std::vector<int>::iterator iter =
|
||||
std::find(m_selectedIndices.begin(), m_selectedIndices.end(), i);
|
||||
|
||||
bool bSelected = (iter != m_selectedIndices.end());
|
||||
|
||||
if (bSelected && m_bDragging)
|
||||
{
|
||||
dc.setPen(m_selCrossPen);
|
||||
dc.drawLine(0, ptProj.y(), width(), ptProj.y());
|
||||
dc.drawLine(ptProj.x(), 0, ptProj.x(), height());
|
||||
}
|
||||
|
||||
dc.fillRect(rcHandle, bSelected
|
||||
? CurveEditor::kColor_SelHandle
|
||||
: CurveEditor::kColor_NormalHandle);
|
||||
|
||||
dc.setPen(CurveEditor::kColor_HandleLight);
|
||||
dc.drawLine(ptProj.x() - CurveEditor::kHandleSizeHalf, ptProj.y() - CurveEditor::kHandleSizeHalf,
|
||||
ptProj.x() - CurveEditor::kHandleSizeHalf, ptProj.y() + CurveEditor::kHandleSizeHalf);
|
||||
dc.drawLine(ptProj.x() - CurveEditor::kHandleSizeHalf, ptProj.y() + CurveEditor::kHandleSizeHalf,
|
||||
ptProj.x() + CurveEditor::kHandleSizeHalf, ptProj.y() + CurveEditor::kHandleSizeHalf);
|
||||
dc.setPen(CurveEditor::kColor_HandleShadow);
|
||||
dc.drawLine(ptProj.x() + CurveEditor::kHandleSizeHalf, ptProj.y() + CurveEditor::kHandleSizeHalf,
|
||||
ptProj.x() + CurveEditor::kHandleSizeHalf, ptProj.y() - CurveEditor::kHandleSizeHalf);
|
||||
dc.drawLine(ptProj.x() + CurveEditor::kHandleSizeHalf, ptProj.y() - CurveEditor::kHandleSizeHalf,
|
||||
ptProj.x() - CurveEditor::kHandleSizeHalf, ptProj.y() - CurveEditor::kHandleSizeHalf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CCurveEditorCtrl::ComputeTangents()
|
||||
{
|
||||
for (size_t i = 0; i < m_points.size(); ++i)
|
||||
{
|
||||
m_points[i].tanA = m_points[i].pos;
|
||||
m_points[i].tanB = m_points[i].pos;
|
||||
}
|
||||
|
||||
int maxIndex = m_points.size() - 1;
|
||||
|
||||
for (size_t i = 0; i < m_points.size(); ++i)
|
||||
{
|
||||
if (i > maxIndex)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
Vec2& p2 = m_points[i].pos;
|
||||
Vec2& back = m_points[i].tanA;
|
||||
Vec2& forw = m_points[i].tanB;
|
||||
const float kEpsilon = 0.000001f;
|
||||
|
||||
// first point
|
||||
if (i == 0)
|
||||
{
|
||||
back = p2;
|
||||
|
||||
if (maxIndex == 1)
|
||||
{
|
||||
Vec2& p3 = m_points[i + 1].pos;
|
||||
forw = p2 + (p3 - p2) / 3.0f;
|
||||
}
|
||||
else if (maxIndex > 0)
|
||||
{
|
||||
Vec2& p3 = m_points[i + 1].pos;
|
||||
Vec2& pb3 = m_points[i + 1].tanA;
|
||||
|
||||
float lenOsn = (pb3 - p2).GetLength();
|
||||
float lenb = (p3 - p2).GetLength();
|
||||
|
||||
if (lenOsn > kEpsilon && lenb > kEpsilon)
|
||||
{
|
||||
forw = p2 + (pb3 - p2) / (lenOsn / lenb * 3.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
forw = p2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (i == maxIndex)
|
||||
{
|
||||
forw = p2;
|
||||
|
||||
if (i > 0)
|
||||
{
|
||||
Vec2& p1 = m_points[i - 1].pos;
|
||||
Vec2& pf1 = m_points[i - 1].tanB;
|
||||
|
||||
float lenOsn = (pf1 - p2).GetLength();
|
||||
float lenf = (p1 - p2).GetLength();
|
||||
|
||||
if (lenOsn > kEpsilon && lenf > kEpsilon)
|
||||
{
|
||||
back = p2 + (pf1 - p2) / (lenOsn / lenf * 3.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
back = p2;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (i >= 1 && i <= maxIndex - 1)
|
||||
{
|
||||
Vec2& p1 = m_points[i - 1].pos;
|
||||
Vec2& p3 = m_points[i + 1].pos;
|
||||
|
||||
float lenOsn = (p3 - p1).GetLength();
|
||||
float lenb = (p1 - p2).GetLength();
|
||||
float lenf = (p3 - p2).GetLength();
|
||||
|
||||
if (lenOsn > kEpsilon
|
||||
&& lenf > kEpsilon
|
||||
&& lenb > kEpsilon)
|
||||
{
|
||||
back = p2 + (p1 - p3) * (lenb / lenOsn / 3.0f);
|
||||
forw = p2 + (p3 - p1) * (lenf / lenOsn / 3.0f);
|
||||
}
|
||||
}
|
||||
|
||||
ClampToDomain(back);
|
||||
ClampToDomain(forw);
|
||||
}
|
||||
|
||||
// fix tangents in relation of one to another
|
||||
for (size_t i = 0; i < m_points.size(); ++i)
|
||||
{
|
||||
Vec2& p = m_points[i].pos;
|
||||
Vec2& tanA = m_points[i].tanA;
|
||||
Vec2& tanB = m_points[i].tanB;
|
||||
|
||||
if (i < m_points.size() - 1)
|
||||
{
|
||||
if (tanB.x > m_points[i + 1].tanA.x)
|
||||
{
|
||||
tanB.x = (m_points[i + 1].pos.x + p.x) * 0.5f;
|
||||
}
|
||||
}
|
||||
if (i > 0)
|
||||
{
|
||||
if (tanA.x < m_points[i - 1].tanB.x)
|
||||
{
|
||||
tanA.x = (m_points[i - 1].pos.x + p.x) * 0.5f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CCurveEditorCtrl::UpdateProjectedPoints()
|
||||
{
|
||||
m_projectedPoints.resize(m_points.size() * 3 - 2);
|
||||
|
||||
int numPts = 0;
|
||||
|
||||
for (size_t i = 0; i < m_points.size(); ++i)
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
m_projectedPoints[numPts++] = ProjectPoint(m_points[i].pos.x, m_points[i].pos.y);
|
||||
m_projectedPoints[numPts++] = ProjectPoint(m_points[i].tanB.x, m_points[i].tanB.y);
|
||||
}
|
||||
else if (i == m_points.size() - 1)
|
||||
{
|
||||
m_projectedPoints[numPts++] = ProjectPoint(m_points[i].tanA.x, m_points[i].tanA.y);
|
||||
m_projectedPoints[numPts++] = ProjectPoint(m_points[i].pos.x, m_points[i].pos.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_projectedPoints[numPts++] = ProjectPoint(m_points[i].tanA.x, m_points[i].tanA.y);
|
||||
m_projectedPoints[numPts++] = ProjectPoint(m_points[i].pos.x, m_points[i].pos.y);
|
||||
m_projectedPoints[numPts++] = ProjectPoint(m_points[i].tanB.x, m_points[i].tanB.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CCurveEditorCtrl::ClampToDomain(Vec2& rVec)
|
||||
{
|
||||
if (rVec.x < m_domainMinX)
|
||||
{
|
||||
rVec.x = m_domainMinX;
|
||||
}
|
||||
else if (rVec.x > m_domainMaxX)
|
||||
{
|
||||
rVec.x = m_domainMaxX;
|
||||
}
|
||||
|
||||
if (rVec.y < m_domainMinY)
|
||||
{
|
||||
rVec.y = m_domainMinY;
|
||||
}
|
||||
else if (rVec.y > m_domainMaxY)
|
||||
{
|
||||
rVec.y = m_domainMaxY;
|
||||
}
|
||||
}
|
||||
|
||||
void CCurveEditorCtrl::GenerateDefaultCurve()
|
||||
{
|
||||
m_points.clear();
|
||||
m_domainMinX = 0.0f;
|
||||
m_domainMinY = 0.0f;
|
||||
m_domainMaxX = 1.0f;
|
||||
m_domainMaxY = 1.0f;
|
||||
m_points.push_back(CurvePoint(0.00f, 0.00f));
|
||||
m_points.push_back(CurvePoint(0.25f, 0.25f));
|
||||
m_points.push_back(CurvePoint(0.50f, 0.50f));
|
||||
m_points.push_back(CurvePoint(0.75f, 0.75f));
|
||||
m_points.push_back(CurvePoint(1.00f, 1.00f));
|
||||
}
|
||||
|
||||
void CCurveEditorCtrl::mousePressEvent(QMouseEvent* event)
|
||||
{
|
||||
QWidget::mousePressEvent(event);
|
||||
if (event->button() != Qt::LeftButton)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const QPoint point = event->pos();
|
||||
if (m_bAllowMouse)
|
||||
{
|
||||
bool bSimpleSelect = !(event->modifiers() & Qt::ShiftModifier) && !(event->modifiers() & Qt::ControlModifier);
|
||||
|
||||
if (bSimpleSelect)
|
||||
{
|
||||
m_selectedIndices.clear();
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < m_points.size(); ++i)
|
||||
{
|
||||
QPoint ptProj = ProjectPoint(m_points[i].pos.x, m_points[i].pos.y);
|
||||
|
||||
QRect rcHandle(0, 0, CurveEditor::kHandleSize, CurveEditor::kHandleSize);
|
||||
rcHandle.moveCenter(ptProj);
|
||||
|
||||
if (rcHandle.contains(point))
|
||||
{
|
||||
if (bSimpleSelect)
|
||||
{
|
||||
m_selectedIndices.push_back(i);
|
||||
break;
|
||||
}
|
||||
|
||||
if (event->modifiers() & Qt::ShiftModifier)
|
||||
{
|
||||
m_selectedIndices.push_back(i);
|
||||
}
|
||||
else if (event->modifiers() & Qt::ControlModifier)
|
||||
{
|
||||
std::vector<int>::iterator iter =
|
||||
std::find(m_selectedIndices.begin(), m_selectedIndices.end(), i);
|
||||
|
||||
if (iter == m_selectedIndices.end())
|
||||
{
|
||||
m_selectedIndices.push_back(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_selectedIndices.erase(iter);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_bMouseDown = true;
|
||||
m_lastMousePoint = point;
|
||||
}
|
||||
|
||||
grabMouse();
|
||||
update();
|
||||
}
|
||||
|
||||
void CCurveEditorCtrl::mouseReleaseEvent(QMouseEvent* event)
|
||||
{
|
||||
QWidget::mouseReleaseEvent(event);
|
||||
if (event->button() != Qt::LeftButton)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_bMouseDown = false;
|
||||
m_bDragging = false;
|
||||
m_selectedIndices.clear();
|
||||
|
||||
releaseMouse();
|
||||
update();
|
||||
}
|
||||
|
||||
void CCurveEditorCtrl::mouseMoveEvent(QMouseEvent* event)
|
||||
{
|
||||
if (m_bMouseDown && !m_bDragging)
|
||||
{
|
||||
m_bDragging = true;
|
||||
}
|
||||
|
||||
m_bHovered = true;
|
||||
if (m_flags & eFlag_ShowCursorAlways)
|
||||
{
|
||||
m_bHovered = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_bHovered = false;
|
||||
|
||||
for (size_t i = 0; i < m_points.size(); ++i)
|
||||
{
|
||||
QPoint ptProj = ProjectPoint(m_points[i].pos.x, m_points[i].pos.y);
|
||||
QRect rcHandle(0, 0, CurveEditor::kHandleSize, CurveEditor::kHandleSize);
|
||||
rcHandle.moveCenter(ptProj);
|
||||
|
||||
if (rcHandle.contains(event->pos()))
|
||||
{
|
||||
m_bHovered = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (m_bDragging)
|
||||
{
|
||||
Vec2 v1 = UnprojectPoint(m_lastMousePoint);
|
||||
Vec2 v2 = UnprojectPoint(event->pos());
|
||||
Vec2 v = v1 - v2;
|
||||
|
||||
for (size_t i = 0; i < m_selectedIndices.size(); ++i)
|
||||
{
|
||||
int index = m_selectedIndices[i];
|
||||
CurvePoint& cpt = m_points[index];
|
||||
|
||||
// do not move first and last points on X
|
||||
if (index > 0 && index < m_points.size() - 1)
|
||||
{
|
||||
cpt.pos.x -= v.x;
|
||||
}
|
||||
|
||||
cpt.pos.y -= v.y;
|
||||
|
||||
// lets check if the point is overlapping its neighbours
|
||||
if (index > 0 && (index - 1) > 0)
|
||||
{
|
||||
if (cpt.pos.x < m_points[index - 1].pos.x)
|
||||
{
|
||||
CurvePoint p = m_points[index];
|
||||
|
||||
// swap!
|
||||
m_points[index] = m_points[index - 1];
|
||||
m_points[index - 1] = p;
|
||||
m_selectedIndices[i] = index - 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (index < m_points.size() - 1 && (index + 1) < m_points.size() - 1)
|
||||
{
|
||||
if (cpt.pos.x > m_points[index + 1].pos.x)
|
||||
{
|
||||
CurvePoint p = m_points[index];
|
||||
|
||||
// swap!
|
||||
m_points[index] = m_points[index + 1];
|
||||
m_points[index + 1] = p;
|
||||
m_selectedIndices[i] = index + 1;
|
||||
}
|
||||
}
|
||||
|
||||
ClampToDomain(cpt.pos);
|
||||
}
|
||||
|
||||
update();
|
||||
m_lastMousePoint = event->pos();
|
||||
}
|
||||
|
||||
QWidget::mouseMoveEvent(event);
|
||||
}
|
||||
|
||||
void CCurveEditorCtrl::MarkX(float value)
|
||||
{
|
||||
m_marksX.push_back(value);
|
||||
}
|
||||
|
||||
void CCurveEditorCtrl::MarkY(float value)
|
||||
{
|
||||
m_marksY.push_back(value);
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_CONTROLS_CURVEEDITORCTRL_H
|
||||
#define CRYINCLUDE_EDITOR_CONTROLS_CURVEEDITORCTRL_H
|
||||
#pragma once
|
||||
#include "Util/GdiUtil.h"
|
||||
#include <QWidget>
|
||||
#include <QPen>
|
||||
|
||||
|
||||
class CCurveEditorCtrl
|
||||
: public QWidget
|
||||
{
|
||||
public:
|
||||
enum EFlags
|
||||
{
|
||||
eFlag_ShowVerticalRuler = (1 << 0),
|
||||
eFlag_ShowHorizontalRuler = (1 << 1),
|
||||
eFlag_ShowVerticalRulerText = (1 << 2),
|
||||
eFlag_ShowHorizontalRulerText = (1 << 3),
|
||||
eFlag_ShowPaddingBorder = (1 << 4),
|
||||
eFlag_ShowMovingPointAxis = (1 << 5),
|
||||
eFlag_ShowPointHandles = (1 << 6),
|
||||
eFlag_ShowCursorAlways = (1 << 7),
|
||||
eFlag_Disabled = (1 << 8) // special case, when disabling preview window.
|
||||
};
|
||||
|
||||
CCurveEditorCtrl(QWidget* parent);
|
||||
virtual ~CCurveEditorCtrl();
|
||||
|
||||
void SetFlags(UINT aFlags);
|
||||
UINT GetFlags() const;
|
||||
void SetMouseEnable(bool bEnable = true) { m_bAllowMouse = bEnable; }
|
||||
bool GetMouseEnable() const {return m_bAllowMouse; }
|
||||
bool SetDomainBounds(float aMinX, float aMinY, float aMaxX, float aMaxY);
|
||||
void GetDomainBounds(float& rMinX, float& rMinY, float& rMaxX, float& rMaxY) const;
|
||||
// labelsX/labelsY must be null (to use default labels)
|
||||
// or contain aHorizontalSplits+1/aVerticalSplits+1 items.
|
||||
void SetGrid(UINT aHorizontalSplits, UINT aVerticalSplits, const QStringList& labelsX = QStringList(), const QStringList& labelsY = QStringList());
|
||||
void SetPadding(float padding) { m_padding = padding; }
|
||||
void MarkX(float value);
|
||||
void MarkY(float value);
|
||||
void AddControlPoint(const Vec2& rPosition);
|
||||
void ClearControlPoints();
|
||||
void SetControlPointCount(UINT aCount);
|
||||
UINT GetControlPointCount() const;
|
||||
void SetControlPoint(UINT aIndex, const Vec2& rPosition);
|
||||
void SetControlPointTangents(UINT aIndex, const Vec2& rLeft, const Vec2& rRight);
|
||||
void GetControlPoint(UINT aIndex, Vec2& rOutPosition) const;
|
||||
void GetControlPointTangents(UINT aIndex, Vec2& rOutLeft, Vec2& rOutRight) const;
|
||||
QPoint ProjectPoint(float x, float y);
|
||||
Vec2 UnprojectPoint(const QPoint& pt);
|
||||
void UpdateProjectedPoints();
|
||||
|
||||
protected:
|
||||
struct CurvePoint
|
||||
{
|
||||
CurvePoint(float aX = 0.0f, float aY = 0.0f)
|
||||
{
|
||||
pos.x = aX;
|
||||
pos.y = aY;
|
||||
}
|
||||
|
||||
Vec2 pos;
|
||||
Vec2 tanA, tanB;
|
||||
};
|
||||
|
||||
void ComputeTangents();
|
||||
void ClampToDomain(Vec2& rVec);
|
||||
void GenerateDefaultCurve();
|
||||
|
||||
void paintEvent(QPaintEvent* event) override;
|
||||
|
||||
std::vector<CurvePoint> m_points;
|
||||
std::vector<QPoint> m_projectedPoints;
|
||||
float m_domainMinX;
|
||||
float m_domainMinY;
|
||||
float m_domainMaxX;
|
||||
float m_domainMaxY;
|
||||
Vec2 m_gridSplits;
|
||||
int m_padding;
|
||||
bool m_bMouseDown, m_bDragging, m_bAllowMouse;
|
||||
bool m_bHovered;
|
||||
QPoint m_lastMousePoint;
|
||||
std::vector<int> m_selectedIndices;
|
||||
QFont m_fntInfo;
|
||||
QPen m_pen, m_selCrossPen;
|
||||
UINT m_flags;
|
||||
QStringList m_labelsX;
|
||||
QStringList m_labelsY;
|
||||
std::vector<float> m_marksX;
|
||||
std::vector<float> m_marksY;
|
||||
|
||||
void mousePressEvent(QMouseEvent* event) override;
|
||||
void mouseReleaseEvent(QMouseEvent* event) override;
|
||||
void mouseMoveEvent(QMouseEvent* event) override;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_CONTROLS_CURVEEDITORCTRL_H
|
||||
@@ -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"));
|
||||
@@ -729,9 +729,6 @@ QMenu* LevelEditorMenuHandler::CreateViewMenu()
|
||||
viewportViewsMenuWrapper.AddAction(ID_WIREFRAME);
|
||||
viewportViewsMenuWrapper.AddSeparator();
|
||||
|
||||
viewportViewsMenuWrapper.AddAction(ID_VIEW_GRIDSETTINGS);
|
||||
viewportViewsMenuWrapper.AddSeparator();
|
||||
|
||||
if (CViewManager::IsMultiViewportEnabled())
|
||||
{
|
||||
viewportViewsMenuWrapper.AddAction(ID_VIEW_CONFIGURELAYOUT);
|
||||
|
||||
@@ -85,7 +85,6 @@ AZ_POP_DISABLE_WARNING
|
||||
// Editor
|
||||
#include "Settings.h"
|
||||
|
||||
#include "Include/IBackgroundScheduleManager.h"
|
||||
#include "GameExporter.h"
|
||||
#include "GameResourcesExporter.h"
|
||||
|
||||
@@ -95,7 +94,6 @@ AZ_POP_DISABLE_WARNING
|
||||
#include "Core/QtEditorApplication.h"
|
||||
#include "StringDlg.h"
|
||||
#include "NewLevelDialog.h"
|
||||
#include "GridSettingsDialog.h"
|
||||
#include "LayoutConfigDialog.h"
|
||||
#include "ViewManager.h"
|
||||
#include "FileTypeUtils.h"
|
||||
@@ -132,7 +130,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 +387,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,11 +396,8 @@ 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)
|
||||
ON_COMMAND(ID_VIEW_CONFIGURELAYOUT, OnViewConfigureLayout)
|
||||
|
||||
ON_COMMAND(IDC_SELECTION, OnDummyCommand)
|
||||
@@ -444,7 +437,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 +519,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 +560,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 +1004,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 +1045,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 +1088,7 @@ BOOL CCryEditApp::CheckIfAlreadyRunning()
|
||||
}
|
||||
}
|
||||
|
||||
// Shader pre-caching may start multiple editor copies
|
||||
if (!FirstInstance(bForceNewInstance) && !m_bPrecacheShaderList)
|
||||
if (!FirstInstance(bForceNewInstance))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -1347,37 +1310,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())
|
||||
{
|
||||
@@ -2381,15 +2313,6 @@ int CCryEditApp::IdleProcessing(bool bBackgroundUpdate)
|
||||
#endif
|
||||
}
|
||||
|
||||
// process the work schedule - regardless if the app is active or not
|
||||
GetIEditor()->GetBackgroundScheduleManager()->Update();
|
||||
|
||||
// if there are active schedules keep updating the application
|
||||
if (GetIEditor()->GetBackgroundScheduleManager()->GetNumSchedules() > 0)
|
||||
{
|
||||
bActive = true;
|
||||
}
|
||||
|
||||
m_bPrevActive = bActive;
|
||||
|
||||
AZStd::chrono::system_clock::time_point now = AZStd::chrono::system_clock::now();
|
||||
@@ -2930,14 +2853,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 +3408,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);
|
||||
@@ -3540,14 +3447,6 @@ void CCryEditApp::OnUpdateWireframe(QAction* action)
|
||||
action->setChecked(nWireframe == R_WIREFRAME_MODE);
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CCryEditApp::OnViewGridsettings()
|
||||
{
|
||||
CGridSettingsDialog dlg;
|
||||
dlg.exec();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CCryEditApp::OnViewConfigureLayout()
|
||||
{
|
||||
@@ -3749,19 +3648,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()
|
||||
{
|
||||
|
||||
@@ -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,10 +364,8 @@ private:
|
||||
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
friend struct PythonTestOutputHandler;
|
||||
|
||||
void OnSnap();
|
||||
void OnWireframe();
|
||||
void OnUpdateWireframe(QAction* action);
|
||||
void OnViewGridsettings();
|
||||
void OnViewConfigureLayout();
|
||||
|
||||
// Tag Locations.
|
||||
@@ -409,8 +400,6 @@ private:
|
||||
void OnToolsScriptHelp();
|
||||
void OnViewCycle2dviewport();
|
||||
void OnDisplayGotoPosition();
|
||||
void OnSnapangle();
|
||||
void OnUpdateSnapangle(QAction* action);
|
||||
void OnChangemovespeedIncrease();
|
||||
void OnChangemovespeedDecrease();
|
||||
void OnChangemovespeedChangestep();
|
||||
|
||||
@@ -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]));
|
||||
}
|
||||
|
||||
{
|
||||
@@ -585,23 +579,13 @@ void CCryEditDoc::SerializeViewSettings(CXmlArchive& xmlAr)
|
||||
view->getAttr(viewerAnglesName.toUtf8().constData(), va);
|
||||
}
|
||||
|
||||
CViewport* pVP = GetIEditor()->GetViewManager()->GetView(i);
|
||||
Matrix34 tm = Matrix34::CreateRotationXYZ(va);
|
||||
tm.SetTranslation(vp);
|
||||
|
||||
|
||||
if (pVP)
|
||||
auto viewportContextManager = AZ::Interface<AZ::RPI::ViewportContextRequestsInterface>::Get();
|
||||
if (auto viewportContext = viewportContextManager->GetViewportContextById(i))
|
||||
{
|
||||
Matrix34 tm = Matrix34::CreateRotationXYZ(va);
|
||||
tm.SetTranslation(vp);
|
||||
pVP->SetViewTM(tm);
|
||||
}
|
||||
|
||||
// Load grid.
|
||||
auto gridName = QString("Grid%1").arg(useOldViewFormat ? "" : QString::number(i));
|
||||
XmlNodeRef gridNode = xmlAr.root->newChild(gridName.toUtf8().constData());
|
||||
|
||||
if (gridNode)
|
||||
{
|
||||
GetIEditor()->GetViewManager()->GetGrid()->Serialize(gridNode, xmlAr.bLoading);
|
||||
viewportContext->SetCameraTransform(LYTransformToAZTransform(tm));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -628,11 +612,6 @@ void CCryEditDoc::SerializeViewSettings(CXmlArchive& xmlAr)
|
||||
auto viewerAnglesName = QString("ViewerAngles%1").arg(i);
|
||||
view->setAttr(viewerAnglesName.toUtf8().constData(), angles);
|
||||
}
|
||||
|
||||
// Save grid.
|
||||
auto gridName = QString("Grid%1").arg(i);
|
||||
XmlNodeRef gridNode = xmlAr.root->newChild(gridName.toUtf8().constData());
|
||||
GetIEditor()->GetViewManager()->GetGrid()->Serialize(gridNode, xmlAr.bLoading);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -668,39 +647,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();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -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);
|
||||
@@ -441,8 +453,11 @@ void EditorViewportWidget::Update()
|
||||
}
|
||||
|
||||
m_updatingCameraPosition = true;
|
||||
auto transform = LYTransformToAZTransform(m_Camera.GetMatrix());
|
||||
m_renderViewport->GetViewportContext()->SetCameraTransform(transform);
|
||||
if (!ed_useNewCameraSystem)
|
||||
{
|
||||
m_renderViewport->GetViewportContext()->SetCameraTransform(LYTransformToAZTransform(m_Camera.GetMatrix()));
|
||||
}
|
||||
|
||||
AZ::Matrix4x4 clipMatrix;
|
||||
AZ::MakePerspectiveFovMatrixRH(
|
||||
clipMatrix,
|
||||
@@ -644,9 +659,6 @@ CBaseObject* EditorViewportWidget::GetCameraObject() const
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void EditorViewportWidget::OnEditorNotifyEvent(EEditorNotifyEvent event)
|
||||
{
|
||||
static ICVar* outputToHMD = gEnv->pConsole->GetCVar("output_to_hmd");
|
||||
AZ_Assert(outputToHMD, "cvar output_to_hmd is undeclared");
|
||||
|
||||
switch (event)
|
||||
{
|
||||
case eNotify_OnBeginGameMode:
|
||||
@@ -668,7 +680,6 @@ void EditorViewportWidget::OnEditorNotifyEvent(EEditorNotifyEvent event)
|
||||
if (deviceInfo)
|
||||
{
|
||||
// Note: This may also need to adjust the viewport size
|
||||
outputToHMD->Set(1);
|
||||
SetActiveWindow();
|
||||
SetFocus();
|
||||
SetSelected(true);
|
||||
@@ -688,10 +699,6 @@ void EditorViewportWidget::OnEditorNotifyEvent(EEditorNotifyEvent event)
|
||||
if (GetIEditor()->GetViewManager()->GetGameViewport() == this)
|
||||
{
|
||||
SetCurrentCursor(STD_CURSOR_DEFAULT);
|
||||
if (gSettings.bEnableGameModeVR)
|
||||
{
|
||||
outputToHMD->Set(0);
|
||||
}
|
||||
m_bInRotateMode = false;
|
||||
m_bInMoveMode = false;
|
||||
m_bInOrbitMode = false;
|
||||
@@ -791,10 +798,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 +1253,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 +2874,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
|
||||
};
|
||||
|
||||
@@ -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)
|
||||
@@ -423,7 +420,6 @@ AZ::Outcome<void, AZStd::string> CGameEngine::Init(
|
||||
#else
|
||||
sip.hWnd = hwndForInputSystem;
|
||||
#endif
|
||||
sip.hWndForInputSystem = hwndForInputSystem;
|
||||
|
||||
sip.pLogCallback = &m_logFile;
|
||||
sip.sLogFileName = "@log@/Editor.log";
|
||||
@@ -444,10 +440,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);
|
||||
@@ -510,7 +502,6 @@ AZ::Outcome<void, AZStd::string> CGameEngine::Init(
|
||||
|
||||
bool CGameEngine::InitGame(const char*)
|
||||
{
|
||||
// in editor we do it later, bExecuteCommandLine was set to false
|
||||
m_pISystem->ExecuteCommandLine();
|
||||
|
||||
return true;
|
||||
@@ -615,17 +606,9 @@ void CGameEngine::SwitchToInGame()
|
||||
|
||||
GetIEditor()->Notify(eNotify_OnBeginGameMode);
|
||||
|
||||
m_pISystem->SetThreadState(ESubsys_Physics, false);
|
||||
|
||||
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.
|
||||
@@ -659,8 +642,6 @@ void CGameEngine::SwitchToInEditor()
|
||||
}
|
||||
m_pISystem->GetIMovieSystem()->Reset(false, false);
|
||||
|
||||
m_pISystem->SetThreadState(ESubsys_Physics, false);
|
||||
|
||||
CViewport* pGameViewport = GetIEditor()->GetViewManager()->GetGameViewport();
|
||||
|
||||
m_pISystem->GetIMovieSystem()->EnablePhysicsEvents(m_bSimulationMode);
|
||||
@@ -792,12 +773,6 @@ void CGameEngine::SetSimulationMode(bool enabled, bool bOnlyPhysics)
|
||||
|
||||
if (enabled)
|
||||
{
|
||||
CRuler* pRuler = GetIEditor()->GetRuler();
|
||||
if (pRuler)
|
||||
{
|
||||
pRuler->SetActive(false);
|
||||
}
|
||||
|
||||
GetIEditor()->Notify(eNotify_OnBeginSimulationMode);
|
||||
}
|
||||
else
|
||||
@@ -810,8 +785,6 @@ void CGameEngine::SetSimulationMode(bool enabled, bool bOnlyPhysics)
|
||||
// Enables engine to know about simulation mode.
|
||||
gEnv->SetIsEditorSimulationMode(enabled);
|
||||
|
||||
m_pISystem->SetThreadState(ESubsys_Physics, false);
|
||||
|
||||
if (m_bSimulationMode)
|
||||
{
|
||||
// [Anton] the order of the next 3 calls changed, since, EVENT_INGAME loads physics state (if any),
|
||||
@@ -922,22 +895,6 @@ void CGameEngine::Update()
|
||||
// [marco] check current sound and vis areas for music etc.
|
||||
// but if in game mode, 'cos is already done in the above call to game->update()
|
||||
unsigned int updateFlags = ESYSUPDATE_EDITOR;
|
||||
|
||||
CRuler* pRuler = GetIEditor()->GetRuler();
|
||||
const bool bRulerNeedsUpdate = (pRuler && pRuler->HasQueuedPaths());
|
||||
|
||||
if (!m_bSimulationMode)
|
||||
{
|
||||
updateFlags |= ESYSUPDATE_IGNORE_PHYSICS;
|
||||
}
|
||||
|
||||
bool bUpdateAIPhysics = GetSimulationMode();
|
||||
|
||||
if (bUpdateAIPhysics)
|
||||
{
|
||||
updateFlags |= ESYSUPDATE_EDITOR_AI_PHYSICS;
|
||||
}
|
||||
|
||||
GetIEditor()->GetAnimation()->Update();
|
||||
GetIEditor()->GetSystem()->UpdatePreTickBus(updateFlags);
|
||||
componentApplication->Tick(gEnv->pTimer->GetFrameTime(ITimer::ETIMER_GAME));
|
||||
|
||||
@@ -79,7 +79,6 @@ public:
|
||||
AZ::Outcome<void, AZStd::string> Init(
|
||||
bool bPreviewMode,
|
||||
bool bTestMode,
|
||||
bool bShaderCacheGen,
|
||||
const char* sCmdLine,
|
||||
IInitializeUIInfo* logo,
|
||||
HWND hwndForInputSystem);
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 "Grid.h"
|
||||
|
||||
// Editor
|
||||
#include "Settings.h"
|
||||
#include "Objects/SelectionGroup.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
CGrid::CGrid()
|
||||
{
|
||||
scale = 1;
|
||||
size = 1;
|
||||
majorLine = 16;
|
||||
bEnabled = true;
|
||||
rotationAngles = Ang3(0.0f, 0.0f, 0.0f);
|
||||
translation = Vec3(0.0f, 0.0f, 0.0f);
|
||||
|
||||
bAngleSnapEnabled = true;
|
||||
angleSnap = 5;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
Vec3 CGrid::Snap(const Vec3& vec) const
|
||||
{
|
||||
if (!bEnabled || size < 0.001)
|
||||
{
|
||||
return vec;
|
||||
}
|
||||
Vec3 snapped;
|
||||
snapped.x = floor((vec.x / size) / scale + 0.5) * size * scale;
|
||||
snapped.y = floor((vec.y / size) / scale + 0.5) * size * scale;
|
||||
snapped.z = floor((vec.z / size) / scale + 0.5) * size * scale;
|
||||
return snapped;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
Vec3 CGrid::Snap(const Vec3& vec, double fZoom) const
|
||||
{
|
||||
if (!bEnabled || size < 0.001f)
|
||||
{
|
||||
return vec;
|
||||
}
|
||||
|
||||
Matrix34 tm = GetMatrix();
|
||||
|
||||
double zoomscale = scale * fZoom;
|
||||
Vec3 snapped;
|
||||
|
||||
Matrix34 invtm = tm.GetInverted();
|
||||
|
||||
snapped = invtm * vec;
|
||||
|
||||
snapped.x = floor((snapped.x / size) / zoomscale + 0.5) * size * zoomscale;
|
||||
snapped.y = floor((snapped.y / size) / zoomscale + 0.5) * size * zoomscale;
|
||||
snapped.z = floor((snapped.z / size) / zoomscale + 0.5) * size * zoomscale;
|
||||
|
||||
snapped = tm * snapped;
|
||||
|
||||
return snapped;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
double CGrid::SnapAngle(double angle) const
|
||||
{
|
||||
if (!bAngleSnapEnabled)
|
||||
{
|
||||
return angle;
|
||||
}
|
||||
return floor(angle / angleSnap + 0.5) * angleSnap;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
Ang3 CGrid::SnapAngle(const Ang3& vec) const
|
||||
{
|
||||
if (!bAngleSnapEnabled)
|
||||
{
|
||||
return vec;
|
||||
}
|
||||
Ang3 snapped;
|
||||
snapped.x = floor(vec.x / angleSnap + 0.5) * angleSnap;
|
||||
snapped.y = floor(vec.y / angleSnap + 0.5) * angleSnap;
|
||||
snapped.z = floor(vec.z / angleSnap + 0.5) * angleSnap;
|
||||
return snapped;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CGrid::Serialize(XmlNodeRef& xmlNode, bool bLoading)
|
||||
{
|
||||
if (bLoading)
|
||||
{
|
||||
// Loading.
|
||||
xmlNode->getAttr("Size", size);
|
||||
xmlNode->getAttr("Scale", scale);
|
||||
xmlNode->getAttr("Enabled", bEnabled);
|
||||
xmlNode->getAttr("MajorSize", majorLine);
|
||||
xmlNode->getAttr("AngleSnap", angleSnap);
|
||||
xmlNode->getAttr("AngleSnapEnabled", bAngleSnapEnabled);
|
||||
if (size < 0.01)
|
||||
{
|
||||
size = 0.01;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Saving.
|
||||
xmlNode->setAttr("Size", size);
|
||||
xmlNode->setAttr("Scale", scale);
|
||||
xmlNode->setAttr("Enabled", bEnabled);
|
||||
xmlNode->setAttr("MajorSize", majorLine);
|
||||
xmlNode->setAttr("AngleSnap", angleSnap);
|
||||
xmlNode->setAttr("AngleSnapEnabled", bAngleSnapEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
Matrix34 CGrid::GetMatrix() const
|
||||
{
|
||||
Matrix34 tm;
|
||||
|
||||
if (gSettings.snap.bGridUserDefined)
|
||||
{
|
||||
Ang3 angles = Ang3(rotationAngles.x * gf_PI / 180.0, rotationAngles.y * gf_PI / 180.0, rotationAngles.z * gf_PI / 180.0);
|
||||
|
||||
tm = Matrix33::CreateRotationXYZ(angles);
|
||||
}
|
||||
else if (GetIEditor()->GetReferenceCoordSys() == COORDS_LOCAL)
|
||||
{
|
||||
tm.SetIdentity();
|
||||
}
|
||||
else
|
||||
{
|
||||
tm.SetIdentity();
|
||||
}
|
||||
|
||||
return tm;
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_GRID_H
|
||||
#define CRYINCLUDE_EDITOR_GRID_H
|
||||
|
||||
#pragma once
|
||||
|
||||
/** Definition of grid used in 2D viewports.
|
||||
*/
|
||||
class SANDBOX_API CGrid
|
||||
{
|
||||
public:
|
||||
//! Resolution of grid, it must be multiply of 2.
|
||||
double size;
|
||||
//! Draw major lines every Nth grid line.
|
||||
int majorLine;
|
||||
//! True if grid enabled.
|
||||
bool bEnabled;
|
||||
//! Meters per grid unit.
|
||||
double scale;
|
||||
|
||||
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
Ang3 rotationAngles;
|
||||
Vec3 translation;
|
||||
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
|
||||
//! If snap to angle.
|
||||
bool bAngleSnapEnabled;
|
||||
double angleSnap;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
CGrid();
|
||||
|
||||
//! Snap vector to this grid.
|
||||
Vec3 Snap(const Vec3& vec) const;
|
||||
Vec3 Snap(const Vec3& vec, double fZoom) const;
|
||||
|
||||
//! Snap angle to current angle snapping value.
|
||||
double SnapAngle(double angle) const;
|
||||
//! Snap angle to current angle snapping value.
|
||||
Ang3 SnapAngle(const Ang3& angle) const;
|
||||
|
||||
//! Enable or disable grid.
|
||||
void Enable(bool enable) { bEnabled = enable; }
|
||||
//! Check if grid enabled.
|
||||
bool IsEnabled() const { return bEnabled; }
|
||||
|
||||
//! Enables or disable angle snapping.
|
||||
void EnableAngleSnap(bool enable) { bAngleSnapEnabled = enable; };
|
||||
|
||||
//! Return if snapping of angle is enabled.
|
||||
bool IsAngleSnapEnabled() const { return bAngleSnapEnabled; };
|
||||
//! Returns ammount of snapping for angle in degrees.
|
||||
double GetAngleSnap() const { return angleSnap; };
|
||||
|
||||
void Serialize(XmlNodeRef& xmlNode, bool bLoading);
|
||||
|
||||
//! Get transformation matrix of gird.
|
||||
Matrix34 GetMatrix() const;
|
||||
};
|
||||
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_GRID_H
|
||||
@@ -1,169 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#include "EditorDefs.h"
|
||||
|
||||
#include "GridSettingsDialog.h"
|
||||
|
||||
// Editor
|
||||
#include "Settings.h"
|
||||
#include "Objects/SelectionGroup.h"
|
||||
#include "ViewManager.h"
|
||||
|
||||
|
||||
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
#include <ui_GridSettingsDialog.h>
|
||||
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
|
||||
// CGridSettingsDialog dialog
|
||||
|
||||
CGridSettingsDialog::CGridSettingsDialog(QWidget* pParent /*=NULL*/)
|
||||
: QDialog(pParent)
|
||||
, ui(new Ui::CGridSettingsDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
setWindowTitle(tr("Grid/Snap Settings"));
|
||||
|
||||
OnInitDialog();
|
||||
|
||||
connect(ui->m_userDefined, &QCheckBox::clicked, this, &CGridSettingsDialog::OnBnUserDefined);
|
||||
connect(ui->m_getFromObject, &QCheckBox::clicked, this, &CGridSettingsDialog::OnBnGetFromObject);
|
||||
|
||||
auto doubleSpinBoxValueChanged = static_cast<void(QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged);
|
||||
|
||||
connect(ui->m_angleX, doubleSpinBoxValueChanged, this, &CGridSettingsDialog::OnValueUpdate);
|
||||
connect(ui->m_angleY, doubleSpinBoxValueChanged, this, &CGridSettingsDialog::OnValueUpdate);
|
||||
connect(ui->m_angleZ, doubleSpinBoxValueChanged, this, &CGridSettingsDialog::OnValueUpdate);
|
||||
|
||||
connect(ui->m_gridSize, doubleSpinBoxValueChanged, this, &CGridSettingsDialog::OnValueUpdate);
|
||||
connect(ui->m_gridScale, doubleSpinBoxValueChanged, this, &CGridSettingsDialog::OnValueUpdate);
|
||||
connect(ui->m_CPSize, doubleSpinBoxValueChanged, this, &CGridSettingsDialog::OnValueUpdate);
|
||||
|
||||
connect(ui->m_displayCP, &QCheckBox::clicked, this, &CGridSettingsDialog::OnValueUpdate);
|
||||
connect(ui->m_getFromObject, &QCheckBox::clicked, this, &CGridSettingsDialog::OnValueUpdate);
|
||||
|
||||
connect(ui->m_buttonBox, &QDialogButtonBox::accepted, this, &CGridSettingsDialog::accept);
|
||||
connect(ui->m_buttonBox, &QDialogButtonBox::rejected, this, &CGridSettingsDialog::reject);
|
||||
}
|
||||
|
||||
CGridSettingsDialog::~CGridSettingsDialog()
|
||||
{
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CGridSettingsDialog::OnInitDialog()
|
||||
{
|
||||
CGrid* pGrid = GetIEditor()->GetViewManager()->GetGrid();
|
||||
|
||||
ui->m_userDefined->setChecked(gSettings.snap.bGridUserDefined);
|
||||
ui->m_getFromObject->setChecked(gSettings.snap.bGridGetFromSelected);
|
||||
|
||||
ui->m_angleX->setValue(pGrid->rotationAngles.x);
|
||||
ui->m_angleY->setValue(pGrid->rotationAngles.y);
|
||||
ui->m_angleZ->setValue(pGrid->rotationAngles.z);
|
||||
|
||||
ui->m_translationX->setValue(pGrid->translation.x);
|
||||
ui->m_translationY->setValue(pGrid->translation.y);
|
||||
ui->m_translationZ->setValue(pGrid->translation.z);
|
||||
|
||||
ui->m_gridSize->setValue(pGrid->size);
|
||||
ui->m_gridScale->setValue(pGrid->scale);
|
||||
ui->m_snapToGrid->setChecked(pGrid->IsEnabled());
|
||||
|
||||
ui->m_angleSnap->setChecked(pGrid->IsAngleSnapEnabled());
|
||||
ui->m_angleSnapScale->setValue(pGrid->GetAngleSnap());
|
||||
ui->m_displayCP->setChecked(gSettings.snap.constructPlaneDisplay);
|
||||
|
||||
ui->m_CPSize->setValue(gSettings.snap.constructPlaneSize);
|
||||
ui->m_displaySnapMarker->setChecked(gSettings.snap.markerDisplay);
|
||||
ui->m_snapMarkerSize->setValue(gSettings.snap.markerSize);
|
||||
|
||||
ui->m_snapMarkerColor->SetColor(gSettings.snap.markerColor);
|
||||
|
||||
EnableGridPropertyControls(gSettings.snap.bGridUserDefined, gSettings.snap.bGridGetFromSelected);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CGridSettingsDialog::accept()
|
||||
{
|
||||
UpdateValues();
|
||||
gSettings.Save();
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
void CGridSettingsDialog::OnBnUserDefined()
|
||||
{
|
||||
EnableGridPropertyControls(ui->m_userDefined->isChecked(), ui->m_getFromObject->isChecked());
|
||||
OnValueUpdate();
|
||||
}
|
||||
|
||||
void CGridSettingsDialog::OnBnGetFromObject()
|
||||
{
|
||||
EnableGridPropertyControls(ui->m_userDefined->isChecked(), ui->m_getFromObject->isChecked());
|
||||
}
|
||||
|
||||
void CGridSettingsDialog::EnableGridPropertyControls(const bool isUserDefined, const bool isGetFromObject)
|
||||
{
|
||||
ui->m_getFromObject->setEnabled(isUserDefined == true);
|
||||
|
||||
ui->m_angleX->setEnabled(isUserDefined == true && isGetFromObject == false);
|
||||
ui->m_angleY->setEnabled(isUserDefined == true && isGetFromObject == false);
|
||||
ui->m_angleZ->setEnabled(isUserDefined == true && isGetFromObject == false);
|
||||
ui->m_translationX->setEnabled(isUserDefined == true && isGetFromObject == false);
|
||||
ui->m_translationY->setEnabled(isUserDefined == true && isGetFromObject == false);
|
||||
ui->m_translationZ->setEnabled(isUserDefined == true && isGetFromObject == false);
|
||||
ui->m_getAnglesFromObject->setEnabled(isUserDefined == true && isGetFromObject == false);
|
||||
ui->m_getTranslationFromObject->setEnabled(isUserDefined == true && isGetFromObject == false);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CGridSettingsDialog::UpdateValues()
|
||||
{
|
||||
CGrid* pGrid = GetIEditor()->GetViewManager()->GetGrid();
|
||||
|
||||
pGrid->Enable(ui->m_snapToGrid->isChecked());
|
||||
pGrid->size = ui->m_gridSize->value();
|
||||
pGrid->scale = ui->m_gridScale->value();
|
||||
|
||||
gSettings.snap.bGridUserDefined = ui->m_userDefined->isChecked();
|
||||
gSettings.snap.bGridGetFromSelected = ui->m_getFromObject->isChecked();
|
||||
pGrid->rotationAngles.x = ui->m_angleX->value();
|
||||
pGrid->rotationAngles.y = ui->m_angleY->value();
|
||||
pGrid->rotationAngles.z = ui->m_angleZ->value();
|
||||
pGrid->translation.x = ui->m_translationX->value();
|
||||
pGrid->translation.y = ui->m_translationY->value();
|
||||
pGrid->translation.z = ui->m_translationZ->value();
|
||||
|
||||
pGrid->bAngleSnapEnabled = ui->m_angleSnap->isChecked();
|
||||
pGrid->angleSnap = ui->m_angleSnapScale->value();
|
||||
|
||||
gSettings.snap.constructPlaneDisplay = ui->m_displayCP->isChecked();
|
||||
gSettings.snap.constructPlaneSize = ui->m_CPSize->value();
|
||||
|
||||
gSettings.snap.markerDisplay = ui->m_displaySnapMarker->isChecked();
|
||||
gSettings.snap.markerSize = ui->m_snapMarkerSize->value();
|
||||
gSettings.snap.markerColor = ui->m_snapMarkerColor->Color();
|
||||
|
||||
NotificationBus::Broadcast(&Notifications::OnGridValuesUpdated);
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CGridSettingsDialog::OnValueUpdate()
|
||||
{
|
||||
UpdateValues();
|
||||
GetIEditor()->UpdateViews(eRedrawViewports);
|
||||
}
|
||||
|
||||
#include <moc_GridSettingsDialog.cpp>
|
||||
@@ -1,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.
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_GRIDSETTINGSDIALOG_H
|
||||
#define CRYINCLUDE_EDITOR_GRIDSETTINGSDIALOG_H
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include <QDialog>
|
||||
#include <AzCore/EBus/EBus.h>
|
||||
#endif
|
||||
|
||||
// CGridSettingsDialog dialog
|
||||
|
||||
namespace Ui {
|
||||
class CGridSettingsDialog;
|
||||
}
|
||||
|
||||
class CGridSettingsDialog
|
||||
: public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
class Notifications
|
||||
: public AZ::EBusTraits
|
||||
{
|
||||
public:
|
||||
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
|
||||
|
||||
virtual void OnGridValuesUpdated() {}
|
||||
};
|
||||
|
||||
using NotificationBus = AZ::EBus<Notifications>;
|
||||
|
||||
CGridSettingsDialog(QWidget* pParent = nullptr); // standard constructor
|
||||
virtual ~CGridSettingsDialog();
|
||||
|
||||
private slots:
|
||||
void accept() override;
|
||||
void OnBnUserDefined();
|
||||
void OnBnGetFromObject();
|
||||
void OnValueUpdate();
|
||||
|
||||
private:
|
||||
void EnableGridPropertyControls(const bool isUserDefined, const bool isGetFromObject);
|
||||
|
||||
void OnInitDialog();
|
||||
void UpdateValues();
|
||||
|
||||
QScopedPointer<Ui::CGridSettingsDialog> ui;
|
||||
};
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_GRIDSETTINGSDIALOG_H
|
||||
@@ -1,505 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CGridSettingsDialog</class>
|
||||
<widget class="QDialog" name="CGridSettingsDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>307</width>
|
||||
<height>707</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="group1">
|
||||
<property name="title">
|
||||
<string>Grid</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="1" colspan="2">
|
||||
<widget class="QCheckBox" name="m_snapToGrid">
|
||||
<property name="text">
|
||||
<string>Snap to Grid</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label1">
|
||||
<property name="text">
|
||||
<string>Grid Lines Every:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QDoubleSpinBox" name="m_gridSize">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>0.010000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>1024.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.010000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QLabel" name="label2">
|
||||
<property name="text">
|
||||
<string>units</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label3">
|
||||
<property name="text">
|
||||
<string>Units Per Meter:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QDoubleSpinBox" name="m_gridScale">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>0.010000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>1024.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.010000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QLabel" name="label4">
|
||||
<property name="text">
|
||||
<string>meters</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1" colspan="2">
|
||||
<widget class="QCheckBox" name="m_userDefined">
|
||||
<property name="text">
|
||||
<string>User Defined Grid</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="3">
|
||||
<widget class="QCheckBox" name="m_getFromObject">
|
||||
<property name="text">
|
||||
<string>Get Angles And Trans. From Selected</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label5">
|
||||
<property name="text">
|
||||
<string>Rotation by X:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QDoubleSpinBox" name="m_angleX">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-180.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>180.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.010000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="2">
|
||||
<widget class="QLabel" name="label6">
|
||||
<property name="text">
|
||||
<string>degrees</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="label7">
|
||||
<property name="text">
|
||||
<string>Rotation by Y:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QDoubleSpinBox" name="m_angleY">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-180.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>180.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.010000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="2">
|
||||
<widget class="QLabel" name="label8">
|
||||
<property name="text">
|
||||
<string>degrees</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="label9">
|
||||
<property name="text">
|
||||
<string>Rotation by Z:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<widget class="QDoubleSpinBox" name="m_angleZ">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-180.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>180.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.010000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="2">
|
||||
<widget class="QLabel" name="label10">
|
||||
<property name="text">
|
||||
<string>degrees</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="QLabel" name="label11">
|
||||
<property name="text">
|
||||
<string>Translation by X:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1">
|
||||
<widget class="QDoubleSpinBox" name="m_translationX">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.010000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="0">
|
||||
<widget class="QLabel" name="label12">
|
||||
<property name="text">
|
||||
<string>Translation by Y:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="1">
|
||||
<widget class="QDoubleSpinBox" name="m_translationY">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.010000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="0">
|
||||
<widget class="QLabel" name="label13">
|
||||
<property name="text">
|
||||
<string>Translation by Z:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="1">
|
||||
<widget class="QDoubleSpinBox" name="m_translationZ">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.010000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="0" colspan="3">
|
||||
<widget class="QPushButton" name="m_getAnglesFromObject">
|
||||
<property name="text">
|
||||
<string>Get Angles From Selected</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="12" column="0" colspan="3">
|
||||
<widget class="QPushButton" name="m_getTranslationFromObject">
|
||||
<property name="text">
|
||||
<string>Get Translation From Selected</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="group2">
|
||||
<property name="title">
|
||||
<string>Angle Snapping</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="1" column="2">
|
||||
<widget class="QSpinBox" name="m_angleSnapScale">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QLabel" name="label14">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>80</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>degrees</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2" colspan="2">
|
||||
<widget class="QCheckBox" name="m_angleSnap">
|
||||
<property name="text">
|
||||
<string>Angle Snap</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="label15">
|
||||
<property name="text">
|
||||
<string>Angle Snap:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="group3">
|
||||
<property name="title">
|
||||
<string>Construction Plane</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="label16">
|
||||
<property name="text">
|
||||
<string>Size:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="m_displayCP">
|
||||
<property name="text">
|
||||
<string>Display</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QDoubleSpinBox" name="m_CPSize">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.010000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Minimum</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>80</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
<zorder>m_displayCP</zorder>
|
||||
<zorder>m_CPSize</zorder>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="group4">
|
||||
<property name="title">
|
||||
<string>Snap Marker</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="3">
|
||||
<widget class="QDoubleSpinBox" name="m_snapMarkerSize">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.010000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="m_displaySnapMarker">
|
||||
<property name="text">
|
||||
<string>Display</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<widget class="ColorButton" name="m_snapMarkerColor">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>80</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Color</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="label17">
|
||||
<property name="text">
|
||||
<string>Size:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="m_buttonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>ColorButton</class>
|
||||
<extends>QToolButton</extends>
|
||||
<header location="global">QtUI/ColorButton.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -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.
|
||||
@@ -552,7 +550,6 @@ struct IEditor
|
||||
virtual class CViewManager* GetViewManager() = 0;
|
||||
virtual class CViewport* GetActiveView() = 0;
|
||||
virtual void SetActiveView(CViewport* viewport) = 0;
|
||||
virtual struct IBackgroundTaskManager* GetBackgroundTaskManager() = 0;
|
||||
virtual struct IEditorFileMonitor* GetFileMonitor() = 0;
|
||||
|
||||
// These are needed for Qt integration:
|
||||
@@ -589,8 +586,6 @@ struct IEditor
|
||||
virtual void SetSelectedRegion(const AABB& box) = 0;
|
||||
//! Get currently selected region.
|
||||
virtual void GetSelectedRegion(AABB& box) = 0;
|
||||
//! Get current ruler
|
||||
virtual CRuler* GetRuler() = 0;
|
||||
|
||||
virtual void SetOperationMode(EOperationMode mode) = 0;
|
||||
virtual EOperationMode GetOperationMode() = 0;
|
||||
@@ -635,7 +630,6 @@ struct IEditor
|
||||
//! Returns true if selection is made and false if selection is canceled.
|
||||
virtual bool SelectColor(QColor& color, QWidget* parent = 0) = 0;
|
||||
//! Get shader enumerator.
|
||||
virtual class CShaderEnum* GetShaderEnum() = 0;
|
||||
virtual class CUndoManager* GetUndoManager() = 0;
|
||||
//! Begin operation requiring undo
|
||||
//! Undo manager enters holding state.
|
||||
@@ -725,7 +719,6 @@ struct IEditor
|
||||
virtual ESystemConfigPlatform GetEditorConfigPlatform() const = 0;
|
||||
virtual void ReloadTemplates() = 0;
|
||||
virtual IResourceSelectorHost* GetResourceSelectorHost() = 0;
|
||||
virtual struct IBackgroundScheduleManager* GetBackgroundScheduleManager() = 0;
|
||||
virtual void ShowStatusText(bool bEnable) = 0;
|
||||
|
||||
// Provides a way to extend the context menu of an object. The function gets called every time the menu is opened.
|
||||
|
||||
@@ -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"
|
||||
@@ -68,12 +66,9 @@ AZ_POP_DISABLE_WARNING
|
||||
#include "Objects/SelectionGroup.h"
|
||||
#include "Objects/ObjectManager.h"
|
||||
|
||||
#include "BackgroundTaskManager.h"
|
||||
#include "BackgroundScheduleManager.h"
|
||||
#include "EditorFileMonitor.h"
|
||||
#include "MainStatusBar.h"
|
||||
|
||||
#include "SettingsBlock.h"
|
||||
#include "ResourceSelectorHost.h"
|
||||
#include "Util/FileUtil_impl.h"
|
||||
#include "Util/ImageUtil_impl.h"
|
||||
@@ -134,7 +129,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 +143,6 @@ CEditorImpl::CEditorImpl()
|
||||
, m_pSourceControl(nullptr)
|
||||
, m_pSelectionTreeManager(nullptr)
|
||||
, m_pUIEnumsDatabase(nullptr)
|
||||
, m_pRuler(nullptr)
|
||||
, m_pConsoleSync(nullptr)
|
||||
, m_pSettingsManager(nullptr)
|
||||
, m_pLevelIndependentFileMan(nullptr)
|
||||
@@ -181,11 +174,8 @@ CEditorImpl::CEditorImpl()
|
||||
regCtx.pCommandManager = m_pCommandManager;
|
||||
regCtx.pClassFactory = m_pClassFactory;
|
||||
m_pEditorFileMonitor.reset(new CEditorFileMonitor());
|
||||
m_pBackgroundTaskManager.reset(new BackgroundTaskManager::CTaskManager);
|
||||
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 +192,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 +324,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 +406,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 +426,6 @@ ISystem* CEditorImpl::GetSystem()
|
||||
return m_pSystem;
|
||||
}
|
||||
|
||||
IRenderer* CEditorImpl::GetRenderer()
|
||||
{
|
||||
if (gEnv)
|
||||
{
|
||||
return gEnv->pRenderer;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
IEditorClassFactory* CEditorImpl::GetClassFactory()
|
||||
{
|
||||
return m_pClassFactory;
|
||||
@@ -862,16 +839,6 @@ IIconManager* CEditorImpl::GetIconManager()
|
||||
return m_pIconManager;
|
||||
}
|
||||
|
||||
IBackgroundTaskManager* CEditorImpl::GetBackgroundTaskManager()
|
||||
{
|
||||
return m_pBackgroundTaskManager.get();
|
||||
}
|
||||
|
||||
IBackgroundScheduleManager* CEditorImpl::GetBackgroundScheduleManager()
|
||||
{
|
||||
return m_pBackgroundScheduleManager.get();
|
||||
}
|
||||
|
||||
IEditorFileMonitor* CEditorImpl::GetFileMonitor()
|
||||
{
|
||||
return m_pEditorFileMonitor.get();
|
||||
@@ -1182,11 +1149,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 +1531,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();
|
||||
@@ -1648,8 +1609,6 @@ ESystemConfigPlatform CEditorImpl::GetEditorConfigPlatform() const
|
||||
|
||||
void CEditorImpl::InitFinished()
|
||||
{
|
||||
SProjectSettingsBlock::Load();
|
||||
|
||||
if (!m_bInitialized)
|
||||
{
|
||||
m_bInitialized = true;
|
||||
|
||||
@@ -43,17 +43,13 @@ class CGameEngine;
|
||||
class CExportManager;
|
||||
class CErrorsDlg;
|
||||
class CIconManager;
|
||||
class CBackgroundTaskManager;
|
||||
class CTrackViewSequenceManager;
|
||||
class CEditorFileMonitor;
|
||||
class AzAssetWindow;
|
||||
class AzAssetBrowserRequestHandler;
|
||||
class AssetEditorRequestsHandler;
|
||||
class CAlembicCompiler;
|
||||
struct IBackgroundTaskManager;
|
||||
struct IBackgroundScheduleManager;
|
||||
struct IEditorFileMonitor;
|
||||
class CShaderEnum;
|
||||
class CVegetationMap;
|
||||
|
||||
|
||||
@@ -62,16 +58,6 @@ namespace Editor
|
||||
class EditorQtApplication;
|
||||
}
|
||||
|
||||
namespace BackgroundScheduleManager
|
||||
{
|
||||
class CScheduleManager;
|
||||
}
|
||||
|
||||
namespace BackgroundTaskManager
|
||||
{
|
||||
class CTaskManager;
|
||||
}
|
||||
|
||||
namespace WinWidget
|
||||
{
|
||||
class WinWidgetManager;
|
||||
@@ -116,7 +102,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
|
||||
@@ -181,8 +166,6 @@ public:
|
||||
IDataBaseManager* GetDBItemManager(EDataBaseItemType itemType);
|
||||
CMusicManager* GetMusicManager() { return m_pMusicManager; };
|
||||
|
||||
IBackgroundTaskManager* GetBackgroundTaskManager() override;
|
||||
IBackgroundScheduleManager* GetBackgroundScheduleManager() override;
|
||||
IEditorFileMonitor* GetFileMonitor() override;
|
||||
void RegisterEventLoopHook(IEventLoopHook* pHook) override;
|
||||
void UnregisterEventLoopHook(IEventLoopHook* pHook) override;
|
||||
@@ -215,7 +198,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 +238,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 +346,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 +370,6 @@ protected:
|
||||
CSelectionTreeManager* m_pSelectionTreeManager;
|
||||
|
||||
CUIEnumsDatabase* m_pUIEnumsDatabase;
|
||||
//! Currently used ruler
|
||||
CRuler* m_pRuler;
|
||||
//! CConsole Synchronization
|
||||
CConsoleSynchronization* m_pConsoleSync;
|
||||
//! Editor Settings Manager
|
||||
@@ -401,8 +379,6 @@ protected:
|
||||
|
||||
//! Export manager for exporting objects and a terrain from the game to DCC tools
|
||||
CExportManager* m_pExportManager;
|
||||
std::unique_ptr<BackgroundTaskManager::CTaskManager> m_pBackgroundTaskManager;
|
||||
std::unique_ptr<BackgroundScheduleManager::CScheduleManager> m_pBackgroundScheduleManager;
|
||||
std::unique_ptr<CEditorFileMonitor> m_pEditorFileMonitor;
|
||||
std::unique_ptr<IResourceSelectorHost> m_pResourceSelectorHost;
|
||||
QString m_selectFileBuffer;
|
||||
|
||||
@@ -1,207 +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.
|
||||
|
||||
//
|
||||
// IBackgroundScheduleManager manages schedule of group of larger operations that should be run in sequence
|
||||
//
|
||||
// Schedules are derived from IBackgroundSchedule and consist of a list of IBackgroundScheduleItems.
|
||||
// Each schedule item is executed IN ORDER for the previous item to complete first.
|
||||
// Each IBackgroundScheduleItems consists of list of user defined work via IBackgroundScheduleItemsWork classes.
|
||||
// Each schedule item work is executed IN PARALEL (they are all started when the item starts).
|
||||
//
|
||||
// Whenever a work item fails to complete the other work items are stopped, the schedule item is marked as "failed"
|
||||
// and so is the whole schedule.
|
||||
//
|
||||
// All logic is performed on the main thread although schedule items are free to use threads.
|
||||
// It is recommended to use IBackgroundTaskManager for dispatching a task list for every schedule work item.
|
||||
//
|
||||
// All objects in the schedule system are reference counted.
|
||||
//
|
||||
|
||||
// State of the whole schedule
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_INCLUDE_IBACKGROUNDSCHEDULEMANAGER_H
|
||||
#define CRYINCLUDE_EDITOR_INCLUDE_IBACKGROUNDSCHEDULEMANAGER_H
|
||||
#pragma once
|
||||
enum EScheduleState
|
||||
{
|
||||
// Item has not started yet but is on the list
|
||||
eScheduleState_Pending,
|
||||
|
||||
// We are processing this item
|
||||
eScheduleState_Processing,
|
||||
|
||||
// We are stopping the schedule
|
||||
eSccheduleState_Stopping,
|
||||
|
||||
// Schedule item has failed
|
||||
eScheduleState_Failed,
|
||||
|
||||
// Schedule item was canceled
|
||||
eScheduleState_Canceled,
|
||||
|
||||
// Schedule item has completed it's work
|
||||
eScheduleState_Completed,
|
||||
};
|
||||
|
||||
// State of the single schedule item
|
||||
enum EScheduleItemState
|
||||
{
|
||||
// Item has not started yet but is on the list
|
||||
eScheduleItemState_Pending,
|
||||
|
||||
// We are processing this item
|
||||
eScheduleItemState_Processing,
|
||||
|
||||
// We are stopping this item
|
||||
eScheduleItemState_Stopping,
|
||||
|
||||
// Schedule item has failed
|
||||
eScheduleItemState_Failed,
|
||||
|
||||
// Schedule item has completed it's work
|
||||
eScheduleItemState_Completed,
|
||||
};
|
||||
|
||||
// Work item status
|
||||
enum EScheduleWorkItemStatus
|
||||
{
|
||||
// Work is still not finished
|
||||
eScheduleWorkItemStatus_NotFinished,
|
||||
|
||||
// Work has failed
|
||||
eScheduleWorkItemStatus_Failed,
|
||||
|
||||
// Work has finished
|
||||
eScheduleWorkItemStatus_Finished,
|
||||
};
|
||||
|
||||
struct IBackgroundScheduleItemWork
|
||||
{
|
||||
// Get human readable description
|
||||
virtual const char* GetDescription() const = 0;
|
||||
|
||||
// Get work item progress
|
||||
virtual float GetProgress() const = 0;
|
||||
|
||||
// Called when the schedule item containing this work piece has started
|
||||
// If the work cannot be started for any reason return false.
|
||||
virtual bool OnStart() = 0;
|
||||
|
||||
// Called when the schedule item containing this work piece has been canceled or failed externally
|
||||
// Not called when schedule item completed without errors.
|
||||
// If the work cannot be stopped this frame return false.
|
||||
virtual bool OnStop() = 0;
|
||||
|
||||
// Called every frame to advance and check the work state
|
||||
// Should return one of the EBackgroundScheduleWorkItemStatus value
|
||||
virtual EScheduleWorkItemStatus OnUpdate() = 0;
|
||||
|
||||
// Reference counting
|
||||
virtual void AddRef() = 0;
|
||||
virtual void Release() = 0;
|
||||
|
||||
protected:
|
||||
virtual ~IBackgroundScheduleItemWork() {};
|
||||
};
|
||||
|
||||
struct IBackgroundScheduleItem
|
||||
{
|
||||
// Get name of the schedule (debug & display)
|
||||
virtual const char* GetDescription() const = 0;
|
||||
|
||||
// Get interal state
|
||||
virtual EScheduleItemState GetState() const = 0;
|
||||
|
||||
// Get overall progress of this schedule item
|
||||
virtual const float GetProgress() const = 0;
|
||||
|
||||
// Get number of work items in this schedule item
|
||||
virtual const uint32 GetNumWorkItems() const = 0;
|
||||
|
||||
// Get n-th work item from the schedule item
|
||||
virtual IBackgroundScheduleItemWork* GetWorkItem(const uint32 index) const = 0;
|
||||
|
||||
// Add work item to the schedule item
|
||||
virtual void AddWorkItem(IBackgroundScheduleItemWork* pWork) = 0;
|
||||
|
||||
// Reference counting
|
||||
virtual void AddRef() = 0;
|
||||
virtual void Release() = 0;
|
||||
|
||||
protected:
|
||||
virtual ~IBackgroundScheduleItem() {};
|
||||
};
|
||||
|
||||
struct IBackgroundSchedule
|
||||
{
|
||||
// Get name of the schedule (debug & display)
|
||||
virtual const char* GetDescription() const = 0;
|
||||
|
||||
// Get overall progress of the whole schedule
|
||||
virtual float GetProgress() const = 0;
|
||||
|
||||
// Get item being currently processed
|
||||
virtual IBackgroundScheduleItem* GetProcessedItem() const = 0;
|
||||
|
||||
// Get number of items in the schedule
|
||||
virtual const uint32 GetNumItems() const = 0;
|
||||
|
||||
// Get single schedule item
|
||||
virtual IBackgroundScheduleItem* GetItem(const uint32 index) const = 0;
|
||||
|
||||
// Get schedule item
|
||||
virtual EScheduleState GetState() const = 0;
|
||||
|
||||
// Cancel the whole schedule
|
||||
virtual void Cancel() = 0;
|
||||
|
||||
// Is the schedule canceled ?
|
||||
virtual bool IsCanceled() const = 0;
|
||||
|
||||
// Add schedule item at the end of the list
|
||||
virtual void AddItem(IBackgroundScheduleItem* pItem) = 0;
|
||||
|
||||
// Reference counting
|
||||
virtual void AddRef() = 0;
|
||||
virtual void Release() = 0;
|
||||
|
||||
protected:
|
||||
virtual ~IBackgroundSchedule() {};
|
||||
};
|
||||
|
||||
struct IBackgroundScheduleManager
|
||||
{
|
||||
virtual ~IBackgroundScheduleManager() {};
|
||||
|
||||
// Create empty schedule
|
||||
virtual IBackgroundSchedule* CreateSchedule(const char* szName) = 0;
|
||||
|
||||
// Create empty schedule item
|
||||
virtual IBackgroundScheduleItem* CreateScheduleItem(const char* szName) = 0;
|
||||
|
||||
// Issue a schedule to the list (will start processing it)
|
||||
virtual void SubmitSchedule(IBackgroundSchedule* pSchedule) = 0;
|
||||
|
||||
// Get number of schedules on the list
|
||||
virtual const uint32 GetNumSchedules() const = 0;
|
||||
|
||||
// Get n-th schedule
|
||||
virtual IBackgroundSchedule* GetSchedule(const uint32 index) const = 0;
|
||||
|
||||
// Advance work on the schedules
|
||||
virtual void Update() = 0;
|
||||
};
|
||||
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_INCLUDE_IBACKGROUNDSCHEDULEMANAGER_H
|
||||
@@ -1,230 +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.
|
||||
|
||||
//
|
||||
// IBackgroundTaskManager runs background tasks in worker thread.
|
||||
//
|
||||
// Tasks are derived from IBackgroundTask. Each task is split in two parts for:
|
||||
// Work - done in background thread.
|
||||
// Finalize - called afterward in main thread to apply results.
|
||||
//
|
||||
// Task objects are reference counted. Task manager will hold its own reference to the task object
|
||||
// for as long as the task is pending or being executed. If you want to keep the task object around
|
||||
// in your code you will have to call AddRef() and Release() on the task object by yourself so there
|
||||
// will be an extra reference to the task object held by your code.
|
||||
//
|
||||
// Work returns the state of the task. Task can be resumed, then the Work
|
||||
// method will be called again. Other tasks can work between calls to Work.
|
||||
// It is possible to Cancel task. Work method is not invoked any more for
|
||||
// Canceled tasks.
|
||||
//
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_INCLUDE_IBACKGROUNDTASKMANAGER_H
|
||||
#define CRYINCLUDE_EDITOR_INCLUDE_IBACKGROUNDTASKMANAGER_H
|
||||
#pragma once
|
||||
|
||||
enum ETaskPriority
|
||||
{
|
||||
eTaskPriority_FileUpdateFinal,
|
||||
eTaskPriority_BackgroundScan,
|
||||
eTaskPriority_FileUpdate,
|
||||
eTaskPriority_RealtimePreview
|
||||
};
|
||||
|
||||
// Result code returned by task Work() function
|
||||
enum ETaskResult
|
||||
{
|
||||
// Task has not yet completed, add it back to the task queue with the same parameters (priority and thread mask)
|
||||
eTaskResult_Resume,
|
||||
|
||||
// Task has completed without errors (it's assumed that the result the task was supposed to achieve was achieved)
|
||||
eTaskResult_Completed,
|
||||
|
||||
// Task was canceled
|
||||
eTaskResult_Canceled,
|
||||
|
||||
// Task has failed to complete it's work
|
||||
eTaskResult_Failed,
|
||||
};
|
||||
|
||||
// Internal task tracking state
|
||||
enum ETaskState
|
||||
{
|
||||
// Task was just created.
|
||||
eTaskState_Created,
|
||||
|
||||
// Task was scheduled to be executed in the future.
|
||||
eTaskState_Scheduled,
|
||||
|
||||
// Task was added to the task queue and is waiting for it's time to be executed.
|
||||
eTaskState_Pending,
|
||||
|
||||
// Task is being processed right now.
|
||||
eTaskState_Working,
|
||||
|
||||
// Task was canceled before it has finished (indication that TaskManager has seen the Cancel() call).
|
||||
eTaskState_Canceled,
|
||||
|
||||
// Task Work() function was called but it ended with an error code.
|
||||
eTaskState_Failed,
|
||||
|
||||
// Task has completed it's Work() function without errors.
|
||||
eTaskState_Completed,
|
||||
};
|
||||
|
||||
// Thread mask controls which on which threads given task can be executed.
|
||||
enum ETaskThreadMask
|
||||
{
|
||||
// Task can run only on the IO thread (default)
|
||||
// There is only one IO thread so all task with this flag are run in a sequence.
|
||||
eTaskThreadMask_IO,
|
||||
|
||||
// Task can run on any thread (concurrent tasks allowed)
|
||||
// There can be many threads with this mask so there's no limit on the concurrent task count.
|
||||
eTaskThreadMask_Any,
|
||||
|
||||
eTaskThreadMask_COUNT,
|
||||
};
|
||||
|
||||
struct IBackgroundTask
|
||||
{
|
||||
public:
|
||||
IBackgroundTask()
|
||||
: m_bCanceled(false)
|
||||
, m_state(eTaskState_Created)
|
||||
, m_progress(-1.0f)
|
||||
, m_refCount(0)
|
||||
, m_bFailReported(false)
|
||||
{}
|
||||
|
||||
void Cancel()
|
||||
{
|
||||
m_bCanceled = true;
|
||||
}
|
||||
|
||||
bool IsCanceled() const
|
||||
{
|
||||
return m_bCanceled;
|
||||
}
|
||||
|
||||
bool HasFinished() const
|
||||
{
|
||||
return (m_state == eTaskState_Canceled) ||
|
||||
(m_state == eTaskState_Completed) ||
|
||||
(m_state == eTaskState_Failed);
|
||||
}
|
||||
|
||||
bool HasFinishedWithoutError() const
|
||||
{
|
||||
return (m_state == eTaskState_Completed);
|
||||
}
|
||||
|
||||
ETaskState GetState() const
|
||||
{
|
||||
return m_state;
|
||||
}
|
||||
|
||||
void SetState(ETaskState state)
|
||||
{
|
||||
m_state = state;
|
||||
}
|
||||
|
||||
float GetProgress() const
|
||||
{
|
||||
return m_progress;
|
||||
}
|
||||
|
||||
int AddRef()
|
||||
{
|
||||
return CryInterlockedIncrement(&m_refCount);
|
||||
}
|
||||
|
||||
int Release()
|
||||
{
|
||||
const int nCount = CryInterlockedDecrement(&m_refCount);
|
||||
assert(nCount >= 0);
|
||||
if (nCount == 0)
|
||||
{
|
||||
Delete();
|
||||
}
|
||||
else if (nCount < 0)
|
||||
{
|
||||
assert(0);
|
||||
CryFatalError("Deleting Reference Counted Object Twice");
|
||||
}
|
||||
return nCount;
|
||||
}
|
||||
|
||||
bool FailReported() const{ return m_bFailReported; }
|
||||
|
||||
// Get the user readable description (name) of this task, used for logging
|
||||
virtual const char* Description() const { return ""; }
|
||||
|
||||
// Get the user readable error message (in case when the task fails), used for logging the errors
|
||||
virtual const char* ErrorMessage() const { return ""; }
|
||||
|
||||
// Called from main thread after task is completed just before the task gets destroyed
|
||||
virtual void Finalize() {}
|
||||
|
||||
// Since there's a possibility that task object were created using different allocator
|
||||
// we need a way to delete the task object once we are done with it
|
||||
virtual void Delete() = 0;
|
||||
|
||||
// Invoked from worker thread, actual work is done here
|
||||
virtual ETaskResult Work() = 0;
|
||||
|
||||
protected:
|
||||
void SetProgress(float progress) { m_progress = progress; }
|
||||
void SetFailReported() { m_bFailReported = true; }
|
||||
|
||||
// destructor is hidden to indicate that we should use Release() method
|
||||
virtual ~IBackgroundTask() {}
|
||||
|
||||
private:
|
||||
volatile int m_refCount;
|
||||
ETaskState m_state;
|
||||
float m_progress;
|
||||
bool m_bCanceled;
|
||||
bool m_bFailReported;
|
||||
};
|
||||
|
||||
struct IBackgroundTaskManagerListener
|
||||
{
|
||||
virtual ~IBackgroundTaskManagerListener() {}
|
||||
|
||||
virtual void OnBackgroundTaskAdded(const char* description) = 0;
|
||||
virtual void OnBackgroundTaskCompleted(ETaskResult taskResult, const char* description) = 0;
|
||||
};
|
||||
|
||||
struct IBackgroundTaskManager
|
||||
{
|
||||
enum
|
||||
{
|
||||
BACKGROUND_TASK_ID_INVALID = 0
|
||||
};
|
||||
|
||||
virtual ~IBackgroundTaskManager() {}
|
||||
|
||||
// Add task to the queue with given priority and thread mask
|
||||
virtual void AddTask(IBackgroundTask* pTask, ETaskPriority priority, ETaskThreadMask threadMask) = 0;
|
||||
|
||||
// Schedule task to be executed in the future
|
||||
virtual void ScheduleTask(IBackgroundTask* pTask, ETaskPriority priority, int delayMilliseconds, ETaskThreadMask threadMask) = 0;
|
||||
|
||||
virtual void AddListener(IBackgroundTaskManagerListener* pListener, const char* name) = 0;
|
||||
|
||||
virtual void RemoveListener(IBackgroundTaskManagerListener* pListener) = 0;
|
||||
};
|
||||
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_INCLUDE_IBACKGROUNDTASKMANAGER_H
|
||||
@@ -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
|
||||
|
||||
@@ -28,16 +28,6 @@
|
||||
// }
|
||||
// REGISTER_RESOURCE_SELECTOR("Sound", SoundFileSelector, "Icons/sound_16x16.png")
|
||||
//
|
||||
// To expose it to serialization:
|
||||
//
|
||||
// #include "Serialization/Decorators/Resources.h"
|
||||
// template<class TString>
|
||||
// ResourceSelector<TString> SoundName(TString& s) { return ResourceSelector<TString>(s, "Sound"); }
|
||||
//
|
||||
// To use in serialization:
|
||||
//
|
||||
// ar(Serialization::SoundName(soundString), "soundString", "Sound String");
|
||||
//
|
||||
// Here is how it can be invoked directly:
|
||||
//
|
||||
// SResourceSelectorContext x;
|
||||
@@ -56,19 +46,7 @@
|
||||
//
|
||||
// QString SoundFileSelector(const SResourceSelectorContext& x, const QString& previousValue,
|
||||
// SoundFileList* list) // your context argument
|
||||
//
|
||||
// And provide this value through serialization context:
|
||||
//
|
||||
// struct SourceFileList
|
||||
// {
|
||||
// void Serialize(IArchive& ar)
|
||||
// {
|
||||
// Serialization::SContext<SourceFileList> context(ar, this);
|
||||
// ...
|
||||
// }
|
||||
// }
|
||||
|
||||
#include <Serialization/TypeID.h>
|
||||
#include <QString>
|
||||
|
||||
class QWidget;
|
||||
@@ -82,7 +60,6 @@ struct SResourceSelectorContext
|
||||
|
||||
unsigned int entityId;
|
||||
void* contextObject;
|
||||
Serialization::TypeID contextObjectType;
|
||||
|
||||
SResourceSelectorContext()
|
||||
: parentWidget(0)
|
||||
@@ -107,7 +84,6 @@ struct IResourceSelectorHost
|
||||
virtual ~IResourceSelectorHost() = default;
|
||||
virtual QString SelectResource(const SResourceSelectorContext& context, const QString& previousValue) = 0;
|
||||
virtual const char* ResourceIconPath(const char* typeName) const = 0;
|
||||
virtual Serialization::TypeID ResourceContextType(const char* typeName) const = 0;
|
||||
|
||||
virtual void RegisterResourceSelector(const SStaticResourceSelectorEntry* entry) = 0;
|
||||
|
||||
@@ -128,7 +104,6 @@ struct SStaticResourceSelectorEntry
|
||||
TResourceSelectionFunction function;
|
||||
TResourceSelectionFunctionWithContext functionWithContext;
|
||||
const char* iconPath;
|
||||
Serialization::TypeID contextType;
|
||||
|
||||
static SStaticResourceSelectorEntry*& GetFirst() { static SStaticResourceSelectorEntry* first; return first; }
|
||||
SStaticResourceSelectorEntry* next;
|
||||
@@ -150,7 +125,6 @@ struct SStaticResourceSelectorEntry
|
||||
, functionWithContext(TResourceSelectionFunctionWithContext(function))
|
||||
, iconPath(icon)
|
||||
{
|
||||
contextType = Serialization::TypeID::get<T>();
|
||||
next = GetFirst();
|
||||
GetFirst() = this;
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -97,10 +97,6 @@ void CLevelInfo::ValidateObjects()
|
||||
|
||||
pObject->Validate(m_pReport);
|
||||
|
||||
CUsedResources rs;
|
||||
pObject->GatherUsedResources(rs);
|
||||
rs.Validate(m_pReport);
|
||||
|
||||
m_pReport->SetCurrentValidatorObject(NULL);
|
||||
}
|
||||
|
||||
|
||||
@@ -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* ());
|
||||
@@ -103,7 +102,6 @@ public:
|
||||
MOCK_METHOD0(GetViewManager, class CViewManager* ());
|
||||
MOCK_METHOD0(GetActiveView, class CViewport* ());
|
||||
MOCK_METHOD1(SetActiveView, void(CViewport*));
|
||||
MOCK_METHOD0(GetBackgroundTaskManager, struct IBackgroundTaskManager* ());
|
||||
MOCK_METHOD0(GetFileMonitor, struct IEditorFileMonitor* ());
|
||||
MOCK_METHOD1(RegisterEventLoopHook, void(IEventLoopHook* ));
|
||||
MOCK_METHOD1(UnregisterEventLoopHook, void(IEventLoopHook* ));
|
||||
@@ -117,7 +115,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 +137,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));
|
||||
@@ -187,7 +183,6 @@ public:
|
||||
MOCK_CONST_METHOD0(GetEditorConfigPlatform, ESystemConfigPlatform());
|
||||
MOCK_METHOD0(ReloadTemplates, void());
|
||||
MOCK_METHOD0(GetResourceSelectorHost, IResourceSelectorHost* ());
|
||||
MOCK_METHOD0(GetBackgroundScheduleManager, struct IBackgroundScheduleManager* ());
|
||||
MOCK_METHOD1(ShowStatusText, void(bool ));
|
||||
MOCK_METHOD1(RegisterObjectContextMenuExtension, void(TContextMenuExtensionFunc ));
|
||||
MOCK_METHOD0(GetEnv, SSystemGlobalEnvironment* ());
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <MainStatusBar.h>
|
||||
#include <IBackgroundTaskManager.h>
|
||||
#include <IRenderer.h>
|
||||
#include <QMutex>
|
||||
#include <QString>
|
||||
|
||||
@@ -66,7 +66,6 @@ AZ_POP_DISABLE_WARNING
|
||||
#include "AssetImporter/AssetImporterManager/AssetImporterDragAndDropHandler.h"
|
||||
#include "CryEdit.h"
|
||||
#include "Controls/ConsoleSCB.h"
|
||||
#include "Grid.h"
|
||||
#include "ViewManager.h"
|
||||
#include "CryEditDoc.h"
|
||||
#include "ToolBox.h"
|
||||
@@ -78,6 +77,7 @@ AZ_POP_DISABLE_WARNING
|
||||
#include "Core/QtEditorApplication.h"
|
||||
#include "UndoDropDown.h"
|
||||
#include "CVarMenu.h"
|
||||
#include "EditorViewportSettings.h"
|
||||
|
||||
#include "KeyboardCustomizationSettings.h"
|
||||
#include "CustomizeKeyboardDialog.h"
|
||||
@@ -92,11 +92,9 @@ AZ_POP_DISABLE_WARNING
|
||||
#include "ErrorReportDialog.h"
|
||||
|
||||
#include "Dialogs/PythonScriptsDialog.h"
|
||||
#include "EngineSettingsManager.h"
|
||||
|
||||
#include "AzAssetBrowser/AzAssetBrowserWindow.h"
|
||||
#include "AssetEditor/AssetEditorWindow.h"
|
||||
#include "GridSettingsDialog.h"
|
||||
#include "ActionManager.h"
|
||||
|
||||
// uncomment this to show thumbnail demo widget
|
||||
@@ -122,12 +120,6 @@ static const char* g_openLocationAttributeName = "OpenLocation"; //Indicates whe
|
||||
|
||||
static const char* g_assetImporterName = "AssetImporter";
|
||||
|
||||
static const char* g_snapToGridEnabled = "mainwindow/snapGridEnabled";
|
||||
static const char* g_snapToGridSize = "mainwindow/snapGridSize";
|
||||
static const char* g_snapAngleEnabled = "mainwindow/snapAngleEnabled";
|
||||
static const char* g_snapAngle = "mainwindow/snapAngle";
|
||||
static const char* g_terrainFollow = "mainwindow/terrainFollow";
|
||||
|
||||
class CEditorOpenViewCommand
|
||||
: public _i_reference_target_t
|
||||
{
|
||||
@@ -307,10 +299,8 @@ namespace
|
||||
|
||||
class SnapToWidget
|
||||
: public QWidget
|
||||
, public CGridSettingsDialog::NotificationBus::Handler
|
||||
{
|
||||
public:
|
||||
|
||||
typedef AZStd::function<void(double)> SetValueCallback;
|
||||
typedef AZStd::function<double()> GetValueCallback;
|
||||
|
||||
@@ -334,12 +324,13 @@ public:
|
||||
m_spinBox->setEnabled(defaultAction->isChecked());
|
||||
m_spinBox->setMinimum(1e-2f);
|
||||
|
||||
OnGridValuesUpdated();
|
||||
{
|
||||
QSignalBlocker signalBlocker(m_spinBox);
|
||||
m_spinBox->setValue(m_getValueCallback());
|
||||
}
|
||||
|
||||
QObject::connect(m_spinBox, QOverload<double>::of(&AzQtComponents::DoubleSpinBox::valueChanged), this, &SnapToWidget::OnValueChanged);
|
||||
QObject::connect(defaultAction, &QAction::changed, this, &SnapToWidget::OnActionChanged);
|
||||
|
||||
CGridSettingsDialog::NotificationBus::Handler::BusConnect();
|
||||
}
|
||||
|
||||
void SetIcon(QIcon icon)
|
||||
@@ -347,14 +338,6 @@ public:
|
||||
m_toolButton->setIcon(icon);
|
||||
}
|
||||
|
||||
void OnGridValuesUpdated() override
|
||||
{
|
||||
// Blocking signals to not trigger the valueChanged callback when we set the value on the spin box.
|
||||
QSignalBlocker signalBlocker(m_spinBox);
|
||||
double value = m_getValueCallback();
|
||||
m_spinBox->setValue(value);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
void OnValueChanged(double value)
|
||||
@@ -542,7 +525,6 @@ void MainWindow::Initialize()
|
||||
RegisterStdViewClasses();
|
||||
InitCentralWidget();
|
||||
|
||||
LoadConfig();
|
||||
InitActions();
|
||||
|
||||
// load toolbars ("shelves") and macros
|
||||
@@ -672,31 +654,8 @@ void MainWindow::closeEvent(QCloseEvent* event)
|
||||
QMainWindow::closeEvent(event);
|
||||
}
|
||||
|
||||
void MainWindow::LoadConfig()
|
||||
{
|
||||
CGrid* grid = gSettings.pGrid;
|
||||
Q_ASSERT(grid);
|
||||
bool terrainValue;
|
||||
|
||||
ReadConfigValue(g_snapAngleEnabled, grid->bAngleSnapEnabled);
|
||||
ReadConfigValue(g_snapAngle, grid->angleSnap);
|
||||
ReadConfigValue(g_snapToGridEnabled, grid->bEnabled);
|
||||
ReadConfigValue(g_snapToGridSize, grid->size);
|
||||
ReadConfigValue(g_terrainFollow, terrainValue);
|
||||
GetIEditor()->SetTerrainAxisIgnoreObjects(terrainValue);
|
||||
}
|
||||
|
||||
void MainWindow::SaveConfig()
|
||||
{
|
||||
CGrid* grid = gSettings.pGrid;
|
||||
Q_ASSERT(grid);
|
||||
|
||||
m_settings.setValue(g_snapAngleEnabled, grid->bAngleSnapEnabled);
|
||||
m_settings.setValue(g_snapAngle, grid->angleSnap);
|
||||
m_settings.setValue(g_snapToGridEnabled, grid->bEnabled);
|
||||
m_settings.setValue(g_snapToGridSize, grid->size);
|
||||
m_settings.setValue(g_terrainFollow, GetIEditor()->IsTerrainAxisIgnoreObjects());
|
||||
|
||||
m_settings.setValue("mainWindowState", saveState());
|
||||
QtViewPaneManager::instance()->SaveLayout();
|
||||
if (m_pLayoutWnd)
|
||||
@@ -735,8 +694,6 @@ void MainWindow::InitActions()
|
||||
am->AddAction(ID_TOOLBAR_WIDGET_REDO, QString());
|
||||
am->AddAction(ID_TOOLBAR_WIDGET_SNAP_ANGLE, QString());
|
||||
am->AddAction(ID_TOOLBAR_WIDGET_SNAP_GRID, QString());
|
||||
am->AddAction(ID_TOOLBAR_WIDGET_ENVIRONMENT_MODE, QString());
|
||||
am->AddAction(ID_TOOLBAR_WIDGET_DEBUG_MODE, QString());
|
||||
am->AddAction(ID_TOOLBAR_WIDGET_SPACER_RIGHT, QString());
|
||||
|
||||
// File actions
|
||||
@@ -915,13 +872,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"))
|
||||
@@ -931,7 +897,6 @@ void MainWindow::InitActions()
|
||||
.SetStatusTip(tr("Render in Wireframe Mode."))
|
||||
.RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdateWireframe);
|
||||
|
||||
am->AddAction(ID_VIEW_GRIDSETTINGS, tr("Grid Settings..."));
|
||||
am->AddAction(ID_SWITCHCAMERA_DEFAULTCAMERA, tr("Default Camera")).SetCheckable(true)
|
||||
.RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdateSwitchToDefaultCamera);
|
||||
am->AddAction(ID_SWITCHCAMERA_SEQUENCECAMERA, tr("Sequence Camera")).SetCheckable(true)
|
||||
@@ -1054,13 +1019,16 @@ void MainWindow::InitActions()
|
||||
.SetApplyHoverEffect()
|
||||
.SetCheckable(true)
|
||||
.RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdatePlayGame);
|
||||
am->AddAction(ID_TOOLBAR_WIDGET_PLAYCONSOLE_LABEL, tr("Play Console"))
|
||||
.SetText(tr("Play Console"));
|
||||
am->AddAction(ID_TOOLBAR_WIDGET_PLAYCONSOLE_LABEL, tr("Play Controls"))
|
||||
.SetText(tr("Play Controls"));
|
||||
am->AddAction(ID_SWITCH_PHYSICS, tr("Simulate"))
|
||||
.SetIcon(QIcon(":/stylesheet/img/UI20/toolbar/Simulate_Physics.svg"))
|
||||
.SetShortcut(tr("Ctrl+P"))
|
||||
.SetToolTip(tr("Simulate (Ctrl+P)"))
|
||||
.SetCheckable(true)
|
||||
.SetStatusTip(tr("Enable processing of Physics and AI."))
|
||||
.SetApplyHoverEffect()
|
||||
.SetCheckable(true)
|
||||
.RegisterUpdateCallback(cryEdit, &CCryEditApp::OnSwitchPhysicsUpdate);
|
||||
am->AddAction(ID_GAME_SYNCPLAYER, tr("Move Player and Camera Separately")).SetCheckable(true)
|
||||
.SetStatusTip(tr("Move Player and Camera Separately"))
|
||||
@@ -1075,8 +1043,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"));
|
||||
@@ -1287,44 +1253,6 @@ QToolButton* MainWindow::CreateUndoRedoButton(int command)
|
||||
return button;
|
||||
}
|
||||
|
||||
QToolButton* MainWindow::CreateEnvironmentModeButton()
|
||||
{
|
||||
QToolButton* environmentModeButton = new QToolButton(this);
|
||||
environmentModeButton->setAutoRaise(true);
|
||||
environmentModeButton->setPopupMode(QToolButton::InstantPopup);
|
||||
environmentModeButton->setIcon(Style::icon("Environment"));
|
||||
environmentModeButton->setStatusTip(tr("Select from a variety of environment mode options"));
|
||||
environmentModeButton->setToolTip(tr("Environment modes"));
|
||||
|
||||
CVarMenu* environmentModeMenu = new CVarMenu(this);
|
||||
connect(environmentModeMenu, &QMenu::aboutToShow, [this, environmentModeMenu]()
|
||||
{
|
||||
InitEnvironmentModeMenu(environmentModeMenu);
|
||||
});
|
||||
environmentModeButton->setMenu(environmentModeMenu);
|
||||
|
||||
return environmentModeButton;
|
||||
}
|
||||
|
||||
QToolButton* MainWindow::CreateDebugModeButton()
|
||||
{
|
||||
QToolButton* debugModeButton = new QToolButton(this);
|
||||
debugModeButton->setAutoRaise(true);
|
||||
debugModeButton->setPopupMode(QToolButton::InstantPopup);
|
||||
debugModeButton->setIcon(Style::icon("Debugging"));
|
||||
debugModeButton->setStatusTip(tr("Select from a variety of debug/view mode options"));
|
||||
debugModeButton->setToolTip(tr("Debug modes"));
|
||||
|
||||
CVarMenu* debugModeMenu = new CVarMenu(this);
|
||||
connect(debugModeMenu, &QMenu::aboutToShow, [this, debugModeMenu]()
|
||||
{
|
||||
InitDebugModeMenu(debugModeMenu);
|
||||
});
|
||||
debugModeButton->setMenu(debugModeMenu);
|
||||
|
||||
return debugModeButton;
|
||||
}
|
||||
|
||||
QWidget* MainWindow::CreateSpacerRightWidget()
|
||||
{
|
||||
QWidget* spacer = new QWidget(this);
|
||||
@@ -1333,93 +1261,6 @@ QWidget* MainWindow::CreateSpacerRightWidget()
|
||||
return spacer;
|
||||
}
|
||||
|
||||
void MainWindow::InitEnvironmentModeMenu(CVarMenu* environmentModeMenu)
|
||||
{
|
||||
environmentModeMenu->clear();
|
||||
environmentModeMenu->AddCVarToggleItem({ "e_Fog", tr("Hide Global Fog"), 0, 1 });
|
||||
environmentModeMenu->AddCVarToggleItem({ "r_FogVolumes", tr("Hide Fog Volumes"), 0, 1 });
|
||||
environmentModeMenu->AddCVarToggleItem({ "e_Clouds", tr("Hide Clouds"), 0, 1 });
|
||||
environmentModeMenu->AddCVarToggleItem({ "e_Wind", tr("Hide Wind"), 0, 1 });
|
||||
environmentModeMenu->AddSeparator();
|
||||
environmentModeMenu->AddCVarToggleItem({ "e_Sun", tr("Hide Sun"), 0, 1 });
|
||||
environmentModeMenu->AddCVarToggleItem({ "e_Skybox", tr("Hide Skybox"), 0, 1 });
|
||||
environmentModeMenu->AddCVarToggleItem({ "r_SSReflections", tr("Hide Screen Space Reflection"), 0, 1 });
|
||||
environmentModeMenu->AddCVarToggleItem({ "e_Shadows", tr("Hide Shadows"), 0, 1 });
|
||||
environmentModeMenu->AddCVarToggleItem({ "r_TransparentPasses", tr("Hide Transparent Objects"), 0, 1 });
|
||||
environmentModeMenu->AddCVarToggleItem({ "r_ssdo", tr("Hide Screen Space Directional Occlusion"), 0, 1 });
|
||||
environmentModeMenu->AddCVarToggleItem({ "e_DynamicLights", tr("Hide All Dynamic Lights"), 0, 1 });
|
||||
environmentModeMenu->AddSeparator();
|
||||
environmentModeMenu->AddCVarToggleItem({ "e_Entities", tr("Hide Entities"), 0, 1 });
|
||||
environmentModeMenu->AddSeparator();
|
||||
environmentModeMenu->AddCVarToggleItem({ "e_Vegetation", tr("Hide Vegetation"), 0, 1 });
|
||||
environmentModeMenu->AddCVarToggleItem({ "e_Terrain", tr("Hide Terrain"), 0, 1 });
|
||||
environmentModeMenu->AddSeparator();
|
||||
environmentModeMenu->AddCVarToggleItem({ "e_Particles", tr("Hide Particles"), 0, 1 });
|
||||
environmentModeMenu->AddCVarToggleItem({ "e_Flares", tr("Hide Flares"), 0, 1 });
|
||||
environmentModeMenu->AddCVarToggleItem({ "e_Decals", tr("Hide Decals"), 0, 1 });
|
||||
environmentModeMenu->AddSeparator();
|
||||
environmentModeMenu->AddCVarToggleItem({ "e_WaterOcean", tr("Hide Ocean Water (for legacy)"), 0, 1 });
|
||||
environmentModeMenu->AddCVarToggleItem({ "e_WaterVolumes", tr("Hide Water Volumes"), 0, 1 });
|
||||
environmentModeMenu->AddSeparator();
|
||||
environmentModeMenu->AddCVarToggleItem({ "e_BBoxes", tr("Hide BBoxes"), 0, 1 });
|
||||
environmentModeMenu->AddSeparator();
|
||||
environmentModeMenu->AddResetCVarsItem();
|
||||
}
|
||||
|
||||
void MainWindow::InitDebugModeMenu(CVarMenu* debugModeMenu)
|
||||
{
|
||||
debugModeMenu->clear();
|
||||
debugModeMenu->AddCVarValuesItem("r_DebugGBuffer", tr("GBuffers"),
|
||||
{
|
||||
{tr("Full Shading Mode (Default)"), 0},
|
||||
{tr("Normal Visualization"), 1},
|
||||
{tr("Smoothness"), 2},
|
||||
{tr("Reflectance"), 3},
|
||||
{tr("Albedo"), 4},
|
||||
{tr("Lighting Model"), 5},
|
||||
{tr("Translucency"), 6},
|
||||
{tr("Sun Self Shadowing"), 7},
|
||||
{tr("Subsurface Scattering"), 8},
|
||||
{tr("Specular Validation Overlay"), 9}
|
||||
}, 0);
|
||||
debugModeMenu->AddSeparator();
|
||||
debugModeMenu->AddCVarValuesItem("r_Stats", tr("Profiling"),
|
||||
{
|
||||
{tr("Frame Timing"), 1},
|
||||
{tr("Object Timing"), 3},
|
||||
{tr("Instance Draw Calls"), 6},
|
||||
}, 0);
|
||||
debugModeMenu->AddSeparator();
|
||||
debugModeMenu->AddUniqueCVarsItem(tr("Wireframe"),
|
||||
{
|
||||
{"r_wireframe", tr("Wireframe Rendering Mode"), 1, 0},
|
||||
{"r_showlines", tr("Wireframe Overlay"), 1, 0}
|
||||
}),
|
||||
debugModeMenu->AddCVarValuesItem("e_debugdraw", tr("Art Info"),
|
||||
{
|
||||
{tr("Texture Memory Usage"), 4},
|
||||
{tr("Renderable Material Count"), 5},
|
||||
{tr("LOD Vertex Count"), 22}
|
||||
}, 0);
|
||||
|
||||
debugModeMenu->AddSeparator();
|
||||
debugModeMenu->AddCVarValuesItem("e_defaultmaterial", tr("Default Material on all Objects"),
|
||||
{
|
||||
{tr("Gray Material with Normal Maps"), 1},
|
||||
}, 0);
|
||||
|
||||
debugModeMenu->AddCVarValuesItem("r_DeferredShadingTiledDebugAlbedo", tr("Debug Visualization of Deferred Lighting"),
|
||||
{
|
||||
{tr("White Albedo"), 1},
|
||||
}, 0);
|
||||
|
||||
debugModeMenu->AddCVarToggleItem({ "r_ShowTangents", tr("Show Tangents"), 1, 0 });
|
||||
debugModeMenu->AddCVarToggleItem({ "p_draw_helpers", tr("Show Collision Shapes (Proxy)"), 1, 0 });
|
||||
|
||||
debugModeMenu->AddSeparator();
|
||||
debugModeMenu->AddResetCVarsItem();
|
||||
}
|
||||
|
||||
UndoRedoToolButton::UndoRedoToolButton(QWidget* parent)
|
||||
: QToolButton(parent)
|
||||
{
|
||||
@@ -1434,12 +1275,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 +1290,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);
|
||||
@@ -1471,15 +1312,6 @@ MainStatusBar* MainWindow::StatusBar() const
|
||||
return static_cast<MainStatusBar*>(statusBar());
|
||||
}
|
||||
|
||||
void MainWindow::OnUpdateSnapToGrid(QAction* action)
|
||||
{
|
||||
Q_ASSERT(action->isCheckable());
|
||||
bool bEnabled = gSettings.pGrid->IsEnabled();
|
||||
action->setChecked(bEnabled);
|
||||
|
||||
action->setText(QObject::tr("Snap To Grid"));
|
||||
}
|
||||
|
||||
KeyboardCustomizationSettings* MainWindow::GetShortcutManager() const
|
||||
{
|
||||
return m_keyboardCustomization;
|
||||
@@ -2111,12 +1943,6 @@ void MainWindow::ConnectivityStateChanged(const AzToolsFramework::SourceControlS
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(CRY_ENABLE_RC_HELPER)
|
||||
CEngineSettingsManager settingsManager;
|
||||
settingsManager.SetModuleSpecificBoolEntry("RC_EnableSourceControl", connected);
|
||||
settingsManager.StoreData();
|
||||
#endif
|
||||
|
||||
gSettings.enableSourceControl = connected;
|
||||
gSettings.SaveEnableSourceControlFlag(false);
|
||||
}
|
||||
@@ -2193,12 +2019,6 @@ QWidget* MainWindow::CreateToolbarWidget(int actionId)
|
||||
case ID_TOOLBAR_WIDGET_SNAP_ANGLE:
|
||||
w = CreateSnapToAngleWidget();
|
||||
break;
|
||||
case ID_TOOLBAR_WIDGET_ENVIRONMENT_MODE:
|
||||
w = CreateEnvironmentModeButton();
|
||||
break;
|
||||
case ID_TOOLBAR_WIDGET_DEBUG_MODE:
|
||||
w = CreateDebugModeButton();
|
||||
break;
|
||||
case ID_TOOLBAR_WIDGET_SPACER_RIGHT:
|
||||
w = CreateSpacerRightWidget();
|
||||
break;
|
||||
|
||||
@@ -191,9 +191,7 @@ private:
|
||||
void InitToolActionHandlers();
|
||||
void InitToolBars();
|
||||
void InitStatusBar();
|
||||
void OnUpdateSnapToGrid(QAction* action);
|
||||
void OnViewPaneCreated(const QtViewPane* pane);
|
||||
void LoadConfig();
|
||||
|
||||
template <class TValue>
|
||||
void ReadConfigValue(const QString& key, TValue& value)
|
||||
@@ -210,11 +208,6 @@ private:
|
||||
|
||||
QToolButton* CreateUndoRedoButton(int command);
|
||||
|
||||
QToolButton* CreateEnvironmentModeButton();
|
||||
QToolButton* CreateDebugModeButton();
|
||||
void InitEnvironmentModeMenu(CVarMenu* environmentModeMenu);
|
||||
void InitDebugModeMenu(CVarMenu* debugModeMenu);
|
||||
|
||||
private Q_SLOTS:
|
||||
void ShowKeyboardCustomization();
|
||||
void ExportKeyboardShortcuts();
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <AzFramework/Input/Devices/Keyboard/InputDeviceKeyboard.h>
|
||||
#include <AzFramework/Input/Devices/Mouse/InputDeviceMouse.h>
|
||||
#include <AzFramework/Viewport/ScreenGeometry.h>
|
||||
#include <AzFramework/Viewport/ViewportScreen.h>
|
||||
#include <AzFramework/Windowing/WindowBus.h>
|
||||
#include <AzToolsFramework/Viewport/ViewportMessages.h>
|
||||
|
||||
@@ -64,17 +65,20 @@ namespace SandboxEditor
|
||||
}
|
||||
}
|
||||
|
||||
ModernViewportCameraControllerInstance::ModernViewportCameraControllerInstance(const AzFramework::ViewportId viewportId, ModernViewportCameraController* controller)
|
||||
ModernViewportCameraControllerInstance::ModernViewportCameraControllerInstance(
|
||||
const AzFramework::ViewportId viewportId, ModernViewportCameraController* controller)
|
||||
: MultiViewportControllerInstanceInterface<ModernViewportCameraController>(viewportId, controller)
|
||||
{
|
||||
controller->SetupCameras(m_cameraSystem.m_cameras);
|
||||
|
||||
if (auto viewportContext = RetrieveViewportContext(GetViewportId()))
|
||||
{
|
||||
auto handleCameraChange = [this](const AZ::Matrix4x4& matrix) {
|
||||
UpdateCameraFromTransform(
|
||||
m_targetCamera,
|
||||
AZ::Transform::CreateFromMatrix3x3AndTranslation(AZ::Matrix3x3::CreateFromMatrix4x4(matrix), matrix.GetTranslation()));
|
||||
auto handleCameraChange = [this, viewportContext](const AZ::Matrix4x4&) {
|
||||
if (!m_updatingTransform)
|
||||
{
|
||||
UpdateCameraFromTransform(m_targetCamera, viewportContext->GetCameraTransform());
|
||||
m_camera = m_targetCamera;
|
||||
}
|
||||
};
|
||||
|
||||
m_cameraViewMatrixChangeHandler = AZ::RPI::ViewportContext::MatrixChangedEvent::Handler(handleCameraChange);
|
||||
@@ -124,6 +128,8 @@ namespace SandboxEditor
|
||||
{
|
||||
if (auto viewportContext = RetrieveViewportContext(GetViewportId()))
|
||||
{
|
||||
m_updatingTransform = true;
|
||||
|
||||
if (m_cameraMode == CameraMode::Control)
|
||||
{
|
||||
m_targetCamera = m_cameraSystem.StepCamera(m_targetCamera, event.m_deltaTime.count());
|
||||
@@ -155,6 +161,8 @@ namespace SandboxEditor
|
||||
|
||||
viewportContext->SetCameraTransform(current);
|
||||
}
|
||||
|
||||
m_updatingTransform = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,14 +20,13 @@
|
||||
namespace SandboxEditor
|
||||
{
|
||||
class ModernViewportCameraControllerInstance;
|
||||
class ModernViewportCameraController
|
||||
: public AzFramework::MultiViewportController<ModernViewportCameraControllerInstance>
|
||||
class ModernViewportCameraController : public AzFramework::MultiViewportController<ModernViewportCameraControllerInstance>
|
||||
{
|
||||
public:
|
||||
using CameraListBuilder = AZStd::function<void(AzFramework::Cameras&)>;
|
||||
|
||||
//! Sets the camera list builder callback used to populate new ModernViewportCameraControllerInstances
|
||||
void SetCameraListBuilderCallback(const CameraListBuilder& builder);
|
||||
|
||||
//! Sets up a camera list based on this controller's CameraListBuilderCallback
|
||||
void SetupCameras(AzFramework::Cameras& cameras);
|
||||
|
||||
@@ -35,9 +34,9 @@ namespace SandboxEditor
|
||||
CameraListBuilder m_cameraListBuilder;
|
||||
};
|
||||
|
||||
class ModernViewportCameraControllerInstance final
|
||||
: public AzFramework::MultiViewportControllerInstanceInterface<ModernViewportCameraController>
|
||||
, private AzFramework::ViewportDebugDisplayEventBus::Handler
|
||||
class ModernViewportCameraControllerInstance final
|
||||
: public AzFramework::MultiViewportControllerInstanceInterface<ModernViewportCameraController>,
|
||||
private AzFramework::ViewportDebugDisplayEventBus::Handler
|
||||
{
|
||||
public:
|
||||
explicit ModernViewportCameraControllerInstance(AzFramework::ViewportId viewportId, ModernViewportCameraController* controller);
|
||||
@@ -65,6 +64,7 @@ namespace SandboxEditor
|
||||
AZ::Transform m_transformEnd = AZ::Transform::CreateIdentity();
|
||||
float m_animationT = 0.0f;
|
||||
CameraMode m_cameraMode = CameraMode::Control;
|
||||
bool m_updatingTransform = false;
|
||||
|
||||
AZ::RPI::ViewportContext::MatrixChangedEvent::Handler m_cameraViewMatrixChangeHandler;
|
||||
};
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
// Editor
|
||||
#include "Viewport.h"
|
||||
#include "GizmoManager.h"
|
||||
#include "Grid.h"
|
||||
#include "ViewManager.h"
|
||||
#include "Settings.h"
|
||||
#include "RenderHelpers/AxisHelper.h"
|
||||
@@ -244,7 +243,8 @@ Matrix34 CAxisGizmo::GetTransformation(RefCoordSys coordSys, IDisplayViewport* v
|
||||
break;
|
||||
case COORDS_USERDEFINED:
|
||||
{
|
||||
Matrix34 userTM = GetIEditor()->GetViewManager()->GetGrid()->GetMatrix();
|
||||
Matrix34 userTM;
|
||||
userTM.SetIdentity();
|
||||
userTM.SetTranslation(m_object->GetWorldTM().GetTranslation());
|
||||
return userTM;
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
@@ -1572,12 +1268,6 @@ int CBaseObject::MouseCreateCallback(CViewport* view, EMouseEvent event, QPoint&
|
||||
if (event == eMouseWheel)
|
||||
{
|
||||
double angle = 1;
|
||||
|
||||
if (view->GetViewManager()->GetGrid()->IsAngleSnapEnabled())
|
||||
{
|
||||
angle = view->GetViewManager()->GetGrid()->GetAngleSnap();
|
||||
}
|
||||
|
||||
Quat rot = GetRotation();
|
||||
rot.SetRotationXYZ(Ang3(0, 0, rot.GetRotZ() + DEG2RAD(flags > 0 ? angle * (-1) : angle)));
|
||||
SetRotation(rot);
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
|
||||
class CEntityObject;
|
||||
class QMenu;
|
||||
class IOpticsElementBase;
|
||||
|
||||
/*!
|
||||
* CEntityEventTarget is an Entity event target and type.
|
||||
|
||||
@@ -342,7 +342,8 @@ void CSelectionGroup::Rotate(const Matrix34& rotateTM, int referenceCoordSys)
|
||||
|
||||
if (referenceCoordSys == COORDS_USERDEFINED)
|
||||
{
|
||||
Matrix34 userTM = GetIEditor()->GetViewManager()->GetGrid()->GetMatrix();
|
||||
Matrix34 userTM;
|
||||
userTM.SetIdentity();
|
||||
Matrix34 invUserTM = userTM.GetInvertedFast();
|
||||
|
||||
ToOrigin = invUserTM * ToOrigin;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1993,28 +1993,27 @@ AzFramework::CameraState CRenderViewport::GetCameraState()
|
||||
|
||||
bool CRenderViewport::GridSnappingEnabled()
|
||||
{
|
||||
return GetViewManager()->GetGrid()->IsEnabled();
|
||||
return false;
|
||||
}
|
||||
|
||||
float CRenderViewport::GridSize()
|
||||
{
|
||||
const CGrid* grid = GetViewManager()->GetGrid();
|
||||
return grid->scale * grid->size;
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
bool CRenderViewport::ShowGrid()
|
||||
{
|
||||
return gSettings.viewports.bShowGridGuide;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CRenderViewport::AngleSnappingEnabled()
|
||||
{
|
||||
return GetViewManager()->GetGrid()->IsAngleSnapEnabled();
|
||||
return false;
|
||||
}
|
||||
|
||||
float CRenderViewport::AngleStep()
|
||||
{
|
||||
return GetViewManager()->GetGrid()->GetAngleSnap();
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
AZ::Vector3 CRenderViewport::PickTerrain(const AzFramework::ScreenPoint& point)
|
||||
@@ -3890,94 +3889,13 @@ void CRenderViewport::ActivateWindowAndSetFocus()
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CRenderViewport::RenderConstructionPlane()
|
||||
{
|
||||
DisplayContext& dc = m_displayContext;
|
||||
|
||||
int prevState = dc.GetState();
|
||||
dc.DepthWriteOff();
|
||||
// Draw Construction plane.
|
||||
|
||||
CGrid* pGrid = GetViewManager()->GetGrid();
|
||||
|
||||
RefCoordSys coordSys = COORDS_WORLD;
|
||||
|
||||
Vec3 p = m_constructionMatrix[coordSys].GetTranslation();
|
||||
Vec3 n = m_constructionPlane.n;
|
||||
|
||||
Vec3 u = Vec3(1, 0, 0);
|
||||
Vec3 v = Vec3(0, 1, 0);
|
||||
|
||||
|
||||
if (gSettings.snap.bGridUserDefined)
|
||||
{
|
||||
Ang3 angles = Ang3(pGrid->rotationAngles.x * gf_PI / 180.0, pGrid->rotationAngles.y * gf_PI / 180.0, pGrid->rotationAngles.z * gf_PI / 180.0);
|
||||
Matrix34 tm = Matrix33::CreateRotationXYZ(angles);
|
||||
|
||||
u = tm * u;
|
||||
v = tm * v;
|
||||
}
|
||||
|
||||
float step = pGrid->scale * pGrid->size;
|
||||
float size = gSettings.snap.constructPlaneSize;
|
||||
|
||||
dc.SetColor(0, 0, 1, 0.1f);
|
||||
|
||||
float s = size;
|
||||
|
||||
dc.DrawQuad(p - u * s - v * s, p + u * s - v * s, p + u * s + v * s, p - u * s + v * s);
|
||||
|
||||
int nSteps = int(size / step);
|
||||
int i;
|
||||
// Draw X lines.
|
||||
dc.SetColor(1, 0, 0.2f, 0.3f);
|
||||
|
||||
for (i = -nSteps; i <= nSteps; i++)
|
||||
{
|
||||
dc.DrawLine(p - u * size + v * (step * i), p + u * size + v * (step * i));
|
||||
}
|
||||
// Draw Y lines.
|
||||
dc.SetColor(0.2f, 1.0f, 0, 0.3f);
|
||||
for (i = -nSteps; i <= nSteps; i++)
|
||||
{
|
||||
dc.DrawLine(p - v * size + u * (step * i), p + v * size + u * (step * i));
|
||||
}
|
||||
|
||||
// Draw origin lines.
|
||||
|
||||
dc.SetLineWidth(2);
|
||||
|
||||
//X
|
||||
dc.SetColor(1, 0, 0);
|
||||
dc.DrawLine(p - u * s, p + u * s);
|
||||
|
||||
//Y
|
||||
dc.SetColor(0, 1, 0);
|
||||
dc.DrawLine(p - v * s, p + v * s);
|
||||
|
||||
//Z
|
||||
dc.SetColor(0, 0, 1);
|
||||
dc.DrawLine(p - n * s, p + n * s);
|
||||
|
||||
dc.SetLineWidth(0);
|
||||
|
||||
dc.SetState(prevState);
|
||||
// noop
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CRenderViewport::RenderSnappingGrid()
|
||||
{
|
||||
// First, Check whether we should draw the grid or not.
|
||||
CGrid* pGrid = GetViewManager()->GetGrid();
|
||||
if (pGrid->IsEnabled() == false && pGrid->IsAngleSnapEnabled() == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
DisplayContext& dc = m_displayContext;
|
||||
|
||||
int prevState = dc.GetState();
|
||||
dc.DepthWriteOff();
|
||||
|
||||
dc.SetState(prevState);
|
||||
// noop
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -79,7 +79,6 @@
|
||||
#define ID_EDIT_HIDE 32898
|
||||
#define ID_EDIT_UNHIDEALL 32899
|
||||
#define ID_RELOAD_TERRAIN 32902
|
||||
#define ID_VIEW_GRIDSETTINGS 32904
|
||||
#define ID_VIEW_CONFIGURELAYOUT 32906
|
||||
#define ID_TOOLS_LOGMEMORYUSAGE 32908
|
||||
#define ID_TERRAIN_EXPORTBLOCK 32909
|
||||
@@ -99,7 +98,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
|
||||
|
||||
@@ -72,16 +72,6 @@ public:
|
||||
return "";
|
||||
}
|
||||
|
||||
Serialization::TypeID ResourceContextType(const char* typeName) const override
|
||||
{
|
||||
TTypeMap::const_iterator it = m_typeMap.find(typeName);
|
||||
if (it != m_typeMap.end())
|
||||
{
|
||||
return it->second->contextType;
|
||||
}
|
||||
return Serialization::TypeID();
|
||||
}
|
||||
|
||||
void RegisterResourceSelector(const SStaticResourceSelectorEntry* entry) override
|
||||
{
|
||||
m_typeMap[entry->typeName] = entry;
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#pragma once
|
||||
#ifndef CRYINCLUDE_EDITOR_SERIALIZATION_H
|
||||
#define CRYINCLUDE_EDITOR_SERIALIZATION_H
|
||||
|
||||
#include <Serialization/STL.h>
|
||||
#include <Serialization/SmartPtr.h>
|
||||
#include <Serialization/ClassFactory.h>
|
||||
#include <Serialization/IArchive.h>
|
||||
#include <Serialization/Enum.h>
|
||||
|
||||
using Serialization::IArchive;
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_SERIALIZATION_H
|
||||
@@ -1,283 +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 "VariableIArchive.h"
|
||||
|
||||
// Editor
|
||||
#include "Serialization/Decorators/Resources.h"
|
||||
#include "Serialization/Decorators/Range.h"
|
||||
|
||||
|
||||
using Serialization::CVariableIArchive;
|
||||
|
||||
namespace VarUtil
|
||||
{
|
||||
_smart_ptr< IVariable > FindChildVariable(const _smart_ptr< IVariable >& pParent, const int childIndexOverride, const char* const name)
|
||||
{
|
||||
if (0 <= childIndexOverride)
|
||||
{
|
||||
return pParent->GetVariable(childIndexOverride);
|
||||
}
|
||||
else
|
||||
{
|
||||
const bool shouldSearchRecursively = false;
|
||||
return pParent->FindVariable(name, shouldSearchRecursively);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template< typename T, typename TOut >
|
||||
bool ReadChildVariableAs(const _smart_ptr< IVariable >& pParent, const int childIndexOverride, const char* const name, TOut& valueOut)
|
||||
{
|
||||
_smart_ptr< IVariable > pVariable = FindChildVariable(pParent, childIndexOverride, name);
|
||||
if (pVariable)
|
||||
{
|
||||
T tmp;
|
||||
pVariable->Get(tmp);
|
||||
valueOut = static_cast< TOut >(tmp);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
template< typename T >
|
||||
bool ReadChildVariable(const _smart_ptr< IVariable >& pParent, const int childIndexOverride, const char* const name, T& valueOut)
|
||||
{
|
||||
return ReadChildVariableAs< T >(pParent, childIndexOverride, name, valueOut);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
CVariableIArchive::CVariableIArchive(const _smart_ptr< IVariable >& pVariable)
|
||||
: IArchive(IArchive::INPUT | IArchive::EDIT | IArchive::NO_EMPTY_NAMES)
|
||||
, m_pVariable(pVariable)
|
||||
, m_childIndexOverride(-1)
|
||||
{
|
||||
CRY_ASSERT(m_pVariable);
|
||||
|
||||
m_structHandlers[ TypeID::get < Serialization::IResourceSelector > ().name() ] = &CVariableIArchive::SerializeResourceSelector;
|
||||
m_structHandlers[ TypeID::get < Serialization::RangeDecorator < float >> ().name() ] = &CVariableIArchive::SerializeRangeFloat;
|
||||
m_structHandlers[ TypeID::get < Serialization::RangeDecorator < int >> ().name() ] = &CVariableIArchive::SerializeRangeInt;
|
||||
m_structHandlers[ TypeID::get < Serialization::RangeDecorator < unsigned int >> ().name() ] = &CVariableIArchive::SerializeRangeUInt;
|
||||
m_structHandlers[ TypeID::get < StringListStaticValue > ().name() ] = &CVariableIArchive::SerializeStringListStaticValue;
|
||||
}
|
||||
|
||||
|
||||
CVariableIArchive::~CVariableIArchive()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
bool CVariableIArchive::operator()(bool& value, const char* name, [[maybe_unused]] const char* label)
|
||||
{
|
||||
return VarUtil::ReadChildVariableAs< bool >(m_pVariable, m_childIndexOverride, name, value);
|
||||
}
|
||||
|
||||
|
||||
bool CVariableIArchive::operator()(Serialization::IString& value, const char* name, [[maybe_unused]] const char* label)
|
||||
{
|
||||
QString stringValue;
|
||||
const bool readSuccess = VarUtil::ReadChildVariableAs< QString >(m_pVariable, m_childIndexOverride, name, stringValue);
|
||||
if (readSuccess)
|
||||
{
|
||||
value.set(stringValue.toUtf8().data());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool CVariableIArchive::operator()([[maybe_unused]] Serialization::IWString& value, [[maybe_unused]] const char* name, [[maybe_unused]] const char* label)
|
||||
{
|
||||
CryFatalError("CVariableIArchive::operator() with IWString is not implemented");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool CVariableIArchive::operator()(float& value, const char* name, [[maybe_unused]] const char* label)
|
||||
{
|
||||
return VarUtil::ReadChildVariableAs< float >(m_pVariable, m_childIndexOverride, name, value);
|
||||
}
|
||||
|
||||
|
||||
bool CVariableIArchive::operator()(double& value, const char* name, [[maybe_unused]] const char* label)
|
||||
{
|
||||
return VarUtil::ReadChildVariableAs< float >(m_pVariable, m_childIndexOverride, name, value);
|
||||
}
|
||||
|
||||
|
||||
bool CVariableIArchive::operator()(int16& value, const char* name, [[maybe_unused]] const char* label)
|
||||
{
|
||||
return VarUtil::ReadChildVariableAs< int >(m_pVariable, m_childIndexOverride, name, value);
|
||||
}
|
||||
|
||||
|
||||
bool CVariableIArchive::operator()(uint16& value, const char* name, [[maybe_unused]] const char* label)
|
||||
{
|
||||
return VarUtil::ReadChildVariableAs< int >(m_pVariable, m_childIndexOverride, name, value);
|
||||
}
|
||||
|
||||
|
||||
bool CVariableIArchive::operator()(int32& value, const char* name, [[maybe_unused]] const char* label)
|
||||
{
|
||||
return VarUtil::ReadChildVariableAs< int >(m_pVariable, m_childIndexOverride, name, value);
|
||||
}
|
||||
|
||||
|
||||
bool CVariableIArchive::operator()(uint32& value, const char* name, [[maybe_unused]] const char* label)
|
||||
{
|
||||
return VarUtil::ReadChildVariableAs< int >(m_pVariable, m_childIndexOverride, name, value);
|
||||
}
|
||||
|
||||
|
||||
bool CVariableIArchive::operator()(int64& value, const char* name, [[maybe_unused]] const char* label)
|
||||
{
|
||||
return VarUtil::ReadChildVariableAs< int >(m_pVariable, m_childIndexOverride, name, value);
|
||||
}
|
||||
|
||||
|
||||
bool CVariableIArchive::operator()(uint64& value, const char* name, [[maybe_unused]] const char* label)
|
||||
{
|
||||
return VarUtil::ReadChildVariableAs< int >(m_pVariable, m_childIndexOverride, name, value);
|
||||
}
|
||||
|
||||
|
||||
bool CVariableIArchive::operator()(int8& value, const char* name, [[maybe_unused]] const char* label)
|
||||
{
|
||||
return VarUtil::ReadChildVariableAs< int >(m_pVariable, m_childIndexOverride, name, value);
|
||||
}
|
||||
|
||||
|
||||
bool CVariableIArchive::operator()(uint8& value, const char* name, [[maybe_unused]] const char* label)
|
||||
{
|
||||
return VarUtil::ReadChildVariableAs< int >(m_pVariable, m_childIndexOverride, name, value);
|
||||
}
|
||||
|
||||
|
||||
bool CVariableIArchive::operator()(char& value, const char* name, [[maybe_unused]] const char* label)
|
||||
{
|
||||
return VarUtil::ReadChildVariableAs< int >(m_pVariable, m_childIndexOverride, name, value);
|
||||
}
|
||||
|
||||
|
||||
bool CVariableIArchive::operator()(const Serialization::SStruct& ser, const char* name, const char* label)
|
||||
{
|
||||
const char* const typeName = ser.type().name();
|
||||
HandlersMap::const_iterator it = m_structHandlers.find(typeName);
|
||||
const bool handlerFound = (it != m_structHandlers.end());
|
||||
if (handlerFound)
|
||||
{
|
||||
StructHandlerFunctionPtr pHandler = it->second;
|
||||
return (this->*pHandler)(ser, name, label);
|
||||
}
|
||||
|
||||
return SerializeStruct(ser, name, label);
|
||||
}
|
||||
|
||||
|
||||
bool CVariableIArchive::operator()(Serialization::IContainer& ser, const char* name, [[maybe_unused]] const char* label)
|
||||
{
|
||||
_smart_ptr< IVariable > pChild = VarUtil::FindChildVariable(m_pVariable, m_childIndexOverride, name);
|
||||
if (pChild)
|
||||
{
|
||||
const int elementCount = pChild->GetNumVariables();
|
||||
ser.resize(elementCount);
|
||||
|
||||
if (0 < elementCount)
|
||||
{
|
||||
CVariableIArchive childArchive(pChild);
|
||||
childArchive.SetFilter(GetFilter());
|
||||
childArchive.SetInnerContext(GetInnerContext());
|
||||
|
||||
for (int i = 0; i < elementCount; ++i)
|
||||
{
|
||||
childArchive.m_childIndexOverride = i;
|
||||
|
||||
ser(childArchive, "", "");
|
||||
ser.next();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool CVariableIArchive::SerializeStruct(const Serialization::SStruct& ser, const char* name, [[maybe_unused]] const char* label)
|
||||
{
|
||||
_smart_ptr< IVariable > pChild = VarUtil::FindChildVariable(m_pVariable, m_childIndexOverride, name);
|
||||
if (pChild)
|
||||
{
|
||||
CVariableIArchive childArchive(pChild);
|
||||
childArchive.SetFilter(GetFilter());
|
||||
childArchive.SetInnerContext(GetInnerContext());
|
||||
|
||||
ser(childArchive);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CVariableIArchive::SerializeResourceSelector(const Serialization::SStruct& ser, const char* name, [[maybe_unused]] const char* label)
|
||||
{
|
||||
Serialization::IResourceSelector* pSelector = reinterpret_cast< Serialization::IResourceSelector* >(ser.pointer());
|
||||
|
||||
QString stringValue;
|
||||
const bool readSuccess = VarUtil::ReadChildVariableAs< QString >(m_pVariable, m_childIndexOverride, name, stringValue);
|
||||
if (readSuccess)
|
||||
{
|
||||
pSelector->SetValue(stringValue.toUtf8().data());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool CVariableIArchive::SerializeStringListStaticValue(const Serialization::SStruct& ser, const char* name, [[maybe_unused]] const char* label)
|
||||
{
|
||||
StringListStaticValue* const pStringListStaticValue = reinterpret_cast< StringListStaticValue* >(ser.pointer());
|
||||
|
||||
_smart_ptr< IVariable > pChild = VarUtil::FindChildVariable(m_pVariable, m_childIndexOverride, name);
|
||||
if (pChild)
|
||||
{
|
||||
int index = -1;
|
||||
pChild->Get(index);
|
||||
*pStringListStaticValue = index;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool CVariableIArchive::SerializeRangeFloat(const Serialization::SStruct& ser, const char* name, [[maybe_unused]] const char* label)
|
||||
{
|
||||
const Serialization::RangeDecorator< float >* const pRange = reinterpret_cast< Serialization::RangeDecorator< float >* >(ser.pointer());
|
||||
return VarUtil::ReadChildVariableAs< float >(m_pVariable, m_childIndexOverride, name, *pRange->value);
|
||||
}
|
||||
|
||||
|
||||
bool CVariableIArchive::SerializeRangeInt(const Serialization::SStruct& ser, const char* name, [[maybe_unused]] const char* label)
|
||||
{
|
||||
const Serialization::RangeDecorator< int >* const pRange = reinterpret_cast< Serialization::RangeDecorator< int >* >(ser.pointer());
|
||||
return VarUtil::ReadChildVariableAs< int >(m_pVariable, m_childIndexOverride, name, *pRange->value);
|
||||
}
|
||||
|
||||
bool CVariableIArchive::SerializeRangeUInt(const Serialization::SStruct& ser, const char* name, [[maybe_unused]] const char* label)
|
||||
{
|
||||
const Serialization::RangeDecorator< unsigned int >* const pRange = reinterpret_cast< Serialization::RangeDecorator< unsigned int >* >(ser.pointer());
|
||||
return VarUtil::ReadChildVariableAs< int >(m_pVariable, m_childIndexOverride, name, *pRange->value);
|
||||
}
|
||||
@@ -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.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Util/Variable.h"
|
||||
#include "Serialization.h"
|
||||
|
||||
namespace Serialization
|
||||
{
|
||||
class CVariableIArchive
|
||||
: public IArchive
|
||||
{
|
||||
public:
|
||||
CVariableIArchive(const _smart_ptr< IVariable >& pVariable);
|
||||
virtual ~CVariableIArchive();
|
||||
|
||||
// IArchive
|
||||
virtual bool operator()(bool& value, const char* name = "", const char* label = 0) override;
|
||||
virtual bool operator()(IString& value, const char* name = "", const char* label = 0) override;
|
||||
virtual bool operator()(IWString& value, const char* name = "", const char* label = 0) override;
|
||||
virtual bool operator()(float& value, const char* name = "", const char* label = 0) override;
|
||||
virtual bool operator()(double& value, const char* name = "", const char* label = 0) override;
|
||||
virtual bool operator()(int16& value, const char* name = "", const char* label = 0) override;
|
||||
virtual bool operator()(uint16& value, const char* name = "", const char* label = 0) override;
|
||||
virtual bool operator()(int32& value, const char* name = "", const char* label = 0) override;
|
||||
virtual bool operator()(uint32& value, const char* name = "", const char* label = 0) override;
|
||||
virtual bool operator()(int64& value, const char* name = "", const char* label = 0) override;
|
||||
virtual bool operator()(uint64& value, const char* name = "", const char* label = 0) override;
|
||||
|
||||
virtual bool operator()(int8& value, const char* name = "", const char* label = 0) override;
|
||||
virtual bool operator()(uint8& value, const char* name = "", const char* label = 0) override;
|
||||
virtual bool operator()(char& value, const char* name = "", const char* label = 0);
|
||||
|
||||
virtual bool operator()(const SStruct& ser, const char* name = "", const char* label = 0) override;
|
||||
virtual bool operator()(IContainer& ser, const char* name = "", const char* label = 0) override;
|
||||
//virtual bool operator()( IPointer& ptr, const char* name = "", const char* label = 0 ) override;
|
||||
// ~IArchive
|
||||
|
||||
using IArchive::operator();
|
||||
|
||||
private:
|
||||
bool SerializeResourceSelector(const SStruct& ser, const char* name, const char* label);
|
||||
|
||||
bool SerializeStruct(const SStruct& ser, const char* name, const char* label);
|
||||
|
||||
bool SerializeStringListStaticValue(const SStruct& ser, const char* name, const char* label);
|
||||
|
||||
bool SerializeRangeFloat(const SStruct& ser, const char* name, const char* label);
|
||||
bool SerializeRangeInt(const SStruct& ser, const char* name, const char* label);
|
||||
bool SerializeRangeUInt(const SStruct& ser, const char* name, const char* label);
|
||||
|
||||
private:
|
||||
_smart_ptr< IVariable > m_pVariable;
|
||||
int m_childIndexOverride;
|
||||
|
||||
typedef bool ( CVariableIArchive::* StructHandlerFunctionPtr )(const SStruct&, const char*, const char*);
|
||||
typedef std::map< string, StructHandlerFunctionPtr > HandlersMap;
|
||||
HandlersMap m_structHandlers; // TODO: have only one of these.
|
||||
};
|
||||
}
|
||||
@@ -1,416 +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 "VariableOArchive.h"
|
||||
|
||||
// Editor
|
||||
#include "Serialization/Decorators/Resources.h"
|
||||
#include "Serialization/Decorators/Range.h"
|
||||
|
||||
|
||||
using Serialization::CVariableOArchive;
|
||||
|
||||
namespace VarUtil
|
||||
{
|
||||
template< typename T >
|
||||
_smart_ptr< IVariable > AddChildVariable(const _smart_ptr< IVariable >& pVariableArray, const T& value, const char* const name, const char* label)
|
||||
{
|
||||
CRY_ASSERT(pVariableArray);
|
||||
|
||||
_smart_ptr< IVariable > pVariable = new CVariable< T >();
|
||||
pVariable->SetName(name);
|
||||
pVariable->SetHumanName(label);
|
||||
pVariable->Set(value);
|
||||
|
||||
pVariableArray->AddVariable(pVariable);
|
||||
|
||||
return pVariable;
|
||||
}
|
||||
|
||||
template< typename TMin, typename TMax >
|
||||
void SetLimits(const _smart_ptr< IVariable >& pVariable, const TMin minValue, const TMax maxValue)
|
||||
{
|
||||
pVariable->SetLimits(static_cast< float >(minValue), static_cast< float >(maxValue));
|
||||
}
|
||||
}
|
||||
|
||||
CVariableOArchive::CVariableOArchive()
|
||||
: IArchive(IArchive::OUTPUT | IArchive::EDIT | IArchive::NO_EMPTY_NAMES)
|
||||
, m_pVariable(new CVariableArray())
|
||||
{
|
||||
m_resourceHandlers[ "Animation" ] = &CVariableOArchive::SerializeAnimationName;
|
||||
m_resourceHandlers[ "Sound" ] = &CVariableOArchive::SerializeSoundName;
|
||||
m_resourceHandlers[ "Model" ] = &CVariableOArchive::SerializeObjectFilename;
|
||||
|
||||
m_structHandlers[ TypeID::get < Serialization::IResourceSelector > ().name() ] = &CVariableOArchive::SerializeIResourceSelector;
|
||||
m_structHandlers[ TypeID::get < Serialization::RangeDecorator < float >> ().name() ] = &CVariableOArchive::SerializeRangeFloat;
|
||||
m_structHandlers[ TypeID::get < Serialization::RangeDecorator < int >> ().name() ] = &CVariableOArchive::SerializeRangeInt;
|
||||
m_structHandlers[ TypeID::get < Serialization::RangeDecorator < unsigned int >> ().name() ] = &CVariableOArchive::SerializeRangeUInt;
|
||||
m_structHandlers[ TypeID::get < StringListStaticValue > ().name() ] = &CVariableOArchive::SerializeStringListStaticValue;
|
||||
}
|
||||
|
||||
|
||||
CVariableOArchive::~CVariableOArchive()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
_smart_ptr< IVariable > CVariableOArchive::GetIVariable() const
|
||||
{
|
||||
return m_pVariable;
|
||||
}
|
||||
|
||||
|
||||
CVarBlockPtr CVariableOArchive::GetVarBlock() const
|
||||
{
|
||||
CVarBlockPtr pVarBlock = new CVarBlock();
|
||||
pVarBlock->AddVariable(m_pVariable);
|
||||
return pVarBlock;
|
||||
}
|
||||
|
||||
|
||||
bool CVariableOArchive::operator()(bool& value, const char* name, const char* label)
|
||||
{
|
||||
VarUtil::AddChildVariable< bool >(m_pVariable, value, name, label);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool CVariableOArchive::operator()(Serialization::IString& value, const char* name, const char* label)
|
||||
{
|
||||
const QString valueString = value.get();
|
||||
VarUtil::AddChildVariable< QString >(m_pVariable, valueString, name, label);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool CVariableOArchive::operator()([[maybe_unused]] Serialization::IWString& value, [[maybe_unused]] const char* name, [[maybe_unused]] const char* label)
|
||||
{
|
||||
CryFatalError("CVarBlockOArchive::operator() with IWString is not implemented");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool CVariableOArchive::operator()(float& value, const char* name, const char* label)
|
||||
{
|
||||
VarUtil::AddChildVariable< float >(m_pVariable, value, name, label);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool CVariableOArchive::operator()(double& value, const char* name, const char* label)
|
||||
{
|
||||
VarUtil::AddChildVariable< float >(m_pVariable, value, name, label);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool CVariableOArchive::operator()(int16& value, const char* name, const char* label)
|
||||
{
|
||||
_smart_ptr< IVariable > pVariable = VarUtil::AddChildVariable< int >(m_pVariable, value, name, label);
|
||||
VarUtil::SetLimits(pVariable, SHRT_MIN, SHRT_MAX);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool CVariableOArchive::operator()(uint16& value, const char* name, const char* label)
|
||||
{
|
||||
_smart_ptr< IVariable > pVariable = VarUtil::AddChildVariable< int >(m_pVariable, value, name, label);
|
||||
VarUtil::SetLimits(pVariable, 0, USHRT_MAX);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool CVariableOArchive::operator()(int32& value, const char* name, const char* label)
|
||||
{
|
||||
_smart_ptr< IVariable > pVariable = VarUtil::AddChildVariable< int >(m_pVariable, value, name, label);
|
||||
VarUtil::SetLimits(pVariable, INT_MIN, INT_MAX);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool CVariableOArchive::operator()(uint32& value, const char* name, const char* label)
|
||||
{
|
||||
_smart_ptr< IVariable > pVariable = VarUtil::AddChildVariable< int >(m_pVariable, value, name, label);
|
||||
VarUtil::SetLimits(pVariable, 0, INT_MAX);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool CVariableOArchive::operator()(int64& value, const char* name, const char* label)
|
||||
{
|
||||
_smart_ptr< IVariable > pVariable = VarUtil::AddChildVariable< int >(m_pVariable, value, name, label);
|
||||
VarUtil::SetLimits(pVariable, INT_MIN, INT_MAX);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool CVariableOArchive::operator()(uint64& value, const char* name, const char* label)
|
||||
{
|
||||
_smart_ptr< IVariable > pVariable = VarUtil::AddChildVariable< int >(m_pVariable, value, name, label);
|
||||
VarUtil::SetLimits(pVariable, 0, INT_MAX);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool CVariableOArchive::operator()(int8& value, const char* name, const char* label)
|
||||
{
|
||||
_smart_ptr< IVariable > pVariable = VarUtil::AddChildVariable< int >(m_pVariable, value, name, label);
|
||||
VarUtil::SetLimits(pVariable, SCHAR_MIN, SCHAR_MAX);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool CVariableOArchive::operator()(uint8& value, const char* name, const char* label)
|
||||
{
|
||||
_smart_ptr< IVariable > pVariable = VarUtil::AddChildVariable< int >(m_pVariable, value, name, label);
|
||||
VarUtil::SetLimits(pVariable, 0, UCHAR_MAX);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool CVariableOArchive::operator()(char& value, const char* name, const char* label)
|
||||
{
|
||||
_smart_ptr< IVariable > pVariable = VarUtil::AddChildVariable< int >(m_pVariable, value, name, label);
|
||||
VarUtil::SetLimits(pVariable, CHAR_MIN, CHAR_MAX);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool CVariableOArchive::operator()(const Serialization::SStruct& ser, const char* name, const char* label)
|
||||
{
|
||||
const char* const typeName = ser.type().name();
|
||||
HandlersMap::const_iterator it = m_structHandlers.find(typeName);
|
||||
const bool handlerFound = (it != m_structHandlers.end());
|
||||
if (handlerFound)
|
||||
{
|
||||
StructHandlerFunctionPtr pHandler = it->second;
|
||||
return (this->*pHandler)(ser, name, label);
|
||||
}
|
||||
|
||||
return SerializeStruct(ser, name, label);
|
||||
}
|
||||
|
||||
static const char* gVec4Names[] = { "X", "Y", "Z", "W" };
|
||||
static const char* gEmptyNames[] = { "" };
|
||||
|
||||
bool CVariableOArchive::operator()(Serialization::IContainer& ser, const char* name, const char* label)
|
||||
{
|
||||
CVariableOArchive childArchive;
|
||||
childArchive.SetFilter(GetFilter());
|
||||
childArchive.SetInnerContext(GetInnerContext());
|
||||
|
||||
_smart_ptr< IVariable > pChildVariable = childArchive.GetIVariable();
|
||||
pChildVariable->SetName(name);
|
||||
pChildVariable->SetHumanName(label);
|
||||
|
||||
m_pVariable->AddVariable(pChildVariable);
|
||||
|
||||
const size_t containerSize = ser.size();
|
||||
|
||||
const char** nameArray = gEmptyNames;
|
||||
size_t nameArraySize = 1;
|
||||
if (containerSize >= 2 && containerSize <= 4)
|
||||
{
|
||||
nameArray = gVec4Names;
|
||||
nameArraySize = containerSize;
|
||||
}
|
||||
|
||||
size_t index = 0;
|
||||
if (0 < containerSize)
|
||||
{
|
||||
do
|
||||
{
|
||||
ser(childArchive, nameArray[index % nameArraySize], nameArray[index % nameArraySize]);
|
||||
++index;
|
||||
} while (ser.next());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool CVariableOArchive::SerializeStruct(const Serialization::SStruct& ser, const char* name, const char* label)
|
||||
{
|
||||
CVariableOArchive childArchive;
|
||||
childArchive.SetFilter(GetFilter());
|
||||
childArchive.SetInnerContext(GetInnerContext());
|
||||
|
||||
_smart_ptr< IVariable > pChildVariable = childArchive.GetIVariable();
|
||||
pChildVariable->SetName(name);
|
||||
pChildVariable->SetHumanName(label);
|
||||
|
||||
m_pVariable->AddVariable(pChildVariable);
|
||||
|
||||
const bool serializeSuccess = ser(childArchive);
|
||||
|
||||
return serializeSuccess;
|
||||
}
|
||||
|
||||
|
||||
bool CVariableOArchive::SerializeAnimationName(const Serialization::IResourceSelector* pSelector, const char* name, const char* label)
|
||||
{
|
||||
const QString valueString = pSelector->GetValue();
|
||||
_smart_ptr< IVariable > pVariable = VarUtil::AddChildVariable< QString >(m_pVariable, valueString, name, label);
|
||||
pVariable->SetDataType(IVariable::DT_ANIMATION);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool CVariableOArchive::SerializeSoundName(const Serialization::IResourceSelector* pSelector, const char* name, const char* label)
|
||||
{
|
||||
const QString valueString = pSelector->GetValue();
|
||||
_smart_ptr< IVariable > pVariable = VarUtil::AddChildVariable< QString >(m_pVariable, valueString, name, label);
|
||||
pVariable->SetDataType(IVariable::DT_AUDIO_TRIGGER);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CVariableOArchive::CreateChildEnumVariable(const QStringList& enumValues, const QString& value, const char* name, const char* label)
|
||||
{
|
||||
if (enumValues.empty())
|
||||
{
|
||||
VarUtil::AddChildVariable< QString >(m_pVariable, value, name, label);
|
||||
}
|
||||
else
|
||||
{
|
||||
_smart_ptr< CVariableEnum< QString > > pVariable = new CVariableEnum< QString >();
|
||||
pVariable->SetName(name);
|
||||
pVariable->SetHumanName(label);
|
||||
|
||||
pVariable->AddEnumItem("", "");
|
||||
|
||||
const size_t enumValuesCount = enumValues.size();
|
||||
for (size_t i = 0; i < enumValuesCount; ++i)
|
||||
{
|
||||
pVariable->AddEnumItem(enumValues[ i ], enumValues[ i ]);
|
||||
}
|
||||
|
||||
pVariable->Set(value);
|
||||
|
||||
m_pVariable->AddVariable(pVariable);
|
||||
}
|
||||
}
|
||||
|
||||
bool CVariableOArchive::SerializeObjectFilename(const Serialization::IResourceSelector* pSelector, const char* name, const char* label)
|
||||
{
|
||||
const QString valueString = pSelector->GetValue();
|
||||
_smart_ptr< IVariable > pVariable = VarUtil::AddChildVariable< QString >(m_pVariable, valueString, name, label);
|
||||
pVariable->SetDataType(IVariable::DT_OBJECT);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool CVariableOArchive::SerializeStringListStaticValue(const Serialization::SStruct& ser, const char* name, const char* label)
|
||||
{
|
||||
const StringListStaticValue* const pStringListStaticValue = reinterpret_cast< StringListStaticValue* >(ser.pointer());
|
||||
const StringListStatic& stringListStatic = pStringListStaticValue->stringList();
|
||||
const int index = pStringListStaticValue->index();
|
||||
|
||||
_smart_ptr< CVariableEnum< int > > pVariable = new CVariableEnum< int >();
|
||||
pVariable->SetName(name);
|
||||
pVariable->SetHumanName(label);
|
||||
|
||||
const size_t stringListStaticSize = stringListStatic.size();
|
||||
for (size_t i = 0; i < stringListStaticSize; ++i)
|
||||
{
|
||||
pVariable->AddEnumItem(stringListStatic[ i ], static_cast< int >(i));
|
||||
}
|
||||
|
||||
if (0 <= index)
|
||||
{
|
||||
CRY_ASSERT(index < stringListStaticSize);
|
||||
pVariable->Set(static_cast< int >(index));
|
||||
}
|
||||
|
||||
m_pVariable->AddVariable(pVariable);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CVariableOArchive::SerializeIResourceSelector(const Serialization::SStruct& ser, const char* name, const char* label)
|
||||
{
|
||||
const Serialization::IResourceSelector* pSelector = reinterpret_cast< Serialization::IResourceSelector* >(ser.pointer());
|
||||
|
||||
ResourceHandlersMap::iterator it = m_resourceHandlers.find(pSelector->resourceType);
|
||||
if (it != m_resourceHandlers.end())
|
||||
{
|
||||
return (this->*(it->second))(pSelector, name, label);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
static void SetLimits(IVariable* pVariable, const Serialization::RangeDecorator<T>* pRange, float stepValue)
|
||||
{
|
||||
if (pRange->softMin != std::numeric_limits<T>::lowest() || pRange->softMax != std::numeric_limits<T>::max())
|
||||
{
|
||||
float minimal = (float)pRange->softMin;
|
||||
float maximal = (float)pRange->softMax;
|
||||
bool hardMin = false;
|
||||
bool hardMax = false;
|
||||
if (pRange->hardMin != std::numeric_limits<T>::lowest())
|
||||
{
|
||||
minimal = pRange->hardMin;
|
||||
hardMin = true;
|
||||
}
|
||||
if (pRange->hardMax != std::numeric_limits<T>::max())
|
||||
{
|
||||
maximal = pRange->hardMax;
|
||||
hardMax = true;
|
||||
}
|
||||
pVariable->SetLimits(minimal, maximal, stepValue, hardMin, hardMax);
|
||||
}
|
||||
else
|
||||
{
|
||||
float minimal = 0.0f;
|
||||
float maximal = 0.0f;
|
||||
float oldStep = 0.0f;
|
||||
bool hardMin = false;
|
||||
bool hardMax = false;
|
||||
pVariable->GetLimits(minimal, maximal, oldStep, hardMin, hardMax);
|
||||
pVariable->SetLimits(minimal, maximal, stepValue, hardMin, hardMax);
|
||||
}
|
||||
}
|
||||
|
||||
bool CVariableOArchive::SerializeRangeFloat(const Serialization::SStruct& ser, const char* name, const char* label)
|
||||
{
|
||||
const Serialization::RangeDecorator< float >* const pRange = reinterpret_cast< Serialization::RangeDecorator< float >* >(ser.pointer());
|
||||
|
||||
_smart_ptr< IVariable > pVariable = VarUtil::AddChildVariable< float >(m_pVariable, *pRange->value, name, label);
|
||||
|
||||
SetLimits(pVariable.get(), pRange, 0.01f);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CVariableOArchive::SerializeRangeInt(const Serialization::SStruct& ser, const char* name, const char* label)
|
||||
{
|
||||
const Serialization::RangeDecorator< int >* const pRange = reinterpret_cast< Serialization::RangeDecorator< int >* >(ser.pointer());
|
||||
|
||||
_smart_ptr< IVariable > pVariable = VarUtil::AddChildVariable< int >(m_pVariable, *pRange->value, name, label);
|
||||
SetLimits(pVariable.get(), pRange, 1.0f);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CVariableOArchive::SerializeRangeUInt(const Serialization::SStruct& ser, const char* name, const char* label)
|
||||
{
|
||||
const Serialization::RangeDecorator< unsigned int >* const pRange = reinterpret_cast< Serialization::RangeDecorator< unsigned int >* >(ser.pointer());
|
||||
|
||||
_smart_ptr< IVariable > pVariable = VarUtil::AddChildVariable< int >(m_pVariable, *pRange->value, name, label);
|
||||
SetLimits(pVariable, pRange, 1.0f);
|
||||
return true;
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Util/Variable.h"
|
||||
#include "Serialization.h"
|
||||
|
||||
|
||||
namespace Serialization
|
||||
{
|
||||
struct IResourceSelector;
|
||||
|
||||
class CVariableOArchive
|
||||
: public IArchive
|
||||
{
|
||||
public:
|
||||
CVariableOArchive();
|
||||
virtual ~CVariableOArchive();
|
||||
|
||||
_smart_ptr< IVariable > GetIVariable() const;
|
||||
CVarBlockPtr GetVarBlock() const;
|
||||
|
||||
// IArchive
|
||||
virtual bool operator()(bool& value, const char* name = "", const char* label = 0) override;
|
||||
virtual bool operator()(IString& value, const char* name = "", const char* label = 0) override;
|
||||
virtual bool operator()(IWString& value, const char* name = "", const char* label = 0) override;
|
||||
virtual bool operator()(float& value, const char* name = "", const char* label = 0) override;
|
||||
virtual bool operator()(double& value, const char* name = "", const char* label = 0) override;
|
||||
virtual bool operator()(int16& value, const char* name = "", const char* label = 0) override;
|
||||
virtual bool operator()(uint16& value, const char* name = "", const char* label = 0) override;
|
||||
virtual bool operator()(int32& value, const char* name = "", const char* label = 0) override;
|
||||
virtual bool operator()(uint32& value, const char* name = "", const char* label = 0) override;
|
||||
virtual bool operator()(int64& value, const char* name = "", const char* label = 0) override;
|
||||
virtual bool operator()(uint64& value, const char* name = "", const char* label = 0) override;
|
||||
|
||||
virtual bool operator()(int8& value, const char* name = "", const char* label = 0) override;
|
||||
virtual bool operator()(uint8& value, const char* name = "", const char* label = 0) override;
|
||||
virtual bool operator()(char& value, const char* name = "", const char* label = 0);
|
||||
|
||||
virtual bool operator()(const SStruct& ser, const char* name = "", const char* label = 0) override;
|
||||
virtual bool operator()(IContainer& ser, const char* name = "", const char* label = 0) override;
|
||||
//virtual bool operator()( IPointer& ptr, const char* name = "", const char* label = 0 ) override;
|
||||
// ~IArchive
|
||||
|
||||
using IArchive::operator();
|
||||
|
||||
private:
|
||||
bool SerializeStruct(const SStruct& ser, const char* name, const char* label);
|
||||
bool SerializeStringListStaticValue(const SStruct& ser, const char* name, const char* label);
|
||||
bool SerializeRangeFloat(const SStruct& ser, const char* name, const char* label);
|
||||
bool SerializeRangeInt(const SStruct& ser, const char* name, const char* label);
|
||||
bool SerializeRangeUInt(const SStruct& ser, const char* name, const char* label);
|
||||
bool SerializeIResourceSelector(const SStruct& ser, const char* name, const char* label);
|
||||
|
||||
bool SerializeAnimationName(const IResourceSelector* pSelector, const char* name, const char* label);
|
||||
bool SerializeSoundName(const IResourceSelector* pSelector, const char* name, const char* label);
|
||||
bool SerializeObjectFilename(const IResourceSelector* pSelector, const char* name, const char* label);
|
||||
|
||||
void CreateChildEnumVariable(const QStringList& enumValues, const QString& value, const char* name, const char* label);
|
||||
|
||||
private:
|
||||
_smart_ptr< IVariable > m_pVariable;
|
||||
|
||||
typedef bool ( CVariableOArchive::* StructHandlerFunctionPtr )(const SStruct&, const char*, const char*);
|
||||
typedef std::map< string, StructHandlerFunctionPtr > HandlersMap;
|
||||
HandlersMap m_structHandlers; // TODO: have only one of these.
|
||||
|
||||
typedef bool ( CVariableOArchive::* ResourceHandlerFunctionPtr )(const IResourceSelector*, const char*, const char*);
|
||||
typedef std::map< string, ResourceHandlerFunctionPtr > ResourceHandlersMap;
|
||||
ResourceHandlersMap m_resourceHandlers;
|
||||
};
|
||||
}
|
||||
@@ -40,8 +40,6 @@
|
||||
|
||||
#include <AzQtComponents/Components/Widgets/ToolBar.h>
|
||||
|
||||
class CGrid;
|
||||
|
||||
struct SGizmoSettings
|
||||
{
|
||||
float axisGizmoSize;
|
||||
@@ -393,9 +391,6 @@ AZ_POP_DISABLE_DLL_EXPORT_BASECLASS_WARNING
|
||||
//! Keeps the editor active even if no focus is set
|
||||
int keepEditorActive;
|
||||
|
||||
//! Pointer to currently used grid.
|
||||
CGrid* pGrid;
|
||||
|
||||
SGizmoSettings gizmo;
|
||||
|
||||
// Settings of the snapping.
|
||||
|
||||
@@ -1,177 +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 "SettingsBlock.h"
|
||||
|
||||
// CryCommon
|
||||
#include <CryCommon/Serialization/ITextInputArchive.h>
|
||||
#include <CryCommon/Serialization/ITextOutputArchive.h>
|
||||
|
||||
// Editor
|
||||
#include "Serialization.h"
|
||||
|
||||
using std::vector;
|
||||
|
||||
SProjectSettingsBlock* SProjectSettingsBlock::s_pLastBlock;
|
||||
|
||||
SProjectSettingsBlock::SProjectSettingsBlock(const char* name, const char* label)
|
||||
: m_name(name)
|
||||
, m_label(label)
|
||||
{
|
||||
m_pPrevious = s_pLastBlock;
|
||||
s_pLastBlock = this;
|
||||
}
|
||||
|
||||
|
||||
struct SAllSettingsSerializer
|
||||
{
|
||||
void Serialize(Serialization::IArchive& ar)
|
||||
{
|
||||
SProjectSettingsBlock* pCurrent = SProjectSettingsBlock::s_pLastBlock;
|
||||
while (pCurrent != 0)
|
||||
{
|
||||
ar(*pCurrent, pCurrent->GetName(), pCurrent->GetLabel());
|
||||
pCurrent = pCurrent->m_pPrevious;
|
||||
}
|
||||
}
|
||||
} static gAllSettingsSerializer;
|
||||
|
||||
void SProjectSettingsBlock::GetAllSettingsSerializer(Serialization::SStruct* pSerializer)
|
||||
{
|
||||
*pSerializer = Serialization::SStruct(gAllSettingsSerializer);
|
||||
}
|
||||
|
||||
SProjectSettingsBlock* SProjectSettingsBlock::Find(const char* blockName)
|
||||
{
|
||||
SProjectSettingsBlock* pCurrent = SProjectSettingsBlock::s_pLastBlock;
|
||||
while (pCurrent != 0)
|
||||
{
|
||||
if (_stricmp(pCurrent->GetName(), blockName) == 0)
|
||||
{
|
||||
return pCurrent;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool ReadFileContent(vector<char>* pBuffer, const char* filename)
|
||||
{
|
||||
AZ::IO::HandleType fileHandle = gEnv->pCryPak->FOpen(filename, "rb");
|
||||
if (fileHandle == AZ::IO::InvalidHandle)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t size = gEnv->pCryPak->FGetSize(fileHandle);
|
||||
pBuffer->resize(size);
|
||||
|
||||
bool result = true;
|
||||
if (gEnv->pCryPak->FRead(&(*pBuffer)[0], size, fileHandle) != size)
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
gEnv->pCryPak->FClose(fileHandle);
|
||||
return result;
|
||||
}
|
||||
|
||||
static bool SaveFileContent(const char* filename, const char* pBuffer, size_t length)
|
||||
{
|
||||
string fullpath = Path::GamePathToFullPath(filename).toUtf8().data();
|
||||
|
||||
AZ::IO::HandleType fileHandle = AZ::IO::InvalidHandle;
|
||||
if (!gEnv->pFileIO->Open(fullpath.c_str(), AZ::IO::GetOpenModeFromStringMode("wb"), fileHandle))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool result = true;
|
||||
if (!gEnv->pFileIO->Write(fileHandle, pBuffer, length))
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
|
||||
gEnv->pFileIO->Close(fileHandle);
|
||||
return result;
|
||||
}
|
||||
|
||||
static bool SaveFileContentIfDiffers(const char* filename, const char* pBuffer, size_t length)
|
||||
{
|
||||
vector<char> content;
|
||||
ReadFileContent(&content, filename);
|
||||
|
||||
bool needToWrite = true;
|
||||
if (!content.empty() && content.size() == length)
|
||||
{
|
||||
needToWrite = memcmp(&content[0], pBuffer, length) != 0;
|
||||
}
|
||||
|
||||
if (needToWrite)
|
||||
{
|
||||
return SaveFileContent(filename, pBuffer, length);
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool SProjectSettingsBlock::Load()
|
||||
{
|
||||
const char* filename = GetFilename();
|
||||
|
||||
vector<char> content;
|
||||
if (!ReadFileContent(&content, filename))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
auto pArchive(Serialization::CreateTextInputArchive());
|
||||
if (!pArchive)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!pArchive->AttachMemory(&content[0], content.size()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Serialization::SStruct serializer;
|
||||
GetAllSettingsSerializer(&serializer);
|
||||
serializer(*pArchive);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SProjectSettingsBlock::Save()
|
||||
{
|
||||
const char* filename = GetFilename();
|
||||
auto pArchive(Serialization::CreateTextOutputArchive());
|
||||
if (!pArchive)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Serialization::SStruct serializer;
|
||||
GetAllSettingsSerializer(&serializer);
|
||||
serializer(*pArchive);
|
||||
|
||||
return SaveFileContentIfDiffers(filename, pArchive->GetBuffer(), pArchive->GetBufferLength());
|
||||
}
|
||||
|
||||
const char* SProjectSettingsBlock::GetFilename()
|
||||
{
|
||||
return "SandboxSettings.json";
|
||||
}
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#pragma once
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Following utility can be used to add blocks of per-project settings.
|
||||
// Example:
|
||||
//
|
||||
// MyComponent.cpp:
|
||||
//
|
||||
// struct SProjectSettingsMy : SProjectSettingsBlock
|
||||
// {
|
||||
// bool bMyOption;
|
||||
//
|
||||
// SProjectSettingsMy()
|
||||
// : SProjectSettingsBlock("my", "My")
|
||||
// , bMyOption(false)
|
||||
// {}
|
||||
//
|
||||
// void Serialize(Serialization::IArchive& ar)
|
||||
// {
|
||||
// ar(bMyOption, "myOption", "My Option");
|
||||
// }
|
||||
//
|
||||
// } static gMySettings;
|
||||
//
|
||||
//
|
||||
// Now gMySettings will be loaded and saved automatically and available for
|
||||
// editing through:
|
||||
//
|
||||
// GetIEditor()->OpenProjectSettings("my");
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
#ifndef CRYINCLUDE_EDITOR_SETTINGSBLOCK_H
|
||||
#define CRYINCLUDE_EDITOR_SETTINGSBLOCK_H
|
||||
|
||||
namespace Serialization
|
||||
{
|
||||
class IArchive;
|
||||
struct SStruct;
|
||||
};
|
||||
|
||||
struct SProjectSettingsBlock
|
||||
{
|
||||
SProjectSettingsBlock(const char* name, const char* label);
|
||||
|
||||
virtual void Serialize(Serialization::IArchive& ar) = 0;
|
||||
|
||||
const char* GetName() const{ return m_name; }
|
||||
const char* GetLabel() const{ return m_label; }
|
||||
|
||||
static void GetAllSettingsSerializer(Serialization::SStruct* serializer);
|
||||
static SProjectSettingsBlock* Find(const char* name);
|
||||
static bool Load();
|
||||
static bool Save();
|
||||
static const char* GetFilename();
|
||||
private:
|
||||
const char* m_name;
|
||||
const char* m_label;
|
||||
SProjectSettingsBlock* m_pPrevious;
|
||||
static SProjectSettingsBlock* s_pLastBlock;
|
||||
friend struct SAllSettingsSerializer;
|
||||
};
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_SETTINGSBLOCK_H
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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
|
||||
@@ -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>
|
||||
@@ -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
|
||||
@@ -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>
|
||||
@@ -595,10 +595,6 @@ AmazonToolbar ToolbarManager::GetEditModeToolbar() const
|
||||
t.AddAction(ID_TOOLBAR_WIDGET_SNAP_GRID, ORIGINAL_TOOLBAR_VERSION);
|
||||
t.AddAction(ID_TOOLBAR_WIDGET_SNAP_ANGLE, ORIGINAL_TOOLBAR_VERSION);
|
||||
|
||||
t.AddAction(ID_TOOLBAR_SEPARATOR, ORIGINAL_TOOLBAR_VERSION);
|
||||
t.AddAction(ID_TOOLBAR_WIDGET_ENVIRONMENT_MODE, ORIGINAL_TOOLBAR_VERSION);
|
||||
t.AddAction(ID_TOOLBAR_WIDGET_DEBUG_MODE, ORIGINAL_TOOLBAR_VERSION);
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
@@ -613,13 +609,15 @@ AmazonToolbar ToolbarManager::GetObjectToolbar() const
|
||||
|
||||
AmazonToolbar ToolbarManager::GetPlayConsoleToolbar() const
|
||||
{
|
||||
AmazonToolbar t = AmazonToolbar("PlayConsole", QObject::tr("Play Console"));
|
||||
AmazonToolbar t = AmazonToolbar("PlayConsole", QObject::tr("Play Controls"));
|
||||
t.SetMainToolbar(true);
|
||||
|
||||
t.AddAction(ID_TOOLBAR_WIDGET_SPACER_RIGHT, ORIGINAL_TOOLBAR_VERSION);
|
||||
t.AddAction(ID_TOOLBAR_SEPARATOR, ORIGINAL_TOOLBAR_VERSION);
|
||||
t.AddAction(ID_TOOLBAR_WIDGET_PLAYCONSOLE_LABEL, ORIGINAL_TOOLBAR_VERSION);
|
||||
t.AddAction(ID_VIEW_SWITCHTOGAME, TOOLBARS_WITH_PLAY_GAME);
|
||||
t.AddAction(ID_TOOLBAR_SEPARATOR, ORIGINAL_TOOLBAR_VERSION);
|
||||
t.AddAction(ID_SWITCH_PHYSICS, TOOLBARS_WITH_PLAY_GAME);
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -27,38 +27,3 @@ void CUsedResources::Add(const char* pResourceFileName)
|
||||
files.insert(pResourceFileName);
|
||||
}
|
||||
}
|
||||
|
||||
void CUsedResources::Validate(IErrorReport* pReport)
|
||||
{
|
||||
auto pPak = gEnv->pCryPak;
|
||||
|
||||
for (TResourceFiles::iterator it = files.begin(); it != files.end(); ++it)
|
||||
{
|
||||
const QString& filename = *it;
|
||||
|
||||
bool fileExists = pPak->IsFileExist(filename.toUtf8().data());
|
||||
|
||||
if (!fileExists)
|
||||
{
|
||||
for (int i = 0; !fileExists && i < IResourceCompilerHelper::GetNumEngineImageFormats(); ++i)
|
||||
{
|
||||
fileExists = gEnv->pCryPak->IsFileExist(PathUtil::ReplaceExtension(filename.toUtf8().data(), IResourceCompilerHelper::GetEngineImageFormat(i, true)).c_str());
|
||||
}
|
||||
for (int i = 0; !fileExists && i < IResourceCompilerHelper::GetNumSourceImageFormats(); ++i)
|
||||
{
|
||||
fileExists = gEnv->pCryPak->IsFileExist(PathUtil::ReplaceExtension(filename.toUtf8().data(), IResourceCompilerHelper::GetSourceImageFormat(i, true)).c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!fileExists)
|
||||
{
|
||||
CErrorRecord err;
|
||||
|
||||
err.error = QObject::tr("Resource File %1 not found,").arg(filename);
|
||||
err.severity = CErrorRecord::ESEVERITY_ERROR;
|
||||
err.flags |= CErrorRecord::FLAG_NOFILE;
|
||||
pReport->ReportError(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,8 +36,6 @@ public:
|
||||
|
||||
CUsedResources();
|
||||
void Add(const char* pResourceFileName);
|
||||
//! validate gathered resources, reports warning if resource is not found
|
||||
void Validate(struct IErrorReport* pReport);
|
||||
|
||||
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
TResourceFiles files;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,224 @@
|
||||
/*
|
||||
* 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_CRYCOMMONTOOLS_STRINGHELPERS_H
|
||||
#define CRYINCLUDE_CRYCOMMONTOOLS_STRINGHELPERS_H
|
||||
#pragma once
|
||||
|
||||
#include <CryString.h>
|
||||
|
||||
namespace StringHelpers
|
||||
{
|
||||
// compares two strings to see if they are the same or different, case sensitive
|
||||
// returns 0 if the strings are the same, a -1 if the first string is bigger, or a 1 if the second string is bigger
|
||||
int Compare(const string& str0, const string& str1);
|
||||
int Compare(const wstring& str0, const wstring& str1);
|
||||
|
||||
// compares two strings to see if they are the same or different, case is ignored
|
||||
// returns 0 if the strings are the same, a -1 if the first string is bigger, or a 1 if the second string is bigger
|
||||
int CompareIgnoreCase(const string& str0, const string& str1);
|
||||
int CompareIgnoreCase(const wstring& str0, const wstring& str1);
|
||||
|
||||
// compares two strings to see if they are the same, case senstive
|
||||
// returns true if they are the same or false if they are different
|
||||
bool Equals(const string& str0, const string& str1);
|
||||
bool Equals(const wstring& str0, const wstring& str1);
|
||||
|
||||
// compares two strings to see if they are the same, case is ignored
|
||||
// returns true if they are the same or false if they are different
|
||||
bool EqualsIgnoreCase(const string& str0, const string& str1);
|
||||
bool EqualsIgnoreCase(const wstring& str0, const wstring& str1);
|
||||
|
||||
// checks to see if a string starts with a specified string, case sensitive
|
||||
// returns true if the string does start with a specified string or false if it does not
|
||||
bool StartsWith(const string& str, const string& pattern);
|
||||
bool StartsWith(const wstring& str, const wstring& pattern);
|
||||
|
||||
// checks to see if a string starts with a specified string, case is ignored
|
||||
// returns true if the string does start with a specified string or false if it does not
|
||||
bool StartsWithIgnoreCase(const string& str, const string& pattern);
|
||||
bool StartsWithIgnoreCase(const wstring& str, const wstring& pattern);
|
||||
|
||||
// checks to see if a string ends with a specified string, case sensitive
|
||||
// returns true if the string does end with a specified string or false if it does not
|
||||
bool EndsWith(const string& str, const string& pattern);
|
||||
bool EndsWith(const wstring& str, const wstring& pattern);
|
||||
|
||||
// checks to see if a string ends with a specified string, case is ignored
|
||||
// returns true if the string does end with a specified string or false if it does not
|
||||
bool EndsWithIgnoreCase(const string& str, const string& pattern);
|
||||
bool EndsWithIgnoreCase(const wstring& str, const wstring& pattern);
|
||||
|
||||
// checks to see if a string contains a specified string, case sensitive
|
||||
// returns true if the string does contain the specified string or false if it does not
|
||||
bool Contains(const string& str, const string& pattern);
|
||||
bool Contains(const wstring& str, const wstring& pattern);
|
||||
|
||||
// checks to see if a string contains a specified string, case is ignored
|
||||
// returns true if the string does contain the specified string or false if it does not
|
||||
bool ContainsIgnoreCase(const string& str, const string& pattern);
|
||||
bool ContainsIgnoreCase(const wstring& str, const wstring& pattern);
|
||||
|
||||
// checks to see if a string contains a wildcard string pattern, case sensitive
|
||||
// returns true if the string does match the wildcard string pattern or false if it does not
|
||||
bool MatchesWildcards(const string& str, const string& wildcards);
|
||||
bool MatchesWildcards(const wstring& str, const wstring& wildcards);
|
||||
|
||||
// checks to see if a string contains a wildcard string pattern, case is ignored
|
||||
// returns true if the string does match the wildcard string pattern or false if it does not
|
||||
bool MatchesWildcardsIgnoreCase(const string& str, const string& wildcards);
|
||||
bool MatchesWildcardsIgnoreCase(const wstring& str, const wstring& wildcards);
|
||||
|
||||
bool MatchesWildcardsIgnoreCaseExt(const string& str, const string& wildcards, std::vector<string>& wildcardMatches);
|
||||
bool MatchesWildcardsIgnoreCaseExt(const wstring& str, const wstring& wildcards, std::vector<wstring>& wildcardMatches);
|
||||
|
||||
string TrimLeft(const string& s);
|
||||
wstring TrimLeft(const wstring& s);
|
||||
|
||||
string TrimRight(const string& s);
|
||||
wstring TrimRight(const wstring& s);
|
||||
|
||||
string Trim(const string& s);
|
||||
wstring Trim(const wstring& s);
|
||||
|
||||
string RemoveDuplicateSpaces(const string& s);
|
||||
wstring RemoveDuplicateSpaces(const wstring& s);
|
||||
|
||||
// converts a string with upper case characters to be all lower case
|
||||
// returns the string in all lower case
|
||||
string MakeLowerCase(const string& s);
|
||||
wstring MakeLowerCase(const wstring& s);
|
||||
|
||||
// converts a string with lower case characters to be all upper case
|
||||
// returns the string in all upper case
|
||||
string MakeUpperCase(const string& s);
|
||||
wstring MakeUpperCase(const wstring& s);
|
||||
|
||||
// replace a specified character in a string with a specified replacement character
|
||||
// returns string with specified character replaced
|
||||
string Replace(const string& s, char oldChar, char newChar);
|
||||
wstring Replace(const wstring& s, wchar_t oldChar, wchar_t newChar);
|
||||
|
||||
void ConvertStringByRef(string& out, const string& in);
|
||||
void ConvertStringByRef(wstring& out, const string& in);
|
||||
void ConvertStringByRef(string& out, const wstring& in);
|
||||
void ConvertStringByRef(wstring& out, const wstring& in);
|
||||
|
||||
template <typename O, typename I>
|
||||
O ConvertString(const I& in)
|
||||
{
|
||||
O out;
|
||||
ConvertStringByRef(out, in);
|
||||
return out;
|
||||
}
|
||||
|
||||
void Split(const string& str, const string& separator, bool bReturnEmptyPartsToo, std::vector<string>& outParts);
|
||||
void Split(const wstring& str, const wstring& separator, bool bReturnEmptyPartsToo, std::vector<wstring>& outParts);
|
||||
|
||||
void SplitByAnyOf(const string& str, const string& separators, bool bReturnEmptyPartsToo, std::vector<string>& outParts);
|
||||
void SplitByAnyOf(const wstring& str, const wstring& separators, bool bReturnEmptyPartsToo, std::vector<wstring>& outParts);
|
||||
|
||||
string FormatVA(const char* const format, va_list parg);
|
||||
wstring FormatVA(const wchar_t* const format, va_list parg);
|
||||
|
||||
inline string Format(const char* const format, ...)
|
||||
{
|
||||
if ((format == 0) || (format[0] == 0))
|
||||
{
|
||||
return string();
|
||||
}
|
||||
va_list parg;
|
||||
va_start(parg, format);
|
||||
const string result = FormatVA(format, parg);
|
||||
va_end(parg);
|
||||
return result;
|
||||
}
|
||||
|
||||
inline wstring Format(const wchar_t* const format, ...)
|
||||
{
|
||||
if ((format == 0) || (format[0] == 0))
|
||||
{
|
||||
return wstring();
|
||||
}
|
||||
va_list parg;
|
||||
va_start(parg, format);
|
||||
const wstring result = FormatVA(format, parg);
|
||||
va_end(parg);
|
||||
return result;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void SafeCopy(char* const pDstBuffer, const size_t dstBufferSizeInBytes, const char* const pSrc);
|
||||
void SafeCopy(wchar_t* const pDstBuffer, const size_t dstBufferSizeInBytes, const wchar_t* const pSrc);
|
||||
|
||||
void SafeCopyPadZeros(char* const pDstBuffer, const size_t dstBufferSizeInBytes, const char* const pSrc);
|
||||
void SafeCopyPadZeros(wchar_t* const pDstBuffer, const size_t dstBufferSizeInBytes, const wchar_t* const pSrc);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ASCII
|
||||
// ANSI (system default Windows ANSI code page)
|
||||
// UTF-8
|
||||
// UTF-16
|
||||
|
||||
// ASCII -> UTF-16
|
||||
|
||||
bool Utf16ContainsAsciiOnly(const wchar_t* wstr);
|
||||
string ConvertAsciiUtf16ToAscii(const wchar_t* wstr);
|
||||
wstring ConvertAsciiToUtf16(const char* str);
|
||||
|
||||
// UTF-8 <-> UTF-16
|
||||
#if defined(AZ_PLATFORM_WINDOWS)
|
||||
wstring ConvertUtf8ToUtf16(const char* str);
|
||||
string ConvertUtf16ToUtf8(const wchar_t* wstr);
|
||||
|
||||
inline string ConvertUtfToUtf8(const char* str)
|
||||
{
|
||||
return string(str);
|
||||
}
|
||||
|
||||
inline string ConvertUtfToUtf8(const wchar_t* wstr)
|
||||
{
|
||||
return ConvertUtf16ToUtf8(wstr);
|
||||
}
|
||||
|
||||
inline wstring ConvertUtfToUtf16(const char* str)
|
||||
{
|
||||
return ConvertUtf8ToUtf16(str);
|
||||
}
|
||||
|
||||
inline wstring ConvertUtfToUtf16(const wchar_t* wstr)
|
||||
{
|
||||
return wstring(wstr);
|
||||
}
|
||||
|
||||
// ANSI <-> UTF-8, UTF-16
|
||||
|
||||
wstring ConvertAnsiToUtf16(const char* str);
|
||||
string ConvertUtf16ToAnsi(const wchar_t* wstr, char badChar);
|
||||
|
||||
inline string ConvertAnsiToUtf8(const char* str)
|
||||
{
|
||||
return ConvertUtf16ToUtf8(ConvertAnsiToUtf16(str).c_str());
|
||||
}
|
||||
inline string ConvertUtf8ToAnsi(const char* str, char badChar)
|
||||
{
|
||||
return ConvertUtf16ToAnsi(ConvertUtf8ToUtf16(str).c_str(), badChar);
|
||||
}
|
||||
#endif
|
||||
|
||||
// ANSI -> ASCII
|
||||
string ConvertAnsiToAscii(const char* str, char badChar);
|
||||
}
|
||||
#endif // CRYINCLUDE_CRYCOMMONTOOLS_STRINGHELPERS_H
|
||||
@@ -0,0 +1,202 @@
|
||||
/*
|
||||
* 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_CRYCOMMONTOOLS_UTIL_H
|
||||
#define CRYINCLUDE_CRYCOMMONTOOLS_UTIL_H
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <cstring> // memset()
|
||||
|
||||
#ifndef BIT
|
||||
#define BIT(x) (1 << (x))
|
||||
#endif
|
||||
|
||||
|
||||
union IntOrPtr
|
||||
{
|
||||
int m_int;
|
||||
unsigned int m_uint;
|
||||
void* m_pVoid;
|
||||
char* m_pChar;
|
||||
|
||||
void setZero()
|
||||
{
|
||||
memset(this, 0, sizeof(*this));
|
||||
}
|
||||
|
||||
bool operator==(const IntOrPtr& a) const
|
||||
{
|
||||
return memcmp(this, &a, sizeof(*this)) == 0;
|
||||
}
|
||||
|
||||
bool operator!=(const IntOrPtr& a) const
|
||||
{
|
||||
return memcmp(this, &a, sizeof(*this)) != 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
namespace Util
|
||||
{
|
||||
// note: names 'getMin' and 'getMax' (instead of usual 'min' and 'max') are
|
||||
// used to avoid conflicts with global and/or user's #define of 'min' and 'max'
|
||||
|
||||
template<class T>
|
||||
inline const T& getMin(const T& a, const T& b)
|
||||
{
|
||||
return (a < b) ? a : b;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline const T& getMax(const T& a, const T& b)
|
||||
{
|
||||
return (a < b) ? b : a;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline const T& getMin(const T& a, const T& b, const T& c)
|
||||
{
|
||||
return (a < b)
|
||||
? ((a < c) ? a : c)
|
||||
: ((b < c) ? b : c);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline const T& getMax(const T& a, const T& b, const T& c)
|
||||
{
|
||||
return (a < b)
|
||||
? ((b < c) ? c : b)
|
||||
: ((a < c) ? c : a);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline const T& getClamped(const T& a, const T& a_min, const T& a_max)
|
||||
{
|
||||
if (a < a_min)
|
||||
{
|
||||
return a_min;
|
||||
}
|
||||
if (a_max < a)
|
||||
{
|
||||
return a_max;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
// note: name 'clampMinMax' (instead of usual 'clamp') is used
|
||||
// to avoid conflicts with global and/or user's #define of 'clamp'
|
||||
template<class T>
|
||||
inline void clampMinMax(T& a, const T& a_min, const T& a_max)
|
||||
{
|
||||
if (a < a_min)
|
||||
{
|
||||
a = a_min;
|
||||
}
|
||||
else if (a_max < a)
|
||||
{
|
||||
a = a_max;
|
||||
}
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline void clampMin(T& a, const T& a_min)
|
||||
{
|
||||
if (a < a_min)
|
||||
{
|
||||
a = a_min;
|
||||
}
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline void clampMax(T& a, const T& a_max)
|
||||
{
|
||||
if (a_max < a)
|
||||
{
|
||||
a = a_max;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <class TInteger>
|
||||
inline bool isPowerOfTwo(TInteger x)
|
||||
{
|
||||
return (x & (x - 1)) == 0;
|
||||
}
|
||||
|
||||
|
||||
template <class TInteger>
|
||||
inline TInteger getCeiledPowerOfTwo(TInteger x)
|
||||
{
|
||||
x = x - 1;
|
||||
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4293)
|
||||
if (sizeof(TInteger) > 0)
|
||||
{
|
||||
x |= x >> 1;
|
||||
}
|
||||
if (sizeof(TInteger) > 0)
|
||||
{
|
||||
x |= x >> 2;
|
||||
}
|
||||
if (sizeof(TInteger) > 0)
|
||||
{
|
||||
x |= x >> 4;
|
||||
}
|
||||
if (sizeof(TInteger) > 1)
|
||||
{
|
||||
x |= x >> 8;
|
||||
}
|
||||
if (sizeof(TInteger) > 2)
|
||||
{
|
||||
x |= x >> 16;
|
||||
}
|
||||
if (sizeof(TInteger) > 4)
|
||||
{
|
||||
x |= x >> 32;
|
||||
}
|
||||
#pragma warning(pop)
|
||||
|
||||
return x + 1;
|
||||
}
|
||||
|
||||
|
||||
template <class TInteger>
|
||||
inline TInteger getFlooredPowerOfTwo(TInteger x)
|
||||
{
|
||||
if (!isPowerOfTwo(x))
|
||||
{
|
||||
x = getCeiledPowerOfTwo(x) >> 1;
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline T square(T x)
|
||||
{
|
||||
return x * x;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline T cube(T x)
|
||||
{
|
||||
return x * x * x;
|
||||
}
|
||||
} // namespace Util
|
||||
|
||||
#endif // CRYINCLUDE_CRYCOMMONTOOLS_UTIL_H
|
||||
@@ -49,8 +49,6 @@ bool CViewManager::IsMultiViewportEnabled()
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
CViewManager::CViewManager()
|
||||
{
|
||||
gSettings.pGrid = &m_grid;
|
||||
|
||||
m_zoomFactor = 1;
|
||||
|
||||
m_origin2D(0, 0, 0);
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "Cry_Geo.h"
|
||||
#include "Grid.h"
|
||||
#include "Viewport.h"
|
||||
#include "Include/IViewPane.h"
|
||||
#include "QtViewPaneManager.h"
|
||||
@@ -67,10 +66,6 @@ public:
|
||||
void SetUpdateRegion(const AABB& updateRegion) { m_updateRegion = updateRegion; };
|
||||
const AABB& GetUpdateRegion() { return m_updateRegion; };
|
||||
|
||||
/** Retrieve Grid used for viewes.
|
||||
*/
|
||||
CGrid* GetGrid() { return &m_grid; };
|
||||
|
||||
/** Get 2D viewports origin.
|
||||
*/
|
||||
Vec3 GetOrigin2D() const { return m_origin2D; }
|
||||
@@ -137,7 +132,6 @@ private:
|
||||
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
AABB m_updateRegion;
|
||||
|
||||
CGrid m_grid;
|
||||
//! Origin of 2d viewports.
|
||||
Vec3 m_origin2D;
|
||||
//! Zoom of 2d viewports.
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
@@ -63,8 +63,6 @@ public:
|
||||
void SetFullscren(bool f);
|
||||
bool IsFullscreen() const { return m_bFullscreen; }
|
||||
|
||||
void SetFullscreenViewport(bool b);
|
||||
|
||||
QWidget* GetViewport() { return m_viewport; }
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user