Refactor all present Bethesda Havok 'support'

android-ndk22
Alexei Dobrohotov 3 years ago
parent 4d09f791ab
commit 59ce00f742

@ -3,52 +3,79 @@
namespace Nif
{
void bhkCollisionObject::read(NIFStream *nif)
/// Non-record data types
void bhkWorldObjCInfoProperty::read(NIFStream *nif)
{
NiCollisionObject::read(nif);
mFlags = nif->getUShort();
mBody.read(nif);
mData = nif->getUInt();
mSize = nif->getUInt();
mCapacityAndFlags = nif->getUInt();
}
void bhkWorldObject::read(NIFStream *nif)
void bhkWorldObjectCInfo::read(NIFStream *nif)
{
mShape.read(nif);
if (nif->getVersion() <= NIFFile::NIFVersion::VER_OB_OLD)
nif->skip(4); // Unknown
mFlags = nif->getUInt();
nif->skip(4); // Unused
mWorldObjectInfo.mPhaseType = nif->getChar();
mPhaseType = static_cast<BroadPhaseType>(nif->getChar());
nif->skip(3); // Unused
mWorldObjectInfo.mData = nif->getUInt();
mWorldObjectInfo.mSize = nif->getUInt();
mWorldObjectInfo.mCapacityAndFlags = nif->getUInt();
mProperty.read(nif);
}
void bhkWorldObject::post(NIFFile *nif)
void HavokMaterial::read(NIFStream *nif)
{
mShape.post(nif);
if (nif->getVersion() <= NIFFile::NIFVersion::VER_OB_OLD)
nif->skip(4); // Unknown
mMaterial = nif->getUInt();
}
void bhkEntity::read(NIFStream *nif)
void HavokFilter::read(NIFStream *nif)
{
mLayer = nif->getChar();
mFlags = nif->getChar();
mGroup = nif->getUShort();
}
void hkSubPartData::read(NIFStream *nif)
{
mHavokFilter.read(nif);
mNumVertices = nif->getUInt();
mHavokMaterial.read(nif);
}
void bhkEntityCInfo::read(NIFStream *nif)
{
bhkWorldObject::read(nif);
mResponseType = static_cast<hkResponseType>(nif->getChar());
nif->skip(1); // Unused
mProcessContactDelay = nif->getUShort();
}
void HavokMaterial::read(NIFStream *nif)
/// Record types
void bhkCollisionObject::read(NIFStream *nif)
{
NiCollisionObject::read(nif);
mFlags = nif->getUShort();
mBody.read(nif);
}
void bhkWorldObject::read(NIFStream *nif)
{
mShape.read(nif);
if (nif->getVersion() <= NIFFile::NIFVersion::VER_OB_OLD)
nif->skip(4); // Unknown
mMaterial = nif->getUInt();
mHavokFilter.read(nif);
mWorldObjectInfo.read(nif);
}
void hkSubPartData::read(NIFStream *nif)
void bhkWorldObject::post(NIFFile *nif)
{
mHavokFilter = nif->getUInt();
mNumVertices = nif->getUInt();
mHavokMaterial.read(nif);
mShape.post(nif);
}
void bhkEntity::read(NIFStream *nif)
{
bhkWorldObject::read(nif);
mInfo.read(nif);
}
} // Namespace

