Skip to content

Commit 0090b0f

Browse files
committed
Fix camera up verctor and scroll events
1 parent 2b00f1d commit 0090b0f

File tree

4 files changed

+40
-36
lines changed

4 files changed

+40
-36
lines changed

src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub use world::{Camera, Entity, World};
5252

5353
/// Window API and input events
5454
pub mod window;
55-
pub use window::event::{Button as ButtonEvent, Event};
55+
pub use window::event::{Button as ButtonEvent, Event, Modifiers, MouseScroll};
5656
pub use window::{Input, ReadInput, Window};
5757

5858
//pub use utils::{ Id };

src/tasks/scheduler.rs

+22-22
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ pub fn spawn<T: context::Context>(
145145
}
146146

147147
if restart_queue {
148-
log::debug!("restart queue(queue_executed: {}", queue_executed);
148+
// log::debug!("restart queue(queue_executed: {}", queue_executed);
149149
if queue_executed {
150150
let mut ctx = context_manager.lock().expect("Mutex to be locked");
151151
ctx.reset_data(tasks_graph_changed);
@@ -155,24 +155,24 @@ pub fn spawn<T: context::Context>(
155155

156156
let default_state = TypeId::of::<()>();
157157
let current_state = ctx.current_state();
158-
log::debug!("current state: {:?}", current_state);
158+
// log::debug!("current state: {:?}", current_state);
159159
if current_state != default_state {
160160
if let Some(tasks) = pool.select_for_state(&default_state) {
161161
for task in tasks.iter() {
162-
log::debug!(
163-
"tasks for default state: {:?}",
164-
pool.get(*task).and_then(|t| t.name())
165-
);
162+
// log::debug!(
163+
// "tasks for default state: {:?}",
164+
// pool.get(*task).and_then(|t| t.name())
165+
// );
166166
}
167167
queue.extend_from_slice(tasks);
168168
}
169169
}
170170
if let Some(tasks) = pool.select_for_state(&current_state) {
171171
for task in tasks.iter() {
172-
log::debug!(
173-
"tasks for current state: {:?}",
174-
pool.get(*task).and_then(|t| t.name())
175-
);
172+
// log::debug!(
173+
// "tasks for current state: {:?}",
174+
// pool.get(*task).and_then(|t| t.name())
175+
// );
176176
}
177177
queue.extend_from_slice(tasks);
178178
}
@@ -198,28 +198,28 @@ pub fn spawn<T: context::Context>(
198198
while index < stop_index {
199199
let task_id = queue[index];
200200
if let Some(mut task) = pool.take(&task_id) {
201-
log::debug!("task({}): begin control", task.name());
201+
// log::debug!("task({}): begin control", task.name());
202202
if !task.is_scheduled() {
203-
log::debug!("task({}): not scheduled yet", task.name());
203+
// log::debug!("task({}): not scheduled yet", task.name());
204204
if task.name() == "dotrix::window::input::ReadInput" {
205-
log::debug!(
206-
"task({}): not scheduled yet: {:?}",
207-
task.name(),
208-
task.dependencies()
209-
);
205+
// log::debug!(
206+
// "task({}): not scheduled yet: {:?}",
207+
// task.name(),
208+
// task.dependencies()
209+
// );
210210
}
211211
if let Some(dependencies_state) = context_manager
212212
.lock()
213213
.unwrap()
214214
.match_dependencies(task.dependencies())
215215
{
216-
log::debug!("task({}): to be scheduled", task.name());
216+
// log::debug!("task({}): to be scheduled", task.name());
217217
task.schedule_with(dependencies_state);
218218
} else {
219-
log::debug!(
220-
"task({}): dependencies are not sattisfied",
221-
task.name()
222-
);
219+
// log::debug!(
220+
// "task({}): dependencies are not sattisfied",
221+
// task.name()
222+
// );
223223
}
224224
}
225225

src/window.rs

+16-12
Original file line numberDiff line numberDiff line change
@@ -224,17 +224,21 @@ impl<T: Application> winit::application::ApplicationHandler for EventLoop<T> {
224224
self.task_manager.provide(input_event);
225225
}
226226
winit::event::WindowEvent::MouseWheel { delta, .. } => {
227-
let input_event = match delta {
228-
winit::event::MouseScrollDelta::LineDelta(x, y) => event::MouseScroll::Lines {
229-
horizontal: x,
230-
vertical: y,
231-
},
232-
winit::event::MouseScrollDelta::PixelDelta(position) => {
233-
event::MouseScroll::Pixels {
234-
horizontal: position.x,
235-
vertical: position.y,
227+
let input_event = event::Event::MouseScroll {
228+
delta: match delta {
229+
winit::event::MouseScrollDelta::LineDelta(x, y) => {
230+
event::MouseScroll::Lines {
231+
horizontal: x,
232+
vertical: y,
233+
}
236234
}
237-
}
235+
winit::event::MouseScrollDelta::PixelDelta(position) => {
236+
event::MouseScroll::Pixels {
237+
horizontal: position.x,
238+
vertical: position.y,
239+
}
240+
}
241+
},
238242
};
239243
self.task_manager.provide(input_event);
240244
}
@@ -255,11 +259,11 @@ impl<T: Application> winit::application::ApplicationHandler for EventLoop<T> {
255259
if let Some(instance) = self.window_instance.as_ref() {
256260
instance.winit_window.pre_present_notify();
257261
}
258-
log::debug!("Wait for presenter...");
262+
// log::debug!("Wait for presenter...");
259263
self.task_manager
260264
.wait_for::<graphics::FramePresenter>()
261265
.present();
262-
log::debug!("...presented");
266+
// log::debug!("...presented");
263267
self.task_manager.run();
264268
// Note: can be used for debug
265269
// fill::fill_window(window);

src/world/camera.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ impl View {
9494

9595
/// Return view matrix made from target
9696
pub fn target(&self, target: Vec3) -> Mat4 {
97-
self.target_up(target, Vec3::Z)
97+
self.target_up(target, -Vec3::Y)
9898
}
9999

100100
/// Return view matrix made from target and up vector

0 commit comments

Comments
 (0)