From 1a0201ee98e890bb4970a725a98cdf634acf16f2 Mon Sep 17 00:00:00 2001 From: viktorljung Date: Mon, 28 Sep 2015 17:19:45 +0200 Subject: [PATCH] Style guide fixes --- include/Physics/PhysicsSystem.h | 111 +++---- include/Physics/PhysicsSystem.h.orig | 149 ---------- src/game/Game/LevelSystem.cpp.orig | 372 ------------------------ src/game/Game/PadSystem.cpp.orig | 313 -------------------- src/game/Physics/ContactListener.cpp | 47 +++ src/game/Physics/PhysicsSystem.cpp | 14 +- src/game/Physics/PhysicsSystem.cpp.orig | 363 ----------------------- 7 files changed, 84 insertions(+), 1285 deletions(-) delete mode 100755 include/Physics/PhysicsSystem.h.orig delete mode 100644 src/game/Game/LevelSystem.cpp.orig delete mode 100755 src/game/Game/PadSystem.cpp.orig create mode 100644 src/game/Physics/ContactListener.cpp delete mode 100755 src/game/Physics/PhysicsSystem.cpp.orig diff --git a/include/Physics/PhysicsSystem.h b/include/Physics/PhysicsSystem.h index eaaf49e..4ab4157 100644 --- a/include/Physics/PhysicsSystem.h +++ b/include/Physics/PhysicsSystem.h @@ -3,19 +3,20 @@ #include +#include + #include "Core/System.h" #include "Core/World.h" -#include "CRectangleShape.h" -#include "Physics/CPhysics.h" -#include +#include "Core/EventBroker.h" #include "Core/CTransform.h" #include "Transform/TransformSystem.h" +#include "CRectangleShape.h" +#include "Physics/CPhysics.h" #include "Physics/EContact.h" #include "Physics/ESetImpulse.h" #include "Physics/CCircleShape.h" -#include "Core/EventBroker.h" -#include "Game/CPad.h" #include "Physics/CWaterVolume.h" +#include "Game/CPad.h" #include "Game/CBall.h" #include "Rendering/CSprite.h" @@ -26,66 +27,55 @@ namespace dd namespace Systems { - class PhysicsSystem : public System { friend class ContractListener; public: PhysicsSystem(World* world, std::shared_ptr eventBroker) - : System(world, eventBroker) {} + : System(world, eventBroker) { } ~PhysicsSystem(); - EventRelay m_SetImpulse; - bool SetImpulse(const Events::SetImpulse &event); - void RegisterComponents(ComponentFactory* cf) override; void Initialize() override; - - // Called once per system every tick void Update(double dt) override; - // Called once for every entity in the world every tick void UpdateEntity(double dt, EntityID entity, EntityID parent) override; - - // Called when components are committed to an entity void OnEntityCommit(EntityID entity) override; - - // Called when an entity is removed void OnEntityRemoved(EntityID entity) override; private: - b2Vec2 m_Gravity; - b2World* m_PhysicsWorld; - float m_TimeStep; - float m_Accumulator; - - int m_VelocityIterations, m_PositionIterations; - - std::unordered_map m_EntitiesToBodies; - std::unordered_map m_BodiesToEntities; - - void CreateBody(EntityID entity); - - b2ParticleSystem *m_ParticleSystem; - b2ParticleGroup* t_watergroup; - - std::unordered_map m_EntitiesToParticleHandle; - std::unordered_map m_ParticleHandleToEntities; - - void InitializeWater(); - void SyncWater(); //TODO: Probably remove this - void CreateParticleGroup(EntityID entity); - struct Impulse { b2Body* Body; b2Vec2 Impulse; b2Vec2 Point; }; + + b2Vec2 m_Gravity = b2Vec2(0.f, -9.82f); + b2World* m_PhysicsWorld = nullptr; + float m_TimeStep = 1.f/60.f; + float m_Accumulator = 0.f; + int m_VelocityIterations = 6; + int m_PositionIterations = 2; + + b2ParticleSystem *m_ParticleSystem; + b2ParticleGroup* t_watergroup; + + std::unordered_map m_EntitiesToBodies; + std::unordered_map m_BodiesToEntities; + std::unordered_map m_EntitiesToParticleHandle; + std::unordered_map m_ParticleHandleToEntities; + std::list m_Impulses; + void CreateBody(EntityID entity); + void InitializeWater(); + void SyncWater(); //TODO: Probably remove this + void CreateParticleGroup(EntityID entity); + EventRelay m_SetImpulse; + bool SetImpulse(const Events::SetImpulse &event); class ContactListener : public b2ContactListener { @@ -93,45 +83,10 @@ private: ContactListener(PhysicsSystem* physicsSystem) : m_PhysicsSystem(physicsSystem) { } - void BeginContact(b2Contact* contact) - { - b2WorldManifold worldManifold; - - contact->GetWorldManifold(&worldManifold); - - Events::Contact e; - e.Entity1 = m_PhysicsSystem->m_BodiesToEntities[contact->GetFixtureA()->GetBody()]; - e.Entity2 = m_PhysicsSystem->m_BodiesToEntities[contact->GetFixtureB()->GetBody()]; - e.Normal = glm::normalize(glm::vec2(contact->GetManifold()->localNormal.x, contact->GetManifold()->localNormal.y)); - e.SignificantNormal = glm::normalize((glm::abs(e.Normal.x) > glm::abs(e.Normal.y)) ? glm::vec2(e.Normal.x, 0) : glm::vec2(0, e.Normal.y)); - - m_PhysicsSystem->EventBroker->Publish(e); - } - void EndContact(b2Contact* contact) - { - - } - void PreSolve(b2Contact* contact, const b2Manifold* oldManifold) - { - EntityID entityA = m_PhysicsSystem->m_BodiesToEntities[contact->GetFixtureA()->GetBody()]; - EntityID entityB = m_PhysicsSystem->m_BodiesToEntities[contact->GetFixtureB()->GetBody()]; - - auto physicsComponentA = m_PhysicsSystem->m_World->GetComponent(entityA); - auto physicsComponentB = m_PhysicsSystem->m_World->GetComponent(entityB); - - if (physicsComponentA != nullptr && physicsComponentB != nullptr) { - if (physicsComponentA->Calculate || physicsComponentB->Calculate) { - // Turn of collisions - contact->SetEnabled(false); - } - } - - - } - void PostSolve(b2Contact* contact, const b2ContactImpulse* impulse) - { - - } + void BeginContact(b2Contact* contact); + void EndContact(b2Contact* contact); + void PreSolve(b2Contact* contact, const b2Manifold* oldManifold); + void PostSolve(b2Contact* contact, const b2ContactImpulse* impulse); private: PhysicsSystem* m_PhysicsSystem; diff --git a/include/Physics/PhysicsSystem.h.orig b/include/Physics/PhysicsSystem.h.orig deleted file mode 100755 index f1465aa..0000000 --- a/include/Physics/PhysicsSystem.h.orig +++ /dev/null @@ -1,149 +0,0 @@ -#ifndef DAYDREAM_PHYSICSSYSTEM_H -#define DAYDREAM_PHYSICSSYSTEM_H - -#include - -#include "Core/System.h" -#include "Core/World.h" -#include "CRectangleShape.h" -#include "Physics/CPhysics.h" -#include -#include "Core/CTransform.h" -#include "Transform/TransformSystem.h" -#include "Physics/EContact.h" -#include "Physics/ESetImpulse.h" -#include "Physics/CCircleShape.h" -#include "Core/EventBroker.h" -#include "Game/CPad.h" -<<<<<<< HEAD -#include "Game/CBall.h" -======= -#include "Physics/CWaterVolume.h" -#include "Rendering/CSprite.h" ->>>>>>> origin/master - - -namespace dd -{ - -namespace Systems -{ - - -class PhysicsSystem : public System -{ - friend class ContractListener; - -public: - PhysicsSystem(World* world, std::shared_ptr eventBroker) - : System(world, eventBroker) {} - - ~PhysicsSystem(); - - EventRelay m_SetImpulse; - bool SetImpulse(const Events::SetImpulse &event); - - void RegisterComponents(ComponentFactory* cf) override; - void Initialize() override; - - // Called once per system every tick - void Update(double dt) override; - // Called once for every entity in the world every tick - void UpdateEntity(double dt, EntityID entity, EntityID parent) override; - - // Called when components are committed to an entity - void OnEntityCommit(EntityID entity) override; - - // Called when an entity is removed - void OnEntityRemoved(EntityID entity) override; - -private: - b2Vec2 m_Gravity; - b2World* m_PhysicsWorld; - float m_TimeStep; - float m_Accumulator; - - int m_VelocityIterations, m_PositionIterations; - - std::unordered_map m_EntitiesToBodies; - std::unordered_map m_BodiesToEntities; - - void CreateBody(EntityID entity); - - b2ParticleSystem *m_ParticleSystem; - b2ParticleGroup* t_watergroup; - - std::unordered_map m_EntitiesToParticleHandle; - std::unordered_map m_ParticleHandleToEntities; - - void InitializeWater(); - void SyncWater(); //TODO: Probably remove this - void CreateParticleGroup(EntityID entity); - - struct Impulse - { - b2Body* Body; - b2Vec2 Impulse; - b2Vec2 Point; - }; - std::list m_Impulses; - - - - class ContactListener : public b2ContactListener - { - public: - ContactListener(PhysicsSystem* physicsSystem) - : m_PhysicsSystem(physicsSystem) { } - - void BeginContact(b2Contact* contact) - { - b2WorldManifold worldManifold; - - contact->GetWorldManifold(&worldManifold); - - Events::Contact e; - e.Entity1 = m_PhysicsSystem->m_BodiesToEntities[contact->GetFixtureA()->GetBody()]; - e.Entity2 = m_PhysicsSystem->m_BodiesToEntities[contact->GetFixtureB()->GetBody()]; - e.Normal = glm::normalize(glm::vec2(contact->GetManifold()->localNormal.x, contact->GetManifold()->localNormal.y)); - e.SignificantNormal = glm::normalize((glm::abs(e.Normal.x) > glm::abs(e.Normal.y)) ? glm::vec2(e.Normal.x, 0) : glm::vec2(0, e.Normal.y)); - - m_PhysicsSystem->EventBroker->Publish(e); - } - void EndContact(b2Contact* contact) - { - - } - void PreSolve(b2Contact* contact, const b2Manifold* oldManifold) - { - EntityID entityA = m_PhysicsSystem->m_BodiesToEntities[contact->GetFixtureA()->GetBody()]; - EntityID entityB = m_PhysicsSystem->m_BodiesToEntities[contact->GetFixtureB()->GetBody()]; - - auto physicsComponentA = m_PhysicsSystem->m_World->GetComponent(entityA); - auto physicsComponentB = m_PhysicsSystem->m_World->GetComponent(entityB); - - if (physicsComponentA != nullptr && physicsComponentB != nullptr) { - if (physicsComponentA->Calculate || physicsComponentB->Calculate) { - // Turn of collisions - contact->SetEnabled(false); - } - } - - - } - void PostSolve(b2Contact* contact, const b2ContactImpulse* impulse) - { - - } - - private: - PhysicsSystem* m_PhysicsSystem; - }; - - ContactListener* m_ContactListener; -}; - -} -} - -#endif //DAYDREAM_PHYSICSSYSTEM_H diff --git a/src/game/Game/LevelSystem.cpp.orig b/src/game/Game/LevelSystem.cpp.orig deleted file mode 100644 index b1d1139..0000000 --- a/src/game/Game/LevelSystem.cpp.orig +++ /dev/null @@ -1,372 +0,0 @@ -// -// Created by Adniklastrator on 2015-09-09. -// - - -#include "PrecompiledHeader.h" -#include "Game/LevelSystem.h" - - -void dd::Systems::LevelSystem::Initialize() -{ - EVENT_SUBSCRIBE_MEMBER(m_EContact, LevelSystem::OnContact); - EVENT_SUBSCRIBE_MEMBER(m_ELifeLost, LevelSystem::OnLifeLost); - EVENT_SUBSCRIBE_MEMBER(m_EScoreEvent, LevelSystem::OnScoreEvent); - EVENT_SUBSCRIBE_MEMBER(m_EMultiBall, LevelSystem::OnMultiBall); - EVENT_SUBSCRIBE_MEMBER(m_ECreatePowerUp, LevelSystem::OnCreatePowerUp); - EVENT_SUBSCRIBE_MEMBER(m_EPowerUpTaken, LevelSystem::OnPowerUpTaken); - EVENT_SUBSCRIBE_MEMBER(m_EStageCleared, LevelSystem::OnStageCleared); - - for (int i = 0; i < Lives(); i++) { - CreateLife(i); - } - - return; -} - -void dd::Systems::LevelSystem::CreateLife(int number) -{ - auto life = m_World->CreateEntity(); - std::shared_ptr transform = m_World->AddComponent(life); - transform->Position = glm::vec3(-1.5f + number * 0.15f, -2.f, -5.f); - transform->Scale = glm::vec3(0.1f, 0.1f, 0.1f); - - std::shared_ptr lifeNr = m_World->AddComponent(life); - lifeNr->Number = number; - - auto model = m_World->AddComponent(life); - model->ModelFile = "Models/Test/Ball/Ballopus.obj"; - - - m_World->CommitEntity(life); -} - -void dd::Systems::LevelSystem::Update(double dt) -{ - if (!m_Initialized) { - CreateBasicLevel(Rows(), Lines(), SpaceBetweenBricks(), SpaceToEdge()); - m_Initialized = true; - } - - if (Lives() < 0) - { - SetLives(3); - Events::GameOver e; - EventBroker->Publish(e); - } -} - -void dd::Systems::LevelSystem::UpdateEntity(double dt, EntityID entity, EntityID parent) -{ - auto ball = m_World->GetComponent(entity); - - if (ball != nullptr) { - auto transformBall = m_World->GetComponent(entity); - if (glm::abs(transformBall->Velocity.y) < 2) { - if (transformBall->Velocity.y > 0) { - transformBall->Velocity.y = 2; - } else { - transformBall->Velocity.y = -2; - } - } - if (transformBall->Position.y < -EdgeY() - 4) { - if (MultiBalls() != 0) { - SetMultiBalls(MultiBalls() - 1); -// m_World->RemoveComponent(entity); -// m_World->RemoveComponent(entity); -// m_World->RemoveComponent(entity); -// m_World->RemoveComponent(entity); - m_World->RemoveEntity(entity); - } else if (Lives() == PastLives()) { - Events::ResetBall be; - EventBroker->Publish(be); - Events::LifeLost e; - e.Entity = entity; - EventBroker->Publish(e); - return; - } - } else if (transformBall->Position.x > EdgeX()) { - if (transformBall->Velocity.x > 0) { - glm::vec2 reflectedVelocity = glm::reflect(glm::vec2(transformBall->Velocity.x, transformBall->Velocity.y), glm::vec2(1, 0)); - transformBall->Velocity = glm::vec3(reflectedVelocity, 0.f); - } - } else if (transformBall->Position.x < -EdgeX()) { - if (transformBall->Velocity.x < 0) { - glm::vec2 reflectedVelocity = glm::reflect(glm::vec2(transformBall->Velocity.x, transformBall->Velocity.y), glm::vec2(-1, 0)); - transformBall->Velocity = glm::vec3(reflectedVelocity, 0.f); - } - } else if (transformBall->Position.y > EdgeY()) { - if (transformBall->Velocity.y > 0) { - glm::vec2 reflectedVelocity = glm::reflect(glm::vec2(transformBall->Velocity.x, transformBall->Velocity.y), glm::vec2(0, 1)); - transformBall->Velocity = glm::vec3(reflectedVelocity, 0.f); - } - } - } - - if (Lives() != PastLives()) { - auto life = m_World->GetComponent(entity); - if (life != nullptr) { - if (life->Number + 1 == PastLives()) { -// m_World->RemoveComponent(entity); -// m_World->RemoveComponent(entity); - m_World->RemoveEntity(entity); - SetPastLives(Lives()); - } - } - } - if (NumberOfBricks() <= 0) { - /*SetRestarting(true); - if (MultiBalls() <= 0 && PowerUps() <= 0) { - Events::ResetBall e; - EventBroker->Publish(e); - Events::ScoreEvent es; - es.Score = 500; - EventBroker->Publish(es); - Events::StageCleared ec; - EventBroker->Publish(ec); - CreateBasicLevel(Rows(), Lines(), SpaceBetweenBricks(), SpaceToEdge()); - } else { - if (ball != nullptr && MultiBalls() > 0) { - SetMultiBalls(MultiBalls() - 1); - m_World->RemoveComponent(entity); - m_World->RemoveComponent(entity); - m_World->RemoveComponent(entity); - m_World->RemoveComponent(entity); - m_World->RemoveEntity(entity); - auto transformBall = m_World->GetComponent(entity); - } else { - auto powerUp = m_World->GetComponent(entity); - if (powerUp != nullptr) { - SetPowerUps(PowerUps() - 1); - m_World->RemoveComponent(entity); - m_World->RemoveComponent(entity); - m_World->RemoveEntity(entity); - } - } - }*/ - } -} - -void dd::Systems::LevelSystem::CreateBasicLevel(int rows, int lines, glm::vec2 spacesBetweenBricks, float spaceToEdge) -{ - SetNumberOfBricks(rows * lines); - std::cout << "You're only doing this once, right?" << std::endl; - int num = 0; - for (int i = 0; i < rows; i++) { - num++; - for (int j = 0; j < Lines(); j++) { - CreateBrick(i, j, spacesBetweenBricks, spaceToEdge, num); - } - if (num == 7) - num = 0; - } - - SetNumberOfBricks(rows * lines); - SetRestarting(false); - return; -} - -void dd::Systems::LevelSystem::CreateBrick(int row, int line, glm::vec2 spacesBetweenBricks, float spaceToEdge, int num) -{ - auto brick = m_World->CreateEntity(); - std::shared_ptr transform = m_World->AddComponent(brick); - auto model = m_World->AddComponent(brick); - std::shared_ptr cBrick = m_World->AddComponent(brick); - std::shared_ptr cRec = m_World->AddComponent(brick); - std::shared_ptr cPhys = m_World->AddComponent(brick); - cPhys->Static = false; - cPhys->GravityScale = 0.f; - cPhys->Category = CollisionLayer::Type::Brick; - cPhys->Mask = CollisionLayer::Type::Ball; - - std::string fileName = "Textures/Bricks/"; - fileName.append(std::to_string(num)); - fileName.append(".png"); - //sprite->SpriteFile = fileName; - model->ModelFile = "Models/Test/Brick/Brick.obj"; - if ((line == 1 && row == 4) || (line == 3 && row == 2) || (line == 6 && row == 6)) { - std::shared_ptr cPow = m_World->AddComponent(brick); - } - float x = line * spacesBetweenBricks.x; - float y = row * spacesBetweenBricks.y; - transform->Scale = glm::vec3(0.8, 0.2, 0.2); - transform->Position = glm::vec3(x - 3, 5 - spaceToEdge - y , -10.f); - cBrick->Score = 10 * num; - - //sound - auto collisionSound = m_World->AddComponent(brick); - collisionSound->filePath = "Sounds/Brick/shortbrickbreak.wav"; - - m_World->CommitEntity(brick); - return; -} - -void dd::Systems::LevelSystem::ProcessCollision() -{ - // Like, go into brick component and check what it does upon collision. Maybe not done here? - return; -} - -void dd::Systems::LevelSystem::OnEntityRemoved(EntityID entity) -{ - auto brick = m_World->GetComponent(entity); - if (brick != nullptr) { - SetNumberOfBricks(NumberOfBricks() - 1); - Events::ScoreEvent es; - es.Score = brick->Score; - EventBroker->Publish(es); - /*if (numberOfBricks < 1) { - EndLevel(); - }*/ - } - return; -} - -bool dd::Systems::LevelSystem::OnContact(const dd::Events::Contact &event) -{ - EntityID entityBrick; - EntityID entityBall; - auto ball = m_World->GetComponent(event.Entity2); - auto brick = m_World->GetComponent(event.Entity1); - if (brick != nullptr) { - entityBrick = event.Entity1; - } else { - brick = m_World->GetComponent(event.Entity2); - if (brick != nullptr) { - entityBrick = event.Entity2; - } else { - return false; - } - } - if (ball != nullptr) { - entityBall = event.Entity2; - } else { - ball = m_World->GetComponent(event.Entity1); - if (ball != nullptr) { - entityBall = event.Entity1; - } else { - return false; - } - } - - brick = m_World->GetComponent(entityBrick); - if (brick == nullptr) { - return false; - } - - auto power = m_World->GetComponent(entityBrick); - if (power != nullptr) { - Events::CreatePowerUp e; - auto transform = m_World->GetComponent(entityBrick); - e.Position = transform->Position; - EventBroker->Publish(e); - } - - if (ball != nullptr && Restarting() == false) { - auto ballTransform = m_World->GetComponent(entityBall); - -// m_World->RemoveComponent(entityBrick); -// m_World->RemoveComponent(entityBrick); -// m_World->RemoveComponent(entityBrick); -// m_World->RemoveComponent(entityBrick); -// m_World->RemoveEntity(entityBrick); - - auto physicsComponent = m_World->GetComponent(entityBrick); - physicsComponent->GravityScale = 1.f; - physicsComponent->Mask = CollisionLayer::Type::Water | CollisionLayer::Type::Wall; - - auto transformComponentBrick = m_World->GetComponent(entityBrick); - auto transformComponentBall = m_World->GetComponent(entityBall); - - Events::SetImpulse e; - e.Entity = entityBrick; - - glm::vec2 point = glm::vec2(transformComponentBrick->Position.x + ((transformComponentBrick->Position.x - transformComponentBall->Position.x)/4), transformComponentBrick->Position.y + ((transformComponentBrick->Position.y - transformComponentBall->Position.y )/4)); - - e.Impulse = glm::normalize(point)/2.f; - e.Point = point; - EventBroker->Publish(e); - //TODO: Bricks dont collide with walls D= - - SetNumberOfBricks(NumberOfBricks() - 1); - if (NumberOfBricks() <= 0) { - SetMultiBalls(MultiBalls() + 1); - } - Events::ScoreEvent es; - es.Score = brick->Score; - EventBroker->Publish(es); - -<<<<<<< HEAD - // std::cout << NumberOfBricks() << std::endl; -======= - //std::cout << NumberOfBricks() << std::endl; ->>>>>>> origin/master - //std::cout << "Score: " << Score() << std::endl; - } - - return true; -} - -bool dd::Systems::LevelSystem::OnLifeLost(const dd::Events::LifeLost &event) -{ - SetLives(Lives() - 1); - - return true; -} - -bool dd::Systems::LevelSystem::OnScoreEvent(const dd::Events::ScoreEvent &event) -{ - SetScore(Score() += event.Score); - - return true; -} - -bool dd::Systems::LevelSystem::OnMultiBall(const dd::Events::MultiBall &event) -{ - SetMultiBalls(MultiBalls()+2); -} - -bool dd::Systems::LevelSystem::OnCreatePowerUp(const dd::Events::CreatePowerUp &event) -{ - SetPowerUps(PowerUps() + 1); - auto powerUp = m_World->CreateEntity(); - std::shared_ptr transform = m_World->AddComponent(powerUp); - auto model = m_World->AddComponent(powerUp); - std::shared_ptr cRec = m_World->AddComponent(powerUp); - std::shared_ptr cPhys = m_World->AddComponent(powerUp); - cPhys->Static = false; - cPhys->Category = CollisionLayer::Type::PowerUp; - cPhys->Mask = CollisionLayer::Type::Pad; - - std::shared_ptr cPow = m_World->AddComponent(powerUp); - - - transform->Position = event.Position; - transform->Scale = glm::vec3(0.2, 0.2, 0.2); - transform->Velocity = glm::vec3(0, -4, 0); - - model->ModelFile = "Models/Test/Ball/Ballopus.obj"; - - m_World->CommitEntity(powerUp); - - return true; -} - -bool dd::Systems::LevelSystem::OnPowerUpTaken(const dd::Events::PowerUpTaken &event) -{ - SetPowerUps(PowerUps() - 1); - return true; -} - -bool dd::Systems::LevelSystem::OnStageCleared(const dd::Events::StageCleared &event) -{ - return true; -} - -void dd::Systems::LevelSystem::EndLevel() -{ - Events::StageCleared e; - EventBroker->Publish(e); - return; -} - diff --git a/src/game/Game/PadSystem.cpp.orig b/src/game/Game/PadSystem.cpp.orig deleted file mode 100755 index 7d21606..0000000 --- a/src/game/Game/PadSystem.cpp.orig +++ /dev/null @@ -1,313 +0,0 @@ -// -// Created by Adniklastrator on 2015-09-10. -// - -#include "PrecompiledHeader.h" -#include "Game/PadSystem.h" -#include "Core/World.h" -#include -#include -#include - - -void dd::Systems::PadSystem::Initialize() -{ - Events::BindKey r; - r.KeyCode = GLFW_KEY_RIGHT; - r.Command = "right"; - EventBroker->Publish(r); - - Events::BindKey l; - l.KeyCode = GLFW_KEY_LEFT; - l.Command = "left"; - EventBroker->Publish(l); - - EVENT_SUBSCRIBE_MEMBER(m_EKeyDown, &PadSystem::OnKeyDown); - EVENT_SUBSCRIBE_MEMBER(m_EKeyUp, &PadSystem::OnKeyUp); - EVENT_SUBSCRIBE_MEMBER(m_EContact, &PadSystem::OnContact); - EVENT_SUBSCRIBE_MEMBER(m_EContactPowerUp, &PadSystem::OnContactPowerUp); - EVENT_SUBSCRIBE_MEMBER(m_EResetBall, &PadSystem::OnResetBall); - EVENT_SUBSCRIBE_MEMBER(m_EMultiBall, &PadSystem::OnMultiBall); - EVENT_SUBSCRIBE_MEMBER(m_EStageCleared, &PadSystem::OnStageCleared); -} - -void dd::Systems::PadSystem::UpdateEntity(double dt, EntityID entity, EntityID parent) -{ - auto ball = m_World->GetComponent(entity); - if (ball != nullptr) { - if (ReplaceBall() == true) { - SetReplaceBall(false); - - auto transform = m_World->GetComponent(entity); - transform->Position = glm::vec3(0.0f, 0.26f, -10.f); - transform->Velocity = glm::vec3(0.0f, -ball->Speed, 0.f); - } - } -} - -void dd::Systems::PadSystem::Update(double dt) -{ - if (Entity() == 0) { - for (auto it = m_World->GetEntities()->begin(); it != m_World->GetEntities()->end(); it++) { - if (m_World->GetProperty(it->first, "Name") == "Pad") { - SetEntity(it->first); - SetTransform(m_World->GetComponent(Entity())); - SetPad(m_World->GetComponent(Entity())); - break; - } - } - } - - auto transform = Transform(); - auto pad = Pad(); - auto acceleration = Acceleration(); - - if (transform->Velocity.x < -pad->MaxSpeed) { - transform->Velocity.x = -pad->MaxSpeed; - } - else if (transform->Velocity.x > pad->MaxSpeed) { - transform->Velocity.x = pad->MaxSpeed; - } - transform->Position += transform->Velocity * (float)dt; - transform->Velocity += acceleration * (float)dt; - transform->Velocity -= transform->Velocity * pad->SlowdownModifier * (float)dt; - - - if (Left()) { - acceleration.x = -pad->AccelerationSpeed; -<<<<<<< HEAD - } - else if (Right()) { -======= - } else if (Right()) { ->>>>>>> 72413dc0a93bd3a2f6ab9fa7e19bbc3b846232db - acceleration.x = pad->AccelerationSpeed; - } else { - acceleration.x = 0.f; - } - - SetTransform(transform); - SetPad(pad); - SetAcceleration(acceleration); - - if (MultiBall() == true) { - SetMultiBall(false); - - Events::MultiBall e; - e.padTransform = transform; - EventBroker->Publish(e); - } - - return; -} - -EntityID dd::Systems::PadSystem::CreateBall() -{ - auto ent = m_World->CreateEntity(); - std::shared_ptr transform = m_World->AddComponent(ent); - transform->Position = glm::vec3(0.5f, 0.26f, -10.f); - transform->Scale = glm::vec3(0.5f, 0.5f, 0.5f); - auto model = m_World->AddComponent(ent); - model->ModelFile = "Models/Test/Ball/Ballopus.obj"; - //auto pointlight = m_World->AddComponent(ent); - std::shared_ptr circleShape = m_World->AddComponent(ent); - std::shared_ptr cball = m_World->AddComponent(ent); - std::shared_ptr physics = m_World->AddComponent(ent); - physics->Static = false; - - cball->Speed = 10; - - m_World->CommitEntity(ent); - - return ent; -} - -bool dd::Systems::PadSystem::OnKeyDown(const dd::Events::KeyDown &event) -{ - int val = event.KeyCode; - if (val == GLFW_KEY_UP) { - //std::cout << "Up!" << std::endl; - } else if (val == GLFW_KEY_DOWN) { - //std::cout << "Down!" << std::endl; - } else if (val == GLFW_KEY_LEFT) { - //std::cout << "Left!" << std::endl; - //acceleration.x = -0.01f; - SetLeft(true); - } else if (val == GLFW_KEY_RIGHT) { - //std::cout << "Right!" << std::endl; - //acceleration.x = 0.01f; - SetRight(true); - } else if (val == GLFW_KEY_R) { - SetReplaceBall(true); - } else if (val == GLFW_KEY_M) { - SetMultiBall(true); - } else if (val == GLFW_KEY_D) { - return false; - } - return true; -} - -bool dd::Systems::PadSystem::OnKeyUp(const dd::Events::KeyUp &event) -{ - int val = event.KeyCode; - if (val == GLFW_KEY_UP) { - - } else if (val == GLFW_KEY_DOWN) { - - } else if (val == GLFW_KEY_LEFT) { - SetLeft(false); - } else if (val == GLFW_KEY_RIGHT) { - SetRight(false); - } - return true; -} - -bool dd::Systems::PadSystem::OnContact(const dd::Events::Contact &event) -{ - /* - EntityID entityBall = event.Entity2; - auto ball = m_World->GetComponent(entityBall); - if (ball == NULL) { - return false; - } - EntityID entityPad = event.Entity1; - auto pad = m_World->GetComponent(entityPad); - if (pad == NULL) { - return false; - } - auto transformBall = m_World->GetComponent(entityBall); - auto transformPad = m_World->GetComponent(entityPad); - - float movementMultiplier = 0.5f; - - //float movementX = (event.ContactPoint.x - transformPad->Position.x) * movementMultiplier; - //float movementY = glm::cos((abs(movementX) / (3.2f * movementMultiplier)) * 3.14159265359f / 2) * 2.f; - if (whatX > 0) { - movementX = movementMultiplier * whatX; - //std::cout << "Right!" << std::endl; - } else { - movementX = movementMultiplier * whatX; - //std::cout << "Left!" << std::endl; - } - - // std::cout << movementX << " " << movementY << std::endl; - - //float movementX = (event.ContactPoint.x - transformPad->Position.x) * movementMultiplier; -<<<<<<< HEAD - float movementY = glm::cos((abs(movementX) / ((1.6f) * movementMultiplier)) * 3.14159265359f / 2) + 1; -======= - float movementY = glm::cos((abs(movementX) / ((1.6f) * movementMultiplier)) * 3.14159265359f / 2)+ 0.2; ->>>>>>> 72413dc0a93bd3a2f6ab9fa7e19bbc3b846232db - - //std::cout << movementX << " " << movementY << std::endl; - - float len = glm::length(transformBall->Velocity); - //auto pointlight = m_World->AddComponent(ent); - - - transformBall->Velocity += glm::vec3(transformPad->Velocity.x, 0, 0); - transformBall->Velocity = glm::normalize(transformBall->Velocity) * len; - - - //transform->Velocity = glm::vec3(movementX, movementY, 0.f); - */ -} - -bool dd::Systems::PadSystem::OnContactPowerUp(const dd::Events::Contact &event) -{ - EntityID entityPower; - EntityID entityPad; - auto powerUp = m_World->GetComponent(event.Entity1); - auto pad = m_World->GetComponent(event.Entity2); - if (powerUp != nullptr) { - entityPower = event.Entity1; - } else { - powerUp = m_World->GetComponent(event.Entity2); - if (powerUp != nullptr) { - entityPower = event.Entity2; - } - } - if (pad != nullptr) { - entityPad = event.Entity2; - } else { - pad = m_World->GetComponent(event.Entity1); - if (pad != nullptr) { - entityPad = event.Entity1; - } - } - - if (entityPower == NULL || entityPad == NULL) { - return false; - } - - pad = m_World->GetComponent(entityPad); - if (pad == nullptr) { - return false; - } - - m_World->RemoveComponent(entityPower); - m_World->RemoveComponent(entityPower); - m_World->RemoveComponent(entityPower); - m_World->RemoveEntity(entityPower); - Events::PowerUpTaken ep; - ep.Name = "Something"; - EventBroker->Publish(ep); - - Events::MultiBall e; - auto transform = m_World->GetComponent(entityPad); - e.padTransform = transform; - EventBroker->Publish(e); - return true; -} - -bool dd::Systems::PadSystem::OnResetBall(const dd::Events::ResetBall &event) -{ - SetReplaceBall(true); - return true; -} - -bool dd::Systems::PadSystem::OnMultiBall(const dd::Events::MultiBall &event) -{ - auto ent1 = CreateBall(); - auto ent2 = CreateBall(); - auto transform1 = m_World->GetComponent(ent1); - auto transform2 = m_World->GetComponent(ent2); - auto ball1 = m_World->GetComponent(ent1); - auto ball2 = m_World->GetComponent(ent2); - auto padTransform = event.padTransform; - float x1 = padTransform->Position.x - 2, x2 = padTransform->Position.x + 2; - if (x1 < -3.1) { - x1 = 3; - } - if (x2 > 3.1) { - x2 = -3; - } - transform1->Position = glm::vec3(x1, -5.5, -10); - transform2->Position = glm::vec3(x2, -5.5, -10); - - transform1->Velocity = glm::normalize(glm::vec3(5, 5 ,0.f)) * ball1->Speed; - transform2->Velocity = glm::normalize(glm::vec3(-5, 5 ,0.f)) * ball2->Speed; - - return true; -} - -bool dd::Systems::PadSystem::OnStageCleared(const dd::Events::StageCleared &event) -{ - auto entity = CreateBall(); - return true; -} - -bool dd::Systems::PadSystem::PadSteeringInputController::OnCommand(const Events::InputCommand &event) -{ - std::string command = event.Command; - - std::cout << "Command!" << std::endl; - - if (command == "right") { - std::cout << "Right!" << std::endl; - } else if (command == "left") { - std::cout << "Left!" << std::endl; - } - - return true; -} \ No newline at end of file diff --git a/src/game/Physics/ContactListener.cpp b/src/game/Physics/ContactListener.cpp new file mode 100644 index 0000000..97981d1 --- /dev/null +++ b/src/game/Physics/ContactListener.cpp @@ -0,0 +1,47 @@ +#include "PrecompiledHeader.h" +#include "Physics/PhysicsSystem.h" + +void dd::Systems::PhysicsSystem::ContactListener::BeginContact(b2Contact* contact) +{ + b2WorldManifold worldManifold; + + contact->GetWorldManifold(&worldManifold); + + Events::Contact e; + e.Entity1 = m_PhysicsSystem->m_BodiesToEntities[contact->GetFixtureA()->GetBody()]; + e.Entity2 = m_PhysicsSystem->m_BodiesToEntities[contact->GetFixtureB()->GetBody()]; + e.Normal = glm::normalize(glm::vec2(contact->GetManifold()->localNormal.x, contact->GetManifold()->localNormal.y)); + e.SignificantNormal = glm::normalize((glm::abs(e.Normal.x) > glm::abs(e.Normal.y)) ? glm::vec2(e.Normal.x, 0) : glm::vec2(0, e.Normal.y)); + + m_PhysicsSystem->EventBroker->Publish(e); +} + +void dd::Systems::PhysicsSystem::ContactListener::EndContact(b2Contact* contact) +{ + +} + +void dd::Systems::PhysicsSystem::ContactListener::PreSolve(b2Contact* contact, const b2Manifold* oldManifold) +{ + EntityID entityA = m_PhysicsSystem->m_BodiesToEntities[contact->GetFixtureA()->GetBody()]; + EntityID entityB = m_PhysicsSystem->m_BodiesToEntities[contact->GetFixtureB()->GetBody()]; + + auto physicsComponentA = m_PhysicsSystem->m_World->GetComponent(entityA); + auto physicsComponentB = m_PhysicsSystem->m_World->GetComponent(entityB); + + if (physicsComponentA != nullptr && physicsComponentB != nullptr) { + if (physicsComponentA->Calculate || physicsComponentB->Calculate) { + // Turn of collisions + contact->SetEnabled(false); + } + } + + +} + +void dd::Systems::PhysicsSystem::ContactListener::PostSolve(b2Contact* contact, const b2ContactImpulse* impulse) +{ + +} + + diff --git a/src/game/Physics/PhysicsSystem.cpp b/src/game/Physics/PhysicsSystem.cpp index 7d23110..8c6f5ed 100644 --- a/src/game/Physics/PhysicsSystem.cpp +++ b/src/game/Physics/PhysicsSystem.cpp @@ -6,24 +6,15 @@ void dd::Systems::PhysicsSystem::RegisterComponents(ComponentFactory* cf) { cf->Register(); + //TODO: REGISTER PHYSICS COMPONENTS HERE } void dd::Systems::PhysicsSystem::Initialize() { m_ContactListener = new ContactListener(this); - - m_Gravity = b2Vec2(0.f, -9.82f); m_PhysicsWorld = new b2World(m_Gravity); - - m_TimeStep = 1.f/60.f; - m_VelocityIterations = 6; - m_PositionIterations = 2; - m_Accumulator = 0.f; - m_PhysicsWorld->SetContactListener(m_ContactListener); - InitializeWater(); - EVENT_SUBSCRIBE_MEMBER(m_SetImpulse, PhysicsSystem::SetImpulse); } @@ -325,8 +316,11 @@ void dd::Systems::PhysicsSystem::CreateParticleGroup(EntityID e) LOG_INFO("ParticleCount: %i", m_ParticleSystem->GetParticleCount()); } + + dd::Systems::PhysicsSystem::~PhysicsSystem() { + //TODO: INPUT CODE HERE if (m_ContactListener != nullptr) { delete m_ContactListener; m_ContactListener = nullptr; diff --git a/src/game/Physics/PhysicsSystem.cpp.orig b/src/game/Physics/PhysicsSystem.cpp.orig deleted file mode 100755 index 7fb8bc1..0000000 --- a/src/game/Physics/PhysicsSystem.cpp.orig +++ /dev/null @@ -1,363 +0,0 @@ -#include "PrecompiledHeader.h" -#include "Physics/PhysicsSystem.h" - - - -void dd::Systems::PhysicsSystem::RegisterComponents(ComponentFactory* cf) -{ - cf->Register(); -} - -void dd::Systems::PhysicsSystem::Initialize() -{ - m_ContactListener = new ContactListener(this); - - m_Gravity = b2Vec2(0.f, -9.82f); - m_PhysicsWorld = new b2World(m_Gravity); - - m_TimeStep = 1.f/60.f; - m_VelocityIterations = 6; - m_PositionIterations = 2; - m_Accumulator = 0.f; - - m_PhysicsWorld->SetContactListener(m_ContactListener); - - InitializeWater(); - - EVENT_SUBSCRIBE_MEMBER(m_SetImpulse, PhysicsSystem::SetImpulse); -} - -void dd::Systems::PhysicsSystem::InitializeWater() -{ - b2ParticleSystemDef m_ParticleSystemDef; - m_ParticleSystemDef.radius = 0.13f; - - m_ParticleSystem = m_PhysicsWorld->CreateParticleSystem(&m_ParticleSystemDef); -} - -bool dd::Systems::PhysicsSystem::SetImpulse(const Events::SetImpulse &event) -{ - b2Body* body = m_EntitiesToBodies[event.Entity]; - - b2Vec2 impulse; - impulse.x = event.Impulse.x; - impulse.y = event.Impulse.y; - - b2Vec2 point; - point.x = event.Point.x; - point.y = event.Point.y; - - - Impulse i; - i.Body = body; - i.Impulse = impulse; - i.Point = point; - - m_Impulses.push_back(i); - - return true; -} - -void dd::Systems::PhysicsSystem::Update(double dt) -{ - - m_Accumulator += dt; - while(m_Accumulator >= m_TimeStep) - { - - for (auto i : m_EntitiesToBodies) { - EntityID entity = i.first; - b2Body* body = i.second; - - auto transformComponent = m_World->GetComponent(entity); - if (! transformComponent) { - continue; - LOG_ERROR("RigidBody with no TransformComponent"); - } - auto physicsComponent = m_World->GetComponent(entity); - if (! physicsComponent) { - continue; - LOG_ERROR("RigidBody with no PhysicsComponent"); - } - - - if (body == nullptr) { - LOG_ERROR("This body should not exist"); - continue; - } - - if (m_World->GetEntityParent(entity) == 0) { //TODO: Make this work with childs too - b2Vec2 position; - position.x = transformComponent->Position.x; - position.y = transformComponent->Position.y; - float angle = -glm::eulerAngles(transformComponent->Orientation).z; - body->SetTransform(position, angle); - body->SetLinearVelocity(b2Vec2(transformComponent->Velocity.x, transformComponent->Velocity.y)); - - body->SetGravityScale(physicsComponent->GravityScale); - -<<<<<<< HEAD - - b2Filter filter; - filter.categoryBits = physicsComponent->Category; - filter.maskBits = physicsComponent->Mask; - body->GetFixtureList()->SetFilterData(filter); - } - } - - for (auto i : m_Impulses) { - i.Body->ApplyLinearImpulse(i.Impulse, i.Point, true); -======= ->>>>>>> origin/master - } - m_Impulses.clear(); - - -<<<<<<< HEAD - - -======= - for (auto i : m_Impulses) { - i.Body->ApplyLinearImpulse(i.Impulse, i.Point, true); - } - m_Impulses.clear(); - m_Accumulator += dt; - while(m_Accumulator >= m_TimeStep) - { ->>>>>>> origin/master - m_PhysicsWorld->Step(m_TimeStep, m_VelocityIterations, m_PositionIterations); - m_Accumulator -= dt; - -<<<<<<< HEAD - -======= - for (auto i : m_EntitiesToBodies) { - EntityID entity = i.first; - b2Body* body = i.second; ->>>>>>> origin/master - - for (auto i : m_EntitiesToBodies) { - EntityID entity = i.first; - b2Body* body = i.second; - - if (body == nullptr) { - LOG_ERROR("This body should not exist"); - continue; - } - -<<<<<<< HEAD - auto transformComponent = m_World->GetComponent(entity); - if (! transformComponent) - continue; - if (m_World->GetEntityParent(entity) == 0) { - b2Vec2 position = body->GetPosition(); - transformComponent->Position.x = position.x; - transformComponent->Position.y = position.y; -======= - auto transformComponent = m_World->GetComponent(entity); - if (! transformComponent) - continue; - auto parent = m_World->GetEntityParent(entity); - if (parent == 0) { - b2Vec2 position = body->GetPosition(); - transformComponent->Position.x = position.x; - transformComponent->Position.y = position.y; ->>>>>>> origin/master - - float angle = body->GetAngle(); - - - transformComponent->Orientation = glm::quat(glm::vec3(0, 0, -angle)); - -<<<<<<< HEAD - b2Vec2 velocity = body->GetLinearVelocity(); - transformComponent->Velocity.x = velocity.x; - transformComponent->Velocity.y = velocity.y; - - } -======= ->>>>>>> origin/master - } - } - - b2Vec2* positionBuffer = m_ParticleSystem->GetPositionBuffer(); - for (auto i : m_EntitiesToParticleHandle) { - EntityID entity = i.first; - b2ParticleHandle* particleH = i.second; - - b2Vec2 positionB2 = positionBuffer[particleH->GetIndex()]; - glm::vec2 position = glm::vec2(positionB2.x, positionB2.y); - - - EntityID entityParent = m_World->GetEntityParent(entity); - auto transform = m_World->GetComponent(entity); - auto transformParent = m_World->GetComponent(entityParent); - - transform->Position = glm::vec3(position.x, position.y, -10) - transformParent->Position; - } -} - -void dd::Systems::PhysicsSystem::UpdateEntity(double dt, EntityID entity, EntityID parent) -{ - -} - -void dd::Systems::PhysicsSystem::OnEntityCommit(EntityID entity) -{ - auto physicsComponent = m_World->GetComponent(entity); - auto waterComponent = m_World->GetComponent(entity); - - if (physicsComponent && waterComponent) { - LOG_ERROR("Entity has both water and physics component, this is illegal. The police has been alerted."); - return; - } - if (physicsComponent) { - CreateBody(entity); - } else if (waterComponent) { - CreateParticleGroup(entity); - } -} - - -void dd::Systems::PhysicsSystem::OnEntityRemoved(EntityID entity) -{ - auto physics = m_World->GetComponent(entity); - if (physics == nullptr) { - return; - } - - b2Body* body = m_EntitiesToBodies[entity]; - - if (body != nullptr) { - m_EntitiesToBodies.erase(entity); - m_BodiesToEntities.erase(body); - - m_PhysicsWorld->DestroyBody(body); - } - -} - - -void dd::Systems::PhysicsSystem::CreateBody(EntityID entity) -{ - auto physicsComponent = m_World->GetComponent(entity); - if(!physicsComponent){ - LOG_ERROR("No PhysicsComponent in CreateBody"); - return; - } - - - auto transformComponent = m_World->GetComponent(entity); - if(!transformComponent) { - LOG_ERROR("No TransformComponent in CreateBody"); - return; - } - - auto absoluteTransform = m_World->GetSystem()->AbsoluteTransform(entity); - - b2BodyDef bodyDef; - bodyDef.position.Set(absoluteTransform.Position.x, absoluteTransform.Position.y); - bodyDef.angle = -glm::eulerAngles(absoluteTransform.Orientation).z; - - if (physicsComponent->Static) { - bodyDef.type = b2_staticBody; - } else { - bodyDef.type = b2_dynamicBody; - - } - - b2Body* body = m_PhysicsWorld->CreateBody(&bodyDef); - - b2Shape* pShape; - - auto boxComponent = m_World->GetComponent(entity); - if (boxComponent) { - b2PolygonShape* bShape = new b2PolygonShape(); - bShape->SetAsBox(absoluteTransform.Scale.x/2, absoluteTransform.Scale.y/2); - pShape = bShape; - } else { - auto circleComponent = m_World->GetComponent(entity); - if (circleComponent) { - pShape = new b2CircleShape(); - pShape->m_radius = absoluteTransform.Scale.x; - - - if (absoluteTransform.Scale.x != absoluteTransform.Scale.y && absoluteTransform.Scale.y != absoluteTransform.Scale.z) { - LOG_WARNING("Circles has to be of uniform scale."); - } - pShape->m_radius = absoluteTransform.Scale.x/2; - - } - } - - b2FixtureDef fixtureDef; - fixtureDef.shape = pShape; - fixtureDef.filter.categoryBits = physicsComponent->Category; - fixtureDef.filter.maskBits = physicsComponent->Mask; - - - if(physicsComponent->Static) { - body->CreateFixture(&fixtureDef); //Density kanske ska vara 0 på statiska kroppar - } - else { - fixtureDef.shape = pShape; - fixtureDef.density = 1.f; - fixtureDef.restitution = 1.0f; - fixtureDef.friction = 0.0f; - body->CreateFixture(&fixtureDef); - - } - - delete pShape; - - - body->SetGravityScale(physicsComponent->GravityScale); - m_EntitiesToBodies.insert(std::make_pair(entity, body)); - m_BodiesToEntities.insert(std::make_pair(body, entity)); -} - -void dd::Systems::PhysicsSystem::CreateParticleGroup(EntityID e) -{ - //TODO: Lägg alla pd i en lista - auto transform = m_World->GetComponent(e); - if (!transform) { - LOG_ERROR("No Transform component in CreateParticleGroup"); - return; - } - - b2ParticleGroupDef pd; - b2PolygonShape shape; - - shape.SetAsBox(transform->Scale.x/2.f, transform->Scale.y/2.f); - pd.shape = &shape; - pd.flags = b2_tensileParticle; - pd.position.Set(transform->Position.x, transform->Position.y); - //TODO: PUT IN LIST - t_watergroup = m_ParticleSystem->CreateParticleGroup(pd); - b2Vec2* t_ParticlePositions = m_ParticleSystem->GetPositionBuffer(); - for(int i = 0; i < m_ParticleSystem->GetParticleCount(); i++){ - { - auto t_waterparticle = m_World->CreateEntity(e); - auto transformChild = m_World->AddComponent(t_waterparticle); - //auto sprite = m_World->AddComponent(t_waterparticle); - - transformChild->Position = glm::vec3(t_ParticlePositions[i].x - transform->Position.x, t_ParticlePositions[i].y - transform->Position.y, -9.5f); - transformChild->Scale = glm::vec3(m_ParticleSystem->GetRadius())/transform->Scale; - //sprite->SpriteFile = "Textures/Ball.png"; - m_World->CommitEntity(t_waterparticle); - - m_EntitiesToParticleHandle.insert(std::make_pair(t_waterparticle, m_ParticleSystem->GetParticleHandleFromIndex(i))); - m_ParticleHandleToEntities.insert(std::make_pair( m_ParticleSystem->GetParticleHandleFromIndex(i), t_waterparticle)); - } - - } - LOG_INFO("ParticleCount: %i", m_ParticleSystem->GetParticleCount()); -} - -dd::Systems::PhysicsSystem::~PhysicsSystem() -{ - if (m_ContactListener != nullptr) { - delete m_ContactListener; - m_ContactListener = nullptr; - } -}