The drawing code does slow things down, but i had to visualize it somehow :) Here's a snippet, all this is done before the path calculation:
var container = this.getParentContainer(); container.redraw(); var s = Haxegui.gridSpacing; var hs = s>>1; var w = (container.box.width/s); var h = (container.box.height/s); var engine = new aPath.Engine(); engine.generateMap(w,h); for(i in 0...w) for(j in 0...h) { // get top-most object var o = container.getObjectsUnderPoint(new flash.geom.Point(hs+i*s, hs+j*s)).pop(); // mark it unwalkable if its a widget if(o!=container && !Std.is(o, toys.Socket) ) { container.graphics.beginFill(Color.BLUE, .5); container.graphics.drawRect(i*s, j*s, s, s); container.graphics.endFill(); engine.map[i][j].close = true; } ... ...Seen on the video, a 10x10px grid takes more than 3.5sec to be marked (this includes drawing "unwalkable" blue tiles, which is expensive, it takes about 0.55sec without, still not fast enough) I guess the most expensive is the getObjectsUnderPoint() but i'll need better profiling to be sure... The next step would be to get the target node, before doing all this, so i could minimize the gridded area to be checked. Any A*\haXe tips and optimizations will be more than welcome, have a great weekend!
No comments:
Post a Comment