The outside corner vertex will be moved passed edge and the triangles appearance will be messed up like it shows on the second image (see the black area it creates).
The same thing is happens if you move an inside vertex past any edge.
I want an effect that looks like this:
I want to select in runtime in Unity any number of vertices to move and when I move them, they push or pull nearby vertexes until a vertex reaches an edge, where it stop moving and can’t move past it. In the screenshots I show, I select only 1 vertex to move but I want it to work for any number of vertex selected.
I tried to find all edges and check if a vertex passes over them but it doesn’t seem to work and performance is bad. I use mesh with around 250 to 500 vertices.
How can I prevent any vertex from passing any edge so that the triangles don’t overlap?
You can get this kind of behavior using Blender’s sculpting tools instead of just editing vertices directly. Try playing with the various sculpting tools Sculpting Tools — Blender Manual
Something like the “Grab” tool might be a good place to start.
@PraetorBlue I think they were specifically asking how to do this programmatically in Unity and just using Blender as an example to illustrate what they’re after.
@brunost6353642 , I don’t believe this will be trivial, and I don’t have specific information to give you. But what you’ll have to do is determine how far from the vertex you’re editing you want to change, fetch the vertices that fall within that distance from the one you’re changing, and shift them along the same vector to a decreasing (likely logarithmic) amount.
You know how when you’re doing this in Blender you have to set the size of the brush that moves other vertices? That’s that max distance I just mentioned. I’m not sure how you’d do it dynamically… Could be a value you set based on the distance from where you started moving to where you stop? Otherwise you may still end up with situations where you create non-Euclidian geometry by having vertices incorrectly shift beyond their neighbors.
What’s the use-case for this? Is it to be run in-editor, or done by the user in a build?
If you don’t already have the mesh manipulation part down, consider this wonderful tutorial. You could then adapt it to do what I was saying with getting additional mesh vertices based on distance and moving them as well, with the amount scaling down the farther they are from the manipulated point.
Edit: It’s worth pointing out, too, that your UVs may become heavily distorted after you start shifting vertices around, which will screw up how your mesh is textured. This technique would probably work best on something that is flat-shaded or vertex colored.
This is done by user in build. The idea is like you press finger toward plane and you push vertices inside while keep the shape of the deform but all vertices is not past others like I show above.
Sorry, did I give the impression I wasn’t understanding what you wanted? That isn’t the case. You want something like Blender’s proportional editing, but in Unity at runtime. Did you understand the way I described you’d go about doing that?
No it doesn’t have anything to do with Blender’s features. I just wanted to use Blender to make diagram for the vertices behaviour to use to ask people on this forum because it was the quickest way for me to do it.
I found this image https://imgur.com/YpiWHyl is kind of similar but the vertices in this image are messed up if you look at the triangles. I want like that effect but more uniform and the triangle not messed up like how I describe above.
Basically I’d just check for all the vertices within a spherical radius and move them in the desired direction, proportional to the inverse of the distance to the center of the sphere. So vertices close to the sphere’s center will move a lot and those farther away will move a little, and those too far away will move not at all.
Doing this in a performant way might be difficult, but that’s the basic approach.