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

Revisit shared world matrix optimization #61

Open
takahirox opened this issue Mar 24, 2022 · 0 comments
Open

Revisit shared world matrix optimization #61

takahirox opened this issue Mar 24, 2022 · 0 comments

Comments

@takahirox
Copy link

takahirox commented Mar 24, 2022

Our fork has an optimization that if an object's local matrix has never been updated the object's .matrixWorld refers to the parent world matrix instance because the object's local matrix is an identity matrix so that the object's world matrix values should be same as the parent's world matrix ones. With this optimization copying or multiplying the parent's world matrix for the world matrix can be avoided.

https://github.com/MozillaReality/three.js/blob/615b1296134ea566d6270bccc79c1d92599e23f9/src/core/Object3D.js#L650
https://github.com/MozillaReality/three.js/blob/615b1296134ea566d6270bccc79c1d92599e23f9/src/core/Object3D.js#L683
https://github.com/MozillaReality/three.js/blob/615b1296134ea566d6270bccc79c1d92599e23f9/src/core/Object3D.js#L996-L1001

But this optimization is risky. Three.js doesn't allow shared world matrix in their official APIs. It breaks their rule so for example (future) Three.js official APIs can be broken with this optimization. (ex: Imagine that moves an object under different parent.)

And this optimization needs maintenance cost. We need some rules and need to carefully follow them when writing components and systems.

So, if we want to adopt this type of risky optimizations, we need to make benchmark test and the optimization should show the significant performance improvement. And we should note the performance improvement number. Otherwise we shouldn't adopt such optimizations.

I prefer to remove this optimization until we make benchmark test if we really need optimization.

And I feel like there might be some safer ways to do similar optimization... It would be worth to try to think of them.

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

No branches or pull requests

1 participant