Constraint 2D (#147)
* Rename all Constraint by [name]Constraint3D * Create Refs and Libraries for Constraint2D * Remove ref to PhysWorld in Constraints ctors * Update Constraint2d ctor to have RigiBodies first * Add New static function for all constraints and fix an oopsie * Add Contraint Library and remove all library useless aliases * Add ConstraintComponent2D * remove useless definition of Constraint2D library * Fix : getting the world of the constraint before having created it * Make the GetStaticBody function return a ref * Remove : Useless AddJoint Fonction and Update CreateJoint function * Update PhysicsSystem3D because GetStaticBody return now a ref * Oops * Having done something with the 3D and i was needing 2D * Add ConstraintComponent as friend of Collision and PhysicsComponent * Update all the Get[Static/Rigid]Body function so they return a pointer * fix the bugs caused by the commit before * update : CreateConstraint lambda for the nullptr case * remove the useless use of const pointer * Update : CreateConstraint function * Update ChangeLog.md
This commit is contained in:
@@ -33,7 +33,7 @@ namespace Ndk
|
||||
{
|
||||
// We update the geometry of the PhysiscsObject linked to the PhysicsComponent2D
|
||||
PhysicsComponent2D& physComponent = m_entity->GetComponent<PhysicsComponent2D>();
|
||||
physComponent.GetRigidBody().SetGeom(m_geom);
|
||||
physComponent.GetRigidBody()->SetGeom(m_geom);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace Ndk
|
||||
{
|
||||
// We update the geometry of the PhysiscsObject linked to the PhysicsComponent3D
|
||||
PhysicsComponent3D& physComponent = m_entity->GetComponent<PhysicsComponent3D>();
|
||||
physComponent.GetRigidBody().SetGeom(m_geom);
|
||||
physComponent.GetRigidBody()->SetGeom(m_geom);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
6
SDK/src/NDK/Components/ConstraintComponent2D.cpp
Normal file
6
SDK/src/NDK/Components/ConstraintComponent2D.cpp
Normal file
@@ -0,0 +1,6 @@
|
||||
#include <NDK/Components/ConstraintComponent2D.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
ComponentIndex ConstraintComponent2D::componentIndex;
|
||||
}
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <NDK/Components/PhysicsComponent2D.hpp>
|
||||
#include <NDK/Components/PhysicsComponent3D.hpp>
|
||||
#include <NDK/Components/VelocityComponent.hpp>
|
||||
#include <NDK/Components/ConstraintComponent2D.hpp>
|
||||
#include <NDK/Systems/PhysicsSystem2D.hpp>
|
||||
#include <NDK/Systems/PhysicsSystem3D.hpp>
|
||||
#include <NDK/Systems/VelocitySystem.hpp>
|
||||
@@ -89,6 +90,7 @@ namespace Ndk
|
||||
InitializeComponent<PhysicsComponent2D>("NdkPhys2");
|
||||
InitializeComponent<PhysicsComponent3D>("NdkPhys3");
|
||||
InitializeComponent<VelocityComponent>("NdkVeloc");
|
||||
InitializeComponent<VelocityComponent>("NdkCons2");
|
||||
|
||||
#ifndef NDK_SERVER
|
||||
// Client components
|
||||
|
||||
@@ -80,9 +80,9 @@ namespace Ndk
|
||||
NodeComponent& node = entity->GetComponent<NodeComponent>();
|
||||
PhysicsComponent2D& phys = entity->GetComponent<PhysicsComponent2D>();
|
||||
|
||||
Nz::RigidBody2D& body = phys.GetRigidBody();
|
||||
node.SetRotation(Nz::EulerAnglesf(0.f, 0.f, body.GetRotation()), Nz::CoordSys_Global);
|
||||
node.SetPosition(Nz::Vector3f(body.GetPosition(), node.GetPosition(Nz::CoordSys_Global).z), Nz::CoordSys_Global);
|
||||
Nz::RigidBody2D* body = phys.GetRigidBody();
|
||||
node.SetRotation(Nz::EulerAnglesf(0.f, 0.f, body->GetRotation()), Nz::CoordSys_Global);
|
||||
node.SetPosition(Nz::Vector3f(body->GetPosition(), node.GetPosition(Nz::CoordSys_Global).z), Nz::CoordSys_Global);
|
||||
}
|
||||
|
||||
float invElapsedTime = 1.f / elapsedTime;
|
||||
|
||||
@@ -84,9 +84,9 @@ namespace Ndk
|
||||
NodeComponent& node = entity->GetComponent<NodeComponent>();
|
||||
PhysicsComponent3D& phys = entity->GetComponent<PhysicsComponent3D>();
|
||||
|
||||
Nz::RigidBody3D& physObj = phys.GetRigidBody();
|
||||
node.SetRotation(physObj.GetRotation(), Nz::CoordSys_Global);
|
||||
node.SetPosition(physObj.GetPosition(), Nz::CoordSys_Global);
|
||||
Nz::RigidBody3D* physObj = phys.GetRigidBody();
|
||||
node.SetRotation(physObj->GetRotation(), Nz::CoordSys_Global);
|
||||
node.SetPosition(physObj->GetPosition(), Nz::CoordSys_Global);
|
||||
}
|
||||
|
||||
float invElapsedTime = 1.f / elapsedTime;
|
||||
|
||||
Reference in New Issue
Block a user