|
|
|
use wgpu::{TextureView, Buffer, BindGroup};
|
|
|
|
use std::sync::Arc;
|
|
|
|
use rapier3d::dynamics::{RigidBody, RigidBodyHandle};
|
|
|
|
use rapier3d::geometry::ColliderHandle;
|
|
|
|
use rapier3d::geometry::Collider as r3dCollider;
|
|
|
|
use std::time::{Duration, Instant};
|
|
|
|
use cgmath::Deg;
|
|
|
|
|
|
|
|
// a component is any type that is 'static, sized, send and sync
|
|
|
|
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq)]
|
|
|
|
pub struct LoopState {
|
|
|
|
pub delta_time: Duration,
|
|
|
|
pub start_time: Instant,
|
|
|
|
pub step_size: f32,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq)]
|
|
|
|
pub struct Position {
|
|
|
|
pub x: f32,
|
|
|
|
pub y: f32,
|
|
|
|
pub z: f32,
|
|
|
|
pub rot: cgmath::Euler<Deg<f32>>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq)]
|
|
|
|
pub struct Color {
|
|
|
|
pub r: f32,
|
|
|
|
pub g: f32,
|
|
|
|
pub b: f32,
|
|
|
|
pub a: f32,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq)]
|
|
|
|
pub struct Velocity {
|
|
|
|
pub dx: f32,
|
|
|
|
pub dy: f32,
|
|
|
|
pub rs: f32,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Default, PartialEq, Eq, Hash, Copy, Debug)]
|
|
|
|
pub struct RangeCopy<Idx> {
|
|
|
|
pub start: Idx,
|
|
|
|
pub end: Idx,
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Debug)]
|
|
|
|
pub struct Mesh {
|
|
|
|
pub index_buffer: Arc<Buffer>,
|
|
|
|
pub index_count: usize,
|
|
|
|
pub index_format: wgpu::IndexFormat,
|
|
|
|
pub vertex_buffer: Arc<Buffer>,
|
|
|
|
pub uniform_buffer: Arc<Buffer>,
|
|
|
|
pub bind_group: Arc<BindGroup>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Debug)]
|
|
|
|
pub struct Physics {
|
|
|
|
pub rigid_body: RigidBody,
|
|
|
|
pub rigid_body_handle: Option<RigidBodyHandle>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone)]
|
|
|
|
pub struct Collider {
|
|
|
|
pub collider: r3dCollider,
|
|
|
|
pub collider_handle: Option<ColliderHandle>,
|
|
|
|
}
|