mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-05-09 03:57:51 +03:00
Refactor NiGeometry/BSTriShape
Don't pass invalid geometry data links to the loaders
This commit is contained in:
parent
deb051639e
commit
bff9231c3b
6 changed files with 73 additions and 89 deletions
|
@ -167,14 +167,14 @@ namespace Nif
|
|||
{
|
||||
NiAVObject::read(nif);
|
||||
|
||||
data.read(nif);
|
||||
skin.read(nif);
|
||||
mData.read(nif);
|
||||
mSkin.read(nif);
|
||||
mMaterial.read(nif);
|
||||
if (nif->getVersion() == NIFFile::NIFVersion::VER_BGS
|
||||
&& nif->getBethVersion() > NIFFile::BethVersion::BETHVER_FO3)
|
||||
{
|
||||
shaderprop.read(nif);
|
||||
alphaprop.read(nif);
|
||||
mShaderProperty.read(nif);
|
||||
mAlphaProperty.read(nif);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -182,12 +182,38 @@ namespace Nif
|
|||
{
|
||||
NiAVObject::post(nif);
|
||||
|
||||
data.post(nif);
|
||||
skin.post(nif);
|
||||
shaderprop.post(nif);
|
||||
alphaprop.post(nif);
|
||||
if (recType != RC_NiParticles && !skin.empty())
|
||||
mData.post(nif);
|
||||
mSkin.post(nif);
|
||||
mShaderProperty.post(nif);
|
||||
mAlphaProperty.post(nif);
|
||||
if (recType != RC_NiParticles && !mSkin.empty())
|
||||
nif.setUseSkinning(true);
|
||||
|
||||
if (!mData.empty())
|
||||
{
|
||||
switch (recType)
|
||||
{
|
||||
case RC_NiTriShape:
|
||||
case RC_BSLODTriShape:
|
||||
if (mData->recType != RC_NiTriShapeData)
|
||||
mData = NiGeometryDataPtr(nullptr);
|
||||
break;
|
||||
case RC_NiTriStrips:
|
||||
if (mData->recType != RC_NiTriStripsData)
|
||||
mData = NiGeometryDataPtr(nullptr);
|
||||
break;
|
||||
case RC_NiParticles:
|
||||
if (mData->recType != RC_NiParticlesData)
|
||||
mData = NiGeometryDataPtr(nullptr);
|
||||
break;
|
||||
case RC_NiLines:
|
||||
if (mData->recType != RC_NiLinesData)
|
||||
mData = NiGeometryDataPtr(nullptr);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BSLODTriShape::read(NIFStream* nif)
|
||||
|
|
|
@ -119,7 +119,14 @@ namespace Nif
|
|||
void post(Reader& nif) override;
|
||||
};
|
||||
|
||||
struct NiGeometry : NiAVObject
|
||||
struct GeometryInterface
|
||||
{
|
||||
NiSkinInstancePtr mSkin;
|
||||
BSShaderPropertyPtr mShaderProperty;
|
||||
NiAlphaPropertyPtr mAlphaProperty;
|
||||
};
|
||||
|
||||
struct NiGeometry : NiAVObject, GeometryInterface
|
||||
{
|
||||
/* Possible flags:
|
||||
0x40 - mesh has no vertex normals ?
|
||||
|
@ -138,17 +145,13 @@ namespace Nif
|
|||
void read(NIFStream* nif);
|
||||
};
|
||||
|
||||
NiGeometryDataPtr data;
|
||||
NiSkinInstancePtr skin;
|
||||
NiGeometryDataPtr mData;
|
||||
MaterialData mMaterial;
|
||||
BSShaderPropertyPtr shaderprop;
|
||||
NiAlphaPropertyPtr alphaprop;
|
||||
|
||||
void read(NIFStream* nif) override;
|
||||
void post(Reader& nif) override;
|
||||
};
|
||||
|
||||
// TODO: consider checking the data record type here
|
||||
struct NiTriShape : NiGeometry
|
||||
{
|
||||
};
|
||||
|
@ -337,13 +340,10 @@ namespace Nif
|
|||
void read(NIFStream* nif, uint16_t flags);
|
||||
};
|
||||
|
||||
struct BSTriShape : NiAVObject
|
||||
struct BSTriShape : NiAVObject, GeometryInterface
|
||||
{
|
||||
osg::BoundingSpheref mBoundingSphere;
|
||||
std::array<float, 6> mBoundMinMax;
|
||||
NiSkinInstancePtr mSkin;
|
||||
BSShaderPropertyPtr mShaderProperty;
|
||||
NiAlphaPropertyPtr mAlphaProperty;
|
||||
BSVertexDesc mVertDesc;
|
||||
uint32_t mDataSize;
|
||||
std::vector<BSVertexData> mVertData;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue