-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Collisions Upgrade! #83
Conversation
🦋 Changeset detectedLatest commit: dc67ce2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@wiledal I've made some additional changes as discussed on Discord, please take a look. I've established an I've deliberately made this function apply the options to the collider and not a collider descriptor, as a first tiny step towards improving the support for HMR. Let me know what you think. |
0302176
to
dc67ce2
Compare
tl;dr
Collision callbacks can now also be set on colliders:
Collision callback payloads now include the collider that was involved in the collision:
Colliders can be configured with
collisionGroup
(andsolverGroup
) props. Since these expect bitmasks and creating bitmasks can be a bit cumberson, this PR also introduces theinteractionGroups
helper function:The first argument is one or multiple group memberships, the second one or multiple groups to interact with. If the second argument is omitted, it defaults to interacting with all groups.
RigidBody can also be configured with these props. Rapier doesn't have collision/solver groups on Rigidbodies, so instead these values act as defaults for all colliders in the rigidbody:
It's possible that the current implementation doesn't connect to all colliders.
utils.ts
seems to include multiple separate/duplicate code paths that create collider descriptors. This would need to be consolidated somehow, but I would like to ask for help from someone who is a little more familiar with the implementation.Onto some more detailed notes!
Notes:
Allow the user to configure active event types (note to self: read up on those again, I think their semantics have changed in Rapier recently!)hasCollisionsEvents
argument.hasCollisionEvents
should work now that colliders themselves can have collision eventsgroup(...) + mask(...)
(adding numbers is fun!)createColliderFromOptions
vs.colliderDescFromGeometry
.) These should/must be consolidated.Other changes/additions in this PR:
.editorconfig
. I know this is not related to the change, but it contains important configuration for the new bits in the README..editorconfig
and a Prettier configuration to the project to make things a little easier for contributors.Further suggestions I have for changes, some of them breaking:
yarn ci
script. As a next step, we may add a GitHub Actions runner for this script; I would also recommend making the building of the library part of the script. We can do this in a separate PR though.target
in the event callback payload might benefit from a better name (especially now that the other collider is also part of the callback payload.) I would suggestotherBody
andotherCollider
.UseColliderOptions
, but nouseCollider
(which is fine). Is this a leftover from an earlier version that had such a hook? It might be good to rename this to justColliderOptions
.