Skip to content

Commit c69fd48

Browse files
committed
- added collision detection for arbitrary meshes based on cubic signed distance fields
- added Discregrid library as external project to generate cubic signed distance fields
1 parent 39a5099 commit c69fd48

Some content is hidden

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

44 files changed

+3426
-193
lines changed

CMakeLists.txt

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,25 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON)
1111
include(${PROJECT_PATH}/CMake/Common.cmake)
1212

1313
if (WIN32)
14-
subdirs(extern/freeglut extern/AntTweakBar extern/glew Demos PositionBasedDynamics)
14+
subdirs(extern/freeglut extern/AntTweakBar extern/glew extern/md5 Demos PositionBasedDynamics)
1515
else()
16-
subdirs(extern/AntTweakBar extern/glew Demos PositionBasedDynamics)
16+
subdirs(extern/AntTweakBar extern/glew extern/md5 Demos PositionBasedDynamics)
1717
endif()
1818

19+
include(ExternalProject)
20+
set(ExternalInstallDir "${CMAKE_SOURCE_DIR}/extern/install")
21+
set(EigenDir "${CMAKE_SOURCE_DIR}/extern/eigen")
22+
23+
## Discregrid
24+
ExternalProject_Add(
25+
ExternalProject_Discregrid
26+
PREFIX "${CMAKE_SOURCE_DIR}/extern/Discregrid"
27+
GIT_REPOSITORY https://github.com/InteractiveComputerGraphics/Discregrid.git
28+
GIT_TAG "573c2f51f433c74de832454272e47f590140e80b"
29+
INSTALL_DIR ${ExternalInstallDir}/Discregrid
30+
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${ExternalInstallDir}/Discregrid -DBUILD_CMD_EXECUTABLE:BOOL=0 -DEIGEN3_INCLUDE_DIR:PATH=${EigenDir}
31+
)
32+
1933
install(DIRECTORY ./Common
2034
DESTINATION include
2135
FILES_MATCHING PATTERN "*.h")

Changelog.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
1.6.0
2+
- added collision detection for arbitrary meshes based on cubic signed distance fields
3+
- added DiscreGrid library as external project to generate cubic signed distance fields
14
- added possibility to define motor target sequences in scene files
25
- added implementation of the paper Kugelstadt, Schoemer, "Position and Orientation Based Cosserat Rods", SCA 2016 and a corresponding demo
36
- update to Eigen 3.3.4

Demos/BarDemo/main.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,18 @@
88
#include "Demos/Simulation/TimeStepController.h"
99
#include <iostream>
1010
#include "Demos/Visualization/Visualization.h"
11-
#include "Demos/Utils/Utilities.h"
11+
#include "Demos/Utils/Logger.h"
1212
#include "Demos/Utils/Timing.h"
13+
#include "Demos/Utils/FileSystem.h"
1314

1415
// Enable memory leak detection
1516
#if defined(_DEBUG) && !defined(EIGEN_ALIGN)
1617
#define new DEBUG_NEW
1718
#endif
1819

20+
INIT_TIMING
21+
INIT_LOGGING
22+
1923
using namespace PBD;
2024
using namespace Eigen;
2125
using namespace std;
@@ -62,7 +66,12 @@ int main( int argc, char **argv )
6266
{
6367
REPORT_MEMORY_LEAKS
6468

65-
exePath = Utilities::getFilePath(argv[0]);
69+
std::string logPath = FileSystem::normalizePath(FileSystem::getProgramPath() + "/log");
70+
FileSystem::makeDirs(logPath);
71+
logger.addSink(unique_ptr<ConsoleSink>(new ConsoleSink(LogLevel::INFO)));
72+
logger.addSink(unique_ptr<FileSink>(new FileSink(LogLevel::DEBUG, logPath + "/PBD.log")));
73+
74+
exePath = FileSystem::getFilePath(argv[0]);
6675
dataPath = exePath + "/" + std::string(PBD_DATA_PATH);
6776

6877
// OpenGL
@@ -385,8 +394,8 @@ void createMesh()
385394
model.getTetModels()[cm]->updateMeshNormals(pd);
386395
}
387396

388-
std::cout << "Number of tets: " << indices.size() / 4 << "\n";
389-
std::cout << "Number of vertices: " << width*height*depth << "\n";
397+
LOG_INFO << "Number of tets: " << indices.size() / 4;
398+
LOG_INFO << "Number of vertices: " << width*height*depth;
390399

