schteppe / p2.js

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

Body.fromPolygon empties my path array. #192

Closed jstoeffler closed 8 years ago

jstoeffler commented 8 years ago

There's quite a few cases where it can be useful to reuse your paths, but apparently when I call Body.fromPolygon, my paths arrays are emptied. Example:

        var legPath = // My character's beautiful leg shape :)
        var frontLeg = new p2.Body({
            // some properties
        });
        var backLeg = new p2.Body({
            // some properties
        });
        frontLeg.fromPolygon(legPath);
        // at this time my beautiful leg path is an empty array :(
        backLeg.fromPolygon(legPath);

Some people also consider it's a bad practice to modify the function arguments unless it's explicit (and I agree, it's probably something you don't expect).

schteppe commented 8 years ago

Thanks for the heads up! Should work as expected now.

jstoeffler commented 8 years ago

Thank you for the quick update! It's really a wonderful project, I hope I'll be able to contribute in the future :)

schteppe commented 8 years ago

Awesome, thanks!