MSTerrain removing extra surface

Topics: Developer Forum, User Forum
Aug 25, 2013 at 10:50 PM
Hey guys,

I'm having a play around with the MSTerrain stuff. All looks great except sometimes the terrain doesn't match the input.

I'm trying to destroy terrain in a circular shape but when it's close to another hole it removes extra terrain.

Here's a picture to better explain:

Image

It's highlighted in the red box. The circle and the hole next to it should be separate but it removes the terrain inbetween.

I've tried all the decomposers, CDT seems to work best but still has the problem. Seidel crashes out but I think that's because of the terrain I'm initialising with.

Anyone has any ideas on how to get round this?

Cheers
Aug 30, 2013 at 5:14 PM
This largely comes due to the algorithm as a whole. The basic idea behind the marching squares is that you can render more complex kinds of surfaces with fewer data points by making a lower resolution grid and drawing lines between the points that you know are inside the terrain and cutting out those that aren't. Its a lot more complicated than that, but its a good way to think about it.

The extra pieces that you see cut out at edges between boundaries are because the circle that you cut out removed one of the coarse grain points, so the engine tries to draw assuming that that part of the terrain is removed.

One way that you can kind of make it better is to increase the resolution of the terrain. This will lower those errors at the cost of performance.

The other strategy that I have had success with in the past is to forgo the marching squares algorithm altogether and use the Yu Peng clipper. It works by cutting out actual polygons from fixtures. This has the side effect of being perfect as far as errors goes, but decreases in performance as time goes on. I should also mention that the Yu Peng clipper is said to be unstable in some circumstances... I haven't seen this, but everybody on the forum warns of it.

So to cap up, Marching Squares cuts with minor errors but practically constant performance as you cut. Yu Peng clipper has no errors (or very few like those) but can become very non-performant over time as you cut more parts away from the main fixture.

I hope this helps some, and feel free to ask more questions.
Aug 31, 2013 at 7:44 PM
Thanks for the info. It was what I was guessing but nice to have confirmation!

I'm running on a mobile platform so unfortunately the higher resolution option is out as performance drops significantly after the values I already have.

Nice idea with the Yu Peng clipper though, I'll definitely give that a try. Maybe a mix of the two - using the Yu Peng clipper but having multiple small body squares like the sub cells of the MS terrain to help keep the performance up.

Thanks again.