#include "munga.h"
#pragma hdrstop

#include "mtrxstk.h"

AffineMatrixStack& AffineMatrixStack::Concatenate(const AffineMatrix& matrix)
{
	AffineMatrix *old_top = Cast_Object(AffineMatrix*,Peek());
	AffineMatrix *new_top = (AffineMatrix*)MemoryStack::Push();
	new_top->Multiply(*old_top,matrix);
	return *this;
}

LinearMatrixStack& LinearMatrixStack::Concatenate(const LinearMatrix& matrix)
{
	LinearMatrix *old_top = Cast_Object(LinearMatrix*,Peek());
	LinearMatrix *new_top = (LinearMatrix*)MemoryStack::Push();
	new_top->Multiply(*old_top,matrix);
	return *this;
}

Matrix4x4Stack& Matrix4x4Stack::Concatenate(const Matrix4x4& matrix)
{
	Matrix4x4 *old_top = Cast_Object(Matrix4x4*,Peek());
	Matrix4x4 *new_top = (Matrix4x4*)MemoryStack::Push();
	new_top->Multiply(*old_top,matrix);
	return *this;
}

Matrix4x4Stack& Matrix4x4Stack::Concatenate(const AffineMatrix& matrix)
{
	Matrix4x4 *old_top = Cast_Object(Matrix4x4*,Peek());
	Matrix4x4 *new_top = (Matrix4x4*)MemoryStack::Push();
	new_top->Multiply(*old_top,matrix);
	return *this;
}

Matrix4x4& Matrix4x4Stack::Push(const AffineMatrix& matrix)
{
	Matrix4x4 *new_top = (Matrix4x4*)MemoryStack::Push();
	return *new_top = matrix;
}
