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