From 0183f60b80422e959ee1e7375b34dfaebb568c5a Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 13 Jan 2018 11:57:30 +0100 Subject: [PATCH] Fix compilation and PR --- .../NDK/Components/ConstraintComponent2D.inl | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/SDK/include/NDK/Components/ConstraintComponent2D.inl b/SDK/include/NDK/Components/ConstraintComponent2D.inl index 8c806e31b..2aade91b5 100644 --- a/SDK/include/NDK/Components/ConstraintComponent2D.inl +++ b/SDK/include/NDK/Components/ConstraintComponent2D.inl @@ -5,23 +5,25 @@ namespace Ndk { template - inline Nz::ObjectRef ConstraintComponent2D::CreateConstraint(const Ndk::EntityHandle first, const Ndk::EntityHandle second, Args && ...args) + inline Nz::ObjectRef ConstraintComponent2D::CreateConstraint(const Ndk::EntityHandle& first, const Ndk::EntityHandle& second, Args && ...args) { - auto QueryBody = [](const Ndk::EntityHandle& entity) -> Nz::RigidBody2D* + auto FetchBody = [](const Ndk::EntityHandle& entity) -> Nz::RigidBody2D* { if (entity->HasComponent()) return entity->GetComponent().GetRigidBody(); else if (entity->HasComponent()) return entity->GetComponent().GetStaticBody(); + return nullptr; }; - Nz::RigidBody2D* body_first{ QueryBody(first) }, body_second{ QueryBody(second) }; + Nz::RigidBody2D* firstBody = FetchBody(first); + NazaraAssert(firstBody, "First entity has no CollisionComponent2D nor PhysicsComponent2D component"); - NazaraAssert(body_first && body_second, "RigidBodies of CollisionComponent2D or PhysicsComponent2D must be valid"); - - Nz::ObjectRef constraint = T::New(*body_first, *body_second, std::forward(args)...); + Nz::RigidBody2D* secondBody = FetchBody(second); + NazaraAssert(secondBody, "Second entity has no CollisionComponent2D nor PhysicsComponent2D component"); + Nz::ObjectRef constraint = T::New(*firstBody, *secondBody, std::forward(args)...); m_constraints.push_back(constraint); return constraint;