Skip to content
This repository has been archived by the owner on Feb 22, 2022. It is now read-only.

Commit

Permalink
Fixes for upstream bevyengine/bevy#1703
Browse files Browse the repository at this point in the history
  • Loading branch information
aevyrie committed Mar 23, 2021
1 parent 8605fb2 commit 5f30c9e
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 151 deletions.
122 changes: 0 additions & 122 deletions assets/models/monkey/Monkey.gltf

This file was deleted.

44 changes: 23 additions & 21 deletions examples/demo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,43 +27,45 @@ fn setup(
Vec3::new(0.0, 0.0, 0.0),
Vec3::new(0.0, 1.0, 0.0),
));
commands.spawn_bundle(ortho_cam);
// AABB
commands
.spawn(ortho_cam)
// AABB
.spawn(PbrBundle {
.spawn_bundle(PbrBundle {
mesh: asset_server.get_handle(mesh_path),
material: materials.add(Color::rgb(1.0, 1.0, 1.0).into()),
transform: Transform::from_translation(Vec3::new(-1.0, 0.0, 0.0)),
..Default::default()
})
.with(Bounded::<aabb::AxisAlignedBB>::default())
.with(debug::DebugBounds)
.with(Rotator)
// OBB
.spawn(PbrBundle {
.insert(Bounded::<aabb::AxisAlignedBB>::default())
.insert(debug::DebugBounds)
.insert(Rotator);
// OBB
commands
.spawn_bundle(PbrBundle {
mesh: asset_server.get_handle(mesh_path),
material: materials.add(Color::rgb(1.0, 1.0, 1.0).into()),
transform: Transform::from_translation(Vec3::new(0.0, 0.0, 0.0)),
..Default::default()
})
.with(Bounded::<obb::OrientedBB>::default())
.with(debug::DebugBounds)
.with(Rotator)
// Sphere
.spawn(PbrBundle {
.insert(Bounded::<obb::OrientedBB>::default())
.insert(debug::DebugBounds)
.insert(Rotator);
// Sphere
commands
.spawn_bundle(PbrBundle {
mesh: asset_server.get_handle(mesh_path),
material: materials.add(Color::rgb(1.0, 1.0, 1.0).into()),
transform: Transform::from_translation(Vec3::new(1.0, 0.0, 0.0)),
..Default::default()
})
.with(Bounded::<sphere::BSphere>::default())
.with(debug::DebugBounds)
.with(Rotator)
// Light
.spawn(LightBundle {
transform: Transform::from_translation(Vec3::new(4.0, 8.0, 4.0)),
..Default::default()
});
.insert(Bounded::<sphere::BSphere>::default())
.insert(debug::DebugBounds)
.insert(Rotator);
// Light
commands.spawn_bundle(LightBundle {
transform: Transform::from_translation(Vec3::new(4.0, 8.0, 4.0)),
..Default::default()
});
}

/// Rotate the meshes to demonstrate how the bounding volumes update
Expand Down
9 changes: 4 additions & 5 deletions src/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,18 @@ pub fn update_debug_meshes<T>(
// if the entity had a child, we don't need to create a new one
if !updated_existing_child {
let mesh_handle = meshes.add(bound_vol.new_debug_mesh(transform));
commands.set_current_entity(entity);
commands.with_children(|parent| {
commands.entity(entity).with_children(|parent| {
parent
.spawn(PbrBundle {
.spawn_bundle(PbrBundle {
mesh: mesh_handle,
material: materials.add(StandardMaterial {
albedo: Color::rgb(0.0, 1.0, 0.0),
base_color: Color::rgb(0.0, 1.0, 0.0),
unlit: true,
..Default::default()
}),
..Default::default()
})
.with(DebugBoundsMesh);
.insert(DebugBoundsMesh);
});
}
}
Expand Down
7 changes: 4 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,12 @@ pub fn spawn<T: 'static + BoundingVolume + Send + Sync + Debug>(
) {
for (handle, transform, entity) in query.iter() {
if let Some(mesh) = meshes.get(handle) {
commands.set_current_entity(entity);
let new_bound = T::new(mesh, transform);
info!("New bounding volume generated: {:?}", new_bound);
commands.with(new_bound);
commands.remove::<Bounded<T>>(entity);
commands
.entity(entity)
.insert(new_bound)
.remove::<Bounded<T>>();
}
}
}
Expand Down

0 comments on commit 5f30c9e

Please sign in to comment.