Continue Jolt integration
This commit is contained in:
committed by
Jérôme Leclercq
parent
21e08798ce
commit
021801f02e
@@ -7,23 +7,21 @@
|
||||
#ifndef NAZARA_JOLTPHYSICS3D_JOLTCOLLIDER3D_HPP
|
||||
#define NAZARA_JOLTPHYSICS3D_JOLTCOLLIDER3D_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <NazaraUtils/Prerequisites.hpp>
|
||||
#include <Nazara/Core/ObjectLibrary.hpp>
|
||||
#include <Nazara/JoltPhysics3D/Config.hpp>
|
||||
#include <Nazara/JoltPhysics3D/Enums.hpp>
|
||||
#include <Nazara/Math/Box.hpp>
|
||||
#include <Nazara/Math/Quaternion.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
#include <Nazara/Utils/Signal.hpp>
|
||||
#include <Nazara/Utils/SparsePtr.hpp>
|
||||
#include <NazaraUtils/Signal.hpp>
|
||||
#include <NazaraUtils/SparsePtr.hpp>
|
||||
#include <memory>
|
||||
|
||||
namespace JPH
|
||||
{
|
||||
class ShapeSettings;
|
||||
class BoxShapeSettings;
|
||||
class CompoundShapeSettings;
|
||||
class SphereShapeSettings;
|
||||
}
|
||||
|
||||
namespace Nz
|
||||
@@ -35,7 +33,7 @@ namespace Nz
|
||||
class NAZARA_JOLTPHYSICS3D_API JoltCollider3D
|
||||
{
|
||||
public:
|
||||
JoltCollider3D() = default;
|
||||
JoltCollider3D();
|
||||
JoltCollider3D(const JoltCollider3D&) = delete;
|
||||
JoltCollider3D(JoltCollider3D&&) = delete;
|
||||
virtual ~JoltCollider3D();
|
||||
@@ -44,7 +42,7 @@ namespace Nz
|
||||
|
||||
virtual std::shared_ptr<StaticMesh> GenerateDebugMesh() const;
|
||||
|
||||
virtual JPH::ShapeSettings* GetShapeSettings() const = 0;
|
||||
inline JPH::ShapeSettings* GetShapeSettings() const;
|
||||
virtual JoltColliderType3D GetType() const = 0;
|
||||
|
||||
JoltCollider3D& operator=(const JoltCollider3D&) = delete;
|
||||
@@ -52,25 +50,28 @@ namespace Nz
|
||||
|
||||
static std::shared_ptr<JoltCollider3D> Build(const PrimitiveList& list);
|
||||
|
||||
protected:
|
||||
template<typename T> const T* GetShapeSettingsAs() const;
|
||||
template<typename T> void SetupShapeSettings(std::unique_ptr<T> shapeSettings);
|
||||
|
||||
private:
|
||||
static std::shared_ptr<JoltCollider3D> CreateGeomFromPrimitive(const Primitive& primitive);
|
||||
|
||||
std::unique_ptr<JPH::ShapeSettings> m_shapeSettings;
|
||||
};
|
||||
|
||||
/*********************************** Shapes ******************************************/
|
||||
|
||||
class NAZARA_JOLTPHYSICS3D_API JoltBoxCollider3D final : public JoltCollider3D
|
||||
{
|
||||
public:
|
||||
JoltBoxCollider3D(const Vector3f& lengths, float convexRadius = 0.f);
|
||||
~JoltBoxCollider3D();
|
||||
~JoltBoxCollider3D() = default;
|
||||
|
||||
void BuildDebugMesh(std::vector<Vector3f>& vertices, std::vector<UInt16>& indices, const Matrix4f& offsetMatrix) const override;
|
||||
|
||||
Vector3f GetLengths() const;
|
||||
JPH::ShapeSettings* GetShapeSettings() const override;
|
||||
JoltColliderType3D GetType() const override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<JPH::BoxShapeSettings> m_shapeSettings;
|
||||
Vector3f m_lengths;
|
||||
};
|
||||
|
||||
class NAZARA_JOLTPHYSICS3D_API JoltCompoundCollider3D final : public JoltCollider3D
|
||||
@@ -79,12 +80,11 @@ namespace Nz
|
||||
struct ChildCollider;
|
||||
|
||||
JoltCompoundCollider3D(std::vector<ChildCollider> childs);
|
||||
~JoltCompoundCollider3D();
|
||||
~JoltCompoundCollider3D() = default;
|
||||
|
||||
void BuildDebugMesh(std::vector<Vector3f>& vertices, std::vector<UInt16>& indices, const Matrix4f& offsetMatrix) const override;
|
||||
|
||||
const std::vector<ChildCollider>& GetGeoms() const;
|
||||
JPH::ShapeSettings* GetShapeSettings() const override;
|
||||
JoltColliderType3D GetType() const override;
|
||||
|
||||
struct ChildCollider
|
||||
@@ -95,7 +95,6 @@ namespace Nz
|
||||
};
|
||||
|
||||
private:
|
||||
std::unique_ptr<JPH::CompoundShapeSettings> m_shapeSettings;
|
||||
std::vector<ChildCollider> m_childs;
|
||||
};
|
||||
|
||||
@@ -103,19 +102,32 @@ namespace Nz
|
||||
{
|
||||
public:
|
||||
JoltSphereCollider3D(float radius);
|
||||
~JoltSphereCollider3D();
|
||||
~JoltSphereCollider3D() = default;
|
||||
|
||||
void BuildDebugMesh(std::vector<Vector3f>& vertices, std::vector<UInt16>& indices, const Matrix4f& offsetMatrix) const override;
|
||||
|
||||
float GetRadius() const;
|
||||
JPH::ShapeSettings* GetShapeSettings() const override;
|
||||
JoltColliderType3D GetType() const override;
|
||||
};
|
||||
|
||||
/*********************************** Decorated ******************************************/
|
||||
|
||||
class NAZARA_JOLTPHYSICS3D_API JoltTranslatedRotatedCollider3D final : public JoltCollider3D
|
||||
{
|
||||
public:
|
||||
inline JoltTranslatedRotatedCollider3D(std::shared_ptr<JoltCollider3D> collider, const Vector3f& translation);
|
||||
inline JoltTranslatedRotatedCollider3D(std::shared_ptr<JoltCollider3D> collider, const Quaternionf& rotation);
|
||||
JoltTranslatedRotatedCollider3D(std::shared_ptr<JoltCollider3D> collider, const Vector3f& translation, const Quaternionf& rotation);
|
||||
~JoltTranslatedRotatedCollider3D() = default;
|
||||
|
||||
void BuildDebugMesh(std::vector<Vector3f>& vertices, std::vector<UInt16>& indices, const Matrix4f& offsetMatrix) const override;
|
||||
|
||||
JoltColliderType3D GetType() const override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<JPH::SphereShapeSettings> m_shapeSettings;
|
||||
Vector3f m_position;
|
||||
float m_radius;
|
||||
std::shared_ptr<JoltCollider3D> m_collider;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#include <Nazara/JoltPhysics3D/JoltCollider3D.inl>
|
||||
|
||||
Reference in New Issue
Block a user