fix NoShadowCaster/Receiver with loaded gltf scenes
This commit is contained in:
parent
dd3fa4f284
commit
c363aa41b1
|
@ -847,14 +847,13 @@ pub fn hide_colliders(mut q_mesh: Query<(&mut Visibility, &Name), (Added<Visibil
|
|||
pub fn process_mesh(
|
||||
mut commands: Commands,
|
||||
mut q_mesh: Query<(Entity, &Name, &Parent), Added<Handle<Mesh>>>,
|
||||
q_parents: Query<(Option<&Parent>, Option<&actor::Player>)>,
|
||||
q_parents: Query<(Option<&Parent>, Option<&actor::Player>, Option<&NotShadowCaster>, Option<&NotShadowReceiver>)>,
|
||||
) {
|
||||
// Add "PlayerCollider" component to the player's collider mesh entity
|
||||
for (child_entity, child_name, child_parent) in &mut q_mesh {
|
||||
if child_name.as_str() == "Collider" {
|
||||
// get the root parent
|
||||
let mut get_parent = q_parents.get(child_parent.get());
|
||||
while let Ok((parent_maybe, _)) = get_parent {
|
||||
while let Ok((parent_maybe, _, _, _)) = get_parent {
|
||||
if let Some(parent) = parent_maybe {
|
||||
get_parent = q_parents.get(parent.get());
|
||||
} else {
|
||||
|
@ -862,11 +861,19 @@ pub fn process_mesh(
|
|||
}
|
||||
}
|
||||
|
||||
if let Ok((_, player, noshadowcast, noshadowrecv)) = get_parent {
|
||||
let childcmd = &mut commands.entity(child_entity);
|
||||
|
||||
// If the root parent is the player, add PlayerCollider to the collider mesh
|
||||
if let Ok((_, player)) = get_parent {
|
||||
if player.is_some() {
|
||||
commands.entity(child_entity).insert(actor::PlayerCollider);
|
||||
if player.is_some() && child_name.as_str() == "Collider" {
|
||||
childcmd.insert(actor::PlayerCollider);
|
||||
}
|
||||
|
||||
if noshadowcast.is_some() {
|
||||
childcmd.insert(NotShadowCaster);
|
||||
}
|
||||
if noshadowrecv.is_some() {
|
||||
childcmd.insert(NotShadowReceiver);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue