-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Normalized return values and made vector classes use extendable types #13076
Normalized return values and made vector classes use extendable types #13076
Conversation
This commit tries to normalize the return type of all math functions so that all ToRef versions return the ref. It also changes so that functions that create new Objects try to do that with an extended type when possible.
Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s). |
Snapshot stored with reference name: Test environment: To test a playground add it to the URL, for example: https://babylonsnapshots.z22.web.core.windows.net/refs/pull/13076/merge/index.html#WGZLGJ#4600 Links to test babylon tools with this snapshot: https://playground.babylonjs.com/?snapshot=refs/pull/13076/merge To test the snapshot in the playground with a playground ID add it after the snapshot query string: https://playground.babylonjs.com/?snapshot=refs/pull/13076/merge#BCU1XR#0 |
Visualization tests for webgl1 have failed. If some tests failed because the snapshots do not match, the report can be found at If tests were successful afterwards, this report might not be available anymore. |
Visualization tests for webgl2 have failed. If some tests failed because the snapshots do not match, the report can be found at If tests were successful afterwards, this report might not be available anymore. |
There is no need to update the "what's new.md" file. A changelog will be generated using the PR and its tags. |
Visualization tests for webgl1 have failed. If some tests failed because the snapshots do not match, the report can be found at If tests were successful afterwards, this report might not be available anymore. |
Visualization tests for webgl2 have failed. If some tests failed because the snapshots do not match, the report can be found at If tests were successful afterwards, this report might not be available anymore. |
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.
I like the changes a lot!
As written in the comment, I am simply not too happy about the any
cast. I know it cannot be solved directly with generics, but I want to see if we find a more elegant solution.
Also note - tests are failing, so something else changed other than types. |
Yes, I did change many places to return ref instead of this in ToRef functions, I felt that we agreed to start of from there since Sebavan and Bghgary thought it was on the edge case for a bug :) Tried to run the test but haven't really contributed to the Babylon source before so not sure how to get the test results to figure out if the failing cases are related to the this vs ref return or something if I broke something else. Could you point me to some guide for the tests? |
Sure. Unit tests are executed using |
There is no need to update the "what's new.md" file. A changelog will be generated using the PR and its tags. |
Now it instead fills Vector4 with 0 to be consistent with Vector2 and Vector3
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.
I'm not 100% sure what I suggested works, but if it does, it is maybe cleaner?
Visualization tests for webgl2 have failed. If some tests failed because the snapshots do not match, the report can be found at If tests were successful afterwards, this report might not be available anymore. |
…#13076) * Normalized return values and made vector classes use extendable types This commit tries to normalize the return type of all math functions so that all ToRef versions return the ref. It also changes so that functions that create new Objects try to do that with an extended type when possible. * Ran prittier and fixed a bug * Added whats new * fixed a missing new * Removed whats new * Fixed Vector4 empty constructor leaving it with x,y,z,w as undefined Now it instead fills Vector4 with 0 to be consistent with Vector2 and Vector3 * Changed casting to any to a constructor type * Prettier * changed casts from <> to as * Prettier Co-authored-by: Pontus Holmertz Liljekvist <pontus.holmertz.liljekvist@rapidimages.se> Former-commit-id: c68db59c23f9047b2f9c0c60523542286a52a885
This commit tries to normalize the return type of all math functions so that all ToRef versions return the ref. It also changes so that functions that create new Objects try to do that with an extended type when possible.
More information can be found here