Skip to content

Commit

Permalink
Merge pull request #11 from diarmidmackenzie/kinematic-ccd
Browse files Browse the repository at this point in the history
Speculative CCD for high-precision kinematic bodies
  • Loading branch information
diarmidmackenzie authored Mar 19, 2023
2 parents 8e72a51 + b56b6df commit 60771f3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dist/physx.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/physx.min.js

Large diffs are not rendered by default.

12 changes: 9 additions & 3 deletions src/physics.js
Original file line number Diff line number Diff line change
Expand Up @@ -1044,11 +1044,17 @@ AFRAME.registerComponent('physx-body', {
this.rigidBody.setAngularDamping(this.data.angularDamping)
this.rigidBody.setLinearDamping(this.data.linearDamping)
this.rigidBody.setRigidBodyFlag(PhysX.PxRigidBodyFlag.eKINEMATIC, false)
if (this.data.highPrecision)
{
this.rigidBody.setSolverIterationCounts(4, 2);
}

if (this.data.highPrecision)
{
this.rigidBody.setSolverIterationCounts(4, 2);
if (this.data.type === 'dynamic') {
this.rigidBody.setRigidBodyFlag(PhysX.PxRigidBodyFlag.eENABLE_CCD, true)
}
else if (this.data.type === 'kinematic') {
this.rigidBody.setRigidBodyFlag(PhysX.PxRigidBodyFlag.eENABLE_SPECULATIVE_CCD, true);
}
}

if (!oldData || this.data.mass !== oldData.mass) this.el.emit('object3dset', {})
Expand Down

0 comments on commit 60771f3

Please sign in to comment.