Updated physics module (Still experimental)

Former-commit-id: 4852b7cf6eca5ba3177397586877fe3d3c39dbd9
This commit is contained in:
Lynix
2013-06-24 13:33:54 +02:00
parent 050f9c2eb7
commit 0e3a4fa90b
6 changed files with 296 additions and 74 deletions

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2013 Jérôme Leclercq
// Copyright (C) 2013 Jérôme Leclercq
// This file is part of the "Nazara Engine - Physics module"
// For conditions of distribution and use, see copyright notice in Config.hpp
@@ -8,6 +8,7 @@
#define NAZARA_PHYSOBJECT_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/Enums.hpp>
#include <Nazara/Core/NonCopyable.hpp>
#include <Nazara/Math/Matrix4.hpp>
#include <Nazara/Math/Quaternion.hpp>
@@ -24,24 +25,40 @@ class NAZARA_API NzPhysObject : NzNonCopyable
NzPhysObject(NzPhysWorld* world, const NzBaseGeom* geom, const NzMatrix4f& mat = NzMatrix4f::Identity());
~NzPhysObject();
void AddForce(const NzVector3f& force, nzCoordSys coordSys = nzCoordSys_Global);
void AddForce(const NzVector3f& force, const NzVector3f& point, nzCoordSys coordSys = nzCoordSys_Global);
void AddTorque(const NzVector3f& torque, nzCoordSys coordSys = nzCoordSys_Global);
void EnableAutoSleep(bool autoSleep);
NzVector3f GetAngularVelocity() const;
float GetGravityFactor() const;
NewtonBody* GetHandle() const;
float GetMass() const;
NzVector3f GetMassCenter() const;
NzVector3f GetMassCenter(nzCoordSys coordSys = nzCoordSys_Local) const;
const NzMatrix4f& GetMatrix() const;
NzVector3f GetPosition() const;
NzQuaternionf GetRotation() const;
NzVector3f GetVelocity() const;
bool IsAutoSleepEnabled() const;
bool IsMoveable() const;
bool IsSleeping() const;
void SetGravityFactor(float gravityFactor);
void SetMass(float mass);
void SetMassCenter(NzVector3f center);
void SetMassCenter(const NzVector3f& center);
void SetPosition(const NzVector3f& position);
void SetRotation(const NzQuaternionf& rotation);
private:
void UpdateBody();
static void ForceAndTorqueCallback(const NewtonBody* body, float timeStep, int threadIndex);
static void TransformCallback(const NewtonBody* body, const float* matrix, int threadIndex);
NzMatrix4f m_matrix;
NzVector3f m_forceAccumulator;
NzVector3f m_torqueAccumulator;
NewtonBody* m_body;
const NzBaseGeom* m_geom;
NzPhysWorld* m_world;