-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
cleanup passing of mat4 arguments #6633
Conversation
🎉 Thanks for opening this pull request! Please check out our contributing guidelines if you haven't already. And be sure to add yourself to the list of contributors on the readme page! |
The previous issueMake sure to reference the issue so that the 2 can be more easily linked in the future for those trying to participate: #6527 Responses
For some reason, although the library is documented to be a matrix class for
I'd recommend calling with the array if you want to keep all of the references to the matrix pointing at the matrix, especially since this can make debugging easier since an abnormally small array is easier to track down than some random If you don't care about keeping the references pointing towards the Matrix pointing towards the Matrix then I'd recommend using the Something that I'd like to say regarding the issueI'd just like to note here that, while I do support improving the existing |
@RandomGamingDev After creating this PR I dove deeper into the p5 |
Yeah, it is pretty messy, but it doesn't look like anyone can work on replacing the math library rn. For now, I'd recommend not assuming that it's always the same value and to copy the list in a way that works regardless of its length like some that I mentioned above just in case some use the mat3 functionality. |
To answer your questions:
Right now the
A few thoughts on this one:
I think it's probably fine to do a quick check in
Yeah, I'm also not opposed to it, but it kinda needs a "champion" to make it happen. In the mean time working on small chunks to improve the code is good!
I wonder if this was initially inspired by the native |
I think this is a good idea so I did it😄. The
This is not ready for merging just yet -- there are some test failures which I need to investigate. |
Other than the test failures this looks good to me |
Ok so it turns out the the failing tests were not due to any changes that I made. I get the same failures when testing the I see the cause of the problem so should I fix it? I think yes, but in a separate PR. All of the tests related to the camera |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work @lindapaiste! Thanks for also adding some error logging for when our input assumptions aren't met!
Background:
This is just a code cleanup and should not change any behaviors. There is a big block of code for passing the arguments of a 4x4 matrix. It is excessively verbose and it's repeated in 10 different places!
p5.js/src/webgl/p5.Camera.js
Lines 1427 to 1444 in fb70e98
These blocks are one of many issues brought up by @RandomGamingDev in this comment on #6527.
Changes:
Simplifies these blocks of code to:
Using:
slice(0,16)
to access the first 16 element of the array (indices 0 through 15)...
(spread syntax) to pass the elements of the array as individual arguments.Questions:
undefined
in that situation. It's the difference between callingfunc(a, b, undefined, undefined)
andfunc(a, b)
..slice(0,16)
is not necessary.Matrix.set()
method accepts an array, in addition to accepting individual numbers. Should I drop the...
and call with the array directly? (But keeping the.slice()
to clone it). Or use the.copy()
method, as suggested by @RandomGamingDev?PR Checklist
npm run lint
passes