Skip to content

Commit

Permalink
- added collision detection for arbitrary meshes based on cubic signe…
Browse files Browse the repository at this point in the history
…d distance fields

- added Discregrid library as external project to generate cubic signed distance fields
  • Loading branch information
janbender committed Nov 10, 2017
1 parent 39a5099 commit c69fd48
Show file tree
Hide file tree
Showing 44 changed files with 3,426 additions and 193 deletions.
18 changes: 16 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,25 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON)
include(${PROJECT_PATH}/CMake/Common.cmake)

if (WIN32)
subdirs(extern/freeglut extern/AntTweakBar extern/glew Demos PositionBasedDynamics)
subdirs(extern/freeglut extern/AntTweakBar extern/glew extern/md5 Demos PositionBasedDynamics)
else()
subdirs(extern/AntTweakBar extern/glew Demos PositionBasedDynamics)
subdirs(extern/AntTweakBar extern/glew extern/md5 Demos PositionBasedDynamics)
endif()

include(ExternalProject)
set(ExternalInstallDir "${CMAKE_SOURCE_DIR}/extern/install")
set(EigenDir "${CMAKE_SOURCE_DIR}/extern/eigen")

## Discregrid
ExternalProject_Add(
ExternalProject_Discregrid
PREFIX "${CMAKE_SOURCE_DIR}/extern/Discregrid"
GIT_REPOSITORY https://github.com/InteractiveComputerGraphics/Discregrid.git
GIT_TAG "573c2f51f433c74de832454272e47f590140e80b"
INSTALL_DIR ${ExternalInstallDir}/Discregrid
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${ExternalInstallDir}/Discregrid -DBUILD_CMD_EXECUTABLE:BOOL=0 -DEIGEN3_INCLUDE_DIR:PATH=${EigenDir}
)

install(DIRECTORY ./Common
DESTINATION include
FILES_MATCHING PATTERN "*.h")
Expand Down
3 changes: 3 additions & 0 deletions Changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
1.6.0
- added collision detection for arbitrary meshes based on cubic signed distance fields
- added DiscreGrid library as external project to generate cubic signed distance fields
- added possibility to define motor target sequences in scene files
- added implementation of the paper Kugelstadt, Schoemer, "Position and Orientation Based Cosserat Rods", SCA 2016 and a corresponding demo
- update to Eigen 3.3.4
Expand Down
17 changes: 13 additions & 4 deletions Demos/BarDemo/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@
#include "Demos/Simulation/TimeStepController.h"
#include <iostream>
#include "Demos/Visualization/Visualization.h"
#include "Demos/Utils/Utilities.h"
#include "Demos/Utils/Logger.h"
#include "Demos/Utils/Timing.h"
#include "Demos/Utils/FileSystem.h"

// Enable memory leak detection
#if defined(_DEBUG) && !defined(EIGEN_ALIGN)
#define new DEBUG_NEW
#endif

INIT_TIMING
INIT_LOGGING

using namespace PBD;
using namespace Eigen;
using namespace std;
Expand Down Expand Up @@ -62,7 +66,12 @@ int main( int argc, char **argv )
{
REPORT_MEMORY_LEAKS

exePath = Utilities::getFilePath(argv[0]);
std::string logPath = FileSystem::normalizePath(FileSystem::getProgramPath() + "/log");
FileSystem::makeDirs(logPath);
logger.addSink(unique_ptr<ConsoleSink>(new ConsoleSink(LogLevel::INFO)));
logger.addSink(unique_ptr<FileSink>(new FileSink(LogLevel::DEBUG, logPath + "/PBD.log")));

exePath = FileSystem::getFilePath(argv[0]);
dataPath = exePath + "/" + std::string(PBD_DATA_PATH);

// OpenGL
Expand Down Expand Up @@ -385,8 +394,8 @@ void createMesh()
model.getTetModels()[cm]->updateMeshNormals(pd);
}

