schteppe / p2.js

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

[idea] Restrict Shape instance to a single Body #171

Closed schteppe closed 8 years ago

schteppe commented 9 years ago

If a Shape was restricted to not be shared between many bodies, a few things would get better, with the obvious cost of memory.

An alternative is to have a Fixture class to make the Shape classes clearly separated from bodies and physics. This could make it possible to use the Shape classes, intersection algorithms and raycasting without having to make a full rigid body simulation. Perhaps the Fixture could be a class that extends each Shape.

schteppe commented 8 years ago

Done in https://github.com/schteppe/p2.js/commit/16e1a479a10e2d2b5ec8648ce9b2bad82e44aace#diff-adbd50cfd9b8533fc35faa0370172289