AnyCollider context#527
Closed
oxkitsune wants to merge 11 commits into
Closed
Conversation
Contributor
Author
|
This is a draft, as I'm looking for comments/feedback on the implementation. |
Jondolf
added a commit
that referenced
this pull request
Mar 20, 2025
# Objective - Updated version of #527 with some changes suggested by Jondolf ## Solution - Reapply the changes from the previous PR - Add a `SimpleCollider` trait that works for colliders with no context to shorten function signatures ## Changelog - Custom colliders can now specify a SystemParam via `AnyCollider::Context` - The context is passed to all `AnyCollider` methods, allowing data from the `World` to be fetched - AnyCollider functions have been suffixed with `_with_collider` - A new `SimpleCollider` trait has been added to retain the simplified methods for colliders that don't need context ## Migration Guide - Custom colliders now need to specify a `Context` `SystemParam`, if this is unnecessary `()` should be used - When trying to use methods from `AnyCollider` on an implementation with `()` context, `SimpleCollider` should be used instead - Methods on `AnyCollider` have been suffixed with `_with_context` --------- Co-authored-by: Gijs de Jong <14833076+oxkitsune@users.noreply.github.com> Co-authored-by: aecsocket <aecsocket@tutanota.com> Co-authored-by: Joona Aalto <jondolf.dev@gmail.com>
Member
|
Adopted in #665, which was just merged. Closing :) |
Jondolf
added a commit
that referenced
this pull request
Mar 21, 2025
# Objective #527 used a read-only `UnsafeWorldCell` for the initialization of `ColliderAabb` in an `on_add` hook for `Collider`. However, it uses methods that provide mutable access, which is unsafe and panics with debug assertions. ## Solution Remove the whole AABB initialization logic and use of `unsafe`. Having it didn't make sense since the initial positions are likely wrong anyway. `ColliderAabb` is now explicitly specified to be `ColliderAabb::INVALID` until the first physics update.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Objective
Provide a way for the methods in
AnyColliderto obtain extra context from the ecs/entity it is attached to.Solution
ContextGAT to theAnyCollidertraitOption<Context>to theAnyCollidermethods when calledChangelog
AnyColliderrequires aContextGAT, to provide additional context from the ecs.