std::cout << "Number of tets: " << indices.size() / 4 << "\n";
std::cout << "Number of vertices: " << width*height*depth << "\n";
LOG_INFO << "Number of tets: " << indices.size() / 4;
LOG_INFO << "Number of vertices: " << width*height*depth;

}

Expand Down
17 changes: 13 additions & 4 deletions Demos/ClothDemo/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@
#include "Demos/Simulation/TimeStepController.h"
#include <iostream>
#include "Demos/Visualization/Visualization.h"
#include "Demos/Utils/Utilities.h"
#include "Demos/Utils/Logger.h"
#include "Demos/Utils/Timing.h"
#include "Demos/Utils/FileSystem.h"

// Enable memory leak detection
#if defined(_DEBUG) && !defined(EIGEN_ALIGN)
#define new DEBUG_NEW
#endif

INIT_TIMING
INIT_LOGGING

using namespace PBD;
using namespace Eigen;
using namespace std;
Expand Down Expand Up @@ -77,7 +81,12 @@ int main( int argc, char **argv )
{
REPORT_MEMORY_LEAKS

exePath = Utilities::getFilePath(argv[0]);
std::string logPath = FileSystem::normalizePath(FileSystem::getProgramPath() + "/log");
FileSystem::makeDirs(logPath);
logger.addSink(unique_ptr<ConsoleSink>(new ConsoleSink(LogLevel::INFO)));
logger.addSink(unique_ptr<FileSink>(new FileSink(LogLevel::DEBUG, logPath + "/PBD.log")));

exePath = FileSystem::getProgramPath();
dataPath = exePath + "/" + std::string(PBD_DATA_PATH);

// OpenGL
Expand Down Expand Up @@ -427,8 +436,8 @@ void createMesh()
}
}

std::cout << "Number of triangles: " << nIndices / 3 << "\n";
std::cout << "Number of vertices: " << nRows*nCols << "\n";
LOG_INFO << "Number of triangles: " << nIndices / 3;
LOG_INFO << "Number of vertices: " << nRows*nCols;

}

Expand Down
17 changes: 13 additions & 4 deletions Demos/CosseratRodsDemo/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@
#include "Demos/Simulation/TimeStepController.h"
#include <iostream>
#include "Demos/Visualization/Visualization.h"
#include "Demos/Utils/Utilities.h"
#include "Demos/Utils/Logger.h"
#include "Demos/Utils/Timing.h"
#include "Demos/Utils/FileSystem.h"

// Enable memory leak detection
#if defined(_DEBUG) && !defined(EIGEN_ALIGN)
#define new DEBUG_NEW
#endif

INIT_TIMING
INIT_LOGGING

using namespace PBD;
using namespace Eigen;
using namespace std;
Expand Down Expand Up @@ -66,7 +70,12 @@ int main( int argc, char **argv )
{
REPORT_MEMORY_LEAKS

exePath = Utilities::getFilePath(argv[0]);
std::string logPath = FileSystem::normalizePath(FileSystem::getProgramPath() + "/log");
FileSystem::makeDirs(logPath);
logger.addSink(unique_ptr<ConsoleSink>(new ConsoleSink(LogLevel::INFO)));
logger.addSink(unique_ptr<FileSink>(new FileSink(LogLevel::DEBUG, logPath + "/PBD.log")));

exePath = FileSystem::getProgramPath();
dataPath = exePath + "/" + std::string(PBD_DATA_PATH);

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

//std::cout << "Number of particles: " << nPoints << "\n";
//std::cout << "Number of quaternions: " << nQuaternions << "\n";
// LOG_INFO << "Number of particles: " << nPoints;
// LOG_INFO << "Number of quaternions: " << nQuaternions;
}

