Merge branch 'slashrslashmarijuanaenthusiasts' into 'master'

Improve Skyrim tree loading (limited)

See merge request OpenMW/openmw!3054
simplify_debugging
Petr Mikheev 2 years ago
commit e74161ea8e

@ -338,9 +338,9 @@ namespace Nif
&& nif->getVersion() <= NIFStream::generateVersion(10, 1, 0, 0)) && nif->getVersion() <= NIFStream::generateVersion(10, 1, 0, 0))
partitions.read(nif); partitions.read(nif);
// Has vertex weights flag bool hasVertexWeights = true;
if (nif->getVersion() > NIFStream::generateVersion(4, 2, 1, 0) && !nif->getBoolean()) if (nif->getVersion() > NIFStream::generateVersion(4, 2, 1, 0))
return; hasVertexWeights = nif->getBoolean();
bones.resize(boneNum); bones.resize(boneNum);
for (BoneInfo& bi : bones) for (BoneInfo& bi : bones)
@ -351,8 +351,12 @@ namespace Nif
bi.boundSphereCenter = nif->getVector3(); bi.boundSphereCenter = nif->getVector3();
bi.boundSphereRadius = nif->getFloat(); bi.boundSphereRadius = nif->getFloat();
// Number of vertex weights size_t numVertices = nif->getUShort();
bi.weights.resize(nif->getUShort());
if (!hasVertexWeights)
continue;
bi.weights.resize(numVertices);
for (size_t j = 0; j < bi.weights.size(); j++) for (size_t j = 0; j < bi.weights.size(); j++)
{ {
bi.weights[j].vertex = nif->getUShort(); bi.weights[j].vertex = nif->getUShort();
@ -484,4 +488,27 @@ namespace Nif
mKeyList->read(nif); mKeyList->read(nif);
} }
void BSMultiBound::read(NIFStream* nif)
{
mData.read(nif);
}
void BSMultiBound::post(Reader& nif)
{
mData.post(nif);
}
void BSMultiBoundOBB::read(NIFStream* nif)
{
mCenter = nif->getVector3();
mSize = nif->getVector3();
mRotation = nif->getMatrix3();
}
void BSMultiBoundSphere::read(NIFStream* nif)
{
mCenter = nif->getVector3();
mRadius = nif->getFloat();
}
} // Namespace } // Namespace

@ -288,5 +288,35 @@ namespace Nif
void read(NIFStream* nif) override; void read(NIFStream* nif) override;
}; };
struct BSMultiBound : public Record
{
BSMultiBoundDataPtr mData;
void read(NIFStream* nif) override;
void post(Reader& nif) override;
};
// Abstract
struct BSMultiBoundData : public Record
{
};
struct BSMultiBoundOBB : public BSMultiBoundData
{
osg::Vec3f mCenter;
osg::Vec3f mSize;
Nif::Matrix3 mRotation;
void read(NIFStream* nif) override;
};
struct BSMultiBoundSphere : public BSMultiBoundData
{
osg::Vec3f mCenter;
float mRadius;
void read(NIFStream* nif) override;
};
} // Namespace } // Namespace
#endif #endif

@ -138,6 +138,8 @@ namespace Nif
{ "NiTransformData", &construct<NiKeyframeData, RC_NiKeyframeData> }, { "NiTransformData", &construct<NiKeyframeData, RC_NiKeyframeData> },
{ "BSFadeNode", &construct<NiNode, RC_NiNode> }, { "BSFadeNode", &construct<NiNode, RC_NiNode> },
{ "BSLeafAnimNode", &construct<NiNode, RC_NiNode> }, { "BSLeafAnimNode", &construct<NiNode, RC_NiNode> },
{ "BSTreeNode", &construct<BSTreeNode, RC_NiNode> },
{ "BSMultiBoundNode", &construct<BSMultiBoundNode, RC_NiNode> },
{ "bhkBlendController", &construct<bhkBlendController, RC_bhkBlendController> }, { "bhkBlendController", &construct<bhkBlendController, RC_bhkBlendController> },
{ "NiFloatInterpolator", &construct<NiFloatInterpolator, RC_NiFloatInterpolator> }, { "NiFloatInterpolator", &construct<NiFloatInterpolator, RC_NiFloatInterpolator> },
{ "NiBoolInterpolator", &construct<NiBoolInterpolator, RC_NiBoolInterpolator> }, { "NiBoolInterpolator", &construct<NiBoolInterpolator, RC_NiBoolInterpolator> },
@ -185,6 +187,9 @@ namespace Nif
&construct<NiBlendTransformInterpolator, RC_NiBlendTransformInterpolator> }, &construct<NiBlendTransformInterpolator, RC_NiBlendTransformInterpolator> },
{ "bhkCompressedMeshShape", &construct<bhkCompressedMeshShape, RC_bhkCompressedMeshShape> }, { "bhkCompressedMeshShape", &construct<bhkCompressedMeshShape, RC_bhkCompressedMeshShape> },
{ "bhkCompressedMeshShapeData", &construct<bhkCompressedMeshShapeData, RC_bhkCompressedMeshShapeData> }, { "bhkCompressedMeshShapeData", &construct<bhkCompressedMeshShapeData, RC_bhkCompressedMeshShapeData> },
{ "BSMultiBound", &construct<BSMultiBound, RC_BSMultiBound> },
{ "BSMultiBoundOBB", &construct<BSMultiBoundOBB, RC_BSMultiBoundOBB> },
{ "BSMultiBoundSphere", &construct<BSMultiBoundSphere, RC_BSMultiBoundSphere> },
}; };
} }

@ -27,6 +27,7 @@ namespace Nif
enum BethVersion enum BethVersion
{ {
BETHVER_FO3 = 34, // Fallout 3 BETHVER_FO3 = 34, // Fallout 3
BETHVER_SKY = 83, // Skyrim
BETHVER_FO4 = 130 // Fallout 4 BETHVER_FO4 = 130 // Fallout 4
}; };

@ -306,4 +306,32 @@ namespace Nif
for (auto& object : mObjects) for (auto& object : mObjects)
object.second.post(nif); object.second.post(nif);
} }
void BSTreeNode::read(NIFStream* nif)
{
NiNode::read(nif);
readRecordList(nif, mBones1);
readRecordList(nif, mBones2);
}
void BSTreeNode::post(Reader& nif)
{
NiNode::post(nif);
postRecordList(nif, mBones1);
postRecordList(nif, mBones2);
}
void BSMultiBoundNode::read(NIFStream* nif)
{
NiNode::read(nif);
mMultiBound.read(nif);
if (nif->getBethVersion() >= NIFFile::BethVersion::BETHVER_SKY)
mType = nif->getUInt();
}
void BSMultiBoundNode::post(Reader& nif)
{
NiNode::post(nif);
mMultiBound.post(nif);
}
} }

@ -284,5 +284,21 @@ namespace Nif
void post(Reader& nif) override; void post(Reader& nif) override;
}; };
struct BSTreeNode : NiNode
{
NodeList mBones1, mBones2;
void read(NIFStream* nif) override;
void post(Reader& nif) override;
};
struct BSMultiBoundNode : NiNode
{
BSMultiBoundPtr mMultiBound;
unsigned int mType{ 0 };
void read(NIFStream* nif) override;
void post(Reader& nif) override;
};
} // Namespace } // Namespace
#endif #endif

@ -159,6 +159,9 @@ namespace Nif
RC_NiBlendTransformInterpolator, RC_NiBlendTransformInterpolator,
RC_bhkCompressedMeshShape, RC_bhkCompressedMeshShape,
RC_bhkCompressedMeshShapeData, RC_bhkCompressedMeshShapeData,
RC_BSMultiBound,
RC_BSMultiBoundOBB,
RC_BSMultiBoundSphere,
}; };
/// Base class for all records /// Base class for all records

@ -146,6 +146,8 @@ namespace Nif
struct NiDefaultAVObjectPalette; struct NiDefaultAVObjectPalette;
struct NiControllerSequence; struct NiControllerSequence;
struct bhkCompressedMeshShapeData; struct bhkCompressedMeshShapeData;
struct BSMultiBound;
struct BSMultiBoundData;
using NodePtr = RecordPtrT<Node>; using NodePtr = RecordPtrT<Node>;
using ExtraPtr = RecordPtrT<Extra>; using ExtraPtr = RecordPtrT<Extra>;
@ -181,6 +183,8 @@ namespace Nif
using NiBlendInterpolatorPtr = RecordPtrT<NiBlendInterpolator>; using NiBlendInterpolatorPtr = RecordPtrT<NiBlendInterpolator>;
using NiDefaultAVObjectPalettePtr = RecordPtrT<NiDefaultAVObjectPalette>; using NiDefaultAVObjectPalettePtr = RecordPtrT<NiDefaultAVObjectPalette>;
using bhkCompressedMeshShapeDataPtr = RecordPtrT<bhkCompressedMeshShapeData>; using bhkCompressedMeshShapeDataPtr = RecordPtrT<bhkCompressedMeshShapeData>;
using BSMultiBoundPtr = RecordPtrT<BSMultiBound>;
using BSMultiBoundDataPtr = RecordPtrT<BSMultiBoundData>;
using NodeList = RecordListT<Node>; using NodeList = RecordListT<Node>;
using PropertyList = RecordListT<Property>; using PropertyList = RecordListT<Property>;

Loading…
Cancel
Save