391400
}
392401

Demos/ClothDemo/main.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,18 @@
88
#include "Demos/Simulation/TimeStepController.h"
99
#include <iostream>
1010
#include "Demos/Visualization/Visualization.h"
11-
#include "Demos/Utils/Utilities.h"
11+
#include "Demos/Utils/Logger.h"
1212
#include "Demos/Utils/Timing.h"
13+
#include "Demos/Utils/FileSystem.h"
1314

1415
// Enable memory leak detection
1516
#if defined(_DEBUG) && !defined(EIGEN_ALIGN)
1617
#define new DEBUG_NEW
1718
#endif
1819

20+
INIT_TIMING
21+
INIT_LOGGING
22+
1923
using namespace PBD;
2024
using namespace Eigen;
2125
using namespace std;
@@ -77,7 +81,12 @@ int main( int argc, char **argv )
7781
{
7882
REPORT_MEMORY_LEAKS
7983

80-
exePath = Utilities::getFilePath(argv[0]);
84+
std::string logPath = FileSystem::normalizePath(FileSystem::getProgramPath() + "/log");
85+
FileSystem::makeDirs(logPath);
86+
logger.addSink(unique_ptr<ConsoleSink>(new ConsoleSink(LogLevel::INFO)));
87+
logger.addSink(unique_ptr<FileSink>(new FileSink(LogLevel::DEBUG, logPath + "/PBD.log")));
88+
89+
exePath = FileSystem::getProgramPath();
8190
dataPath = exePath + "/" + std::string(PBD_DATA_PATH);
8291

8392
// OpenGL
@@ -427,8 +436,8 @@ void createMesh()
427436
}
428437
}
429438

430-
std::cout << "Number of triangles: " << nIndices / 3 << "\n";
431-
std::cout << "Number of vertices: " << nRows*nCols << "\n";
439+
LOG_INFO << "Number of triangles: " << nIndices / 3;
440+
LOG_INFO << "Number of vertices: " << nRows*nCols;
432441

433442
}
434443

Demos/CosseratRodsDemo/main.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,18 @@
88
#include "Demos/Simulation/TimeStepController.h"
99
#include <iostream>
1010
#include "Demos/Visualization/Visualization.h"
11-
#include "Demos/Utils/Utilities.h"
11+
#include "Demos/Utils/Logger.h"
1212
#include "Demos/Utils/Timing.h"
13+
#include "Demos/Utils/FileSystem.h"
1314

1415
// Enable memory leak detection
1516
#if defined(_DEBUG) && !defined(EIGEN_ALIGN)
1617
#define new DEBUG_NEW
1718
#endif
1819

20+
INIT_TIMING
21+
INIT_LOGGING
22+
1923
using namespace PBD;
2024
using namespace Eigen;
2125
using namespace std;
@@ -66,7 +70,12 @@ int main( int argc, char **argv )
6670
{
6771
REPORT_MEMORY_LEAKS
6872

69-
exePath = Utilities::getFilePath(argv[0]);
73+
std::string logPath = FileSystem::normalizePath(FileSystem::getProgramPath() + "/log");
74+
FileSystem::makeDirs(logPath);
75+
logger.addSink(unique_ptr<ConsoleSink>(new ConsoleSink(LogLevel::INFO)));
76+
logger.addSink(unique_ptr<FileSink>(new FileSink(LogLevel::DEBUG, logPath + "/PBD.log")));
77+
78+
exePath = FileSystem::getProgramPath();
7079
dataPath = exePath + "/" + std::string(PBD_DATA_PATH);
7180

7281
// OpenGL
@@ -339,8 +348,8 @@ void createHelix(const Vector3r &position, const Matrix3r &orientation, Real rad
339348
model.addBendTwistConstraint(q1, q2);
340349
}
341350

342-
//std::cout << "Number of particles: " << nPoints << "\n";
343-
//std::cout << "Number of quaternions: " << nQuaternions << "\n";
351+
// LOG_INFO << "Number of particles: " << nPoints;
352+
// LOG_INFO << "Number of quaternions: " << nQuaternions;
344353
}
345354

346355
void TW_CALL setTimeStep(const void *value, void *clientData)