void TW_CALL setTimeStep(const void *value, void *clientData)
Expand Down
19 changes: 14 additions & 5 deletions Demos/CouplingDemos/RigidBodyClothCouplingDemo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
#include "Demos/Simulation/Constraints.h"
#include "Demos/Visualization/Visualization.h"
#include "Demos/Utils/OBJLoader.h"
#include "Demos/Utils/Utilities.h"
#include "Demos/Utils/Logger.h"
#include "Demos/Utils/Timing.h"
#include "Demos/Utils/FileSystem.h"

#define _USE_MATH_DEFINES
#include "math.h"
Expand All @@ -21,6 +22,9 @@
#define new DEBUG_NEW
#endif

INIT_TIMING
INIT_LOGGING

using namespace PBD;
using namespace Eigen;
using namespace std;
Expand Down Expand Up @@ -92,7 +96,12 @@ int main( int argc, char **argv )
{
REPORT_MEMORY_LEAKS

exePath = Utilities::getFilePath(argv[0]);
std::string logPath = FileSystem::normalizePath(FileSystem::getProgramPath() + "/log");
FileSystem::makeDirs(logPath);
logger.addSink(unique_ptr<ConsoleSink>(new ConsoleSink(LogLevel::INFO)));
logger.addSink(unique_ptr<FileSink>(new FileSink(LogLevel::DEBUG, logPath + "/PBD.log")));

exePath = FileSystem::getProgramPath();
dataPath = exePath + "/" + std::string(PBD_DATA_PATH);

// OpenGL
Expand Down Expand Up @@ -404,7 +413,7 @@ void createRigidBodyModel()
SimulationModel::RigidBodyVector &rb = model.getRigidBodies();
SimulationModel::ConstraintVector &constraints = model.getConstraints();

string fileName = Utilities::normalizePath(dataPath + "/models/cube.obj");
string fileName = FileSystem::normalizePath(dataPath + "/models/cube.obj");
IndexedFaceMesh mesh;
VertexData vd;
OBJLoader::loadObj(fileName, vd, mesh, Vector3r(width, height, depth));
Expand Down Expand Up @@ -696,8 +705,8 @@ void createClothMesh()
}
}

std::cout << "Number of triangles: " << nIndices / 3 << "\n";
std::cout << "Number of vertices: " << nRows*nCols << "\n";
LOG_INFO << "Number of triangles: " << nIndices / 3;
LOG_INFO << "Number of vertices: " << nRows*nCols;

}

Expand Down
21 changes: 15 additions & 6 deletions Demos/DistanceFieldDemos/ClothCollisionDemo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,20 @@
#include "Demos/Simulation/TimeStepController.h"
#include <iostream>
#include "Demos/Visualization/Visualization.h"
#include "Demos/Utils/Utilities.h"
#include "Demos/Simulation/DistanceFieldCollisionDetection.h"
#include "Demos/Utils/OBJLoader.h"
#include "Demos/Utils/Logger.h"
#include "Demos/Utils/Timing.h"
#include "Demos/Utils/FileSystem.h"

// Enable memory leak detection
#if defined(_DEBUG) && !defined(EIGEN_ALIGN)
#define new DEBUG_NEW
#endif

INIT_TIMING
INIT_LOGGING

using namespace PBD;
using namespace Eigen;
using namespace std;
Expand Down Expand Up @@ -94,7 +98,12 @@ int main( int argc, char **argv )
{
REPORT_MEMORY_LEAKS

exePath = Utilities::getFilePath(argv[0]);
std::string logPath = FileSystem::normalizePath(FileSystem::getProgramPath() + "/log");
FileSystem::makeDirs(logPath);
logger.addSink(unique_ptr<ConsoleSink>(new ConsoleSink(LogLevel::INFO)));
logger.addSink(unique_ptr<FileSink>(new FileSink(LogLevel::DEBUG, logPath + "/PBD.log")));

exePath = FileSystem::getProgramPath();
dataPath = exePath + "/" + std::string(PBD_DATA_PATH);

// OpenGL
Expand Down Expand Up @@ -252,12 +261,12 @@ void buildModel ()
createMesh();

// create static rigid body
string fileName = Utilities::normalizePath(dataPath + "/models/cube.obj");
string fileName = FileSystem::normalizePath(dataPath + "/models/cube.obj");
IndexedFaceMesh mesh;
VertexData vd;
OBJLoader::loadObj(fileName, vd, mesh);

string fileNameTorus = Utilities::normalizePath(dataPath + "/models/torus.obj");
string fileNameTorus = FileSystem::normalizePath(dataPath + "/models/torus.obj");
IndexedFaceMesh meshTorus;
VertexData vdTorus;
OBJLoader::loadObj(fileNameTorus, vdTorus, meshTorus);
Expand Down Expand Up @@ -563,8 +572,8 @@ void createMesh()
}
}

