From 5f7fa640b0fa9356cb524981f1ffe6f80ff07d59 Mon Sep 17 00:00:00 2001 From: Alexei Kotov Date: Tue, 17 Sep 2024 00:12:38 +0300 Subject: [PATCH] Parse bhkRagdollTemplate/bhkRagdollTemplateData --- components/nif/niffile.cpp | 4 ++++ components/nif/physics.cpp | 27 +++++++++++++++++++++++++++ components/nif/physics.hpp | 22 ++++++++++++++++++++++ components/nif/record.hpp | 2 ++ 4 files changed, 55 insertions(+) diff --git a/components/nif/niffile.cpp b/components/nif/niffile.cpp index d360552f9f..e0616a679a 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 139f6dda41..762e83515d 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 4b8571e20e..ecefd55616 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 21e0b0d382..ebb237edd3 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,