修改游戏底层矩阵相关

This commit is contained in:
2025-10-26 14:38:53 +08:00
parent dc0213dc16
commit 88f039348a
50 changed files with 1983 additions and 362 deletions

View File

@@ -1,4 +1,14 @@
#include "BaseNode.h"
#include "EngineCore/Game.h"
BaseNode::BaseNode()
{
Game::GetInstance().m_nodeCount++;
}
BaseNode::~BaseNode()
{
Game::GetInstance().m_nodeCount--;
}
void BaseNode::Init()
{
@@ -67,7 +77,7 @@ void BaseNode::SetCallbackOnUpdate(const UpdateCallback &cb)
void BaseNode::SetChildIterationTransform()
{
TransformT n_transform;
Transform n_transform;
n_transform.position = transform.position + transformIter.position;
n_transform.scale = transform.scale * transformIter.scale;
n_transform.rotation = transform.rotation + transformIter.rotation;
@@ -147,7 +157,7 @@ void BaseNode::AddChild(RefPtr<BaseNode> child)
// 如果组件有transform标签则设置其位置
if (child->hasTag(Tag::TRANSFORM))
{
TransformT n_transform;
Transform n_transform;
n_transform.position = transform.position + transformIter.position;
n_transform.scale = transform.scale * transformIter.scale;
n_transform.rotation = transform.rotation + transformIter.rotation;
@@ -172,7 +182,7 @@ void BaseNode::OnAdded(BaseNode *node)
m_Parent = node;
}
void BaseNode::SetIterationTransform(TransformT n_transform)
void BaseNode::SetIterationTransform(Transform n_transform)
{
if (n_transform == transformIter)
return;
@@ -181,12 +191,12 @@ void BaseNode::SetIterationTransform(TransformT n_transform)
SetChildIterationTransform();
}
TransformT BaseNode::GetIterationTransform()
Transform BaseNode::GetIterationTransform()
{
return transformIter;
}
void BaseNode::SetTransform(TransformT n_transform)
void BaseNode::SetTransform(Transform n_transform)
{
if (n_transform == transform)
return;
@@ -195,12 +205,12 @@ void BaseNode::SetTransform(TransformT n_transform)
SetChildIterationTransform();
}
TransformT BaseNode::GetTransform()
Transform BaseNode::GetTransform()
{
return transform;
}
void BaseNode::SetPos(VecFPos pos)
void BaseNode::SetPos(Vec2 pos)
{
if (pos == this->transform.position)
return;
@@ -209,17 +219,17 @@ void BaseNode::SetPos(VecFPos pos)
SetChildIterationTransform();
}
VecFPos BaseNode::GetPos()
Vec2 BaseNode::GetPos()
{
return this->transform.position;
}
VecFPos BaseNode::GetWorldPos()
Vec2 BaseNode::GetWorldPos()
{
return this->transform.position + this->transformIter.position;
}
void BaseNode::SetScale(VecFPos scale)
void BaseNode::SetScale(Vec2 scale)
{
if (scale == this->transform.scale)
return;
@@ -228,7 +238,7 @@ void BaseNode::SetScale(VecFPos scale)
SetChildIterationTransform();
}
VecFPos BaseNode::GetScale()
Vec2 BaseNode::GetScale()
{
return this->transform.scale;
}
@@ -247,7 +257,7 @@ float BaseNode::GetRotation()
return this->transform.rotation;
}
void BaseNode::SetAnchor(VecFPos anchor)
void BaseNode::SetAnchor(Vec2 anchor)
{
if (anchor == this->Anchor)
return;
@@ -255,9 +265,9 @@ void BaseNode::SetAnchor(VecFPos anchor)
Anchor.y = anchor.y;
}
VecFPos BaseNode::GetAnchor()
Vec2 BaseNode::GetAnchor()
{
VecFPos P;
Vec2 P;
P.x = Anchor.x;
P.y = Anchor.y;
return P;
@@ -298,7 +308,7 @@ float BaseNode::GetAlpha()
return this->Alpha;
}
void BaseNode::SetIterationPos(VecFPos pos)
void BaseNode::SetIterationPos(Vec2 pos)
{
if (pos == this->transformIter.position)
return;
@@ -307,12 +317,12 @@ void BaseNode::SetIterationPos(VecFPos pos)
SetChildIterationTransform();
}
VecFPos BaseNode::GetIterationPos()
Vec2 BaseNode::GetIterationPos()
{
return this->transformIter.position;
}
void BaseNode::SetIterationScale(VecFPos scale)
void BaseNode::SetIterationScale(Vec2 scale)
{
if (scale == this->transformIter.scale)
return;
@@ -321,7 +331,7 @@ void BaseNode::SetIterationScale(VecFPos scale)
SetChildIterationTransform();
}
VecFPos BaseNode::GetIterationScale()
Vec2 BaseNode::GetIterationScale()
{
return this->transformIter.scale;
}
@@ -339,3 +349,13 @@ float BaseNode::GetIterationRotation()
{
return this->transformIter.rotation;
}
void BaseNode::SetBlendMode(LE_BlEND_MODE mode)
{
this->_BlendMode = mode;
}
LE_BlEND_MODE BaseNode::GetBlendMode()
{
return this->_BlendMode;
}