std::cout << "Number of triangles: " << nIndices / 3 << "\n";
std::cout << "Number of vertices: " << nRows*nCols << "\n";
LOG_INFO << "Number of triangles: " << nIndices / 3;
LOG_INFO << "Number of vertices: " << nRows*nCols;

}

Expand Down
21 changes: 15 additions & 6 deletions Demos/DistanceFieldDemos/DeformableCollisionDemo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,20 @@
#include "Demos/Simulation/TimeStepController.h"
#include <iostream>
#include "Demos/Visualization/Visualization.h"
#include "Demos/Utils/Utilities.h"
#include "Demos/Simulation/DistanceFieldCollisionDetection.h"
#include "Demos/Utils/OBJLoader.h"
#include "Demos/Utils/Logger.h"
#include "Demos/Utils/Timing.h"
#include "Demos/Utils/FileSystem.h"

// Enable memory leak detection
#if defined(_DEBUG) && !defined(EIGEN_ALIGN)
#define new DEBUG_NEW
#endif

INIT_TIMING
INIT_LOGGING

using namespace PBD;
using namespace Eigen;
using namespace std;
Expand Down Expand Up @@ -78,7 +82,12 @@ int main( int argc, char **argv )
{
REPORT_MEMORY_LEAKS

exePath = Utilities::getFilePath(argv[0]);
std::string logPath = FileSystem::normalizePath(FileSystem::getProgramPath() + "/log");
FileSystem::makeDirs(logPath);
logger.addSink(unique_ptr<ConsoleSink>(new ConsoleSink(LogLevel::INFO)));
logger.addSink(unique_ptr<FileSink>(new FileSink(LogLevel::DEBUG, logPath + "/PBD.log")));

exePath = FileSystem::getProgramPath();
dataPath = exePath + "/" + std::string(PBD_DATA_PATH);

// OpenGL
Expand Down Expand Up @@ -210,12 +219,12 @@ void buildModel ()
createMesh();

// create static rigid body
string fileName = Utilities::normalizePath(dataPath + "/models/cube.obj");
string fileName = FileSystem::normalizePath(dataPath + "/models/cube.obj");
IndexedFaceMesh mesh;
VertexData vd;
OBJLoader::loadObj(fileName, vd, mesh);

string fileNameTorus = Utilities::normalizePath(dataPath + "/models/torus.obj");
string fileNameTorus = FileSystem::normalizePath(dataPath + "/models/torus.obj");
IndexedFaceMesh meshTorus;
VertexData vdTorus;
OBJLoader::loadObj(fileNameTorus, vdTorus, meshTorus);
Expand Down Expand Up @@ -480,8 +489,8 @@ void createMesh()
model.getTetModels()[cm]->updateMeshNormals(pd);
}

std::cout << "Number of tets: " << indices.size() / 4 << "\n";
std::cout << "Number of vertices: " << width*height*depth << "\n";
LOG_INFO << "Number of tets: " << indices.size() / 4;
LOG_INFO << "Number of vertices: " << width*height*depth;

}

Expand Down
Loading

0 comments on commit c69fd48

Please sign in to comment.