Physics3D: Switch from Newton Dynamics to Bullet3
This commit is contained in:
committed by
Jérôme Leclercq
parent
ec1efb5e56
commit
795efae3a0
@@ -16,7 +16,7 @@
|
||||
#include <Nazara/Physics3D/Config.hpp>
|
||||
#include <NazaraUtils/MovablePtr.hpp>
|
||||
|
||||
class NewtonBody;
|
||||
class btRigidBody;
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
@@ -27,7 +27,7 @@ namespace Nz
|
||||
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);
|
||||
RigidBody3D(const RigidBody3D& object) = delete;
|
||||
RigidBody3D(RigidBody3D&& object) noexcept;
|
||||
~RigidBody3D();
|
||||
|
||||
@@ -35,64 +35,54 @@ namespace Nz
|
||||
void AddForce(const Vector3f& force, const Vector3f& point, CoordSys coordSys = CoordSys::Global);
|
||||
void AddTorque(const Vector3f& torque, CoordSys coordSys = CoordSys::Global);
|
||||
|
||||
void EnableAutoSleep(bool autoSleep);
|
||||
void EnableSimulation(bool simulation);
|
||||
inline void DisableSleeping();
|
||||
void EnableSleeping(bool enable);
|
||||
|
||||
void FallAsleep();
|
||||
|
||||
Boxf GetAABB() const;
|
||||
Vector3f GetAngularDamping() const;
|
||||
float GetAngularDamping() const;
|
||||
Vector3f GetAngularVelocity() const;
|
||||
const std::shared_ptr<Collider3D>& GetGeom() const;
|
||||
float GetGravityFactor() const;
|
||||
NewtonBody* GetHandle() const;
|
||||
float GetLinearDamping() const;
|
||||
Vector3f GetLinearVelocity() const;
|
||||
float GetMass() const;
|
||||
Vector3f GetMassCenter(CoordSys coordSys = CoordSys::Local) const;
|
||||
int GetMaterial() const;
|
||||
Matrix4f GetMatrix() const;
|
||||
Vector3f GetPosition() const;
|
||||
btRigidBody* GetRigidBody() const;
|
||||
Quaternionf GetRotation() const;
|
||||
void* GetUserdata() const;
|
||||
PhysWorld3D* GetWorld() const;
|
||||
|
||||
bool IsAutoSleepEnabled() const;
|
||||
bool IsMoveable() const;
|
||||
bool IsSimulationEnabled() const;
|
||||
bool IsSleeping() const;
|
||||
bool IsSleepingEnabled() const;
|
||||
|
||||
void SetAngularDamping(const Vector3f& angularDamping);
|
||||
void SetAngularDamping(float angularDamping);
|
||||
void SetAngularVelocity(const Vector3f& angularVelocity);
|
||||
void SetGeom(std::shared_ptr<Collider3D> geom);
|
||||
void SetGravityFactor(float gravityFactor);
|
||||
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 SetMaterial(const std::string& materialName);
|
||||
void SetMaterial(int materialIndex);
|
||||
void SetPosition(const Vector3f& position);
|
||||
void SetRotation(const Quaternionf& rotation);
|
||||
void SetUserdata(void* ud);
|
||||
|
||||
RigidBody3D& operator=(const RigidBody3D& object);
|
||||
void WakeUp();
|
||||
|
||||
RigidBody3D& operator=(const RigidBody3D& object) = delete;
|
||||
RigidBody3D& operator=(RigidBody3D&& object) noexcept;
|
||||
|
||||
protected:
|
||||
void Destroy();
|
||||
|
||||
private:
|
||||
void UpdateBody(const Matrix4f& transformMatrix);
|
||||
static void ForceAndTorqueCallback(const NewtonBody* body, float timeStep, int threadIndex);
|
||||
|
||||
std::shared_ptr<Collider3D> m_geom;
|
||||
MovablePtr<NewtonBody> m_body;
|
||||
Vector3f m_forceAccumulator;
|
||||
Vector3f m_torqueAccumulator;
|
||||
std::unique_ptr<btRigidBody> m_body;
|
||||
PhysWorld3D* m_world;
|
||||
void* m_userdata;
|
||||
float m_gravityFactor;
|
||||
float m_mass;
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Physics3D/RigidBody3D.inl>
|
||||
|
||||
#endif // NAZARA_PHYSICS3D_RIGIDBODY3D_HPP
|
||||
|
||||
Reference in New Issue
Block a user