mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-03 17:54:06 +00:00
f2fb3d6de8
NIFFile might not always be created from a file or stream containing NIF data. Basically there are 2 different responsibilities for this class: 1. Read NIF file 2. Provide input for nifosg and bulletnifloader. Remove no longer needed NIFFileMock since the state of NIFFfile can be initialized independently from reading NIF file.
78 lines
2.0 KiB
C++
78 lines
2.0 KiB
C++
#ifndef OPENMW_COMPONENTS_NIFBULLET_BULLETNIFLOADER_HPP
|
|
#define OPENMW_COMPONENTS_NIFBULLET_BULLETNIFLOADER_HPP
|
|
|
|
#include <cassert>
|
|
#include <map>
|
|
#include <set>
|
|
#include <string>
|
|
|
|
#include <osg/BoundingBox>
|
|
#include <osg/Matrixf>
|
|
#include <osg/Referenced>
|
|
#include <osg/ref_ptr>
|
|
|
|
#include <BulletCollision/CollisionShapes/btCompoundShape.h>
|
|
|
|
#include <components/debug/debuglog.hpp>
|
|
#include <components/nif/niffile.hpp>
|
|
#include <components/resource/bulletshape.hpp>
|
|
|
|
class btTriangleMesh;
|
|
class btCompoundShape;
|
|
class btCollisionShape;
|
|
|
|
namespace Nif
|
|
{
|
|
struct Node;
|
|
struct Transformation;
|
|
struct NiTriShape;
|
|
struct NiTriStrips;
|
|
struct NiGeometry;
|
|
struct Parent;
|
|
}
|
|
|
|
namespace NifBullet
|
|
{
|
|
|
|
/**
|
|
*Load bulletShape from NIF files.
|
|
*/
|
|
class BulletNifLoader
|
|
{
|
|
public:
|
|
void warn(const std::string& msg) { Log(Debug::Warning) << "NIFLoader: Warn: " << msg; }
|
|
|
|
[[noreturn]] void fail(const std::string& msg)
|
|
{
|
|
Log(Debug::Error) << "NIFLoader: Fail: " << msg;
|
|
abort();
|
|
}
|
|
|
|
osg::ref_ptr<Resource::BulletShape> load(const Nif::NIFFile& file);
|
|
|
|
private:
|
|
bool findBoundingBox(const Nif::Node& node, const std::string& filename);
|
|
|
|
void handleNode(const std::string& fileName, const Nif::Node& node, const Nif::Parent* parent, int flags,
|
|
bool isCollisionNode, bool isAnimated, bool autogenerated, bool avoid,
|
|
Resource::VisualCollisionType& visualCollisionType);
|
|
|
|
bool hasRootCollisionNode(const Nif::Node& rootNode) const;
|
|
bool collisionShapeIsEmpty(const Nif::Node& rootNode) const;
|
|
|
|
void handleNiTriShape(const Nif::NiGeometry& nifNode, const Nif::Parent* parent, const osg::Matrixf& transform,
|
|
bool isAnimated, bool avoid);
|
|
|
|
std::unique_ptr<btCompoundShape, Resource::DeleteCollisionShape> mCompoundShape;
|
|
|
|
std::unique_ptr<btTriangleMesh> mStaticMesh;
|
|
|
|
std::unique_ptr<btTriangleMesh> mAvoidStaticMesh;
|
|
|
|
osg::ref_ptr<Resource::BulletShape> mShape;
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|