Skip to content

Adding Vector3 for all the [f32; 3]#88

Merged
ElhamAryanpur merged 6 commits intoAryanpurTech:masterfrom
Gipson62:master
Jan 11, 2025
Merged

Adding Vector3 for all the [f32; 3]#88
ElhamAryanpur merged 6 commits intoAryanpurTech:masterfrom
Gipson62:master

Conversation

@Gipson62
Copy link
Copy Markdown
Contributor

This should resolve #71 as all the function that set a position takes impl Into<Position3D> as input, and you can trivially cast a Position3D to a nalgebra_glm::Vec3 with .into() when needed.

Tho, all the examples have to be updated accordingly in the next update

This should resolve AryanpurTech#71 as all of the function that set a position taks `impl Into<Position3D>` as input and you can trivially cast a Position3D to a nalgebra_glm::Vec3 with `.into()` when needed
The Position3D already got replaced by a more general purposes Vector3. A lot of implementation got done so the Vector3 supports all of the basic operations: + - * / & += -= *= /= and also you can do all the base matrix operations on them.
Also modified the ./primitive_shapes codes to use directly Vector3 & Vector2 directly instead of casting arrays to their respectives Vector.
@Gipson62
Copy link
Copy Markdown
Contributor Author

Examples don't work if you use blue_engine_core = { path = "./crates/blue_engine_core" } because they haven't been updated yet. There's an issue with the cube, it's fixed on my machine, but I'll push everything at once (with examples & some more features for both Vector3 & Vector2) once blue_engine 0.6.1 or so is published, to avoid any breaking changes in the master branch.

All of the *most used* functions are implemented for both Vector3 & Vector2. Examples have been updated, tho it makes the import of blue_engine in `Cargo.toml` be a path instead of a version. Cube has been fixed, there might need more test to ensure everything is working correctly

/// The uint type used for indices and more
#[cfg(feature = "u16")]
pub type UnsignedIntType = u16;

Check failure

Code scanning / clippy

the name `UnsignedIntType` is defined multiple times

the name `UnsignedIntType` is defined multiple times
#[cfg(feature = "u16")]
pub type UnsignedIntType = u16;
#[cfg(feature = "u32")]
pub type UnsignedIntType = u32;

Check failure

Code scanning / clippy

the name `UnsignedIntType` is defined multiple times

the name `UnsignedIntType` is defined multiple times
@Gipson62 Gipson62 changed the title feat!: added Position3D for all of the position: [f32; 3] Adding Vector3 for all the [f32; 3] Jan 11, 2025
Copy link
Copy Markdown
Collaborator

@ElhamAryanpur ElhamAryanpur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely the most amazing commit of this project

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't this auto cast?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most statically typed language doesn't allow implicit casting as the end users wouldn't be able to know the cost of that casting. By making it explicit, the compiler can be sure that the user actively want to pay that cost. So no, sadly no auto cast. Tho [f32; 3].into() works fine, I just changed it so it is a better example for other users

@ElhamAryanpur ElhamAryanpur added documentation Improvements or additions to documentation enhancement New feature or request labels Jan 11, 2025
@ElhamAryanpur ElhamAryanpur added this to the 0.6.0 milestone Jan 11, 2025
@ElhamAryanpur ElhamAryanpur merged commit b84b193 into AryanpurTech:master Jan 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use impl Into<T>

3 participants