Load NiCollisionObject and bhkCollisionObject

macos-builds-only-for-openmw
Alexei Dobrohotov 3 years ago
parent 9500afaa5a
commit 5571099147

@ -61,7 +61,7 @@ add_component_dir (sceneutil
)
add_component_dir (nif
controlled effect niftypes record controller extra node record_ptr data niffile property nifkey base nifstream
controlled effect niftypes record controller extra node record_ptr data niffile property nifkey base nifstream physics
)
add_component_dir (nifosg

@ -137,6 +137,8 @@ static std::map<std::string,RecordFactoryEntry> makeFactory()
factory["BSShaderPPLightingProperty"] = {&construct <BSShaderPPLightingProperty> , RC_BSShaderPPLightingProperty };
factory["BSShaderNoLightingProperty"] = {&construct <BSShaderNoLightingProperty> , RC_BSShaderNoLightingProperty };
factory["BSFurnitureMarker"] = {&construct <BSFurnitureMarker> , RC_BSFurnitureMarker };
factory["NiCollisionObject"] = {&construct <NiCollisionObject> , RC_NiCollisionObject };
factory["bhkCollisionObject"] = {&construct <bhkCollisionObject> , RC_bhkCollisionObject };
return factory;
}

@ -8,6 +8,7 @@
#include "niftypes.hpp"
#include "controller.hpp"
#include "base.hpp"
#include "physics.hpp"
#include <components/misc/stringops.hpp>
@ -143,6 +144,9 @@ struct Node : public Named
bool hasBounds{false};
NiBoundingVolume bounds;
// Collision object info
NiCollisionObjectPtr collision;
void read(NIFStream *nif) override
{
Named::read(nif);
@ -160,7 +164,7 @@ struct Node : public Named
bounds.read(nif);
// Reference to the collision object in Gamebryo files.
if (nif->getVersion() >= NIFStream::generateVersion(10,0,1,0))
nif->skip(4);
collision.read(nif);
parent = nullptr;
@ -171,6 +175,7 @@ struct Node : public Named
{
Named::post(nif);
props.post(nif);
collision.post(nif);
}
// Parent node, or nullptr for the root node. As far as I'm aware, only

@ -0,0 +1,32 @@
#include "physics.hpp"
#include "node.hpp"
namespace Nif
{
void bhkCollisionObject::read(NIFStream *nif)
{
NiCollisionObject::read(nif);
flags = nif->getUShort();
body.read(nif);
}
void bhkWorldObject::read(NIFStream *nif)
{
shape.read(nif);
if (nif->getVersion() <= NIFFile::NIFVersion::VER_OB_OLD)
nif->skip(4); // Unknown
flags = nif->getUInt();
nif->skip(4); // Unused
worldObjectInfo.phaseType = nif->getChar();
nif->skip(3); // Unused
worldObjectInfo.data = nif->getUInt();
worldObjectInfo.size = nif->getUInt();
worldObjectInfo.capacityAndFlags = nif->getUInt();
}
void bhkWorldObject::post(NIFFile *nif)
{
shape.post(nif);
}
} // Namespace

@ -0,0 +1,62 @@
#ifndef OPENMW_COMPONENTS_NIF_PHYSICS_HPP
#define OPENMW_COMPONENTS_NIF_PHYSICS_HPP
#include "base.hpp"
// This header contains certain record definitions
// specific to Bethesda implementation of Havok physics
namespace Nif
{
// Generic collision object
struct NiCollisionObject : public Record
{
// The node that references this object
NodePtr target;
void read(NIFStream *nif) override
{
target.read(nif);
}
void post(NIFFile *nif) override
{
target.post(nif);
}
};
// Bethesda Havok-specific collision object
struct bhkCollisionObject : public NiCollisionObject
{
unsigned short flags;
CollisionBodyPtr body;
void read(NIFStream *nif) override;
void post(NIFFile *nif) override
{
NiCollisionObject::post(nif);
body.post(nif);
}
};
// Abstract Havok shape info record
struct bhkWorldObject : public Record
{
bhkShapePtr shape;
unsigned int flags; // Havok layer type, collision filter flags and group
struct WorldObjectInfo
{
unsigned char phaseType;
unsigned int data;
unsigned int size;
unsigned int capacityAndFlags;
};
WorldObjectInfo worldObjectInfo;
void read(NIFStream *nif) override;
void post(NIFFile *nif) override;
};
struct bhkShape : public Record {};
} // Namespace
#endif

@ -126,7 +126,9 @@ enum RecordType
RC_BSShaderProperty,
RC_BSShaderPPLightingProperty,
RC_BSShaderNoLightingProperty,
RC_BSFurnitureMarker
RC_BSFurnitureMarker,
RC_NiCollisionObject,
RC_bhkCollisionObject
};
/// Base class for all records

@ -148,6 +148,9 @@ struct BSShaderTextureSet;
struct NiGeometryData;
struct BSShaderProperty;
struct NiAlphaProperty;
struct NiCollisionObject;
struct bhkWorldObject;
struct bhkShape;
using NodePtr = RecordPtrT<Node>;
using ExtraPtr = RecordPtrT<Extra>;
@ -175,6 +178,9 @@ using BSShaderTextureSetPtr = RecordPtrT<BSShaderTextureSet>;
using NiGeometryDataPtr = RecordPtrT<NiGeometryData>;
using BSShaderPropertyPtr = RecordPtrT<BSShaderProperty>;
using NiAlphaPropertyPtr = RecordPtrT<NiAlphaProperty>;
using NiCollisionObjectPtr = RecordPtrT<NiCollisionObject>;
using CollisionBodyPtr = RecordPtrT<bhkWorldObject>;
using bhkShapePtr = RecordPtrT<bhkShape>;
using NodeList = RecordListT<Node>;
using PropertyList = RecordListT<Property>;

Loading…
Cancel
Save