Defining mesh shape?

Hi! I hope someone can solve this better than me.
I have two type of meshes…
rectangular/squared (most terrains)
6918677--811550--Screen Shot 2021-03-09 at 17.25.09.png
unequal sides:
6918677--811556--Screen Shot 2021-03-09 at 17.26.28.png

I simply need to know if the mesh I’m introducing to my script is RECTANGULAR (symmetric) or not… (on XZ axis)
I did it by finding the edges and bounds of the edge… but if there are too many vertices this is an slow solution…

Maybe there is a better method to do it…
6918677--811559--Screen Shot 2021-03-09 at 17.26.35.png 6918677--811553--Screen Shot 2021-03-09 at 17.25.22.png

I don’t think symmetry is the word you’re looking for. Nothing above looks symmetrical.

One of the meshes appears rectilinear in the X/Z bounds and one does not.

Are you making and loading these in the project? Why not just make a table of them and mark which ones meet your criteria or not? Code you don’t have to write also does not have to be debugged. It’s kinda cool.

Okay then the correct word would be a rectangular shape… on X,Z.
Those are generated in the runtime by a list of vertices… any clue how to do it?

oh so you want to flip the mesh like scale x-1 y1 z-1?

Ohh no…

I want to know if the mesh I select… (any)
Is either rectangular or non-rectangular shape on the x and z axis… no matter the height

i will try to create a ray casting steps and checking the distance, but it need collider

1 Like

I guess you could see what the min/max X and Z values are, then see if there are more than a certain fraction of the extreme verts at that same linear position… are the verts utterly random or in a grid?

if in a grid, find the min/max X for each Z line of verts, see if those Min/Max X are mostly in line with each other at each end

You could lay a finer (or coarser?) grid over it and mark which verts touch each one (bucketizing), then study the edge of that finer grid and see if all the limit verts are roughly in line.

I guess this can certainly be done analytically… but is there any reason to do so? You’re presumably either creating these meshes at runtime or loading them in yourself, right? Any reason you can’t just store an enum value association for the shape somewhere on or related to the object?

The only reason to do this analytically as far as I can reckon is if it’s user-generated content or something.

1 Like

And if it is user-generated, tell them to describe it as rectangular or not. Don’t make extra analytical work for yourself.

1 Like

I believe if the user has to do less is better user experience… I guess I’ll just grab the (4)bound points and ray cast as Putcho suggested to see if they are inside the mesh or not… if they are then rectangular shape :smile:

This may be true. However what is the relative effort of having the user design a huge landscape versus clicking a checkbox that says rectangular when you’re done?!?

I imagine the two are quite different levels of effort, but it’s your project.

Meanwhile remember that all the time you are debating working on this problem, your game is not getting closer to shipping. :slight_smile:

1 Like