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

explicitly switch between dynamic and static body types #401

Merged
merged 2 commits into from
Jun 1, 2018

Conversation

InfiniteLee
Copy link
Contributor

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.js

aframe-physics-system PR to allow this here: n5ro/aframe-physics-system#97

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
Copy link
Contributor

@netpro2k netpro2k left a 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 });
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@InfiniteLee
Copy link
Contributor Author

I just tried removing the mass property from super-networked-interactable and unfortunately I don't think we can get rid of that yet. The problem is you do need to know the original mass of the entity (in order to set it back to the correct value when you grab it). The remote client has no way of knowing what the original mass of the object is except through the super-networked-interactable property, however.

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.

2 participants