Skip to content

Commit

Permalink
Add instancing.
Browse files Browse the repository at this point in the history
  • Loading branch information
tychedelia committed May 6, 2024
1 parent c936252 commit b65ca6a
Show file tree
Hide file tree
Showing 10 changed files with 857 additions and 92 deletions.
423 changes: 395 additions & 28 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ members = [
"generative_design",
# "guide/book_tests",
"nannou",
# "nannou_audio",
"nannou_audio",
"nannou_core",
# "nannou_egui",
# "nannou_egui_demo_app",
Expand Down
4 changes: 3 additions & 1 deletion bevy_nannou_draw/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ bevy = { workspace = true }
lyon = "0.17"
nannou_core = { path = "../nannou_core" }
rusttype = { version = "0.8", features = ["gpu_cache"] }
num-traits = "0.2"
num-traits = "0.2"
bytemuck = "1.15.0"
rayon = "1.10"
10 changes: 5 additions & 5 deletions bevy_nannou_draw/src/draw/drawing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub struct Drawing<'a, T, M>
// The `Draw` instance used to create this drawing.
draw: DrawRef<'a, M>,
// The draw command index of the primitive being drawn.
index: usize,
pub(crate) index: usize,
// Whether or not the **Drawing** should attempt to finish the drawing on drop.
finish_on_drop: bool,
// The node type currently being drawn.
Expand Down Expand Up @@ -120,7 +120,7 @@ where
// If we are "Owned", that means we mutated our material and so need to
// spawn a new entity just for this primitive.
DrawRef::Owned(draw) => {
let material = draw.material.read().unwrap().clone();
let material = draw.material.clone();
state.draw_commands.push(Some(Box::new(move |world: &mut World| {
let mut materials = world.resource_mut::<Assets<M>>();
let material = materials.add(material);
Expand Down Expand Up @@ -171,7 +171,7 @@ where
} = self;

Drawing::<'a, T, ExtendedMaterial<StandardMaterial, NannouMaterial<"", FS>>> {
draw: DrawRef::Owned(draw.material()),
draw: DrawRef::Owned(draw.material(Default::default())),
index,
finish_on_drop: true,
_ty: Default::default(),
Expand All @@ -184,11 +184,11 @@ where
{
self.finish_on_drop = false;
let Drawing { ref draw, index, .. } = self;
let material = map(self.draw.material.read().unwrap().clone());
let material = map(self.draw.material.clone());
let draw = Draw {
state: draw.state.clone(),
context: draw.context.clone(),
material: Arc::new(RwLock::new(Cd::new(material))),
material,
window: draw.window,
};
Drawing {
Expand Down
Loading

0 comments on commit b65ca6a

Please sign in to comment.