use bytemuck::{Pod, Zeroable}; use galactica_constants::OBJECT_SPRITE_INSTANCE_LIMIT; use std::mem; use wgpu; #[repr(C)] #[derive(Debug, Copy, Clone, Pod, Zeroable, Default)] pub struct ObjectData { pub xpos: f32, pub ypos: f32, pub zpos: f32, pub angle: f32, pub size: f32, /// Index of parent object pub parent: u32, /// 1 if has parent, 0 if not pub is_child: u32, pub _padding: [f32; 1], } impl ObjectData { pub const SIZE: u64 = mem::size_of::() as wgpu::BufferAddress; } #[derive(Debug, Copy, Clone)] pub struct ObjectLocationArray { pub data: [ObjectData; OBJECT_SPRITE_INSTANCE_LIMIT as usize], } unsafe impl Pod for ObjectLocationArray {} unsafe impl Zeroable for ObjectLocationArray { fn zeroed() -> Self { Self { data: [ObjectData::zeroed(); OBJECT_SPRITE_INSTANCE_LIMIT as usize], } } } impl Default for ObjectLocationArray { fn default() -> Self { Self::zeroed() } } impl ObjectLocationArray { pub const SIZE: u64 = mem::size_of::() as wgpu::BufferAddress; }