@ -8,6 +8,82 @@
namespace Nif
{
/// Non-record data types
struct bhkWorldObjCInfoProperty
{
unsigned int mData;
unsigned int mSize;
unsigned int mCapacityAndFlags;
void read(NIFStream *nif);
};
enum class BroadPhaseType : uint8_t
{
BroadPhase_Invalid = 0,
BroadPhase_Entity = 1,
BroadPhase_Phantom = 2,
BroadPhase_Border = 3
};
struct bhkWorldObjectCInfo
{
BroadPhaseType mPhaseType;
bhkWorldObjCInfoProperty mProperty;
void read(NIFStream *nif);
};
struct HavokMaterial
{
unsigned int mMaterial;
void read(NIFStream *nif);
};
struct HavokFilter
{
unsigned char mLayer;
unsigned char mFlags;
unsigned short mGroup;
void read(NIFStream *nif);
};
struct hkSubPartData
{
HavokMaterial mHavokMaterial;
unsigned int mNumVertices;
HavokFilter mHavokFilter;
void read(NIFStream *nif);
};
enum class hkResponseType : uint8_t
{
Response_Invalid = 0,
Response_SimpleContact = 1,
Response_Reporting = 2,
Response_None = 3
};
struct bhkEntityCInfo
{
hkResponseType mResponseType;
unsigned short mProcessContactDelay;
void read(NIFStream *nif);
}
/// Record types
// Abstract Bethesda Havok object
struct bhkRefObject : public Record {};
// Abstract serializable Bethesda Havok object
struct bhkSerializable : public bhkRefObject {};
// Abstract narrowphase collision detection object
struct bhkShape : public bhkSerializable {};
// Abstract bhkShape collection
struct bhkShapeCollection : public bhkShape {};
// Generic collision object
struct NiCollisionObject : public Record
{
@ -28,7 +104,7 @@ struct NiCollisionObject : public Record
struct bhkCollisionObject : public NiCollisionObject
{
unsigned short mFlags;
CollisionBodyPtr mBody;
bhkWorldObjectPtr mBody;
void read(NIFStream *nif) override;
void post(NIFFile *nif) override
@ -39,52 +115,21 @@ struct bhkCollisionObject : public NiCollisionObject
};
// Abstract Havok shape info record
struct bhkWorldObject : public Record
struct bhkWorldObject : public bhkSerializable
{
bhkShapePtr mShape;
unsigned int mFlags; // Havok layer type, collision filter flags and group
struct WorldObjectInfo
{
unsigned char mPhaseType;
unsigned int mData;
unsigned int mSize;
unsigned int mCapacityAndFlags;
};
WorldObjectInfo mWorldObjectInfo;
HavokFilter mHavokFilter;
bhkWorldObjectCInfo mWorldObjectInfo;
void read(NIFStream *nif) override;
void post(NIFFile *nif) override;
};
struct bhkShape : public Record {};
enum class hkResponseType : uint8_t
{
Response_Invalid = 0,
Response_SimpleContact = 1,
Response_Reporting = 2,
Response_None = 3
};
// Abstract
struct bhkEntity : public bhkWorldObject
{
hkResponseType mResponseType;
unsigned short mProcessContactDelay;
bhkEntityCInfo mInfo;
void read(NIFStream *nif) override;
};
struct HavokMaterial
{
unsigned int mMaterial;
void read(NIFStream *nif);
};
struct hkSubPartData
{
HavokMaterial mHavokMaterial;
unsigned int mNumVertices;
unsigned int mHavokFilter;
void read(NIFStream *nif);
};
} // Namespace
#endif

@ -151,6 +151,7 @@ struct NiAlphaProperty;
struct NiCollisionObject;
struct bhkWorldObject;
struct bhkShape;
struct bhkSerializable;
using NodePtr = RecordPtrT<Node>;
using ExtraPtr = RecordPtrT<Extra>;
@ -179,7 +180,7 @@ using NiGeometryDataPtr = RecordPtrT<NiGeometryData>;
using BSShaderPropertyPtr = RecordPtrT<BSShaderProperty>;
using NiAlphaPropertyPtr = RecordPtrT<NiAlphaProperty>;
using NiCollisionObjectPtr = RecordPtrT<NiCollisionObject>;
using CollisionBodyPtr = RecordPtrT<bhkWorldObject>;
using bhkWorldObjectPtr = RecordPtrT<bhkWorldObject>;
using bhkShapePtr = RecordPtrT<bhkShape>;
using NodeList = RecordListT<Node>;
@ -188,6 +189,8 @@ using ExtraList = RecordListT<Extra>;
using NiSourceTextureList = RecordListT<NiSourceTexture>;
using NiFloatInterpolatorList = RecordListT<NiFloatInterpolator>;
using NiTriStripsDataList = RecordListT<NiTriStripsData>;
using bhkShapeList = RecordListT<bhkShape>;
using bhkSerializableList = RecordListT<bhkSerializable>;
} // Namespace
#endif

Loading…
Cancel
Save