#include "xsurfacevertexinfo.h"

XSurfaceVertexInfo::XSurfaceVertexInfo()
    : XAsset()
    , mVertCount(4)
    , mVertsBlend()
{
    SetName("Surface Vertex Info");
}

void XSurfaceVertexInfo::ParseData(XDataStream *aStream)
{
    if (GetPtr() == -1)
    {
        *aStream >> mVertCount[0];
        if (IsDebug())
        {
            qDebug() << QString("[%1] mVertCount[0] = %2").arg(aStream->device()->pos(), 10, 10, QChar('0')).arg(mVertCount[0]);
        }

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

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

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

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


        if (vertsBlendPtr == -1)
        {
            aStream->readRawData(mVertsBlend.data(), 2 * (mVertCount[0] + 3 * mVertCount[1] + 5 * mVertCount[2] + 7 * mVertCount[3]));

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

        }
    }
}

void XSurfaceVertexInfo::Clear()
{
    
}
