Is it possible to make a proc which would generate bounding boxes for an object based on the first and last "filled in" pixels along the object icon's x and y axis?
The proc would properly set the object's bound_x, bound_y, bound_height, and bound_width variables based on the object icon's properties.
How would this be done? Or, if you have a better idea please say. Thanks.
ID:155142
Sep 3 2011, 5:20 pm
|
|
Sep 3 2011, 5:47 pm
|
|
Yes it's possible. Use Width() and Height() proc's to find out icons dimension, then make nested loop to loop through every pixel. Inside loop use GetPixel() to figure if pixel is "filled in".
|
In response to Zaoshi
|
|
sounds like a sure-fire way to devour CPU
|
In response to Mista-mage123
|
|
Not unless you run it once on world start up
|
In response to Mista-mage123
|
|
You should do it only once, when worlds starts. Plus it's pretty fast actually (for normal icons), also a little optimization can make it even faster (400% faster on average).
|
In response to Zaoshi
|
|
wat
Where did that figure come from? |
In response to Stephen001
|
|
Well you can get a 300% speedup just by changing your syntax highlighting so the code is red. You could totally eke out another 100% on top of that, right?
|
In response to Jp
|
|
omg i gotta change it right nao
|
In response to Stephen001
|
|
Who knows :|
|
I actually made a utility that matched overlays to an icons movement with transperant dots using this method
Unless you cache the results, it'll lag whenever you create an object (and regardless it'll lag -very- badly when the game starts up) but its very possible. |
In response to ExPixel
|
|
*facepalm* at other replies...
Well it's obviously faster if you add few break's than loop through EVERY pixel. With breaks on average you'd need to loop only through less than 25% of pixels, which will be 400% faster than code which will loop through every pixel. |