From 6b28f07537fb2cb77aad106469e793e2be6beb92 Mon Sep 17 00:00:00 2001 From: Alexei Kotov Date: Sat, 23 Sep 2023 15:42:10 +0300 Subject: [PATCH] Read bhkPlaneShape and bhkMultiSphereShape --- components/nif/niffile.cpp | 2 ++ components/nif/physics.cpp | 23 +++++++++++++++++++++++ components/nif/physics.hpp | 28 ++++++++++++++++++++++++++++ components/nif/record.hpp | 2 ++ 4 files changed, 55 insertions(+) diff --git a/components/nif/niffile.cpp b/components/nif/niffile.cpp index 6ed6b8fc08..682fef1987 100644 --- a/components/nif/niffile.cpp +++ b/components/nif/niffile.cpp @@ -421,9 +421,11 @@ namespace Nif { "bhkConvexVerticesShape", &construct }, { "bhkListShape", &construct }, { "bhkMoppBvTreeShape", &construct }, + { "bhkMultiSphereShape", &construct }, { "bhkNiTriStripsShape", &construct }, { "bhkPackedNiTriStripsShape", &construct }, { "hkPackedNiTriStripsData", &construct }, + { "bhkPlaneShape", &construct }, { "bhkSimpleShapePhantom", &construct }, { "bhkSphereShape", &construct }, { "bhkTransformShape", &construct }, diff --git a/components/nif/physics.cpp b/components/nif/physics.cpp index 4eaf77f510..4969bf2cb9 100644 --- a/components/nif/physics.cpp +++ b/components/nif/physics.cpp @@ -716,6 +716,29 @@ namespace Nif nif->skip(12); // Unused } + void bhkHeightfieldShape::read(NIFStream* nif) + { + mHavokMaterial.read(nif); + } + + void bhkPlaneShape::read(NIFStream* nif) + { + bhkHeightfieldShape::read(nif); + + nif->skip(12); // Unused + mPlane = osg::Plane(nif->get()); + nif->read(mExtents); + nif->read(mCenter); + } + + void bhkMultiSphereShape::read(NIFStream* nif) + { + bhkSphereRepShape::read(nif); + + mShapeProperty.read(nif); + nif->readVector(mSpheres, nif->get()); + } + void bhkListShape::read(NIFStream* nif) { readRecordList(nif, mSubshapes); diff --git a/components/nif/physics.hpp b/components/nif/physics.hpp index d4eaccfc94..a14d1d55f6 100644 --- a/components/nif/physics.hpp +++ b/components/nif/physics.hpp @@ -6,6 +6,7 @@ #include "recordptr.hpp" #include +#include #include #include @@ -676,9 +677,36 @@ namespace Nif void read(NIFStream* nif) override; }; + // Abstract shape that can collide with an array of spheres + struct bhkHeightfieldShape : bhkShape + { + HavokMaterial mHavokMaterial; + + void read(NIFStream* nif) override; + }; + + // A plane bounded by an AABB + struct bhkPlaneShape : bhkHeightfieldShape + { + osg::Plane mPlane; + osg::Vec4f mExtents; + osg::Vec4f mCenter; + + void read(NIFStream* nif) override; + }; + // A sphere using bhkSphereShape = bhkConvexShape; + // Multiple spheres + struct bhkMultiSphereShape : bhkSphereRepShape + { + bhkWorldObjCInfoProperty mShapeProperty; + std::vector mSpheres; + + void read(NIFStream* nif) override; + }; + // A list of shapes struct bhkListShape : public bhkShapeCollection { diff --git a/components/nif/record.hpp b/components/nif/record.hpp index 332647a661..331c2ff645 100644 --- a/components/nif/record.hpp +++ b/components/nif/record.hpp @@ -56,8 +56,10 @@ namespace Nif RC_bhkListShape, RC_bhkMalleableConstraint, RC_bhkMoppBvTreeShape, + RC_bhkMultiSphereShape, RC_bhkNiTriStripsShape, RC_bhkPackedNiTriStripsShape, + RC_bhkPlaneShape, RC_bhkPhysicsSystem, RC_bhkPrismaticConstraint, RC_bhkRagdollConstraint,