Skip to content

Add vectors and math functions#41

Merged
gibbiemonster merged 10 commits intomainfrom
feature/vectors
May 11, 2025
Merged

Add vectors and math functions#41
gibbiemonster merged 10 commits intomainfrom
feature/vectors

Conversation

@zNotChill
Copy link
Contributor

@zNotChill zNotChill commented May 9, 2025

This PR aims to add 3d vectors with a handful of useful utility functions, taking use of Twine's new overloading feature.

Unfortunately, due to the fact that Lua has a built-in math library, this does override it. Which is why I have tried to re-implement the expected behaviour from existing math functions.

As far as I know, this re-implements nearly all of the existing math functions. The only current issue is min and max functions not working, due to Twine's lack of a working vararg system. Hopefully, this will be addressed and fixed by me or somebody else if needed.

The reason for this custom math library is that vector utilities would be very useful, such as math.abs(Double) and math.abs(Vector3)

This PR could be merged, since any existing issues would be addressed and fixed later on, and I think its important for vectors to exist in the main branch before any world/entity stuff is started.

Signed-off-by: zNotChill <znotchill@znci.dev>
Signed-off-by: zNotChill <znotchill@znci.dev>
Signed-off-by: zNotChill <znotchill@znci.dev>
@zNotChill zNotChill marked this pull request as ready for review May 9, 2025 16:36
@github-actions
Copy link

github-actions bot commented May 9, 2025

Qodana Community for JVM

88 new problems were found

Inspection name Severity Problems
Unused symbol 🔶 Warning 61
Unused import directive 🔶 Warning 11
Redundant call of conversion method 🔶 Warning 2
Unresolved reference in KDoc 🔶 Warning 1
Usage of redundant or deprecated syntax or deprecated symbols 🔶 Warning 1
Redundant nullable return type 🔶 Warning 1
Class member can have 'private' visibility ◽️ Notice 6
If-Null return/break/... foldable to '?:' ◽️ Notice 2
Variable declaration could be moved inside 'when' ◽️ Notice 1
Redundant empty primary constructor ◽️ Notice 1
Accessor call that can be replaced with property access syntax ◽️ Notice 1

☁️ View the detailed Qodana report

Contact Qodana team

Contact us at qodana-support@jetbrains.com

Copy link
Contributor

@gibbiemonster gibbiemonster left a comment

Choose a reason for hiding this comment

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

LGTM, but remember to bump twine version.

Copy link
Contributor

@gibbiemonster gibbiemonster left a comment

Choose a reason for hiding this comment

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

Nevermind. Write unit tests 🙂

@zNotChill
Copy link
Contributor Author

zNotChill commented May 11, 2025

Reviewing again right now is not necessary, since I am now working on unit tests which I will finish tomorrow.

Copy link
Contributor

@gibbiemonster gibbiemonster left a comment

Choose a reason for hiding this comment

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

Just some test style things. Otherwise, they pass and run.
Well done 🙂

@gibbiemonster gibbiemonster merged commit 0c8beee into main May 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments