Skip to content

Commit 64b3683

Browse files
committed
Add concatenate node?
1 parent 473177f commit 64b3683

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

node-graph/gcore/src/graphic_element.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,31 @@ async fn layer(_: impl Ctx, mut stack: GraphicGroupTable, element: GraphicElemen
289289
stack
290290
}
291291

292+
#[node_macro::node(category("General"))]
293+
async fn concatenate<T: Clone>(
294+
_: impl Ctx,
295+
#[implementations(
296+
GraphicGroupTable,
297+
VectorDataTable,
298+
ImageFrameTable<Color>,
299+
TextureFrameTable,
300+
)]
301+
from: Instances<T>,
302+
#[expose]
303+
#[implementations(
304+
GraphicGroupTable,
305+
VectorDataTable,
306+
ImageFrameTable<Color>,
307+
TextureFrameTable,
308+
)]
309+
mut to: Instances<T>,
310+
) -> Instances<T> {
311+
for instance in from.instances() {
312+
to.push_instance(instance);
313+
}
314+
to
315+
}
316+
292317
#[node_macro::node(category("Debug"))]
293318
async fn to_element<Data: Into<GraphicElement> + 'n>(
294319
_: impl Ctx,

node-graph/gcore/src/instances.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,25 @@ impl<T> Instances<T> {
6161
}
6262
}
6363

64+
pub fn push_instance(&mut self, instance: Instance<T>) -> InstanceMut<T>
65+
where
66+
T: Clone,
67+
{
68+
self.id.push(*instance.id);
69+
self.instance.push(instance.instance.clone());
70+
self.transform.push(*instance.transform);
71+
self.alpha_blending.push(*instance.alpha_blending);
72+
self.source_node_id.push(*instance.source_node_id);
73+
74+
InstanceMut {
75+
id: self.id.last_mut().expect("Shouldn't be empty"),
76+
instance: self.instance.last_mut().expect("Shouldn't be empty"),
77+
transform: self.transform.last_mut().expect("Shouldn't be empty"),
78+
alpha_blending: self.alpha_blending.last_mut().expect("Shouldn't be empty"),
79+
source_node_id: self.source_node_id.last_mut().expect("Shouldn't be empty"),
80+
}
81+
}
82+
6483
pub fn one_instance(&self) -> Instance<T> {
6584
Instance {
6685
id: self.id.first().unwrap_or_else(|| panic!("ONE INSTANCE EXPECTED, FOUND {}", self.instance.len())),

0 commit comments

Comments
 (0)