2024-01-05 19:56:26 -08:00
|
|
|
use bytemuck::{Pod, Zeroable};
|
2024-01-10 18:53:19 -08:00
|
|
|
use galactica_util::constants::OBJECT_SPRITE_INSTANCE_LIMIT;
|
2024-01-05 19:56:26 -08:00
|
|
|
use std::mem;
|
|
|
|
use wgpu;
|
|
|
|
|
|
|
|
#[repr(C)]
|
|
|
|
#[derive(Debug, Copy, Clone, Pod, Zeroable, Default)]
|
2024-01-06 14:02:50 -08:00
|
|
|
pub struct ObjectData {
|
2024-01-05 19:56:26 -08:00
|
|
|
pub xpos: f32,
|
|
|
|
pub ypos: f32,
|
|
|
|
pub zpos: f32,
|
|
|
|
pub angle: f32,
|
|
|
|
pub size: f32,
|
|
|
|
|
2024-01-06 14:02:50 -08:00
|
|
|
/// Index of parent object
|
|
|
|
pub parent: u32,
|
|
|
|
|
|
|
|
/// 1 if has parent, 0 if not
|
|
|
|
pub is_child: u32,
|
|
|
|
|
|
|
|
pub _padding: [f32; 1],
|
2024-01-05 19:56:26 -08:00
|
|
|
}
|
|
|
|
|
2024-01-06 14:02:50 -08:00
|
|
|
impl ObjectData {
|
2024-01-05 19:56:26 -08:00
|
|
|
pub const SIZE: u64 = mem::size_of::<Self>() as wgpu::BufferAddress;
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Copy, Clone)]
|
|
|
|
pub struct ObjectLocationArray {
|
2024-01-06 14:02:50 -08:00
|
|
|
pub data: [ObjectData; OBJECT_SPRITE_INSTANCE_LIMIT as usize],
|
2024-01-05 19:56:26 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
unsafe impl Pod for ObjectLocationArray {}
|
|
|
|
unsafe impl Zeroable for ObjectLocationArray {
|
|
|
|
fn zeroed() -> Self {
|
|
|
|
Self {
|
2024-01-06 14:02:50 -08:00
|
|
|
data: [ObjectData::zeroed(); OBJECT_SPRITE_INSTANCE_LIMIT as usize],
|
2024-01-05 19:56:26 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Default for ObjectLocationArray {
|
|
|
|
fn default() -> Self {
|
|
|
|
Self::zeroed()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl ObjectLocationArray {
|
|
|
|
pub const SIZE: u64 = mem::size_of::<Self>() as wgpu::BufferAddress;
|
|
|
|
}
|