1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-15 15:19:55 +00:00
openmw-tes3mp/components/detournavigator/recastmeshobject.hpp
elsid 82cff1abf8
Create RecastMesh outside critical section
To not lock main thread when it tries to update objects.
2021-08-04 13:16:55 +02:00

72 lines
1.8 KiB
C++

#ifndef OPENMW_COMPONENTS_DETOURNAVIGATOR_RECASTMESHOBJECT_H
#define OPENMW_COMPONENTS_DETOURNAVIGATOR_RECASTMESHOBJECT_H
#include "areatype.hpp"
#include <LinearMath/btTransform.h>
#include <osg/ref_ptr>
#include <osg/Object>
#include <functional>
#include <vector>
class btCollisionShape;
class btCompoundShape;
namespace DetourNavigator
{
class CollisionShape
{
public:
CollisionShape(osg::ref_ptr<const osg::Object> holder, const btCollisionShape& shape)
: mHolder(std::move(holder))
, mShape(shape)
{}
const osg::ref_ptr<const osg::Object>& getHolder() const { return mHolder; }
const btCollisionShape& getShape() const { return mShape; }
private:
osg::ref_ptr<const osg::Object> mHolder;
std::reference_wrapper<const btCollisionShape> mShape;
};
class RecastMeshObject
{
public:
RecastMeshObject(const CollisionShape& shape, const btTransform& transform, const AreaType areaType);
bool update(const btTransform& transform, const AreaType areaType);
const osg::ref_ptr<const osg::Object>& getHolder() const
{
return mHolder;
}
const btCollisionShape& getShape() const
{
return mShape;
}
const btTransform& getTransform() const
{
return mTransform;
}
AreaType getAreaType() const
{
return mAreaType;
}
private:
osg::ref_ptr<const osg::Object> mHolder;
std::reference_wrapper<const btCollisionShape> mShape;
btTransform mTransform;
AreaType mAreaType;
btVector3 mLocalScaling;
std::vector<RecastMeshObject> mChildren;
};
}
#endif