#include "pw/scene/transform.hpp"
#include "pw/scene/node.hpp"

namespace pw {

transform::transform()
{
	_local.set_identity();
	_global.set_identity();
}

void transform::set_local(const matrix4x4 &local)
{
    // TODO need to rebuild the transforms: both -> global down and global up
    _local = local;

}

void transform::set_global(const matrix4x4 &global)
{
	//TODO need to rebuild **_local** from parent
	_global = global;
}


void transform::update(node& node)
{
}

void transform::update_global_from_local()
{
	// update the global transform
	if (_node && _node->parent())
	{
		this->_global = _node->transform()._global * _local;
	} else
	{
		this->_global = _local;
	}
}

void transform::update_local_from_global()
{

//	_local = this->global()
}

}
