My hills have holes. Help?

I’m trying to make a map editor and I’m stuck on a weird bug I’m having with my add sand tool.

It is not a Unity Terrain, it’s a big hexagonal mesh of equilateral triangles with side length of 1.

For some mysterious reason, there are vertices on the mesh that never get updated. The result is that there are
single vertex pits- not exactly random, they seem to always be in the same spot- but no rhyme nor reason to their
placement, either.

Rather than try to explain at length, here’s a quick’n’ dirty webplayer build so you can see for yourself:

Here’s the actual script that does the sand.

I know all the verts are getting added to allVerts (did a test function that put a cube on every one, and there were no cubes missing)— so maybe neighbors are being calculated wrong, although I can’t see what would keep a vertex from being considered a neighbor of any other vertex. But you can still click directly on one of the holes, and it will fill in. Sand will just never slide down to them by clicking nearby.

Thought maybe it would be more obvious to someone else what I did wrong here…?

I don’t know if it’s related, but I see an issue. Once it finds 1 critical slope, they’re all critical from then on. You should be setting isCritical to false at the start of your loop. Right at:

allVerts[i].y += amount;

In the web player, I see some areas that aren’t being filled in properly, but if I drop sand in the middle of them, they work fine. Are those the areas you mean? It sounded like there was nothing you could do to fill them in, when you were describing it.

Thats very cool and entertaining. At least this was entertaining for me while i was watching unity import assets again.
lol, sorry i have nothing to add other than that.

Thanks! I totally overlooked that. Fixing it didn’t seem to have any noticeable effect; though.
I also have the “Churn” function that cycles through the whole mesh and compares each vertex to its neighbors a few times per second, so even if “AddSand” wasn’t working properly, that should still be finding the ‘pits’ as soon as they happen and marking all their neighbors as critical.

I think the mesh itself may be my problem. I just noticed in the stats that it is using 3 draw calls when it really only should be using 1, and the editor is seeing 22.1k verts whereas my script only is counting 7351. So maybe the mesh is somehow 3-ply?
Back to the modeler then…
-edit- Nope; that was just the shader’s fault.

The formatting’s off, so it’s really hard to read that code… But I don’t see anything else that pops out.

Have you checked to make sure that it eventually stops the repeated checking? If it stops, then it means that there’s a problem detecting crits.

If it never stops, then it’s detecting them, but it’s not filling them.

That should at least give you somewhere to start looking.

massive facepalm
It was because all my for loops should go to 6; not 5.
For some reason I thought
“for (var i : int = 0; i < 6; i++)”
would reach neighbors[vert][6] and give an ArrayIndexOutOfBounds exception.
But not so. I was only checking 5 of 6 neighbors for each vert, and the pits were just where all the neighbor gaps happened to line up.