-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
168 changed files
with
747 additions
and
326 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
pub struct Image {} | ||
|
||
impl Image { | ||
pub fn new() {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use std::{ | ||
env, | ||
path::{Path, PathBuf}, | ||
}; | ||
|
||
pub(crate) fn get_base_path() -> PathBuf { | ||
if let Ok(manifest_dir) = env::var("CARGO_MANIFEST_DIR") { | ||
PathBuf::from(manifest_dir) | ||
} else { | ||
env::current_exe() | ||
.map(|path| path.parent().map(ToOwned::to_owned).unwrap()) | ||
.unwrap() | ||
} | ||
} | ||
|
||
/// I/O implementation for the local filesystem. | ||
/// | ||
/// This asset I/O is fully featured but it's not available on `android` and `wasm` targets. | ||
pub struct FileAssetReader { | ||
root_path: PathBuf, | ||
} | ||
|
||
impl FileAssetReader { | ||
pub fn new<P: AsRef<Path>>(path: P) -> Self { | ||
let root_path = get_base_path().join(path.as_ref()); | ||
// try create root | ||
std::fs::create_dir_all(&root_path).expect("Failed to create root dirs"); | ||
Self { root_path } | ||
} | ||
|
||
pub fn root_path(&self) -> &PathBuf { | ||
&self.root_path | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
mod file; | ||
|
||
pub struct AssetsLoader {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
use std::ops::{Mul, MulAssign}; | ||
|
||
#[repr(C)] | ||
pub struct IVec2 { | ||
pub x: i32, | ||
pub y: i32, | ||
} | ||
|
||
impl IVec2 { | ||
/// All zeroes. | ||
pub const ZERO: Self = Self::splat(0); | ||
|
||
/// All ones. | ||
pub const ONE: Self = Self::splat(1); | ||
|
||
/// All negative ones. | ||
pub const NEG_ONE: Self = Self::splat(-1); | ||
|
||
/// All `i32::MIN`. | ||
pub const MIN: Self = Self::splat(i32::MIN); | ||
|
||
/// All `i32::MAX`. | ||
pub const MAX: Self = Self::splat(i32::MAX); | ||
|
||
/// A unit vector pointing along the positive X axis. | ||
pub const X: Self = Self::new(1, 0); | ||
|
||
/// A unit vector pointing along the positive Y axis. | ||
pub const Y: Self = Self::new(0, 1); | ||
|
||
/// A unit vector pointing along the negative X axis. | ||
pub const NEG_X: Self = Self::new(-1, 0); | ||
|
||
/// A unit vector pointing along the negative Y axis. | ||
pub const NEG_Y: Self = Self::new(0, -1); | ||
|
||
/// The unit axes. | ||
pub const AXES: [Self; 2] = [Self::X, Self::Y]; | ||
|
||
/// Creates a new vector. | ||
#[inline(always)] | ||
#[must_use] | ||
pub const fn new(x: i32, y: i32) -> Self { | ||
Self { x, y } | ||
} | ||
|
||
/// Creates a vector with all elements set to `v`. | ||
#[inline] | ||
#[must_use] | ||
pub const fn splat(v: i32) -> Self { | ||
Self { x: v, y: v } | ||
} | ||
} | ||
|
||
impl Mul<i32> for IVec2 { | ||
type Output = Self; | ||
#[inline] | ||
fn mul(self, rhs: i32) -> Self { | ||
Self { | ||
x: self.x.mul(rhs), | ||
y: self.y.mul(rhs), | ||
} | ||
} | ||
} | ||
|
||
impl MulAssign<i32> for IVec2 { | ||
#[inline] | ||
fn mul_assign(&mut self, rhs: i32) { | ||
self.x.mul_assign(rhs); | ||
self.y.mul_assign(rhs); | ||
} | ||
} | ||
|
||
impl Mul<IVec2> for i32 { | ||
type Output = IVec2; | ||
#[inline] | ||
fn mul(self, rhs: IVec2) -> IVec2 { | ||
IVec2 { | ||
x: self.mul(rhs.x), | ||
y: self.mul(rhs.y), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub mod ivec2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
pub mod vec2; | ||
pub mod vec3; | ||
pub mod vec4; | ||
|
||
pub mod i32; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.