GSoC 2019: Cloth Simulator Improvement - Weekly Reports

Week 1:

  • Went through the research and prepared notes of the same
  • Went through the current cloth simulator and prepared notes of the same
  • Prepared an outline of what changes need to be made to the current cloth simulator in order to add the remeshing step
  • Removed cloth cache system
    • This has been done to minimize the possible areas of bugs during the implementation of the remeshing step since the current cache system may not be compatible with changing meshes
  • Made changes to cloth modifier, now works with changing meshes

Plan for following week:

  • Based on discussion with mentor (@brecht), implement a test suite in python to ensure nothing breaks during implementation of remeshing
  • Initial implementation of remeshing step

Week 2:

  • Added Remeshing parameters
  • Initial implementation of remeshing step
    • Added “bad edges” and “edge size”
    • Partially added “split edges”
      • Current method splits all “bad” edges and then triangulates the whole mesh, this is not ideal. Need to implement a method that splits a “bad” mesh and ensures that mesh remains triangulated
  • Test suite pending from planned
    • Since the caching system has been removed, upon rendering a scene, the cloth does not update, only during animation playback does the simulation take place. This limitation prevents rendering of the different scenes that would be used as test cases so need to find a different way to implement a test suite.

Plan for the following week:

  • Improve implementation of “split edges”
  • Add UI for the remeshing parameters to make it easier to test
  • Try to add newly created vertices into the mass spring system
  • Initial implementation of “collapse edges”

Week 3:

  • Implemented “split edges” completely
    • Fixed major issue of edges that have vertices with multiple UV coordinates subdividing infinitely
    • No longer relies on triangulating the mesh after all the edges have been split, this can sometimes lead to unexpected results and is slower. Now it correctly splits the edge while ensuring connected faces have proper triangulation
  • Added UI
    • This is not the final UI but is a placeholder to allow for faster testing without recompiling, most UI elements are not currently used
  • Implemented a test suite
    • Added support to export BMesh as obj with UVs and normals
    • Created a python script that imports obj sequence and sets keyframes such that each mesh is visible (viewport and render) during its corresponding keyframe. Link to the same.
  • Trying to add newly created vertices into the mass spring system
    • Many of the smaller bits of the puzzle have been worked out and implemented, need to connect them all and test

Plan for the following week:

  • Finish adding newly created vertices into the mass spring system
  • Initial implementation of “collapse edges”

Week 4:

  • Nearly finished adding newly created vertices into the mass spring system

    • Simulation now takes place with newly created vertices :smiley: (check link to video for the same)
    • There has been a change in the implementation, it was initially designed to add all the newly created vertices at the end of the remeshing step, this would have been the right move as long as there were no vertices that would be deleted from the cloth (which “collapse edges” would do). This had been overlooked during initial design, now each newly created vertex is immediately added into the cloth system to ensure accuracy of the simulation.
    • Currently doesn’t support stitching, I have thought about some implementation approaches, but yet to be coded
    • There are some random crashes that take place, possibly due to floating point precision errors, some workarounds are already in place but not enough to prevent all crashes
  • “collapse edges” pending from planned

    • Adding newly created vertices has been a very large task, had been extremely optimistic to finish it by this week but still haven’t been able to finish it.

Plan for the following week:

  • Fix crashes while adding newly created vertices into the mass spring system
  • Initial implementation of “collapse edges”

Week 5:

  • Fixed crashes while adding newly created vertices into the mass spring system
    • Main problem was that the object matrix was not applied to the BMesh that is generated when the simulation is reset, this is now fixed
    • The above problem upon fixing also fixed most of the previously thought floating point related errors, further testings needs to be done
  • Started initial implementation of “collapse edges”
    • The ground work for next week has been set, hope to have something running by next week
  • Started initial implementation of “flip edges”
    • “flip edges” is required to ensure proper orientation of triangles to the sizing field
    • Needs to be run after “split edges” and “collapse edges”, so best to continue its development along with “collapse edges”
  • Ported remeshing code to cpp
    • This has been done mainly for the functionality of vector<> which is crucial for “collapse edges” and “flip edges”. Tried to use BLI_linklist and BLI_array, but were cumbersome to use.

Plan for the following week:

  • Continue development on “collapse edges”
  • Continue development on “flip edges”

Week 6:

  • Nearing completion on “collapse edge”
    • Added support for edge size with vertex
      • To determine the edge size if a collapse edge is performed
    • Added support to delete vertices from clothObject
    • Added support to reindex the clothObject->verts to match bmesh
      • After deleting or adding vertices, the indices might not match which can lead to several errors, thus reindexing must be performed

