Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
f210446
Initial project setup
VincentChen1113 Apr 13, 2026
cf5992a
Update README
VincentChen1113 Apr 13, 2026
717ff90
Update README
VincentChen1113 Apr 13, 2026
3942215
Anotation in Mesh.cpp and app.cpp to help understanding the code stru…
VincentChen1113 Apr 19, 2026
09ca42b
Add initial PBD solver scaffold and demo mode selection- create PBDSo…
VincentChen1113 Apr 19, 2026
7bbf617
Add an interface to reuse the function for handling mouse draging in …
VincentChen1113 Apr 20, 2026
694f692
- Add generic PBDConstraint interface (evaluate, gradients, project)-…
VincentChen1113 Apr 20, 2026
2c865a8
Add comments to explain the solver and update README by adding runnin…
VincentChen1113 Apr 26, 2026
b3ea7f4
Change bend collision handling from distance projection to using pape…
VincentChen1113 Apr 27, 2026
5846c6a
Implemnet self collision base on the paper's approach. Need to tune t…
VincentChen1113 Apr 27, 2026
0e1eba5
Fixed for pushing an not compiling code for self-collision
VincentChen1113 Apr 27, 2026
0d04232
Improve PBD self-collision with previous-frame normal orientation, cr…
VincentChen1113 Apr 30, 2026
b7aa9a0
Tuning the variable to achieve a better visual result for demo.
VincentChen1113 Apr 30, 2026
ea4d533
Improve PBD floor demo tuning, add floor scene, and add self-collisio…
VincentChen1113 May 3, 2026
6c79b4a
Reorganize the structure of the code and add a checklist to the README.
VincentChen1113 May 3, 2026
9039d06
Resolve the over-constraint's issue by loweringthe maxSelfCollisionCo…
VincentChen1113 May 3, 2026
deda0dc
Implement a simple mimic wind demo. This demo apply external force wi…
VincentChen1113 May 3, 2026
6613bcc
Improve sphere collision handling and render sphere demo object.
VincentChen1113 May 4, 2026
3ed5829
Add dual obstacle PBD demo with analytic cube collisions and floor sh…
VincentChen1113 May 4, 2026
8a33b4c
Replace mock wind demo with wind drag force + noise.
VincentChen1113 May 6, 2026
8b0d9ee
Update README for wind demo.
VincentChen1113 May 6, 2026
7b6e3b5
Add lift force as one of the external forces and apply a US flag text…
VincentChen1113 May 9, 2026
ed1bd1d
Constrain user's mouse drag motion to prevent extreme movement. Updat…
VincentChen1113 May 9, 2026
373bd9e
Add runtime interface for hang demo and update README.
VincentChen1113 May 9, 2026
684626e
Add interface for drop on sphere demo, and update README for interfac…
VincentChen1113 May 9, 2026
4ca22de
Add interface for self-collision drop-floor demo, and update README f…
VincentChen1113 May 9, 2026
71a72a1
Add interface for drop dual object demo, and update README for interf…
VincentChen1113 May 9, 2026
1cccfd2
Add interface for wind demo, and update README for interface instruct…
VincentChen1113 May 9, 2026
984ea35
Reorganize the app file and add demo record into README.
VincentChen1113 May 9, 2026
c533989
Missing check for Demo video / GIF in README.
VincentChen1113 May 9, 2026
d803525
Update README
VincentChen1113 May 9, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
cmake_minimum_required(VERSION 3.10.0)

if(POLICY CMP0072)
cmake_policy(SET CMP0072 NEW)
endif()

project(fast-mass-spring)

set(OpenGL_GL_PREFERENCE GLVND)

