#include "xmodellodinfo.h"

XModelLodInfo::XModelLodInfo()
    : XAsset()
    , mDist(0)
    , mNumSurfs(0)
    , mSurfIndex(0)
    , mPartBits(4)
{
    SetName("Model LOD Info");
}

XModelLodInfo::~XModelLodInfo()
{
    
}

void XModelLodInfo::ParseData(XDataStream *aStream)
{
    quint32 rawDist;
    *aStream >> rawDist;
    memcpy(&mDist, &rawDist, sizeof(mDist));

    if (IsDebug())
    {
        qDebug() << QString("[%1] mDist = %2").arg(aStream->device()->pos(), 10, 10, QChar('0')).arg(mDist);
    }
    *aStream  >> mNumSurfs;
    if (IsDebug())
    {
        qDebug() << QString("[%1] mNumSurfs = %2").arg(aStream->device()->pos(), 10, 10, QChar('0')).arg(mNumSurfs);
    }
    *aStream  >> mSurfIndex;
    if (IsDebug())
    {
        qDebug() << QString("[%1] mSurfIndex = %2").arg(aStream->device()->pos(), 10, 10, QChar('0')).arg(mSurfIndex);
    }
    *aStream  >> mPartBits[0];
    if (IsDebug())
    {
        qDebug() << QString("[%1] mPartBits[0] = %2").arg(aStream->device()->pos(), 10, 10, QChar('0')).arg(mPartBits[0]);
    }
    *aStream  >> mPartBits[1];
    if (IsDebug())
    {
        qDebug() << QString("[%1] mPartBits[1] = %2").arg(aStream->device()->pos(), 10, 10, QChar('0')).arg(mPartBits[1]);
    }
    *aStream  >> mPartBits[2];
    if (IsDebug())
    {
        qDebug() << QString("[%1] mPartBits[2] = %2").arg(aStream->device()->pos(), 10, 10, QChar('0')).arg(mPartBits[2]);
    }
    *aStream  >> mPartBits[3];
    if (IsDebug())
    {
        qDebug() << QString("[%1] mPartBits[3] = %2").arg(aStream->device()->pos(), 10, 10, QChar('0')).arg(mPartBits[3]);
    }
}

void XModelLodInfo::Clear()
{
    mDist = 0;
    mNumSurfs = 0;
    mSurfIndex = 0;
    mPartBits.clear();
}
