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

(breaking) vec: Rework vec2.to_vec3; add vec3.to_xz #81

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

idbrii
Copy link
Contributor

@idbrii idbrii commented May 27, 2022

  • Replace vec2.to_vec3 with vec3.from_table.
  • Add vec3.to_xz, vec3.to_xy, vec3.to_table.
  • Add vec2.to_table for completeness.

Simplify converting into flat plane math. Often I want to do math on the
ground plane, so it's helpful to easily convert vec3 into vec2 (like for
angle_to).

Remove vec2.to_vec3 so vec3 can depend on vec2 instead and we can do
to_xz and to_xy, which seem far more useful. vec3.from_table(a) is
mostly equivalent to to_vec3, but doesn't accept a value for z.

Add to_table as a pair for from_table and for converting into a
serializable. No vec2.from_table because it's the same as vec2.new.


What do you think about this one? Maybe all the to/from_table should be removed and just add vec3.from_vec2?

* Replace vec2.to_vec3 with vec3.from_table.
* Add vec3.to_xz, vec3.to_xy, vec3.to_table.
* Add vec2.to_table for completeness.

Simplify converting into flat plane math. Often I want to do math on the
ground plane, so it's helpful to easily convert vec3 into vec2 (like for
angle_to).

Remove vec2.to_vec3 so vec3 can depend on vec2 instead and we can do
to_xz and to_xy, which seem far more useful. vec3.from_table(a) is
mostly equivalent to to_vec3, but doesn't accept a value for z.

Add to_table as a pair for from_table and for converting into a
serializable. No vec2.from_table because it's the same as vec2.new.
@idbrii idbrii changed the title vec: Rework vec2.to_vec3; add vec3.to_xz (breaking) vec: Rework vec2.to_vec3; add vec3.to_xz May 27, 2022
@idbrii
Copy link
Contributor Author

idbrii commented May 27, 2022

From the failed test:

Error -> spec/vec2_spec.lua @ 268
vec2: converts a 2-vector to a 3-vector
./modules/vec3.lua:403: 'struct 96' has no member named 'z'

stack traceback:
./modules/vec3.lua:403: in function 'from_table'
spec/vec2_spec.lua:271: in function <spec/vec2_spec.lua:268>

I guess for ffi, I have to make it from_vec2.

@mcclure
Copy link
Collaborator

mcclure commented May 28, 2022

That's rough...
I don't know the best way to handle that. Maybe we could have files with "type only" definitions of vec2 and vec3.

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