#include "xcleaf.h"

XCLeaf::XCLeaf()
    : XAsset()
    , mFirstCollAabbIndex(0)
    , mCollAabbCount(0)
    , mBrushContents(0)
    , mTerrainContents(0)
    , mMins({0.0f, 0.0f, 0.0f})
    , mMaxs({0.0f, 0.0f, 0.0f})
    , mLeafBrushNode(0)
    , mCluster(0)
{
    SetName("C Leaf");
}

XCLeaf::~XCLeaf()
{

}

void XCLeaf::ParseData(XDataStream *aStream) {
    if (GetPtr() == -1) {
        mFirstCollAabbIndex = aStream->ParseUInt32(QString("%1 first collision AABB index").arg(GetName()));
        mCollAabbCount = aStream->ParseUInt32(QString("%1 collision AABB count").arg(GetName()));
        mBrushContents = aStream->ParseInt32(QString("%1 brush contents").arg(GetName()));
        mTerrainContents = aStream->ParseInt32(QString("%1 terrain contents").arg(GetName()));

        for (int i = 0; i < 3; i++)
        {
            mMins[i] = aStream->ParseSingle(QString("%1 min %2").arg(GetName()).arg(i));
        }

        for (int i = 0; i < 3; i++)
        {
            mMaxs[i] = aStream->ParseSingle(QString("%1 max %2").arg(GetName()).arg(i));
        }

        mLeafBrushNode = aStream->ParseInt32(QString("%1 leaf brush node").arg(GetName()));
        mCluster = aStream->ParseInt16(QString("%1 cluster").arg(GetName()));

        aStream->skipRawData(2);
    }
}

void XCLeaf::Clear()
{

}
