-
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
explicitly switch between dynamic and static body types #401
Conversation
This should be a performance boost when there are many non-owned interactables in the scene because there are calculations that are run only on bodies set to dynamic in CANNON
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.
Looks good though I would use this as a chacne to remove the mass propert from super-networked-interatcable
since it shouldnt be needed and was surprising to me when it overwrote the mass I had defined on a body.
@@ -46,7 +46,7 @@ AFRAME.registerComponent("super-networked-interactable", { | |||
this.hand = e.detail.hand; | |||
if (this.networkedEl && !NAF.utils.isMine(this.networkedEl)) { | |||
if (NAF.utils.takeOwnership(this.networkedEl)) { | |||
this.el.setAttribute("body", { mass: this.data.mass }); | |||
this.el.setAttribute("body", { type: "dynamic", mass: this.data.mass }); |
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.
Since we are actually toggling the type now we should be able to get rid of mass
from this component's schema and just never touch the body's mass.
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.
toggling the type doesn't change the need for changing mass. Changing the mass is still required to get the behavior of switching between dynamic and static. Changing the type simply avoids unnecessary methods from being called on non-owned objects.
I just tried removing the mass property from |
This should be a performance boost when there are many non-owned interactables in the scene because there are calculations that are run only on bodies set to dynamic in CANNON. See instances of
if(this.type !== Body.DYNAMIC)
in https://github.com/schteppe/cannon.js/blob/master/src/objects/Body.jsaframe-physics-system
PR to allow this here: n5ro/aframe-physics-system#97