mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-23 06:41:08 +00:00
Read all remaining Havok constraint records
This commit is contained in:
parent
3296dadf60
commit
02c895c107
@ -395,6 +395,9 @@ namespace Nif
|
|||||||
{ "bhkLimitedHingeConstraint", &construct<bhkLimitedHingeConstraint, RC_bhkLimitedHingeConstraint> },
|
{ "bhkLimitedHingeConstraint", &construct<bhkLimitedHingeConstraint, RC_bhkLimitedHingeConstraint> },
|
||||||
{ "bhkRagdollConstraint", &construct<bhkRagdollConstraint, RC_bhkRagdollConstraint> },
|
{ "bhkRagdollConstraint", &construct<bhkRagdollConstraint, RC_bhkRagdollConstraint> },
|
||||||
{ "bhkStiffSpringConstraint", &construct<bhkStiffSpringConstraint, RC_bhkStiffSpringConstraint> },
|
{ "bhkStiffSpringConstraint", &construct<bhkStiffSpringConstraint, RC_bhkStiffSpringConstraint> },
|
||||||
|
{ "bhkPrismaticConstraint", &construct<bhkPrismaticConstraint, RC_bhkPrismaticConstraint> },
|
||||||
|
{ "bhkMalleableConstraint", &construct<bhkMalleableConstraint, RC_bhkMalleableConstraint> },
|
||||||
|
{ "bhkBreakableConstraint", &construct<bhkBreakableConstraint, RC_bhkBreakableConstraint> },
|
||||||
|
|
||||||
// Physics body records, Bethesda
|
// Physics body records, Bethesda
|
||||||
{ "bhkRigidBody", &construct<bhkRigidBody, RC_bhkRigidBody> },
|
{ "bhkRigidBody", &construct<bhkRigidBody, RC_bhkRigidBody> },
|
||||||
|
@ -345,6 +345,109 @@ namespace Nif
|
|||||||
nif->read(mLength);
|
nif->read(mLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void bhkPrismaticConstraintCInfo::read(NIFStream* nif)
|
||||||
|
{
|
||||||
|
if (nif->getVersion() <= NIFFile::NIFVersion::VER_OB)
|
||||||
|
{
|
||||||
|
nif->read(mDataA.mPivot);
|
||||||
|
nif->read(mDataA.mRotation);
|
||||||
|
nif->read(mDataA.mPlane);
|
||||||
|
nif->read(mDataA.mSliding);
|
||||||
|
nif->read(mDataB.mSliding);
|
||||||
|
nif->read(mDataB.mPivot);
|
||||||
|
nif->read(mDataB.mRotation);
|
||||||
|
nif->read(mDataB.mPlane);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nif->read(mDataA.mSliding);
|
||||||
|
nif->read(mDataA.mRotation);
|
||||||
|
nif->read(mDataA.mPlane);
|
||||||
|
nif->read(mDataA.mPivot);
|
||||||
|
nif->read(mDataB.mSliding);
|
||||||
|
nif->read(mDataB.mRotation);
|
||||||
|
nif->read(mDataB.mPlane);
|
||||||
|
nif->read(mDataB.mPivot);
|
||||||
|
}
|
||||||
|
nif->read(mMinDistance);
|
||||||
|
nif->read(mMaxDistance);
|
||||||
|
nif->read(mFriction);
|
||||||
|
if (nif->getVersion() >= NIFFile::NIFVersion::VER_BGS && nif->getBethVersion() >= 17)
|
||||||
|
mMotor.read(nif);
|
||||||
|
}
|
||||||
|
|
||||||
|
void bhkMalleableConstraintCInfo::read(NIFStream* nif)
|
||||||
|
{
|
||||||
|
mType = static_cast<hkConstraintType>(nif->get<uint32_t>());
|
||||||
|
mInfo.read(nif);
|
||||||
|
switch (mType)
|
||||||
|
{
|
||||||
|
case hkConstraintType::BallAndSocket:
|
||||||
|
mBallAndSocketInfo.read(nif);
|
||||||
|
break;
|
||||||
|
case hkConstraintType::Hinge:
|
||||||
|
mHingeInfo.read(nif);
|
||||||
|
break;
|
||||||
|
case hkConstraintType::LimitedHinge:
|
||||||
|
mLimitedHingeInfo.read(nif);
|
||||||
|
break;
|
||||||
|
case hkConstraintType::Prismatic:
|
||||||
|
mPrismaticInfo.read(nif);
|
||||||
|
break;
|
||||||
|
case hkConstraintType::Ragdoll:
|
||||||
|
mRagdollInfo.read(nif);
|
||||||
|
break;
|
||||||
|
case hkConstraintType::StiffSpring:
|
||||||
|
mStiffSpringInfo.read(nif);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw Nif::Exception(
|
||||||
|
"Unrecognized constraint type in bhkMalleableConstraint", nif->getFile().getFilename());
|
||||||
|
}
|
||||||
|
if (nif->getVersion() <= NIFFile::NIFVersion::VER_OB)
|
||||||
|
{
|
||||||
|
nif->read(mTau);
|
||||||
|
nif->read(mDamping);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nif->read(mStrength);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void bhkWrappedConstraintData::read(NIFStream* nif)
|
||||||
|
{
|
||||||
|
mType = static_cast<hkConstraintType>(nif->get<uint32_t>());
|
||||||
|
mInfo.read(nif);
|
||||||
|
switch (mType)
|
||||||
|
{
|
||||||
|
case hkConstraintType::BallAndSocket:
|
||||||
|
mBallAndSocketInfo.read(nif);
|
||||||
|
break;
|
||||||
|
case hkConstraintType::Hinge:
|
||||||
|
mHingeInfo.read(nif);
|
||||||
|
break;
|
||||||
|
case hkConstraintType::LimitedHinge:
|
||||||
|
mLimitedHingeInfo.read(nif);
|
||||||
|
break;
|
||||||
|
case hkConstraintType::Prismatic:
|
||||||
|
mPrismaticInfo.read(nif);
|
||||||
|
break;
|
||||||
|
case hkConstraintType::Ragdoll:
|
||||||
|
mRagdollInfo.read(nif);
|
||||||
|
break;
|
||||||
|
case hkConstraintType::StiffSpring:
|
||||||
|
mStiffSpringInfo.read(nif);
|
||||||
|
break;
|
||||||
|
case hkConstraintType::Malleable:
|
||||||
|
mMalleableInfo.read(nif);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw Nif::Exception(
|
||||||
|
"Unrecognized constraint type in bhkWrappedConstraintData", nif->getFile().getFilename());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Record types
|
/// Record types
|
||||||
|
|
||||||
void bhkCollisionObject::read(NIFStream* nif)
|
void bhkCollisionObject::read(NIFStream* nif)
|
||||||
@ -746,4 +849,27 @@ namespace Nif
|
|||||||
mConstraint.read(nif);
|
mConstraint.read(nif);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void bhkPrismaticConstraint::read(NIFStream* nif)
|
||||||
|
{
|
||||||
|
bhkConstraint::read(nif);
|
||||||
|
|
||||||
|
mConstraint.read(nif);
|
||||||
|
}
|
||||||
|
|
||||||
|
void bhkMalleableConstraint::read(NIFStream* nif)
|
||||||
|
{
|
||||||
|
bhkConstraint::read(nif);
|
||||||
|
|
||||||
|
mConstraint.read(nif);
|
||||||
|
}
|
||||||
|
|
||||||
|
void bhkBreakableConstraint::read(NIFStream* nif)
|
||||||
|
{
|
||||||
|
bhkConstraint::read(nif);
|
||||||
|
|
||||||
|
mConstraint.read(nif);
|
||||||
|
nif->read(mThreshold);
|
||||||
|
nif->read(mRemoveWhenBroken);
|
||||||
|
}
|
||||||
|
|
||||||
} // Namespace
|
} // Namespace
|
||||||
|
@ -363,6 +363,64 @@ namespace Nif
|
|||||||
void read(NIFStream* nif);
|
void read(NIFStream* nif);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct bhkPrismaticConstraintCInfo
|
||||||
|
{
|
||||||
|
struct Data
|
||||||
|
{
|
||||||
|
osg::Vec4f mSliding;
|
||||||
|
osg::Vec4f mRotation;
|
||||||
|
osg::Vec4f mPlane;
|
||||||
|
osg::Vec4f mPivot;
|
||||||
|
};
|
||||||
|
|
||||||
|
Data mDataA;
|
||||||
|
Data mDataB;
|
||||||
|
float mMinDistance, mMaxDistance;
|
||||||
|
float mFriction;
|
||||||
|
bhkConstraintMotorCInfo mMotor;
|
||||||
|
|
||||||
|
void read(NIFStream* nif);
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class hkConstraintType : uint32_t
|
||||||
|
{
|
||||||
|
BallAndSocket = 0,
|
||||||
|
Hinge = 1,
|
||||||
|
LimitedHinge = 2,
|
||||||
|
Prismatic = 6,
|
||||||
|
Ragdoll = 7,
|
||||||
|
StiffSpring = 8,
|
||||||
|
Malleable = 13,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct bhkWrappedConstraintDataBase
|
||||||
|
{
|
||||||
|
hkConstraintType mType;
|
||||||
|
bhkConstraintCInfo mInfo;
|
||||||
|
bhkBallAndSocketConstraintCInfo mBallAndSocketInfo;
|
||||||
|
bhkHingeConstraintCInfo mHingeInfo;
|
||||||
|
bhkLimitedHingeConstraintCInfo mLimitedHingeInfo;
|
||||||
|
bhkPrismaticConstraintCInfo mPrismaticInfo;
|
||||||
|
bhkRagdollConstraintCInfo mRagdollInfo;
|
||||||
|
bhkStiffSpringConstraintCInfo mStiffSpringInfo;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct bhkMalleableConstraintCInfo : bhkWrappedConstraintDataBase
|
||||||
|
{
|
||||||
|
float mTau;
|
||||||
|
float mDamping;
|
||||||
|
float mStrength;
|
||||||
|
|
||||||
|
void read(NIFStream* nif);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct bhkWrappedConstraintData : bhkWrappedConstraintDataBase
|
||||||
|
{
|
||||||
|
bhkMalleableConstraintCInfo mMalleableInfo;
|
||||||
|
|
||||||
|
void read(NIFStream* nif);
|
||||||
|
};
|
||||||
|
|
||||||
/// Record types
|
/// Record types
|
||||||
|
|
||||||
// Abstract Bethesda Havok object
|
// Abstract Bethesda Havok object
|
||||||
@ -713,5 +771,28 @@ namespace Nif
|
|||||||
void read(NIFStream* nif) override;
|
void read(NIFStream* nif) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct bhkPrismaticConstraint : bhkConstraint
|
||||||
|
{
|
||||||
|
bhkPrismaticConstraintCInfo mConstraint;
|
||||||
|
|
||||||
|
void read(NIFStream* nif) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct bhkMalleableConstraint : bhkConstraint
|
||||||
|
{
|
||||||
|
bhkMalleableConstraintCInfo mConstraint;
|
||||||
|
|
||||||
|
void read(NIFStream* nif) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct bhkBreakableConstraint : bhkConstraint
|
||||||
|
{
|
||||||
|
bhkWrappedConstraintData mConstraint;
|
||||||
|
float mThreshold;
|
||||||
|
bool mRemoveWhenBroken;
|
||||||
|
|
||||||
|
void read(NIFStream* nif) override;
|
||||||
|
};
|
||||||
|
|
||||||
} // Namespace
|
} // Namespace
|
||||||
#endif
|
#endif
|
||||||
|
@ -40,6 +40,7 @@ namespace Nif
|
|||||||
RC_bhkBlendCollisionObject,
|
RC_bhkBlendCollisionObject,
|
||||||
RC_bhkBlendController,
|
RC_bhkBlendController,
|
||||||
RC_bhkBoxShape,
|
RC_bhkBoxShape,
|
||||||
|
RC_bhkBreakableConstraint,
|
||||||
RC_bhkCapsuleShape,
|
RC_bhkCapsuleShape,
|
||||||
RC_bhkCylinderShape,
|
RC_bhkCylinderShape,
|
||||||
RC_bhkCollisionObject,
|
RC_bhkCollisionObject,
|
||||||
@ -52,10 +53,12 @@ namespace Nif
|
|||||||
RC_bhkHingeConstraint,
|
RC_bhkHingeConstraint,
|
||||||
RC_bhkLimitedHingeConstraint,
|
RC_bhkLimitedHingeConstraint,
|
||||||
RC_bhkListShape,
|
RC_bhkListShape,
|
||||||
|
RC_bhkMalleableConstraint,
|
||||||
RC_bhkMoppBvTreeShape,
|
RC_bhkMoppBvTreeShape,
|
||||||
RC_bhkNiTriStripsShape,
|
RC_bhkNiTriStripsShape,
|
||||||
RC_bhkPackedNiTriStripsShape,
|
RC_bhkPackedNiTriStripsShape,
|
||||||
RC_bhkPhysicsSystem,
|
RC_bhkPhysicsSystem,
|
||||||
|
RC_bhkPrismaticConstraint,
|
||||||
RC_bhkRagdollConstraint,
|
RC_bhkRagdollConstraint,
|
||||||
RC_bhkRagdollSystem,
|
RC_bhkRagdollSystem,
|
||||||
RC_bhkRigidBody,
|
RC_bhkRigidBody,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user