diff --git a/include/Nazara/Physics3D/Geom.hpp b/include/Nazara/Physics3D/Collider3D.hpp similarity index 82% rename from include/Nazara/Physics3D/Geom.hpp rename to include/Nazara/Physics3D/Collider3D.hpp index b15c4ca9b..59946d5c5 100644 --- a/include/Nazara/Physics3D/Geom.hpp +++ b/include/Nazara/Physics3D/Collider3D.hpp @@ -4,8 +4,8 @@ #pragma once -#ifndef NAZARA_GEOM_HPP -#define NAZARA_GEOM_HPP +#ifndef NAZARA_COLLIDER3D_HPP +#define NAZARA_COLLIDER3D_HPP #include #include @@ -30,23 +30,23 @@ namespace Nz ///TODO: SceneGeom ///TODO: TreeGeom - class PhysGeom; + class Collider3D; class PhysWorld; - using PhysGeomConstRef = ObjectRef; - using PhysGeomLibrary = ObjectLibrary; - using PhysGeomRef = ObjectRef; + using Collider3DConstRef = ObjectRef; + using Collider3DLibrary = ObjectLibrary; + using Collider3DRef = ObjectRef; - 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 m_handles; - static PhysGeomLibrary::LibraryMap s_library; + static Collider3DLibrary::LibraryMap s_library; }; class BoxGeom; @@ -80,7 +80,7 @@ namespace Nz using BoxGeomConstRef = ObjectRef; using BoxGeomRef = ObjectRef; - 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; using CapsuleGeomRef = ObjectRef; - 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; using CompoundGeomRef = ObjectRef; - 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& GetGeoms() const; + const std::vector& GetGeoms() const; GeomType GetType() const override; template static CompoundGeomRef New(Args&&... args); @@ -144,7 +144,7 @@ namespace Nz private: NewtonCollision* CreateHandle(PhysWorld* world) const override; - std::vector m_geoms; + std::vector m_geoms; }; class ConeGeom; @@ -152,7 +152,7 @@ namespace Nz using ConeGeomConstRef = ObjectRef; using ConeGeomRef = ObjectRef; - 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; using ConvexHullGeomRef = ObjectRef; - 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; using CylinderGeomRef = ObjectRef; - 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; using NullGeomRef = ObjectRef; - 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; using SphereGeomRef = ObjectRef; - 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 +#include -#endif // NAZARA_PHYSWORLD_HPP +#endif // NAZARA_COLLIDER3D_HPP diff --git a/include/Nazara/Physics3D/Geom.inl b/include/Nazara/Physics3D/Collider3D.inl similarity index 100% rename from include/Nazara/Physics3D/Geom.inl rename to include/Nazara/Physics3D/Collider3D.inl diff --git a/src/Nazara/Physics3D/Geom.cpp b/src/Nazara/Physics3D/Collider3D.cpp similarity index 93% rename from src/Nazara/Physics3D/Geom.cpp rename to src/Nazara/Physics3D/Collider3D.cpp index 452098c63..f01e79047 100644 --- a/src/Nazara/Physics3D/Geom.cpp +++ b/src/Nazara/Physics3D/Collider3D.cpp @@ -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 geoms(primitiveCount); + std::vector 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) diff --git a/src/Nazara/Physics3D/Physics.cpp b/src/Nazara/Physics3D/Physics.cpp index 7deef9f10..9c7b1d122 100644 --- a/src/Nazara/Physics3D/Physics.cpp +++ b/src/Nazara/Physics3D/Physics.cpp @@ -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;