Skip to content

Commit 7417d58

Browse files
author
bender
committed
- fixed build for Linux
- added AntTweakBar sources
1 parent 4fad902 commit 7417d58

File tree

110 files changed

+62227
-144
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+62227
-144
lines changed

CMake/AntTweakBar.cmake

Lines changed: 0 additions & 19 deletions
This file was deleted.

CMake/Common.cmake

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
1-
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/../bin)
2-
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/../lib)
3-
SET(CMAKE_DEBUG_POSTFIX "d")
1+
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/../bin)
2+
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/../lib)
3+
set(CMAKE_DEBUG_POSTFIX "d")
44

5-
IF (WIN32)
6-
SET(CMAKE_USE_RELATIVE_PATHS "1")
7-
# Set compiler flags for "release"
8-
SET(CMAKE_CXX_FLAGS_RELEASE "/MD /Ox /Ob2 /Oi /Ot /GL /D NDEBUG")
9-
SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "/INCREMENTAL:NO /LTCG")
10-
SET(IBDS_STATIC_LIBRARY_FLAGS_RELEASE "/INCREMENTAL:NO /LTCG")
11-
ENDIF (WIN32)
5+
if (WIN32)
6+
set(CMAKE_USE_RELATIVE_PATHS "1")
7+
# Set compiler flags for "release"
8+
set(CMAKE_CXX_FLAGS_RELEASE "/MD /Ox /Ob2 /Oi /Ot /GL /D NDEBUG")
9+
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/INCREMENTAL:NO /LTCG")
10+
set(IBDS_STATIC_LIBRARY_FLAGS_RELEASE "/INCREMENTAL:NO /LTCG")
11+
endif (WIN32)
1212

13-
IF (UNIX)
14-
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/../bin/${CMAKE_BUILD_TYPE})
15-
ENDIF (UNIX)
13+
if (UNIX)
14+
set(CMAKE_USE_RELATIVE_PATHS "1")
15+
# Set compiler flags for "release"
16+
set(CMAKE_CXX_FLAGS_RELEASE "/MD /Ox /Ob2 /Oi /Ot /GL /D NDEBUG")
17+
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/INCREMENTAL:NO /LTCG")
18+
set(IBDS_STATIC_LIBRARY_FLAGS_RELEASE "/INCREMENTAL:NO /LTCG")
19+
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/../bin/${CMAKE_BUILD_TYPE})
20+
endif (UNIX)
1621

17-
ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE)
22+
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
1823

1924

CMakeLists.txt

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
cmake_minimum_required(VERSION 2.8)
22

3-
PROJECT(PositionBasedDynamics)
3+
project(PositionBasedDynamics)
44

5-
SET(PROJECT_PATH ${PROJECT_SOURCE_DIR})
6-
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR})
5+
set(PROJECT_PATH ${PROJECT_SOURCE_DIR})
6+
include_directories(${PROJECT_SOURCE_DIR})
77

8-
SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake" ${CMAKE_MODULE_PATH})
9-
10-
INCLUDE(${PROJECT_PATH}/CMake/Common.cmake)
11-
INCLUDE(${PROJECT_PATH}/CMake/AntTweakBar.cmake)
12-
13-
SUBDIRS(extern/freeglut Demos PositionBasedDynamics)
8+
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake" ${CMAKE_MODULE_PATH})
149

10+
include(${PROJECT_PATH}/CMake/Common.cmake)
1511

12+
if (WIN32)
13+
subdirs(extern/freeglut extern/AntTweakBar Demos PositionBasedDynamics)
14+
else()
15+
subdirs(extern/AntTweakBar Demos PositionBasedDynamics)
16+
endif()
1617

1718

1819

