1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-03-03 03:39:42 +00:00

Read bhkBallSocketConstraintChain and BSProceduralLightingController

This commit is contained in:
Alexei Kotov 2023-09-23 13:52:37 +03:00
parent 02c895c107
commit 285eafbf66
7 changed files with 133 additions and 0 deletions

View file

@ -553,6 +553,49 @@ namespace Nif
nif->read(mMaximumDistance);
}
void BSProceduralLightningController::read(NIFStream* nif)
{
NiTimeController::read(nif);
mGenerationInterp.read(nif);
mMutationInterp.read(nif);
mSubdivisionInterp.read(nif);
mNumBranchesInterp.read(nif);
mNumBranchesVarInterp.read(nif);
mLengthInterp.read(nif);
mLengthVarInterp.read(nif);
mWidthInterp.read(nif);
mArcOffsetInterp.read(nif);
nif->read(mSubdivisions);
nif->read(mNumBranches);
nif->read(mNumBranchesVar);
nif->read(mLength);
nif->read(mLengthVar);
nif->read(mWidth);
nif->read(mChildWidthMult);
nif->read(mArcOffset);
nif->read(mFadeMainBolt);
nif->read(mFadeChildBolts);
nif->read(mAnimateArcOffset);
mShaderProperty.read(nif);
}
void BSProceduralLightningController::post(Reader& nif)
{
NiTimeController::post(nif);
mGenerationInterp.post(nif);
mMutationInterp.post(nif);
mSubdivisionInterp.post(nif);
mNumBranchesInterp.post(nif);
mNumBranchesVarInterp.post(nif);
mLengthInterp.post(nif);
mLengthVarInterp.post(nif);
mWidthInterp.post(nif);
mArcOffsetInterp.post(nif);
mShaderProperty.post(nif);
}
void NiControllerManager::read(NIFStream* nif)
{
NiTimeController::read(nif);

View file

@ -354,6 +354,34 @@ namespace Nif
void read(NIFStream* nif) override;
};
struct BSProceduralLightningController : NiTimeController
{
NiInterpolatorPtr mGenerationInterp;
NiInterpolatorPtr mMutationInterp;
NiInterpolatorPtr mSubdivisionInterp;
NiInterpolatorPtr mNumBranchesInterp;
NiInterpolatorPtr mNumBranchesVarInterp;
NiInterpolatorPtr mLengthInterp;
NiInterpolatorPtr mLengthVarInterp;
NiInterpolatorPtr mWidthInterp;
NiInterpolatorPtr mArcOffsetInterp;
uint16_t mSubdivisions;
uint16_t mNumBranches;
uint16_t mNumBranchesVar;
float mLength;
float mLengthVar;
float mWidth;
float mChildWidthMult;
float mArcOffset;
bool mFadeMainBolt;
bool mFadeChildBolts;
bool mAnimateArcOffset;
BSShaderPropertyPtr mShaderProperty;
void read(NIFStream* nif) override;
void post(Reader& nif) override;
};
struct NiControllerManager : public NiTimeController
{
bool mCumulative;

View file

@ -138,6 +138,8 @@ namespace Nif
{ "BSFrustumFOVController", &construct<NiFloatInterpController, RC_BSFrustumFOVController> },
{ "BSKeyframeController", &construct<BSKeyframeController, RC_BSKeyframeController> },
{ "BSLagBoneController", &construct<BSLagBoneController, RC_BSLagBoneController> },
{ "BSProceduralLightningController",
&construct<BSProceduralLightningController, RC_BSProceduralLightningController> },
{ "BSMaterialEmittanceMultController",
&construct<NiFloatInterpController, RC_BSMaterialEmittanceMultController> },
{ "BSNiAlphaPropertyTestRefController",
@ -391,6 +393,7 @@ namespace Nif
// Constraint records, Bethesda
{ "bhkBallAndSocketConstraint", &construct<bhkBallAndSocketConstraint, RC_bhkBallAndSocketConstraint> },
{ "bhkBallSocketConstraintChain", &construct<bhkBallSocketConstraintChain, RC_bhkBallSocketConstraintChain> },
{ "bhkHingeConstraint", &construct<bhkHingeConstraint, RC_bhkHingeConstraint> },
{ "bhkLimitedHingeConstraint", &construct<bhkLimitedHingeConstraint, RC_bhkLimitedHingeConstraint> },
{ "bhkRagdollConstraint", &construct<bhkRagdollConstraint, RC_bhkRagdollConstraint> },

View file

@ -448,6 +448,17 @@ namespace Nif
}
}
void bhkConstraintChainCInfo::read(NIFStream* nif)
{
readRecordList(nif, mEntities);
mInfo.read(nif);
}
void bhkConstraintChainCInfo::post(Reader& nif)
{
postRecordList(nif, mEntities);
}
/// Record types
void bhkCollisionObject::read(NIFStream* nif)
@ -842,6 +853,27 @@ namespace Nif
mConstraint.read(nif);
}
void bhkBallSocketConstraintChain::read(NIFStream* nif)
{
uint32_t numPivots = nif->get<uint32_t>();
if (numPivots % 2 != 0)
throw Nif::Exception(
"Invalid number of constraints in bhkBallSocketConstraintChain", nif->getFile().getFilename());
mConstraints.resize(numPivots / 2);
for (bhkBallAndSocketConstraintCInfo& info : mConstraints)
info.read(nif);
nif->read(mTau);
nif->read(mDamping);
nif->read(mConstraintForceMixing);
nif->read(mMaxErrorDistance);
mConstraintChainInfo.read(nif);
}
void bhkBallSocketConstraintChain::post(Reader& nif)
{
mConstraintChainInfo.post(nif);
}
void bhkStiffSpringConstraint::read(NIFStream* nif)
{
bhkConstraint::read(nif);

View file

@ -421,6 +421,15 @@ namespace Nif
void read(NIFStream* nif);
};
struct bhkConstraintChainCInfo
{
bhkRigidBodyList mEntities;
bhkConstraintCInfo mInfo;
void read(NIFStream* nif);
void post(Reader& nif);
};
/// Record types
// Abstract Bethesda Havok object
@ -764,6 +773,19 @@ namespace Nif
void read(NIFStream* nif) override;
};
struct bhkBallSocketConstraintChain : bhkSerializable
{
std::vector<bhkBallAndSocketConstraintCInfo> mConstraints;
float mTau;
float mDamping;
float mConstraintForceMixing;
float mMaxErrorDistance;
bhkConstraintChainCInfo mConstraintChainInfo;
void read(NIFStream* nif) override;
void post(Reader& nif) override;
};
struct bhkStiffSpringConstraint : bhkConstraint
{
bhkStiffSpringConstraintCInfo mConstraint;

View file

@ -37,6 +37,7 @@ namespace Nif
RC_MISSING = 0,
RC_AvoidNode,
RC_bhkBallAndSocketConstraint,
RC_bhkBallSocketConstraintChain,
RC_bhkBlendCollisionObject,
RC_bhkBlendController,
RC_bhkBoxShape,
@ -98,6 +99,7 @@ namespace Nif
RC_BSNiAlphaPropertyTestRefController,
RC_BSPackedAdditionalGeometryData,
RC_BSParentVelocityModifier,
RC_BSProceduralLightningController,
RC_BSPSysArrayEmitter,
RC_BSPSysInheritVelocityModifier,
RC_BSPSysLODModifier,

View file

@ -150,6 +150,7 @@ namespace Nif
struct bhkSerializable;
struct bhkEntity;
struct bhkConvexShape;
struct bhkRigidBody;
struct hkPackedNiTriStripsData;
struct NiAccumulator;
struct NiInterpolator;
@ -198,6 +199,7 @@ namespace Nif
using bhkShapePtr = RecordPtrT<bhkShape>;
using bhkEntityPtr = RecordPtrT<bhkEntity>;
using bhkConvexShapePtr = RecordPtrT<bhkConvexShape>;
using bhkRigidBodyPtr = RecordPtrT<bhkRigidBody>;
using hkPackedNiTriStripsDataPtr = RecordPtrT<hkPackedNiTriStripsData>;
using NiAccumulatorPtr = RecordPtrT<NiAccumulator>;
using NiInterpolatorPtr = RecordPtrT<NiInterpolator>;
@ -218,6 +220,7 @@ namespace Nif
using bhkShapeList = RecordListT<bhkShape>;
using bhkSerializableList = RecordListT<bhkSerializable>;
using bhkEntityList = RecordListT<bhkEntity>;
using bhkRigidBodyList = RecordListT<bhkEntity>;
using NiControllerSequenceList = RecordListT<NiControllerSequence>;
using NiPSysModifierList = RecordListT<NiPSysModifier>;
using NiTriBasedGeomList = RecordListT<NiTriBasedGeom>;