From eae8847bd1d69cdd3ac004f2d0319397a000df47 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 13 Oct 2016 06:01:32 +0200 Subject: [PATCH 01/10] Physics: Move files to Physics3D --- build/scripts/modules/{physics.lua => physics3d.lua} | 2 +- include/Nazara/{Physics => Physics3D}/Config.hpp | 0 include/Nazara/{Physics => Physics3D}/ConfigCheck.hpp | 0 include/Nazara/{Physics => Physics3D}/Debug.hpp | 0 include/Nazara/{Physics => Physics3D}/DebugOff.hpp | 0 include/Nazara/{Physics => Physics3D}/Enums.hpp | 0 include/Nazara/{Physics => Physics3D}/Geom.hpp | 0 include/Nazara/{Physics => Physics3D}/Geom.inl | 0 include/Nazara/{Physics => Physics3D}/PhysObject.hpp | 0 include/Nazara/{Physics => Physics3D}/PhysWorld.hpp | 0 include/Nazara/{Physics => Physics3D}/Physics.hpp | 0 src/Nazara/{Physics => Physics3D}/Debug/NewOverload.cpp | 0 src/Nazara/{Physics => Physics3D}/Geom.cpp | 0 src/Nazara/{Physics => Physics3D}/PhysObject.cpp | 0 src/Nazara/{Physics => Physics3D}/PhysWorld.cpp | 0 src/Nazara/{Physics => Physics3D}/Physics.cpp | 0 16 files changed, 1 insertion(+), 1 deletion(-) rename build/scripts/modules/{physics.lua => physics3d.lua} (73%) rename include/Nazara/{Physics => Physics3D}/Config.hpp (100%) rename include/Nazara/{Physics => Physics3D}/ConfigCheck.hpp (100%) rename include/Nazara/{Physics => Physics3D}/Debug.hpp (100%) rename include/Nazara/{Physics => Physics3D}/DebugOff.hpp (100%) rename include/Nazara/{Physics => Physics3D}/Enums.hpp (100%) rename include/Nazara/{Physics => Physics3D}/Geom.hpp (100%) rename include/Nazara/{Physics => Physics3D}/Geom.inl (100%) rename include/Nazara/{Physics => Physics3D}/PhysObject.hpp (100%) rename include/Nazara/{Physics => Physics3D}/PhysWorld.hpp (100%) rename include/Nazara/{Physics => Physics3D}/Physics.hpp (100%) rename src/Nazara/{Physics => Physics3D}/Debug/NewOverload.cpp (100%) rename src/Nazara/{Physics => Physics3D}/Geom.cpp (100%) rename src/Nazara/{Physics => Physics3D}/PhysObject.cpp (100%) rename src/Nazara/{Physics => Physics3D}/PhysWorld.cpp (100%) rename src/Nazara/{Physics => Physics3D}/Physics.cpp (100%) diff --git a/build/scripts/modules/physics.lua b/build/scripts/modules/physics3d.lua similarity index 73% rename from build/scripts/modules/physics.lua rename to build/scripts/modules/physics3d.lua index 0796c46fd..d98a6f645 100644 --- a/build/scripts/modules/physics.lua +++ b/build/scripts/modules/physics3d.lua @@ -1,4 +1,4 @@ -MODULE.Name = "Physics" +MODULE.Name = "Physics3D" MODULE.Libraries = { "NazaraCore", diff --git a/include/Nazara/Physics/Config.hpp b/include/Nazara/Physics3D/Config.hpp similarity index 100% rename from include/Nazara/Physics/Config.hpp rename to include/Nazara/Physics3D/Config.hpp diff --git a/include/Nazara/Physics/ConfigCheck.hpp b/include/Nazara/Physics3D/ConfigCheck.hpp similarity index 100% rename from include/Nazara/Physics/ConfigCheck.hpp rename to include/Nazara/Physics3D/ConfigCheck.hpp diff --git a/include/Nazara/Physics/Debug.hpp b/include/Nazara/Physics3D/Debug.hpp similarity index 100% rename from include/Nazara/Physics/Debug.hpp rename to include/Nazara/Physics3D/Debug.hpp diff --git a/include/Nazara/Physics/DebugOff.hpp b/include/Nazara/Physics3D/DebugOff.hpp similarity index 100% rename from include/Nazara/Physics/DebugOff.hpp rename to include/Nazara/Physics3D/DebugOff.hpp diff --git a/include/Nazara/Physics/Enums.hpp b/include/Nazara/Physics3D/Enums.hpp similarity index 100% rename from include/Nazara/Physics/Enums.hpp rename to include/Nazara/Physics3D/Enums.hpp diff --git a/include/Nazara/Physics/Geom.hpp b/include/Nazara/Physics3D/Geom.hpp similarity index 100% rename from include/Nazara/Physics/Geom.hpp rename to include/Nazara/Physics3D/Geom.hpp diff --git a/include/Nazara/Physics/Geom.inl b/include/Nazara/Physics3D/Geom.inl similarity index 100% rename from include/Nazara/Physics/Geom.inl rename to include/Nazara/Physics3D/Geom.inl diff --git a/include/Nazara/Physics/PhysObject.hpp b/include/Nazara/Physics3D/PhysObject.hpp similarity index 100% rename from include/Nazara/Physics/PhysObject.hpp rename to include/Nazara/Physics3D/PhysObject.hpp diff --git a/include/Nazara/Physics/PhysWorld.hpp b/include/Nazara/Physics3D/PhysWorld.hpp similarity index 100% rename from include/Nazara/Physics/PhysWorld.hpp rename to include/Nazara/Physics3D/PhysWorld.hpp diff --git a/include/Nazara/Physics/Physics.hpp b/include/Nazara/Physics3D/Physics.hpp similarity index 100% rename from include/Nazara/Physics/Physics.hpp rename to include/Nazara/Physics3D/Physics.hpp diff --git a/src/Nazara/Physics/Debug/NewOverload.cpp b/src/Nazara/Physics3D/Debug/NewOverload.cpp similarity index 100% rename from src/Nazara/Physics/Debug/NewOverload.cpp rename to src/Nazara/Physics3D/Debug/NewOverload.cpp diff --git a/src/Nazara/Physics/Geom.cpp b/src/Nazara/Physics3D/Geom.cpp similarity index 100% rename from src/Nazara/Physics/Geom.cpp rename to src/Nazara/Physics3D/Geom.cpp diff --git a/src/Nazara/Physics/PhysObject.cpp b/src/Nazara/Physics3D/PhysObject.cpp similarity index 100% rename from src/Nazara/Physics/PhysObject.cpp rename to src/Nazara/Physics3D/PhysObject.cpp diff --git a/src/Nazara/Physics/PhysWorld.cpp b/src/Nazara/Physics3D/PhysWorld.cpp similarity index 100% rename from src/Nazara/Physics/PhysWorld.cpp rename to src/Nazara/Physics3D/PhysWorld.cpp diff --git a/src/Nazara/Physics/Physics.cpp b/src/Nazara/Physics3D/Physics.cpp similarity index 100% rename from src/Nazara/Physics/Physics.cpp rename to src/Nazara/Physics3D/Physics.cpp From 24f1859ec26589f61fa2477a6ee0d0c660045f10 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 13 Oct 2016 06:03:22 +0200 Subject: [PATCH 02/10] Physics: Change includes to Physics3D --- .../NDK/Components/CollisionComponent.hpp | 2 +- .../NDK/Components/PhysicsComponent.hpp | 2 +- SDK/include/NDK/Systems/PhysicsSystem.hpp | 2 +- SDK/src/NDK/Components/CollisionComponent.cpp | 2 +- SDK/src/NDK/Components/PhysicsComponent.cpp | 2 +- SDK/src/NDK/Sdk.cpp | 2 +- SDK/src/NDK/Systems/PhysicsSystem.cpp | 2 +- include/Nazara/Physics3D/Config.hpp | 18 +++++++------- include/Nazara/Physics3D/ConfigCheck.hpp | 2 +- include/Nazara/Physics3D/Debug.hpp | 2 +- include/Nazara/Physics3D/Geom.hpp | 24 +++++++++---------- include/Nazara/Physics3D/Geom.inl | 4 ++-- include/Nazara/Physics3D/PhysObject.hpp | 6 ++--- include/Nazara/Physics3D/PhysWorld.hpp | 4 ++-- include/Nazara/Physics3D/Physics.hpp | 4 ++-- src/Nazara/Physics3D/Debug/NewOverload.cpp | 2 +- src/Nazara/Physics3D/Geom.cpp | 6 ++--- src/Nazara/Physics3D/PhysObject.cpp | 8 +++---- src/Nazara/Physics3D/PhysWorld.cpp | 4 ++-- src/Nazara/Physics3D/Physics.cpp | 8 +++---- 20 files changed, 53 insertions(+), 53 deletions(-) diff --git a/SDK/include/NDK/Components/CollisionComponent.hpp b/SDK/include/NDK/Components/CollisionComponent.hpp index e0af0d09b..fa42b88f7 100644 --- a/SDK/include/NDK/Components/CollisionComponent.hpp +++ b/SDK/include/NDK/Components/CollisionComponent.hpp @@ -7,7 +7,7 @@ #ifndef NDK_COMPONENTS_COLLISIONCOMPONENT_HPP #define NDK_COMPONENTS_COLLISIONCOMPONENT_HPP -#include +#include #include #include diff --git a/SDK/include/NDK/Components/PhysicsComponent.hpp b/SDK/include/NDK/Components/PhysicsComponent.hpp index 9c5618785..97d2c62f6 100644 --- a/SDK/include/NDK/Components/PhysicsComponent.hpp +++ b/SDK/include/NDK/Components/PhysicsComponent.hpp @@ -7,7 +7,7 @@ #ifndef NDK_COMPONENTS_PHYSICSCOMPONENT_HPP #define NDK_COMPONENTS_PHYSICSCOMPONENT_HPP -#include +#include #include #include diff --git a/SDK/include/NDK/Systems/PhysicsSystem.hpp b/SDK/include/NDK/Systems/PhysicsSystem.hpp index 5c24c2b8a..3eb4f8f2e 100644 --- a/SDK/include/NDK/Systems/PhysicsSystem.hpp +++ b/SDK/include/NDK/Systems/PhysicsSystem.hpp @@ -7,7 +7,7 @@ #ifndef NDK_SYSTEMS_PHYSICSSYSTEM_HPP #define NDK_SYSTEMS_PHYSICSSYSTEM_HPP -#include +#include #include #include #include diff --git a/SDK/src/NDK/Components/CollisionComponent.cpp b/SDK/src/NDK/Components/CollisionComponent.cpp index 0f812e73b..7e8f9481a 100644 --- a/SDK/src/NDK/Components/CollisionComponent.cpp +++ b/SDK/src/NDK/Components/CollisionComponent.cpp @@ -3,7 +3,7 @@ // For conditions of distribution and use, see copyright notice in Prerequesites.hpp #include -#include +#include #include #include #include diff --git a/SDK/src/NDK/Components/PhysicsComponent.cpp b/SDK/src/NDK/Components/PhysicsComponent.cpp index 6cfd1077d..91be73792 100644 --- a/SDK/src/NDK/Components/PhysicsComponent.cpp +++ b/SDK/src/NDK/Components/PhysicsComponent.cpp @@ -3,7 +3,7 @@ // For conditions of distribution and use, see copyright notice in Prerequesites.hpp #include -#include +#include #include #include #include diff --git a/SDK/src/NDK/Sdk.cpp b/SDK/src/NDK/Sdk.cpp index 326eec502..bf6c9abbb 100644 --- a/SDK/src/NDK/Sdk.cpp +++ b/SDK/src/NDK/Sdk.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/SDK/src/NDK/Systems/PhysicsSystem.cpp b/SDK/src/NDK/Systems/PhysicsSystem.cpp index 793b0f1dc..f6621261a 100644 --- a/SDK/src/NDK/Systems/PhysicsSystem.cpp +++ b/SDK/src/NDK/Systems/PhysicsSystem.cpp @@ -3,7 +3,7 @@ // For conditions of distribution and use, see copyright notice in Prerequesites.hpp #include -#include +#include #include #include #include diff --git a/include/Nazara/Physics3D/Config.hpp b/include/Nazara/Physics3D/Config.hpp index b57e39378..23669240a 100644 --- a/include/Nazara/Physics3D/Config.hpp +++ b/include/Nazara/Physics3D/Config.hpp @@ -24,28 +24,28 @@ #pragma once -#ifndef NAZARA_CONFIG_PHYSICS_HPP -#define NAZARA_CONFIG_PHYSICS_HPP +#ifndef NAZARA_CONFIG_PHYSICS3D_HPP +#define NAZARA_CONFIG_PHYSICS3D_HPP /// Chaque modification d'un paramètre du module nécessite une recompilation de celui-ci // Utilise un manager de mémoire pour gérer les allocations dynamiques (détecte les leaks au prix d'allocations/libérations dynamiques plus lentes) -#define NAZARA_PHYSICS_MANAGE_MEMORY 0 +#define NAZARA_PHYSICS3D_MANAGE_MEMORY 0 // Active les tests de sécurité basés sur le code (Conseillé pour le développement) -#define NAZARA_PHYSICS_SAFE 1 +#define NAZARA_PHYSICS3D_SAFE 1 /// Vérification des valeurs et types de certaines constantes -#include +#include #if defined(NAZARA_STATIC) - #define NAZARA_PHYSICS_API + #define NAZARA_PHYSICS3D_API #else #ifdef NAZARA_PHYSICS_BUILD - #define NAZARA_PHYSICS_API NAZARA_EXPORT + #define NAZARA_PHYSICS3D_API NAZARA_EXPORT #else - #define NAZARA_PHYSICS_API NAZARA_IMPORT + #define NAZARA_PHYSICS3D_API NAZARA_IMPORT #endif #endif -#endif // NAZARA_CONFIG_PHYSICS_HPP +#endif // NAZARA_CONFIG_PHYSICS3D_HPP diff --git a/include/Nazara/Physics3D/ConfigCheck.hpp b/include/Nazara/Physics3D/ConfigCheck.hpp index 5721e2660..937712b0e 100644 --- a/include/Nazara/Physics3D/ConfigCheck.hpp +++ b/include/Nazara/Physics3D/ConfigCheck.hpp @@ -12,7 +12,7 @@ // On force la valeur de MANAGE_MEMORY en mode debug #if defined(NAZARA_DEBUG) && !NAZARA_PHYSICS_MANAGE_MEMORY #undef NAZARA_PHYSICS_MANAGE_MEMORY - #define NAZARA_PHYSICS_MANAGE_MEMORY 0 + #define NAZARA_PHYSICS3D_MANAGE_MEMORY 0 #endif #endif // NAZARA_CONFIG_CHECK_PHYSICS_HPP diff --git a/include/Nazara/Physics3D/Debug.hpp b/include/Nazara/Physics3D/Debug.hpp index 3f3d8fe41..d8b47e454 100644 --- a/include/Nazara/Physics3D/Debug.hpp +++ b/include/Nazara/Physics3D/Debug.hpp @@ -2,7 +2,7 @@ // This file is part of the "Nazara Engine - Physics module" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #if NAZARA_PHYSICS_MANAGE_MEMORY #include #endif diff --git a/include/Nazara/Physics3D/Geom.hpp b/include/Nazara/Physics3D/Geom.hpp index e228c3d07..b15c4ca9b 100644 --- a/include/Nazara/Physics3D/Geom.hpp +++ b/include/Nazara/Physics3D/Geom.hpp @@ -16,8 +16,8 @@ #include #include #include -#include -#include +#include +#include #include class NewtonCollision; @@ -37,7 +37,7 @@ namespace Nz using PhysGeomLibrary = ObjectLibrary; using PhysGeomRef = ObjectRef; - class NAZARA_PHYSICS_API PhysGeom : public RefCounted + class NAZARA_PHYSICS3D_API PhysGeom : public RefCounted { friend PhysGeomLibrary; friend class Physics; @@ -80,7 +80,7 @@ namespace Nz using BoxGeomConstRef = ObjectRef; using BoxGeomRef = ObjectRef; - class NAZARA_PHYSICS_API BoxGeom : public PhysGeom + class NAZARA_PHYSICS3D_API BoxGeom : public PhysGeom { public: BoxGeom(const Vector3f& lengths, const Matrix4f& transformMatrix = Matrix4f::Identity()); @@ -106,7 +106,7 @@ namespace Nz using CapsuleGeomConstRef = ObjectRef; using CapsuleGeomRef = ObjectRef; - class NAZARA_PHYSICS_API CapsuleGeom : public PhysGeom + class NAZARA_PHYSICS3D_API CapsuleGeom : public PhysGeom { public: CapsuleGeom(float length, float radius, const Matrix4f& transformMatrix = Matrix4f::Identity()); @@ -131,7 +131,7 @@ namespace Nz using CompoundGeomConstRef = ObjectRef; using CompoundGeomRef = ObjectRef; - class NAZARA_PHYSICS_API CompoundGeom : public PhysGeom + class NAZARA_PHYSICS3D_API CompoundGeom : public PhysGeom { public: CompoundGeom(PhysGeom** geoms, std::size_t geomCount); @@ -152,7 +152,7 @@ namespace Nz using ConeGeomConstRef = ObjectRef; using ConeGeomRef = ObjectRef; - class NAZARA_PHYSICS_API ConeGeom : public PhysGeom + class NAZARA_PHYSICS3D_API ConeGeom : public PhysGeom { 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_PHYSICS_API ConvexHullGeom : public PhysGeom + class NAZARA_PHYSICS3D_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()); @@ -201,7 +201,7 @@ namespace Nz using CylinderGeomConstRef = ObjectRef; using CylinderGeomRef = ObjectRef; - class NAZARA_PHYSICS_API CylinderGeom : public PhysGeom + class NAZARA_PHYSICS3D_API CylinderGeom : public PhysGeom { 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_PHYSICS_API NullGeom : public PhysGeom + class NAZARA_PHYSICS3D_API NullGeom : public PhysGeom { public: NullGeom(); @@ -246,7 +246,7 @@ namespace Nz using SphereGeomConstRef = ObjectRef; using SphereGeomRef = ObjectRef; - class NAZARA_PHYSICS_API SphereGeom : public PhysGeom + class NAZARA_PHYSICS3D_API SphereGeom : public PhysGeom { public: SphereGeom(float radius, const Matrix4f& transformMatrix = Matrix4f::Identity()); @@ -268,6 +268,6 @@ namespace Nz }; } -#include +#include #endif // NAZARA_PHYSWORLD_HPP diff --git a/include/Nazara/Physics3D/Geom.inl b/include/Nazara/Physics3D/Geom.inl index 9699cac96..9caf824aa 100644 --- a/include/Nazara/Physics3D/Geom.inl +++ b/include/Nazara/Physics3D/Geom.inl @@ -3,7 +3,7 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#include +#include namespace Nz { @@ -80,4 +80,4 @@ namespace Nz } } -#include +#include diff --git a/include/Nazara/Physics3D/PhysObject.hpp b/include/Nazara/Physics3D/PhysObject.hpp index d4d9c61b7..fac27e940 100644 --- a/include/Nazara/Physics3D/PhysObject.hpp +++ b/include/Nazara/Physics3D/PhysObject.hpp @@ -12,8 +12,8 @@ #include #include #include -#include -#include +#include +#include class NewtonBody; @@ -21,7 +21,7 @@ namespace Nz { class PhysWorld; - class NAZARA_PHYSICS_API PhysObject + class NAZARA_PHYSICS3D_API PhysObject { public: PhysObject(PhysWorld* world, const Matrix4f& mat = Matrix4f::Identity()); diff --git a/include/Nazara/Physics3D/PhysWorld.hpp b/include/Nazara/Physics3D/PhysWorld.hpp index 0300048b5..1bd072bf2 100644 --- a/include/Nazara/Physics3D/PhysWorld.hpp +++ b/include/Nazara/Physics3D/PhysWorld.hpp @@ -10,13 +10,13 @@ #include #include #include -#include +#include class NewtonWorld; namespace Nz { - class NAZARA_PHYSICS_API PhysWorld + class NAZARA_PHYSICS3D_API PhysWorld { public: PhysWorld(); diff --git a/include/Nazara/Physics3D/Physics.hpp b/include/Nazara/Physics3D/Physics.hpp index 3bb6ebde3..4efaa5cb4 100644 --- a/include/Nazara/Physics3D/Physics.hpp +++ b/include/Nazara/Physics3D/Physics.hpp @@ -9,11 +9,11 @@ #include #include -#include +#include namespace Nz { - class NAZARA_PHYSICS_API Physics + class NAZARA_PHYSICS3D_API Physics { public: Physics() = delete; diff --git a/src/Nazara/Physics3D/Debug/NewOverload.cpp b/src/Nazara/Physics3D/Debug/NewOverload.cpp index b7ca2c243..f6c7b64de 100644 --- a/src/Nazara/Physics3D/Debug/NewOverload.cpp +++ b/src/Nazara/Physics3D/Debug/NewOverload.cpp @@ -2,7 +2,7 @@ // This file is part of the "Nazara Engine - Physics module" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #if NAZARA_PHYSICS_MANAGE_MEMORY #include diff --git a/src/Nazara/Physics3D/Geom.cpp b/src/Nazara/Physics3D/Geom.cpp index 48d6f0090..452098c63 100644 --- a/src/Nazara/Physics3D/Geom.cpp +++ b/src/Nazara/Physics3D/Geom.cpp @@ -2,11 +2,11 @@ // This file is part of the "Nazara Engine - Physics module" // For conditions of distribution and use, see copyright notice in Config.hpp -#include -#include +#include +#include #include #include -#include +#include namespace Nz { diff --git a/src/Nazara/Physics3D/PhysObject.cpp b/src/Nazara/Physics3D/PhysObject.cpp index 1ee4a44d5..7fa02789b 100644 --- a/src/Nazara/Physics3D/PhysObject.cpp +++ b/src/Nazara/Physics3D/PhysObject.cpp @@ -2,13 +2,13 @@ // This file is part of the "Nazara Engine - Physics module" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include -#include -#include +#include +#include #include #include -#include +#include namespace Nz { diff --git a/src/Nazara/Physics3D/PhysWorld.cpp b/src/Nazara/Physics3D/PhysWorld.cpp index a3d76429b..5d2170aad 100644 --- a/src/Nazara/Physics3D/PhysWorld.cpp +++ b/src/Nazara/Physics3D/PhysWorld.cpp @@ -2,9 +2,9 @@ // This file is part of the "Nazara Engine - Physics module" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include -#include +#include namespace Nz { diff --git a/src/Nazara/Physics3D/Physics.cpp b/src/Nazara/Physics3D/Physics.cpp index 584c334ab..7deef9f10 100644 --- a/src/Nazara/Physics3D/Physics.cpp +++ b/src/Nazara/Physics3D/Physics.cpp @@ -2,14 +2,14 @@ // This file is part of the "Nazara Engine - Physics module" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include #include #include -#include -#include +#include +#include #include -#include +#include namespace Nz { From 8781a628e0c0b58b0823c3cb28cfdf2310fc710b Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 13 Oct 2016 06:08:17 +0200 Subject: [PATCH 03/10] Physics: Rename PhysGeom to Collider3D --- .../Physics3D/{Geom.hpp => Collider3D.hpp} | 60 +++++++++---------- .../Physics3D/{Geom.inl => Collider3D.inl} | 0 .../Physics3D/{Geom.cpp => Collider3D.cpp} | 24 ++++---- src/Nazara/Physics3D/Physics.cpp | 4 +- 4 files changed, 44 insertions(+), 44 deletions(-) rename include/Nazara/Physics3D/{Geom.hpp => Collider3D.hpp} (82%) rename include/Nazara/Physics3D/{Geom.inl => Collider3D.inl} (100%) rename src/Nazara/Physics3D/{Geom.cpp => Collider3D.cpp} (93%) 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; From b7a383d68cc953b90c808869e5eef2f10a5ed000 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 13 Oct 2016 07:29:34 +0200 Subject: [PATCH 04/10] Physics3D: Rename all *Geom to Collider3D --- .../NDK/Components/CollisionComponent.hpp | 12 +- .../NDK/Components/CollisionComponent.inl | 6 +- SDK/src/NDK/Components/CollisionComponent.cpp | 2 +- SDK/src/NDK/Components/PhysicsComponent.cpp | 4 +- include/Nazara/Physics3D/Collider3D.hpp | 108 ++++++------- include/Nazara/Physics3D/Collider3D.inl | 32 ++-- include/Nazara/Physics3D/PhysObject.hpp | 10 +- src/Nazara/Physics3D/Collider3D.cpp | 148 +++++++++--------- src/Nazara/Physics3D/PhysObject.cpp | 12 +- src/Nazara/Physics3D/Physics.cpp | 2 +- 10 files changed, 168 insertions(+), 168 deletions(-) diff --git a/SDK/include/NDK/Components/CollisionComponent.hpp b/SDK/include/NDK/Components/CollisionComponent.hpp index fa42b88f7..722a5476e 100644 --- a/SDK/include/NDK/Components/CollisionComponent.hpp +++ b/SDK/include/NDK/Components/CollisionComponent.hpp @@ -7,7 +7,7 @@ #ifndef NDK_COMPONENTS_COLLISIONCOMPONENT_HPP #define NDK_COMPONENTS_COLLISIONCOMPONENT_HPP -#include +#include #include #include @@ -26,15 +26,15 @@ namespace Ndk friend class StaticCollisionSystem; public: - CollisionComponent(Nz::PhysGeomRef geom = Nz::PhysGeomRef()); + CollisionComponent(Nz::Collider3DRef geom = Nz::Collider3DRef()); CollisionComponent(const CollisionComponent& collision); ~CollisionComponent() = default; - const Nz::PhysGeomRef& GetGeom() const; + const Nz::Collider3DRef& GetGeom() const; - void SetGeom(Nz::PhysGeomRef geom); + void SetGeom(Nz::Collider3DRef geom); - CollisionComponent& operator=(Nz::PhysGeomRef geom); + CollisionComponent& operator=(Nz::Collider3DRef geom); CollisionComponent& operator=(CollisionComponent&& collision) = default; static ComponentIndex componentIndex; @@ -49,7 +49,7 @@ namespace Ndk void OnDetached() override; std::unique_ptr m_staticBody; - Nz::PhysGeomRef m_geom; + Nz::Collider3DRef m_geom; bool m_bodyUpdated; }; } diff --git a/SDK/include/NDK/Components/CollisionComponent.inl b/SDK/include/NDK/Components/CollisionComponent.inl index b08e7054e..c34b1e219 100644 --- a/SDK/include/NDK/Components/CollisionComponent.inl +++ b/SDK/include/NDK/Components/CollisionComponent.inl @@ -15,7 +15,7 @@ namespace Ndk * \param geom Reference to a geometry symbolizing the entity */ - inline CollisionComponent::CollisionComponent(Nz::PhysGeomRef geom) : + inline CollisionComponent::CollisionComponent(Nz::Collider3DRef geom) : m_geom(std::move(geom)), m_bodyUpdated(false) { @@ -38,7 +38,7 @@ namespace Ndk * \return A constant reference to the physics geometry */ - inline const Nz::PhysGeomRef& CollisionComponent::GetGeom() const + inline const Nz::Collider3DRef& CollisionComponent::GetGeom() const { return m_geom; } @@ -50,7 +50,7 @@ namespace Ndk * \param geom Reference to a geometry symbolizing the entity */ - inline CollisionComponent& CollisionComponent::operator=(Nz::PhysGeomRef geom) + inline CollisionComponent& CollisionComponent::operator=(Nz::Collider3DRef geom) { SetGeom(geom); diff --git a/SDK/src/NDK/Components/CollisionComponent.cpp b/SDK/src/NDK/Components/CollisionComponent.cpp index 7e8f9481a..130eae7dd 100644 --- a/SDK/src/NDK/Components/CollisionComponent.cpp +++ b/SDK/src/NDK/Components/CollisionComponent.cpp @@ -25,7 +25,7 @@ namespace Ndk * \remark Produces a NazaraAssert if the entity has no physics component and has no static body */ - void CollisionComponent::SetGeom(Nz::PhysGeomRef geom) + void CollisionComponent::SetGeom(Nz::Collider3DRef geom) { m_geom = std::move(geom); diff --git a/SDK/src/NDK/Components/PhysicsComponent.cpp b/SDK/src/NDK/Components/PhysicsComponent.cpp index 91be73792..668dbcd79 100644 --- a/SDK/src/NDK/Components/PhysicsComponent.cpp +++ b/SDK/src/NDK/Components/PhysicsComponent.cpp @@ -31,7 +31,7 @@ namespace Ndk Nz::PhysWorld& world = entityWorld->GetSystem().GetWorld(); - Nz::PhysGeomRef geom; + Nz::Collider3DRef geom; if (m_entity->HasComponent()) geom = m_entity->GetComponent().GetGeom(); @@ -75,7 +75,7 @@ namespace Ndk if (IsComponent(component)) { NazaraAssert(m_object, "Invalid object"); - m_object->SetGeom(Nz::NullGeom::New()); + m_object->SetGeom(Nz::NullCollider3D::New()); } } diff --git a/include/Nazara/Physics3D/Collider3D.hpp b/include/Nazara/Physics3D/Collider3D.hpp index 59946d5c5..e4f8de63e 100644 --- a/include/Nazara/Physics3D/Collider3D.hpp +++ b/include/Nazara/Physics3D/Collider3D.hpp @@ -75,16 +75,16 @@ namespace Nz static Collider3DLibrary::LibraryMap s_library; }; - class BoxGeom; + class BoxCollider3D; - using BoxGeomConstRef = ObjectRef; - using BoxGeomRef = ObjectRef; + using BoxCollider3DConstRef = ObjectRef; + using BoxCollider3DRef = ObjectRef; - class NAZARA_PHYSICS3D_API BoxGeom : public Collider3D + class NAZARA_PHYSICS3D_API BoxCollider3D : public Collider3D { public: - BoxGeom(const Vector3f& lengths, const Matrix4f& transformMatrix = Matrix4f::Identity()); - BoxGeom(const Vector3f& lengths, const Vector3f& translation, const Quaternionf& rotation = Quaternionf::Identity()); + BoxCollider3D(const Vector3f& lengths, const Matrix4f& transformMatrix = Matrix4f::Identity()); + BoxCollider3D(const Vector3f& lengths, const Vector3f& translation, const Quaternionf& rotation = Quaternionf::Identity()); Boxf ComputeAABB(const Matrix4f& offsetMatrix = Matrix4f::Identity(), const Vector3f& scale = Vector3f::Unit()) const override; float ComputeVolume() const override; @@ -92,7 +92,7 @@ namespace Nz Vector3f GetLengths() const; GeomType GetType() const override; - template static BoxGeomRef New(Args&&... args); + template static BoxCollider3DRef New(Args&&... args); private: NewtonCollision* CreateHandle(PhysWorld* world) const override; @@ -101,22 +101,22 @@ namespace Nz Vector3f m_lengths; }; - class CapsuleGeom; + class CapsuleCollider3D; - using CapsuleGeomConstRef = ObjectRef; - using CapsuleGeomRef = ObjectRef; + using CapsuleCollider3DConstRef = ObjectRef; + using CapsuleCollider3DRef = ObjectRef; - class NAZARA_PHYSICS3D_API CapsuleGeom : public Collider3D + class NAZARA_PHYSICS3D_API CapsuleCollider3D : public Collider3D { public: - CapsuleGeom(float length, float radius, const Matrix4f& transformMatrix = Matrix4f::Identity()); - CapsuleGeom(float length, float radius, const Vector3f& translation, const Quaternionf& rotation = Quaternionf::Identity()); + CapsuleCollider3D(float length, float radius, const Matrix4f& transformMatrix = Matrix4f::Identity()); + CapsuleCollider3D(float length, float radius, const Vector3f& translation, const Quaternionf& rotation = Quaternionf::Identity()); float GetLength() const; float GetRadius() const; GeomType GetType() const override; - template static CapsuleGeomRef New(Args&&... args); + template static CapsuleCollider3DRef New(Args&&... args); private: NewtonCollision* CreateHandle(PhysWorld* world) const override; @@ -126,20 +126,20 @@ namespace Nz float m_radius; }; - class CompoundGeom; + class CompoundCollider3D; - using CompoundGeomConstRef = ObjectRef; - using CompoundGeomRef = ObjectRef; + using CompoundCollider3DConstRef = ObjectRef; + using CompoundCollider3DRef = ObjectRef; - class NAZARA_PHYSICS3D_API CompoundGeom : public Collider3D + class NAZARA_PHYSICS3D_API CompoundCollider3D : public Collider3D { public: - CompoundGeom(Collider3D** geoms, std::size_t geomCount); + CompoundCollider3D(Collider3D** geoms, std::size_t geomCount); const std::vector& GetGeoms() const; GeomType GetType() const override; - template static CompoundGeomRef New(Args&&... args); + template static CompoundCollider3DRef New(Args&&... args); private: NewtonCollision* CreateHandle(PhysWorld* world) const override; @@ -147,22 +147,22 @@ namespace Nz std::vector m_geoms; }; - class ConeGeom; + class ConeCollider3D; - using ConeGeomConstRef = ObjectRef; - using ConeGeomRef = ObjectRef; + using ConeCollider3DConstRef = ObjectRef; + using ConeCollider3DRef = ObjectRef; - class NAZARA_PHYSICS3D_API ConeGeom : public Collider3D + class NAZARA_PHYSICS3D_API ConeCollider3D : public Collider3D { public: - ConeGeom(float length, float radius, const Matrix4f& transformMatrix = Matrix4f::Identity()); - ConeGeom(float length, float radius, const Vector3f& translation, const Quaternionf& rotation = Quaternionf::Identity()); + ConeCollider3D(float length, float radius, const Matrix4f& transformMatrix = Matrix4f::Identity()); + ConeCollider3D(float length, float radius, const Vector3f& translation, const Quaternionf& rotation = Quaternionf::Identity()); float GetLength() const; float GetRadius() const; GeomType GetType() const override; - template static ConeGeomRef New(Args&&... args); + template static ConeCollider3DRef New(Args&&... args); private: NewtonCollision* CreateHandle(PhysWorld* world) const override; @@ -172,20 +172,20 @@ namespace Nz float m_radius; }; - class ConvexHullGeom; + class ConvexCollider3D; - using ConvexHullGeomConstRef = ObjectRef; - using ConvexHullGeomRef = ObjectRef; + using ConvexCollider3DConstRef = ObjectRef; + using ConvexCollider3DRef = ObjectRef; - class NAZARA_PHYSICS3D_API ConvexHullGeom : public Collider3D + class NAZARA_PHYSICS3D_API ConvexCollider3D : public Collider3D { 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()); + ConvexCollider3D(const void* vertices, unsigned int vertexCount, unsigned int stride = sizeof(Vector3f), float tolerance = 0.002f, const Matrix4f& transformMatrix = Matrix4f::Identity()); + ConvexCollider3D(const void* vertices, unsigned int vertexCount, unsigned int stride, float tolerance, const Vector3f& translation, const Quaternionf& rotation = Quaternionf::Identity()); GeomType GetType() const override; - template static ConvexHullGeomRef New(Args&&... args); + template static ConvexCollider3DRef New(Args&&... args); private: NewtonCollision* CreateHandle(PhysWorld* world) const override; @@ -196,22 +196,22 @@ namespace Nz unsigned int m_vertexStride; }; - class CylinderGeom; + class CylinderCollider3D; - using CylinderGeomConstRef = ObjectRef; - using CylinderGeomRef = ObjectRef; + using CylinderCollider3DConstRef = ObjectRef; + using CylinderCollider3DRef = ObjectRef; - class NAZARA_PHYSICS3D_API CylinderGeom : public Collider3D + class NAZARA_PHYSICS3D_API CylinderCollider3D : public Collider3D { public: - CylinderGeom(float length, float radius, const Matrix4f& transformMatrix = Matrix4f::Identity()); - CylinderGeom(float length, float radius, const Vector3f& translation, const Quaternionf& rotation = Quaternionf::Identity()); + CylinderCollider3D(float length, float radius, const Matrix4f& transformMatrix = Matrix4f::Identity()); + CylinderCollider3D(float length, float radius, const Vector3f& translation, const Quaternionf& rotation = Quaternionf::Identity()); float GetLength() const; float GetRadius() const; GeomType GetType() const override; - template static CylinderGeomRef New(Args&&... args); + template static CylinderCollider3DRef New(Args&&... args); private: NewtonCollision* CreateHandle(PhysWorld* world) const override; @@ -221,36 +221,36 @@ namespace Nz float m_radius; }; - class NullGeom; + class NullCollider3D; - using NullGeomConstRef = ObjectRef; - using NullGeomRef = ObjectRef; + using NullCollider3DConstRef = ObjectRef; + using NullCollider3DRef = ObjectRef; - class NAZARA_PHYSICS3D_API NullGeom : public Collider3D + class NAZARA_PHYSICS3D_API NullCollider3D : public Collider3D { public: - NullGeom(); + NullCollider3D(); void ComputeInertialMatrix(Vector3f* inertia, Vector3f* center) const override; GeomType GetType() const override; - template static NullGeomRef New(Args&&... args); + template static NullCollider3DRef New(Args&&... args); private: NewtonCollision* CreateHandle(PhysWorld* world) const override; }; - class SphereGeom; + class SphereCollider3D; - using SphereGeomConstRef = ObjectRef; - using SphereGeomRef = ObjectRef; + using SphereCollider3DConstRef = ObjectRef; + using SphereCollider3DRef = ObjectRef; - class NAZARA_PHYSICS3D_API SphereGeom : public Collider3D + class NAZARA_PHYSICS3D_API SphereCollider3D : public Collider3D { public: - SphereGeom(float radius, const Matrix4f& transformMatrix = Matrix4f::Identity()); - SphereGeom(float radius, const Vector3f& translation, const Quaternionf& rotation = Quaternionf::Identity()); + SphereCollider3D(float radius, const Matrix4f& transformMatrix = Matrix4f::Identity()); + SphereCollider3D(float radius, const Vector3f& translation, const Quaternionf& rotation = Quaternionf::Identity()); Boxf ComputeAABB(const Matrix4f& offsetMatrix = Matrix4f::Identity(), const Vector3f& scale = Vector3f::Unit()) const override; float ComputeVolume() const override; @@ -258,7 +258,7 @@ namespace Nz float GetRadius() const; GeomType GetType() const override; - template static SphereGeomRef New(Args&&... args); + template static SphereCollider3DRef New(Args&&... args); private: NewtonCollision* CreateHandle(PhysWorld* world) const override; diff --git a/include/Nazara/Physics3D/Collider3D.inl b/include/Nazara/Physics3D/Collider3D.inl index 9caf824aa..dc2d5184f 100644 --- a/include/Nazara/Physics3D/Collider3D.inl +++ b/include/Nazara/Physics3D/Collider3D.inl @@ -8,72 +8,72 @@ namespace Nz { template - BoxGeomRef BoxGeom::New(Args&&... args) + BoxCollider3DRef BoxCollider3D::New(Args&&... args) { - std::unique_ptr object(new BoxGeom(std::forward(args)...)); + std::unique_ptr object(new BoxCollider3D(std::forward(args)...)); object->SetPersistent(false); return object.release(); } template - CapsuleGeomRef CapsuleGeom::New(Args&&... args) + CapsuleCollider3DRef CapsuleCollider3D::New(Args&&... args) { - std::unique_ptr object(new CapsuleGeom(std::forward(args)...)); + std::unique_ptr object(new CapsuleCollider3D(std::forward(args)...)); object->SetPersistent(false); return object.release(); } template - CompoundGeomRef CompoundGeom::New(Args&&... args) + CompoundCollider3DRef CompoundCollider3D::New(Args&&... args) { - std::unique_ptr object(new CompoundGeom(std::forward(args)...)); + std::unique_ptr object(new CompoundCollider3D(std::forward(args)...)); object->SetPersistent(false); return object.release(); } template - ConeGeomRef ConeGeom::New(Args&&... args) + ConeCollider3DRef ConeCollider3D::New(Args&&... args) { - std::unique_ptr object(new ConeGeom(std::forward(args)...)); + std::unique_ptr object(new ConeCollider3D(std::forward(args)...)); object->SetPersistent(false); return object.release(); } template - ConvexHullGeomRef ConvexHullGeom::New(Args&&... args) + ConvexCollider3DRef ConvexCollider3D::New(Args&&... args) { - std::unique_ptr object(new ConvexHullGeom(std::forward(args)...)); + std::unique_ptr object(new ConvexCollider3D(std::forward(args)...)); object->SetPersistent(false); return object.release(); } template - CylinderGeomRef CylinderGeom::New(Args&&... args) + CylinderCollider3DRef CylinderCollider3D::New(Args&&... args) { - std::unique_ptr object(new CylinderGeom(std::forward(args)...)); + std::unique_ptr object(new CylinderCollider3D(std::forward(args)...)); object->SetPersistent(false); return object.release(); } template - NullGeomRef NullGeom::New(Args&&... args) + NullCollider3DRef NullCollider3D::New(Args&&... args) { - std::unique_ptr object(new NullGeom(std::forward(args)...)); + std::unique_ptr object(new NullCollider3D(std::forward(args)...)); object->SetPersistent(false); return object.release(); } template - SphereGeomRef SphereGeom::New(Args&&... args) + SphereCollider3DRef SphereCollider3D::New(Args&&... args) { - std::unique_ptr object(new SphereGeom(std::forward(args)...)); + std::unique_ptr object(new SphereCollider3D(std::forward(args)...)); object->SetPersistent(false); return object.release(); diff --git a/include/Nazara/Physics3D/PhysObject.hpp b/include/Nazara/Physics3D/PhysObject.hpp index fac27e940..e819c8e09 100644 --- a/include/Nazara/Physics3D/PhysObject.hpp +++ b/include/Nazara/Physics3D/PhysObject.hpp @@ -13,7 +13,7 @@ #include #include #include -#include +#include class NewtonBody; @@ -25,7 +25,7 @@ namespace Nz { public: PhysObject(PhysWorld* world, const Matrix4f& mat = Matrix4f::Identity()); - PhysObject(PhysWorld* world, PhysGeomRef geom, const Matrix4f& mat = Matrix4f::Identity()); + PhysObject(PhysWorld* world, Collider3DRef geom, const Matrix4f& mat = Matrix4f::Identity()); PhysObject(const PhysObject& object); PhysObject(PhysObject&& object); ~PhysObject(); @@ -38,7 +38,7 @@ namespace Nz Boxf GetAABB() const; Vector3f GetAngularVelocity() const; - const PhysGeomRef& GetGeom() const; + const Collider3DRef& GetGeom() const; float GetGravityFactor() const; NewtonBody* GetHandle() const; float GetMass() const; @@ -53,7 +53,7 @@ namespace Nz bool IsSleeping() const; void SetAngularVelocity(const Vector3f& angularVelocity); - void SetGeom(PhysGeomRef geom); + void SetGeom(Collider3DRef geom); void SetGravityFactor(float gravityFactor); void SetMass(float mass); void SetMassCenter(const Vector3f& center); @@ -70,7 +70,7 @@ namespace Nz static void TransformCallback(const NewtonBody* body, const float* matrix, int threadIndex); Matrix4f m_matrix; - PhysGeomRef m_geom; + Collider3DRef m_geom; Vector3f m_forceAccumulator; Vector3f m_torqueAccumulator; NewtonBody* m_body; diff --git a/src/Nazara/Physics3D/Collider3D.cpp b/src/Nazara/Physics3D/Collider3D.cpp index f01e79047..1487bdd01 100644 --- a/src/Nazara/Physics3D/Collider3D.cpp +++ b/src/Nazara/Physics3D/Collider3D.cpp @@ -2,7 +2,7 @@ // This file is part of the "Nazara Engine - Physics module" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include #include #include @@ -12,26 +12,26 @@ namespace Nz { namespace { - PhysGeomRef CreateGeomFromPrimitive(const Primitive& primitive) + Collider3DRef CreateGeomFromPrimitive(const Primitive& primitive) { switch (primitive.type) { case PrimitiveType_Box: - return BoxGeom::New(primitive.box.lengths, primitive.matrix); + return BoxCollider3D::New(primitive.box.lengths, primitive.matrix); case PrimitiveType_Cone: - return ConeGeom::New(primitive.cone.length, primitive.cone.radius, primitive.matrix); + return ConeCollider3D::New(primitive.cone.length, primitive.cone.radius, primitive.matrix); case PrimitiveType_Plane: - return BoxGeom::New(Vector3f(primitive.plane.size.x, 0.01f, primitive.plane.size.y), primitive.matrix); + return BoxCollider3D::New(Vector3f(primitive.plane.size.x, 0.01f, primitive.plane.size.y), primitive.matrix); ///TODO: PlaneGeom? case PrimitiveType_Sphere: - return SphereGeom::New(primitive.sphere.size, primitive.matrix.GetTranslation()); + return SphereCollider3D::New(primitive.sphere.size, primitive.matrix.GetTranslation()); } NazaraError("Primitive type not handled (0x" + String::Number(primitive.type, 16) + ')'); - return PhysGeomRef(); + return Collider3DRef(); } } @@ -123,7 +123,7 @@ namespace Nz return it->second; } - PhysGeomRef Collider3D::Build(const PrimitiveList& list) + Collider3DRef Collider3D::Build(const PrimitiveList& list) { std::size_t primitiveCount = list.GetSize(); if (primitiveCount > 1) @@ -133,17 +133,17 @@ namespace Nz for (unsigned int i = 0; i < primitiveCount; ++i) geoms[i] = CreateGeomFromPrimitive(list.GetPrimitive(i)); - return CompoundGeom::New(&geoms[0], primitiveCount); + return CompoundCollider3D::New(&geoms[0], primitiveCount); } else if (primitiveCount > 0) return CreateGeomFromPrimitive(list.GetPrimitive(0)); else - return NullGeom::New(); + return NullCollider3D::New(); } bool Collider3D::Initialize() { - if (!PhysGeomLibrary::Initialize()) + if (!Collider3DLibrary::Initialize()) { NazaraError("Failed to initialise library"); return false; @@ -154,25 +154,25 @@ namespace Nz void Collider3D::Uninitialize() { - PhysGeomLibrary::Uninitialize(); + Collider3DLibrary::Uninitialize(); } - PhysGeomLibrary::LibraryMap Collider3D::s_library; + Collider3DLibrary::LibraryMap Collider3D::s_library; - /********************************** BoxGeom **********************************/ + /********************************** BoxCollider3D **********************************/ - BoxGeom::BoxGeom(const Vector3f& lengths, const Matrix4f& transformMatrix) : + BoxCollider3D::BoxCollider3D(const Vector3f& lengths, const Matrix4f& transformMatrix) : m_matrix(transformMatrix), m_lengths(lengths) { } - BoxGeom::BoxGeom(const Vector3f& lengths, const Vector3f& translation, const Quaternionf& rotation) : - BoxGeom(lengths, Matrix4f::Transform(translation, rotation)) + BoxCollider3D::BoxCollider3D(const Vector3f& lengths, const Vector3f& translation, const Quaternionf& rotation) : + BoxCollider3D(lengths, Matrix4f::Transform(translation, rotation)) { } - Boxf BoxGeom::ComputeAABB(const Matrix4f& offsetMatrix, const Vector3f& scale) const + Boxf BoxCollider3D::ComputeAABB(const Matrix4f& offsetMatrix, const Vector3f& scale) const { Vector3f halfLengths(m_lengths * 0.5f); @@ -183,90 +183,90 @@ namespace Nz return aabb; } - float BoxGeom::ComputeVolume() const + float BoxCollider3D::ComputeVolume() const { return m_lengths.x * m_lengths.y * m_lengths.z; } - Vector3f BoxGeom::GetLengths() const + Vector3f BoxCollider3D::GetLengths() const { return m_lengths; } - GeomType BoxGeom::GetType() const + GeomType BoxCollider3D::GetType() const { return GeomType_Box; } - NewtonCollision* BoxGeom::CreateHandle(PhysWorld* world) const + NewtonCollision* BoxCollider3D::CreateHandle(PhysWorld* world) const { return NewtonCreateBox(world->GetHandle(), m_lengths.x, m_lengths.y, m_lengths.z, 0, m_matrix); } - /******************************** CapsuleGeom ********************************/ + /******************************** CapsuleCollider3D ********************************/ - CapsuleGeom::CapsuleGeom(float length, float radius, const Matrix4f& transformMatrix) : + CapsuleCollider3D::CapsuleCollider3D(float length, float radius, const Matrix4f& transformMatrix) : m_matrix(transformMatrix), m_length(length), m_radius(radius) { } - CapsuleGeom::CapsuleGeom(float length, float radius, const Vector3f& translation, const Quaternionf& rotation) : - CapsuleGeom(length, radius, Matrix4f::Transform(translation, rotation)) + CapsuleCollider3D::CapsuleCollider3D(float length, float radius, const Vector3f& translation, const Quaternionf& rotation) : + CapsuleCollider3D(length, radius, Matrix4f::Transform(translation, rotation)) { } - float CapsuleGeom::GetLength() const + float CapsuleCollider3D::GetLength() const { return m_length; } - float CapsuleGeom::GetRadius() const + float CapsuleCollider3D::GetRadius() const { return m_radius; } - GeomType CapsuleGeom::GetType() const + GeomType CapsuleCollider3D::GetType() const { return GeomType_Capsule; } - NewtonCollision* CapsuleGeom::CreateHandle(PhysWorld* world) const + NewtonCollision* CapsuleCollider3D::CreateHandle(PhysWorld* world) const { return NewtonCreateCapsule(world->GetHandle(), m_radius, m_length, 0, m_matrix); } - /******************************* CompoundGeom ********************************/ + /******************************* CompoundCollider3D ********************************/ - CompoundGeom::CompoundGeom(Collider3D** geoms, std::size_t geomCount) + CompoundCollider3D::CompoundCollider3D(Collider3D** geoms, std::size_t geomCount) { m_geoms.reserve(geomCount); for (std::size_t i = 0; i < geomCount; ++i) m_geoms.emplace_back(geoms[i]); } - const std::vector& CompoundGeom::GetGeoms() const + const std::vector& CompoundCollider3D::GetGeoms() const { return m_geoms; } - GeomType CompoundGeom::GetType() const + GeomType CompoundCollider3D::GetType() const { return GeomType_Compound; } - NewtonCollision* CompoundGeom::CreateHandle(PhysWorld* world) const + NewtonCollision* CompoundCollider3D::CreateHandle(PhysWorld* world) const { NewtonCollision* compoundCollision = NewtonCreateCompoundCollision(world->GetHandle(), 0); NewtonCompoundCollisionBeginAddRemove(compoundCollision); - for (const PhysGeomRef& geom : m_geoms) + for (const Collider3DRef& geom : m_geoms) { if (geom->GetType() == GeomType_Compound) { - CompoundGeom* compoundGeom = static_cast(geom.Get()); - for (const PhysGeomRef& piece : compoundGeom->GetGeoms()) + CompoundCollider3D* compoundGeom = static_cast(geom.Get()); + for (const Collider3DRef& piece : compoundGeom->GetGeoms()) NewtonCompoundCollisionAddSubCollision(compoundCollision, piece->GetHandle(world)); } else @@ -277,43 +277,43 @@ namespace Nz return compoundCollision; } - /********************************* ConeGeom **********************************/ + /********************************* ConeCollider3D **********************************/ - ConeGeom::ConeGeom(float length, float radius, const Matrix4f& transformMatrix) : + ConeCollider3D::ConeCollider3D(float length, float radius, const Matrix4f& transformMatrix) : m_matrix(transformMatrix), m_length(length), m_radius(radius) { } - ConeGeom::ConeGeom(float length, float radius, const Vector3f& translation, const Quaternionf& rotation) : - ConeGeom(length, radius, Matrix4f::Transform(translation, rotation)) + ConeCollider3D::ConeCollider3D(float length, float radius, const Vector3f& translation, const Quaternionf& rotation) : + ConeCollider3D(length, radius, Matrix4f::Transform(translation, rotation)) { } - float ConeGeom::GetLength() const + float ConeCollider3D::GetLength() const { return m_length; } - float ConeGeom::GetRadius() const + float ConeCollider3D::GetRadius() const { return m_radius; } - GeomType ConeGeom::GetType() const + GeomType ConeCollider3D::GetType() const { return GeomType_Cone; } - NewtonCollision* ConeGeom::CreateHandle(PhysWorld* world) const + NewtonCollision* ConeCollider3D::CreateHandle(PhysWorld* world) const { return NewtonCreateCone(world->GetHandle(), m_radius, m_length, 0, m_matrix); } - /****************************** ConvexHullGeom *******************************/ + /****************************** ConvexCollider3D *******************************/ - ConvexHullGeom::ConvexHullGeom(const void* vertices, unsigned int vertexCount, unsigned int stride, float tolerance, const Matrix4f& transformMatrix) : + ConvexCollider3D::ConvexCollider3D(const void* vertices, unsigned int vertexCount, unsigned int stride, float tolerance, const Matrix4f& transformMatrix) : m_matrix(transformMatrix), m_tolerance(tolerance), m_vertexStride(stride) @@ -330,67 +330,67 @@ namespace Nz std::memcpy(m_vertices.data(), vertices, vertexCount*sizeof(Vector3f)); } - ConvexHullGeom::ConvexHullGeom(const void* vertices, unsigned int vertexCount, unsigned int stride, float tolerance, const Vector3f& translation, const Quaternionf& rotation) : - ConvexHullGeom(vertices, vertexCount, stride, tolerance, Matrix4f::Transform(translation, rotation)) + ConvexCollider3D::ConvexCollider3D(const void* vertices, unsigned int vertexCount, unsigned int stride, float tolerance, const Vector3f& translation, const Quaternionf& rotation) : + ConvexCollider3D(vertices, vertexCount, stride, tolerance, Matrix4f::Transform(translation, rotation)) { } - GeomType ConvexHullGeom::GetType() const + GeomType ConvexCollider3D::GetType() const { return GeomType_Compound; } - NewtonCollision* ConvexHullGeom::CreateHandle(PhysWorld* world) const + NewtonCollision* ConvexCollider3D::CreateHandle(PhysWorld* world) const { return NewtonCreateConvexHull(world->GetHandle(), static_cast(m_vertices.size()), reinterpret_cast(m_vertices.data()), sizeof(Vector3f), m_tolerance, 0, m_matrix); } - /******************************* CylinderGeom ********************************/ + /******************************* CylinderCollider3D ********************************/ - CylinderGeom::CylinderGeom(float length, float radius, const Matrix4f& transformMatrix) : + CylinderCollider3D::CylinderCollider3D(float length, float radius, const Matrix4f& transformMatrix) : m_matrix(transformMatrix), m_length(length), m_radius(radius) { } - CylinderGeom::CylinderGeom(float length, float radius, const Vector3f& translation, const Quaternionf& rotation) : - CylinderGeom(length, radius, Matrix4f::Transform(translation, rotation)) + CylinderCollider3D::CylinderCollider3D(float length, float radius, const Vector3f& translation, const Quaternionf& rotation) : + CylinderCollider3D(length, radius, Matrix4f::Transform(translation, rotation)) { } - float CylinderGeom::GetLength() const + float CylinderCollider3D::GetLength() const { return m_length; } - float CylinderGeom::GetRadius() const + float CylinderCollider3D::GetRadius() const { return m_radius; } - GeomType CylinderGeom::GetType() const + GeomType CylinderCollider3D::GetType() const { return GeomType_Cylinder; } - NewtonCollision* CylinderGeom::CreateHandle(PhysWorld* world) const + NewtonCollision* CylinderCollider3D::CreateHandle(PhysWorld* world) const { return NewtonCreateCylinder(world->GetHandle(), m_radius, m_length, 0, m_matrix); } - /********************************* NullGeom **********************************/ + /********************************* NullCollider3D **********************************/ - NullGeom::NullGeom() + NullCollider3D::NullCollider3D() { } - GeomType NullGeom::GetType() const + GeomType NullCollider3D::GetType() const { return GeomType_Null; } - void NullGeom::ComputeInertialMatrix(Vector3f* inertia, Vector3f* center) const + void NullCollider3D::ComputeInertialMatrix(Vector3f* inertia, Vector3f* center) const { if (inertia) inertia->MakeUnit(); @@ -399,26 +399,26 @@ namespace Nz center->MakeZero(); } - NewtonCollision* NullGeom::CreateHandle(PhysWorld* world) const + NewtonCollision* NullCollider3D::CreateHandle(PhysWorld* world) const { return NewtonCreateNull(world->GetHandle()); } - /******************************** SphereGeom *********************************/ + /******************************** SphereCollider3D *********************************/ - SphereGeom::SphereGeom(float radius, const Matrix4f& transformMatrix) : - SphereGeom(radius, transformMatrix.GetTranslation()) + SphereCollider3D::SphereCollider3D(float radius, const Matrix4f& transformMatrix) : + SphereCollider3D(radius, transformMatrix.GetTranslation()) { } - SphereGeom::SphereGeom(float radius, const Vector3f& translation, const Quaternionf& rotation) : + SphereCollider3D::SphereCollider3D(float radius, const Vector3f& translation, const Quaternionf& rotation) : m_position(translation), m_radius(radius) { NazaraUnused(rotation); } - Boxf SphereGeom::ComputeAABB(const Matrix4f& offsetMatrix, const Vector3f& scale) const + Boxf SphereCollider3D::ComputeAABB(const Matrix4f& offsetMatrix, const Vector3f& scale) const { Vector3f size(m_radius * NazaraSuffixMacro(M_SQRT3, f) * scale); Vector3f position(offsetMatrix.GetTranslation()); @@ -426,22 +426,22 @@ namespace Nz return Boxf(position - size, position + size); } - float SphereGeom::ComputeVolume() const + float SphereCollider3D::ComputeVolume() const { return float(M_PI) * m_radius * m_radius * m_radius / 3.f; } - float SphereGeom::GetRadius() const + float SphereCollider3D::GetRadius() const { return m_radius; } - GeomType SphereGeom::GetType() const + GeomType SphereCollider3D::GetType() const { return GeomType_Sphere; } - NewtonCollision* SphereGeom::CreateHandle(PhysWorld* world) const + NewtonCollision* SphereCollider3D::CreateHandle(PhysWorld* world) const { return NewtonCreateSphere(world->GetHandle(), m_radius, 0, Matrix4f::Translate(m_position)); } diff --git a/src/Nazara/Physics3D/PhysObject.cpp b/src/Nazara/Physics3D/PhysObject.cpp index 7fa02789b..f23070654 100644 --- a/src/Nazara/Physics3D/PhysObject.cpp +++ b/src/Nazara/Physics3D/PhysObject.cpp @@ -13,11 +13,11 @@ namespace Nz { PhysObject::PhysObject(PhysWorld* world, const Matrix4f& mat) : - PhysObject(world, NullGeom::New(), mat) + PhysObject(world, NullCollider3D::New(), mat) { } - PhysObject::PhysObject(PhysWorld* world, PhysGeomRef geom, const Matrix4f& mat) : + PhysObject::PhysObject(PhysWorld* world, Collider3DRef geom, const Matrix4f& mat) : m_matrix(mat), m_geom(std::move(geom)), m_forceAccumulator(Vector3f::Zero()), @@ -29,7 +29,7 @@ namespace Nz NazaraAssert(m_world, "Invalid world"); if (!m_geom) - m_geom = NullGeom::New(); + m_geom = NullCollider3D::New(); m_body = NewtonCreateDynamicBody(m_world->GetHandle(), m_geom->GetHandle(m_world), m_matrix); NewtonBodySetUserData(m_body, this); @@ -143,7 +143,7 @@ namespace Nz return angularVelocity; } - const PhysGeomRef& PhysObject::GetGeom() const + const Collider3DRef& PhysObject::GetGeom() const { return m_geom; } @@ -224,14 +224,14 @@ namespace Nz NewtonBodySetOmega(m_body, angularVelocity); } - void PhysObject::SetGeom(PhysGeomRef geom) + void PhysObject::SetGeom(Collider3DRef geom) { if (m_geom.Get() != geom) { if (geom) m_geom = geom; else - m_geom = NullGeom::New(); + m_geom = NullCollider3D::New(); NewtonBodySetCollision(m_body, m_geom->GetHandle(m_world)); } diff --git a/src/Nazara/Physics3D/Physics.cpp b/src/Nazara/Physics3D/Physics.cpp index 9c7b1d122..592075097 100644 --- a/src/Nazara/Physics3D/Physics.cpp +++ b/src/Nazara/Physics3D/Physics.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include From 49f4df649619f9abef1cf5da65b1d7d1d6bd5c06 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 13 Oct 2016 07:30:04 +0200 Subject: [PATCH 05/10] Physics: Fix linking --- include/Nazara/Physics3D/Config.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/Nazara/Physics3D/Config.hpp b/include/Nazara/Physics3D/Config.hpp index 23669240a..f2db50fce 100644 --- a/include/Nazara/Physics3D/Config.hpp +++ b/include/Nazara/Physics3D/Config.hpp @@ -41,7 +41,7 @@ #if defined(NAZARA_STATIC) #define NAZARA_PHYSICS3D_API #else - #ifdef NAZARA_PHYSICS_BUILD + #ifdef NAZARA_PHYSICS3D_BUILD #define NAZARA_PHYSICS3D_API NAZARA_EXPORT #else #define NAZARA_PHYSICS3D_API NAZARA_IMPORT From 3c4d084b278fd9c7dd442650a83fcf72cbe17272 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 13 Oct 2016 07:40:12 +0200 Subject: [PATCH 06/10] Physics3D: Rename Physics module class to Physics3D --- SDK/src/NDK/Sdk.cpp | 6 +++--- include/Nazara/Physics3D/Collider3D.hpp | 4 ++-- include/Nazara/Physics3D/Collider3D.inl | 2 +- include/Nazara/Physics3D/Config.hpp | 2 +- include/Nazara/Physics3D/ConfigCheck.hpp | 2 +- include/Nazara/Physics3D/Debug.hpp | 2 +- include/Nazara/Physics3D/DebugOff.hpp | 2 +- include/Nazara/Physics3D/Enums.hpp | 2 +- include/Nazara/Physics3D/PhysObject.hpp | 2 +- include/Nazara/Physics3D/PhysWorld.hpp | 2 +- .../Physics3D/{Physics.hpp => Physics3D.hpp} | 14 +++++++------- src/Nazara/Physics3D/Collider3D.cpp | 2 +- src/Nazara/Physics3D/Debug/NewOverload.cpp | 2 +- src/Nazara/Physics3D/PhysObject.cpp | 2 +- src/Nazara/Physics3D/PhysWorld.cpp | 2 +- .../Physics3D/{Physics.cpp => Physics3D.cpp} | 18 +++++++++--------- 16 files changed, 33 insertions(+), 33 deletions(-) rename include/Nazara/Physics3D/{Physics.hpp => Physics3D.hpp} (66%) rename src/Nazara/Physics3D/{Physics.cpp => Physics3D.cpp} (75%) diff --git a/SDK/src/NDK/Sdk.cpp b/SDK/src/NDK/Sdk.cpp index bf6c9abbb..895adf178 100644 --- a/SDK/src/NDK/Sdk.cpp +++ b/SDK/src/NDK/Sdk.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include @@ -68,7 +68,7 @@ namespace Ndk Nz::Lua::Initialize(); Nz::Noise::Initialize(); - Nz::Physics::Initialize(); + Nz::Physics3D::Initialize(); Nz::Utility::Initialize(); #ifndef NDK_SERVER @@ -161,7 +161,7 @@ namespace Ndk // Shared modules Nz::Lua::Uninitialize(); Nz::Noise::Uninitialize(); - Nz::Physics::Uninitialize(); + Nz::Physics3D::Uninitialize(); Nz::Utility::Uninitialize(); NazaraNotice("Uninitialized: SDK"); diff --git a/include/Nazara/Physics3D/Collider3D.hpp b/include/Nazara/Physics3D/Collider3D.hpp index e4f8de63e..463e6afac 100644 --- a/include/Nazara/Physics3D/Collider3D.hpp +++ b/include/Nazara/Physics3D/Collider3D.hpp @@ -1,5 +1,5 @@ // Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Physics module" +// This file is part of the "Nazara Engine - Physics 3D module" // For conditions of distribution and use, see copyright notice in Config.hpp #pragma once @@ -40,7 +40,7 @@ namespace Nz class NAZARA_PHYSICS3D_API Collider3D : public RefCounted { friend Collider3DLibrary; - friend class Physics; + friend class Physics3D; public: Collider3D() = default; diff --git a/include/Nazara/Physics3D/Collider3D.inl b/include/Nazara/Physics3D/Collider3D.inl index dc2d5184f..aeb7073d8 100644 --- a/include/Nazara/Physics3D/Collider3D.inl +++ b/include/Nazara/Physics3D/Collider3D.inl @@ -1,5 +1,5 @@ // Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Physics module" +// This file is part of the "Nazara Engine - Physics 3D module" // For conditions of distribution and use, see copyright notice in Config.hpp #include diff --git a/include/Nazara/Physics3D/Config.hpp b/include/Nazara/Physics3D/Config.hpp index f2db50fce..91ecec8e3 100644 --- a/include/Nazara/Physics3D/Config.hpp +++ b/include/Nazara/Physics3D/Config.hpp @@ -1,5 +1,5 @@ /* - Nazara Engine - Physics module + Nazara Engine - Physics 3D module Copyright (C) 2015 Jérôme "Lynix" Leclercq (Lynix680@gmail.com) diff --git a/include/Nazara/Physics3D/ConfigCheck.hpp b/include/Nazara/Physics3D/ConfigCheck.hpp index 937712b0e..6b1c82073 100644 --- a/include/Nazara/Physics3D/ConfigCheck.hpp +++ b/include/Nazara/Physics3D/ConfigCheck.hpp @@ -1,5 +1,5 @@ // Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Physics module" +// This file is part of the "Nazara Engine - Physics 3D module" // For conditions of distribution and use, see copyright notice in Config.hpp #pragma once diff --git a/include/Nazara/Physics3D/Debug.hpp b/include/Nazara/Physics3D/Debug.hpp index d8b47e454..f70a8b570 100644 --- a/include/Nazara/Physics3D/Debug.hpp +++ b/include/Nazara/Physics3D/Debug.hpp @@ -1,5 +1,5 @@ // Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Physics module" +// This file is part of the "Nazara Engine - Physics 3D module" // For conditions of distribution and use, see copyright notice in Config.hpp #include diff --git a/include/Nazara/Physics3D/DebugOff.hpp b/include/Nazara/Physics3D/DebugOff.hpp index 4ea033e46..595f0ad94 100644 --- a/include/Nazara/Physics3D/DebugOff.hpp +++ b/include/Nazara/Physics3D/DebugOff.hpp @@ -1,5 +1,5 @@ // Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Physics module" +// This file is part of the "Nazara Engine - Physics 3D module" // For conditions of distribution and use, see copyright notice in Config.hpp // On suppose que Debug.hpp a déjà été inclus, tout comme Config.hpp diff --git a/include/Nazara/Physics3D/Enums.hpp b/include/Nazara/Physics3D/Enums.hpp index 1951d3eda..853f30b23 100644 --- a/include/Nazara/Physics3D/Enums.hpp +++ b/include/Nazara/Physics3D/Enums.hpp @@ -1,5 +1,5 @@ // Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Physics module" +// This file is part of the "Nazara Engine - Physics 3D module" // For conditions of distribution and use, see copyright notice in Config.hpp #pragma once diff --git a/include/Nazara/Physics3D/PhysObject.hpp b/include/Nazara/Physics3D/PhysObject.hpp index e819c8e09..a2894d0ce 100644 --- a/include/Nazara/Physics3D/PhysObject.hpp +++ b/include/Nazara/Physics3D/PhysObject.hpp @@ -1,5 +1,5 @@ // Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Physics module" +// This file is part of the "Nazara Engine - Physics 3D module" // For conditions of distribution and use, see copyright notice in Config.hpp #pragma once diff --git a/include/Nazara/Physics3D/PhysWorld.hpp b/include/Nazara/Physics3D/PhysWorld.hpp index 1bd072bf2..06d0aea4e 100644 --- a/include/Nazara/Physics3D/PhysWorld.hpp +++ b/include/Nazara/Physics3D/PhysWorld.hpp @@ -1,5 +1,5 @@ // Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Physics module" +// This file is part of the "Nazara Engine - Physics 3D module" // For conditions of distribution and use, see copyright notice in Config.hpp #pragma once diff --git a/include/Nazara/Physics3D/Physics.hpp b/include/Nazara/Physics3D/Physics3D.hpp similarity index 66% rename from include/Nazara/Physics3D/Physics.hpp rename to include/Nazara/Physics3D/Physics3D.hpp index 4efaa5cb4..949301002 100644 --- a/include/Nazara/Physics3D/Physics.hpp +++ b/include/Nazara/Physics3D/Physics3D.hpp @@ -1,11 +1,11 @@ // Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Physics module" +// This file is part of the "Nazara Engine - Physics 3D module" // For conditions of distribution and use, see copyright notice in Config.hpp #pragma once -#ifndef NAZARA_PHYSICS_HPP -#define NAZARA_PHYSICS_HPP +#ifndef NAZARA_PHYSICS3D_HPP +#define NAZARA_PHYSICS3D_HPP #include #include @@ -13,11 +13,11 @@ namespace Nz { - class NAZARA_PHYSICS3D_API Physics + class NAZARA_PHYSICS3D_API Physics3D { public: - Physics() = delete; - ~Physics() = delete; + Physics3D() = delete; + ~Physics3D() = delete; static unsigned int GetMemoryUsed(); @@ -32,4 +32,4 @@ namespace Nz }; } -#endif // NAZARA_PHYSICS_HPP +#endif // NAZARA_PHYSICS3D_HPP diff --git a/src/Nazara/Physics3D/Collider3D.cpp b/src/Nazara/Physics3D/Collider3D.cpp index 1487bdd01..4ea0175e3 100644 --- a/src/Nazara/Physics3D/Collider3D.cpp +++ b/src/Nazara/Physics3D/Collider3D.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Physics module" +// This file is part of the "Nazara Engine - Physics 3D module" // For conditions of distribution and use, see copyright notice in Config.hpp #include diff --git a/src/Nazara/Physics3D/Debug/NewOverload.cpp b/src/Nazara/Physics3D/Debug/NewOverload.cpp index f6c7b64de..18092514c 100644 --- a/src/Nazara/Physics3D/Debug/NewOverload.cpp +++ b/src/Nazara/Physics3D/Debug/NewOverload.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Physics module" +// This file is part of the "Nazara Engine - Physics 3D module" // For conditions of distribution and use, see copyright notice in Config.hpp #include diff --git a/src/Nazara/Physics3D/PhysObject.cpp b/src/Nazara/Physics3D/PhysObject.cpp index f23070654..283d7ac84 100644 --- a/src/Nazara/Physics3D/PhysObject.cpp +++ b/src/Nazara/Physics3D/PhysObject.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Physics module" +// This file is part of the "Nazara Engine - Physics 3D module" // For conditions of distribution and use, see copyright notice in Config.hpp #include diff --git a/src/Nazara/Physics3D/PhysWorld.cpp b/src/Nazara/Physics3D/PhysWorld.cpp index 5d2170aad..020a54cfb 100644 --- a/src/Nazara/Physics3D/PhysWorld.cpp +++ b/src/Nazara/Physics3D/PhysWorld.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Physics module" +// This file is part of the "Nazara Engine - Physics 3D module" // For conditions of distribution and use, see copyright notice in Config.hpp #include diff --git a/src/Nazara/Physics3D/Physics.cpp b/src/Nazara/Physics3D/Physics3D.cpp similarity index 75% rename from src/Nazara/Physics3D/Physics.cpp rename to src/Nazara/Physics3D/Physics3D.cpp index 592075097..8fb470f2a 100644 --- a/src/Nazara/Physics3D/Physics.cpp +++ b/src/Nazara/Physics3D/Physics3D.cpp @@ -1,8 +1,8 @@ // Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Physics module" +// This file is part of the "Nazara Engine - Physics 3D module" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include #include #include @@ -13,12 +13,12 @@ namespace Nz { - unsigned int Physics::GetMemoryUsed() + unsigned int Physics3D::GetMemoryUsed() { return NewtonGetMemoryUsed(); } - bool Physics::Initialize() + bool Physics3D::Initialize() { if (s_moduleReferenceCounter > 0) { @@ -42,16 +42,16 @@ namespace Nz return false; } - NazaraNotice("Initialized: Physics module"); + NazaraNotice("Initialized: Physics3D module"); return true; } - bool Physics::IsInitialized() + bool Physics3D::IsInitialized() { return s_moduleReferenceCounter != 0; } - void Physics::Uninitialize() + void Physics3D::Uninitialize() { if (s_moduleReferenceCounter != 1) { @@ -67,11 +67,11 @@ namespace Nz s_moduleReferenceCounter = 0; - NazaraNotice("Uninitialized: Physics module"); + NazaraNotice("Uninitialized: Physics3D module"); // Libération des dépendances Core::Uninitialize(); } - unsigned int Physics::s_moduleReferenceCounter = 0; + unsigned int Physics3D::s_moduleReferenceCounter = 0; } From 3765cba0465c1461669240e561711cbcf3a96a93 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 13 Oct 2016 08:06:14 +0200 Subject: [PATCH 07/10] Physics3D: Rename PhysObject to RigidBody3D --- .../NDK/Components/CollisionComponent.hpp | 6 +- .../NDK/Components/CollisionComponent.inl | 2 +- .../NDK/Components/PhysicsComponent.hpp | 4 +- .../NDK/Components/PhysicsComponent.inl | 2 +- SDK/src/NDK/Components/CollisionComponent.cpp | 2 +- SDK/src/NDK/Components/PhysicsComponent.cpp | 2 +- SDK/src/NDK/Systems/PhysicsSystem.cpp | 4 +- .../{PhysObject.hpp => RigidBody3D.hpp} | 24 ++-- .../{PhysObject.cpp => RigidBody3D.cpp} | 105 +++++++++--------- 9 files changed, 74 insertions(+), 77 deletions(-) rename include/Nazara/Physics3D/{PhysObject.hpp => RigidBody3D.hpp} (80%) rename src/Nazara/Physics3D/{PhysObject.cpp => RigidBody3D.cpp} (70%) diff --git a/SDK/include/NDK/Components/CollisionComponent.hpp b/SDK/include/NDK/Components/CollisionComponent.hpp index 722a5476e..565a60871 100644 --- a/SDK/include/NDK/Components/CollisionComponent.hpp +++ b/SDK/include/NDK/Components/CollisionComponent.hpp @@ -13,7 +13,7 @@ namespace Nz { - class PhysObject; + class RigidBody3D; } namespace Ndk @@ -41,14 +41,14 @@ namespace Ndk private: void InitializeStaticBody(); - Nz::PhysObject* GetStaticBody(); + Nz::RigidBody3D* GetStaticBody(); void OnAttached() override; void OnComponentAttached(BaseComponent& component) override; void OnComponentDetached(BaseComponent& component) override; void OnDetached() override; - std::unique_ptr m_staticBody; + std::unique_ptr m_staticBody; Nz::Collider3DRef m_geom; bool m_bodyUpdated; }; diff --git a/SDK/include/NDK/Components/CollisionComponent.inl b/SDK/include/NDK/Components/CollisionComponent.inl index c34b1e219..7243996fb 100644 --- a/SDK/include/NDK/Components/CollisionComponent.inl +++ b/SDK/include/NDK/Components/CollisionComponent.inl @@ -62,7 +62,7 @@ namespace Ndk * \return A pointer to the entity */ - inline Nz::PhysObject* CollisionComponent::GetStaticBody() + inline Nz::RigidBody3D* CollisionComponent::GetStaticBody() { return m_staticBody.get(); } diff --git a/SDK/include/NDK/Components/PhysicsComponent.hpp b/SDK/include/NDK/Components/PhysicsComponent.hpp index 97d2c62f6..b6abe24e1 100644 --- a/SDK/include/NDK/Components/PhysicsComponent.hpp +++ b/SDK/include/NDK/Components/PhysicsComponent.hpp @@ -56,14 +56,14 @@ namespace Ndk static ComponentIndex componentIndex; private: - Nz::PhysObject& GetPhysObject(); + Nz::RigidBody3D& GetPhysObject(); void OnAttached() override; void OnComponentAttached(BaseComponent& component) override; void OnComponentDetached(BaseComponent& component) override; void OnDetached() override; - std::unique_ptr m_object; + std::unique_ptr m_object; }; } diff --git a/SDK/include/NDK/Components/PhysicsComponent.inl b/SDK/include/NDK/Components/PhysicsComponent.inl index 5682603e0..009d62ba5 100644 --- a/SDK/include/NDK/Components/PhysicsComponent.inl +++ b/SDK/include/NDK/Components/PhysicsComponent.inl @@ -350,7 +350,7 @@ namespace Ndk * \return A reference to the physics object */ - inline Nz::PhysObject& PhysicsComponent::GetPhysObject() + inline Nz::RigidBody3D& PhysicsComponent::GetPhysObject() { return *m_object.get(); } diff --git a/SDK/src/NDK/Components/CollisionComponent.cpp b/SDK/src/NDK/Components/CollisionComponent.cpp index 130eae7dd..44d70be24 100644 --- a/SDK/src/NDK/Components/CollisionComponent.cpp +++ b/SDK/src/NDK/Components/CollisionComponent.cpp @@ -58,7 +58,7 @@ namespace Ndk NazaraAssert(entityWorld->HasSystem(), "World must have a physics system"); Nz::PhysWorld& physWorld = entityWorld->GetSystem().GetWorld(); - m_staticBody.reset(new Nz::PhysObject(&physWorld, m_geom)); + m_staticBody.reset(new Nz::RigidBody3D(&physWorld, m_geom)); m_staticBody->EnableAutoSleep(false); } diff --git a/SDK/src/NDK/Components/PhysicsComponent.cpp b/SDK/src/NDK/Components/PhysicsComponent.cpp index 668dbcd79..2ac6e3dab 100644 --- a/SDK/src/NDK/Components/PhysicsComponent.cpp +++ b/SDK/src/NDK/Components/PhysicsComponent.cpp @@ -41,7 +41,7 @@ namespace Ndk else matrix.MakeIdentity(); - m_object.reset(new Nz::PhysObject(&world, geom, matrix)); + m_object.reset(new Nz::RigidBody3D(&world, geom, matrix)); m_object->SetMass(1.f); } diff --git a/SDK/src/NDK/Systems/PhysicsSystem.cpp b/SDK/src/NDK/Systems/PhysicsSystem.cpp index f6621261a..83a368b37 100644 --- a/SDK/src/NDK/Systems/PhysicsSystem.cpp +++ b/SDK/src/NDK/Systems/PhysicsSystem.cpp @@ -83,7 +83,7 @@ namespace Ndk NodeComponent& node = entity->GetComponent(); PhysicsComponent& phys = entity->GetComponent(); - Nz::PhysObject& physObj = phys.GetPhysObject(); + Nz::RigidBody3D& physObj = phys.GetPhysObject(); node.SetRotation(physObj.GetRotation(), Nz::CoordSys_Global); node.SetPosition(physObj.GetPosition(), Nz::CoordSys_Global); } @@ -94,7 +94,7 @@ namespace Ndk CollisionComponent& collision = entity->GetComponent(); NodeComponent& node = entity->GetComponent(); - Nz::PhysObject* physObj = collision.GetStaticBody(); + Nz::RigidBody3D* physObj = collision.GetStaticBody(); Nz::Quaternionf oldRotation = physObj->GetRotation(); Nz::Vector3f oldPosition = physObj->GetPosition(); diff --git a/include/Nazara/Physics3D/PhysObject.hpp b/include/Nazara/Physics3D/RigidBody3D.hpp similarity index 80% rename from include/Nazara/Physics3D/PhysObject.hpp rename to include/Nazara/Physics3D/RigidBody3D.hpp index a2894d0ce..0a92cb310 100644 --- a/include/Nazara/Physics3D/PhysObject.hpp +++ b/include/Nazara/Physics3D/RigidBody3D.hpp @@ -4,8 +4,8 @@ #pragma once -#ifndef NAZARA_PHYSOBJECT_HPP -#define NAZARA_PHYSOBJECT_HPP +#ifndef NAZARA_RIGIDBODY3D_HPP +#define NAZARA_RIGIDBODY3D_HPP #include #include @@ -21,14 +21,14 @@ namespace Nz { class PhysWorld; - class NAZARA_PHYSICS3D_API PhysObject + class NAZARA_PHYSICS3D_API RigidBody3D { public: - PhysObject(PhysWorld* world, const Matrix4f& mat = Matrix4f::Identity()); - PhysObject(PhysWorld* world, Collider3DRef geom, const Matrix4f& mat = Matrix4f::Identity()); - PhysObject(const PhysObject& object); - PhysObject(PhysObject&& object); - ~PhysObject(); + RigidBody3D(PhysWorld* world, const Matrix4f& mat = Matrix4f::Identity()); + RigidBody3D(PhysWorld* world, Collider3DRef geom, const Matrix4f& mat = Matrix4f::Identity()); + RigidBody3D(const RigidBody3D& object); + RigidBody3D(RigidBody3D&& object); + ~RigidBody3D(); void AddForce(const Vector3f& force, CoordSys coordSys = CoordSys_Global); void AddForce(const Vector3f& force, const Vector3f& point, CoordSys coordSys = CoordSys_Global); @@ -61,16 +61,16 @@ namespace Nz void SetRotation(const Quaternionf& rotation); void SetVelocity(const Vector3f& velocity); - PhysObject& operator=(const PhysObject& object); - PhysObject& operator=(PhysObject&& object); + RigidBody3D& operator=(const RigidBody3D& object); + RigidBody3D& operator=(RigidBody3D&& object); 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; Collider3DRef m_geom; + Matrix4f m_matrix; Vector3f m_forceAccumulator; Vector3f m_torqueAccumulator; NewtonBody* m_body; @@ -80,4 +80,4 @@ namespace Nz }; } -#endif // NAZARA_PHYSOBJECT_HPP +#endif // NAZARA_RIGIDBODY3D_HPP diff --git a/src/Nazara/Physics3D/PhysObject.cpp b/src/Nazara/Physics3D/RigidBody3D.cpp similarity index 70% rename from src/Nazara/Physics3D/PhysObject.cpp rename to src/Nazara/Physics3D/RigidBody3D.cpp index 283d7ac84..9a2d3d545 100644 --- a/src/Nazara/Physics3D/PhysObject.cpp +++ b/src/Nazara/Physics3D/RigidBody3D.cpp @@ -2,7 +2,7 @@ // This file is part of the "Nazara Engine - Physics 3D module" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include #include #include @@ -12,14 +12,14 @@ namespace Nz { - PhysObject::PhysObject(PhysWorld* world, const Matrix4f& mat) : - PhysObject(world, NullCollider3D::New(), mat) + RigidBody3D::RigidBody3D(PhysWorld* world, const Matrix4f& mat) : + RigidBody3D(world, NullCollider3D::New(), mat) { } - PhysObject::PhysObject(PhysWorld* world, Collider3DRef geom, const Matrix4f& mat) : - m_matrix(mat), + RigidBody3D::RigidBody3D(PhysWorld* world, Collider3DRef geom, const Matrix4f& mat) : m_geom(std::move(geom)), + m_matrix(mat), m_forceAccumulator(Vector3f::Zero()), m_torqueAccumulator(Vector3f::Zero()), m_world(world), @@ -35,9 +35,9 @@ namespace Nz NewtonBodySetUserData(m_body, this); } - PhysObject::PhysObject(const PhysObject& object) : - m_matrix(object.m_matrix), + RigidBody3D::RigidBody3D(const RigidBody3D& object) : m_geom(object.m_geom), + m_matrix(object.m_matrix), m_forceAccumulator(Vector3f::Zero()), m_torqueAccumulator(Vector3f::Zero()), m_world(object.m_world), @@ -52,9 +52,9 @@ namespace Nz SetMass(object.m_mass); } - PhysObject::PhysObject(PhysObject&& object) : - m_matrix(std::move(object.m_matrix)), + RigidBody3D::RigidBody3D(RigidBody3D&& object) : m_geom(std::move(object.m_geom)), + m_matrix(std::move(object.m_matrix)), m_forceAccumulator(std::move(object.m_forceAccumulator)), m_torqueAccumulator(std::move(object.m_torqueAccumulator)), m_body(object.m_body), @@ -65,13 +65,13 @@ namespace Nz object.m_body = nullptr; } - PhysObject::~PhysObject() + RigidBody3D::~RigidBody3D() { if (m_body) NewtonDestroyBody(m_body); } - void PhysObject::AddForce(const Vector3f& force, CoordSys coordSys) + void RigidBody3D::AddForce(const Vector3f& force, CoordSys coordSys) { switch (coordSys) { @@ -88,7 +88,7 @@ namespace Nz NewtonBodySetSleepState(m_body, 0); } - void PhysObject::AddForce(const Vector3f& force, const Vector3f& point, CoordSys coordSys) + void RigidBody3D::AddForce(const Vector3f& force, const Vector3f& point, CoordSys coordSys) { switch (coordSys) { @@ -105,7 +105,7 @@ namespace Nz NewtonBodySetSleepState(m_body, 0); } - void PhysObject::AddTorque(const Vector3f& torque, CoordSys coordSys) + void RigidBody3D::AddTorque(const Vector3f& torque, CoordSys coordSys) { switch (coordSys) { @@ -122,12 +122,12 @@ namespace Nz NewtonBodySetSleepState(m_body, 0); } - void PhysObject::EnableAutoSleep(bool autoSleep) + void RigidBody3D::EnableAutoSleep(bool autoSleep) { NewtonBodySetAutoSleep(m_body, autoSleep); } - Boxf PhysObject::GetAABB() const + Boxf RigidBody3D::GetAABB() const { Vector3f min, max; NewtonBodyGetAABB(m_body, min, max); @@ -135,7 +135,7 @@ namespace Nz return Boxf(min, max); } - Vector3f PhysObject::GetAngularVelocity() const + Vector3f RigidBody3D::GetAngularVelocity() const { Vector3f angularVelocity; NewtonBodyGetOmega(m_body, angularVelocity); @@ -143,27 +143,27 @@ namespace Nz return angularVelocity; } - const Collider3DRef& PhysObject::GetGeom() const + const Collider3DRef& RigidBody3D::GetGeom() const { return m_geom; } - float PhysObject::GetGravityFactor() const + float RigidBody3D::GetGravityFactor() const { return m_gravityFactor; } - NewtonBody* PhysObject::GetHandle() const + NewtonBody* RigidBody3D::GetHandle() const { return m_body; } - float PhysObject::GetMass() const + float RigidBody3D::GetMass() const { return m_mass; } - Vector3f PhysObject::GetMassCenter(CoordSys coordSys) const + Vector3f RigidBody3D::GetMassCenter(CoordSys coordSys) const { Vector3f center; NewtonBodyGetCentreOfMass(m_body, center); @@ -181,22 +181,22 @@ namespace Nz return center; } - const Matrix4f& PhysObject::GetMatrix() const + const Matrix4f& RigidBody3D::GetMatrix() const { return m_matrix; } - Vector3f PhysObject::GetPosition() const + Vector3f RigidBody3D::GetPosition() const { return m_matrix.GetTranslation(); } - Quaternionf PhysObject::GetRotation() const + Quaternionf RigidBody3D::GetRotation() const { return m_matrix.GetRotation(); } - Vector3f PhysObject::GetVelocity() const + Vector3f RigidBody3D::GetVelocity() const { Vector3f velocity; NewtonBodyGetVelocity(m_body, velocity); @@ -204,27 +204,27 @@ namespace Nz return velocity; } - bool PhysObject::IsAutoSleepEnabled() const + bool RigidBody3D::IsAutoSleepEnabled() const { return NewtonBodyGetAutoSleep(m_body) != 0; } - bool PhysObject::IsMoveable() const + bool RigidBody3D::IsMoveable() const { return m_mass > 0.f; } - bool PhysObject::IsSleeping() const + bool RigidBody3D::IsSleeping() const { return NewtonBodyGetSleepState(m_body) != 0; } - void PhysObject::SetAngularVelocity(const Vector3f& angularVelocity) + void RigidBody3D::SetAngularVelocity(const Vector3f& angularVelocity) { NewtonBodySetOmega(m_body, angularVelocity); } - void PhysObject::SetGeom(Collider3DRef geom) + void RigidBody3D::SetGeom(Collider3DRef geom) { if (m_geom.Get() != geom) { @@ -237,17 +237,19 @@ namespace Nz } } - void PhysObject::SetGravityFactor(float gravityFactor) + void RigidBody3D::SetGravityFactor(float gravityFactor) { m_gravityFactor = gravityFactor; } - void PhysObject::SetMass(float mass) + void RigidBody3D::SetMass(float mass) { if (m_mass > 0.f) { + // If we already have a mass, we already have an inertial matrix as well, just rescale it float Ix, Iy, Iz; NewtonBodyGetMassMatrix(m_body, &m_mass, &Ix, &Iy, &Iz); + float scale = mass/m_mass; NewtonBodySetMassMatrix(m_body, mass, Ix*scale, Iy*scale, Iz*scale); } @@ -265,41 +267,44 @@ namespace Nz m_mass = mass; } - void PhysObject::SetMassCenter(const Vector3f& center) + void RigidBody3D::SetMassCenter(const Vector3f& center) { if (m_mass > 0.f) NewtonBodySetCentreOfMass(m_body, center); } - void PhysObject::SetPosition(const Vector3f& position) + void RigidBody3D::SetPosition(const Vector3f& position) { m_matrix.SetTranslation(position); + UpdateBody(); } - void PhysObject::SetRotation(const Quaternionf& rotation) + void RigidBody3D::SetRotation(const Quaternionf& rotation) { m_matrix.SetRotation(rotation); + UpdateBody(); } - void PhysObject::SetVelocity(const Vector3f& velocity) + void RigidBody3D::SetVelocity(const Vector3f& velocity) { NewtonBodySetVelocity(m_body, velocity); } - PhysObject& PhysObject::operator=(const PhysObject& object) + RigidBody3D& RigidBody3D::operator=(const RigidBody3D& object) { - PhysObject physObj(object); + RigidBody3D physObj(object); return operator=(std::move(physObj)); } - void PhysObject::UpdateBody() + void RigidBody3D::UpdateBody() { NewtonBodySetMatrix(m_body, m_matrix); if (NumberEquals(m_mass, 0.f)) { + // Moving a static body in Newton does not update bodies at the target location // http://newtondynamics.com/wiki/index.php5?title=Can_i_dynamicly_move_a_TriMesh%3F Vector3f min, max; NewtonBodyGetAABB(m_body, min, max); @@ -312,11 +317,9 @@ namespace Nz }, nullptr); } - /*for (std::set::iterator it = m_listeners.begin(); it != m_listeners.end(); ++it) - (*it)->PhysObjectOnUpdate(this);*/ } - PhysObject& PhysObject::operator=(PhysObject&& object) + RigidBody3D& RigidBody3D::operator=(RigidBody3D&& object) { if (m_body) NewtonDestroyBody(m_body); @@ -335,36 +338,30 @@ namespace Nz return *this; } - void PhysObject::ForceAndTorqueCallback(const NewtonBody* body, float timeStep, int threadIndex) + void RigidBody3D::ForceAndTorqueCallback(const NewtonBody* body, float timeStep, int threadIndex) { NazaraUnused(timeStep); NazaraUnused(threadIndex); - PhysObject* me = static_cast(NewtonBodyGetUserData(body)); + RigidBody3D* me = static_cast(NewtonBodyGetUserData(body)); if (!NumberEquals(me->m_gravityFactor, 0.f)) me->m_forceAccumulator += me->m_world->GetGravity() * me->m_gravityFactor * me->m_mass; - /*for (std::set::iterator it = me->m_listeners.begin(); it != me->m_listeners.end(); ++it) - (*it)->PhysObjectApplyForce(me);*/ - NewtonBodySetForce(body, me->m_forceAccumulator); NewtonBodySetTorque(body, me->m_torqueAccumulator); me->m_torqueAccumulator.Set(0.f); me->m_forceAccumulator.Set(0.f); - ///TODO: Implanter la force gyroscopique? + ///TODO: Implement gyroscopic force? } - void PhysObject::TransformCallback(const NewtonBody* body, const float* matrix, int threadIndex) + void RigidBody3D::TransformCallback(const NewtonBody* body, const float* matrix, int threadIndex) { NazaraUnused(threadIndex); - PhysObject* me = static_cast(NewtonBodyGetUserData(body)); + RigidBody3D* me = static_cast(NewtonBodyGetUserData(body)); me->m_matrix.Set(matrix); - - /*for (std::set::iterator it = me->m_listeners.begin(); it != me->m_listeners.end(); ++it) - (*it)->PhysObjectOnUpdate(me);*/ - } + } } From b52c7c57bf6dcaaa2c5ee1f4c087234c8417784d Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 13 Oct 2016 08:13:56 +0200 Subject: [PATCH 08/10] Physics3D: Rename PhysWorld to PhysWorld3D --- .../NDK/Components/PhysicsComponent.hpp | 2 +- SDK/include/NDK/Systems/PhysicsSystem.hpp | 8 +++---- SDK/include/NDK/Systems/PhysicsSystem.inl | 4 ++-- SDK/src/NDK/Components/CollisionComponent.cpp | 4 ++-- SDK/src/NDK/Components/PhysicsComponent.cpp | 4 ++-- SDK/src/NDK/Systems/PhysicsSystem.cpp | 4 ++-- include/Nazara/Physics3D/Collider3D.hpp | 24 +++++++++---------- .../{PhysWorld.hpp => PhysWorld3D.hpp} | 14 +++++------ include/Nazara/Physics3D/RigidBody3D.hpp | 8 +++---- src/Nazara/Physics3D/Collider3D.cpp | 24 +++++++++---------- .../{PhysWorld.cpp => PhysWorld3D.cpp} | 18 +++++++------- src/Nazara/Physics3D/RigidBody3D.cpp | 4 ++-- 12 files changed, 59 insertions(+), 59 deletions(-) rename include/Nazara/Physics3D/{PhysWorld.hpp => PhysWorld3D.hpp} (74%) rename src/Nazara/Physics3D/{PhysWorld.cpp => PhysWorld3D.cpp} (69%) diff --git a/SDK/include/NDK/Components/PhysicsComponent.hpp b/SDK/include/NDK/Components/PhysicsComponent.hpp index b6abe24e1..c426d71bb 100644 --- a/SDK/include/NDK/Components/PhysicsComponent.hpp +++ b/SDK/include/NDK/Components/PhysicsComponent.hpp @@ -7,7 +7,7 @@ #ifndef NDK_COMPONENTS_PHYSICSCOMPONENT_HPP #define NDK_COMPONENTS_PHYSICSCOMPONENT_HPP -#include +#include #include #include diff --git a/SDK/include/NDK/Systems/PhysicsSystem.hpp b/SDK/include/NDK/Systems/PhysicsSystem.hpp index 3eb4f8f2e..1e5400e82 100644 --- a/SDK/include/NDK/Systems/PhysicsSystem.hpp +++ b/SDK/include/NDK/Systems/PhysicsSystem.hpp @@ -7,7 +7,7 @@ #ifndef NDK_SYSTEMS_PHYSICSSYSTEM_HPP #define NDK_SYSTEMS_PHYSICSSYSTEM_HPP -#include +#include #include #include #include @@ -21,8 +21,8 @@ namespace Ndk PhysicsSystem(const PhysicsSystem& system); ~PhysicsSystem() = default; - Nz::PhysWorld& GetWorld(); - const Nz::PhysWorld& GetWorld() const; + Nz::PhysWorld3D& GetWorld(); + const Nz::PhysWorld3D& GetWorld() const; static SystemIndex systemIndex; @@ -32,7 +32,7 @@ namespace Ndk EntityList m_dynamicObjects; EntityList m_staticObjects; - std::unique_ptr m_world; ///TODO: std::optional (Should I make a Nz::Optional class?) + std::unique_ptr m_world; ///TODO: std::optional (Should I make a Nz::Optional class?) }; } diff --git a/SDK/include/NDK/Systems/PhysicsSystem.inl b/SDK/include/NDK/Systems/PhysicsSystem.inl index 443b82060..4ec400fe7 100644 --- a/SDK/include/NDK/Systems/PhysicsSystem.inl +++ b/SDK/include/NDK/Systems/PhysicsSystem.inl @@ -9,7 +9,7 @@ namespace Ndk * \return A reference to the physical world */ - inline Nz::PhysWorld& PhysicsSystem::GetWorld() + inline Nz::PhysWorld3D& PhysicsSystem::GetWorld() { return *m_world; } @@ -19,7 +19,7 @@ namespace Ndk * \return A constant reference to the physical world */ - inline const Nz::PhysWorld& PhysicsSystem::GetWorld() const + inline const Nz::PhysWorld3D& PhysicsSystem::GetWorld() const { return *m_world; } diff --git a/SDK/src/NDK/Components/CollisionComponent.cpp b/SDK/src/NDK/Components/CollisionComponent.cpp index 44d70be24..6806701f2 100644 --- a/SDK/src/NDK/Components/CollisionComponent.cpp +++ b/SDK/src/NDK/Components/CollisionComponent.cpp @@ -3,7 +3,7 @@ // For conditions of distribution and use, see copyright notice in Prerequesites.hpp #include -#include +#include #include #include #include @@ -56,7 +56,7 @@ namespace Ndk NazaraAssert(entityWorld, "Entity must have world"); NazaraAssert(entityWorld->HasSystem(), "World must have a physics system"); - Nz::PhysWorld& physWorld = entityWorld->GetSystem().GetWorld(); + Nz::PhysWorld3D& physWorld = entityWorld->GetSystem().GetWorld(); m_staticBody.reset(new Nz::RigidBody3D(&physWorld, m_geom)); m_staticBody->EnableAutoSleep(false); diff --git a/SDK/src/NDK/Components/PhysicsComponent.cpp b/SDK/src/NDK/Components/PhysicsComponent.cpp index 2ac6e3dab..ec9620541 100644 --- a/SDK/src/NDK/Components/PhysicsComponent.cpp +++ b/SDK/src/NDK/Components/PhysicsComponent.cpp @@ -3,7 +3,7 @@ // For conditions of distribution and use, see copyright notice in Prerequesites.hpp #include -#include +#include #include #include #include @@ -29,7 +29,7 @@ namespace Ndk World* entityWorld = m_entity->GetWorld(); NazaraAssert(entityWorld->HasSystem(), "World must have a physics system"); - Nz::PhysWorld& world = entityWorld->GetSystem().GetWorld(); + Nz::PhysWorld3D& world = entityWorld->GetSystem().GetWorld(); Nz::Collider3DRef geom; if (m_entity->HasComponent()) diff --git a/SDK/src/NDK/Systems/PhysicsSystem.cpp b/SDK/src/NDK/Systems/PhysicsSystem.cpp index 83a368b37..e30dd7abc 100644 --- a/SDK/src/NDK/Systems/PhysicsSystem.cpp +++ b/SDK/src/NDK/Systems/PhysicsSystem.cpp @@ -3,7 +3,7 @@ // For conditions of distribution and use, see copyright notice in Prerequesites.hpp #include -#include +#include #include #include #include @@ -62,7 +62,7 @@ namespace Ndk entities.Insert(entity); if (!m_world) - m_world = std::make_unique(); + m_world = std::make_unique(); } /*! diff --git a/include/Nazara/Physics3D/Collider3D.hpp b/include/Nazara/Physics3D/Collider3D.hpp index 463e6afac..351508f27 100644 --- a/include/Nazara/Physics3D/Collider3D.hpp +++ b/include/Nazara/Physics3D/Collider3D.hpp @@ -31,7 +31,7 @@ namespace Nz ///TODO: TreeGeom class Collider3D; - class PhysWorld; + class PhysWorld3D; using Collider3DConstRef = ObjectRef; using Collider3DLibrary = ObjectLibrary; @@ -53,7 +53,7 @@ namespace Nz virtual void ComputeInertialMatrix(Vector3f* inertia, Vector3f* center) const; virtual float ComputeVolume() const; - NewtonCollision* GetHandle(PhysWorld* world) const; + NewtonCollision* GetHandle(PhysWorld3D* world) const; virtual GeomType GetType() const = 0; Collider3D& operator=(const Collider3D&) = delete; @@ -65,12 +65,12 @@ namespace Nz NazaraSignal(OnColliderRelease, const Collider3D* /*collider*/); protected: - virtual NewtonCollision* CreateHandle(PhysWorld* world) const = 0; + virtual NewtonCollision* CreateHandle(PhysWorld3D* world) const = 0; static bool Initialize(); static void Uninitialize(); - mutable std::unordered_map m_handles; + mutable std::unordered_map m_handles; static Collider3DLibrary::LibraryMap s_library; }; @@ -95,7 +95,7 @@ namespace Nz template static BoxCollider3DRef New(Args&&... args); private: - NewtonCollision* CreateHandle(PhysWorld* world) const override; + NewtonCollision* CreateHandle(PhysWorld3D* world) const override; Matrix4f m_matrix; Vector3f m_lengths; @@ -119,7 +119,7 @@ namespace Nz template static CapsuleCollider3DRef New(Args&&... args); private: - NewtonCollision* CreateHandle(PhysWorld* world) const override; + NewtonCollision* CreateHandle(PhysWorld3D* world) const override; Matrix4f m_matrix; float m_length; @@ -142,7 +142,7 @@ namespace Nz template static CompoundCollider3DRef New(Args&&... args); private: - NewtonCollision* CreateHandle(PhysWorld* world) const override; + NewtonCollision* CreateHandle(PhysWorld3D* world) const override; std::vector m_geoms; }; @@ -165,7 +165,7 @@ namespace Nz template static ConeCollider3DRef New(Args&&... args); private: - NewtonCollision* CreateHandle(PhysWorld* world) const override; + NewtonCollision* CreateHandle(PhysWorld3D* world) const override; Matrix4f m_matrix; float m_length; @@ -188,7 +188,7 @@ namespace Nz template static ConvexCollider3DRef New(Args&&... args); private: - NewtonCollision* CreateHandle(PhysWorld* world) const override; + NewtonCollision* CreateHandle(PhysWorld3D* world) const override; std::vector m_vertices; Matrix4f m_matrix; @@ -214,7 +214,7 @@ namespace Nz template static CylinderCollider3DRef New(Args&&... args); private: - NewtonCollision* CreateHandle(PhysWorld* world) const override; + NewtonCollision* CreateHandle(PhysWorld3D* world) const override; Matrix4f m_matrix; float m_length; @@ -238,7 +238,7 @@ namespace Nz template static NullCollider3DRef New(Args&&... args); private: - NewtonCollision* CreateHandle(PhysWorld* world) const override; + NewtonCollision* CreateHandle(PhysWorld3D* world) const override; }; class SphereCollider3D; @@ -261,7 +261,7 @@ namespace Nz template static SphereCollider3DRef New(Args&&... args); private: - NewtonCollision* CreateHandle(PhysWorld* world) const override; + NewtonCollision* CreateHandle(PhysWorld3D* world) const override; Vector3f m_position; float m_radius; diff --git a/include/Nazara/Physics3D/PhysWorld.hpp b/include/Nazara/Physics3D/PhysWorld3D.hpp similarity index 74% rename from include/Nazara/Physics3D/PhysWorld.hpp rename to include/Nazara/Physics3D/PhysWorld3D.hpp index 06d0aea4e..ea84aa931 100644 --- a/include/Nazara/Physics3D/PhysWorld.hpp +++ b/include/Nazara/Physics3D/PhysWorld3D.hpp @@ -16,13 +16,13 @@ class NewtonWorld; namespace Nz { - class NAZARA_PHYSICS3D_API PhysWorld + class NAZARA_PHYSICS3D_API PhysWorld3D { public: - PhysWorld(); - PhysWorld(const PhysWorld&) = delete; - PhysWorld(PhysWorld&&) = delete; ///TODO - ~PhysWorld(); + PhysWorld3D(); + PhysWorld3D(const PhysWorld3D&) = delete; + PhysWorld3D(PhysWorld3D&&) = delete; ///TODO + ~PhysWorld3D(); Vector3f GetGravity() const; NewtonWorld* GetHandle() const; @@ -34,8 +34,8 @@ namespace Nz void Step(float timestep); - PhysWorld& operator=(const PhysWorld&) = delete; - PhysWorld& operator=(PhysWorld&&) = delete; ///TODO + PhysWorld3D& operator=(const PhysWorld3D&) = delete; + PhysWorld3D& operator=(PhysWorld3D&&) = delete; ///TODO private: Vector3f m_gravity; diff --git a/include/Nazara/Physics3D/RigidBody3D.hpp b/include/Nazara/Physics3D/RigidBody3D.hpp index 0a92cb310..d895e9040 100644 --- a/include/Nazara/Physics3D/RigidBody3D.hpp +++ b/include/Nazara/Physics3D/RigidBody3D.hpp @@ -19,13 +19,13 @@ class NewtonBody; namespace Nz { - class PhysWorld; + class PhysWorld3D; class NAZARA_PHYSICS3D_API RigidBody3D { public: - RigidBody3D(PhysWorld* world, const Matrix4f& mat = Matrix4f::Identity()); - RigidBody3D(PhysWorld* world, Collider3DRef geom, const Matrix4f& mat = Matrix4f::Identity()); + RigidBody3D(PhysWorld3D* world, const Matrix4f& mat = Matrix4f::Identity()); + RigidBody3D(PhysWorld3D* world, Collider3DRef geom, const Matrix4f& mat = Matrix4f::Identity()); RigidBody3D(const RigidBody3D& object); RigidBody3D(RigidBody3D&& object); ~RigidBody3D(); @@ -74,7 +74,7 @@ namespace Nz Vector3f m_forceAccumulator; Vector3f m_torqueAccumulator; NewtonBody* m_body; - PhysWorld* m_world; + PhysWorld3D* m_world; float m_gravityFactor; float m_mass; }; diff --git a/src/Nazara/Physics3D/Collider3D.cpp b/src/Nazara/Physics3D/Collider3D.cpp index 4ea0175e3..9afcdd80d 100644 --- a/src/Nazara/Physics3D/Collider3D.cpp +++ b/src/Nazara/Physics3D/Collider3D.cpp @@ -53,7 +53,7 @@ namespace Nz // Si nous n'avons aucune instance, nous en créons une temporaire if (m_handles.empty()) { - PhysWorld world; + PhysWorld3D world; NewtonCollision* collision = CreateHandle(&world); { @@ -75,7 +75,7 @@ namespace Nz // Si nous n'avons aucune instance, nous en créons une temporaire if (m_handles.empty()) { - PhysWorld world; + PhysWorld3D world; NewtonCollision* collision = CreateHandle(&world); { @@ -100,7 +100,7 @@ namespace Nz // Si nous n'avons aucune instance, nous en créons une temporaire if (m_handles.empty()) { - PhysWorld world; + PhysWorld3D world; NewtonCollision* collision = CreateHandle(&world); { @@ -114,7 +114,7 @@ namespace Nz return volume; } - NewtonCollision* Collider3D::GetHandle(PhysWorld* world) const + NewtonCollision* Collider3D::GetHandle(PhysWorld3D* world) const { auto it = m_handles.find(world); if (it == m_handles.end()) @@ -198,7 +198,7 @@ namespace Nz return GeomType_Box; } - NewtonCollision* BoxCollider3D::CreateHandle(PhysWorld* world) const + NewtonCollision* BoxCollider3D::CreateHandle(PhysWorld3D* world) const { return NewtonCreateBox(world->GetHandle(), m_lengths.x, m_lengths.y, m_lengths.z, 0, m_matrix); } @@ -232,7 +232,7 @@ namespace Nz return GeomType_Capsule; } - NewtonCollision* CapsuleCollider3D::CreateHandle(PhysWorld* world) const + NewtonCollision* CapsuleCollider3D::CreateHandle(PhysWorld3D* world) const { return NewtonCreateCapsule(world->GetHandle(), m_radius, m_length, 0, m_matrix); } @@ -256,7 +256,7 @@ namespace Nz return GeomType_Compound; } - NewtonCollision* CompoundCollider3D::CreateHandle(PhysWorld* world) const + NewtonCollision* CompoundCollider3D::CreateHandle(PhysWorld3D* world) const { NewtonCollision* compoundCollision = NewtonCreateCompoundCollision(world->GetHandle(), 0); @@ -306,7 +306,7 @@ namespace Nz return GeomType_Cone; } - NewtonCollision* ConeCollider3D::CreateHandle(PhysWorld* world) const + NewtonCollision* ConeCollider3D::CreateHandle(PhysWorld3D* world) const { return NewtonCreateCone(world->GetHandle(), m_radius, m_length, 0, m_matrix); } @@ -340,7 +340,7 @@ namespace Nz return GeomType_Compound; } - NewtonCollision* ConvexCollider3D::CreateHandle(PhysWorld* world) const + NewtonCollision* ConvexCollider3D::CreateHandle(PhysWorld3D* world) const { return NewtonCreateConvexHull(world->GetHandle(), static_cast(m_vertices.size()), reinterpret_cast(m_vertices.data()), sizeof(Vector3f), m_tolerance, 0, m_matrix); } @@ -374,7 +374,7 @@ namespace Nz return GeomType_Cylinder; } - NewtonCollision* CylinderCollider3D::CreateHandle(PhysWorld* world) const + NewtonCollision* CylinderCollider3D::CreateHandle(PhysWorld3D* world) const { return NewtonCreateCylinder(world->GetHandle(), m_radius, m_length, 0, m_matrix); } @@ -399,7 +399,7 @@ namespace Nz center->MakeZero(); } - NewtonCollision* NullCollider3D::CreateHandle(PhysWorld* world) const + NewtonCollision* NullCollider3D::CreateHandle(PhysWorld3D* world) const { return NewtonCreateNull(world->GetHandle()); } @@ -441,7 +441,7 @@ namespace Nz return GeomType_Sphere; } - NewtonCollision* SphereCollider3D::CreateHandle(PhysWorld* world) const + NewtonCollision* SphereCollider3D::CreateHandle(PhysWorld3D* world) const { return NewtonCreateSphere(world->GetHandle(), m_radius, 0, Matrix4f::Translate(m_position)); } diff --git a/src/Nazara/Physics3D/PhysWorld.cpp b/src/Nazara/Physics3D/PhysWorld3D.cpp similarity index 69% rename from src/Nazara/Physics3D/PhysWorld.cpp rename to src/Nazara/Physics3D/PhysWorld3D.cpp index 020a54cfb..8499071cd 100644 --- a/src/Nazara/Physics3D/PhysWorld.cpp +++ b/src/Nazara/Physics3D/PhysWorld3D.cpp @@ -8,7 +8,7 @@ namespace Nz { - PhysWorld::PhysWorld() : + PhysWorld3D::PhysWorld3D() : m_gravity(Vector3f::Zero()), m_stepSize(0.005f), m_timestepAccumulator(0.f) @@ -17,42 +17,42 @@ namespace Nz NewtonWorldSetUserData(m_world, this); } - PhysWorld::~PhysWorld() + PhysWorld3D::~PhysWorld3D() { NewtonDestroy(m_world); } - Vector3f PhysWorld::GetGravity() const + Vector3f PhysWorld3D::GetGravity() const { return m_gravity; } - NewtonWorld* PhysWorld::GetHandle() const + NewtonWorld* PhysWorld3D::GetHandle() const { return m_world; } - float PhysWorld::GetStepSize() const + float PhysWorld3D::GetStepSize() const { return m_stepSize; } - void PhysWorld::SetGravity(const Vector3f& gravity) + void PhysWorld3D::SetGravity(const Vector3f& gravity) { m_gravity = gravity; } - void PhysWorld::SetSolverModel(unsigned int model) + void PhysWorld3D::SetSolverModel(unsigned int model) { NewtonSetSolverModel(m_world, model); } - void PhysWorld::SetStepSize(float stepSize) + void PhysWorld3D::SetStepSize(float stepSize) { m_stepSize = stepSize; } - void PhysWorld::Step(float timestep) + void PhysWorld3D::Step(float timestep) { m_timestepAccumulator += timestep; diff --git a/src/Nazara/Physics3D/RigidBody3D.cpp b/src/Nazara/Physics3D/RigidBody3D.cpp index 9a2d3d545..86e78f100 100644 --- a/src/Nazara/Physics3D/RigidBody3D.cpp +++ b/src/Nazara/Physics3D/RigidBody3D.cpp @@ -12,12 +12,12 @@ namespace Nz { - RigidBody3D::RigidBody3D(PhysWorld* world, const Matrix4f& mat) : + RigidBody3D::RigidBody3D(PhysWorld3D* world, const Matrix4f& mat) : RigidBody3D(world, NullCollider3D::New(), mat) { } - RigidBody3D::RigidBody3D(PhysWorld* world, Collider3DRef geom, const Matrix4f& mat) : + RigidBody3D::RigidBody3D(PhysWorld3D* world, Collider3DRef geom, const Matrix4f& mat) : m_geom(std::move(geom)), m_matrix(mat), m_forceAccumulator(Vector3f::Zero()), From be44a89a858b72fb2ea352d47ccd1219e838c55d Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 13 Oct 2016 08:23:25 +0200 Subject: [PATCH 09/10] Sdk: Rename [Collision|Physics]Component to [Collision|Physics]Component3D --- SDK/include/NDK/Components.hpp | 4 +- ...Component.hpp => CollisionComponent3D.hpp} | 16 +++--- ...Component.inl => CollisionComponent3D.inl} | 20 +++---- ...csComponent.hpp => PhysicsComponent3D.hpp} | 20 +++---- ...csComponent.inl => PhysicsComponent3D.inl} | 52 +++++++++---------- SDK/include/NDK/Systems.hpp | 2 +- ...{PhysicsSystem.hpp => PhysicsSystem3D.hpp} | 16 +++--- ...{PhysicsSystem.inl => PhysicsSystem3D.inl} | 4 +- ...Component.cpp => CollisionComponent3D.cpp} | 38 +++++++------- ...csComponent.cpp => PhysicsComponent3D.cpp} | 32 ++++++------ SDK/src/NDK/Sdk.cpp | 12 ++--- ...{PhysicsSystem.cpp => PhysicsSystem3D.cpp} | 30 +++++------ SDK/src/NDK/Systems/VelocitySystem.cpp | 6 +-- SDK/src/NDK/World.cpp | 4 +- src/Nazara/Physics3D/Collider3D.cpp | 2 +- src/Nazara/Physics3D/PhysWorld3D.cpp | 2 +- src/Nazara/Physics3D/RigidBody3D.cpp | 2 +- ...{PhysicsSystem.cpp => PhysicsSystem3D.cpp} | 10 ++-- 18 files changed, 136 insertions(+), 136 deletions(-) rename SDK/include/NDK/Components/{CollisionComponent.hpp => CollisionComponent3D.hpp} (69%) rename SDK/include/NDK/Components/{CollisionComponent.inl => CollisionComponent3D.inl} (57%) rename SDK/include/NDK/Components/{PhysicsComponent.hpp => PhysicsComponent3D.hpp} (79%) rename SDK/include/NDK/Components/{PhysicsComponent.inl => PhysicsComponent3D.inl} (79%) rename SDK/include/NDK/Systems/{PhysicsSystem.hpp => PhysicsSystem3D.hpp} (69%) rename SDK/include/NDK/Systems/{PhysicsSystem.inl => PhysicsSystem3D.inl} (78%) rename SDK/src/NDK/Components/{CollisionComponent.cpp => CollisionComponent3D.cpp} (66%) rename SDK/src/NDK/Components/{PhysicsComponent.cpp => PhysicsComponent3D.cpp} (63%) rename SDK/src/NDK/Systems/{PhysicsSystem.cpp => PhysicsSystem3D.cpp} (77%) rename tests/SDK/NDK/Systems/{PhysicsSystem.cpp => PhysicsSystem3D.cpp} (73%) diff --git a/SDK/include/NDK/Components.hpp b/SDK/include/NDK/Components.hpp index 79bc196f7..afa25ade8 100644 --- a/SDK/include/NDK/Components.hpp +++ b/SDK/include/NDK/Components.hpp @@ -6,14 +6,14 @@ #define NDK_COMPONENTS_GLOBAL_HPP #include -#include +#include #include #include #include #include #include #include -#include +#include #include #endif // NDK_COMPONENTS_GLOBAL_HPP diff --git a/SDK/include/NDK/Components/CollisionComponent.hpp b/SDK/include/NDK/Components/CollisionComponent3D.hpp similarity index 69% rename from SDK/include/NDK/Components/CollisionComponent.hpp rename to SDK/include/NDK/Components/CollisionComponent3D.hpp index 565a60871..f6a07ede6 100644 --- a/SDK/include/NDK/Components/CollisionComponent.hpp +++ b/SDK/include/NDK/Components/CollisionComponent3D.hpp @@ -20,22 +20,22 @@ namespace Ndk { class Entity; - class NDK_API CollisionComponent : public Component + class NDK_API CollisionComponent3D : public Component { - friend class PhysicsSystem; + friend class PhysicsSystem3D; friend class StaticCollisionSystem; public: - CollisionComponent(Nz::Collider3DRef geom = Nz::Collider3DRef()); - CollisionComponent(const CollisionComponent& collision); - ~CollisionComponent() = default; + CollisionComponent3D(Nz::Collider3DRef geom = Nz::Collider3DRef()); + CollisionComponent3D(const CollisionComponent3D& collision); + ~CollisionComponent3D() = default; const Nz::Collider3DRef& GetGeom() const; void SetGeom(Nz::Collider3DRef geom); - CollisionComponent& operator=(Nz::Collider3DRef geom); - CollisionComponent& operator=(CollisionComponent&& collision) = default; + CollisionComponent3D& operator=(Nz::Collider3DRef geom); + CollisionComponent3D& operator=(CollisionComponent3D&& collision) = default; static ComponentIndex componentIndex; @@ -54,6 +54,6 @@ namespace Ndk }; } -#include +#include #endif // NDK_COMPONENTS_COLLISIONCOMPONENT_HPP diff --git a/SDK/include/NDK/Components/CollisionComponent.inl b/SDK/include/NDK/Components/CollisionComponent3D.inl similarity index 57% rename from SDK/include/NDK/Components/CollisionComponent.inl rename to SDK/include/NDK/Components/CollisionComponent3D.inl index 7243996fb..d5dfeaacc 100644 --- a/SDK/include/NDK/Components/CollisionComponent.inl +++ b/SDK/include/NDK/Components/CollisionComponent3D.inl @@ -4,30 +4,30 @@ #include #include -#include -#include +#include +#include namespace Ndk { /*! - * \brief Constructs a CollisionComponent object with a geometry + * \brief Constructs a CollisionComponent3D object with a geometry * * \param geom Reference to a geometry symbolizing the entity */ - inline CollisionComponent::CollisionComponent(Nz::Collider3DRef geom) : + inline CollisionComponent3D::CollisionComponent3D(Nz::Collider3DRef geom) : m_geom(std::move(geom)), m_bodyUpdated(false) { } /*! - * \brief Constructs a CollisionComponent object by copy semantic + * \brief Constructs a CollisionComponent3D object by copy semantic * - * \param collision CollisionComponent to copy + * \param collision CollisionComponent3D to copy */ - inline CollisionComponent::CollisionComponent(const CollisionComponent& collision) : + inline CollisionComponent3D::CollisionComponent3D(const CollisionComponent3D& collision) : m_geom(collision.m_geom), m_bodyUpdated(false) { @@ -38,7 +38,7 @@ namespace Ndk * \return A constant reference to the physics geometry */ - inline const Nz::Collider3DRef& CollisionComponent::GetGeom() const + inline const Nz::Collider3DRef& CollisionComponent3D::GetGeom() const { return m_geom; } @@ -50,7 +50,7 @@ namespace Ndk * \param geom Reference to a geometry symbolizing the entity */ - inline CollisionComponent& CollisionComponent::operator=(Nz::Collider3DRef geom) + inline CollisionComponent3D& CollisionComponent3D::operator=(Nz::Collider3DRef geom) { SetGeom(geom); @@ -62,7 +62,7 @@ namespace Ndk * \return A pointer to the entity */ - inline Nz::RigidBody3D* CollisionComponent::GetStaticBody() + inline Nz::RigidBody3D* CollisionComponent3D::GetStaticBody() { return m_staticBody.get(); } diff --git a/SDK/include/NDK/Components/PhysicsComponent.hpp b/SDK/include/NDK/Components/PhysicsComponent3D.hpp similarity index 79% rename from SDK/include/NDK/Components/PhysicsComponent.hpp rename to SDK/include/NDK/Components/PhysicsComponent3D.hpp index c426d71bb..fc1367d84 100644 --- a/SDK/include/NDK/Components/PhysicsComponent.hpp +++ b/SDK/include/NDK/Components/PhysicsComponent3D.hpp @@ -4,8 +4,8 @@ #pragma once -#ifndef NDK_COMPONENTS_PHYSICSCOMPONENT_HPP -#define NDK_COMPONENTS_PHYSICSCOMPONENT_HPP +#ifndef NDK_COMPONENTS_PHYSICSCOMPONENT3D_HPP +#define NDK_COMPONENTS_PHYSICSCOMPONENT3D_HPP #include #include @@ -15,15 +15,15 @@ namespace Ndk { class Entity; - class NDK_API PhysicsComponent : public Component + class NDK_API PhysicsComponent3D : public Component { - friend class CollisionComponent; - friend class PhysicsSystem; + friend class CollisionComponent3D; + friend class PhysicsSystem3D; public: - PhysicsComponent() = default; - PhysicsComponent(const PhysicsComponent& physics); - ~PhysicsComponent() = default; + PhysicsComponent3D() = default; + PhysicsComponent3D(const PhysicsComponent3D& physics); + ~PhysicsComponent3D() = default; void AddForce(const Nz::Vector3f& force, Nz::CoordSys coordSys = Nz::CoordSys_Global); void AddForce(const Nz::Vector3f& force, const Nz::Vector3f& point, Nz::CoordSys coordSys = Nz::CoordSys_Global); @@ -67,6 +67,6 @@ namespace Ndk }; } -#include +#include -#endif // NDK_COMPONENTS_PHYSICSCOMPONENT_HPP +#endif // NDK_COMPONENTS_PHYSICSCOMPONENT3D_HPP diff --git a/SDK/include/NDK/Components/PhysicsComponent.inl b/SDK/include/NDK/Components/PhysicsComponent3D.inl similarity index 79% rename from SDK/include/NDK/Components/PhysicsComponent.inl rename to SDK/include/NDK/Components/PhysicsComponent3D.inl index 009d62ba5..84bc36db7 100644 --- a/SDK/include/NDK/Components/PhysicsComponent.inl +++ b/SDK/include/NDK/Components/PhysicsComponent3D.inl @@ -7,12 +7,12 @@ namespace Ndk { /*! - * \brief Constructs a PhysicsComponent object by copy semantic + * \brief Constructs a PhysicsComponent3D object by copy semantic * - * \param physics PhysicsComponent to copy + * \param physics PhysicsComponent3D to copy */ - inline PhysicsComponent::PhysicsComponent(const PhysicsComponent& physics) + inline PhysicsComponent3D::PhysicsComponent3D(const PhysicsComponent3D& physics) { // No copy of physical object (because we only create it when attached to an entity) NazaraUnused(physics); @@ -27,7 +27,7 @@ namespace Ndk * \remark Produces a NazaraAssert if the physics object is invalid */ - inline void PhysicsComponent::AddForce(const Nz::Vector3f& force, Nz::CoordSys coordSys) + inline void PhysicsComponent3D::AddForce(const Nz::Vector3f& force, Nz::CoordSys coordSys) { NazaraAssert(m_object, "Invalid physics object"); @@ -44,7 +44,7 @@ namespace Ndk * \remark Produces a NazaraAssert if the physics object is invalid */ - inline void PhysicsComponent::AddForce(const Nz::Vector3f& force, const Nz::Vector3f& point, Nz::CoordSys coordSys) + inline void PhysicsComponent3D::AddForce(const Nz::Vector3f& force, const Nz::Vector3f& point, Nz::CoordSys coordSys) { NazaraAssert(m_object, "Invalid physics object"); @@ -60,7 +60,7 @@ namespace Ndk * \remark Produces a NazaraAssert if the physics object is invalid */ - inline void PhysicsComponent::AddTorque(const Nz::Vector3f& torque, Nz::CoordSys coordSys) + inline void PhysicsComponent3D::AddTorque(const Nz::Vector3f& torque, Nz::CoordSys coordSys) { NazaraAssert(m_object, "Invalid physics object"); @@ -75,7 +75,7 @@ namespace Ndk * \remark Produces a NazaraAssert if the physics object is invalid */ - inline void PhysicsComponent::EnableAutoSleep(bool autoSleep) + inline void PhysicsComponent3D::EnableAutoSleep(bool autoSleep) { NazaraAssert(m_object, "Invalid physics object"); @@ -89,7 +89,7 @@ namespace Ndk * \remark Produces a NazaraAssert if the physics object is invalid */ - inline Nz::Boxf PhysicsComponent::GetAABB() const + inline Nz::Boxf PhysicsComponent3D::GetAABB() const { NazaraAssert(m_object, "Invalid physics object"); @@ -103,7 +103,7 @@ namespace Ndk * \remark Produces a NazaraAssert if the physics object is invalid */ - inline Nz::Vector3f PhysicsComponent::GetAngularVelocity() const + inline Nz::Vector3f PhysicsComponent3D::GetAngularVelocity() const { NazaraAssert(m_object, "Invalid physics object"); @@ -117,7 +117,7 @@ namespace Ndk * \remark Produces a NazaraAssert if the physics object is invalid */ - inline float PhysicsComponent::GetGravityFactor() const + inline float PhysicsComponent3D::GetGravityFactor() const { NazaraAssert(m_object, "Invalid physics object"); @@ -131,7 +131,7 @@ namespace Ndk * \remark Produces a NazaraAssert if the physics object is invalid */ - inline float PhysicsComponent::GetMass() const + inline float PhysicsComponent3D::GetMass() const { NazaraAssert(m_object, "Invalid physics object"); @@ -147,7 +147,7 @@ namespace Ndk * \remark Produces a NazaraAssert if the physics object is invalid */ - inline Nz::Vector3f PhysicsComponent::GetMassCenter(Nz::CoordSys coordSys) const + inline Nz::Vector3f PhysicsComponent3D::GetMassCenter(Nz::CoordSys coordSys) const { NazaraAssert(m_object, "Invalid physics object"); @@ -161,7 +161,7 @@ namespace Ndk * \remark Produces a NazaraAssert if the physics object is invalid */ - inline const Nz::Matrix4f& PhysicsComponent::GetMatrix() const + inline const Nz::Matrix4f& PhysicsComponent3D::GetMatrix() const { NazaraAssert(m_object, "Invalid physics object"); @@ -175,7 +175,7 @@ namespace Ndk * \remark Produces a NazaraAssert if the physics object is invalid */ - inline Nz::Vector3f PhysicsComponent::GetPosition() const + inline Nz::Vector3f PhysicsComponent3D::GetPosition() const { NazaraAssert(m_object, "Invalid physics object"); @@ -189,7 +189,7 @@ namespace Ndk * \remark Produces a NazaraAssert if the physics object is invalid */ - inline Nz::Quaternionf PhysicsComponent::GetRotation() const + inline Nz::Quaternionf PhysicsComponent3D::GetRotation() const { NazaraAssert(m_object, "Invalid physics object"); @@ -203,7 +203,7 @@ namespace Ndk * \remark Produces a NazaraAssert if the physics object is invalid */ - inline Nz::Vector3f PhysicsComponent::GetVelocity() const + inline Nz::Vector3f PhysicsComponent3D::GetVelocity() const { NazaraAssert(m_object, "Invalid physics object"); @@ -217,7 +217,7 @@ namespace Ndk * \remark Produces a NazaraAssert if the physics object is invalid */ - inline bool PhysicsComponent::IsAutoSleepEnabled() const + inline bool PhysicsComponent3D::IsAutoSleepEnabled() const { NazaraAssert(m_object, "Invalid physics object"); @@ -231,7 +231,7 @@ namespace Ndk * \remark Produces a NazaraAssert if the physics object is invalid */ - inline bool PhysicsComponent::IsSleeping() const + inline bool PhysicsComponent3D::IsSleeping() const { NazaraAssert(m_object, "Invalid physics object"); @@ -246,7 +246,7 @@ namespace Ndk * \remark Produces a NazaraAssert if the physics object is invalid */ - inline void PhysicsComponent::SetAngularVelocity(const Nz::Vector3f& angularVelocity) + inline void PhysicsComponent3D::SetAngularVelocity(const Nz::Vector3f& angularVelocity) { NazaraAssert(m_object, "Invalid physics object"); @@ -261,7 +261,7 @@ namespace Ndk * \remark Produces a NazaraAssert if the physics object is invalid */ - inline void PhysicsComponent::SetGravityFactor(float gravityFactor) + inline void PhysicsComponent3D::SetGravityFactor(float gravityFactor) { NazaraAssert(m_object, "Invalid physics object"); @@ -277,7 +277,7 @@ namespace Ndk * \remark Produces a NazaraAssert if the mass is negative */ - inline void PhysicsComponent::SetMass(float mass) + inline void PhysicsComponent3D::SetMass(float mass) { NazaraAssert(m_object, "Invalid physics object"); NazaraAssert(mass > 0.f, "Mass should be positive"); @@ -293,7 +293,7 @@ namespace Ndk * \remark Produces a NazaraAssert if the physics object is invalid */ - inline void PhysicsComponent::SetMassCenter(const Nz::Vector3f& center) + inline void PhysicsComponent3D::SetMassCenter(const Nz::Vector3f& center) { NazaraAssert(m_object, "Invalid physics object"); @@ -308,7 +308,7 @@ namespace Ndk * \remark Produces a NazaraAssert if the physics object is invalid */ - inline void PhysicsComponent::SetPosition(const Nz::Vector3f& position) + inline void PhysicsComponent3D::SetPosition(const Nz::Vector3f& position) { NazaraAssert(m_object, "Invalid physics object"); @@ -323,7 +323,7 @@ namespace Ndk * \remark Produces a NazaraAssert if the physics object is invalid */ - inline void PhysicsComponent::SetRotation(const Nz::Quaternionf& rotation) + inline void PhysicsComponent3D::SetRotation(const Nz::Quaternionf& rotation) { NazaraAssert(m_object, "Invalid physics object"); @@ -338,7 +338,7 @@ namespace Ndk * \remark Produces a NazaraAssert if the physics object is invalid */ - inline void PhysicsComponent::SetVelocity(const Nz::Vector3f& velocity) + inline void PhysicsComponent3D::SetVelocity(const Nz::Vector3f& velocity) { NazaraAssert(m_object, "Invalid physics object"); @@ -350,7 +350,7 @@ namespace Ndk * \return A reference to the physics object */ - inline Nz::RigidBody3D& PhysicsComponent::GetPhysObject() + inline Nz::RigidBody3D& PhysicsComponent3D::GetPhysObject() { return *m_object.get(); } diff --git a/SDK/include/NDK/Systems.hpp b/SDK/include/NDK/Systems.hpp index 269bead6f..287a2d61a 100644 --- a/SDK/include/NDK/Systems.hpp +++ b/SDK/include/NDK/Systems.hpp @@ -7,7 +7,7 @@ #include #include -#include +#include #include #include diff --git a/SDK/include/NDK/Systems/PhysicsSystem.hpp b/SDK/include/NDK/Systems/PhysicsSystem3D.hpp similarity index 69% rename from SDK/include/NDK/Systems/PhysicsSystem.hpp rename to SDK/include/NDK/Systems/PhysicsSystem3D.hpp index 1e5400e82..86ee0aa65 100644 --- a/SDK/include/NDK/Systems/PhysicsSystem.hpp +++ b/SDK/include/NDK/Systems/PhysicsSystem3D.hpp @@ -4,8 +4,8 @@ #pragma once -#ifndef NDK_SYSTEMS_PHYSICSSYSTEM_HPP -#define NDK_SYSTEMS_PHYSICSSYSTEM_HPP +#ifndef NDK_SYSTEMS_PHYSICSSYSTEM3D_HPP +#define NDK_SYSTEMS_PHYSICSSYSTEM3D_HPP #include #include @@ -14,12 +14,12 @@ namespace Ndk { - class NDK_API PhysicsSystem : public System + class NDK_API PhysicsSystem3D : public System { public: - PhysicsSystem(); - PhysicsSystem(const PhysicsSystem& system); - ~PhysicsSystem() = default; + PhysicsSystem3D(); + PhysicsSystem3D(const PhysicsSystem3D& system); + ~PhysicsSystem3D() = default; Nz::PhysWorld3D& GetWorld(); const Nz::PhysWorld3D& GetWorld() const; @@ -36,6 +36,6 @@ namespace Ndk }; } -#include +#include -#endif // NDK_SYSTEMS_PHYSICSSYSTEM_HPP +#endif // NDK_SYSTEMS_PHYSICSSYSTEM3D_HPP diff --git a/SDK/include/NDK/Systems/PhysicsSystem.inl b/SDK/include/NDK/Systems/PhysicsSystem3D.inl similarity index 78% rename from SDK/include/NDK/Systems/PhysicsSystem.inl rename to SDK/include/NDK/Systems/PhysicsSystem3D.inl index 4ec400fe7..9a8d3ba8c 100644 --- a/SDK/include/NDK/Systems/PhysicsSystem.inl +++ b/SDK/include/NDK/Systems/PhysicsSystem3D.inl @@ -9,7 +9,7 @@ namespace Ndk * \return A reference to the physical world */ - inline Nz::PhysWorld3D& PhysicsSystem::GetWorld() + inline Nz::PhysWorld3D& PhysicsSystem3D::GetWorld() { return *m_world; } @@ -19,7 +19,7 @@ namespace Ndk * \return A constant reference to the physical world */ - inline const Nz::PhysWorld3D& PhysicsSystem::GetWorld() const + inline const Nz::PhysWorld3D& PhysicsSystem3D::GetWorld() const { return *m_world; } diff --git a/SDK/src/NDK/Components/CollisionComponent.cpp b/SDK/src/NDK/Components/CollisionComponent3D.cpp similarity index 66% rename from SDK/src/NDK/Components/CollisionComponent.cpp rename to SDK/src/NDK/Components/CollisionComponent3D.cpp index 6806701f2..423b06cb4 100644 --- a/SDK/src/NDK/Components/CollisionComponent.cpp +++ b/SDK/src/NDK/Components/CollisionComponent3D.cpp @@ -2,18 +2,18 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp -#include +#include #include #include #include -#include -#include +#include +#include namespace Ndk { /*! * \ingroup NDK - * \class Ndk::CollisionComponent + * \class Ndk::CollisionComponent3D * \brief NDK class that represents the component for collision (meant for static objects) */ @@ -25,14 +25,14 @@ namespace Ndk * \remark Produces a NazaraAssert if the entity has no physics component and has no static body */ - void CollisionComponent::SetGeom(Nz::Collider3DRef geom) + void CollisionComponent3D::SetGeom(Nz::Collider3DRef geom) { m_geom = std::move(geom); - if (m_entity->HasComponent()) + if (m_entity->HasComponent()) { - // We update the geometry of the PhysiscsObject linked to the PhysicsComponent - PhysicsComponent& physComponent = m_entity->GetComponent(); + // We update the geometry of the PhysiscsObject linked to the PhysicsComponent3D + PhysicsComponent3D& physComponent = m_entity->GetComponent(); physComponent.GetPhysObject().SetGeom(m_geom); } else @@ -49,14 +49,14 @@ namespace Ndk * \remark Produces a NazaraAssert if entity is not linked to a world, or the world has no physics system */ - void CollisionComponent::InitializeStaticBody() + void CollisionComponent3D::InitializeStaticBody() { NazaraAssert(m_entity, "Invalid entity"); World* entityWorld = m_entity->GetWorld(); NazaraAssert(entityWorld, "Entity must have world"); - NazaraAssert(entityWorld->HasSystem(), "World must have a physics system"); - Nz::PhysWorld3D& physWorld = entityWorld->GetSystem().GetWorld(); + NazaraAssert(entityWorld->HasSystem(), "World must have a physics system"); + Nz::PhysWorld3D& physWorld = entityWorld->GetSystem().GetWorld(); m_staticBody.reset(new Nz::RigidBody3D(&physWorld, m_geom)); m_staticBody->EnableAutoSleep(false); @@ -66,9 +66,9 @@ namespace Ndk * \brief Operation to perform when component is attached to an entity */ - void CollisionComponent::OnAttached() + void CollisionComponent3D::OnAttached() { - if (!m_entity->HasComponent()) + if (!m_entity->HasComponent()) InitializeStaticBody(); } @@ -78,9 +78,9 @@ namespace Ndk * \param component Component being attached */ - void CollisionComponent::OnComponentAttached(BaseComponent& component) + void CollisionComponent3D::OnComponentAttached(BaseComponent& component) { - if (IsComponent(component)) + if (IsComponent(component)) m_staticBody.reset(); } @@ -90,9 +90,9 @@ namespace Ndk * \param component Component being detached */ - void CollisionComponent::OnComponentDetached(BaseComponent& component) + void CollisionComponent3D::OnComponentDetached(BaseComponent& component) { - if (IsComponent(component)) + if (IsComponent(component)) InitializeStaticBody(); } @@ -100,10 +100,10 @@ namespace Ndk * \brief Operation to perform when component is detached from an entity */ - void CollisionComponent::OnDetached() + void CollisionComponent3D::OnDetached() { m_staticBody.reset(); } - ComponentIndex CollisionComponent::componentIndex; + ComponentIndex CollisionComponent3D::componentIndex; } diff --git a/SDK/src/NDK/Components/PhysicsComponent.cpp b/SDK/src/NDK/Components/PhysicsComponent3D.cpp similarity index 63% rename from SDK/src/NDK/Components/PhysicsComponent.cpp rename to SDK/src/NDK/Components/PhysicsComponent3D.cpp index ec9620541..7dfffab85 100644 --- a/SDK/src/NDK/Components/PhysicsComponent.cpp +++ b/SDK/src/NDK/Components/PhysicsComponent3D.cpp @@ -2,19 +2,19 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp -#include +#include #include #include #include -#include +#include #include -#include +#include namespace Ndk { /*! * \ingroup NDK - * \class Ndk::PhysicsComponent + * \class Ndk::PhysicsComponent3D * \brief NDK class that represents the component for physics (meant for dynamic objects) */ @@ -24,16 +24,16 @@ namespace Ndk * \remark Produces a NazaraAssert if the world does not have a physics system */ - void PhysicsComponent::OnAttached() + void PhysicsComponent3D::OnAttached() { World* entityWorld = m_entity->GetWorld(); - NazaraAssert(entityWorld->HasSystem(), "World must have a physics system"); + NazaraAssert(entityWorld->HasSystem(), "World must have a physics system"); - Nz::PhysWorld3D& world = entityWorld->GetSystem().GetWorld(); + Nz::PhysWorld3D& world = entityWorld->GetSystem().GetWorld(); Nz::Collider3DRef geom; - if (m_entity->HasComponent()) - geom = m_entity->GetComponent().GetGeom(); + if (m_entity->HasComponent()) + geom = m_entity->GetComponent().GetGeom(); Nz::Matrix4f matrix; if (m_entity->HasComponent()) @@ -53,12 +53,12 @@ namespace Ndk * \remark Produces a NazaraAssert if physical object is invalid */ - void PhysicsComponent::OnComponentAttached(BaseComponent& component) + void PhysicsComponent3D::OnComponentAttached(BaseComponent& component) { - if (IsComponent(component)) + if (IsComponent(component)) { NazaraAssert(m_object, "Invalid object"); - m_object->SetGeom(static_cast(component).GetGeom()); + m_object->SetGeom(static_cast(component).GetGeom()); } } @@ -70,9 +70,9 @@ namespace Ndk * \remark Produces a NazaraAssert if physical object is invalid */ - void PhysicsComponent::OnComponentDetached(BaseComponent& component) + void PhysicsComponent3D::OnComponentDetached(BaseComponent& component) { - if (IsComponent(component)) + if (IsComponent(component)) { NazaraAssert(m_object, "Invalid object"); m_object->SetGeom(Nz::NullCollider3D::New()); @@ -83,10 +83,10 @@ namespace Ndk * \brief Operation to perform when component is detached from an entity */ - void PhysicsComponent::OnDetached() + void PhysicsComponent3D::OnDetached() { m_object.reset(); } - ComponentIndex PhysicsComponent::componentIndex; + ComponentIndex PhysicsComponent3D::componentIndex; } diff --git a/SDK/src/NDK/Sdk.cpp b/SDK/src/NDK/Sdk.cpp index 895adf178..36283ada3 100644 --- a/SDK/src/NDK/Sdk.cpp +++ b/SDK/src/NDK/Sdk.cpp @@ -13,11 +13,11 @@ #include #include #include -#include +#include #include -#include +#include #include -#include +#include #include #ifndef NDK_SERVER @@ -83,9 +83,9 @@ namespace Ndk BaseComponent::Initialize(); // Shared components - InitializeComponent("NdkColli"); + InitializeComponent("NdkColli"); InitializeComponent("NdkNode"); - InitializeComponent("NdkPhys"); + InitializeComponent("NdkPhys"); InitializeComponent("NdkVeloc"); #ifndef NDK_SERVER @@ -103,7 +103,7 @@ namespace Ndk BaseSystem::Initialize(); // Shared systems - InitializeSystem(); + InitializeSystem(); InitializeSystem(); #ifndef NDK_SERVER diff --git a/SDK/src/NDK/Systems/PhysicsSystem.cpp b/SDK/src/NDK/Systems/PhysicsSystem3D.cpp similarity index 77% rename from SDK/src/NDK/Systems/PhysicsSystem.cpp rename to SDK/src/NDK/Systems/PhysicsSystem3D.cpp index e30dd7abc..7f41d02c8 100644 --- a/SDK/src/NDK/Systems/PhysicsSystem.cpp +++ b/SDK/src/NDK/Systems/PhysicsSystem3D.cpp @@ -2,11 +2,11 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp -#include +#include #include -#include +#include #include -#include +#include namespace Ndk { @@ -15,7 +15,7 @@ namespace Ndk * \class Ndk::PhysicsSystem * \brief NDK class that represents the physics system * - * \remark This system is enabled if the entity has the trait: NodeComponent and any of these two: CollisionComponent or PhysicsComponent + * \remark This system is enabled if the entity has the trait: NodeComponent and any of these two: CollisionComponent3D or PhysicsComponent3D * \remark Static objects do not have a velocity specified by the physical engine */ @@ -23,10 +23,10 @@ namespace Ndk * \brief Constructs an PhysicsSystem object by default */ - PhysicsSystem::PhysicsSystem() + PhysicsSystem3D::PhysicsSystem3D() { Requires(); - RequiresAny(); + RequiresAny(); } /*! @@ -35,7 +35,7 @@ namespace Ndk * \param system PhysicsSystem to copy */ - PhysicsSystem::PhysicsSystem(const PhysicsSystem& system) : + PhysicsSystem3D::PhysicsSystem3D(const PhysicsSystem3D& system) : System(system), m_world() { @@ -48,17 +48,17 @@ namespace Ndk * \param justAdded Is the entity newly added */ - void PhysicsSystem::OnEntityValidation(Entity* entity, bool justAdded) + void PhysicsSystem3D::OnEntityValidation(Entity* entity, bool justAdded) { - // It's possible our entity got revalidated because of the addition/removal of a PhysicsComponent + // It's possible our entity got revalidated because of the addition/removal of a PhysicsComponent3D if (!justAdded) { // We take the opposite array from which the entity should belong to - auto& entities = (entity->HasComponent()) ? m_staticObjects : m_dynamicObjects; + auto& entities = (entity->HasComponent()) ? m_staticObjects : m_dynamicObjects; entities.Remove(entity); } - auto& entities = (entity->HasComponent()) ? m_dynamicObjects : m_staticObjects; + auto& entities = (entity->HasComponent()) ? m_dynamicObjects : m_staticObjects; entities.Insert(entity); if (!m_world) @@ -71,7 +71,7 @@ namespace Ndk * \param elapsedTime Delta time used for the update */ - void PhysicsSystem::OnUpdate(float elapsedTime) + void PhysicsSystem3D::OnUpdate(float elapsedTime) { if (!m_world) return; @@ -81,7 +81,7 @@ namespace Ndk for (const Ndk::EntityHandle& entity : m_dynamicObjects) { NodeComponent& node = entity->GetComponent(); - PhysicsComponent& phys = entity->GetComponent(); + PhysicsComponent3D& phys = entity->GetComponent(); Nz::RigidBody3D& physObj = phys.GetPhysObject(); node.SetRotation(physObj.GetRotation(), Nz::CoordSys_Global); @@ -91,7 +91,7 @@ namespace Ndk float invElapsedTime = 1.f / elapsedTime; for (const Ndk::EntityHandle& entity : m_staticObjects) { - CollisionComponent& collision = entity->GetComponent(); + CollisionComponent3D& collision = entity->GetComponent(); NodeComponent& node = entity->GetComponent(); Nz::RigidBody3D* physObj = collision.GetStaticBody(); @@ -127,5 +127,5 @@ namespace Ndk } } - SystemIndex PhysicsSystem::systemIndex; + SystemIndex PhysicsSystem3D::systemIndex; } diff --git a/SDK/src/NDK/Systems/VelocitySystem.cpp b/SDK/src/NDK/Systems/VelocitySystem.cpp index e8cfe2f23..c1298bde3 100644 --- a/SDK/src/NDK/Systems/VelocitySystem.cpp +++ b/SDK/src/NDK/Systems/VelocitySystem.cpp @@ -4,7 +4,7 @@ #include #include -#include +#include #include namespace Ndk @@ -15,7 +15,7 @@ namespace Ndk * \brief NDK class that represents the velocity system * * \remark This system is enabled if the entity owns the trait: NodeComponent and VelocityComponent - * but it's disabled with the trait: PhysicsComponent + * but it's disabled with the trait: PhysicsComponent3D */ /*! @@ -25,7 +25,7 @@ namespace Ndk VelocitySystem::VelocitySystem() { Requires(); - Excludes(); + Excludes(); } /*! diff --git a/SDK/src/NDK/World.cpp b/SDK/src/NDK/World.cpp index 938722feb..6ba110aee 100644 --- a/SDK/src/NDK/World.cpp +++ b/SDK/src/NDK/World.cpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #ifndef NDK_SERVER @@ -40,7 +40,7 @@ namespace Ndk void World::AddDefaultSystems() { - AddSystem(); + AddSystem(); AddSystem(); #ifndef NDK_SERVER diff --git a/src/Nazara/Physics3D/Collider3D.cpp b/src/Nazara/Physics3D/Collider3D.cpp index 9afcdd80d..451686530 100644 --- a/src/Nazara/Physics3D/Collider3D.cpp +++ b/src/Nazara/Physics3D/Collider3D.cpp @@ -3,7 +3,7 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#include +#include #include #include #include diff --git a/src/Nazara/Physics3D/PhysWorld3D.cpp b/src/Nazara/Physics3D/PhysWorld3D.cpp index 8499071cd..c6990f635 100644 --- a/src/Nazara/Physics3D/PhysWorld3D.cpp +++ b/src/Nazara/Physics3D/PhysWorld3D.cpp @@ -2,7 +2,7 @@ // This file is part of the "Nazara Engine - Physics 3D module" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include #include diff --git a/src/Nazara/Physics3D/RigidBody3D.cpp b/src/Nazara/Physics3D/RigidBody3D.cpp index 86e78f100..5051fa143 100644 --- a/src/Nazara/Physics3D/RigidBody3D.cpp +++ b/src/Nazara/Physics3D/RigidBody3D.cpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/tests/SDK/NDK/Systems/PhysicsSystem.cpp b/tests/SDK/NDK/Systems/PhysicsSystem3D.cpp similarity index 73% rename from tests/SDK/NDK/Systems/PhysicsSystem.cpp rename to tests/SDK/NDK/Systems/PhysicsSystem3D.cpp index 2aa3c313e..3cb0d6bdb 100644 --- a/tests/SDK/NDK/Systems/PhysicsSystem.cpp +++ b/tests/SDK/NDK/Systems/PhysicsSystem3D.cpp @@ -1,8 +1,8 @@ -#include +#include #include -#include +#include #include -#include +#include #include SCENARIO("PhysicsSystem", "[NDK][PHYSICSSYSTEM]") @@ -11,12 +11,12 @@ SCENARIO("PhysicsSystem", "[NDK][PHYSICSSYSTEM]") { Ndk::World world; const Ndk::EntityHandle& staticEntity = world.CreateEntity(); - Ndk::CollisionComponent& collisionComponentStatic = staticEntity->AddComponent(); + Ndk::CollisionComponent3D& collisionComponentStatic = staticEntity->AddComponent(); Ndk::NodeComponent& nodeComponentStatic = staticEntity->AddComponent(); const Ndk::EntityHandle& dynamicEntity = world.CreateEntity(); Ndk::NodeComponent& nodeComponentDynamic = dynamicEntity->AddComponent(); - Ndk::PhysicsComponent& physicsComponentDynamic = dynamicEntity->AddComponent(); + Ndk::PhysicsComponent3D& physicsComponentDynamic = dynamicEntity->AddComponent(); WHEN("We make collide these two entities") { From 634b67be56a67ce5d0d06f46da09713e165957e4 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 13 Oct 2016 08:33:15 +0200 Subject: [PATCH 10/10] Fix merge fail --- SDK/include/NDK/Systems/PhysicsSystem3D.hpp | 2 +- SDK/src/NDK/Systems/PhysicsSystem3D.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/SDK/include/NDK/Systems/PhysicsSystem3D.hpp b/SDK/include/NDK/Systems/PhysicsSystem3D.hpp index f1164fd0d..35194b7c8 100644 --- a/SDK/include/NDK/Systems/PhysicsSystem3D.hpp +++ b/SDK/include/NDK/Systems/PhysicsSystem3D.hpp @@ -33,7 +33,7 @@ namespace Ndk EntityList m_dynamicObjects; EntityList m_staticObjects; - std::unique_ptr m_world; ///TODO: std::optional (Should I make a Nz::Optional class?) + mutable std::unique_ptr m_world; ///TODO: std::optional (Should I make a Nz::Optional class?) }; } diff --git a/SDK/src/NDK/Systems/PhysicsSystem3D.cpp b/SDK/src/NDK/Systems/PhysicsSystem3D.cpp index f92e8a92a..fd5e05d66 100644 --- a/SDK/src/NDK/Systems/PhysicsSystem3D.cpp +++ b/SDK/src/NDK/Systems/PhysicsSystem3D.cpp @@ -41,11 +41,11 @@ namespace Ndk { } - void PhysicsSystem::CreatePhysWorld() const + void PhysicsSystem3D::CreatePhysWorld() const { NazaraAssert(!m_world, "Physics world should not be created twice"); - m_world = std::make_unique(); + m_world = std::make_unique(); } /*!