1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-03-25 16:43:33 +00:00

Don't mess with A/B hardcoding in constraints

This commit is contained in:
Alexei Kotov 2023-07-15 06:59:22 +03:00
parent eb3e762c50
commit ed8fd81714
3 changed files with 24 additions and 21 deletions

View File

@ -190,16 +190,16 @@ namespace Nif
void bhkConstraintCInfo::read(NIFStream* nif) void bhkConstraintCInfo::read(NIFStream* nif)
{ {
nif->get<unsigned int>(); // Number of entities, unused nif->get<unsigned int>(); // Number of entities, unused
mEntities.resize(2); // Hardcoded mEntityA.read(nif);
for (auto& entity : mEntities) mEntityB.read(nif);
entity.read(nif);
mPriority = static_cast<ConstraintPriority>(nif->get<uint32_t>()); mPriority = static_cast<ConstraintPriority>(nif->get<uint32_t>());
} }
void bhkConstraintCInfo::post(Reader& nif) void bhkConstraintCInfo::post(Reader& nif)
{ {
postRecordList(nif, mEntities); mEntityA.post(nif);
mEntityB.post(nif);
} }
void bhkPositionConstraintMotor::read(NIFStream* nif) void bhkPositionConstraintMotor::read(NIFStream* nif)
@ -254,25 +254,25 @@ namespace Nif
void bhkRagdollConstraintCInfo::read(NIFStream* nif) void bhkRagdollConstraintCInfo::read(NIFStream* nif)
{ {
mEntityData.resize(2); // Hardcoded by the format
if (nif->getBethVersion() <= 16) if (nif->getBethVersion() <= 16)
{ {
for (EntityData& data: mEntityData) nif->read(mDataA.mPivot);
{ nif->read(mDataA.mPlane);
nif->read(data.mPivot); nif->read(mDataA.mTwist);
nif->read(data.mPlane); nif->read(mDataB.mPivot);
nif->read(data.mTwist); nif->read(mDataB.mPlane);
} nif->read(mDataB.mTwist);
} }
else else
{ {
for (EntityData& data: mEntityData) nif->read(mDataA.mTwist);
{ nif->read(mDataA.mPlane);
nif->read(data.mTwist); nif->read(mDataA.mMotor);
nif->read(data.mPlane); nif->read(mDataA.mPivot);
nif->read(data.mMotor); nif->read(mDataB.mTwist);
nif->read(data.mPivot); nif->read(mDataB.mPlane);
} nif->read(mDataB.mMotor);
nif->read(mDataB.mPivot);
} }
nif->read(mConeMaxAngle); nif->read(mConeMaxAngle);
nif->read(mPlaneMinAngle); nif->read(mPlaneMinAngle);

View File

@ -219,7 +219,8 @@ namespace Nif
struct bhkConstraintCInfo struct bhkConstraintCInfo
{ {
bhkEntityList mEntities; bhkEntityPtr mEntityA;
bhkEntityPtr mEntityB;
ConstraintPriority mPriority; ConstraintPriority mPriority;
void read(NIFStream* nif); void read(NIFStream* nif);
void post(Reader& nif); void post(Reader& nif);
@ -274,14 +275,15 @@ namespace Nif
struct bhkRagdollConstraintCInfo struct bhkRagdollConstraintCInfo
{ {
struct EntityData struct Data
{ {
osg::Vec4f mPivot; osg::Vec4f mPivot;
osg::Vec4f mPlane; osg::Vec4f mPlane;
osg::Vec4f mTwist; osg::Vec4f mTwist;
osg::Vec4f mMotor; osg::Vec4f mMotor;
}; };
std::vector<EntityData> mEntityData; Data mDataA;
Data mDataB;
float mConeMaxAngle; float mConeMaxAngle;
float mPlaneMinAngle, mPlaneMaxAngle; float mPlaneMinAngle, mPlaneMaxAngle;
float mTwistMinAngle, mTwistMaxAngle; float mTwistMinAngle, mTwistMaxAngle;

View File

@ -176,6 +176,7 @@ namespace Nif
using NiCollisionObjectPtr = RecordPtrT<NiCollisionObject>; using NiCollisionObjectPtr = RecordPtrT<NiCollisionObject>;
using bhkWorldObjectPtr = RecordPtrT<bhkWorldObject>; using bhkWorldObjectPtr = RecordPtrT<bhkWorldObject>;
using bhkShapePtr = RecordPtrT<bhkShape>; using bhkShapePtr = RecordPtrT<bhkShape>;
using bhkEntityPtr = RecordPtrT<bhkEntity>;
using hkPackedNiTriStripsDataPtr = RecordPtrT<hkPackedNiTriStripsData>; using hkPackedNiTriStripsDataPtr = RecordPtrT<hkPackedNiTriStripsData>;
using NiAccumulatorPtr = RecordPtrT<NiAccumulator>; using NiAccumulatorPtr = RecordPtrT<NiAccumulator>;
using NiInterpolatorPtr = RecordPtrT<NiInterpolator>; using NiInterpolatorPtr = RecordPtrT<NiInterpolator>;