Demos/CouplingDemos/RigidBodyClothCouplingDemo.cpp

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
#include "Demos/Simulation/Constraints.h"
1111
#include "Demos/Visualization/Visualization.h"
1212
#include "Demos/Utils/OBJLoader.h"
13-
#include "Demos/Utils/Utilities.h"
13+
#include "Demos/Utils/Logger.h"
1414
#include "Demos/Utils/Timing.h"
15+
#include "Demos/Utils/FileSystem.h"
1516

1617
#define _USE_MATH_DEFINES
1718
#include "math.h"
@@ -21,6 +22,9 @@
2122
#define new DEBUG_NEW
2223
#endif
2324

25+
INIT_TIMING
26+
INIT_LOGGING
27+
2428
using namespace PBD;
2529
using namespace Eigen;
2630
using namespace std;
@@ -92,7 +96,12 @@ int main( int argc, char **argv )
9296
{
9397
REPORT_MEMORY_LEAKS
9498

95-
exePath = Utilities::getFilePath(argv[0]);
99+
std::string logPath = FileSystem::normalizePath(FileSystem::getProgramPath() + "/log");
100+
FileSystem::makeDirs(logPath);
101+
logger.addSink(unique_ptr<ConsoleSink>(new ConsoleSink(LogLevel::INFO)));
102+
logger.addSink(unique_ptr<FileSink>(new FileSink(LogLevel::DEBUG, logPath + "/PBD.log")));
103+
104+
exePath = FileSystem::getProgramPath();
96105
dataPath = exePath + "/" + std::string(PBD_DATA_PATH);
97106

98107
// OpenGL
@@ -404,7 +413,7 @@ void createRigidBodyModel()
404413
SimulationModel::RigidBodyVector &rb = model.getRigidBodies();
405414
SimulationModel::ConstraintVector &constraints = model.getConstraints();
406415

407-
string fileName = Utilities::normalizePath(dataPath + "/models/cube.obj");
416+
string fileName = FileSystem::normalizePath(dataPath + "/models/cube.obj");
408417
IndexedFaceMesh mesh;
409418
VertexData vd;
410419
OBJLoader::loadObj(fileName, vd, mesh, Vector3r(width, height, depth));
@@ -696,8 +705,8 @@ void createClothMesh()
696705
}
697706
}
698707

699-
std::cout << "Number of triangles: " << nIndices / 3 << "\n";
700-
std::cout << "Number of vertices: " << nRows*nCols << "\n";
708+
LOG_INFO << "Number of triangles: " << nIndices / 3;
709+
LOG_INFO << "Number of vertices: " << nRows*nCols;
701710

702711
}
703712

Demos/DistanceFieldDemos/ClothCollisionDemo.cpp

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,20 @@
99
#include "Demos/Simulation/TimeStepController.h"
1010
#include <iostream>
1111
#include "Demos/Visualization/Visualization.h"
12-
#include "Demos/Utils/Utilities.h"
1312
#include "Demos/Simulation/DistanceFieldCollisionDetection.h"
1413
#include "Demos/Utils/OBJLoader.h"
14+
#include "Demos/Utils/Logger.h"
1515
#include "Demos/Utils/Timing.h"
16+
#include "Demos/Utils/FileSystem.h"
1617

1718
// Enable memory leak detection
1819
#if defined(_DEBUG) && !defined(EIGEN_ALIGN)
1920
#define new DEBUG_NEW
2021
#endif
2122

23+
INIT_TIMING
24+
INIT_LOGGING
25+
2226
using namespace PBD;
2327
using namespace Eigen;
2428
using namespace std;
@@ -94,7 +98,12 @@ int main( int argc, char **argv )
9498
{
9599
REPORT_MEMORY_LEAKS
96100

97-
exePath = Utilities::getFilePath(argv[0]);
101+
std::string logPath = FileSystem::normalizePath(FileSystem::getProgramPath() + "/log");
102+
FileSystem::makeDirs(logPath);
103+
logger.addSink(unique_ptr<ConsoleSink>(new ConsoleSink(LogLevel::INFO)));
104+
logger.addSink(unique_ptr<FileSink>(new FileSink(LogLevel::DEBUG, logPath + "/PBD.log")));
105+
106+
exePath = FileSystem::getProgramPath();
98107
dataPath = exePath + "/" + std::string(PBD_DATA_PATH);
99108

100109
// OpenGL
@@ -252,12 +261,12 @@ void buildModel ()
252261
createMesh();
253262

254263
// create static rigid body
255-
string fileName = Utilities::normalizePath(dataPath + "/models/cube.obj");
264+
string fileName = FileSystem::normalizePath(dataPath + "/models/cube.obj");
256265
IndexedFaceMesh mesh;
257266
VertexData vd;
258267
OBJLoader::loadObj(fileName, vd, mesh);
259268

260-
string fileNameTorus = Utilities::normalizePath(dataPath + "/models/torus.obj");
269+
string fileNameTorus = FileSystem::normalizePath(dataPath + "/models/torus.obj");
261270
IndexedFaceMesh meshTorus;
262271
VertexData vdTorus;
263272
OBJLoader::loadObj(fileNameTorus, vdTorus, meshTorus);
@@ -563,8 +572,8 @@ void createMesh()
563572
}
564573
}
565574

