File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
node-graph/nodes/vector/src Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -2058,6 +2058,31 @@ async fn count_points(_: impl Ctx, source: Table<Vector>) -> f64 {
20582058 source. into_iter ( ) . map ( |row| row. element . point_domain . positions ( ) . len ( ) as f64 ) . sum ( )
20592059}
20602060
2061+ #[ node_macro:: node( category( "Vector" ) , path( graphene_core:: vector) ) ]
2062+ async fn index_points ( _: impl Ctx , source : Table < Vector > , index : f64 ) -> DVec2 {
2063+ let points_count = source. iter ( ) . map ( |row| row. element . point_domain . positions ( ) . len ( ) ) . sum :: < usize > ( ) ;
2064+
2065+ // Clamp and allow negative indexing from the end
2066+ let index = index as isize ;
2067+ let index = if index < 0 {
2068+ ( points_count as isize + index) . max ( 0 ) as usize
2069+ } else {
2070+ ( index as usize ) . min ( points_count - 1 )
2071+ } ;
2072+
2073+ // Find the point at the given index across all vector elements
2074+ let mut accumulated = 0 ;
2075+ for row in source. iter ( ) {
2076+ let row_point_count = row. element . point_domain . positions ( ) . len ( ) ;
2077+ if index - accumulated < row_point_count {
2078+ return row. element . point_domain . positions ( ) [ index - accumulated] ;
2079+ }
2080+ accumulated += row_point_count;
2081+ }
2082+
2083+ DVec2 :: ZERO
2084+ }
2085+
20612086#[ node_macro:: node( category( "Vector: Measure" ) , path( core_types:: vector) ) ]
20622087async fn path_length ( _: impl Ctx , source : Table < Vector > ) -> f64 {
20632088 source
You can’t perform that action at this time.
0 commit comments