kantholtz / norne

A storytelling engine
MIT License
0 stars 0 forks source link

Forcefield behaviour #15

Open kantholtz opened 10 years ago

kantholtz commented 10 years ago

A method to use some sort of newtonian behaviour must be found. It is possible to write a behaviour that lets all bodies be attracted to another subset of those bodies. But PhysicsJS does not explicitly group its maintained bodies.

So there may be different approaches to this problem:

  1. Use the query facility of PhysicsJS. But I must look at it further, since everything I found was the (now closed) issue. It must be possible to save a query, otherwise there might be a lot of computation overhead for repeated querying. However, this saved query must be maintained carefully, since forcefields can be added and removed arbitrarily.
  2. Add a property directly to every PhysicsJS world, that saves references to all added forcefields. This approach looks simple at the first glance but might cause a lot of trouble. Forcefield bodies would be maintained redundantly which could lead to inconsistency.
  3. Add a property to every body or use body[i].geometry.name (might be slow though because of the necessary prototype chain lookup). This could be handled pretty well on the behaviour implementation level, but may cause overhead since the subset must be filtered every time 'behave' gets called.