commit
b5ddc20771
|
@ -13,21 +13,9 @@ uint32 CSceneNode::smNumNodes = 0;
|
|||
CColor CSceneNode::skSelectionTint = CColor::Integral(39, 154, 167);
|
||||
|
||||
CSceneNode::CSceneNode(CScene *pScene, uint32 NodeID, CSceneNode *pParent)
|
||||
: mpScene(pScene)
|
||||
: _mID(NodeID)
|
||||
, mpParent(pParent)
|
||||
, _mID(NodeID)
|
||||
, mPosition(CVector3f::skZero)
|
||||
, mRotation(CQuaternion::skIdentity)
|
||||
, mScale(CVector3f::skOne)
|
||||
, _mTransformDirty(true)
|
||||
, _mInheritsPosition(true)
|
||||
, _mInheritsRotation(true)
|
||||
, _mInheritsScale(true)
|
||||
, mLightLayerIndex(0)
|
||||
, mLightCount(0)
|
||||
, mMouseHovering(false)
|
||||
, mSelected(false)
|
||||
, mVisible(true)
|
||||
, mpScene(pScene)
|
||||
{
|
||||
smNumNodes++;
|
||||
|
||||
|
@ -38,8 +26,7 @@ CSceneNode::CSceneNode(CScene *pScene, uint32 NodeID, CSceneNode *pParent)
|
|||
CSceneNode::~CSceneNode()
|
||||
{
|
||||
smNumNodes--;
|
||||
for (auto it = mChildren.begin(); it != mChildren.end(); it++)
|
||||
delete (*it);
|
||||
DeleteChildren();
|
||||
}
|
||||
|
||||
// ************ VIRTUAL ************
|
||||
|
@ -81,8 +68,8 @@ void CSceneNode::OnLoadFinished()
|
|||
{
|
||||
PostLoad();
|
||||
|
||||
for (auto it = mChildren.begin(); it != mChildren.end(); it++)
|
||||
(*it)->OnLoadFinished();
|
||||
for (auto* child : mChildren)
|
||||
child->OnLoadFinished();
|
||||
}
|
||||
|
||||
void CSceneNode::Unparent()
|
||||
|
@ -97,7 +84,7 @@ void CSceneNode::Unparent()
|
|||
|
||||
void CSceneNode::RemoveChild(CSceneNode *pChild)
|
||||
{
|
||||
for (auto it = mChildren.begin(); it != mChildren.end(); it++)
|
||||
for (auto it = mChildren.begin(); it != mChildren.end(); ++it)
|
||||
{
|
||||
if (*it == pChild)
|
||||
{
|
||||
|
@ -109,8 +96,8 @@ void CSceneNode::RemoveChild(CSceneNode *pChild)
|
|||
|
||||
void CSceneNode::DeleteChildren()
|
||||
{
|
||||
for (auto it = mChildren.begin(); it != mChildren.end(); it++)
|
||||
delete *it;
|
||||
for (auto* child : mChildren)
|
||||
delete child;
|
||||
|
||||
mChildren.clear();
|
||||
}
|
||||
|
@ -329,8 +316,8 @@ void CSceneNode::ForceRecalculateTransform() const
|
|||
// If so, the children will already be marked
|
||||
if (!_mTransformDirty)
|
||||
{
|
||||
for (auto it = mChildren.begin(); it != mChildren.end(); it++)
|
||||
(*it)->MarkTransformChanged();
|
||||
for (auto* child : mChildren)
|
||||
child->MarkTransformChanged();
|
||||
}
|
||||
_mTransformDirty = false;
|
||||
}
|
||||
|
@ -339,8 +326,8 @@ void CSceneNode::MarkTransformChanged() const
|
|||
{
|
||||
if (!_mTransformDirty)
|
||||
{
|
||||
for (auto it = mChildren.begin(); it != mChildren.end(); it++)
|
||||
(*it)->MarkTransformChanged();
|
||||
for (auto* child : mChildren)
|
||||
child->MarkTransformChanged();
|
||||
}
|
||||
|
||||
_mTransformDirty = true;
|
||||
|
@ -367,7 +354,7 @@ CVector3f CSceneNode::AbsolutePosition() const
|
|||
{
|
||||
CVector3f ret = mPosition;
|
||||
|
||||
if ((mpParent) && (InheritsPosition()))
|
||||
if (mpParent != nullptr && InheritsPosition())
|
||||
ret += mpParent->AbsolutePosition();
|
||||
|
||||
return ret;
|
||||
|
@ -377,7 +364,7 @@ CQuaternion CSceneNode::AbsoluteRotation() const
|
|||
{
|
||||
CQuaternion ret = mRotation;
|
||||
|
||||
if ((mpParent) && (InheritsRotation()))
|
||||
if (mpParent != nullptr && InheritsRotation())
|
||||
ret *= mpParent->AbsoluteRotation();
|
||||
|
||||
return ret;
|
||||
|
@ -387,7 +374,7 @@ CVector3f CSceneNode::AbsoluteScale() const
|
|||
{
|
||||
CVector3f ret = mScale;
|
||||
|
||||
if ((mpParent) && (InheritsScale()))
|
||||
if (mpParent != nullptr && InheritsScale())
|
||||
ret *= mpParent->AbsoluteScale();
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include <Common/Math/CTransform4f.h>
|
||||
#include <Common/Math/CVector3f.h>
|
||||
#include <Common/Math/ETransformSpace.h>
|
||||
#include <array>
|
||||
|
||||
class CRenderer;
|
||||
class CScene;
|
||||
|
@ -71,11 +72,11 @@ class CSceneNode : public IRenderable
|
|||
private:
|
||||
mutable CTransform4f _mCachedTransform;
|
||||
mutable CAABox _mCachedAABox;
|
||||
mutable bool _mTransformDirty;
|
||||
mutable bool _mTransformDirty = true;
|
||||
|
||||
bool _mInheritsPosition;
|
||||
bool _mInheritsRotation;
|
||||
bool _mInheritsScale;
|
||||
bool _mInheritsPosition = true;
|
||||
bool _mInheritsRotation = true;
|
||||
bool _mInheritsScale = true;
|
||||
|
||||
uint32 _mID;
|
||||
|
||||
|
@ -85,29 +86,29 @@ protected:
|
|||
CSceneNode *mpParent;
|
||||
CScene *mpScene;
|
||||
|
||||
CVector3f mPosition;
|
||||
CQuaternion mRotation;
|
||||
CVector3f mScale;
|
||||
CVector3f mPosition{CVector3f::skZero};
|
||||
CQuaternion mRotation{CQuaternion::skIdentity};
|
||||
CVector3f mScale{CVector3f::skOne};
|
||||
CAABox mLocalAABox;
|
||||
|
||||
bool mMouseHovering;
|
||||
bool mSelected;
|
||||
bool mVisible;
|
||||
bool mMouseHovering = false;
|
||||
bool mSelected = false;
|
||||
bool mVisible = true;
|
||||
std::list<CSceneNode*> mChildren;
|
||||
|
||||
uint32 mLightLayerIndex;
|
||||
uint32 mLightCount;
|
||||
CLight* mLights[8];
|
||||
uint32 mLightLayerIndex = 0;
|
||||
uint32 mLightCount = 0;
|
||||
std::array<CLight*, 8> mLights{};
|
||||
CColor mAmbientColor;
|
||||
|
||||
public:
|
||||
explicit CSceneNode(CScene *pScene, uint32 NodeID, CSceneNode *pParent = 0);
|
||||
virtual ~CSceneNode();
|
||||
~CSceneNode() override;
|
||||
virtual ENodeType NodeType() = 0;
|
||||
virtual void PostLoad() {}
|
||||
virtual void OnTransformed() {}
|
||||
virtual void AddToRenderer(CRenderer* /*pRenderer*/, const SViewInfo& /*rkViewInfo*/) {}
|
||||
virtual void DrawSelection();
|
||||
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 bool AllowsTranslate() const { return true; }
|
||||
|
@ -179,7 +180,7 @@ public:
|
|||
void SetVisible(bool Visible) { mVisible = Visible; }
|
||||
|
||||
// Static
|
||||
inline static int NumNodes() { return smNumNodes; }
|
||||
static int NumNodes() { return smNumNodes; }
|
||||
static CColor skSelectionTint;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue