Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vec2: add meta functions for mathematical operators #68

Merged
merged 4 commits into from
Dec 14, 2023

Conversation

billmakes
Copy link
Contributor

@billmakes billmakes commented Dec 13, 2023

As the title describes, this PR add's meta functions for mathematical operators.

addition:
vec2(1, 2) + vec2(3, 4) (4.00, 6.00)

subtraction:
vec2(1, 2) - vec2(3, 4) (-2.00, -2.00)

multiplication:
vec2(1, 2) * 2 (2.00, 4.00)
2 * vec2(3, 4) (6.00, 8.00)
vec2(1, 2) * vec2(3, 4) (3.00, 8.00)

division:
vec2(4, 4) / 2 (2.00, 2.00)

state_machine:
I added another field on the state_machine for the previous state name. This was a really small change and figured I would get input on that too while I'm here, though it probably should have been a separate PR...

The use-case for me personally was using it to calculate unique behavior based on where we came from. For example I want to enter jump state from wallgrab state, but I want the velocity direction to be slightly tweaked in the jump state's update method if we came from wallgrab.

I find having these handy very useful and intuitive, let me know you're thoughts :)

@billmakes billmakes changed the title add meta functions for mathmatical operators vec2: add meta functions for mathematical operators Dec 13, 2023
@billmakes billmakes changed the title vec2: add meta functions for mathematical operators vec2: add meta functions for mathematical operators, state_machine: prev_state_name Dec 13, 2023
@1bardesign
Copy link
Owner

Separating the state machine stuff would be nice so it can be reviewed and commented on in isolation 🙏

For meta functions/operator overloads on vec2 - i'm ok with this. The reason for using methods is that it encourages the possibility of upgrading to inplace versions which drastically reduces garbage churn, but I appreciate it's very wordy.

@1bardesign
Copy link
Owner

I'd like to request that they go through the existing methods though rather than contain separate inline implementations. Also support for vector division probably makes sense.

@billmakes billmakes changed the title vec2: add meta functions for mathematical operators, state_machine: prev_state_name vec2: add meta functions for mathematical operators Dec 13, 2023
@billmakes
Copy link
Contributor Author

I'd like to request that they go through the existing methods though rather than contain separate inline implementations. Also support for vector division probably makes sense.

Cool, that's actually a great idea. I updated the PR

@1bardesign
Copy link
Owner

👍 🎉

@1bardesign 1bardesign merged commit 90f46c2 into 1bardesign:master Dec 14, 2023
2 checks passed
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