2013-02-24 13:52:23 -08:00
|
|
|
#ifndef OPENMW_COMPONENTS_NIFBULLET_BULLETNIFLOADER_HPP
|
|
|
|
#define OPENMW_COMPONENTS_NIFBULLET_BULLETNIFLOADER_HPP
|
2011-01-13 17:51:50 +01:00
|
|
|
|
2012-07-17 09:27:12 +02:00
|
|
|
#include <cassert>
|
2015-05-12 03:02:15 +02:00
|
|
|
#include <map>
|
2015-05-10 00:28:51 +02:00
|
|
|
#include <set>
|
2011-01-13 17:51:50 +01:00
|
|
|
#include <string>
|
|
|
|
|
2015-05-12 03:02:15 +02:00
|
|
|
#include <osg/BoundingBox>
|
|
|
|
#include <osg/Referenced>
|
|
|
|
#include <osg/ref_ptr>
|
2015-05-07 21:17:15 +02:00
|
|
|
|
2018-07-11 01:05:19 +03:00
|
|
|
#include <BulletCollision/CollisionShapes/btCompoundShape.h>
|
|
|
|
|
2018-08-14 19:42:41 +04:00
|
|
|
#include <components/debug/debuglog.hpp>
|
2015-05-12 03:02:15 +02:00
|
|
|
#include <components/nif/niffile.hpp>
|
2015-11-16 23:30:10 +01:00
|
|
|
#include <components/resource/bulletshape.hpp>
|
2011-01-13 17:51:50 +01:00
|
|
|
|
2015-05-27 22:32:11 +02:00
|
|
|
class btTriangleMesh;
|
|
|
|
class btCompoundShape;
|
|
|
|
class btCollisionShape;
|
|
|
|
|
2011-01-13 17:51:50 +01:00
|
|
|
namespace Nif
|
|
|
|
{
|
2020-12-28 12:19:22 +04:00
|
|
|
struct Node;
|
2015-03-06 21:36:42 +13:00
|
|
|
struct Transformation;
|
|
|
|
struct NiTriShape;
|
2019-08-08 13:11:24 +03:00
|
|
|
struct NiTriStrips;
|
2021-10-31 14:27:16 +01:00
|
|
|
struct NiGeometry;
|
2022-01-22 00:15:56 +01:00
|
|
|
struct Parent;
|
2011-01-13 17:51:50 +01:00
|
|
|
}
|
|
|
|
|
2011-06-19 18:45:23 +02:00
|
|
|
namespace NifBullet
|
|
|
|
{
|
2011-01-13 17:51:50 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
*Load bulletShape from NIF files.
|
|
|
|
*/
|
2015-05-12 03:02:15 +02:00
|
|
|
class BulletNifLoader
|
2011-04-01 23:35:56 +02:00
|
|
|
{
|
2022-09-22 21:26:05 +03:00
|
|
|
public:
|
2020-11-14 03:42:15 +03:00
|
|
|
void warn(const std::string& msg) { Log(Debug::Warning) << "NIFLoader: Warn: " << msg; }
|
2011-01-13 17:51:50 +01:00
|
|
|
|
2021-04-29 21:30:25 +02:00
|
|
|
[[noreturn]] void fail(const std::string& msg)
|
2011-04-01 23:35:56 +02:00
|
|
|
{
|
2018-08-14 19:42:41 +04:00
|
|
|
Log(Debug::Error) << "NIFLoader: Fail: " << msg;
|
2013-02-20 05:35:52 +01:00
|
|
|
abort();
|
2011-04-01 23:35:56 +02:00
|
|
|
}
|
2011-01-13 17:51:50 +01:00
|
|
|
|
2022-09-18 14:12:49 +02:00
|
|
|
osg::ref_ptr<Resource::BulletShape> load(Nif::FileView file);
|
2015-05-12 03:02:15 +02:00
|
|
|
|
2011-01-13 17:51:50 +01:00
|
|
|
private:
|
2021-10-31 14:23:44 +01:00
|
|
|
bool findBoundingBox(const Nif::Node& node, const std::string& filename);
|
2011-01-13 17:51:50 +01:00
|
|
|
|
2022-08-25 00:14:17 +02:00
|
|
|
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);
|
2011-03-23 13:42:28 +01:00
|
|
|
|
2022-07-03 02:14:32 +02:00
|
|
|
bool hasRootCollisionNode(const Nif::Node& rootNode) const;
|
|
|
|
bool collisionShapeIsEmpty(const Nif::Node& rootNode) const;
|
2011-01-13 17:51:50 +01:00
|
|
|
|
2023-03-08 14:17:45 +03:00
|
|
|
void handleNiTriShape(const Nif::NiGeometry& nifNode, const Nif::Parent* parent, bool isAnimated, bool avoid);
|
2021-10-31 14:27:16 +01:00
|
|
|
|
2021-10-30 03:46:29 +02:00
|
|
|
std::unique_ptr<btCompoundShape, Resource::DeleteCollisionShape> mCompoundShape;
|
2023-02-25 07:06:49 +03:00
|
|
|
std::unique_ptr<btCompoundShape, Resource::DeleteCollisionShape> mAvoidCompoundShape;
|
2018-07-11 01:05:19 +03:00
|
|
|
|
2015-11-16 23:30:10 +01:00
|
|
|
osg::ref_ptr<Resource::BulletShape> mShape;
|
2011-01-13 17:51:50 +01:00
|
|
|
};
|
|
|
|
|
2011-06-19 18:45:23 +02:00
|
|
|
}
|
|
|
|
|
2011-01-13 17:51:50 +01:00
|
|
|
#endif
|