#include "xphysgeominfo.h"

XPhysGeomInfo::XPhysGeomInfo()
    : XAsset()
    , mBrush()
    , mType(0)
    , mOrientation()
    , mOffset()
    , mHalfLengths()
{
    SetName("Phys Geometry Info");
}

XPhysGeomInfo::~XPhysGeomInfo()
{
    
}

void XPhysGeomInfo::ParseData(XDataStream *aStream)
{
    qint32 brushPtr;

    *aStream
        >> brushPtr
        >> mType;

    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            quint32 rawOrientation;
            *aStream >> rawOrientation;
            memcpy(&mOrientation[i][j], &rawOrientation, sizeof(mOrientation[i][j]));
        }
    }

    for (int i = 0; i < 3; i++)
    {
        quint32 rawOffset;
        *aStream >> rawOffset;
        memcpy(&mOffset[i], &rawOffset, sizeof(mOffset[i]));
    }

    for (int i = 0; i < 3; i++)
    {
        quint32 rawHalfLength;
        *aStream >> rawHalfLength;
        memcpy(&mHalfLengths[i], &rawHalfLength, sizeof(mHalfLengths[i]));
    }
}

void XPhysGeomInfo::Clear()
{
    mBrush.Clear();
    mType = 0;
    mOrientation.clear();
    mOffset = QVector3D();
    mHalfLengths = QVector3D();
}
