mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-12-17 17:05:37 +00:00
CScene: Pass by const in getters
These are overly restrictive, since the parameters are only ever queried.
This commit is contained in:
@@ -324,12 +324,12 @@ CScriptNode* CScene::NodeForInstanceID(uint32 InstanceID)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
CScriptNode* CScene::NodeForInstance(CScriptObject *pObj)
|
CScriptNode* CScene::NodeForInstance(const CScriptObject *pObj)
|
||||||
{
|
{
|
||||||
return (pObj ? NodeForInstanceID(pObj->InstanceID()) : nullptr);
|
return (pObj ? NodeForInstanceID(pObj->InstanceID()) : nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
CLightNode* CScene::NodeForLight(CLight *pLight)
|
CLightNode* CScene::NodeForLight(const CLight *pLight)
|
||||||
{
|
{
|
||||||
// Slow. Is there a better way to do this?
|
// Slow. Is there a better way to do this?
|
||||||
std::vector<CSceneNode*>& rLights = mNodes[ENodeType::Light];
|
std::vector<CSceneNode*>& rLights = mNodes[ENodeType::Light];
|
||||||
|
|||||||
@@ -64,8 +64,8 @@ public:
|
|||||||
SRayIntersection SceneRayCast(const CRay& rkRay, const SViewInfo& rkViewInfo);
|
SRayIntersection SceneRayCast(const CRay& rkRay, const SViewInfo& rkViewInfo);
|
||||||
CSceneNode* NodeByID(uint32 NodeID);
|
CSceneNode* NodeByID(uint32 NodeID);
|
||||||
CScriptNode* NodeForInstanceID(uint32 InstanceID);
|
CScriptNode* NodeForInstanceID(uint32 InstanceID);
|
||||||
CScriptNode* NodeForInstance(CScriptObject *pObj);
|
CScriptNode* NodeForInstance(const CScriptObject *pObj);
|
||||||
CLightNode* NodeForLight(CLight *pLight);
|
CLightNode* NodeForLight(const CLight *pLight);
|
||||||
CModel* ActiveSkybox();
|
CModel* ActiveSkybox();
|
||||||
CGameArea* ActiveArea();
|
CGameArea* ActiveArea();
|
||||||
|
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ CDeleteSelectionCommand::CDeleteSelectionCommand(CWorldEditor *pEditor, const QS
|
|||||||
// Remove selected objects from the linked instances list.
|
// Remove selected objects from the linked instances list.
|
||||||
LinkedInstances.removeAll(nullptr);
|
LinkedInstances.removeAll(nullptr);
|
||||||
|
|
||||||
for (CScriptObject *pInst : LinkedInstances)
|
for (const CScriptObject* pInst : LinkedInstances)
|
||||||
{
|
{
|
||||||
if (mpEditor->Scene()->NodeForInstance(pInst)->IsSelected())
|
if (mpEditor->Scene()->NodeForInstance(pInst)->IsSelected())
|
||||||
LinkedInstances.removeOne(pInst);
|
LinkedInstances.removeOne(pInst);
|
||||||
|
|||||||
@@ -314,8 +314,8 @@ QVariant CInstancesModel::data(const QModelIndex& rkIndex, int Role) const
|
|||||||
// Show/Hide Instance
|
// Show/Hide Instance
|
||||||
else if (Type == EIndexType::Instance)
|
else if (Type == EIndexType::Instance)
|
||||||
{
|
{
|
||||||
CScriptObject *pObj = IndexObject(rkIndex);
|
const CScriptObject* pObj = IndexObject(rkIndex);
|
||||||
const CScriptNode *pNode = mpScene->NodeForInstance(pObj);
|
const CScriptNode* pNode = mpScene->NodeForInstance(pObj);
|
||||||
if (pNode->MarkedVisible())
|
if (pNode->MarkedVisible())
|
||||||
return Visible;
|
return Visible;
|
||||||
return Invisible;
|
return Invisible;
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public:
|
|||||||
: QAbstractListModel(pParent)
|
: QAbstractListModel(pParent)
|
||||||
, mpPoiTemplate(pPoiTemplate)
|
, mpPoiTemplate(pPoiTemplate)
|
||||||
{
|
{
|
||||||
for (auto* obj : mpPoiTemplate->ObjectList())
|
for (const auto* obj : mpPoiTemplate->ObjectList())
|
||||||
{
|
{
|
||||||
auto* pNode = pScene->NodeForInstance(obj);
|
auto* pNode = pScene->NodeForInstance(obj);
|
||||||
|
|
||||||
|
|||||||
@@ -30,8 +30,8 @@ QVariant CPoiMapModel::data(const QModelIndex& rkIndex, int Role) const
|
|||||||
{
|
{
|
||||||
if (rkIndex.row() < rowCount(QModelIndex()))
|
if (rkIndex.row() < rowCount(QModelIndex()))
|
||||||
{
|
{
|
||||||
const CPoiToWorld::SPoiMap *pkMap = mpPoiToWorld->MapByIndex(static_cast<size_t>(rkIndex.row()));
|
const CPoiToWorld::SPoiMap* pkMap = mpPoiToWorld->MapByIndex(static_cast<size_t>(rkIndex.row()));
|
||||||
CScriptObject *pPOI = mpArea->InstanceByID(pkMap->PoiID);
|
const CScriptObject* pPOI = mpArea->InstanceByID(pkMap->PoiID);
|
||||||
|
|
||||||
if (Role == Qt::DisplayRole)
|
if (Role == Qt::DisplayRole)
|
||||||
{
|
{
|
||||||
@@ -48,9 +48,7 @@ QVariant CPoiMapModel::data(const QModelIndex& rkIndex, int Role) const
|
|||||||
if (const CScriptNode* pNode = mpEditor->Scene()->NodeForInstance(pPOI))
|
if (const CScriptNode* pNode = mpEditor->Scene()->NodeForInstance(pPOI))
|
||||||
{
|
{
|
||||||
// Get scan
|
// Get scan
|
||||||
const CScan *pScan = static_cast<CPointOfInterestExtra*>(pNode->Extra())->GetScan();
|
if (const CScan* pScan = static_cast<CPointOfInterestExtra*>(pNode->Extra())->GetScan())
|
||||||
|
|
||||||
if (pScan)
|
|
||||||
IsImportant = pScan->IsCriticalPropertyRef();
|
IsImportant = pScan->IsCriticalPropertyRef();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -252,7 +252,8 @@ bool CWorldEditor::CloseWorld()
|
|||||||
emit MapChanged(mpWorld, mpArea);
|
emit MapChanged(mpWorld, mpArea);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else return false;
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CWorldEditor::SetArea(CWorld *pWorld, int AreaIndex)
|
bool CWorldEditor::SetArea(CWorld *pWorld, int AreaIndex)
|
||||||
@@ -414,8 +415,9 @@ void CWorldEditor::Paste()
|
|||||||
CVector3f PastePoint;
|
CVector3f PastePoint;
|
||||||
|
|
||||||
if (ui->MainViewport->underMouse() && !ui->MainViewport->IsMouseInputActive())
|
if (ui->MainViewport->underMouse() && !ui->MainViewport->IsMouseInputActive())
|
||||||
|
{
|
||||||
PastePoint = ui->MainViewport->HoverPoint();
|
PastePoint = ui->MainViewport->HoverPoint();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CRay Ray = ui->MainViewport->Camera().CastRay(CVector2f(0.f, 0.f));
|
CRay Ray = ui->MainViewport->Camera().CastRay(CVector2f(0.f, 0.f));
|
||||||
@@ -560,7 +562,7 @@ void CWorldEditor::OnActiveProjectChanged(CGameProject *pProj)
|
|||||||
|
|
||||||
void CWorldEditor::OnLinksModified(const QList<CScriptObject*>& rkInstances)
|
void CWorldEditor::OnLinksModified(const QList<CScriptObject*>& rkInstances)
|
||||||
{
|
{
|
||||||
for (CScriptObject *pInstance : rkInstances)
|
for (const CScriptObject* pInstance : rkInstances)
|
||||||
{
|
{
|
||||||
CScriptNode *pNode = mScene.NodeForInstance(pInstance);
|
CScriptNode *pNode = mScene.NodeForInstance(pInstance);
|
||||||
pNode->LinksModified();
|
pNode->LinksModified();
|
||||||
@@ -610,8 +612,10 @@ void CWorldEditor::OnPropertyModified(IProperty *pProp)
|
|||||||
ShouldUpdateSelection = true;
|
ShouldUpdateSelection = true;
|
||||||
}
|
}
|
||||||
else if (pProp->Type() == EPropertyType::AnimationSet)
|
else if (pProp->Type() == EPropertyType::AnimationSet)
|
||||||
|
{
|
||||||
ShouldUpdateSelection = true;
|
ShouldUpdateSelection = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (ShouldUpdateSelection)
|
if (ShouldUpdateSelection)
|
||||||
{
|
{
|
||||||
@@ -758,10 +762,11 @@ void CWorldEditor::UpdateOpenRecentActions()
|
|||||||
pAction->setText(ActionText);
|
pAction->setText(ActionText);
|
||||||
pAction->setVisible(true);
|
pAction->setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
|
{
|
||||||
pAction->setVisible(false);
|
pAction->setVisible(false);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWorldEditor::UpdateWindowTitle()
|
void CWorldEditor::UpdateWindowTitle()
|
||||||
@@ -840,10 +845,14 @@ void CWorldEditor::UpdateGizmoUI()
|
|||||||
SpinBoxValue = mpSelection->Front()->AbsoluteScale();
|
SpinBoxValue = mpSelection->Front()->AbsoluteScale();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: break;
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!mpSelection->IsEmpty()) SpinBoxValue = mpSelection->Front()->AbsolutePosition();
|
else if (!mpSelection->IsEmpty())
|
||||||
|
{
|
||||||
|
SpinBoxValue = mpSelection->Front()->AbsolutePosition();
|
||||||
|
}
|
||||||
|
|
||||||
ui->TransformSpinBox->blockSignals(true);
|
ui->TransformSpinBox->blockSignals(true);
|
||||||
ui->TransformSpinBox->SetValue(SpinBoxValue);
|
ui->TransformSpinBox->SetValue(SpinBoxValue);
|
||||||
@@ -907,9 +916,7 @@ void CWorldEditor::UpdateNewLinkLine()
|
|||||||
ui->MainViewport->SetLinkLineEnabled(true);
|
ui->MainViewport->SetLinkLineEnabled(true);
|
||||||
ui->MainViewport->SetLinkLine(Start, End);
|
ui->MainViewport->SetLinkLine(Start, End);
|
||||||
}
|
}
|
||||||
|
else // Otherwise check whether there's just a sender or just a receiver
|
||||||
// Otherwise check whether there's just a sender or just a receiver
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
CScriptObject *pSender = nullptr;
|
CScriptObject *pSender = nullptr;
|
||||||
CScriptObject *pReceiver = nullptr;
|
CScriptObject *pReceiver = nullptr;
|
||||||
@@ -922,21 +929,25 @@ void CWorldEditor::UpdateNewLinkLine()
|
|||||||
pReceiver = mpLinkDialog->Receiver();
|
pReceiver = mpLinkDialog->Receiver();
|
||||||
}
|
}
|
||||||
else if (mIsMakingLink && mpNewLinkSender)
|
else if (mIsMakingLink && mpNewLinkSender)
|
||||||
|
{
|
||||||
pSender = mpNewLinkSender;
|
pSender = mpNewLinkSender;
|
||||||
|
}
|
||||||
else if (mpScriptSidebar->ModifyTab()->IsPicking() && mpScriptSidebar->ModifyTab()->EditNode()->NodeType() == ENodeType::Script)
|
else if (mpScriptSidebar->ModifyTab()->IsPicking() && mpScriptSidebar->ModifyTab()->EditNode()->NodeType() == ENodeType::Script)
|
||||||
|
{
|
||||||
pSender = static_cast<CScriptNode*>(mpScriptSidebar->ModifyTab()->EditNode())->Instance();
|
pSender = static_cast<CScriptNode*>(mpScriptSidebar->ModifyTab()->EditNode())->Instance();
|
||||||
|
}
|
||||||
|
|
||||||
// No sender and no receiver = no line
|
// No sender and no receiver = no line
|
||||||
if (!pSender && !pReceiver)
|
if (!pSender && !pReceiver)
|
||||||
|
{
|
||||||
ui->MainViewport->SetLinkLineEnabled(false);
|
ui->MainViewport->SetLinkLineEnabled(false);
|
||||||
|
}
|
||||||
// Yes sender and yes receiver = yes line
|
// Yes sender and yes receiver = yes line
|
||||||
else if (pSender && pReceiver)
|
else if (pSender && pReceiver)
|
||||||
{
|
{
|
||||||
ui->MainViewport->SetLinkLineEnabled(true);
|
ui->MainViewport->SetLinkLineEnabled(true);
|
||||||
ui->MainViewport->SetLinkLine( mScene.NodeForInstance(pSender)->CenterPoint(), mScene.NodeForInstance(pReceiver)->CenterPoint() );
|
ui->MainViewport->SetLinkLine( mScene.NodeForInstance(pSender)->CenterPoint(), mScene.NodeForInstance(pReceiver)->CenterPoint() );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compensate for missing sender or missing receiver
|
// Compensate for missing sender or missing receiver
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -944,19 +955,20 @@ void CWorldEditor::UpdateNewLinkLine()
|
|||||||
|
|
||||||
if (ui->MainViewport->underMouse() && !ui->MainViewport->IsMouseInputActive() && IsPicking)
|
if (ui->MainViewport->underMouse() && !ui->MainViewport->IsMouseInputActive() && IsPicking)
|
||||||
{
|
{
|
||||||
CSceneNode *pHoverNode = ui->MainViewport->HoverNode();
|
CSceneNode* pHoverNode = ui->MainViewport->HoverNode();
|
||||||
CScriptObject *pInst = (pSender ? pSender : pReceiver);
|
const CScriptObject* pInst = (pSender ? pSender : pReceiver);
|
||||||
|
|
||||||
CVector3f Start = mScene.NodeForInstance(pInst)->CenterPoint();
|
CVector3f Start = mScene.NodeForInstance(pInst)->CenterPoint();
|
||||||
CVector3f End = (pHoverNode && pHoverNode->NodeType() == ENodeType::Script ? pHoverNode->CenterPoint() : ui->MainViewport->HoverPoint());
|
CVector3f End = (pHoverNode && pHoverNode->NodeType() == ENodeType::Script ? pHoverNode->CenterPoint() : ui->MainViewport->HoverPoint());
|
||||||
ui->MainViewport->SetLinkLineEnabled(true);
|
ui->MainViewport->SetLinkLineEnabled(true);
|
||||||
ui->MainViewport->SetLinkLine(Start, End);
|
ui->MainViewport->SetLinkLine(Start, End);
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
|
{
|
||||||
ui->MainViewport->SetLinkLineEnabled(false);
|
ui->MainViewport->SetLinkLineEnabled(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWorldEditor::LaunchQuickplay()
|
void CWorldEditor::LaunchQuickplay()
|
||||||
@@ -1062,7 +1074,6 @@ void CWorldEditor::OnLinkButtonToggled(bool Enabled)
|
|||||||
mpNewLinkSender = nullptr;
|
mpNewLinkSender = nullptr;
|
||||||
mpNewLinkReceiver = nullptr;
|
mpNewLinkReceiver = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (mIsMakingLink)
|
if (mIsMakingLink)
|
||||||
@@ -1076,7 +1087,6 @@ void CWorldEditor::OnLinkClick(const SRayIntersection& rkIntersect)
|
|||||||
{
|
{
|
||||||
mpNewLinkSender = static_cast<CScriptNode*>(rkIntersect.pNode)->Instance();
|
mpNewLinkSender = static_cast<CScriptNode*>(rkIntersect.pNode)->Instance();
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mpNewLinkReceiver = static_cast<CScriptNode*>(rkIntersect.pNode)->Instance();
|
mpNewLinkReceiver = static_cast<CScriptNode*>(rkIntersect.pNode)->Instance();
|
||||||
@@ -1207,7 +1217,9 @@ void CWorldEditor::OnTransformSpinBoxModified(const CVector3f& Value)
|
|||||||
UndoStack().push(new CScaleNodeCommand(this, mpSelection->SelectedNodeList(), true, mGizmo.Position(), Delta));
|
UndoStack().push(new CScaleNodeCommand(this, mpSelection->SelectedNodeList(), true, mGizmo.Position(), Delta));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: break;
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateGizmoUI();
|
UpdateGizmoUI();
|
||||||
|
|||||||
@@ -92,13 +92,9 @@ void WInstancesTab::OnTreeClick(QModelIndex Index)
|
|||||||
// Show/Hide Instance
|
// Show/Hide Instance
|
||||||
if (mpTypesModel->IndexType(SourceIndex) == CInstancesModel::EIndexType::Instance)
|
if (mpTypesModel->IndexType(SourceIndex) == CInstancesModel::EIndexType::Instance)
|
||||||
{
|
{
|
||||||
CScriptObject *pObj = mpTypesModel->IndexObject(SourceIndex);
|
if (const CScriptObject* pObj = mpTypesModel->IndexObject(SourceIndex))
|
||||||
|
|
||||||
if (pObj)
|
|
||||||
{
|
{
|
||||||
CScriptNode *pNode = mpScene->NodeForInstance(pObj);
|
if (CScriptNode* pNode = mpScene->NodeForInstance(pObj))
|
||||||
|
|
||||||
if (pNode)
|
|
||||||
pNode->SetVisible(!pNode->IsVisible());
|
pNode->SetVisible(!pNode->IsVisible());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,7 +147,7 @@ void WInstancesTab::OnTreeContextMenu(QPoint Pos)
|
|||||||
// Determine type
|
// Determine type
|
||||||
mMenuIndexType = (IsLayers ? mpLayersModel->IndexType(mMenuIndex) : mpTypesModel->IndexType(mMenuIndex));
|
mMenuIndexType = (IsLayers ? mpLayersModel->IndexType(mMenuIndex) : mpTypesModel->IndexType(mMenuIndex));
|
||||||
|
|
||||||
CScriptObject *pObject = nullptr;
|
const CScriptObject *pObject = nullptr;
|
||||||
mpMenuObject = nullptr;
|
mpMenuObject = nullptr;
|
||||||
mpMenuLayer = nullptr;
|
mpMenuLayer = nullptr;
|
||||||
mpMenuTemplate = nullptr;
|
mpMenuTemplate = nullptr;
|
||||||
|
|||||||
Reference in New Issue
Block a user