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)
|
||||
{
|
||||
if (!mpCollision) return;
|
||||
if (!rkViewInfo.ViewFrustum.BoxInFrustum(AABox())) return;
|
||||
if (rkViewInfo.GameMode) return;
|
||||
if (!mpCollision)
|
||||
return;
|
||||
if (!rkViewInfo.ViewFrustum.BoxInFrustum(AABox()))
|
||||
return;
|
||||
if (rkViewInfo.GameMode)
|
||||
return;
|
||||
|
||||
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)
|
||||
{
|
||||
if (!mpCollision) return;
|
||||
if (!mpCollision)
|
||||
return;
|
||||
|
||||
LoadModelMatrix();
|
||||
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
uint32 CSceneNode::smNumNodes = 0;
|
||||
uint32_t CSceneNode::smNumNodes = 0;
|
||||
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)
|
||||
, mpParent(pParent)
|
||||
, mpScene(pScene)
|
||||
@@ -168,7 +168,7 @@ void CSceneNode::BuildLightList(CGameArea *pArea)
|
||||
std::sort(LightEntries.begin(), LightEntries.end());
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ void CSceneNode::LoadLights(const SViewInfo& rkViewInfo)
|
||||
// World lighting: world ambient color, node dynamic lights
|
||||
CGraphics::sVertexBlock.COLOR0_Amb = mAmbientColor;
|
||||
|
||||
for (uint32 iLight = 0; iLight < mLightCount; iLight++)
|
||||
for (uint32_t iLight = 0; iLight < mLightCount; iLight++)
|
||||
mLights[iLight]->Load();
|
||||
break;
|
||||
}
|
||||
@@ -384,7 +384,7 @@ CVector3f CSceneNode::AbsoluteScale() const
|
||||
return ret;
|
||||
}
|
||||
|
||||
CAABox CSceneNode::AABox() const
|
||||
const CAABox& CSceneNode::AABox() const
|
||||
{
|
||||
if (_mTransformDirty)
|
||||
ForceRecalculateTransform();
|
||||
|
||||
@@ -78,10 +78,10 @@ private:
|
||||
bool _mInheritsRotation = true;
|
||||
bool _mInheritsScale = true;
|
||||
|
||||
uint32 _mID;
|
||||
uint32_t _mID;
|
||||
|
||||
protected:
|
||||
static uint32 smNumNodes;
|
||||
static uint32_t smNumNodes;
|
||||
TString mName;
|
||||
CSceneNode *mpParent;
|
||||
CScene *mpScene;
|
||||
@@ -96,13 +96,13 @@ protected:
|
||||
bool mVisible = true;
|
||||
std::list<CSceneNode*> mChildren;
|
||||
|
||||
uint32 mLightLayerIndex = 0;
|
||||
uint32 mLightCount = 0;
|
||||
uint32_t mLightLayerIndex = 0;
|
||||
uint32_t mLightCount = 0;
|
||||
std::array<CLight*, 8> mLights{};
|
||||
CColor mAmbientColor;
|
||||
|
||||
public:
|
||||
explicit CSceneNode(CScene *pScene, uint32 NodeID, CSceneNode *pParent = nullptr);
|
||||
explicit CSceneNode(CScene *pScene, uint32_t NodeID, CSceneNode *pParent = nullptr);
|
||||
~CSceneNode() override;
|
||||
virtual ENodeType NodeType() const = 0;
|
||||
virtual void PostLoad() {}
|
||||
@@ -110,7 +110,7 @@ public:
|
||||
void AddToRenderer(CRenderer* /*pRenderer*/, const SViewInfo& /*rkViewInfo*/) override {}
|
||||
void DrawSelection() override;
|
||||
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 AllowsRotate() const { return true; }
|
||||
virtual bool AllowsScale() const { return true; }
|
||||
@@ -149,18 +149,18 @@ public:
|
||||
CVector3f AbsolutePosition() const;
|
||||
CQuaternion AbsoluteRotation() const;
|
||||
CVector3f AbsoluteScale() const;
|
||||
CAABox AABox() const;
|
||||
const CAABox& AABox() const;
|
||||
|
||||
// Inline Accessors
|
||||
TString Name() const { return mName; }
|
||||
const TString& Name() const { return mName; }
|
||||
CSceneNode* Parent() const { return mpParent; }
|
||||
CScene* Scene() const { return mpScene; }
|
||||
uint32 ID() const { return _mID; }
|
||||
CVector3f LocalPosition() const { return mPosition; }
|
||||
CQuaternion LocalRotation() const { return mRotation; }
|
||||
CVector3f LocalScale() const { return mScale; }
|
||||
uint32_t ID() const { return _mID; }
|
||||
const CVector3f& LocalPosition() const { return mPosition; }
|
||||
const CQuaternion& LocalRotation() const { return mRotation; }
|
||||
const CVector3f& LocalScale() const { return mScale; }
|
||||
CVector3f CenterPoint() const { return AABox().Center(); }
|
||||
uint32 LightLayerIndex() const { return mLightLayerIndex; }
|
||||
uint32_t LightLayerIndex() const { return mLightLayerIndex; }
|
||||
bool MarkedVisible() const { return mVisible; }
|
||||
bool IsMouseHovering() const { return mMouseHovering; }
|
||||
bool IsSelected() const { return mSelected; }
|
||||
@@ -174,7 +174,7 @@ public:
|
||||
void SetRotation(const CQuaternion& rkRotation) { mRotation = rkRotation; MarkTransformChanged(); }
|
||||
void SetRotation(const CVector3f& rkRotEuler) { mRotation = CQuaternion::FromEuler(rkRotEuler); 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 SetSelected(bool Selected) { mSelected = Selected; }
|
||||
void SetVisible(bool Visible) { mVisible = Visible; }
|
||||
|
||||
@@ -69,7 +69,7 @@ CSceneNode* CSceneViewport::HoverNode()
|
||||
return mpHoverNode;
|
||||
}
|
||||
|
||||
CVector3f CSceneViewport::HoverPoint() const
|
||||
const CVector3f& CSceneViewport::HoverPoint() const
|
||||
{
|
||||
return mHoverPoint;
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ public:
|
||||
FShowFlags ShowFlags() const;
|
||||
CRenderer* Renderer();
|
||||
CSceneNode* HoverNode();
|
||||
CVector3f HoverPoint() const;
|
||||
const CVector3f& HoverPoint() const;
|
||||
void CheckGizmoInput(const CRay& rkRay);
|
||||
SRayIntersection SceneRayCast(const CRay& rkRay);
|
||||
void ResetHover();
|
||||
|
||||
@@ -911,8 +911,8 @@ void CWorldEditor::UpdateNewLinkLine()
|
||||
// Check if there is a sender+receiver
|
||||
if (mpLinkDialog->isVisible() && mpLinkDialog->Sender() && mpLinkDialog->Receiver() && !mpLinkDialog->IsPicking())
|
||||
{
|
||||
CVector3f Start = mScene.NodeForInstance(mpLinkDialog->Sender())->CenterPoint();
|
||||
CVector3f End = mScene.NodeForInstance(mpLinkDialog->Receiver())->CenterPoint();
|
||||
const CVector3f& Start = mScene.NodeForInstance(mpLinkDialog->Sender())->CenterPoint();
|
||||
const CVector3f& End = mScene.NodeForInstance(mpLinkDialog->Receiver())->CenterPoint();
|
||||
ui->MainViewport->SetLinkLineEnabled(true);
|
||||
ui->MainViewport->SetLinkLine(Start, End);
|
||||
}
|
||||
@@ -958,8 +958,8 @@ void CWorldEditor::UpdateNewLinkLine()
|
||||
const CSceneNode* pHoverNode = ui->MainViewport->HoverNode();
|
||||
const CScriptObject* pInst = (pSender ? pSender : pReceiver);
|
||||
|
||||
CVector3f Start = mScene.NodeForInstance(pInst)->CenterPoint();
|
||||
CVector3f End = (pHoverNode && pHoverNode->NodeType() == ENodeType::Script ? pHoverNode->CenterPoint() : ui->MainViewport->HoverPoint());
|
||||
const CVector3f& Start = mScene.NodeForInstance(pInst)->CenterPoint();
|
||||
const CVector3f& End = (pHoverNode && pHoverNode->NodeType() == ENodeType::Script ? pHoverNode->CenterPoint() : ui->MainViewport->HoverPoint());
|
||||
ui->MainViewport->SetLinkLineEnabled(true);
|
||||
ui->MainViewport->SetLinkLine(Start, End);
|
||||
}
|
||||
|
||||
@@ -41,13 +41,13 @@ bool WCreateTab::eventFilter(QObject *pObj, QEvent *pEvent)
|
||||
|
||||
else if (pEvent->type() == QEvent::Drop)
|
||||
{
|
||||
QDropEvent *pDropEvent = static_cast<QDropEvent*>(pEvent);
|
||||
const CTemplateMimeData *pMimeData = qobject_cast<const CTemplateMimeData*>(pDropEvent->mimeData());
|
||||
const auto* pDropEvent = static_cast<QDropEvent*>(pEvent);
|
||||
const auto* pMimeData = qobject_cast<const CTemplateMimeData*>(pDropEvent->mimeData());
|
||||
|
||||
if (pMimeData)
|
||||
{
|
||||
CVector3f SpawnPoint = mpEditor->Viewport()->HoverPoint();
|
||||
CCreateInstanceCommand *pCmd = new CCreateInstanceCommand(mpEditor, pMimeData->Template(), mpSpawnLayer, SpawnPoint);
|
||||
const CVector3f& SpawnPoint = mpEditor->Viewport()->HoverPoint();
|
||||
auto* pCmd = new CCreateInstanceCommand(mpEditor, pMimeData->Template(), mpSpawnLayer, SpawnPoint);
|
||||
mpEditor->UndoStack().push(pCmd);
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user