Skip to content

Commit

Permalink
Parse bhkRagdollTemplate/bhkRagdollTemplateData
Browse files Browse the repository at this point in the history
  • Loading branch information
Capostrophic committed Sep 16, 2024
1 parent b9cb028 commit 5f7fa64
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 0 deletions.
4 changes: 4 additions & 0 deletions components/nif/niffile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,10 @@ namespace Nif
{ "bhkLiquidAction", &construct<bhkLiquidAction, RC_bhkLiquidAction> },
{ "bhkOrientHingedBodyAction", &construct<bhkOrientHingedBodyAction, RC_bhkOrientHingedBodyAction> },

// Ragdoll template records
{ "bhkRagdollTemplate", &construct<bhkRagdollTemplate, RC_bhkRagdollTemplate> },
{ "bhkRagdollTemplateData", &construct<bhkRagdollTemplateData, RC_bhkRagdollTemplateData> },

// PROPERTIES

// 4.0.0.2
Expand Down
27 changes: 27 additions & 0 deletions components/nif/physics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint32_t>());
for (bhkWrappedConstraintData& constraint : mConstraints)
constraint.read(nif);
}

} // Namespace
22 changes: 22 additions & 0 deletions components/nif/physics.hpp
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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<bhkWrappedConstraintData> mConstraints;

void read(NIFStream* nif) override;
};

} // Namespace
#endif
2 changes: 2 additions & 0 deletions components/nif/record.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ namespace Nif
RC_bhkPrismaticConstraint,
RC_bhkRagdollConstraint,
RC_bhkRagdollSystem,
RC_bhkRagdollTemplate,
RC_bhkRagdollTemplateData,
RC_bhkRigidBody,
RC_bhkRigidBodyT,
RC_bhkSimpleShapePhantom,
Expand Down

0 comments on commit 5f7fa64

Please sign in to comment.