deltaluca / nape

Haxe/AS3 Physics Engine
http://napephys.com
Other
542 stars 77 forks source link

Small bug in splice_collinear of PR(Polygon). #37

Closed deltaluca closed 12 years ago

deltaluca commented 12 years ago

Doesn't seem to handle start vertex being one of the vertices to be removed:

Test case:

package;
$(import);

class DummyNapeMain {
    static function main() {
        var space = new Space();

        var tris = new Body(BodyType.STATIC);
        tris.shapes.add(new Polygon([
            new Vec2(0,200), new Vec2(50,250), new Vec2(100,300), new Vec2(50,300), new Vec2(0,300), new Vec2(0,250)
        ]));
        tris.shapes.add(new Polygon([
            new Vec2(250,250), new Vec2(300,200), new Vec2(300,250), new Vec2(300,300), new Vec2(250,300), new Vec2(200,300)    
        ]));
        tris.space = space;

        var debug = new ShapeDebug(1,1);
        flash.Lib.current.addChild(debug.display);

        for(i in 0...11) {
            var b = new Body();
            b.shapes.add(new Circle(4));
            b.position.x = 300/10*i;
            b.space = space;
            b.velocity.y = 100;
        }

        (new haxe.Timer(11)).run = function() {
            debug.clear();
            space.step(1/60,10,10);
            debug.draw(space);
        }
    }
}
deltaluca commented 12 years ago

Fixed on github. Should make a release shortly lest I forget :P