gameobjects
This commit is contained in:
@@ -31,6 +31,7 @@ use line_vs::ty::LinePushConstants;
|
||||
use vs::ty::PushConstants;
|
||||
|
||||
use crate::mesh::CPUMesh;
|
||||
use crate::gameobject::{GameObject, GameObjectHandle};
|
||||
|
||||
const VALIDATION_LAYERS: &[&str] = &[
|
||||
"VK_LAYER_LUNARG_standard_validation"
|
||||
@@ -62,13 +63,6 @@ pub struct Mesh {
|
||||
index_buffer: Arc<CpuAccessibleBuffer<[u32]>>,
|
||||
}
|
||||
|
||||
pub struct GameObject {
|
||||
pub mesh_index: usize,
|
||||
pub texture_index: usize,
|
||||
pub model_matrix: Matrix4<f32>,
|
||||
}
|
||||
|
||||
pub(crate) type GameObjectHandle = usize;
|
||||
pub(crate) type MeshHandle = usize;
|
||||
|
||||
pub struct GameData {
|
||||
@@ -457,9 +451,11 @@ impl VulkanRenderer {
|
||||
self.game_data.textures.push(image_view);
|
||||
}
|
||||
|
||||
pub fn add_game_object(self: &mut Self, game_object: GameObject) -> usize {
|
||||
pub fn add_game_object(self: &mut Self, game_object: GameObject) -> GameObjectHandle {
|
||||
self.game_data.game_objects.push(game_object);
|
||||
self.game_data.game_objects.len() - 1
|
||||
GameObjectHandle {
|
||||
object_index: self.game_data.game_objects.len() - 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -573,9 +569,3 @@ fn create_pipeline<V: vulkano::pipeline::vertex::Vertex>(device: Arc<Device>, re
|
||||
|
||||
return Some(pipeline);
|
||||
}
|
||||
|
||||
impl GameObject {
|
||||
pub fn new(mesh: MeshHandle, texture_index: usize) -> GameObject {
|
||||
GameObject { mesh_index: mesh, texture_index, model_matrix: Matrix4::identity() }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user