Remove BulletPhysics3D module

Having two physics engine seems redundant, Bullet3 development seems to have halted and JoltPhysics seems to be a better fit to Nazara
This commit is contained in:
Lynix
2024-02-06 20:45:06 +01:00
committed by Jérôme Leclercq
parent cb484a2432
commit 139bed2b0a
40 changed files with 31 additions and 2503 deletions

View File

@@ -1,47 +0,0 @@
// this file was automatically generated and should not be edited
/*
Nazara Engine - BulletPhysics3D module
Copyright (C) 2024 Jérôme "SirLynix" Leclercq (lynix680@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#pragma once
#ifndef NAZARA_GLOBAL_BULLETPHYSICS3D_HPP
#define NAZARA_GLOBAL_BULLETPHYSICS3D_HPP
#include <Nazara/BulletPhysics3D/BulletCollider3D.hpp>
#include <Nazara/BulletPhysics3D/BulletConstraint3D.hpp>
#include <Nazara/BulletPhysics3D/BulletPhysics3D.hpp>
#include <Nazara/BulletPhysics3D/BulletPhysWorld3D.hpp>
#include <Nazara/BulletPhysics3D/BulletRigidBody3D.hpp>
#include <Nazara/BulletPhysics3D/Config.hpp>
#include <Nazara/BulletPhysics3D/Enums.hpp>
#ifdef NAZARA_ENTT
#include <Nazara/BulletPhysics3D/Components.hpp>
#include <Nazara/BulletPhysics3D/Systems.hpp>
#endif
#endif // NAZARA_GLOBAL_BULLETPHYSICS3D_HPP

View File

@@ -1,240 +0,0 @@
// Copyright (C) 2024 Jérôme "SirLynix" Leclercq (lynix680@gmail.com)
// This file is part of the "Nazara Engine - BulletPhysics3D module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_BULLETPHYSICS3D_BULLETCOLLIDER3D_HPP
#define NAZARA_BULLETPHYSICS3D_BULLETCOLLIDER3D_HPP
#include <NazaraUtils/Prerequisites.hpp>
#include <Nazara/BulletPhysics3D/Config.hpp>
#include <Nazara/BulletPhysics3D/Enums.hpp>
#include <Nazara/Core/ObjectLibrary.hpp>
#include <Nazara/Math/Box.hpp>
#include <Nazara/Math/Plane.hpp>
#include <Nazara/Math/Quaternion.hpp>
#include <Nazara/Math/Vector3.hpp>
#include <NazaraUtils/Signal.hpp>
#include <NazaraUtils/SparsePtr.hpp>
#include <memory>
class btBoxShape;
class btCapsuleShape;
class btCompoundShape;
class btCollisionShape;
class btConeShape;
class btConvexHullShape;
class btCylinderShape;
class btEmptyShape;
class btSphereShape;
class btStaticPlaneShape;
namespace Nz
{
class PrimitiveList;
class StaticMesh;
struct Primitive;
class NAZARA_BULLETPHYSICS3D_API BulletCollider3D
{
public:
BulletCollider3D() = default;
BulletCollider3D(const BulletCollider3D&) = delete;
BulletCollider3D(BulletCollider3D&&) = delete;
virtual ~BulletCollider3D();
virtual void BuildDebugMesh(std::vector<Vector3f>& vertices, std::vector<UInt16>& indices, const Matrix4f& offsetMatrix = Matrix4f::Identity()) const = 0;
Boxf ComputeAABB(const Vector3f& translation, const Quaternionf& rotation, const Vector3f& scale) const;
virtual Boxf ComputeAABB(const Matrix4f& offsetMatrix = Matrix4f::Identity(), const Vector3f& scale = Vector3f::Unit()) const;
virtual void ComputeInertia(float mass, Vector3f* inertia) const;
virtual std::shared_ptr<StaticMesh> GenerateDebugMesh() const;
virtual btCollisionShape* GetShape() const = 0;
virtual BulletColliderType3D GetType() const = 0;
BulletCollider3D& operator=(const BulletCollider3D&) = delete;
BulletCollider3D& operator=(BulletCollider3D&&) = delete;
static std::shared_ptr<BulletCollider3D> Build(const PrimitiveList& list);
private:
static std::shared_ptr<BulletCollider3D> CreateGeomFromPrimitive(const Primitive& primitive);
};
class NAZARA_BULLETPHYSICS3D_API BulletBoxCollider3D final : public BulletCollider3D
{
public:
BulletBoxCollider3D(const Vector3f& lengths);
~BulletBoxCollider3D();
void BuildDebugMesh(std::vector<Vector3f>& vertices, std::vector<UInt16>& indices, const Matrix4f& offsetMatrix) const override;
Vector3f GetLengths() const;
btCollisionShape* GetShape() const override;
BulletColliderType3D GetType() const override;
private:
std::unique_ptr<btBoxShape> m_shape;
Vector3f m_lengths;
};
class NAZARA_BULLETPHYSICS3D_API BulletCapsuleCollider3D final : public BulletCollider3D
{
public:
BulletCapsuleCollider3D(float length, float radius);
~BulletCapsuleCollider3D();
void BuildDebugMesh(std::vector<Vector3f>& vertices, std::vector<UInt16>& indices, const Matrix4f& offsetMatrix) const override;
float GetLength() const;
float GetRadius() const;
btCollisionShape* GetShape() const override;
BulletColliderType3D GetType() const override;
private:
std::unique_ptr<btCapsuleShape> m_shape;
float m_length;
float m_radius;
};
class NAZARA_BULLETPHYSICS3D_API BulletCompoundCollider3D final : public BulletCollider3D
{
public:
struct ChildCollider;
BulletCompoundCollider3D(std::vector<ChildCollider> childs);
~BulletCompoundCollider3D();
void BuildDebugMesh(std::vector<Vector3f>& vertices, std::vector<UInt16>& indices, const Matrix4f& offsetMatrix) const override;
const std::vector<ChildCollider>& GetGeoms() const;
btCollisionShape* GetShape() const override;
BulletColliderType3D GetType() const override;
struct ChildCollider
{
std::shared_ptr<BulletCollider3D> collider;
Matrix4f offsetMatrix;
};
private:
std::unique_ptr<btCompoundShape> m_shape;
std::vector<ChildCollider> m_childs;
};
class NAZARA_BULLETPHYSICS3D_API BulletConeCollider3D final : public BulletCollider3D
{
public:
BulletConeCollider3D(float length, float radius);
~BulletConeCollider3D();
void BuildDebugMesh(std::vector<Vector3f>& vertices, std::vector<UInt16>& indices, const Matrix4f& offsetMatrix) const override;
float GetLength() const;
float GetRadius() const;
btCollisionShape* GetShape() const override;
BulletColliderType3D GetType() const override;
private:
std::unique_ptr<btConeShape> m_shape;
float m_length;
float m_radius;
};
class NAZARA_BULLETPHYSICS3D_API BulletConvexCollider3D final : public BulletCollider3D
{
public:
BulletConvexCollider3D(SparsePtr<const Vector3f> vertices, unsigned int vertexCount);
~BulletConvexCollider3D();
void BuildDebugMesh(std::vector<Vector3f>& vertices, std::vector<UInt16>& indices, const Matrix4f& offsetMatrix) const override;
btCollisionShape* GetShape() const override;
BulletColliderType3D GetType() const override;
private:
std::unique_ptr<btConvexHullShape> m_shape;
};
class NAZARA_BULLETPHYSICS3D_API BulletCylinderCollider3D final : public BulletCollider3D
{
public:
BulletCylinderCollider3D(float length, float radius);
~BulletCylinderCollider3D();
void BuildDebugMesh(std::vector<Vector3f>& vertices, std::vector<UInt16>& indices, const Matrix4f& offsetMatrix) const override;
float GetLength() const;
float GetRadius() const;
btCollisionShape* GetShape() const override;
BulletColliderType3D GetType() const override;
private:
std::unique_ptr<btCylinderShape> m_shape;
Matrix4f m_matrix;
float m_length;
float m_radius;
};
class NAZARA_BULLETPHYSICS3D_API BulletNullCollider3D final : public BulletCollider3D
{
public:
BulletNullCollider3D();
~BulletNullCollider3D();
void BuildDebugMesh(std::vector<Vector3f>& vertices, std::vector<UInt16>& indices, const Matrix4f& offsetMatrix) const override;
void ComputeInertia(float mass, Vector3f* inertia) const override;
btCollisionShape* GetShape() const override;
BulletColliderType3D GetType() const override;
private:
std::unique_ptr<btEmptyShape> m_shape;
};
class NAZARA_BULLETPHYSICS3D_API BulletSphereCollider3D final : public BulletCollider3D
{
public:
BulletSphereCollider3D(float radius);
~BulletSphereCollider3D();
void BuildDebugMesh(std::vector<Vector3f>& vertices, std::vector<UInt16>& indices, const Matrix4f& offsetMatrix) const override;
float GetRadius() const;
btCollisionShape* GetShape() const override;
BulletColliderType3D GetType() const override;
private:
std::unique_ptr<btSphereShape> m_shape;
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;
BulletColliderType3D GetType() const override;
private:
std::unique_ptr<btStaticPlaneShape> m_shape;
Vector3f m_normal;
float m_distance;
};
}
#include <Nazara/BulletPhysics3D/BulletCollider3D.inl>
#endif // NAZARA_BULLETPHYSICS3D_BULLETCOLLIDER3D_HPP

View File

@@ -1,12 +0,0 @@
// Copyright (C) 2024 Jérôme "SirLynix" Leclercq (lynix680@gmail.com)
// This file is part of the "Nazara Engine - BulletPhysics3D module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <memory>
#include <Nazara/BulletPhysics3D/Debug.hpp>
namespace Nz
{
}
#include <Nazara/BulletPhysics3D/DebugOff.hpp>

View File

@@ -1,82 +0,0 @@
// Copyright (C) 2024 Jérôme "SirLynix" Leclercq (lynix680@gmail.com)
// This file is part of the "Nazara Engine - BulletPhysics3D module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_BULLETPHYSICS3D_BULLETCONSTRAINT3D_HPP
#define NAZARA_BULLETPHYSICS3D_BULLETCONSTRAINT3D_HPP
#include <NazaraUtils/Prerequisites.hpp>
#include <Nazara/BulletPhysics3D/BulletPhysWorld3D.hpp>
#include <Nazara/BulletPhysics3D/BulletRigidBody3D.hpp>
#include <Nazara/BulletPhysics3D/Config.hpp>
#include <Nazara/Core/HandledObject.hpp>
#include <Nazara/Core/ObjectHandle.hpp>
class btTypedConstraint;
namespace Nz
{
class BulletConstraint3D;
using BulletConstraint3DHandle = ObjectHandle<BulletConstraint3D>;
class NAZARA_BULLETPHYSICS3D_API BulletConstraint3D : public HandledObject<BulletConstraint3D>
{
public:
BulletConstraint3D(const BulletConstraint3D&) = delete;
BulletConstraint3D(BulletConstraint3D&& constraint) noexcept;
virtual ~BulletConstraint3D();
BulletRigidBody3D& GetBodyA();
const BulletRigidBody3D& GetBodyA() const;
BulletRigidBody3D& GetBodyB();
const BulletRigidBody3D& GetBodyB() const;
BulletPhysWorld3D& GetWorld();
const BulletPhysWorld3D& GetWorld() const;
inline bool IsBodyCollisionEnabled() const;
bool IsSingleBody() const;
BulletConstraint3D& operator=(const BulletConstraint3D&) = delete;
BulletConstraint3D& operator=(BulletConstraint3D&& constraint) noexcept;
protected:
BulletConstraint3D(std::unique_ptr<btTypedConstraint> constraint, bool disableCollisions = false);
template<typename T> T* GetConstraint();
template<typename T> const T* GetConstraint() const;
private:
void Destroy();
std::unique_ptr<btTypedConstraint> m_constraint;
bool m_bodyCollisionEnabled;
};
class NAZARA_BULLETPHYSICS3D_API BulletPivotConstraint3D : public BulletConstraint3D
{
public:
BulletPivotConstraint3D(BulletRigidBody3D& first, const Vector3f& pivot);
BulletPivotConstraint3D(BulletRigidBody3D& first, BulletRigidBody3D& second, const Vector3f& pivot, bool disableCollisions = false);
BulletPivotConstraint3D(BulletRigidBody3D& first, BulletRigidBody3D& second, const Vector3f& firstAnchor, const Vector3f& secondAnchor, bool disableCollisions = false);
~BulletPivotConstraint3D() = default;
Vector3f GetFirstAnchor() const;
Vector3f GetSecondAnchor() const;
float GetDamping() const;
float GetImpulseClamp() const;
void SetFirstAnchor(const Vector3f& firstAnchor);
void SetSecondAnchor(const Vector3f& secondAnchor);
void SetDamping(float damping);
void SetImpulseClamp(float impulseClamp);
};
}
#include <Nazara/BulletPhysics3D/BulletConstraint3D.inl>
#endif // NAZARA_BULLETPHYSICS3D_BULLETCONSTRAINT3D_HPP

View File

@@ -1,27 +0,0 @@
// Copyright (C) 2024 Jérôme "SirLynix" Leclercq (lynix680@gmail.com)
// This file is part of the "Nazara Engine - BulletPhysics3D module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/BulletPhysics3D/Debug.hpp>
namespace Nz
{
inline bool BulletConstraint3D::IsBodyCollisionEnabled() const
{
return m_bodyCollisionEnabled;
}
template<typename T>
T* BulletConstraint3D::GetConstraint()
{
return SafeCast<T*>(m_constraint.get());
}
template<typename T>
const T* BulletConstraint3D::GetConstraint() const
{
return SafeCast<const T*>(m_constraint.get());
}
}
#include <Nazara/BulletPhysics3D/DebugOff.hpp>

View File

@@ -1,77 +0,0 @@
// Copyright (C) 2024 Jérôme "SirLynix" Leclercq (lynix680@gmail.com)
// This file is part of the "Nazara Engine - BulletPhysics3D module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_BULLETPHYSICS3D_BULLETPHYSWORLD3D_HPP
#define NAZARA_BULLETPHYSICS3D_BULLETPHYSWORLD3D_HPP
#include <NazaraUtils/Prerequisites.hpp>
#include <Nazara/BulletPhysics3D/Config.hpp>
#include <Nazara/Core/Time.hpp>
#include <Nazara/Math/Box.hpp>
#include <Nazara/Math/Vector3.hpp>
#include <NazaraUtils/FunctionRef.hpp>
#include <NazaraUtils/MovablePtr.hpp>
#include <optional>
class btDynamicsWorld;
class btRigidBody;
namespace Nz
{
class BulletRigidBody3D;
class NAZARA_BULLETPHYSICS3D_API BulletPhysWorld3D
{
friend BulletRigidBody3D;
public:
struct RaycastHit;
BulletPhysWorld3D();
BulletPhysWorld3D(const BulletPhysWorld3D&) = delete;
BulletPhysWorld3D(BulletPhysWorld3D&& ph) = delete;
~BulletPhysWorld3D();
btDynamicsWorld* GetDynamicsWorld();
Vector3f GetGravity() const;
std::size_t GetMaxStepCount() const;
Time GetStepSize() const;
bool RaycastQuery(const Vector3f& from, const Vector3f& to, const FunctionRef<std::optional<float>(const RaycastHit& hitInfo)>& callback);
bool RaycastQueryFirst(const Vector3f& from, const Vector3f& to, RaycastHit* hitInfo = nullptr);
void SetGravity(const Vector3f& gravity);
void SetMaxStepCount(std::size_t maxStepCount);
void SetStepSize(Time stepSize);
void Step(Time timestep);
BulletPhysWorld3D& operator=(const BulletPhysWorld3D&) = delete;
BulletPhysWorld3D& operator=(BulletPhysWorld3D&&) = delete;
struct RaycastHit
{
float fraction;
BulletRigidBody3D* hitBody = nullptr;
Vector3f hitPosition;
Vector3f hitNormal;
};
private:
btRigidBody* AddRigidBody(std::size_t& rigidBodyIndex, FunctionRef<void(btRigidBody* body)> constructor);
void RemoveRigidBody(btRigidBody* rigidBody, std::size_t rigidBodyIndex);
struct BulletWorld;
std::size_t m_maxStepCount;
std::unique_ptr<BulletWorld> m_world;
Vector3f m_gravity;
Time m_stepSize;
Time m_timestepAccumulator;
};
}
#endif // NAZARA_BULLETPHYSICS3D_BULLETPHYSWORLD3D_HPP

View File

@@ -1,33 +0,0 @@
// Copyright (C) 2024 Jérôme "SirLynix" Leclercq (lynix680@gmail.com)
// This file is part of the "Nazara Engine - BulletPhysics3D module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_BULLETPHYSICS3D_HPP
#define NAZARA_BULLETPHYSICS3D_HPP
#include <NazaraUtils/Prerequisites.hpp>
#include <Nazara/BulletPhysics3D/Config.hpp>
#include <Nazara/Core/Core.hpp>
namespace Nz
{
class NAZARA_BULLETPHYSICS3D_API BulletPhysics3D : public ModuleBase<BulletPhysics3D>
{
friend ModuleBase;
public:
using Dependencies = TypeList<Core>;
struct Config {};
BulletPhysics3D(Config /*config*/);
~BulletPhysics3D() = default;
private:
static BulletPhysics3D* s_instance;
};
}
#endif // NAZARA_BULLETPHYSICS3D_HPP

