Merge remote-tracking branch 'origin/master' into LevelSystemAndSuch
This commit is contained in:
@@ -14,7 +14,7 @@ void dd::Systems::PhysicsSystem::Initialize()
|
||||
m_PhysicsWorld = new b2World(m_Gravity);
|
||||
m_PhysicsWorld->SetContactListener(m_ContactListener);
|
||||
InitializeWater();
|
||||
EVENT_SUBSCRIBE_MEMBER(m_SetImpulse, PhysicsSystem::SetImpulse);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_SetImpulse, &PhysicsSystem::SetImpulse);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EPause, &PhysicsSystem::OnPause);
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ bool dd::Systems::PhysicsSystem::SetImpulse(const Events::SetImpulse &event)
|
||||
|
||||
Impulse i;
|
||||
i.Body = it->second;
|
||||
i.Impulse = impulse;
|
||||
i.Vector = impulse;
|
||||
i.Point = point;
|
||||
|
||||
m_Impulses.push_back(i);
|
||||
@@ -155,7 +155,7 @@ void dd::Systems::PhysicsSystem::Update(double dt)
|
||||
|
||||
//Apply Impulses Must be done after SyncEntitiesWithBodies
|
||||
for (auto i : m_Impulses) {
|
||||
i.Body->ApplyLinearImpulse(i.Impulse, i.Point, true);
|
||||
i.Body->ApplyLinearImpulse(i.Vector, i.Point, true);
|
||||
}
|
||||
m_Impulses.clear();
|
||||
|
||||
@@ -170,7 +170,7 @@ void dd::Systems::PhysicsSystem::Update(double dt)
|
||||
b2Vec2 *positionBuffer = m_ParticleSystem[e]->GetPositionBuffer();
|
||||
for (auto i : m_EntitiesToParticleHandle[e]) {
|
||||
EntityID entity = i.first;
|
||||
b2ParticleHandle *particleH = i.second;
|
||||
const b2ParticleHandle *particleH = i.second;
|
||||
|
||||
b2Vec2 positionB2 = positionBuffer[particleH->GetIndex()];
|
||||
glm::vec2 position = glm::vec2(positionB2.x, positionB2.y);
|
||||
@@ -377,10 +377,10 @@ void dd::Systems::PhysicsSystem::CreateParticleGroup(EntityID e)
|
||||
|
||||
void dd::Systems::PhysicsSystem::UpdateParticleEmitters(double dt)
|
||||
{
|
||||
for (int i = 0; i < m_ParticleEmitters.ParticleSystem.size(); i++) {
|
||||
auto e = m_ParticleEmitters.ParticleEmitter[i];
|
||||
auto pt = m_ParticleEmitters.ParticleTemplate[i];
|
||||
auto ps = m_ParticleEmitters.ParticleSystem[i];
|
||||
for (int i = 0; i < m_ParticleEmitters.System.size(); i++) {
|
||||
auto e = m_ParticleEmitters.Emitter[i];
|
||||
auto pt = m_ParticleEmitters.Template[i];
|
||||
auto ps = m_ParticleEmitters.System[i];
|
||||
|
||||
|
||||
auto emitter = m_World->GetComponent<Components::ParticleEmitter>(e);
|
||||
@@ -432,14 +432,14 @@ void dd::Systems::PhysicsSystem::CreateParticleEmitter(EntityID entity)
|
||||
auto particleTemplate = m_World->GetComponent<Components::Template>(c);
|
||||
if (!p) {
|
||||
continue;
|
||||
LOG_WARNING("--ParticleEmitter's Child is not a particle.");
|
||||
LOG_WARNING("--Emitter's Child is not a particle.");
|
||||
}
|
||||
if(!particleTemplate) {
|
||||
LOG_ERROR("ParticleEmitter's particleChild is not a template.");
|
||||
LOG_ERROR("Emitter's particleChild is not a template.");
|
||||
continue;
|
||||
}
|
||||
if (pf != 0) {
|
||||
LOG_WARNING("ParticleEmitter has more than one child that is a particleTemplate, only the first one is used.");
|
||||
LOG_WARNING("Emitter has more than one child that is a particleTemplate, only the first one is used.");
|
||||
break;
|
||||
}
|
||||
childEntity = c;
|
||||
@@ -447,9 +447,9 @@ void dd::Systems::PhysicsSystem::CreateParticleEmitter(EntityID entity)
|
||||
pf++;
|
||||
}
|
||||
//TODO: Skicka med fler flaggor till particlesystemet;
|
||||
m_ParticleEmitters.ParticleSystem.push_back(CreateParticleSystem(particle->Radius, 0.f));
|
||||
m_ParticleEmitters.ParticleEmitter.push_back(entity);
|
||||
m_ParticleEmitters.ParticleTemplate.push_back(childEntity);
|
||||
m_ParticleEmitters.System.push_back(CreateParticleSystem(particle->Radius, 0.f));
|
||||
m_ParticleEmitters.Emitter.push_back(entity);
|
||||
m_ParticleEmitters.Template.push_back(childEntity);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ BOOST_AUTO_TEST_CASE(FrameTest)
|
||||
BOOST_CHECK(f2.X == 100); BOOST_CHECK(f2.X == f1.X + f1.Width);
|
||||
BOOST_CHECK(f2.Left() == 200); BOOST_CHECK(f2.Left() == f1.Right());
|
||||
BOOST_CHECK(f2.Y == 100); BOOST_CHECK(f2.Y == f1.Y + f1.Height);
|
||||
BOOST_CHECK(f2.Top() == 150); BOOST_CHECK(f2.Top() == f1.Bottom());
|
||||
BOOST_CHECK(f2.Top() == 200); BOOST_CHECK(f2.Top() == f1.Bottom());
|
||||
BOOST_CHECK(f2.Right() == 250); BOOST_CHECK(f2.Right() == f1.Right() + f2.Width);
|
||||
BOOST_CHECK(f2.Bottom() == 200); BOOST_CHECK(f2.Bottom() == f1.Bottom() + f2.Height);
|
||||
BOOST_CHECK(f2.Bottom() == 250); BOOST_CHECK(f2.Bottom() == f1.Bottom() + f2.Height);
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
#include "PrecompiledHeader.h"
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include "Core/World.h"
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Physics/PhysicsSystem.h"
|
||||
#include "Transform/TransformSystem.h"
|
||||
|
||||
#include "Physics/CPhysics.h"
|
||||
#include "Physics/CRectangleShape.h"
|
||||
|
||||
|
||||
|
||||
|
||||
using namespace dd;
|
||||
|
||||
BOOST_AUTO_TEST_CASE(RemovePhysicsSystemTest)
|
||||
{
|
||||
// Setup world
|
||||
std::shared_ptr<EventBroker> eventBroker = std::make_shared<EventBroker>();
|
||||
World world(eventBroker);
|
||||
|
||||
world.SystemFactory.Register<Systems::TransformSystem>(
|
||||
[this]() { return new Systems::TransformSystem(&world, eventBroker); });
|
||||
world.AddSystem<Systems::TransformSystem>();
|
||||
|
||||
world.SystemFactory.Register<Systems::PhysicsSystem>(
|
||||
[this]() { return new Systems::PhysicsSystem(&world, eventBroker); });
|
||||
world.AddSystem<Systems::PhysicsSystem>();
|
||||
|
||||
world.ComponentFactory.Register<Components::RectangleShape>();
|
||||
world.ComponentFactory.Register<Components::Physics>();
|
||||
|
||||
//Create entity
|
||||
EntityID ent = world.CreateEntity();
|
||||
|
||||
auto transform = world.AddComponent<Components::Transform>(ent);
|
||||
transform->Position = glm::vec3(20.f, 0.f, -10.f);
|
||||
transform->Velocity = glm::vec3(1.f, 3.f, 0.f);
|
||||
transform->Scale = glm::vec3(2.f, 5.f, 1.f);
|
||||
|
||||
auto physics = world.AddComponent<Components::Physics>(ent);
|
||||
physics->Static = false;
|
||||
physics->Calculate = true;
|
||||
physics->Category = CollisionLayer::Type::Ball;
|
||||
physics->Mask = CollisionLayer::Type::Brick | CollisionLayer::Type::Pad | CollisionLayer::Wall;
|
||||
physics->GravityScale = 0.f;
|
||||
|
||||
auto rectangle = world.AddComponent<Components::RectangleShape>(ent);
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user