mirror of
https://github.com/lisk77/comet.git
synced 2025-10-23 21:38:50 +00:00
fix: completely annihilated matrix
and rewrote it with a good orthographic projection matrix finally
This commit is contained in:
parent
c79e69f8f4
commit
4e9e296ba4
4 changed files with 341 additions and 518 deletions
|
@ -345,6 +345,6 @@ impl Camera for Camera2D {
|
|||
let bottom = -self.dimensions.y() / 2.0;
|
||||
let top = self.dimensions.y() / 2.0;
|
||||
|
||||
Mat4::OPENGL * Mat4::orthographic_matrix(left, right, bottom, top, 1.0, 0.0)
|
||||
Mat4::OPENGL_CONV * Mat4::orthographic_projection(left, right, bottom, top, 1.0, 0.0)
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,4 +1,4 @@
|
|||
use comet_math::{Point3, Vec2, Vec3};
|
||||
use comet_math::{Mat4, Point3, Vec2, Vec3};
|
||||
|
||||
#[rustfmt::skip]
|
||||
pub const OPENGL_TO_WGPU_MATRIX: cgmath::Matrix4<f32> = cgmath::Matrix4::new(
|
||||
|
@ -29,16 +29,23 @@ impl Camera {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn build_view_projection_matrix(&self) -> cgmath::Matrix4<f32> {
|
||||
pub fn build_view_projection_matrix(&self) -> Mat4 {
|
||||
let zoomed_width = self.dimension.x() / self.zoom;
|
||||
let zoomed_height = self.dimension.y() / self.zoom;
|
||||
|
||||
OPENGL_TO_WGPU_MATRIX * cgmath::ortho(self.position.x() - zoomed_width / 2.0,
|
||||
Mat4::OPENGL_CONV * Mat4::orthographic_projection(self.position.x() - zoomed_width / 2.0,
|
||||
self.position.x() + zoomed_width / 2.0,
|
||||
self.position.y() - zoomed_height / 2.0,
|
||||
self.position.y() + zoomed_height / 2.0,
|
||||
1.0,
|
||||
0.0)
|
||||
|
||||
/*OPENGL_TO_WGPU_MATRIX * cgmath::ortho(self.position.x() - zoomed_width / 2.0,
|
||||
self.position.x() + zoomed_width / 2.0,
|
||||
self.position.y() - zoomed_height / 2.0,
|
||||
self.position.y() + zoomed_height / 2.0,
|
||||
1.0,
|
||||
0.0)
|
||||
0.0)*/
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,8 +25,8 @@ impl Projection {
|
|||
|
||||
pub fn resize(&mut self, width: u32, height: u32) { self.aspect = width as f32 / height as f32; }
|
||||
|
||||
pub fn calc_matrix(&self) -> Mat4 {
|
||||
/*pub fn calc_matrix(&self) -> Mat4 {
|
||||
Mat4::perspective_matrix(self.fovy, self.aspect, self.znear, self.zfar)
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue