Physics/Geom: Improved Geom class
Renamed BaseGeom to PhysGeom, made it a reference-counted class Former-commit-id: 5b3a2921addb537c2744346edc9c74eafb3260b0
This commit is contained in:
@@ -8,8 +8,12 @@
|
||||
#define NAZARA_GEOM_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/PrimitiveList.hpp>
|
||||
#include <Nazara/Core/NonCopyable.hpp>
|
||||
#include <Nazara/Core/PrimitiveList.hpp>
|
||||
#include <Nazara/Core/ObjectLibrary.hpp>
|
||||
#include <Nazara/Core/ObjectListenerWrapper.hpp>
|
||||
#include <Nazara/Core/ObjectRef.hpp>
|
||||
#include <Nazara/Core/RefCounted.hpp>
|
||||
#include <Nazara/Math/Box.hpp>
|
||||
#include <Nazara/Math/Quaternion.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
@@ -21,14 +25,21 @@
|
||||
///TODO: SceneGeom
|
||||
///TODO: TreeGeom
|
||||
|
||||
class NzPhysGeom;
|
||||
class NzPhysWorld;
|
||||
struct NewtonCollision;
|
||||
|
||||
class NAZARA_API NzBaseGeom : NzNonCopyable
|
||||
using NzPhysGeomConstListener = NzObjectListenerWrapper<const NzPhysGeom>;
|
||||
using NzPhysGeomConstRef = NzObjectRef<const NzPhysGeom>;
|
||||
using NzPhysGeomLibrary = NzObjectLibrary<NzPhysGeom>;
|
||||
using NzPhysGeomListener = NzObjectListenerWrapper<NzPhysGeom>;
|
||||
using NzPhysGeomRef = NzObjectRef<NzPhysGeom>;
|
||||
|
||||
class NAZARA_API NzPhysGeom : public NzRefCounted, NzNonCopyable
|
||||
{
|
||||
public:
|
||||
NzBaseGeom(NzPhysWorld* physWorld);
|
||||
virtual ~NzBaseGeom();
|
||||
NzPhysGeom(NzPhysWorld* physWorld);
|
||||
virtual ~NzPhysGeom();
|
||||
|
||||
virtual NzBoxf ComputeAABB(const NzVector3f& translation, const NzQuaternionf& rotation, const NzVector3f& scale) const;
|
||||
virtual NzBoxf ComputeAABB(const NzMatrix4f& offsetMatrix = NzMatrix4f::Identity()) const;
|
||||
@@ -40,14 +51,23 @@ class NAZARA_API NzBaseGeom : NzNonCopyable
|
||||
|
||||
NzPhysWorld* GetWorld() const;
|
||||
|
||||
static NzBaseGeom* Build(NzPhysWorld* physWorld, const NzPrimitiveList& list);
|
||||
static NzPhysGeomRef Build(NzPhysWorld* physWorld, const NzPrimitiveList& list);
|
||||
|
||||
protected:
|
||||
NewtonCollision* m_collision;
|
||||
NzPhysWorld* m_world;
|
||||
|
||||
static NzPhysGeomLibrary::LibraryMap s_library;
|
||||
};
|
||||
|
||||
class NAZARA_API NzBoxGeom : public NzBaseGeom
|
||||
class NzBoxGeom;
|
||||
|
||||
using NzBoxGeomConstListener = NzObjectListenerWrapper<const NzBoxGeom>;
|
||||
using NzBoxGeomConstRef = NzObjectRef<const NzBoxGeom>;
|
||||
using NzBoxGeomListener = NzObjectListenerWrapper<NzBoxGeom>;
|
||||
using NzBoxGeomRef = NzObjectRef<NzBoxGeom>;
|
||||
|
||||
class NAZARA_API NzBoxGeom : public NzPhysGeom
|
||||
{
|
||||
public:
|
||||
NzBoxGeom(NzPhysWorld* physWorld, const NzVector3f& lengths, const NzMatrix4f& transformMatrix = NzMatrix4f::Identity());
|
||||
@@ -56,11 +76,20 @@ class NAZARA_API NzBoxGeom : public NzBaseGeom
|
||||
NzVector3f GetLengths() const;
|
||||
nzGeomType GetType() const override;
|
||||
|
||||
template<typename... Args> static NzBoxGeomRef New(Args&&... args);
|
||||
|
||||
private:
|
||||
NzVector3f m_lengths;
|
||||
};
|
||||
|
||||
class NAZARA_API NzCapsuleGeom : public NzBaseGeom
|
||||
class NzCapsuleGeom;
|
||||
|
||||
using NzCapsuleGeomConstListener = NzObjectListenerWrapper<const NzCapsuleGeom>;
|
||||
using NzCapsuleGeomConstRef = NzObjectRef<const NzCapsuleGeom>;
|
||||
using NzCapsuleGeomListener = NzObjectListenerWrapper<NzCapsuleGeom>;
|
||||
using NzCapsuleGeomRef = NzObjectRef<NzCapsuleGeom>;
|
||||
|
||||
class NAZARA_API NzCapsuleGeom : public NzPhysGeom
|
||||
{
|
||||
public:
|
||||
NzCapsuleGeom(NzPhysWorld* physWorld, float length, float radius, const NzMatrix4f& transformMatrix = NzMatrix4f::Identity());
|
||||
@@ -70,20 +99,38 @@ class NAZARA_API NzCapsuleGeom : public NzBaseGeom
|
||||
float GetRadius() const;
|
||||
nzGeomType GetType() const override;
|
||||
|
||||
template<typename... Args> static NzCapsuleGeomRef New(Args&&... args);
|
||||
|
||||
private:
|
||||
float m_length;
|
||||
float m_radius;
|
||||
};
|
||||
|
||||
class NAZARA_API NzCompoundGeom : public NzBaseGeom
|
||||
class NzCompoundGeom;
|
||||
|
||||
using NzCompoundGeomConstListener = NzObjectListenerWrapper<const NzCompoundGeom>;
|
||||
using NzCompoundGeomConstRef = NzObjectRef<const NzCompoundGeom>;
|
||||
using NzCompoundGeomListener = NzObjectListenerWrapper<NzCompoundGeom>;
|
||||
using NzCompoundGeomRef = NzObjectRef<NzCompoundGeom>;
|
||||
|
||||
class NAZARA_API NzCompoundGeom : public NzPhysGeom
|
||||
{
|
||||
public:
|
||||
NzCompoundGeom(NzPhysWorld* physWorld, NzBaseGeom** geoms, unsigned int geomCount);
|
||||
NzCompoundGeom(NzPhysWorld* physWorld, NzPhysGeom** geoms, unsigned int geomCount);
|
||||
|
||||
nzGeomType GetType() const override;
|
||||
|
||||
template<typename... Args> static NzCompoundGeomRef New(Args&&... args);
|
||||
};
|
||||
|
||||
class NAZARA_API NzConeGeom : public NzBaseGeom
|
||||
class NzConeGeom;
|
||||
|
||||
using NzConeGeomConstListener = NzObjectListenerWrapper<const NzConeGeom>;
|
||||
using NzConeGeomConstRef = NzObjectRef<const NzConeGeom>;
|
||||
using NzConeGeomListener = NzObjectListenerWrapper<NzConeGeom>;
|
||||
using NzConeGeomRef = NzObjectRef<NzConeGeom>;
|
||||
|
||||
class NAZARA_API NzConeGeom : public NzPhysGeom
|
||||
{
|
||||
public:
|
||||
NzConeGeom(NzPhysWorld* physWorld, float length, float radius, const NzMatrix4f& transformMatrix = NzMatrix4f::Identity());
|
||||
@@ -93,21 +140,39 @@ class NAZARA_API NzConeGeom : public NzBaseGeom
|
||||
float GetRadius() const;
|
||||
nzGeomType GetType() const override;
|
||||
|
||||
template<typename... Args> static NzConeGeomRef New(Args&&... args);
|
||||
|
||||
private:
|
||||
float m_length;
|
||||
float m_radius;
|
||||
};
|
||||
|
||||
class NAZARA_API NzConvexHullGeom : public NzBaseGeom
|
||||
class NzConvexHullGeom;
|
||||
|
||||
using NzConvexHullGeomConstListener = NzObjectListenerWrapper<const NzConvexHullGeom>;
|
||||
using NzConvexHullGeomConstRef = NzObjectRef<const NzConvexHullGeom>;
|
||||
using NzConvexHullGeomListener = NzObjectListenerWrapper<NzConvexHullGeom>;
|
||||
using NzConvexHullGeomRef = NzObjectRef<NzConvexHullGeom>;
|
||||
|
||||
class NAZARA_API NzConvexHullGeom : public NzPhysGeom
|
||||
{
|
||||
public:
|
||||
NzConvexHullGeom(NzPhysWorld* physWorld, const void* vertices, unsigned int vertexCount, unsigned int stride = sizeof(NzVector3f), float tolerance = 0.002f, const NzMatrix4f& transformMatrix = NzMatrix4f::Identity());
|
||||
NzConvexHullGeom(NzPhysWorld* physWorld, const void* vertices, unsigned int vertexCount, unsigned int stride, float tolerance, const NzVector3f& translation, const NzQuaternionf& rotation = NzQuaternionf::Identity());
|
||||
|
||||
nzGeomType GetType() const override;
|
||||
|
||||
template<typename... Args> static NzConvexHullGeomRef New(Args&&... args);
|
||||
};
|
||||
|
||||
class NAZARA_API NzCylinderGeom : public NzBaseGeom
|
||||
class NzCylinderGeom;
|
||||
|
||||
using NzCylinderGeomConstListener = NzObjectListenerWrapper<const NzCylinderGeom>;
|
||||
using NzCylinderGeomConstRef = NzObjectRef<const NzCylinderGeom>;
|
||||
using NzCylinderGeomListener = NzObjectListenerWrapper<NzCylinderGeom>;
|
||||
using NzCylinderGeomRef = NzObjectRef<NzCylinderGeom>;
|
||||
|
||||
class NAZARA_API NzCylinderGeom : public NzPhysGeom
|
||||
{
|
||||
public:
|
||||
NzCylinderGeom(NzPhysWorld* physWorld, float length, float radius, const NzMatrix4f& transformMatrix = NzMatrix4f::Identity());
|
||||
@@ -117,20 +182,38 @@ class NAZARA_API NzCylinderGeom : public NzBaseGeom
|
||||
float GetRadius() const;
|
||||
nzGeomType GetType() const override;
|
||||
|
||||
template<typename... Args> static NzCylinderGeomRef New(Args&&... args);
|
||||
|
||||
private:
|
||||
float m_length;
|
||||
float m_radius;
|
||||
};
|
||||
|
||||
class NAZARA_API NzNullGeom : public NzBaseGeom
|
||||
class NzNullGeom;
|
||||
|
||||
using NzNullGeomConstListener = NzObjectListenerWrapper<const NzNullGeom>;
|
||||
using NzNullGeomConstRef = NzObjectRef<const NzNullGeom>;
|
||||
using NzNullGeomListener = NzObjectListenerWrapper<NzNullGeom>;
|
||||
using NzNullGeomRef = NzObjectRef<NzNullGeom>;
|
||||
|
||||
class NAZARA_API NzNullGeom : public NzPhysGeom
|
||||
{
|
||||
public:
|
||||
NzNullGeom(NzPhysWorld* physWorld);
|
||||
|
||||
nzGeomType GetType() const override;
|
||||
|
||||
template<typename... Args> static NzNullGeomRef New(Args&&... args);
|
||||
};
|
||||
|
||||
class NAZARA_API NzSphereGeom : public NzBaseGeom
|
||||
class NzSphereGeom;
|
||||
|
||||
using NzSphereGeomConstListener = NzObjectListenerWrapper<const NzSphereGeom>;
|
||||
using NzSphereGeomConstRef = NzObjectRef<const NzSphereGeom>;
|
||||
using NzSphereGeomListener = NzObjectListenerWrapper<NzSphereGeom>;
|
||||
using NzSphereGeomRef = NzObjectRef<NzSphereGeom>;
|
||||
|
||||
class NAZARA_API NzSphereGeom : public NzPhysGeom
|
||||
{
|
||||
public:
|
||||
NzSphereGeom(NzPhysWorld* physWorld, float radius, const NzMatrix4f& transformMatrix = NzMatrix4f::Identity());
|
||||
@@ -139,8 +222,12 @@ class NAZARA_API NzSphereGeom : public NzBaseGeom
|
||||
NzVector3f GetRadius() const;
|
||||
nzGeomType GetType() const override;
|
||||
|
||||
template<typename... Args> static NzSphereGeomRef New(Args&&... args);
|
||||
|
||||
private:
|
||||
NzVector3f m_radius;
|
||||
};
|
||||
|
||||
#include <Nazara/Physics/Geom.inl>
|
||||
|
||||
#endif // NAZARA_PHYSWORLD_HPP
|
||||
|
||||
Reference in New Issue
Block a user