use std::rc::Rc;
use crate::basic_types::{IDCounter, ID};
use super::{material::Material, mesh::Mesh};
static ID_COUNTER: IDCounter = IDCounter::new();
pub struct ShapePart {
mesh: Rc<Mesh>,
material: Rc<Material>,
}
impl ShapePart {
pub fn new(mesh: Rc<Mesh>, material: Rc<Material>) -> Self {
Self { mesh, material }
}
pub fn get_mesh(&self) -> Rc<Mesh> {
self.mesh.clone()
}
pub fn get_material(&self) -> Rc<Material> {
self.material.clone()
}
}
pub struct Shape {
id: ID,
parts: Vec<ShapePart>,
}
impl Shape {
pub fn new() -> Self {
let id = ID_COUNTER.gen();
Self {
id,
parts: Vec::new(),
}
}
#[inline]
pub fn get_id(&self) -> ID {
self.id
}
pub fn add_part(&mut self, part: ShapePart) {
self.parts.push(part);
}
pub fn get_parts(&self) -> &[ShapePart] {
&self.parts
}
}
impl PartialEq for Shape {
fn eq(&self, other: &Self) -> bool {
self.id == other.id
}
}
impl Eq for Shape {}