Page 1 of 1

Per-pixel Destructible Terrain

Posted: Sun Jun 09, 2013 3:17 pm
by X Abstract X
I've been working on a project for a little over a month now, it's got a per-pixel destructible environment similar to Worms. I've reached a point where I could use some help trying to solve an issue I'm faced with though.

My method of "destroying" the environment is to simply take circle-shaped chunks of varying size out of it whenever an explosion or other destructible event occurs. I do this by drawing to the environment's image data using Bresenham's Circle filling algorithm. That's working fine but I'm not too sure on what to do with any stray pixels that could result, and end up cluttering up the game; preventing the player from moving when there's only perhaps a single pixel or two of floating impassable terrain left in some area.

I've thought of trying to come up with a modification to the circle filling algorithm to somehow check around the circle for potential stray pixels that would result and if any are found, just increase the radius of the circle a bit to "absorb" the strays. That seems mathematically difficult though. Anyone have any ideas?

Re: Per-pixel Destructible Terrain

Posted: Mon Jun 10, 2013 2:46 am
by K-Bal
You could perform an opening operation with a bigger radius: http://en.wikipedia.org/wiki/Opening_(morphology)

Btw, at least in Worms 2, which is what I played a lot 10 years ago, single pixels weren't removed. You were blocked by them and you could stand on them.

Greetings,
Marius

Re: Per-pixel Destructible Terrain

Posted: Mon Jun 10, 2013 9:00 am
by Falco Girgis
I'm wondering if the naive and simple approach would actually be cheaper than trying to be all smart and mathy and recalculate the explosion geometry...

You could probably easily get away with bounding some rectangle around each explosion then simply iterating over it removing any stray pixels you find.

Re: Per-pixel Destructible Terrain

Posted: Thu Jun 13, 2013 10:40 pm
by MadPumpkin
Try checking out the source code for Open Liero Xtreme here: http://www.openlierox.net/ here's the Git information page they have. http://www.openlierox.net/wiki/index.ph ... e_from_Git I'm not sure how they perform destructible terrain particularly, but I know it's done per pixel, and they use a color map per level to show which terrain can/cannot be destroyed.

EDIT: It is after all a worm clone in of itself!

Re: Per-pixel Destructible Terrain

Posted: Sat Jun 22, 2013 8:57 pm
by MarauderIIC
I did something similar long ago, but I didn't get too far. I did it with a color map too, actually.

Instead of removing single pixels you could make them able to be passed thru -- if player collides, see if pixel has at least one adjacent collidable pixel?

Re: Per-pixel Destructible Terrain

Posted: Sat Jun 22, 2013 11:07 pm
by dandymcgee
MarauderIIC wrote:I did something similar long ago, but I didn't get too far. I did it with a color map too, actually.

Instead of removing single pixels you could make them able to be passed thru -- if player collides, see if pixel has at least one adjacent collidable pixel?
Well, you might as well remove them during this check. It would certainly be better than running a "RemoveSinglePixels()" check every frame.