🚨 fix cargo check lints

main
_ 2022-01-09 17:15:26 +00:00
parent e96474b73a
commit 5509aece8f
4 changed files with 28 additions and 64 deletions

View File

@ -4,7 +4,7 @@ use std::{
use glam::{ use glam::{
Quat, Quat,
Vec4, // Vec4,
}; };
use opengl_rust::{ use opengl_rust::{
@ -15,18 +15,13 @@ use opengl_rust::{
Pass, Pass,
}, },
renderable_model::{ renderable_model::{
attributes,
RenderableModel, RenderableModel,
attributes,
}, },
shader_closure::ShaderLookup, shader_closure::ShaderLookup,
texture::Texture, texture::Texture,
}; };
use crate::{
GameState,
TriangleStream,
};
mod uniforms { mod uniforms {
use iota::iota; use iota::iota;
iota! { iota! {
@ -47,12 +42,12 @@ pub struct Graphics {
shaders: Vec <ShaderClosure>, shaders: Vec <ShaderClosure>,
shader_lookup: HashMap <u32, usize>, shader_lookup: HashMap <u32, usize>,
mesh_cube: RenderableModel, // mesh_cube: RenderableModel,
mesh_protag_kun: RenderableModel, mesh_protag_kun: RenderableModel,
mesh_sky: RenderableModel, mesh_sky: RenderableModel,
mesh_sphere: RenderableModel, mesh_sphere: RenderableModel,
text_stream: TriangleStream, // text_stream: TriangleStream,
texture_crate: Texture, texture_crate: Texture,
texture_earth: Texture, texture_earth: Texture,
@ -100,7 +95,7 @@ impl Graphics {
}) })
.collect (); .collect ();
let mesh_cube = renderable_from_iqm_file ("cube.iqm"); // let mesh_cube = renderable_from_iqm_file ("cube.iqm");
let mesh_protag_kun = renderable_from_iqm_file ("protag-kun.iqm"); let mesh_protag_kun = renderable_from_iqm_file ("protag-kun.iqm");
let mesh_sky = renderable_from_iqm_file ("sky-sphere.iqm"); let mesh_sky = renderable_from_iqm_file ("sky-sphere.iqm");
let mesh_sphere = renderable_from_iqm_file ("sphere.iqm"); let mesh_sphere = renderable_from_iqm_file ("sphere.iqm");
@ -125,7 +120,7 @@ impl Graphics {
.depth_mask (1) .depth_mask (1)
.clone (), .clone (),
]; ];
/*
let text_stream = TriangleStream { let text_stream = TriangleStream {
verts: gpu_buffers::VertexBuffer::streaming (4 * 5 * 6 * 1024), verts: gpu_buffers::VertexBuffer::streaming (4 * 5 * 6 * 1024),
indices: { indices: {
@ -140,7 +135,7 @@ impl Graphics {
gpu_buffers::IndexBuffer::from_slice_u32 (&v) gpu_buffers::IndexBuffer::from_slice_u32 (&v)
} }
}; };
*/
let shader_lookup = HashMap::from_iter (shaders.iter ().enumerate () let shader_lookup = HashMap::from_iter (shaders.iter ().enumerate ()
.map (|(i, s)| { .map (|(i, s)| {
(s.get_id (), i) (s.get_id (), i)
@ -154,14 +149,14 @@ impl Graphics {
}); });
Graphics { Graphics {
mesh_cube, // mesh_cube,
mesh_protag_kun, mesh_protag_kun,
mesh_sky, mesh_sky,
mesh_sphere, mesh_sphere,
passes, passes,
shader_lookup, shader_lookup,
shaders, shaders,
text_stream, // text_stream,
texture_crate: Texture::from_file ("crate.png"), texture_crate: Texture::from_file ("crate.png"),
texture_earth: Texture::from_file ("earth.png"), texture_earth: Texture::from_file ("earth.png"),
texture_sky: Texture::from_file ("sky.png"), texture_sky: Texture::from_file ("sky.png"),
@ -178,9 +173,9 @@ impl Graphics {
level: &crate::LoadedLevel, level: &crate::LoadedLevel,
camera: &crate::Camera, camera: &crate::Camera,
) { ) {
use serde::Deserialize; // use serde::Deserialize;
use uniforms as u; use uniforms as u;
/*
#[derive (Default, Deserialize)] #[derive (Default, Deserialize)]
struct Config { struct Config {
camera: CameraCfg, camera: CameraCfg,
@ -193,7 +188,7 @@ impl Graphics {
#[serde(default)] #[serde(default)]
translate_mix: f32, translate_mix: f32,
} }
/*
let cfg: Option <Config> = std::fs::read_to_string ("config.json").ok () let cfg: Option <Config> = std::fs::read_to_string ("config.json").ok ()
.map (|s| serde_json::from_str (s.as_str ()).ok ()) .map (|s| serde_json::from_str (s.as_str ()).ok ())
.flatten (); .flatten ();
@ -227,8 +222,6 @@ impl Graphics {
let view_mat = proj_mat * view_mat; let view_mat = proj_mat * view_mat;
let world_model_mat = Mat4::IDENTITY;
self.passes [0].with (gl_state, || { self.passes [0].with (gl_state, || {
glezz::clear_color (109f32 / 255.0, 194f32 / 255.0, 202f32 / 255.0, 1.0f32); glezz::clear_color (109f32 / 255.0, 194f32 / 255.0, 202f32 / 255.0, 1.0f32);
glezz::clear (gl::COLOR_BUFFER_BIT | gl::DEPTH_BUFFER_BIT | gl::STENCIL_BUFFER_BIT); glezz::clear (gl::COLOR_BUFFER_BIT | gl::DEPTH_BUFFER_BIT | gl::STENCIL_BUFFER_BIT);

View File

@ -14,7 +14,6 @@ impl LoadedLevel {
pub fn from_path (path: &str) -> Result <Self> { pub fn from_path (path: &str) -> Result <Self> {
use gltf::{ use gltf::{
Semantic, Semantic,
scene::Transform,
}; };
let (level, buffers, _) = gltf::import (path)?; let (level, buffers, _) = gltf::import (path)?;
@ -35,11 +34,11 @@ impl LoadedLevel {
let (translation, _, _) = node.transform ().decomposed (); let (translation, _, _) = node.transform ().decomposed ();
player_spawn = Some (Vec3::from (translation)); player_spawn = Some (Vec3::from (translation));
} }
else if let Some (camera) = node.camera () { else if let Some (_camera) = node.camera () {
} }
else if let Some (mesh) = node.mesh () { else if let Some (mesh) = node.mesh () {
for (i, prim) in mesh.primitives ().enumerate () { for (_i, prim) in mesh.primitives ().enumerate () {
let positions = match prim.get (&Semantic::Positions) { let positions = match prim.get (&Semantic::Positions) {
None => continue, None => continue,
Some (x) => x, Some (x) => x,
@ -52,15 +51,15 @@ impl LoadedLevel {
None => continue, None => continue,
Some (x) => x, Some (x) => x,
}; };
let pos_view = match positions.view () { let _pos_view = match positions.view () {
None => continue, None => continue,
Some (x) => x, Some (x) => x,
}; };
let norm_view = match normals.view () { let _norm_view = match normals.view () {
None => continue, None => continue,
Some (x) => x, Some (x) => x,
}; };
let indices_view = match indices.view () { let _indices_view = match indices.view () {
None => continue, None => continue,
Some (x) => x, Some (x) => x,
}; };

View File

@ -1,21 +1,12 @@
use std::{ use std::{
collections::HashMap,
time::Instant, time::Instant,
}; };
use anyhow::Result; use anyhow::Result;
use maplit::hashmap;
use opengl_rust::{ use opengl_rust::{
prelude::*, prelude::*,
gl_state::*,
physics::PhysicsBody, physics::PhysicsBody,
renderable_model::{
attributes,
RenderableModel,
},
shader_closure::ShaderLookup,
texture::Texture,
}; };
mod graphics; mod graphics;
@ -31,12 +22,12 @@ pub struct GameState {
static_level: StaticLevel, static_level: StaticLevel,
} }
struct StaticLevel { pub struct StaticLevel {
tris: Vec <opengl_rust::physics::Triangle>, tris: Vec <opengl_rust::physics::Triangle>,
} }
#[derive (Clone, Default)] #[derive (Clone, Default)]
struct LogicState { pub struct LogicState {
player: PhysicsBody, player: PhysicsBody,
player_jump_vec: Option <Vec3>, player_jump_vec: Option <Vec3>,
} }
@ -199,7 +190,7 @@ async fn main () -> Result <()> {
let mut phys_tris: Vec <opengl_rust::physics::Triangle> = Vec::new (); let mut phys_tris: Vec <opengl_rust::physics::Triangle> = Vec::new ();
for node in scene.nodes () { for node in scene.nodes () {
if let Some (c) = node.camera () { if node.camera ().is_some () {
camera = Some (Camera { camera = Some (Camera {
transform: node.transform ().clone (), transform: node.transform ().clone (),
}); });
@ -409,34 +400,13 @@ async fn main () -> Result <()> {
Ok (()) Ok (())
} }
struct ShaderLocations { /*
attr_pos: u32,
attr_normal: u32,
attr_color: u32,
uni_mvp: i32,
}
impl ShaderLocations {
pub fn new (shader_program: &opengl_rust::shader::ShaderProgram) -> anyhow::Result <Self>
{
let attr = |name: &str| shader_program.get_attribute_location (&CString::new (name.as_bytes ())?).try_into ().context ("Attribute location negative");
let uni = |name: &str| shader_program.get_uniform_location (&CString::new (name.as_bytes ())?).try_into ().context ("Uniform location bad");
Ok (Self {
attr_pos: attr ("attr_pos")?,
attr_normal: attr ("attr_normal")?,
attr_color: attr ("attr_color")?,
uni_mvp: uni ("uni_mvp")?,
})
}
}
struct TriangleStream { struct TriangleStream {
pub verts: gpu_buffers::VertexBuffer, pub verts: gpu_buffers::VertexBuffer,
pub indices: gpu_buffers::IndexBuffer, pub indices: gpu_buffers::IndexBuffer,
} }
*/
struct Camera { pub struct Camera {
transform: gltf::scene::Transform, transform: gltf::scene::Transform,
} }

View File

@ -155,6 +155,8 @@ pub fn step (
} }
} }
let _ = t_remaining;
PhysicsResult { PhysicsResult {
body: PhysicsBody { body: PhysicsBody {
pos: old_pos, pos: old_pos,
@ -178,7 +180,7 @@ pub fn get_candidate (
radius, radius,
radius radius
)); ));
let v = p1 - p0; let _v = p1 - p0;
let mut candidate = Collision { let mut candidate = Collision {
t: 2.0, t: 2.0,
@ -358,12 +360,12 @@ pub fn get_candidate (
fn get_candidate_face (verts: &[Vec3], normal: Vec3, p0: Vec3, p1: Vec3, radius: f32) fn get_candidate_face (verts: &[Vec3], normal: Vec3, p0: Vec3, p1: Vec3, radius: f32)
-> Option <PrimCollision> -> Option <PrimCollision>
{ {
let radius3 = Vec3::from (( let _radius3 = Vec3::from ((
radius, radius,
radius, radius,
radius radius
)); ));
let v = p1 - p0; let _v = p1 - p0;
let distance_to_face0 = Vec3::dot (normal, p0 - verts [0]) - radius; let distance_to_face0 = Vec3::dot (normal, p0 - verts [0]) - radius;
let distance_to_face1 = Vec3::dot (normal, p1 - verts [0]) - radius; let distance_to_face1 = Vec3::dot (normal, p1 - verts [0]) - radius;