Rename Physics3D to BulletPhysics3D

This commit is contained in:
SirLynix
2023-03-14 18:30:41 +01:00
committed by Jérôme Leclercq
parent 5cbc435e1a
commit bd4c2d6ee7
49 changed files with 687 additions and 685 deletions

View File

@@ -1,218 +0,0 @@
// Copyright (C) 2023 Jérôme "Lynix" Leclercq (lynix680@gmail.com)
// This file is part of the "Nazara Engine - Physics3D module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_PHYSICS3D_COLLIDER3D_HPP
#define NAZARA_PHYSICS3D_COLLIDER3D_HPP
#include <NazaraUtils/Prerequisites.hpp>
#include <Nazara/Core/ObjectLibrary.hpp>
#include <Nazara/Math/Box.hpp>
#include <Nazara/Math/Quaternion.hpp>
#include <Nazara/Math/Vector3.hpp>
#include <Nazara/Physics3D/Config.hpp>
#include <Nazara/Physics3D/Enums.hpp>
#include <NazaraUtils/Signal.hpp>
#include <NazaraUtils/SparsePtr.hpp>
#include <unordered_map>
class btBoxShape;
class btCapsuleShape;
class btCompoundShape;
class btCollisionShape;
class btConeShape;
class btConvexHullShape;
class btCylinderShape;
class btEmptyShape;
class btSphereShape;
namespace Nz
{
class PrimitiveList;
class StaticMesh;
struct Primitive;
class NAZARA_PHYSICS3D_API Collider3D
{
public:
Collider3D() = default;
Collider3D(const Collider3D&) = delete;
Collider3D(Collider3D&&) = delete;
virtual ~Collider3D();
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 ColliderType3D GetType() const = 0;
Collider3D& operator=(const Collider3D&) = delete;
Collider3D& operator=(Collider3D&&) = delete;
static std::shared_ptr<Collider3D> Build(const PrimitiveList& list);
private:
static std::shared_ptr<Collider3D> CreateGeomFromPrimitive(const Primitive& primitive);
};
class NAZARA_PHYSICS3D_API BoxCollider3D final : public Collider3D
{
public:
BoxCollider3D(const Vector3f& lengths);
~BoxCollider3D();
void BuildDebugMesh(std::vector<Vector3f>& vertices, std::vector<UInt16>& indices, const Matrix4f& offsetMatrix) const override;
Vector3f GetLengths() const;
btCollisionShape* GetShape() const override;
ColliderType3D GetType() const override;
private:
std::unique_ptr<btBoxShape> m_shape;
Vector3f m_lengths;
};
class NAZARA_PHYSICS3D_API CapsuleCollider3D final : public Collider3D
{
public:
CapsuleCollider3D(float length, float radius);
~CapsuleCollider3D();
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;
ColliderType3D GetType() const override;
private:
std::unique_ptr<btCapsuleShape> m_shape;
float m_length;
float m_radius;
};
class NAZARA_PHYSICS3D_API CompoundCollider3D final : public Collider3D
{
public:
struct ChildCollider;
CompoundCollider3D(std::vector<ChildCollider> childs);
~CompoundCollider3D();
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;
ColliderType3D GetType() const override;
struct ChildCollider
{
std::shared_ptr<Collider3D> collider;
Matrix4f offsetMatrix;
};
private:
std::unique_ptr<btCompoundShape> m_shape;
std::vector<ChildCollider> m_childs;
};
class NAZARA_PHYSICS3D_API ConeCollider3D final : public Collider3D
{
public:
ConeCollider3D(float length, float radius);
~ConeCollider3D();
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;
ColliderType3D GetType() const override;
private:
std::unique_ptr<btConeShape> m_shape;
float m_length;
float m_radius;
};
class NAZARA_PHYSICS3D_API ConvexCollider3D final : public Collider3D
{
public:
ConvexCollider3D(SparsePtr<const Vector3f> vertices, unsigned int vertexCount);
~ConvexCollider3D();
void BuildDebugMesh(std::vector<Vector3f>& vertices, std::vector<UInt16>& indices, const Matrix4f& offsetMatrix) const override;
btCollisionShape* GetShape() const override;
ColliderType3D GetType() const override;
private:
std::unique_ptr<btConvexHullShape> m_shape;
};
class NAZARA_PHYSICS3D_API CylinderCollider3D final : public Collider3D
{
public:
CylinderCollider3D(float length, float radius);
~CylinderCollider3D();
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;
ColliderType3D GetType() const override;
private:
std::unique_ptr<btCylinderShape> m_shape;
Matrix4f m_matrix;
float m_length;
float m_radius;
};
class NAZARA_PHYSICS3D_API NullCollider3D final : public Collider3D
{
public:
NullCollider3D();
~NullCollider3D();
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;
ColliderType3D GetType() const override;
private:
std::unique_ptr<btEmptyShape> m_shape;
};
class NAZARA_PHYSICS3D_API SphereCollider3D final : public Collider3D
{
public:
SphereCollider3D(float radius);
~SphereCollider3D();
void BuildDebugMesh(std::vector<Vector3f>& vertices, std::vector<UInt16>& indices, const Matrix4f& offsetMatrix) const override;
float GetRadius() const;
btCollisionShape* GetShape() const override;
ColliderType3D GetType() const override;
private:
std::unique_ptr<btSphereShape> m_shape;
Vector3f m_position;
float m_radius;
};
}
#include <Nazara/Physics3D/Collider3D.inl>
#endif // NAZARA_PHYSICS3D_COLLIDER3D_HPP

