Added IdentityLocalMatrix in SceneOrient

This commit is contained in:
hyzboy 2024-07-17 23:56:10 +08:00
parent a04752b391
commit d11b84222f
2 changed files with 12 additions and 1 deletions

View File

@ -21,6 +21,8 @@ namespace hgl
Vector3f Position; ///<坐标
Vector3f Direction; ///<方向
bool IdentityLocalMatrix; ///<是否为空矩阵
Matrix4f LocalMatrix; ///<当前矩阵(指相对上一级的变换矩阵)
Matrix4f LocalToWorldMatrix; ///<当前到世界矩阵
@ -43,6 +45,8 @@ namespace hgl
public:
const bool IsIdentityLocalMatrix ()const{return IdentityLocalMatrix;} ///<是否为空矩阵(相对上一级没变化)
Matrix4f & SetLocalMatrix (const Matrix4f &); ///<设定当前节点矩阵
Matrix4f & SetLocalToWorldMatrix (const Matrix4f &); ///<设定当前节点到世界矩阵

View File

@ -8,6 +8,8 @@ namespace hgl
Position=Vector3f(0.0f);
Direction=Vector3f(0.0f);
IdentityLocalMatrix=true;
LocalMatrix =Identity4f;
LocalToWorldMatrix =Identity4f;
InverseLocalMatrix =Identity4f;
@ -26,6 +28,8 @@ namespace hgl
{
LocalMatrix=m;
IdentityLocalMatrix=IsIdentity(m);
InverseLocalMatrix=inverse(LocalMatrix);
return LocalMatrix;
@ -46,7 +50,10 @@ namespace hgl
*/
void SceneOrient::RefreshLocalToWorldMatrix(const Matrix4f *m)
{
SetLocalToWorldMatrix(TransformMatrix(*m,LocalMatrix));
if(IdentityLocalMatrix)
SetLocalToWorldMatrix(*m);
else
SetLocalToWorldMatrix(TransformMatrix(*m,LocalMatrix));
}
}//namespace graph
}//namespace hgl