XPlor/libs/xassets/xgfxcell.cpp

100 lines
2.9 KiB
C++
Raw Normal View History

2025-09-05 21:32:39 +00:00
#include "xgfxcell.h"
XGfxCell::XGfxCell()
: XAsset()
, mMins()
, mMaxs()
, mAabbTreeCount(0)
, mAabbTree()
, mPortalCount(0)
, mPortals()
, mCullGroupCount(0)
, mCullGroups()
, mReflectionProbeCount(0)
, mReflectionProbes()
{
2025-09-10 21:58:26 -04:00
SetName("GFX Cell");
2025-09-05 21:32:39 +00:00
}
XGfxCell::~XGfxCell()
{
}
2025-09-10 21:58:26 -04:00
void XGfxCell::ParseData(XDataStream *aStream)
2025-09-05 21:32:39 +00:00
{
2025-09-07 23:15:57 -04:00
qint32 aabbTreePtr, portalsPtr, cullGroupsPtr, reflectionProbesPtr;
2025-09-10 21:58:26 -04:00
mMins.setX(aStream->ParseSingle(QString("%1 mins x").arg(GetName())));
mMins.setY(aStream->ParseSingle(QString("%1 mins y").arg(GetName())));
mMins.setZ(aStream->ParseSingle(QString("%1 mins z").arg(GetName())));
mMaxs.setX(aStream->ParseSingle(QString("%1 maxs x").arg(GetName())));
mMaxs.setY(aStream->ParseSingle(QString("%1 maxs y").arg(GetName())));
mMaxs.setZ(aStream->ParseSingle(QString("%1 maxs z").arg(GetName())));
mAabbTreeCount = aStream->ParseInt32(QString("%1 aabb tree count").arg(GetName()));
aabbTreePtr = aStream->ParseInt32(QString("%1 aabb tree ptr").arg(GetName()));
mPortalCount = aStream->ParseInt32(QString("%1 portal count").arg(GetName()));
portalsPtr = aStream->ParseInt32(QString("%1 portals ptr").arg(GetName()));
mCullGroupCount = aStream->ParseInt32(QString("%1 cull group count").arg(GetName()));
cullGroupsPtr = aStream->ParseInt32(QString("%1 cull groups ptr").arg(GetName()));
mReflectionProbeCount = aStream->ParseUInt8(QString("%1 reflection probe count").arg(GetName()));
reflectionProbesPtr = aStream->ParseInt32(QString("%1 reflection probes ptr").arg(GetName()));
2025-09-05 21:32:39 +00:00
2025-09-07 23:15:57 -04:00
if (aabbTreePtr)
{
for (int i = 0; i < mAabbTreeCount; i++)
{
XGfxAabbTree newTree;
newTree.ParseData(aStream);
mAabbTree.append(newTree);
}
}
if (portalsPtr)
{
for (int i = 0; i < mPortalCount; i++)
{
XGfxPortal newPortal;
newPortal.ParseData(aStream);
mPortals.append(newPortal);
}
}
if (cullGroupsPtr)
{
for (int i = 0; i < mCullGroupCount; i++)
{
2025-09-10 21:58:26 -04:00
qint32 newCullGroup = aStream->ParseInt32(QString("%1 cull group %2").arg(GetName()).arg(i));
2025-09-07 23:15:57 -04:00
mCullGroups.append(newCullGroup);
}
}
if (reflectionProbesPtr)
{
for (int i = 0; i < mReflectionProbeCount; i++)
{
2025-09-10 21:58:26 -04:00
quint8 newReflectionProbe = aStream->ParseUInt8(QString("%1 reflection probe %2").arg(GetName()).arg(i));
2025-09-07 23:15:57 -04:00
mReflectionProbes.append(newReflectionProbe);
}
}
2025-09-05 21:32:39 +00:00
}
void XGfxCell::Clear()
{
mMins = QVector3D();
mMaxs = QVector3D();
mAabbTreeCount = 0;
mAabbTree.clear();
mPortalCount = 0;
mPortals.clear();
mCullGroupCount = 0;
mCullGroups.clear();
mReflectionProbeCount = 0;
mReflectionProbes.clear();
}