From b52c7c57bf6dcaaa2c5ee1f4c087234c8417784d Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 13 Oct 2016 08:13:56 +0200 Subject: [PATCH] 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()),