mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-12-17 00:47:05 +00:00
CSceneNode: Return getters by const reference where applicable
Avoids a few unnecessary copies.
This commit is contained in:
2
externals/LibCommon
vendored
2
externals/LibCommon
vendored
Submodule externals/LibCommon updated: 4ff3ada345...85c8fc7223
@@ -18,9 +18,12 @@ ENodeType CCollisionNode::NodeType() const
|
|||||||
|
|
||||||
void CCollisionNode::AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkViewInfo)
|
void CCollisionNode::AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkViewInfo)
|
||||||
{
|
{
|
||||||
if (!mpCollision) return;
|
if (!mpCollision)
|
||||||
if (!rkViewInfo.ViewFrustum.BoxInFrustum(AABox())) return;
|
return;
|
||||||
if (rkViewInfo.GameMode) return;
|
if (!rkViewInfo.ViewFrustum.BoxInFrustum(AABox()))
|
||||||
|
return;
|
||||||
|
if (rkViewInfo.GameMode)
|
||||||
|
return;
|
||||||
|
|
||||||
pRenderer->AddMesh(this, -1, AABox(), false, ERenderCommand::DrawMesh);
|
pRenderer->AddMesh(this, -1, AABox(), false, ERenderCommand::DrawMesh);
|
||||||
|
|
||||||
@@ -30,7 +33,8 @@ void CCollisionNode::AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkView
|
|||||||
|
|
||||||
void CCollisionNode::Draw(FRenderOptions /*Options*/, int /*ComponentIndex*/, ERenderCommand /*Command*/, const SViewInfo& rkViewInfo)
|
void CCollisionNode::Draw(FRenderOptions /*Options*/, int /*ComponentIndex*/, ERenderCommand /*Command*/, const SViewInfo& rkViewInfo)
|
||||||
{
|
{
|
||||||
if (!mpCollision) return;
|
if (!mpCollision)
|
||||||
|
return;
|
||||||
|
|
||||||
LoadModelMatrix();
|
LoadModelMatrix();
|
||||||
|
|
||||||
|
|||||||
@@ -9,10 +9,10 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
uint32 CSceneNode::smNumNodes = 0;
|
uint32_t CSceneNode::smNumNodes = 0;
|
||||||
CColor CSceneNode::skSelectionTint = CColor::Integral(39, 154, 167);
|
CColor CSceneNode::skSelectionTint = CColor::Integral(39, 154, 167);
|
||||||
|
|
||||||
CSceneNode::CSceneNode(CScene *pScene, uint32 NodeID, CSceneNode *pParent)
|
CSceneNode::CSceneNode(CScene *pScene, uint32_t NodeID, CSceneNode *pParent)
|
||||||
: _mID(NodeID)
|
: _mID(NodeID)
|
||||||
, mpParent(pParent)
|
, mpParent(pParent)
|
||||||
, mpScene(pScene)
|
, mpScene(pScene)
|
||||||
@@ -168,7 +168,7 @@ void CSceneNode::BuildLightList(CGameArea *pArea)
|
|||||||
std::sort(LightEntries.begin(), LightEntries.end());
|
std::sort(LightEntries.begin(), LightEntries.end());
|
||||||
mLightCount = (LightEntries.size() > 8) ? 8 : LightEntries.size();
|
mLightCount = (LightEntries.size() > 8) ? 8 : LightEntries.size();
|
||||||
|
|
||||||
for (uint32 iLight = 0; iLight < mLightCount; iLight++)
|
for (uint32_t iLight = 0; iLight < mLightCount; iLight++)
|
||||||
mLights[iLight] = LightEntries[iLight].pLight;
|
mLights[iLight] = LightEntries[iLight].pLight;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,7 +194,7 @@ void CSceneNode::LoadLights(const SViewInfo& rkViewInfo)
|
|||||||
// World lighting: world ambient color, node dynamic lights
|
// World lighting: world ambient color, node dynamic lights
|
||||||
CGraphics::sVertexBlock.COLOR0_Amb = mAmbientColor;
|
CGraphics::sVertexBlock.COLOR0_Amb = mAmbientColor;
|
||||||
|
|
||||||
for (uint32 iLight = 0; iLight < mLightCount; iLight++)
|
for (uint32_t iLight = 0; iLight < mLightCount; iLight++)
|
||||||
mLights[iLight]->Load();
|
mLights[iLight]->Load();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -384,7 +384,7 @@ CVector3f CSceneNode::AbsoluteScale() const
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
CAABox CSceneNode::AABox() const
|
const CAABox& CSceneNode::AABox() const
|
||||||
{
|
{
|
||||||
if (_mTransformDirty)
|
if (_mTransformDirty)
|
||||||
ForceRecalculateTransform();
|
ForceRecalculateTransform();
|
||||||
|
|||||||
@@ -78,10 +78,10 @@ private:
|
|||||||
bool _mInheritsRotation = true;
|
bool _mInheritsRotation = true;
|
||||||
bool _mInheritsScale = true;
|
bool _mInheritsScale = true;
|
||||||
|
|
||||||
uint32 _mID;
|
uint32_t _mID;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static uint32 smNumNodes;
|
static uint32_t smNumNodes;
|
||||||
TString mName;
|
TString mName;
|
||||||
CSceneNode *mpParent;
|
CSceneNode *mpParent;
|
||||||
CScene *mpScene;
|
CScene *mpScene;
|
||||||
@@ -96,13 +96,13 @@ protected:
|
|||||||
bool mVisible = true;
|
bool mVisible = true;
|
||||||
std::list<CSceneNode*> mChildren;
|
std::list<CSceneNode*> mChildren;
|
||||||
|
|
||||||
uint32 mLightLayerIndex = 0;
|
uint32_t mLightLayerIndex = 0;
|
||||||
uint32 mLightCount = 0;
|
uint32_t mLightCount = 0;
|
||||||
std::array<CLight*, 8> mLights{};
|
std::array<CLight*, 8> mLights{};
|
||||||
CColor mAmbientColor;
|
CColor mAmbientColor;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CSceneNode(CScene *pScene, uint32 NodeID, CSceneNode *pParent = nullptr);
|
explicit CSceneNode(CScene *pScene, uint32_t NodeID, CSceneNode *pParent = nullptr);
|
||||||
~CSceneNode() override;
|
~CSceneNode() override;
|
||||||
virtual ENodeType NodeType() const = 0;
|
virtual ENodeType NodeType() const = 0;
|
||||||
virtual void PostLoad() {}
|
virtual void PostLoad() {}
|
||||||
@@ -110,7 +110,7 @@ public:
|
|||||||
void AddToRenderer(CRenderer* /*pRenderer*/, const SViewInfo& /*rkViewInfo*/) override {}
|
void AddToRenderer(CRenderer* /*pRenderer*/, const SViewInfo& /*rkViewInfo*/) override {}
|
||||||
void DrawSelection() override;
|
void DrawSelection() override;
|
||||||
virtual void RayAABoxIntersectTest(CRayCollisionTester& rTester, const SViewInfo& rkViewInfo);
|
virtual void RayAABoxIntersectTest(CRayCollisionTester& rTester, const SViewInfo& rkViewInfo);
|
||||||
virtual SRayIntersection RayNodeIntersectTest(const CRay& rkRay, uint32 AssetID, const SViewInfo& rkViewInfo) = 0;
|
virtual SRayIntersection RayNodeIntersectTest(const CRay& rkRay, uint32_t AssetID, const SViewInfo& rkViewInfo) = 0;
|
||||||
virtual bool AllowsTranslate() const { return true; }
|
virtual bool AllowsTranslate() const { return true; }
|
||||||
virtual bool AllowsRotate() const { return true; }
|
virtual bool AllowsRotate() const { return true; }
|
||||||
virtual bool AllowsScale() const { return true; }
|
virtual bool AllowsScale() const { return true; }
|
||||||
@@ -149,24 +149,24 @@ public:
|
|||||||
CVector3f AbsolutePosition() const;
|
CVector3f AbsolutePosition() const;
|
||||||
CQuaternion AbsoluteRotation() const;
|
CQuaternion AbsoluteRotation() const;
|
||||||
CVector3f AbsoluteScale() const;
|
CVector3f AbsoluteScale() const;
|
||||||
CAABox AABox() const;
|
const CAABox& AABox() const;
|
||||||
|
|
||||||
// Inline Accessors
|
// Inline Accessors
|
||||||
TString Name() const { return mName; }
|
const TString& Name() const { return mName; }
|
||||||
CSceneNode* Parent() const { return mpParent; }
|
CSceneNode* Parent() const { return mpParent; }
|
||||||
CScene* Scene() const { return mpScene; }
|
CScene* Scene() const { return mpScene; }
|
||||||
uint32 ID() const { return _mID; }
|
uint32_t ID() const { return _mID; }
|
||||||
CVector3f LocalPosition() const { return mPosition; }
|
const CVector3f& LocalPosition() const { return mPosition; }
|
||||||
CQuaternion LocalRotation() const { return mRotation; }
|
const CQuaternion& LocalRotation() const { return mRotation; }
|
||||||
CVector3f LocalScale() const { return mScale; }
|
const CVector3f& LocalScale() const { return mScale; }
|
||||||
CVector3f CenterPoint() const { return AABox().Center(); }
|
CVector3f CenterPoint() const { return AABox().Center(); }
|
||||||
uint32 LightLayerIndex() const { return mLightLayerIndex; }
|
uint32_t LightLayerIndex() const { return mLightLayerIndex; }
|
||||||
bool MarkedVisible() const { return mVisible; }
|
bool MarkedVisible() const { return mVisible; }
|
||||||
bool IsMouseHovering() const { return mMouseHovering; }
|
bool IsMouseHovering() const { return mMouseHovering; }
|
||||||
bool IsSelected() const { return mSelected; }
|
bool IsSelected() const { return mSelected; }
|
||||||
bool InheritsPosition() const { return _mInheritsPosition; }
|
bool InheritsPosition() const { return _mInheritsPosition; }
|
||||||
bool InheritsRotation() const { return _mInheritsRotation; }
|
bool InheritsRotation() const { return _mInheritsRotation; }
|
||||||
bool InheritsScale() const { return _mInheritsScale; }
|
bool InheritsScale() const { return _mInheritsScale; }
|
||||||
|
|
||||||
// Setters
|
// Setters
|
||||||
void SetName(TString rkName) { mName = std::move(rkName); }
|
void SetName(TString rkName) { mName = std::move(rkName); }
|
||||||
@@ -174,7 +174,7 @@ public:
|
|||||||
void SetRotation(const CQuaternion& rkRotation) { mRotation = rkRotation; MarkTransformChanged(); }
|
void SetRotation(const CQuaternion& rkRotation) { mRotation = rkRotation; MarkTransformChanged(); }
|
||||||
void SetRotation(const CVector3f& rkRotEuler) { mRotation = CQuaternion::FromEuler(rkRotEuler); MarkTransformChanged(); }
|
void SetRotation(const CVector3f& rkRotEuler) { mRotation = CQuaternion::FromEuler(rkRotEuler); MarkTransformChanged(); }
|
||||||
void SetScale(const CVector3f& rkScale) { mScale = rkScale; MarkTransformChanged(); }
|
void SetScale(const CVector3f& rkScale) { mScale = rkScale; MarkTransformChanged(); }
|
||||||
void SetLightLayerIndex(uint32 Index) { mLightLayerIndex = Index; }
|
void SetLightLayerIndex(uint32_t Index) { mLightLayerIndex = Index; }
|
||||||
void SetMouseHovering(bool Hovering) { mMouseHovering = Hovering; }
|
void SetMouseHovering(bool Hovering) { mMouseHovering = Hovering; }
|
||||||
void SetSelected(bool Selected) { mSelected = Selected; }
|
void SetSelected(bool Selected) { mSelected = Selected; }
|
||||||
void SetVisible(bool Visible) { mVisible = Visible; }
|
void SetVisible(bool Visible) { mVisible = Visible; }
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ CSceneNode* CSceneViewport::HoverNode()
|
|||||||
return mpHoverNode;
|
return mpHoverNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
CVector3f CSceneViewport::HoverPoint() const
|
const CVector3f& CSceneViewport::HoverPoint() const
|
||||||
{
|
{
|
||||||
return mHoverPoint;
|
return mHoverPoint;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ public:
|
|||||||
FShowFlags ShowFlags() const;
|
FShowFlags ShowFlags() const;
|
||||||
CRenderer* Renderer();
|
CRenderer* Renderer();
|
||||||
CSceneNode* HoverNode();
|
CSceneNode* HoverNode();
|
||||||
CVector3f HoverPoint() const;
|
const CVector3f& HoverPoint() const;
|
||||||
void CheckGizmoInput(const CRay& rkRay);
|
void CheckGizmoInput(const CRay& rkRay);
|
||||||
SRayIntersection SceneRayCast(const CRay& rkRay);
|
SRayIntersection SceneRayCast(const CRay& rkRay);
|
||||||
void ResetHover();
|
void ResetHover();
|
||||||
|
|||||||
@@ -911,8 +911,8 @@ void CWorldEditor::UpdateNewLinkLine()
|
|||||||
// Check if there is a sender+receiver
|
// Check if there is a sender+receiver
|
||||||
if (mpLinkDialog->isVisible() && mpLinkDialog->Sender() && mpLinkDialog->Receiver() && !mpLinkDialog->IsPicking())
|
if (mpLinkDialog->isVisible() && mpLinkDialog->Sender() && mpLinkDialog->Receiver() && !mpLinkDialog->IsPicking())
|
||||||
{
|
{
|
||||||
CVector3f Start = mScene.NodeForInstance(mpLinkDialog->Sender())->CenterPoint();
|
const CVector3f& Start = mScene.NodeForInstance(mpLinkDialog->Sender())->CenterPoint();
|
||||||
CVector3f End = mScene.NodeForInstance(mpLinkDialog->Receiver())->CenterPoint();
|
const CVector3f& End = mScene.NodeForInstance(mpLinkDialog->Receiver())->CenterPoint();
|
||||||
ui->MainViewport->SetLinkLineEnabled(true);
|
ui->MainViewport->SetLinkLineEnabled(true);
|
||||||
ui->MainViewport->SetLinkLine(Start, End);
|
ui->MainViewport->SetLinkLine(Start, End);
|
||||||
}
|
}
|
||||||
@@ -958,8 +958,8 @@ void CWorldEditor::UpdateNewLinkLine()
|
|||||||
const CSceneNode* pHoverNode = ui->MainViewport->HoverNode();
|
const CSceneNode* pHoverNode = ui->MainViewport->HoverNode();
|
||||||
const CScriptObject* pInst = (pSender ? pSender : pReceiver);
|
const CScriptObject* pInst = (pSender ? pSender : pReceiver);
|
||||||
|
|
||||||
CVector3f Start = mScene.NodeForInstance(pInst)->CenterPoint();
|
const CVector3f& Start = mScene.NodeForInstance(pInst)->CenterPoint();
|
||||||
CVector3f End = (pHoverNode && pHoverNode->NodeType() == ENodeType::Script ? pHoverNode->CenterPoint() : ui->MainViewport->HoverPoint());
|
const 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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,13 +41,13 @@ bool WCreateTab::eventFilter(QObject *pObj, QEvent *pEvent)
|
|||||||
|
|
||||||
else if (pEvent->type() == QEvent::Drop)
|
else if (pEvent->type() == QEvent::Drop)
|
||||||
{
|
{
|
||||||
QDropEvent *pDropEvent = static_cast<QDropEvent*>(pEvent);
|
const auto* pDropEvent = static_cast<QDropEvent*>(pEvent);
|
||||||
const CTemplateMimeData *pMimeData = qobject_cast<const CTemplateMimeData*>(pDropEvent->mimeData());
|
const auto* pMimeData = qobject_cast<const CTemplateMimeData*>(pDropEvent->mimeData());
|
||||||
|
|
||||||
if (pMimeData)
|
if (pMimeData)
|
||||||
{
|
{
|
||||||
CVector3f SpawnPoint = mpEditor->Viewport()->HoverPoint();
|
const CVector3f& SpawnPoint = mpEditor->Viewport()->HoverPoint();
|
||||||
CCreateInstanceCommand *pCmd = new CCreateInstanceCommand(mpEditor, pMimeData->Template(), mpSpawnLayer, SpawnPoint);
|
auto* pCmd = new CCreateInstanceCommand(mpEditor, pMimeData->Template(), mpSpawnLayer, SpawnPoint);
|
||||||
mpEditor->UndoStack().push(pCmd);
|
mpEditor->UndoStack().push(pCmd);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user