Fix axis layout and implement click raytracing
This commit is contained in:
@@ -57,7 +57,7 @@ impl GameObject {
|
||||
pub fn get_push_constants(&self) -> vs::ty::PushConstants {
|
||||
vs::ty::PushConstants {
|
||||
model: self.get_model_matrix().into(),
|
||||
is_selected: if self.is_selected { 0 } else { 1 },
|
||||
is_selected: if self.is_selected { 1 } else { 0 },
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,6 @@ pub struct Mesh {
|
||||
pub vertex_buffer: Arc<CpuAccessibleBuffer<[Vertex]>>,
|
||||
pub index_buffer: Arc<CpuAccessibleBuffer<[u32]>>,
|
||||
pub original_path: String,
|
||||
pub collision_mesh: mgf::Mesh,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
@@ -245,7 +244,7 @@ impl VulkanRenderer {
|
||||
|
||||
let pipelines: Vec<Box<dyn Drawcall>> = vec![
|
||||
Box::new(DefaultShader::new(device.clone(), render_pass.clone())),
|
||||
Box::new(LineShader::new(device.clone(), render_pass.clone(), line_vertex_buffer.clone())),
|
||||
// Box::new(LineShader::new(device.clone(), render_pass.clone(), line_vertex_buffer.clone())),
|
||||
];
|
||||
|
||||
// Dynamic viewports allow us to recreate just the viewport when the window is resized
|
||||
@@ -344,7 +343,7 @@ impl VulkanRenderer {
|
||||
|
||||
self.pipelines = vec![
|
||||
Box::new(DefaultShader::new(self.device.clone(), self.render_pass.clone())),
|
||||
Box::new(LineShader::new(self.device.clone(), self.render_pass.clone(), self.line_vertex_buffer.clone())),
|
||||
// Box::new(LineShader::new(self.device.clone(), self.render_pass.clone(), self.line_vertex_buffer.clone())),
|
||||
];
|
||||
|
||||
self.swapchain = new_swapchain;
|
||||
@@ -413,18 +412,18 @@ impl VulkanRenderer {
|
||||
}
|
||||
|
||||
pub fn upload_mesh(self: &mut Self, mesh: CPUMesh, original_path: String) -> usize {
|
||||
let mut collision_mesh = mgf::Mesh::new();
|
||||
mesh.vertices.iter().for_each(|v| {
|
||||
collision_mesh.push_vert(v.position.into());
|
||||
}); // TODO: convert vert pos to world space
|
||||
for i in (0..mesh.indices.len()).step_by(3) {
|
||||
collision_mesh.push_face((mesh.indices[i] as usize, mesh.indices[i + 1] as usize, mesh.indices[i + 2] as usize));
|
||||
}
|
||||
// let mut collision_mesh = mgf::Mesh::new();
|
||||
// mesh.vertices.iter().for_each(|v| {
|
||||
// collision_mesh.push_vert(v.position.into());
|
||||
// }); // TODO: convert vert pos to world space
|
||||
// for i in (0..mesh.indices.len()).step_by(3) {
|
||||
// collision_mesh.push_face((mesh.indices[i] as usize, mesh.indices[i + 1] as usize, mesh.indices[i + 2] as usize));
|
||||
// }
|
||||
|
||||
let vertex_buffer = CpuAccessibleBuffer::from_iter(self.device.clone(), BufferUsage::vertex_buffer(), false, mesh.vertices.into_iter()).unwrap();
|
||||
let index_buffer = CpuAccessibleBuffer::from_iter(self.device.clone(), BufferUsage::index_buffer(), false, mesh.indices.into_iter()).unwrap();
|
||||
|
||||
self.game_data.meshes.push(Mesh { vertex_buffer, index_buffer, original_path, collision_mesh });
|
||||
self.game_data.meshes.push(Mesh { vertex_buffer, index_buffer, original_path });
|
||||
self.game_data.meshes.len() - 1
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user