Merge remote-tracking branch 'refs/remotes/origin/master' into enet_wip_nothing_to_see_here

This commit is contained in:
Lynix 2017-03-09 18:20:30 +01:00
commit 2cf1d5ddfc
4 changed files with 11 additions and 12 deletions

View File

@ -92,7 +92,6 @@ namespace Ndk
{
// Kill rigid body before entity destruction to force contact callbacks to be called while the entity is still valid
m_object.reset();
}
ComponentIndex PhysicsComponent3D::componentIndex;

View File

@ -91,7 +91,7 @@ namespace Nz
private:
void InitCallbacks(cpCollisionHandler* handler, const Callback& callbacks);
using PostStep = std::function<void()>;
using PostStep = std::function<void(Nz::RigidBody2D* body)>;
void OnRigidBodyMoved(RigidBody2D* oldPointer, RigidBody2D* newPointer);
void OnRigidBodyRelease(RigidBody2D* rigidBody);

View File

@ -169,7 +169,7 @@ namespace Nz
for (const auto& pair : m_rigidPostSteps)
{
for (const auto& step : pair.second.funcs)
step();
step(pair.first);
}
m_rigidPostSteps.clear();

View File

@ -245,24 +245,24 @@ namespace Nz
{
if (mass > 0.f)
{
m_world->RegisterPostStep(this, [this, mass]()
m_world->RegisterPostStep(this, [mass](Nz::RigidBody2D* body)
{
cpBodySetMass(m_handle, mass);
cpBodySetMoment(m_handle, m_geom->ComputeInertialMatrix(m_mass));
cpBodySetMass(body->GetHandle(), mass);
cpBodySetMoment(body->GetHandle(), body->GetGeom()->ComputeInertialMatrix(mass));
});
}
else
m_world->RegisterPostStep(this, [this]() { cpBodySetType(m_handle, CP_BODY_TYPE_STATIC); } );
m_world->RegisterPostStep(this, [](Nz::RigidBody2D* body) { cpBodySetType(body->GetHandle(), CP_BODY_TYPE_STATIC); } );
}
else if (mass > 0.f)
{
m_world->RegisterPostStep(this, [this, mass]()
m_world->RegisterPostStep(this, [mass](Nz::RigidBody2D* body)
{
if (cpBodyGetType(m_handle) == CP_BODY_TYPE_STATIC)
if (cpBodyGetType(body->GetHandle()) == CP_BODY_TYPE_STATIC)
{
cpBodySetType(m_handle, CP_BODY_TYPE_DYNAMIC);
cpBodySetMass(m_handle, mass);
cpBodySetMoment(m_handle, m_geom->ComputeInertialMatrix(m_mass));
cpBodySetType(body->GetHandle(), CP_BODY_TYPE_DYNAMIC);
cpBodySetMass(body->GetHandle(), mass);
cpBodySetMoment(body->GetHandle(), body->GetGeom()->ComputeInertialMatrix(mass));
}
});
}