stephengold / Libbulletjme

A JNI interface to Bullet Physics and V-HACD
https://stephengold.github.io/Libbulletjme/lbj-en/English/overview.html
Other
86 stars 10 forks source link

Create a method in MeshCollisionShape to get a triangle #28

Closed CientistaVuador closed 6 months ago

CientistaVuador commented 6 months ago

I need to get the normal of a triangle in a MeshCollisionShape using the partIndex() and triangleIndex() from the sweep test result but I don't see any way to do it without using reflection and getting the CompoundMesh directly, the normal from the sweep test result is not accurate as you can see here: https://pybullet.org/Bullet/phpBB3/viewtopic.php?t=3538

stephengold commented 6 months ago

Thanks for raising this issue. I'll investigate.

CientistaVuador commented 6 months ago

thanks

stephengold commented 6 months ago

I propose to add 2 public methods to MeshCollisionShape:

    /**
     * Count how many submeshes are in the mesh.
     *
     * @return the count (≥0)
     */
    public int countSubmeshes() {
        //...
    }

    /**
     * Access the specified submesh.
     *
     * @param index the index of the desired submesh (in the order the submeshes
     * were added, ≥0)
     * @return the pre-existing instance (not null)
     */
    public IndexedMesh getSubmesh(int index) {
        //...
    }

That should provide sufficient access to avoid any need for reflection in this use case.

And since GImpactCollisionShape potentially has the same issue, I'll add similar methods there.

Sound good?

CientistaVuador commented 6 months ago

yes

stephengold commented 6 months ago

I'll release a new version ASAP.

CientistaVuador commented 6 months ago

thanks

stephengold commented 6 months ago

@CientistaVuador: Please test whether version 20.2.0 solves this issue for you.

CientistaVuador commented 6 months ago

I tested it, works fine