View File

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

View File

@@ -1,34 +0,0 @@
// this file was automatically generated and should not be edited
/*
Nazara Engine - Physics3D module
Copyright (C) 2023 Jérôme "Lynix" 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_PHYSICS3D_COMPONENTS_HPP
#define NAZARA_PHYSICS3D_COMPONENTS_HPP
#include <Nazara/Physics3D/Components/RigidBody3DComponent.hpp>
#endif // NAZARA_PHYSICS3D_COMPONENTS_HPP

View File

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

View File

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

View File

@@ -1,48 +0,0 @@
/*
Nazara Engine - Physics3D module
Copyright (C) 2023 Jérôme "Lynix" 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_PHYSICS3D_CONFIG_HPP
#define NAZARA_PHYSICS3D_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_PHYSICS3D_SAFE 1
/// Vérification des valeurs et types de certaines constantes
#include <Nazara/Physics3D/ConfigCheck.hpp>
#if defined(NAZARA_STATIC)
#define NAZARA_PHYSICS3D_API
#else
#ifdef NAZARA_PHYSICS3D_BUILD
#define NAZARA_PHYSICS3D_API NAZARA_EXPORT
#else
#define NAZARA_PHYSICS3D_API NAZARA_IMPORT
#endif
#endif
#endif // NAZARA_PHYSICS3D_CONFIG_HPP

View File

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

View File

@@ -1,74 +0,0 @@
// Copyright (C) 2023 Jérôme "Lynix" Leclercq (lynix680@gmail.com)
// This file is part of the "Nazara Engine - Physics3D module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_PHYSICS3D_CONSTRAINT3D_HPP
#define NAZARA_PHYSICS3D_CONSTRAINT3D_HPP
#include <Nazara/Prerequisites.hpp>
#include <Nazara/Core/HandledObject.hpp>
#include <Nazara/Core/ObjectHandle.hpp>
#include <Nazara/Physics3D/Config.hpp>
#include <Nazara/Physics3D/PhysWorld3D.hpp>
#include <Nazara/Physics3D/RigidBody3D.hpp>
class btTypedConstraint;
namespace Nz
{
class Constraint3D;
using Constraint3DHandle = ObjectHandle<Constraint3D>;
class NAZARA_PHYSICS3D_API Constraint3D : public HandledObject<Constraint3D>
{
public:
Constraint3D(const Constraint3D&) = delete;
Constraint3D(Constraint3D&& constraint) noexcept;
virtual ~Constraint3D();
RigidBody3D& GetBodyA();
const RigidBody3D& GetBodyA() const;
RigidBody3D& GetBodyB();
const RigidBody3D& GetBodyB() const;
PhysWorld3D& GetWorld();
const PhysWorld3D& GetWorld() const;
inline bool IsBodyCollisionEnabled() const;
bool IsSingleBody() const;
Constraint3D& operator=(const Constraint3D&) = delete;
Constraint3D& operator=(Constraint3D&& constraint) noexcept;
protected:
Constraint3D(std::unique_ptr<btTypedConstraint> constraint, bool disableCollisions = false);
template<typename T> T* GetConstraint();
template<typename T> const T* GetConstraint() const;
private:
std::unique_ptr<btTypedConstraint> m_constraint;
bool m_bodyCollisionEnabled;
};
class NAZARA_PHYSICS3D_API PivotConstraint3D : public Constraint3D
{
public:
PivotConstraint3D(RigidBody3D& first, const Vector3f& pivot);
PivotConstraint3D(RigidBody3D& first, RigidBody3D& second, const Vector3f& pivot, bool disableCollisions = false);
PivotConstraint3D(RigidBody3D& first, RigidBody3D& second, const Vector3f& firstAnchor, const Vector3f& secondAnchor, bool disableCollisions = false);
~PivotConstraint3D() = default;
Vector3f GetFirstAnchor() const;
Vector3f GetSecondAnchor() const;
void SetFirstAnchor(const Vector3f& firstAnchor);
void SetSecondAnchor(const Vector3f& secondAnchor);
};
}
#include <Nazara/Physics3D/Constraint3D.inl>
#endif // NAZARA_PHYSICS3D_CONSTRAINT3D_HPP

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,75 +0,0 @@
// Copyright (C) 2023 Jérôme "Lynix" Leclercq (lynix680@gmail.com)
// This file is part of the "Nazara Engine - Physics3D module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_PHYSICS3D_PHYSWORLD3D_HPP
#define NAZARA_PHYSICS3D_PHYSWORLD3D_HPP
#include <NazaraUtils/Prerequisites.hpp>
#include <Nazara/Core/Time.hpp>
#include <Nazara/Math/Box.hpp>
#include <Nazara/Math/Vector3.hpp>
#include <Nazara/Physics3D/Config.hpp>
#include <NazaraUtils/FunctionRef.hpp>
#include <NazaraUtils/MovablePtr.hpp>
class btDynamicsWorld;
class btRigidBody;
namespace Nz
{
class RigidBody3D;
class NAZARA_PHYSICS3D_API PhysWorld3D
{
friend RigidBody3D;
public:
struct RaycastHit;
PhysWorld3D();
PhysWorld3D(const PhysWorld3D&) = delete;
PhysWorld3D(PhysWorld3D&& ph) = delete;
~PhysWorld3D();
btDynamicsWorld* GetDynamicsWorld();
Vector3f GetGravity() const;
std::size_t GetMaxStepCount() const;
Time GetStepSize() const;
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);
PhysWorld3D& operator=(const PhysWorld3D&) = delete;
PhysWorld3D& operator=(PhysWorld3D&&) = delete;
struct RaycastHit
{
float fraction;
RigidBody3D* 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_PHYSICS3D_PHYSWORLD3D_HPP

View File

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

View File

@@ -1,95 +0,0 @@
// Copyright (C) 2023 Jérôme "Lynix" Leclercq (lynix680@gmail.com)
// This file is part of the "Nazara Engine - Physics3D module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_PHYSICS3D_RIGIDBODY3D_HPP
#define NAZARA_PHYSICS3D_RIGIDBODY3D_HPP
#include <NazaraUtils/Prerequisites.hpp>
#include <Nazara/Core/Enums.hpp>
#include <Nazara/Math/Matrix4.hpp>
#include <Nazara/Math/Quaternion.hpp>
#include <Nazara/Math/Vector3.hpp>
#include <Nazara/Physics3D/Collider3D.hpp>
#include <Nazara/Physics3D/Config.hpp>
#include <NazaraUtils/MovablePtr.hpp>
class btRigidBody;
namespace Nz
{
class PhysWorld3D;
class NAZARA_PHYSICS3D_API RigidBody3D
{
public:
RigidBody3D(PhysWorld3D* world, const Matrix4f& mat = Matrix4f::Identity());
RigidBody3D(PhysWorld3D* world, std::shared_ptr<Collider3D> geom, const Matrix4f& mat = Matrix4f::Identity());
RigidBody3D(const RigidBody3D& object) = delete;
RigidBody3D(RigidBody3D&& object) noexcept;
~RigidBody3D();
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<Collider3D>& 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 PhysWorld3D* 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<Collider3D> 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 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();
RigidBody3D& operator=(const RigidBody3D& object) = delete;
RigidBody3D& operator=(RigidBody3D&& object) noexcept;
protected:
void Destroy();
private:
std::shared_ptr<Collider3D> m_geom;
std::size_t m_bodyPoolIndex;
btRigidBody* m_body;
PhysWorld3D* m_world;
};
}
#include <Nazara/Physics3D/RigidBody3D.inl>
#endif // NAZARA_PHYSICS3D_RIGIDBODY3D_HPP

View File

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

View File

@@ -1,34 +0,0 @@
// this file was automatically generated and should not be edited
/*
Nazara Engine - Physics3D module
Copyright (C) 2023 Jérôme "Lynix" 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_PHYSICS3D_SYSTEMS_HPP
#define NAZARA_PHYSICS3D_SYSTEMS_HPP
#include <Nazara/Physics3D/Systems/Physics3DSystem.hpp>
#endif // NAZARA_PHYSICS3D_SYSTEMS_HPP

View File

@@ -1,65 +0,0 @@
// Copyright (C) 2023 Jérôme "Lynix" Leclercq (lynix680@gmail.com)
// This file is part of the "Nazara Engine - Physics3D module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_PHYSICS3D_SYSTEMS_PHYSICS3DSYSTEM_HPP
#define NAZARA_PHYSICS3D_SYSTEMS_PHYSICS3DSYSTEM_HPP
#include <NazaraUtils/Prerequisites.hpp>
#include <Nazara/Core/Time.hpp>
#include <Nazara/Physics3D/PhysWorld3D.hpp>
#include <Nazara/Physics3D/Components/RigidBody3DComponent.hpp>
#include <NazaraUtils/TypeList.hpp>
#include <entt/entt.hpp>
#include <vector>
namespace Nz
{
class NAZARA_PHYSICS3D_API Physics3DSystem
{
public:
static constexpr Int64 ExecutionOrder = 0;
using Components = TypeList<RigidBody3DComponent, class NodeComponent>;
struct RaycastHit;
Physics3DSystem(entt::registry& registry);
Physics3DSystem(const Physics3DSystem&) = delete;
Physics3DSystem(Physics3DSystem&&) = delete;
~Physics3DSystem();
template<typename... Args> RigidBody3DComponent CreateRigidBody(Args&&... args);
inline PhysWorld3D& GetPhysWorld();
inline const PhysWorld3D& GetPhysWorld() const;
bool RaycastQueryFirst(const Vector3f& from, const Vector3f& to, RaycastHit* hitInfo = nullptr);
void Update(Time elapsedTime);
Physics3DSystem& operator=(const Physics3DSystem&) = delete;
Physics3DSystem& operator=(Physics3DSystem&&) = delete;
struct RaycastHit : PhysWorld3D::RaycastHit
{
entt::handle hitEntity;
};
private:
void OnConstruct(entt::registry& registry, entt::entity entity);
void OnDestruct(entt::registry& registry, entt::entity entity);
std::vector<entt::entity> m_physicsEntities;
entt::registry& m_registry;
entt::observer m_physicsConstructObserver;
entt::scoped_connection m_constructConnection;
entt::scoped_connection m_destructConnection;
PhysWorld3D m_physWorld;
};
}
#include <Nazara/Physics3D/Systems/Physics3DSystem.inl>
#endif // NAZARA_PHYSICS3D_SYSTEMS_PHYSICS3DSYSTEM_HPP

View File

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