From 6204a83a2b238cae3ee538b064e70291b81e5465 Mon Sep 17 00:00:00 2001 From: Alexei Kotov Date: Thu, 21 Sep 2023 22:59:55 +0300 Subject: [PATCH] Read bhkBallAndSocketConstraint and bhkStiffSpringConstraint --- components/nif/niffile.cpp | 2 ++ components/nif/physics.cpp | 27 +++++++++++++++++++++++++++ components/nif/physics.hpp | 29 +++++++++++++++++++++++++++++ components/nif/record.hpp | 2 ++ 4 files changed, 60 insertions(+) diff --git a/components/nif/niffile.cpp b/components/nif/niffile.cpp index bad2482432..8f0925103a 100644 --- a/components/nif/niffile.cpp +++ b/components/nif/niffile.cpp @@ -338,9 +338,11 @@ namespace Nif { "bhkBlendCollisionObject", &construct }, // Constraint records, Bethesda + { "bhkBallAndSocketConstraint", &construct }, { "bhkHingeConstraint", &construct }, { "bhkLimitedHingeConstraint", &construct }, { "bhkRagdollConstraint", &construct }, + { "bhkStiffSpringConstraint", &construct }, // Physics body records, Bethesda { "bhkRigidBody", &construct }, diff --git a/components/nif/physics.cpp b/components/nif/physics.cpp index a359f86066..f97b4b6169 100644 --- a/components/nif/physics.cpp +++ b/components/nif/physics.cpp @@ -332,6 +332,19 @@ namespace Nif mMotor.read(nif); } + void bhkBallAndSocketConstraintCInfo::read(NIFStream* nif) + { + nif->read(mPivotA); + nif->read(mPivotB); + } + + void bhkStiffSpringConstraintCInfo::read(NIFStream* nif) + { + nif->read(mPivotA); + nif->read(mPivotB); + nif->read(mLength); + } + /// Record types void bhkCollisionObject::read(NIFStream* nif) @@ -719,4 +732,18 @@ namespace Nif mConstraint.read(nif); } + void bhkBallAndSocketConstraint::read(NIFStream* nif) + { + bhkConstraint::read(nif); + + mConstraint.read(nif); + } + + void bhkStiffSpringConstraint::read(NIFStream* nif) + { + bhkConstraint::read(nif); + + mConstraint.read(nif); + } + } // Namespace diff --git a/components/nif/physics.hpp b/components/nif/physics.hpp index 91d55c1f80..d9656510c3 100644 --- a/components/nif/physics.hpp +++ b/components/nif/physics.hpp @@ -348,6 +348,21 @@ namespace Nif void read(NIFStream* nif); }; + struct bhkBallAndSocketConstraintCInfo + { + osg::Vec4f mPivotA, mPivotB; + + void read(NIFStream* nif); + }; + + struct bhkStiffSpringConstraintCInfo + { + osg::Vec4f mPivotA, mPivotB; + float mLength; + + void read(NIFStream* nif); + }; + /// Record types // Abstract Bethesda Havok object @@ -684,5 +699,19 @@ namespace Nif void read(NIFStream* nif) override; }; + struct bhkBallAndSocketConstraint : bhkConstraint + { + bhkBallAndSocketConstraintCInfo mConstraint; + + void read(NIFStream* nif) override; + }; + + struct bhkStiffSpringConstraint : bhkConstraint + { + bhkStiffSpringConstraintCInfo mConstraint; + + void read(NIFStream* nif) override; + }; + } // Namespace #endif diff --git a/components/nif/record.hpp b/components/nif/record.hpp index b26233259a..d399660432 100644 --- a/components/nif/record.hpp +++ b/components/nif/record.hpp @@ -36,6 +36,7 @@ namespace Nif { RC_MISSING = 0, RC_AvoidNode, + RC_bhkBallAndSocketConstraint, RC_bhkBlendCollisionObject, RC_bhkBlendController, RC_bhkBoxShape, @@ -61,6 +62,7 @@ namespace Nif RC_bhkRigidBodyT, RC_bhkSimpleShapePhantom, RC_bhkSphereShape, + RC_bhkStiffSpringConstraint, RC_BSBehaviorGraphExtraData, RC_BSBound, RC_BSBoneLODExtraData,