45 lines
936 B
Rust
45 lines
936 B
Rust
|
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 ObjectLocation {
|
||
|
pub xpos: f32,
|
||
|
pub ypos: f32,
|
||
|
pub zpos: f32,
|
||
|
pub angle: f32,
|
||
|
pub size: f32,
|
||
|
|
||
|
pub _padding: [f32; 3],
|
||
|
}
|
||
|
|
||
|
impl ObjectLocation {
|
||
|
pub const SIZE: u64 = mem::size_of::<Self>() as wgpu::BufferAddress;
|
||
|
}
|
||
|
|
||
|
#[derive(Debug, Copy, Clone)]
|
||
|
pub struct ObjectLocationArray {
|
||
|
pub data: [ObjectLocation; OBJECT_SPRITE_INSTANCE_LIMIT as usize],
|
||
|
}
|
||
|
|
||
|
unsafe impl Pod for ObjectLocationArray {}
|
||
|
unsafe impl Zeroable for ObjectLocationArray {
|
||
|
fn zeroed() -> Self {
|
||
|
Self {
|
||
|
data: [ObjectLocation::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::<Self>() as wgpu::BufferAddress;
|
||
|
}
|