chore: renamed the structs Vec2, Vec3, Vec4, Mat2, Mat3, Mat4, Point2, Point3 to v2, v3, v4, m2, m3, m4, p2, p3

This commit is contained in:
lisk77 2025-04-17 00:54:09 +02:00
parent 982323f671
commit fd8cf1f278
22 changed files with 430 additions and 430 deletions

View file

@ -1,4 +1,4 @@
use comet_math::{Mat4, Point3, Vec2, Vec3};
use comet_math::{m4, p3, v2, v3};
#[rustfmt::skip]
pub const OPENGL_TO_WGPU_MATRIX: cgmath::Matrix4<f32> = cgmath::Matrix4::new(
@ -12,15 +12,15 @@ const SAFE_FRAC_PI_2: f32 = std::f32::consts::FRAC_PI_2 - 0.0001;
pub struct RenderCamera {
zoom: f32,
dimension: Vec2,
position: Vec3
dimension: v2,
position: v3
}
impl RenderCamera {
pub fn new(
zoom: f32,
dimension: Vec2,
position: Vec3
zoom: f32,
dimension: v2,
position: v3
) -> Self {
Self {
zoom,
@ -29,16 +29,16 @@ impl RenderCamera {
}
}
pub fn build_view_projection_matrix(&self) -> Mat4 {
pub fn build_view_projection_matrix(&self) -> m4 {
let zoomed_width = self.dimension.x() / self.zoom;
let zoomed_height = self.dimension.y() / self.zoom;
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)
m4::OPENGL_CONV * m4::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,

View file

@ -12,7 +12,7 @@ use winit::window::Window;
use comet_colors::{ Color, LinearRgba };
use comet_ecs::{Camera, Camera2D, Component, Position2D, Render, Render2D, Transform2D, Scene};
use comet_log::{debug, error, info};
use comet_math::{Point2, Point3, Vec2, Vec3};
use comet_math::{p2, p3, v2, v3};
use comet_resources::{texture, graphic_resource_manager::GraphicResourceManager, Texture, Vertex};
use comet_resources::texture_atlas::TextureRegion;
use comet_structs::ComponentSet;
@ -127,7 +127,7 @@ impl<'a> Renderer2D<'a> {
label: Some("texture_bind_group_layout"),
});
let camera = RenderCamera::new(1.0, Vec2::new(2.0, 2.0), Vec3::new(0.0, 0.0, 0.0));
let camera = RenderCamera::new(1.0, v2::new(2.0, 2.0), v3::new(0.0, 0.0, 0.0));
let mut camera_uniform = CameraUniform::new();
camera_uniform.update_view_proj(&camera);
@ -471,7 +471,7 @@ impl<'a> Renderer2D<'a> {
}
/// A function to just draw a textured quad at a given position.
pub fn draw_texture_at(&mut self, texture_path: String, position: Point3) {
pub fn draw_texture_at(&mut self, texture_path: String, position: p3) {
let region = self.graphic_resource_manager.texture_locations().get(&texture_path).unwrap();
let (dim_x, dim_y) = region.dimensions();
@ -496,13 +496,13 @@ impl<'a> Renderer2D<'a> {
}
/// A function to draw text at a given position.
pub fn draw_text_at(&mut self, text: &str, font: String, size: f32, position: Point2, color: impl Color) {
pub fn draw_text_at(&mut self, text: &str, font: String, size: f32, position: p2, color: impl Color) {
//self.set_font_atlas(font.clone());
let wgpu_color = color.to_wgpu();
let vert_color = [wgpu_color.r as f32, wgpu_color.g as f32, wgpu_color.b as f32, wgpu_color.a as f32];
let screen_position = Point2::new(position.x()/self.config.width as f32, position.y()/self.config.height as f32);
let screen_position = p2::new(position.x()/self.config.width as f32, position.y()/self.config.height as f32);
let scale_factor = size / self.graphic_resource_manager.fonts().iter().find(|f| f.name() == font).unwrap().size();
let line_height = (self.graphic_resource_manager.fonts().iter().find(|f| f.name() == font).unwrap().line_height() / self.config.height as f32) * scale_factor;
@ -550,10 +550,10 @@ impl<'a> Renderer2D<'a> {
}
}
fn add_text_to_buffers(&self, text: String, font: String, size: f32, position: Point2, color: wgpu::Color) -> (Vec<Vertex>, Vec<u16>) {
fn add_text_to_buffers(&self, text: String, font: String, size: f32, position: p2, color: wgpu::Color) -> (Vec<Vertex>, Vec<u16>) {
let vert_color = [color.r as f32, color.g as f32, color.b as f32, color.a as f32];
let screen_position = Point2::new(position.x()/self.config.width as f32, position.y()/self.config.height as f32);
let screen_position = p2::new(position.x()/self.config.width as f32, position.y()/self.config.height as f32);
let scale_factor = size / self.graphic_resource_manager.fonts().iter().find(|f| f.name() == font).unwrap().size();
let line_height = (self.graphic_resource_manager.fonts().iter().find(|f| f.name() == font).unwrap().line_height() / self.config.height as f32) * scale_factor;
@ -632,9 +632,9 @@ impl<'a> Renderer2D<'a> {
let camera = RenderCamera::new(
camera_component.zoom(),
camera_component.dimensions(),
Vec3::new(camera_position.as_vec().x(),
camera_position.as_vec().y(),
0.0));
v3::new(camera_position.as_vec().x(),
camera_position.as_vec().y(),
0.0));
let mut camera_uniform = CameraUniform::new();
camera_uniform.update_view_proj(&camera);