From 4e0b0ffc392d81ec9acbed87fdcd042724cd66f2 Mon Sep 17 00:00:00 2001 From: Robin Rolf Date: Tue, 20 Sep 2016 00:50:37 +0200 Subject: [PATCH] Replace liquidfun with box2d Liquidfun seems abandoned and for some reason has warnings = errors, which are annoying I'm not using any of the features anyways so we're just replacing it. --- .gitmodules | 5 +---- CMakeLists.txt | 23 +++++++++------------- external/box2d | 1 + external/liquidfun | 1 - include/Engine/util/Box2dDebugDraw.hpp | 2 -- includes.cmake | 2 +- src/Light.cpp | 27 ++++++++++++++++---------- src/util/Box2dDebugDraw.cpp | 3 --- 8 files changed, 29 insertions(+), 35 deletions(-) create mode 160000 external/box2d delete mode 160000 external/liquidfun diff --git a/.gitmodules b/.gitmodules index 561d89a..094c97b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -6,7 +6,4 @@ url = git://github.com/open-source-parsers/jsoncpp.git [submodule "external/box2d"] path = external/box2d - url = git://github.com/imerr/box2d.git -[submodule "external/liquidfun"] - path = external/liquidfun - url = git://github.com/imerr/liquidfun.git + url = git://github.com/erincatto/Box2D.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 43c3d14..d380030 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,20 +31,15 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO} /MAP /OPT:ICF /OPT:REF /LTCG /INCREMENTAL:NO") set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /MAP /OPT:ICF /OPT:REF /LTCG /INCREMENTAL:NO") else () - set(CMAKE_CXX_FLAGS "-Wall -march=pentium4 -mmmx -msse -msse2 -std=c++11 -fno-rtti") - set(CMAKE_CXX_FLAGS_DEBUG "-g -DDEBUG") - set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-Ofast -g") - set(CMAKE_CXX_FLAGS_RELEASE "-Ofast") + set(CMAKE_CXX_FLAGS "-Wall -std=c++11 -fno-exceptions -fno-rtti -Wno-unused-value") + set(CMAKE_CXX_FLAGS_DEBUG "-g -DDEBUG") + set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-Ofast -g") + set(CMAKE_CXX_FLAGS_RELEASE "-Ofast") - set(CMAKE_C_FLAGS "-Wall -march=pentium4 -mmmx -msse -msse2") - set(CMAKE_C_FLAGS_DEBUG "-g -DDEBUG") - set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g") - set(CMAKE_C_FLAGS_RELEASE "-O2") - - if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpmath=sse") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfpmath=sse") - endif () + set(CMAKE_C_FLAGS "-Wall") + set(CMAKE_C_FLAGS_DEBUG "-g -DDEBUG") + set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g") + set(CMAKE_C_FLAGS_RELEASE "-O2") endif () set(JSONCPP_WITH_TESTS OFF CACHE BOOL "Dont want jsoncpp tests") @@ -53,7 +48,7 @@ set(BOX2D_BUILD_EXAMPLES OFF CACHE BOOL "Dont want box2d examples") set(BOX2D_BUILD_STATIC ON CACHE BOOL "Build box2d as static lib") set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build jsoncpp as static lib" FORCE) add_subdirectory(${EXTERNAL_PATH}/jsoncpp ${CMAKE_CURRENT_BINARY_DIR}/external/jsoncpp/) -add_subdirectory(${EXTERNAL_PATH}/liquidfun/liquidfun/Box2D ${CMAKE_CURRENT_BINARY_DIR}/external/liquidfun) +add_subdirectory(${EXTERNAL_PATH}/box2d/Box2D ${CMAKE_CURRENT_BINARY_DIR}/external/box2d) set(BUILD_SHARED_LIBS ON CACHE BOOL "Build sfml as shared lib" FORCE) add_subdirectory(${EXTERNAL_PATH}/SFML ${CMAKE_CURRENT_BINARY_DIR}/external/sfml/) diff --git a/external/box2d b/external/box2d new file mode 160000 index 0000000..a7c9304 --- /dev/null +++ b/external/box2d @@ -0,0 +1 @@ +Subproject commit a7c93049dc9e9f00bfe9a6818323d62481c64a3d diff --git a/external/liquidfun b/external/liquidfun deleted file mode 160000 index b458c31..0000000 --- a/external/liquidfun +++ /dev/null @@ -1 +0,0 @@ -Subproject commit b458c316ba51911934f571562c93b07d5363eb84 diff --git a/include/Engine/util/Box2dDebugDraw.hpp b/include/Engine/util/Box2dDebugDraw.hpp index a5ae24f..55acb5e 100644 --- a/include/Engine/util/Box2dDebugDraw.hpp +++ b/include/Engine/util/Box2dDebugDraw.hpp @@ -45,8 +45,6 @@ namespace engine { /// Draw a transform. Choose your own length scale. /// @param xf a transform. virtual void DrawTransform(const b2Transform& xf); - - virtual void DrawParticles(const b2Vec2 *centers, float32 radius, const b2ParticleColor *colors, int32 count); }; } } diff --git a/includes.cmake b/includes.cmake index a42a569..84401b3 100644 --- a/includes.cmake +++ b/includes.cmake @@ -1,4 +1,4 @@ include_directories(${EXTERNAL_PATH}/SFML/include) include_directories(${EXTERNAL_PATH}/jsoncpp/include) -include_directories(${EXTERNAL_PATH}/liquidfun/liquidfun/Box2D) +include_directories(${EXTERNAL_PATH}/box2d/Box2D) include_directories(${SFMLENGINE_PATH}/include) \ No newline at end of file diff --git a/src/Light.cpp b/src/Light.cpp index a02779b..06c6b12 100644 --- a/src/Light.cpp +++ b/src/Light.cpp @@ -100,7 +100,8 @@ namespace engine { int i = static_cast(angle / util::fPI * 180) % 360; auto it = edges.find(i); if (it == edges.end()) { - edgeData def{basePos + m_radius / m_scene->GetPixelMeterRatio(), nullptr, 0}; + float r = m_radius / m_scene->GetPixelMeterRatio(); + edgeData def{basePos + b2Vec2(r, r), nullptr, 0}; edges.insert(std::make_pair(i, def)); return &edges.find(i)->second; } @@ -204,25 +205,31 @@ namespace engine { float checkAngle = edgeAngle - (util::fPI / 840.f); if (checkAngle > 0) { f = 1.0; - b2Vec2 edge = basePos + - (b2Vec2(cosf(edgeAngle - (util::fPI / 840.f)), - sinf(edgeAngle - (util::fPI / 840.f))) * - (m_radius / m_scene->GetPixelMeterRatio())); + b2Vec2 edge = b2Vec2(cosf(edgeAngle - (util::fPI / 840.f)), + sinf(edgeAngle - (util::fPI / 840.f))); + edge *= (m_radius / m_scene->GetPixelMeterRatio()); + edge += basePos; m_scene->GetWorld()->RayCast(&rayCastCallback, basePos, edge); if (f > edgeLengthPct) { - addPoint(basePos + (basePos - edge) * -f); + b2Vec2 p = (basePos - edge); + p *= -f; + addPoint(basePos + p); } } addPoint(it->second.pos); f = 1.0; checkAngle = edgeAngle + (util::fPI / 840.f); if (checkAngle < util::fPI * 2) { - b2Vec2 edge = basePos + - (b2Vec2(cosf(checkAngle), - sinf(checkAngle)) * (m_radius / m_scene->GetPixelMeterRatio())); + b2Vec2 edge = + b2Vec2(cosf(checkAngle), + sinf(checkAngle)); + edge *= (m_radius / m_scene->GetPixelMeterRatio()); + edge += basePos; m_scene->GetWorld()->RayCast(&rayCastCallback, basePos, edge); if (f > edgeLengthPct) { - addPoint(basePos + (basePos - edge) * -f); + b2Vec2 p = (basePos - edge); + p *= -f; + addPoint(basePos + p); } } ++it; diff --git a/src/util/Box2dDebugDraw.cpp b/src/util/Box2dDebugDraw.cpp index b6b6d7e..e42170c 100644 --- a/src/util/Box2dDebugDraw.cpp +++ b/src/util/Box2dDebugDraw.cpp @@ -116,9 +116,6 @@ namespace engine { void Box2dDebugDraw::DrawTransform(const b2Transform& xf) { } - void Box2dDebugDraw::DrawParticles(const b2Vec2 *centers, float32 radius, const b2ParticleColor *colors, int32 count) { - // TODO - } } }