566-
std::cout << "Number of triangles: " << nIndices / 3 << "\n";
567-
std::cout << "Number of vertices: " << nRows*nCols << "\n";
575+
LOG_INFO << "Number of triangles: " << nIndices / 3;
576+
LOG_INFO << "Number of vertices: " << nRows*nCols;
568577

569578
}
570579

Demos/DistanceFieldDemos/DeformableCollisionDemo.cpp

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,20 @@
88
#include "Demos/Simulation/TimeStepController.h"
99
#include <iostream>
1010
#include "Demos/Visualization/Visualization.h"
11-
#include "Demos/Utils/Utilities.h"
1211
#include "Demos/Simulation/DistanceFieldCollisionDetection.h"
1312
#include "Demos/Utils/OBJLoader.h"
13+
#include "Demos/Utils/Logger.h"
1414
#include "Demos/Utils/Timing.h"
15+
#include "Demos/Utils/FileSystem.h"
1516

1617
// Enable memory leak detection
1718
#if defined(_DEBUG) && !defined(EIGEN_ALIGN)
1819
#define new DEBUG_NEW
1920
#endif
2021

22+
INIT_TIMING
23+
INIT_LOGGING
24+
2125
using namespace PBD;
2226
using namespace Eigen;
2327
using namespace std;
@@ -78,7 +82,12 @@ int main( int argc, char **argv )
7882
{
7983
REPORT_MEMORY_LEAKS
8084

81-
exePath = Utilities::getFilePath(argv[0]);
85+
std::string logPath = FileSystem::normalizePath(FileSystem::getProgramPath() + "/log");
86+
FileSystem::makeDirs(logPath);
87+
logger.addSink(unique_ptr<ConsoleSink>(new ConsoleSink(LogLevel::INFO)));
88+
logger.addSink(unique_ptr<FileSink>(new FileSink(LogLevel::DEBUG, logPath + "/PBD.log")));
89+
90+
exePath = FileSystem::getProgramPath();
8291
dataPath = exePath + "/" + std::string(PBD_DATA_PATH);
8392

8493
// OpenGL
@@ -210,12 +219,12 @@ void buildModel ()
210219
createMesh();
211220

212221
// create static rigid body
213-
string fileName = Utilities::normalizePath(dataPath + "/models/cube.obj");
222+
string fileName = FileSystem::normalizePath(dataPath + "/models/cube.obj");
214223
IndexedFaceMesh mesh;
215224
VertexData vd;
216225
OBJLoader::loadObj(fileName, vd, mesh);
217226

218-
string fileNameTorus = Utilities::normalizePath(dataPath + "/models/torus.obj");
227+
string fileNameTorus = FileSystem::normalizePath(dataPath + "/models/torus.obj");
219228
IndexedFaceMesh meshTorus;
220229
VertexData vdTorus;
221230
OBJLoader::loadObj(fileNameTorus, vdTorus, meshTorus);
@@ -480,8 +489,8 @@ void createMesh()
480489
model.getTetModels()[cm]->updateMeshNormals(pd);
481490
}
482491

483-
std::cout << "Number of tets: " << indices.size() / 4 << "\n";
484-
std::cout << "Number of vertices: " << width*height*depth << "\n";
492+
LOG_INFO << "Number of tets: " << indices.size() / 4;
493+
LOG_INFO << "Number of vertices: " << width*height*depth;
485494

486495
}
487496

0 commit comments

Comments
 (0)