BulletPhysics3D: Add StaticPlaneCollider3D
This commit is contained in:
parent
021801f02e
commit
3efd422e86
|
|
@ -13,6 +13,7 @@
|
|||
#include <Nazara/Core/ObjectLibrary.hpp>
|
||||
#include <Nazara/Math/Box.hpp>
|
||||
#include <Nazara/Math/Quaternion.hpp>
|
||||
#include <Nazara/Math/Plane.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
#include <NazaraUtils/Signal.hpp>
|
||||
#include <NazaraUtils/SparsePtr.hpp>
|
||||
|
|
@ -27,6 +28,7 @@ class btConvexHullShape;
|
|||
class btCylinderShape;
|
||||
class btEmptyShape;
|
||||
class btSphereShape;
|
||||
class btStaticPlaneShape;
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
|
|
@ -211,6 +213,26 @@ namespace Nz
|
|||
Vector3f m_position;
|
||||
float m_radius;
|
||||
};
|
||||
|
||||
class NAZARA_BULLETPHYSICS3D_API BulletStaticPlaneCollider3D final : public BulletCollider3D
|
||||
{
|
||||
public:
|
||||
BulletStaticPlaneCollider3D(const Planef& plane);
|
||||
BulletStaticPlaneCollider3D(const Vector3f& normal, float distance);
|
||||
~BulletStaticPlaneCollider3D();
|
||||
|
||||
void BuildDebugMesh(std::vector<Vector3f>& vertices, std::vector<UInt16>& indices, const Matrix4f& offsetMatrix) const override;
|
||||
|
||||
float GetDistance() const;
|
||||
const Vector3f& GetNormal() const;
|
||||
btCollisionShape* GetShape() const override;
|
||||
ColliderType3D GetType() const override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<btStaticPlaneShape> m_shape;
|
||||
Vector3f m_normal;
|
||||
float m_distance;
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/BulletPhysics3D/BulletCollider3D.inl>
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@ namespace Nz
|
|||
Null,
|
||||
Scene,
|
||||
Sphere,
|
||||
Tree,
|
||||
StaticPlane,
|
||||
|
||||
Max = Tree
|
||||
Max = StaticPlane
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
#include <BulletCollision/CollisionShapes/btCylinderShape.h>
|
||||
#include <BulletCollision/CollisionShapes/btEmptyShape.h>
|
||||
#include <BulletCollision/CollisionShapes/btSphereShape.h>
|
||||
#include <BulletCollision/CollisionShapes/btStaticPlaneShape.h>
|
||||
#include <Nazara/BulletPhysics3D/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
|
|
@ -426,4 +427,44 @@ namespace Nz
|
|||
{
|
||||
return ColliderType3D::Sphere;
|
||||
}
|
||||
|
||||
/******************************** StaticPlaneCollider3D *********************************/
|
||||
|
||||
StaticPlaneCollider3D::StaticPlaneCollider3D(const Planef& plane) :
|
||||
StaticPlaneCollider3D(plane.normal, plane.distance)
|
||||
{
|
||||
}
|
||||
|
||||
StaticPlaneCollider3D::StaticPlaneCollider3D(const Vector3f& normal, float distance) :
|
||||
m_normal(normal),
|
||||
m_distance(distance)
|
||||
{
|
||||
m_shape = std::make_unique<btStaticPlaneShape>(ToBullet(m_normal), m_distance);
|
||||
}
|
||||
|
||||
StaticPlaneCollider3D::~StaticPlaneCollider3D() = default;
|
||||
|
||||
void StaticPlaneCollider3D::BuildDebugMesh(std::vector<Vector3f>& vertices, std::vector<UInt16>& indices, const Matrix4f& offsetMatrix) const
|
||||
{
|
||||
}
|
||||
|
||||
float StaticPlaneCollider3D::GetDistance() const
|
||||
{
|
||||
return m_distance;
|
||||
}
|
||||
|
||||
const Vector3f& StaticPlaneCollider3D::GetNormal() const
|
||||
{
|
||||
return m_normal;
|
||||
}
|
||||
|
||||
btCollisionShape* StaticPlaneCollider3D::GetShape() const
|
||||
{
|
||||
return m_shape.get();
|
||||
}
|
||||
|
||||
ColliderType3D StaticPlaneCollider3D::GetType() const
|
||||
{
|
||||
return ColliderType3D::StaticPlane;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue