-
Notifications
You must be signed in to change notification settings - Fork 1.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
GraphNode setPositionAndRotation #6625
Conversation
Should the table compare
I do not see any timing of setRot to conclude the combined functionality is not an improvement. Would you have some numbers here @kpal81xd ? |
The screenshot names are actuallly incorrect the |
So in this case, the combined functionality has a nice performance benefit (34% faster), and we should definitely consider including this in the engine. |
This api of having |
By a quick look at the code, I'd say that this is not likely to win much performance, so perhaps not, as those are a simple functions. |
Looking at the new function, it does not seem to work the same way the two separate functions work though, which is undesirable? |
Wdym? The end result of the transformation? Or the fact that the function uses the transform of the node as opposed to the parent transform directly? |
The individual functions transform the provided world space position and rotation to the parent space. Add a unit test for it and compare the results with old and new functions. |
And the performance benefit is smaller now, around 8.5%. Any way to optimize this? But perhaps a separate PR for the affine part, if we ge to it. |
I modified the code to use the existing inverse matrix instead of calling getRotation which re generates the parent world transform. Looks like a ~40% speedup |
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.
Nice!
Presumably we can now swap out individual calls to |
This method is not included in v1 of the engine, can you include it in the build? |
* added new method on graph node for setting position and rotation together * set transform on entity directly instead of using parent * added back the same position and rotation logic and test for setPositionAndRotation * removed extra call to get ptm * removed mat3 and used inv parent matrix directly * revereted example changes * Updated description of setPositionAndRotation # Conflicts: # src/scene/graph-node.js
I just cherry picked it to v1, this will get released in the future. |
Fixes #6317
Adds a method to graph node class for apply both position and rotation together.
Performance Testing
Average of 5
1e6 Iterations
Random Positions [-5, 5]
Random Rotations [0, 360]
Using
entity.getWorldTransform().setTRS
directly is the fastest however the local positions and rotations are not updated and so neither is the local transform.