Merge remote-tracking branch 'origin/master' into LevelSystemAndSuch
This commit is contained in:
+10
-4
@@ -15,11 +15,11 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -fpermissive")
|
|
||||||
if(UNIX)
|
if(UNIX)
|
||||||
# Needed to link with debug version of bgfx on linux
|
# Needed to link with debug version of bgfx on linux
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -ldl")
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -ldl")
|
||||||
endif()
|
endif()
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(BUILD_SHARED_LIBS FALSE)
|
set(BUILD_SHARED_LIBS FALSE)
|
||||||
@@ -31,7 +31,7 @@ include_directories(${PROJECT_SOURCE_DIR}/include)
|
|||||||
#set(GLFW_INCLUDE_DIR ${daydream_SOURCE_DIR}/libs/glfw-3.0.4/include)
|
#set(GLFW_INCLUDE_DIR ${daydream_SOURCE_DIR}/libs/glfw-3.0.4/include)
|
||||||
#set(GLFW_LIBRARY ${daydream_SOURCE_DIR}/libs/glfw-3.0.4/lib/Release/glfw3dll.lib)
|
#set(GLFW_LIBRARY ${daydream_SOURCE_DIR}/libs/glfw-3.0.4/lib/Release/glfw3dll.lib)
|
||||||
|
|
||||||
set(Boost_DEBUG ON)
|
#set(Boost_DEBUG ON)
|
||||||
set(Boost_USE_STATIC_LIBS on)
|
set(Boost_USE_STATIC_LIBS on)
|
||||||
add_definitions(-DBOOST_ALL_NO_LIB)
|
add_definitions(-DBOOST_ALL_NO_LIB)
|
||||||
#set(BOOST_INCLUDEDIR ${BOOST_ROOT}/boost)
|
#set(BOOST_INCLUDEDIR ${BOOST_ROOT}/boost)
|
||||||
@@ -40,9 +40,15 @@ set(BOOST_LIBRARYDIR $ENV{BOOST_ROOT}/lib64-msvc-12.0)
|
|||||||
|
|
||||||
#add_definitions(-DGLEW_MX)
|
#add_definitions(-DGLEW_MX)
|
||||||
|
|
||||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib)
|
|
||||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib)
|
|
||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)
|
||||||
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib)
|
||||||
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib)
|
||||||
|
foreach(OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES})
|
||||||
|
string(TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG)
|
||||||
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} )
|
||||||
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} )
|
||||||
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY} )
|
||||||
|
endforeach(OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES)
|
||||||
|
|
||||||
add_subdirectory(src/game)
|
add_subdirectory(src/game)
|
||||||
add_subdirectory(src/tests)
|
add_subdirectory(src/tests)
|
||||||
|
|||||||
@@ -200,7 +200,7 @@ public:
|
|||||||
// {
|
// {
|
||||||
// auto Pe = m_World->CreateEntity();
|
// auto Pe = m_World->CreateEntity();
|
||||||
// auto transform = m_World->AddComponent<Components::Transform>(Pe);
|
// auto transform = m_World->AddComponent<Components::Transform>(Pe);
|
||||||
// auto particleEmitter= m_World->AddComponent<Components::ParticleEmitter>(Pe);
|
// auto particleEmitter= m_World->AddComponent<Components::Emitter>(Pe);
|
||||||
//
|
//
|
||||||
// transform->Position = glm::vec3(0.f, -5.f, -10.f);
|
// transform->Position = glm::vec3(0.f, -5.f, -10.f);
|
||||||
// particleEmitter->GravityScale = 0.0f;
|
// particleEmitter->GravityScale = 0.0f;
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ struct ParticleEmitter : public Component
|
|||||||
double SpawnRate = 1.f;
|
double SpawnRate = 1.f;
|
||||||
double TimeSinceLastSpawn = 0;
|
double TimeSinceLastSpawn = 0;
|
||||||
|
|
||||||
//ParticleSystem variables
|
//System variables
|
||||||
float GravityScale = 1.0f;
|
float GravityScale = 1.0f;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ namespace dd
|
|||||||
struct Impulse
|
struct Impulse
|
||||||
{
|
{
|
||||||
b2Body* Body;
|
b2Body* Body;
|
||||||
b2Vec2 Impulse;
|
b2Vec2 Vector;
|
||||||
b2Vec2 Point;
|
b2Vec2 Point;
|
||||||
};
|
};
|
||||||
bool m_Pause = false;
|
bool m_Pause = false;
|
||||||
@@ -99,9 +99,9 @@ namespace dd
|
|||||||
//TODO: Fill struct with info needed.
|
//TODO: Fill struct with info needed.
|
||||||
struct ParticleEmitter
|
struct ParticleEmitter
|
||||||
{
|
{
|
||||||
std::vector<b2ParticleSystem*> ParticleSystem;
|
std::vector<b2ParticleSystem*> System;
|
||||||
std::vector<EntityID> ParticleEmitter;
|
std::vector<EntityID> Emitter;
|
||||||
std::vector<EntityID> ParticleTemplate;
|
std::vector<EntityID> Template;
|
||||||
};
|
};
|
||||||
ParticleEmitter m_ParticleEmitters;
|
ParticleEmitter m_ParticleEmitters;
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ void dd::Systems::PhysicsSystem::Initialize()
|
|||||||
m_PhysicsWorld = new b2World(m_Gravity);
|
m_PhysicsWorld = new b2World(m_Gravity);
|
||||||
m_PhysicsWorld->SetContactListener(m_ContactListener);
|
m_PhysicsWorld->SetContactListener(m_ContactListener);
|
||||||
InitializeWater();
|
InitializeWater();
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_SetImpulse, PhysicsSystem::SetImpulse);
|
EVENT_SUBSCRIBE_MEMBER(m_SetImpulse, &PhysicsSystem::SetImpulse);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EPause, &PhysicsSystem::OnPause);
|
EVENT_SUBSCRIBE_MEMBER(m_EPause, &PhysicsSystem::OnPause);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ bool dd::Systems::PhysicsSystem::SetImpulse(const Events::SetImpulse &event)
|
|||||||
|
|
||||||
Impulse i;
|
Impulse i;
|
||||||
i.Body = it->second;
|
i.Body = it->second;
|
||||||
i.Impulse = impulse;
|
i.Vector = impulse;
|
||||||
i.Point = point;
|
i.Point = point;
|
||||||
|
|
||||||
m_Impulses.push_back(i);
|
m_Impulses.push_back(i);
|
||||||
@@ -155,7 +155,7 @@ void dd::Systems::PhysicsSystem::Update(double dt)
|
|||||||
|
|
||||||
//Apply Impulses Must be done after SyncEntitiesWithBodies
|
//Apply Impulses Must be done after SyncEntitiesWithBodies
|
||||||
for (auto i : m_Impulses) {
|
for (auto i : m_Impulses) {
|
||||||
i.Body->ApplyLinearImpulse(i.Impulse, i.Point, true);
|
i.Body->ApplyLinearImpulse(i.Vector, i.Point, true);
|
||||||
}
|
}
|
||||||
m_Impulses.clear();
|
m_Impulses.clear();
|
||||||
|
|
||||||
@@ -170,7 +170,7 @@ void dd::Systems::PhysicsSystem::Update(double dt)
|
|||||||
b2Vec2 *positionBuffer = m_ParticleSystem[e]->GetPositionBuffer();
|
b2Vec2 *positionBuffer = m_ParticleSystem[e]->GetPositionBuffer();
|
||||||
for (auto i : m_EntitiesToParticleHandle[e]) {
|
for (auto i : m_EntitiesToParticleHandle[e]) {
|
||||||
EntityID entity = i.first;
|
EntityID entity = i.first;
|
||||||
b2ParticleHandle *particleH = i.second;
|
const b2ParticleHandle *particleH = i.second;
|
||||||
|
|
||||||
b2Vec2 positionB2 = positionBuffer[particleH->GetIndex()];
|
b2Vec2 positionB2 = positionBuffer[particleH->GetIndex()];
|
||||||
glm::vec2 position = glm::vec2(positionB2.x, positionB2.y);
|
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)
|
void dd::Systems::PhysicsSystem::UpdateParticleEmitters(double dt)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < m_ParticleEmitters.ParticleSystem.size(); i++) {
|
for (int i = 0; i < m_ParticleEmitters.System.size(); i++) {
|
||||||
auto e = m_ParticleEmitters.ParticleEmitter[i];
|
auto e = m_ParticleEmitters.Emitter[i];
|
||||||
auto pt = m_ParticleEmitters.ParticleTemplate[i];
|
auto pt = m_ParticleEmitters.Template[i];
|
||||||
auto ps = m_ParticleEmitters.ParticleSystem[i];
|
auto ps = m_ParticleEmitters.System[i];
|
||||||
|
|
||||||
|
|
||||||
auto emitter = m_World->GetComponent<Components::ParticleEmitter>(e);
|
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);
|
auto particleTemplate = m_World->GetComponent<Components::Template>(c);
|
||||||
if (!p) {
|
if (!p) {
|
||||||
continue;
|
continue;
|
||||||
LOG_WARNING("--ParticleEmitter's Child is not a particle.");
|
LOG_WARNING("--Emitter's Child is not a particle.");
|
||||||
}
|
}
|
||||||
if(!particleTemplate) {
|
if(!particleTemplate) {
|
||||||
LOG_ERROR("ParticleEmitter's particleChild is not a template.");
|
LOG_ERROR("Emitter's particleChild is not a template.");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (pf != 0) {
|
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;
|
break;
|
||||||
}
|
}
|
||||||
childEntity = c;
|
childEntity = c;
|
||||||
@@ -447,9 +447,9 @@ void dd::Systems::PhysicsSystem::CreateParticleEmitter(EntityID entity)
|
|||||||
pf++;
|
pf++;
|
||||||
}
|
}
|
||||||
//TODO: Skicka med fler flaggor till particlesystemet;
|
//TODO: Skicka med fler flaggor till particlesystemet;
|
||||||
m_ParticleEmitters.ParticleSystem.push_back(CreateParticleSystem(particle->Radius, 0.f));
|
m_ParticleEmitters.System.push_back(CreateParticleSystem(particle->Radius, 0.f));
|
||||||
m_ParticleEmitters.ParticleEmitter.push_back(entity);
|
m_ParticleEmitters.Emitter.push_back(entity);
|
||||||
m_ParticleEmitters.ParticleTemplate.push_back(childEntity);
|
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.X == 100); BOOST_CHECK(f2.X == f1.X + f1.Width);
|
||||||
BOOST_CHECK(f2.Left() == 200); BOOST_CHECK(f2.Left() == f1.Right());
|
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.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.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