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

Normalized return values and made vector classes use extendable types #13076

Merged

Conversation

LostInClams
Copy link
Contributor

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

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.
@azure-pipelines
Copy link

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@azure-pipelines
Copy link

@azure-pipelines
Copy link

Visualization tests for webgl1 have failed. If some tests failed because the snapshots do not match, the report can be found at

https://babylonsnapshots.z22.web.core.windows.net/refs/pull/13076/merge/testResults/webgl1/index.html

If tests were successful afterwards, this report might not be available anymore.

@azure-pipelines
Copy link

Visualization tests for webgl2 have failed. If some tests failed because the snapshots do not match, the report can be found at

https://babylonsnapshots.z22.web.core.windows.net/refs/pull/13076/merge/testResults/webgl2/index.html

If tests were successful afterwards, this report might not be available anymore.

@azure-pipelines
Copy link

There is no need to update the "what's new.md" file. A changelog will be generated using the PR and its tags.

@azure-pipelines
Copy link

Visualization tests for webgl1 have failed. If some tests failed because the snapshots do not match, the report can be found at

https://babylonsnapshots.z22.web.core.windows.net/refs/pull/13076/merge/testResults/webgl1/index.html

If tests were successful afterwards, this report might not be available anymore.

@azure-pipelines
Copy link

Visualization tests for webgl2 have failed. If some tests failed because the snapshots do not match, the report can be found at

https://babylonsnapshots.z22.web.core.windows.net/refs/pull/13076/merge/testResults/webgl2/index.html

If tests were successful afterwards, this report might not be available anymore.

Copy link
Member

@RaananW RaananW left a 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.

@RaananW
Copy link
Member

RaananW commented Oct 10, 2022

Also note - tests are failing, so something else changed other than types.

@LostInClams
Copy link
Contributor Author

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?

@RaananW
Copy link
Member

RaananW commented Oct 10, 2022

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 npm run test:unit. Visualization tests (webgl2) are executed using npm run test:visualization -- -i webgl2, but you also need the local babylon-server in the background, so run npm run serve -w @tools/babylon-server in a different terminal first

@azure-pipelines
Copy link

There is no need to update the "what's new.md" file. A changelog will be generated using the PR and its tags.

Pontus Holmertz Liljekvist added 4 commits October 12, 2022 17:22
Copy link
Contributor

@bghgary bghgary left a 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?

Pontus Holmertz Liljekvist added 2 commits October 14, 2022 16:01
@azure-pipelines
Copy link

Visualization tests for webgl2 have failed. If some tests failed because the snapshots do not match, the report can be found at

https://babylonsnapshots.z22.web.core.windows.net/refs/pull/13076/merge/testResults/webgl2/index.html

If tests were successful afterwards, this report might not be available anymore.

@RaananW RaananW merged commit 9dff3e0 into BabylonJS:master Oct 17, 2022
RaananW pushed a commit that referenced this pull request Dec 9, 2022
…#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
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.

3 participants