-
-
Notifications
You must be signed in to change notification settings - Fork 116
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
Support default layers and density for ColliderConstructorHierarchy
#386
Conversation
1c49621
to
9ee6f30
Compare
9ee6f30
to
8cbe48c
Compare
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))] | ||
#[cfg_attr(feature = "serialize", reflect(Serialize, Deserialize))] | ||
#[cfg_attr(all(feature = "3d", feature = "collider-from-mesh"), reflect(Default))] | ||
pub struct ColliderConstructorHierarchyConfig { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's weird how everything but the constructor is optional. With this PR, wouldn't it make sense to want to override only the layers
and leave the default constructor? I'd suggest making the constructor an Option
as well.
This will also remove the special-cased Default
and the need for ColliderConstructorHierarchyConfig::from_constructor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I agree. I made the constructor an Option
and reworked the related logic a bit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feature looks good to me now :) Could you duplicate the collider_constructor_hierarchy_inserts_computed_colliders_on_scene
test and adapt it to test the new behavior?
…com/Jondolf/bevy_xpbd into more-default-config-for-hierarchies
Objective
When loading a (glTF) scene and generating colliders for it, it can be useful to be able to add all entities in that scene to some collision layer. However,
ColliderConstructorHierarchy
(previouslyAsyncSceneCollider
, see #378) doesn't currently allow specifying default collision layer or density configurations despite allowing configurations for individual entities.Solution
Add
default_layers
anddefault_density
properties forColliderConstructorHierarchy
. Thelayers
anddensity
properties ofColliderConstructorHierarchyData
are nowOption
s, and if they areNone
, the default values are used.I also moved the collider constructor types and tests to their own module, and updated some docs to remove mesh-specific wording.
For reviewing purposes, the first commit (8cbe48c) should be easier to read, the other commit just moves code to the
constructor
module.Migration Guide
If the default constructor for a
ColliderConstructorHierarchy
isNone
, meshes no longer default to triangle mesh colliders being generated even if they have a density or layers configured. The constructor must be specified either individually or through the default constructor.