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