1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-03-17 10:21:11 +00:00

Read BSMeshLODTriShape and BSDynamicTriShape

Slightly clean up BSVertexData loading
Fix skin tint alpha loading in BSLightingShaderProperty
This commit is contained in:
Alexei Kotov 2023-09-20 01:54:26 +03:00
parent a39182f7de
commit 30b842dd1e
5 changed files with 41 additions and 25 deletions

View File

@ -249,7 +249,9 @@ namespace Nif
// Bethesda // Bethesda
{ "BSDismemberSkinInstance", &construct<BSDismemberSkinInstance, RC_BSDismemberSkinInstance> }, { "BSDismemberSkinInstance", &construct<BSDismemberSkinInstance, RC_BSDismemberSkinInstance> },
{ "BSTriShape", &construct<BSTriShape, RC_BSTriShape> }, { "BSTriShape", &construct<BSTriShape, RC_BSTriShape> },
{ "BSDynamicTriShape", &construct<BSDynamicTriShape, RC_BSDynamicTriShape> },
{ "BSLODTriShape", &construct<BSLODTriShape, RC_BSLODTriShape> }, { "BSLODTriShape", &construct<BSLODTriShape, RC_BSLODTriShape> },
{ "BSMeshLODTriShape", &construct<BSMeshLODTriShape, RC_BSMeshLODTriShape> },
// PARTICLES // PARTICLES

View File

@ -414,6 +414,23 @@ namespace Nif
mAlphaProperty.post(nif); mAlphaProperty.post(nif);
} }
void BSDynamicTriShape::read(NIFStream* nif)
{
BSTriShape::read(nif);
nif->read(mDynamicDataSize);
// nifly style.
// Consider complaining if mDynamicDataSize * 16 != mVertData.size()?
nif->readVector(mDynamicData, mVertData.size());
}
void BSMeshLODTriShape::read(NIFStream* nif)
{
BSTriShape::read(nif);
nif->readArray(mLOD);
}
void BSVertexDesc::read(NIFStream* nif) void BSVertexDesc::read(NIFStream* nif)
{ {
uint64_t data; uint64_t data;
@ -448,21 +465,9 @@ namespace Nif
if (hasVertex) if (hasVertex)
{ {
if (fullPrecision) if (fullPrecision)
{
nif->read(mVertex); nif->read(mVertex);
if (hasTangent)
nif->read(mBitangentX);
else
nif->skip(4); // Unused
}
else else
{
nif->readArray(mHalfVertex); nif->readArray(mHalfVertex);
if (hasTangent)
nif->read(mHalfBitangentX);
else
nif->skip(2); // Unused
}
} }
if (hasUV) if (hasUV)
@ -471,12 +476,8 @@ namespace Nif
if (hasNormal) if (hasNormal)
{ {
nif->readArray(mNormal); nif->readArray(mNormal);
nif->read(mBitangentY);
if (hasTangent) if (hasTangent)
{
nif->readArray(mTangent); nif->readArray(mTangent);
nif->read(mBitangentZ);
}
} }
if (hasVertexColor) if (hasVertexColor)

View File

@ -338,15 +338,11 @@ namespace Nif
struct BSVertexData struct BSVertexData
{ {
osg::Vec3f mVertex; osg::Vec4f mVertex; // Bitangent X is stored in the fourth component
std::array<Misc::float16_t, 3> mHalfVertex; std::array<Misc::float16_t, 4> mHalfVertex; // Ditto
float mBitangentX;
Misc::float16_t mHalfBitangentX;
std::array<Misc::float16_t, 2> mUV; std::array<Misc::float16_t, 2> mUV;
std::array<char, 3> mNormal; std::array<char, 4> mNormal; // Bitangent Y is stored in the fourth component
char mBitangentY; std::array<char, 4> mTangent; // Bitangent Z is stored in the fourth component
std::array<char, 3> mTangent;
char mBitangentZ;
std::array<char, 4> mVertColor; std::array<char, 4> mVertColor;
std::array<Misc::float16_t, 4> mBoneWeights; std::array<Misc::float16_t, 4> mBoneWeights;
std::array<char, 4> mBoneIndices; std::array<char, 4> mBoneIndices;
@ -372,6 +368,21 @@ namespace Nif
void post(Reader& nif) override; void post(Reader& nif) override;
}; };
struct BSDynamicTriShape : BSTriShape
{
uint32_t mDynamicDataSize;
std::vector<osg::Vec4f> mDynamicData;
void read(NIFStream* nif) override;
};
struct BSMeshLODTriShape : BSTriShape
{
std::array<uint32_t, 3> mLOD;
void read(NIFStream* nif) override;
};
struct BSValueNode : NiNode struct BSValueNode : NiNode
{ {
enum Flags enum Flags

View File

@ -349,7 +349,7 @@ namespace Nif
break; break;
case BSLightingShaderType::ShaderType_SkinTint: case BSLightingShaderType::ShaderType_SkinTint:
nif->read(mSkinTintColor); nif->read(mSkinTintColor);
if (nif->getBethVersion() > NIFFile::BethVersion::BETHVER_FO4) if (nif->getBethVersion() >= NIFFile::BethVersion::BETHVER_FO4)
nif->read(mSkinTintAlpha); nif->read(mSkinTintAlpha);
break; break;
case BSLightingShaderType::ShaderType_HairTint: case BSLightingShaderType::ShaderType_HairTint:

View File

@ -60,6 +60,7 @@ namespace Nif
RC_BSBoneLODExtraData, RC_BSBoneLODExtraData,
RC_BSClothExtraData, RC_BSClothExtraData,
RC_BSDecalPlacementVectorExtraData, RC_BSDecalPlacementVectorExtraData,
RC_BSDynamicTriShape,
RC_BSDismemberSkinInstance, RC_BSDismemberSkinInstance,
RC_BSDistantObjectExtraData, RC_BSDistantObjectExtraData,
RC_BSDistantObjectLargeRefExtraData, RC_BSDistantObjectLargeRefExtraData,
@ -74,6 +75,7 @@ namespace Nif
RC_BSLightingShaderPropertyFloatController, RC_BSLightingShaderPropertyFloatController,
RC_BSLODTriShape, RC_BSLODTriShape,
RC_BSMaterialEmittanceMultController, RC_BSMaterialEmittanceMultController,
RC_BSMeshLODTriShape,
RC_BSMultiBound, RC_BSMultiBound,
RC_BSMultiBoundOBB, RC_BSMultiBoundOBB,
RC_BSMultiBoundSphere, RC_BSMultiBoundSphere,