#include "SceneModel.h"

#include "AbstractGeometricItem.h"
#include "AbstractMesh.h"

SceneModel::SceneModel(std::unique_ptr<AbstractMesh> mesh)
    : SceneItem(),
      mMesh(std::move(mesh))
{

}

SceneModel::~SceneModel()
{

}

SceneModel::SceneModel(std::unique_ptr<AbstractGeometricItem> geometry)
    : SceneItem(),
      mGeometry(std::move(geometry))
{

}

AbstractMesh* SceneModel::getMesh() const
{
    if (mMesh)
    {
        return mMesh.get();
    }
    else
    {
        return mRawMesh;
    }
}

AbstractGeometricItem* SceneModel::getGeometry() const
{
    return mGeometry.get();
}

SceneItem::Type SceneModel::getType() const
{
    return SceneItem::Type::MODEL;
}

void SceneModel::setShowOutline(bool showOutline)
{
    mShowOutline = showOutline;
}

bool SceneModel::getShowOutline() const
{
    return mShowOutline;
}

void SceneModel::updateMesh(std::unique_ptr<AbstractMesh> mesh)
{
    mMesh = std::move(mesh);
    mGeometryIsDirty = true;
}

void SceneModel::setMeshTransform(const Transform& transform)
{
    if (mMeshTransform != transform)
    {
        mMeshTransform = transform;
        mGeometryIsDirty = true;
    }
}

void SceneModel::updateGeometry(std::unique_ptr<AbstractGeometricItem> geometry)
{
    mGeometry = std::move(geometry);
    mGeometryIsDirty = true;
}

void SceneModel::updateMesh(AbstractMesh* mesh)
{
    mRawMesh = mesh;
    mGeometryIsDirty = true;
}


