schteppe / p2.js

JavaScript 2D physics library
Other
2.64k stars 330 forks source link

Sensor Affects Moment of Inertia #244

Open gaufqwi opened 8 years ago

gaufqwi commented 8 years ago

I have attached a large circle shape as a sensor to several bodies to serve as a kind of proximity sensor. This seems to work except it has an enormous impact on the moment of inertia of the body, making it hard to turn. So two questions:

1) Is using a large sensor this way to detect when bodies are within a certain range of each other good practice? I know that it increases the number of potential collisions that need to be checked. Is there a better way to do this?

2) Should sensor shapes even impact the moment of inertia of a body at all?

schteppe commented 8 years ago

I think it's a valid and good approach to use a large sensor to detect proximity. It should be fast enough (using the broadphase).

I'm not sure about the inertia part but the gut feeling is that a sensor should not affect the inertia of a dynamic body. I checked the docs for box2d and it looks like they get around the problem by using density per shape, instead of per body. Thus you can just set the sensor density to zero.

pkieltyka commented 7 years ago

hey @gaufqwi just wondering if you were able to solve this? I also have a proximity sensor around a body object, used for proxy bomb detection.