removed TempData struct

Objects
Milk.H 2023-03-30 16:57:35 +02:00
parent 397a86043a
commit 37b38694c5
No known key found for this signature in database
GPG Key ID: 3D9DAE46AAC37BD8
2 changed files with 6 additions and 77 deletions

View File

@ -11,7 +11,6 @@ mod info;
pub enum dEvent
{
loadModel(i32),
setTest(f32, i32),
getObj(i32),
addWindow(OpenWindows),
removeWindow(OpenWindows),
@ -23,7 +22,6 @@ pub enum dEvent
pub enum Callback
{
ModelInfo(info::ModelI),
TestWind(info::testI),
ObjectInfo(info::ObjectI),
MainMenu,
}
@ -31,7 +29,6 @@ pub enum Callback
#[derive(Clone, PartialEq)]
pub enum OpenWindows {
ModelInfo,
TestWind,
MainMenu,
Object(i32),
}
@ -110,8 +107,6 @@ impl Debug {
match call {
Callback::ModelInfo(a) =>
ret.append(&mut Debug::displayModel(ui, &a)),
Callback::TestWind(mut a) =>
ret.append(&mut Debug::displayTest(ui, &mut a)),
Callback::MainMenu =>
ret.append(&mut Debug::displayMain(ui)),
Callback::ObjectInfo(mut a) =>
@ -170,28 +165,6 @@ impl Debug {
}
}
fn displayTest(ui: &mut imgui::Ui, testI: &mut info::testI) -> Vec<dEvent>
{
let mut ret = Vec::new();
let mut selectedModel = testI.selectedModel;
let mut spinSpeed = testI.spinSpeed;
ui.window("POLY I WILL FUCKING")
.always_auto_resize(true)
.build(|| {
ui.text("you serve no purpose in life");
ui.text("Your Purpose in life is to suck my dick");
ui.slider("The Spin Speed", 0.1, 10.0, &mut spinSpeed);
if ui
.button("Close") {
ret.push(dEvent::removeWindow(OpenWindows::TestWind));
}
if ui.list_box("Select Model to Load", &mut selectedModel, &MODELS, 5) {
ret.push(dEvent::loadModel(selectedModel));
}
});
ret.push(dEvent::setTest(spinSpeed, selectedModel));
ret
}
fn displayModel(ui: &mut imgui::Ui ,model: &info::ModelI) -> Vec<dEvent>
{
@ -227,9 +200,6 @@ impl Debug {
if ui.button("Open the Model Info") {
ret.push(dEvent::addWindow(OpenWindows::ModelInfo))
}
if ui.button("Open the Test Modifier"){
ret.push(dEvent::addWindow(OpenWindows::TestWind))
}
if ui.button("Open Object Modifier") {
ret.push(dEvent::addWindow(OpenWindows::Object(0)))
}
@ -273,14 +243,6 @@ pub fn ModelInfo(model: &model::Model) -> Callback
})
}
pub fn TestWind(spinSpeed: f32, selectedModel: i32) -> Callback
{
Callback::TestWind(info::testI {
spinSpeed,
selectedModel,
})
}
use crate::scene::objects::Player;
pub fn ObjectInfo(object: &Player) -> Callback

View File

@ -23,17 +23,6 @@ const SCR_HEIGHT: u32 = 900;
const MODELS: [&str; 3]= ["resources/models/TestCarModel/CarW4.obj", "resources/models/TestCarModel/CarW1.obj",
"resources/models/TestCarModel/CarW0.obj"];
/// XXX this is temporary, thus the name
pub struct tempData {
pub projection: Matrix4<f32>,
pub spinSpeed: f32,
pub current_rad: f32,
pub currentFrame: f32,
pub deltaTime: f32,
pub lastFrame: f32,
DebugMode: bool,
selectedModel: i32
}
use crate::debug::Debug;
pub enum SceneEnum {
@ -50,7 +39,7 @@ pub struct Scene {
debug: Debug,
shaders: Vec<Rc<shader>>,
time: std::time::Instant,
tempData: tempData,
DebugMode: bool,
}
impl Scene{
@ -68,18 +57,6 @@ impl Scene{
..Camera::default()
};
let tempData = tempData {
projection: perspective(Deg(45.0), 1600.0/ 900.0, 0.1, 100.0),
spinSpeed: 1.0,
current_rad: 1.0,
currentFrame: 0.0,
deltaTime: 0.0,
lastFrame: 0.0,
DebugMode: false,
selectedModel: 0,
};
let debug = Debug::new(gl.clone());
Scene{
gl,
@ -88,16 +65,14 @@ impl Scene{
debug,
shaders: vec![shader],
time,
tempData,
DebugMode: false
}
}
pub fn update(&mut self ,events_loop: &mut sdl2::EventPump, window: &sdl2::video::Window) -> SceneEnum
{
self.tempData.currentFrame = self.time.elapsed().as_secs_f32();
self.tempData.deltaTime = self.tempData.currentFrame - self.tempData.lastFrame;
self.tempData.lastFrame = self.tempData.currentFrame;
let mut ret = SceneEnum::Resume;
unsafe {
self.gl.enable(glow::DEPTH_TEST);
self.gl.clear(glow::COLOR_BUFFER_BIT | glow::DEPTH_BUFFER_BIT);
@ -122,12 +97,12 @@ impl Scene{
self.Car.Draw(&self.shaders[0], &self.camera);
if self.tempData.DebugMode{
if self.DebugMode{
self.handleDebug(events_loop, window, &mut ret)
}
for event in events_loop.poll_iter() {
if self.tempData.DebugMode {
if self.DebugMode {
self.debug.handle(&event);
}
match event {
@ -138,7 +113,7 @@ impl Scene{
Event::KeyDown {keycode: Some(Keycode::P), ..} => {
},
Event::KeyDown {keycode: Some(Keycode::Q), ..} => {
self.tempData.DebugMode = !self.tempData.DebugMode
self.DebugMode = !self.DebugMode
},
Event::KeyDown {keycode: Some(Keycode::W), ..} => {
self.Car.forward();
@ -148,9 +123,6 @@ impl Scene{
}
Event::KeyDown {keycode: Some(Keycode::M), ..} => {
self.debug.addWindow(debug::OpenWindows::ModelInfo)
},
Event::KeyDown {keycode: Some(Keycode::T), ..} => {
self.camera.ProcessKeyboard(Camera_Movement::FORWARD, self.tempData.deltaTime);
},
_ => {}
}
@ -168,7 +140,6 @@ impl Scene{
{
match window {
debug::OpenWindows::ModelInfo => Callbacks.push(debug::ModelInfo(&self.Car.Model)),
debug::OpenWindows::TestWind => Callbacks.push(debug::TestWind(self.tempData.spinSpeed, self.tempData.selectedModel)),
debug::OpenWindows::MainMenu => Callbacks.push(debug::Callback::MainMenu),
debug::OpenWindows::Object(a) => Callbacks.push(debug::ObjectInfo(&self.Car)),
@ -183,10 +154,6 @@ impl Scene{
{
dEvent::exit => *ret = SceneEnum::Exit,
dEvent::loadModel(i) => self.Car.Model = Model::new(MODELS[i as usize], Arc::clone(&self.gl)),
dEvent::setTest(a, b) => {
self.tempData.spinSpeed = a;
self.tempData.selectedModel = b;
},
dEvent::addWindow(a) => self.debug.addWindow(a),
dEvent::removeWindow(a) => self.debug.removeWindow(a),
dEvent::setObj(p) =>