1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-16 19:59:55 +00:00
openmw/components/nifbullet/bulletnifloader.hpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

75 lines
1.9 KiB
C++
Raw Normal View History

2013-02-24 21:52:23 +00:00
#ifndef OPENMW_COMPONENTS_NIFBULLET_BULLETNIFLOADER_HPP
#define OPENMW_COMPONENTS_NIFBULLET_BULLETNIFLOADER_HPP
2011-01-13 16:51:50 +00:00
#include <cassert>
#include <map>
#include <set>
2011-01-13 16:51:50 +00:00
#include <string>
#include <osg/BoundingBox>
#include <osg/Referenced>
#include <osg/ref_ptr>
2015-05-07 19:17:15 +00:00
#include <BulletCollision/CollisionShapes/btCompoundShape.h>
2018-08-14 15:42:41 +00:00
#include <components/debug/debuglog.hpp>
#include <components/nif/niffile.hpp>
#include <components/resource/bulletshape.hpp>
2011-01-13 16:51:50 +00:00
2015-05-27 20:32:11 +00:00
class btTriangleMesh;
class btCompoundShape;
class btCollisionShape;
2011-01-13 16:51:50 +00:00
namespace Nif
{
struct NiAVObject;
struct NiNode;
struct NiGeometry;
struct Parent;
2011-01-13 16:51:50 +00:00
}
namespace NifBullet
{
2011-01-13 16:51:50 +00:00
/**
*Load bulletShape from NIF files.
*/
class BulletNifLoader
{
2022-09-22 18:26:05 +00:00
public:
void warn(const std::string& msg) { Log(Debug::Warning) << "NIFLoader: Warn: " << msg; }
2011-01-13 16:51:50 +00:00
[[noreturn]] void fail(const std::string& msg)
{
2018-08-14 15:42:41 +00:00
Log(Debug::Error) << "NIFLoader: Fail: " << msg;
abort();
}
2011-01-13 16:51:50 +00:00
osg::ref_ptr<Resource::BulletShape> load(Nif::FileView file);
2011-01-13 16:51:50 +00:00
private:
bool findBoundingBox(const Nif::NiAVObject& node);
2011-01-13 16:51:50 +00:00
struct HandleNodeArgs
{
bool mHasMarkers{ false };
bool mAnimated{ false };
bool mIsCollisionNode{ false };
bool mAutogenerated{ false };
bool mAvoid{ false };
};
void handleRoot(Nif::FileView nif, const Nif::NiAVObject& node, HandleNodeArgs args);
void handleNode(const Nif::NiAVObject& node, const Nif::Parent* parent, HandleNodeArgs args);
void handleNiTriShape(const Nif::NiGeometry& nifNode, const Nif::Parent* parent, HandleNodeArgs args);
std::unique_ptr<btCompoundShape, Resource::DeleteCollisionShape> mCompoundShape;
std::unique_ptr<btCompoundShape, Resource::DeleteCollisionShape> mAvoidCompoundShape;
osg::ref_ptr<Resource::BulletShape> mShape;
2011-01-13 16:51:50 +00:00
};
}
2011-01-13 16:51:50 +00:00
#endif