diff --git a/components/nif/physics.cpp b/components/nif/physics.cpp index 9636ec22da..2d1abeff58 100644 --- a/components/nif/physics.cpp +++ b/components/nif/physics.cpp @@ -187,6 +187,21 @@ namespace Nif nif->skip(12); // Unused } + void bhkConstraintCInfo::read(NIFStream* nif) + { + nif->get(); // Number of entities, unused + mEntities.resize(2); // Hardcoded + for (auto& entity : mEntities) + entity.read(nif); + + mPriority = static_cast(nif->get()); + } + + void bhkConstraintCInfo::post(Reader& nif) + { + postRecordList(nif, mEntities); + } + /// Record types void bhkCollisionObject::read(NIFStream* nif) @@ -448,4 +463,15 @@ namespace Nif nif->readArray(mat); mTransform.set(mat.data()); } + + void bhkConstraint::read(NIFStream* nif) + { + mInfo.read(nif); + } + + void bhkConstraint::post(Reader& nif) + { + mInfo.post(nif); + } + } // Namespace diff --git a/components/nif/physics.hpp b/components/nif/physics.hpp index 3124e05692..bf1ca4c011 100644 --- a/components/nif/physics.hpp +++ b/components/nif/physics.hpp @@ -210,6 +210,21 @@ namespace Nif void read(NIFStream* nif); }; + enum class ConstraintPriority : uint32_t + { + Priority_Invalid = 0, + Priority_PhysicsTime = 1, + Priority_TimeOfImpact = 3 + }; + + struct bhkConstraintCInfo + { + bhkEntityList mEntities; + ConstraintPriority mPriority; + void read(NIFStream* nif); + void post(Reader& nif); + }; + /// Record types // Abstract Bethesda Havok object @@ -431,5 +446,14 @@ namespace Nif osg::Matrixf mTransform; void read(NIFStream* nif) override; }; + + // Abstract constraint + struct bhkConstraint : public bhkSerializable + { + bhkConstraintCInfo mInfo; + void read(NIFStream* nif) override; + void post(Reader& nif) override; + }; + } // Namespace #endif diff --git a/components/nif/recordptr.hpp b/components/nif/recordptr.hpp index 7025063213..3c22502145 100644 --- a/components/nif/recordptr.hpp +++ b/components/nif/recordptr.hpp @@ -137,6 +137,7 @@ namespace Nif struct bhkWorldObject; struct bhkShape; struct bhkSerializable; + struct bhkEntity; struct hkPackedNiTriStripsData; struct NiAccumulator; struct NiInterpolator; @@ -194,6 +195,7 @@ namespace Nif using NiTriStripsDataList = RecordListT; using bhkShapeList = RecordListT; using bhkSerializableList = RecordListT; + using bhkEntityList = RecordListT; using NiControllerSequenceList = RecordListT; } // Namespace