implement better scene collider removal
This commit is contained in:
parent
b186b37ffb
commit
babbef279a
|
@ -14,10 +14,13 @@ impl Plugin for CommandsPlugin {
|
|||
fn build(&self, app: &mut App) {
|
||||
app.add_systems(Startup, load_defs);
|
||||
app.add_systems(Update, spawn_entities);
|
||||
app.add_systems(PreUpdate, hide_colliders
|
||||
.run_if(any_with_component::<NeedsSceneColliderRemoved>));
|
||||
app.add_event::<SpawnEvent>();
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Component)] pub struct NeedsSceneColliderRemoved;
|
||||
#[derive(Event)] pub struct SpawnEvent(ParserState);
|
||||
#[derive(PartialEq, Clone)]
|
||||
enum DefClass {
|
||||
|
@ -508,6 +511,7 @@ fn spawn_entities(
|
|||
.with_layers_for_name("Collider", CollisionLayers::ALL)
|
||||
//.with_density_for_name("Collider", state.density)
|
||||
);
|
||||
actor.insert(NeedsSceneColliderRemoved);
|
||||
}
|
||||
else {
|
||||
actor.insert(state.collider.clone());
|
||||
|
@ -611,3 +615,14 @@ fn spawn_entities(
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pub fn hide_colliders(
|
||||
mut q_mesh: Query<(&mut Visibility, &Name), (With<NeedsSceneColliderRemoved>, With<Handle<Mesh>>)>,
|
||||
) {
|
||||
for (mut visibility, name) in &mut q_mesh {
|
||||
if name.as_str() == "Collider" {
|
||||
*visibility = Visibility::Hidden;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,3 +19,14 @@ impl Material for JupitersRing {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
#[derive(Asset, TypePath, AsBindGroup, Debug, Clone)]
|
||||
pub struct AsteroidSurface {
|
||||
}
|
||||
|
||||
impl Material for AsteroidSurface {
|
||||
fn fragment_shader() -> ShaderRef {
|
||||
"shaders/material_asteroid.wgsl".into()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
12
src/world.rs
12
src/world.rs
|
@ -48,7 +48,6 @@ impl Plugin for WorldPlugin {
|
|||
fn build(&self, app: &mut App) {
|
||||
app.add_systems(Startup, setup);
|
||||
app.add_systems(Update, handle_cheats);
|
||||
app.add_systems(PreUpdate, hide_colliders); // gotta do this better
|
||||
app.add_systems(PostUpdate, handle_despawn);
|
||||
app.add_systems(Update, spawn_despawn_asteroids);
|
||||
app.add_plugins(PhysicsPlugins::default());
|
||||
|
@ -451,17 +450,6 @@ fn handle_cheats(
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
pub fn hide_colliders(
|
||||
mut q_mesh: Query<(&mut Visibility, &Name), With<Handle<Mesh>>>,
|
||||
) {
|
||||
for (mut visibility, name) in &mut q_mesh {
|
||||
if name.as_str() == "Collider" {
|
||||
*visibility = Visibility::Hidden;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// A variant of bevy_xpbd_3d::plugins::position_to_transform that adjusts
|
||||
// the rendering position to center entities at the player camera.
|
||||
// This avoids rendering glitches when very far away from the origin.
|
||||
|
|
Loading…
Reference in a new issue