#include "xcollisionpartition.h"

XCollisionPartition::XCollisionPartition()
    : XAsset()
    , mTriCount(0)
    , mBorderCount(0)
    , mFirstTri(0)
    , mBorders()
{
    SetName("Collision Partition");
}

XCollisionPartition::~XCollisionPartition()
{

}

void XCollisionPartition::ParseData(XDataStream *aStream) {
    if (GetPtr() == -1) {
        *aStream
            >> mTriCount
            >> mBorderCount;

        aStream->skipRawData(2);

        qint32 bordersPtr;
        *aStream
            >> mFirstTri
            >> bordersPtr;

        if (bordersPtr == -1)
        {
            for (int i = 0; i < mBorderCount; i++)
            {
                XCollisionBorder newBorder;
                newBorder.ParseData(aStream);
                mBorders.append(newBorder);
            }
        }
    }
}

void XCollisionPartition::Clear()
{
    mTriCount = 0;
    mBorderCount = 0;
    mFirstTri = 0;
    mBorders = QVector<XCollisionBorder>();
}
