From beca6e7dd565f2e7c281ba6b388fc03498812120 Mon Sep 17 00:00:00 2001 From: Faymoon Date: Tue, 14 Aug 2018 18:44:41 +0200 Subject: [PATCH] little fixes (#183) * Update * Add: [Get/Set]AngularDaming for standardization * Fix: Name error * Add: [Get/Set][AngularDamping/MomentOfInertia] in PhysicsComponent2D * Forgot in last commit * Add: param coordSys in [PhysicsComponent2D/RigidBody2D]::SetMassCenter * Add: Some forgotten inline * Fix little error * Fix: Indentation before case * Move and Change GetCenterOfGravity * Rename m_world into m_physWorld * Rename GetWorld int GetPhysWorld * Update: PhysicsSystem2D became an interface of PhysWorld2D * Update Collison/PhysicsComponent because GetWorld was renamed * Update tests * Update: Make the interface usable with Entity instead of PhysicsComponent * Update: Make GetPhysWorld private * Update PhysicsSystem2D.hpp * Update: indent * Remove: useless blank line * update order(?) * Update PhysicsSystem2D.hpp * Add calls to GetPhysWorld to attempt a nullptr value * update include * little fix * add some missing inline --- .../NDK/Components/PhysicsComponent3D.hpp | 70 +++++++++---------- SDK/include/NDK/Systems/PhysicsSystem2D.hpp | 4 +- SDK/include/NDK/Systems/PhysicsSystem2D.inl | 44 +++--------- SDK/src/NDK/Systems/PhysicsSystem2D.cpp | 12 ++-- src/Nazara/Network/Win32/SocketImpl.cpp | 2 +- 5 files changed, 55 insertions(+), 77 deletions(-) diff --git a/SDK/include/NDK/Components/PhysicsComponent3D.hpp b/SDK/include/NDK/Components/PhysicsComponent3D.hpp index 98e36079a..d7c9ddd52 100644 --- a/SDK/include/NDK/Components/PhysicsComponent3D.hpp +++ b/SDK/include/NDK/Components/PhysicsComponent3D.hpp @@ -23,49 +23,49 @@ namespace Ndk 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); - void AddTorque(const Nz::Vector3f& torque, Nz::CoordSys coordSys = Nz::CoordSys_Global); + inline void AddForce(const Nz::Vector3f& force, Nz::CoordSys coordSys = Nz::CoordSys_Global); + inline void AddForce(const Nz::Vector3f& force, const Nz::Vector3f& point, Nz::CoordSys coordSys = Nz::CoordSys_Global); + inline void AddTorque(const Nz::Vector3f& torque, Nz::CoordSys coordSys = Nz::CoordSys_Global); - void EnableAutoSleep(bool autoSleep); - void EnableNodeSynchronization(bool nodeSynchronization); + inline void EnableAutoSleep(bool autoSleep); + inline void EnableNodeSynchronization(bool nodeSynchronization); - Nz::Boxf GetAABB() const; - Nz::Vector3f GetAngularDamping() const; - Nz::Vector3f GetAngularVelocity() const; - float GetGravityFactor() const; - float GetLinearDamping() const; - Nz::Vector3f GetLinearVelocity() const; - float GetMass() const; - Nz::Vector3f GetMassCenter(Nz::CoordSys coordSys = Nz::CoordSys_Local) const; - const Nz::Matrix4f& GetMatrix() const; - Nz::Vector3f GetPosition() const; - Nz::Quaternionf GetRotation() const; + inline Nz::Boxf GetAABB() const; + inline Nz::Vector3f GetAngularDamping() const; + inline Nz::Vector3f GetAngularVelocity() const; + inline float GetGravityFactor() const; + inline float GetLinearDamping() const; + inline Nz::Vector3f GetLinearVelocity() const; + inline float GetMass() const; + inline Nz::Vector3f GetMassCenter(Nz::CoordSys coordSys = Nz::CoordSys_Local) const; + inline const Nz::Matrix4f& GetMatrix() const; + inline Nz::Vector3f GetPosition() const; + inline Nz::Quaternionf GetRotation() const; - bool IsAutoSleepEnabled() const; - bool IsMoveable() const; - bool IsNodeSynchronizationEnabled() const; - bool IsSleeping() const; + inline bool IsAutoSleepEnabled() const; + inline bool IsMoveable() const; + inline bool IsNodeSynchronizationEnabled() const; + inline bool IsSleeping() const; - void SetAngularDamping(const Nz::Vector3f& angularDamping); - void SetAngularVelocity(const Nz::Vector3f& angularVelocity); - void SetGravityFactor(float gravityFactor); - void SetLinearDamping(float damping); - void SetLinearVelocity(const Nz::Vector3f& velocity); - void SetMass(float mass); - void SetMassCenter(const Nz::Vector3f& center); - void SetMaterial(const Nz::String& materialName); - void SetMaterial(int materialIndex); - void SetPosition(const Nz::Vector3f& position); - void SetRotation(const Nz::Quaternionf& rotation); + inline void SetAngularDamping(const Nz::Vector3f& angularDamping); + inline void SetAngularVelocity(const Nz::Vector3f& angularVelocity); + inline void SetGravityFactor(float gravityFactor); + inline void SetLinearDamping(float damping); + inline void SetLinearVelocity(const Nz::Vector3f& velocity); + inline void SetMass(float mass); + inline void SetMassCenter(const Nz::Vector3f& center); + inline void SetMaterial(const Nz::String& materialName); + inline void SetMaterial(int materialIndex); + inline void SetPosition(const Nz::Vector3f& position); + inline void SetRotation(const Nz::Quaternionf& rotation); static ComponentIndex componentIndex; private: - void ApplyPhysicsState(Nz::RigidBody3D& rigidBody) const; - void CopyPhysicsState(const Nz::RigidBody3D& rigidBody); - Nz::RigidBody3D* GetRigidBody(); - const Nz::RigidBody3D& GetRigidBody() const; + inline void ApplyPhysicsState(Nz::RigidBody3D& rigidBody) const; + inline void CopyPhysicsState(const Nz::RigidBody3D& rigidBody); + inline Nz::RigidBody3D* GetRigidBody(); + inline const Nz::RigidBody3D& GetRigidBody() const; void OnAttached() override; void OnComponentAttached(BaseComponent& component) override; diff --git a/SDK/include/NDK/Systems/PhysicsSystem2D.hpp b/SDK/include/NDK/Systems/PhysicsSystem2D.hpp index 95b6767c4..1683fc7fb 100644 --- a/SDK/include/NDK/Systems/PhysicsSystem2D.hpp +++ b/SDK/include/NDK/Systems/PhysicsSystem2D.hpp @@ -114,8 +114,8 @@ namespace Ndk private: void CreatePhysWorld() const; const EntityHandle& GetEntityFromBody(const Nz::RigidBody2D& body) const; - Nz::PhysWorld2D& GetPhysWorld(); - const Nz::PhysWorld2D& GetPhysWorld() const; + inline Nz::PhysWorld2D& GetPhysWorld(); + inline const Nz::PhysWorld2D& GetPhysWorld() const; void OnEntityValidation(Entity* entity, bool justAdded) override; void OnUpdate(float elapsedTime) override; diff --git a/SDK/include/NDK/Systems/PhysicsSystem2D.inl b/SDK/include/NDK/Systems/PhysicsSystem2D.inl index cc1010c1f..b8e7c61a2 100644 --- a/SDK/include/NDK/Systems/PhysicsSystem2D.inl +++ b/SDK/include/NDK/Systems/PhysicsSystem2D.inl @@ -6,79 +6,57 @@ namespace Ndk { inline float PhysicsSystem2D::GetDamping() const { - NazaraAssert(m_physWorld, "Invalid physics world"); - - return m_physWorld->GetDamping(); + return GetPhysWorld().GetDamping(); } inline Nz::Vector2f PhysicsSystem2D::GetGravity() const { - NazaraAssert(m_physWorld, "Invalid physics world"); - - return m_physWorld->GetGravity(); + return GetPhysWorld().GetGravity(); } inline std::size_t PhysicsSystem2D::GetIterationCount() const { - NazaraAssert(m_physWorld, "Invalid physics world"); - - return m_physWorld->GetIterationCount(); + return GetPhysWorld().GetIterationCount(); } inline std::size_t PhysicsSystem2D::GetMaxStepCount() const { - NazaraAssert(m_physWorld, "Invalid physics world"); - - return m_physWorld->GetMaxStepCount(); + return GetPhysWorld().GetMaxStepCount(); } inline float PhysicsSystem2D::GetStepSize() const { - NazaraAssert(m_physWorld, "Invalid physics world"); - - return m_physWorld->GetStepSize(); + return GetPhysWorld().GetStepSize(); } inline void PhysicsSystem2D::SetDamping(float dampingValue) { - NazaraAssert(m_physWorld, "Invalid physics world"); - - m_physWorld->SetDamping(dampingValue); + GetPhysWorld().SetDamping(dampingValue); } inline void PhysicsSystem2D::SetGravity(const Nz::Vector2f& gravity) { - NazaraAssert(m_physWorld, "Invalid physics world"); - - m_physWorld->SetGravity(gravity); + GetPhysWorld().SetGravity(gravity); } inline void PhysicsSystem2D::SetIterationCount(std::size_t iterationCount) { - NazaraAssert(m_physWorld, "Invalid physics world"); - - m_physWorld->SetIterationCount(iterationCount); + GetPhysWorld().SetIterationCount(iterationCount); } inline void PhysicsSystem2D::SetMaxStepCount(std::size_t maxStepCount) { - NazaraAssert(m_physWorld, "Invalid physics world"); - - m_physWorld->SetMaxStepCount(maxStepCount); + GetPhysWorld().SetMaxStepCount(maxStepCount); } inline void PhysicsSystem2D::SetStepSize(float stepSize) { - NazaraAssert(m_physWorld, "Invalid physics world"); - - m_physWorld->SetStepSize(stepSize); + GetPhysWorld().SetStepSize(stepSize); } inline void PhysicsSystem2D::UseSpatialHash(float cellSize, std::size_t entityCount) { - NazaraAssert(m_physWorld, "Invalid physics world"); - - m_physWorld->UseSpatialHash(cellSize, entityCount); + GetPhysWorld().UseSpatialHash(cellSize, entityCount); } /*! diff --git a/SDK/src/NDK/Systems/PhysicsSystem2D.cpp b/SDK/src/NDK/Systems/PhysicsSystem2D.cpp index ec615b041..c717fcf80 100644 --- a/SDK/src/NDK/Systems/PhysicsSystem2D.cpp +++ b/SDK/src/NDK/Systems/PhysicsSystem2D.cpp @@ -59,7 +59,7 @@ namespace Ndk worldOptions.userdata = options.userdata; - m_physWorld->DebugDraw(worldOptions, drawShapes, drawConstraints, drawCollisions); + GetPhysWorld().DebugDraw(worldOptions, drawShapes, drawConstraints, drawCollisions); } const EntityHandle& PhysicsSystem2D::GetEntityFromBody(const Nz::RigidBody2D& body) const @@ -76,7 +76,7 @@ namespace Ndk bool PhysicsSystem2D::NearestBodyQuery(const Nz::Vector2f& from, float maxDistance, Nz::UInt32 collisionGroup, Nz::UInt32 categoryMask, Nz::UInt32 collisionMask, EntityHandle* nearestBody) { Nz::RigidBody2D* body; - bool res = m_physWorld->NearestBodyQuery(from, maxDistance, collisionGroup, categoryMask, collisionMask, &body); + bool res = GetPhysWorld().NearestBodyQuery(from, maxDistance, collisionGroup, categoryMask, collisionMask, &body); (*nearestBody) = GetEntityFromBody(*body); @@ -86,7 +86,7 @@ namespace Ndk bool PhysicsSystem2D::NearestBodyQuery(const Nz::Vector2f& from, float maxDistance, Nz::UInt32 collisionGroup, Nz::UInt32 categoryMask, Nz::UInt32 collisionMask, NearestQueryResult* result) { Nz::PhysWorld2D::NearestQueryResult queryResult; - bool res = m_physWorld->NearestBodyQuery(from, maxDistance, collisionGroup, categoryMask, collisionMask, &queryResult); + bool res = GetPhysWorld().NearestBodyQuery(from, maxDistance, collisionGroup, categoryMask, collisionMask, &queryResult); result->nearestBody = GetEntityFromBody(*queryResult.nearestBody); result->closestPoint = std::move(queryResult.closestPoint); @@ -99,7 +99,7 @@ namespace Ndk bool PhysicsSystem2D::RaycastQuery(const Nz::Vector2f& from, const Nz::Vector2f& to, float radius, Nz::UInt32 collisionGroup, Nz::UInt32 categoryMask, Nz::UInt32 collisionMask, std::vector* hitInfos) { std::vector queryResult; - bool res = m_physWorld->RaycastQuery(from, to, radius, collisionGroup, categoryMask, collisionMask, &queryResult); + bool res = GetPhysWorld().RaycastQuery(from, to, radius, collisionGroup, categoryMask, collisionMask, &queryResult); for (auto& hitResult : queryResult) { @@ -117,7 +117,7 @@ namespace Ndk bool PhysicsSystem2D::RaycastQueryFirst(const Nz::Vector2f& from, const Nz::Vector2f& to, float radius, Nz::UInt32 collisionGroup, Nz::UInt32 categoryMask, Nz::UInt32 collisionMask, RaycastHit* hitInfo) { Nz::PhysWorld2D::RaycastHit queryResult; - bool res = m_physWorld->RaycastQueryFirst(from, to, radius, collisionGroup, categoryMask, collisionMask, &queryResult); + bool res = GetPhysWorld().RaycastQueryFirst(from, to, radius, collisionGroup, categoryMask, collisionMask, &queryResult); hitInfo->body = GetEntityFromBody(*queryResult.nearestBody); hitInfo->hitPos = std::move(queryResult.hitPos); @@ -130,7 +130,7 @@ namespace Ndk void PhysicsSystem2D::RegionQuery(const Nz::Rectf& boundingBox, Nz::UInt32 collisionGroup, Nz::UInt32 categoryMask, Nz::UInt32 collisionMask, std::vector* bodies) { std::vector queryResult; - m_physWorld->RegionQuery(boundingBox, collisionGroup, categoryMask, collisionMask, &queryResult); + GetPhysWorld().RegionQuery(boundingBox, collisionGroup, categoryMask, collisionMask, &queryResult); for (auto& body : queryResult) { diff --git a/src/Nazara/Network/Win32/SocketImpl.cpp b/src/Nazara/Network/Win32/SocketImpl.cpp index 15b89801b..097927dc6 100644 --- a/src/Nazara/Network/Win32/SocketImpl.cpp +++ b/src/Nazara/Network/Win32/SocketImpl.cpp @@ -29,7 +29,7 @@ struct tcp_keepalive #define SIO_KEEPALIVE_VALS _WSAIOW(IOC_VENDOR,4) #endif -#include +#include #include