1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-07 12:54:00 +00:00
OpenMW/components/detournavigator/recastmeshobject.hpp

78 lines
2.3 KiB
C++
Raw Normal View History

2018-05-26 14:44:25 +00:00
#ifndef OPENMW_COMPONENTS_DETOURNAVIGATOR_RECASTMESHOBJECT_H
#define OPENMW_COMPONENTS_DETOURNAVIGATOR_RECASTMESHOBJECT_H
2018-07-18 19:09:50 +00:00
#include "areatype.hpp"
2018-05-26 14:44:25 +00:00
#include <LinearMath/btTransform.h>
#include <osg/ref_ptr>
#include <osg/Referenced>
2018-05-26 14:44:25 +00:00
#include <functional>
#include <vector>
class btCollisionShape;
class btCompoundShape;
namespace DetourNavigator
{
class CollisionShape
{
public:
CollisionShape(osg::ref_ptr<const osg::Referenced> holder, const btCollisionShape& shape)
: mHolder(std::move(holder))
, mShape(shape)
{}
const osg::ref_ptr<const osg::Referenced>& getHolder() const { return mHolder; }
const btCollisionShape& getShape() const { return mShape; }
private:
osg::ref_ptr<const osg::Referenced> mHolder;
std::reference_wrapper<const btCollisionShape> mShape;
};
class ChildRecastMeshObject
2018-05-26 14:44:25 +00:00
{
public:
ChildRecastMeshObject(const btCollisionShape& shape, const btTransform& transform, const AreaType areaType);
2018-05-26 14:44:25 +00:00
2018-07-18 19:09:50 +00:00
bool update(const btTransform& transform, const AreaType areaType);
2018-05-26 14:44:25 +00:00
const btCollisionShape& getShape() const { return mShape; }
2018-05-26 14:44:25 +00:00
const btTransform& getTransform() const { return mTransform; }
2018-05-26 14:44:25 +00:00
AreaType getAreaType() const { return mAreaType; }
2018-07-12 08:44:11 +00:00
2018-05-26 14:44:25 +00:00
private:
std::reference_wrapper<const btCollisionShape> mShape;
btTransform mTransform;
2018-07-18 19:09:50 +00:00
AreaType mAreaType;
2019-03-03 12:51:02 +00:00
btVector3 mLocalScaling;
std::vector<ChildRecastMeshObject> mChildren;
};
class RecastMeshObject
{
public:
RecastMeshObject(const CollisionShape& shape, const btTransform& transform, const AreaType areaType);
bool update(const btTransform& transform, const AreaType areaType) { return mImpl.update(transform, areaType); }
const osg::ref_ptr<const osg::Referenced>& getHolder() const { return mHolder; }
const btCollisionShape& getShape() const { return mImpl.getShape(); }
const btTransform& getTransform() const { return mImpl.getTransform(); }
AreaType getAreaType() const { return mImpl.getAreaType(); }
private:
osg::ref_ptr<const osg::Referenced> mHolder;
ChildRecastMeshObject mImpl;
2018-05-26 14:44:25 +00:00
};
}
#endif