0
$\begingroup$

enter image description hereConsider having two (multiple) objects that are very close to each other. Is there any algorithm which can identify vertices of these objects that their distances are less than a tolerance and then move those vertices away from each other until the defined tolerance is reached? the figure is a 2D representation of the problem which is actually in 3d space.

$\endgroup$
  • $\begingroup$ Gonna need more information on this. How many vertices are you talking about? Can you create a diagram image to show what you mean? $\endgroup$ – bertmoog Sep 15 '17 at 18:06
  • $\begingroup$ please look at the updated image $\endgroup$ – Benancio Sep 15 '17 at 18:23
  • $\begingroup$ Yes, I understand the tolerance factor, but I'm assuming you don't mean two one-vertex-objects. How many vertices are you talking about? All of the vertices of an object? Do you want the object to stay intact (i.e. keep it's form... be static)? Are you applying physics/rigid-body to the objects? Animating them? $\endgroup$ – bertmoog Sep 15 '17 at 18:57
  • $\begingroup$ There are potentially multiple ways of doing this, you just need to narrow down the application. $\endgroup$ – bertmoog Sep 15 '17 at 19:16
  • $\begingroup$ objects are static, each object has a few hundred vertices, a proximity query for each vertex of one objects with all vertices of surrendering objects can identify the vertices that are "close" to each other, then those pairs need to be distanced. however, they should not be distance too much since it is desired to keep the shape and volume of the objects intact. $\endgroup$ – Benancio Sep 15 '17 at 19:55
0
$\begingroup$

Probably a nice balance between easy to implement and reasonably efficient would be to create a BVHTree for the mesh of one object, and query that with all the vertices of the other mesh using find_nearest_range(...).

Moving the vertices away is probably easiest if you mark the entire mesh as smooth first. That will casue the vertex normals to be in the opposite direction you want to move the vertices in. Then, for each vertex v that you want to move, you can do v.co -= f * v.normal, where f is a smoothing factor. The value of f depends on how quickly you want the vertices to move. You can use a fixed value like 0.01 to move them by 1/100th unit, or you could use a dynamic value that depends on the distance between the two meshes at that point.

$\endgroup$
  • $\begingroup$ yes, an efficient search for finding the vertices is possible with BVHTree or KDtree, but what I'm interested in is an algorithm to move these vertices away from each other. $\endgroup$ – Benancio Sep 16 '17 at 13:04
  • $\begingroup$ Then you have to decide how you want to do that. Do you want to move each point away from the closest point on the other mesh? Or in the direction of the average face normal of the surrounding faces? Or parallel to the lines between the object origins? First you need to decide this, only then can you think of an algorithm to do it. $\endgroup$ – dr. Sybren Sep 16 '17 at 14:04
  • $\begingroup$ I want to move vertices on the two objects away from each other in direction of the average face normal of the surrounding faces of each vertex. $\endgroup$ – Benancio Sep 16 '17 at 18:13
  • $\begingroup$ I've added an approach to the answer that should do this. $\endgroup$ – dr. Sybren Sep 17 '17 at 8:58
  • $\begingroup$ thanks for the answer! could please clarify what do you mean by marking the entire mesh as smooth? are you talking about smooth modifier? $\endgroup$ – Benancio Sep 17 '17 at 20:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.