Lives kind of work, and so does the demo!

This commit is contained in:
PlatinumSkink
2015-09-15 13:35:04 +02:00
parent 9db15aa898
commit ce878ac1db
4 changed files with 51 additions and 38 deletions
+10 -4
View File
@@ -49,6 +49,8 @@ void dd::Systems::PhysicsSystem::Update(double dt)
b2Body* body = i.second;
auto transformComponent = m_World->GetComponent<Components::Transform>(entity);
if (! transformComponent)
continue;
if (m_World->GetEntityParent(entity) == 0) {
@@ -85,7 +87,8 @@ void dd::Systems::PhysicsSystem::Update(double dt)
b2Body* body = i.second;
auto transformComponent = m_World->GetComponent<Components::Transform>(entity);
if (! transformComponent)
continue;
if (m_World->GetEntityParent(entity) == 0) {
b2Vec2 position = body->GetPosition();
@@ -119,10 +122,13 @@ void dd::Systems::PhysicsSystem::OnEntityRemoved(EntityID entity)
{
b2Body* body = m_EntitiesToBodies[entity];
m_EntitiesToBodies.erase(entity);
m_BodiesToEntities.erase(body);
if (body != nullptr) {
m_EntitiesToBodies.erase(entity);
m_BodiesToEntities.erase(body);
m_PhysicsWorld->DestroyBody(body);
}
m_PhysicsWorld->DestroyBody(body);
}