View File

@@ -1,96 +0,0 @@
// Copyright (C) 2024 Jérôme "SirLynix" Leclercq (lynix680@gmail.com)
// This file is part of the "Nazara Engine - BulletPhysics3D module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_BULLETPHYSICS3D_BULLETRIGIDBODY3D_HPP
#define NAZARA_BULLETPHYSICS3D_BULLETRIGIDBODY3D_HPP
#include <NazaraUtils/Prerequisites.hpp>
#include <Nazara/BulletPhysics3D/BulletCollider3D.hpp>
#include <Nazara/BulletPhysics3D/Config.hpp>
#include <Nazara/Core/Enums.hpp>
#include <Nazara/Math/Matrix4.hpp>
#include <Nazara/Math/Quaternion.hpp>
#include <Nazara/Math/Vector3.hpp>
#include <NazaraUtils/MovablePtr.hpp>
class btRigidBody;
namespace Nz
{
class BulletPhysWorld3D;
class NAZARA_BULLETPHYSICS3D_API BulletRigidBody3D
{
public:
BulletRigidBody3D(BulletPhysWorld3D* world, const Matrix4f& mat = Matrix4f::Identity());
BulletRigidBody3D(BulletPhysWorld3D* world, std::shared_ptr<BulletCollider3D> geom, const Matrix4f& mat = Matrix4f::Identity());
BulletRigidBody3D(const BulletRigidBody3D& object) = delete;
BulletRigidBody3D(BulletRigidBody3D&& object) noexcept;
~BulletRigidBody3D();
void AddForce(const Vector3f& force, CoordSys coordSys = CoordSys::Global);
void AddForce(const Vector3f& force, const Vector3f& point, CoordSys coordSys = CoordSys::Global);
void AddTorque(const Vector3f& torque, CoordSys coordSys = CoordSys::Global);
inline void DisableSleeping();
void EnableSleeping(bool enable);
void FallAsleep();
Boxf GetAABB() const;
float GetAngularDamping() const;
Vector3f GetAngularVelocity() const;
inline const std::shared_ptr<BulletCollider3D>& GetGeom() const;
float GetLinearDamping() const;
Vector3f GetLinearVelocity() const;
float GetMass() const;
Vector3f GetMassCenter(CoordSys coordSys = CoordSys::Local) const;
Matrix4f GetMatrix() const;
Vector3f GetPosition() const;
inline btRigidBody* GetRigidBody() const;
Quaternionf GetRotation() const;
inline std::size_t GetUniqueIndex() const;
inline BulletPhysWorld3D* GetWorld() const;
bool IsSimulationEnabled() const;
bool IsSleeping() const;
bool IsSleepingEnabled() const;
void SetAngularDamping(float angularDamping);
void SetAngularVelocity(const Vector3f& angularVelocity);
void SetGeom(std::shared_ptr<BulletCollider3D> geom, bool recomputeInertia = true);
void SetLinearDamping(float damping);
void SetLinearVelocity(const Vector3f& velocity);
void SetMass(float mass);
void SetMassCenter(const Vector3f& center);
void SetPosition(const Vector3f& position);
void SetPositionAndRotation(const Vector3f& position, const Quaternionf& rotation);
void SetRotation(const Quaternionf& rotation);
Quaternionf ToLocal(const Quaternionf& worldRotation);
Vector3f ToLocal(const Vector3f& worldPosition);
Quaternionf ToWorld(const Quaternionf& localRotation);
Vector3f ToWorld(const Vector3f& localPosition);
void WakeUp();
BulletRigidBody3D& operator=(const BulletRigidBody3D& object) = delete;
BulletRigidBody3D& operator=(BulletRigidBody3D&& object) noexcept;
protected:
void Destroy();
private:
std::shared_ptr<BulletCollider3D> m_geom;
std::size_t m_bodyPoolIndex;
btRigidBody* m_body;
BulletPhysWorld3D* m_world;
};
}
#include <Nazara/BulletPhysics3D/BulletRigidBody3D.inl>
#endif // NAZARA_BULLETPHYSICS3D_BULLETRIGIDBODY3D_HPP

