Jump to content

Cables mess :: fix overlap


csp

Recommended Posts

I want to create a procedural cable mess which is working fine but the tricky part is to fix procedurally the intersection of the cables when they are close. I have attache a complete example of my cable mess setup which includes my attempts to address this problem.

I am using two loops, the first loop in every cable carve and the second in every point of the current carve (loop in a loop). Then each point using a point cloud the points of the other carves in order to find the nearest point, its position and the distance from it. In a second vopsop I am using these info to find if the distance is less than the radius*2 of the cable then move equally the two points away. The right way to do it will be to substrate the distance from the given radius, then divide it and translate the current point in that amount and getting the direction vector by (nearPointPosition - currentPointPosition).

Pseudocode:

for each carve in the carves

for each point in the carve

find near point

if nearPoint less than (cableRadius*2)

then

float tranf = ((cableRadius*2) - nearPointDistance)/2

vector dir = (nearPointPosition - currentPointPosition)

move point

else

keep current point

end loop

end loop

1) I am not sure how to move the point based on the above idea using the direction vector. (now I am moving in z axis)

2) It seems a bit slow when there are a lot of cables. Is there any way to make it faster based on what I have in the attached scene?

3) Any better other way to fix this?

thanks in advance for any help

cables_mess.hip

Link to comment
Share on other sites

One thing you could do is first construct an sdf of the cable mess, and then move points according to the sdf value&gradient.

To get it really working, you would probably do several iterations of the whole process, with some gravity factored in, as just a single pass might not solve the whole mess.

Or just create the whole mess by dropping the cable with wire solver.. :)

Link to comment
Share on other sites

Here's an idea:

In a vopsop, do a pc import, search for the nearest non-connected neighbour. Get the distance to it. Ramp the distance by something like 1/dist so that the close, the higher the value. Displace by that value along the vector separating the two points.

That should be very fast.

Edit: now I see, very similar to your pseudocode. All you need is a handful of nodes for this.

Edited by Macha
  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...