NVIDIA / warp

A Python framework for high performance GPU simulation and graphics
https://nvidia.github.io/warp/
Other
4.27k stars 243 forks source link

[BUG] Typo in warp.sim.model.ModelBuilder.add_cloth_mesh bending constraints (edge) initialization? #319

Closed OhLeMatt closed 1 month ago

OhLeMatt commented 1 month ago

Bug Description

Hello warp community,

I noticed that the initialization of cloth bending constraints for arbitrary cloth-mesh presents what is mostlikely a typo in the call of add_edges(...). The fourth argument is currently: https://github.com/NVIDIA/warp/blob/a7ecac07d10ce5daa636d60fd6c24ae8576fd0ab/warp/sim/model.py#L4018 Whereas it should probably be (to reflect the same functionning as in add_cloth_grid):

            edgeinds[:, 3],

For some more context, this is the current code:

        adj = wp.utils.MeshAdjacency(self.tri_indices[start_tri:end_tri], end_tri - start_tri)

        edgeinds = np.fromiter(
            (x for e in adj.edges.values() for x in (e.o0, e.o1, e.v0, e.v1)),
            int,
        ).reshape(-1, 4)
        self.add_edges(
            edgeinds[:, 0],
            edgeinds[:, 1],
            edgeinds[:, 2],
            edgeinds[:, 0],
            edge_ke=[edge_ke] * len(edgeinds),
            edge_kd=[edge_kd] * len(edgeinds),
        )

I hope this issue was not already raised, I looked and found nothing yet. Thank you for your time and awesome lib!

System Information

No response

AnkaChan commented 1 month ago

I just submitted a fixing MR.

shi-eric commented 1 month ago

Fix is merged in main and will be in the next Warp release, thanks!