komadori / bevy_mod_outline

Apache License 2.0
123 stars 10 forks source link

Outline renders only for one of the same skinned meshes #39

Closed barsoosayque closed 3 months ago

barsoosayque commented 3 months ago

If there are multiple skinned meshes with animation (sharing the same Handle<Mesh>), and I put OutlineBundle on them, only one will have its outline rendered. I assume https://github.com/komadori/bevy_mod_outline/commit/8e7bbdb0807e1b63ffe1961600707d72a7535946 doesn't count for skinned meshes somehow, because I tested it both on shapes and animation_fox examples, and only the latest reproduced this issue.

image

Repro For reproduction, please use this patch for [`examples/animated_fox.rs`](https://github.com/komadori/bevy_mod_outline/blob/master/examples/animated_fox.rs) ```diff --- a/examples/animated_fox.rs +++ b/examples/animated_fox.rs @@ -64,6 +64,8 @@ fn setup( commands .spawn(SceneBundle { scene: asset_server.load("Fox.glb#Scene0"), + transform: Transform::from_translation(Vec3::new(-5.0, 0.0, 0.0)) + .with_scale(Vec3::splat(0.1)), ..default() }) .insert(OutlineBundle { @@ -75,6 +77,22 @@ fn setup( ..default() }) .insert(AsyncSceneInheritOutline); + commands + .spawn(SceneBundle { + scene: asset_server.load("Fox.glb#Scene0"), + transform: Transform::from_translation(Vec3::new(5.0, 0.0, 0.0)) + .with_scale(Vec3::splat(0.1)), + ..default() + }) + .insert(OutlineBundle { + outline: OutlineVolume { + visible: true, + width: 3.0, + colour: Color::srgb(0.0, 1.0, 0.0), + }, + ..default() + }) + .insert(AsyncSceneInheritOutline); } // Once the scene is loaded, start the animation ```
komadori commented 3 months ago

Bevy doesn't support automatically batching skinned and morphed meshes. Hence, there is system inside Bevy which adds the NoAutomaticBatching component to entities with such meshes. Otherwise, each element in the batch would use the data from the first element and, in the case of skinning at least, render on top of each other. The bug here is that bevy_mod_outline didn't respect the NoAutomaticBatching component.

Fixed in 185c50d0731911d5c5288acae2230e6530a243f4. I'll make a new minor release shortly.

komadori commented 3 months ago

Fix released in 0.8.1.