Skip to content

Commit

Permalink
Add #[reflect(Component)] for AncestorMarker and register the type (
Browse files Browse the repository at this point in the history
#461)

# Objective

Fixes #460.

## Solution

Add `#[reflect(Component)]` for `AncestorMarker` and register the type.
  • Loading branch information
Jondolf authored Jul 21, 2024
1 parent 47bf699 commit 5ecfd5a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/sync/ancestor_marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,19 @@ impl<C: Component> Plugin for AncestorMarkerPlugin<C> {
/// A marker component that marks an entity as an ancestor of an entity with the given component `C`.
///
/// This is added and removed automatically by the [`AncestorMarkerPlugin`] if it is enabled.
#[derive(Component, Reflect)]
#[derive(Component, Copy, Reflect)]
#[reflect(Component, Default)]
pub struct AncestorMarker<C: Component> {
#[reflect(ignore)]
_phantom: PhantomData<C>,
}

impl<C: Component> Clone for AncestorMarker<C> {
fn clone(&self) -> Self {
Self::default()
}
}

impl<C: Component> Default for AncestorMarker<C> {
fn default() -> Self {
Self {
Expand Down
4 changes: 3 additions & 1 deletion src/type_registration.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
prelude::*,
sync::{PreviousGlobalTransform, SyncConfig},
sync::{ancestor_marker::AncestorMarker, PreviousGlobalTransform, SyncConfig},
};
use bevy::prelude::*;
use broad_phase::AabbIntersections;
Expand Down Expand Up @@ -68,6 +68,8 @@ impl Plugin for PhysicsTypeRegistrationPlugin {
.register_type::<ColliderConstructor>()
.register_type::<ColliderConstructorHierarchy>()
.register_type::<ColliderConstructorHierarchyConfig>()
.register_type::<AncestorMarker<RigidBody>>()
.register_type::<AncestorMarker<ColliderMarker>>()
.register_type::<RayCaster>()
.register_type::<ShapeCaster>()
.register_type::<DistanceJoint>()
Expand Down

0 comments on commit 5ecfd5a

Please sign in to comment.