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