Demos/BarDemo/CMakeLists.txt

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
1-
SET(SIMULATION_LINK_LIBRARIES freeglut PositionBasedDynamics opengl32.lib glu32.lib ${ANTTWEAKBAR_LIBS})
2-
SET (SIMULATION_DEPENDENCIES freeglut PositionBasedDynamics)
1+
set(SIMULATION_LINK_LIBRARIES AntTweakBar PositionBasedDynamics)
2+
set(SIMULATION_DEPENDENCIES AntTweakBar PositionBasedDynamics)
33

4-
ADD_EXECUTABLE(BarDemo
4+
if(WIN32)
5+
set(SIMULATION_LINK_LIBRARIES freeglut opengl32.lib glu32.lib ${SIMULATION_LINK_LIBRARIES})
6+
set(SIMULATION_DEPENDENCIES freeglut ${SIMULATION_DEPENDENCIES})
7+
else()
8+
find_package(GLUT REQUIRED)
9+
find_package(OpenGL REQUIRED)
10+
11+
set(SIMULATION_LINK_LIBRARIES
12+
${GLUT_LIBRARIES}
13+
${OPENGL_LIBRARIES}
14+
${SIMULATION_LINK_LIBRARIES}
15+
)
16+
endif()
17+
18+
add_executable(BarDemo
519
main.cpp
620

721
TimeStepTetModel.cpp
@@ -20,11 +34,12 @@ ADD_EXECUTABLE(BarDemo
2034
CMakeLists.txt
2135
)
2236

37+
add_definitions(-DTW_NO_LIB_PRAGMA -DTW_STATIC)
38+
2339
find_package( Eigen3 REQUIRED )
2440
include_directories( ${EIGEN3_INCLUDE_DIR} )
25-
INCLUDE_DIRECTORIES(${PROJECT_PATH}/extern/freeglut/include)
41+
include_directories(${PROJECT_PATH}/extern/freeglut/include)
2642

27-
ADD_DEPENDENCIES(BarDemo ${SIMULATION_DEPENDENCIES})
28-
TARGET_LINK_LIBRARIES(BarDemo ${SIMULATION_LINK_LIBRARIES})
43+
add_dependencies(BarDemo ${SIMULATION_DEPENDENCIES})
44+
target_link_libraries(BarDemo ${SIMULATION_LINK_LIBRARIES})
2945
VIS_SOURCE_GROUPS()
30-
COPY_ANTTWEAKBAR_DLL(BarDemo)

Demos/BarDemo/TetModel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "TetModel.h"
2-
#include "PositionBasedDynamics\PositionBasedDynamics.h"
2+
#include "PositionBasedDynamics/PositionBasedDynamics.h"
33

44
using namespace PBD;
55

Demos/BarDemo/main.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ TimeStepTetModel simulation;
4545
const unsigned int width = 30;
4646
const unsigned int depth = 5;
4747
const unsigned int height = 5;
48-
bool pause = true;
48+
bool doPause = true;
4949
std::vector<unsigned int> selectedParticles;
5050
Eigen::Vector3f oldMousePos;
5151

@@ -67,7 +67,7 @@ int main( int argc, char **argv )
6767
MiniGL::setClientSceneFunc(render);
6868
MiniGL::setViewport (40.0f, 0.1f, 500.0f, Vector3f (5.0, -10.0, 30.0), Vector3f (5.0, 0.0, 0.0));
6969

70-
TwAddVarRW(MiniGL::getTweakBar(), "Pause", TW_TYPE_BOOLCPP, &pause, " label='Pause' group=Simulation key=SPACE ");
70+
TwAddVarRW(MiniGL::getTweakBar(), "Pause", TW_TYPE_BOOLCPP, &doPause, " label='Pause' group=Simulation key=SPACE ");
7171
TwAddVarCB(MiniGL::getTweakBar(), "TimeStepSize", TW_TYPE_FLOAT, setTimeStep, getTimeStep, &model, " label='Time step size' min=0.0 max = 0.1 step=0.001 precision=4 group=Simulation ");
7272
TwType enumType = TwDefineEnum("VelocityUpdateMethodType", NULL, 0);
7373
TwAddVarCB(MiniGL::getTweakBar(), "VelocityUpdateMethod", enumType, setVelocityUpdateMethod, getVelocityUpdateMethod, &simulation, " label='Velocity update method' enum='0 {First Order Update}, 1 {Second Order Update}' group=Simulation");
@@ -131,7 +131,7 @@ void selection(const Eigen::Vector2i &start, const Eigen::Vector2i &end)
131131

132132
void timeStep ()
133133
{
134-
if (pause)
134+
if (doPause)
135135
return;
136136

137137
// Simulation code

Demos/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
INCLUDE(Visualization/CMakeLists.txt)
1+
include(Visualization/CMakeLists.txt)
22

33
subdirs(BarDemo ClothDemo)

Demos/ClothDemo/CMakeLists.txt

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
1-
SET(SIMULATION_LINK_LIBRARIES freeglut PositionBasedDynamics opengl32.lib glu32.lib ${ANTTWEAKBAR_LIBS})
2-
SET (SIMULATION_DEPENDENCIES freeglut PositionBasedDynamics)
1+
set(SIMULATION_LINK_LIBRARIES AntTweakBar PositionBasedDynamics)
2+
set(SIMULATION_DEPENDENCIES AntTweakBar PositionBasedDynamics)
33

4-
ADD_EXECUTABLE(ClothDemo
4+
if(WIN32)
5+
set(SIMULATION_LINK_LIBRARIES freeglut opengl32.lib glu32.lib ${SIMULATION_LINK_LIBRARIES})
6+
set(SIMULATION_DEPENDENCIES freeglut ${SIMULATION_DEPENDENCIES})
7+
else()
8+
find_package(GLUT REQUIRED)
9+
find_package(OpenGL REQUIRED)
10+
11+
set(SIMULATION_LINK_LIBRARIES
12+
${GLUT_LIBRARIES}
13+
${OPENGL_LIBRARIES}
14+
${SIMULATION_LINK_LIBRARIES}
15+
)
16+
endif()
17+
18+
add_executable(ClothDemo
519
main.cpp
620

721
TimeStepTriangleModel.cpp
@@ -19,11 +33,12 @@ ADD_EXECUTABLE(ClothDemo
1933
CMakeLists.txt
2034
)
2135

36+
add_definitions(-DTW_NO_LIB_PRAGMA -DTW_STATIC)
37+
2238
find_package( Eigen3 REQUIRED )
2339
include_directories( ${EIGEN3_INCLUDE_DIR} )
24-
INCLUDE_DIRECTORIES(${PROJECT_PATH}/extern/freeglut/include)
40+
include_directories(${PROJECT_PATH}/extern/freeglut/include)
2541

26-
ADD_DEPENDENCIES(ClothDemo ${SIMULATION_DEPENDENCIES})
27-
TARGET_LINK_LIBRARIES(ClothDemo ${SIMULATION_LINK_LIBRARIES})
42+
add_dependencies(ClothDemo ${SIMULATION_DEPENDENCIES})
43+
target_link_libraries(ClothDemo ${SIMULATION_LINK_LIBRARIES})
2844
VIS_SOURCE_GROUPS()
29-
COPY_ANTTWEAKBAR_DLL(ClothDemo)

Demos/ClothDemo/TriangleModel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "TriangleModel.h"
2-
#include "PositionBasedDynamics\PositionBasedDynamics.h"
2+
#include "PositionBasedDynamics/PositionBasedDynamics.h"
33

44
using namespace PBD;
55

Demos/ClothDemo/main.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const int nRows = 30;
5959
const int nCols = 30;
6060
const float width = 10.0f;
6161
const float height = 10.0f;
62-
bool pause = true;
62+
bool doPause = true;
6363
std::vector<unsigned int> selectedParticles;
6464
Eigen::Vector3f oldMousePos;
6565

@@ -81,7 +81,7 @@ int main( int argc, char **argv )
8181
MiniGL::setClientSceneFunc(render);
8282
MiniGL::setViewport (40.0f, 0.1f, 500.0f, Vector3f (5.0, -10.0, 30.0), Vector3f (5.0, 0.0, 0.0));
8383

84-
TwAddVarRW(MiniGL::getTweakBar(), "Pause", TW_TYPE_BOOLCPP, &pause, " label='Pause' group=Simulation key=SPACE ");
84+
TwAddVarRW(MiniGL::getTweakBar(), "Pause", TW_TYPE_BOOLCPP, &doPause, " label='Pause' group=Simulation key=SPACE ");
8585
TwAddVarCB(MiniGL::getTweakBar(), "TimeStepSize", TW_TYPE_FLOAT, setTimeStep, getTimeStep, &model, " label='Time step size' min=0.0 max = 0.1 step=0.001 precision=4 group=Simulation ");
8686
TwType enumType = TwDefineEnum("VelocityUpdateMethodType", NULL, 0);
8787
TwAddVarCB(MiniGL::getTweakBar(), "VelocityUpdateMethod", enumType, setVelocityUpdateMethod, getVelocityUpdateMethod, &simulation, " label='Velocity update method' enum='0 {First Order Update}, 1 {Second Order Update}' group=Simulation");
@@ -154,7 +154,7 @@ void selection(const Eigen::Vector2i &start, const Eigen::Vector2i &end)
154154

155155
void timeStep ()
156156
{
157-
if (pause)
157+
if (doPause)
158158
return;
159159

160160
// Simulation code

Demos/Utils/Config.h

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
#ifndef __CONFIG_H__
22
#define __CONFIG_H__
33

4-
// Enable memory leak detection
5-
#ifdef _DEBUG
6-
#define _CRTDBG_MAP_ALLOC
7-
#include <stdlib.h>
8-
#include <crtdbg.h>
9-
#define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
10-
#define REPORT_MEMORY_LEAKS _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
4+
#if defined(WIN32) || defined(_WIN32) || defined(WIN64)
5+
// Enable memory leak detection
6+
#ifdef _DEBUG
7+
#define _CRTDBG_MAP_ALLOC
8+
#include <stdlib.h>
9+
#include <crtdbg.h>
10+
#define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
11+
#define REPORT_MEMORY_LEAKS _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
12+
#else
13+
#define REPORT_MEMORY_LEAKS
14+
#endif
15+
16+
#define FORCE_INLINE __forceinline
1117
#else
12-
#define REPORT_MEMORY_LEAKS
18+
#define REPORT_MEMORY_LEAKS
19+
#define FORCE_INLINE __attribute__((always_inline))
1320
#endif
1421

15-
#define FORCE_INLINE __forceinline
16-
1722
#endif

Demos/Utils/IndexedFaceMesh.h

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,12 @@ namespace PBD
3939
{
4040
m_numFaces = other.m_numFaces;
4141
m_fIndices = new unsigned int[m_numFaces];
42+
#if defined(WIN32) || defined(_WIN32) || defined(WIN64)
4243
std::copy(other.m_fIndices, other.m_fIndices + m_numFaces,
4344
stdext::unchecked_array_iterator<unsigned int*>(m_fIndices));
45+
#else
46+
std::copy(other.m_fIndices, other.m_fIndices + m_numFaces, m_fIndices);
47+
#endif
4448
return *this;
4549
}
4650

@@ -71,8 +75,12 @@ namespace PBD
7175
{
7276
m_numEdges = other.m_numEdges;
7377
m_eIndices = new unsigned int[m_numEdges];
78+
#if defined(WIN32) || defined(_WIN32) || defined(WIN64)
7479
std::copy(other.m_eIndices, other.m_eIndices + m_numEdges,
7580
stdext::unchecked_array_iterator<unsigned int*>(m_eIndices));
81+
#else
82+
std::copy(other.m_eIndices, other.m_eIndices + m_numEdges, m_eIndices);
83+
#endif
7684
return *this;
7785
}
7886

@@ -179,19 +187,23 @@ namespace PBD
179187
m_normals = other.m_normals;
180188
m_vertexNormals = other.m_vertexNormals;
181189

182-
for (auto i(0u); i < m_faces.size(); ++i)
190+
for (size_t i(0u); i < m_faces.size(); ++i)
183191
{
184192
m_faces[i].m_edges = new unsigned int[m_verticesPerFace];
193+
#if defined(WIN32) || defined(_WIN32) || defined(WIN64)
185194
std::copy(other.m_faces[i].m_edges, other.m_faces[i].m_edges + m_verticesPerFace,
186195
stdext::unchecked_array_iterator<unsigned int*>(m_faces[i].m_edges));
196+
#else
197+
std::copy(other.m_faces[i].m_edges, other.m_faces[i].m_edges + m_verticesPerFace, m_faces[i].m_edges);
198+
#endif
187199
}
188200

189201
m_verticesEdges.resize(other.m_verticesEdges.size());
190-
for (auto i(0u); i < m_verticesEdges.size(); ++i)
202+
for (size_t i(0u); i < m_verticesEdges.size(); ++i)
191203
m_verticesEdges[i] = other.m_verticesEdges[i];
192204

193205
m_verticesFaces.resize(other.m_verticesFaces.size());
194-
for (auto i(0u); i < m_verticesFaces.size(); ++i)
206+
for (size_t i(0u); i < m_verticesFaces.size(); ++i)
195207
m_verticesFaces[i] = other.m_verticesFaces[i];
196208

197209
return *this;

Demos/Visualization/CMakeLists.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
INCLUDE_DIRECTORIES(${PROJECT_PATH}/extern/freeglut/include)
1+
include_directories(${PROJECT_PATH}/extern/freeglut/include)
22

3-
SET(VIS_HEADER_FILES
3+
set(VIS_HEADER_FILES
44
${PROJECT_PATH}/Demos/Visualization/MiniGL.h
55
${PROJECT_PATH}/Demos/Visualization/Selection.h
66
)
77

88

9-
SET(VIS_SOURCE_FILES
9+
set(VIS_SOURCE_FILES
1010
${PROJECT_PATH}/Demos/Visualization/MiniGL.cpp
1111
)
1212

1313

14-
SET(VIS_FILES
14+
set(VIS_FILES
1515
${VIS_HEADER_FILES}
1616
${VIS_SOURCE_FILES}
1717
)
1818

1919
# A macro for the source groups
20-
MACRO(VIS_SOURCE_GROUPS)
21-
SOURCE_GROUP("Header Files\\Visualization" FILES ${VIS_HEADER_FILES})
22-
SOURCE_GROUP("Source Files\\Visualization" FILES ${VIS_SOURCE_FILES})
23-
ENDMACRO(VIS_SOURCE_GROUPS)
20+
macro(VIS_SOURCE_GROUPS)
21+
source_group("Header Files\\Visualization" FILES ${VIS_HEADER_FILES})
22+
source_group("Source Files\\Visualization" FILES ${VIS_SOURCE_FILES})
23+
endmacro(VIS_SOURCE_GROUPS)
2424

2525

2626

Demos/Visualization/MiniGL.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
#ifdef WIN32
44
#include "windows.h"
5+
#else
6+
#include <cstdio>
57
#endif
68

79
#include "GL/gl.h"

Demos/Visualization/MiniGL.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include "Demos/Utils/Config.h"
55
#include <Eigen/Dense>
66
#include <Eigen/Geometry>
7-
#include "extern/AntTweakBar/AntTweakBar.h"
7+
#include "extern/AntTweakBar/include/AntTweakBar.h"
88

99

1010
namespace PBD

0 commit comments

Comments
 (0)