Physics3D: Switch from Newton Dynamics to Bullet3
This commit is contained in:
committed by
Jérôme Leclercq
parent
ec1efb5e56
commit
795efae3a0
@@ -13,52 +13,27 @@
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
#include <Nazara/Physics3D/Config.hpp>
|
||||
#include <NazaraUtils/MovablePtr.hpp>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
class NewtonBody;
|
||||
class NewtonJoint;
|
||||
class NewtonMaterial;
|
||||
class NewtonWorld;
|
||||
class btDynamicsWorld;
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class RigidBody3D;
|
||||
|
||||
class NAZARA_PHYSICS3D_API PhysWorld3D
|
||||
{
|
||||
public:
|
||||
using BodyIterator = std::function<bool(RigidBody3D& body)>;
|
||||
using AABBOverlapCallback = std::function<bool(const RigidBody3D& firstBody, const RigidBody3D& secondBody)>;
|
||||
using CollisionCallback = std::function<bool(const RigidBody3D& firstBody, const RigidBody3D& secondBody)>;
|
||||
|
||||
PhysWorld3D();
|
||||
PhysWorld3D(const PhysWorld3D&) = delete;
|
||||
PhysWorld3D(PhysWorld3D&& ph) noexcept;
|
||||
~PhysWorld3D();
|
||||
|
||||
int CreateMaterial(std::string name = {});
|
||||
|
||||
void ForEachBodyInAABB(const Boxf& box, const BodyIterator& iterator);
|
||||
|
||||
btDynamicsWorld* GetDynamicsWorld();
|
||||
Vector3f GetGravity() const;
|
||||
NewtonWorld* GetHandle() const;
|
||||
int GetMaterial(const std::string& name);
|
||||
std::size_t GetMaxStepCount() const;
|
||||
Time GetStepSize() const;
|
||||
unsigned int GetThreadCount() const;
|
||||
|
||||
void SetGravity(const Vector3f& gravity);
|
||||
void SetMaxStepCount(std::size_t maxStepCount);
|
||||
void SetStepSize(Time stepSize);
|
||||
void SetThreadCount(unsigned int threadCount);
|
||||
|
||||
void SetMaterialCollisionCallback(int firstMaterial, int secondMaterial, AABBOverlapCallback aabbOverlapCallback, CollisionCallback collisionCallback);
|
||||
void SetMaterialDefaultCollidable(int firstMaterial, int secondMaterial, bool collidable);
|
||||
void SetMaterialDefaultElasticity(int firstMaterial, int secondMaterial, float elasticCoef);
|
||||
void SetMaterialDefaultFriction(int firstMaterial, int secondMaterial, float staticFriction, float kineticFriction);
|
||||
void SetMaterialDefaultSoftness(int firstMaterial, int secondMaterial, float softness);
|
||||
void SetMaterialSurfaceThickness(int firstMaterial, int secondMaterial, float thickness);
|
||||
|
||||
void Step(Time timestep);
|
||||
|
||||
@@ -66,19 +41,10 @@ namespace Nz
|
||||
PhysWorld3D& operator=(PhysWorld3D&&) noexcept;
|
||||
|
||||
private:
|
||||
struct Callback
|
||||
{
|
||||
AABBOverlapCallback aabbOverlapCallback;
|
||||
CollisionCallback collisionCallback;
|
||||
};
|
||||
struct BulletWorld;
|
||||
|
||||
static int OnAABBOverlap(const NewtonJoint* const contact, float timestep, int threadIndex);
|
||||
static void ProcessContact(const NewtonJoint* const contact, float timestep, int threadIndex);
|
||||
|
||||
std::unordered_map<Nz::UInt64, std::unique_ptr<Callback>> m_callbacks;
|
||||
std::unordered_map<std::string, int> m_materialIds;
|
||||
std::size_t m_maxStepCount;
|
||||
MovablePtr<NewtonWorld> m_world;
|
||||
std::unique_ptr<BulletWorld> m_world;
|
||||
Vector3f m_gravity;
|
||||
Time m_stepSize;
|
||||
Time m_timestepAccumulator;
|
||||
|
||||
Reference in New Issue
Block a user