From 66feadfd046a815e4770fc0547012214ea17a793 Mon Sep 17 00:00:00 2001 From: Stiffly Date: Thu, 8 Oct 2015 11:04:35 +0200 Subject: [PATCH] Fixed physics wrong error message --- include/Core/Engine.h | 6 +++--- src/game/Physics/PhysicsSystem.cpp | 19 ++++--------------- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/include/Core/Engine.h b/include/Core/Engine.h index 19ebbae..673805d 100755 --- a/include/Core/Engine.h +++ b/include/Core/Engine.h @@ -200,7 +200,7 @@ public: //ParticleTest - /*{ + { auto Pe = m_World->CreateEntity(); auto transform = m_World->AddComponent(Pe); auto particleEmitter= m_World->AddComponent(Pe); @@ -228,10 +228,10 @@ public: PtTransform->Position = transform->Position; PtSprite->SpriteFile = "Textures/Background.png"; PtParticle->LifeTime = 3.f; - PtParticle->Flags = ParticleFlags::Type::powderParticle | ParticleFlags::Type::particleContactFilterParticle | ParticleFlags::Type::fixtureContactFilterParticle; + PtParticle->Flags = static_cast(ParticleFlags::Type::Powder | ParticleFlags::Type::ParticleContactFilter | ParticleFlags::Type::FixtureContactFilter); } m_World->CommitEntity(Pe); - }*/ + } //TODO: Why does the ball not collide with these bricks? //BottomBox diff --git a/src/game/Physics/PhysicsSystem.cpp b/src/game/Physics/PhysicsSystem.cpp index 2824a39..98c8b82 100755 --- a/src/game/Physics/PhysicsSystem.cpp +++ b/src/game/Physics/PhysicsSystem.cpp @@ -303,23 +303,12 @@ void dd::Systems::PhysicsSystem::OnEntityCommit(EntityID entity) void dd::Systems::PhysicsSystem::OnEntityRemoved(EntityID entity) { - /* auto physics = m_World->GetComponent(entity); - if (physics == nullptr) { - return; - }*/ - auto it = m_EntitiesToBodies.find(entity); - if(it == m_EntitiesToBodies.end()) { - LOG_ERROR("Trying to remove non-exsisting body, Entity: %i", entity); - return; + if(it != m_EntitiesToBodies.end()) { + it->second->GetWorld()->DestroyBody(it->second); + m_BodiesToEntities.erase(it->second); + m_EntitiesToBodies.erase(entity); } - - //It told me I was removing a lot of objects, and I didn't need that information, so I commented it out. - //LOG_INFO("Removing entity %i", entity); - it->second->GetWorld()->DestroyBody(it->second); - m_BodiesToEntities.erase(it->second); - m_EntitiesToBodies.erase(entity); - //delete body; }