Replace Bytes with Byteable for TextureAtlasSprite (#874)

Replace Bytes with Byteable for TextureAtlasSprite
This commit is contained in:
Joshua J. Bouw 2020-11-22 02:48:10 +07:00 committed by GitHub
parent 4fecb899aa
commit b4a864ba5a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,6 +1,6 @@
use crate::Rect;
use bevy_asset::Handle;
use bevy_core::Bytes;
use bevy_core::Byteable;
use bevy_math::Vec2;
use bevy_render::{
color::Color,
@ -25,9 +25,7 @@ pub struct TextureAtlas {
pub texture_handles: Option<HashMap<Handle<Texture>, usize>>,
}
// NOTE: cannot do `unsafe impl Byteable` here because Vec3 takes up the space of a Vec4. If/when glam changes this we can swap out
// Bytes for Byteable as a micro-optimization. https://github.com/bitshifter/glam-rs/issues/36
#[derive(Bytes, Debug, RenderResources, RenderResource)]
#[derive(Debug, RenderResources, RenderResource)]
#[render_resources(from_self)]
pub struct TextureAtlasSprite {
pub color: Color,
@ -43,6 +41,8 @@ impl Default for TextureAtlasSprite {
}
}
unsafe impl Byteable for TextureAtlasSprite {}
impl TextureAtlasSprite {
pub fn new(index: u32) -> TextureAtlasSprite {
Self {