From de7da82022ddb9a6a740ad5b757c215a817b2272 Mon Sep 17 00:00:00 2001 From: hypercube <0hypercube@gmail.com> Date: Mon, 10 Nov 2025 20:09:05 +0000 Subject: [PATCH] Reverse the loop level input to instance_index node --- node-graph/gcore/src/context.rs | 10 +++++----- node-graph/gcore/src/vector/algorithms/instance.rs | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/node-graph/gcore/src/context.rs b/node-graph/gcore/src/context.rs index ba4836d04d..0a4ebc545f 100644 --- a/node-graph/gcore/src/context.rs +++ b/node-graph/gcore/src/context.rs @@ -27,7 +27,7 @@ pub trait ExtractAnimationTime { } pub trait ExtractIndex { - fn try_index(&self) -> Option>; + fn try_index(&self) -> Option>; } // Consider returning a slice or something like that @@ -175,7 +175,7 @@ impl ExtractAnimationTime for Option { } } impl ExtractIndex for Option { - fn try_index(&self) -> Option> { + fn try_index(&self) -> Option> { self.as_ref().and_then(|x| x.try_index()) } } @@ -212,7 +212,7 @@ impl ExtractAnimationTime for Arc { } } impl ExtractIndex for Arc { - fn try_index(&self) -> Option> { + fn try_index(&self) -> Option> { (**self).try_index() } } @@ -268,7 +268,7 @@ impl ExtractRealTime for ContextImpl<'_> { } } impl ExtractIndex for ContextImpl<'_> { - fn try_index(&self) -> Option> { + fn try_index(&self) -> Option> { self.index.clone().map(|x| x.into_iter()) } } @@ -304,7 +304,7 @@ impl ExtractAnimationTime for OwnedContextImpl { } } impl ExtractIndex for OwnedContextImpl { - fn try_index(&self) -> Option> { + fn try_index(&self) -> Option> { self.index.clone().map(|x| x.into_iter()) } } diff --git a/node-graph/gcore/src/vector/algorithms/instance.rs b/node-graph/gcore/src/vector/algorithms/instance.rs index 9e40093bc0..d550f72f9f 100644 --- a/node-graph/gcore/src/vector/algorithms/instance.rs +++ b/node-graph/gcore/src/vector/algorithms/instance.rs @@ -109,7 +109,8 @@ async fn instance_position(ctx: impl Ctx + ExtractVarArgs) -> DVec2 { async fn instance_index(ctx: impl Ctx + ExtractIndex, _primary: (), loop_level: u32) -> f64 { let Some(index_iter) = ctx.try_index() else { return 0. }; let mut last = 0; - for (i, index) in index_iter.enumerate() { + // Index zero should be the top most index for some reason https://github.com/GraphiteEditor/Graphite/issues/3360 + for (i, index) in index_iter.rev().enumerate() { if i == loop_level as usize { return index as f64; }