//===========================================================================//
// File:	mtrxstk.cc                                                          //
// Project: MUNGA           Brick: Math Library                              //
// Contents: Interface specification for the matrix class                    //
//---------------------------------------------------------------------------//
//   Date    Who  Modification                                               //
// --------  ---  ---------------------------------------------------------- //
// 11/21/94  JMA  Initial coding.                                            //
// 12/01/94  JMA  Changed Matrix to FullMatrix, based both matrix classes on //
//                  Matrix44Base                                             //
//---------------------------------------------------------------------------//
// Copyright (C) 1994-1995, Virtual World Entertainment, Inc.                //
// All Rights reserved worldwide                                             //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL               //
//===========================================================================//

#include "StuffHeaders.hpp"

AffinerMatrix4DStack&
	AffinerMatrix4DStack::Concatenate(const AffineMatrix4D& matrix)
{
	Check_Object(this);
	Check_Object(&matrix);

	AffineMatrix4D *old_top = Peek();
	Check_Object(old_top);
	AffineMatrix4D *new_top = Cast_Pointer(AffineMatrix4D*, MemoryStack::Push());
	new_top->Multiply(matrix, *old_top);
	return *this;
}

AffineMatrix4D&
	AffinerMatrix4DStack::Push(const AffineMatrix4D& matrix)
{
	Check_Object(this);
	Check_Object(&matrix);

	AffineMatrix4D *new_top = Cast_Pointer(AffineMatrix4D*, MemoryStack::Push());
	return *new_top = matrix;
}

LinearMatrix4DStack&
	LinearMatrix4DStack::Concatenate(const LinearMatrix4D& matrix)
{
	Check_Object(this);
	Check_Object(&matrix);

	LinearMatrix4D *old_top = Peek();
	Check_Object(old_top);
	LinearMatrix4D *new_top = Cast_Pointer(LinearMatrix4D*, MemoryStack::Push());
	new_top->Multiply(matrix, *old_top);
	return *this;
}

LinearMatrix4D&
	LinearMatrix4DStack::Push(const LinearMatrix4D& matrix)
{
	Check_Object(this);
	Check_Object(&matrix);

	LinearMatrix4D *new_top = Cast_Pointer(LinearMatrix4D*, MemoryStack::Push());
	return *new_top = matrix;
}

Matrix4DStack&
	Matrix4DStack::Concatenate(const Matrix4D& matrix)
{
	Check_Object(this);
	Check_Object(&matrix);

	Matrix4D *old_top = Peek();
	Check_Object(old_top);
	Matrix4D *new_top = Cast_Pointer(Matrix4D*, MemoryStack::Push());
	new_top->Multiply(matrix, *old_top);
	return *this;
}

Matrix4DStack&
	Matrix4DStack::Concatenate(const AffineMatrix4D& matrix)
{
	Check_Object(this);
	Check_Object(&matrix);

	Matrix4D *old_top = Peek();
	Check_Object(old_top);
	Matrix4D *new_top = Cast_Pointer(Matrix4D*, MemoryStack::Push());
	new_top->Multiply(matrix, *old_top);
	return *this;
}

Matrix4D&
	Matrix4DStack::Push(const Matrix4D& matrix)
{
	Check_Object(this);
	Check_Object(&matrix);

	Matrix4D *new_top = Cast_Pointer(Matrix4D*, MemoryStack::Push());
	return *new_top = matrix;
}

Matrix4D&
	Matrix4DStack::Push(const AffineMatrix4D& matrix)
{
	Check_Object(this);
	Check_Object(&matrix);

	Matrix4D *new_top = Cast_Pointer(Matrix4D*, MemoryStack::Push());
	return *new_top = matrix;
}

