Shortest path.
1502 12 1- petipet
- Member
- 16 posts
- Joined: 4月 2020
- Offline
- viklc
- Member
- 135 posts
- Joined: 5月 2017
- Offline
- Aizatulin
- Member
- 470 posts
- Joined: 7月 2005
- Offline
- petipet
- Member
- 16 posts
- Joined: 4月 2020
- Offline
vik_lc
Hi,
it could be due to the geomtry used, maybe there are overlaps or points that are not used. This can cause the shortest path to be misleading. Try the Fuse SOP or the Clean SOP (Delete unused Points).
I checked, the problem is still in the written algorithm. In other programs this function works much better and it's frustrating because Houdini is super powerful and I like its procedural structure.
- petipet
- Member
- 16 posts
- Joined: 4月 2020
- Offline
- animatrix_
- Member
- 4460 posts
- Joined: 2月 2012
- Offline
Hi,
You can also select edge loops using VEX:
You can also select edge loops using VEX:
function int [ ] GetPrimsFromEdge ( int input; int pt0; int pt1 ) { int prims [ ]; int hedge = pointedge ( input, pt0, pt1 ); if ( hedge != -1 ) { int count = hedge_equivcount ( input, hedge ); for ( int i = 0; i < count; ++i ) { int pr = hedge_prim ( input, hedge ); if ( pr != -1 ) { append ( prims, pr ); hedge = hedge_nextequiv ( input, hedge ); } } } return prims; } int GetNextPoint ( int input; int edgept0; int edgept1; int currentpt ) { int ptneighbours [ ] = neighbours ( input, currentpt ); int primpts [ ]; int prims [ ] = GetPrimsFromEdge ( input, edgept0, edgept1 ); for ( int i = 0; i < len ( prims ); ++i ) { int count = primvertexcount ( input, prims [ i ] ); for ( int f = 0; f < count; ++f ) { int vertIndex = vertexindex ( input, prims [ i ], f ); int pointIndex = vertexpoint ( input, vertIndex ); append ( primpts, pointIndex ); } } int uniquepts [ ]; foreach ( int pt; ptneighbours ) { if ( find ( primpts, pt ) < 0 ) append ( uniquepts, pt ); } if ( len ( uniquepts ) == 1 ) return uniquepts [ 0 ]; return -1; } void GroupEdgeLoops ( int input; string edgegroup, groupname ) { if ( edgegroup == "" ) { setedgegroup ( geoself ( ), groupname, 0, 0, 0 ); return; } int loopedgepts [ ] = { }; int edges [ ] = expandedgegroup ( input, edgegroup ); if ( len ( edges ) == 0 ) { setedgegroup ( geoself ( ), groupname, 0, 0, 0 ); return; } int count = int ( 0.5 * len ( edges ) ); for ( int i = 0; i < count; ++i ) { int edgepts [ ] = sort ( array ( edges [ 2 * i ], edges [ 1 + 2 * i ] ) ); int index0 = find ( loopedgepts, edgepts [ 0 ] ); int index1 = find ( loopedgepts, edgepts [ 1 ] ); int edgefound = index0 % 2 == 0 && index1 % 2 == 1 && index1 == 1 + index0; if ( !edgefound ) { for ( int c = 0; c < 2; ++c ) { int points [ ]; int pt0 = edgepts [ c ]; int pt1 = edgepts [ 1 - c ]; int currentpt = pt0; int lastPoint = pt0; append ( points, currentpt ); int nextPoint = GetNextPoint ( input, pt0, pt1, currentpt ); while ( nextPoint != -1 && nextPoint != lastPoint ) { pt0 = currentpt; pt1 = nextPoint; currentpt = pt1; append ( points, currentpt ); nextPoint = GetNextPoint ( input, pt0, pt1, currentpt ); } int ptcount = len ( points ) - 1; for ( int f = 0; f < ptcount; ++f ) setedgegroup ( geoself ( ), groupname, points [ f ], points [ 1 + f ], 1 ); } setedgegroup ( geoself ( ), groupname, edgepts [ 0 ], edgepts [ 1 ], 1 ); } } } GroupEdgeLoops ( 0, chs("edge_group"), chs("group_name") );
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]
youtube.com/@pragmaticvfx | patreon.com/animatrix | animatrix2k7.gumroad.com
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]
youtube.com/@pragmaticvfx | patreon.com/animatrix | animatrix2k7.gumroad.com
- petipet
- Member
- 16 posts
- Joined: 4月 2020
- Offline
animatrix_
Hi,
You can also select edge loops using VEX:function int [ ] GetPrimsFromEdge ( int input; int pt0; int pt1 ) { int prims [ ]; int hedge = pointedge ( input, pt0, pt1 ); if ( hedge != -1 ) { int count = hedge_equivcount ( input, hedge ); for ( int i = 0; i < count; ++i ) { int pr = hedge_prim ( input, hedge ); if ( pr != -1 ) { append ( prims, pr ); hedge = hedge_nextequiv ( input, hedge ); } } } return prims; } int GetNextPoint ( int input; int edgept0; int edgept1; int currentpt ) { int ptneighbours [ ] = neighbours ( input, currentpt ); int primpts [ ]; int prims [ ] = GetPrimsFromEdge ( input, edgept0, edgept1 ); for ( int i = 0; i < len ( prims ); ++i ) { int count = primvertexcount ( input, prims [ i ] ); for ( int f = 0; f < count; ++f ) { int vertIndex = vertexindex ( input, prims [ i ], f ); int pointIndex = vertexpoint ( input, vertIndex ); append ( primpts, pointIndex ); } } int uniquepts [ ]; foreach ( int pt; ptneighbours ) { if ( find ( primpts, pt ) < 0 ) append ( uniquepts, pt ); } if ( len ( uniquepts ) == 1 ) return uniquepts [ 0 ]; return -1; } void GroupEdgeLoops ( int input; string edgegroup, groupname ) { if ( edgegroup == "" ) { setedgegroup ( geoself ( ), groupname, 0, 0, 0 ); return; } int loopedgepts [ ] = { }; int edges [ ] = expandedgegroup ( input, edgegroup ); if ( len ( edges ) == 0 ) { setedgegroup ( geoself ( ), groupname, 0, 0, 0 ); return; } int count = int ( 0.5 * len ( edges ) ); for ( int i = 0; i < count; ++i ) { int edgepts [ ] = sort ( array ( edges [ 2 * i ], edges [ 1 + 2 * i ] ) ); int index0 = find ( loopedgepts, edgepts [ 0 ] ); int index1 = find ( loopedgepts, edgepts [ 1 ] ); int edgefound = index0 % 2 == 0 && index1 % 2 == 1 && index1 == 1 + index0; if ( !edgefound ) { for ( int c = 0; c < 2; ++c ) { int points [ ]; int pt0 = edgepts [ c ]; int pt1 = edgepts [ 1 - c ]; int currentpt = pt0; int lastPoint = pt0; append ( points, currentpt ); int nextPoint = GetNextPoint ( input, pt0, pt1, currentpt ); while ( nextPoint != -1 && nextPoint != lastPoint ) { pt0 = currentpt; pt1 = nextPoint; currentpt = pt1; append ( points, currentpt ); nextPoint = GetNextPoint ( input, pt0, pt1, currentpt ); } int ptcount = len ( points ) - 1; for ( int f = 0; f < ptcount; ++f ) setedgegroup ( geoself ( ), groupname, points [ f ], points [ 1 + f ], 1 ); } setedgegroup ( geoself ( ), groupname, edgepts [ 0 ], edgepts [ 1 ], 1 ); } } } GroupEdgeLoops ( 0, chs("edge_group"), chs("group_name") );
I don't understand how it works and how it can help me to quickly selection edges along the shortest path.
I did not think that such a familiar, already practiced to the point of automatism operation could put me in a stupor in such an advanced program. It's a bit weird and I haven't found a way around it yet, sometimes I have to select the edges one at a time. It is quite slow and unproductive.
- animatrix_
- Member
- 4460 posts
- Joined: 2月 2012
- Offline
There are a few things:
This code only selects edge loops using the connectivity of quad polygons.
The wrangle should be set to detail run over mode.
If the result is like in your screenshot, there is disconnected polygons in that region of your geometry.
So attaching the geo here would help to identify the issue.
This code only selects edge loops using the connectivity of quad polygons.
The wrangle should be set to detail run over mode.
If the result is like in your screenshot, there is disconnected polygons in that region of your geometry.
So attaching the geo here would help to identify the issue.
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]
youtube.com/@pragmaticvfx | patreon.com/animatrix | animatrix2k7.gumroad.com
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]
youtube.com/@pragmaticvfx | patreon.com/animatrix | animatrix2k7.gumroad.com
- petipet
- Member
- 16 posts
- Joined: 4月 2020
- Offline
animatrix_
There are a few things:
This code only selects edge loops using the connectivity of quad polygons.
The wrangle should be set to detail run over mode.
If the result is like in your screenshot, there is disconnected polygons in that region of your geometry.
So attaching the geo here would help to identify the issue.
This is very simple geometry. There are no disconnected polygons here. I noticed that the algorithm only needs quad polygons to work correctly. I noticed that the shortest path goes to the place with the triangle, it chooses the path where the quad polygon is.
- animatrix_
- Member
- 4460 posts
- Joined: 2月 2012
- Offline
petipetanimatrix_
There are a few things:
This code only selects edge loops using the connectivity of quad polygons.
The wrangle should be set to detail run over mode.
If the result is like in your screenshot, there is disconnected polygons in that region of your geometry.
So attaching the geo here would help to identify the issue.
This is very simple geometry. There are no disconnected polygons here. I noticed that the algorithm only needs quad polygons to work correctly. I noticed that the shortest path goes to the place with the triangle, it chooses the path where the quad polygon is.
I just tried your geometry, selecting the edge loops works as expected. Make sure to set the Run Over parameter to Detail.
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]
youtube.com/@pragmaticvfx | patreon.com/animatrix | animatrix2k7.gumroad.com
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]
youtube.com/@pragmaticvfx | patreon.com/animatrix | animatrix2k7.gumroad.com
- animatrix_
- Member
- 4460 posts
- Joined: 2月 2012
- Offline
Find Shortest Path also works in my test:
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]
youtube.com/@pragmaticvfx | patreon.com/animatrix | animatrix2k7.gumroad.com
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]
youtube.com/@pragmaticvfx | patreon.com/animatrix | animatrix2k7.gumroad.com
- petipet
- Member
- 16 posts
- Joined: 4月 2020
- Offline
- petipet
- Member
- 16 posts
- Joined: 4月 2020
- Offline
-
- Quick Links