View File

@@ -1,34 +0,0 @@
// Copyright (C) 2024 Jérôme "SirLynix" Leclercq (lynix680@gmail.com)
// This file is part of the "Nazara Engine - BulletPhysics3D module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/BulletPhysics3D/Debug.hpp>
namespace Nz
{
inline void BulletRigidBody3D::DisableSleeping()
{
return EnableSleeping(false);
}
inline const std::shared_ptr<BulletCollider3D>& BulletRigidBody3D::GetGeom() const
{
return m_geom;
}
inline btRigidBody* BulletRigidBody3D::GetRigidBody() const
{
return m_body;
}
inline std::size_t BulletRigidBody3D::GetUniqueIndex() const
{
return m_bodyPoolIndex;
}
inline BulletPhysWorld3D* BulletRigidBody3D::GetWorld() const
{
return m_world;
}
}
#include <Nazara/BulletPhysics3D/DebugOff.hpp>

View File

@@ -1,34 +0,0 @@
// this file was automatically generated and should not be edited
/*
Nazara Engine - BulletPhysics3D module
Copyright (C) 2024 Jérôme "SirLynix" Leclercq (lynix680@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#pragma once
#ifndef NAZARA_BULLETPHYSICS3D_COMPONENTS_HPP
#define NAZARA_BULLETPHYSICS3D_COMPONENTS_HPP
#include <Nazara/BulletPhysics3D/Components/BulletRigidBody3DComponent.hpp>
#endif // NAZARA_BULLETPHYSICS3D_COMPONENTS_HPP

View File

@@ -1,32 +0,0 @@
// Copyright (C) 2024 Jérôme "SirLynix" Leclercq (lynix680@gmail.com)
// This file is part of the "Nazara Engine - BulletPhysics3D module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_BULLETPHYSICS3D_COMPONENTS_BULLETRIGIDBODY3DCOMPONENT_HPP
#define NAZARA_BULLETPHYSICS3D_COMPONENTS_BULLETRIGIDBODY3DCOMPONENT_HPP
#include <NazaraUtils/Prerequisites.hpp>
#include <Nazara/BulletPhysics3D/BulletRigidBody3D.hpp>
namespace Nz
{
class NAZARA_BULLETPHYSICS3D_API BulletRigidBody3DComponent : public BulletRigidBody3D
{
friend class BulletPhysics3DSystem;
public:
using BulletRigidBody3D::BulletRigidBody3D;
BulletRigidBody3DComponent(const BulletRigidBody3DComponent&) = default;
BulletRigidBody3DComponent(BulletRigidBody3DComponent&&) noexcept = default;
~BulletRigidBody3DComponent() = default;
BulletRigidBody3DComponent& operator=(const BulletRigidBody3DComponent&) = default;
BulletRigidBody3DComponent& operator=(BulletRigidBody3DComponent&&) noexcept = default;
};
}
#include <Nazara/BulletPhysics3D/Components/BulletRigidBody3DComponent.inl>
#endif // NAZARA_BULLETPHYSICS3D_COMPONENTS_BULLETRIGIDBODY3DCOMPONENT_HPP

View File

@@ -1,11 +0,0 @@
// Copyright (C) 2024 Jérôme "SirLynix" Leclercq (lynix680@gmail.com)
// This file is part of the "Nazara Engine - BulletPhysics3D module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/BulletPhysics3D/Debug.hpp>
namespace Nz
{
}
#include <Nazara/BulletPhysics3D/DebugOff.hpp>

View File

@@ -1,48 +0,0 @@
/*
Nazara Engine - BulletPhysics3D module
Copyright (C) 2024 Jérôme "SirLynix" Leclercq (lynix680@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#pragma once
#ifndef NAZARA_BULLETPHYSICS3D_CONFIG_HPP
#define NAZARA_BULLETPHYSICS3D_CONFIG_HPP
/// Chaque modification d'un paramètre du module nécessite une recompilation de celui-ci
// Active les tests de sécurité basés sur le code (Conseillé pour le développement)
#define NAZARA_BULLETPHYSICS3D_SAFE 1
/// Vérification des valeurs et types de certaines constantes
#include <Nazara/BulletPhysics3D/ConfigCheck.hpp>
#if defined(NAZARA_STATIC)
#define NAZARA_BULLETPHYSICS3D_API
#else
#ifdef NAZARA_BULLETPHYSICS3D_BUILD
#define NAZARA_BULLETPHYSICS3D_API NAZARA_EXPORT
#else
#define NAZARA_BULLETPHYSICS3D_API NAZARA_IMPORT
#endif
#endif
#endif // NAZARA_BULLETPHYSICS3D_CONFIG_HPP

View File

@@ -1,10 +0,0 @@
// Copyright (C) 2024 Jérôme "SirLynix" Leclercq (lynix680@gmail.com)
// This file is part of the "Nazara Engine - BulletPhysics3D module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_BULLETPHYSICS3D_CONFIGCHECK_HPP
#define NAZARA_BULLETPHYSICS3D_CONFIGCHECK_HPP
#endif // NAZARA_BULLETPHYSICS3D_CONFIGCHECK_HPP

View File

@@ -1,5 +0,0 @@
// Copyright (C) 2024 Jérôme "SirLynix" Leclercq (lynix680@gmail.com)
// This file is part of the "Nazara Engine - BulletPhysics3D module"
// For conditions of distribution and use, see copyright notice in Config.hpp
// no header guards

View File

@@ -1,5 +0,0 @@
// Copyright (C) 2024 Jérôme "SirLynix" Leclercq (lynix680@gmail.com)
// This file is part of the "Nazara Engine - BulletPhysics3D module"
// For conditions of distribution and use, see copyright notice in Config.hpp
// no header guards

View File

@@ -1,30 +0,0 @@
// Copyright (C) 2024 Jérôme "SirLynix" Leclercq (lynix680@gmail.com)
// This file is part of the "Nazara Engine - BulletPhysics3D module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_BULLETPHYSICS3D_ENUMS_HPP
#define NAZARA_BULLETPHYSICS3D_ENUMS_HPP
namespace Nz
{
enum class BulletColliderType3D
{
Box,
Capsule,
Cone,
Compound,
ConvexHull,
Cylinder,
Heightfield,
Null,
Scene,
Sphere,
StaticPlane,
Max = StaticPlane
};
}
#endif // NAZARA_BULLETPHYSICS3D_ENUMS_HPP

View File

@@ -1,34 +0,0 @@
// this file was automatically generated and should not be edited
/*
Nazara Engine - BulletPhysics3D module
Copyright (C) 2024 Jérôme "SirLynix" Leclercq (lynix680@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#pragma once
#ifndef NAZARA_BULLETPHYSICS3D_SYSTEMS_HPP
#define NAZARA_BULLETPHYSICS3D_SYSTEMS_HPP
#include <Nazara/BulletPhysics3D/Systems/BulletPhysics3DSystem.hpp>
#endif // NAZARA_BULLETPHYSICS3D_SYSTEMS_HPP

View File

@@ -1,73 +0,0 @@
// Copyright (C) 2024 Jérôme "SirLynix" Leclercq (lynix680@gmail.com)
// This file is part of the "Nazara Engine - BulletPhysics3D module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_BULLETPHYSICS3D_SYSTEMS_BULLETPHYSICS3DSYSTEM_HPP
#define NAZARA_BULLETPHYSICS3D_SYSTEMS_BULLETPHYSICS3DSYSTEM_HPP
#include <NazaraUtils/Prerequisites.hpp>
#include <Nazara/BulletPhysics3D/BulletPhysWorld3D.hpp>
#include <Nazara/BulletPhysics3D/Components/BulletRigidBody3DComponent.hpp>
#include <Nazara/Core/Clock.hpp>
#include <Nazara/Core/Time.hpp>
#include <NazaraUtils/TypeList.hpp>
#include <entt/entt.hpp>
#include <vector>
namespace Nz
{
class NAZARA_BULLETPHYSICS3D_API BulletPhysics3DSystem
{
public:
static constexpr Int64 ExecutionOrder = 0;
using Components = TypeList<BulletRigidBody3DComponent, class NodeComponent>;
struct RaycastHit;
BulletPhysics3DSystem(entt::registry& registry);
BulletPhysics3DSystem(const BulletPhysics3DSystem&) = delete;
BulletPhysics3DSystem(BulletPhysics3DSystem&&) = delete;
~BulletPhysics3DSystem();
template<typename... Args> BulletRigidBody3DComponent CreateRigidBody(Args&&... args);
void Dump();
inline BulletPhysWorld3D& GetPhysWorld();
inline const BulletPhysWorld3D& GetPhysWorld() const;
bool RaycastQuery(const Vector3f& from, const Vector3f& to, const FunctionRef<std::optional<float>(const RaycastHit& hitInfo)>& callback);
bool RaycastQueryFirst(const Vector3f& from, const Vector3f& to, RaycastHit* hitInfo = nullptr);
void Update(Time elapsedTime);
BulletPhysics3DSystem& operator=(const BulletPhysics3DSystem&) = delete;
BulletPhysics3DSystem& operator=(BulletPhysics3DSystem&&) = delete;
struct RaycastHit : BulletPhysWorld3D::RaycastHit
{
entt::handle hitEntity;
};
private:
void OnConstruct(entt::registry& registry, entt::entity entity);
void OnDestruct(entt::registry& registry, entt::entity entity);
std::size_t m_activeObjectCount;
std::size_t m_stepCount;
std::vector<entt::entity> m_physicsEntities;
entt::registry& m_registry;
entt::observer m_physicsConstructObserver;
entt::scoped_connection m_constructConnection;
entt::scoped_connection m_destructConnection;
BulletPhysWorld3D m_physWorld;
Time m_physicsTime;
Time m_updateTime;
};
}
#include <Nazara/BulletPhysics3D/Systems/BulletPhysics3DSystem.inl>
#endif // NAZARA_BULLETPHYSICS3D_SYSTEMS_BULLETPHYSICS3DSYSTEM_HPP

View File

@@ -1,26 +0,0 @@
// Copyright (C) 2024 Jérôme "SirLynix" Leclercq (lynix680@gmail.com)
// This file is part of the "Nazara Engine - BulletPhysics3D module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/BulletPhysics3D/Debug.hpp>
namespace Nz
{
template<typename... Args>
BulletRigidBody3DComponent BulletPhysics3DSystem::CreateRigidBody(Args&&... args)
{
return BulletRigidBody3DComponent(&m_physWorld, std::forward<Args>(args)...);
}
inline BulletPhysWorld3D& BulletPhysics3DSystem::GetPhysWorld()
{
return m_physWorld;
}
inline const BulletPhysWorld3D& BulletPhysics3DSystem::GetPhysWorld() const
{
return m_physWorld;
}
}
#include <Nazara/BulletPhysics3D/DebugOff.hpp>