AlexanderFabisch / distance3d

Distance computation and collision detection in 3D.
https://alexanderfabisch.github.io/distance3d/
Other
61 stars 8 forks source link

Fix broad phase for cube vs. sphere #58

Closed MaartenBehn closed 2 years ago

MaartenBehn commented 2 years ago

The AABBs of an axis aligned Cube contains always two equal AABBs for every side of the cube. When unique is turned on the AABBs library deletes one pair hence the wrong results.

Calculation times on my machine: AABB Tree time: 0.14666247367858887 Brute-Force time: 0.9549121856689453

AlexanderFabisch commented 2 years ago

Hey,

I have the following times on my computer (AMD Ryzen 7 2700 Eight-Core Processor):

AABB Tree time: 0.395 (test_Bug = False, test_AABBs_Tree = True) Brute-Force time: 0.106 (test_Bug = False, test_AABBs_Tree = False)

Because of vectorization and parallelization, building and using the AABBTree is actually a bit slower than not using it at all. Even when I scale the number of tetrahedra up a lot (rigid_body1 = hydroelastic_contact.RigidBody.make_sphere(0.13 * np.ones(3), 0.15, 5)), I get the following results:

AABB Tree time: 24.787 (test_Bug = False, test_AABBs_Tree = True) Brute-Force time: 2.05 (test_Bug = False, test_AABBs_Tree = False)

Still, brute force is way faster. The factor is even bigger. (I don't know why to be honest.)

Conclusion: we need a faster AABBTree implementation :)

AlexanderFabisch commented 2 years ago

btw. you based your branch on hydroelastic_mesh, which I don't want to merge to master yet. Please cherry-pick your commits to your master branch and make a new PR.

MaartenBehn commented 2 years ago

Thx for the rewiev. I will close this PR and create a new one into master.