erwincoumans / tiny-differentiable-simulator

Tiny Differentiable Simulator is a header-only C++ and CUDA physics library for reinforcement learning and robotics with zero dependencies.
Apache License 2.0
1.2k stars 129 forks source link

Sdf to mesh #112

Closed Sanithovski closed 3 years ago

Sanithovski commented 3 years ago

I added a component to render basic geometry shapes with their Signed Distance Functions (SDFs). The mesh can be generated from the SDF at runtime instead of being read from pre-generated mesh files. The mesh generation is achieved with a local implementation Marching Cubes algorithm. CGAL is no longer needed for mesh generation.

The URDF visualizer in examples can now render geometry shapes with the new mesh generation component. To use SDF to mesh for visualization, set USE_SDF_TO_MESH to 1. Change it to 0 to disable this functionality.

Here is a list of changes I made:

Sanithovski commented 3 years ago

There's a build issue. Inverstigating.

erwincoumans commented 3 years ago

Thanks, you can see some errors in the log here: https://travis-ci.org/github/google-research/tiny-differentiable-simulator/jobs/770750707

Sanithovski commented 3 years ago

I have fixed the build issues. Now the SDF to mesh component should build with Eigen and on MacOS.

erwincoumans commented 3 years ago

Thanks a lot for the contribution. I'd rather not have multiple inheritance. Will look how we can work around that, and look a bit more into the code.

Sanithovski commented 3 years ago

I'm adding an SDF for the Plane class. After that, each of the existing geometry types would have an SDF function, and we can remove the SDF class and move its contents to the Geometry base class. This should remove the multiple inheritance concern.

Sanithovski commented 3 years ago

Hi. I have removed the SDF helper class and moved its contents to the Geometry class. I've added the SDF function for the Plane class and an error message if the SDF distance function is called from an unsupported geometry class.

erwincoumans commented 3 years ago

Thanks for all the effort, but it can't be merged as-as at the moment. The dependency from geometry.hpp to sdf_utils.hpp to one of the visualizers (visualizer/opengl/tiny_gl_instancing_renderer.h) is not ok: the visualizers are optional. I'll get back to this later, no need to take further action at this stage.

erwincoumans commented 3 years ago

Also,what is the license of the MarchingCubes code by Michael Polyakov? If there are other parts of this pull request are written by others, please provide license info.

Sanithovski commented 3 years ago

The MarchingCubes code is retrieved from this website: https://www.angelfire.com/linux/myp/MCAdvanced/MCImproved.html I've made some changes to the code so it conforms with our program structure. The author, Michael Y. Polyakov (myp@andrew.cmu.edu, mikepolyakov@hotmail.com), did not leave license information. The original website is not fully operational and I cannot find up-to-date information about him. I can try to reach him at the above email addresses (probably the Hotmail one since I suspect he/she has graduated from CMU) if that's necessary.

erwincoumans commented 3 years ago

Thanks a lot for the pull request. I'll make some minor changes in a follow up PR.