c-frame / physx

A-Frame physics using PhysX
MIT License
24 stars 4 forks source link

Adding SCCD for kinematic objects using the highPrecision option #10

Closed jameskane05 closed 1 year ago

jameskane05 commented 1 year ago

Above Par-adowski Mini-Golf would like to make use of this open source repo and would prefer to point to main branch dist builds, but we need the SCCD flag triggerable with the highPrecision component option.

This allows you to do continuous collision detection on kinematic objects. This helps to avoid collision tunneling (collision misses) on fast-moving kinematic objects by checking not only the final collision boundaries, but also collisions all along the path from its location in the previous frame to the next. This is described here:

https://docs.nvidia.com/gameworks/content/gameworkslibrary/physx/guide/Manual/AdvancedCollisionDetection.html#speculative-ccd

This is in use on the club head in AboveParadowski.com - without it, you can swing right through the ball on hard swings. Easy to apply to the physx-body component like so:

this.clubHeadContainerEl.setAttribute("physx-body", {
      type: "kinematic",
      highPrecision: true,
    });

I would think most PhysX users would like access to this property when needed.

diarmidmackenzie commented 1 year ago

Closed in favour of #11