schteppe / cannon.js

A lightweight 3D physics engine written in JavaScript.
http://schteppe.github.com/cannon.js
MIT License
4.71k stars 710 forks source link

Sleeping object #163

Open fjavierv opened 9 years ago

fjavierv commented 9 years ago

Hi!. Should cannon consider rotational speed to avoid sleep object?. Thank for all and great job ;)

fjavierv commented 9 years ago

I was thinking also that maybe would be interesting to used the distance to mesure when one objeto should sleep. Sometime object are vibrating (hight speed) however they are not moving, in the cases cannon won't sleep that object and maybe it should.

schteppe commented 9 years ago

Cannon does consider the rotational speed. Added it in this commit: https://github.com/schteppe/cannon.js/commit/116750b76499dc8d015eb12a445101788ad9fd4b Did you enable sleeping on both the world and the body?

Distance might be an idea, but shouldn't a larger sleep threshold fix it anyway?

Stefan

fjavierv commented 9 years ago

I'.m sorry I was working with some old versión. I should have checked new code before write this.

You are right larger sleep threshold will repair, but some times you don't know what object should recieve this larger threshold, so if you apply it to all the object the get worse the performance.

schteppe commented 9 years ago

True that. I think that statistical variance can be used to track the distance. Not sure if it would be better though.