feature/test #9
@ -1,25 +1,33 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "xcleaf.h"
|
||||
|
||||
XCLeaf::XCLeaf()
|
||||
: XAsset() {
|
||||
: 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)
|
||||
{
|
||||
}
|
||||
|
||||
void XCLeaf::ParseData(QDataStream *aStream) {
|
||||
if (GetPtr() == -1) {
|
||||
aStream->read((char*)&mFirstCollAabbIndex, sizeof(quint16));
|
||||
aStream->read((char*)&mCollAabbCount, sizeof(quint16));
|
||||
aStream->read((char*)&mBrushContents, sizeof(int));
|
||||
aStream->read((char*)&mTerrainContents, sizeof(int));
|
||||
aStream->read((char*)mMins, 3 * sizeof(float));
|
||||
aStream->read((char*)mMaxs, 3 * sizeof(float));
|
||||
aStream->read((char*)&mLeafBrushNode, sizeof(int));
|
||||
aStream->read((char*)&mCluster, sizeof(qint16));
|
||||
*aStream
|
||||
>> mFirstCollAabbIndex
|
||||
>> mCollAabbCount
|
||||
>> mBrushContents
|
||||
>> mTerrainContents
|
||||
>> mMins[0]
|
||||
>> mMins[1]
|
||||
>> mMins[2]
|
||||
>> mMaxs[0]
|
||||
>> mMaxs[1]
|
||||
>> mMaxs[2]
|
||||
>> mLeafBrushNode
|
||||
>> mCluster;
|
||||
}
|
||||
}
|
||||
|
||||
@ -55,24 +63,20 @@ void XCLeaf::SetTerrainContents(int contents) {
|
||||
mTerrainContents = contents;
|
||||
}
|
||||
|
||||
const float* XCLeaf::GetMins() const {
|
||||
QVector<float> XCLeaf::GetMins() const {
|
||||
return mMins;
|
||||
}
|
||||
|
||||
void XCLeaf::SetMins(const float* mins, size_t count) {
|
||||
if (count <= 3) {
|
||||
memcpy(mMins, mins, count * sizeof(float));
|
||||
}
|
||||
void XCLeaf::SetMins(QVector<float> aMins) {
|
||||
mMins = aMins;
|
||||
}
|
||||
|
||||
const float* XCLeaf::GetMaxs() const {
|
||||
QVector<float> XCLeaf::GetMaxs() const {
|
||||
return mMaxs;
|
||||
}
|
||||
|
||||
void XCLeaf::SetMaxs(const float* maxs, size_t count) {
|
||||
if (count <= 3) {
|
||||
memcpy(mMaxs, maxs, count * sizeof(float));
|
||||
}
|
||||
void XCLeaf::SetMaxs(QVector<float> aMaxs) {
|
||||
mMaxs = aMaxs;
|
||||
}
|
||||
|
||||
int XCLeaf::GetLeafBrushNode() const {
|
||||
|
||||
@ -1,14 +1,10 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef XCLEAF_H
|
||||
#define XCLEAF_H
|
||||
|
||||
#include "xasset.h"
|
||||
|
||||
#include <QVector>
|
||||
|
||||
class XCLeaf : public XAsset
|
||||
{
|
||||
public:
|
||||
@ -28,11 +24,11 @@ public:
|
||||
int GetTerrainContents() const;
|
||||
void SetTerrainContents(int contents);
|
||||
|
||||
const float* GetMins() const;
|
||||
void SetMins(const float* mins, size_t count = 3);
|
||||
QVector<float> GetMins() const;
|
||||
void SetMins(QVector<float> aMins);
|
||||
|
||||
const float* GetMaxs() const;
|
||||
void SetMaxs(const float* maxs, size_t count = 3);
|
||||
QVector<float> GetMaxs() const;
|
||||
void SetMaxs(QVector<float> aMaxs);
|
||||
|
||||
int GetLeafBrushNode() const;
|
||||
void SetLeafBrushNode(int node);
|
||||
@ -41,19 +37,14 @@ public:
|
||||
void SetCluster(qint16 cluster);
|
||||
|
||||
private:
|
||||
quint16 mFirstCollAabbIndex = 0;
|
||||
quint16 mCollAabbCount = 0;
|
||||
int mBrushContents = 0;
|
||||
int mTerrainContents = 0;
|
||||
float mMins[3] = {0.0f, 0.0f, 0.0f};
|
||||
float mMaxs[3] = {0.0f, 0.0f, 0.0f};
|
||||
int mLeafBrushNode = 0;
|
||||
qint16 mCluster = 0;
|
||||
quint16 mFirstCollAabbIndex;
|
||||
quint16 mCollAabbCount;
|
||||
int mBrushContents;
|
||||
int mTerrainContents;
|
||||
QVector<float> mMins;
|
||||
QVector<float> mMaxs;
|
||||
int mLeafBrushNode;
|
||||
qint16 mCluster;
|
||||
};
|
||||
|
||||
#endif // XCLEAF_H
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,22 +1,39 @@
|
||||
|
||||
|
||||
#include "xcleafbrushnode.h"
|
||||
|
||||
XCLeafBrushNode::XCLeafBrushNode()
|
||||
: XAsset() {
|
||||
: XAsset()
|
||||
, mAxis(0)
|
||||
, mLeafBrushCount(0)
|
||||
, mContents(0)
|
||||
, mData()
|
||||
{
|
||||
}
|
||||
|
||||
XCLeafBrushNode::~XCLeafBrushNode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void XCLeafBrushNode::ParseData(QDataStream *aStream) {
|
||||
if (GetPtr() == -1) {
|
||||
aStream->read((char*)&mAxis, sizeof(quint8));
|
||||
aStream->read((char*)&mLeafBrushCount, sizeof(qint16));
|
||||
aStream->read((char*)&mContents, sizeof(int));
|
||||
*aStream
|
||||
>> mAxis
|
||||
>> mLeafBrushCount
|
||||
>> mContents;
|
||||
|
||||
// Parse data
|
||||
mData.ParseData(aStream);
|
||||
}
|
||||
}
|
||||
|
||||
void XCLeafBrushNode::Clear()
|
||||
{
|
||||
mAxis = 0;
|
||||
mLeafBrushCount = 0;
|
||||
mContents = 0;
|
||||
mData = XCLeafBrushNodeData();
|
||||
}
|
||||
|
||||
quint8 XCLeafBrushNode::GetAxis() const {
|
||||
return mAxis;
|
||||
}
|
||||
@ -52,4 +69,3 @@ const XCLeafBrushNodeData& XCLeafBrushNode::GetData() const {
|
||||
void XCLeafBrushNode::SetData(const XCLeafBrushNodeData& data) {
|
||||
mData = data;
|
||||
}
|
||||
|
||||
|
||||
@ -1,9 +1,3 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef XCLEAFBRUSHNODE_H
|
||||
#define XCLEAFBRUSHNODE_H
|
||||
|
||||
@ -14,8 +8,10 @@ class XCLeafBrushNode : public XAsset
|
||||
{
|
||||
public:
|
||||
explicit XCLeafBrushNode();
|
||||
~XCLeafBrushNode();
|
||||
|
||||
void ParseData(QDataStream *aStream) override;
|
||||
void Clear() override;
|
||||
|
||||
quint8 GetAxis() const;
|
||||
void SetAxis(quint8 axis);
|
||||
@ -31,15 +27,10 @@ public:
|
||||
void SetData(const XCLeafBrushNodeData& data);
|
||||
|
||||
private:
|
||||
quint8 mAxis = 0;
|
||||
qint16 mLeafBrushCount = 0;
|
||||
int mContents = 0;
|
||||
quint8 mAxis;
|
||||
qint16 mLeafBrushCount;
|
||||
int mContents;
|
||||
XCLeafBrushNodeData mData;
|
||||
};
|
||||
|
||||
#endif // XCLEAFBRUSHNODE_H
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,13 +1,15 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "xcleafbrushnodedata.h"
|
||||
|
||||
XCLeafBrushNodeData::XCLeafBrushNodeData()
|
||||
: XAsset() {
|
||||
: XAsset()
|
||||
, mLeaf()
|
||||
, mChildren()
|
||||
{
|
||||
}
|
||||
|
||||
XCLeafBrushNodeData::~XCLeafBrushNodeData()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void XCLeafBrushNodeData::ParseData(QDataStream *aStream) {
|
||||
@ -18,6 +20,12 @@ void XCLeafBrushNodeData::ParseData(QDataStream *aStream) {
|
||||
}
|
||||
}
|
||||
|
||||
void XCLeafBrushNodeData::Clear()
|
||||
{
|
||||
mLeaf.Clear();
|
||||
mChildren.Clear();
|
||||
}
|
||||
|
||||
const XCLeafBrushNodeLeaf& XCLeafBrushNodeData::GetLeaf() const {
|
||||
return mLeaf;
|
||||
}
|
||||
@ -33,7 +41,3 @@ const XCLeafBrushNodeChildren& XCLeafBrushNodeData::GetChildren() const {
|
||||
void XCLeafBrushNodeData::SetChildren(const XCLeafBrushNodeChildren& children) {
|
||||
mChildren = children;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,9 +1,3 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef XCLEAFBRUSHNODEDATA_H
|
||||
#define XCLEAFBRUSHNODEDATA_H
|
||||
|
||||
@ -15,8 +9,10 @@ class XCLeafBrushNodeData : public XAsset
|
||||
{
|
||||
public:
|
||||
explicit XCLeafBrushNodeData();
|
||||
virtual ~XCLeafBrushNodeData() override;
|
||||
|
||||
void ParseData(QDataStream *aStream) override;
|
||||
void Clear() override;
|
||||
|
||||
// Option 1: Leaf data
|
||||
const XCLeafBrushNodeLeaf& GetLeaf() const;
|
||||
@ -27,10 +23,8 @@ public:
|
||||
void SetChildren(const XCLeafBrushNodeChildren& children);
|
||||
|
||||
private:
|
||||
union {
|
||||
XCLeafBrushNodeLeaf mLeaf;
|
||||
XCLeafBrushNodeChildren mChildren;
|
||||
};
|
||||
XCLeafBrushNodeLeaf mLeaf;
|
||||
XCLeafBrushNodeChildren mChildren;
|
||||
};
|
||||
|
||||
#endif // XCLEAFBRUSHNODEDATA_H
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user