diff --git a/components/nif/niffile.cpp b/components/nif/niffile.cpp index d360552f9f3..e0616a679ad 100644 --- a/components/nif/niffile.cpp +++ b/components/nif/niffile.cpp @@ -477,6 +477,10 @@ namespace Nif { "bhkLiquidAction", &construct }, { "bhkOrientHingedBodyAction", &construct }, + // Ragdoll template records + { "bhkRagdollTemplate", &construct }, + { "bhkRagdollTemplateData", &construct }, + // PROPERTIES // 4.0.0.2 diff --git a/components/nif/physics.cpp b/components/nif/physics.cpp index 139f6dda419..762e83515d9 100644 --- a/components/nif/physics.cpp +++ b/components/nif/physics.cpp @@ -986,4 +986,31 @@ namespace Nif nif->skip(8); // Unused } + void bhkRagdollTemplate::read(NIFStream* nif) + { + Extra::read(nif); + + readRecordList(nif, mBones); + } + + void bhkRagdollTemplate::post(Reader& nif) + { + Extra::post(nif); + + postRecordList(nif, mBones); + } + + void bhkRagdollTemplateData::read(NIFStream* nif) + { + nif->read(mName); + nif->read(mMass); + nif->read(mRestitution); + nif->read(mFriction); + nif->read(mRadius); + mHavokMaterial.read(nif); + mConstraints.resize(nif->get()); + for (bhkWrappedConstraintData& constraint : mConstraints) + constraint.read(nif); + } + } // Namespace diff --git a/components/nif/physics.hpp b/components/nif/physics.hpp index 4b8571e20e2..ecefd556164 100644 --- a/components/nif/physics.hpp +++ b/components/nif/physics.hpp @@ -1,6 +1,7 @@ #ifndef OPENMW_COMPONENTS_NIF_PHYSICS_HPP #define OPENMW_COMPONENTS_NIF_PHYSICS_HPP +#include "extra.hpp" #include "niftypes.hpp" #include "record.hpp" #include "recordptr.hpp" @@ -908,5 +909,26 @@ namespace Nif void read(NIFStream* nif) override; }; + struct bhkRagdollTemplate : Extra + { + NiAVObjectList mBones; + + void read(NIFStream* nif) override; + void post(Reader& nif) override; + }; + + struct bhkRagdollTemplateData : Record + { + std::string mName; + float mMass; + float mRestitution; + float mFriction; + float mRadius; + HavokMaterial mHavokMaterial; + std::vector mConstraints; + + void read(NIFStream* nif) override; + }; + } // Namespace #endif diff --git a/components/nif/record.hpp b/components/nif/record.hpp index 21e0b0d3820..ebb237edd37 100644 --- a/components/nif/record.hpp +++ b/components/nif/record.hpp @@ -68,6 +68,8 @@ namespace Nif RC_bhkPrismaticConstraint, RC_bhkRagdollConstraint, RC_bhkRagdollSystem, + RC_bhkRagdollTemplate, + RC_bhkRagdollTemplateData, RC_bhkRigidBody, RC_bhkRigidBodyT, RC_bhkSimpleShapePhantom,