Refactor all present Bethesda Havok 'support'

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

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

@ -8,6 +8,82 @@
namespace Nif 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 // Generic collision object
struct NiCollisionObject : public Record struct NiCollisionObject : public Record
{ {
@ -28,7 +104,7 @@ struct NiCollisionObject : public Record
struct bhkCollisionObject : public NiCollisionObject struct bhkCollisionObject : public NiCollisionObject
{ {
unsigned short mFlags; unsigned short mFlags;
CollisionBodyPtr mBody; bhkWorldObjectPtr mBody;
void read(NIFStream *nif) override; void read(NIFStream *nif) override;
void post(NIFFile *nif) override void post(NIFFile *nif) override
@ -39,52 +115,21 @@ struct bhkCollisionObject : public NiCollisionObject
}; };
// Abstract Havok shape info record // Abstract Havok shape info record
struct bhkWorldObject : public Record struct bhkWorldObject : public bhkSerializable
{ {
bhkShapePtr mShape; bhkShapePtr mShape;
unsigned int mFlags; // Havok layer type, collision filter flags and group HavokFilter mHavokFilter;
struct WorldObjectInfo bhkWorldObjectCInfo mWorldObjectInfo;
{
unsigned char mPhaseType;
unsigned int mData;
unsigned int mSize;
unsigned int mCapacityAndFlags;
};
WorldObjectInfo mWorldObjectInfo;
void read(NIFStream *nif) override; void read(NIFStream *nif) override;
void post(NIFFile *nif) override; void post(NIFFile *nif) override;
}; };
struct bhkShape : public Record {}; // Abstract
enum class hkResponseType : uint8_t
{
Response_Invalid = 0,
Response_SimpleContact = 1,
Response_Reporting = 2,
Response_None = 3
};
struct bhkEntity : public bhkWorldObject struct bhkEntity : public bhkWorldObject
{ {
hkResponseType mResponseType; bhkEntityCInfo mInfo;
unsigned short mProcessContactDelay;
void read(NIFStream *nif) override; 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 } // Namespace
#endif #endif

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

Loading…
Cancel
Save