set(Sources
ClothApp/app.cpp
ClothApp/MassSpringSolver.cpp
ClothApp/PBDSolver.cpp
ClothApp/Mesh.cpp
ClothApp/Renderer.cpp
ClothApp/Shader.cpp
Expand All @@ -27,6 +34,7 @@ FetchContent_Declare(
FetchContent_Declare(
eigen
GIT_REPOSITORY https://gitlab.com/libeigen/eigen.git
GIT_TAG 3.4.0
)

FetchContent_Declare(
Expand All @@ -43,9 +51,11 @@ endif()
FetchContent_GetProperties(eigen)
if(NOT eigen_POPULATED)
FetchContent_Populate(eigen)
add_subdirectory(${eigen_SOURCE_DIR} ${eigen_BINARY_DIR})
endif()

add_library(eigen INTERFACE)
target_include_directories(eigen INTERFACE ${eigen_SOURCE_DIR})


FetchContent_GetProperties(glm)
if(NOT glm_POPULATED)
Expand All @@ -58,9 +68,15 @@ if(WIN32)
add_definitions(-D_USE_MATH_DEFINES)
endif()

# copy shaders to binary directory
file(INSTALL ClothApp/shaders/ DESTINATION shaders/)

# create executable
add_executable(fast-mass-spring ${Sources})
target_link_libraries(fast-mass-spring ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES} ${GLEW_LIBRARIES} OpenMeshCore eigen glm)

# copy shaders to binary directory on every build.
add_custom_target(copy_shaders ALL
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_CURRENT_SOURCE_DIR}/ClothApp/shaders
${CMAKE_CURRENT_BINARY_DIR}/shaders
)

add_dependencies(fast-mass-spring copy_shaders)
1 change: 1 addition & 0 deletions ClothApp/MassSpringSolver.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "MassSpringSolver.h"
#include <iostream>
#include <cassert>

// S Y S T E M //////////////////////////////////////////////////////////////////////////////////////
mass_spring_system::mass_spring_system(
Expand Down
9 changes: 8 additions & 1 deletion ClothApp/MassSpringSolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,13 @@ class MassSpringBuilder {
// Constraint Graph
class CgNodeVisitor; // Constraint graph node visitor

class FixedPointController {
public:
virtual ~FixedPointController() = default;
virtual void fixPoint(unsigned int i) = 0;
virtual void releasePoint(unsigned int i) = 0;
};

// Constraint graph node
class CgNode {
protected:
Expand Down Expand Up @@ -158,7 +165,7 @@ class CgRootNode : public CgSpringNode {
virtual bool accept(CgNodeVisitor& visitor);
};

class CgPointFixNode : public CgPointNode {
class CgPointFixNode : public CgPointNode, public FixedPointController {
protected:
typedef Eigen::Vector3f Vector3f;
std::unordered_map<unsigned int, Vector3f> fix_map;
Expand Down
10 changes: 5 additions & 5 deletions ClothApp/Mesh.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#include "Mesh.h"

// M E S H /////////////////////////////////////////////////////////////////////////////////////
float* Mesh::vbuff() { return VERTEX_DATA(this); }
float* Mesh::nbuff() { return NORMAL_DATA(this); }
float* Mesh::tbuff() { return TEXTURE_DATA(this); }
unsigned int* Mesh::ibuff() { return &_ibuff[0]; }
float* Mesh::vbuff() { return VERTEX_DATA(this); } // vertex buffer
float* Mesh::nbuff() { return NORMAL_DATA(this); } // normal buffer
float* Mesh::tbuff() { return TEXTURE_DATA(this); } // texture coordinate buffer
unsigned int* Mesh::ibuff() { return &_ibuff[0]; } // index buffer
void Mesh::useIBuff(std::vector<unsigned int>& _ibuff) { this->_ibuff = _ibuff; }

unsigned int Mesh::vbuffLen() { return (unsigned int)n_vertices() * 3; }
Expand Down Expand Up @@ -35,7 +35,7 @@ void MeshBuilder::uniformGrid(float w, int n) {

for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
handle_table[j + i * n] = result->add_vertex(o + d*j*ux + d*i*uy); // add vertex
handle_table[j + i * n] = result->add_vertex(o + d*j*ux + d*i*uy); // add vertex, vertexId(i, j) = i * n + j
result->set_texcoord2D(handle_table[j + i * n], OpenMesh::Vec2f(ud*j, ud*i)); // add texture coordinates

//add connectivity
Expand Down
Loading