Switch from Nz prefix to namespace Nz
What a huge commit Former-commit-id: 38ac5eebf70adc1180f571f6006192d28fb99897
This commit is contained in:
@@ -7,21 +7,21 @@
|
||||
#ifndef NAZARA_ENUMS_PHYSICS_HPP
|
||||
#define NAZARA_ENUMS_PHYSICS_HPP
|
||||
|
||||
enum nzGeomType
|
||||
enum GeomType
|
||||
{
|
||||
nzGeomType_Box,
|
||||
nzGeomType_Capsule,
|
||||
nzGeomType_Cone,
|
||||
nzGeomType_Compound,
|
||||
nzGeomType_ConvexHull,
|
||||
nzGeomType_Cylinder,
|
||||
nzGeomType_Heightfield,
|
||||
nzGeomType_Null,
|
||||
nzGeomType_Scene,
|
||||
nzGeomType_Sphere,
|
||||
nzGeomType_Tree,
|
||||
GeomType_Box,
|
||||
GeomType_Capsule,
|
||||
GeomType_Cone,
|
||||
GeomType_Compound,
|
||||
GeomType_ConvexHull,
|
||||
GeomType_Cylinder,
|
||||
GeomType_Heightfield,
|
||||
GeomType_Null,
|
||||
GeomType_Scene,
|
||||
GeomType_Sphere,
|
||||
GeomType_Tree,
|
||||
|
||||
nzGeomType_Max = nzGeomType_Tree
|
||||
GeomType_Max = GeomType_Tree
|
||||
};
|
||||
|
||||
#endif // NAZARA_ENUMS_PHYSICS_HPP
|
||||
|
||||
@@ -20,243 +20,247 @@
|
||||
#include <Nazara/Physics/Enums.hpp>
|
||||
#include <unordered_map>
|
||||
|
||||
///TODO: CollisionModifier
|
||||
///TODO: HeightfieldGeom
|
||||
///TODO: PlaneGeom ?
|
||||
///TODO: SceneGeom
|
||||
///TODO: TreeGeom
|
||||
|
||||
class NzPhysGeom;
|
||||
class NzPhysWorld;
|
||||
struct NewtonCollision;
|
||||
|
||||
using NzPhysGeomConstRef = NzObjectRef<const NzPhysGeom>;
|
||||
using NzPhysGeomLibrary = NzObjectLibrary<NzPhysGeom>;
|
||||
using NzPhysGeomRef = NzObjectRef<NzPhysGeom>;
|
||||
|
||||
class NAZARA_PHYSICS_API NzPhysGeom : public NzRefCounted
|
||||
namespace Nz
|
||||
{
|
||||
public:
|
||||
NzPhysGeom() = default;
|
||||
NzPhysGeom(const NzPhysGeom&) = delete;
|
||||
NzPhysGeom(NzPhysGeom&&) = delete;
|
||||
virtual ~NzPhysGeom();
|
||||
///TODO: CollisionModifier
|
||||
///TODO: HeightfieldGeom
|
||||
///TODO: PlaneGeom ?
|
||||
///TODO: SceneGeom
|
||||
///TODO: TreeGeom
|
||||
|
||||
NzBoxf ComputeAABB(const NzVector3f& translation, const NzQuaternionf& rotation, const NzVector3f& scale) const;
|
||||
virtual NzBoxf ComputeAABB(const NzMatrix4f& offsetMatrix = NzMatrix4f::Identity(), const NzVector3f& scale = NzVector3f::Unit()) const;
|
||||
virtual void ComputeInertialMatrix(NzVector3f* inertia, NzVector3f* center) const;
|
||||
virtual float ComputeVolume() const;
|
||||
class PhysGeom;
|
||||
class PhysWorld;
|
||||
|
||||
NewtonCollision* GetHandle(NzPhysWorld* world) const;
|
||||
virtual nzGeomType GetType() const = 0;
|
||||
using PhysGeomConstRef = ObjectRef<const PhysGeom>;
|
||||
using PhysGeomLibrary = ObjectLibrary<PhysGeom>;
|
||||
using PhysGeomRef = ObjectRef<PhysGeom>;
|
||||
|
||||
NzPhysGeom& operator=(const NzPhysGeom&) = delete;
|
||||
NzPhysGeom& operator=(NzPhysGeom&&) = delete;
|
||||
class NAZARA_PHYSICS_API PhysGeom : public RefCounted
|
||||
{
|
||||
public:
|
||||
PhysGeom() = default;
|
||||
PhysGeom(const PhysGeom&) = delete;
|
||||
PhysGeom(PhysGeom&&) = delete;
|
||||
virtual ~PhysGeom();
|
||||
|
||||
static NzPhysGeomRef Build(const NzPrimitiveList& list);
|
||||
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 ComputeInertialMatrix(Vector3f* inertia, Vector3f* center) const;
|
||||
virtual float ComputeVolume() const;
|
||||
|
||||
// Signals:
|
||||
NazaraSignal(OnPhysGeomRelease, const NzPhysGeom* /*physGeom*/);
|
||||
NewtonCollision* GetHandle(PhysWorld* world) const;
|
||||
virtual GeomType GetType() const = 0;
|
||||
|
||||
protected:
|
||||
virtual NewtonCollision* CreateHandle(NzPhysWorld* world) const = 0;
|
||||
PhysGeom& operator=(const PhysGeom&) = delete;
|
||||
PhysGeom& operator=(PhysGeom&&) = delete;
|
||||
|
||||
mutable std::unordered_map<NzPhysWorld*, NewtonCollision*> m_handles;
|
||||
static PhysGeomRef Build(const PrimitiveList& list);
|
||||
|
||||
static NzPhysGeomLibrary::LibraryMap s_library;
|
||||
};
|
||||
// Signals:
|
||||
NazaraSignal(OnPhysGeomRelease, const PhysGeom* /*physGeom*/);
|
||||
|
||||
class NzBoxGeom;
|
||||
protected:
|
||||
virtual NewtonCollision* CreateHandle(PhysWorld* world) const = 0;
|
||||
|
||||
using NzBoxGeomConstRef = NzObjectRef<const NzBoxGeom>;
|
||||
using NzBoxGeomRef = NzObjectRef<NzBoxGeom>;
|
||||
mutable std::unordered_map<PhysWorld*, NewtonCollision*> m_handles;
|
||||
|
||||
class NAZARA_PHYSICS_API NzBoxGeom : public NzPhysGeom
|
||||
{
|
||||
public:
|
||||
NzBoxGeom(const NzVector3f& lengths, const NzMatrix4f& transformMatrix = NzMatrix4f::Identity());
|
||||
NzBoxGeom(const NzVector3f& lengths, const NzVector3f& translation, const NzQuaternionf& rotation = NzQuaternionf::Identity());
|
||||
static PhysGeomLibrary::LibraryMap s_library;
|
||||
};
|
||||
|
||||
NzBoxf ComputeAABB(const NzMatrix4f& offsetMatrix = NzMatrix4f::Identity(), const NzVector3f& scale = NzVector3f::Unit()) const override;
|
||||
float ComputeVolume() const override;
|
||||
class BoxGeom;
|
||||
|
||||
NzVector3f GetLengths() const;
|
||||
nzGeomType GetType() const override;
|
||||
using BoxGeomConstRef = ObjectRef<const BoxGeom>;
|
||||
using BoxGeomRef = ObjectRef<BoxGeom>;
|
||||
|
||||
template<typename... Args> static NzBoxGeomRef New(Args&&... args);
|
||||
class NAZARA_PHYSICS_API BoxGeom : public PhysGeom
|
||||
{
|
||||
public:
|
||||
BoxGeom(const Vector3f& lengths, const Matrix4f& transformMatrix = Matrix4f::Identity());
|
||||
BoxGeom(const Vector3f& lengths, const Vector3f& translation, const Quaternionf& rotation = Quaternionf::Identity());
|
||||
|
||||
private:
|
||||
NewtonCollision* CreateHandle(NzPhysWorld* world) const override;
|
||||
Boxf ComputeAABB(const Matrix4f& offsetMatrix = Matrix4f::Identity(), const Vector3f& scale = Vector3f::Unit()) const override;
|
||||
float ComputeVolume() const override;
|
||||
|
||||
NzMatrix4f m_matrix;
|
||||
NzVector3f m_lengths;
|
||||
};
|
||||
Vector3f GetLengths() const;
|
||||
GeomType GetType() const override;
|
||||
|
||||
class NzCapsuleGeom;
|
||||
template<typename... Args> static BoxGeomRef New(Args&&... args);
|
||||
|
||||
using NzCapsuleGeomConstRef = NzObjectRef<const NzCapsuleGeom>;
|
||||
using NzCapsuleGeomRef = NzObjectRef<NzCapsuleGeom>;
|
||||
private:
|
||||
NewtonCollision* CreateHandle(PhysWorld* world) const override;
|
||||
|
||||
class NAZARA_PHYSICS_API NzCapsuleGeom : public NzPhysGeom
|
||||
{
|
||||
public:
|
||||
NzCapsuleGeom(float length, float radius, const NzMatrix4f& transformMatrix = NzMatrix4f::Identity());
|
||||
NzCapsuleGeom(float length, float radius, const NzVector3f& translation, const NzQuaternionf& rotation = NzQuaternionf::Identity());
|
||||
Matrix4f m_matrix;
|
||||
Vector3f m_lengths;
|
||||
};
|
||||
|
||||
float GetLength() const;
|
||||
float GetRadius() const;
|
||||
nzGeomType GetType() const override;
|
||||
class CapsuleGeom;
|
||||
|
||||
template<typename... Args> static NzCapsuleGeomRef New(Args&&... args);
|
||||
using CapsuleGeomConstRef = ObjectRef<const CapsuleGeom>;
|
||||
using CapsuleGeomRef = ObjectRef<CapsuleGeom>;
|
||||
|
||||
private:
|
||||
NewtonCollision* CreateHandle(NzPhysWorld* world) const override;
|
||||
class NAZARA_PHYSICS_API CapsuleGeom : public PhysGeom
|
||||
{
|
||||
public:
|
||||
CapsuleGeom(float length, float radius, const Matrix4f& transformMatrix = Matrix4f::Identity());
|
||||
CapsuleGeom(float length, float radius, const Vector3f& translation, const Quaternionf& rotation = Quaternionf::Identity());
|
||||
|
||||
NzMatrix4f m_matrix;
|
||||
float m_length;
|
||||
float m_radius;
|
||||
};
|
||||
float GetLength() const;
|
||||
float GetRadius() const;
|
||||
GeomType GetType() const override;
|
||||
|
||||
class NzCompoundGeom;
|
||||
template<typename... Args> static CapsuleGeomRef New(Args&&... args);
|
||||
|
||||
using NzCompoundGeomConstRef = NzObjectRef<const NzCompoundGeom>;
|
||||
using NzCompoundGeomRef = NzObjectRef<NzCompoundGeom>;
|
||||
private:
|
||||
NewtonCollision* CreateHandle(PhysWorld* world) const override;
|
||||
|
||||
class NAZARA_PHYSICS_API NzCompoundGeom : public NzPhysGeom
|
||||
{
|
||||
public:
|
||||
NzCompoundGeom(NzPhysGeom** geoms, unsigned int geomCount);
|
||||
Matrix4f m_matrix;
|
||||
float m_length;
|
||||
float m_radius;
|
||||
};
|
||||
|
||||
const std::vector<NzPhysGeomRef>& GetGeoms() const;
|
||||
nzGeomType GetType() const override;
|
||||
class CompoundGeom;
|
||||
|
||||
template<typename... Args> static NzCompoundGeomRef New(Args&&... args);
|
||||
using CompoundGeomConstRef = ObjectRef<const CompoundGeom>;
|
||||
using CompoundGeomRef = ObjectRef<CompoundGeom>;
|
||||
|
||||
private:
|
||||
NewtonCollision* CreateHandle(NzPhysWorld* world) const override;
|
||||
class NAZARA_PHYSICS_API CompoundGeom : public PhysGeom
|
||||
{
|
||||
public:
|
||||
CompoundGeom(PhysGeom** geoms, unsigned int geomCount);
|
||||
|
||||
std::vector<NzPhysGeomRef> m_geoms;
|
||||
};
|
||||
const std::vector<PhysGeomRef>& GetGeoms() const;
|
||||
GeomType GetType() const override;
|
||||
|
||||
class NzConeGeom;
|
||||
template<typename... Args> static CompoundGeomRef New(Args&&... args);
|
||||
|
||||
using NzConeGeomConstRef = NzObjectRef<const NzConeGeom>;
|
||||
using NzConeGeomRef = NzObjectRef<NzConeGeom>;
|
||||
private:
|
||||
NewtonCollision* CreateHandle(PhysWorld* world) const override;
|
||||
|
||||
class NAZARA_PHYSICS_API NzConeGeom : public NzPhysGeom
|
||||
{
|
||||
public:
|
||||
NzConeGeom(float length, float radius, const NzMatrix4f& transformMatrix = NzMatrix4f::Identity());
|
||||
NzConeGeom(float length, float radius, const NzVector3f& translation, const NzQuaternionf& rotation = NzQuaternionf::Identity());
|
||||
std::vector<PhysGeomRef> m_geoms;
|
||||
};
|
||||
|
||||
float GetLength() const;
|
||||
float GetRadius() const;
|
||||
nzGeomType GetType() const override;
|
||||
class ConeGeom;
|
||||
|
||||
template<typename... Args> static NzConeGeomRef New(Args&&... args);
|
||||
using ConeGeomConstRef = ObjectRef<const ConeGeom>;
|
||||
using ConeGeomRef = ObjectRef<ConeGeom>;
|
||||
|
||||
private:
|
||||
NewtonCollision* CreateHandle(NzPhysWorld* world) const override;
|
||||
class NAZARA_PHYSICS_API ConeGeom : public PhysGeom
|
||||
{
|
||||
public:
|
||||
ConeGeom(float length, float radius, const Matrix4f& transformMatrix = Matrix4f::Identity());
|
||||
ConeGeom(float length, float radius, const Vector3f& translation, const Quaternionf& rotation = Quaternionf::Identity());
|
||||
|
||||
NzMatrix4f m_matrix;
|
||||
float m_length;
|
||||
float m_radius;
|
||||
};
|
||||
float GetLength() const;
|
||||
float GetRadius() const;
|
||||
GeomType GetType() const override;
|
||||
|
||||
class NzConvexHullGeom;
|
||||
template<typename... Args> static ConeGeomRef New(Args&&... args);
|
||||
|
||||
using NzConvexHullGeomConstRef = NzObjectRef<const NzConvexHullGeom>;
|
||||
using NzConvexHullGeomRef = NzObjectRef<NzConvexHullGeom>;
|
||||
private:
|
||||
NewtonCollision* CreateHandle(PhysWorld* world) const override;
|
||||
|
||||
class NAZARA_PHYSICS_API NzConvexHullGeom : public NzPhysGeom
|
||||
{
|
||||
public:
|
||||
NzConvexHullGeom(const void* vertices, unsigned int vertexCount, unsigned int stride = sizeof(NzVector3f), float tolerance = 0.002f, const NzMatrix4f& transformMatrix = NzMatrix4f::Identity());
|
||||
NzConvexHullGeom(const void* vertices, unsigned int vertexCount, unsigned int stride, float tolerance, const NzVector3f& translation, const NzQuaternionf& rotation = NzQuaternionf::Identity());
|
||||
Matrix4f m_matrix;
|
||||
float m_length;
|
||||
float m_radius;
|
||||
};
|
||||
|
||||
nzGeomType GetType() const override;
|
||||
class ConvexHullGeom;
|
||||
|
||||
template<typename... Args> static NzConvexHullGeomRef New(Args&&... args);
|
||||
using ConvexHullGeomConstRef = ObjectRef<const ConvexHullGeom>;
|
||||
using ConvexHullGeomRef = ObjectRef<ConvexHullGeom>;
|
||||
|
||||
private:
|
||||
NewtonCollision* CreateHandle(NzPhysWorld* world) const override;
|
||||
class NAZARA_PHYSICS_API ConvexHullGeom : public PhysGeom
|
||||
{
|
||||
public:
|
||||
ConvexHullGeom(const void* vertices, unsigned int vertexCount, unsigned int stride = sizeof(Vector3f), float tolerance = 0.002f, const Matrix4f& transformMatrix = Matrix4f::Identity());
|
||||
ConvexHullGeom(const void* vertices, unsigned int vertexCount, unsigned int stride, float tolerance, const Vector3f& translation, const Quaternionf& rotation = Quaternionf::Identity());
|
||||
|
||||
std::vector<NzVector3f> m_vertices;
|
||||
NzMatrix4f m_matrix;
|
||||
float m_tolerance;
|
||||
unsigned int m_vertexStride;
|
||||
};
|
||||
GeomType GetType() const override;
|
||||
|
||||
class NzCylinderGeom;
|
||||
template<typename... Args> static ConvexHullGeomRef New(Args&&... args);
|
||||
|
||||
using NzCylinderGeomConstRef = NzObjectRef<const NzCylinderGeom>;
|
||||
using NzCylinderGeomRef = NzObjectRef<NzCylinderGeom>;
|
||||
private:
|
||||
NewtonCollision* CreateHandle(PhysWorld* world) const override;
|
||||
|
||||
class NAZARA_PHYSICS_API NzCylinderGeom : public NzPhysGeom
|
||||
{
|
||||
public:
|
||||
NzCylinderGeom(float length, float radius, const NzMatrix4f& transformMatrix = NzMatrix4f::Identity());
|
||||
NzCylinderGeom(float length, float radius, const NzVector3f& translation, const NzQuaternionf& rotation = NzQuaternionf::Identity());
|
||||
std::vector<Vector3f> m_vertices;
|
||||
Matrix4f m_matrix;
|
||||
float m_tolerance;
|
||||
unsigned int m_vertexStride;
|
||||
};
|
||||
|
||||
float GetLength() const;
|
||||
float GetRadius() const;
|
||||
nzGeomType GetType() const override;
|
||||
class NzCylinderGeom;
|
||||
|
||||
template<typename... Args> static NzCylinderGeomRef New(Args&&... args);
|
||||
using NzCylinderGeomConstRef = ObjectRef<const NzCylinderGeom>;
|
||||
using NzCylinderGeomRef = ObjectRef<NzCylinderGeom>;
|
||||
|
||||
private:
|
||||
NewtonCollision* CreateHandle(NzPhysWorld* world) const override;
|
||||
class NAZARA_PHYSICS_API NzCylinderGeom : public PhysGeom
|
||||
{
|
||||
public:
|
||||
NzCylinderGeom(float length, float radius, const Matrix4f& transformMatrix = Matrix4f::Identity());
|
||||
NzCylinderGeom(float length, float radius, const Vector3f& translation, const Quaternionf& rotation = Quaternionf::Identity());
|
||||
|
||||
NzMatrix4f m_matrix;
|
||||
float m_length;
|
||||
float m_radius;
|
||||
};
|
||||
float GetLength() const;
|
||||
float GetRadius() const;
|
||||
GeomType GetType() const override;
|
||||
|
||||
class NzNullGeom;
|
||||
template<typename... Args> static NzCylinderGeomRef New(Args&&... args);
|
||||
|
||||
using NzNullGeomConstRef = NzObjectRef<const NzNullGeom>;
|
||||
using NzNullGeomRef = NzObjectRef<NzNullGeom>;
|
||||
private:
|
||||
NewtonCollision* CreateHandle(PhysWorld* world) const override;
|
||||
|
||||
class NAZARA_PHYSICS_API NzNullGeom : public NzPhysGeom
|
||||
{
|
||||
public:
|
||||
NzNullGeom();
|
||||
Matrix4f m_matrix;
|
||||
float m_length;
|
||||
float m_radius;
|
||||
};
|
||||
|
||||
void ComputeInertialMatrix(NzVector3f* inertia, NzVector3f* center) const;
|
||||
class NullGeom;
|
||||
|
||||
nzGeomType GetType() const override;
|
||||
using NullGeomConstRef = ObjectRef<const NullGeom>;
|
||||
using NullGeomRef = ObjectRef<NullGeom>;
|
||||
|
||||
template<typename... Args> static NzNullGeomRef New(Args&&... args);
|
||||
class NAZARA_PHYSICS_API NullGeom : public PhysGeom
|
||||
{
|
||||
public:
|
||||
NullGeom();
|
||||
|
||||
private:
|
||||
NewtonCollision* CreateHandle(NzPhysWorld* world) const override;
|
||||
};
|
||||
void ComputeInertialMatrix(Vector3f* inertia, Vector3f* center) const;
|
||||
|
||||
class NzSphereGeom;
|
||||
GeomType GetType() const override;
|
||||
|
||||
using NzSphereGeomConstRef = NzObjectRef<const NzSphereGeom>;
|
||||
using NzSphereGeomRef = NzObjectRef<NzSphereGeom>;
|
||||
template<typename... Args> static NullGeomRef New(Args&&... args);
|
||||
|
||||
class NAZARA_PHYSICS_API NzSphereGeom : public NzPhysGeom
|
||||
{
|
||||
public:
|
||||
NzSphereGeom(float radius, const NzMatrix4f& transformMatrix = NzMatrix4f::Identity());
|
||||
NzSphereGeom(float radius, const NzVector3f& translation, const NzQuaternionf& rotation = NzQuaternionf::Identity());
|
||||
private:
|
||||
NewtonCollision* CreateHandle(PhysWorld* world) const override;
|
||||
};
|
||||
|
||||
NzBoxf ComputeAABB(const NzMatrix4f& offsetMatrix = NzMatrix4f::Identity(), const NzVector3f& scale = NzVector3f::Unit()) const override;
|
||||
float ComputeVolume() const override;
|
||||
class SphereGeom;
|
||||
|
||||
float GetRadius() const;
|
||||
nzGeomType GetType() const override;
|
||||
using SphereGeomConstRef = ObjectRef<const SphereGeom>;
|
||||
using SphereGeomRef = ObjectRef<SphereGeom>;
|
||||
|
||||
template<typename... Args> static NzSphereGeomRef New(Args&&... args);
|
||||
class NAZARA_PHYSICS_API SphereGeom : public PhysGeom
|
||||
{
|
||||
public:
|
||||
SphereGeom(float radius, const Matrix4f& transformMatrix = Matrix4f::Identity());
|
||||
SphereGeom(float radius, const Vector3f& translation, const Quaternionf& rotation = Quaternionf::Identity());
|
||||
|
||||
private:
|
||||
NewtonCollision* CreateHandle(NzPhysWorld* world) const override;
|
||||
Boxf ComputeAABB(const Matrix4f& offsetMatrix = Matrix4f::Identity(), const Vector3f& scale = Vector3f::Unit()) const override;
|
||||
float ComputeVolume() const override;
|
||||
|
||||
NzVector3f m_position;
|
||||
float m_radius;
|
||||
};
|
||||
float GetRadius() const;
|
||||
GeomType GetType() const override;
|
||||
|
||||
template<typename... Args> static SphereGeomRef New(Args&&... args);
|
||||
|
||||
private:
|
||||
NewtonCollision* CreateHandle(PhysWorld* world) const override;
|
||||
|
||||
Vector3f m_position;
|
||||
float m_radius;
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Physics/Geom.inl>
|
||||
|
||||
|
||||
@@ -5,76 +5,79 @@
|
||||
#include <memory>
|
||||
#include <Nazara/Physics/Debug.hpp>
|
||||
|
||||
template<typename... Args>
|
||||
NzBoxGeomRef NzBoxGeom::New(Args&&... args)
|
||||
namespace Nz
|
||||
{
|
||||
std::unique_ptr<NzBoxGeom> object(new NzBoxGeom(std::forward<Args>(args)...));
|
||||
object->SetPersistent(false);
|
||||
template<typename... Args>
|
||||
BoxGeomRef BoxGeom::New(Args&&... args)
|
||||
{
|
||||
std::unique_ptr<BoxGeom> object(new BoxGeom(std::forward<Args>(args)...));
|
||||
object->SetPersistent(false);
|
||||
|
||||
return object.release();
|
||||
}
|
||||
return object.release();
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
NzCapsuleGeomRef NzCapsuleGeom::New(Args&&... args)
|
||||
{
|
||||
std::unique_ptr<NzCapsuleGeom> object(new NzCapsuleGeom(std::forward<Args>(args)...));
|
||||
object->SetPersistent(false);
|
||||
template<typename... Args>
|
||||
CapsuleGeomRef CapsuleGeom::New(Args&&... args)
|
||||
{
|
||||
std::unique_ptr<CapsuleGeom> object(new CapsuleGeom(std::forward<Args>(args)...));
|
||||
object->SetPersistent(false);
|
||||
|
||||
return object.release();
|
||||
}
|
||||
return object.release();
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
NzCompoundGeomRef NzCompoundGeom::New(Args&&... args)
|
||||
{
|
||||
std::unique_ptr<NzCompoundGeom> object(new NzCompoundGeom(std::forward<Args>(args)...));
|
||||
object->SetPersistent(false);
|
||||
template<typename... Args>
|
||||
CompoundGeomRef CompoundGeom::New(Args&&... args)
|
||||
{
|
||||
std::unique_ptr<CompoundGeom> object(new CompoundGeom(std::forward<Args>(args)...));
|
||||
object->SetPersistent(false);
|
||||
|
||||
return object.release();
|
||||
}
|
||||
return object.release();
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
NzConeGeomRef NzConeGeom::New(Args&&... args)
|
||||
{
|
||||
std::unique_ptr<NzConeGeom> object(new NzConeGeom(std::forward<Args>(args)...));
|
||||
object->SetPersistent(false);
|
||||
template<typename... Args>
|
||||
ConeGeomRef ConeGeom::New(Args&&... args)
|
||||
{
|
||||
std::unique_ptr<ConeGeom> object(new ConeGeom(std::forward<Args>(args)...));
|
||||
object->SetPersistent(false);
|
||||
|
||||
return object.release();
|
||||
}
|
||||
return object.release();
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
NzConvexHullGeomRef NzConvexHullGeom::New(Args&&... args)
|
||||
{
|
||||
std::unique_ptr<NzConvexHullGeom> object(new NzConvexHullGeom(std::forward<Args>(args)...));
|
||||
object->SetPersistent(false);
|
||||
template<typename... Args>
|
||||
ConvexHullGeomRef ConvexHullGeom::New(Args&&... args)
|
||||
{
|
||||
std::unique_ptr<ConvexHullGeom> object(new ConvexHullGeom(std::forward<Args>(args)...));
|
||||
object->SetPersistent(false);
|
||||
|
||||
return object.release();
|
||||
}
|
||||
return object.release();
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
NzCylinderGeomRef NzCylinderGeom::New(Args&&... args)
|
||||
{
|
||||
std::unique_ptr<NzCylinderGeom> object(new NzCylinderGeom(std::forward<Args>(args)...));
|
||||
object->SetPersistent(false);
|
||||
template<typename... Args>
|
||||
NzCylinderGeomRef NzCylinderGeom::New(Args&&... args)
|
||||
{
|
||||
std::unique_ptr<NzCylinderGeom> object(new NzCylinderGeom(std::forward<Args>(args)...));
|
||||
object->SetPersistent(false);
|
||||
|
||||
return object.release();
|
||||
}
|
||||
return object.release();
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
NzNullGeomRef NzNullGeom::New(Args&&... args)
|
||||
{
|
||||
std::unique_ptr<NzNullGeom> object(new NzNullGeom(std::forward<Args>(args)...));
|
||||
object->SetPersistent(false);
|
||||
template<typename... Args>
|
||||
NullGeomRef NullGeom::New(Args&&... args)
|
||||
{
|
||||
std::unique_ptr<NullGeom> object(new NullGeom(std::forward<Args>(args)...));
|
||||
object->SetPersistent(false);
|
||||
|
||||
return object.release();
|
||||
}
|
||||
return object.release();
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
NzSphereGeomRef NzSphereGeom::New(Args&&... args)
|
||||
{
|
||||
std::unique_ptr<NzSphereGeom> object(new NzSphereGeom(std::forward<Args>(args)...));
|
||||
object->SetPersistent(false);
|
||||
template<typename... Args>
|
||||
SphereGeomRef SphereGeom::New(Args&&... args)
|
||||
{
|
||||
std::unique_ptr<SphereGeom> object(new SphereGeom(std::forward<Args>(args)...));
|
||||
object->SetPersistent(false);
|
||||
|
||||
return object.release();
|
||||
return object.release();
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Physics/DebugOff.hpp>
|
||||
|
||||
@@ -15,65 +15,69 @@
|
||||
#include <Nazara/Physics/Config.hpp>
|
||||
#include <Nazara/Physics/Geom.hpp>
|
||||
|
||||
class NzPhysWorld;
|
||||
struct NewtonBody;
|
||||
|
||||
class NAZARA_PHYSICS_API NzPhysObject
|
||||
namespace Nz
|
||||
{
|
||||
public:
|
||||
NzPhysObject(NzPhysWorld* world, const NzMatrix4f& mat = NzMatrix4f::Identity());
|
||||
NzPhysObject(NzPhysWorld* world, NzPhysGeomRef geom, const NzMatrix4f& mat = NzMatrix4f::Identity());
|
||||
NzPhysObject(const NzPhysObject& object);
|
||||
NzPhysObject(NzPhysObject&& object);
|
||||
~NzPhysObject();
|
||||
class PhysWorld;
|
||||
|
||||
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);
|
||||
class NAZARA_PHYSICS_API PhysObject
|
||||
{
|
||||
public:
|
||||
PhysObject(PhysWorld* world, const Matrix4f& mat = Matrix4f::Identity());
|
||||
PhysObject(PhysWorld* world, PhysGeomRef geom, const Matrix4f& mat = Matrix4f::Identity());
|
||||
PhysObject(const PhysObject& object);
|
||||
PhysObject(PhysObject&& object);
|
||||
~PhysObject();
|
||||
|
||||
void EnableAutoSleep(bool autoSleep);
|
||||
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);
|
||||
|
||||
NzBoxf GetAABB() const;
|
||||
NzVector3f GetAngularVelocity() const;
|
||||
const NzPhysGeomRef& GetGeom() const;
|
||||
float GetGravityFactor() const;
|
||||
NewtonBody* GetHandle() const;
|
||||
float GetMass() const;
|
||||
NzVector3f GetMassCenter(nzCoordSys coordSys = nzCoordSys_Local) const;
|
||||
const NzMatrix4f& GetMatrix() const;
|
||||
NzVector3f GetPosition() const;
|
||||
NzQuaternionf GetRotation() const;
|
||||
NzVector3f GetVelocity() const;
|
||||
void EnableAutoSleep(bool autoSleep);
|
||||
|
||||
bool IsAutoSleepEnabled() const;
|
||||
bool IsMoveable() const;
|
||||
bool IsSleeping() const;
|
||||
Boxf GetAABB() const;
|
||||
Vector3f GetAngularVelocity() const;
|
||||
const PhysGeomRef& GetGeom() const;
|
||||
float GetGravityFactor() const;
|
||||
NewtonBody* GetHandle() const;
|
||||
float GetMass() const;
|
||||
Vector3f GetMassCenter(CoordSys coordSys = CoordSys_Local) const;
|
||||
const Matrix4f& GetMatrix() const;
|
||||
Vector3f GetPosition() const;
|
||||
Quaternionf GetRotation() const;
|
||||
Vector3f GetVelocity() const;
|
||||
|
||||
void SetAngularVelocity(const NzVector3f& angularVelocity);
|
||||
void SetGeom(NzPhysGeomRef geom);
|
||||
void SetGravityFactor(float gravityFactor);
|
||||
void SetMass(float mass);
|
||||
void SetMassCenter(const NzVector3f& center);
|
||||
void SetPosition(const NzVector3f& position);
|
||||
void SetRotation(const NzQuaternionf& rotation);
|
||||
void SetVelocity(const NzVector3f& velocity);
|
||||
bool IsAutoSleepEnabled() const;
|
||||
bool IsMoveable() const;
|
||||
bool IsSleeping() const;
|
||||
|
||||
NzPhysObject& operator=(const NzPhysObject& object);
|
||||
NzPhysObject& operator=(NzPhysObject&& object);
|
||||
void SetAngularVelocity(const Vector3f& angularVelocity);
|
||||
void SetGeom(PhysGeomRef geom);
|
||||
void SetGravityFactor(float gravityFactor);
|
||||
void SetMass(float mass);
|
||||
void SetMassCenter(const Vector3f& center);
|
||||
void SetPosition(const Vector3f& position);
|
||||
void SetRotation(const Quaternionf& rotation);
|
||||
void SetVelocity(const Vector3f& velocity);
|
||||
|
||||
private:
|
||||
void UpdateBody();
|
||||
static void ForceAndTorqueCallback(const NewtonBody* body, float timeStep, int threadIndex);
|
||||
static void TransformCallback(const NewtonBody* body, const float* matrix, int threadIndex);
|
||||
PhysObject& operator=(const PhysObject& object);
|
||||
PhysObject& operator=(PhysObject&& object);
|
||||
|
||||
NzMatrix4f m_matrix;
|
||||
NzPhysGeomRef m_geom;
|
||||
NzVector3f m_forceAccumulator;
|
||||
NzVector3f m_torqueAccumulator;
|
||||
NewtonBody* m_body;
|
||||
NzPhysWorld* m_world;
|
||||
float m_gravityFactor;
|
||||
float m_mass;
|
||||
};
|
||||
private:
|
||||
void UpdateBody();
|
||||
static void ForceAndTorqueCallback(const NewtonBody* body, float timeStep, int threadIndex);
|
||||
static void TransformCallback(const NewtonBody* body, const float* matrix, int threadIndex);
|
||||
|
||||
Matrix4f m_matrix;
|
||||
PhysGeomRef m_geom;
|
||||
Vector3f m_forceAccumulator;
|
||||
Vector3f m_torqueAccumulator;
|
||||
NewtonBody* m_body;
|
||||
PhysWorld* m_world;
|
||||
float m_gravityFactor;
|
||||
float m_mass;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_PHYSOBJECT_HPP
|
||||
|
||||
@@ -14,32 +14,35 @@
|
||||
|
||||
struct NewtonWorld;
|
||||
|
||||
class NAZARA_PHYSICS_API NzPhysWorld
|
||||
namespace Nz
|
||||
{
|
||||
public:
|
||||
NzPhysWorld();
|
||||
NzPhysWorld(const NzPhysWorld&) = delete;
|
||||
NzPhysWorld(NzPhysWorld&&) = delete; ///TODO
|
||||
~NzPhysWorld();
|
||||
class NAZARA_PHYSICS_API PhysWorld
|
||||
{
|
||||
public:
|
||||
PhysWorld();
|
||||
PhysWorld(const PhysWorld&) = delete;
|
||||
PhysWorld(PhysWorld&&) = delete; ///TODO
|
||||
~PhysWorld();
|
||||
|
||||
NzVector3f GetGravity() const;
|
||||
NewtonWorld* GetHandle() const;
|
||||
float GetStepSize() const;
|
||||
Vector3f GetGravity() const;
|
||||
NewtonWorld* GetHandle() const;
|
||||
float GetStepSize() const;
|
||||
|
||||
void SetGravity(const NzVector3f& gravity);
|
||||
void SetSolverModel(unsigned int model);
|
||||
void SetStepSize(float stepSize);
|
||||
void SetGravity(const Vector3f& gravity);
|
||||
void SetSolverModel(unsigned int model);
|
||||
void SetStepSize(float stepSize);
|
||||
|
||||
void Step(float timestep);
|
||||
void Step(float timestep);
|
||||
|
||||
NzPhysWorld& operator=(const NzPhysWorld&) = delete;
|
||||
NzPhysWorld& operator=(NzPhysWorld&&) = delete; ///TODO
|
||||
PhysWorld& operator=(const PhysWorld&) = delete;
|
||||
PhysWorld& operator=(PhysWorld&&) = delete; ///TODO
|
||||
|
||||
private:
|
||||
NzVector3f m_gravity;
|
||||
NewtonWorld* m_world;
|
||||
float m_stepSize;
|
||||
float m_timestepAccumulator;
|
||||
};
|
||||
private:
|
||||
Vector3f m_gravity;
|
||||
NewtonWorld* m_world;
|
||||
float m_stepSize;
|
||||
float m_timestepAccumulator;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_PHYSWORLD_HPP
|
||||
|
||||
@@ -11,22 +11,25 @@
|
||||
#include <Nazara/Core/Initializer.hpp>
|
||||
#include <Nazara/Physics/Config.hpp>
|
||||
|
||||
class NAZARA_PHYSICS_API NzPhysics
|
||||
namespace Nz
|
||||
{
|
||||
public:
|
||||
NzPhysics() = delete;
|
||||
~NzPhysics() = delete;
|
||||
class NAZARA_PHYSICS_API Physics
|
||||
{
|
||||
public:
|
||||
Physics() = delete;
|
||||
~Physics() = delete;
|
||||
|
||||
static unsigned int GetMemoryUsed();
|
||||
static unsigned int GetMemoryUsed();
|
||||
|
||||
static bool Initialize();
|
||||
static bool Initialize();
|
||||
|
||||
static bool IsInitialized();
|
||||
static bool IsInitialized();
|
||||
|
||||
static void Uninitialize();
|
||||
static void Uninitialize();
|
||||
|
||||
private:
|
||||
static unsigned int s_moduleReferenceCounter;
|
||||
};
|
||||
private:
|
||||
static unsigned int s_moduleReferenceCounter;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_PHYSICS_HPP
|
||||
|
||||
Reference in New Issue
Block a user