Skip to content

Commit

Permalink
Replace liquidfun with box2d
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
imerr committed Sep 19, 2016
1 parent 48ab91d commit 4e0b0ff
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 35 deletions.
5 changes: 1 addition & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -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
23 changes: 9 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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/)

Expand Down
1 change: 1 addition & 0 deletions external/box2d
Submodule box2d added at a7c930
1 change: 0 additions & 1 deletion external/liquidfun
Submodule liquidfun deleted from b458c3
2 changes: 0 additions & 2 deletions include/Engine/util/Box2dDebugDraw.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
}
}
Expand Down
2 changes: 1 addition & 1 deletion includes.cmake
Original file line number Diff line number Diff line change
@@ -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)
27 changes: 17 additions & 10 deletions src/Light.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ namespace engine {
int i = static_cast<int>(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;
}
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 0 additions & 3 deletions src/util/Box2dDebugDraw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

}
}

0 comments on commit 4e0b0ff

Please sign in to comment.