Plan for the following week:

  • Continue development on “collapse edges”
  • Continue development on “flip edges”

Week 7:

  • Completed “collapse edges” development
    • Added seam detection support to ensure vertex on a seam is not killed unless both vertices of edge is on the seam
    • Added aspect ratio support to ensure clean topology
  • Completed “flip edges” development
    • Implemented method to find “flipable” edges
    • Implemented method to find “independent” edges
  • Fixed multiple bugs
    • Fixed rare infinite loop in “split edges”
    • Fixed updating of “active faces” to ensure no duplication of face occurs
    • Found some of the smaller bugs and fixed them

Plan for the following week:

  • Start development on dynamic remeshing
  • Try to add back support for pinned vertices and sewing

How much faster do you think calcualting the adaptive cloth simulation is compared to normal simulation method? Also thanks and keep up the good work. :blush:

1 Like

Let us continue this discussion here.


'I think it’s wonderful what you’re doing, thx.I was watching a video on Youtube Named " Technical Talk_ A multi-scale model for simulating liquid-fabric interactions" & was wondering if this may be possible in Blender since you’re already improving the cloth simulation? The video had links to the code used for it but I know nothing about any of that. Please let me know, Thx again.

It would be great addition but adding liquid-fabric interaction would involve significant change in the fluid simulator as well. As you may know, Blender’s fluid simulator is going to be dissolved and replaced with Mantaflow. It will be better to look into this after Mantaflow has been merged into the master to prevent work being done multiple times.


Thx for the info, that sounds logical. Can’t wait.:grin:

Week 8:

  • Nearly finished dynamic remeshing support
    • Converted sizing to be a mapping between pointer to BMVert and ClothSizing
    • Added different sizing metrics
      • Curvature metric
      • Compression metric
      • Velocity metric
      • Nearly finished obstacle metric
  • Started to add back support for pinned vertices and sewing

Plan for the following week:

  • Finish obstacle metric to fully support dynamic remeshing
  • Continue to add back support for pinned vertices and sewing
  • Read and understand the caching system so that support for changing number of vertices in caching system can be added

@ish_bosamiya It hasn’t directly to do with this gsoc project, but do you know whether it would be somehow possible with the current cloth simulation system to implement the ability to rip and break clothes?

Yes, it is definitely possible but there would be many limitations to it so it has not been worked on yet.
After this GSoC project, it would get easier to implement cloth tearing because dynamically changing number of vertices would be supported. I hope to work on this after my GSoC :slight_smile:


Hello, first of all thanks for all the hard work. About this project, my main concern is if the remeshing feature will work with motion blur, as it changes the number of vertices per frame.

1 Like

I am not really sure about this, fluid simulation which has constantly changing number of vertices has motion blur applied in Cycles, of course EEVEE doesn’t support it because it is compatible only with object basis motion blur. So it might be possible to add such support even for this.

Week 9:

  • Finished obstacle metric support but dynamic remeshing not fully supported yet, need to continue to refine some parts
    • Split edges now flips the newly created edges if needed
    • Transitioned to using ClothVertMap which is a mapping between the BMVert pointer and the ClothVertex, this is important to eliminate floating point precision errors and to also speed up the remeshing step
    • Switched to using the same edge size calculation for all the different sub algorithms during remeshing to ensure consistency and better maintenance of code
    • Edge face pair detection used the method part of the BMesh api, it was overlooked that it gives the face pair if and only if 2 faces are available for the edge. Hence switched to custom function which works with even a single face.
    • Improved UV determination method
  • Started discussion with mentor about how the caching system can be changed to support changing number of vertices
    • One of the plans is to run the remeshing step before the cache file is read to ensure that the number of vertices matches for both, the mesh and the cache file match. The cache file already stores the information that is needed during the remeshing step, this would mean no extra data needs to be stored. Although this does have a time overhead.
    • Another plan is to store Barycentric UV coordinates of all the new points within the existing faces and also store face indices for each of those points. It might be possible to reconstruct the topological data from this information.

Plan for the following week:

  • Have a working build for dynamic remeshing
  • Start to implement the above mentioned caching methods
  • Continue to add back support for pinned vertices and sewing

Hello again. When will there be a tutorial for using this new syste? Dan’t wait, Thx :grin:

1 Like

Thanks for the answer! It’d be awesome having true motion blur on the adaptive remeshing, otherwise would be kind of limiting render-wise.

1 Like