





#include "xcollisionaabbtree.h"

XCollisionAabbTree::XCollisionAabbTree()
    : XAsset() {
}

void XCollisionAabbTree::ParseData(QDataStream *aStream) {
    if (GetPtr() == -1) {
        aStream->read((char*)mOrigin, 3 * sizeof(float));
        aStream->read((char*)mHalfSize, 3 * sizeof(float));
        aStream->read((char*)&mMaterialIndex, sizeof(quint16));
        aStream->read((char*)&mChildCount, sizeof(quint16));

        // Parse union
        mU.ParseData(aStream);
    }
}

const float* XCollisionAabbTree::GetOrigin() const {
    return mOrigin;
}

void XCollisionAabbTree::SetOrigin(const float* origin, size_t count) {
    if (count <= 3) {
        memcpy(mOrigin, origin, count * sizeof(float));
    }
}

const float* XCollisionAabbTree::GetHalfSize() const {
    return mHalfSize;
}

void XCollisionAabbTree::SetHalfSize(const float* halfSize, size_t count) {
    if (count <= 3) {
        memcpy(mHalfSize, halfSize, count * sizeof(float));
    }
}

quint16 XCollisionAabbTree::GetMaterialIndex() const {
    return mMaterialIndex;
}

void XCollisionAabbTree::SetMaterialIndex(quint16 index) {
    mMaterialIndex = index;
}

quint16 XCollisionAabbTree::GetChildCount() const {
    return mChildCount;
}

void XCollisionAabbTree::SetChildCount(quint16 count) {
    mChildCount = count;
}

XCollisionAabbTreeIndex& XCollisionAabbTree::GetU() {
    return mU;
}

const XCollisionAabbTreeIndex& XCollisionAabbTree::GetU() const {
    return mU;
}

void XCollisionAabbTree::SetU(const XCollisionAabbTreeIndex& u) {
    mU = u;
}



