Physics: Rename PhysGeom to Collider3D
This commit is contained in:
parent
24f1859ec2
commit
8781a628e0
|
|
@ -4,8 +4,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifndef NAZARA_GEOM_HPP
|
#ifndef NAZARA_COLLIDER3D_HPP
|
||||||
#define NAZARA_GEOM_HPP
|
#define NAZARA_COLLIDER3D_HPP
|
||||||
|
|
||||||
#include <Nazara/Prerequesites.hpp>
|
#include <Nazara/Prerequesites.hpp>
|
||||||
#include <Nazara/Core/PrimitiveList.hpp>
|
#include <Nazara/Core/PrimitiveList.hpp>
|
||||||
|
|
@ -30,23 +30,23 @@ namespace Nz
|
||||||
///TODO: SceneGeom
|
///TODO: SceneGeom
|
||||||
///TODO: TreeGeom
|
///TODO: TreeGeom
|
||||||
|
|
||||||
class PhysGeom;
|
class Collider3D;
|
||||||
class PhysWorld;
|
class PhysWorld;
|
||||||
|
|
||||||
using PhysGeomConstRef = ObjectRef<const PhysGeom>;
|
using Collider3DConstRef = ObjectRef<const Collider3D>;
|
||||||
using PhysGeomLibrary = ObjectLibrary<PhysGeom>;
|
using Collider3DLibrary = ObjectLibrary<Collider3D>;
|
||||||
using PhysGeomRef = ObjectRef<PhysGeom>;
|
using Collider3DRef = ObjectRef<Collider3D>;
|
||||||
|
|
||||||
class NAZARA_PHYSICS3D_API PhysGeom : public RefCounted
|
class NAZARA_PHYSICS3D_API Collider3D : public RefCounted
|
||||||
{
|
{
|
||||||
friend PhysGeomLibrary;
|
friend Collider3DLibrary;
|
||||||
friend class Physics;
|
friend class Physics;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PhysGeom() = default;
|
Collider3D() = default;
|
||||||
PhysGeom(const PhysGeom&) = delete;
|
Collider3D(const Collider3D&) = delete;
|
||||||
PhysGeom(PhysGeom&&) = delete;
|
Collider3D(Collider3D&&) = delete;
|
||||||
virtual ~PhysGeom();
|
virtual ~Collider3D();
|
||||||
|
|
||||||
Boxf ComputeAABB(const Vector3f& translation, const Quaternionf& rotation, const Vector3f& scale) const;
|
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 Boxf ComputeAABB(const Matrix4f& offsetMatrix = Matrix4f::Identity(), const Vector3f& scale = Vector3f::Unit()) const;
|
||||||
|
|
@ -56,13 +56,13 @@ namespace Nz
|
||||||
NewtonCollision* GetHandle(PhysWorld* world) const;
|
NewtonCollision* GetHandle(PhysWorld* world) const;
|
||||||
virtual GeomType GetType() const = 0;
|
virtual GeomType GetType() const = 0;
|
||||||
|
|
||||||
PhysGeom& operator=(const PhysGeom&) = delete;
|
Collider3D& operator=(const Collider3D&) = delete;
|
||||||
PhysGeom& operator=(PhysGeom&&) = delete;
|
Collider3D& operator=(Collider3D&&) = delete;
|
||||||
|
|
||||||
static PhysGeomRef Build(const PrimitiveList& list);
|
static Collider3DRef Build(const PrimitiveList& list);
|
||||||
|
|
||||||
// Signals:
|
// Signals:
|
||||||
NazaraSignal(OnPhysGeomRelease, const PhysGeom* /*physGeom*/);
|
NazaraSignal(OnColliderRelease, const Collider3D* /*collider*/);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual NewtonCollision* CreateHandle(PhysWorld* world) const = 0;
|
virtual NewtonCollision* CreateHandle(PhysWorld* world) const = 0;
|
||||||
|
|
@ -72,7 +72,7 @@ namespace Nz
|
||||||
|
|
||||||
mutable std::unordered_map<PhysWorld*, NewtonCollision*> m_handles;
|
mutable std::unordered_map<PhysWorld*, NewtonCollision*> m_handles;
|
||||||
|
|
||||||
static PhysGeomLibrary::LibraryMap s_library;
|
static Collider3DLibrary::LibraryMap s_library;
|
||||||
};
|
};
|
||||||
|
|
||||||
class BoxGeom;
|
class BoxGeom;
|
||||||
|
|
@ -80,7 +80,7 @@ namespace Nz
|
||||||
using BoxGeomConstRef = ObjectRef<const BoxGeom>;
|
using BoxGeomConstRef = ObjectRef<const BoxGeom>;
|
||||||
using BoxGeomRef = ObjectRef<BoxGeom>;
|
using BoxGeomRef = ObjectRef<BoxGeom>;
|
||||||
|
|
||||||
class NAZARA_PHYSICS3D_API BoxGeom : public PhysGeom
|
class NAZARA_PHYSICS3D_API BoxGeom : public Collider3D
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BoxGeom(const Vector3f& lengths, const Matrix4f& transformMatrix = Matrix4f::Identity());
|
BoxGeom(const Vector3f& lengths, const Matrix4f& transformMatrix = Matrix4f::Identity());
|
||||||
|
|
@ -106,7 +106,7 @@ namespace Nz
|
||||||
using CapsuleGeomConstRef = ObjectRef<const CapsuleGeom>;
|
using CapsuleGeomConstRef = ObjectRef<const CapsuleGeom>;
|
||||||
using CapsuleGeomRef = ObjectRef<CapsuleGeom>;
|
using CapsuleGeomRef = ObjectRef<CapsuleGeom>;
|
||||||
|
|
||||||
class NAZARA_PHYSICS3D_API CapsuleGeom : public PhysGeom
|
class NAZARA_PHYSICS3D_API CapsuleGeom : public Collider3D
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CapsuleGeom(float length, float radius, const Matrix4f& transformMatrix = Matrix4f::Identity());
|
CapsuleGeom(float length, float radius, const Matrix4f& transformMatrix = Matrix4f::Identity());
|
||||||
|
|
@ -131,12 +131,12 @@ namespace Nz
|
||||||
using CompoundGeomConstRef = ObjectRef<const CompoundGeom>;
|
using CompoundGeomConstRef = ObjectRef<const CompoundGeom>;
|
||||||
using CompoundGeomRef = ObjectRef<CompoundGeom>;
|
using CompoundGeomRef = ObjectRef<CompoundGeom>;
|
||||||
|
|
||||||
class NAZARA_PHYSICS3D_API CompoundGeom : public PhysGeom
|
class NAZARA_PHYSICS3D_API CompoundGeom : public Collider3D
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CompoundGeom(PhysGeom** geoms, std::size_t geomCount);
|
CompoundGeom(Collider3D** geoms, std::size_t geomCount);
|
||||||
|
|
||||||
const std::vector<PhysGeomRef>& GetGeoms() const;
|
const std::vector<Collider3DRef>& GetGeoms() const;
|
||||||
GeomType GetType() const override;
|
GeomType GetType() const override;
|
||||||
|
|
||||||
template<typename... Args> static CompoundGeomRef New(Args&&... args);
|
template<typename... Args> static CompoundGeomRef New(Args&&... args);
|
||||||
|
|
@ -144,7 +144,7 @@ namespace Nz
|
||||||
private:
|
private:
|
||||||
NewtonCollision* CreateHandle(PhysWorld* world) const override;
|
NewtonCollision* CreateHandle(PhysWorld* world) const override;
|
||||||
|
|
||||||
std::vector<PhysGeomRef> m_geoms;
|
std::vector<Collider3DRef> m_geoms;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ConeGeom;
|
class ConeGeom;
|
||||||
|
|
@ -152,7 +152,7 @@ namespace Nz
|
||||||
using ConeGeomConstRef = ObjectRef<const ConeGeom>;
|
using ConeGeomConstRef = ObjectRef<const ConeGeom>;
|
||||||
using ConeGeomRef = ObjectRef<ConeGeom>;
|
using ConeGeomRef = ObjectRef<ConeGeom>;
|
||||||
|
|
||||||
class NAZARA_PHYSICS3D_API ConeGeom : public PhysGeom
|
class NAZARA_PHYSICS3D_API ConeGeom : public Collider3D
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ConeGeom(float length, float radius, const Matrix4f& transformMatrix = Matrix4f::Identity());
|
ConeGeom(float length, float radius, const Matrix4f& transformMatrix = Matrix4f::Identity());
|
||||||
|
|
@ -177,7 +177,7 @@ namespace Nz
|
||||||
using ConvexHullGeomConstRef = ObjectRef<const ConvexHullGeom>;
|
using ConvexHullGeomConstRef = ObjectRef<const ConvexHullGeom>;
|
||||||
using ConvexHullGeomRef = ObjectRef<ConvexHullGeom>;
|
using ConvexHullGeomRef = ObjectRef<ConvexHullGeom>;
|
||||||
|
|
||||||
class NAZARA_PHYSICS3D_API ConvexHullGeom : public PhysGeom
|
class NAZARA_PHYSICS3D_API ConvexHullGeom : public Collider3D
|
||||||
{
|
{
|
||||||
public:
|
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 = sizeof(Vector3f), float tolerance = 0.002f, const Matrix4f& transformMatrix = Matrix4f::Identity());
|
||||||
|
|
@ -201,7 +201,7 @@ namespace Nz
|
||||||
using CylinderGeomConstRef = ObjectRef<const CylinderGeom>;
|
using CylinderGeomConstRef = ObjectRef<const CylinderGeom>;
|
||||||
using CylinderGeomRef = ObjectRef<CylinderGeom>;
|
using CylinderGeomRef = ObjectRef<CylinderGeom>;
|
||||||
|
|
||||||
class NAZARA_PHYSICS3D_API CylinderGeom : public PhysGeom
|
class NAZARA_PHYSICS3D_API CylinderGeom : public Collider3D
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CylinderGeom(float length, float radius, const Matrix4f& transformMatrix = Matrix4f::Identity());
|
CylinderGeom(float length, float radius, const Matrix4f& transformMatrix = Matrix4f::Identity());
|
||||||
|
|
@ -226,7 +226,7 @@ namespace Nz
|
||||||
using NullGeomConstRef = ObjectRef<const NullGeom>;
|
using NullGeomConstRef = ObjectRef<const NullGeom>;
|
||||||
using NullGeomRef = ObjectRef<NullGeom>;
|
using NullGeomRef = ObjectRef<NullGeom>;
|
||||||
|
|
||||||
class NAZARA_PHYSICS3D_API NullGeom : public PhysGeom
|
class NAZARA_PHYSICS3D_API NullGeom : public Collider3D
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NullGeom();
|
NullGeom();
|
||||||
|
|
@ -246,7 +246,7 @@ namespace Nz
|
||||||
using SphereGeomConstRef = ObjectRef<const SphereGeom>;
|
using SphereGeomConstRef = ObjectRef<const SphereGeom>;
|
||||||
using SphereGeomRef = ObjectRef<SphereGeom>;
|
using SphereGeomRef = ObjectRef<SphereGeom>;
|
||||||
|
|
||||||
class NAZARA_PHYSICS3D_API SphereGeom : public PhysGeom
|
class NAZARA_PHYSICS3D_API SphereGeom : public Collider3D
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SphereGeom(float radius, const Matrix4f& transformMatrix = Matrix4f::Identity());
|
SphereGeom(float radius, const Matrix4f& transformMatrix = Matrix4f::Identity());
|
||||||
|
|
@ -268,6 +268,6 @@ namespace Nz
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <Nazara/Physics3D/Geom.inl>
|
#include <Nazara/Physics3D/Collider3D.inl>
|
||||||
|
|
||||||
#endif // NAZARA_PHYSWORLD_HPP
|
#endif // NAZARA_COLLIDER3D_HPP
|
||||||
|
|
@ -35,18 +35,18 @@ namespace Nz
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PhysGeom::~PhysGeom()
|
Collider3D::~Collider3D()
|
||||||
{
|
{
|
||||||
for (auto& pair : m_handles)
|
for (auto& pair : m_handles)
|
||||||
NewtonDestroyCollision(pair.second);
|
NewtonDestroyCollision(pair.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
Boxf PhysGeom::ComputeAABB(const Vector3f& translation, const Quaternionf& rotation, const Vector3f& scale) const
|
Boxf Collider3D::ComputeAABB(const Vector3f& translation, const Quaternionf& rotation, const Vector3f& scale) const
|
||||||
{
|
{
|
||||||
return ComputeAABB(Matrix4f::Transform(translation, rotation), scale);
|
return ComputeAABB(Matrix4f::Transform(translation, rotation), scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
Boxf PhysGeom::ComputeAABB(const Matrix4f& offsetMatrix, const Vector3f& scale) const
|
Boxf Collider3D::ComputeAABB(const Matrix4f& offsetMatrix, const Vector3f& scale) const
|
||||||
{
|
{
|
||||||
Vector3f min, max;
|
Vector3f min, max;
|
||||||
|
|
||||||
|
|
@ -67,7 +67,7 @@ namespace Nz
|
||||||
return Boxf(scale * min, scale * max);
|
return Boxf(scale * min, scale * max);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysGeom::ComputeInertialMatrix(Vector3f* inertia, Vector3f* center) const
|
void Collider3D::ComputeInertialMatrix(Vector3f* inertia, Vector3f* center) const
|
||||||
{
|
{
|
||||||
float inertiaMatrix[3];
|
float inertiaMatrix[3];
|
||||||
float origin[3];
|
float origin[3];
|
||||||
|
|
@ -93,7 +93,7 @@ namespace Nz
|
||||||
center->Set(origin);
|
center->Set(origin);
|
||||||
}
|
}
|
||||||
|
|
||||||
float PhysGeom::ComputeVolume() const
|
float Collider3D::ComputeVolume() const
|
||||||
{
|
{
|
||||||
float volume;
|
float volume;
|
||||||
|
|
||||||
|
|
@ -114,7 +114,7 @@ namespace Nz
|
||||||
return volume;
|
return volume;
|
||||||
}
|
}
|
||||||
|
|
||||||
NewtonCollision* PhysGeom::GetHandle(PhysWorld* world) const
|
NewtonCollision* Collider3D::GetHandle(PhysWorld* world) const
|
||||||
{
|
{
|
||||||
auto it = m_handles.find(world);
|
auto it = m_handles.find(world);
|
||||||
if (it == m_handles.end())
|
if (it == m_handles.end())
|
||||||
|
|
@ -123,12 +123,12 @@ namespace Nz
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
PhysGeomRef PhysGeom::Build(const PrimitiveList& list)
|
PhysGeomRef Collider3D::Build(const PrimitiveList& list)
|
||||||
{
|
{
|
||||||
std::size_t primitiveCount = list.GetSize();
|
std::size_t primitiveCount = list.GetSize();
|
||||||
if (primitiveCount > 1)
|
if (primitiveCount > 1)
|
||||||
{
|
{
|
||||||
std::vector<PhysGeom*> geoms(primitiveCount);
|
std::vector<Collider3D*> geoms(primitiveCount);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < primitiveCount; ++i)
|
for (unsigned int i = 0; i < primitiveCount; ++i)
|
||||||
geoms[i] = CreateGeomFromPrimitive(list.GetPrimitive(i));
|
geoms[i] = CreateGeomFromPrimitive(list.GetPrimitive(i));
|
||||||
|
|
@ -141,7 +141,7 @@ namespace Nz
|
||||||
return NullGeom::New();
|
return NullGeom::New();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PhysGeom::Initialize()
|
bool Collider3D::Initialize()
|
||||||
{
|
{
|
||||||
if (!PhysGeomLibrary::Initialize())
|
if (!PhysGeomLibrary::Initialize())
|
||||||
{
|
{
|
||||||
|
|
@ -152,12 +152,12 @@ namespace Nz
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysGeom::Uninitialize()
|
void Collider3D::Uninitialize()
|
||||||
{
|
{
|
||||||
PhysGeomLibrary::Uninitialize();
|
PhysGeomLibrary::Uninitialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
PhysGeomLibrary::LibraryMap PhysGeom::s_library;
|
PhysGeomLibrary::LibraryMap Collider3D::s_library;
|
||||||
|
|
||||||
/********************************** BoxGeom **********************************/
|
/********************************** BoxGeom **********************************/
|
||||||
|
|
||||||
|
|
@ -239,7 +239,7 @@ namespace Nz
|
||||||
|
|
||||||
/******************************* CompoundGeom ********************************/
|
/******************************* CompoundGeom ********************************/
|
||||||
|
|
||||||
CompoundGeom::CompoundGeom(PhysGeom** geoms, std::size_t geomCount)
|
CompoundGeom::CompoundGeom(Collider3D** geoms, std::size_t geomCount)
|
||||||
{
|
{
|
||||||
m_geoms.reserve(geomCount);
|
m_geoms.reserve(geomCount);
|
||||||
for (std::size_t i = 0; i < geomCount; ++i)
|
for (std::size_t i = 0; i < geomCount; ++i)
|
||||||
|
|
@ -36,7 +36,7 @@ namespace Nz
|
||||||
s_moduleReferenceCounter++;
|
s_moduleReferenceCounter++;
|
||||||
|
|
||||||
// Initialisation du module
|
// Initialisation du module
|
||||||
if (!PhysGeom::Initialize())
|
if (!Collider3D::Initialize())
|
||||||
{
|
{
|
||||||
NazaraError("Failed to initialize geoms");
|
NazaraError("Failed to initialize geoms");
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -63,7 +63,7 @@ namespace Nz
|
||||||
}
|
}
|
||||||
|
|
||||||
// Libération du module
|
// Libération du module
|
||||||
PhysGeom::Uninitialize();
|
Collider3D::Uninitialize();
|
||||||
|
|
||||||
s_moduleReferenceCounter = 0;
|
s_moduleReferenceCounter = 0;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue